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