Revert "Revert "ide: try to use PIO Mode 0 during probe if possible""
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / kernel / sysctl.c
blob6ba49c7cb128ed92bf630dde9ee713282a2dce4b
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/kmemcheck.h>
31 #include <linux/smp_lock.h>
32 #include <linux/fs.h>
33 #include <linux/init.h>
34 #include <linux/kernel.h>
35 #include <linux/kobject.h>
36 #include <linux/net.h>
37 #include <linux/sysrq.h>
38 #include <linux/highuid.h>
39 #include <linux/writeback.h>
40 #include <linux/hugetlb.h>
41 #include <linux/initrd.h>
42 #include <linux/key.h>
43 #include <linux/times.h>
44 #include <linux/limits.h>
45 #include <linux/dcache.h>
46 #include <linux/syscalls.h>
47 #include <linux/vmstat.h>
48 #include <linux/nfs_fs.h>
49 #include <linux/acpi.h>
50 #include <linux/reboot.h>
51 #include <linux/ftrace.h>
52 #include <linux/slow-work.h>
53 #include <linux/perf_event.h>
55 #include <asm/uaccess.h>
56 #include <asm/processor.h>
58 #ifdef CONFIG_X86
59 #include <asm/nmi.h>
60 #include <asm/stacktrace.h>
61 #include <asm/io.h>
62 #endif
64 static int deprecated_sysctl_warning(struct __sysctl_args *args);
66 #if defined(CONFIG_SYSCTL)
68 /* External variables not in a header file. */
69 extern int C_A_D;
70 extern int print_fatal_signals;
71 extern int sysctl_overcommit_memory;
72 extern int sysctl_overcommit_ratio;
73 extern int sysctl_panic_on_oom;
74 extern int sysctl_oom_kill_allocating_task;
75 extern int sysctl_oom_dump_tasks;
76 extern int max_threads;
77 extern int core_uses_pid;
78 extern int suid_dumpable;
79 extern char core_pattern[];
80 extern int pid_max;
81 extern int min_free_kbytes;
82 extern int pid_max_min, pid_max_max;
83 extern int sysctl_drop_caches;
84 extern int percpu_pagelist_fraction;
85 extern int compat_log;
86 extern int latencytop_enabled;
87 extern int sysctl_nr_open_min, sysctl_nr_open_max;
88 #ifndef CONFIG_MMU
89 extern int sysctl_nr_trim_pages;
90 #endif
91 #ifdef CONFIG_RCU_TORTURE_TEST
92 extern int rcutorture_runnable;
93 #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
94 #ifdef CONFIG_BLOCK
95 extern int blk_iopoll_enabled;
96 #endif
98 /* Constants used for minimum and maximum */
99 #ifdef CONFIG_DETECT_SOFTLOCKUP
100 static int sixty = 60;
101 static int neg_one = -1;
102 #endif
104 static int zero;
105 static int __maybe_unused one = 1;
106 static int __maybe_unused two = 2;
107 static unsigned long one_ul = 1;
108 static int one_hundred = 100;
110 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
111 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
113 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
114 static int maxolduid = 65535;
115 static int minolduid;
116 static int min_percpu_pagelist_fract = 8;
118 static int ngroups_max = NGROUPS_MAX;
120 #ifdef CONFIG_MODULES
121 extern char modprobe_path[];
122 extern int modules_disabled;
123 #endif
124 #ifdef CONFIG_CHR_DEV_SG
125 extern int sg_big_buff;
126 #endif
128 #ifdef CONFIG_SPARC
129 #include <asm/system.h>
130 #endif
132 #ifdef CONFIG_SPARC64
133 extern int sysctl_tsb_ratio;
134 #endif
136 #ifdef __hppa__
137 extern int pwrsw_enabled;
138 extern int unaligned_enabled;
139 #endif
141 #ifdef CONFIG_S390
142 #ifdef CONFIG_MATHEMU
143 extern int sysctl_ieee_emulation_warnings;
144 #endif
145 extern int sysctl_userprocess_debug;
146 extern int spin_retry;
147 #endif
149 #ifdef CONFIG_BSD_PROCESS_ACCT
150 extern int acct_parm[];
151 #endif
153 #ifdef CONFIG_IA64
154 extern int no_unaligned_warning;
155 extern int unaligned_dump_stack;
156 #endif
158 #ifdef CONFIG_RT_MUTEXES
159 extern int max_lock_depth;
160 #endif
162 #ifdef CONFIG_PROC_SYSCTL
163 static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
164 void __user *buffer, size_t *lenp, loff_t *ppos);
165 static int proc_taint(struct ctl_table *table, int write, struct file *filp,
166 void __user *buffer, size_t *lenp, loff_t *ppos);
167 #endif
169 static struct ctl_table root_table[];
170 static struct ctl_table_root sysctl_table_root;
171 static struct ctl_table_header root_table_header = {
172 .count = 1,
173 .ctl_table = root_table,
174 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
175 .root = &sysctl_table_root,
176 .set = &sysctl_table_root.default_set,
178 static struct ctl_table_root sysctl_table_root = {
179 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
180 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
183 static struct ctl_table kern_table[];
184 static struct ctl_table vm_table[];
185 static struct ctl_table fs_table[];
186 static struct ctl_table debug_table[];
187 static struct ctl_table dev_table[];
188 extern struct ctl_table random_table[];
189 #ifdef CONFIG_INOTIFY_USER
190 extern struct ctl_table inotify_table[];
191 #endif
192 #ifdef CONFIG_EPOLL
193 extern struct ctl_table epoll_table[];
194 #endif
196 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
197 int sysctl_legacy_va_layout;
198 #endif
200 extern int prove_locking;
201 extern int lock_stat;
203 /* The default sysctl tables: */
205 static struct ctl_table root_table[] = {
207 .ctl_name = CTL_KERN,
208 .procname = "kernel",
209 .mode = 0555,
210 .child = kern_table,
213 .ctl_name = CTL_VM,
214 .procname = "vm",
215 .mode = 0555,
216 .child = vm_table,
219 .ctl_name = CTL_FS,
220 .procname = "fs",
221 .mode = 0555,
222 .child = fs_table,
225 .ctl_name = CTL_DEBUG,
226 .procname = "debug",
227 .mode = 0555,
228 .child = debug_table,
231 .ctl_name = CTL_DEV,
232 .procname = "dev",
233 .mode = 0555,
234 .child = dev_table,
237 * NOTE: do not add new entries to this table unless you have read
238 * Documentation/sysctl/ctl_unnumbered.txt
240 { .ctl_name = 0 }
243 #ifdef CONFIG_SCHED_DEBUG
244 static int min_sched_granularity_ns = 100000; /* 100 usecs */
245 static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
246 static int min_wakeup_granularity_ns; /* 0 usecs */
247 static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
248 #endif
250 static struct ctl_table kern_table[] = {
252 .ctl_name = CTL_UNNUMBERED,
253 .procname = "sched_child_runs_first",
254 .data = &sysctl_sched_child_runs_first,
255 .maxlen = sizeof(unsigned int),
256 .mode = 0644,
257 .proc_handler = &proc_dointvec,
259 #ifdef CONFIG_SCHED_DEBUG
261 .ctl_name = CTL_UNNUMBERED,
262 .procname = "sched_min_granularity_ns",
263 .data = &sysctl_sched_min_granularity,
264 .maxlen = sizeof(unsigned int),
265 .mode = 0644,
266 .proc_handler = &sched_nr_latency_handler,
267 .strategy = &sysctl_intvec,
268 .extra1 = &min_sched_granularity_ns,
269 .extra2 = &max_sched_granularity_ns,
272 .ctl_name = CTL_UNNUMBERED,
273 .procname = "sched_latency_ns",
274 .data = &sysctl_sched_latency,
275 .maxlen = sizeof(unsigned int),
276 .mode = 0644,
277 .proc_handler = &sched_nr_latency_handler,
278 .strategy = &sysctl_intvec,
279 .extra1 = &min_sched_granularity_ns,
280 .extra2 = &max_sched_granularity_ns,
283 .ctl_name = CTL_UNNUMBERED,
284 .procname = "sched_wakeup_granularity_ns",
285 .data = &sysctl_sched_wakeup_granularity,
286 .maxlen = sizeof(unsigned int),
287 .mode = 0644,
288 .proc_handler = &proc_dointvec_minmax,
289 .strategy = &sysctl_intvec,
290 .extra1 = &min_wakeup_granularity_ns,
291 .extra2 = &max_wakeup_granularity_ns,
294 .ctl_name = CTL_UNNUMBERED,
295 .procname = "sched_shares_ratelimit",
296 .data = &sysctl_sched_shares_ratelimit,
297 .maxlen = sizeof(unsigned int),
298 .mode = 0644,
299 .proc_handler = &proc_dointvec,
302 .ctl_name = CTL_UNNUMBERED,
303 .procname = "sched_shares_thresh",
304 .data = &sysctl_sched_shares_thresh,
305 .maxlen = sizeof(unsigned int),
306 .mode = 0644,
307 .proc_handler = &proc_dointvec_minmax,
308 .strategy = &sysctl_intvec,
309 .extra1 = &zero,
312 .ctl_name = CTL_UNNUMBERED,
313 .procname = "sched_features",
314 .data = &sysctl_sched_features,
315 .maxlen = sizeof(unsigned int),
316 .mode = 0644,
317 .proc_handler = &proc_dointvec,
320 .ctl_name = CTL_UNNUMBERED,
321 .procname = "sched_migration_cost",
322 .data = &sysctl_sched_migration_cost,
323 .maxlen = sizeof(unsigned int),
324 .mode = 0644,
325 .proc_handler = &proc_dointvec,
328 .ctl_name = CTL_UNNUMBERED,
329 .procname = "sched_nr_migrate",
330 .data = &sysctl_sched_nr_migrate,
331 .maxlen = sizeof(unsigned int),
332 .mode = 0644,
333 .proc_handler = &proc_dointvec,
336 .ctl_name = CTL_UNNUMBERED,
337 .procname = "sched_time_avg",
338 .data = &sysctl_sched_time_avg,
339 .maxlen = sizeof(unsigned int),
340 .mode = 0644,
341 .proc_handler = &proc_dointvec,
344 .ctl_name = CTL_UNNUMBERED,
345 .procname = "timer_migration",
346 .data = &sysctl_timer_migration,
347 .maxlen = sizeof(unsigned int),
348 .mode = 0644,
349 .proc_handler = &proc_dointvec_minmax,
350 .strategy = &sysctl_intvec,
351 .extra1 = &zero,
352 .extra2 = &one,
354 #endif
356 .ctl_name = CTL_UNNUMBERED,
357 .procname = "sched_rt_period_us",
358 .data = &sysctl_sched_rt_period,
359 .maxlen = sizeof(unsigned int),
360 .mode = 0644,
361 .proc_handler = &sched_rt_handler,
364 .ctl_name = CTL_UNNUMBERED,
365 .procname = "sched_rt_runtime_us",
366 .data = &sysctl_sched_rt_runtime,
367 .maxlen = sizeof(int),
368 .mode = 0644,
369 .proc_handler = &sched_rt_handler,
372 .ctl_name = CTL_UNNUMBERED,
373 .procname = "sched_compat_yield",
374 .data = &sysctl_sched_compat_yield,
375 .maxlen = sizeof(unsigned int),
376 .mode = 0644,
377 .proc_handler = &proc_dointvec,
379 #ifdef CONFIG_PROVE_LOCKING
381 .ctl_name = CTL_UNNUMBERED,
382 .procname = "prove_locking",
383 .data = &prove_locking,
384 .maxlen = sizeof(int),
385 .mode = 0644,
386 .proc_handler = &proc_dointvec,
388 #endif
389 #ifdef CONFIG_LOCK_STAT
391 .ctl_name = CTL_UNNUMBERED,
392 .procname = "lock_stat",
393 .data = &lock_stat,
394 .maxlen = sizeof(int),
395 .mode = 0644,
396 .proc_handler = &proc_dointvec,
398 #endif
400 .ctl_name = KERN_PANIC,
401 .procname = "panic",
402 .data = &panic_timeout,
403 .maxlen = sizeof(int),
404 .mode = 0644,
405 .proc_handler = &proc_dointvec,
408 .ctl_name = KERN_CORE_USES_PID,
409 .procname = "core_uses_pid",
410 .data = &core_uses_pid,
411 .maxlen = sizeof(int),
412 .mode = 0644,
413 .proc_handler = &proc_dointvec,
416 .ctl_name = KERN_CORE_PATTERN,
417 .procname = "core_pattern",
418 .data = core_pattern,
419 .maxlen = CORENAME_MAX_SIZE,
420 .mode = 0644,
421 .proc_handler = &proc_dostring,
422 .strategy = &sysctl_string,
424 #ifdef CONFIG_PROC_SYSCTL
426 .procname = "tainted",
427 .maxlen = sizeof(long),
428 .mode = 0644,
429 .proc_handler = &proc_taint,
431 #endif
432 #ifdef CONFIG_LATENCYTOP
434 .procname = "latencytop",
435 .data = &latencytop_enabled,
436 .maxlen = sizeof(int),
437 .mode = 0644,
438 .proc_handler = &proc_dointvec,
440 #endif
441 #ifdef CONFIG_BLK_DEV_INITRD
443 .ctl_name = KERN_REALROOTDEV,
444 .procname = "real-root-dev",
445 .data = &real_root_dev,
446 .maxlen = sizeof(int),
447 .mode = 0644,
448 .proc_handler = &proc_dointvec,
450 #endif
452 .ctl_name = CTL_UNNUMBERED,
453 .procname = "print-fatal-signals",
454 .data = &print_fatal_signals,
455 .maxlen = sizeof(int),
456 .mode = 0644,
457 .proc_handler = &proc_dointvec,
459 #ifdef CONFIG_SPARC
461 .ctl_name = KERN_SPARC_REBOOT,
462 .procname = "reboot-cmd",
463 .data = reboot_command,
464 .maxlen = 256,
465 .mode = 0644,
466 .proc_handler = &proc_dostring,
467 .strategy = &sysctl_string,
470 .ctl_name = KERN_SPARC_STOP_A,
471 .procname = "stop-a",
472 .data = &stop_a_enabled,
473 .maxlen = sizeof (int),
474 .mode = 0644,
475 .proc_handler = &proc_dointvec,
478 .ctl_name = KERN_SPARC_SCONS_PWROFF,
479 .procname = "scons-poweroff",
480 .data = &scons_pwroff,
481 .maxlen = sizeof (int),
482 .mode = 0644,
483 .proc_handler = &proc_dointvec,
485 #endif
486 #ifdef CONFIG_SPARC64
488 .ctl_name = CTL_UNNUMBERED,
489 .procname = "tsb-ratio",
490 .data = &sysctl_tsb_ratio,
491 .maxlen = sizeof (int),
492 .mode = 0644,
493 .proc_handler = &proc_dointvec,
495 #endif
496 #ifdef __hppa__
498 .ctl_name = KERN_HPPA_PWRSW,
499 .procname = "soft-power",
500 .data = &pwrsw_enabled,
501 .maxlen = sizeof (int),
502 .mode = 0644,
503 .proc_handler = &proc_dointvec,
506 .ctl_name = KERN_HPPA_UNALIGNED,
507 .procname = "unaligned-trap",
508 .data = &unaligned_enabled,
509 .maxlen = sizeof (int),
510 .mode = 0644,
511 .proc_handler = &proc_dointvec,
513 #endif
515 .ctl_name = KERN_CTLALTDEL,
516 .procname = "ctrl-alt-del",
517 .data = &C_A_D,
518 .maxlen = sizeof(int),
519 .mode = 0644,
520 .proc_handler = &proc_dointvec,
522 #ifdef CONFIG_FUNCTION_TRACER
524 .ctl_name = CTL_UNNUMBERED,
525 .procname = "ftrace_enabled",
526 .data = &ftrace_enabled,
527 .maxlen = sizeof(int),
528 .mode = 0644,
529 .proc_handler = &ftrace_enable_sysctl,
531 #endif
532 #ifdef CONFIG_STACK_TRACER
534 .ctl_name = CTL_UNNUMBERED,
535 .procname = "stack_tracer_enabled",
536 .data = &stack_tracer_enabled,
537 .maxlen = sizeof(int),
538 .mode = 0644,
539 .proc_handler = &stack_trace_sysctl,
541 #endif
542 #ifdef CONFIG_TRACING
544 .ctl_name = CTL_UNNUMBERED,
545 .procname = "ftrace_dump_on_oops",
546 .data = &ftrace_dump_on_oops,
547 .maxlen = sizeof(int),
548 .mode = 0644,
549 .proc_handler = &proc_dointvec,
551 #endif
552 #ifdef CONFIG_MODULES
554 .ctl_name = KERN_MODPROBE,
555 .procname = "modprobe",
556 .data = &modprobe_path,
557 .maxlen = KMOD_PATH_LEN,
558 .mode = 0644,
559 .proc_handler = &proc_dostring,
560 .strategy = &sysctl_string,
563 .ctl_name = CTL_UNNUMBERED,
564 .procname = "modules_disabled",
565 .data = &modules_disabled,
566 .maxlen = sizeof(int),
567 .mode = 0644,
568 /* only handle a transition from default "0" to "1" */
569 .proc_handler = &proc_dointvec_minmax,
570 .extra1 = &one,
571 .extra2 = &one,
573 #endif
574 #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
576 .ctl_name = KERN_HOTPLUG,
577 .procname = "hotplug",
578 .data = &uevent_helper,
579 .maxlen = UEVENT_HELPER_PATH_LEN,
580 .mode = 0644,
581 .proc_handler = &proc_dostring,
582 .strategy = &sysctl_string,
584 #endif
585 #ifdef CONFIG_CHR_DEV_SG
587 .ctl_name = KERN_SG_BIG_BUFF,
588 .procname = "sg-big-buff",
589 .data = &sg_big_buff,
590 .maxlen = sizeof (int),
591 .mode = 0444,
592 .proc_handler = &proc_dointvec,
594 #endif
595 #ifdef CONFIG_BSD_PROCESS_ACCT
597 .ctl_name = KERN_ACCT,
598 .procname = "acct",
599 .data = &acct_parm,
600 .maxlen = 3*sizeof(int),
601 .mode = 0644,
602 .proc_handler = &proc_dointvec,
604 #endif
605 #ifdef CONFIG_MAGIC_SYSRQ
607 .ctl_name = KERN_SYSRQ,
608 .procname = "sysrq",
609 .data = &__sysrq_enabled,
610 .maxlen = sizeof (int),
611 .mode = 0644,
612 .proc_handler = &proc_dointvec,
614 #endif
615 #ifdef CONFIG_PROC_SYSCTL
617 .procname = "cad_pid",
618 .data = NULL,
619 .maxlen = sizeof (int),
620 .mode = 0600,
621 .proc_handler = &proc_do_cad_pid,
623 #endif
625 .ctl_name = KERN_MAX_THREADS,
626 .procname = "threads-max",
627 .data = &max_threads,
628 .maxlen = sizeof(int),
629 .mode = 0644,
630 .proc_handler = &proc_dointvec,
633 .ctl_name = KERN_RANDOM,
634 .procname = "random",
635 .mode = 0555,
636 .child = random_table,
639 .ctl_name = KERN_OVERFLOWUID,
640 .procname = "overflowuid",
641 .data = &overflowuid,
642 .maxlen = sizeof(int),
643 .mode = 0644,
644 .proc_handler = &proc_dointvec_minmax,
645 .strategy = &sysctl_intvec,
646 .extra1 = &minolduid,
647 .extra2 = &maxolduid,
650 .ctl_name = KERN_OVERFLOWGID,
651 .procname = "overflowgid",
652 .data = &overflowgid,
653 .maxlen = sizeof(int),
654 .mode = 0644,
655 .proc_handler = &proc_dointvec_minmax,
656 .strategy = &sysctl_intvec,
657 .extra1 = &minolduid,
658 .extra2 = &maxolduid,
660 #ifdef CONFIG_S390
661 #ifdef CONFIG_MATHEMU
663 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
664 .procname = "ieee_emulation_warnings",
665 .data = &sysctl_ieee_emulation_warnings,
666 .maxlen = sizeof(int),
667 .mode = 0644,
668 .proc_handler = &proc_dointvec,
670 #endif
672 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
673 .procname = "userprocess_debug",
674 .data = &sysctl_userprocess_debug,
675 .maxlen = sizeof(int),
676 .mode = 0644,
677 .proc_handler = &proc_dointvec,
679 #endif
681 .ctl_name = KERN_PIDMAX,
682 .procname = "pid_max",
683 .data = &pid_max,
684 .maxlen = sizeof (int),
685 .mode = 0644,
686 .proc_handler = &proc_dointvec_minmax,
687 .strategy = sysctl_intvec,
688 .extra1 = &pid_max_min,
689 .extra2 = &pid_max_max,
692 .ctl_name = KERN_PANIC_ON_OOPS,
693 .procname = "panic_on_oops",
694 .data = &panic_on_oops,
695 .maxlen = sizeof(int),
696 .mode = 0644,
697 .proc_handler = &proc_dointvec,
699 #if defined CONFIG_PRINTK
701 .ctl_name = KERN_PRINTK,
702 .procname = "printk",
703 .data = &console_loglevel,
704 .maxlen = 4*sizeof(int),
705 .mode = 0644,
706 .proc_handler = &proc_dointvec,
709 .ctl_name = KERN_PRINTK_RATELIMIT,
710 .procname = "printk_ratelimit",
711 .data = &printk_ratelimit_state.interval,
712 .maxlen = sizeof(int),
713 .mode = 0644,
714 .proc_handler = &proc_dointvec_jiffies,
715 .strategy = &sysctl_jiffies,
718 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
719 .procname = "printk_ratelimit_burst",
720 .data = &printk_ratelimit_state.burst,
721 .maxlen = sizeof(int),
722 .mode = 0644,
723 .proc_handler = &proc_dointvec,
725 #endif
727 .ctl_name = KERN_NGROUPS_MAX,
728 .procname = "ngroups_max",
729 .data = &ngroups_max,
730 .maxlen = sizeof (int),
731 .mode = 0444,
732 .proc_handler = &proc_dointvec,
734 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
736 .ctl_name = KERN_UNKNOWN_NMI_PANIC,
737 .procname = "unknown_nmi_panic",
738 .data = &unknown_nmi_panic,
739 .maxlen = sizeof (int),
740 .mode = 0644,
741 .proc_handler = &proc_dointvec,
744 .procname = "nmi_watchdog",
745 .data = &nmi_watchdog_enabled,
746 .maxlen = sizeof (int),
747 .mode = 0644,
748 .proc_handler = &proc_nmi_enabled,
750 #endif
751 #if defined(CONFIG_X86)
753 .ctl_name = KERN_PANIC_ON_NMI,
754 .procname = "panic_on_unrecovered_nmi",
755 .data = &panic_on_unrecovered_nmi,
756 .maxlen = sizeof(int),
757 .mode = 0644,
758 .proc_handler = &proc_dointvec,
761 .ctl_name = CTL_UNNUMBERED,
762 .procname = "panic_on_io_nmi",
763 .data = &panic_on_io_nmi,
764 .maxlen = sizeof(int),
765 .mode = 0644,
766 .proc_handler = &proc_dointvec,
769 .ctl_name = KERN_BOOTLOADER_TYPE,
770 .procname = "bootloader_type",
771 .data = &bootloader_type,
772 .maxlen = sizeof (int),
773 .mode = 0444,
774 .proc_handler = &proc_dointvec,
777 .ctl_name = CTL_UNNUMBERED,
778 .procname = "bootloader_version",
779 .data = &bootloader_version,
780 .maxlen = sizeof (int),
781 .mode = 0444,
782 .proc_handler = &proc_dointvec,
785 .ctl_name = CTL_UNNUMBERED,
786 .procname = "kstack_depth_to_print",
787 .data = &kstack_depth_to_print,
788 .maxlen = sizeof(int),
789 .mode = 0644,
790 .proc_handler = &proc_dointvec,
793 .ctl_name = CTL_UNNUMBERED,
794 .procname = "io_delay_type",
795 .data = &io_delay_type,
796 .maxlen = sizeof(int),
797 .mode = 0644,
798 .proc_handler = &proc_dointvec,
800 #endif
801 #if defined(CONFIG_MMU)
803 .ctl_name = KERN_RANDOMIZE,
804 .procname = "randomize_va_space",
805 .data = &randomize_va_space,
806 .maxlen = sizeof(int),
807 .mode = 0644,
808 .proc_handler = &proc_dointvec,
810 #endif
811 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
813 .ctl_name = KERN_SPIN_RETRY,
814 .procname = "spin_retry",
815 .data = &spin_retry,
816 .maxlen = sizeof (int),
817 .mode = 0644,
818 .proc_handler = &proc_dointvec,
820 #endif
821 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
823 .procname = "acpi_video_flags",
824 .data = &acpi_realmode_flags,
825 .maxlen = sizeof (unsigned long),
826 .mode = 0644,
827 .proc_handler = &proc_doulongvec_minmax,
829 #endif
830 #ifdef CONFIG_IA64
832 .ctl_name = KERN_IA64_UNALIGNED,
833 .procname = "ignore-unaligned-usertrap",
834 .data = &no_unaligned_warning,
835 .maxlen = sizeof (int),
836 .mode = 0644,
837 .proc_handler = &proc_dointvec,
840 .ctl_name = CTL_UNNUMBERED,
841 .procname = "unaligned-dump-stack",
842 .data = &unaligned_dump_stack,
843 .maxlen = sizeof (int),
844 .mode = 0644,
845 .proc_handler = &proc_dointvec,
847 #endif
848 #ifdef CONFIG_DETECT_SOFTLOCKUP
850 .ctl_name = CTL_UNNUMBERED,
851 .procname = "softlockup_panic",
852 .data = &softlockup_panic,
853 .maxlen = sizeof(int),
854 .mode = 0644,
855 .proc_handler = &proc_dointvec_minmax,
856 .strategy = &sysctl_intvec,
857 .extra1 = &zero,
858 .extra2 = &one,
861 .ctl_name = CTL_UNNUMBERED,
862 .procname = "softlockup_thresh",
863 .data = &softlockup_thresh,
864 .maxlen = sizeof(int),
865 .mode = 0644,
866 .proc_handler = &proc_dosoftlockup_thresh,
867 .strategy = &sysctl_intvec,
868 .extra1 = &neg_one,
869 .extra2 = &sixty,
871 #endif
872 #ifdef CONFIG_DETECT_HUNG_TASK
874 .ctl_name = CTL_UNNUMBERED,
875 .procname = "hung_task_panic",
876 .data = &sysctl_hung_task_panic,
877 .maxlen = sizeof(int),
878 .mode = 0644,
879 .proc_handler = &proc_dointvec_minmax,
880 .strategy = &sysctl_intvec,
881 .extra1 = &zero,
882 .extra2 = &one,
885 .ctl_name = CTL_UNNUMBERED,
886 .procname = "hung_task_check_count",
887 .data = &sysctl_hung_task_check_count,
888 .maxlen = sizeof(unsigned long),
889 .mode = 0644,
890 .proc_handler = &proc_doulongvec_minmax,
891 .strategy = &sysctl_intvec,
894 .ctl_name = CTL_UNNUMBERED,
895 .procname = "hung_task_timeout_secs",
896 .data = &sysctl_hung_task_timeout_secs,
897 .maxlen = sizeof(unsigned long),
898 .mode = 0644,
899 .proc_handler = &proc_dohung_task_timeout_secs,
900 .strategy = &sysctl_intvec,
903 .ctl_name = CTL_UNNUMBERED,
904 .procname = "hung_task_warnings",
905 .data = &sysctl_hung_task_warnings,
906 .maxlen = sizeof(unsigned long),
907 .mode = 0644,
908 .proc_handler = &proc_doulongvec_minmax,
909 .strategy = &sysctl_intvec,
911 #endif
912 #ifdef CONFIG_COMPAT
914 .ctl_name = KERN_COMPAT_LOG,
915 .procname = "compat-log",
916 .data = &compat_log,
917 .maxlen = sizeof (int),
918 .mode = 0644,
919 .proc_handler = &proc_dointvec,
921 #endif
922 #ifdef CONFIG_RT_MUTEXES
924 .ctl_name = KERN_MAX_LOCK_DEPTH,
925 .procname = "max_lock_depth",
926 .data = &max_lock_depth,
927 .maxlen = sizeof(int),
928 .mode = 0644,
929 .proc_handler = &proc_dointvec,
931 #endif
933 .ctl_name = CTL_UNNUMBERED,
934 .procname = "poweroff_cmd",
935 .data = &poweroff_cmd,
936 .maxlen = POWEROFF_CMD_PATH_LEN,
937 .mode = 0644,
938 .proc_handler = &proc_dostring,
939 .strategy = &sysctl_string,
941 #ifdef CONFIG_KEYS
943 .ctl_name = CTL_UNNUMBERED,
944 .procname = "keys",
945 .mode = 0555,
946 .child = key_sysctls,
948 #endif
949 #ifdef CONFIG_RCU_TORTURE_TEST
951 .ctl_name = CTL_UNNUMBERED,
952 .procname = "rcutorture_runnable",
953 .data = &rcutorture_runnable,
954 .maxlen = sizeof(int),
955 .mode = 0644,
956 .proc_handler = &proc_dointvec,
958 #endif
959 #ifdef CONFIG_SLOW_WORK
961 .ctl_name = CTL_UNNUMBERED,
962 .procname = "slow-work",
963 .mode = 0555,
964 .child = slow_work_sysctls,
966 #endif
967 #ifdef CONFIG_PERF_EVENTS
969 .ctl_name = CTL_UNNUMBERED,
970 .procname = "perf_event_paranoid",
971 .data = &sysctl_perf_event_paranoid,
972 .maxlen = sizeof(sysctl_perf_event_paranoid),
973 .mode = 0644,
974 .proc_handler = &proc_dointvec,
977 .ctl_name = CTL_UNNUMBERED,
978 .procname = "perf_event_mlock_kb",
979 .data = &sysctl_perf_event_mlock,
980 .maxlen = sizeof(sysctl_perf_event_mlock),
981 .mode = 0644,
982 .proc_handler = &proc_dointvec,
985 .ctl_name = CTL_UNNUMBERED,
986 .procname = "perf_event_max_sample_rate",
987 .data = &sysctl_perf_event_sample_rate,
988 .maxlen = sizeof(sysctl_perf_event_sample_rate),
989 .mode = 0644,
990 .proc_handler = &proc_dointvec,
992 #endif
993 #ifdef CONFIG_KMEMCHECK
995 .ctl_name = CTL_UNNUMBERED,
996 .procname = "kmemcheck",
997 .data = &kmemcheck_enabled,
998 .maxlen = sizeof(int),
999 .mode = 0644,
1000 .proc_handler = &proc_dointvec,
1002 #endif
1003 #ifdef CONFIG_BLOCK
1005 .ctl_name = CTL_UNNUMBERED,
1006 .procname = "blk_iopoll",
1007 .data = &blk_iopoll_enabled,
1008 .maxlen = sizeof(int),
1009 .mode = 0644,
1010 .proc_handler = &proc_dointvec,
1012 #endif
1014 * NOTE: do not add new entries to this table unless you have read
1015 * Documentation/sysctl/ctl_unnumbered.txt
1017 { .ctl_name = 0 }
1020 static struct ctl_table vm_table[] = {
1022 .ctl_name = VM_OVERCOMMIT_MEMORY,
1023 .procname = "overcommit_memory",
1024 .data = &sysctl_overcommit_memory,
1025 .maxlen = sizeof(sysctl_overcommit_memory),
1026 .mode = 0644,
1027 .proc_handler = &proc_dointvec,
1030 .ctl_name = VM_PANIC_ON_OOM,
1031 .procname = "panic_on_oom",
1032 .data = &sysctl_panic_on_oom,
1033 .maxlen = sizeof(sysctl_panic_on_oom),
1034 .mode = 0644,
1035 .proc_handler = &proc_dointvec,
1038 .ctl_name = CTL_UNNUMBERED,
1039 .procname = "oom_kill_allocating_task",
1040 .data = &sysctl_oom_kill_allocating_task,
1041 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1042 .mode = 0644,
1043 .proc_handler = &proc_dointvec,
1046 .ctl_name = CTL_UNNUMBERED,
1047 .procname = "oom_dump_tasks",
1048 .data = &sysctl_oom_dump_tasks,
1049 .maxlen = sizeof(sysctl_oom_dump_tasks),
1050 .mode = 0644,
1051 .proc_handler = &proc_dointvec,
1054 .ctl_name = VM_OVERCOMMIT_RATIO,
1055 .procname = "overcommit_ratio",
1056 .data = &sysctl_overcommit_ratio,
1057 .maxlen = sizeof(sysctl_overcommit_ratio),
1058 .mode = 0644,
1059 .proc_handler = &proc_dointvec,
1062 .ctl_name = VM_PAGE_CLUSTER,
1063 .procname = "page-cluster",
1064 .data = &page_cluster,
1065 .maxlen = sizeof(int),
1066 .mode = 0644,
1067 .proc_handler = &proc_dointvec,
1070 .ctl_name = VM_DIRTY_BACKGROUND,
1071 .procname = "dirty_background_ratio",
1072 .data = &dirty_background_ratio,
1073 .maxlen = sizeof(dirty_background_ratio),
1074 .mode = 0644,
1075 .proc_handler = &dirty_background_ratio_handler,
1076 .strategy = &sysctl_intvec,
1077 .extra1 = &zero,
1078 .extra2 = &one_hundred,
1081 .ctl_name = CTL_UNNUMBERED,
1082 .procname = "dirty_background_bytes",
1083 .data = &dirty_background_bytes,
1084 .maxlen = sizeof(dirty_background_bytes),
1085 .mode = 0644,
1086 .proc_handler = &dirty_background_bytes_handler,
1087 .strategy = &sysctl_intvec,
1088 .extra1 = &one_ul,
1091 .ctl_name = VM_DIRTY_RATIO,
1092 .procname = "dirty_ratio",
1093 .data = &vm_dirty_ratio,
1094 .maxlen = sizeof(vm_dirty_ratio),
1095 .mode = 0644,
1096 .proc_handler = &dirty_ratio_handler,
1097 .strategy = &sysctl_intvec,
1098 .extra1 = &zero,
1099 .extra2 = &one_hundred,
1102 .ctl_name = CTL_UNNUMBERED,
1103 .procname = "dirty_bytes",
1104 .data = &vm_dirty_bytes,
1105 .maxlen = sizeof(vm_dirty_bytes),
1106 .mode = 0644,
1107 .proc_handler = &dirty_bytes_handler,
1108 .strategy = &sysctl_intvec,
1109 .extra1 = &dirty_bytes_min,
1112 .procname = "dirty_writeback_centisecs",
1113 .data = &dirty_writeback_interval,
1114 .maxlen = sizeof(dirty_writeback_interval),
1115 .mode = 0644,
1116 .proc_handler = &dirty_writeback_centisecs_handler,
1119 .procname = "dirty_expire_centisecs",
1120 .data = &dirty_expire_interval,
1121 .maxlen = sizeof(dirty_expire_interval),
1122 .mode = 0644,
1123 .proc_handler = &proc_dointvec,
1126 .ctl_name = VM_NR_PDFLUSH_THREADS,
1127 .procname = "nr_pdflush_threads",
1128 .data = &nr_pdflush_threads,
1129 .maxlen = sizeof nr_pdflush_threads,
1130 .mode = 0444 /* read-only*/,
1131 .proc_handler = &proc_dointvec,
1134 .ctl_name = VM_SWAPPINESS,
1135 .procname = "swappiness",
1136 .data = &vm_swappiness,
1137 .maxlen = sizeof(vm_swappiness),
1138 .mode = 0644,
1139 .proc_handler = &proc_dointvec_minmax,
1140 .strategy = &sysctl_intvec,
1141 .extra1 = &zero,
1142 .extra2 = &one_hundred,
1144 #ifdef CONFIG_HUGETLB_PAGE
1146 .procname = "nr_hugepages",
1147 .data = NULL,
1148 .maxlen = sizeof(unsigned long),
1149 .mode = 0644,
1150 .proc_handler = &hugetlb_sysctl_handler,
1151 .extra1 = (void *)&hugetlb_zero,
1152 .extra2 = (void *)&hugetlb_infinity,
1155 .ctl_name = VM_HUGETLB_GROUP,
1156 .procname = "hugetlb_shm_group",
1157 .data = &sysctl_hugetlb_shm_group,
1158 .maxlen = sizeof(gid_t),
1159 .mode = 0644,
1160 .proc_handler = &proc_dointvec,
1163 .ctl_name = CTL_UNNUMBERED,
1164 .procname = "hugepages_treat_as_movable",
1165 .data = &hugepages_treat_as_movable,
1166 .maxlen = sizeof(int),
1167 .mode = 0644,
1168 .proc_handler = &hugetlb_treat_movable_handler,
1171 .ctl_name = CTL_UNNUMBERED,
1172 .procname = "nr_overcommit_hugepages",
1173 .data = NULL,
1174 .maxlen = sizeof(unsigned long),
1175 .mode = 0644,
1176 .proc_handler = &hugetlb_overcommit_handler,
1177 .extra1 = (void *)&hugetlb_zero,
1178 .extra2 = (void *)&hugetlb_infinity,
1180 #endif
1182 .ctl_name = VM_LOWMEM_RESERVE_RATIO,
1183 .procname = "lowmem_reserve_ratio",
1184 .data = &sysctl_lowmem_reserve_ratio,
1185 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1186 .mode = 0644,
1187 .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
1188 .strategy = &sysctl_intvec,
1191 .ctl_name = VM_DROP_PAGECACHE,
1192 .procname = "drop_caches",
1193 .data = &sysctl_drop_caches,
1194 .maxlen = sizeof(int),
1195 .mode = 0644,
1196 .proc_handler = drop_caches_sysctl_handler,
1197 .strategy = &sysctl_intvec,
1200 .ctl_name = VM_MIN_FREE_KBYTES,
1201 .procname = "min_free_kbytes",
1202 .data = &min_free_kbytes,
1203 .maxlen = sizeof(min_free_kbytes),
1204 .mode = 0644,
1205 .proc_handler = &min_free_kbytes_sysctl_handler,
1206 .strategy = &sysctl_intvec,
1207 .extra1 = &zero,
1210 .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
1211 .procname = "percpu_pagelist_fraction",
1212 .data = &percpu_pagelist_fraction,
1213 .maxlen = sizeof(percpu_pagelist_fraction),
1214 .mode = 0644,
1215 .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
1216 .strategy = &sysctl_intvec,
1217 .extra1 = &min_percpu_pagelist_fract,
1219 #ifdef CONFIG_MMU
1221 .ctl_name = VM_MAX_MAP_COUNT,
1222 .procname = "max_map_count",
1223 .data = &sysctl_max_map_count,
1224 .maxlen = sizeof(sysctl_max_map_count),
1225 .mode = 0644,
1226 .proc_handler = &proc_dointvec
1228 #else
1230 .ctl_name = CTL_UNNUMBERED,
1231 .procname = "nr_trim_pages",
1232 .data = &sysctl_nr_trim_pages,
1233 .maxlen = sizeof(sysctl_nr_trim_pages),
1234 .mode = 0644,
1235 .proc_handler = &proc_dointvec_minmax,
1236 .strategy = &sysctl_intvec,
1237 .extra1 = &zero,
1239 #endif
1241 .ctl_name = VM_LAPTOP_MODE,
1242 .procname = "laptop_mode",
1243 .data = &laptop_mode,
1244 .maxlen = sizeof(laptop_mode),
1245 .mode = 0644,
1246 .proc_handler = &proc_dointvec_jiffies,
1247 .strategy = &sysctl_jiffies,
1250 .ctl_name = VM_BLOCK_DUMP,
1251 .procname = "block_dump",
1252 .data = &block_dump,
1253 .maxlen = sizeof(block_dump),
1254 .mode = 0644,
1255 .proc_handler = &proc_dointvec,
1256 .strategy = &sysctl_intvec,
1257 .extra1 = &zero,
1260 .ctl_name = VM_VFS_CACHE_PRESSURE,
1261 .procname = "vfs_cache_pressure",
1262 .data = &sysctl_vfs_cache_pressure,
1263 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1264 .mode = 0644,
1265 .proc_handler = &proc_dointvec,
1266 .strategy = &sysctl_intvec,
1267 .extra1 = &zero,
1269 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1271 .ctl_name = VM_LEGACY_VA_LAYOUT,
1272 .procname = "legacy_va_layout",
1273 .data = &sysctl_legacy_va_layout,
1274 .maxlen = sizeof(sysctl_legacy_va_layout),
1275 .mode = 0644,
1276 .proc_handler = &proc_dointvec,
1277 .strategy = &sysctl_intvec,
1278 .extra1 = &zero,
1280 #endif
1281 #ifdef CONFIG_NUMA
1283 .ctl_name = VM_ZONE_RECLAIM_MODE,
1284 .procname = "zone_reclaim_mode",
1285 .data = &zone_reclaim_mode,
1286 .maxlen = sizeof(zone_reclaim_mode),
1287 .mode = 0644,
1288 .proc_handler = &proc_dointvec,
1289 .strategy = &sysctl_intvec,
1290 .extra1 = &zero,
1293 .ctl_name = VM_MIN_UNMAPPED,
1294 .procname = "min_unmapped_ratio",
1295 .data = &sysctl_min_unmapped_ratio,
1296 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1297 .mode = 0644,
1298 .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
1299 .strategy = &sysctl_intvec,
1300 .extra1 = &zero,
1301 .extra2 = &one_hundred,
1304 .ctl_name = VM_MIN_SLAB,
1305 .procname = "min_slab_ratio",
1306 .data = &sysctl_min_slab_ratio,
1307 .maxlen = sizeof(sysctl_min_slab_ratio),
1308 .mode = 0644,
1309 .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
1310 .strategy = &sysctl_intvec,
1311 .extra1 = &zero,
1312 .extra2 = &one_hundred,
1314 #endif
1315 #ifdef CONFIG_SMP
1317 .ctl_name = CTL_UNNUMBERED,
1318 .procname = "stat_interval",
1319 .data = &sysctl_stat_interval,
1320 .maxlen = sizeof(sysctl_stat_interval),
1321 .mode = 0644,
1322 .proc_handler = &proc_dointvec_jiffies,
1323 .strategy = &sysctl_jiffies,
1325 #endif
1327 .ctl_name = CTL_UNNUMBERED,
1328 .procname = "mmap_min_addr",
1329 .data = &dac_mmap_min_addr,
1330 .maxlen = sizeof(unsigned long),
1331 .mode = 0644,
1332 .proc_handler = &mmap_min_addr_handler,
1334 #ifdef CONFIG_NUMA
1336 .ctl_name = CTL_UNNUMBERED,
1337 .procname = "numa_zonelist_order",
1338 .data = &numa_zonelist_order,
1339 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1340 .mode = 0644,
1341 .proc_handler = &numa_zonelist_order_handler,
1342 .strategy = &sysctl_string,
1344 #endif
1345 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1346 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1348 .ctl_name = VM_VDSO_ENABLED,
1349 .procname = "vdso_enabled",
1350 .data = &vdso_enabled,
1351 .maxlen = sizeof(vdso_enabled),
1352 .mode = 0644,
1353 .proc_handler = &proc_dointvec,
1354 .strategy = &sysctl_intvec,
1355 .extra1 = &zero,
1357 #endif
1358 #ifdef CONFIG_HIGHMEM
1360 .ctl_name = CTL_UNNUMBERED,
1361 .procname = "highmem_is_dirtyable",
1362 .data = &vm_highmem_is_dirtyable,
1363 .maxlen = sizeof(vm_highmem_is_dirtyable),
1364 .mode = 0644,
1365 .proc_handler = &proc_dointvec_minmax,
1366 .strategy = &sysctl_intvec,
1367 .extra1 = &zero,
1368 .extra2 = &one,
1370 #endif
1372 .ctl_name = CTL_UNNUMBERED,
1373 .procname = "scan_unevictable_pages",
1374 .data = &scan_unevictable_pages,
1375 .maxlen = sizeof(scan_unevictable_pages),
1376 .mode = 0644,
1377 .proc_handler = &scan_unevictable_handler,
1380 * NOTE: do not add new entries to this table unless you have read
1381 * Documentation/sysctl/ctl_unnumbered.txt
1383 { .ctl_name = 0 }
1386 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1387 static struct ctl_table binfmt_misc_table[] = {
1388 { .ctl_name = 0 }
1390 #endif
1392 static struct ctl_table fs_table[] = {
1394 .ctl_name = FS_NRINODE,
1395 .procname = "inode-nr",
1396 .data = &inodes_stat,
1397 .maxlen = 2*sizeof(int),
1398 .mode = 0444,
1399 .proc_handler = &proc_dointvec,
1402 .ctl_name = FS_STATINODE,
1403 .procname = "inode-state",
1404 .data = &inodes_stat,
1405 .maxlen = 7*sizeof(int),
1406 .mode = 0444,
1407 .proc_handler = &proc_dointvec,
1410 .procname = "file-nr",
1411 .data = &files_stat,
1412 .maxlen = 3*sizeof(int),
1413 .mode = 0444,
1414 .proc_handler = &proc_nr_files,
1417 .ctl_name = FS_MAXFILE,
1418 .procname = "file-max",
1419 .data = &files_stat.max_files,
1420 .maxlen = sizeof(int),
1421 .mode = 0644,
1422 .proc_handler = &proc_dointvec,
1425 .ctl_name = CTL_UNNUMBERED,
1426 .procname = "nr_open",
1427 .data = &sysctl_nr_open,
1428 .maxlen = sizeof(int),
1429 .mode = 0644,
1430 .proc_handler = &proc_dointvec_minmax,
1431 .extra1 = &sysctl_nr_open_min,
1432 .extra2 = &sysctl_nr_open_max,
1435 .ctl_name = FS_DENTRY,
1436 .procname = "dentry-state",
1437 .data = &dentry_stat,
1438 .maxlen = 6*sizeof(int),
1439 .mode = 0444,
1440 .proc_handler = &proc_dointvec,
1443 .ctl_name = FS_OVERFLOWUID,
1444 .procname = "overflowuid",
1445 .data = &fs_overflowuid,
1446 .maxlen = sizeof(int),
1447 .mode = 0644,
1448 .proc_handler = &proc_dointvec_minmax,
1449 .strategy = &sysctl_intvec,
1450 .extra1 = &minolduid,
1451 .extra2 = &maxolduid,
1454 .ctl_name = FS_OVERFLOWGID,
1455 .procname = "overflowgid",
1456 .data = &fs_overflowgid,
1457 .maxlen = sizeof(int),
1458 .mode = 0644,
1459 .proc_handler = &proc_dointvec_minmax,
1460 .strategy = &sysctl_intvec,
1461 .extra1 = &minolduid,
1462 .extra2 = &maxolduid,
1464 #ifdef CONFIG_FILE_LOCKING
1466 .ctl_name = FS_LEASES,
1467 .procname = "leases-enable",
1468 .data = &leases_enable,
1469 .maxlen = sizeof(int),
1470 .mode = 0644,
1471 .proc_handler = &proc_dointvec,
1473 #endif
1474 #ifdef CONFIG_DNOTIFY
1476 .ctl_name = FS_DIR_NOTIFY,
1477 .procname = "dir-notify-enable",
1478 .data = &dir_notify_enable,
1479 .maxlen = sizeof(int),
1480 .mode = 0644,
1481 .proc_handler = &proc_dointvec,
1483 #endif
1484 #ifdef CONFIG_MMU
1485 #ifdef CONFIG_FILE_LOCKING
1487 .ctl_name = FS_LEASE_TIME,
1488 .procname = "lease-break-time",
1489 .data = &lease_break_time,
1490 .maxlen = sizeof(int),
1491 .mode = 0644,
1492 .proc_handler = &proc_dointvec,
1494 #endif
1495 #ifdef CONFIG_AIO
1497 .procname = "aio-nr",
1498 .data = &aio_nr,
1499 .maxlen = sizeof(aio_nr),
1500 .mode = 0444,
1501 .proc_handler = &proc_doulongvec_minmax,
1504 .procname = "aio-max-nr",
1505 .data = &aio_max_nr,
1506 .maxlen = sizeof(aio_max_nr),
1507 .mode = 0644,
1508 .proc_handler = &proc_doulongvec_minmax,
1510 #endif /* CONFIG_AIO */
1511 #ifdef CONFIG_INOTIFY_USER
1513 .ctl_name = FS_INOTIFY,
1514 .procname = "inotify",
1515 .mode = 0555,
1516 .child = inotify_table,
1518 #endif
1519 #ifdef CONFIG_EPOLL
1521 .procname = "epoll",
1522 .mode = 0555,
1523 .child = epoll_table,
1525 #endif
1526 #endif
1528 .ctl_name = KERN_SETUID_DUMPABLE,
1529 .procname = "suid_dumpable",
1530 .data = &suid_dumpable,
1531 .maxlen = sizeof(int),
1532 .mode = 0644,
1533 .proc_handler = &proc_dointvec_minmax,
1534 .strategy = &sysctl_intvec,
1535 .extra1 = &zero,
1536 .extra2 = &two,
1538 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1540 .ctl_name = CTL_UNNUMBERED,
1541 .procname = "binfmt_misc",
1542 .mode = 0555,
1543 .child = binfmt_misc_table,
1545 #endif
1547 * NOTE: do not add new entries to this table unless you have read
1548 * Documentation/sysctl/ctl_unnumbered.txt
1550 { .ctl_name = 0 }
1553 static struct ctl_table debug_table[] = {
1554 #if defined(CONFIG_X86) || defined(CONFIG_PPC)
1556 .ctl_name = CTL_UNNUMBERED,
1557 .procname = "exception-trace",
1558 .data = &show_unhandled_signals,
1559 .maxlen = sizeof(int),
1560 .mode = 0644,
1561 .proc_handler = proc_dointvec
1563 #endif
1564 { .ctl_name = 0 }
1567 static struct ctl_table dev_table[] = {
1568 { .ctl_name = 0 }
1571 static DEFINE_SPINLOCK(sysctl_lock);
1573 /* called under sysctl_lock */
1574 static int use_table(struct ctl_table_header *p)
1576 if (unlikely(p->unregistering))
1577 return 0;
1578 p->used++;
1579 return 1;
1582 /* called under sysctl_lock */
1583 static void unuse_table(struct ctl_table_header *p)
1585 if (!--p->used)
1586 if (unlikely(p->unregistering))
1587 complete(p->unregistering);
1590 /* called under sysctl_lock, will reacquire if has to wait */
1591 static void start_unregistering(struct ctl_table_header *p)
1594 * if p->used is 0, nobody will ever touch that entry again;
1595 * we'll eliminate all paths to it before dropping sysctl_lock
1597 if (unlikely(p->used)) {
1598 struct completion wait;
1599 init_completion(&wait);
1600 p->unregistering = &wait;
1601 spin_unlock(&sysctl_lock);
1602 wait_for_completion(&wait);
1603 spin_lock(&sysctl_lock);
1604 } else {
1605 /* anything non-NULL; we'll never dereference it */
1606 p->unregistering = ERR_PTR(-EINVAL);
1609 * do not remove from the list until nobody holds it; walking the
1610 * list in do_sysctl() relies on that.
1612 list_del_init(&p->ctl_entry);
1615 void sysctl_head_get(struct ctl_table_header *head)
1617 spin_lock(&sysctl_lock);
1618 head->count++;
1619 spin_unlock(&sysctl_lock);
1622 void sysctl_head_put(struct ctl_table_header *head)
1624 spin_lock(&sysctl_lock);
1625 if (!--head->count)
1626 kfree(head);
1627 spin_unlock(&sysctl_lock);
1630 struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1632 if (!head)
1633 BUG();
1634 spin_lock(&sysctl_lock);
1635 if (!use_table(head))
1636 head = ERR_PTR(-ENOENT);
1637 spin_unlock(&sysctl_lock);
1638 return head;
1641 void sysctl_head_finish(struct ctl_table_header *head)
1643 if (!head)
1644 return;
1645 spin_lock(&sysctl_lock);
1646 unuse_table(head);
1647 spin_unlock(&sysctl_lock);
1650 static struct ctl_table_set *
1651 lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1653 struct ctl_table_set *set = &root->default_set;
1654 if (root->lookup)
1655 set = root->lookup(root, namespaces);
1656 return set;
1659 static struct list_head *
1660 lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1662 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1663 return &set->list;
1666 struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1667 struct ctl_table_header *prev)
1669 struct ctl_table_root *root;
1670 struct list_head *header_list;
1671 struct ctl_table_header *head;
1672 struct list_head *tmp;
1674 spin_lock(&sysctl_lock);
1675 if (prev) {
1676 head = prev;
1677 tmp = &prev->ctl_entry;
1678 unuse_table(prev);
1679 goto next;
1681 tmp = &root_table_header.ctl_entry;
1682 for (;;) {
1683 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1685 if (!use_table(head))
1686 goto next;
1687 spin_unlock(&sysctl_lock);
1688 return head;
1689 next:
1690 root = head->root;
1691 tmp = tmp->next;
1692 header_list = lookup_header_list(root, namespaces);
1693 if (tmp != header_list)
1694 continue;
1696 do {
1697 root = list_entry(root->root_list.next,
1698 struct ctl_table_root, root_list);
1699 if (root == &sysctl_table_root)
1700 goto out;
1701 header_list = lookup_header_list(root, namespaces);
1702 } while (list_empty(header_list));
1703 tmp = header_list->next;
1705 out:
1706 spin_unlock(&sysctl_lock);
1707 return NULL;
1710 struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1712 return __sysctl_head_next(current->nsproxy, prev);
1715 void register_sysctl_root(struct ctl_table_root *root)
1717 spin_lock(&sysctl_lock);
1718 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1719 spin_unlock(&sysctl_lock);
1722 #ifdef CONFIG_SYSCTL_SYSCALL
1723 /* Perform the actual read/write of a sysctl table entry. */
1724 static int do_sysctl_strategy(struct ctl_table_root *root,
1725 struct ctl_table *table,
1726 void __user *oldval, size_t __user *oldlenp,
1727 void __user *newval, size_t newlen)
1729 int op = 0, rc;
1731 if (oldval)
1732 op |= MAY_READ;
1733 if (newval)
1734 op |= MAY_WRITE;
1735 if (sysctl_perm(root, table, op))
1736 return -EPERM;
1738 if (table->strategy) {
1739 rc = table->strategy(table, oldval, oldlenp, newval, newlen);
1740 if (rc < 0)
1741 return rc;
1742 if (rc > 0)
1743 return 0;
1746 /* If there is no strategy routine, or if the strategy returns
1747 * zero, proceed with automatic r/w */
1748 if (table->data && table->maxlen) {
1749 rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
1750 if (rc < 0)
1751 return rc;
1753 return 0;
1756 static int parse_table(int __user *name, int nlen,
1757 void __user *oldval, size_t __user *oldlenp,
1758 void __user *newval, size_t newlen,
1759 struct ctl_table_root *root,
1760 struct ctl_table *table)
1762 int n;
1763 repeat:
1764 if (!nlen)
1765 return -ENOTDIR;
1766 if (get_user(n, name))
1767 return -EFAULT;
1768 for ( ; table->ctl_name || table->procname; table++) {
1769 if (!table->ctl_name)
1770 continue;
1771 if (n == table->ctl_name) {
1772 int error;
1773 if (table->child) {
1774 if (sysctl_perm(root, table, MAY_EXEC))
1775 return -EPERM;
1776 name++;
1777 nlen--;
1778 table = table->child;
1779 goto repeat;
1781 error = do_sysctl_strategy(root, table,
1782 oldval, oldlenp,
1783 newval, newlen);
1784 return error;
1787 return -ENOTDIR;
1790 int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1791 void __user *newval, size_t newlen)
1793 struct ctl_table_header *head;
1794 int error = -ENOTDIR;
1796 if (nlen <= 0 || nlen >= CTL_MAXNAME)
1797 return -ENOTDIR;
1798 if (oldval) {
1799 int old_len;
1800 if (!oldlenp || get_user(old_len, oldlenp))
1801 return -EFAULT;
1804 for (head = sysctl_head_next(NULL); head;
1805 head = sysctl_head_next(head)) {
1806 error = parse_table(name, nlen, oldval, oldlenp,
1807 newval, newlen,
1808 head->root, head->ctl_table);
1809 if (error != -ENOTDIR) {
1810 sysctl_head_finish(head);
1811 break;
1814 return error;
1817 SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
1819 struct __sysctl_args tmp;
1820 int error;
1822 if (copy_from_user(&tmp, args, sizeof(tmp)))
1823 return -EFAULT;
1825 error = deprecated_sysctl_warning(&tmp);
1826 if (error)
1827 goto out;
1829 lock_kernel();
1830 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1831 tmp.newval, tmp.newlen);
1832 unlock_kernel();
1833 out:
1834 return error;
1836 #endif /* CONFIG_SYSCTL_SYSCALL */
1839 * sysctl_perm does NOT grant the superuser all rights automatically, because
1840 * some sysctl variables are readonly even to root.
1843 static int test_perm(int mode, int op)
1845 if (!current_euid())
1846 mode >>= 6;
1847 else if (in_egroup_p(0))
1848 mode >>= 3;
1849 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
1850 return 0;
1851 return -EACCES;
1854 int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
1856 int error;
1857 int mode;
1859 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
1860 if (error)
1861 return error;
1863 if (root->permissions)
1864 mode = root->permissions(root, current->nsproxy, table);
1865 else
1866 mode = table->mode;
1868 return test_perm(mode, op);
1871 static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1873 for (; table->ctl_name || table->procname; table++) {
1874 table->parent = parent;
1875 if (table->child)
1876 sysctl_set_parent(table, table->child);
1880 static __init int sysctl_init(void)
1882 sysctl_set_parent(NULL, root_table);
1883 #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1885 int err;
1886 err = sysctl_check_table(current->nsproxy, root_table);
1888 #endif
1889 return 0;
1892 core_initcall(sysctl_init);
1894 static struct ctl_table *is_branch_in(struct ctl_table *branch,
1895 struct ctl_table *table)
1897 struct ctl_table *p;
1898 const char *s = branch->procname;
1900 /* branch should have named subdirectory as its first element */
1901 if (!s || !branch->child)
1902 return NULL;
1904 /* ... and nothing else */
1905 if (branch[1].procname || branch[1].ctl_name)
1906 return NULL;
1908 /* table should contain subdirectory with the same name */
1909 for (p = table; p->procname || p->ctl_name; p++) {
1910 if (!p->child)
1911 continue;
1912 if (p->procname && strcmp(p->procname, s) == 0)
1913 return p;
1915 return NULL;
1918 /* see if attaching q to p would be an improvement */
1919 static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1921 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1922 struct ctl_table *next;
1923 int is_better = 0;
1924 int not_in_parent = !p->attached_by;
1926 while ((next = is_branch_in(by, to)) != NULL) {
1927 if (by == q->attached_by)
1928 is_better = 1;
1929 if (to == p->attached_by)
1930 not_in_parent = 1;
1931 by = by->child;
1932 to = next->child;
1935 if (is_better && not_in_parent) {
1936 q->attached_by = by;
1937 q->attached_to = to;
1938 q->parent = p;
1943 * __register_sysctl_paths - register a sysctl hierarchy
1944 * @root: List of sysctl headers to register on
1945 * @namespaces: Data to compute which lists of sysctl entries are visible
1946 * @path: The path to the directory the sysctl table is in.
1947 * @table: the top-level table structure
1949 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1950 * array. A completely 0 filled entry terminates the table.
1952 * The members of the &struct ctl_table structure are used as follows:
1954 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1955 * must be unique within that level of sysctl
1957 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1958 * enter a sysctl file
1960 * data - a pointer to data for use by proc_handler
1962 * maxlen - the maximum size in bytes of the data
1964 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1966 * child - a pointer to the child sysctl table if this entry is a directory, or
1967 * %NULL.
1969 * proc_handler - the text handler routine (described below)
1971 * strategy - the strategy routine (described below)
1973 * de - for internal use by the sysctl routines
1975 * extra1, extra2 - extra pointers usable by the proc handler routines
1977 * Leaf nodes in the sysctl tree will be represented by a single file
1978 * under /proc; non-leaf nodes will be represented by directories.
1980 * sysctl(2) can automatically manage read and write requests through
1981 * the sysctl table. The data and maxlen fields of the ctl_table
1982 * struct enable minimal validation of the values being written to be
1983 * performed, and the mode field allows minimal authentication.
1985 * More sophisticated management can be enabled by the provision of a
1986 * strategy routine with the table entry. This will be called before
1987 * any automatic read or write of the data is performed.
1989 * The strategy routine may return
1991 * < 0 - Error occurred (error is passed to user process)
1993 * 0 - OK - proceed with automatic read or write.
1995 * > 0 - OK - read or write has been done by the strategy routine, so
1996 * return immediately.
1998 * There must be a proc_handler routine for any terminal nodes
1999 * mirrored under /proc/sys (non-terminals are handled by a built-in
2000 * directory handler). Several default handlers are available to
2001 * cover common cases -
2003 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
2004 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
2005 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
2007 * It is the handler's job to read the input buffer from user memory
2008 * and process it. The handler should return 0 on success.
2010 * This routine returns %NULL on a failure to register, and a pointer
2011 * to the table header on success.
2013 struct ctl_table_header *__register_sysctl_paths(
2014 struct ctl_table_root *root,
2015 struct nsproxy *namespaces,
2016 const struct ctl_path *path, struct ctl_table *table)
2018 struct ctl_table_header *header;
2019 struct ctl_table *new, **prevp;
2020 unsigned int n, npath;
2021 struct ctl_table_set *set;
2023 /* Count the path components */
2024 for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
2028 * For each path component, allocate a 2-element ctl_table array.
2029 * The first array element will be filled with the sysctl entry
2030 * for this, the second will be the sentinel (ctl_name == 0).
2032 * We allocate everything in one go so that we don't have to
2033 * worry about freeing additional memory in unregister_sysctl_table.
2035 header = kzalloc(sizeof(struct ctl_table_header) +
2036 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
2037 if (!header)
2038 return NULL;
2040 new = (struct ctl_table *) (header + 1);
2042 /* Now connect the dots */
2043 prevp = &header->ctl_table;
2044 for (n = 0; n < npath; ++n, ++path) {
2045 /* Copy the procname */
2046 new->procname = path->procname;
2047 new->ctl_name = path->ctl_name;
2048 new->mode = 0555;
2050 *prevp = new;
2051 prevp = &new->child;
2053 new += 2;
2055 *prevp = table;
2056 header->ctl_table_arg = table;
2058 INIT_LIST_HEAD(&header->ctl_entry);
2059 header->used = 0;
2060 header->unregistering = NULL;
2061 header->root = root;
2062 sysctl_set_parent(NULL, header->ctl_table);
2063 header->count = 1;
2064 #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
2065 if (sysctl_check_table(namespaces, header->ctl_table)) {
2066 kfree(header);
2067 return NULL;
2069 #endif
2070 spin_lock(&sysctl_lock);
2071 header->set = lookup_header_set(root, namespaces);
2072 header->attached_by = header->ctl_table;
2073 header->attached_to = root_table;
2074 header->parent = &root_table_header;
2075 for (set = header->set; set; set = set->parent) {
2076 struct ctl_table_header *p;
2077 list_for_each_entry(p, &set->list, ctl_entry) {
2078 if (p->unregistering)
2079 continue;
2080 try_attach(p, header);
2083 header->parent->count++;
2084 list_add_tail(&header->ctl_entry, &header->set->list);
2085 spin_unlock(&sysctl_lock);
2087 return header;
2091 * register_sysctl_table_path - register a sysctl table hierarchy
2092 * @path: The path to the directory the sysctl table is in.
2093 * @table: the top-level table structure
2095 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2096 * array. A completely 0 filled entry terminates the table.
2098 * See __register_sysctl_paths for more details.
2100 struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2101 struct ctl_table *table)
2103 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
2104 path, table);
2108 * register_sysctl_table - register a sysctl table hierarchy
2109 * @table: the top-level table structure
2111 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2112 * array. A completely 0 filled entry terminates the table.
2114 * See register_sysctl_paths for more details.
2116 struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
2118 static const struct ctl_path null_path[] = { {} };
2120 return register_sysctl_paths(null_path, table);
2124 * unregister_sysctl_table - unregister a sysctl table hierarchy
2125 * @header: the header returned from register_sysctl_table
2127 * Unregisters the sysctl table and all children. proc entries may not
2128 * actually be removed until they are no longer used by anyone.
2130 void unregister_sysctl_table(struct ctl_table_header * header)
2132 might_sleep();
2134 if (header == NULL)
2135 return;
2137 spin_lock(&sysctl_lock);
2138 start_unregistering(header);
2139 if (!--header->parent->count) {
2140 WARN_ON(1);
2141 kfree(header->parent);
2143 if (!--header->count)
2144 kfree(header);
2145 spin_unlock(&sysctl_lock);
2148 int sysctl_is_seen(struct ctl_table_header *p)
2150 struct ctl_table_set *set = p->set;
2151 int res;
2152 spin_lock(&sysctl_lock);
2153 if (p->unregistering)
2154 res = 0;
2155 else if (!set->is_seen)
2156 res = 1;
2157 else
2158 res = set->is_seen(set);
2159 spin_unlock(&sysctl_lock);
2160 return res;
2163 void setup_sysctl_set(struct ctl_table_set *p,
2164 struct ctl_table_set *parent,
2165 int (*is_seen)(struct ctl_table_set *))
2167 INIT_LIST_HEAD(&p->list);
2168 p->parent = parent ? parent : &sysctl_table_root.default_set;
2169 p->is_seen = is_seen;
2172 #else /* !CONFIG_SYSCTL */
2173 struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
2175 return NULL;
2178 struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2179 struct ctl_table *table)
2181 return NULL;
2184 void unregister_sysctl_table(struct ctl_table_header * table)
2188 void setup_sysctl_set(struct ctl_table_set *p,
2189 struct ctl_table_set *parent,
2190 int (*is_seen)(struct ctl_table_set *))
2194 void sysctl_head_put(struct ctl_table_header *head)
2198 #endif /* CONFIG_SYSCTL */
2201 * /proc/sys support
2204 #ifdef CONFIG_PROC_SYSCTL
2206 static int _proc_do_string(void* data, int maxlen, int write,
2207 struct file *filp, void __user *buffer,
2208 size_t *lenp, loff_t *ppos)
2210 size_t len;
2211 char __user *p;
2212 char c;
2214 if (!data || !maxlen || !*lenp) {
2215 *lenp = 0;
2216 return 0;
2219 if (write) {
2220 len = 0;
2221 p = buffer;
2222 while (len < *lenp) {
2223 if (get_user(c, p++))
2224 return -EFAULT;
2225 if (c == 0 || c == '\n')
2226 break;
2227 len++;
2229 if (len >= maxlen)
2230 len = maxlen-1;
2231 if(copy_from_user(data, buffer, len))
2232 return -EFAULT;
2233 ((char *) data)[len] = 0;
2234 *ppos += *lenp;
2235 } else {
2236 len = strlen(data);
2237 if (len > maxlen)
2238 len = maxlen;
2240 if (*ppos > len) {
2241 *lenp = 0;
2242 return 0;
2245 data += *ppos;
2246 len -= *ppos;
2248 if (len > *lenp)
2249 len = *lenp;
2250 if (len)
2251 if(copy_to_user(buffer, data, len))
2252 return -EFAULT;
2253 if (len < *lenp) {
2254 if(put_user('\n', ((char __user *) buffer) + len))
2255 return -EFAULT;
2256 len++;
2258 *lenp = len;
2259 *ppos += len;
2261 return 0;
2265 * proc_dostring - read a string sysctl
2266 * @table: the sysctl table
2267 * @write: %TRUE if this is a write to the sysctl file
2268 * @filp: the file structure
2269 * @buffer: the user buffer
2270 * @lenp: the size of the user buffer
2271 * @ppos: file position
2273 * Reads/writes a string from/to the user buffer. If the kernel
2274 * buffer provided is not large enough to hold the string, the
2275 * string is truncated. The copied string is %NULL-terminated.
2276 * If the string is being read by the user process, it is copied
2277 * and a newline '\n' is added. It is truncated if the buffer is
2278 * not large enough.
2280 * Returns 0 on success.
2282 int proc_dostring(struct ctl_table *table, int write, struct file *filp,
2283 void __user *buffer, size_t *lenp, loff_t *ppos)
2285 return _proc_do_string(table->data, table->maxlen, write, filp,
2286 buffer, lenp, ppos);
2290 static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2291 int *valp,
2292 int write, void *data)
2294 if (write) {
2295 *valp = *negp ? -*lvalp : *lvalp;
2296 } else {
2297 int val = *valp;
2298 if (val < 0) {
2299 *negp = -1;
2300 *lvalp = (unsigned long)-val;
2301 } else {
2302 *negp = 0;
2303 *lvalp = (unsigned long)val;
2306 return 0;
2309 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
2310 int write, struct file *filp, void __user *buffer,
2311 size_t *lenp, loff_t *ppos,
2312 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2313 int write, void *data),
2314 void *data)
2316 #define TMPBUFLEN 21
2317 int *i, vleft, first = 1, neg;
2318 unsigned long lval;
2319 size_t left, len;
2321 char buf[TMPBUFLEN], *p;
2322 char __user *s = buffer;
2324 if (!tbl_data || !table->maxlen || !*lenp ||
2325 (*ppos && !write)) {
2326 *lenp = 0;
2327 return 0;
2330 i = (int *) tbl_data;
2331 vleft = table->maxlen / sizeof(*i);
2332 left = *lenp;
2334 if (!conv)
2335 conv = do_proc_dointvec_conv;
2337 for (; left && vleft--; i++, first=0) {
2338 if (write) {
2339 while (left) {
2340 char c;
2341 if (get_user(c, s))
2342 return -EFAULT;
2343 if (!isspace(c))
2344 break;
2345 left--;
2346 s++;
2348 if (!left)
2349 break;
2350 neg = 0;
2351 len = left;
2352 if (len > sizeof(buf) - 1)
2353 len = sizeof(buf) - 1;
2354 if (copy_from_user(buf, s, len))
2355 return -EFAULT;
2356 buf[len] = 0;
2357 p = buf;
2358 if (*p == '-' && left > 1) {
2359 neg = 1;
2360 p++;
2362 if (*p < '0' || *p > '9')
2363 break;
2365 lval = simple_strtoul(p, &p, 0);
2367 len = p-buf;
2368 if ((len < left) && *p && !isspace(*p))
2369 break;
2370 s += len;
2371 left -= len;
2373 if (conv(&neg, &lval, i, 1, data))
2374 break;
2375 } else {
2376 p = buf;
2377 if (!first)
2378 *p++ = '\t';
2380 if (conv(&neg, &lval, i, 0, data))
2381 break;
2383 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2384 len = strlen(buf);
2385 if (len > left)
2386 len = left;
2387 if(copy_to_user(s, buf, len))
2388 return -EFAULT;
2389 left -= len;
2390 s += len;
2394 if (!write && !first && left) {
2395 if(put_user('\n', s))
2396 return -EFAULT;
2397 left--, s++;
2399 if (write) {
2400 while (left) {
2401 char c;
2402 if (get_user(c, s++))
2403 return -EFAULT;
2404 if (!isspace(c))
2405 break;
2406 left--;
2409 if (write && first)
2410 return -EINVAL;
2411 *lenp -= left;
2412 *ppos += *lenp;
2413 return 0;
2414 #undef TMPBUFLEN
2417 static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2418 void __user *buffer, size_t *lenp, loff_t *ppos,
2419 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2420 int write, void *data),
2421 void *data)
2423 return __do_proc_dointvec(table->data, table, write, filp,
2424 buffer, lenp, ppos, conv, data);
2428 * proc_dointvec - read a vector of integers
2429 * @table: the sysctl table
2430 * @write: %TRUE if this is a write to the sysctl file
2431 * @filp: the file structure
2432 * @buffer: the user buffer
2433 * @lenp: the size of the user buffer
2434 * @ppos: file position
2436 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2437 * values from/to the user buffer, treated as an ASCII string.
2439 * Returns 0 on success.
2441 int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2442 void __user *buffer, size_t *lenp, loff_t *ppos)
2444 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2445 NULL,NULL);
2449 * Taint values can only be increased
2450 * This means we can safely use a temporary.
2452 static int proc_taint(struct ctl_table *table, int write, struct file *filp,
2453 void __user *buffer, size_t *lenp, loff_t *ppos)
2455 struct ctl_table t;
2456 unsigned long tmptaint = get_taint();
2457 int err;
2459 if (write && !capable(CAP_SYS_ADMIN))
2460 return -EPERM;
2462 t = *table;
2463 t.data = &tmptaint;
2464 err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos);
2465 if (err < 0)
2466 return err;
2468 if (write) {
2470 * Poor man's atomic or. Not worth adding a primitive
2471 * to everyone's atomic.h for this
2473 int i;
2474 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2475 if ((tmptaint >> i) & 1)
2476 add_taint(i);
2480 return err;
2483 struct do_proc_dointvec_minmax_conv_param {
2484 int *min;
2485 int *max;
2488 static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2489 int *valp,
2490 int write, void *data)
2492 struct do_proc_dointvec_minmax_conv_param *param = data;
2493 if (write) {
2494 int val = *negp ? -*lvalp : *lvalp;
2495 if ((param->min && *param->min > val) ||
2496 (param->max && *param->max < val))
2497 return -EINVAL;
2498 *valp = val;
2499 } else {
2500 int val = *valp;
2501 if (val < 0) {
2502 *negp = -1;
2503 *lvalp = (unsigned long)-val;
2504 } else {
2505 *negp = 0;
2506 *lvalp = (unsigned long)val;
2509 return 0;
2513 * proc_dointvec_minmax - read a vector of integers with min/max values
2514 * @table: the sysctl table
2515 * @write: %TRUE if this is a write to the sysctl file
2516 * @filp: the file structure
2517 * @buffer: the user buffer
2518 * @lenp: the size of the user buffer
2519 * @ppos: file position
2521 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2522 * values from/to the user buffer, treated as an ASCII string.
2524 * This routine will ensure the values are within the range specified by
2525 * table->extra1 (min) and table->extra2 (max).
2527 * Returns 0 on success.
2529 int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
2530 void __user *buffer, size_t *lenp, loff_t *ppos)
2532 struct do_proc_dointvec_minmax_conv_param param = {
2533 .min = (int *) table->extra1,
2534 .max = (int *) table->extra2,
2536 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2537 do_proc_dointvec_minmax_conv, &param);
2540 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
2541 struct file *filp,
2542 void __user *buffer,
2543 size_t *lenp, loff_t *ppos,
2544 unsigned long convmul,
2545 unsigned long convdiv)
2547 #define TMPBUFLEN 21
2548 unsigned long *i, *min, *max, val;
2549 int vleft, first=1, neg;
2550 size_t len, left;
2551 char buf[TMPBUFLEN], *p;
2552 char __user *s = buffer;
2554 if (!data || !table->maxlen || !*lenp ||
2555 (*ppos && !write)) {
2556 *lenp = 0;
2557 return 0;
2560 i = (unsigned long *) data;
2561 min = (unsigned long *) table->extra1;
2562 max = (unsigned long *) table->extra2;
2563 vleft = table->maxlen / sizeof(unsigned long);
2564 left = *lenp;
2566 for (; left && vleft--; i++, min++, max++, first=0) {
2567 if (write) {
2568 while (left) {
2569 char c;
2570 if (get_user(c, s))
2571 return -EFAULT;
2572 if (!isspace(c))
2573 break;
2574 left--;
2575 s++;
2577 if (!left)
2578 break;
2579 neg = 0;
2580 len = left;
2581 if (len > TMPBUFLEN-1)
2582 len = TMPBUFLEN-1;
2583 if (copy_from_user(buf, s, len))
2584 return -EFAULT;
2585 buf[len] = 0;
2586 p = buf;
2587 if (*p == '-' && left > 1) {
2588 neg = 1;
2589 p++;
2591 if (*p < '0' || *p > '9')
2592 break;
2593 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2594 len = p-buf;
2595 if ((len < left) && *p && !isspace(*p))
2596 break;
2597 if (neg)
2598 val = -val;
2599 s += len;
2600 left -= len;
2602 if(neg)
2603 continue;
2604 if ((min && val < *min) || (max && val > *max))
2605 continue;
2606 *i = val;
2607 } else {
2608 p = buf;
2609 if (!first)
2610 *p++ = '\t';
2611 sprintf(p, "%lu", convdiv * (*i) / convmul);
2612 len = strlen(buf);
2613 if (len > left)
2614 len = left;
2615 if(copy_to_user(s, buf, len))
2616 return -EFAULT;
2617 left -= len;
2618 s += len;
2622 if (!write && !first && left) {
2623 if(put_user('\n', s))
2624 return -EFAULT;
2625 left--, s++;
2627 if (write) {
2628 while (left) {
2629 char c;
2630 if (get_user(c, s++))
2631 return -EFAULT;
2632 if (!isspace(c))
2633 break;
2634 left--;
2637 if (write && first)
2638 return -EINVAL;
2639 *lenp -= left;
2640 *ppos += *lenp;
2641 return 0;
2642 #undef TMPBUFLEN
2645 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2646 struct file *filp,
2647 void __user *buffer,
2648 size_t *lenp, loff_t *ppos,
2649 unsigned long convmul,
2650 unsigned long convdiv)
2652 return __do_proc_doulongvec_minmax(table->data, table, write,
2653 filp, buffer, lenp, ppos, convmul, convdiv);
2657 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2658 * @table: the sysctl table
2659 * @write: %TRUE if this is a write to the sysctl file
2660 * @filp: the file structure
2661 * @buffer: the user buffer
2662 * @lenp: the size of the user buffer
2663 * @ppos: file position
2665 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2666 * values from/to the user buffer, treated as an ASCII string.
2668 * This routine will ensure the values are within the range specified by
2669 * table->extra1 (min) and table->extra2 (max).
2671 * Returns 0 on success.
2673 int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
2674 void __user *buffer, size_t *lenp, loff_t *ppos)
2676 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
2680 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2681 * @table: the sysctl table
2682 * @write: %TRUE if this is a write to the sysctl file
2683 * @filp: the file structure
2684 * @buffer: the user buffer
2685 * @lenp: the size of the user buffer
2686 * @ppos: file position
2688 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2689 * values from/to the user buffer, treated as an ASCII string. The values
2690 * are treated as milliseconds, and converted to jiffies when they are stored.
2692 * This routine will ensure the values are within the range specified by
2693 * table->extra1 (min) and table->extra2 (max).
2695 * Returns 0 on success.
2697 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2698 struct file *filp,
2699 void __user *buffer,
2700 size_t *lenp, loff_t *ppos)
2702 return do_proc_doulongvec_minmax(table, write, filp, buffer,
2703 lenp, ppos, HZ, 1000l);
2707 static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2708 int *valp,
2709 int write, void *data)
2711 if (write) {
2712 if (*lvalp > LONG_MAX / HZ)
2713 return 1;
2714 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2715 } else {
2716 int val = *valp;
2717 unsigned long lval;
2718 if (val < 0) {
2719 *negp = -1;
2720 lval = (unsigned long)-val;
2721 } else {
2722 *negp = 0;
2723 lval = (unsigned long)val;
2725 *lvalp = lval / HZ;
2727 return 0;
2730 static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2731 int *valp,
2732 int write, void *data)
2734 if (write) {
2735 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2736 return 1;
2737 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2738 } else {
2739 int val = *valp;
2740 unsigned long lval;
2741 if (val < 0) {
2742 *negp = -1;
2743 lval = (unsigned long)-val;
2744 } else {
2745 *negp = 0;
2746 lval = (unsigned long)val;
2748 *lvalp = jiffies_to_clock_t(lval);
2750 return 0;
2753 static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2754 int *valp,
2755 int write, void *data)
2757 if (write) {
2758 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2759 } else {
2760 int val = *valp;
2761 unsigned long lval;
2762 if (val < 0) {
2763 *negp = -1;
2764 lval = (unsigned long)-val;
2765 } else {
2766 *negp = 0;
2767 lval = (unsigned long)val;
2769 *lvalp = jiffies_to_msecs(lval);
2771 return 0;
2775 * proc_dointvec_jiffies - read a vector of integers as seconds
2776 * @table: the sysctl table
2777 * @write: %TRUE if this is a write to the sysctl file
2778 * @filp: the file structure
2779 * @buffer: the user buffer
2780 * @lenp: the size of the user buffer
2781 * @ppos: file position
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 seconds, and are converted into
2786 * jiffies.
2788 * Returns 0 on success.
2790 int proc_dointvec_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_jiffies_conv,NULL);
2798 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2799 * @table: the sysctl table
2800 * @write: %TRUE if this is a write to the sysctl file
2801 * @filp: the file structure
2802 * @buffer: the user buffer
2803 * @lenp: the size of the user buffer
2804 * @ppos: pointer to the file position
2806 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2807 * values from/to the user buffer, treated as an ASCII string.
2808 * The values read are assumed to be in 1/USER_HZ seconds, and
2809 * are converted into jiffies.
2811 * Returns 0 on success.
2813 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
2814 void __user *buffer, size_t *lenp, loff_t *ppos)
2816 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2817 do_proc_dointvec_userhz_jiffies_conv,NULL);
2821 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2822 * @table: the sysctl table
2823 * @write: %TRUE if this is a write to the sysctl file
2824 * @filp: the file structure
2825 * @buffer: the user buffer
2826 * @lenp: the size of the user buffer
2827 * @ppos: file position
2828 * @ppos: the current position in the file
2830 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2831 * values from/to the user buffer, treated as an ASCII string.
2832 * The values read are assumed to be in 1/1000 seconds, and
2833 * are converted into jiffies.
2835 * Returns 0 on success.
2837 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
2838 void __user *buffer, size_t *lenp, loff_t *ppos)
2840 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2841 do_proc_dointvec_ms_jiffies_conv, NULL);
2844 static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
2845 void __user *buffer, size_t *lenp, loff_t *ppos)
2847 struct pid *new_pid;
2848 pid_t tmp;
2849 int r;
2851 tmp = pid_vnr(cad_pid);
2853 r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
2854 lenp, ppos, NULL, NULL);
2855 if (r || !write)
2856 return r;
2858 new_pid = find_get_pid(tmp);
2859 if (!new_pid)
2860 return -ESRCH;
2862 put_pid(xchg(&cad_pid, new_pid));
2863 return 0;
2866 #else /* CONFIG_PROC_FS */
2868 int proc_dostring(struct ctl_table *table, int write, struct file *filp,
2869 void __user *buffer, size_t *lenp, loff_t *ppos)
2871 return -ENOSYS;
2874 int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2875 void __user *buffer, size_t *lenp, loff_t *ppos)
2877 return -ENOSYS;
2880 int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
2881 void __user *buffer, size_t *lenp, loff_t *ppos)
2883 return -ENOSYS;
2886 int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
2887 void __user *buffer, size_t *lenp, loff_t *ppos)
2889 return -ENOSYS;
2892 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
2893 void __user *buffer, size_t *lenp, loff_t *ppos)
2895 return -ENOSYS;
2898 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
2899 void __user *buffer, size_t *lenp, loff_t *ppos)
2901 return -ENOSYS;
2904 int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
2905 void __user *buffer, size_t *lenp, loff_t *ppos)
2907 return -ENOSYS;
2910 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2911 struct file *filp,
2912 void __user *buffer,
2913 size_t *lenp, loff_t *ppos)
2915 return -ENOSYS;
2919 #endif /* CONFIG_PROC_FS */
2922 #ifdef CONFIG_SYSCTL_SYSCALL
2924 * General sysctl support routines
2927 /* The generic sysctl data routine (used if no strategy routine supplied) */
2928 int sysctl_data(struct ctl_table *table,
2929 void __user *oldval, size_t __user *oldlenp,
2930 void __user *newval, size_t newlen)
2932 size_t len;
2934 /* Get out of I don't have a variable */
2935 if (!table->data || !table->maxlen)
2936 return -ENOTDIR;
2938 if (oldval && oldlenp) {
2939 if (get_user(len, oldlenp))
2940 return -EFAULT;
2941 if (len) {
2942 if (len > table->maxlen)
2943 len = table->maxlen;
2944 if (copy_to_user(oldval, table->data, len))
2945 return -EFAULT;
2946 if (put_user(len, oldlenp))
2947 return -EFAULT;
2951 if (newval && newlen) {
2952 if (newlen > table->maxlen)
2953 newlen = table->maxlen;
2955 if (copy_from_user(table->data, newval, newlen))
2956 return -EFAULT;
2958 return 1;
2961 /* The generic string strategy routine: */
2962 int sysctl_string(struct ctl_table *table,
2963 void __user *oldval, size_t __user *oldlenp,
2964 void __user *newval, size_t newlen)
2966 if (!table->data || !table->maxlen)
2967 return -ENOTDIR;
2969 if (oldval && oldlenp) {
2970 size_t bufsize;
2971 if (get_user(bufsize, oldlenp))
2972 return -EFAULT;
2973 if (bufsize) {
2974 size_t len = strlen(table->data), copied;
2976 /* This shouldn't trigger for a well-formed sysctl */
2977 if (len > table->maxlen)
2978 len = table->maxlen;
2980 /* Copy up to a max of bufsize-1 bytes of the string */
2981 copied = (len >= bufsize) ? bufsize - 1 : len;
2983 if (copy_to_user(oldval, table->data, copied) ||
2984 put_user(0, (char __user *)(oldval + copied)))
2985 return -EFAULT;
2986 if (put_user(len, oldlenp))
2987 return -EFAULT;
2990 if (newval && newlen) {
2991 size_t len = newlen;
2992 if (len > table->maxlen)
2993 len = table->maxlen;
2994 if(copy_from_user(table->data, newval, len))
2995 return -EFAULT;
2996 if (len == table->maxlen)
2997 len--;
2998 ((char *) table->data)[len] = 0;
3000 return 1;
3004 * This function makes sure that all of the integers in the vector
3005 * are between the minimum and maximum values given in the arrays
3006 * table->extra1 and table->extra2, respectively.
3008 int sysctl_intvec(struct ctl_table *table,
3009 void __user *oldval, size_t __user *oldlenp,
3010 void __user *newval, size_t newlen)
3013 if (newval && newlen) {
3014 int __user *vec = (int __user *) newval;
3015 int *min = (int *) table->extra1;
3016 int *max = (int *) table->extra2;
3017 size_t length;
3018 int i;
3020 if (newlen % sizeof(int) != 0)
3021 return -EINVAL;
3023 if (!table->extra1 && !table->extra2)
3024 return 0;
3026 if (newlen > table->maxlen)
3027 newlen = table->maxlen;
3028 length = newlen / sizeof(int);
3030 for (i = 0; i < length; i++) {
3031 int value;
3032 if (get_user(value, vec + i))
3033 return -EFAULT;
3034 if (min && value < min[i])
3035 return -EINVAL;
3036 if (max && value > max[i])
3037 return -EINVAL;
3040 return 0;
3043 /* Strategy function to convert jiffies to seconds */
3044 int sysctl_jiffies(struct ctl_table *table,
3045 void __user *oldval, size_t __user *oldlenp,
3046 void __user *newval, size_t newlen)
3048 if (oldval && oldlenp) {
3049 size_t olen;
3051 if (get_user(olen, oldlenp))
3052 return -EFAULT;
3053 if (olen) {
3054 int val;
3056 if (olen < sizeof(int))
3057 return -EINVAL;
3059 val = *(int *)(table->data) / HZ;
3060 if (put_user(val, (int __user *)oldval))
3061 return -EFAULT;
3062 if (put_user(sizeof(int), oldlenp))
3063 return -EFAULT;
3066 if (newval && newlen) {
3067 int new;
3068 if (newlen != sizeof(int))
3069 return -EINVAL;
3070 if (get_user(new, (int __user *)newval))
3071 return -EFAULT;
3072 *(int *)(table->data) = new*HZ;
3074 return 1;
3077 /* Strategy function to convert jiffies to seconds */
3078 int sysctl_ms_jiffies(struct ctl_table *table,
3079 void __user *oldval, size_t __user *oldlenp,
3080 void __user *newval, size_t newlen)
3082 if (oldval && oldlenp) {
3083 size_t olen;
3085 if (get_user(olen, oldlenp))
3086 return -EFAULT;
3087 if (olen) {
3088 int val;
3090 if (olen < sizeof(int))
3091 return -EINVAL;
3093 val = jiffies_to_msecs(*(int *)(table->data));
3094 if (put_user(val, (int __user *)oldval))
3095 return -EFAULT;
3096 if (put_user(sizeof(int), oldlenp))
3097 return -EFAULT;
3100 if (newval && newlen) {
3101 int new;
3102 if (newlen != sizeof(int))
3103 return -EINVAL;
3104 if (get_user(new, (int __user *)newval))
3105 return -EFAULT;
3106 *(int *)(table->data) = msecs_to_jiffies(new);
3108 return 1;
3113 #else /* CONFIG_SYSCTL_SYSCALL */
3116 SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
3118 struct __sysctl_args tmp;
3119 int error;
3121 if (copy_from_user(&tmp, args, sizeof(tmp)))
3122 return -EFAULT;
3124 error = deprecated_sysctl_warning(&tmp);
3126 /* If no error reading the parameters then just -ENOSYS ... */
3127 if (!error)
3128 error = -ENOSYS;
3130 return error;
3133 int sysctl_data(struct ctl_table *table,
3134 void __user *oldval, size_t __user *oldlenp,
3135 void __user *newval, size_t newlen)
3137 return -ENOSYS;
3140 int sysctl_string(struct ctl_table *table,
3141 void __user *oldval, size_t __user *oldlenp,
3142 void __user *newval, size_t newlen)
3144 return -ENOSYS;
3147 int sysctl_intvec(struct ctl_table *table,
3148 void __user *oldval, size_t __user *oldlenp,
3149 void __user *newval, size_t newlen)
3151 return -ENOSYS;
3154 int sysctl_jiffies(struct ctl_table *table,
3155 void __user *oldval, size_t __user *oldlenp,
3156 void __user *newval, size_t newlen)
3158 return -ENOSYS;
3161 int sysctl_ms_jiffies(struct ctl_table *table,
3162 void __user *oldval, size_t __user *oldlenp,
3163 void __user *newval, size_t newlen)
3165 return -ENOSYS;
3168 #endif /* CONFIG_SYSCTL_SYSCALL */
3170 static int deprecated_sysctl_warning(struct __sysctl_args *args)
3172 static int msg_count;
3173 int name[CTL_MAXNAME];
3174 int i;
3176 /* Check args->nlen. */
3177 if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
3178 return -ENOTDIR;
3180 /* Read in the sysctl name for better debug message logging */
3181 for (i = 0; i < args->nlen; i++)
3182 if (get_user(name[i], args->name + i))
3183 return -EFAULT;
3185 /* Ignore accesses to kernel.version */
3186 if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
3187 return 0;
3189 if (msg_count < 5) {
3190 msg_count++;
3191 printk(KERN_INFO
3192 "warning: process `%s' used the deprecated sysctl "
3193 "system call with ", current->comm);
3194 for (i = 0; i < args->nlen; i++)
3195 printk("%d.", name[i]);
3196 printk("\n");
3198 return 0;
3202 * No sense putting this after each symbol definition, twice,
3203 * exception granted :-)
3205 EXPORT_SYMBOL(proc_dointvec);
3206 EXPORT_SYMBOL(proc_dointvec_jiffies);
3207 EXPORT_SYMBOL(proc_dointvec_minmax);
3208 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3209 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3210 EXPORT_SYMBOL(proc_dostring);
3211 EXPORT_SYMBOL(proc_doulongvec_minmax);
3212 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3213 EXPORT_SYMBOL(register_sysctl_table);
3214 EXPORT_SYMBOL(register_sysctl_paths);
3215 EXPORT_SYMBOL(sysctl_intvec);
3216 EXPORT_SYMBOL(sysctl_jiffies);
3217 EXPORT_SYMBOL(sysctl_ms_jiffies);
3218 EXPORT_SYMBOL(sysctl_string);
3219 EXPORT_SYMBOL(sysctl_data);
3220 EXPORT_SYMBOL(unregister_sysctl_table);