OMAP2xxx clock: fix broken cpu_mask code
[linux-ginger.git] / kernel / sysctl.c
blob4286b62b34a0a2d0f9a00f96ae2e8822647238bf
1 /*
2 * sysctl.c: General linux system control interface
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
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/vmstat.h>
47 #include <linux/nfs_fs.h>
48 #include <linux/acpi.h>
49 #include <linux/reboot.h>
50 #include <linux/ftrace.h>
51 #include <linux/slow-work.h>
53 #include <asm/uaccess.h>
54 #include <asm/processor.h>
56 #ifdef CONFIG_X86
57 #include <asm/nmi.h>
58 #include <asm/stacktrace.h>
59 #include <asm/io.h>
60 #endif
62 static int deprecated_sysctl_warning(struct __sysctl_args *args);
64 #if defined(CONFIG_SYSCTL)
66 /* External variables not in a header file. */
67 extern int C_A_D;
68 extern int print_fatal_signals;
69 extern int sysctl_overcommit_memory;
70 extern int sysctl_overcommit_ratio;
71 extern int sysctl_panic_on_oom;
72 extern int sysctl_oom_kill_allocating_task;
73 extern int sysctl_oom_dump_tasks;
74 extern int max_threads;
75 extern int core_uses_pid;
76 extern int suid_dumpable;
77 extern char core_pattern[];
78 extern int pid_max;
79 extern int min_free_kbytes;
80 extern int pid_max_min, pid_max_max;
81 extern int sysctl_drop_caches;
82 extern int percpu_pagelist_fraction;
83 extern int compat_log;
84 extern int latencytop_enabled;
85 extern int sysctl_nr_open_min, sysctl_nr_open_max;
86 #ifndef CONFIG_MMU
87 extern int sysctl_nr_trim_pages;
88 #endif
89 #ifdef CONFIG_RCU_TORTURE_TEST
90 extern int rcutorture_runnable;
91 #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
93 /* Constants used for minimum and maximum */
94 #ifdef CONFIG_DETECT_SOFTLOCKUP
95 static int sixty = 60;
96 static int neg_one = -1;
97 #endif
99 static int zero;
100 static int __maybe_unused one = 1;
101 static int __maybe_unused two = 2;
102 static unsigned long one_ul = 1;
103 static int one_hundred = 100;
104 static int one_thousand = 1000;
106 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
107 static int maxolduid = 65535;
108 static int minolduid;
109 static int min_percpu_pagelist_fract = 8;
111 static int ngroups_max = NGROUPS_MAX;
113 #ifdef CONFIG_MODULES
114 extern char modprobe_path[];
115 #endif
116 #ifdef CONFIG_CHR_DEV_SG
117 extern int sg_big_buff;
118 #endif
120 #ifdef CONFIG_SPARC
121 #include <asm/system.h>
122 #endif
124 #ifdef CONFIG_SPARC64
125 extern int sysctl_tsb_ratio;
126 #endif
128 #ifdef __hppa__
129 extern int pwrsw_enabled;
130 extern int unaligned_enabled;
131 #endif
133 #ifdef CONFIG_S390
134 #ifdef CONFIG_MATHEMU
135 extern int sysctl_ieee_emulation_warnings;
136 #endif
137 extern int sysctl_userprocess_debug;
138 extern int spin_retry;
139 #endif
141 #ifdef CONFIG_BSD_PROCESS_ACCT
142 extern int acct_parm[];
143 #endif
145 #ifdef CONFIG_IA64
146 extern int no_unaligned_warning;
147 extern int unaligned_dump_stack;
148 #endif
150 #ifdef CONFIG_RT_MUTEXES
151 extern int max_lock_depth;
152 #endif
154 #ifdef CONFIG_PROC_SYSCTL
155 static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
156 void __user *buffer, size_t *lenp, loff_t *ppos);
157 static int proc_taint(struct ctl_table *table, int write, struct file *filp,
158 void __user *buffer, size_t *lenp, loff_t *ppos);
159 #endif
161 static struct ctl_table root_table[];
162 static struct ctl_table_root sysctl_table_root;
163 static struct ctl_table_header root_table_header = {
164 .count = 1,
165 .ctl_table = root_table,
166 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
167 .root = &sysctl_table_root,
168 .set = &sysctl_table_root.default_set,
170 static struct ctl_table_root sysctl_table_root = {
171 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
172 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
175 static struct ctl_table kern_table[];
176 static struct ctl_table vm_table[];
177 static struct ctl_table fs_table[];
178 static struct ctl_table debug_table[];
179 static struct ctl_table dev_table[];
180 extern struct ctl_table random_table[];
181 #ifdef CONFIG_INOTIFY_USER
182 extern struct ctl_table inotify_table[];
183 #endif
184 #ifdef CONFIG_EPOLL
185 extern struct ctl_table epoll_table[];
186 #endif
188 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
189 int sysctl_legacy_va_layout;
190 #endif
192 extern int prove_locking;
193 extern int lock_stat;
195 /* The default sysctl tables: */
197 static struct ctl_table root_table[] = {
199 .ctl_name = CTL_KERN,
200 .procname = "kernel",
201 .mode = 0555,
202 .child = kern_table,
205 .ctl_name = CTL_VM,
206 .procname = "vm",
207 .mode = 0555,
208 .child = vm_table,
211 .ctl_name = CTL_FS,
212 .procname = "fs",
213 .mode = 0555,
214 .child = fs_table,
217 .ctl_name = CTL_DEBUG,
218 .procname = "debug",
219 .mode = 0555,
220 .child = debug_table,
223 .ctl_name = CTL_DEV,
224 .procname = "dev",
225 .mode = 0555,
226 .child = dev_table,
229 * NOTE: do not add new entries to this table unless you have read
230 * Documentation/sysctl/ctl_unnumbered.txt
232 { .ctl_name = 0 }
235 #ifdef CONFIG_SCHED_DEBUG
236 static int min_sched_granularity_ns = 100000; /* 100 usecs */
237 static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
238 static int min_wakeup_granularity_ns; /* 0 usecs */
239 static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
240 #endif
242 static struct ctl_table kern_table[] = {
243 #ifdef CONFIG_SCHED_DEBUG
245 .ctl_name = CTL_UNNUMBERED,
246 .procname = "sched_min_granularity_ns",
247 .data = &sysctl_sched_min_granularity,
248 .maxlen = sizeof(unsigned int),
249 .mode = 0644,
250 .proc_handler = &sched_nr_latency_handler,
251 .strategy = &sysctl_intvec,
252 .extra1 = &min_sched_granularity_ns,
253 .extra2 = &max_sched_granularity_ns,
256 .ctl_name = CTL_UNNUMBERED,
257 .procname = "sched_latency_ns",
258 .data = &sysctl_sched_latency,
259 .maxlen = sizeof(unsigned int),
260 .mode = 0644,
261 .proc_handler = &sched_nr_latency_handler,
262 .strategy = &sysctl_intvec,
263 .extra1 = &min_sched_granularity_ns,
264 .extra2 = &max_sched_granularity_ns,
267 .ctl_name = CTL_UNNUMBERED,
268 .procname = "sched_wakeup_granularity_ns",
269 .data = &sysctl_sched_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,
278 .ctl_name = CTL_UNNUMBERED,
279 .procname = "sched_shares_ratelimit",
280 .data = &sysctl_sched_shares_ratelimit,
281 .maxlen = sizeof(unsigned int),
282 .mode = 0644,
283 .proc_handler = &proc_dointvec,
286 .ctl_name = CTL_UNNUMBERED,
287 .procname = "sched_shares_thresh",
288 .data = &sysctl_sched_shares_thresh,
289 .maxlen = sizeof(unsigned int),
290 .mode = 0644,
291 .proc_handler = &proc_dointvec_minmax,
292 .strategy = &sysctl_intvec,
293 .extra1 = &zero,
296 .ctl_name = CTL_UNNUMBERED,
297 .procname = "sched_child_runs_first",
298 .data = &sysctl_sched_child_runs_first,
299 .maxlen = sizeof(unsigned int),
300 .mode = 0644,
301 .proc_handler = &proc_dointvec,
304 .ctl_name = CTL_UNNUMBERED,
305 .procname = "sched_features",
306 .data = &sysctl_sched_features,
307 .maxlen = sizeof(unsigned int),
308 .mode = 0644,
309 .proc_handler = &proc_dointvec,
312 .ctl_name = CTL_UNNUMBERED,
313 .procname = "sched_migration_cost",
314 .data = &sysctl_sched_migration_cost,
315 .maxlen = sizeof(unsigned int),
316 .mode = 0644,
317 .proc_handler = &proc_dointvec,
320 .ctl_name = CTL_UNNUMBERED,
321 .procname = "sched_nr_migrate",
322 .data = &sysctl_sched_nr_migrate,
323 .maxlen = sizeof(unsigned int),
324 .mode = 0644,
325 .proc_handler = &proc_dointvec,
327 #endif
329 .ctl_name = CTL_UNNUMBERED,
330 .procname = "sched_rt_period_us",
331 .data = &sysctl_sched_rt_period,
332 .maxlen = sizeof(unsigned int),
333 .mode = 0644,
334 .proc_handler = &sched_rt_handler,
337 .ctl_name = CTL_UNNUMBERED,
338 .procname = "sched_rt_runtime_us",
339 .data = &sysctl_sched_rt_runtime,
340 .maxlen = sizeof(int),
341 .mode = 0644,
342 .proc_handler = &sched_rt_handler,
345 .ctl_name = CTL_UNNUMBERED,
346 .procname = "sched_compat_yield",
347 .data = &sysctl_sched_compat_yield,
348 .maxlen = sizeof(unsigned int),
349 .mode = 0644,
350 .proc_handler = &proc_dointvec,
352 #ifdef CONFIG_PROVE_LOCKING
354 .ctl_name = CTL_UNNUMBERED,
355 .procname = "prove_locking",
356 .data = &prove_locking,
357 .maxlen = sizeof(int),
358 .mode = 0644,
359 .proc_handler = &proc_dointvec,
361 #endif
362 #ifdef CONFIG_LOCK_STAT
364 .ctl_name = CTL_UNNUMBERED,
365 .procname = "lock_stat",
366 .data = &lock_stat,
367 .maxlen = sizeof(int),
368 .mode = 0644,
369 .proc_handler = &proc_dointvec,
371 #endif
373 .ctl_name = KERN_PANIC,
374 .procname = "panic",
375 .data = &panic_timeout,
376 .maxlen = sizeof(int),
377 .mode = 0644,
378 .proc_handler = &proc_dointvec,
381 .ctl_name = KERN_CORE_USES_PID,
382 .procname = "core_uses_pid",
383 .data = &core_uses_pid,
384 .maxlen = sizeof(int),
385 .mode = 0644,
386 .proc_handler = &proc_dointvec,
389 .ctl_name = KERN_CORE_PATTERN,
390 .procname = "core_pattern",
391 .data = core_pattern,
392 .maxlen = CORENAME_MAX_SIZE,
393 .mode = 0644,
394 .proc_handler = &proc_dostring,
395 .strategy = &sysctl_string,
397 #ifdef CONFIG_PROC_SYSCTL
399 .procname = "tainted",
400 .maxlen = sizeof(long),
401 .mode = 0644,
402 .proc_handler = &proc_taint,
404 #endif
405 #ifdef CONFIG_LATENCYTOP
407 .procname = "latencytop",
408 .data = &latencytop_enabled,
409 .maxlen = sizeof(int),
410 .mode = 0644,
411 .proc_handler = &proc_dointvec,
413 #endif
414 #ifdef CONFIG_BLK_DEV_INITRD
416 .ctl_name = KERN_REALROOTDEV,
417 .procname = "real-root-dev",
418 .data = &real_root_dev,
419 .maxlen = sizeof(int),
420 .mode = 0644,
421 .proc_handler = &proc_dointvec,
423 #endif
425 .ctl_name = CTL_UNNUMBERED,
426 .procname = "print-fatal-signals",
427 .data = &print_fatal_signals,
428 .maxlen = sizeof(int),
429 .mode = 0644,
430 .proc_handler = &proc_dointvec,
432 #ifdef CONFIG_SPARC
434 .ctl_name = KERN_SPARC_REBOOT,
435 .procname = "reboot-cmd",
436 .data = reboot_command,
437 .maxlen = 256,
438 .mode = 0644,
439 .proc_handler = &proc_dostring,
440 .strategy = &sysctl_string,
443 .ctl_name = KERN_SPARC_STOP_A,
444 .procname = "stop-a",
445 .data = &stop_a_enabled,
446 .maxlen = sizeof (int),
447 .mode = 0644,
448 .proc_handler = &proc_dointvec,
451 .ctl_name = KERN_SPARC_SCONS_PWROFF,
452 .procname = "scons-poweroff",
453 .data = &scons_pwroff,
454 .maxlen = sizeof (int),
455 .mode = 0644,
456 .proc_handler = &proc_dointvec,
458 #endif
459 #ifdef CONFIG_SPARC64
461 .ctl_name = CTL_UNNUMBERED,
462 .procname = "tsb-ratio",
463 .data = &sysctl_tsb_ratio,
464 .maxlen = sizeof (int),
465 .mode = 0644,
466 .proc_handler = &proc_dointvec,
468 #endif
469 #ifdef __hppa__
471 .ctl_name = KERN_HPPA_PWRSW,
472 .procname = "soft-power",
473 .data = &pwrsw_enabled,
474 .maxlen = sizeof (int),
475 .mode = 0644,
476 .proc_handler = &proc_dointvec,
479 .ctl_name = KERN_HPPA_UNALIGNED,
480 .procname = "unaligned-trap",
481 .data = &unaligned_enabled,
482 .maxlen = sizeof (int),
483 .mode = 0644,
484 .proc_handler = &proc_dointvec,
486 #endif
488 .ctl_name = KERN_CTLALTDEL,
489 .procname = "ctrl-alt-del",
490 .data = &C_A_D,
491 .maxlen = sizeof(int),
492 .mode = 0644,
493 .proc_handler = &proc_dointvec,
495 #ifdef CONFIG_FUNCTION_TRACER
497 .ctl_name = CTL_UNNUMBERED,
498 .procname = "ftrace_enabled",
499 .data = &ftrace_enabled,
500 .maxlen = sizeof(int),
501 .mode = 0644,
502 .proc_handler = &ftrace_enable_sysctl,
504 #endif
505 #ifdef CONFIG_STACK_TRACER
507 .ctl_name = CTL_UNNUMBERED,
508 .procname = "stack_tracer_enabled",
509 .data = &stack_tracer_enabled,
510 .maxlen = sizeof(int),
511 .mode = 0644,
512 .proc_handler = &stack_trace_sysctl,
514 #endif
515 #ifdef CONFIG_TRACING
517 .ctl_name = CTL_UNNUMBERED,
518 .procname = "ftrace_dump_on_oops",
519 .data = &ftrace_dump_on_oops,
520 .maxlen = sizeof(int),
521 .mode = 0644,
522 .proc_handler = &proc_dointvec,
524 #endif
525 #ifdef CONFIG_MODULES
527 .ctl_name = KERN_MODPROBE,
528 .procname = "modprobe",
529 .data = &modprobe_path,
530 .maxlen = KMOD_PATH_LEN,
531 .mode = 0644,
532 .proc_handler = &proc_dostring,
533 .strategy = &sysctl_string,
535 #endif
536 #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
538 .ctl_name = KERN_HOTPLUG,
539 .procname = "hotplug",
540 .data = &uevent_helper,
541 .maxlen = UEVENT_HELPER_PATH_LEN,
542 .mode = 0644,
543 .proc_handler = &proc_dostring,
544 .strategy = &sysctl_string,
546 #endif
547 #ifdef CONFIG_CHR_DEV_SG
549 .ctl_name = KERN_SG_BIG_BUFF,
550 .procname = "sg-big-buff",
551 .data = &sg_big_buff,
552 .maxlen = sizeof (int),
553 .mode = 0444,
554 .proc_handler = &proc_dointvec,
556 #endif
557 #ifdef CONFIG_BSD_PROCESS_ACCT
559 .ctl_name = KERN_ACCT,
560 .procname = "acct",
561 .data = &acct_parm,
562 .maxlen = 3*sizeof(int),
563 .mode = 0644,
564 .proc_handler = &proc_dointvec,
566 #endif
567 #ifdef CONFIG_MAGIC_SYSRQ
569 .ctl_name = KERN_SYSRQ,
570 .procname = "sysrq",
571 .data = &__sysrq_enabled,
572 .maxlen = sizeof (int),
573 .mode = 0644,
574 .proc_handler = &proc_dointvec,
576 #endif
577 #ifdef CONFIG_PROC_SYSCTL
579 .procname = "cad_pid",
580 .data = NULL,
581 .maxlen = sizeof (int),
582 .mode = 0600,
583 .proc_handler = &proc_do_cad_pid,
585 #endif
587 .ctl_name = KERN_MAX_THREADS,
588 .procname = "threads-max",
589 .data = &max_threads,
590 .maxlen = sizeof(int),
591 .mode = 0644,
592 .proc_handler = &proc_dointvec,
595 .ctl_name = KERN_RANDOM,
596 .procname = "random",
597 .mode = 0555,
598 .child = random_table,
601 .ctl_name = KERN_OVERFLOWUID,
602 .procname = "overflowuid",
603 .data = &overflowuid,
604 .maxlen = sizeof(int),
605 .mode = 0644,
606 .proc_handler = &proc_dointvec_minmax,
607 .strategy = &sysctl_intvec,
608 .extra1 = &minolduid,
609 .extra2 = &maxolduid,
612 .ctl_name = KERN_OVERFLOWGID,
613 .procname = "overflowgid",
614 .data = &overflowgid,
615 .maxlen = sizeof(int),
616 .mode = 0644,
617 .proc_handler = &proc_dointvec_minmax,
618 .strategy = &sysctl_intvec,
619 .extra1 = &minolduid,
620 .extra2 = &maxolduid,
622 #ifdef CONFIG_S390
623 #ifdef CONFIG_MATHEMU
625 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
626 .procname = "ieee_emulation_warnings",
627 .data = &sysctl_ieee_emulation_warnings,
628 .maxlen = sizeof(int),
629 .mode = 0644,
630 .proc_handler = &proc_dointvec,
632 #endif
634 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
635 .procname = "userprocess_debug",
636 .data = &sysctl_userprocess_debug,
637 .maxlen = sizeof(int),
638 .mode = 0644,
639 .proc_handler = &proc_dointvec,
641 #endif
643 .ctl_name = KERN_PIDMAX,
644 .procname = "pid_max",
645 .data = &pid_max,
646 .maxlen = sizeof (int),
647 .mode = 0644,
648 .proc_handler = &proc_dointvec_minmax,
649 .strategy = sysctl_intvec,
650 .extra1 = &pid_max_min,
651 .extra2 = &pid_max_max,
654 .ctl_name = KERN_PANIC_ON_OOPS,
655 .procname = "panic_on_oops",
656 .data = &panic_on_oops,
657 .maxlen = sizeof(int),
658 .mode = 0644,
659 .proc_handler = &proc_dointvec,
661 #if defined CONFIG_PRINTK
663 .ctl_name = KERN_PRINTK,
664 .procname = "printk",
665 .data = &console_loglevel,
666 .maxlen = 4*sizeof(int),
667 .mode = 0644,
668 .proc_handler = &proc_dointvec,
671 .ctl_name = KERN_PRINTK_RATELIMIT,
672 .procname = "printk_ratelimit",
673 .data = &printk_ratelimit_state.interval,
674 .maxlen = sizeof(int),
675 .mode = 0644,
676 .proc_handler = &proc_dointvec_jiffies,
677 .strategy = &sysctl_jiffies,
680 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
681 .procname = "printk_ratelimit_burst",
682 .data = &printk_ratelimit_state.burst,
683 .maxlen = sizeof(int),
684 .mode = 0644,
685 .proc_handler = &proc_dointvec,
687 #endif
689 .ctl_name = KERN_NGROUPS_MAX,
690 .procname = "ngroups_max",
691 .data = &ngroups_max,
692 .maxlen = sizeof (int),
693 .mode = 0444,
694 .proc_handler = &proc_dointvec,
696 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
698 .ctl_name = KERN_UNKNOWN_NMI_PANIC,
699 .procname = "unknown_nmi_panic",
700 .data = &unknown_nmi_panic,
701 .maxlen = sizeof (int),
702 .mode = 0644,
703 .proc_handler = &proc_dointvec,
706 .procname = "nmi_watchdog",
707 .data = &nmi_watchdog_enabled,
708 .maxlen = sizeof (int),
709 .mode = 0644,
710 .proc_handler = &proc_nmi_enabled,
712 #endif
713 #if defined(CONFIG_X86)
715 .ctl_name = KERN_PANIC_ON_NMI,
716 .procname = "panic_on_unrecovered_nmi",
717 .data = &panic_on_unrecovered_nmi,
718 .maxlen = sizeof(int),
719 .mode = 0644,
720 .proc_handler = &proc_dointvec,
723 .ctl_name = KERN_BOOTLOADER_TYPE,
724 .procname = "bootloader_type",
725 .data = &bootloader_type,
726 .maxlen = sizeof (int),
727 .mode = 0444,
728 .proc_handler = &proc_dointvec,
731 .ctl_name = CTL_UNNUMBERED,
732 .procname = "kstack_depth_to_print",
733 .data = &kstack_depth_to_print,
734 .maxlen = sizeof(int),
735 .mode = 0644,
736 .proc_handler = &proc_dointvec,
739 .ctl_name = CTL_UNNUMBERED,
740 .procname = "io_delay_type",
741 .data = &io_delay_type,
742 .maxlen = sizeof(int),
743 .mode = 0644,
744 .proc_handler = &proc_dointvec,
746 #endif
747 #if defined(CONFIG_MMU)
749 .ctl_name = KERN_RANDOMIZE,
750 .procname = "randomize_va_space",
751 .data = &randomize_va_space,
752 .maxlen = sizeof(int),
753 .mode = 0644,
754 .proc_handler = &proc_dointvec,
756 #endif
757 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
759 .ctl_name = KERN_SPIN_RETRY,
760 .procname = "spin_retry",
761 .data = &spin_retry,
762 .maxlen = sizeof (int),
763 .mode = 0644,
764 .proc_handler = &proc_dointvec,
766 #endif
767 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
769 .procname = "acpi_video_flags",
770 .data = &acpi_realmode_flags,
771 .maxlen = sizeof (unsigned long),
772 .mode = 0644,
773 .proc_handler = &proc_doulongvec_minmax,
775 #endif
776 #ifdef CONFIG_IA64
778 .ctl_name = KERN_IA64_UNALIGNED,
779 .procname = "ignore-unaligned-usertrap",
780 .data = &no_unaligned_warning,
781 .maxlen = sizeof (int),
782 .mode = 0644,
783 .proc_handler = &proc_dointvec,
786 .ctl_name = CTL_UNNUMBERED,
787 .procname = "unaligned-dump-stack",
788 .data = &unaligned_dump_stack,
789 .maxlen = sizeof (int),
790 .mode = 0644,
791 .proc_handler = &proc_dointvec,
793 #endif
794 #ifdef CONFIG_DETECT_SOFTLOCKUP
796 .ctl_name = CTL_UNNUMBERED,
797 .procname = "softlockup_panic",
798 .data = &softlockup_panic,
799 .maxlen = sizeof(int),
800 .mode = 0644,
801 .proc_handler = &proc_dointvec_minmax,
802 .strategy = &sysctl_intvec,
803 .extra1 = &zero,
804 .extra2 = &one,
807 .ctl_name = CTL_UNNUMBERED,
808 .procname = "softlockup_thresh",
809 .data = &softlockup_thresh,
810 .maxlen = sizeof(int),
811 .mode = 0644,
812 .proc_handler = &proc_dosoftlockup_thresh,
813 .strategy = &sysctl_intvec,
814 .extra1 = &neg_one,
815 .extra2 = &sixty,
817 #endif
818 #ifdef CONFIG_DETECT_HUNG_TASK
820 .ctl_name = CTL_UNNUMBERED,
821 .procname = "hung_task_panic",
822 .data = &sysctl_hung_task_panic,
823 .maxlen = sizeof(int),
824 .mode = 0644,
825 .proc_handler = &proc_dointvec_minmax,
826 .strategy = &sysctl_intvec,
827 .extra1 = &zero,
828 .extra2 = &one,
831 .ctl_name = CTL_UNNUMBERED,
832 .procname = "hung_task_check_count",
833 .data = &sysctl_hung_task_check_count,
834 .maxlen = sizeof(unsigned long),
835 .mode = 0644,
836 .proc_handler = &proc_doulongvec_minmax,
837 .strategy = &sysctl_intvec,
840 .ctl_name = CTL_UNNUMBERED,
841 .procname = "hung_task_timeout_secs",
842 .data = &sysctl_hung_task_timeout_secs,
843 .maxlen = sizeof(unsigned long),
844 .mode = 0644,
845 .proc_handler = &proc_dohung_task_timeout_secs,
846 .strategy = &sysctl_intvec,
849 .ctl_name = CTL_UNNUMBERED,
850 .procname = "hung_task_warnings",
851 .data = &sysctl_hung_task_warnings,
852 .maxlen = sizeof(unsigned long),
853 .mode = 0644,
854 .proc_handler = &proc_doulongvec_minmax,
855 .strategy = &sysctl_intvec,
857 #endif
858 #ifdef CONFIG_COMPAT
860 .ctl_name = KERN_COMPAT_LOG,
861 .procname = "compat-log",
862 .data = &compat_log,
863 .maxlen = sizeof (int),
864 .mode = 0644,
865 .proc_handler = &proc_dointvec,
867 #endif
868 #ifdef CONFIG_RT_MUTEXES
870 .ctl_name = KERN_MAX_LOCK_DEPTH,
871 .procname = "max_lock_depth",
872 .data = &max_lock_depth,
873 .maxlen = sizeof(int),
874 .mode = 0644,
875 .proc_handler = &proc_dointvec,
877 #endif
879 .ctl_name = CTL_UNNUMBERED,
880 .procname = "poweroff_cmd",
881 .data = &poweroff_cmd,
882 .maxlen = POWEROFF_CMD_PATH_LEN,
883 .mode = 0644,
884 .proc_handler = &proc_dostring,
885 .strategy = &sysctl_string,
887 #ifdef CONFIG_KEYS
889 .ctl_name = CTL_UNNUMBERED,
890 .procname = "keys",
891 .mode = 0555,
892 .child = key_sysctls,
894 #endif
895 #ifdef CONFIG_RCU_TORTURE_TEST
897 .ctl_name = CTL_UNNUMBERED,
898 .procname = "rcutorture_runnable",
899 .data = &rcutorture_runnable,
900 .maxlen = sizeof(int),
901 .mode = 0644,
902 .proc_handler = &proc_dointvec,
904 #endif
905 #ifdef CONFIG_UNEVICTABLE_LRU
907 .ctl_name = CTL_UNNUMBERED,
908 .procname = "scan_unevictable_pages",
909 .data = &scan_unevictable_pages,
910 .maxlen = sizeof(scan_unevictable_pages),
911 .mode = 0644,
912 .proc_handler = &scan_unevictable_handler,
914 #endif
915 #ifdef CONFIG_SLOW_WORK
917 .ctl_name = CTL_UNNUMBERED,
918 .procname = "slow-work",
919 .mode = 0555,
920 .child = slow_work_sysctls,
922 #endif
924 * NOTE: do not add new entries to this table unless you have read
925 * Documentation/sysctl/ctl_unnumbered.txt
927 { .ctl_name = 0 }
930 static struct ctl_table vm_table[] = {
932 .ctl_name = VM_OVERCOMMIT_MEMORY,
933 .procname = "overcommit_memory",
934 .data = &sysctl_overcommit_memory,
935 .maxlen = sizeof(sysctl_overcommit_memory),
936 .mode = 0644,
937 .proc_handler = &proc_dointvec,
940 .ctl_name = VM_PANIC_ON_OOM,
941 .procname = "panic_on_oom",
942 .data = &sysctl_panic_on_oom,
943 .maxlen = sizeof(sysctl_panic_on_oom),
944 .mode = 0644,
945 .proc_handler = &proc_dointvec,
948 .ctl_name = CTL_UNNUMBERED,
949 .procname = "oom_kill_allocating_task",
950 .data = &sysctl_oom_kill_allocating_task,
951 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
952 .mode = 0644,
953 .proc_handler = &proc_dointvec,
956 .ctl_name = CTL_UNNUMBERED,
957 .procname = "oom_dump_tasks",
958 .data = &sysctl_oom_dump_tasks,
959 .maxlen = sizeof(sysctl_oom_dump_tasks),
960 .mode = 0644,
961 .proc_handler = &proc_dointvec,
964 .ctl_name = VM_OVERCOMMIT_RATIO,
965 .procname = "overcommit_ratio",
966 .data = &sysctl_overcommit_ratio,
967 .maxlen = sizeof(sysctl_overcommit_ratio),
968 .mode = 0644,
969 .proc_handler = &proc_dointvec,
972 .ctl_name = VM_PAGE_CLUSTER,
973 .procname = "page-cluster",
974 .data = &page_cluster,
975 .maxlen = sizeof(int),
976 .mode = 0644,
977 .proc_handler = &proc_dointvec,
980 .ctl_name = VM_DIRTY_BACKGROUND,
981 .procname = "dirty_background_ratio",
982 .data = &dirty_background_ratio,
983 .maxlen = sizeof(dirty_background_ratio),
984 .mode = 0644,
985 .proc_handler = &dirty_background_ratio_handler,
986 .strategy = &sysctl_intvec,
987 .extra1 = &zero,
988 .extra2 = &one_hundred,
991 .ctl_name = CTL_UNNUMBERED,
992 .procname = "dirty_background_bytes",
993 .data = &dirty_background_bytes,
994 .maxlen = sizeof(dirty_background_bytes),
995 .mode = 0644,
996 .proc_handler = &dirty_background_bytes_handler,
997 .strategy = &sysctl_intvec,
998 .extra1 = &one_ul,
1001 .ctl_name = VM_DIRTY_RATIO,
1002 .procname = "dirty_ratio",
1003 .data = &vm_dirty_ratio,
1004 .maxlen = sizeof(vm_dirty_ratio),
1005 .mode = 0644,
1006 .proc_handler = &dirty_ratio_handler,
1007 .strategy = &sysctl_intvec,
1008 .extra1 = &zero,
1009 .extra2 = &one_hundred,
1012 .ctl_name = CTL_UNNUMBERED,
1013 .procname = "dirty_bytes",
1014 .data = &vm_dirty_bytes,
1015 .maxlen = sizeof(vm_dirty_bytes),
1016 .mode = 0644,
1017 .proc_handler = &dirty_bytes_handler,
1018 .strategy = &sysctl_intvec,
1019 .extra1 = &one_ul,
1022 .procname = "dirty_writeback_centisecs",
1023 .data = &dirty_writeback_interval,
1024 .maxlen = sizeof(dirty_writeback_interval),
1025 .mode = 0644,
1026 .proc_handler = &dirty_writeback_centisecs_handler,
1029 .procname = "dirty_expire_centisecs",
1030 .data = &dirty_expire_interval,
1031 .maxlen = sizeof(dirty_expire_interval),
1032 .mode = 0644,
1033 .proc_handler = &proc_dointvec,
1036 .ctl_name = VM_NR_PDFLUSH_THREADS,
1037 .procname = "nr_pdflush_threads",
1038 .data = &nr_pdflush_threads,
1039 .maxlen = sizeof nr_pdflush_threads,
1040 .mode = 0444 /* read-only*/,
1041 .proc_handler = &proc_dointvec,
1044 .ctl_name = CTL_UNNUMBERED,
1045 .procname = "nr_pdflush_threads_min",
1046 .data = &nr_pdflush_threads_min,
1047 .maxlen = sizeof nr_pdflush_threads_min,
1048 .mode = 0644 /* read-write */,
1049 .proc_handler = &proc_dointvec_minmax,
1050 .strategy = &sysctl_intvec,
1051 .extra1 = &one,
1052 .extra2 = &nr_pdflush_threads_max,
1055 .ctl_name = CTL_UNNUMBERED,
1056 .procname = "nr_pdflush_threads_max",
1057 .data = &nr_pdflush_threads_max,
1058 .maxlen = sizeof nr_pdflush_threads_max,
1059 .mode = 0644 /* read-write */,
1060 .proc_handler = &proc_dointvec_minmax,
1061 .strategy = &sysctl_intvec,
1062 .extra1 = &nr_pdflush_threads_min,
1063 .extra2 = &one_thousand,
1066 .ctl_name = VM_SWAPPINESS,
1067 .procname = "swappiness",
1068 .data = &vm_swappiness,
1069 .maxlen = sizeof(vm_swappiness),
1070 .mode = 0644,
1071 .proc_handler = &proc_dointvec_minmax,
1072 .strategy = &sysctl_intvec,
1073 .extra1 = &zero,
1074 .extra2 = &one_hundred,
1076 #ifdef CONFIG_HUGETLB_PAGE
1078 .procname = "nr_hugepages",
1079 .data = NULL,
1080 .maxlen = sizeof(unsigned long),
1081 .mode = 0644,
1082 .proc_handler = &hugetlb_sysctl_handler,
1083 .extra1 = (void *)&hugetlb_zero,
1084 .extra2 = (void *)&hugetlb_infinity,
1087 .ctl_name = VM_HUGETLB_GROUP,
1088 .procname = "hugetlb_shm_group",
1089 .data = &sysctl_hugetlb_shm_group,
1090 .maxlen = sizeof(gid_t),
1091 .mode = 0644,
1092 .proc_handler = &proc_dointvec,
1095 .ctl_name = CTL_UNNUMBERED,
1096 .procname = "hugepages_treat_as_movable",
1097 .data = &hugepages_treat_as_movable,
1098 .maxlen = sizeof(int),
1099 .mode = 0644,
1100 .proc_handler = &hugetlb_treat_movable_handler,
1103 .ctl_name = CTL_UNNUMBERED,
1104 .procname = "nr_overcommit_hugepages",
1105 .data = NULL,
1106 .maxlen = sizeof(unsigned long),
1107 .mode = 0644,
1108 .proc_handler = &hugetlb_overcommit_handler,
1109 .extra1 = (void *)&hugetlb_zero,
1110 .extra2 = (void *)&hugetlb_infinity,
1112 #endif
1114 .ctl_name = VM_LOWMEM_RESERVE_RATIO,
1115 .procname = "lowmem_reserve_ratio",
1116 .data = &sysctl_lowmem_reserve_ratio,
1117 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1118 .mode = 0644,
1119 .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
1120 .strategy = &sysctl_intvec,
1123 .ctl_name = VM_DROP_PAGECACHE,
1124 .procname = "drop_caches",
1125 .data = &sysctl_drop_caches,
1126 .maxlen = sizeof(int),
1127 .mode = 0644,
1128 .proc_handler = drop_caches_sysctl_handler,
1129 .strategy = &sysctl_intvec,
1132 .ctl_name = VM_MIN_FREE_KBYTES,
1133 .procname = "min_free_kbytes",
1134 .data = &min_free_kbytes,
1135 .maxlen = sizeof(min_free_kbytes),
1136 .mode = 0644,
1137 .proc_handler = &min_free_kbytes_sysctl_handler,
1138 .strategy = &sysctl_intvec,
1139 .extra1 = &zero,
1142 .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
1143 .procname = "percpu_pagelist_fraction",
1144 .data = &percpu_pagelist_fraction,
1145 .maxlen = sizeof(percpu_pagelist_fraction),
1146 .mode = 0644,
1147 .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
1148 .strategy = &sysctl_intvec,
1149 .extra1 = &min_percpu_pagelist_fract,
1151 #ifdef CONFIG_MMU
1153 .ctl_name = VM_MAX_MAP_COUNT,
1154 .procname = "max_map_count",
1155 .data = &sysctl_max_map_count,
1156 .maxlen = sizeof(sysctl_max_map_count),
1157 .mode = 0644,
1158 .proc_handler = &proc_dointvec
1160 #else
1162 .ctl_name = CTL_UNNUMBERED,
1163 .procname = "nr_trim_pages",
1164 .data = &sysctl_nr_trim_pages,
1165 .maxlen = sizeof(sysctl_nr_trim_pages),
1166 .mode = 0644,
1167 .proc_handler = &proc_dointvec_minmax,
1168 .strategy = &sysctl_intvec,
1169 .extra1 = &zero,
1171 #endif
1173 .ctl_name = VM_LAPTOP_MODE,
1174 .procname = "laptop_mode",
1175 .data = &laptop_mode,
1176 .maxlen = sizeof(laptop_mode),
1177 .mode = 0644,
1178 .proc_handler = &proc_dointvec_jiffies,
1179 .strategy = &sysctl_jiffies,
1182 .ctl_name = VM_BLOCK_DUMP,
1183 .procname = "block_dump",
1184 .data = &block_dump,
1185 .maxlen = sizeof(block_dump),
1186 .mode = 0644,
1187 .proc_handler = &proc_dointvec,
1188 .strategy = &sysctl_intvec,
1189 .extra1 = &zero,
1192 .ctl_name = VM_VFS_CACHE_PRESSURE,
1193 .procname = "vfs_cache_pressure",
1194 .data = &sysctl_vfs_cache_pressure,
1195 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1196 .mode = 0644,
1197 .proc_handler = &proc_dointvec,
1198 .strategy = &sysctl_intvec,
1199 .extra1 = &zero,
1201 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1203 .ctl_name = VM_LEGACY_VA_LAYOUT,
1204 .procname = "legacy_va_layout",
1205 .data = &sysctl_legacy_va_layout,
1206 .maxlen = sizeof(sysctl_legacy_va_layout),
1207 .mode = 0644,
1208 .proc_handler = &proc_dointvec,
1209 .strategy = &sysctl_intvec,
1210 .extra1 = &zero,
1212 #endif
1213 #ifdef CONFIG_NUMA
1215 .ctl_name = VM_ZONE_RECLAIM_MODE,
1216 .procname = "zone_reclaim_mode",
1217 .data = &zone_reclaim_mode,
1218 .maxlen = sizeof(zone_reclaim_mode),
1219 .mode = 0644,
1220 .proc_handler = &proc_dointvec,
1221 .strategy = &sysctl_intvec,
1222 .extra1 = &zero,
1225 .ctl_name = VM_MIN_UNMAPPED,
1226 .procname = "min_unmapped_ratio",
1227 .data = &sysctl_min_unmapped_ratio,
1228 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1229 .mode = 0644,
1230 .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
1231 .strategy = &sysctl_intvec,
1232 .extra1 = &zero,
1233 .extra2 = &one_hundred,
1236 .ctl_name = VM_MIN_SLAB,
1237 .procname = "min_slab_ratio",
1238 .data = &sysctl_min_slab_ratio,
1239 .maxlen = sizeof(sysctl_min_slab_ratio),
1240 .mode = 0644,
1241 .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
1242 .strategy = &sysctl_intvec,
1243 .extra1 = &zero,
1244 .extra2 = &one_hundred,
1246 #endif
1247 #ifdef CONFIG_SMP
1249 .ctl_name = CTL_UNNUMBERED,
1250 .procname = "stat_interval",
1251 .data = &sysctl_stat_interval,
1252 .maxlen = sizeof(sysctl_stat_interval),
1253 .mode = 0644,
1254 .proc_handler = &proc_dointvec_jiffies,
1255 .strategy = &sysctl_jiffies,
1257 #endif
1258 #ifdef CONFIG_SECURITY
1260 .ctl_name = CTL_UNNUMBERED,
1261 .procname = "mmap_min_addr",
1262 .data = &mmap_min_addr,
1263 .maxlen = sizeof(unsigned long),
1264 .mode = 0644,
1265 .proc_handler = &proc_doulongvec_minmax,
1267 #endif
1268 #ifdef CONFIG_NUMA
1270 .ctl_name = CTL_UNNUMBERED,
1271 .procname = "numa_zonelist_order",
1272 .data = &numa_zonelist_order,
1273 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1274 .mode = 0644,
1275 .proc_handler = &numa_zonelist_order_handler,
1276 .strategy = &sysctl_string,
1278 #endif
1279 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1280 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1282 .ctl_name = VM_VDSO_ENABLED,
1283 .procname = "vdso_enabled",
1284 .data = &vdso_enabled,
1285 .maxlen = sizeof(vdso_enabled),
1286 .mode = 0644,
1287 .proc_handler = &proc_dointvec,
1288 .strategy = &sysctl_intvec,
1289 .extra1 = &zero,
1291 #endif
1292 #ifdef CONFIG_HIGHMEM
1294 .ctl_name = CTL_UNNUMBERED,
1295 .procname = "highmem_is_dirtyable",
1296 .data = &vm_highmem_is_dirtyable,
1297 .maxlen = sizeof(vm_highmem_is_dirtyable),
1298 .mode = 0644,
1299 .proc_handler = &proc_dointvec_minmax,
1300 .strategy = &sysctl_intvec,
1301 .extra1 = &zero,
1302 .extra2 = &one,
1304 #endif
1306 * NOTE: do not add new entries to this table unless you have read
1307 * Documentation/sysctl/ctl_unnumbered.txt
1309 { .ctl_name = 0 }
1312 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1313 static struct ctl_table binfmt_misc_table[] = {
1314 { .ctl_name = 0 }
1316 #endif
1318 static struct ctl_table fs_table[] = {
1320 .ctl_name = FS_NRINODE,
1321 .procname = "inode-nr",
1322 .data = &inodes_stat,
1323 .maxlen = 2*sizeof(int),
1324 .mode = 0444,
1325 .proc_handler = &proc_dointvec,
1328 .ctl_name = FS_STATINODE,
1329 .procname = "inode-state",
1330 .data = &inodes_stat,
1331 .maxlen = 7*sizeof(int),
1332 .mode = 0444,
1333 .proc_handler = &proc_dointvec,
1336 .procname = "file-nr",
1337 .data = &files_stat,
1338 .maxlen = 3*sizeof(int),
1339 .mode = 0444,
1340 .proc_handler = &proc_nr_files,
1343 .ctl_name = FS_MAXFILE,
1344 .procname = "file-max",
1345 .data = &files_stat.max_files,
1346 .maxlen = sizeof(int),
1347 .mode = 0644,
1348 .proc_handler = &proc_dointvec,
1351 .ctl_name = CTL_UNNUMBERED,
1352 .procname = "nr_open",
1353 .data = &sysctl_nr_open,
1354 .maxlen = sizeof(int),
1355 .mode = 0644,
1356 .proc_handler = &proc_dointvec_minmax,
1357 .extra1 = &sysctl_nr_open_min,
1358 .extra2 = &sysctl_nr_open_max,
1361 .ctl_name = FS_DENTRY,
1362 .procname = "dentry-state",
1363 .data = &dentry_stat,
1364 .maxlen = 6*sizeof(int),
1365 .mode = 0444,
1366 .proc_handler = &proc_dointvec,
1369 .ctl_name = FS_OVERFLOWUID,
1370 .procname = "overflowuid",
1371 .data = &fs_overflowuid,
1372 .maxlen = sizeof(int),
1373 .mode = 0644,
1374 .proc_handler = &proc_dointvec_minmax,
1375 .strategy = &sysctl_intvec,
1376 .extra1 = &minolduid,
1377 .extra2 = &maxolduid,
1380 .ctl_name = FS_OVERFLOWGID,
1381 .procname = "overflowgid",
1382 .data = &fs_overflowgid,
1383 .maxlen = sizeof(int),
1384 .mode = 0644,
1385 .proc_handler = &proc_dointvec_minmax,
1386 .strategy = &sysctl_intvec,
1387 .extra1 = &minolduid,
1388 .extra2 = &maxolduid,
1390 #ifdef CONFIG_FILE_LOCKING
1392 .ctl_name = FS_LEASES,
1393 .procname = "leases-enable",
1394 .data = &leases_enable,
1395 .maxlen = sizeof(int),
1396 .mode = 0644,
1397 .proc_handler = &proc_dointvec,
1399 #endif
1400 #ifdef CONFIG_DNOTIFY
1402 .ctl_name = FS_DIR_NOTIFY,
1403 .procname = "dir-notify-enable",
1404 .data = &dir_notify_enable,
1405 .maxlen = sizeof(int),
1406 .mode = 0644,
1407 .proc_handler = &proc_dointvec,
1409 #endif
1410 #ifdef CONFIG_MMU
1411 #ifdef CONFIG_FILE_LOCKING
1413 .ctl_name = FS_LEASE_TIME,
1414 .procname = "lease-break-time",
1415 .data = &lease_break_time,
1416 .maxlen = sizeof(int),
1417 .mode = 0644,
1418 .proc_handler = &proc_dointvec,
1420 #endif
1421 #ifdef CONFIG_AIO
1423 .procname = "aio-nr",
1424 .data = &aio_nr,
1425 .maxlen = sizeof(aio_nr),
1426 .mode = 0444,
1427 .proc_handler = &proc_doulongvec_minmax,
1430 .procname = "aio-max-nr",
1431 .data = &aio_max_nr,
1432 .maxlen = sizeof(aio_max_nr),
1433 .mode = 0644,
1434 .proc_handler = &proc_doulongvec_minmax,
1436 #endif /* CONFIG_AIO */
1437 #ifdef CONFIG_INOTIFY_USER
1439 .ctl_name = FS_INOTIFY,
1440 .procname = "inotify",
1441 .mode = 0555,
1442 .child = inotify_table,
1444 #endif
1445 #ifdef CONFIG_EPOLL
1447 .procname = "epoll",
1448 .mode = 0555,
1449 .child = epoll_table,
1451 #endif
1452 #endif
1454 .ctl_name = KERN_SETUID_DUMPABLE,
1455 .procname = "suid_dumpable",
1456 .data = &suid_dumpable,
1457 .maxlen = sizeof(int),
1458 .mode = 0644,
1459 .proc_handler = &proc_dointvec_minmax,
1460 .strategy = &sysctl_intvec,
1461 .extra1 = &zero,
1462 .extra2 = &two,
1464 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1466 .ctl_name = CTL_UNNUMBERED,
1467 .procname = "binfmt_misc",
1468 .mode = 0555,
1469 .child = binfmt_misc_table,
1471 #endif
1473 * NOTE: do not add new entries to this table unless you have read
1474 * Documentation/sysctl/ctl_unnumbered.txt
1476 { .ctl_name = 0 }
1479 static struct ctl_table debug_table[] = {
1480 #if defined(CONFIG_X86) || defined(CONFIG_PPC)
1482 .ctl_name = CTL_UNNUMBERED,
1483 .procname = "exception-trace",
1484 .data = &show_unhandled_signals,
1485 .maxlen = sizeof(int),
1486 .mode = 0644,
1487 .proc_handler = proc_dointvec
1489 #endif
1490 { .ctl_name = 0 }
1493 static struct ctl_table dev_table[] = {
1494 { .ctl_name = 0 }
1497 static DEFINE_SPINLOCK(sysctl_lock);
1499 /* called under sysctl_lock */
1500 static int use_table(struct ctl_table_header *p)
1502 if (unlikely(p->unregistering))
1503 return 0;
1504 p->used++;
1505 return 1;
1508 /* called under sysctl_lock */
1509 static void unuse_table(struct ctl_table_header *p)
1511 if (!--p->used)
1512 if (unlikely(p->unregistering))
1513 complete(p->unregistering);
1516 /* called under sysctl_lock, will reacquire if has to wait */
1517 static void start_unregistering(struct ctl_table_header *p)
1520 * if p->used is 0, nobody will ever touch that entry again;
1521 * we'll eliminate all paths to it before dropping sysctl_lock
1523 if (unlikely(p->used)) {
1524 struct completion wait;
1525 init_completion(&wait);
1526 p->unregistering = &wait;
1527 spin_unlock(&sysctl_lock);
1528 wait_for_completion(&wait);
1529 spin_lock(&sysctl_lock);
1530 } else {
1531 /* anything non-NULL; we'll never dereference it */
1532 p->unregistering = ERR_PTR(-EINVAL);
1535 * do not remove from the list until nobody holds it; walking the
1536 * list in do_sysctl() relies on that.
1538 list_del_init(&p->ctl_entry);
1541 void sysctl_head_get(struct ctl_table_header *head)
1543 spin_lock(&sysctl_lock);
1544 head->count++;
1545 spin_unlock(&sysctl_lock);
1548 void sysctl_head_put(struct ctl_table_header *head)
1550 spin_lock(&sysctl_lock);
1551 if (!--head->count)
1552 kfree(head);
1553 spin_unlock(&sysctl_lock);
1556 struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1558 if (!head)
1559 BUG();
1560 spin_lock(&sysctl_lock);
1561 if (!use_table(head))
1562 head = ERR_PTR(-ENOENT);
1563 spin_unlock(&sysctl_lock);
1564 return head;
1567 void sysctl_head_finish(struct ctl_table_header *head)
1569 if (!head)
1570 return;
1571 spin_lock(&sysctl_lock);
1572 unuse_table(head);
1573 spin_unlock(&sysctl_lock);
1576 static struct ctl_table_set *
1577 lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1579 struct ctl_table_set *set = &root->default_set;
1580 if (root->lookup)
1581 set = root->lookup(root, namespaces);
1582 return set;
1585 static struct list_head *
1586 lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1588 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1589 return &set->list;
1592 struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1593 struct ctl_table_header *prev)
1595 struct ctl_table_root *root;
1596 struct list_head *header_list;
1597 struct ctl_table_header *head;
1598 struct list_head *tmp;
1600 spin_lock(&sysctl_lock);
1601 if (prev) {
1602 head = prev;
1603 tmp = &prev->ctl_entry;
1604 unuse_table(prev);
1605 goto next;
1607 tmp = &root_table_header.ctl_entry;
1608 for (;;) {
1609 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1611 if (!use_table(head))
1612 goto next;
1613 spin_unlock(&sysctl_lock);
1614 return head;
1615 next:
1616 root = head->root;
1617 tmp = tmp->next;
1618 header_list = lookup_header_list(root, namespaces);
1619 if (tmp != header_list)
1620 continue;
1622 do {
1623 root = list_entry(root->root_list.next,
1624 struct ctl_table_root, root_list);
1625 if (root == &sysctl_table_root)
1626 goto out;
1627 header_list = lookup_header_list(root, namespaces);
1628 } while (list_empty(header_list));
1629 tmp = header_list->next;
1631 out:
1632 spin_unlock(&sysctl_lock);
1633 return NULL;
1636 struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1638 return __sysctl_head_next(current->nsproxy, prev);
1641 void register_sysctl_root(struct ctl_table_root *root)
1643 spin_lock(&sysctl_lock);
1644 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1645 spin_unlock(&sysctl_lock);
1648 #ifdef CONFIG_SYSCTL_SYSCALL
1649 /* Perform the actual read/write of a sysctl table entry. */
1650 static int do_sysctl_strategy(struct ctl_table_root *root,
1651 struct ctl_table *table,
1652 void __user *oldval, size_t __user *oldlenp,
1653 void __user *newval, size_t newlen)
1655 int op = 0, rc;
1657 if (oldval)
1658 op |= MAY_READ;
1659 if (newval)
1660 op |= MAY_WRITE;
1661 if (sysctl_perm(root, table, op))
1662 return -EPERM;
1664 if (table->strategy) {
1665 rc = table->strategy(table, oldval, oldlenp, newval, newlen);
1666 if (rc < 0)
1667 return rc;
1668 if (rc > 0)
1669 return 0;
1672 /* If there is no strategy routine, or if the strategy returns
1673 * zero, proceed with automatic r/w */
1674 if (table->data && table->maxlen) {
1675 rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
1676 if (rc < 0)
1677 return rc;
1679 return 0;
1682 static int parse_table(int __user *name, int nlen,
1683 void __user *oldval, size_t __user *oldlenp,
1684 void __user *newval, size_t newlen,
1685 struct ctl_table_root *root,
1686 struct ctl_table *table)
1688 int n;
1689 repeat:
1690 if (!nlen)
1691 return -ENOTDIR;
1692 if (get_user(n, name))
1693 return -EFAULT;
1694 for ( ; table->ctl_name || table->procname; table++) {
1695 if (!table->ctl_name)
1696 continue;
1697 if (n == table->ctl_name) {
1698 int error;
1699 if (table->child) {
1700 if (sysctl_perm(root, table, MAY_EXEC))
1701 return -EPERM;
1702 name++;
1703 nlen--;
1704 table = table->child;
1705 goto repeat;
1707 error = do_sysctl_strategy(root, table,
1708 oldval, oldlenp,
1709 newval, newlen);
1710 return error;
1713 return -ENOTDIR;
1716 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1717 void __user *newval, size_t newlen)
1719 struct ctl_table_header *head;
1720 int error = -ENOTDIR;
1722 if (nlen <= 0 || nlen >= CTL_MAXNAME)
1723 return -ENOTDIR;
1724 if (oldval) {
1725 int old_len;
1726 if (!oldlenp || get_user(old_len, oldlenp))
1727 return -EFAULT;
1730 for (head = sysctl_head_next(NULL); head;
1731 head = sysctl_head_next(head)) {
1732 error = parse_table(name, nlen, oldval, oldlenp,
1733 newval, newlen,
1734 head->root, head->ctl_table);
1735 if (error != -ENOTDIR) {
1736 sysctl_head_finish(head);
1737 break;
1740 return error;
1743 SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
1745 struct __sysctl_args tmp;
1746 int error;
1748 if (copy_from_user(&tmp, args, sizeof(tmp)))
1749 return -EFAULT;
1751 error = deprecated_sysctl_warning(&tmp);
1752 if (error)
1753 goto out;
1755 lock_kernel();
1756 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1757 tmp.newval, tmp.newlen);
1758 unlock_kernel();
1759 out:
1760 return error;
1762 #endif /* CONFIG_SYSCTL_SYSCALL */
1765 * sysctl_perm does NOT grant the superuser all rights automatically, because
1766 * some sysctl variables are readonly even to root.
1769 static int test_perm(int mode, int op)
1771 if (!current_euid())
1772 mode >>= 6;
1773 else if (in_egroup_p(0))
1774 mode >>= 3;
1775 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
1776 return 0;
1777 return -EACCES;
1780 int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
1782 int error;
1783 int mode;
1785 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
1786 if (error)
1787 return error;
1789 if (root->permissions)
1790 mode = root->permissions(root, current->nsproxy, table);
1791 else
1792 mode = table->mode;
1794 return test_perm(mode, op);
1797 static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1799 for (; table->ctl_name || table->procname; table++) {
1800 table->parent = parent;
1801 if (table->child)
1802 sysctl_set_parent(table, table->child);
1806 static __init int sysctl_init(void)
1808 sysctl_set_parent(NULL, root_table);
1809 #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1811 int err;
1812 err = sysctl_check_table(current->nsproxy, root_table);
1814 #endif
1815 return 0;
1818 core_initcall(sysctl_init);
1820 static struct ctl_table *is_branch_in(struct ctl_table *branch,
1821 struct ctl_table *table)
1823 struct ctl_table *p;
1824 const char *s = branch->procname;
1826 /* branch should have named subdirectory as its first element */
1827 if (!s || !branch->child)
1828 return NULL;
1830 /* ... and nothing else */
1831 if (branch[1].procname || branch[1].ctl_name)
1832 return NULL;
1834 /* table should contain subdirectory with the same name */
1835 for (p = table; p->procname || p->ctl_name; p++) {
1836 if (!p->child)
1837 continue;
1838 if (p->procname && strcmp(p->procname, s) == 0)
1839 return p;
1841 return NULL;
1844 /* see if attaching q to p would be an improvement */
1845 static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1847 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1848 struct ctl_table *next;
1849 int is_better = 0;
1850 int not_in_parent = !p->attached_by;
1852 while ((next = is_branch_in(by, to)) != NULL) {
1853 if (by == q->attached_by)
1854 is_better = 1;
1855 if (to == p->attached_by)
1856 not_in_parent = 1;
1857 by = by->child;
1858 to = next->child;
1861 if (is_better && not_in_parent) {
1862 q->attached_by = by;
1863 q->attached_to = to;
1864 q->parent = p;
1869 * __register_sysctl_paths - register a sysctl hierarchy
1870 * @root: List of sysctl headers to register on
1871 * @namespaces: Data to compute which lists of sysctl entries are visible
1872 * @path: The path to the directory the sysctl table is in.
1873 * @table: the top-level table structure
1875 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1876 * array. A completely 0 filled entry terminates the table.
1878 * The members of the &struct ctl_table structure are used as follows:
1880 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1881 * must be unique within that level of sysctl
1883 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1884 * enter a sysctl file
1886 * data - a pointer to data for use by proc_handler
1888 * maxlen - the maximum size in bytes of the data
1890 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1892 * child - a pointer to the child sysctl table if this entry is a directory, or
1893 * %NULL.
1895 * proc_handler - the text handler routine (described below)
1897 * strategy - the strategy routine (described below)
1899 * de - for internal use by the sysctl routines
1901 * extra1, extra2 - extra pointers usable by the proc handler routines
1903 * Leaf nodes in the sysctl tree will be represented by a single file
1904 * under /proc; non-leaf nodes will be represented by directories.
1906 * sysctl(2) can automatically manage read and write requests through
1907 * the sysctl table. The data and maxlen fields of the ctl_table
1908 * struct enable minimal validation of the values being written to be
1909 * performed, and the mode field allows minimal authentication.
1911 * More sophisticated management can be enabled by the provision of a
1912 * strategy routine with the table entry. This will be called before
1913 * any automatic read or write of the data is performed.
1915 * The strategy routine may return
1917 * < 0 - Error occurred (error is passed to user process)
1919 * 0 - OK - proceed with automatic read or write.
1921 * > 0 - OK - read or write has been done by the strategy routine, so
1922 * return immediately.
1924 * There must be a proc_handler routine for any terminal nodes
1925 * mirrored under /proc/sys (non-terminals are handled by a built-in
1926 * directory handler). Several default handlers are available to
1927 * cover common cases -
1929 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1930 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1931 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1933 * It is the handler's job to read the input buffer from user memory
1934 * and process it. The handler should return 0 on success.
1936 * This routine returns %NULL on a failure to register, and a pointer
1937 * to the table header on success.
1939 struct ctl_table_header *__register_sysctl_paths(
1940 struct ctl_table_root *root,
1941 struct nsproxy *namespaces,
1942 const struct ctl_path *path, struct ctl_table *table)
1944 struct ctl_table_header *header;
1945 struct ctl_table *new, **prevp;
1946 unsigned int n, npath;
1947 struct ctl_table_set *set;
1949 /* Count the path components */
1950 for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
1954 * For each path component, allocate a 2-element ctl_table array.
1955 * The first array element will be filled with the sysctl entry
1956 * for this, the second will be the sentinel (ctl_name == 0).
1958 * We allocate everything in one go so that we don't have to
1959 * worry about freeing additional memory in unregister_sysctl_table.
1961 header = kzalloc(sizeof(struct ctl_table_header) +
1962 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1963 if (!header)
1964 return NULL;
1966 new = (struct ctl_table *) (header + 1);
1968 /* Now connect the dots */
1969 prevp = &header->ctl_table;
1970 for (n = 0; n < npath; ++n, ++path) {
1971 /* Copy the procname */
1972 new->procname = path->procname;
1973 new->ctl_name = path->ctl_name;
1974 new->mode = 0555;
1976 *prevp = new;
1977 prevp = &new->child;
1979 new += 2;
1981 *prevp = table;
1982 header->ctl_table_arg = table;
1984 INIT_LIST_HEAD(&header->ctl_entry);
1985 header->used = 0;
1986 header->unregistering = NULL;
1987 header->root = root;
1988 sysctl_set_parent(NULL, header->ctl_table);
1989 header->count = 1;
1990 #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1991 if (sysctl_check_table(namespaces, header->ctl_table)) {
1992 kfree(header);
1993 return NULL;
1995 #endif
1996 spin_lock(&sysctl_lock);
1997 header->set = lookup_header_set(root, namespaces);
1998 header->attached_by = header->ctl_table;
1999 header->attached_to = root_table;
2000 header->parent = &root_table_header;
2001 for (set = header->set; set; set = set->parent) {
2002 struct ctl_table_header *p;
2003 list_for_each_entry(p, &set->list, ctl_entry) {
2004 if (p->unregistering)
2005 continue;
2006 try_attach(p, header);
2009 header->parent->count++;
2010 list_add_tail(&header->ctl_entry, &header->set->list);
2011 spin_unlock(&sysctl_lock);
2013 return header;
2017 * register_sysctl_table_path - register a sysctl table hierarchy
2018 * @path: The path to the directory the sysctl table is in.
2019 * @table: the top-level table structure
2021 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2022 * array. A completely 0 filled entry terminates the table.
2024 * See __register_sysctl_paths for more details.
2026 struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2027 struct ctl_table *table)
2029 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
2030 path, table);
2034 * register_sysctl_table - register a sysctl table hierarchy
2035 * @table: the top-level table structure
2037 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2038 * array. A completely 0 filled entry terminates the table.
2040 * See register_sysctl_paths for more details.
2042 struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
2044 static const struct ctl_path null_path[] = { {} };
2046 return register_sysctl_paths(null_path, table);
2050 * unregister_sysctl_table - unregister a sysctl table hierarchy
2051 * @header: the header returned from register_sysctl_table
2053 * Unregisters the sysctl table and all children. proc entries may not
2054 * actually be removed until they are no longer used by anyone.
2056 void unregister_sysctl_table(struct ctl_table_header * header)
2058 might_sleep();
2060 if (header == NULL)
2061 return;
2063 spin_lock(&sysctl_lock);
2064 start_unregistering(header);
2065 if (!--header->parent->count) {
2066 WARN_ON(1);
2067 kfree(header->parent);
2069 if (!--header->count)
2070 kfree(header);
2071 spin_unlock(&sysctl_lock);
2074 int sysctl_is_seen(struct ctl_table_header *p)
2076 struct ctl_table_set *set = p->set;
2077 int res;
2078 spin_lock(&sysctl_lock);
2079 if (p->unregistering)
2080 res = 0;
2081 else if (!set->is_seen)
2082 res = 1;
2083 else
2084 res = set->is_seen(set);
2085 spin_unlock(&sysctl_lock);
2086 return res;
2089 void setup_sysctl_set(struct ctl_table_set *p,
2090 struct ctl_table_set *parent,
2091 int (*is_seen)(struct ctl_table_set *))
2093 INIT_LIST_HEAD(&p->list);
2094 p->parent = parent ? parent : &sysctl_table_root.default_set;
2095 p->is_seen = is_seen;
2098 #else /* !CONFIG_SYSCTL */
2099 struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
2101 return NULL;
2104 struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2105 struct ctl_table *table)
2107 return NULL;
2110 void unregister_sysctl_table(struct ctl_table_header * table)
2114 void setup_sysctl_set(struct ctl_table_set *p,
2115 struct ctl_table_set *parent,
2116 int (*is_seen)(struct ctl_table_set *))
2120 void sysctl_head_put(struct ctl_table_header *head)
2124 #endif /* CONFIG_SYSCTL */
2127 * /proc/sys support
2130 #ifdef CONFIG_PROC_SYSCTL
2132 static int _proc_do_string(void* data, int maxlen, int write,
2133 struct file *filp, void __user *buffer,
2134 size_t *lenp, loff_t *ppos)
2136 size_t len;
2137 char __user *p;
2138 char c;
2140 if (!data || !maxlen || !*lenp) {
2141 *lenp = 0;
2142 return 0;
2145 if (write) {
2146 len = 0;
2147 p = buffer;
2148 while (len < *lenp) {
2149 if (get_user(c, p++))
2150 return -EFAULT;
2151 if (c == 0 || c == '\n')
2152 break;
2153 len++;
2155 if (len >= maxlen)
2156 len = maxlen-1;
2157 if(copy_from_user(data, buffer, len))
2158 return -EFAULT;
2159 ((char *) data)[len] = 0;
2160 *ppos += *lenp;
2161 } else {
2162 len = strlen(data);
2163 if (len > maxlen)
2164 len = maxlen;
2166 if (*ppos > len) {
2167 *lenp = 0;
2168 return 0;
2171 data += *ppos;
2172 len -= *ppos;
2174 if (len > *lenp)
2175 len = *lenp;
2176 if (len)
2177 if(copy_to_user(buffer, data, len))
2178 return -EFAULT;
2179 if (len < *lenp) {
2180 if(put_user('\n', ((char __user *) buffer) + len))
2181 return -EFAULT;
2182 len++;
2184 *lenp = len;
2185 *ppos += len;
2187 return 0;
2191 * proc_dostring - read a string sysctl
2192 * @table: the sysctl table
2193 * @write: %TRUE if this is a write to the sysctl file
2194 * @filp: the file structure
2195 * @buffer: the user buffer
2196 * @lenp: the size of the user buffer
2197 * @ppos: file position
2199 * Reads/writes a string from/to the user buffer. If the kernel
2200 * buffer provided is not large enough to hold the string, the
2201 * string is truncated. The copied string is %NULL-terminated.
2202 * If the string is being read by the user process, it is copied
2203 * and a newline '\n' is added. It is truncated if the buffer is
2204 * not large enough.
2206 * Returns 0 on success.
2208 int proc_dostring(struct ctl_table *table, int write, struct file *filp,
2209 void __user *buffer, size_t *lenp, loff_t *ppos)
2211 return _proc_do_string(table->data, table->maxlen, write, filp,
2212 buffer, lenp, ppos);
2216 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2217 int *valp,
2218 int write, void *data)
2220 if (write) {
2221 *valp = *negp ? -*lvalp : *lvalp;
2222 } else {
2223 int val = *valp;
2224 if (val < 0) {
2225 *negp = -1;
2226 *lvalp = (unsigned long)-val;
2227 } else {
2228 *negp = 0;
2229 *lvalp = (unsigned long)val;
2232 return 0;
2235 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
2236 int write, struct file *filp, void __user *buffer,
2237 size_t *lenp, loff_t *ppos,
2238 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2239 int write, void *data),
2240 void *data)
2242 #define TMPBUFLEN 21
2243 int *i, vleft, first=1, neg, val;
2244 unsigned long lval;
2245 size_t left, len;
2247 char buf[TMPBUFLEN], *p;
2248 char __user *s = buffer;
2250 if (!tbl_data || !table->maxlen || !*lenp ||
2251 (*ppos && !write)) {
2252 *lenp = 0;
2253 return 0;
2256 i = (int *) tbl_data;
2257 vleft = table->maxlen / sizeof(*i);
2258 left = *lenp;
2260 if (!conv)
2261 conv = do_proc_dointvec_conv;
2263 for (; left && vleft--; i++, first=0) {
2264 if (write) {
2265 while (left) {
2266 char c;
2267 if (get_user(c, s))
2268 return -EFAULT;
2269 if (!isspace(c))
2270 break;
2271 left--;
2272 s++;
2274 if (!left)
2275 break;
2276 neg = 0;
2277 len = left;
2278 if (len > sizeof(buf) - 1)
2279 len = sizeof(buf) - 1;
2280 if (copy_from_user(buf, s, len))
2281 return -EFAULT;
2282 buf[len] = 0;
2283 p = buf;
2284 if (*p == '-' && left > 1) {
2285 neg = 1;
2286 p++;
2288 if (*p < '0' || *p > '9')
2289 break;
2291 lval = simple_strtoul(p, &p, 0);
2293 len = p-buf;
2294 if ((len < left) && *p && !isspace(*p))
2295 break;
2296 if (neg)
2297 val = -val;
2298 s += len;
2299 left -= len;
2301 if (conv(&neg, &lval, i, 1, data))
2302 break;
2303 } else {
2304 p = buf;
2305 if (!first)
2306 *p++ = '\t';
2308 if (conv(&neg, &lval, i, 0, data))
2309 break;
2311 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2312 len = strlen(buf);
2313 if (len > left)
2314 len = left;
2315 if(copy_to_user(s, buf, len))
2316 return -EFAULT;
2317 left -= len;
2318 s += len;
2322 if (!write && !first && left) {
2323 if(put_user('\n', s))
2324 return -EFAULT;
2325 left--, s++;
2327 if (write) {
2328 while (left) {
2329 char c;
2330 if (get_user(c, s++))
2331 return -EFAULT;
2332 if (!isspace(c))
2333 break;
2334 left--;
2337 if (write && first)
2338 return -EINVAL;
2339 *lenp -= left;
2340 *ppos += *lenp;
2341 return 0;
2342 #undef TMPBUFLEN
2345 static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2346 void __user *buffer, size_t *lenp, loff_t *ppos,
2347 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2348 int write, void *data),
2349 void *data)
2351 return __do_proc_dointvec(table->data, table, write, filp,
2352 buffer, lenp, ppos, conv, data);
2356 * proc_dointvec - read a vector of integers
2357 * @table: the sysctl table
2358 * @write: %TRUE if this is a write to the sysctl file
2359 * @filp: the file structure
2360 * @buffer: the user buffer
2361 * @lenp: the size of the user buffer
2362 * @ppos: file position
2364 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2365 * values from/to the user buffer, treated as an ASCII string.
2367 * Returns 0 on success.
2369 int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2370 void __user *buffer, size_t *lenp, loff_t *ppos)
2372 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2373 NULL,NULL);
2377 * Taint values can only be increased
2378 * This means we can safely use a temporary.
2380 static int proc_taint(struct ctl_table *table, int write, struct file *filp,
2381 void __user *buffer, size_t *lenp, loff_t *ppos)
2383 struct ctl_table t;
2384 unsigned long tmptaint = get_taint();
2385 int err;
2387 if (write && !capable(CAP_SYS_ADMIN))
2388 return -EPERM;
2390 t = *table;
2391 t.data = &tmptaint;
2392 err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos);
2393 if (err < 0)
2394 return err;
2396 if (write) {
2398 * Poor man's atomic or. Not worth adding a primitive
2399 * to everyone's atomic.h for this
2401 int i;
2402 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2403 if ((tmptaint >> i) & 1)
2404 add_taint(i);
2408 return err;
2411 struct do_proc_dointvec_minmax_conv_param {
2412 int *min;
2413 int *max;
2416 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2417 int *valp,
2418 int write, void *data)
2420 struct do_proc_dointvec_minmax_conv_param *param = data;
2421 if (write) {
2422 int val = *negp ? -*lvalp : *lvalp;
2423 if ((param->min && *param->min > val) ||
2424 (param->max && *param->max < val))
2425 return -EINVAL;
2426 *valp = val;
2427 } else {
2428 int val = *valp;
2429 if (val < 0) {
2430 *negp = -1;
2431 *lvalp = (unsigned long)-val;
2432 } else {
2433 *negp = 0;
2434 *lvalp = (unsigned long)val;
2437 return 0;
2441 * proc_dointvec_minmax - read a vector of integers with min/max values
2442 * @table: the sysctl table
2443 * @write: %TRUE if this is a write to the sysctl file
2444 * @filp: the file structure
2445 * @buffer: the user buffer
2446 * @lenp: the size of the user buffer
2447 * @ppos: file position
2449 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2450 * values from/to the user buffer, treated as an ASCII string.
2452 * This routine will ensure the values are within the range specified by
2453 * table->extra1 (min) and table->extra2 (max).
2455 * Returns 0 on success.
2457 int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
2458 void __user *buffer, size_t *lenp, loff_t *ppos)
2460 struct do_proc_dointvec_minmax_conv_param param = {
2461 .min = (int *) table->extra1,
2462 .max = (int *) table->extra2,
2464 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2465 do_proc_dointvec_minmax_conv, &param);
2468 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
2469 struct file *filp,
2470 void __user *buffer,
2471 size_t *lenp, loff_t *ppos,
2472 unsigned long convmul,
2473 unsigned long convdiv)
2475 #define TMPBUFLEN 21
2476 unsigned long *i, *min, *max, val;
2477 int vleft, first=1, neg;
2478 size_t len, left;
2479 char buf[TMPBUFLEN], *p;
2480 char __user *s = buffer;
2482 if (!data || !table->maxlen || !*lenp ||
2483 (*ppos && !write)) {
2484 *lenp = 0;
2485 return 0;
2488 i = (unsigned long *) data;
2489 min = (unsigned long *) table->extra1;
2490 max = (unsigned long *) table->extra2;
2491 vleft = table->maxlen / sizeof(unsigned long);
2492 left = *lenp;
2494 for (; left && vleft--; i++, min++, max++, first=0) {
2495 if (write) {
2496 while (left) {
2497 char c;
2498 if (get_user(c, s))
2499 return -EFAULT;
2500 if (!isspace(c))
2501 break;
2502 left--;
2503 s++;
2505 if (!left)
2506 break;
2507 neg = 0;
2508 len = left;
2509 if (len > TMPBUFLEN-1)
2510 len = TMPBUFLEN-1;
2511 if (copy_from_user(buf, s, len))
2512 return -EFAULT;
2513 buf[len] = 0;
2514 p = buf;
2515 if (*p == '-' && left > 1) {
2516 neg = 1;
2517 p++;
2519 if (*p < '0' || *p > '9')
2520 break;
2521 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2522 len = p-buf;
2523 if ((len < left) && *p && !isspace(*p))
2524 break;
2525 if (neg)
2526 val = -val;
2527 s += len;
2528 left -= len;
2530 if(neg)
2531 continue;
2532 if ((min && val < *min) || (max && val > *max))
2533 continue;
2534 *i = val;
2535 } else {
2536 p = buf;
2537 if (!first)
2538 *p++ = '\t';
2539 sprintf(p, "%lu", convdiv * (*i) / convmul);
2540 len = strlen(buf);
2541 if (len > left)
2542 len = left;
2543 if(copy_to_user(s, buf, len))
2544 return -EFAULT;
2545 left -= len;
2546 s += len;
2550 if (!write && !first && left) {
2551 if(put_user('\n', s))
2552 return -EFAULT;
2553 left--, s++;
2555 if (write) {
2556 while (left) {
2557 char c;
2558 if (get_user(c, s++))
2559 return -EFAULT;
2560 if (!isspace(c))
2561 break;
2562 left--;
2565 if (write && first)
2566 return -EINVAL;
2567 *lenp -= left;
2568 *ppos += *lenp;
2569 return 0;
2570 #undef TMPBUFLEN
2573 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2574 struct file *filp,
2575 void __user *buffer,
2576 size_t *lenp, loff_t *ppos,
2577 unsigned long convmul,
2578 unsigned long convdiv)
2580 return __do_proc_doulongvec_minmax(table->data, table, write,
2581 filp, buffer, lenp, ppos, convmul, convdiv);
2585 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2586 * @table: the sysctl table
2587 * @write: %TRUE if this is a write to the sysctl file
2588 * @filp: the file structure
2589 * @buffer: the user buffer
2590 * @lenp: the size of the user buffer
2591 * @ppos: file position
2593 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2594 * values from/to the user buffer, treated as an ASCII string.
2596 * This routine will ensure the values are within the range specified by
2597 * table->extra1 (min) and table->extra2 (max).
2599 * Returns 0 on success.
2601 int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
2602 void __user *buffer, size_t *lenp, loff_t *ppos)
2604 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
2608 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2609 * @table: the sysctl table
2610 * @write: %TRUE if this is a write to the sysctl file
2611 * @filp: the file structure
2612 * @buffer: the user buffer
2613 * @lenp: the size of the user buffer
2614 * @ppos: file position
2616 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2617 * values from/to the user buffer, treated as an ASCII string. The values
2618 * are treated as milliseconds, and converted to jiffies when they are stored.
2620 * This routine will ensure the values are within the range specified by
2621 * table->extra1 (min) and table->extra2 (max).
2623 * Returns 0 on success.
2625 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2626 struct file *filp,
2627 void __user *buffer,
2628 size_t *lenp, loff_t *ppos)
2630 return do_proc_doulongvec_minmax(table, write, filp, buffer,
2631 lenp, ppos, HZ, 1000l);
2635 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2636 int *valp,
2637 int write, void *data)
2639 if (write) {
2640 if (*lvalp > LONG_MAX / HZ)
2641 return 1;
2642 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2643 } else {
2644 int val = *valp;
2645 unsigned long lval;
2646 if (val < 0) {
2647 *negp = -1;
2648 lval = (unsigned long)-val;
2649 } else {
2650 *negp = 0;
2651 lval = (unsigned long)val;
2653 *lvalp = lval / HZ;
2655 return 0;
2658 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2659 int *valp,
2660 int write, void *data)
2662 if (write) {
2663 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2664 return 1;
2665 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2666 } else {
2667 int val = *valp;
2668 unsigned long lval;
2669 if (val < 0) {
2670 *negp = -1;
2671 lval = (unsigned long)-val;
2672 } else {
2673 *negp = 0;
2674 lval = (unsigned long)val;
2676 *lvalp = jiffies_to_clock_t(lval);
2678 return 0;
2681 static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2682 int *valp,
2683 int write, void *data)
2685 if (write) {
2686 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2687 } else {
2688 int val = *valp;
2689 unsigned long lval;
2690 if (val < 0) {
2691 *negp = -1;
2692 lval = (unsigned long)-val;
2693 } else {
2694 *negp = 0;
2695 lval = (unsigned long)val;
2697 *lvalp = jiffies_to_msecs(lval);
2699 return 0;
2703 * proc_dointvec_jiffies - read a vector of integers as seconds
2704 * @table: the sysctl table
2705 * @write: %TRUE if this is a write to the sysctl file
2706 * @filp: the file structure
2707 * @buffer: the user buffer
2708 * @lenp: the size of the user buffer
2709 * @ppos: file position
2711 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2712 * values from/to the user buffer, treated as an ASCII string.
2713 * The values read are assumed to be in seconds, and are converted into
2714 * jiffies.
2716 * Returns 0 on success.
2718 int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
2719 void __user *buffer, size_t *lenp, loff_t *ppos)
2721 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2722 do_proc_dointvec_jiffies_conv,NULL);
2726 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2727 * @table: the sysctl table
2728 * @write: %TRUE if this is a write to the sysctl file
2729 * @filp: the file structure
2730 * @buffer: the user buffer
2731 * @lenp: the size of the user buffer
2732 * @ppos: pointer to the file position
2734 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2735 * values from/to the user buffer, treated as an ASCII string.
2736 * The values read are assumed to be in 1/USER_HZ seconds, and
2737 * are converted into jiffies.
2739 * Returns 0 on success.
2741 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
2742 void __user *buffer, size_t *lenp, loff_t *ppos)
2744 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2745 do_proc_dointvec_userhz_jiffies_conv,NULL);
2749 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2750 * @table: the sysctl table
2751 * @write: %TRUE if this is a write to the sysctl file
2752 * @filp: the file structure
2753 * @buffer: the user buffer
2754 * @lenp: the size of the user buffer
2755 * @ppos: file position
2756 * @ppos: the current position in the file
2758 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2759 * values from/to the user buffer, treated as an ASCII string.
2760 * The values read are assumed to be in 1/1000 seconds, and
2761 * are converted into jiffies.
2763 * Returns 0 on success.
2765 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
2766 void __user *buffer, size_t *lenp, loff_t *ppos)
2768 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2769 do_proc_dointvec_ms_jiffies_conv, NULL);
2772 static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
2773 void __user *buffer, size_t *lenp, loff_t *ppos)
2775 struct pid *new_pid;
2776 pid_t tmp;
2777 int r;
2779 tmp = pid_vnr(cad_pid);
2781 r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
2782 lenp, ppos, NULL, NULL);
2783 if (r || !write)
2784 return r;
2786 new_pid = find_get_pid(tmp);
2787 if (!new_pid)
2788 return -ESRCH;
2790 put_pid(xchg(&cad_pid, new_pid));
2791 return 0;
2794 #else /* CONFIG_PROC_FS */
2796 int proc_dostring(struct ctl_table *table, int write, struct file *filp,
2797 void __user *buffer, size_t *lenp, loff_t *ppos)
2799 return -ENOSYS;
2802 int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2803 void __user *buffer, size_t *lenp, loff_t *ppos)
2805 return -ENOSYS;
2808 int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
2809 void __user *buffer, size_t *lenp, loff_t *ppos)
2811 return -ENOSYS;
2814 int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
2815 void __user *buffer, size_t *lenp, loff_t *ppos)
2817 return -ENOSYS;
2820 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
2821 void __user *buffer, size_t *lenp, loff_t *ppos)
2823 return -ENOSYS;
2826 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
2827 void __user *buffer, size_t *lenp, loff_t *ppos)
2829 return -ENOSYS;
2832 int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
2833 void __user *buffer, size_t *lenp, loff_t *ppos)
2835 return -ENOSYS;
2838 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2839 struct file *filp,
2840 void __user *buffer,
2841 size_t *lenp, loff_t *ppos)
2843 return -ENOSYS;
2847 #endif /* CONFIG_PROC_FS */
2850 #ifdef CONFIG_SYSCTL_SYSCALL
2852 * General sysctl support routines
2855 /* The generic sysctl data routine (used if no strategy routine supplied) */
2856 int sysctl_data(struct ctl_table *table,
2857 void __user *oldval, size_t __user *oldlenp,
2858 void __user *newval, size_t newlen)
2860 size_t len;
2862 /* Get out of I don't have a variable */
2863 if (!table->data || !table->maxlen)
2864 return -ENOTDIR;
2866 if (oldval && oldlenp) {
2867 if (get_user(len, oldlenp))
2868 return -EFAULT;
2869 if (len) {
2870 if (len > table->maxlen)
2871 len = table->maxlen;
2872 if (copy_to_user(oldval, table->data, len))
2873 return -EFAULT;
2874 if (put_user(len, oldlenp))
2875 return -EFAULT;
2879 if (newval && newlen) {
2880 if (newlen > table->maxlen)
2881 newlen = table->maxlen;
2883 if (copy_from_user(table->data, newval, newlen))
2884 return -EFAULT;
2886 return 1;
2889 /* The generic string strategy routine: */
2890 int sysctl_string(struct ctl_table *table,
2891 void __user *oldval, size_t __user *oldlenp,
2892 void __user *newval, size_t newlen)
2894 if (!table->data || !table->maxlen)
2895 return -ENOTDIR;
2897 if (oldval && oldlenp) {
2898 size_t bufsize;
2899 if (get_user(bufsize, oldlenp))
2900 return -EFAULT;
2901 if (bufsize) {
2902 size_t len = strlen(table->data), copied;
2904 /* This shouldn't trigger for a well-formed sysctl */
2905 if (len > table->maxlen)
2906 len = table->maxlen;
2908 /* Copy up to a max of bufsize-1 bytes of the string */
2909 copied = (len >= bufsize) ? bufsize - 1 : len;
2911 if (copy_to_user(oldval, table->data, copied) ||
2912 put_user(0, (char __user *)(oldval + copied)))
2913 return -EFAULT;
2914 if (put_user(len, oldlenp))
2915 return -EFAULT;
2918 if (newval && newlen) {
2919 size_t len = newlen;
2920 if (len > table->maxlen)
2921 len = table->maxlen;
2922 if(copy_from_user(table->data, newval, len))
2923 return -EFAULT;
2924 if (len == table->maxlen)
2925 len--;
2926 ((char *) table->data)[len] = 0;
2928 return 1;
2932 * This function makes sure that all of the integers in the vector
2933 * are between the minimum and maximum values given in the arrays
2934 * table->extra1 and table->extra2, respectively.
2936 int sysctl_intvec(struct ctl_table *table,
2937 void __user *oldval, size_t __user *oldlenp,
2938 void __user *newval, size_t newlen)
2941 if (newval && newlen) {
2942 int __user *vec = (int __user *) newval;
2943 int *min = (int *) table->extra1;
2944 int *max = (int *) table->extra2;
2945 size_t length;
2946 int i;
2948 if (newlen % sizeof(int) != 0)
2949 return -EINVAL;
2951 if (!table->extra1 && !table->extra2)
2952 return 0;
2954 if (newlen > table->maxlen)
2955 newlen = table->maxlen;
2956 length = newlen / sizeof(int);
2958 for (i = 0; i < length; i++) {
2959 int value;
2960 if (get_user(value, vec + i))
2961 return -EFAULT;
2962 if (min && value < min[i])
2963 return -EINVAL;
2964 if (max && value > max[i])
2965 return -EINVAL;
2968 return 0;
2971 /* Strategy function to convert jiffies to seconds */
2972 int sysctl_jiffies(struct ctl_table *table,
2973 void __user *oldval, size_t __user *oldlenp,
2974 void __user *newval, size_t newlen)
2976 if (oldval && oldlenp) {
2977 size_t olen;
2979 if (get_user(olen, oldlenp))
2980 return -EFAULT;
2981 if (olen) {
2982 int val;
2984 if (olen < sizeof(int))
2985 return -EINVAL;
2987 val = *(int *)(table->data) / HZ;
2988 if (put_user(val, (int __user *)oldval))
2989 return -EFAULT;
2990 if (put_user(sizeof(int), oldlenp))
2991 return -EFAULT;
2994 if (newval && newlen) {
2995 int new;
2996 if (newlen != sizeof(int))
2997 return -EINVAL;
2998 if (get_user(new, (int __user *)newval))
2999 return -EFAULT;
3000 *(int *)(table->data) = new*HZ;
3002 return 1;
3005 /* Strategy function to convert jiffies to seconds */
3006 int sysctl_ms_jiffies(struct ctl_table *table,
3007 void __user *oldval, size_t __user *oldlenp,
3008 void __user *newval, size_t newlen)
3010 if (oldval && oldlenp) {
3011 size_t olen;
3013 if (get_user(olen, oldlenp))
3014 return -EFAULT;
3015 if (olen) {
3016 int val;
3018 if (olen < sizeof(int))
3019 return -EINVAL;
3021 val = jiffies_to_msecs(*(int *)(table->data));
3022 if (put_user(val, (int __user *)oldval))
3023 return -EFAULT;
3024 if (put_user(sizeof(int), oldlenp))
3025 return -EFAULT;
3028 if (newval && newlen) {
3029 int new;
3030 if (newlen != sizeof(int))
3031 return -EINVAL;
3032 if (get_user(new, (int __user *)newval))
3033 return -EFAULT;
3034 *(int *)(table->data) = msecs_to_jiffies(new);
3036 return 1;
3041 #else /* CONFIG_SYSCTL_SYSCALL */
3044 SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
3046 struct __sysctl_args tmp;
3047 int error;
3049 if (copy_from_user(&tmp, args, sizeof(tmp)))
3050 return -EFAULT;
3052 error = deprecated_sysctl_warning(&tmp);
3054 /* If no error reading the parameters then just -ENOSYS ... */
3055 if (!error)
3056 error = -ENOSYS;
3058 return error;
3061 int sysctl_data(struct ctl_table *table,
3062 void __user *oldval, size_t __user *oldlenp,
3063 void __user *newval, size_t newlen)
3065 return -ENOSYS;
3068 int sysctl_string(struct ctl_table *table,
3069 void __user *oldval, size_t __user *oldlenp,
3070 void __user *newval, size_t newlen)
3072 return -ENOSYS;
3075 int sysctl_intvec(struct ctl_table *table,
3076 void __user *oldval, size_t __user *oldlenp,
3077 void __user *newval, size_t newlen)
3079 return -ENOSYS;
3082 int sysctl_jiffies(struct ctl_table *table,
3083 void __user *oldval, size_t __user *oldlenp,
3084 void __user *newval, size_t newlen)
3086 return -ENOSYS;
3089 int sysctl_ms_jiffies(struct ctl_table *table,
3090 void __user *oldval, size_t __user *oldlenp,
3091 void __user *newval, size_t newlen)
3093 return -ENOSYS;
3096 #endif /* CONFIG_SYSCTL_SYSCALL */
3098 static int deprecated_sysctl_warning(struct __sysctl_args *args)
3100 static int msg_count;
3101 int name[CTL_MAXNAME];
3102 int i;
3104 /* Check args->nlen. */
3105 if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
3106 return -ENOTDIR;
3108 /* Read in the sysctl name for better debug message logging */
3109 for (i = 0; i < args->nlen; i++)
3110 if (get_user(name[i], args->name + i))
3111 return -EFAULT;
3113 /* Ignore accesses to kernel.version */
3114 if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
3115 return 0;
3117 if (msg_count < 5) {
3118 msg_count++;
3119 printk(KERN_INFO
3120 "warning: process `%s' used the deprecated sysctl "
3121 "system call with ", current->comm);
3122 for (i = 0; i < args->nlen; i++)
3123 printk("%d.", name[i]);
3124 printk("\n");
3126 return 0;
3130 * No sense putting this after each symbol definition, twice,
3131 * exception granted :-)
3133 EXPORT_SYMBOL(proc_dointvec);
3134 EXPORT_SYMBOL(proc_dointvec_jiffies);
3135 EXPORT_SYMBOL(proc_dointvec_minmax);
3136 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3137 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3138 EXPORT_SYMBOL(proc_dostring);
3139 EXPORT_SYMBOL(proc_doulongvec_minmax);
3140 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3141 EXPORT_SYMBOL(register_sysctl_table);
3142 EXPORT_SYMBOL(register_sysctl_paths);
3143 EXPORT_SYMBOL(sysctl_intvec);
3144 EXPORT_SYMBOL(sysctl_jiffies);
3145 EXPORT_SYMBOL(sysctl_ms_jiffies);
3146 EXPORT_SYMBOL(sysctl_string);
3147 EXPORT_SYMBOL(sysctl_data);
3148 EXPORT_SYMBOL(unregister_sysctl_table);