5bff141c9572163d9a1cc4564a14a24f74cdd279
[projects/modsched/linux.git] / kernel / sysctl.c
1 /*
2  * sysctl.c: General linux system control interface
3  *
4  * Begun 24 March 1995, Stephen Tweedie
5  * Added /proc support, Dec 1995
6  * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7  * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8  * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9  * Dynamic registration fixes, Stephen Tweedie.
10  * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11  * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12  *  Horn.
13  * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14  * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15  * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16  *  Wendling.
17  * The list_for_each() macro wasn't appropriate for the sysctl loop.
18  *  Removed it and replaced it with older style, 03/23/00, Bill Wendling
19  */
20
21 #include <linux/module.h>
22 #include <linux/aio.h>
23 #include <linux/mm.h>
24 #include <linux/swap.h>
25 #include <linux/slab.h>
26 #include <linux/sysctl.h>
27 #include <linux/bitmap.h>
28 #include <linux/signal.h>
29 #include <linux/printk.h>
30 #include <linux/proc_fs.h>
31 #include <linux/security.h>
32 #include <linux/ctype.h>
33 #include <linux/kmemcheck.h>
34 #include <linux/kmemleak.h>
35 #include <linux/fs.h>
36 #include <linux/init.h>
37 #include <linux/kernel.h>
38 #include <linux/kobject.h>
39 #include <linux/net.h>
40 #include <linux/sysrq.h>
41 #include <linux/highuid.h>
42 #include <linux/writeback.h>
43 #include <linux/ratelimit.h>
44 #include <linux/compaction.h>
45 #include <linux/hugetlb.h>
46 #include <linux/initrd.h>
47 #include <linux/key.h>
48 #include <linux/times.h>
49 #include <linux/limits.h>
50 #include <linux/dcache.h>
51 #include <linux/dnotify.h>
52 #include <linux/syscalls.h>
53 #include <linux/vmstat.h>
54 #include <linux/nfs_fs.h>
55 #include <linux/acpi.h>
56 #include <linux/reboot.h>
57 #include <linux/ftrace.h>
58 #include <linux/perf_event.h>
59 #include <linux/kprobes.h>
60 #include <linux/pipe_fs_i.h>
61 #include <linux/oom.h>
62 #include <linux/kmod.h>
63 #include <linux/capability.h>
64 #include <linux/binfmts.h>
65 #include <linux/sched/sysctl.h>
66 #include <linux/kexec.h>
67
68 #include <asm/uaccess.h>
69 #include <asm/processor.h>
70
71 #ifdef CONFIG_X86
72 #include <asm/nmi.h>
73 #include <asm/stacktrace.h>
74 #include <asm/io.h>
75 #endif
76 #ifdef CONFIG_SPARC
77 #include <asm/setup.h>
78 #endif
79 #ifdef CONFIG_BSD_PROCESS_ACCT
80 #include <linux/acct.h>
81 #endif
82 #ifdef CONFIG_RT_MUTEXES
83 #include <linux/rtmutex.h>
84 #endif
85 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
86 #include <linux/lockdep.h>
87 #endif
88 #ifdef CONFIG_CHR_DEV_SG
89 #include <scsi/sg.h>
90 #endif
91
92 #ifdef CONFIG_LOCKUP_DETECTOR
93 #include <linux/nmi.h>
94 #endif
95
96 #if defined(CONFIG_SYSCTL)
97
98 /* External variables not in a header file. */
99 extern int suid_dumpable;
100 #ifdef CONFIG_COREDUMP
101 extern int core_uses_pid;
102 extern char core_pattern[];
103 extern unsigned int core_pipe_limit;
104 #endif
105 extern int pid_max;
106 extern int pid_max_min, pid_max_max;
107 extern int percpu_pagelist_fraction;
108 extern int compat_log;
109 extern int latencytop_enabled;
110 extern int sysctl_nr_open_min, sysctl_nr_open_max;
111 #ifndef CONFIG_MMU
112 extern int sysctl_nr_trim_pages;
113 #endif
114
115 /* Constants used for minimum and  maximum */
116 #ifdef CONFIG_LOCKUP_DETECTOR
117 static int sixty = 60;
118 #endif
119
120 static int __maybe_unused neg_one = -1;
121
122 static int zero;
123 static int __maybe_unused one = 1;
124 static int __maybe_unused two = 2;
125 static int __maybe_unused four = 4;
126 static unsigned long one_ul = 1;
127 static int one_hundred = 100;
128 #ifdef CONFIG_PRINTK
129 static int ten_thousand = 10000;
130 #endif
131
132 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
133 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
134
135 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
136 static int maxolduid = 65535;
137 static int minolduid;
138
139 static int ngroups_max = NGROUPS_MAX;
140 static const int cap_last_cap = CAP_LAST_CAP;
141
142 /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
143 #ifdef CONFIG_DETECT_HUNG_TASK
144 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
145 #endif
146
147 #ifdef CONFIG_INOTIFY_USER
148 #include <linux/inotify.h>
149 #endif
150 #ifdef CONFIG_SPARC
151 #endif
152
153 #ifdef __hppa__
154 extern int pwrsw_enabled;
155 #endif
156
157 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
158 extern int unaligned_enabled;
159 #endif
160
161 #ifdef CONFIG_IA64
162 extern int unaligned_dump_stack;
163 #endif
164
165 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
166 extern int no_unaligned_warning;
167 #endif
168
169 #ifdef CONFIG_PROC_SYSCTL
170
171 #define SYSCTL_WRITES_LEGACY    -1
172 #define SYSCTL_WRITES_WARN       0
173 #define SYSCTL_WRITES_STRICT     1
174
175 static int sysctl_writes_strict = SYSCTL_WRITES_WARN;
176
177 static int proc_do_cad_pid(struct ctl_table *table, int write,
178                   void __user *buffer, size_t *lenp, loff_t *ppos);
179 static int proc_taint(struct ctl_table *table, int write,
180                                void __user *buffer, size_t *lenp, loff_t *ppos);
181 #endif
182
183 #ifdef CONFIG_PRINTK
184 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
185                                 void __user *buffer, size_t *lenp, loff_t *ppos);
186 #endif
187
188 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
189                 void __user *buffer, size_t *lenp, loff_t *ppos);
190 #ifdef CONFIG_COREDUMP
191 static int proc_dostring_coredump(struct ctl_table *table, int write,
192                 void __user *buffer, size_t *lenp, loff_t *ppos);
193 #endif
194
195 #ifdef CONFIG_MAGIC_SYSRQ
196 /* Note: sysrq code uses it's own private copy */
197 static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
198
199 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
200                                 void __user *buffer, size_t *lenp,
201                                 loff_t *ppos)
202 {
203         int error;
204
205         error = proc_dointvec(table, write, buffer, lenp, ppos);
206         if (error)
207                 return error;
208
209         if (write)
210                 sysrq_toggle_support(__sysrq_enabled);
211
212         return 0;
213 }
214
215 #endif
216
217 static struct ctl_table kern_table[];
218 static struct ctl_table vm_table[];
219 static struct ctl_table fs_table[];
220 static struct ctl_table debug_table[];
221 static struct ctl_table dev_table[];
222 extern struct ctl_table random_table[];
223 #ifdef CONFIG_EPOLL
224 extern struct ctl_table epoll_table[];
225 #endif
226
227 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
228 int sysctl_legacy_va_layout;
229 #endif
230
231 /* The default sysctl tables: */
232
233 static struct ctl_table sysctl_base_table[] = {
234         {
235                 .procname       = "kernel",
236                 .mode           = 0555,
237                 .child          = kern_table,
238         },
239         {
240                 .procname       = "vm",
241                 .mode           = 0555,
242                 .child          = vm_table,
243         },
244         {
245                 .procname       = "fs",
246                 .mode           = 0555,
247                 .child          = fs_table,
248         },
249         {
250                 .procname       = "debug",
251                 .mode           = 0555,
252                 .child          = debug_table,
253         },
254         {
255                 .procname       = "dev",
256                 .mode           = 0555,
257                 .child          = dev_table,
258         },
259         { }
260 };
261
262 #ifdef CONFIG_SCHED_DEBUG
263 static int min_sched_granularity_ns = 100000;           /* 100 usecs */
264 static int max_sched_granularity_ns = NSEC_PER_SEC;     /* 1 second */
265 static int min_wakeup_granularity_ns;                   /* 0 usecs */
266 static int max_wakeup_granularity_ns = NSEC_PER_SEC;    /* 1 second */
267 #ifdef CONFIG_SMP
268 static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
269 static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
270 #endif /* CONFIG_SMP */
271 #endif /* CONFIG_SCHED_DEBUG */
272
273 #ifdef CONFIG_COMPACTION
274 static int min_extfrag_threshold;
275 static int max_extfrag_threshold = 1000;
276 #endif
277
278 static struct ctl_table kern_table[] = {
279         {
280                 .procname       = "sched_child_runs_first",
281                 .data           = &sysctl_sched_child_runs_first,
282                 .maxlen         = sizeof(unsigned int),
283                 .mode           = 0644,
284                 .proc_handler   = proc_dointvec,
285         },
286 #ifdef CONFIG_SCHED_DEBUG
287         {
288                 .procname       = "sched_min_granularity_ns",
289                 .data           = &sysctl_sched_min_granularity,
290                 .maxlen         = sizeof(unsigned int),
291                 .mode           = 0644,
292                 .proc_handler   = sched_proc_update_handler,
293                 .extra1         = &min_sched_granularity_ns,
294                 .extra2         = &max_sched_granularity_ns,
295         },
296         {
297                 .procname       = "sched_latency_ns",
298                 .data           = &sysctl_sched_latency,
299                 .maxlen         = sizeof(unsigned int),
300                 .mode           = 0644,
301                 .proc_handler   = sched_proc_update_handler,
302                 .extra1         = &min_sched_granularity_ns,
303                 .extra2         = &max_sched_granularity_ns,
304         },
305         {
306                 .procname       = "sched_wakeup_granularity_ns",
307                 .data           = &sysctl_sched_wakeup_granularity,
308                 .maxlen         = sizeof(unsigned int),
309                 .mode           = 0644,
310                 .proc_handler   = sched_proc_update_handler,
311                 .extra1         = &min_wakeup_granularity_ns,
312                 .extra2         = &max_wakeup_granularity_ns,
313         },
314 #ifdef CONFIG_SMP
315         {
316                 .procname       = "sched_tunable_scaling",
317                 .data           = &sysctl_sched_tunable_scaling,
318                 .maxlen         = sizeof(enum sched_tunable_scaling),
319                 .mode           = 0644,
320                 .proc_handler   = sched_proc_update_handler,
321                 .extra1         = &min_sched_tunable_scaling,
322                 .extra2         = &max_sched_tunable_scaling,
323         },
324         {
325                 .procname       = "sched_migration_cost_ns",
326                 .data           = &sysctl_sched_migration_cost,
327                 .maxlen         = sizeof(unsigned int),
328                 .mode           = 0644,
329                 .proc_handler   = proc_dointvec,
330         },
331         {
332                 .procname       = "sched_nr_migrate",
333                 .data           = &sysctl_sched_nr_migrate,
334                 .maxlen         = sizeof(unsigned int),
335                 .mode           = 0644,
336                 .proc_handler   = proc_dointvec,
337         },
338         {
339                 .procname       = "sched_time_avg_ms",
340                 .data           = &sysctl_sched_time_avg,
341                 .maxlen         = sizeof(unsigned int),
342                 .mode           = 0644,
343                 .proc_handler   = proc_dointvec,
344         },
345         {
346                 .procname       = "sched_shares_window_ns",
347                 .data           = &sysctl_sched_shares_window,
348                 .maxlen         = sizeof(unsigned int),
349                 .mode           = 0644,
350                 .proc_handler   = proc_dointvec,
351         },
352 #endif /* CONFIG_SMP */
353 #ifdef CONFIG_NUMA_BALANCING
354         {
355                 .procname       = "numa_balancing_scan_delay_ms",
356                 .data           = &sysctl_numa_balancing_scan_delay,
357                 .maxlen         = sizeof(unsigned int),
358                 .mode           = 0644,
359                 .proc_handler   = proc_dointvec,
360         },
361         {
362                 .procname       = "numa_balancing_scan_period_min_ms",
363                 .data           = &sysctl_numa_balancing_scan_period_min,
364                 .maxlen         = sizeof(unsigned int),
365                 .mode           = 0644,
366                 .proc_handler   = proc_dointvec,
367         },
368         {
369                 .procname       = "numa_balancing_scan_period_max_ms",
370                 .data           = &sysctl_numa_balancing_scan_period_max,
371                 .maxlen         = sizeof(unsigned int),
372                 .mode           = 0644,
373                 .proc_handler   = proc_dointvec,
374         },
375         {
376                 .procname       = "numa_balancing_scan_size_mb",
377                 .data           = &sysctl_numa_balancing_scan_size,
378                 .maxlen         = sizeof(unsigned int),
379                 .mode           = 0644,
380                 .proc_handler   = proc_dointvec_minmax,
381                 .extra1         = &one,
382         },
383         {
384                 .procname       = "numa_balancing",
385                 .data           = NULL, /* filled in by handler */
386                 .maxlen         = sizeof(unsigned int),
387                 .mode           = 0644,
388                 .proc_handler   = sysctl_numa_balancing,
389                 .extra1         = &zero,
390                 .extra2         = &one,
391         },
392 #endif /* CONFIG_NUMA_BALANCING */
393 #endif /* CONFIG_SCHED_DEBUG */
394         {
395                 .procname       = "sched_rt_period_us",
396                 .data           = &sysctl_sched_rt_period,
397                 .maxlen         = sizeof(unsigned int),
398                 .mode           = 0644,
399                 .proc_handler   = sched_rt_handler,
400         },
401         {
402                 .procname       = "sched_rt_runtime_us",
403                 .data           = &sysctl_sched_rt_runtime,
404                 .maxlen         = sizeof(int),
405                 .mode           = 0644,
406                 .proc_handler   = sched_rt_handler,
407         },
408         {
409                 .procname       = "sched_rr_timeslice_ms",
410                 .data           = &sched_rr_timeslice,
411                 .maxlen         = sizeof(int),
412                 .mode           = 0644,
413                 .proc_handler   = sched_rr_handler,
414         },
415 #ifdef CONFIG_MOD_SCHED
416         {
417                 .procname       = "sched_type",
418                 .data           = "CoBaS",
419                 .maxlen         = sizeof("CoBaS"),
420                 .mode           = 0444,
421                 .proc_handler   = proc_dostring,
422         },
423 #endif
424 #ifdef CONFIG_SCHED_AUTOGROUP
425         {
426                 .procname       = "sched_autogroup_enabled",
427                 .data           = &sysctl_sched_autogroup_enabled,
428                 .maxlen         = sizeof(unsigned int),
429                 .mode           = 0644,
430                 .proc_handler   = proc_dointvec_minmax,
431                 .extra1         = &zero,
432                 .extra2         = &one,
433         },
434 #endif
435 #ifdef CONFIG_CFS_BANDWIDTH
436         {
437                 .procname       = "sched_cfs_bandwidth_slice_us",
438                 .data           = &sysctl_sched_cfs_bandwidth_slice,
439                 .maxlen         = sizeof(unsigned int),
440                 .mode           = 0644,
441                 .proc_handler   = proc_dointvec_minmax,
442                 .extra1         = &one,
443         },
444 #endif
445 #ifdef CONFIG_PROVE_LOCKING
446         {
447                 .procname       = "prove_locking",
448                 .data           = &prove_locking,
449                 .maxlen         = sizeof(int),
450                 .mode           = 0644,
451                 .proc_handler   = proc_dointvec,
452         },
453 #endif
454 #ifdef CONFIG_LOCK_STAT
455         {
456                 .procname       = "lock_stat",
457                 .data           = &lock_stat,
458                 .maxlen         = sizeof(int),
459                 .mode           = 0644,
460                 .proc_handler   = proc_dointvec,
461         },
462 #endif
463         {
464                 .procname       = "panic",
465                 .data           = &panic_timeout,
466                 .maxlen         = sizeof(int),
467                 .mode           = 0644,
468                 .proc_handler   = proc_dointvec,
469         },
470 #ifdef CONFIG_COREDUMP
471         {
472                 .procname       = "core_uses_pid",
473                 .data           = &core_uses_pid,
474                 .maxlen         = sizeof(int),
475                 .mode           = 0644,
476                 .proc_handler   = proc_dointvec,
477         },
478         {
479                 .procname       = "core_pattern",
480                 .data           = core_pattern,
481                 .maxlen         = CORENAME_MAX_SIZE,
482                 .mode           = 0644,
483                 .proc_handler   = proc_dostring_coredump,
484         },
485         {
486                 .procname       = "core_pipe_limit",
487                 .data           = &core_pipe_limit,
488                 .maxlen         = sizeof(unsigned int),
489                 .mode           = 0644,
490                 .proc_handler   = proc_dointvec,
491         },
492 #endif
493 #ifdef CONFIG_PROC_SYSCTL
494         {
495                 .procname       = "tainted",
496                 .maxlen         = sizeof(long),
497                 .mode           = 0644,
498                 .proc_handler   = proc_taint,
499         },
500         {
501                 .procname       = "sysctl_writes_strict",
502                 .data           = &sysctl_writes_strict,
503                 .maxlen         = sizeof(int),
504                 .mode           = 0644,
505                 .proc_handler   = proc_dointvec_minmax,
506                 .extra1         = &neg_one,
507                 .extra2         = &one,
508         },
509 #endif
510 #ifdef CONFIG_LATENCYTOP
511         {
512                 .procname       = "latencytop",
513                 .data           = &latencytop_enabled,
514                 .maxlen         = sizeof(int),
515                 .mode           = 0644,
516                 .proc_handler   = proc_dointvec,
517         },
518 #endif
519 #ifdef CONFIG_BLK_DEV_INITRD
520         {
521                 .procname       = "real-root-dev",
522                 .data           = &real_root_dev,
523                 .maxlen         = sizeof(int),
524                 .mode           = 0644,
525                 .proc_handler   = proc_dointvec,
526         },
527 #endif
528         {
529                 .procname       = "print-fatal-signals",
530                 .data           = &print_fatal_signals,
531                 .maxlen         = sizeof(int),
532                 .mode           = 0644,
533                 .proc_handler   = proc_dointvec,
534         },
535 #ifdef CONFIG_SPARC
536         {
537                 .procname       = "reboot-cmd",
538                 .data           = reboot_command,
539                 .maxlen         = 256,
540                 .mode           = 0644,
541                 .proc_handler   = proc_dostring,
542         },
543         {
544                 .procname       = "stop-a",
545                 .data           = &stop_a_enabled,
546                 .maxlen         = sizeof (int),
547                 .mode           = 0644,
548                 .proc_handler   = proc_dointvec,
549         },
550         {
551                 .procname       = "scons-poweroff",
552                 .data           = &scons_pwroff,
553                 .maxlen         = sizeof (int),
554                 .mode           = 0644,
555                 .proc_handler   = proc_dointvec,
556         },
557 #endif
558 #ifdef CONFIG_SPARC64
559         {
560                 .procname       = "tsb-ratio",
561                 .data           = &sysctl_tsb_ratio,
562                 .maxlen         = sizeof (int),
563                 .mode           = 0644,
564                 .proc_handler   = proc_dointvec,
565         },
566 #endif
567 #ifdef __hppa__
568         {
569                 .procname       = "soft-power",
570                 .data           = &pwrsw_enabled,
571                 .maxlen         = sizeof (int),
572                 .mode           = 0644,
573                 .proc_handler   = proc_dointvec,
574         },
575 #endif
576 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
577         {
578                 .procname       = "unaligned-trap",
579                 .data           = &unaligned_enabled,
580                 .maxlen         = sizeof (int),
581                 .mode           = 0644,
582                 .proc_handler   = proc_dointvec,
583         },
584 #endif
585         {
586                 .procname       = "ctrl-alt-del",
587                 .data           = &C_A_D,
588                 .maxlen         = sizeof(int),
589                 .mode           = 0644,
590                 .proc_handler   = proc_dointvec,
591         },
592 #ifdef CONFIG_FUNCTION_TRACER
593         {
594                 .procname       = "ftrace_enabled",
595                 .data           = &ftrace_enabled,
596                 .maxlen         = sizeof(int),
597                 .mode           = 0644,
598                 .proc_handler   = ftrace_enable_sysctl,
599         },
600 #endif
601 #ifdef CONFIG_STACK_TRACER
602         {
603                 .procname       = "stack_tracer_enabled",
604                 .data           = &stack_tracer_enabled,
605                 .maxlen         = sizeof(int),
606                 .mode           = 0644,
607                 .proc_handler   = stack_trace_sysctl,
608         },
609 #endif
610 #ifdef CONFIG_TRACING
611         {
612                 .procname       = "ftrace_dump_on_oops",
613                 .data           = &ftrace_dump_on_oops,
614                 .maxlen         = sizeof(int),
615                 .mode           = 0644,
616                 .proc_handler   = proc_dointvec,
617         },
618         {
619                 .procname       = "traceoff_on_warning",
620                 .data           = &__disable_trace_on_warning,
621                 .maxlen         = sizeof(__disable_trace_on_warning),
622                 .mode           = 0644,
623                 .proc_handler   = proc_dointvec,
624         },
625         {
626                 .procname       = "tracepoint_printk",
627                 .data           = &tracepoint_printk,
628                 .maxlen         = sizeof(tracepoint_printk),
629                 .mode           = 0644,
630                 .proc_handler   = proc_dointvec,
631         },
632 #endif
633 #ifdef CONFIG_KEXEC_CORE
634         {
635                 .procname       = "kexec_load_disabled",
636                 .data           = &kexec_load_disabled,
637                 .maxlen         = sizeof(int),
638                 .mode           = 0644,
639                 /* only handle a transition from default "0" to "1" */
640                 .proc_handler   = proc_dointvec_minmax,
641                 .extra1         = &one,
642                 .extra2         = &one,
643         },
644 #endif
645 #ifdef CONFIG_MODULES
646         {
647                 .procname       = "modprobe",
648                 .data           = &modprobe_path,
649                 .maxlen         = KMOD_PATH_LEN,
650                 .mode           = 0644,
651                 .proc_handler   = proc_dostring,
652         },
653         {
654                 .procname       = "modules_disabled",
655                 .data           = &modules_disabled,
656                 .maxlen         = sizeof(int),
657                 .mode           = 0644,
658                 /* only handle a transition from default "0" to "1" */
659                 .proc_handler   = proc_dointvec_minmax,
660                 .extra1         = &one,
661                 .extra2         = &one,
662         },
663 #endif
664 #ifdef CONFIG_UEVENT_HELPER
665         {
666                 .procname       = "hotplug",
667                 .data           = &uevent_helper,
668                 .maxlen         = UEVENT_HELPER_PATH_LEN,
669                 .mode           = 0644,
670                 .proc_handler   = proc_dostring,
671         },
672 #endif
673 #ifdef CONFIG_CHR_DEV_SG
674         {
675                 .procname       = "sg-big-buff",
676                 .data           = &sg_big_buff,
677                 .maxlen         = sizeof (int),
678                 .mode           = 0444,
679                 .proc_handler   = proc_dointvec,
680         },
681 #endif
682 #ifdef CONFIG_BSD_PROCESS_ACCT
683         {
684                 .procname       = "acct",
685                 .data           = &acct_parm,
686                 .maxlen         = 3*sizeof(int),
687                 .mode           = 0644,
688                 .proc_handler   = proc_dointvec,
689         },
690 #endif
691 #ifdef CONFIG_MAGIC_SYSRQ
692         {
693                 .procname       = "sysrq",
694                 .data           = &__sysrq_enabled,
695                 .maxlen         = sizeof (int),
696                 .mode           = 0644,
697                 .proc_handler   = sysrq_sysctl_handler,
698         },
699 #endif
700 #ifdef CONFIG_PROC_SYSCTL
701         {
702                 .procname       = "cad_pid",
703                 .data           = NULL,
704                 .maxlen         = sizeof (int),
705                 .mode           = 0600,
706                 .proc_handler   = proc_do_cad_pid,
707         },
708 #endif
709         {
710                 .procname       = "threads-max",
711                 .data           = NULL,
712                 .maxlen         = sizeof(int),
713                 .mode           = 0644,
714                 .proc_handler   = sysctl_max_threads,
715         },
716         {
717                 .procname       = "random",
718                 .mode           = 0555,
719                 .child          = random_table,
720         },
721         {
722                 .procname       = "usermodehelper",
723                 .mode           = 0555,
724                 .child          = usermodehelper_table,
725         },
726         {
727                 .procname       = "overflowuid",
728                 .data           = &overflowuid,
729                 .maxlen         = sizeof(int),
730                 .mode           = 0644,
731                 .proc_handler   = proc_dointvec_minmax,
732                 .extra1         = &minolduid,
733                 .extra2         = &maxolduid,
734         },
735         {
736                 .procname       = "overflowgid",
737                 .data           = &overflowgid,
738                 .maxlen         = sizeof(int),
739                 .mode           = 0644,
740                 .proc_handler   = proc_dointvec_minmax,
741                 .extra1         = &minolduid,
742                 .extra2         = &maxolduid,
743         },
744 #ifdef CONFIG_S390
745 #ifdef CONFIG_MATHEMU
746         {
747                 .procname       = "ieee_emulation_warnings",
748                 .data           = &sysctl_ieee_emulation_warnings,
749                 .maxlen         = sizeof(int),
750                 .mode           = 0644,
751                 .proc_handler   = proc_dointvec,
752         },
753 #endif
754         {
755                 .procname       = "userprocess_debug",
756                 .data           = &show_unhandled_signals,
757                 .maxlen         = sizeof(int),
758                 .mode           = 0644,
759                 .proc_handler   = proc_dointvec,
760         },
761 #endif
762         {
763                 .procname       = "pid_max",
764                 .data           = &pid_max,
765                 .maxlen         = sizeof (int),
766                 .mode           = 0644,
767                 .proc_handler   = proc_dointvec_minmax,
768                 .extra1         = &pid_max_min,
769                 .extra2         = &pid_max_max,
770         },
771         {
772                 .procname       = "panic_on_oops",
773                 .data           = &panic_on_oops,
774                 .maxlen         = sizeof(int),
775                 .mode           = 0644,
776                 .proc_handler   = proc_dointvec,
777         },
778 #if defined CONFIG_PRINTK
779         {
780                 .procname       = "printk",
781                 .data           = &console_loglevel,
782                 .maxlen         = 4*sizeof(int),
783                 .mode           = 0644,
784                 .proc_handler   = proc_dointvec,
785         },
786         {
787                 .procname       = "printk_ratelimit",
788                 .data           = &printk_ratelimit_state.interval,
789                 .maxlen         = sizeof(int),
790                 .mode           = 0644,
791                 .proc_handler   = proc_dointvec_jiffies,
792         },
793         {
794                 .procname       = "printk_ratelimit_burst",
795                 .data           = &printk_ratelimit_state.burst,
796                 .maxlen         = sizeof(int),
797                 .mode           = 0644,
798                 .proc_handler   = proc_dointvec,
799         },
800         {
801                 .procname       = "printk_delay",
802                 .data           = &printk_delay_msec,
803                 .maxlen         = sizeof(int),
804                 .mode           = 0644,
805                 .proc_handler   = proc_dointvec_minmax,
806                 .extra1         = &zero,
807                 .extra2         = &ten_thousand,
808         },
809         {
810                 .procname       = "dmesg_restrict",
811                 .data           = &dmesg_restrict,
812                 .maxlen         = sizeof(int),
813                 .mode           = 0644,
814                 .proc_handler   = proc_dointvec_minmax_sysadmin,
815                 .extra1         = &zero,
816                 .extra2         = &one,
817         },
818         {
819                 .procname       = "kptr_restrict",
820                 .data           = &kptr_restrict,
821                 .maxlen         = sizeof(int),
822                 .mode           = 0644,
823                 .proc_handler   = proc_dointvec_minmax_sysadmin,
824                 .extra1         = &zero,
825                 .extra2         = &two,
826         },
827 #endif
828         {
829                 .procname       = "ngroups_max",
830                 .data           = &ngroups_max,
831                 .maxlen         = sizeof (int),
832                 .mode           = 0444,
833                 .proc_handler   = proc_dointvec,
834         },
835         {
836                 .procname       = "cap_last_cap",
837                 .data           = (void *)&cap_last_cap,
838                 .maxlen         = sizeof(int),
839                 .mode           = 0444,
840                 .proc_handler   = proc_dointvec,
841         },
842 #if defined(CONFIG_LOCKUP_DETECTOR)
843         {
844                 .procname       = "watchdog",
845                 .data           = &watchdog_user_enabled,
846                 .maxlen         = sizeof (int),
847                 .mode           = 0644,
848                 .proc_handler   = proc_watchdog,
849                 .extra1         = &zero,
850                 .extra2         = &one,
851         },
852         {
853                 .procname       = "watchdog_thresh",
854                 .data           = &watchdog_thresh,
855                 .maxlen         = sizeof(int),
856                 .mode           = 0644,
857                 .proc_handler   = proc_watchdog_thresh,
858                 .extra1         = &zero,
859                 .extra2         = &sixty,
860         },
861         {
862                 .procname       = "nmi_watchdog",
863                 .data           = &nmi_watchdog_enabled,
864                 .maxlen         = sizeof (int),
865                 .mode           = 0644,
866                 .proc_handler   = proc_nmi_watchdog,
867                 .extra1         = &zero,
868 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
869                 .extra2         = &one,
870 #else
871                 .extra2         = &zero,
872 #endif
873         },
874         {
875                 .procname       = "soft_watchdog",
876                 .data           = &soft_watchdog_enabled,
877                 .maxlen         = sizeof (int),
878                 .mode           = 0644,
879                 .proc_handler   = proc_soft_watchdog,
880                 .extra1         = &zero,
881                 .extra2         = &one,
882         },
883         {
884                 .procname       = "watchdog_cpumask",
885                 .data           = &watchdog_cpumask_bits,
886                 .maxlen         = NR_CPUS,
887                 .mode           = 0644,
888                 .proc_handler   = proc_watchdog_cpumask,
889         },
890         {
891                 .procname       = "softlockup_panic",
892                 .data           = &softlockup_panic,
893                 .maxlen         = sizeof(int),
894                 .mode           = 0644,
895                 .proc_handler   = proc_dointvec_minmax,
896                 .extra1         = &zero,
897                 .extra2         = &one,
898         },
899 #ifdef CONFIG_SMP
900         {
901                 .procname       = "softlockup_all_cpu_backtrace",
902                 .data           = &sysctl_softlockup_all_cpu_backtrace,
903                 .maxlen         = sizeof(int),
904                 .mode           = 0644,
905                 .proc_handler   = proc_dointvec_minmax,
906                 .extra1         = &zero,
907                 .extra2         = &one,
908         },
909 #endif /* CONFIG_SMP */
910 #endif
911 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
912         {
913                 .procname       = "unknown_nmi_panic",
914                 .data           = &unknown_nmi_panic,
915                 .maxlen         = sizeof (int),
916                 .mode           = 0644,
917                 .proc_handler   = proc_dointvec,
918         },
919 #endif
920 #if defined(CONFIG_X86)
921         {
922                 .procname       = "panic_on_unrecovered_nmi",
923                 .data           = &panic_on_unrecovered_nmi,
924                 .maxlen         = sizeof(int),
925                 .mode           = 0644,
926                 .proc_handler   = proc_dointvec,
927         },
928         {
929                 .procname       = "panic_on_io_nmi",
930                 .data           = &panic_on_io_nmi,
931                 .maxlen         = sizeof(int),
932                 .mode           = 0644,
933                 .proc_handler   = proc_dointvec,
934         },
935 #ifdef CONFIG_DEBUG_STACKOVERFLOW
936         {
937                 .procname       = "panic_on_stackoverflow",
938                 .data           = &sysctl_panic_on_stackoverflow,
939                 .maxlen         = sizeof(int),
940                 .mode           = 0644,
941                 .proc_handler   = proc_dointvec,
942         },
943 #endif
944         {
945                 .procname       = "bootloader_type",
946                 .data           = &bootloader_type,
947                 .maxlen         = sizeof (int),
948                 .mode           = 0444,
949                 .proc_handler   = proc_dointvec,
950         },
951         {
952                 .procname       = "bootloader_version",
953                 .data           = &bootloader_version,
954                 .maxlen         = sizeof (int),
955                 .mode           = 0444,
956                 .proc_handler   = proc_dointvec,
957         },
958         {
959                 .procname       = "kstack_depth_to_print",
960                 .data           = &kstack_depth_to_print,
961                 .maxlen         = sizeof(int),
962                 .mode           = 0644,
963                 .proc_handler   = proc_dointvec,
964         },
965         {
966                 .procname       = "io_delay_type",
967                 .data           = &io_delay_type,
968                 .maxlen         = sizeof(int),
969                 .mode           = 0644,
970                 .proc_handler   = proc_dointvec,
971         },
972 #endif
973 #if defined(CONFIG_MMU)
974         {
975                 .procname       = "randomize_va_space",
976                 .data           = &randomize_va_space,
977                 .maxlen         = sizeof(int),
978                 .mode           = 0644,
979                 .proc_handler   = proc_dointvec,
980         },
981 #endif
982 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
983         {
984                 .procname       = "spin_retry",
985                 .data           = &spin_retry,
986                 .maxlen         = sizeof (int),
987                 .mode           = 0644,
988                 .proc_handler   = proc_dointvec,
989         },
990 #endif
991 #if     defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
992         {
993                 .procname       = "acpi_video_flags",
994                 .data           = &acpi_realmode_flags,
995                 .maxlen         = sizeof (unsigned long),
996                 .mode           = 0644,
997                 .proc_handler   = proc_doulongvec_minmax,
998         },
999 #endif
1000 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1001         {
1002                 .procname       = "ignore-unaligned-usertrap",
1003                 .data           = &no_unaligned_warning,
1004                 .maxlen         = sizeof (int),
1005                 .mode           = 0644,
1006                 .proc_handler   = proc_dointvec,
1007         },
1008 #endif
1009 #ifdef CONFIG_IA64
1010         {
1011                 .procname       = "unaligned-dump-stack",
1012                 .data           = &unaligned_dump_stack,
1013                 .maxlen         = sizeof (int),
1014                 .mode           = 0644,
1015                 .proc_handler   = proc_dointvec,
1016         },
1017 #endif
1018 #ifdef CONFIG_DETECT_HUNG_TASK
1019         {
1020                 .procname       = "hung_task_panic",
1021                 .data           = &sysctl_hung_task_panic,
1022                 .maxlen         = sizeof(int),
1023                 .mode           = 0644,
1024                 .proc_handler   = proc_dointvec_minmax,
1025                 .extra1         = &zero,
1026                 .extra2         = &one,
1027         },
1028         {
1029                 .procname       = "hung_task_check_count",
1030                 .data           = &sysctl_hung_task_check_count,
1031                 .maxlen         = sizeof(int),
1032                 .mode           = 0644,
1033                 .proc_handler   = proc_dointvec_minmax,
1034                 .extra1         = &zero,
1035         },
1036         {
1037                 .procname       = "hung_task_timeout_secs",
1038                 .data           = &sysctl_hung_task_timeout_secs,
1039                 .maxlen         = sizeof(unsigned long),
1040                 .mode           = 0644,
1041                 .proc_handler   = proc_dohung_task_timeout_secs,
1042                 .extra2         = &hung_task_timeout_max,
1043         },
1044         {
1045                 .procname       = "hung_task_warnings",
1046                 .data           = &sysctl_hung_task_warnings,
1047                 .maxlen         = sizeof(int),
1048                 .mode           = 0644,
1049                 .proc_handler   = proc_dointvec_minmax,
1050                 .extra1         = &neg_one,
1051         },
1052 #endif
1053 #ifdef CONFIG_COMPAT
1054         {
1055                 .procname       = "compat-log",
1056                 .data           = &compat_log,
1057                 .maxlen         = sizeof (int),
1058                 .mode           = 0644,
1059                 .proc_handler   = proc_dointvec,
1060         },
1061 #endif
1062 #ifdef CONFIG_RT_MUTEXES
1063         {
1064                 .procname       = "max_lock_depth",
1065                 .data           = &max_lock_depth,
1066                 .maxlen         = sizeof(int),
1067                 .mode           = 0644,
1068                 .proc_handler   = proc_dointvec,
1069         },
1070 #endif
1071         {
1072                 .procname       = "poweroff_cmd",
1073                 .data           = &poweroff_cmd,
1074                 .maxlen         = POWEROFF_CMD_PATH_LEN,
1075                 .mode           = 0644,
1076                 .proc_handler   = proc_dostring,
1077         },
1078 #ifdef CONFIG_KEYS
1079         {
1080                 .procname       = "keys",
1081                 .mode           = 0555,
1082                 .child          = key_sysctls,
1083         },
1084 #endif
1085 #ifdef CONFIG_PERF_EVENTS
1086         /*
1087          * User-space scripts rely on the existence of this file
1088          * as a feature check for perf_events being enabled.
1089          *
1090          * So it's an ABI, do not remove!
1091          */
1092         {
1093                 .procname       = "perf_event_paranoid",
1094                 .data           = &sysctl_perf_event_paranoid,
1095                 .maxlen         = sizeof(sysctl_perf_event_paranoid),
1096                 .mode           = 0644,
1097                 .proc_handler   = proc_dointvec,
1098         },
1099         {
1100                 .procname       = "perf_event_mlock_kb",
1101                 .data           = &sysctl_perf_event_mlock,
1102                 .maxlen         = sizeof(sysctl_perf_event_mlock),
1103                 .mode           = 0644,
1104                 .proc_handler   = proc_dointvec,
1105         },
1106         {
1107                 .procname       = "perf_event_max_sample_rate",
1108                 .data           = &sysctl_perf_event_sample_rate,
1109                 .maxlen         = sizeof(sysctl_perf_event_sample_rate),
1110                 .mode           = 0644,
1111                 .proc_handler   = perf_proc_update_handler,
1112                 .extra1         = &one,
1113         },
1114         {
1115                 .procname       = "perf_cpu_time_max_percent",
1116                 .data           = &sysctl_perf_cpu_time_max_percent,
1117                 .maxlen         = sizeof(sysctl_perf_cpu_time_max_percent),
1118                 .mode           = 0644,
1119                 .proc_handler   = perf_cpu_time_max_percent_handler,
1120                 .extra1         = &zero,
1121                 .extra2         = &one_hundred,
1122         },
1123 #endif
1124 #ifdef CONFIG_KMEMCHECK
1125         {
1126                 .procname       = "kmemcheck",
1127                 .data           = &kmemcheck_enabled,
1128                 .maxlen         = sizeof(int),
1129                 .mode           = 0644,
1130                 .proc_handler   = proc_dointvec,
1131         },
1132 #endif
1133         {
1134                 .procname       = "panic_on_warn",
1135                 .data           = &panic_on_warn,
1136                 .maxlen         = sizeof(int),
1137                 .mode           = 0644,
1138                 .proc_handler   = proc_dointvec_minmax,
1139                 .extra1         = &zero,
1140                 .extra2         = &one,
1141         },
1142 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1143         {
1144                 .procname       = "timer_migration",
1145                 .data           = &sysctl_timer_migration,
1146                 .maxlen         = sizeof(unsigned int),
1147                 .mode           = 0644,
1148                 .proc_handler   = timer_migration_handler,
1149         },
1150 #endif
1151         { }
1152 };
1153
1154 static struct ctl_table vm_table[] = {
1155         {
1156                 .procname       = "overcommit_memory",
1157                 .data           = &sysctl_overcommit_memory,
1158                 .maxlen         = sizeof(sysctl_overcommit_memory),
1159                 .mode           = 0644,
1160                 .proc_handler   = proc_dointvec_minmax,
1161                 .extra1         = &zero,
1162                 .extra2         = &two,
1163         },
1164         {
1165                 .procname       = "panic_on_oom",
1166                 .data           = &sysctl_panic_on_oom,
1167                 .maxlen         = sizeof(sysctl_panic_on_oom),
1168                 .mode           = 0644,
1169                 .proc_handler   = proc_dointvec_minmax,
1170                 .extra1         = &zero,
1171                 .extra2         = &two,
1172         },
1173         {
1174                 .procname       = "oom_kill_allocating_task",
1175                 .data           = &sysctl_oom_kill_allocating_task,
1176                 .maxlen         = sizeof(sysctl_oom_kill_allocating_task),
1177                 .mode           = 0644,
1178                 .proc_handler   = proc_dointvec,
1179         },
1180         {
1181                 .procname       = "oom_dump_tasks",
1182                 .data           = &sysctl_oom_dump_tasks,
1183                 .maxlen         = sizeof(sysctl_oom_dump_tasks),
1184                 .mode           = 0644,
1185                 .proc_handler   = proc_dointvec,
1186         },
1187         {
1188                 .procname       = "overcommit_ratio",
1189                 .data           = &sysctl_overcommit_ratio,
1190                 .maxlen         = sizeof(sysctl_overcommit_ratio),
1191                 .mode           = 0644,
1192                 .proc_handler   = overcommit_ratio_handler,
1193         },
1194         {
1195                 .procname       = "overcommit_kbytes",
1196                 .data           = &sysctl_overcommit_kbytes,
1197                 .maxlen         = sizeof(sysctl_overcommit_kbytes),
1198                 .mode           = 0644,
1199                 .proc_handler   = overcommit_kbytes_handler,
1200         },
1201         {
1202                 .procname       = "page-cluster", 
1203                 .data           = &page_cluster,
1204                 .maxlen         = sizeof(int),
1205                 .mode           = 0644,
1206                 .proc_handler   = proc_dointvec_minmax,
1207                 .extra1         = &zero,
1208         },
1209         {
1210                 .procname       = "dirty_background_ratio",
1211                 .data           = &dirty_background_ratio,
1212                 .maxlen         = sizeof(dirty_background_ratio),
1213                 .mode           = 0644,
1214                 .proc_handler   = dirty_background_ratio_handler,
1215                 .extra1         = &zero,
1216                 .extra2         = &one_hundred,
1217         },
1218         {
1219                 .procname       = "dirty_background_bytes",
1220                 .data           = &dirty_background_bytes,
1221                 .maxlen         = sizeof(dirty_background_bytes),
1222                 .mode           = 0644,
1223                 .proc_handler   = dirty_background_bytes_handler,
1224                 .extra1         = &one_ul,
1225         },
1226         {
1227                 .procname       = "dirty_ratio",
1228                 .data           = &vm_dirty_ratio,
1229                 .maxlen         = sizeof(vm_dirty_ratio),
1230                 .mode           = 0644,
1231                 .proc_handler   = dirty_ratio_handler,
1232                 .extra1         = &zero,
1233                 .extra2         = &one_hundred,
1234         },
1235         {
1236                 .procname       = "dirty_bytes",
1237                 .data           = &vm_dirty_bytes,
1238                 .maxlen         = sizeof(vm_dirty_bytes),
1239                 .mode           = 0644,
1240                 .proc_handler   = dirty_bytes_handler,
1241                 .extra1         = &dirty_bytes_min,
1242         },
1243         {
1244                 .procname       = "dirty_writeback_centisecs",
1245                 .data           = &dirty_writeback_interval,
1246                 .maxlen         = sizeof(dirty_writeback_interval),
1247                 .mode           = 0644,
1248                 .proc_handler   = dirty_writeback_centisecs_handler,
1249         },
1250         {
1251                 .procname       = "dirty_expire_centisecs",
1252                 .data           = &dirty_expire_interval,
1253                 .maxlen         = sizeof(dirty_expire_interval),
1254                 .mode           = 0644,
1255                 .proc_handler   = proc_dointvec_minmax,
1256                 .extra1         = &zero,
1257         },
1258         {
1259                 .procname       = "dirtytime_expire_seconds",
1260                 .data           = &dirtytime_expire_interval,
1261                 .maxlen         = sizeof(dirty_expire_interval),
1262                 .mode           = 0644,
1263                 .proc_handler   = dirtytime_interval_handler,
1264                 .extra1         = &zero,
1265         },
1266         {
1267                 .procname       = "nr_pdflush_threads",
1268                 .mode           = 0444 /* read-only */,
1269                 .proc_handler   = pdflush_proc_obsolete,
1270         },
1271         {
1272                 .procname       = "swappiness",
1273                 .data           = &vm_swappiness,
1274                 .maxlen         = sizeof(vm_swappiness),
1275                 .mode           = 0644,
1276                 .proc_handler   = proc_dointvec_minmax,
1277                 .extra1         = &zero,
1278                 .extra2         = &one_hundred,
1279         },
1280 #ifdef CONFIG_HUGETLB_PAGE
1281         {
1282                 .procname       = "nr_hugepages",
1283                 .data           = NULL,
1284                 .maxlen         = sizeof(unsigned long),
1285                 .mode           = 0644,
1286                 .proc_handler   = hugetlb_sysctl_handler,
1287         },
1288 #ifdef CONFIG_NUMA
1289         {
1290                 .procname       = "nr_hugepages_mempolicy",
1291                 .data           = NULL,
1292                 .maxlen         = sizeof(unsigned long),
1293                 .mode           = 0644,
1294                 .proc_handler   = &hugetlb_mempolicy_sysctl_handler,
1295         },
1296 #endif
1297          {
1298                 .procname       = "hugetlb_shm_group",
1299                 .data           = &sysctl_hugetlb_shm_group,
1300                 .maxlen         = sizeof(gid_t),
1301                 .mode           = 0644,
1302                 .proc_handler   = proc_dointvec,
1303          },
1304          {
1305                 .procname       = "hugepages_treat_as_movable",
1306                 .data           = &hugepages_treat_as_movable,
1307                 .maxlen         = sizeof(int),
1308                 .mode           = 0644,
1309                 .proc_handler   = proc_dointvec,
1310         },
1311         {
1312                 .procname       = "nr_overcommit_hugepages",
1313                 .data           = NULL,
1314                 .maxlen         = sizeof(unsigned long),
1315                 .mode           = 0644,
1316                 .proc_handler   = hugetlb_overcommit_handler,
1317         },
1318 #endif
1319         {
1320                 .procname       = "lowmem_reserve_ratio",
1321                 .data           = &sysctl_lowmem_reserve_ratio,
1322                 .maxlen         = sizeof(sysctl_lowmem_reserve_ratio),
1323                 .mode           = 0644,
1324                 .proc_handler   = lowmem_reserve_ratio_sysctl_handler,
1325         },
1326         {
1327                 .procname       = "drop_caches",
1328                 .data           = &sysctl_drop_caches,
1329                 .maxlen         = sizeof(int),
1330                 .mode           = 0644,
1331                 .proc_handler   = drop_caches_sysctl_handler,
1332                 .extra1         = &one,
1333                 .extra2         = &four,
1334         },
1335 #ifdef CONFIG_COMPACTION
1336         {
1337                 .procname       = "compact_memory",
1338                 .data           = &sysctl_compact_memory,
1339                 .maxlen         = sizeof(int),
1340                 .mode           = 0200,
1341                 .proc_handler   = sysctl_compaction_handler,
1342         },
1343         {
1344                 .procname       = "extfrag_threshold",
1345                 .data           = &sysctl_extfrag_threshold,
1346                 .maxlen         = sizeof(int),
1347                 .mode           = 0644,
1348                 .proc_handler   = sysctl_extfrag_handler,
1349                 .extra1         = &min_extfrag_threshold,
1350                 .extra2         = &max_extfrag_threshold,
1351         },
1352         {
1353                 .procname       = "compact_unevictable_allowed",
1354                 .data           = &sysctl_compact_unevictable_allowed,
1355                 .maxlen         = sizeof(int),
1356                 .mode           = 0644,
1357                 .proc_handler   = proc_dointvec,
1358                 .extra1         = &zero,
1359                 .extra2         = &one,
1360         },
1361
1362 #endif /* CONFIG_COMPACTION */
1363         {
1364                 .procname       = "min_free_kbytes",
1365                 .data           = &min_free_kbytes,
1366                 .maxlen         = sizeof(min_free_kbytes),
1367                 .mode           = 0644,
1368                 .proc_handler   = min_free_kbytes_sysctl_handler,
1369                 .extra1         = &zero,
1370         },
1371         {
1372                 .procname       = "percpu_pagelist_fraction",
1373                 .data           = &percpu_pagelist_fraction,
1374                 .maxlen         = sizeof(percpu_pagelist_fraction),
1375                 .mode           = 0644,
1376                 .proc_handler   = percpu_pagelist_fraction_sysctl_handler,
1377                 .extra1         = &zero,
1378         },
1379 #ifdef CONFIG_MMU
1380         {
1381                 .procname       = "max_map_count",
1382                 .data           = &sysctl_max_map_count,
1383                 .maxlen         = sizeof(sysctl_max_map_count),
1384                 .mode           = 0644,
1385                 .proc_handler   = proc_dointvec_minmax,
1386                 .extra1         = &zero,
1387         },
1388 #else
1389         {
1390                 .procname       = "nr_trim_pages",
1391                 .data           = &sysctl_nr_trim_pages,
1392                 .maxlen         = sizeof(sysctl_nr_trim_pages),
1393                 .mode           = 0644,
1394                 .proc_handler   = proc_dointvec_minmax,
1395                 .extra1         = &zero,
1396         },
1397 #endif
1398         {
1399                 .procname       = "laptop_mode",
1400                 .data           = &laptop_mode,
1401                 .maxlen         = sizeof(laptop_mode),
1402                 .mode           = 0644,
1403                 .proc_handler   = proc_dointvec_jiffies,
1404         },
1405         {
1406                 .procname       = "block_dump",
1407                 .data           = &block_dump,
1408                 .maxlen         = sizeof(block_dump),
1409                 .mode           = 0644,
1410                 .proc_handler   = proc_dointvec,
1411                 .extra1         = &zero,
1412         },
1413         {
1414                 .procname       = "vfs_cache_pressure",
1415                 .data           = &sysctl_vfs_cache_pressure,
1416                 .maxlen         = sizeof(sysctl_vfs_cache_pressure),
1417                 .mode           = 0644,
1418                 .proc_handler   = proc_dointvec,
1419                 .extra1         = &zero,
1420         },
1421 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1422         {
1423                 .procname       = "legacy_va_layout",
1424                 .data           = &sysctl_legacy_va_layout,
1425                 .maxlen         = sizeof(sysctl_legacy_va_layout),
1426                 .mode           = 0644,
1427                 .proc_handler   = proc_dointvec,
1428                 .extra1         = &zero,
1429         },
1430 #endif
1431 #ifdef CONFIG_NUMA
1432         {
1433                 .procname       = "zone_reclaim_mode",
1434                 .data           = &zone_reclaim_mode,
1435                 .maxlen         = sizeof(zone_reclaim_mode),
1436                 .mode           = 0644,
1437                 .proc_handler   = proc_dointvec,
1438                 .extra1         = &zero,
1439         },
1440         {
1441                 .procname       = "min_unmapped_ratio",
1442                 .data           = &sysctl_min_unmapped_ratio,
1443                 .maxlen         = sizeof(sysctl_min_unmapped_ratio),
1444                 .mode           = 0644,
1445                 .proc_handler   = sysctl_min_unmapped_ratio_sysctl_handler,
1446                 .extra1         = &zero,
1447                 .extra2         = &one_hundred,
1448         },
1449         {
1450                 .procname       = "min_slab_ratio",
1451                 .data           = &sysctl_min_slab_ratio,
1452                 .maxlen         = sizeof(sysctl_min_slab_ratio),
1453                 .mode           = 0644,
1454                 .proc_handler   = sysctl_min_slab_ratio_sysctl_handler,
1455                 .extra1         = &zero,
1456                 .extra2         = &one_hundred,
1457         },
1458 #endif
1459 #ifdef CONFIG_SMP
1460         {
1461                 .procname       = "stat_interval",
1462                 .data           = &sysctl_stat_interval,
1463                 .maxlen         = sizeof(sysctl_stat_interval),
1464                 .mode           = 0644,
1465                 .proc_handler   = proc_dointvec_jiffies,
1466         },
1467 #endif
1468 #ifdef CONFIG_MMU
1469         {
1470                 .procname       = "mmap_min_addr",
1471                 .data           = &dac_mmap_min_addr,
1472                 .maxlen         = sizeof(unsigned long),
1473                 .mode           = 0644,
1474                 .proc_handler   = mmap_min_addr_handler,
1475         },
1476 #endif
1477 #ifdef CONFIG_NUMA
1478         {
1479                 .procname       = "numa_zonelist_order",
1480                 .data           = &numa_zonelist_order,
1481                 .maxlen         = NUMA_ZONELIST_ORDER_LEN,
1482                 .mode           = 0644,
1483                 .proc_handler   = numa_zonelist_order_handler,
1484         },
1485 #endif
1486 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1487    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1488         {
1489                 .procname       = "vdso_enabled",
1490 #ifdef CONFIG_X86_32
1491                 .data           = &vdso32_enabled,
1492                 .maxlen         = sizeof(vdso32_enabled),
1493 #else
1494                 .data           = &vdso_enabled,
1495                 .maxlen         = sizeof(vdso_enabled),
1496 #endif
1497                 .mode           = 0644,
1498                 .proc_handler   = proc_dointvec,
1499                 .extra1         = &zero,
1500         },
1501 #endif
1502 #ifdef CONFIG_HIGHMEM
1503         {
1504                 .procname       = "highmem_is_dirtyable",
1505                 .data           = &vm_highmem_is_dirtyable,
1506                 .maxlen         = sizeof(vm_highmem_is_dirtyable),
1507                 .mode           = 0644,
1508                 .proc_handler   = proc_dointvec_minmax,
1509                 .extra1         = &zero,
1510                 .extra2         = &one,
1511         },
1512 #endif
1513 #ifdef CONFIG_MEMORY_FAILURE
1514         {
1515                 .procname       = "memory_failure_early_kill",
1516                 .data           = &sysctl_memory_failure_early_kill,
1517                 .maxlen         = sizeof(sysctl_memory_failure_early_kill),
1518                 .mode           = 0644,
1519                 .proc_handler   = proc_dointvec_minmax,
1520                 .extra1         = &zero,
1521                 .extra2         = &one,
1522         },
1523         {
1524                 .procname       = "memory_failure_recovery",
1525                 .data           = &sysctl_memory_failure_recovery,
1526                 .maxlen         = sizeof(sysctl_memory_failure_recovery),
1527                 .mode           = 0644,
1528                 .proc_handler   = proc_dointvec_minmax,
1529                 .extra1         = &zero,
1530                 .extra2         = &one,
1531         },
1532 #endif
1533         {
1534                 .procname       = "user_reserve_kbytes",
1535                 .data           = &sysctl_user_reserve_kbytes,
1536                 .maxlen         = sizeof(sysctl_user_reserve_kbytes),
1537                 .mode           = 0644,
1538                 .proc_handler   = proc_doulongvec_minmax,
1539         },
1540         {
1541                 .procname       = "admin_reserve_kbytes",
1542                 .data           = &sysctl_admin_reserve_kbytes,
1543                 .maxlen         = sizeof(sysctl_admin_reserve_kbytes),
1544                 .mode           = 0644,
1545                 .proc_handler   = proc_doulongvec_minmax,
1546         },
1547         { }
1548 };
1549
1550 static struct ctl_table fs_table[] = {
1551         {
1552                 .procname       = "inode-nr",
1553                 .data           = &inodes_stat,
1554                 .maxlen         = 2*sizeof(long),
1555                 .mode           = 0444,
1556                 .proc_handler   = proc_nr_inodes,
1557         },
1558         {
1559                 .procname       = "inode-state",
1560                 .data           = &inodes_stat,
1561                 .maxlen         = 7*sizeof(long),
1562                 .mode           = 0444,
1563                 .proc_handler   = proc_nr_inodes,
1564         },
1565         {
1566                 .procname       = "file-nr",
1567                 .data           = &files_stat,
1568                 .maxlen         = sizeof(files_stat),
1569                 .mode           = 0444,
1570                 .proc_handler   = proc_nr_files,
1571         },
1572         {
1573                 .procname       = "file-max",
1574                 .data           = &files_stat.max_files,
1575                 .maxlen         = sizeof(files_stat.max_files),
1576                 .mode           = 0644,
1577                 .proc_handler   = proc_doulongvec_minmax,
1578         },
1579         {
1580                 .procname       = "nr_open",
1581                 .data           = &sysctl_nr_open,
1582                 .maxlen         = sizeof(int),
1583                 .mode           = 0644,
1584                 .proc_handler   = proc_dointvec_minmax,
1585                 .extra1         = &sysctl_nr_open_min,
1586                 .extra2         = &sysctl_nr_open_max,
1587         },
1588         {
1589                 .procname       = "dentry-state",
1590                 .data           = &dentry_stat,
1591                 .maxlen         = 6*sizeof(long),
1592                 .mode           = 0444,
1593                 .proc_handler   = proc_nr_dentry,
1594         },
1595         {
1596                 .procname       = "overflowuid",
1597                 .data           = &fs_overflowuid,
1598                 .maxlen         = sizeof(int),
1599                 .mode           = 0644,
1600                 .proc_handler   = proc_dointvec_minmax,
1601                 .extra1         = &minolduid,
1602                 .extra2         = &maxolduid,
1603         },
1604         {
1605                 .procname       = "overflowgid",
1606                 .data           = &fs_overflowgid,
1607                 .maxlen         = sizeof(int),
1608                 .mode           = 0644,
1609                 .proc_handler   = proc_dointvec_minmax,
1610                 .extra1         = &minolduid,
1611                 .extra2         = &maxolduid,
1612         },
1613 #ifdef CONFIG_FILE_LOCKING
1614         {
1615                 .procname       = "leases-enable",
1616                 .data           = &leases_enable,
1617                 .maxlen         = sizeof(int),
1618                 .mode           = 0644,
1619                 .proc_handler   = proc_dointvec,
1620         },
1621 #endif
1622 #ifdef CONFIG_DNOTIFY
1623         {
1624                 .procname       = "dir-notify-enable",
1625                 .data           = &dir_notify_enable,
1626                 .maxlen         = sizeof(int),
1627                 .mode           = 0644,
1628                 .proc_handler   = proc_dointvec,
1629         },
1630 #endif
1631 #ifdef CONFIG_MMU
1632 #ifdef CONFIG_FILE_LOCKING
1633         {
1634                 .procname       = "lease-break-time",
1635                 .data           = &lease_break_time,
1636                 .maxlen         = sizeof(int),
1637                 .mode           = 0644,
1638                 .proc_handler   = proc_dointvec,
1639         },
1640 #endif
1641 #ifdef CONFIG_AIO
1642         {
1643                 .procname       = "aio-nr",
1644                 .data           = &aio_nr,
1645                 .maxlen         = sizeof(aio_nr),
1646                 .mode           = 0444,
1647                 .proc_handler   = proc_doulongvec_minmax,
1648         },
1649         {
1650                 .procname       = "aio-max-nr",
1651                 .data           = &aio_max_nr,
1652                 .maxlen         = sizeof(aio_max_nr),
1653                 .mode           = 0644,
1654                 .proc_handler   = proc_doulongvec_minmax,
1655         },
1656 #endif /* CONFIG_AIO */
1657 #ifdef CONFIG_INOTIFY_USER
1658         {
1659                 .procname       = "inotify",
1660                 .mode           = 0555,
1661                 .child          = inotify_table,
1662         },
1663 #endif  
1664 #ifdef CONFIG_EPOLL
1665         {
1666                 .procname       = "epoll",
1667                 .mode           = 0555,
1668                 .child          = epoll_table,
1669         },
1670 #endif
1671 #endif
1672         {
1673                 .procname       = "protected_symlinks",
1674                 .data           = &sysctl_protected_symlinks,
1675                 .maxlen         = sizeof(int),
1676                 .mode           = 0600,
1677                 .proc_handler   = proc_dointvec_minmax,
1678                 .extra1         = &zero,
1679                 .extra2         = &one,
1680         },
1681         {
1682                 .procname       = "protected_hardlinks",
1683                 .data           = &sysctl_protected_hardlinks,
1684                 .maxlen         = sizeof(int),
1685                 .mode           = 0600,
1686                 .proc_handler   = proc_dointvec_minmax,
1687                 .extra1         = &zero,
1688                 .extra2         = &one,
1689         },
1690         {
1691                 .procname       = "suid_dumpable",
1692                 .data           = &suid_dumpable,
1693                 .maxlen         = sizeof(int),
1694                 .mode           = 0644,
1695                 .proc_handler   = proc_dointvec_minmax_coredump,
1696                 .extra1         = &zero,
1697                 .extra2         = &two,
1698         },
1699 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1700         {
1701                 .procname       = "binfmt_misc",
1702                 .mode           = 0555,
1703                 .child          = sysctl_mount_point,
1704         },
1705 #endif
1706         {
1707                 .procname       = "pipe-max-size",
1708                 .data           = &pipe_max_size,
1709                 .maxlen         = sizeof(int),
1710                 .mode           = 0644,
1711                 .proc_handler   = &pipe_proc_fn,
1712                 .extra1         = &pipe_min_size,
1713         },
1714         { }
1715 };
1716
1717 static struct ctl_table debug_table[] = {
1718 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1719         {
1720                 .procname       = "exception-trace",
1721                 .data           = &show_unhandled_signals,
1722                 .maxlen         = sizeof(int),
1723                 .mode           = 0644,
1724                 .proc_handler   = proc_dointvec
1725         },
1726 #endif
1727 #if defined(CONFIG_OPTPROBES)
1728         {
1729                 .procname       = "kprobes-optimization",
1730                 .data           = &sysctl_kprobes_optimization,
1731                 .maxlen         = sizeof(int),
1732                 .mode           = 0644,
1733                 .proc_handler   = proc_kprobes_optimization_handler,
1734                 .extra1         = &zero,
1735                 .extra2         = &one,
1736         },
1737 #endif
1738         { }
1739 };
1740
1741 static struct ctl_table dev_table[] = {
1742         { }
1743 };
1744
1745 int __init sysctl_init(void)
1746 {
1747         struct ctl_table_header *hdr;
1748
1749         hdr = register_sysctl_table(sysctl_base_table);
1750         kmemleak_not_leak(hdr);
1751         return 0;
1752 }
1753
1754 #endif /* CONFIG_SYSCTL */
1755
1756 /*
1757  * /proc/sys support
1758  */
1759
1760 #ifdef CONFIG_PROC_SYSCTL
1761
1762 static int _proc_do_string(char *data, int maxlen, int write,
1763                            char __user *buffer,
1764                            size_t *lenp, loff_t *ppos)
1765 {
1766         size_t len;
1767         char __user *p;
1768         char c;
1769
1770         if (!data || !maxlen || !*lenp) {
1771                 *lenp = 0;
1772                 return 0;
1773         }
1774
1775         if (write) {
1776                 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1777                         /* Only continue writes not past the end of buffer. */
1778                         len = strlen(data);
1779                         if (len > maxlen - 1)
1780                                 len = maxlen - 1;
1781
1782                         if (*ppos > len)
1783                                 return 0;
1784                         len = *ppos;
1785                 } else {
1786                         /* Start writing from beginning of buffer. */
1787                         len = 0;
1788                 }
1789
1790                 *ppos += *lenp;
1791                 p = buffer;
1792                 while ((p - buffer) < *lenp && len < maxlen - 1) {
1793                         if (get_user(c, p++))
1794                                 return -EFAULT;
1795                         if (c == 0 || c == '\n')
1796                                 break;
1797                         data[len++] = c;
1798                 }
1799                 data[len] = 0;
1800         } else {
1801                 len = strlen(data);
1802                 if (len > maxlen)
1803                         len = maxlen;
1804
1805                 if (*ppos > len) {
1806                         *lenp = 0;
1807                         return 0;
1808                 }
1809
1810                 data += *ppos;
1811                 len  -= *ppos;
1812
1813                 if (len > *lenp)
1814                         len = *lenp;
1815                 if (len)
1816                         if (copy_to_user(buffer, data, len))
1817                                 return -EFAULT;
1818                 if (len < *lenp) {
1819                         if (put_user('\n', buffer + len))
1820                                 return -EFAULT;
1821                         len++;
1822                 }
1823                 *lenp = len;
1824                 *ppos += len;
1825         }
1826         return 0;
1827 }
1828
1829 static void warn_sysctl_write(struct ctl_table *table)
1830 {
1831         pr_warn_once("%s wrote to %s when file position was not 0!\n"
1832                 "This will not be supported in the future. To silence this\n"
1833                 "warning, set kernel.sysctl_writes_strict = -1\n",
1834                 current->comm, table->procname);
1835 }
1836
1837 /**
1838  * proc_dostring - read a string sysctl
1839  * @table: the sysctl table
1840  * @write: %TRUE if this is a write to the sysctl file
1841  * @buffer: the user buffer
1842  * @lenp: the size of the user buffer
1843  * @ppos: file position
1844  *
1845  * Reads/writes a string from/to the user buffer. If the kernel
1846  * buffer provided is not large enough to hold the string, the
1847  * string is truncated. The copied string is %NULL-terminated.
1848  * If the string is being read by the user process, it is copied
1849  * and a newline '\n' is added. It is truncated if the buffer is
1850  * not large enough.
1851  *
1852  * Returns 0 on success.
1853  */
1854 int proc_dostring(struct ctl_table *table, int write,
1855                   void __user *buffer, size_t *lenp, loff_t *ppos)
1856 {
1857         if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
1858                 warn_sysctl_write(table);
1859
1860         return _proc_do_string((char *)(table->data), table->maxlen, write,
1861                                (char __user *)buffer, lenp, ppos);
1862 }
1863
1864 static size_t proc_skip_spaces(char **buf)
1865 {
1866         size_t ret;
1867         char *tmp = skip_spaces(*buf);
1868         ret = tmp - *buf;
1869         *buf = tmp;
1870         return ret;
1871 }
1872
1873 static void proc_skip_char(char **buf, size_t *size, const char v)
1874 {
1875         while (*size) {
1876                 if (**buf != v)
1877                         break;
1878                 (*size)--;
1879                 (*buf)++;
1880         }
1881 }
1882
1883 #define TMPBUFLEN 22
1884 /**
1885  * proc_get_long - reads an ASCII formatted integer from a user buffer
1886  *
1887  * @buf: a kernel buffer
1888  * @size: size of the kernel buffer
1889  * @val: this is where the number will be stored
1890  * @neg: set to %TRUE if number is negative
1891  * @perm_tr: a vector which contains the allowed trailers
1892  * @perm_tr_len: size of the perm_tr vector
1893  * @tr: pointer to store the trailer character
1894  *
1895  * In case of success %0 is returned and @buf and @size are updated with
1896  * the amount of bytes read. If @tr is non-NULL and a trailing
1897  * character exists (size is non-zero after returning from this
1898  * function), @tr is updated with the trailing character.
1899  */
1900 static int proc_get_long(char **buf, size_t *size,
1901                           unsigned long *val, bool *neg,
1902                           const char *perm_tr, unsigned perm_tr_len, char *tr)
1903 {
1904         int len;
1905         char *p, tmp[TMPBUFLEN];
1906
1907         if (!*size)
1908                 return -EINVAL;
1909
1910         len = *size;
1911         if (len > TMPBUFLEN - 1)
1912                 len = TMPBUFLEN - 1;
1913
1914         memcpy(tmp, *buf, len);
1915
1916         tmp[len] = 0;
1917         p = tmp;
1918         if (*p == '-' && *size > 1) {
1919                 *neg = true;
1920                 p++;
1921         } else
1922                 *neg = false;
1923         if (!isdigit(*p))
1924                 return -EINVAL;
1925
1926         *val = simple_strtoul(p, &p, 0);
1927
1928         len = p - tmp;
1929
1930         /* We don't know if the next char is whitespace thus we may accept
1931          * invalid integers (e.g. 1234...a) or two integers instead of one
1932          * (e.g. 123...1). So lets not allow such large numbers. */
1933         if (len == TMPBUFLEN - 1)
1934                 return -EINVAL;
1935
1936         if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1937                 return -EINVAL;
1938
1939         if (tr && (len < *size))
1940                 *tr = *p;
1941
1942         *buf += len;
1943         *size -= len;
1944
1945         return 0;
1946 }
1947
1948 /**
1949  * proc_put_long - converts an integer to a decimal ASCII formatted string
1950  *
1951  * @buf: the user buffer
1952  * @size: the size of the user buffer
1953  * @val: the integer to be converted
1954  * @neg: sign of the number, %TRUE for negative
1955  *
1956  * In case of success %0 is returned and @buf and @size are updated with
1957  * the amount of bytes written.
1958  */
1959 static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1960                           bool neg)
1961 {
1962         int len;
1963         char tmp[TMPBUFLEN], *p = tmp;
1964
1965         sprintf(p, "%s%lu", neg ? "-" : "", val);
1966         len = strlen(tmp);
1967         if (len > *size)
1968                 len = *size;
1969         if (copy_to_user(*buf, tmp, len))
1970                 return -EFAULT;
1971         *size -= len;
1972         *buf += len;
1973         return 0;
1974 }
1975 #undef TMPBUFLEN
1976
1977 static int proc_put_char(void __user **buf, size_t *size, char c)
1978 {
1979         if (*size) {
1980                 char __user **buffer = (char __user **)buf;
1981                 if (put_user(c, *buffer))
1982                         return -EFAULT;
1983                 (*size)--, (*buffer)++;
1984                 *buf = *buffer;
1985         }
1986         return 0;
1987 }
1988
1989 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
1990                                  int *valp,
1991                                  int write, void *data)
1992 {
1993         if (write) {
1994                 if (*negp) {
1995                         if (*lvalp > (unsigned long) INT_MAX + 1)
1996                                 return -EINVAL;
1997                         *valp = -*lvalp;
1998                 } else {
1999                         if (*lvalp > (unsigned long) INT_MAX)
2000                                 return -EINVAL;
2001                         *valp = *lvalp;
2002                 }
2003         } else {
2004                 int val = *valp;
2005                 if (val < 0) {
2006                         *negp = true;
2007                         *lvalp = -(unsigned long)val;
2008                 } else {
2009                         *negp = false;
2010                         *lvalp = (unsigned long)val;
2011                 }
2012         }
2013         return 0;
2014 }
2015
2016 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2017
2018 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
2019                   int write, void __user *buffer,
2020                   size_t *lenp, loff_t *ppos,
2021                   int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2022                               int write, void *data),
2023                   void *data)
2024 {
2025         int *i, vleft, first = 1, err = 0;
2026         unsigned long page = 0;
2027         size_t left;
2028         char *kbuf;
2029         
2030         if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2031                 *lenp = 0;
2032                 return 0;
2033         }
2034         
2035         i = (int *) tbl_data;
2036         vleft = table->maxlen / sizeof(*i);
2037         left = *lenp;
2038
2039         if (!conv)
2040                 conv = do_proc_dointvec_conv;
2041
2042         if (write) {
2043                 if (*ppos) {
2044                         switch (sysctl_writes_strict) {
2045                         case SYSCTL_WRITES_STRICT:
2046                                 goto out;
2047                         case SYSCTL_WRITES_WARN:
2048                                 warn_sysctl_write(table);
2049                                 break;
2050                         default:
2051                                 break;
2052                         }
2053                 }
2054
2055                 if (left > PAGE_SIZE - 1)
2056                         left = PAGE_SIZE - 1;
2057                 page = __get_free_page(GFP_TEMPORARY);
2058                 kbuf = (char *) page;
2059                 if (!kbuf)
2060                         return -ENOMEM;
2061                 if (copy_from_user(kbuf, buffer, left)) {
2062                         err = -EFAULT;
2063                         goto free;
2064                 }
2065                 kbuf[left] = 0;
2066         }
2067
2068         for (; left && vleft--; i++, first=0) {
2069                 unsigned long lval;
2070                 bool neg;
2071
2072                 if (write) {
2073                         left -= proc_skip_spaces(&kbuf);
2074
2075                         if (!left)
2076                                 break;
2077                         err = proc_get_long(&kbuf, &left, &lval, &neg,
2078                                              proc_wspace_sep,
2079                                              sizeof(proc_wspace_sep), NULL);
2080                         if (err)
2081                                 break;
2082                         if (conv(&neg, &lval, i, 1, data)) {
2083                                 err = -EINVAL;
2084                                 break;
2085                         }
2086                 } else {
2087                         if (conv(&neg, &lval, i, 0, data)) {
2088                                 err = -EINVAL;
2089                                 break;
2090                         }
2091                         if (!first)
2092                                 err = proc_put_char(&buffer, &left, '\t');
2093                         if (err)
2094                                 break;
2095                         err = proc_put_long(&buffer, &left, lval, neg);
2096                         if (err)
2097                                 break;
2098                 }
2099         }
2100
2101         if (!write && !first && left && !err)
2102                 err = proc_put_char(&buffer, &left, '\n');
2103         if (write && !err && left)
2104                 left -= proc_skip_spaces(&kbuf);
2105 free:
2106         if (write) {
2107                 free_page(page);
2108                 if (first)
2109                         return err ? : -EINVAL;
2110         }
2111         *lenp -= left;
2112 out:
2113         *ppos += *lenp;
2114         return err;
2115 }
2116
2117 static int do_proc_dointvec(struct ctl_table *table, int write,
2118                   void __user *buffer, size_t *lenp, loff_t *ppos,
2119                   int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2120                               int write, void *data),
2121                   void *data)
2122 {
2123         return __do_proc_dointvec(table->data, table, write,
2124                         buffer, lenp, ppos, conv, data);
2125 }
2126
2127 /**
2128  * proc_dointvec - read a vector of integers
2129  * @table: the sysctl table
2130  * @write: %TRUE if this is a write to the sysctl file
2131  * @buffer: the user buffer
2132  * @lenp: the size of the user buffer
2133  * @ppos: file position
2134  *
2135  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2136  * values from/to the user buffer, treated as an ASCII string. 
2137  *
2138  * Returns 0 on success.
2139  */
2140 int proc_dointvec(struct ctl_table *table, int write,
2141                      void __user *buffer, size_t *lenp, loff_t *ppos)
2142 {
2143     return do_proc_dointvec(table,write,buffer,lenp,ppos,
2144                             NULL,NULL);
2145 }
2146
2147 /*
2148  * Taint values can only be increased
2149  * This means we can safely use a temporary.
2150  */
2151 static int proc_taint(struct ctl_table *table, int write,
2152                                void __user *buffer, size_t *lenp, loff_t *ppos)
2153 {
2154         struct ctl_table t;
2155         unsigned long tmptaint = get_taint();
2156         int err;
2157
2158         if (write && !capable(CAP_SYS_ADMIN))
2159                 return -EPERM;
2160
2161         t = *table;
2162         t.data = &tmptaint;
2163         err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
2164         if (err < 0)
2165                 return err;
2166
2167         if (write) {
2168                 /*
2169                  * Poor man's atomic or. Not worth adding a primitive
2170                  * to everyone's atomic.h for this
2171                  */
2172                 int i;
2173                 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2174                         if ((tmptaint >> i) & 1)
2175                                 add_taint(i, LOCKDEP_STILL_OK);
2176                 }
2177         }
2178
2179         return err;
2180 }
2181
2182 #ifdef CONFIG_PRINTK
2183 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
2184                                 void __user *buffer, size_t *lenp, loff_t *ppos)
2185 {
2186         if (write && !capable(CAP_SYS_ADMIN))
2187                 return -EPERM;
2188
2189         return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2190 }
2191 #endif
2192
2193 struct do_proc_dointvec_minmax_conv_param {
2194         int *min;
2195         int *max;
2196 };
2197
2198 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2199                                         int *valp,
2200                                         int write, void *data)
2201 {
2202         struct do_proc_dointvec_minmax_conv_param *param = data;
2203         if (write) {
2204                 int val = *negp ? -*lvalp : *lvalp;
2205                 if ((param->min && *param->min > val) ||
2206                     (param->max && *param->max < val))
2207                         return -EINVAL;
2208                 *valp = val;
2209         } else {
2210                 int val = *valp;
2211                 if (val < 0) {
2212                         *negp = true;
2213                         *lvalp = -(unsigned long)val;
2214                 } else {
2215                         *negp = false;
2216                         *lvalp = (unsigned long)val;
2217                 }
2218         }
2219         return 0;
2220 }
2221
2222 /**
2223  * proc_dointvec_minmax - read a vector of integers with min/max values
2224  * @table: the sysctl table
2225  * @write: %TRUE if this is a write to the sysctl file
2226  * @buffer: the user buffer
2227  * @lenp: the size of the user buffer
2228  * @ppos: file position
2229  *
2230  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2231  * values from/to the user buffer, treated as an ASCII string.
2232  *
2233  * This routine will ensure the values are within the range specified by
2234  * table->extra1 (min) and table->extra2 (max).
2235  *
2236  * Returns 0 on success.
2237  */
2238 int proc_dointvec_minmax(struct ctl_table *table, int write,
2239                   void __user *buffer, size_t *lenp, loff_t *ppos)
2240 {
2241         struct do_proc_dointvec_minmax_conv_param param = {
2242                 .min = (int *) table->extra1,
2243                 .max = (int *) table->extra2,
2244         };
2245         return do_proc_dointvec(table, write, buffer, lenp, ppos,
2246                                 do_proc_dointvec_minmax_conv, &param);
2247 }
2248
2249 static void validate_coredump_safety(void)
2250 {
2251 #ifdef CONFIG_COREDUMP
2252         if (suid_dumpable == SUID_DUMP_ROOT &&
2253             core_pattern[0] != '/' && core_pattern[0] != '|') {
2254                 printk(KERN_WARNING "Unsafe core_pattern used with "\
2255                         "suid_dumpable=2. Pipe handler or fully qualified "\
2256                         "core dump path required.\n");
2257         }
2258 #endif
2259 }
2260
2261 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2262                 void __user *buffer, size_t *lenp, loff_t *ppos)
2263 {
2264         int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2265         if (!error)
2266                 validate_coredump_safety();
2267         return error;
2268 }
2269
2270 #ifdef CONFIG_COREDUMP
2271 static int proc_dostring_coredump(struct ctl_table *table, int write,
2272                   void __user *buffer, size_t *lenp, loff_t *ppos)
2273 {
2274         int error = proc_dostring(table, write, buffer, lenp, ppos);
2275         if (!error)
2276                 validate_coredump_safety();
2277         return error;
2278 }
2279 #endif
2280
2281 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
2282                                      void __user *buffer,
2283                                      size_t *lenp, loff_t *ppos,
2284                                      unsigned long convmul,
2285                                      unsigned long convdiv)
2286 {
2287         unsigned long *i, *min, *max;
2288         int vleft, first = 1, err = 0;
2289         unsigned long page = 0;
2290         size_t left;
2291         char *kbuf;
2292
2293         if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
2294                 *lenp = 0;
2295                 return 0;
2296         }
2297
2298         i = (unsigned long *) data;
2299         min = (unsigned long *) table->extra1;
2300         max = (unsigned long *) table->extra2;
2301         vleft = table->maxlen / sizeof(unsigned long);
2302         left = *lenp;
2303
2304         if (write) {
2305                 if (*ppos) {
2306                         switch (sysctl_writes_strict) {
2307                         case SYSCTL_WRITES_STRICT:
2308                                 goto out;
2309                         case SYSCTL_WRITES_WARN:
2310                                 warn_sysctl_write(table);
2311                                 break;
2312                         default:
2313                                 break;
2314                         }
2315                 }
2316
2317                 if (left > PAGE_SIZE - 1)
2318                         left = PAGE_SIZE - 1;
2319                 page = __get_free_page(GFP_TEMPORARY);
2320                 kbuf = (char *) page;
2321                 if (!kbuf)
2322                         return -ENOMEM;
2323                 if (copy_from_user(kbuf, buffer, left)) {
2324                         err = -EFAULT;
2325                         goto free;
2326                 }
2327                 kbuf[left] = 0;
2328         }
2329
2330         for (; left && vleft--; i++, first = 0) {
2331                 unsigned long val;
2332
2333                 if (write) {
2334                         bool neg;
2335
2336                         left -= proc_skip_spaces(&kbuf);
2337
2338                         err = proc_get_long(&kbuf, &left, &val, &neg,
2339                                              proc_wspace_sep,
2340                                              sizeof(proc_wspace_sep), NULL);
2341                         if (err)
2342                                 break;
2343                         if (neg)
2344                                 continue;
2345                         if ((min && val < *min) || (max && val > *max))
2346                                 continue;
2347                         *i = val;
2348                 } else {
2349                         val = convdiv * (*i) / convmul;
2350                         if (!first) {
2351                                 err = proc_put_char(&buffer, &left, '\t');
2352                                 if (err)
2353                                         break;
2354                         }
2355                         err = proc_put_long(&buffer, &left, val, false);
2356                         if (err)
2357                                 break;
2358                 }
2359         }
2360
2361         if (!write && !first && left && !err)
2362                 err = proc_put_char(&buffer, &left, '\n');
2363         if (write && !err)
2364                 left -= proc_skip_spaces(&kbuf);
2365 free:
2366         if (write) {
2367                 free_page(page);
2368                 if (first)
2369                         return err ? : -EINVAL;
2370         }
2371         *lenp -= left;
2372 out:
2373         *ppos += *lenp;
2374         return err;
2375 }
2376
2377 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2378                                      void __user *buffer,
2379                                      size_t *lenp, loff_t *ppos,
2380                                      unsigned long convmul,
2381                                      unsigned long convdiv)
2382 {
2383         return __do_proc_doulongvec_minmax(table->data, table, write,
2384                         buffer, lenp, ppos, convmul, convdiv);
2385 }
2386
2387 /**
2388  * proc_doulongvec_minmax - read a vector of long integers with min/max values
2389  * @table: the sysctl table
2390  * @write: %TRUE if this is a write to the sysctl file
2391  * @buffer: the user buffer
2392  * @lenp: the size of the user buffer
2393  * @ppos: file position
2394  *
2395  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2396  * values from/to the user buffer, treated as an ASCII string.
2397  *
2398  * This routine will ensure the values are within the range specified by
2399  * table->extra1 (min) and table->extra2 (max).
2400  *
2401  * Returns 0 on success.
2402  */
2403 int proc_doulongvec_minmax(struct ctl_table *table, int write,
2404                            void __user *buffer, size_t *lenp, loff_t *ppos)
2405 {
2406     return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
2407 }
2408
2409 /**
2410  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2411  * @table: the sysctl table
2412  * @write: %TRUE if this is a write to the sysctl file
2413  * @buffer: the user buffer
2414  * @lenp: the size of the user buffer
2415  * @ppos: file position
2416  *
2417  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2418  * values from/to the user buffer, treated as an ASCII string. The values
2419  * are treated as milliseconds, and converted to jiffies when they are stored.
2420  *
2421  * This routine will ensure the values are within the range specified by
2422  * table->extra1 (min) and table->extra2 (max).
2423  *
2424  * Returns 0 on success.
2425  */
2426 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2427                                       void __user *buffer,
2428                                       size_t *lenp, loff_t *ppos)
2429 {
2430     return do_proc_doulongvec_minmax(table, write, buffer,
2431                                      lenp, ppos, HZ, 1000l);
2432 }
2433
2434
2435 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
2436                                          int *valp,
2437                                          int write, void *data)
2438 {
2439         if (write) {
2440                 if (*lvalp > LONG_MAX / HZ)
2441                         return 1;
2442                 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2443         } else {
2444                 int val = *valp;
2445                 unsigned long lval;
2446                 if (val < 0) {
2447                         *negp = true;
2448                         lval = -(unsigned long)val;
2449                 } else {
2450                         *negp = false;
2451                         lval = (unsigned long)val;
2452                 }
2453                 *lvalp = lval / HZ;
2454         }
2455         return 0;
2456 }
2457
2458 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
2459                                                 int *valp,
2460                                                 int write, void *data)
2461 {
2462         if (write) {
2463                 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2464                         return 1;
2465                 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2466         } else {
2467                 int val = *valp;
2468                 unsigned long lval;
2469                 if (val < 0) {
2470                         *negp = true;
2471                         lval = -(unsigned long)val;
2472                 } else {
2473                         *negp = false;
2474                         lval = (unsigned long)val;
2475                 }
2476                 *lvalp = jiffies_to_clock_t(lval);
2477         }
2478         return 0;
2479 }
2480
2481 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
2482                                             int *valp,
2483                                             int write, void *data)
2484 {
2485         if (write) {
2486                 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2487
2488                 if (jif > INT_MAX)
2489                         return 1;
2490                 *valp = (int)jif;
2491         } else {
2492                 int val = *valp;
2493                 unsigned long lval;
2494                 if (val < 0) {
2495                         *negp = true;
2496                         lval = -(unsigned long)val;
2497                 } else {
2498                         *negp = false;
2499                         lval = (unsigned long)val;
2500                 }
2501                 *lvalp = jiffies_to_msecs(lval);
2502         }
2503         return 0;
2504 }
2505
2506 /**
2507  * proc_dointvec_jiffies - read a vector of integers as seconds
2508  * @table: the sysctl table
2509  * @write: %TRUE if this is a write to the sysctl file
2510  * @buffer: the user buffer
2511  * @lenp: the size of the user buffer
2512  * @ppos: file position
2513  *
2514  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2515  * values from/to the user buffer, treated as an ASCII string. 
2516  * The values read are assumed to be in seconds, and are converted into
2517  * jiffies.
2518  *
2519  * Returns 0 on success.
2520  */
2521 int proc_dointvec_jiffies(struct ctl_table *table, int write,
2522                           void __user *buffer, size_t *lenp, loff_t *ppos)
2523 {
2524     return do_proc_dointvec(table,write,buffer,lenp,ppos,
2525                             do_proc_dointvec_jiffies_conv,NULL);
2526 }
2527
2528 /**
2529  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2530  * @table: the sysctl table
2531  * @write: %TRUE if this is a write to the sysctl file
2532  * @buffer: the user buffer
2533  * @lenp: the size of the user buffer
2534  * @ppos: pointer to the file position
2535  *
2536  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2537  * values from/to the user buffer, treated as an ASCII string. 
2538  * The values read are assumed to be in 1/USER_HZ seconds, and 
2539  * are converted into jiffies.
2540  *
2541  * Returns 0 on success.
2542  */
2543 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
2544                                  void __user *buffer, size_t *lenp, loff_t *ppos)
2545 {
2546     return do_proc_dointvec(table,write,buffer,lenp,ppos,
2547                             do_proc_dointvec_userhz_jiffies_conv,NULL);
2548 }
2549
2550 /**
2551  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2552  * @table: the sysctl table
2553  * @write: %TRUE if this is a write to the sysctl file
2554  * @buffer: the user buffer
2555  * @lenp: the size of the user buffer
2556  * @ppos: file position
2557  * @ppos: the current position in the file
2558  *
2559  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2560  * values from/to the user buffer, treated as an ASCII string. 
2561  * The values read are assumed to be in 1/1000 seconds, and 
2562  * are converted into jiffies.
2563  *
2564  * Returns 0 on success.
2565  */
2566 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
2567                              void __user *buffer, size_t *lenp, loff_t *ppos)
2568 {
2569         return do_proc_dointvec(table, write, buffer, lenp, ppos,
2570                                 do_proc_dointvec_ms_jiffies_conv, NULL);
2571 }
2572
2573 static int proc_do_cad_pid(struct ctl_table *table, int write,
2574                            void __user *buffer, size_t *lenp, loff_t *ppos)
2575 {
2576         struct pid *new_pid;
2577         pid_t tmp;
2578         int r;
2579
2580         tmp = pid_vnr(cad_pid);
2581
2582         r = __do_proc_dointvec(&tmp, table, write, buffer,
2583                                lenp, ppos, NULL, NULL);
2584         if (r || !write)
2585                 return r;
2586
2587         new_pid = find_get_pid(tmp);
2588         if (!new_pid)
2589                 return -ESRCH;
2590
2591         put_pid(xchg(&cad_pid, new_pid));
2592         return 0;
2593 }
2594
2595 /**
2596  * proc_do_large_bitmap - read/write from/to a large bitmap
2597  * @table: the sysctl table
2598  * @write: %TRUE if this is a write to the sysctl file
2599  * @buffer: the user buffer
2600  * @lenp: the size of the user buffer
2601  * @ppos: file position
2602  *
2603  * The bitmap is stored at table->data and the bitmap length (in bits)
2604  * in table->maxlen.
2605  *
2606  * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2607  * large bitmaps may be represented in a compact manner. Writing into
2608  * the file will clear the bitmap then update it with the given input.
2609  *
2610  * Returns 0 on success.
2611  */
2612 int proc_do_large_bitmap(struct ctl_table *table, int write,
2613                          void __user *buffer, size_t *lenp, loff_t *ppos)
2614 {
2615         int err = 0;
2616         bool first = 1;
2617         size_t left = *lenp;
2618         unsigned long bitmap_len = table->maxlen;
2619         unsigned long *bitmap = *(unsigned long **) table->data;
2620         unsigned long *tmp_bitmap = NULL;
2621         char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2622
2623         if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
2624                 *lenp = 0;
2625                 return 0;
2626         }
2627
2628         if (write) {
2629                 unsigned long page = 0;
2630                 char *kbuf;
2631
2632                 if (left > PAGE_SIZE - 1)
2633                         left = PAGE_SIZE - 1;
2634
2635                 page = __get_free_page(GFP_TEMPORARY);
2636                 kbuf = (char *) page;
2637                 if (!kbuf)
2638                         return -ENOMEM;
2639                 if (copy_from_user(kbuf, buffer, left)) {
2640                         free_page(page);
2641                         return -EFAULT;
2642                 }
2643                 kbuf[left] = 0;
2644
2645                 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2646                                      GFP_KERNEL);
2647                 if (!tmp_bitmap) {
2648                         free_page(page);
2649                         return -ENOMEM;
2650                 }
2651                 proc_skip_char(&kbuf, &left, '\n');
2652                 while (!err && left) {
2653                         unsigned long val_a, val_b;
2654                         bool neg;
2655
2656                         err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2657                                              sizeof(tr_a), &c);
2658                         if (err)
2659                                 break;
2660                         if (val_a >= bitmap_len || neg) {
2661                                 err = -EINVAL;
2662                                 break;
2663                         }
2664
2665                         val_b = val_a;
2666                         if (left) {
2667                                 kbuf++;
2668                                 left--;
2669                         }
2670
2671                         if (c == '-') {
2672                                 err = proc_get_long(&kbuf, &left, &val_b,
2673                                                      &neg, tr_b, sizeof(tr_b),
2674                                                      &c);
2675                                 if (err)
2676                                         break;
2677                                 if (val_b >= bitmap_len || neg ||
2678                                     val_a > val_b) {
2679                                         err = -EINVAL;
2680                                         break;
2681                                 }
2682                                 if (left) {
2683                                         kbuf++;
2684                                         left--;
2685                                 }
2686                         }
2687
2688                         bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
2689                         first = 0;
2690                         proc_skip_char(&kbuf, &left, '\n');
2691                 }
2692                 free_page(page);
2693         } else {
2694                 unsigned long bit_a, bit_b = 0;
2695
2696                 while (left) {
2697                         bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2698                         if (bit_a >= bitmap_len)
2699                                 break;
2700                         bit_b = find_next_zero_bit(bitmap, bitmap_len,
2701                                                    bit_a + 1) - 1;
2702
2703                         if (!first) {
2704                                 err = proc_put_char(&buffer, &left, ',');
2705                                 if (err)
2706                                         break;
2707                         }
2708                         err = proc_put_long(&buffer, &left, bit_a, false);
2709                         if (err)
2710                                 break;
2711                         if (bit_a != bit_b) {
2712                                 err = proc_put_char(&buffer, &left, '-');
2713                                 if (err)
2714                                         break;
2715                                 err = proc_put_long(&buffer, &left, bit_b, false);
2716                                 if (err)
2717                                         break;
2718                         }
2719
2720                         first = 0; bit_b++;
2721                 }
2722                 if (!err)
2723                         err = proc_put_char(&buffer, &left, '\n');
2724         }
2725
2726         if (!err) {
2727                 if (write) {
2728                         if (*ppos)
2729                                 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2730                         else
2731                                 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
2732                 }
2733                 kfree(tmp_bitmap);
2734                 *lenp -= left;
2735                 *ppos += *lenp;
2736                 return 0;
2737         } else {
2738                 kfree(tmp_bitmap);
2739                 return err;
2740         }
2741 }
2742
2743 #else /* CONFIG_PROC_SYSCTL */
2744
2745 int proc_dostring(struct ctl_table *table, int write,
2746                   void __user *buffer, size_t *lenp, loff_t *ppos)
2747 {
2748         return -ENOSYS;
2749 }
2750
2751 int proc_dointvec(struct ctl_table *table, int write,
2752                   void __user *buffer, size_t *lenp, loff_t *ppos)
2753 {
2754         return -ENOSYS;
2755 }
2756
2757 int proc_dointvec_minmax(struct ctl_table *table, int write,
2758                     void __user *buffer, size_t *lenp, loff_t *ppos)
2759 {
2760         return -ENOSYS;
2761 }
2762
2763 int proc_dointvec_jiffies(struct ctl_table *table, int write,
2764                     void __user *buffer, size_t *lenp, loff_t *ppos)
2765 {
2766         return -ENOSYS;
2767 }
2768
2769 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
2770                     void __user *buffer, size_t *lenp, loff_t *ppos)
2771 {
2772         return -ENOSYS;
2773 }
2774
2775 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
2776                              void __user *buffer, size_t *lenp, loff_t *ppos)
2777 {
2778         return -ENOSYS;
2779 }
2780
2781 int proc_doulongvec_minmax(struct ctl_table *table, int write,
2782                     void __user *buffer, size_t *lenp, loff_t *ppos)
2783 {
2784         return -ENOSYS;
2785 }
2786
2787 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2788                                       void __user *buffer,
2789                                       size_t *lenp, loff_t *ppos)
2790 {
2791     return -ENOSYS;
2792 }
2793
2794
2795 #endif /* CONFIG_PROC_SYSCTL */
2796
2797 /*
2798  * No sense putting this after each symbol definition, twice,
2799  * exception granted :-)
2800  */
2801 EXPORT_SYMBOL(proc_dointvec);
2802 EXPORT_SYMBOL(proc_dointvec_jiffies);
2803 EXPORT_SYMBOL(proc_dointvec_minmax);
2804 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2805 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2806 EXPORT_SYMBOL(proc_dostring);
2807 EXPORT_SYMBOL(proc_doulongvec_minmax);
2808 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);