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