tmio_mmc: map SD control registers after enabling the MFD cell
[linux-2.6/mini2440.git] / kernel / sysctl.c
blobce664f98e3fb67d7741182b9bce3fd29f4b8b88f
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>
52 #include <linux/perf_counter.h>
54 #include <asm/uaccess.h>
55 #include <asm/processor.h>
57 #ifdef CONFIG_X86
58 #include <asm/nmi.h>
59 #include <asm/stacktrace.h>
60 #include <asm/io.h>
61 #endif
63 static int deprecated_sysctl_warning(struct __sysctl_args *args);
65 #if defined(CONFIG_SYSCTL)
67 /* External variables not in a header file. */
68 extern int C_A_D;
69 extern int print_fatal_signals;
70 extern int sysctl_overcommit_memory;
71 extern int sysctl_overcommit_ratio;
72 extern int sysctl_panic_on_oom;
73 extern int sysctl_oom_kill_allocating_task;
74 extern int sysctl_oom_dump_tasks;
75 extern int max_threads;
76 extern int core_uses_pid;
77 extern int suid_dumpable;
78 extern char core_pattern[];
79 extern int pid_max;
80 extern int min_free_kbytes;
81 extern int pid_max_min, pid_max_max;
82 extern int sysctl_drop_caches;
83 extern int percpu_pagelist_fraction;
84 extern int compat_log;
85 extern int latencytop_enabled;
86 extern int sysctl_nr_open_min, sysctl_nr_open_max;
87 #ifndef CONFIG_MMU
88 extern int sysctl_nr_trim_pages;
89 #endif
90 #ifdef CONFIG_RCU_TORTURE_TEST
91 extern int rcutorture_runnable;
92 #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
94 /* Constants used for minimum and maximum */
95 #ifdef CONFIG_DETECT_SOFTLOCKUP
96 static int sixty = 60;
97 static int neg_one = -1;
98 #endif
100 static int zero;
101 static int __maybe_unused one = 1;
102 static int __maybe_unused two = 2;
103 static unsigned long one_ul = 1;
104 static int one_hundred = 100;
106 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
107 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
109 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
110 static int maxolduid = 65535;
111 static int minolduid;
112 static int min_percpu_pagelist_fract = 8;
114 static int ngroups_max = NGROUPS_MAX;
116 #ifdef CONFIG_MODULES
117 extern char modprobe_path[];
118 extern int modules_disabled;
119 #endif
120 #ifdef CONFIG_CHR_DEV_SG
121 extern int sg_big_buff;
122 #endif
124 #ifdef CONFIG_SPARC
125 #include <asm/system.h>
126 #endif
128 #ifdef CONFIG_SPARC64
129 extern int sysctl_tsb_ratio;
130 #endif
132 #ifdef __hppa__
133 extern int pwrsw_enabled;
134 extern int unaligned_enabled;
135 #endif
137 #ifdef CONFIG_S390
138 #ifdef CONFIG_MATHEMU
139 extern int sysctl_ieee_emulation_warnings;
140 #endif
141 extern int sysctl_userprocess_debug;
142 extern int spin_retry;
143 #endif
145 #ifdef CONFIG_BSD_PROCESS_ACCT
146 extern int acct_parm[];
147 #endif
149 #ifdef CONFIG_IA64
150 extern int no_unaligned_warning;
151 extern int unaligned_dump_stack;
152 #endif
154 #ifdef CONFIG_RT_MUTEXES
155 extern int max_lock_depth;
156 #endif
158 #ifdef CONFIG_PROC_SYSCTL
159 static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
160 void __user *buffer, size_t *lenp, loff_t *ppos);
161 static int proc_taint(struct ctl_table *table, int write, struct file *filp,
162 void __user *buffer, size_t *lenp, loff_t *ppos);
163 #endif
165 static struct ctl_table root_table[];
166 static struct ctl_table_root sysctl_table_root;
167 static struct ctl_table_header root_table_header = {
168 .count = 1,
169 .ctl_table = root_table,
170 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
171 .root = &sysctl_table_root,
172 .set = &sysctl_table_root.default_set,
174 static struct ctl_table_root sysctl_table_root = {
175 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
176 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
179 static struct ctl_table kern_table[];
180 static struct ctl_table vm_table[];
181 static struct ctl_table fs_table[];
182 static struct ctl_table debug_table[];
183 static struct ctl_table dev_table[];
184 extern struct ctl_table random_table[];
185 #ifdef CONFIG_INOTIFY_USER
186 extern struct ctl_table inotify_table[];
187 #endif
188 #ifdef CONFIG_EPOLL
189 extern struct ctl_table epoll_table[];
190 #endif
192 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
193 int sysctl_legacy_va_layout;
194 #endif
196 extern int prove_locking;
197 extern int lock_stat;
199 /* The default sysctl tables: */
201 static struct ctl_table root_table[] = {
203 .ctl_name = CTL_KERN,
204 .procname = "kernel",
205 .mode = 0555,
206 .child = kern_table,
209 .ctl_name = CTL_VM,
210 .procname = "vm",
211 .mode = 0555,
212 .child = vm_table,
215 .ctl_name = CTL_FS,
216 .procname = "fs",
217 .mode = 0555,
218 .child = fs_table,
221 .ctl_name = CTL_DEBUG,
222 .procname = "debug",
223 .mode = 0555,
224 .child = debug_table,
227 .ctl_name = CTL_DEV,
228 .procname = "dev",
229 .mode = 0555,
230 .child = dev_table,
233 * NOTE: do not add new entries to this table unless you have read
234 * Documentation/sysctl/ctl_unnumbered.txt
236 { .ctl_name = 0 }
239 #ifdef CONFIG_SCHED_DEBUG
240 static int min_sched_granularity_ns = 100000; /* 100 usecs */
241 static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
242 static int min_wakeup_granularity_ns; /* 0 usecs */
243 static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
244 #endif
246 static struct ctl_table kern_table[] = {
247 #ifdef CONFIG_SCHED_DEBUG
249 .ctl_name = CTL_UNNUMBERED,
250 .procname = "sched_min_granularity_ns",
251 .data = &sysctl_sched_min_granularity,
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,
260 .ctl_name = CTL_UNNUMBERED,
261 .procname = "sched_latency_ns",
262 .data = &sysctl_sched_latency,
263 .maxlen = sizeof(unsigned int),
264 .mode = 0644,
265 .proc_handler = &sched_nr_latency_handler,
266 .strategy = &sysctl_intvec,
267 .extra1 = &min_sched_granularity_ns,
268 .extra2 = &max_sched_granularity_ns,
271 .ctl_name = CTL_UNNUMBERED,
272 .procname = "sched_wakeup_granularity_ns",
273 .data = &sysctl_sched_wakeup_granularity,
274 .maxlen = sizeof(unsigned int),
275 .mode = 0644,
276 .proc_handler = &proc_dointvec_minmax,
277 .strategy = &sysctl_intvec,
278 .extra1 = &min_wakeup_granularity_ns,
279 .extra2 = &max_wakeup_granularity_ns,
282 .ctl_name = CTL_UNNUMBERED,
283 .procname = "sched_shares_ratelimit",
284 .data = &sysctl_sched_shares_ratelimit,
285 .maxlen = sizeof(unsigned int),
286 .mode = 0644,
287 .proc_handler = &proc_dointvec,
290 .ctl_name = CTL_UNNUMBERED,
291 .procname = "sched_shares_thresh",
292 .data = &sysctl_sched_shares_thresh,
293 .maxlen = sizeof(unsigned int),
294 .mode = 0644,
295 .proc_handler = &proc_dointvec_minmax,
296 .strategy = &sysctl_intvec,
297 .extra1 = &zero,
300 .ctl_name = CTL_UNNUMBERED,
301 .procname = "sched_child_runs_first",
302 .data = &sysctl_sched_child_runs_first,
303 .maxlen = sizeof(unsigned int),
304 .mode = 0644,
305 .proc_handler = &proc_dointvec,
308 .ctl_name = CTL_UNNUMBERED,
309 .procname = "sched_features",
310 .data = &sysctl_sched_features,
311 .maxlen = sizeof(unsigned int),
312 .mode = 0644,
313 .proc_handler = &proc_dointvec,
316 .ctl_name = CTL_UNNUMBERED,
317 .procname = "sched_migration_cost",
318 .data = &sysctl_sched_migration_cost,
319 .maxlen = sizeof(unsigned int),
320 .mode = 0644,
321 .proc_handler = &proc_dointvec,
324 .ctl_name = CTL_UNNUMBERED,
325 .procname = "sched_nr_migrate",
326 .data = &sysctl_sched_nr_migrate,
327 .maxlen = sizeof(unsigned int),
328 .mode = 0644,
329 .proc_handler = &proc_dointvec,
331 #endif
333 .ctl_name = CTL_UNNUMBERED,
334 .procname = "sched_rt_period_us",
335 .data = &sysctl_sched_rt_period,
336 .maxlen = sizeof(unsigned int),
337 .mode = 0644,
338 .proc_handler = &sched_rt_handler,
341 .ctl_name = CTL_UNNUMBERED,
342 .procname = "sched_rt_runtime_us",
343 .data = &sysctl_sched_rt_runtime,
344 .maxlen = sizeof(int),
345 .mode = 0644,
346 .proc_handler = &sched_rt_handler,
349 .ctl_name = CTL_UNNUMBERED,
350 .procname = "sched_compat_yield",
351 .data = &sysctl_sched_compat_yield,
352 .maxlen = sizeof(unsigned int),
353 .mode = 0644,
354 .proc_handler = &proc_dointvec,
356 #ifdef CONFIG_PROVE_LOCKING
358 .ctl_name = CTL_UNNUMBERED,
359 .procname = "prove_locking",
360 .data = &prove_locking,
361 .maxlen = sizeof(int),
362 .mode = 0644,
363 .proc_handler = &proc_dointvec,
365 #endif
366 #ifdef CONFIG_LOCK_STAT
368 .ctl_name = CTL_UNNUMBERED,
369 .procname = "lock_stat",
370 .data = &lock_stat,
371 .maxlen = sizeof(int),
372 .mode = 0644,
373 .proc_handler = &proc_dointvec,
375 #endif
377 .ctl_name = KERN_PANIC,
378 .procname = "panic",
379 .data = &panic_timeout,
380 .maxlen = sizeof(int),
381 .mode = 0644,
382 .proc_handler = &proc_dointvec,
385 .ctl_name = KERN_CORE_USES_PID,
386 .procname = "core_uses_pid",
387 .data = &core_uses_pid,
388 .maxlen = sizeof(int),
389 .mode = 0644,
390 .proc_handler = &proc_dointvec,
393 .ctl_name = KERN_CORE_PATTERN,
394 .procname = "core_pattern",
395 .data = core_pattern,
396 .maxlen = CORENAME_MAX_SIZE,
397 .mode = 0644,
398 .proc_handler = &proc_dostring,
399 .strategy = &sysctl_string,
401 #ifdef CONFIG_PROC_SYSCTL
403 .procname = "tainted",
404 .maxlen = sizeof(long),
405 .mode = 0644,
406 .proc_handler = &proc_taint,
408 #endif
409 #ifdef CONFIG_LATENCYTOP
411 .procname = "latencytop",
412 .data = &latencytop_enabled,
413 .maxlen = sizeof(int),
414 .mode = 0644,
415 .proc_handler = &proc_dointvec,
417 #endif
418 #ifdef CONFIG_BLK_DEV_INITRD
420 .ctl_name = KERN_REALROOTDEV,
421 .procname = "real-root-dev",
422 .data = &real_root_dev,
423 .maxlen = sizeof(int),
424 .mode = 0644,
425 .proc_handler = &proc_dointvec,
427 #endif
429 .ctl_name = CTL_UNNUMBERED,
430 .procname = "print-fatal-signals",
431 .data = &print_fatal_signals,
432 .maxlen = sizeof(int),
433 .mode = 0644,
434 .proc_handler = &proc_dointvec,
436 #ifdef CONFIG_SPARC
438 .ctl_name = KERN_SPARC_REBOOT,
439 .procname = "reboot-cmd",
440 .data = reboot_command,
441 .maxlen = 256,
442 .mode = 0644,
443 .proc_handler = &proc_dostring,
444 .strategy = &sysctl_string,
447 .ctl_name = KERN_SPARC_STOP_A,
448 .procname = "stop-a",
449 .data = &stop_a_enabled,
450 .maxlen = sizeof (int),
451 .mode = 0644,
452 .proc_handler = &proc_dointvec,
455 .ctl_name = KERN_SPARC_SCONS_PWROFF,
456 .procname = "scons-poweroff",
457 .data = &scons_pwroff,
458 .maxlen = sizeof (int),
459 .mode = 0644,
460 .proc_handler = &proc_dointvec,
462 #endif
463 #ifdef CONFIG_SPARC64
465 .ctl_name = CTL_UNNUMBERED,
466 .procname = "tsb-ratio",
467 .data = &sysctl_tsb_ratio,
468 .maxlen = sizeof (int),
469 .mode = 0644,
470 .proc_handler = &proc_dointvec,
472 #endif
473 #ifdef __hppa__
475 .ctl_name = KERN_HPPA_PWRSW,
476 .procname = "soft-power",
477 .data = &pwrsw_enabled,
478 .maxlen = sizeof (int),
479 .mode = 0644,
480 .proc_handler = &proc_dointvec,
483 .ctl_name = KERN_HPPA_UNALIGNED,
484 .procname = "unaligned-trap",
485 .data = &unaligned_enabled,
486 .maxlen = sizeof (int),
487 .mode = 0644,
488 .proc_handler = &proc_dointvec,
490 #endif
492 .ctl_name = KERN_CTLALTDEL,
493 .procname = "ctrl-alt-del",
494 .data = &C_A_D,
495 .maxlen = sizeof(int),
496 .mode = 0644,
497 .proc_handler = &proc_dointvec,
499 #ifdef CONFIG_FUNCTION_TRACER
501 .ctl_name = CTL_UNNUMBERED,
502 .procname = "ftrace_enabled",
503 .data = &ftrace_enabled,
504 .maxlen = sizeof(int),
505 .mode = 0644,
506 .proc_handler = &ftrace_enable_sysctl,
508 #endif
509 #ifdef CONFIG_STACK_TRACER
511 .ctl_name = CTL_UNNUMBERED,
512 .procname = "stack_tracer_enabled",
513 .data = &stack_tracer_enabled,
514 .maxlen = sizeof(int),
515 .mode = 0644,
516 .proc_handler = &stack_trace_sysctl,
518 #endif
519 #ifdef CONFIG_TRACING
521 .ctl_name = CTL_UNNUMBERED,
522 .procname = "ftrace_dump_on_oops",
523 .data = &ftrace_dump_on_oops,
524 .maxlen = sizeof(int),
525 .mode = 0644,
526 .proc_handler = &proc_dointvec,
528 #endif
529 #ifdef CONFIG_MODULES
531 .ctl_name = KERN_MODPROBE,
532 .procname = "modprobe",
533 .data = &modprobe_path,
534 .maxlen = KMOD_PATH_LEN,
535 .mode = 0644,
536 .proc_handler = &proc_dostring,
537 .strategy = &sysctl_string,
540 .ctl_name = CTL_UNNUMBERED,
541 .procname = "modules_disabled",
542 .data = &modules_disabled,
543 .maxlen = sizeof(int),
544 .mode = 0644,
545 /* only handle a transition from default "0" to "1" */
546 .proc_handler = &proc_dointvec_minmax,
547 .extra1 = &one,
548 .extra2 = &one,
550 #endif
551 #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
553 .ctl_name = KERN_HOTPLUG,
554 .procname = "hotplug",
555 .data = &uevent_helper,
556 .maxlen = UEVENT_HELPER_PATH_LEN,
557 .mode = 0644,
558 .proc_handler = &proc_dostring,
559 .strategy = &sysctl_string,
561 #endif
562 #ifdef CONFIG_CHR_DEV_SG
564 .ctl_name = KERN_SG_BIG_BUFF,
565 .procname = "sg-big-buff",
566 .data = &sg_big_buff,
567 .maxlen = sizeof (int),
568 .mode = 0444,
569 .proc_handler = &proc_dointvec,
571 #endif
572 #ifdef CONFIG_BSD_PROCESS_ACCT
574 .ctl_name = KERN_ACCT,
575 .procname = "acct",
576 .data = &acct_parm,
577 .maxlen = 3*sizeof(int),
578 .mode = 0644,
579 .proc_handler = &proc_dointvec,
581 #endif
582 #ifdef CONFIG_MAGIC_SYSRQ
584 .ctl_name = KERN_SYSRQ,
585 .procname = "sysrq",
586 .data = &__sysrq_enabled,
587 .maxlen = sizeof (int),
588 .mode = 0644,
589 .proc_handler = &proc_dointvec,
591 #endif
592 #ifdef CONFIG_PROC_SYSCTL
594 .procname = "cad_pid",
595 .data = NULL,
596 .maxlen = sizeof (int),
597 .mode = 0600,
598 .proc_handler = &proc_do_cad_pid,
600 #endif
602 .ctl_name = KERN_MAX_THREADS,
603 .procname = "threads-max",
604 .data = &max_threads,
605 .maxlen = sizeof(int),
606 .mode = 0644,
607 .proc_handler = &proc_dointvec,
610 .ctl_name = KERN_RANDOM,
611 .procname = "random",
612 .mode = 0555,
613 .child = random_table,
616 .ctl_name = KERN_OVERFLOWUID,
617 .procname = "overflowuid",
618 .data = &overflowuid,
619 .maxlen = sizeof(int),
620 .mode = 0644,
621 .proc_handler = &proc_dointvec_minmax,
622 .strategy = &sysctl_intvec,
623 .extra1 = &minolduid,
624 .extra2 = &maxolduid,
627 .ctl_name = KERN_OVERFLOWGID,
628 .procname = "overflowgid",
629 .data = &overflowgid,
630 .maxlen = sizeof(int),
631 .mode = 0644,
632 .proc_handler = &proc_dointvec_minmax,
633 .strategy = &sysctl_intvec,
634 .extra1 = &minolduid,
635 .extra2 = &maxolduid,
637 #ifdef CONFIG_S390
638 #ifdef CONFIG_MATHEMU
640 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
641 .procname = "ieee_emulation_warnings",
642 .data = &sysctl_ieee_emulation_warnings,
643 .maxlen = sizeof(int),
644 .mode = 0644,
645 .proc_handler = &proc_dointvec,
647 #endif
649 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
650 .procname = "userprocess_debug",
651 .data = &sysctl_userprocess_debug,
652 .maxlen = sizeof(int),
653 .mode = 0644,
654 .proc_handler = &proc_dointvec,
656 #endif
658 .ctl_name = KERN_PIDMAX,
659 .procname = "pid_max",
660 .data = &pid_max,
661 .maxlen = sizeof (int),
662 .mode = 0644,
663 .proc_handler = &proc_dointvec_minmax,
664 .strategy = sysctl_intvec,
665 .extra1 = &pid_max_min,
666 .extra2 = &pid_max_max,
669 .ctl_name = KERN_PANIC_ON_OOPS,
670 .procname = "panic_on_oops",
671 .data = &panic_on_oops,
672 .maxlen = sizeof(int),
673 .mode = 0644,
674 .proc_handler = &proc_dointvec,
676 #if defined CONFIG_PRINTK
678 .ctl_name = KERN_PRINTK,
679 .procname = "printk",
680 .data = &console_loglevel,
681 .maxlen = 4*sizeof(int),
682 .mode = 0644,
683 .proc_handler = &proc_dointvec,
686 .ctl_name = KERN_PRINTK_RATELIMIT,
687 .procname = "printk_ratelimit",
688 .data = &printk_ratelimit_state.interval,
689 .maxlen = sizeof(int),
690 .mode = 0644,
691 .proc_handler = &proc_dointvec_jiffies,
692 .strategy = &sysctl_jiffies,
695 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
696 .procname = "printk_ratelimit_burst",
697 .data = &printk_ratelimit_state.burst,
698 .maxlen = sizeof(int),
699 .mode = 0644,
700 .proc_handler = &proc_dointvec,
702 #endif
704 .ctl_name = KERN_NGROUPS_MAX,
705 .procname = "ngroups_max",
706 .data = &ngroups_max,
707 .maxlen = sizeof (int),
708 .mode = 0444,
709 .proc_handler = &proc_dointvec,
711 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
713 .ctl_name = KERN_UNKNOWN_NMI_PANIC,
714 .procname = "unknown_nmi_panic",
715 .data = &unknown_nmi_panic,
716 .maxlen = sizeof (int),
717 .mode = 0644,
718 .proc_handler = &proc_dointvec,
721 .procname = "nmi_watchdog",
722 .data = &nmi_watchdog_enabled,
723 .maxlen = sizeof (int),
724 .mode = 0644,
725 .proc_handler = &proc_nmi_enabled,
727 #endif
728 #if defined(CONFIG_X86)
730 .ctl_name = KERN_PANIC_ON_NMI,
731 .procname = "panic_on_unrecovered_nmi",
732 .data = &panic_on_unrecovered_nmi,
733 .maxlen = sizeof(int),
734 .mode = 0644,
735 .proc_handler = &proc_dointvec,
738 .ctl_name = KERN_BOOTLOADER_TYPE,
739 .procname = "bootloader_type",
740 .data = &bootloader_type,
741 .maxlen = sizeof (int),
742 .mode = 0444,
743 .proc_handler = &proc_dointvec,
746 .ctl_name = CTL_UNNUMBERED,
747 .procname = "bootloader_version",
748 .data = &bootloader_version,
749 .maxlen = sizeof (int),
750 .mode = 0444,
751 .proc_handler = &proc_dointvec,
754 .ctl_name = CTL_UNNUMBERED,
755 .procname = "kstack_depth_to_print",
756 .data = &kstack_depth_to_print,
757 .maxlen = sizeof(int),
758 .mode = 0644,
759 .proc_handler = &proc_dointvec,
762 .ctl_name = CTL_UNNUMBERED,
763 .procname = "io_delay_type",
764 .data = &io_delay_type,
765 .maxlen = sizeof(int),
766 .mode = 0644,
767 .proc_handler = &proc_dointvec,
769 #endif
770 #if defined(CONFIG_MMU)
772 .ctl_name = KERN_RANDOMIZE,
773 .procname = "randomize_va_space",
774 .data = &randomize_va_space,
775 .maxlen = sizeof(int),
776 .mode = 0644,
777 .proc_handler = &proc_dointvec,
779 #endif
780 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
782 .ctl_name = KERN_SPIN_RETRY,
783 .procname = "spin_retry",
784 .data = &spin_retry,
785 .maxlen = sizeof (int),
786 .mode = 0644,
787 .proc_handler = &proc_dointvec,
789 #endif
790 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
792 .procname = "acpi_video_flags",
793 .data = &acpi_realmode_flags,
794 .maxlen = sizeof (unsigned long),
795 .mode = 0644,
796 .proc_handler = &proc_doulongvec_minmax,
798 #endif
799 #ifdef CONFIG_IA64
801 .ctl_name = KERN_IA64_UNALIGNED,
802 .procname = "ignore-unaligned-usertrap",
803 .data = &no_unaligned_warning,
804 .maxlen = sizeof (int),
805 .mode = 0644,
806 .proc_handler = &proc_dointvec,
809 .ctl_name = CTL_UNNUMBERED,
810 .procname = "unaligned-dump-stack",
811 .data = &unaligned_dump_stack,
812 .maxlen = sizeof (int),
813 .mode = 0644,
814 .proc_handler = &proc_dointvec,
816 #endif
817 #ifdef CONFIG_DETECT_SOFTLOCKUP
819 .ctl_name = CTL_UNNUMBERED,
820 .procname = "softlockup_panic",
821 .data = &softlockup_panic,
822 .maxlen = sizeof(int),
823 .mode = 0644,
824 .proc_handler = &proc_dointvec_minmax,
825 .strategy = &sysctl_intvec,
826 .extra1 = &zero,
827 .extra2 = &one,
830 .ctl_name = CTL_UNNUMBERED,
831 .procname = "softlockup_thresh",
832 .data = &softlockup_thresh,
833 .maxlen = sizeof(int),
834 .mode = 0644,
835 .proc_handler = &proc_dosoftlockup_thresh,
836 .strategy = &sysctl_intvec,
837 .extra1 = &neg_one,
838 .extra2 = &sixty,
840 #endif
841 #ifdef CONFIG_DETECT_HUNG_TASK
843 .ctl_name = CTL_UNNUMBERED,
844 .procname = "hung_task_panic",
845 .data = &sysctl_hung_task_panic,
846 .maxlen = sizeof(int),
847 .mode = 0644,
848 .proc_handler = &proc_dointvec_minmax,
849 .strategy = &sysctl_intvec,
850 .extra1 = &zero,
851 .extra2 = &one,
854 .ctl_name = CTL_UNNUMBERED,
855 .procname = "hung_task_check_count",
856 .data = &sysctl_hung_task_check_count,
857 .maxlen = sizeof(unsigned long),
858 .mode = 0644,
859 .proc_handler = &proc_doulongvec_minmax,
860 .strategy = &sysctl_intvec,
863 .ctl_name = CTL_UNNUMBERED,
864 .procname = "hung_task_timeout_secs",
865 .data = &sysctl_hung_task_timeout_secs,
866 .maxlen = sizeof(unsigned long),
867 .mode = 0644,
868 .proc_handler = &proc_dohung_task_timeout_secs,
869 .strategy = &sysctl_intvec,
872 .ctl_name = CTL_UNNUMBERED,
873 .procname = "hung_task_warnings",
874 .data = &sysctl_hung_task_warnings,
875 .maxlen = sizeof(unsigned long),
876 .mode = 0644,
877 .proc_handler = &proc_doulongvec_minmax,
878 .strategy = &sysctl_intvec,
880 #endif
881 #ifdef CONFIG_COMPAT
883 .ctl_name = KERN_COMPAT_LOG,
884 .procname = "compat-log",
885 .data = &compat_log,
886 .maxlen = sizeof (int),
887 .mode = 0644,
888 .proc_handler = &proc_dointvec,
890 #endif
891 #ifdef CONFIG_RT_MUTEXES
893 .ctl_name = KERN_MAX_LOCK_DEPTH,
894 .procname = "max_lock_depth",
895 .data = &max_lock_depth,
896 .maxlen = sizeof(int),
897 .mode = 0644,
898 .proc_handler = &proc_dointvec,
900 #endif
902 .ctl_name = CTL_UNNUMBERED,
903 .procname = "poweroff_cmd",
904 .data = &poweroff_cmd,
905 .maxlen = POWEROFF_CMD_PATH_LEN,
906 .mode = 0644,
907 .proc_handler = &proc_dostring,
908 .strategy = &sysctl_string,
910 #ifdef CONFIG_KEYS
912 .ctl_name = CTL_UNNUMBERED,
913 .procname = "keys",
914 .mode = 0555,
915 .child = key_sysctls,
917 #endif
918 #ifdef CONFIG_RCU_TORTURE_TEST
920 .ctl_name = CTL_UNNUMBERED,
921 .procname = "rcutorture_runnable",
922 .data = &rcutorture_runnable,
923 .maxlen = sizeof(int),
924 .mode = 0644,
925 .proc_handler = &proc_dointvec,
927 #endif
928 #ifdef CONFIG_SLOW_WORK
930 .ctl_name = CTL_UNNUMBERED,
931 .procname = "slow-work",
932 .mode = 0555,
933 .child = slow_work_sysctls,
935 #endif
936 #ifdef CONFIG_PERF_COUNTERS
938 .ctl_name = CTL_UNNUMBERED,
939 .procname = "perf_counter_paranoid",
940 .data = &sysctl_perf_counter_paranoid,
941 .maxlen = sizeof(sysctl_perf_counter_paranoid),
942 .mode = 0644,
943 .proc_handler = &proc_dointvec,
946 .ctl_name = CTL_UNNUMBERED,
947 .procname = "perf_counter_mlock_kb",
948 .data = &sysctl_perf_counter_mlock,
949 .maxlen = sizeof(sysctl_perf_counter_mlock),
950 .mode = 0644,
951 .proc_handler = &proc_dointvec,
954 .ctl_name = CTL_UNNUMBERED,
955 .procname = "perf_counter_max_sample_rate",
956 .data = &sysctl_perf_counter_sample_rate,
957 .maxlen = sizeof(sysctl_perf_counter_sample_rate),
958 .mode = 0644,
959 .proc_handler = &proc_dointvec,
961 #endif
963 * NOTE: do not add new entries to this table unless you have read
964 * Documentation/sysctl/ctl_unnumbered.txt
966 { .ctl_name = 0 }
969 static struct ctl_table vm_table[] = {
971 .ctl_name = VM_OVERCOMMIT_MEMORY,
972 .procname = "overcommit_memory",
973 .data = &sysctl_overcommit_memory,
974 .maxlen = sizeof(sysctl_overcommit_memory),
975 .mode = 0644,
976 .proc_handler = &proc_dointvec,
979 .ctl_name = VM_PANIC_ON_OOM,
980 .procname = "panic_on_oom",
981 .data = &sysctl_panic_on_oom,
982 .maxlen = sizeof(sysctl_panic_on_oom),
983 .mode = 0644,
984 .proc_handler = &proc_dointvec,
987 .ctl_name = CTL_UNNUMBERED,
988 .procname = "oom_kill_allocating_task",
989 .data = &sysctl_oom_kill_allocating_task,
990 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
991 .mode = 0644,
992 .proc_handler = &proc_dointvec,
995 .ctl_name = CTL_UNNUMBERED,
996 .procname = "oom_dump_tasks",
997 .data = &sysctl_oom_dump_tasks,
998 .maxlen = sizeof(sysctl_oom_dump_tasks),
999 .mode = 0644,
1000 .proc_handler = &proc_dointvec,
1003 .ctl_name = VM_OVERCOMMIT_RATIO,
1004 .procname = "overcommit_ratio",
1005 .data = &sysctl_overcommit_ratio,
1006 .maxlen = sizeof(sysctl_overcommit_ratio),
1007 .mode = 0644,
1008 .proc_handler = &proc_dointvec,
1011 .ctl_name = VM_PAGE_CLUSTER,
1012 .procname = "page-cluster",
1013 .data = &page_cluster,
1014 .maxlen = sizeof(int),
1015 .mode = 0644,
1016 .proc_handler = &proc_dointvec,
1019 .ctl_name = VM_DIRTY_BACKGROUND,
1020 .procname = "dirty_background_ratio",
1021 .data = &dirty_background_ratio,
1022 .maxlen = sizeof(dirty_background_ratio),
1023 .mode = 0644,
1024 .proc_handler = &dirty_background_ratio_handler,
1025 .strategy = &sysctl_intvec,
1026 .extra1 = &zero,
1027 .extra2 = &one_hundred,
1030 .ctl_name = CTL_UNNUMBERED,
1031 .procname = "dirty_background_bytes",
1032 .data = &dirty_background_bytes,
1033 .maxlen = sizeof(dirty_background_bytes),
1034 .mode = 0644,
1035 .proc_handler = &dirty_background_bytes_handler,
1036 .strategy = &sysctl_intvec,
1037 .extra1 = &one_ul,
1040 .ctl_name = VM_DIRTY_RATIO,
1041 .procname = "dirty_ratio",
1042 .data = &vm_dirty_ratio,
1043 .maxlen = sizeof(vm_dirty_ratio),
1044 .mode = 0644,
1045 .proc_handler = &dirty_ratio_handler,
1046 .strategy = &sysctl_intvec,
1047 .extra1 = &zero,
1048 .extra2 = &one_hundred,
1051 .ctl_name = CTL_UNNUMBERED,
1052 .procname = "dirty_bytes",
1053 .data = &vm_dirty_bytes,
1054 .maxlen = sizeof(vm_dirty_bytes),
1055 .mode = 0644,
1056 .proc_handler = &dirty_bytes_handler,
1057 .strategy = &sysctl_intvec,
1058 .extra1 = &dirty_bytes_min,
1061 .procname = "dirty_writeback_centisecs",
1062 .data = &dirty_writeback_interval,
1063 .maxlen = sizeof(dirty_writeback_interval),
1064 .mode = 0644,
1065 .proc_handler = &dirty_writeback_centisecs_handler,
1068 .procname = "dirty_expire_centisecs",
1069 .data = &dirty_expire_interval,
1070 .maxlen = sizeof(dirty_expire_interval),
1071 .mode = 0644,
1072 .proc_handler = &proc_dointvec,
1075 .ctl_name = VM_NR_PDFLUSH_THREADS,
1076 .procname = "nr_pdflush_threads",
1077 .data = &nr_pdflush_threads,
1078 .maxlen = sizeof nr_pdflush_threads,
1079 .mode = 0444 /* read-only*/,
1080 .proc_handler = &proc_dointvec,
1083 .ctl_name = VM_SWAPPINESS,
1084 .procname = "swappiness",
1085 .data = &vm_swappiness,
1086 .maxlen = sizeof(vm_swappiness),
1087 .mode = 0644,
1088 .proc_handler = &proc_dointvec_minmax,
1089 .strategy = &sysctl_intvec,
1090 .extra1 = &zero,
1091 .extra2 = &one_hundred,
1093 #ifdef CONFIG_HUGETLB_PAGE
1095 .procname = "nr_hugepages",
1096 .data = NULL,
1097 .maxlen = sizeof(unsigned long),
1098 .mode = 0644,
1099 .proc_handler = &hugetlb_sysctl_handler,
1100 .extra1 = (void *)&hugetlb_zero,
1101 .extra2 = (void *)&hugetlb_infinity,
1104 .ctl_name = VM_HUGETLB_GROUP,
1105 .procname = "hugetlb_shm_group",
1106 .data = &sysctl_hugetlb_shm_group,
1107 .maxlen = sizeof(gid_t),
1108 .mode = 0644,
1109 .proc_handler = &proc_dointvec,
1112 .ctl_name = CTL_UNNUMBERED,
1113 .procname = "hugepages_treat_as_movable",
1114 .data = &hugepages_treat_as_movable,
1115 .maxlen = sizeof(int),
1116 .mode = 0644,
1117 .proc_handler = &hugetlb_treat_movable_handler,
1120 .ctl_name = CTL_UNNUMBERED,
1121 .procname = "nr_overcommit_hugepages",
1122 .data = NULL,
1123 .maxlen = sizeof(unsigned long),
1124 .mode = 0644,
1125 .proc_handler = &hugetlb_overcommit_handler,
1126 .extra1 = (void *)&hugetlb_zero,
1127 .extra2 = (void *)&hugetlb_infinity,
1129 #endif
1131 .ctl_name = VM_LOWMEM_RESERVE_RATIO,
1132 .procname = "lowmem_reserve_ratio",
1133 .data = &sysctl_lowmem_reserve_ratio,
1134 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1135 .mode = 0644,
1136 .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
1137 .strategy = &sysctl_intvec,
1140 .ctl_name = VM_DROP_PAGECACHE,
1141 .procname = "drop_caches",
1142 .data = &sysctl_drop_caches,
1143 .maxlen = sizeof(int),
1144 .mode = 0644,
1145 .proc_handler = drop_caches_sysctl_handler,
1146 .strategy = &sysctl_intvec,
1149 .ctl_name = VM_MIN_FREE_KBYTES,
1150 .procname = "min_free_kbytes",
1151 .data = &min_free_kbytes,
1152 .maxlen = sizeof(min_free_kbytes),
1153 .mode = 0644,
1154 .proc_handler = &min_free_kbytes_sysctl_handler,
1155 .strategy = &sysctl_intvec,
1156 .extra1 = &zero,
1159 .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
1160 .procname = "percpu_pagelist_fraction",
1161 .data = &percpu_pagelist_fraction,
1162 .maxlen = sizeof(percpu_pagelist_fraction),
1163 .mode = 0644,
1164 .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
1165 .strategy = &sysctl_intvec,
1166 .extra1 = &min_percpu_pagelist_fract,
1168 #ifdef CONFIG_MMU
1170 .ctl_name = VM_MAX_MAP_COUNT,
1171 .procname = "max_map_count",
1172 .data = &sysctl_max_map_count,
1173 .maxlen = sizeof(sysctl_max_map_count),
1174 .mode = 0644,
1175 .proc_handler = &proc_dointvec
1177 #else
1179 .ctl_name = CTL_UNNUMBERED,
1180 .procname = "nr_trim_pages",
1181 .data = &sysctl_nr_trim_pages,
1182 .maxlen = sizeof(sysctl_nr_trim_pages),
1183 .mode = 0644,
1184 .proc_handler = &proc_dointvec_minmax,
1185 .strategy = &sysctl_intvec,
1186 .extra1 = &zero,
1188 #endif
1190 .ctl_name = VM_LAPTOP_MODE,
1191 .procname = "laptop_mode",
1192 .data = &laptop_mode,
1193 .maxlen = sizeof(laptop_mode),
1194 .mode = 0644,
1195 .proc_handler = &proc_dointvec_jiffies,
1196 .strategy = &sysctl_jiffies,
1199 .ctl_name = VM_BLOCK_DUMP,
1200 .procname = "block_dump",
1201 .data = &block_dump,
1202 .maxlen = sizeof(block_dump),
1203 .mode = 0644,
1204 .proc_handler = &proc_dointvec,
1205 .strategy = &sysctl_intvec,
1206 .extra1 = &zero,
1209 .ctl_name = VM_VFS_CACHE_PRESSURE,
1210 .procname = "vfs_cache_pressure",
1211 .data = &sysctl_vfs_cache_pressure,
1212 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1213 .mode = 0644,
1214 .proc_handler = &proc_dointvec,
1215 .strategy = &sysctl_intvec,
1216 .extra1 = &zero,
1218 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1220 .ctl_name = VM_LEGACY_VA_LAYOUT,
1221 .procname = "legacy_va_layout",
1222 .data = &sysctl_legacy_va_layout,
1223 .maxlen = sizeof(sysctl_legacy_va_layout),
1224 .mode = 0644,
1225 .proc_handler = &proc_dointvec,
1226 .strategy = &sysctl_intvec,
1227 .extra1 = &zero,
1229 #endif
1230 #ifdef CONFIG_NUMA
1232 .ctl_name = VM_ZONE_RECLAIM_MODE,
1233 .procname = "zone_reclaim_mode",
1234 .data = &zone_reclaim_mode,
1235 .maxlen = sizeof(zone_reclaim_mode),
1236 .mode = 0644,
1237 .proc_handler = &proc_dointvec,
1238 .strategy = &sysctl_intvec,
1239 .extra1 = &zero,
1242 .ctl_name = VM_MIN_UNMAPPED,
1243 .procname = "min_unmapped_ratio",
1244 .data = &sysctl_min_unmapped_ratio,
1245 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1246 .mode = 0644,
1247 .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
1248 .strategy = &sysctl_intvec,
1249 .extra1 = &zero,
1250 .extra2 = &one_hundred,
1253 .ctl_name = VM_MIN_SLAB,
1254 .procname = "min_slab_ratio",
1255 .data = &sysctl_min_slab_ratio,
1256 .maxlen = sizeof(sysctl_min_slab_ratio),
1257 .mode = 0644,
1258 .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
1259 .strategy = &sysctl_intvec,
1260 .extra1 = &zero,
1261 .extra2 = &one_hundred,
1263 #endif
1264 #ifdef CONFIG_SMP
1266 .ctl_name = CTL_UNNUMBERED,
1267 .procname = "stat_interval",
1268 .data = &sysctl_stat_interval,
1269 .maxlen = sizeof(sysctl_stat_interval),
1270 .mode = 0644,
1271 .proc_handler = &proc_dointvec_jiffies,
1272 .strategy = &sysctl_jiffies,
1274 #endif
1276 .ctl_name = CTL_UNNUMBERED,
1277 .procname = "mmap_min_addr",
1278 .data = &mmap_min_addr,
1279 .maxlen = sizeof(unsigned long),
1280 .mode = 0644,
1281 .proc_handler = &proc_doulongvec_minmax,
1283 #ifdef CONFIG_NUMA
1285 .ctl_name = CTL_UNNUMBERED,
1286 .procname = "numa_zonelist_order",
1287 .data = &numa_zonelist_order,
1288 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1289 .mode = 0644,
1290 .proc_handler = &numa_zonelist_order_handler,
1291 .strategy = &sysctl_string,
1293 #endif
1294 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1295 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1297 .ctl_name = VM_VDSO_ENABLED,
1298 .procname = "vdso_enabled",
1299 .data = &vdso_enabled,
1300 .maxlen = sizeof(vdso_enabled),
1301 .mode = 0644,
1302 .proc_handler = &proc_dointvec,
1303 .strategy = &sysctl_intvec,
1304 .extra1 = &zero,
1306 #endif
1307 #ifdef CONFIG_HIGHMEM
1309 .ctl_name = CTL_UNNUMBERED,
1310 .procname = "highmem_is_dirtyable",
1311 .data = &vm_highmem_is_dirtyable,
1312 .maxlen = sizeof(vm_highmem_is_dirtyable),
1313 .mode = 0644,
1314 .proc_handler = &proc_dointvec_minmax,
1315 .strategy = &sysctl_intvec,
1316 .extra1 = &zero,
1317 .extra2 = &one,
1319 #endif
1320 #ifdef CONFIG_UNEVICTABLE_LRU
1322 .ctl_name = CTL_UNNUMBERED,
1323 .procname = "scan_unevictable_pages",
1324 .data = &scan_unevictable_pages,
1325 .maxlen = sizeof(scan_unevictable_pages),
1326 .mode = 0644,
1327 .proc_handler = &scan_unevictable_handler,
1329 #endif
1331 * NOTE: do not add new entries to this table unless you have read
1332 * Documentation/sysctl/ctl_unnumbered.txt
1334 { .ctl_name = 0 }
1337 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1338 static struct ctl_table binfmt_misc_table[] = {
1339 { .ctl_name = 0 }
1341 #endif
1343 static struct ctl_table fs_table[] = {
1345 .ctl_name = FS_NRINODE,
1346 .procname = "inode-nr",
1347 .data = &inodes_stat,
1348 .maxlen = 2*sizeof(int),
1349 .mode = 0444,
1350 .proc_handler = &proc_dointvec,
1353 .ctl_name = FS_STATINODE,
1354 .procname = "inode-state",
1355 .data = &inodes_stat,
1356 .maxlen = 7*sizeof(int),
1357 .mode = 0444,
1358 .proc_handler = &proc_dointvec,
1361 .procname = "file-nr",
1362 .data = &files_stat,
1363 .maxlen = 3*sizeof(int),
1364 .mode = 0444,
1365 .proc_handler = &proc_nr_files,
1368 .ctl_name = FS_MAXFILE,
1369 .procname = "file-max",
1370 .data = &files_stat.max_files,
1371 .maxlen = sizeof(int),
1372 .mode = 0644,
1373 .proc_handler = &proc_dointvec,
1376 .ctl_name = CTL_UNNUMBERED,
1377 .procname = "nr_open",
1378 .data = &sysctl_nr_open,
1379 .maxlen = sizeof(int),
1380 .mode = 0644,
1381 .proc_handler = &proc_dointvec_minmax,
1382 .extra1 = &sysctl_nr_open_min,
1383 .extra2 = &sysctl_nr_open_max,
1386 .ctl_name = FS_DENTRY,
1387 .procname = "dentry-state",
1388 .data = &dentry_stat,
1389 .maxlen = 6*sizeof(int),
1390 .mode = 0444,
1391 .proc_handler = &proc_dointvec,
1394 .ctl_name = FS_OVERFLOWUID,
1395 .procname = "overflowuid",
1396 .data = &fs_overflowuid,
1397 .maxlen = sizeof(int),
1398 .mode = 0644,
1399 .proc_handler = &proc_dointvec_minmax,
1400 .strategy = &sysctl_intvec,
1401 .extra1 = &minolduid,
1402 .extra2 = &maxolduid,
1405 .ctl_name = FS_OVERFLOWGID,
1406 .procname = "overflowgid",
1407 .data = &fs_overflowgid,
1408 .maxlen = sizeof(int),
1409 .mode = 0644,
1410 .proc_handler = &proc_dointvec_minmax,
1411 .strategy = &sysctl_intvec,
1412 .extra1 = &minolduid,
1413 .extra2 = &maxolduid,
1415 #ifdef CONFIG_FILE_LOCKING
1417 .ctl_name = FS_LEASES,
1418 .procname = "leases-enable",
1419 .data = &leases_enable,
1420 .maxlen = sizeof(int),
1421 .mode = 0644,
1422 .proc_handler = &proc_dointvec,
1424 #endif
1425 #ifdef CONFIG_DNOTIFY
1427 .ctl_name = FS_DIR_NOTIFY,
1428 .procname = "dir-notify-enable",
1429 .data = &dir_notify_enable,
1430 .maxlen = sizeof(int),
1431 .mode = 0644,
1432 .proc_handler = &proc_dointvec,
1434 #endif
1435 #ifdef CONFIG_MMU
1436 #ifdef CONFIG_FILE_LOCKING
1438 .ctl_name = FS_LEASE_TIME,
1439 .procname = "lease-break-time",
1440 .data = &lease_break_time,
1441 .maxlen = sizeof(int),
1442 .mode = 0644,
1443 .proc_handler = &proc_dointvec,
1445 #endif
1446 #ifdef CONFIG_AIO
1448 .procname = "aio-nr",
1449 .data = &aio_nr,
1450 .maxlen = sizeof(aio_nr),
1451 .mode = 0444,
1452 .proc_handler = &proc_doulongvec_minmax,
1455 .procname = "aio-max-nr",
1456 .data = &aio_max_nr,
1457 .maxlen = sizeof(aio_max_nr),
1458 .mode = 0644,
1459 .proc_handler = &proc_doulongvec_minmax,
1461 #endif /* CONFIG_AIO */
1462 #ifdef CONFIG_INOTIFY_USER
1464 .ctl_name = FS_INOTIFY,
1465 .procname = "inotify",
1466 .mode = 0555,
1467 .child = inotify_table,
1469 #endif
1470 #ifdef CONFIG_EPOLL
1472 .procname = "epoll",
1473 .mode = 0555,
1474 .child = epoll_table,
1476 #endif
1477 #endif
1479 .ctl_name = KERN_SETUID_DUMPABLE,
1480 .procname = "suid_dumpable",
1481 .data = &suid_dumpable,
1482 .maxlen = sizeof(int),
1483 .mode = 0644,
1484 .proc_handler = &proc_dointvec_minmax,
1485 .strategy = &sysctl_intvec,
1486 .extra1 = &zero,
1487 .extra2 = &two,
1489 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1491 .ctl_name = CTL_UNNUMBERED,
1492 .procname = "binfmt_misc",
1493 .mode = 0555,
1494 .child = binfmt_misc_table,
1496 #endif
1498 * NOTE: do not add new entries to this table unless you have read
1499 * Documentation/sysctl/ctl_unnumbered.txt
1501 { .ctl_name = 0 }
1504 static struct ctl_table debug_table[] = {
1505 #if defined(CONFIG_X86) || defined(CONFIG_PPC)
1507 .ctl_name = CTL_UNNUMBERED,
1508 .procname = "exception-trace",
1509 .data = &show_unhandled_signals,
1510 .maxlen = sizeof(int),
1511 .mode = 0644,
1512 .proc_handler = proc_dointvec
1514 #endif
1515 { .ctl_name = 0 }
1518 static struct ctl_table dev_table[] = {
1519 { .ctl_name = 0 }
1522 static DEFINE_SPINLOCK(sysctl_lock);
1524 /* called under sysctl_lock */
1525 static int use_table(struct ctl_table_header *p)
1527 if (unlikely(p->unregistering))
1528 return 0;
1529 p->used++;
1530 return 1;
1533 /* called under sysctl_lock */
1534 static void unuse_table(struct ctl_table_header *p)
1536 if (!--p->used)
1537 if (unlikely(p->unregistering))
1538 complete(p->unregistering);
1541 /* called under sysctl_lock, will reacquire if has to wait */
1542 static void start_unregistering(struct ctl_table_header *p)
1545 * if p->used is 0, nobody will ever touch that entry again;
1546 * we'll eliminate all paths to it before dropping sysctl_lock
1548 if (unlikely(p->used)) {
1549 struct completion wait;
1550 init_completion(&wait);
1551 p->unregistering = &wait;
1552 spin_unlock(&sysctl_lock);
1553 wait_for_completion(&wait);
1554 spin_lock(&sysctl_lock);
1555 } else {
1556 /* anything non-NULL; we'll never dereference it */
1557 p->unregistering = ERR_PTR(-EINVAL);
1560 * do not remove from the list until nobody holds it; walking the
1561 * list in do_sysctl() relies on that.
1563 list_del_init(&p->ctl_entry);
1566 void sysctl_head_get(struct ctl_table_header *head)
1568 spin_lock(&sysctl_lock);
1569 head->count++;
1570 spin_unlock(&sysctl_lock);
1573 void sysctl_head_put(struct ctl_table_header *head)
1575 spin_lock(&sysctl_lock);
1576 if (!--head->count)
1577 kfree(head);
1578 spin_unlock(&sysctl_lock);
1581 struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1583 if (!head)
1584 BUG();
1585 spin_lock(&sysctl_lock);
1586 if (!use_table(head))
1587 head = ERR_PTR(-ENOENT);
1588 spin_unlock(&sysctl_lock);
1589 return head;
1592 void sysctl_head_finish(struct ctl_table_header *head)
1594 if (!head)
1595 return;
1596 spin_lock(&sysctl_lock);
1597 unuse_table(head);
1598 spin_unlock(&sysctl_lock);
1601 static struct ctl_table_set *
1602 lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1604 struct ctl_table_set *set = &root->default_set;
1605 if (root->lookup)
1606 set = root->lookup(root, namespaces);
1607 return set;
1610 static struct list_head *
1611 lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1613 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1614 return &set->list;
1617 struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1618 struct ctl_table_header *prev)
1620 struct ctl_table_root *root;
1621 struct list_head *header_list;
1622 struct ctl_table_header *head;
1623 struct list_head *tmp;
1625 spin_lock(&sysctl_lock);
1626 if (prev) {
1627 head = prev;
1628 tmp = &prev->ctl_entry;
1629 unuse_table(prev);
1630 goto next;
1632 tmp = &root_table_header.ctl_entry;
1633 for (;;) {
1634 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1636 if (!use_table(head))
1637 goto next;
1638 spin_unlock(&sysctl_lock);
1639 return head;
1640 next:
1641 root = head->root;
1642 tmp = tmp->next;
1643 header_list = lookup_header_list(root, namespaces);
1644 if (tmp != header_list)
1645 continue;
1647 do {
1648 root = list_entry(root->root_list.next,
1649 struct ctl_table_root, root_list);
1650 if (root == &sysctl_table_root)
1651 goto out;
1652 header_list = lookup_header_list(root, namespaces);
1653 } while (list_empty(header_list));
1654 tmp = header_list->next;
1656 out:
1657 spin_unlock(&sysctl_lock);
1658 return NULL;
1661 struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1663 return __sysctl_head_next(current->nsproxy, prev);
1666 void register_sysctl_root(struct ctl_table_root *root)
1668 spin_lock(&sysctl_lock);
1669 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1670 spin_unlock(&sysctl_lock);
1673 #ifdef CONFIG_SYSCTL_SYSCALL
1674 /* Perform the actual read/write of a sysctl table entry. */
1675 static int do_sysctl_strategy(struct ctl_table_root *root,
1676 struct ctl_table *table,
1677 void __user *oldval, size_t __user *oldlenp,
1678 void __user *newval, size_t newlen)
1680 int op = 0, rc;
1682 if (oldval)
1683 op |= MAY_READ;
1684 if (newval)
1685 op |= MAY_WRITE;
1686 if (sysctl_perm(root, table, op))
1687 return -EPERM;
1689 if (table->strategy) {
1690 rc = table->strategy(table, oldval, oldlenp, newval, newlen);
1691 if (rc < 0)
1692 return rc;
1693 if (rc > 0)
1694 return 0;
1697 /* If there is no strategy routine, or if the strategy returns
1698 * zero, proceed with automatic r/w */
1699 if (table->data && table->maxlen) {
1700 rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
1701 if (rc < 0)
1702 return rc;
1704 return 0;
1707 static int parse_table(int __user *name, int nlen,
1708 void __user *oldval, size_t __user *oldlenp,
1709 void __user *newval, size_t newlen,
1710 struct ctl_table_root *root,
1711 struct ctl_table *table)
1713 int n;
1714 repeat:
1715 if (!nlen)
1716 return -ENOTDIR;
1717 if (get_user(n, name))
1718 return -EFAULT;
1719 for ( ; table->ctl_name || table->procname; table++) {
1720 if (!table->ctl_name)
1721 continue;
1722 if (n == table->ctl_name) {
1723 int error;
1724 if (table->child) {
1725 if (sysctl_perm(root, table, MAY_EXEC))
1726 return -EPERM;
1727 name++;
1728 nlen--;
1729 table = table->child;
1730 goto repeat;
1732 error = do_sysctl_strategy(root, table,
1733 oldval, oldlenp,
1734 newval, newlen);
1735 return error;
1738 return -ENOTDIR;
1741 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1742 void __user *newval, size_t newlen)
1744 struct ctl_table_header *head;
1745 int error = -ENOTDIR;
1747 if (nlen <= 0 || nlen >= CTL_MAXNAME)
1748 return -ENOTDIR;
1749 if (oldval) {
1750 int old_len;
1751 if (!oldlenp || get_user(old_len, oldlenp))
1752 return -EFAULT;
1755 for (head = sysctl_head_next(NULL); head;
1756 head = sysctl_head_next(head)) {
1757 error = parse_table(name, nlen, oldval, oldlenp,
1758 newval, newlen,
1759 head->root, head->ctl_table);
1760 if (error != -ENOTDIR) {
1761 sysctl_head_finish(head);
1762 break;
1765 return error;
1768 SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
1770 struct __sysctl_args tmp;
1771 int error;
1773 if (copy_from_user(&tmp, args, sizeof(tmp)))
1774 return -EFAULT;
1776 error = deprecated_sysctl_warning(&tmp);
1777 if (error)
1778 goto out;
1780 lock_kernel();
1781 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1782 tmp.newval, tmp.newlen);
1783 unlock_kernel();
1784 out:
1785 return error;
1787 #endif /* CONFIG_SYSCTL_SYSCALL */
1790 * sysctl_perm does NOT grant the superuser all rights automatically, because
1791 * some sysctl variables are readonly even to root.
1794 static int test_perm(int mode, int op)
1796 if (!current_euid())
1797 mode >>= 6;
1798 else if (in_egroup_p(0))
1799 mode >>= 3;
1800 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
1801 return 0;
1802 return -EACCES;
1805 int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
1807 int error;
1808 int mode;
1810 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
1811 if (error)
1812 return error;
1814 if (root->permissions)
1815 mode = root->permissions(root, current->nsproxy, table);
1816 else
1817 mode = table->mode;
1819 return test_perm(mode, op);
1822 static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1824 for (; table->ctl_name || table->procname; table++) {
1825 table->parent = parent;
1826 if (table->child)
1827 sysctl_set_parent(table, table->child);
1831 static __init int sysctl_init(void)
1833 sysctl_set_parent(NULL, root_table);
1834 #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1836 int err;
1837 err = sysctl_check_table(current->nsproxy, root_table);
1839 #endif
1840 return 0;
1843 core_initcall(sysctl_init);
1845 static struct ctl_table *is_branch_in(struct ctl_table *branch,
1846 struct ctl_table *table)
1848 struct ctl_table *p;
1849 const char *s = branch->procname;
1851 /* branch should have named subdirectory as its first element */
1852 if (!s || !branch->child)
1853 return NULL;
1855 /* ... and nothing else */
1856 if (branch[1].procname || branch[1].ctl_name)
1857 return NULL;
1859 /* table should contain subdirectory with the same name */
1860 for (p = table; p->procname || p->ctl_name; p++) {
1861 if (!p->child)
1862 continue;
1863 if (p->procname && strcmp(p->procname, s) == 0)
1864 return p;
1866 return NULL;
1869 /* see if attaching q to p would be an improvement */
1870 static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1872 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1873 struct ctl_table *next;
1874 int is_better = 0;
1875 int not_in_parent = !p->attached_by;
1877 while ((next = is_branch_in(by, to)) != NULL) {
1878 if (by == q->attached_by)
1879 is_better = 1;
1880 if (to == p->attached_by)
1881 not_in_parent = 1;
1882 by = by->child;
1883 to = next->child;
1886 if (is_better && not_in_parent) {
1887 q->attached_by = by;
1888 q->attached_to = to;
1889 q->parent = p;
1894 * __register_sysctl_paths - register a sysctl hierarchy
1895 * @root: List of sysctl headers to register on
1896 * @namespaces: Data to compute which lists of sysctl entries are visible
1897 * @path: The path to the directory the sysctl table is in.
1898 * @table: the top-level table structure
1900 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1901 * array. A completely 0 filled entry terminates the table.
1903 * The members of the &struct ctl_table structure are used as follows:
1905 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1906 * must be unique within that level of sysctl
1908 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1909 * enter a sysctl file
1911 * data - a pointer to data for use by proc_handler
1913 * maxlen - the maximum size in bytes of the data
1915 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1917 * child - a pointer to the child sysctl table if this entry is a directory, or
1918 * %NULL.
1920 * proc_handler - the text handler routine (described below)
1922 * strategy - the strategy routine (described below)
1924 * de - for internal use by the sysctl routines
1926 * extra1, extra2 - extra pointers usable by the proc handler routines
1928 * Leaf nodes in the sysctl tree will be represented by a single file
1929 * under /proc; non-leaf nodes will be represented by directories.
1931 * sysctl(2) can automatically manage read and write requests through
1932 * the sysctl table. The data and maxlen fields of the ctl_table
1933 * struct enable minimal validation of the values being written to be
1934 * performed, and the mode field allows minimal authentication.
1936 * More sophisticated management can be enabled by the provision of a
1937 * strategy routine with the table entry. This will be called before
1938 * any automatic read or write of the data is performed.
1940 * The strategy routine may return
1942 * < 0 - Error occurred (error is passed to user process)
1944 * 0 - OK - proceed with automatic read or write.
1946 * > 0 - OK - read or write has been done by the strategy routine, so
1947 * return immediately.
1949 * There must be a proc_handler routine for any terminal nodes
1950 * mirrored under /proc/sys (non-terminals are handled by a built-in
1951 * directory handler). Several default handlers are available to
1952 * cover common cases -
1954 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1955 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1956 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1958 * It is the handler's job to read the input buffer from user memory
1959 * and process it. The handler should return 0 on success.
1961 * This routine returns %NULL on a failure to register, and a pointer
1962 * to the table header on success.
1964 struct ctl_table_header *__register_sysctl_paths(
1965 struct ctl_table_root *root,
1966 struct nsproxy *namespaces,
1967 const struct ctl_path *path, struct ctl_table *table)
1969 struct ctl_table_header *header;
1970 struct ctl_table *new, **prevp;
1971 unsigned int n, npath;
1972 struct ctl_table_set *set;
1974 /* Count the path components */
1975 for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
1979 * For each path component, allocate a 2-element ctl_table array.
1980 * The first array element will be filled with the sysctl entry
1981 * for this, the second will be the sentinel (ctl_name == 0).
1983 * We allocate everything in one go so that we don't have to
1984 * worry about freeing additional memory in unregister_sysctl_table.
1986 header = kzalloc(sizeof(struct ctl_table_header) +
1987 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1988 if (!header)
1989 return NULL;
1991 new = (struct ctl_table *) (header + 1);
1993 /* Now connect the dots */
1994 prevp = &header->ctl_table;
1995 for (n = 0; n < npath; ++n, ++path) {
1996 /* Copy the procname */
1997 new->procname = path->procname;
1998 new->ctl_name = path->ctl_name;
1999 new->mode = 0555;
2001 *prevp = new;
2002 prevp = &new->child;
2004 new += 2;
2006 *prevp = table;
2007 header->ctl_table_arg = table;
2009 INIT_LIST_HEAD(&header->ctl_entry);
2010 header->used = 0;
2011 header->unregistering = NULL;
2012 header->root = root;
2013 sysctl_set_parent(NULL, header->ctl_table);
2014 header->count = 1;
2015 #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
2016 if (sysctl_check_table(namespaces, header->ctl_table)) {
2017 kfree(header);
2018 return NULL;
2020 #endif
2021 spin_lock(&sysctl_lock);
2022 header->set = lookup_header_set(root, namespaces);
2023 header->attached_by = header->ctl_table;
2024 header->attached_to = root_table;
2025 header->parent = &root_table_header;
2026 for (set = header->set; set; set = set->parent) {
2027 struct ctl_table_header *p;
2028 list_for_each_entry(p, &set->list, ctl_entry) {
2029 if (p->unregistering)
2030 continue;
2031 try_attach(p, header);
2034 header->parent->count++;
2035 list_add_tail(&header->ctl_entry, &header->set->list);
2036 spin_unlock(&sysctl_lock);
2038 return header;
2042 * register_sysctl_table_path - register a sysctl table hierarchy
2043 * @path: The path to the directory the sysctl table is in.
2044 * @table: the top-level table structure
2046 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2047 * array. A completely 0 filled entry terminates the table.
2049 * See __register_sysctl_paths for more details.
2051 struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2052 struct ctl_table *table)
2054 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
2055 path, table);
2059 * register_sysctl_table - register a sysctl table hierarchy
2060 * @table: the top-level table structure
2062 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2063 * array. A completely 0 filled entry terminates the table.
2065 * See register_sysctl_paths for more details.
2067 struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
2069 static const struct ctl_path null_path[] = { {} };
2071 return register_sysctl_paths(null_path, table);
2075 * unregister_sysctl_table - unregister a sysctl table hierarchy
2076 * @header: the header returned from register_sysctl_table
2078 * Unregisters the sysctl table and all children. proc entries may not
2079 * actually be removed until they are no longer used by anyone.
2081 void unregister_sysctl_table(struct ctl_table_header * header)
2083 might_sleep();
2085 if (header == NULL)
2086 return;
2088 spin_lock(&sysctl_lock);
2089 start_unregistering(header);
2090 if (!--header->parent->count) {
2091 WARN_ON(1);
2092 kfree(header->parent);
2094 if (!--header->count)
2095 kfree(header);
2096 spin_unlock(&sysctl_lock);
2099 int sysctl_is_seen(struct ctl_table_header *p)
2101 struct ctl_table_set *set = p->set;
2102 int res;
2103 spin_lock(&sysctl_lock);
2104 if (p->unregistering)
2105 res = 0;
2106 else if (!set->is_seen)
2107 res = 1;
2108 else
2109 res = set->is_seen(set);
2110 spin_unlock(&sysctl_lock);
2111 return res;
2114 void setup_sysctl_set(struct ctl_table_set *p,
2115 struct ctl_table_set *parent,
2116 int (*is_seen)(struct ctl_table_set *))
2118 INIT_LIST_HEAD(&p->list);
2119 p->parent = parent ? parent : &sysctl_table_root.default_set;
2120 p->is_seen = is_seen;
2123 #else /* !CONFIG_SYSCTL */
2124 struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
2126 return NULL;
2129 struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2130 struct ctl_table *table)
2132 return NULL;
2135 void unregister_sysctl_table(struct ctl_table_header * table)
2139 void setup_sysctl_set(struct ctl_table_set *p,
2140 struct ctl_table_set *parent,
2141 int (*is_seen)(struct ctl_table_set *))
2145 void sysctl_head_put(struct ctl_table_header *head)
2149 #endif /* CONFIG_SYSCTL */
2152 * /proc/sys support
2155 #ifdef CONFIG_PROC_SYSCTL
2157 static int _proc_do_string(void* data, int maxlen, int write,
2158 struct file *filp, void __user *buffer,
2159 size_t *lenp, loff_t *ppos)
2161 size_t len;
2162 char __user *p;
2163 char c;
2165 if (!data || !maxlen || !*lenp) {
2166 *lenp = 0;
2167 return 0;
2170 if (write) {
2171 len = 0;
2172 p = buffer;
2173 while (len < *lenp) {
2174 if (get_user(c, p++))
2175 return -EFAULT;
2176 if (c == 0 || c == '\n')
2177 break;
2178 len++;
2180 if (len >= maxlen)
2181 len = maxlen-1;
2182 if(copy_from_user(data, buffer, len))
2183 return -EFAULT;
2184 ((char *) data)[len] = 0;
2185 *ppos += *lenp;
2186 } else {
2187 len = strlen(data);
2188 if (len > maxlen)
2189 len = maxlen;
2191 if (*ppos > len) {
2192 *lenp = 0;
2193 return 0;
2196 data += *ppos;
2197 len -= *ppos;
2199 if (len > *lenp)
2200 len = *lenp;
2201 if (len)
2202 if(copy_to_user(buffer, data, len))
2203 return -EFAULT;
2204 if (len < *lenp) {
2205 if(put_user('\n', ((char __user *) buffer) + len))
2206 return -EFAULT;
2207 len++;
2209 *lenp = len;
2210 *ppos += len;
2212 return 0;
2216 * proc_dostring - read a string sysctl
2217 * @table: the sysctl table
2218 * @write: %TRUE if this is a write to the sysctl file
2219 * @filp: the file structure
2220 * @buffer: the user buffer
2221 * @lenp: the size of the user buffer
2222 * @ppos: file position
2224 * Reads/writes a string from/to the user buffer. If the kernel
2225 * buffer provided is not large enough to hold the string, the
2226 * string is truncated. The copied string is %NULL-terminated.
2227 * If the string is being read by the user process, it is copied
2228 * and a newline '\n' is added. It is truncated if the buffer is
2229 * not large enough.
2231 * Returns 0 on success.
2233 int proc_dostring(struct ctl_table *table, int write, struct file *filp,
2234 void __user *buffer, size_t *lenp, loff_t *ppos)
2236 return _proc_do_string(table->data, table->maxlen, write, filp,
2237 buffer, lenp, ppos);
2241 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2242 int *valp,
2243 int write, void *data)
2245 if (write) {
2246 *valp = *negp ? -*lvalp : *lvalp;
2247 } else {
2248 int val = *valp;
2249 if (val < 0) {
2250 *negp = -1;
2251 *lvalp = (unsigned long)-val;
2252 } else {
2253 *negp = 0;
2254 *lvalp = (unsigned long)val;
2257 return 0;
2260 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
2261 int write, struct file *filp, void __user *buffer,
2262 size_t *lenp, loff_t *ppos,
2263 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2264 int write, void *data),
2265 void *data)
2267 #define TMPBUFLEN 21
2268 int *i, vleft, first=1, neg, val;
2269 unsigned long lval;
2270 size_t left, len;
2272 char buf[TMPBUFLEN], *p;
2273 char __user *s = buffer;
2275 if (!tbl_data || !table->maxlen || !*lenp ||
2276 (*ppos && !write)) {
2277 *lenp = 0;
2278 return 0;
2281 i = (int *) tbl_data;
2282 vleft = table->maxlen / sizeof(*i);
2283 left = *lenp;
2285 if (!conv)
2286 conv = do_proc_dointvec_conv;
2288 for (; left && vleft--; i++, first=0) {
2289 if (write) {
2290 while (left) {
2291 char c;
2292 if (get_user(c, s))
2293 return -EFAULT;
2294 if (!isspace(c))
2295 break;
2296 left--;
2297 s++;
2299 if (!left)
2300 break;
2301 neg = 0;
2302 len = left;
2303 if (len > sizeof(buf) - 1)
2304 len = sizeof(buf) - 1;
2305 if (copy_from_user(buf, s, len))
2306 return -EFAULT;
2307 buf[len] = 0;
2308 p = buf;
2309 if (*p == '-' && left > 1) {
2310 neg = 1;
2311 p++;
2313 if (*p < '0' || *p > '9')
2314 break;
2316 lval = simple_strtoul(p, &p, 0);
2318 len = p-buf;
2319 if ((len < left) && *p && !isspace(*p))
2320 break;
2321 if (neg)
2322 val = -val;
2323 s += len;
2324 left -= len;
2326 if (conv(&neg, &lval, i, 1, data))
2327 break;
2328 } else {
2329 p = buf;
2330 if (!first)
2331 *p++ = '\t';
2333 if (conv(&neg, &lval, i, 0, data))
2334 break;
2336 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2337 len = strlen(buf);
2338 if (len > left)
2339 len = left;
2340 if(copy_to_user(s, buf, len))
2341 return -EFAULT;
2342 left -= len;
2343 s += len;
2347 if (!write && !first && left) {
2348 if(put_user('\n', s))
2349 return -EFAULT;
2350 left--, s++;
2352 if (write) {
2353 while (left) {
2354 char c;
2355 if (get_user(c, s++))
2356 return -EFAULT;
2357 if (!isspace(c))
2358 break;
2359 left--;
2362 if (write && first)
2363 return -EINVAL;
2364 *lenp -= left;
2365 *ppos += *lenp;
2366 return 0;
2367 #undef TMPBUFLEN
2370 static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2371 void __user *buffer, size_t *lenp, loff_t *ppos,
2372 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2373 int write, void *data),
2374 void *data)
2376 return __do_proc_dointvec(table->data, table, write, filp,
2377 buffer, lenp, ppos, conv, data);
2381 * proc_dointvec - read a vector of integers
2382 * @table: the sysctl table
2383 * @write: %TRUE if this is a write to the sysctl file
2384 * @filp: the file structure
2385 * @buffer: the user buffer
2386 * @lenp: the size of the user buffer
2387 * @ppos: file position
2389 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2390 * values from/to the user buffer, treated as an ASCII string.
2392 * Returns 0 on success.
2394 int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2395 void __user *buffer, size_t *lenp, loff_t *ppos)
2397 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2398 NULL,NULL);
2402 * Taint values can only be increased
2403 * This means we can safely use a temporary.
2405 static int proc_taint(struct ctl_table *table, int write, struct file *filp,
2406 void __user *buffer, size_t *lenp, loff_t *ppos)
2408 struct ctl_table t;
2409 unsigned long tmptaint = get_taint();
2410 int err;
2412 if (write && !capable(CAP_SYS_ADMIN))
2413 return -EPERM;
2415 t = *table;
2416 t.data = &tmptaint;
2417 err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos);
2418 if (err < 0)
2419 return err;
2421 if (write) {
2423 * Poor man's atomic or. Not worth adding a primitive
2424 * to everyone's atomic.h for this
2426 int i;
2427 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2428 if ((tmptaint >> i) & 1)
2429 add_taint(i);
2433 return err;
2436 struct do_proc_dointvec_minmax_conv_param {
2437 int *min;
2438 int *max;
2441 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2442 int *valp,
2443 int write, void *data)
2445 struct do_proc_dointvec_minmax_conv_param *param = data;
2446 if (write) {
2447 int val = *negp ? -*lvalp : *lvalp;
2448 if ((param->min && *param->min > val) ||
2449 (param->max && *param->max < val))
2450 return -EINVAL;
2451 *valp = val;
2452 } else {
2453 int val = *valp;
2454 if (val < 0) {
2455 *negp = -1;
2456 *lvalp = (unsigned long)-val;
2457 } else {
2458 *negp = 0;
2459 *lvalp = (unsigned long)val;
2462 return 0;
2466 * proc_dointvec_minmax - read a vector of integers with min/max values
2467 * @table: the sysctl table
2468 * @write: %TRUE if this is a write to the sysctl file
2469 * @filp: the file structure
2470 * @buffer: the user buffer
2471 * @lenp: the size of the user buffer
2472 * @ppos: file position
2474 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2475 * values from/to the user buffer, treated as an ASCII string.
2477 * This routine will ensure the values are within the range specified by
2478 * table->extra1 (min) and table->extra2 (max).
2480 * Returns 0 on success.
2482 int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
2483 void __user *buffer, size_t *lenp, loff_t *ppos)
2485 struct do_proc_dointvec_minmax_conv_param param = {
2486 .min = (int *) table->extra1,
2487 .max = (int *) table->extra2,
2489 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2490 do_proc_dointvec_minmax_conv, &param);
2493 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
2494 struct file *filp,
2495 void __user *buffer,
2496 size_t *lenp, loff_t *ppos,
2497 unsigned long convmul,
2498 unsigned long convdiv)
2500 #define TMPBUFLEN 21
2501 unsigned long *i, *min, *max, val;
2502 int vleft, first=1, neg;
2503 size_t len, left;
2504 char buf[TMPBUFLEN], *p;
2505 char __user *s = buffer;
2507 if (!data || !table->maxlen || !*lenp ||
2508 (*ppos && !write)) {
2509 *lenp = 0;
2510 return 0;
2513 i = (unsigned long *) data;
2514 min = (unsigned long *) table->extra1;
2515 max = (unsigned long *) table->extra2;
2516 vleft = table->maxlen / sizeof(unsigned long);
2517 left = *lenp;
2519 for (; left && vleft--; i++, min++, max++, first=0) {
2520 if (write) {
2521 while (left) {
2522 char c;
2523 if (get_user(c, s))
2524 return -EFAULT;
2525 if (!isspace(c))
2526 break;
2527 left--;
2528 s++;
2530 if (!left)
2531 break;
2532 neg = 0;
2533 len = left;
2534 if (len > TMPBUFLEN-1)
2535 len = TMPBUFLEN-1;
2536 if (copy_from_user(buf, s, len))
2537 return -EFAULT;
2538 buf[len] = 0;
2539 p = buf;
2540 if (*p == '-' && left > 1) {
2541 neg = 1;
2542 p++;
2544 if (*p < '0' || *p > '9')
2545 break;
2546 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2547 len = p-buf;
2548 if ((len < left) && *p && !isspace(*p))
2549 break;
2550 if (neg)
2551 val = -val;
2552 s += len;
2553 left -= len;
2555 if(neg)
2556 continue;
2557 if ((min && val < *min) || (max && val > *max))
2558 continue;
2559 *i = val;
2560 } else {
2561 p = buf;
2562 if (!first)
2563 *p++ = '\t';
2564 sprintf(p, "%lu", convdiv * (*i) / convmul);
2565 len = strlen(buf);
2566 if (len > left)
2567 len = left;
2568 if(copy_to_user(s, buf, len))
2569 return -EFAULT;
2570 left -= len;
2571 s += len;
2575 if (!write && !first && left) {
2576 if(put_user('\n', s))
2577 return -EFAULT;
2578 left--, s++;
2580 if (write) {
2581 while (left) {
2582 char c;
2583 if (get_user(c, s++))
2584 return -EFAULT;
2585 if (!isspace(c))
2586 break;
2587 left--;
2590 if (write && first)
2591 return -EINVAL;
2592 *lenp -= left;
2593 *ppos += *lenp;
2594 return 0;
2595 #undef TMPBUFLEN
2598 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2599 struct file *filp,
2600 void __user *buffer,
2601 size_t *lenp, loff_t *ppos,
2602 unsigned long convmul,
2603 unsigned long convdiv)
2605 return __do_proc_doulongvec_minmax(table->data, table, write,
2606 filp, buffer, lenp, ppos, convmul, convdiv);
2610 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2611 * @table: the sysctl table
2612 * @write: %TRUE if this is a write to the sysctl file
2613 * @filp: the file structure
2614 * @buffer: the user buffer
2615 * @lenp: the size of the user buffer
2616 * @ppos: file position
2618 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2619 * values from/to the user buffer, treated as an ASCII string.
2621 * This routine will ensure the values are within the range specified by
2622 * table->extra1 (min) and table->extra2 (max).
2624 * Returns 0 on success.
2626 int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
2627 void __user *buffer, size_t *lenp, loff_t *ppos)
2629 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
2633 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2634 * @table: the sysctl table
2635 * @write: %TRUE if this is a write to the sysctl file
2636 * @filp: the file structure
2637 * @buffer: the user buffer
2638 * @lenp: the size of the user buffer
2639 * @ppos: file position
2641 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2642 * values from/to the user buffer, treated as an ASCII string. The values
2643 * are treated as milliseconds, and converted to jiffies when they are stored.
2645 * This routine will ensure the values are within the range specified by
2646 * table->extra1 (min) and table->extra2 (max).
2648 * Returns 0 on success.
2650 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2651 struct file *filp,
2652 void __user *buffer,
2653 size_t *lenp, loff_t *ppos)
2655 return do_proc_doulongvec_minmax(table, write, filp, buffer,
2656 lenp, ppos, HZ, 1000l);
2660 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2661 int *valp,
2662 int write, void *data)
2664 if (write) {
2665 if (*lvalp > LONG_MAX / HZ)
2666 return 1;
2667 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2668 } else {
2669 int val = *valp;
2670 unsigned long lval;
2671 if (val < 0) {
2672 *negp = -1;
2673 lval = (unsigned long)-val;
2674 } else {
2675 *negp = 0;
2676 lval = (unsigned long)val;
2678 *lvalp = lval / HZ;
2680 return 0;
2683 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2684 int *valp,
2685 int write, void *data)
2687 if (write) {
2688 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2689 return 1;
2690 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2691 } else {
2692 int val = *valp;
2693 unsigned long lval;
2694 if (val < 0) {
2695 *negp = -1;
2696 lval = (unsigned long)-val;
2697 } else {
2698 *negp = 0;
2699 lval = (unsigned long)val;
2701 *lvalp = jiffies_to_clock_t(lval);
2703 return 0;
2706 static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2707 int *valp,
2708 int write, void *data)
2710 if (write) {
2711 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2712 } else {
2713 int val = *valp;
2714 unsigned long lval;
2715 if (val < 0) {
2716 *negp = -1;
2717 lval = (unsigned long)-val;
2718 } else {
2719 *negp = 0;
2720 lval = (unsigned long)val;
2722 *lvalp = jiffies_to_msecs(lval);
2724 return 0;
2728 * proc_dointvec_jiffies - read a vector of integers as seconds
2729 * @table: the sysctl table
2730 * @write: %TRUE if this is a write to the sysctl file
2731 * @filp: the file structure
2732 * @buffer: the user buffer
2733 * @lenp: the size of the user buffer
2734 * @ppos: file position
2736 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2737 * values from/to the user buffer, treated as an ASCII string.
2738 * The values read are assumed to be in seconds, and are converted into
2739 * jiffies.
2741 * Returns 0 on success.
2743 int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
2744 void __user *buffer, size_t *lenp, loff_t *ppos)
2746 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2747 do_proc_dointvec_jiffies_conv,NULL);
2751 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2752 * @table: the sysctl table
2753 * @write: %TRUE if this is a write to the sysctl file
2754 * @filp: the file structure
2755 * @buffer: the user buffer
2756 * @lenp: the size of the user buffer
2757 * @ppos: pointer to the file position
2759 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2760 * values from/to the user buffer, treated as an ASCII string.
2761 * The values read are assumed to be in 1/USER_HZ seconds, and
2762 * are converted into jiffies.
2764 * Returns 0 on success.
2766 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
2767 void __user *buffer, size_t *lenp, loff_t *ppos)
2769 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2770 do_proc_dointvec_userhz_jiffies_conv,NULL);
2774 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2775 * @table: the sysctl table
2776 * @write: %TRUE if this is a write to the sysctl file
2777 * @filp: the file structure
2778 * @buffer: the user buffer
2779 * @lenp: the size of the user buffer
2780 * @ppos: file position
2781 * @ppos: the current position in the file
2783 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2784 * values from/to the user buffer, treated as an ASCII string.
2785 * The values read are assumed to be in 1/1000 seconds, and
2786 * are converted into jiffies.
2788 * Returns 0 on success.
2790 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
2791 void __user *buffer, size_t *lenp, loff_t *ppos)
2793 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2794 do_proc_dointvec_ms_jiffies_conv, NULL);
2797 static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
2798 void __user *buffer, size_t *lenp, loff_t *ppos)
2800 struct pid *new_pid;
2801 pid_t tmp;
2802 int r;
2804 tmp = pid_vnr(cad_pid);
2806 r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
2807 lenp, ppos, NULL, NULL);
2808 if (r || !write)
2809 return r;
2811 new_pid = find_get_pid(tmp);
2812 if (!new_pid)
2813 return -ESRCH;
2815 put_pid(xchg(&cad_pid, new_pid));
2816 return 0;
2819 #else /* CONFIG_PROC_FS */
2821 int proc_dostring(struct ctl_table *table, int write, struct file *filp,
2822 void __user *buffer, size_t *lenp, loff_t *ppos)
2824 return -ENOSYS;
2827 int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2828 void __user *buffer, size_t *lenp, loff_t *ppos)
2830 return -ENOSYS;
2833 int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
2834 void __user *buffer, size_t *lenp, loff_t *ppos)
2836 return -ENOSYS;
2839 int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
2840 void __user *buffer, size_t *lenp, loff_t *ppos)
2842 return -ENOSYS;
2845 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
2846 void __user *buffer, size_t *lenp, loff_t *ppos)
2848 return -ENOSYS;
2851 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
2852 void __user *buffer, size_t *lenp, loff_t *ppos)
2854 return -ENOSYS;
2857 int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
2858 void __user *buffer, size_t *lenp, loff_t *ppos)
2860 return -ENOSYS;
2863 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2864 struct file *filp,
2865 void __user *buffer,
2866 size_t *lenp, loff_t *ppos)
2868 return -ENOSYS;
2872 #endif /* CONFIG_PROC_FS */
2875 #ifdef CONFIG_SYSCTL_SYSCALL
2877 * General sysctl support routines
2880 /* The generic sysctl data routine (used if no strategy routine supplied) */
2881 int sysctl_data(struct ctl_table *table,
2882 void __user *oldval, size_t __user *oldlenp,
2883 void __user *newval, size_t newlen)
2885 size_t len;
2887 /* Get out of I don't have a variable */
2888 if (!table->data || !table->maxlen)
2889 return -ENOTDIR;
2891 if (oldval && oldlenp) {
2892 if (get_user(len, oldlenp))
2893 return -EFAULT;
2894 if (len) {
2895 if (len > table->maxlen)
2896 len = table->maxlen;
2897 if (copy_to_user(oldval, table->data, len))
2898 return -EFAULT;
2899 if (put_user(len, oldlenp))
2900 return -EFAULT;
2904 if (newval && newlen) {
2905 if (newlen > table->maxlen)
2906 newlen = table->maxlen;
2908 if (copy_from_user(table->data, newval, newlen))
2909 return -EFAULT;
2911 return 1;
2914 /* The generic string strategy routine: */
2915 int sysctl_string(struct ctl_table *table,
2916 void __user *oldval, size_t __user *oldlenp,
2917 void __user *newval, size_t newlen)
2919 if (!table->data || !table->maxlen)
2920 return -ENOTDIR;
2922 if (oldval && oldlenp) {
2923 size_t bufsize;
2924 if (get_user(bufsize, oldlenp))
2925 return -EFAULT;
2926 if (bufsize) {
2927 size_t len = strlen(table->data), copied;
2929 /* This shouldn't trigger for a well-formed sysctl */
2930 if (len > table->maxlen)
2931 len = table->maxlen;
2933 /* Copy up to a max of bufsize-1 bytes of the string */
2934 copied = (len >= bufsize) ? bufsize - 1 : len;
2936 if (copy_to_user(oldval, table->data, copied) ||
2937 put_user(0, (char __user *)(oldval + copied)))
2938 return -EFAULT;
2939 if (put_user(len, oldlenp))
2940 return -EFAULT;
2943 if (newval && newlen) {
2944 size_t len = newlen;
2945 if (len > table->maxlen)
2946 len = table->maxlen;
2947 if(copy_from_user(table->data, newval, len))
2948 return -EFAULT;
2949 if (len == table->maxlen)
2950 len--;
2951 ((char *) table->data)[len] = 0;
2953 return 1;
2957 * This function makes sure that all of the integers in the vector
2958 * are between the minimum and maximum values given in the arrays
2959 * table->extra1 and table->extra2, respectively.
2961 int sysctl_intvec(struct ctl_table *table,
2962 void __user *oldval, size_t __user *oldlenp,
2963 void __user *newval, size_t newlen)
2966 if (newval && newlen) {
2967 int __user *vec = (int __user *) newval;
2968 int *min = (int *) table->extra1;
2969 int *max = (int *) table->extra2;
2970 size_t length;
2971 int i;
2973 if (newlen % sizeof(int) != 0)
2974 return -EINVAL;
2976 if (!table->extra1 && !table->extra2)
2977 return 0;
2979 if (newlen > table->maxlen)
2980 newlen = table->maxlen;
2981 length = newlen / sizeof(int);
2983 for (i = 0; i < length; i++) {
2984 int value;
2985 if (get_user(value, vec + i))
2986 return -EFAULT;
2987 if (min && value < min[i])
2988 return -EINVAL;
2989 if (max && value > max[i])
2990 return -EINVAL;
2993 return 0;
2996 /* Strategy function to convert jiffies to seconds */
2997 int sysctl_jiffies(struct ctl_table *table,
2998 void __user *oldval, size_t __user *oldlenp,
2999 void __user *newval, size_t newlen)
3001 if (oldval && oldlenp) {
3002 size_t olen;
3004 if (get_user(olen, oldlenp))
3005 return -EFAULT;
3006 if (olen) {
3007 int val;
3009 if (olen < sizeof(int))
3010 return -EINVAL;
3012 val = *(int *)(table->data) / HZ;
3013 if (put_user(val, (int __user *)oldval))
3014 return -EFAULT;
3015 if (put_user(sizeof(int), oldlenp))
3016 return -EFAULT;
3019 if (newval && newlen) {
3020 int new;
3021 if (newlen != sizeof(int))
3022 return -EINVAL;
3023 if (get_user(new, (int __user *)newval))
3024 return -EFAULT;
3025 *(int *)(table->data) = new*HZ;
3027 return 1;
3030 /* Strategy function to convert jiffies to seconds */
3031 int sysctl_ms_jiffies(struct ctl_table *table,
3032 void __user *oldval, size_t __user *oldlenp,
3033 void __user *newval, size_t newlen)
3035 if (oldval && oldlenp) {
3036 size_t olen;
3038 if (get_user(olen, oldlenp))
3039 return -EFAULT;
3040 if (olen) {
3041 int val;
3043 if (olen < sizeof(int))
3044 return -EINVAL;
3046 val = jiffies_to_msecs(*(int *)(table->data));
3047 if (put_user(val, (int __user *)oldval))
3048 return -EFAULT;
3049 if (put_user(sizeof(int), oldlenp))
3050 return -EFAULT;
3053 if (newval && newlen) {
3054 int new;
3055 if (newlen != sizeof(int))
3056 return -EINVAL;
3057 if (get_user(new, (int __user *)newval))
3058 return -EFAULT;
3059 *(int *)(table->data) = msecs_to_jiffies(new);
3061 return 1;
3066 #else /* CONFIG_SYSCTL_SYSCALL */
3069 SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
3071 struct __sysctl_args tmp;
3072 int error;
3074 if (copy_from_user(&tmp, args, sizeof(tmp)))
3075 return -EFAULT;
3077 error = deprecated_sysctl_warning(&tmp);
3079 /* If no error reading the parameters then just -ENOSYS ... */
3080 if (!error)
3081 error = -ENOSYS;
3083 return error;
3086 int sysctl_data(struct ctl_table *table,
3087 void __user *oldval, size_t __user *oldlenp,
3088 void __user *newval, size_t newlen)
3090 return -ENOSYS;
3093 int sysctl_string(struct ctl_table *table,
3094 void __user *oldval, size_t __user *oldlenp,
3095 void __user *newval, size_t newlen)
3097 return -ENOSYS;
3100 int sysctl_intvec(struct ctl_table *table,
3101 void __user *oldval, size_t __user *oldlenp,
3102 void __user *newval, size_t newlen)
3104 return -ENOSYS;
3107 int sysctl_jiffies(struct ctl_table *table,
3108 void __user *oldval, size_t __user *oldlenp,
3109 void __user *newval, size_t newlen)
3111 return -ENOSYS;
3114 int sysctl_ms_jiffies(struct ctl_table *table,
3115 void __user *oldval, size_t __user *oldlenp,
3116 void __user *newval, size_t newlen)
3118 return -ENOSYS;
3121 #endif /* CONFIG_SYSCTL_SYSCALL */
3123 static int deprecated_sysctl_warning(struct __sysctl_args *args)
3125 static int msg_count;
3126 int name[CTL_MAXNAME];
3127 int i;
3129 /* Check args->nlen. */
3130 if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
3131 return -ENOTDIR;
3133 /* Read in the sysctl name for better debug message logging */
3134 for (i = 0; i < args->nlen; i++)
3135 if (get_user(name[i], args->name + i))
3136 return -EFAULT;
3138 /* Ignore accesses to kernel.version */
3139 if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
3140 return 0;
3142 if (msg_count < 5) {
3143 msg_count++;
3144 printk(KERN_INFO
3145 "warning: process `%s' used the deprecated sysctl "
3146 "system call with ", current->comm);
3147 for (i = 0; i < args->nlen; i++)
3148 printk("%d.", name[i]);
3149 printk("\n");
3151 return 0;
3155 * No sense putting this after each symbol definition, twice,
3156 * exception granted :-)
3158 EXPORT_SYMBOL(proc_dointvec);
3159 EXPORT_SYMBOL(proc_dointvec_jiffies);
3160 EXPORT_SYMBOL(proc_dointvec_minmax);
3161 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3162 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3163 EXPORT_SYMBOL(proc_dostring);
3164 EXPORT_SYMBOL(proc_doulongvec_minmax);
3165 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3166 EXPORT_SYMBOL(register_sysctl_table);
3167 EXPORT_SYMBOL(register_sysctl_paths);
3168 EXPORT_SYMBOL(sysctl_intvec);
3169 EXPORT_SYMBOL(sysctl_jiffies);
3170 EXPORT_SYMBOL(sysctl_ms_jiffies);
3171 EXPORT_SYMBOL(sysctl_string);
3172 EXPORT_SYMBOL(sysctl_data);
3173 EXPORT_SYMBOL(unregister_sysctl_table);