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