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