]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - kernel/sysctl.c
sched: fix copy_namespace() <-> sched_fork() dependency in do_fork
[mirror_ubuntu-zesty-kernel.git] / kernel / sysctl.c
CommitLineData
1da177e4
LT
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
1da177e4
LT
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/proc_fs.h>
72c2d582 27#include <linux/security.h>
1da177e4
LT
28#include <linux/ctype.h>
29#include <linux/utsname.h>
1da177e4 30#include <linux/smp_lock.h>
62239ac2 31#include <linux/fs.h>
1da177e4
LT
32#include <linux/init.h>
33#include <linux/kernel.h>
0296b228 34#include <linux/kobject.h>
20380731 35#include <linux/net.h>
1da177e4
LT
36#include <linux/sysrq.h>
37#include <linux/highuid.h>
38#include <linux/writeback.h>
39#include <linux/hugetlb.h>
40#include <linux/security.h>
41#include <linux/initrd.h>
42#include <linux/times.h>
43#include <linux/limits.h>
44#include <linux/dcache.h>
45#include <linux/syscalls.h>
c255d844
PM
46#include <linux/nfs_fs.h>
47#include <linux/acpi.h>
10a0a8d4 48#include <linux/reboot.h>
1da177e4
LT
49
50#include <asm/uaccess.h>
51#include <asm/processor.h>
52
29cbc78b
AK
53#ifdef CONFIG_X86
54#include <asm/nmi.h>
0741f4d2 55#include <asm/stacktrace.h>
29cbc78b
AK
56#endif
57
7058cb02
EB
58static int deprecated_sysctl_warning(struct __sysctl_args *args);
59
1da177e4
LT
60#if defined(CONFIG_SYSCTL)
61
62/* External variables not in a header file. */
63extern int C_A_D;
45807a1d 64extern int print_fatal_signals;
1da177e4
LT
65extern int sysctl_overcommit_memory;
66extern int sysctl_overcommit_ratio;
fadd8fbd 67extern int sysctl_panic_on_oom;
fe071d7e 68extern int sysctl_oom_kill_allocating_task;
1da177e4 69extern int max_threads;
1da177e4 70extern int core_uses_pid;
d6e71144 71extern int suid_dumpable;
1da177e4 72extern char core_pattern[];
1da177e4
LT
73extern int pid_max;
74extern int min_free_kbytes;
75extern int printk_ratelimit_jiffies;
76extern int printk_ratelimit_burst;
77extern int pid_max_min, pid_max_max;
9d0243bc 78extern int sysctl_drop_caches;
8ad4b1fb 79extern int percpu_pagelist_fraction;
bebfa101 80extern int compat_log;
5096add8 81extern int maps_protect;
77461ab3 82extern int sysctl_stat_interval;
bdf4c48a 83extern int audit_argv_kb;
1da177e4 84
c4f3b63f
RT
85/* Constants used for minimum and maximum */
86#ifdef CONFIG_DETECT_SOFTLOCKUP
87static int one = 1;
88static int sixty = 60;
89#endif
90
91#ifdef CONFIG_MMU
92static int two = 2;
93#endif
94
95static int zero;
96static int one_hundred = 100;
97
1da177e4
LT
98/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
99static int maxolduid = 65535;
100static int minolduid;
8ad4b1fb 101static int min_percpu_pagelist_fract = 8;
1da177e4
LT
102
103static int ngroups_max = NGROUPS_MAX;
104
105#ifdef CONFIG_KMOD
106extern char modprobe_path[];
107#endif
1da177e4
LT
108#ifdef CONFIG_CHR_DEV_SG
109extern int sg_big_buff;
110#endif
1da177e4
LT
111
112#ifdef __sparc__
113extern char reboot_command [];
114extern int stop_a_enabled;
115extern int scons_pwroff;
116#endif
117
118#ifdef __hppa__
119extern int pwrsw_enabled;
120extern int unaligned_enabled;
121#endif
122
347a8dc3 123#ifdef CONFIG_S390
1da177e4
LT
124#ifdef CONFIG_MATHEMU
125extern int sysctl_ieee_emulation_warnings;
126#endif
127extern int sysctl_userprocess_debug;
951f22d5 128extern int spin_retry;
1da177e4
LT
129#endif
130
131extern int sysctl_hz_timer;
132
133#ifdef CONFIG_BSD_PROCESS_ACCT
134extern int acct_parm[];
135#endif
136
d2b176ed
JS
137#ifdef CONFIG_IA64
138extern int no_unaligned_warning;
139#endif
140
23f78d4a
IM
141#ifdef CONFIG_RT_MUTEXES
142extern int max_lock_depth;
143#endif
144
b89a8171
EB
145#ifdef CONFIG_SYSCTL_SYSCALL
146static int parse_table(int __user *, int, void __user *, size_t __user *,
d8217f07 147 void __user *, size_t, struct ctl_table *);
b89a8171
EB
148#endif
149
6b49a257 150
d6f8ff73 151#ifdef CONFIG_PROC_SYSCTL
d8217f07 152static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
9ec52099 153 void __user *buffer, size_t *lenp, loff_t *ppos);
d8217f07 154static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp,
34f5a398 155 void __user *buffer, size_t *lenp, loff_t *ppos);
d6f8ff73 156#endif
9ec52099 157
d8217f07 158static struct ctl_table root_table[];
1da177e4
LT
159static struct ctl_table_header root_table_header =
160 { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
161
d8217f07
EB
162static struct ctl_table kern_table[];
163static struct ctl_table vm_table[];
164static struct ctl_table fs_table[];
165static struct ctl_table debug_table[];
166static struct ctl_table dev_table[];
167extern struct ctl_table random_table[];
2d9048e2 168#ifdef CONFIG_INOTIFY_USER
d8217f07 169extern struct ctl_table inotify_table[];
0399cb08 170#endif
1da177e4
LT
171
172#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
173int sysctl_legacy_va_layout;
174#endif
175
f20786ff
PZ
176extern int prove_locking;
177extern int lock_stat;
9bc9a6bd 178
1da177e4
LT
179/* The default sysctl tables: */
180
d8217f07 181static struct ctl_table root_table[] = {
1da177e4
LT
182 {
183 .ctl_name = CTL_KERN,
184 .procname = "kernel",
185 .mode = 0555,
186 .child = kern_table,
187 },
188 {
189 .ctl_name = CTL_VM,
190 .procname = "vm",
191 .mode = 0555,
192 .child = vm_table,
193 },
194#ifdef CONFIG_NET
195 {
196 .ctl_name = CTL_NET,
197 .procname = "net",
198 .mode = 0555,
199 .child = net_table,
200 },
201#endif
1da177e4
LT
202 {
203 .ctl_name = CTL_FS,
204 .procname = "fs",
205 .mode = 0555,
206 .child = fs_table,
207 },
208 {
209 .ctl_name = CTL_DEBUG,
210 .procname = "debug",
211 .mode = 0555,
212 .child = debug_table,
213 },
214 {
215 .ctl_name = CTL_DEV,
216 .procname = "dev",
217 .mode = 0555,
218 .child = dev_table,
219 },
2be7fe07
AM
220/*
221 * NOTE: do not add new entries to this table unless you have read
222 * Documentation/sysctl/ctl_unnumbered.txt
223 */
1da177e4
LT
224 { .ctl_name = 0 }
225};
226
77e54a1f
IM
227#ifdef CONFIG_SCHED_DEBUG
228static unsigned long min_sched_granularity_ns = 100000; /* 100 usecs */
d6322faf 229static unsigned long max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
77e54a1f 230static unsigned long min_wakeup_granularity_ns; /* 0 usecs */
d6322faf 231static unsigned long max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
77e54a1f
IM
232#endif
233
d8217f07 234static struct ctl_table kern_table[] = {
77e54a1f
IM
235#ifdef CONFIG_SCHED_DEBUG
236 {
237 .ctl_name = CTL_UNNUMBERED,
b2be5e96
PZ
238 .procname = "sched_min_granularity_ns",
239 .data = &sysctl_sched_min_granularity,
77e54a1f
IM
240 .maxlen = sizeof(unsigned int),
241 .mode = 0644,
b2be5e96
PZ
242 .proc_handler = &sched_nr_latency_handler,
243 .strategy = &sysctl_intvec,
244 .extra1 = &min_sched_granularity_ns,
245 .extra2 = &max_sched_granularity_ns,
77e54a1f 246 },
21805085
PZ
247 {
248 .ctl_name = CTL_UNNUMBERED,
249 .procname = "sched_latency_ns",
250 .data = &sysctl_sched_latency,
251 .maxlen = sizeof(unsigned int),
252 .mode = 0644,
b2be5e96 253 .proc_handler = &sched_nr_latency_handler,
21805085
PZ
254 .strategy = &sysctl_intvec,
255 .extra1 = &min_sched_granularity_ns,
256 .extra2 = &max_sched_granularity_ns,
257 },
77e54a1f
IM
258 {
259 .ctl_name = CTL_UNNUMBERED,
260 .procname = "sched_wakeup_granularity_ns",
261 .data = &sysctl_sched_wakeup_granularity,
262 .maxlen = sizeof(unsigned int),
263 .mode = 0644,
264 .proc_handler = &proc_dointvec_minmax,
265 .strategy = &sysctl_intvec,
266 .extra1 = &min_wakeup_granularity_ns,
267 .extra2 = &max_wakeup_granularity_ns,
268 },
269 {
270 .ctl_name = CTL_UNNUMBERED,
271 .procname = "sched_batch_wakeup_granularity_ns",
272 .data = &sysctl_sched_batch_wakeup_granularity,
273 .maxlen = sizeof(unsigned int),
274 .mode = 0644,
275 .proc_handler = &proc_dointvec_minmax,
276 .strategy = &sysctl_intvec,
277 .extra1 = &min_wakeup_granularity_ns,
278 .extra2 = &max_wakeup_granularity_ns,
279 },
77e54a1f
IM
280 {
281 .ctl_name = CTL_UNNUMBERED,
282 .procname = "sched_child_runs_first",
283 .data = &sysctl_sched_child_runs_first,
284 .maxlen = sizeof(unsigned int),
285 .mode = 0644,
286 .proc_handler = &proc_dointvec,
287 },
1fc84aaa
PZ
288 {
289 .ctl_name = CTL_UNNUMBERED,
290 .procname = "sched_features",
291 .data = &sysctl_sched_features,
292 .maxlen = sizeof(unsigned int),
293 .mode = 0644,
294 .proc_handler = &proc_dointvec,
295 },
da84d961
IM
296 {
297 .ctl_name = CTL_UNNUMBERED,
298 .procname = "sched_migration_cost",
299 .data = &sysctl_sched_migration_cost,
300 .maxlen = sizeof(unsigned int),
301 .mode = 0644,
302 .proc_handler = &proc_dointvec,
303 },
1fc84aaa 304#endif
1799e35d
IM
305 {
306 .ctl_name = CTL_UNNUMBERED,
307 .procname = "sched_compat_yield",
308 .data = &sysctl_sched_compat_yield,
309 .maxlen = sizeof(unsigned int),
310 .mode = 0644,
311 .proc_handler = &proc_dointvec,
312 },
f20786ff
PZ
313#ifdef CONFIG_PROVE_LOCKING
314 {
315 .ctl_name = CTL_UNNUMBERED,
316 .procname = "prove_locking",
317 .data = &prove_locking,
318 .maxlen = sizeof(int),
319 .mode = 0644,
320 .proc_handler = &proc_dointvec,
321 },
322#endif
323#ifdef CONFIG_LOCK_STAT
324 {
325 .ctl_name = CTL_UNNUMBERED,
326 .procname = "lock_stat",
327 .data = &lock_stat,
328 .maxlen = sizeof(int),
329 .mode = 0644,
330 .proc_handler = &proc_dointvec,
331 },
77e54a1f 332#endif
1da177e4
LT
333 {
334 .ctl_name = KERN_PANIC,
335 .procname = "panic",
336 .data = &panic_timeout,
337 .maxlen = sizeof(int),
338 .mode = 0644,
339 .proc_handler = &proc_dointvec,
340 },
341 {
342 .ctl_name = KERN_CORE_USES_PID,
343 .procname = "core_uses_pid",
344 .data = &core_uses_pid,
345 .maxlen = sizeof(int),
346 .mode = 0644,
347 .proc_handler = &proc_dointvec,
348 },
bdf4c48a
PZ
349#ifdef CONFIG_AUDITSYSCALL
350 {
351 .ctl_name = CTL_UNNUMBERED,
352 .procname = "audit_argv_kb",
353 .data = &audit_argv_kb,
354 .maxlen = sizeof(int),
355 .mode = 0644,
356 .proc_handler = &proc_dointvec,
357 },
358#endif
1da177e4
LT
359 {
360 .ctl_name = KERN_CORE_PATTERN,
361 .procname = "core_pattern",
362 .data = core_pattern,
71ce92f3 363 .maxlen = CORENAME_MAX_SIZE,
1da177e4
LT
364 .mode = 0644,
365 .proc_handler = &proc_dostring,
366 .strategy = &sysctl_string,
367 },
34f5a398 368#ifdef CONFIG_PROC_SYSCTL
1da177e4 369 {
1da177e4
LT
370 .procname = "tainted",
371 .data = &tainted,
372 .maxlen = sizeof(int),
34f5a398
TT
373 .mode = 0644,
374 .proc_handler = &proc_dointvec_taint,
1da177e4 375 },
34f5a398 376#endif
72c2d582 377#ifdef CONFIG_SECURITY_CAPABILITIES
1da177e4 378 {
1da177e4
LT
379 .procname = "cap-bound",
380 .data = &cap_bset,
381 .maxlen = sizeof(kernel_cap_t),
382 .mode = 0600,
383 .proc_handler = &proc_dointvec_bset,
384 },
72c2d582 385#endif /* def CONFIG_SECURITY_CAPABILITIES */
1da177e4
LT
386#ifdef CONFIG_BLK_DEV_INITRD
387 {
388 .ctl_name = KERN_REALROOTDEV,
389 .procname = "real-root-dev",
390 .data = &real_root_dev,
391 .maxlen = sizeof(int),
392 .mode = 0644,
393 .proc_handler = &proc_dointvec,
394 },
395#endif
45807a1d
IM
396 {
397 .ctl_name = CTL_UNNUMBERED,
398 .procname = "print-fatal-signals",
399 .data = &print_fatal_signals,
400 .maxlen = sizeof(int),
401 .mode = 0644,
402 .proc_handler = &proc_dointvec,
403 },
1da177e4
LT
404#ifdef __sparc__
405 {
406 .ctl_name = KERN_SPARC_REBOOT,
407 .procname = "reboot-cmd",
408 .data = reboot_command,
409 .maxlen = 256,
410 .mode = 0644,
411 .proc_handler = &proc_dostring,
412 .strategy = &sysctl_string,
413 },
414 {
415 .ctl_name = KERN_SPARC_STOP_A,
416 .procname = "stop-a",
417 .data = &stop_a_enabled,
418 .maxlen = sizeof (int),
419 .mode = 0644,
420 .proc_handler = &proc_dointvec,
421 },
422 {
423 .ctl_name = KERN_SPARC_SCONS_PWROFF,
424 .procname = "scons-poweroff",
425 .data = &scons_pwroff,
426 .maxlen = sizeof (int),
427 .mode = 0644,
428 .proc_handler = &proc_dointvec,
429 },
430#endif
431#ifdef __hppa__
432 {
433 .ctl_name = KERN_HPPA_PWRSW,
434 .procname = "soft-power",
435 .data = &pwrsw_enabled,
436 .maxlen = sizeof (int),
437 .mode = 0644,
438 .proc_handler = &proc_dointvec,
439 },
440 {
441 .ctl_name = KERN_HPPA_UNALIGNED,
442 .procname = "unaligned-trap",
443 .data = &unaligned_enabled,
444 .maxlen = sizeof (int),
445 .mode = 0644,
446 .proc_handler = &proc_dointvec,
447 },
448#endif
449 {
450 .ctl_name = KERN_CTLALTDEL,
451 .procname = "ctrl-alt-del",
452 .data = &C_A_D,
453 .maxlen = sizeof(int),
454 .mode = 0644,
455 .proc_handler = &proc_dointvec,
456 },
457 {
458 .ctl_name = KERN_PRINTK,
459 .procname = "printk",
460 .data = &console_loglevel,
461 .maxlen = 4*sizeof(int),
462 .mode = 0644,
463 .proc_handler = &proc_dointvec,
464 },
465#ifdef CONFIG_KMOD
466 {
467 .ctl_name = KERN_MODPROBE,
468 .procname = "modprobe",
469 .data = &modprobe_path,
470 .maxlen = KMOD_PATH_LEN,
471 .mode = 0644,
472 .proc_handler = &proc_dostring,
473 .strategy = &sysctl_string,
474 },
475#endif
57ae2508 476#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
1da177e4
LT
477 {
478 .ctl_name = KERN_HOTPLUG,
479 .procname = "hotplug",
312c004d
KS
480 .data = &uevent_helper,
481 .maxlen = UEVENT_HELPER_PATH_LEN,
1da177e4
LT
482 .mode = 0644,
483 .proc_handler = &proc_dostring,
484 .strategy = &sysctl_string,
485 },
486#endif
487#ifdef CONFIG_CHR_DEV_SG
488 {
489 .ctl_name = KERN_SG_BIG_BUFF,
490 .procname = "sg-big-buff",
491 .data = &sg_big_buff,
492 .maxlen = sizeof (int),
493 .mode = 0444,
494 .proc_handler = &proc_dointvec,
495 },
496#endif
497#ifdef CONFIG_BSD_PROCESS_ACCT
498 {
499 .ctl_name = KERN_ACCT,
500 .procname = "acct",
501 .data = &acct_parm,
502 .maxlen = 3*sizeof(int),
503 .mode = 0644,
504 .proc_handler = &proc_dointvec,
505 },
506#endif
1da177e4
LT
507#ifdef CONFIG_MAGIC_SYSRQ
508 {
509 .ctl_name = KERN_SYSRQ,
510 .procname = "sysrq",
5d6f647f 511 .data = &__sysrq_enabled,
1da177e4
LT
512 .maxlen = sizeof (int),
513 .mode = 0644,
514 .proc_handler = &proc_dointvec,
515 },
516#endif
d6f8ff73 517#ifdef CONFIG_PROC_SYSCTL
1da177e4 518 {
1da177e4 519 .procname = "cad_pid",
9ec52099 520 .data = NULL,
1da177e4
LT
521 .maxlen = sizeof (int),
522 .mode = 0600,
9ec52099 523 .proc_handler = &proc_do_cad_pid,
1da177e4 524 },
d6f8ff73 525#endif
1da177e4
LT
526 {
527 .ctl_name = KERN_MAX_THREADS,
528 .procname = "threads-max",
529 .data = &max_threads,
530 .maxlen = sizeof(int),
531 .mode = 0644,
532 .proc_handler = &proc_dointvec,
533 },
534 {
535 .ctl_name = KERN_RANDOM,
536 .procname = "random",
537 .mode = 0555,
538 .child = random_table,
539 },
1da177e4
LT
540 {
541 .ctl_name = KERN_OVERFLOWUID,
542 .procname = "overflowuid",
543 .data = &overflowuid,
544 .maxlen = sizeof(int),
545 .mode = 0644,
546 .proc_handler = &proc_dointvec_minmax,
547 .strategy = &sysctl_intvec,
548 .extra1 = &minolduid,
549 .extra2 = &maxolduid,
550 },
551 {
552 .ctl_name = KERN_OVERFLOWGID,
553 .procname = "overflowgid",
554 .data = &overflowgid,
555 .maxlen = sizeof(int),
556 .mode = 0644,
557 .proc_handler = &proc_dointvec_minmax,
558 .strategy = &sysctl_intvec,
559 .extra1 = &minolduid,
560 .extra2 = &maxolduid,
561 },
347a8dc3 562#ifdef CONFIG_S390
1da177e4
LT
563#ifdef CONFIG_MATHEMU
564 {
565 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
566 .procname = "ieee_emulation_warnings",
567 .data = &sysctl_ieee_emulation_warnings,
568 .maxlen = sizeof(int),
569 .mode = 0644,
570 .proc_handler = &proc_dointvec,
571 },
572#endif
573#ifdef CONFIG_NO_IDLE_HZ
574 {
575 .ctl_name = KERN_HZ_TIMER,
576 .procname = "hz_timer",
577 .data = &sysctl_hz_timer,
578 .maxlen = sizeof(int),
579 .mode = 0644,
580 .proc_handler = &proc_dointvec,
581 },
582#endif
583 {
584 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
585 .procname = "userprocess_debug",
586 .data = &sysctl_userprocess_debug,
587 .maxlen = sizeof(int),
588 .mode = 0644,
589 .proc_handler = &proc_dointvec,
590 },
591#endif
592 {
593 .ctl_name = KERN_PIDMAX,
594 .procname = "pid_max",
595 .data = &pid_max,
596 .maxlen = sizeof (int),
597 .mode = 0644,
598 .proc_handler = &proc_dointvec_minmax,
599 .strategy = sysctl_intvec,
600 .extra1 = &pid_max_min,
601 .extra2 = &pid_max_max,
602 },
603 {
604 .ctl_name = KERN_PANIC_ON_OOPS,
605 .procname = "panic_on_oops",
606 .data = &panic_on_oops,
607 .maxlen = sizeof(int),
608 .mode = 0644,
609 .proc_handler = &proc_dointvec,
610 },
611 {
612 .ctl_name = KERN_PRINTK_RATELIMIT,
613 .procname = "printk_ratelimit",
614 .data = &printk_ratelimit_jiffies,
615 .maxlen = sizeof(int),
616 .mode = 0644,
617 .proc_handler = &proc_dointvec_jiffies,
618 .strategy = &sysctl_jiffies,
619 },
620 {
621 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
622 .procname = "printk_ratelimit_burst",
623 .data = &printk_ratelimit_burst,
624 .maxlen = sizeof(int),
625 .mode = 0644,
626 .proc_handler = &proc_dointvec,
627 },
628 {
629 .ctl_name = KERN_NGROUPS_MAX,
630 .procname = "ngroups_max",
631 .data = &ngroups_max,
632 .maxlen = sizeof (int),
633 .mode = 0444,
634 .proc_handler = &proc_dointvec,
635 },
636#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
637 {
638 .ctl_name = KERN_UNKNOWN_NMI_PANIC,
639 .procname = "unknown_nmi_panic",
640 .data = &unknown_nmi_panic,
641 .maxlen = sizeof (int),
642 .mode = 0644,
2fbe7b25 643 .proc_handler = &proc_dointvec,
1da177e4 644 },
407984f1 645 {
407984f1
DZ
646 .procname = "nmi_watchdog",
647 .data = &nmi_watchdog_enabled,
648 .maxlen = sizeof (int),
649 .mode = 0644,
650 .proc_handler = &proc_nmi_enabled,
1da177e4
LT
651 },
652#endif
653#if defined(CONFIG_X86)
8da5adda
DZ
654 {
655 .ctl_name = KERN_PANIC_ON_NMI,
656 .procname = "panic_on_unrecovered_nmi",
657 .data = &panic_on_unrecovered_nmi,
658 .maxlen = sizeof(int),
659 .mode = 0644,
660 .proc_handler = &proc_dointvec,
661 },
1da177e4
LT
662 {
663 .ctl_name = KERN_BOOTLOADER_TYPE,
664 .procname = "bootloader_type",
665 .data = &bootloader_type,
666 .maxlen = sizeof (int),
667 .mode = 0444,
668 .proc_handler = &proc_dointvec,
669 },
0741f4d2
CE
670 {
671 .ctl_name = CTL_UNNUMBERED,
672 .procname = "kstack_depth_to_print",
673 .data = &kstack_depth_to_print,
674 .maxlen = sizeof(int),
675 .mode = 0644,
676 .proc_handler = &proc_dointvec,
677 },
1da177e4 678#endif
7a9166e3 679#if defined(CONFIG_MMU)
1da177e4
LT
680 {
681 .ctl_name = KERN_RANDOMIZE,
682 .procname = "randomize_va_space",
683 .data = &randomize_va_space,
684 .maxlen = sizeof(int),
685 .mode = 0644,
686 .proc_handler = &proc_dointvec,
687 },
7a9166e3 688#endif
0152fb37 689#if defined(CONFIG_S390) && defined(CONFIG_SMP)
951f22d5
MS
690 {
691 .ctl_name = KERN_SPIN_RETRY,
692 .procname = "spin_retry",
693 .data = &spin_retry,
694 .maxlen = sizeof (int),
695 .mode = 0644,
696 .proc_handler = &proc_dointvec,
697 },
c255d844 698#endif
673d5b43 699#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
c255d844 700 {
c255d844 701 .procname = "acpi_video_flags",
77afcf78 702 .data = &acpi_realmode_flags,
c255d844
PM
703 .maxlen = sizeof (unsigned long),
704 .mode = 0644,
7f99f06f 705 .proc_handler = &proc_doulongvec_minmax,
c255d844 706 },
d2b176ed
JS
707#endif
708#ifdef CONFIG_IA64
709 {
710 .ctl_name = KERN_IA64_UNALIGNED,
711 .procname = "ignore-unaligned-usertrap",
712 .data = &no_unaligned_warning,
713 .maxlen = sizeof (int),
714 .mode = 0644,
715 .proc_handler = &proc_dointvec,
716 },
bebfa101 717#endif
c4f3b63f
RT
718#ifdef CONFIG_DETECT_SOFTLOCKUP
719 {
720 .ctl_name = CTL_UNNUMBERED,
721 .procname = "softlockup_thresh",
722 .data = &softlockup_thresh,
723 .maxlen = sizeof(int),
724 .mode = 0644,
725 .proc_handler = &proc_dointvec_minmax,
726 .strategy = &sysctl_intvec,
727 .extra1 = &one,
728 .extra2 = &sixty,
729 },
730#endif
bebfa101
AK
731#ifdef CONFIG_COMPAT
732 {
733 .ctl_name = KERN_COMPAT_LOG,
734 .procname = "compat-log",
735 .data = &compat_log,
736 .maxlen = sizeof (int),
737 .mode = 0644,
738 .proc_handler = &proc_dointvec,
739 },
951f22d5 740#endif
23f78d4a
IM
741#ifdef CONFIG_RT_MUTEXES
742 {
743 .ctl_name = KERN_MAX_LOCK_DEPTH,
744 .procname = "max_lock_depth",
745 .data = &max_lock_depth,
746 .maxlen = sizeof(int),
747 .mode = 0644,
748 .proc_handler = &proc_dointvec,
749 },
750#endif
5096add8
KC
751#ifdef CONFIG_PROC_FS
752 {
753 .ctl_name = CTL_UNNUMBERED,
754 .procname = "maps_protect",
755 .data = &maps_protect,
756 .maxlen = sizeof(int),
757 .mode = 0644,
758 .proc_handler = &proc_dointvec,
759 },
760#endif
10a0a8d4
JF
761 {
762 .ctl_name = CTL_UNNUMBERED,
763 .procname = "poweroff_cmd",
764 .data = &poweroff_cmd,
765 .maxlen = POWEROFF_CMD_PATH_LEN,
766 .mode = 0644,
767 .proc_handler = &proc_dostring,
768 .strategy = &sysctl_string,
769 },
ed2c12f3
AM
770/*
771 * NOTE: do not add new entries to this table unless you have read
772 * Documentation/sysctl/ctl_unnumbered.txt
773 */
1da177e4
LT
774 { .ctl_name = 0 }
775};
776
d8217f07 777static struct ctl_table vm_table[] = {
1da177e4
LT
778 {
779 .ctl_name = VM_OVERCOMMIT_MEMORY,
780 .procname = "overcommit_memory",
781 .data = &sysctl_overcommit_memory,
782 .maxlen = sizeof(sysctl_overcommit_memory),
783 .mode = 0644,
784 .proc_handler = &proc_dointvec,
785 },
fadd8fbd
KH
786 {
787 .ctl_name = VM_PANIC_ON_OOM,
788 .procname = "panic_on_oom",
789 .data = &sysctl_panic_on_oom,
790 .maxlen = sizeof(sysctl_panic_on_oom),
791 .mode = 0644,
792 .proc_handler = &proc_dointvec,
793 },
fe071d7e
DR
794 {
795 .ctl_name = CTL_UNNUMBERED,
796 .procname = "oom_kill_allocating_task",
797 .data = &sysctl_oom_kill_allocating_task,
798 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
799 .mode = 0644,
800 .proc_handler = &proc_dointvec,
801 },
1da177e4
LT
802 {
803 .ctl_name = VM_OVERCOMMIT_RATIO,
804 .procname = "overcommit_ratio",
805 .data = &sysctl_overcommit_ratio,
806 .maxlen = sizeof(sysctl_overcommit_ratio),
807 .mode = 0644,
808 .proc_handler = &proc_dointvec,
809 },
810 {
811 .ctl_name = VM_PAGE_CLUSTER,
812 .procname = "page-cluster",
813 .data = &page_cluster,
814 .maxlen = sizeof(int),
815 .mode = 0644,
816 .proc_handler = &proc_dointvec,
817 },
818 {
819 .ctl_name = VM_DIRTY_BACKGROUND,
820 .procname = "dirty_background_ratio",
821 .data = &dirty_background_ratio,
822 .maxlen = sizeof(dirty_background_ratio),
823 .mode = 0644,
824 .proc_handler = &proc_dointvec_minmax,
825 .strategy = &sysctl_intvec,
826 .extra1 = &zero,
827 .extra2 = &one_hundred,
828 },
829 {
830 .ctl_name = VM_DIRTY_RATIO,
831 .procname = "dirty_ratio",
832 .data = &vm_dirty_ratio,
833 .maxlen = sizeof(vm_dirty_ratio),
834 .mode = 0644,
04fbfdc1 835 .proc_handler = &dirty_ratio_handler,
1da177e4
LT
836 .strategy = &sysctl_intvec,
837 .extra1 = &zero,
838 .extra2 = &one_hundred,
839 },
840 {
1da177e4 841 .procname = "dirty_writeback_centisecs",
f6ef9438
BS
842 .data = &dirty_writeback_interval,
843 .maxlen = sizeof(dirty_writeback_interval),
1da177e4
LT
844 .mode = 0644,
845 .proc_handler = &dirty_writeback_centisecs_handler,
846 },
847 {
1da177e4 848 .procname = "dirty_expire_centisecs",
f6ef9438
BS
849 .data = &dirty_expire_interval,
850 .maxlen = sizeof(dirty_expire_interval),
1da177e4 851 .mode = 0644,
f6ef9438 852 .proc_handler = &proc_dointvec_userhz_jiffies,
1da177e4
LT
853 },
854 {
855 .ctl_name = VM_NR_PDFLUSH_THREADS,
856 .procname = "nr_pdflush_threads",
857 .data = &nr_pdflush_threads,
858 .maxlen = sizeof nr_pdflush_threads,
859 .mode = 0444 /* read-only*/,
860 .proc_handler = &proc_dointvec,
861 },
862 {
863 .ctl_name = VM_SWAPPINESS,
864 .procname = "swappiness",
865 .data = &vm_swappiness,
866 .maxlen = sizeof(vm_swappiness),
867 .mode = 0644,
868 .proc_handler = &proc_dointvec_minmax,
869 .strategy = &sysctl_intvec,
870 .extra1 = &zero,
871 .extra2 = &one_hundred,
872 },
873#ifdef CONFIG_HUGETLB_PAGE
874 {
1da177e4
LT
875 .procname = "nr_hugepages",
876 .data = &max_huge_pages,
877 .maxlen = sizeof(unsigned long),
878 .mode = 0644,
879 .proc_handler = &hugetlb_sysctl_handler,
880 .extra1 = (void *)&hugetlb_zero,
881 .extra2 = (void *)&hugetlb_infinity,
882 },
883 {
884 .ctl_name = VM_HUGETLB_GROUP,
885 .procname = "hugetlb_shm_group",
886 .data = &sysctl_hugetlb_shm_group,
887 .maxlen = sizeof(gid_t),
888 .mode = 0644,
889 .proc_handler = &proc_dointvec,
890 },
396faf03
MG
891 {
892 .ctl_name = CTL_UNNUMBERED,
893 .procname = "hugepages_treat_as_movable",
894 .data = &hugepages_treat_as_movable,
895 .maxlen = sizeof(int),
896 .mode = 0644,
897 .proc_handler = &hugetlb_treat_movable_handler,
898 },
54f9f80d
AL
899 {
900 .ctl_name = CTL_UNNUMBERED,
901 .procname = "hugetlb_dynamic_pool",
902 .data = &hugetlb_dynamic_pool,
903 .maxlen = sizeof(hugetlb_dynamic_pool),
904 .mode = 0644,
905 .proc_handler = &proc_dointvec,
906 },
1da177e4
LT
907#endif
908 {
909 .ctl_name = VM_LOWMEM_RESERVE_RATIO,
910 .procname = "lowmem_reserve_ratio",
911 .data = &sysctl_lowmem_reserve_ratio,
912 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
913 .mode = 0644,
914 .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
915 .strategy = &sysctl_intvec,
916 },
9d0243bc
AM
917 {
918 .ctl_name = VM_DROP_PAGECACHE,
919 .procname = "drop_caches",
920 .data = &sysctl_drop_caches,
921 .maxlen = sizeof(int),
922 .mode = 0644,
923 .proc_handler = drop_caches_sysctl_handler,
924 .strategy = &sysctl_intvec,
925 },
1da177e4
LT
926 {
927 .ctl_name = VM_MIN_FREE_KBYTES,
928 .procname = "min_free_kbytes",
929 .data = &min_free_kbytes,
930 .maxlen = sizeof(min_free_kbytes),
931 .mode = 0644,
932 .proc_handler = &min_free_kbytes_sysctl_handler,
933 .strategy = &sysctl_intvec,
934 .extra1 = &zero,
935 },
8ad4b1fb
RS
936 {
937 .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
938 .procname = "percpu_pagelist_fraction",
939 .data = &percpu_pagelist_fraction,
940 .maxlen = sizeof(percpu_pagelist_fraction),
941 .mode = 0644,
942 .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
943 .strategy = &sysctl_intvec,
944 .extra1 = &min_percpu_pagelist_fract,
945 },
1da177e4
LT
946#ifdef CONFIG_MMU
947 {
948 .ctl_name = VM_MAX_MAP_COUNT,
949 .procname = "max_map_count",
950 .data = &sysctl_max_map_count,
951 .maxlen = sizeof(sysctl_max_map_count),
952 .mode = 0644,
953 .proc_handler = &proc_dointvec
954 },
955#endif
956 {
957 .ctl_name = VM_LAPTOP_MODE,
958 .procname = "laptop_mode",
959 .data = &laptop_mode,
960 .maxlen = sizeof(laptop_mode),
961 .mode = 0644,
ed5b43f1
BS
962 .proc_handler = &proc_dointvec_jiffies,
963 .strategy = &sysctl_jiffies,
1da177e4
LT
964 },
965 {
966 .ctl_name = VM_BLOCK_DUMP,
967 .procname = "block_dump",
968 .data = &block_dump,
969 .maxlen = sizeof(block_dump),
970 .mode = 0644,
971 .proc_handler = &proc_dointvec,
972 .strategy = &sysctl_intvec,
973 .extra1 = &zero,
974 },
975 {
976 .ctl_name = VM_VFS_CACHE_PRESSURE,
977 .procname = "vfs_cache_pressure",
978 .data = &sysctl_vfs_cache_pressure,
979 .maxlen = sizeof(sysctl_vfs_cache_pressure),
980 .mode = 0644,
981 .proc_handler = &proc_dointvec,
982 .strategy = &sysctl_intvec,
983 .extra1 = &zero,
984 },
985#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
986 {
987 .ctl_name = VM_LEGACY_VA_LAYOUT,
988 .procname = "legacy_va_layout",
989 .data = &sysctl_legacy_va_layout,
990 .maxlen = sizeof(sysctl_legacy_va_layout),
991 .mode = 0644,
992 .proc_handler = &proc_dointvec,
993 .strategy = &sysctl_intvec,
994 .extra1 = &zero,
995 },
996#endif
1743660b
CL
997#ifdef CONFIG_NUMA
998 {
999 .ctl_name = VM_ZONE_RECLAIM_MODE,
1000 .procname = "zone_reclaim_mode",
1001 .data = &zone_reclaim_mode,
1002 .maxlen = sizeof(zone_reclaim_mode),
1003 .mode = 0644,
1004 .proc_handler = &proc_dointvec,
c84db23c
CL
1005 .strategy = &sysctl_intvec,
1006 .extra1 = &zero,
1743660b 1007 },
9614634f
CL
1008 {
1009 .ctl_name = VM_MIN_UNMAPPED,
1010 .procname = "min_unmapped_ratio",
1011 .data = &sysctl_min_unmapped_ratio,
1012 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1013 .mode = 0644,
1014 .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
1015 .strategy = &sysctl_intvec,
1016 .extra1 = &zero,
1017 .extra2 = &one_hundred,
1018 },
0ff38490
CL
1019 {
1020 .ctl_name = VM_MIN_SLAB,
1021 .procname = "min_slab_ratio",
1022 .data = &sysctl_min_slab_ratio,
1023 .maxlen = sizeof(sysctl_min_slab_ratio),
1024 .mode = 0644,
1025 .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
1026 .strategy = &sysctl_intvec,
1027 .extra1 = &zero,
1028 .extra2 = &one_hundred,
1029 },
e6e5494c 1030#endif
77461ab3
CL
1031#ifdef CONFIG_SMP
1032 {
1033 .ctl_name = CTL_UNNUMBERED,
1034 .procname = "stat_interval",
1035 .data = &sysctl_stat_interval,
1036 .maxlen = sizeof(sysctl_stat_interval),
1037 .mode = 0644,
1038 .proc_handler = &proc_dointvec_jiffies,
1039 .strategy = &sysctl_jiffies,
1040 },
1041#endif
ed032189
EP
1042#ifdef CONFIG_SECURITY
1043 {
1044 .ctl_name = CTL_UNNUMBERED,
1045 .procname = "mmap_min_addr",
1046 .data = &mmap_min_addr,
1047 .maxlen = sizeof(unsigned long),
1048 .mode = 0644,
1049 .proc_handler = &proc_doulongvec_minmax,
1050 },
8daec965 1051#endif
f0c0b2b8
KH
1052#ifdef CONFIG_NUMA
1053 {
1054 .ctl_name = CTL_UNNUMBERED,
1055 .procname = "numa_zonelist_order",
1056 .data = &numa_zonelist_order,
1057 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1058 .mode = 0644,
1059 .proc_handler = &numa_zonelist_order_handler,
1060 .strategy = &sysctl_string,
1061 },
1062#endif
2b8232ce 1063#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
5c36e657 1064 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
e6e5494c
IM
1065 {
1066 .ctl_name = VM_VDSO_ENABLED,
1067 .procname = "vdso_enabled",
1068 .data = &vdso_enabled,
1069 .maxlen = sizeof(vdso_enabled),
1070 .mode = 0644,
1071 .proc_handler = &proc_dointvec,
1072 .strategy = &sysctl_intvec,
1073 .extra1 = &zero,
1074 },
1da177e4 1075#endif
2be7fe07
AM
1076/*
1077 * NOTE: do not add new entries to this table unless you have read
1078 * Documentation/sysctl/ctl_unnumbered.txt
1079 */
1da177e4
LT
1080 { .ctl_name = 0 }
1081};
1082
2abc26fc 1083#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
d8217f07 1084static struct ctl_table binfmt_misc_table[] = {
2abc26fc
EB
1085 { .ctl_name = 0 }
1086};
1087#endif
1088
d8217f07 1089static struct ctl_table fs_table[] = {
1da177e4
LT
1090 {
1091 .ctl_name = FS_NRINODE,
1092 .procname = "inode-nr",
1093 .data = &inodes_stat,
1094 .maxlen = 2*sizeof(int),
1095 .mode = 0444,
1096 .proc_handler = &proc_dointvec,
1097 },
1098 {
1099 .ctl_name = FS_STATINODE,
1100 .procname = "inode-state",
1101 .data = &inodes_stat,
1102 .maxlen = 7*sizeof(int),
1103 .mode = 0444,
1104 .proc_handler = &proc_dointvec,
1105 },
1106 {
1da177e4
LT
1107 .procname = "file-nr",
1108 .data = &files_stat,
1109 .maxlen = 3*sizeof(int),
1110 .mode = 0444,
529bf6be 1111 .proc_handler = &proc_nr_files,
1da177e4
LT
1112 },
1113 {
1114 .ctl_name = FS_MAXFILE,
1115 .procname = "file-max",
1116 .data = &files_stat.max_files,
1117 .maxlen = sizeof(int),
1118 .mode = 0644,
1119 .proc_handler = &proc_dointvec,
1120 },
1121 {
1122 .ctl_name = FS_DENTRY,
1123 .procname = "dentry-state",
1124 .data = &dentry_stat,
1125 .maxlen = 6*sizeof(int),
1126 .mode = 0444,
1127 .proc_handler = &proc_dointvec,
1128 },
1129 {
1130 .ctl_name = FS_OVERFLOWUID,
1131 .procname = "overflowuid",
1132 .data = &fs_overflowuid,
1133 .maxlen = sizeof(int),
1134 .mode = 0644,
1135 .proc_handler = &proc_dointvec_minmax,
1136 .strategy = &sysctl_intvec,
1137 .extra1 = &minolduid,
1138 .extra2 = &maxolduid,
1139 },
1140 {
1141 .ctl_name = FS_OVERFLOWGID,
1142 .procname = "overflowgid",
1143 .data = &fs_overflowgid,
1144 .maxlen = sizeof(int),
1145 .mode = 0644,
1146 .proc_handler = &proc_dointvec_minmax,
1147 .strategy = &sysctl_intvec,
1148 .extra1 = &minolduid,
1149 .extra2 = &maxolduid,
1150 },
1151 {
1152 .ctl_name = FS_LEASES,
1153 .procname = "leases-enable",
1154 .data = &leases_enable,
1155 .maxlen = sizeof(int),
1156 .mode = 0644,
1157 .proc_handler = &proc_dointvec,
1158 },
1159#ifdef CONFIG_DNOTIFY
1160 {
1161 .ctl_name = FS_DIR_NOTIFY,
1162 .procname = "dir-notify-enable",
1163 .data = &dir_notify_enable,
1164 .maxlen = sizeof(int),
1165 .mode = 0644,
1166 .proc_handler = &proc_dointvec,
1167 },
1168#endif
1169#ifdef CONFIG_MMU
1170 {
1171 .ctl_name = FS_LEASE_TIME,
1172 .procname = "lease-break-time",
1173 .data = &lease_break_time,
1174 .maxlen = sizeof(int),
1175 .mode = 0644,
76fdbb25
KH
1176 .proc_handler = &proc_dointvec_minmax,
1177 .strategy = &sysctl_intvec,
1178 .extra1 = &zero,
1179 .extra2 = &two,
1da177e4
LT
1180 },
1181 {
1da177e4
LT
1182 .procname = "aio-nr",
1183 .data = &aio_nr,
1184 .maxlen = sizeof(aio_nr),
1185 .mode = 0444,
d55b5fda 1186 .proc_handler = &proc_doulongvec_minmax,
1da177e4
LT
1187 },
1188 {
1da177e4
LT
1189 .procname = "aio-max-nr",
1190 .data = &aio_max_nr,
1191 .maxlen = sizeof(aio_max_nr),
1192 .mode = 0644,
d55b5fda 1193 .proc_handler = &proc_doulongvec_minmax,
1da177e4 1194 },
2d9048e2 1195#ifdef CONFIG_INOTIFY_USER
0399cb08
RL
1196 {
1197 .ctl_name = FS_INOTIFY,
1198 .procname = "inotify",
1199 .mode = 0555,
1200 .child = inotify_table,
1201 },
1202#endif
1da177e4 1203#endif
d6e71144
AC
1204 {
1205 .ctl_name = KERN_SETUID_DUMPABLE,
1206 .procname = "suid_dumpable",
1207 .data = &suid_dumpable,
1208 .maxlen = sizeof(int),
1209 .mode = 0644,
1210 .proc_handler = &proc_dointvec,
1211 },
2abc26fc
EB
1212#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1213 {
1214 .ctl_name = CTL_UNNUMBERED,
1215 .procname = "binfmt_misc",
1216 .mode = 0555,
1217 .child = binfmt_misc_table,
1218 },
1219#endif
2be7fe07
AM
1220/*
1221 * NOTE: do not add new entries to this table unless you have read
1222 * Documentation/sysctl/ctl_unnumbered.txt
2be7fe07 1223 */
1da177e4
LT
1224 { .ctl_name = 0 }
1225};
1226
d8217f07 1227static struct ctl_table debug_table[] = {
d0c3d534 1228#if defined(CONFIG_X86) || defined(CONFIG_PPC)
abd4f750
MAS
1229 {
1230 .ctl_name = CTL_UNNUMBERED,
1231 .procname = "exception-trace",
1232 .data = &show_unhandled_signals,
1233 .maxlen = sizeof(int),
1234 .mode = 0644,
1235 .proc_handler = proc_dointvec
1236 },
1237#endif
1da177e4
LT
1238 { .ctl_name = 0 }
1239};
1240
d8217f07 1241static struct ctl_table dev_table[] = {
1da177e4 1242 { .ctl_name = 0 }
0eeca283 1243};
1da177e4 1244
330d57fb
AV
1245static DEFINE_SPINLOCK(sysctl_lock);
1246
1247/* called under sysctl_lock */
1248static int use_table(struct ctl_table_header *p)
1249{
1250 if (unlikely(p->unregistering))
1251 return 0;
1252 p->used++;
1253 return 1;
1254}
1255
1256/* called under sysctl_lock */
1257static void unuse_table(struct ctl_table_header *p)
1258{
1259 if (!--p->used)
1260 if (unlikely(p->unregistering))
1261 complete(p->unregistering);
1262}
1263
1264/* called under sysctl_lock, will reacquire if has to wait */
1265static void start_unregistering(struct ctl_table_header *p)
1266{
1267 /*
1268 * if p->used is 0, nobody will ever touch that entry again;
1269 * we'll eliminate all paths to it before dropping sysctl_lock
1270 */
1271 if (unlikely(p->used)) {
1272 struct completion wait;
1273 init_completion(&wait);
1274 p->unregistering = &wait;
1275 spin_unlock(&sysctl_lock);
1276 wait_for_completion(&wait);
1277 spin_lock(&sysctl_lock);
1278 }
1279 /*
1280 * do not remove from the list until nobody holds it; walking the
1281 * list in do_sysctl() relies on that.
1282 */
1283 list_del_init(&p->ctl_entry);
1284}
1285
805b5d5e
EB
1286void sysctl_head_finish(struct ctl_table_header *head)
1287{
1288 if (!head)
1289 return;
1290 spin_lock(&sysctl_lock);
1291 unuse_table(head);
1292 spin_unlock(&sysctl_lock);
1293}
1294
1295struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1296{
1297 struct ctl_table_header *head;
1298 struct list_head *tmp;
1299 spin_lock(&sysctl_lock);
1300 if (prev) {
1301 tmp = &prev->ctl_entry;
1302 unuse_table(prev);
1303 goto next;
1304 }
1305 tmp = &root_table_header.ctl_entry;
1306 for (;;) {
1307 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1308
1309 if (!use_table(head))
1310 goto next;
1311 spin_unlock(&sysctl_lock);
1312 return head;
1313 next:
1314 tmp = tmp->next;
1315 if (tmp == &root_table_header.ctl_entry)
1316 break;
1317 }
1318 spin_unlock(&sysctl_lock);
1319 return NULL;
1320}
1321
b89a8171 1322#ifdef CONFIG_SYSCTL_SYSCALL
1da177e4
LT
1323int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1324 void __user *newval, size_t newlen)
1325{
805b5d5e 1326 struct ctl_table_header *head;
330d57fb 1327 int error = -ENOTDIR;
1da177e4
LT
1328
1329 if (nlen <= 0 || nlen >= CTL_MAXNAME)
1330 return -ENOTDIR;
1331 if (oldval) {
1332 int old_len;
1333 if (!oldlenp || get_user(old_len, oldlenp))
1334 return -EFAULT;
1335 }
330d57fb 1336
805b5d5e
EB
1337 for (head = sysctl_head_next(NULL); head;
1338 head = sysctl_head_next(head)) {
330d57fb 1339 error = parse_table(name, nlen, oldval, oldlenp,
1f29bcd7 1340 newval, newlen, head->ctl_table);
805b5d5e
EB
1341 if (error != -ENOTDIR) {
1342 sysctl_head_finish(head);
330d57fb 1343 break;
805b5d5e
EB
1344 }
1345 }
330d57fb 1346 return error;
1da177e4
LT
1347}
1348
1349asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1350{
1351 struct __sysctl_args tmp;
1352 int error;
1353
1354 if (copy_from_user(&tmp, args, sizeof(tmp)))
1355 return -EFAULT;
1356
7058cb02
EB
1357 error = deprecated_sysctl_warning(&tmp);
1358 if (error)
1359 goto out;
1360
1da177e4
LT
1361 lock_kernel();
1362 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1363 tmp.newval, tmp.newlen);
1364 unlock_kernel();
7058cb02 1365out:
1da177e4
LT
1366 return error;
1367}
b89a8171 1368#endif /* CONFIG_SYSCTL_SYSCALL */
1da177e4
LT
1369
1370/*
1ff007eb 1371 * sysctl_perm does NOT grant the superuser all rights automatically, because
1da177e4
LT
1372 * some sysctl variables are readonly even to root.
1373 */
1374
1375static int test_perm(int mode, int op)
1376{
1377 if (!current->euid)
1378 mode >>= 6;
1379 else if (in_egroup_p(0))
1380 mode >>= 3;
1381 if ((mode & op & 0007) == op)
1382 return 0;
1383 return -EACCES;
1384}
1385
d8217f07 1386int sysctl_perm(struct ctl_table *table, int op)
1da177e4
LT
1387{
1388 int error;
1389 error = security_sysctl(table, op);
1390 if (error)
1391 return error;
1392 return test_perm(table->mode, op);
1393}
1394
b89a8171 1395#ifdef CONFIG_SYSCTL_SYSCALL
1da177e4
LT
1396static int parse_table(int __user *name, int nlen,
1397 void __user *oldval, size_t __user *oldlenp,
1398 void __user *newval, size_t newlen,
d8217f07 1399 struct ctl_table *table)
1da177e4
LT
1400{
1401 int n;
1402repeat:
1403 if (!nlen)
1404 return -ENOTDIR;
1405 if (get_user(n, name))
1406 return -EFAULT;
d99f160a
EB
1407 for ( ; table->ctl_name || table->procname; table++) {
1408 if (!table->ctl_name)
1409 continue;
6703ddfc 1410 if (n == table->ctl_name) {
1da177e4
LT
1411 int error;
1412 if (table->child) {
1ff007eb 1413 if (sysctl_perm(table, 001))
1da177e4 1414 return -EPERM;
1da177e4
LT
1415 name++;
1416 nlen--;
1417 table = table->child;
1418 goto repeat;
1419 }
1420 error = do_sysctl_strategy(table, name, nlen,
1421 oldval, oldlenp,
1f29bcd7 1422 newval, newlen);
1da177e4
LT
1423 return error;
1424 }
1425 }
1426 return -ENOTDIR;
1427}
1428
1429/* Perform the actual read/write of a sysctl table entry. */
d8217f07 1430int do_sysctl_strategy (struct ctl_table *table,
1da177e4
LT
1431 int __user *name, int nlen,
1432 void __user *oldval, size_t __user *oldlenp,
1f29bcd7 1433 void __user *newval, size_t newlen)
1da177e4
LT
1434{
1435 int op = 0, rc;
1da177e4
LT
1436
1437 if (oldval)
1438 op |= 004;
1439 if (newval)
1440 op |= 002;
1ff007eb 1441 if (sysctl_perm(table, op))
1da177e4
LT
1442 return -EPERM;
1443
1444 if (table->strategy) {
1445 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1f29bcd7 1446 newval, newlen);
1da177e4
LT
1447 if (rc < 0)
1448 return rc;
1449 if (rc > 0)
1450 return 0;
1451 }
1452
1453 /* If there is no strategy routine, or if the strategy returns
1454 * zero, proceed with automatic r/w */
1455 if (table->data && table->maxlen) {
49a0c458
EB
1456 rc = sysctl_data(table, name, nlen, oldval, oldlenp,
1457 newval, newlen);
1458 if (rc < 0)
1459 return rc;
1da177e4
LT
1460 }
1461 return 0;
1462}
b89a8171 1463#endif /* CONFIG_SYSCTL_SYSCALL */
1da177e4 1464
d912b0cc
EB
1465static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1466{
1467 for (; table->ctl_name || table->procname; table++) {
1468 table->parent = parent;
1469 if (table->child)
1470 sysctl_set_parent(table, table->child);
1471 }
1472}
1473
1474static __init int sysctl_init(void)
1475{
fc6cd25b 1476 int err;
d912b0cc 1477 sysctl_set_parent(NULL, root_table);
fc6cd25b 1478 err = sysctl_check_table(root_table);
d912b0cc
EB
1479 return 0;
1480}
1481
1482core_initcall(sysctl_init);
1483
1da177e4
LT
1484/**
1485 * register_sysctl_table - register a sysctl hierarchy
1486 * @table: the top-level table structure
1da177e4
LT
1487 *
1488 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1489 * array. An entry with a ctl_name of 0 terminates the table.
1490 *
d8217f07 1491 * The members of the &struct ctl_table structure are used as follows:
1da177e4
LT
1492 *
1493 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1494 * must be unique within that level of sysctl
1495 *
1496 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1497 * enter a sysctl file
1498 *
1499 * data - a pointer to data for use by proc_handler
1500 *
1501 * maxlen - the maximum size in bytes of the data
1502 *
1503 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1504 *
1505 * child - a pointer to the child sysctl table if this entry is a directory, or
1506 * %NULL.
1507 *
1508 * proc_handler - the text handler routine (described below)
1509 *
1510 * strategy - the strategy routine (described below)
1511 *
1512 * de - for internal use by the sysctl routines
1513 *
1514 * extra1, extra2 - extra pointers usable by the proc handler routines
1515 *
1516 * Leaf nodes in the sysctl tree will be represented by a single file
1517 * under /proc; non-leaf nodes will be represented by directories.
1518 *
1519 * sysctl(2) can automatically manage read and write requests through
1520 * the sysctl table. The data and maxlen fields of the ctl_table
1521 * struct enable minimal validation of the values being written to be
1522 * performed, and the mode field allows minimal authentication.
1523 *
1524 * More sophisticated management can be enabled by the provision of a
1525 * strategy routine with the table entry. This will be called before
1526 * any automatic read or write of the data is performed.
1527 *
1528 * The strategy routine may return
1529 *
1530 * < 0 - Error occurred (error is passed to user process)
1531 *
1532 * 0 - OK - proceed with automatic read or write.
1533 *
1534 * > 0 - OK - read or write has been done by the strategy routine, so
1535 * return immediately.
1536 *
1537 * There must be a proc_handler routine for any terminal nodes
1538 * mirrored under /proc/sys (non-terminals are handled by a built-in
1539 * directory handler). Several default handlers are available to
1540 * cover common cases -
1541 *
1542 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1543 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1544 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1545 *
1546 * It is the handler's job to read the input buffer from user memory
1547 * and process it. The handler should return 0 on success.
1548 *
1549 * This routine returns %NULL on a failure to register, and a pointer
1550 * to the table header on success.
1551 */
d8217f07 1552struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
1da177e4
LT
1553{
1554 struct ctl_table_header *tmp;
1555 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1556 if (!tmp)
1557 return NULL;
1558 tmp->ctl_table = table;
1559 INIT_LIST_HEAD(&tmp->ctl_entry);
330d57fb
AV
1560 tmp->used = 0;
1561 tmp->unregistering = NULL;
d912b0cc 1562 sysctl_set_parent(NULL, table);
fc6cd25b
EB
1563 if (sysctl_check_table(tmp->ctl_table)) {
1564 kfree(tmp);
1565 return NULL;
1566 }
330d57fb 1567 spin_lock(&sysctl_lock);
0b4d4147 1568 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
330d57fb 1569 spin_unlock(&sysctl_lock);
1da177e4
LT
1570 return tmp;
1571}
1572
1573/**
1574 * unregister_sysctl_table - unregister a sysctl table hierarchy
1575 * @header: the header returned from register_sysctl_table
1576 *
1577 * Unregisters the sysctl table and all children. proc entries may not
1578 * actually be removed until they are no longer used by anyone.
1579 */
1580void unregister_sysctl_table(struct ctl_table_header * header)
1581{
330d57fb
AV
1582 might_sleep();
1583 spin_lock(&sysctl_lock);
1584 start_unregistering(header);
330d57fb 1585 spin_unlock(&sysctl_lock);
1da177e4
LT
1586 kfree(header);
1587}
1588
b89a8171 1589#else /* !CONFIG_SYSCTL */
d8217f07 1590struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
b89a8171
EB
1591{
1592 return NULL;
1593}
1594
1595void unregister_sysctl_table(struct ctl_table_header * table)
1596{
1597}
1598
1599#endif /* CONFIG_SYSCTL */
1600
1da177e4
LT
1601/*
1602 * /proc/sys support
1603 */
1604
b89a8171 1605#ifdef CONFIG_PROC_SYSCTL
1da177e4 1606
b1ba4ddd
AB
1607static int _proc_do_string(void* data, int maxlen, int write,
1608 struct file *filp, void __user *buffer,
1609 size_t *lenp, loff_t *ppos)
1da177e4
LT
1610{
1611 size_t len;
1612 char __user *p;
1613 char c;
8d060877
ON
1614
1615 if (!data || !maxlen || !*lenp) {
1da177e4
LT
1616 *lenp = 0;
1617 return 0;
1618 }
8d060877 1619
1da177e4
LT
1620 if (write) {
1621 len = 0;
1622 p = buffer;
1623 while (len < *lenp) {
1624 if (get_user(c, p++))
1625 return -EFAULT;
1626 if (c == 0 || c == '\n')
1627 break;
1628 len++;
1629 }
f5dd3d6f
SV
1630 if (len >= maxlen)
1631 len = maxlen-1;
1632 if(copy_from_user(data, buffer, len))
1da177e4 1633 return -EFAULT;
f5dd3d6f 1634 ((char *) data)[len] = 0;
1da177e4
LT
1635 *ppos += *lenp;
1636 } else {
f5dd3d6f
SV
1637 len = strlen(data);
1638 if (len > maxlen)
1639 len = maxlen;
8d060877
ON
1640
1641 if (*ppos > len) {
1642 *lenp = 0;
1643 return 0;
1644 }
1645
1646 data += *ppos;
1647 len -= *ppos;
1648
1da177e4
LT
1649 if (len > *lenp)
1650 len = *lenp;
1651 if (len)
f5dd3d6f 1652 if(copy_to_user(buffer, data, len))
1da177e4
LT
1653 return -EFAULT;
1654 if (len < *lenp) {
1655 if(put_user('\n', ((char __user *) buffer) + len))
1656 return -EFAULT;
1657 len++;
1658 }
1659 *lenp = len;
1660 *ppos += len;
1661 }
1662 return 0;
1663}
1664
f5dd3d6f
SV
1665/**
1666 * proc_dostring - read a string sysctl
1667 * @table: the sysctl table
1668 * @write: %TRUE if this is a write to the sysctl file
1669 * @filp: the file structure
1670 * @buffer: the user buffer
1671 * @lenp: the size of the user buffer
1672 * @ppos: file position
1673 *
1674 * Reads/writes a string from/to the user buffer. If the kernel
1675 * buffer provided is not large enough to hold the string, the
1676 * string is truncated. The copied string is %NULL-terminated.
1677 * If the string is being read by the user process, it is copied
1678 * and a newline '\n' is added. It is truncated if the buffer is
1679 * not large enough.
1680 *
1681 * Returns 0 on success.
1682 */
d8217f07 1683int proc_dostring(struct ctl_table *table, int write, struct file *filp,
f5dd3d6f
SV
1684 void __user *buffer, size_t *lenp, loff_t *ppos)
1685{
1686 return _proc_do_string(table->data, table->maxlen, write, filp,
1687 buffer, lenp, ppos);
1688}
1689
1da177e4
LT
1690
1691static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1692 int *valp,
1693 int write, void *data)
1694{
1695 if (write) {
1696 *valp = *negp ? -*lvalp : *lvalp;
1697 } else {
1698 int val = *valp;
1699 if (val < 0) {
1700 *negp = -1;
1701 *lvalp = (unsigned long)-val;
1702 } else {
1703 *negp = 0;
1704 *lvalp = (unsigned long)val;
1705 }
1706 }
1707 return 0;
1708}
1709
d8217f07 1710static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
fcfbd547
KK
1711 int write, struct file *filp, void __user *buffer,
1712 size_t *lenp, loff_t *ppos,
1da177e4
LT
1713 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1714 int write, void *data),
1715 void *data)
1716{
1717#define TMPBUFLEN 21
1718 int *i, vleft, first=1, neg, val;
1719 unsigned long lval;
1720 size_t left, len;
1721
1722 char buf[TMPBUFLEN], *p;
1723 char __user *s = buffer;
1724
fcfbd547 1725 if (!tbl_data || !table->maxlen || !*lenp ||
1da177e4
LT
1726 (*ppos && !write)) {
1727 *lenp = 0;
1728 return 0;
1729 }
1730
fcfbd547 1731 i = (int *) tbl_data;
1da177e4
LT
1732 vleft = table->maxlen / sizeof(*i);
1733 left = *lenp;
1734
1735 if (!conv)
1736 conv = do_proc_dointvec_conv;
1737
1738 for (; left && vleft--; i++, first=0) {
1739 if (write) {
1740 while (left) {
1741 char c;
1742 if (get_user(c, s))
1743 return -EFAULT;
1744 if (!isspace(c))
1745 break;
1746 left--;
1747 s++;
1748 }
1749 if (!left)
1750 break;
1751 neg = 0;
1752 len = left;
1753 if (len > sizeof(buf) - 1)
1754 len = sizeof(buf) - 1;
1755 if (copy_from_user(buf, s, len))
1756 return -EFAULT;
1757 buf[len] = 0;
1758 p = buf;
1759 if (*p == '-' && left > 1) {
1760 neg = 1;
bd9b0bac 1761 p++;
1da177e4
LT
1762 }
1763 if (*p < '0' || *p > '9')
1764 break;
1765
1766 lval = simple_strtoul(p, &p, 0);
1767
1768 len = p-buf;
1769 if ((len < left) && *p && !isspace(*p))
1770 break;
1771 if (neg)
1772 val = -val;
1773 s += len;
1774 left -= len;
1775
1776 if (conv(&neg, &lval, i, 1, data))
1777 break;
1778 } else {
1779 p = buf;
1780 if (!first)
1781 *p++ = '\t';
1782
1783 if (conv(&neg, &lval, i, 0, data))
1784 break;
1785
1786 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1787 len = strlen(buf);
1788 if (len > left)
1789 len = left;
1790 if(copy_to_user(s, buf, len))
1791 return -EFAULT;
1792 left -= len;
1793 s += len;
1794 }
1795 }
1796
1797 if (!write && !first && left) {
1798 if(put_user('\n', s))
1799 return -EFAULT;
1800 left--, s++;
1801 }
1802 if (write) {
1803 while (left) {
1804 char c;
1805 if (get_user(c, s++))
1806 return -EFAULT;
1807 if (!isspace(c))
1808 break;
1809 left--;
1810 }
1811 }
1812 if (write && first)
1813 return -EINVAL;
1814 *lenp -= left;
1815 *ppos += *lenp;
1816 return 0;
1817#undef TMPBUFLEN
1818}
1819
d8217f07 1820static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
fcfbd547
KK
1821 void __user *buffer, size_t *lenp, loff_t *ppos,
1822 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1823 int write, void *data),
1824 void *data)
1825{
1826 return __do_proc_dointvec(table->data, table, write, filp,
1827 buffer, lenp, ppos, conv, data);
1828}
1829
1da177e4
LT
1830/**
1831 * proc_dointvec - read a vector of integers
1832 * @table: the sysctl table
1833 * @write: %TRUE if this is a write to the sysctl file
1834 * @filp: the file structure
1835 * @buffer: the user buffer
1836 * @lenp: the size of the user buffer
1837 * @ppos: file position
1838 *
1839 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1840 * values from/to the user buffer, treated as an ASCII string.
1841 *
1842 * Returns 0 on success.
1843 */
d8217f07 1844int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
1da177e4
LT
1845 void __user *buffer, size_t *lenp, loff_t *ppos)
1846{
1847 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1848 NULL,NULL);
1849}
1850
1851#define OP_SET 0
1852#define OP_AND 1
34f5a398 1853#define OP_OR 2
1da177e4
LT
1854
1855static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1856 int *valp,
1857 int write, void *data)
1858{
1859 int op = *(int *)data;
1860 if (write) {
1861 int val = *negp ? -*lvalp : *lvalp;
1862 switch(op) {
1863 case OP_SET: *valp = val; break;
1864 case OP_AND: *valp &= val; break;
34f5a398 1865 case OP_OR: *valp |= val; break;
1da177e4
LT
1866 }
1867 } else {
1868 int val = *valp;
1869 if (val < 0) {
1870 *negp = -1;
1871 *lvalp = (unsigned long)-val;
1872 } else {
1873 *negp = 0;
1874 *lvalp = (unsigned long)val;
1875 }
1876 }
1877 return 0;
1878}
1879
72c2d582 1880#ifdef CONFIG_SECURITY_CAPABILITIES
1da177e4
LT
1881/*
1882 * init may raise the set.
1883 */
72c2d582 1884
d8217f07 1885int proc_dointvec_bset(struct ctl_table *table, int write, struct file *filp,
1da177e4
LT
1886 void __user *buffer, size_t *lenp, loff_t *ppos)
1887{
1888 int op;
1889
6ff1b442 1890 if (write && !capable(CAP_SYS_MODULE)) {
1da177e4
LT
1891 return -EPERM;
1892 }
1893
b460cbc5 1894 op = is_global_init(current) ? OP_SET : OP_AND;
1da177e4
LT
1895 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1896 do_proc_dointvec_bset_conv,&op);
1897}
72c2d582 1898#endif /* def CONFIG_SECURITY_CAPABILITIES */
1da177e4 1899
34f5a398
TT
1900/*
1901 * Taint values can only be increased
1902 */
d8217f07 1903static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp,
34f5a398
TT
1904 void __user *buffer, size_t *lenp, loff_t *ppos)
1905{
1906 int op;
1907
91fcd412 1908 if (write && !capable(CAP_SYS_ADMIN))
34f5a398
TT
1909 return -EPERM;
1910
1911 op = OP_OR;
1912 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1913 do_proc_dointvec_bset_conv,&op);
1914}
1915
1da177e4
LT
1916struct do_proc_dointvec_minmax_conv_param {
1917 int *min;
1918 int *max;
1919};
1920
1921static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1922 int *valp,
1923 int write, void *data)
1924{
1925 struct do_proc_dointvec_minmax_conv_param *param = data;
1926 if (write) {
1927 int val = *negp ? -*lvalp : *lvalp;
1928 if ((param->min && *param->min > val) ||
1929 (param->max && *param->max < val))
1930 return -EINVAL;
1931 *valp = val;
1932 } else {
1933 int val = *valp;
1934 if (val < 0) {
1935 *negp = -1;
1936 *lvalp = (unsigned long)-val;
1937 } else {
1938 *negp = 0;
1939 *lvalp = (unsigned long)val;
1940 }
1941 }
1942 return 0;
1943}
1944
1945/**
1946 * proc_dointvec_minmax - read a vector of integers with min/max values
1947 * @table: the sysctl table
1948 * @write: %TRUE if this is a write to the sysctl file
1949 * @filp: the file structure
1950 * @buffer: the user buffer
1951 * @lenp: the size of the user buffer
1952 * @ppos: file position
1953 *
1954 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1955 * values from/to the user buffer, treated as an ASCII string.
1956 *
1957 * This routine will ensure the values are within the range specified by
1958 * table->extra1 (min) and table->extra2 (max).
1959 *
1960 * Returns 0 on success.
1961 */
d8217f07 1962int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
1da177e4
LT
1963 void __user *buffer, size_t *lenp, loff_t *ppos)
1964{
1965 struct do_proc_dointvec_minmax_conv_param param = {
1966 .min = (int *) table->extra1,
1967 .max = (int *) table->extra2,
1968 };
1969 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
1970 do_proc_dointvec_minmax_conv, &param);
1971}
1972
d8217f07 1973static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
1da177e4
LT
1974 struct file *filp,
1975 void __user *buffer,
1976 size_t *lenp, loff_t *ppos,
1977 unsigned long convmul,
1978 unsigned long convdiv)
1979{
1980#define TMPBUFLEN 21
1981 unsigned long *i, *min, *max, val;
1982 int vleft, first=1, neg;
1983 size_t len, left;
1984 char buf[TMPBUFLEN], *p;
1985 char __user *s = buffer;
1986
fcfbd547 1987 if (!data || !table->maxlen || !*lenp ||
1da177e4
LT
1988 (*ppos && !write)) {
1989 *lenp = 0;
1990 return 0;
1991 }
1992
fcfbd547 1993 i = (unsigned long *) data;
1da177e4
LT
1994 min = (unsigned long *) table->extra1;
1995 max = (unsigned long *) table->extra2;
1996 vleft = table->maxlen / sizeof(unsigned long);
1997 left = *lenp;
1998
1999 for (; left && vleft--; i++, min++, max++, first=0) {
2000 if (write) {
2001 while (left) {
2002 char c;
2003 if (get_user(c, s))
2004 return -EFAULT;
2005 if (!isspace(c))
2006 break;
2007 left--;
2008 s++;
2009 }
2010 if (!left)
2011 break;
2012 neg = 0;
2013 len = left;
2014 if (len > TMPBUFLEN-1)
2015 len = TMPBUFLEN-1;
2016 if (copy_from_user(buf, s, len))
2017 return -EFAULT;
2018 buf[len] = 0;
2019 p = buf;
2020 if (*p == '-' && left > 1) {
2021 neg = 1;
bd9b0bac 2022 p++;
1da177e4
LT
2023 }
2024 if (*p < '0' || *p > '9')
2025 break;
2026 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2027 len = p-buf;
2028 if ((len < left) && *p && !isspace(*p))
2029 break;
2030 if (neg)
2031 val = -val;
2032 s += len;
2033 left -= len;
2034
2035 if(neg)
2036 continue;
2037 if ((min && val < *min) || (max && val > *max))
2038 continue;
2039 *i = val;
2040 } else {
2041 p = buf;
2042 if (!first)
2043 *p++ = '\t';
2044 sprintf(p, "%lu", convdiv * (*i) / convmul);
2045 len = strlen(buf);
2046 if (len > left)
2047 len = left;
2048 if(copy_to_user(s, buf, len))
2049 return -EFAULT;
2050 left -= len;
2051 s += len;
2052 }
2053 }
2054
2055 if (!write && !first && left) {
2056 if(put_user('\n', s))
2057 return -EFAULT;
2058 left--, s++;
2059 }
2060 if (write) {
2061 while (left) {
2062 char c;
2063 if (get_user(c, s++))
2064 return -EFAULT;
2065 if (!isspace(c))
2066 break;
2067 left--;
2068 }
2069 }
2070 if (write && first)
2071 return -EINVAL;
2072 *lenp -= left;
2073 *ppos += *lenp;
2074 return 0;
2075#undef TMPBUFLEN
2076}
2077
d8217f07 2078static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
fcfbd547
KK
2079 struct file *filp,
2080 void __user *buffer,
2081 size_t *lenp, loff_t *ppos,
2082 unsigned long convmul,
2083 unsigned long convdiv)
2084{
2085 return __do_proc_doulongvec_minmax(table->data, table, write,
2086 filp, buffer, lenp, ppos, convmul, convdiv);
2087}
2088
1da177e4
LT
2089/**
2090 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2091 * @table: the sysctl table
2092 * @write: %TRUE if this is a write to the sysctl file
2093 * @filp: the file structure
2094 * @buffer: the user buffer
2095 * @lenp: the size of the user buffer
2096 * @ppos: file position
2097 *
2098 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2099 * values from/to the user buffer, treated as an ASCII string.
2100 *
2101 * This routine will ensure the values are within the range specified by
2102 * table->extra1 (min) and table->extra2 (max).
2103 *
2104 * Returns 0 on success.
2105 */
d8217f07 2106int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
1da177e4
LT
2107 void __user *buffer, size_t *lenp, loff_t *ppos)
2108{
2109 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
2110}
2111
2112/**
2113 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2114 * @table: the sysctl table
2115 * @write: %TRUE if this is a write to the sysctl file
2116 * @filp: the file structure
2117 * @buffer: the user buffer
2118 * @lenp: the size of the user buffer
2119 * @ppos: file position
2120 *
2121 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2122 * values from/to the user buffer, treated as an ASCII string. The values
2123 * are treated as milliseconds, and converted to jiffies when they are stored.
2124 *
2125 * This routine will ensure the values are within the range specified by
2126 * table->extra1 (min) and table->extra2 (max).
2127 *
2128 * Returns 0 on success.
2129 */
d8217f07 2130int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1da177e4
LT
2131 struct file *filp,
2132 void __user *buffer,
2133 size_t *lenp, loff_t *ppos)
2134{
2135 return do_proc_doulongvec_minmax(table, write, filp, buffer,
2136 lenp, ppos, HZ, 1000l);
2137}
2138
2139
2140static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2141 int *valp,
2142 int write, void *data)
2143{
2144 if (write) {
cba9f33d
BS
2145 if (*lvalp > LONG_MAX / HZ)
2146 return 1;
1da177e4
LT
2147 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2148 } else {
2149 int val = *valp;
2150 unsigned long lval;
2151 if (val < 0) {
2152 *negp = -1;
2153 lval = (unsigned long)-val;
2154 } else {
2155 *negp = 0;
2156 lval = (unsigned long)val;
2157 }
2158 *lvalp = lval / HZ;
2159 }
2160 return 0;
2161}
2162
2163static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2164 int *valp,
2165 int write, void *data)
2166{
2167 if (write) {
cba9f33d
BS
2168 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2169 return 1;
1da177e4
LT
2170 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2171 } else {
2172 int val = *valp;
2173 unsigned long lval;
2174 if (val < 0) {
2175 *negp = -1;
2176 lval = (unsigned long)-val;
2177 } else {
2178 *negp = 0;
2179 lval = (unsigned long)val;
2180 }
2181 *lvalp = jiffies_to_clock_t(lval);
2182 }
2183 return 0;
2184}
2185
2186static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2187 int *valp,
2188 int write, void *data)
2189{
2190 if (write) {
2191 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2192 } else {
2193 int val = *valp;
2194 unsigned long lval;
2195 if (val < 0) {
2196 *negp = -1;
2197 lval = (unsigned long)-val;
2198 } else {
2199 *negp = 0;
2200 lval = (unsigned long)val;
2201 }
2202 *lvalp = jiffies_to_msecs(lval);
2203 }
2204 return 0;
2205}
2206
2207/**
2208 * proc_dointvec_jiffies - read a vector of integers as seconds
2209 * @table: the sysctl table
2210 * @write: %TRUE if this is a write to the sysctl file
2211 * @filp: the file structure
2212 * @buffer: the user buffer
2213 * @lenp: the size of the user buffer
2214 * @ppos: file position
2215 *
2216 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2217 * values from/to the user buffer, treated as an ASCII string.
2218 * The values read are assumed to be in seconds, and are converted into
2219 * jiffies.
2220 *
2221 * Returns 0 on success.
2222 */
d8217f07 2223int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
1da177e4
LT
2224 void __user *buffer, size_t *lenp, loff_t *ppos)
2225{
2226 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2227 do_proc_dointvec_jiffies_conv,NULL);
2228}
2229
2230/**
2231 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2232 * @table: the sysctl table
2233 * @write: %TRUE if this is a write to the sysctl file
2234 * @filp: the file structure
2235 * @buffer: the user buffer
2236 * @lenp: the size of the user buffer
1e5d5331 2237 * @ppos: pointer to the file position
1da177e4
LT
2238 *
2239 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2240 * values from/to the user buffer, treated as an ASCII string.
2241 * The values read are assumed to be in 1/USER_HZ seconds, and
2242 * are converted into jiffies.
2243 *
2244 * Returns 0 on success.
2245 */
d8217f07 2246int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
1da177e4
LT
2247 void __user *buffer, size_t *lenp, loff_t *ppos)
2248{
2249 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2250 do_proc_dointvec_userhz_jiffies_conv,NULL);
2251}
2252
2253/**
2254 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2255 * @table: the sysctl table
2256 * @write: %TRUE if this is a write to the sysctl file
2257 * @filp: the file structure
2258 * @buffer: the user buffer
2259 * @lenp: the size of the user buffer
67be2dd1
MW
2260 * @ppos: file position
2261 * @ppos: the current position in the file
1da177e4
LT
2262 *
2263 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2264 * values from/to the user buffer, treated as an ASCII string.
2265 * The values read are assumed to be in 1/1000 seconds, and
2266 * are converted into jiffies.
2267 *
2268 * Returns 0 on success.
2269 */
d8217f07 2270int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
1da177e4
LT
2271 void __user *buffer, size_t *lenp, loff_t *ppos)
2272{
2273 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2274 do_proc_dointvec_ms_jiffies_conv, NULL);
2275}
2276
d8217f07 2277static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
9ec52099
CLG
2278 void __user *buffer, size_t *lenp, loff_t *ppos)
2279{
2280 struct pid *new_pid;
2281 pid_t tmp;
2282 int r;
2283
b488893a 2284 tmp = pid_nr_ns(cad_pid, current->nsproxy->pid_ns);
9ec52099
CLG
2285
2286 r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
2287 lenp, ppos, NULL, NULL);
2288 if (r || !write)
2289 return r;
2290
2291 new_pid = find_get_pid(tmp);
2292 if (!new_pid)
2293 return -ESRCH;
2294
2295 put_pid(xchg(&cad_pid, new_pid));
2296 return 0;
2297}
2298
1da177e4
LT
2299#else /* CONFIG_PROC_FS */
2300
d8217f07 2301int proc_dostring(struct ctl_table *table, int write, struct file *filp,
1da177e4
LT
2302 void __user *buffer, size_t *lenp, loff_t *ppos)
2303{
2304 return -ENOSYS;
2305}
2306
d8217f07 2307int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
1da177e4
LT
2308 void __user *buffer, size_t *lenp, loff_t *ppos)
2309{
2310 return -ENOSYS;
2311}
2312
d8217f07 2313int proc_dointvec_bset(struct ctl_table *table, int write, struct file *filp,
1da177e4
LT
2314 void __user *buffer, size_t *lenp, loff_t *ppos)
2315{
2316 return -ENOSYS;
2317}
2318
d8217f07 2319int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
1da177e4
LT
2320 void __user *buffer, size_t *lenp, loff_t *ppos)
2321{
2322 return -ENOSYS;
2323}
2324
d8217f07 2325int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
1da177e4
LT
2326 void __user *buffer, size_t *lenp, loff_t *ppos)
2327{
2328 return -ENOSYS;
2329}
2330
d8217f07 2331int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
1da177e4
LT
2332 void __user *buffer, size_t *lenp, loff_t *ppos)
2333{
2334 return -ENOSYS;
2335}
2336
d8217f07 2337int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
1da177e4
LT
2338 void __user *buffer, size_t *lenp, loff_t *ppos)
2339{
2340 return -ENOSYS;
2341}
2342
d8217f07 2343int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
1da177e4
LT
2344 void __user *buffer, size_t *lenp, loff_t *ppos)
2345{
2346 return -ENOSYS;
2347}
2348
d8217f07 2349int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1da177e4
LT
2350 struct file *filp,
2351 void __user *buffer,
2352 size_t *lenp, loff_t *ppos)
2353{
2354 return -ENOSYS;
2355}
2356
2357
2358#endif /* CONFIG_PROC_FS */
2359
2360
b89a8171 2361#ifdef CONFIG_SYSCTL_SYSCALL
1da177e4
LT
2362/*
2363 * General sysctl support routines
2364 */
2365
49a0c458
EB
2366/* The generic sysctl data routine (used if no strategy routine supplied) */
2367int sysctl_data(struct ctl_table *table, int __user *name, int nlen,
2368 void __user *oldval, size_t __user *oldlenp,
2369 void __user *newval, size_t newlen)
2370{
2371 size_t len;
2372
2373 /* Get out of I don't have a variable */
2374 if (!table->data || !table->maxlen)
2375 return -ENOTDIR;
2376
2377 if (oldval && oldlenp) {
2378 if (get_user(len, oldlenp))
2379 return -EFAULT;
2380 if (len) {
2381 if (len > table->maxlen)
2382 len = table->maxlen;
2383 if (copy_to_user(oldval, table->data, len))
2384 return -EFAULT;
2385 if (put_user(len, oldlenp))
2386 return -EFAULT;
2387 }
2388 }
2389
2390 if (newval && newlen) {
2391 if (newlen > table->maxlen)
2392 newlen = table->maxlen;
2393
2394 if (copy_from_user(table->data, newval, newlen))
2395 return -EFAULT;
2396 }
2397 return 1;
2398}
2399
1da177e4 2400/* The generic string strategy routine: */
d8217f07 2401int sysctl_string(struct ctl_table *table, int __user *name, int nlen,
1da177e4 2402 void __user *oldval, size_t __user *oldlenp,
1f29bcd7 2403 void __user *newval, size_t newlen)
1da177e4 2404{
1da177e4
LT
2405 if (!table->data || !table->maxlen)
2406 return -ENOTDIR;
2407
2408 if (oldval && oldlenp) {
de9e007d
LT
2409 size_t bufsize;
2410 if (get_user(bufsize, oldlenp))
1da177e4 2411 return -EFAULT;
de9e007d
LT
2412 if (bufsize) {
2413 size_t len = strlen(table->data), copied;
2414
2415 /* This shouldn't trigger for a well-formed sysctl */
2416 if (len > table->maxlen)
1da177e4 2417 len = table->maxlen;
de9e007d
LT
2418
2419 /* Copy up to a max of bufsize-1 bytes of the string */
2420 copied = (len >= bufsize) ? bufsize - 1 : len;
2421
2422 if (copy_to_user(oldval, table->data, copied) ||
2423 put_user(0, (char __user *)(oldval + copied)))
1da177e4 2424 return -EFAULT;
de9e007d 2425 if (put_user(len, oldlenp))
1da177e4
LT
2426 return -EFAULT;
2427 }
2428 }
2429 if (newval && newlen) {
de9e007d 2430 size_t len = newlen;
1da177e4
LT
2431 if (len > table->maxlen)
2432 len = table->maxlen;
2433 if(copy_from_user(table->data, newval, len))
2434 return -EFAULT;
2435 if (len == table->maxlen)
2436 len--;
2437 ((char *) table->data)[len] = 0;
2438 }
82c9df82 2439 return 1;
1da177e4
LT
2440}
2441
2442/*
2443 * This function makes sure that all of the integers in the vector
2444 * are between the minimum and maximum values given in the arrays
2445 * table->extra1 and table->extra2, respectively.
2446 */
d8217f07 2447int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen,
1da177e4 2448 void __user *oldval, size_t __user *oldlenp,
1f29bcd7 2449 void __user *newval, size_t newlen)
1da177e4
LT
2450{
2451
2452 if (newval && newlen) {
2453 int __user *vec = (int __user *) newval;
2454 int *min = (int *) table->extra1;
2455 int *max = (int *) table->extra2;
2456 size_t length;
2457 int i;
2458
2459 if (newlen % sizeof(int) != 0)
2460 return -EINVAL;
2461
2462 if (!table->extra1 && !table->extra2)
2463 return 0;
2464
2465 if (newlen > table->maxlen)
2466 newlen = table->maxlen;
2467 length = newlen / sizeof(int);
2468
2469 for (i = 0; i < length; i++) {
2470 int value;
2471 if (get_user(value, vec + i))
2472 return -EFAULT;
2473 if (min && value < min[i])
2474 return -EINVAL;
2475 if (max && value > max[i])
2476 return -EINVAL;
2477 }
2478 }
2479 return 0;
2480}
2481
2482/* Strategy function to convert jiffies to seconds */
d8217f07 2483int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen,
1da177e4 2484 void __user *oldval, size_t __user *oldlenp,
1f29bcd7 2485 void __user *newval, size_t newlen)
1da177e4 2486{
3ee75ac3 2487 if (oldval && oldlenp) {
1da177e4 2488 size_t olen;
3ee75ac3
AD
2489
2490 if (get_user(olen, oldlenp))
2491 return -EFAULT;
2492 if (olen) {
2493 int val;
2494
2495 if (olen < sizeof(int))
2496 return -EINVAL;
2497
2498 val = *(int *)(table->data) / HZ;
2499 if (put_user(val, (int __user *)oldval))
2500 return -EFAULT;
2501 if (put_user(sizeof(int), oldlenp))
1da177e4 2502 return -EFAULT;
1da177e4 2503 }
1da177e4
LT
2504 }
2505 if (newval && newlen) {
2506 int new;
2507 if (newlen != sizeof(int))
2508 return -EINVAL;
2509 if (get_user(new, (int __user *)newval))
2510 return -EFAULT;
2511 *(int *)(table->data) = new*HZ;
2512 }
2513 return 1;
2514}
2515
2516/* Strategy function to convert jiffies to seconds */
d8217f07 2517int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen,
1da177e4 2518 void __user *oldval, size_t __user *oldlenp,
1f29bcd7 2519 void __user *newval, size_t newlen)
1da177e4 2520{
3ee75ac3 2521 if (oldval && oldlenp) {
1da177e4 2522 size_t olen;
3ee75ac3
AD
2523
2524 if (get_user(olen, oldlenp))
2525 return -EFAULT;
2526 if (olen) {
2527 int val;
2528
2529 if (olen < sizeof(int))
2530 return -EINVAL;
2531
2532 val = jiffies_to_msecs(*(int *)(table->data));
2533 if (put_user(val, (int __user *)oldval))
2534 return -EFAULT;
2535 if (put_user(sizeof(int), oldlenp))
1da177e4 2536 return -EFAULT;
1da177e4 2537 }
1da177e4
LT
2538 }
2539 if (newval && newlen) {
2540 int new;
2541 if (newlen != sizeof(int))
2542 return -EINVAL;
2543 if (get_user(new, (int __user *)newval))
2544 return -EFAULT;
2545 *(int *)(table->data) = msecs_to_jiffies(new);
2546 }
2547 return 1;
2548}
2549
c4b8b769 2550
c4b8b769 2551
b89a8171 2552#else /* CONFIG_SYSCTL_SYSCALL */
1da177e4
LT
2553
2554
2555asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2556{
0e009be8 2557 struct __sysctl_args tmp;
7058cb02 2558 int error;
0e009be8 2559
0e009be8
EB
2560 if (copy_from_user(&tmp, args, sizeof(tmp)))
2561 return -EFAULT;
0e009be8 2562
7058cb02 2563 error = deprecated_sysctl_warning(&tmp);
b89a8171 2564
7058cb02
EB
2565 /* If no error reading the parameters then just -ENOSYS ... */
2566 if (!error)
2567 error = -ENOSYS;
2568
2569 return error;
1da177e4
LT
2570}
2571
49a0c458
EB
2572int sysctl_data(struct ctl_table *table, int __user *name, int nlen,
2573 void __user *oldval, size_t __user *oldlenp,
2574 void __user *newval, size_t newlen)
2575{
2576 return -ENOSYS;
2577}
2578
d8217f07 2579int sysctl_string(struct ctl_table *table, int __user *name, int nlen,
1da177e4 2580 void __user *oldval, size_t __user *oldlenp,
1f29bcd7 2581 void __user *newval, size_t newlen)
1da177e4
LT
2582{
2583 return -ENOSYS;
2584}
2585
d8217f07 2586int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen,
1da177e4 2587 void __user *oldval, size_t __user *oldlenp,
1f29bcd7 2588 void __user *newval, size_t newlen)
1da177e4
LT
2589{
2590 return -ENOSYS;
2591}
2592
d8217f07 2593int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen,
1da177e4 2594 void __user *oldval, size_t __user *oldlenp,
1f29bcd7 2595 void __user *newval, size_t newlen)
1da177e4
LT
2596{
2597 return -ENOSYS;
2598}
2599
d8217f07 2600int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen,
1da177e4 2601 void __user *oldval, size_t __user *oldlenp,
1f29bcd7 2602 void __user *newval, size_t newlen)
1da177e4
LT
2603{
2604 return -ENOSYS;
2605}
2606
b89a8171 2607#endif /* CONFIG_SYSCTL_SYSCALL */
1da177e4 2608
7058cb02
EB
2609static int deprecated_sysctl_warning(struct __sysctl_args *args)
2610{
2611 static int msg_count;
2612 int name[CTL_MAXNAME];
2613 int i;
2614
2615 /* Read in the sysctl name for better debug message logging */
2616 for (i = 0; i < args->nlen; i++)
2617 if (get_user(name[i], args->name + i))
2618 return -EFAULT;
2619
2620 /* Ignore accesses to kernel.version */
2621 if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
2622 return 0;
2623
2624 if (msg_count < 5) {
2625 msg_count++;
2626 printk(KERN_INFO
2627 "warning: process `%s' used the deprecated sysctl "
2628 "system call with ", current->comm);
2629 for (i = 0; i < args->nlen; i++)
2630 printk("%d.", name[i]);
2631 printk("\n");
2632 }
2633 return 0;
2634}
2635
1da177e4
LT
2636/*
2637 * No sense putting this after each symbol definition, twice,
2638 * exception granted :-)
2639 */
2640EXPORT_SYMBOL(proc_dointvec);
2641EXPORT_SYMBOL(proc_dointvec_jiffies);
2642EXPORT_SYMBOL(proc_dointvec_minmax);
2643EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2644EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2645EXPORT_SYMBOL(proc_dostring);
2646EXPORT_SYMBOL(proc_doulongvec_minmax);
2647EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2648EXPORT_SYMBOL(register_sysctl_table);
2649EXPORT_SYMBOL(sysctl_intvec);
2650EXPORT_SYMBOL(sysctl_jiffies);
2651EXPORT_SYMBOL(sysctl_ms_jiffies);
2652EXPORT_SYMBOL(sysctl_string);
49a0c458 2653EXPORT_SYMBOL(sysctl_data);
1da177e4 2654EXPORT_SYMBOL(unregister_sysctl_table);