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
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
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>
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/kmemcheck.h>
30 #include <linux/smp_lock.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_event.h>
54 #include <asm/uaccess.h>
55 #include <asm/processor.h>
59 #include <asm/stacktrace.h>
63 static int deprecated_sysctl_warning(struct __sysctl_args
*args
);
65 #if defined(CONFIG_SYSCTL)
67 /* External variables not in a header file. */
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 unsigned int core_pipe_limit
;
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
;
89 extern int sysctl_nr_trim_pages
;
91 #ifdef CONFIG_RCU_TORTURE_TEST
92 extern int rcutorture_runnable
;
93 #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
95 extern int blk_iopoll_enabled
;
98 /* Constants used for minimum and maximum */
99 #ifdef CONFIG_DETECT_SOFTLOCKUP
100 static int sixty
= 60;
101 static int neg_one
= -1;
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 static int ten_thousand
= 10000;
113 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
114 static unsigned long dirty_bytes_min
= 2 * PAGE_SIZE
;
116 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
117 static int maxolduid
= 65535;
118 static int minolduid
;
119 static int min_percpu_pagelist_fract
= 8;
121 static int ngroups_max
= NGROUPS_MAX
;
123 #ifdef CONFIG_MODULES
124 extern char modprobe_path
[];
125 extern int modules_disabled
;
127 #ifdef CONFIG_CHR_DEV_SG
128 extern int sg_big_buff
;
132 #include <asm/system.h>
135 #ifdef CONFIG_SPARC64
136 extern int sysctl_tsb_ratio
;
140 extern int pwrsw_enabled
;
141 extern int unaligned_enabled
;
145 #ifdef CONFIG_MATHEMU
146 extern int sysctl_ieee_emulation_warnings
;
148 extern int sysctl_userprocess_debug
;
149 extern int spin_retry
;
152 #ifdef CONFIG_BSD_PROCESS_ACCT
153 extern int acct_parm
[];
157 extern int no_unaligned_warning
;
158 extern int unaligned_dump_stack
;
161 #ifdef CONFIG_RT_MUTEXES
162 extern int max_lock_depth
;
165 #ifdef CONFIG_PROC_SYSCTL
166 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
167 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
168 static int proc_taint(struct ctl_table
*table
, int write
,
169 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
172 static struct ctl_table root_table
[];
173 static struct ctl_table_root sysctl_table_root
;
174 static struct ctl_table_header root_table_header
= {
176 .ctl_table
= root_table
,
177 .ctl_entry
= LIST_HEAD_INIT(sysctl_table_root
.default_set
.list
),
178 .root
= &sysctl_table_root
,
179 .set
= &sysctl_table_root
.default_set
,
181 static struct ctl_table_root sysctl_table_root
= {
182 .root_list
= LIST_HEAD_INIT(sysctl_table_root
.root_list
),
183 .default_set
.list
= LIST_HEAD_INIT(root_table_header
.ctl_entry
),
186 static struct ctl_table kern_table
[];
187 static struct ctl_table vm_table
[];
188 static struct ctl_table fs_table
[];
189 static struct ctl_table debug_table
[];
190 static struct ctl_table dev_table
[];
191 extern struct ctl_table random_table
[];
192 #ifdef CONFIG_INOTIFY_USER
193 extern struct ctl_table inotify_table
[];
196 extern struct ctl_table epoll_table
[];
199 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
200 int sysctl_legacy_va_layout
;
203 extern int prove_locking
;
204 extern int lock_stat
;
206 /* The default sysctl tables: */
208 static struct ctl_table root_table
[] = {
210 .ctl_name
= CTL_KERN
,
211 .procname
= "kernel",
228 .ctl_name
= CTL_DEBUG
,
231 .child
= debug_table
,
240 * NOTE: do not add new entries to this table unless you have read
241 * Documentation/sysctl/ctl_unnumbered.txt
246 #ifdef CONFIG_SCHED_DEBUG
247 static int min_sched_granularity_ns
= 100000; /* 100 usecs */
248 static int max_sched_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
249 static int min_wakeup_granularity_ns
; /* 0 usecs */
250 static int max_wakeup_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
253 static struct ctl_table kern_table
[] = {
255 .ctl_name
= CTL_UNNUMBERED
,
256 .procname
= "sched_child_runs_first",
257 .data
= &sysctl_sched_child_runs_first
,
258 .maxlen
= sizeof(unsigned int),
260 .proc_handler
= &proc_dointvec
,
262 #ifdef CONFIG_SCHED_DEBUG
264 .ctl_name
= CTL_UNNUMBERED
,
265 .procname
= "sched_min_granularity_ns",
266 .data
= &sysctl_sched_min_granularity
,
267 .maxlen
= sizeof(unsigned int),
269 .proc_handler
= &sched_nr_latency_handler
,
270 .strategy
= &sysctl_intvec
,
271 .extra1
= &min_sched_granularity_ns
,
272 .extra2
= &max_sched_granularity_ns
,
275 .ctl_name
= CTL_UNNUMBERED
,
276 .procname
= "sched_latency_ns",
277 .data
= &sysctl_sched_latency
,
278 .maxlen
= sizeof(unsigned int),
280 .proc_handler
= &sched_nr_latency_handler
,
281 .strategy
= &sysctl_intvec
,
282 .extra1
= &min_sched_granularity_ns
,
283 .extra2
= &max_sched_granularity_ns
,
286 .ctl_name
= CTL_UNNUMBERED
,
287 .procname
= "sched_wakeup_granularity_ns",
288 .data
= &sysctl_sched_wakeup_granularity
,
289 .maxlen
= sizeof(unsigned int),
291 .proc_handler
= &proc_dointvec_minmax
,
292 .strategy
= &sysctl_intvec
,
293 .extra1
= &min_wakeup_granularity_ns
,
294 .extra2
= &max_wakeup_granularity_ns
,
297 .ctl_name
= CTL_UNNUMBERED
,
298 .procname
= "sched_shares_ratelimit",
299 .data
= &sysctl_sched_shares_ratelimit
,
300 .maxlen
= sizeof(unsigned int),
302 .proc_handler
= &proc_dointvec
,
305 .ctl_name
= CTL_UNNUMBERED
,
306 .procname
= "sched_shares_thresh",
307 .data
= &sysctl_sched_shares_thresh
,
308 .maxlen
= sizeof(unsigned int),
310 .proc_handler
= &proc_dointvec_minmax
,
311 .strategy
= &sysctl_intvec
,
315 .ctl_name
= CTL_UNNUMBERED
,
316 .procname
= "sched_features",
317 .data
= &sysctl_sched_features
,
318 .maxlen
= sizeof(unsigned int),
320 .proc_handler
= &proc_dointvec
,
323 .ctl_name
= CTL_UNNUMBERED
,
324 .procname
= "sched_migration_cost",
325 .data
= &sysctl_sched_migration_cost
,
326 .maxlen
= sizeof(unsigned int),
328 .proc_handler
= &proc_dointvec
,
331 .ctl_name
= CTL_UNNUMBERED
,
332 .procname
= "sched_nr_migrate",
333 .data
= &sysctl_sched_nr_migrate
,
334 .maxlen
= sizeof(unsigned int),
336 .proc_handler
= &proc_dointvec
,
339 .ctl_name
= CTL_UNNUMBERED
,
340 .procname
= "sched_time_avg",
341 .data
= &sysctl_sched_time_avg
,
342 .maxlen
= sizeof(unsigned int),
344 .proc_handler
= &proc_dointvec
,
347 .ctl_name
= CTL_UNNUMBERED
,
348 .procname
= "timer_migration",
349 .data
= &sysctl_timer_migration
,
350 .maxlen
= sizeof(unsigned int),
352 .proc_handler
= &proc_dointvec_minmax
,
353 .strategy
= &sysctl_intvec
,
359 .ctl_name
= CTL_UNNUMBERED
,
360 .procname
= "sched_rt_period_us",
361 .data
= &sysctl_sched_rt_period
,
362 .maxlen
= sizeof(unsigned int),
364 .proc_handler
= &sched_rt_handler
,
367 .ctl_name
= CTL_UNNUMBERED
,
368 .procname
= "sched_rt_runtime_us",
369 .data
= &sysctl_sched_rt_runtime
,
370 .maxlen
= sizeof(int),
372 .proc_handler
= &sched_rt_handler
,
375 .ctl_name
= CTL_UNNUMBERED
,
376 .procname
= "sched_compat_yield",
377 .data
= &sysctl_sched_compat_yield
,
378 .maxlen
= sizeof(unsigned int),
380 .proc_handler
= &proc_dointvec
,
382 #ifdef CONFIG_PROVE_LOCKING
384 .ctl_name
= CTL_UNNUMBERED
,
385 .procname
= "prove_locking",
386 .data
= &prove_locking
,
387 .maxlen
= sizeof(int),
389 .proc_handler
= &proc_dointvec
,
392 #ifdef CONFIG_LOCK_STAT
394 .ctl_name
= CTL_UNNUMBERED
,
395 .procname
= "lock_stat",
397 .maxlen
= sizeof(int),
399 .proc_handler
= &proc_dointvec
,
403 .ctl_name
= KERN_PANIC
,
405 .data
= &panic_timeout
,
406 .maxlen
= sizeof(int),
408 .proc_handler
= &proc_dointvec
,
411 .ctl_name
= KERN_CORE_USES_PID
,
412 .procname
= "core_uses_pid",
413 .data
= &core_uses_pid
,
414 .maxlen
= sizeof(int),
416 .proc_handler
= &proc_dointvec
,
419 .ctl_name
= KERN_CORE_PATTERN
,
420 .procname
= "core_pattern",
421 .data
= core_pattern
,
422 .maxlen
= CORENAME_MAX_SIZE
,
424 .proc_handler
= &proc_dostring
,
425 .strategy
= &sysctl_string
,
428 .ctl_name
= CTL_UNNUMBERED
,
429 .procname
= "core_pipe_limit",
430 .data
= &core_pipe_limit
,
431 .maxlen
= sizeof(unsigned int),
433 .proc_handler
= &proc_dointvec
,
435 #ifdef CONFIG_PROC_SYSCTL
437 .procname
= "tainted",
438 .maxlen
= sizeof(long),
440 .proc_handler
= &proc_taint
,
443 #ifdef CONFIG_LATENCYTOP
445 .procname
= "latencytop",
446 .data
= &latencytop_enabled
,
447 .maxlen
= sizeof(int),
449 .proc_handler
= &proc_dointvec
,
452 #ifdef CONFIG_BLK_DEV_INITRD
454 .ctl_name
= KERN_REALROOTDEV
,
455 .procname
= "real-root-dev",
456 .data
= &real_root_dev
,
457 .maxlen
= sizeof(int),
459 .proc_handler
= &proc_dointvec
,
463 .ctl_name
= CTL_UNNUMBERED
,
464 .procname
= "print-fatal-signals",
465 .data
= &print_fatal_signals
,
466 .maxlen
= sizeof(int),
468 .proc_handler
= &proc_dointvec
,
472 .ctl_name
= KERN_SPARC_REBOOT
,
473 .procname
= "reboot-cmd",
474 .data
= reboot_command
,
477 .proc_handler
= &proc_dostring
,
478 .strategy
= &sysctl_string
,
481 .ctl_name
= KERN_SPARC_STOP_A
,
482 .procname
= "stop-a",
483 .data
= &stop_a_enabled
,
484 .maxlen
= sizeof (int),
486 .proc_handler
= &proc_dointvec
,
489 .ctl_name
= KERN_SPARC_SCONS_PWROFF
,
490 .procname
= "scons-poweroff",
491 .data
= &scons_pwroff
,
492 .maxlen
= sizeof (int),
494 .proc_handler
= &proc_dointvec
,
497 #ifdef CONFIG_SPARC64
499 .ctl_name
= CTL_UNNUMBERED
,
500 .procname
= "tsb-ratio",
501 .data
= &sysctl_tsb_ratio
,
502 .maxlen
= sizeof (int),
504 .proc_handler
= &proc_dointvec
,
509 .ctl_name
= KERN_HPPA_PWRSW
,
510 .procname
= "soft-power",
511 .data
= &pwrsw_enabled
,
512 .maxlen
= sizeof (int),
514 .proc_handler
= &proc_dointvec
,
517 .ctl_name
= KERN_HPPA_UNALIGNED
,
518 .procname
= "unaligned-trap",
519 .data
= &unaligned_enabled
,
520 .maxlen
= sizeof (int),
522 .proc_handler
= &proc_dointvec
,
526 .ctl_name
= KERN_CTLALTDEL
,
527 .procname
= "ctrl-alt-del",
529 .maxlen
= sizeof(int),
531 .proc_handler
= &proc_dointvec
,
533 #ifdef CONFIG_FUNCTION_TRACER
535 .ctl_name
= CTL_UNNUMBERED
,
536 .procname
= "ftrace_enabled",
537 .data
= &ftrace_enabled
,
538 .maxlen
= sizeof(int),
540 .proc_handler
= &ftrace_enable_sysctl
,
543 #ifdef CONFIG_STACK_TRACER
545 .ctl_name
= CTL_UNNUMBERED
,
546 .procname
= "stack_tracer_enabled",
547 .data
= &stack_tracer_enabled
,
548 .maxlen
= sizeof(int),
550 .proc_handler
= &stack_trace_sysctl
,
553 #ifdef CONFIG_TRACING
555 .ctl_name
= CTL_UNNUMBERED
,
556 .procname
= "ftrace_dump_on_oops",
557 .data
= &ftrace_dump_on_oops
,
558 .maxlen
= sizeof(int),
560 .proc_handler
= &proc_dointvec
,
563 #ifdef CONFIG_MODULES
565 .ctl_name
= KERN_MODPROBE
,
566 .procname
= "modprobe",
567 .data
= &modprobe_path
,
568 .maxlen
= KMOD_PATH_LEN
,
570 .proc_handler
= &proc_dostring
,
571 .strategy
= &sysctl_string
,
574 .ctl_name
= CTL_UNNUMBERED
,
575 .procname
= "modules_disabled",
576 .data
= &modules_disabled
,
577 .maxlen
= sizeof(int),
579 /* only handle a transition from default "0" to "1" */
580 .proc_handler
= &proc_dointvec_minmax
,
585 #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
587 .ctl_name
= KERN_HOTPLUG
,
588 .procname
= "hotplug",
589 .data
= &uevent_helper
,
590 .maxlen
= UEVENT_HELPER_PATH_LEN
,
592 .proc_handler
= &proc_dostring
,
593 .strategy
= &sysctl_string
,
596 #ifdef CONFIG_CHR_DEV_SG
598 .ctl_name
= KERN_SG_BIG_BUFF
,
599 .procname
= "sg-big-buff",
600 .data
= &sg_big_buff
,
601 .maxlen
= sizeof (int),
603 .proc_handler
= &proc_dointvec
,
606 #ifdef CONFIG_BSD_PROCESS_ACCT
608 .ctl_name
= KERN_ACCT
,
611 .maxlen
= 3*sizeof(int),
613 .proc_handler
= &proc_dointvec
,
616 #ifdef CONFIG_MAGIC_SYSRQ
618 .ctl_name
= KERN_SYSRQ
,
620 .data
= &__sysrq_enabled
,
621 .maxlen
= sizeof (int),
623 .proc_handler
= &proc_dointvec
,
626 #ifdef CONFIG_PROC_SYSCTL
628 .procname
= "cad_pid",
630 .maxlen
= sizeof (int),
632 .proc_handler
= &proc_do_cad_pid
,
636 .ctl_name
= KERN_MAX_THREADS
,
637 .procname
= "threads-max",
638 .data
= &max_threads
,
639 .maxlen
= sizeof(int),
641 .proc_handler
= &proc_dointvec
,
644 .ctl_name
= KERN_RANDOM
,
645 .procname
= "random",
647 .child
= random_table
,
650 .ctl_name
= KERN_OVERFLOWUID
,
651 .procname
= "overflowuid",
652 .data
= &overflowuid
,
653 .maxlen
= sizeof(int),
655 .proc_handler
= &proc_dointvec_minmax
,
656 .strategy
= &sysctl_intvec
,
657 .extra1
= &minolduid
,
658 .extra2
= &maxolduid
,
661 .ctl_name
= KERN_OVERFLOWGID
,
662 .procname
= "overflowgid",
663 .data
= &overflowgid
,
664 .maxlen
= sizeof(int),
666 .proc_handler
= &proc_dointvec_minmax
,
667 .strategy
= &sysctl_intvec
,
668 .extra1
= &minolduid
,
669 .extra2
= &maxolduid
,
672 #ifdef CONFIG_MATHEMU
674 .ctl_name
= KERN_IEEE_EMULATION_WARNINGS
,
675 .procname
= "ieee_emulation_warnings",
676 .data
= &sysctl_ieee_emulation_warnings
,
677 .maxlen
= sizeof(int),
679 .proc_handler
= &proc_dointvec
,
683 .ctl_name
= KERN_S390_USER_DEBUG_LOGGING
,
684 .procname
= "userprocess_debug",
685 .data
= &sysctl_userprocess_debug
,
686 .maxlen
= sizeof(int),
688 .proc_handler
= &proc_dointvec
,
692 .ctl_name
= KERN_PIDMAX
,
693 .procname
= "pid_max",
695 .maxlen
= sizeof (int),
697 .proc_handler
= &proc_dointvec_minmax
,
698 .strategy
= sysctl_intvec
,
699 .extra1
= &pid_max_min
,
700 .extra2
= &pid_max_max
,
703 .ctl_name
= KERN_PANIC_ON_OOPS
,
704 .procname
= "panic_on_oops",
705 .data
= &panic_on_oops
,
706 .maxlen
= sizeof(int),
708 .proc_handler
= &proc_dointvec
,
710 #if defined CONFIG_PRINTK
712 .ctl_name
= KERN_PRINTK
,
713 .procname
= "printk",
714 .data
= &console_loglevel
,
715 .maxlen
= 4*sizeof(int),
717 .proc_handler
= &proc_dointvec
,
720 .ctl_name
= KERN_PRINTK_RATELIMIT
,
721 .procname
= "printk_ratelimit",
722 .data
= &printk_ratelimit_state
.interval
,
723 .maxlen
= sizeof(int),
725 .proc_handler
= &proc_dointvec_jiffies
,
726 .strategy
= &sysctl_jiffies
,
729 .ctl_name
= KERN_PRINTK_RATELIMIT_BURST
,
730 .procname
= "printk_ratelimit_burst",
731 .data
= &printk_ratelimit_state
.burst
,
732 .maxlen
= sizeof(int),
734 .proc_handler
= &proc_dointvec
,
737 .ctl_name
= CTL_UNNUMBERED
,
738 .procname
= "printk_delay",
739 .data
= &printk_delay_msec
,
740 .maxlen
= sizeof(int),
742 .proc_handler
= &proc_dointvec_minmax
,
743 .strategy
= &sysctl_intvec
,
745 .extra2
= &ten_thousand
,
749 .ctl_name
= KERN_NGROUPS_MAX
,
750 .procname
= "ngroups_max",
751 .data
= &ngroups_max
,
752 .maxlen
= sizeof (int),
754 .proc_handler
= &proc_dointvec
,
756 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
758 .ctl_name
= KERN_UNKNOWN_NMI_PANIC
,
759 .procname
= "unknown_nmi_panic",
760 .data
= &unknown_nmi_panic
,
761 .maxlen
= sizeof (int),
763 .proc_handler
= &proc_dointvec
,
766 .procname
= "nmi_watchdog",
767 .data
= &nmi_watchdog_enabled
,
768 .maxlen
= sizeof (int),
770 .proc_handler
= &proc_nmi_enabled
,
773 #if defined(CONFIG_X86)
775 .ctl_name
= KERN_PANIC_ON_NMI
,
776 .procname
= "panic_on_unrecovered_nmi",
777 .data
= &panic_on_unrecovered_nmi
,
778 .maxlen
= sizeof(int),
780 .proc_handler
= &proc_dointvec
,
783 .ctl_name
= CTL_UNNUMBERED
,
784 .procname
= "panic_on_io_nmi",
785 .data
= &panic_on_io_nmi
,
786 .maxlen
= sizeof(int),
788 .proc_handler
= &proc_dointvec
,
791 .ctl_name
= KERN_BOOTLOADER_TYPE
,
792 .procname
= "bootloader_type",
793 .data
= &bootloader_type
,
794 .maxlen
= sizeof (int),
796 .proc_handler
= &proc_dointvec
,
799 .ctl_name
= CTL_UNNUMBERED
,
800 .procname
= "bootloader_version",
801 .data
= &bootloader_version
,
802 .maxlen
= sizeof (int),
804 .proc_handler
= &proc_dointvec
,
807 .ctl_name
= CTL_UNNUMBERED
,
808 .procname
= "kstack_depth_to_print",
809 .data
= &kstack_depth_to_print
,
810 .maxlen
= sizeof(int),
812 .proc_handler
= &proc_dointvec
,
815 .ctl_name
= CTL_UNNUMBERED
,
816 .procname
= "io_delay_type",
817 .data
= &io_delay_type
,
818 .maxlen
= sizeof(int),
820 .proc_handler
= &proc_dointvec
,
823 #if defined(CONFIG_MMU)
825 .ctl_name
= KERN_RANDOMIZE
,
826 .procname
= "randomize_va_space",
827 .data
= &randomize_va_space
,
828 .maxlen
= sizeof(int),
830 .proc_handler
= &proc_dointvec
,
833 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
835 .ctl_name
= KERN_SPIN_RETRY
,
836 .procname
= "spin_retry",
838 .maxlen
= sizeof (int),
840 .proc_handler
= &proc_dointvec
,
843 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
845 .procname
= "acpi_video_flags",
846 .data
= &acpi_realmode_flags
,
847 .maxlen
= sizeof (unsigned long),
849 .proc_handler
= &proc_doulongvec_minmax
,
854 .ctl_name
= KERN_IA64_UNALIGNED
,
855 .procname
= "ignore-unaligned-usertrap",
856 .data
= &no_unaligned_warning
,
857 .maxlen
= sizeof (int),
859 .proc_handler
= &proc_dointvec
,
862 .ctl_name
= CTL_UNNUMBERED
,
863 .procname
= "unaligned-dump-stack",
864 .data
= &unaligned_dump_stack
,
865 .maxlen
= sizeof (int),
867 .proc_handler
= &proc_dointvec
,
870 #ifdef CONFIG_DETECT_SOFTLOCKUP
872 .ctl_name
= CTL_UNNUMBERED
,
873 .procname
= "softlockup_panic",
874 .data
= &softlockup_panic
,
875 .maxlen
= sizeof(int),
877 .proc_handler
= &proc_dointvec_minmax
,
878 .strategy
= &sysctl_intvec
,
883 .ctl_name
= CTL_UNNUMBERED
,
884 .procname
= "softlockup_thresh",
885 .data
= &softlockup_thresh
,
886 .maxlen
= sizeof(int),
888 .proc_handler
= &proc_dosoftlockup_thresh
,
889 .strategy
= &sysctl_intvec
,
894 #ifdef CONFIG_DETECT_HUNG_TASK
896 .ctl_name
= CTL_UNNUMBERED
,
897 .procname
= "hung_task_panic",
898 .data
= &sysctl_hung_task_panic
,
899 .maxlen
= sizeof(int),
901 .proc_handler
= &proc_dointvec_minmax
,
902 .strategy
= &sysctl_intvec
,
907 .ctl_name
= CTL_UNNUMBERED
,
908 .procname
= "hung_task_check_count",
909 .data
= &sysctl_hung_task_check_count
,
910 .maxlen
= sizeof(unsigned long),
912 .proc_handler
= &proc_doulongvec_minmax
,
913 .strategy
= &sysctl_intvec
,
916 .ctl_name
= CTL_UNNUMBERED
,
917 .procname
= "hung_task_timeout_secs",
918 .data
= &sysctl_hung_task_timeout_secs
,
919 .maxlen
= sizeof(unsigned long),
921 .proc_handler
= &proc_dohung_task_timeout_secs
,
922 .strategy
= &sysctl_intvec
,
925 .ctl_name
= CTL_UNNUMBERED
,
926 .procname
= "hung_task_warnings",
927 .data
= &sysctl_hung_task_warnings
,
928 .maxlen
= sizeof(unsigned long),
930 .proc_handler
= &proc_doulongvec_minmax
,
931 .strategy
= &sysctl_intvec
,
936 .ctl_name
= KERN_COMPAT_LOG
,
937 .procname
= "compat-log",
939 .maxlen
= sizeof (int),
941 .proc_handler
= &proc_dointvec
,
944 #ifdef CONFIG_RT_MUTEXES
946 .ctl_name
= KERN_MAX_LOCK_DEPTH
,
947 .procname
= "max_lock_depth",
948 .data
= &max_lock_depth
,
949 .maxlen
= sizeof(int),
951 .proc_handler
= &proc_dointvec
,
955 .ctl_name
= CTL_UNNUMBERED
,
956 .procname
= "poweroff_cmd",
957 .data
= &poweroff_cmd
,
958 .maxlen
= POWEROFF_CMD_PATH_LEN
,
960 .proc_handler
= &proc_dostring
,
961 .strategy
= &sysctl_string
,
965 .ctl_name
= CTL_UNNUMBERED
,
968 .child
= key_sysctls
,
971 #ifdef CONFIG_RCU_TORTURE_TEST
973 .ctl_name
= CTL_UNNUMBERED
,
974 .procname
= "rcutorture_runnable",
975 .data
= &rcutorture_runnable
,
976 .maxlen
= sizeof(int),
978 .proc_handler
= &proc_dointvec
,
981 #ifdef CONFIG_SLOW_WORK
983 .ctl_name
= CTL_UNNUMBERED
,
984 .procname
= "slow-work",
986 .child
= slow_work_sysctls
,
989 #ifdef CONFIG_PERF_EVENTS
991 .ctl_name
= CTL_UNNUMBERED
,
992 .procname
= "perf_event_paranoid",
993 .data
= &sysctl_perf_event_paranoid
,
994 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
996 .proc_handler
= &proc_dointvec
,
999 .ctl_name
= CTL_UNNUMBERED
,
1000 .procname
= "perf_event_mlock_kb",
1001 .data
= &sysctl_perf_event_mlock
,
1002 .maxlen
= sizeof(sysctl_perf_event_mlock
),
1004 .proc_handler
= &proc_dointvec
,
1007 .ctl_name
= CTL_UNNUMBERED
,
1008 .procname
= "perf_event_max_sample_rate",
1009 .data
= &sysctl_perf_event_sample_rate
,
1010 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1012 .proc_handler
= &proc_dointvec
,
1015 #ifdef CONFIG_KMEMCHECK
1017 .ctl_name
= CTL_UNNUMBERED
,
1018 .procname
= "kmemcheck",
1019 .data
= &kmemcheck_enabled
,
1020 .maxlen
= sizeof(int),
1022 .proc_handler
= &proc_dointvec
,
1027 .ctl_name
= CTL_UNNUMBERED
,
1028 .procname
= "blk_iopoll",
1029 .data
= &blk_iopoll_enabled
,
1030 .maxlen
= sizeof(int),
1032 .proc_handler
= &proc_dointvec
,
1036 * NOTE: do not add new entries to this table unless you have read
1037 * Documentation/sysctl/ctl_unnumbered.txt
1042 static struct ctl_table vm_table
[] = {
1044 .ctl_name
= VM_OVERCOMMIT_MEMORY
,
1045 .procname
= "overcommit_memory",
1046 .data
= &sysctl_overcommit_memory
,
1047 .maxlen
= sizeof(sysctl_overcommit_memory
),
1049 .proc_handler
= &proc_dointvec
,
1052 .ctl_name
= VM_PANIC_ON_OOM
,
1053 .procname
= "panic_on_oom",
1054 .data
= &sysctl_panic_on_oom
,
1055 .maxlen
= sizeof(sysctl_panic_on_oom
),
1057 .proc_handler
= &proc_dointvec
,
1060 .ctl_name
= CTL_UNNUMBERED
,
1061 .procname
= "oom_kill_allocating_task",
1062 .data
= &sysctl_oom_kill_allocating_task
,
1063 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
1065 .proc_handler
= &proc_dointvec
,
1068 .ctl_name
= CTL_UNNUMBERED
,
1069 .procname
= "oom_dump_tasks",
1070 .data
= &sysctl_oom_dump_tasks
,
1071 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
1073 .proc_handler
= &proc_dointvec
,
1076 .ctl_name
= VM_OVERCOMMIT_RATIO
,
1077 .procname
= "overcommit_ratio",
1078 .data
= &sysctl_overcommit_ratio
,
1079 .maxlen
= sizeof(sysctl_overcommit_ratio
),
1081 .proc_handler
= &proc_dointvec
,
1084 .ctl_name
= VM_PAGE_CLUSTER
,
1085 .procname
= "page-cluster",
1086 .data
= &page_cluster
,
1087 .maxlen
= sizeof(int),
1089 .proc_handler
= &proc_dointvec
,
1092 .ctl_name
= VM_DIRTY_BACKGROUND
,
1093 .procname
= "dirty_background_ratio",
1094 .data
= &dirty_background_ratio
,
1095 .maxlen
= sizeof(dirty_background_ratio
),
1097 .proc_handler
= &dirty_background_ratio_handler
,
1098 .strategy
= &sysctl_intvec
,
1100 .extra2
= &one_hundred
,
1103 .ctl_name
= CTL_UNNUMBERED
,
1104 .procname
= "dirty_background_bytes",
1105 .data
= &dirty_background_bytes
,
1106 .maxlen
= sizeof(dirty_background_bytes
),
1108 .proc_handler
= &dirty_background_bytes_handler
,
1109 .strategy
= &sysctl_intvec
,
1113 .ctl_name
= VM_DIRTY_RATIO
,
1114 .procname
= "dirty_ratio",
1115 .data
= &vm_dirty_ratio
,
1116 .maxlen
= sizeof(vm_dirty_ratio
),
1118 .proc_handler
= &dirty_ratio_handler
,
1119 .strategy
= &sysctl_intvec
,
1121 .extra2
= &one_hundred
,
1124 .ctl_name
= CTL_UNNUMBERED
,
1125 .procname
= "dirty_bytes",
1126 .data
= &vm_dirty_bytes
,
1127 .maxlen
= sizeof(vm_dirty_bytes
),
1129 .proc_handler
= &dirty_bytes_handler
,
1130 .strategy
= &sysctl_intvec
,
1131 .extra1
= &dirty_bytes_min
,
1134 .procname
= "dirty_writeback_centisecs",
1135 .data
= &dirty_writeback_interval
,
1136 .maxlen
= sizeof(dirty_writeback_interval
),
1138 .proc_handler
= &dirty_writeback_centisecs_handler
,
1141 .procname
= "dirty_expire_centisecs",
1142 .data
= &dirty_expire_interval
,
1143 .maxlen
= sizeof(dirty_expire_interval
),
1145 .proc_handler
= &proc_dointvec
,
1148 .ctl_name
= VM_NR_PDFLUSH_THREADS
,
1149 .procname
= "nr_pdflush_threads",
1150 .data
= &nr_pdflush_threads
,
1151 .maxlen
= sizeof nr_pdflush_threads
,
1152 .mode
= 0444 /* read-only*/,
1153 .proc_handler
= &proc_dointvec
,
1156 .ctl_name
= VM_SWAPPINESS
,
1157 .procname
= "swappiness",
1158 .data
= &vm_swappiness
,
1159 .maxlen
= sizeof(vm_swappiness
),
1161 .proc_handler
= &proc_dointvec_minmax
,
1162 .strategy
= &sysctl_intvec
,
1164 .extra2
= &one_hundred
,
1166 #ifdef CONFIG_HUGETLB_PAGE
1168 .procname
= "nr_hugepages",
1170 .maxlen
= sizeof(unsigned long),
1172 .proc_handler
= &hugetlb_sysctl_handler
,
1173 .extra1
= (void *)&hugetlb_zero
,
1174 .extra2
= (void *)&hugetlb_infinity
,
1177 .ctl_name
= VM_HUGETLB_GROUP
,
1178 .procname
= "hugetlb_shm_group",
1179 .data
= &sysctl_hugetlb_shm_group
,
1180 .maxlen
= sizeof(gid_t
),
1182 .proc_handler
= &proc_dointvec
,
1185 .ctl_name
= CTL_UNNUMBERED
,
1186 .procname
= "hugepages_treat_as_movable",
1187 .data
= &hugepages_treat_as_movable
,
1188 .maxlen
= sizeof(int),
1190 .proc_handler
= &hugetlb_treat_movable_handler
,
1193 .ctl_name
= CTL_UNNUMBERED
,
1194 .procname
= "nr_overcommit_hugepages",
1196 .maxlen
= sizeof(unsigned long),
1198 .proc_handler
= &hugetlb_overcommit_handler
,
1199 .extra1
= (void *)&hugetlb_zero
,
1200 .extra2
= (void *)&hugetlb_infinity
,
1204 .ctl_name
= VM_LOWMEM_RESERVE_RATIO
,
1205 .procname
= "lowmem_reserve_ratio",
1206 .data
= &sysctl_lowmem_reserve_ratio
,
1207 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
1209 .proc_handler
= &lowmem_reserve_ratio_sysctl_handler
,
1210 .strategy
= &sysctl_intvec
,
1213 .ctl_name
= VM_DROP_PAGECACHE
,
1214 .procname
= "drop_caches",
1215 .data
= &sysctl_drop_caches
,
1216 .maxlen
= sizeof(int),
1218 .proc_handler
= drop_caches_sysctl_handler
,
1219 .strategy
= &sysctl_intvec
,
1222 .ctl_name
= VM_MIN_FREE_KBYTES
,
1223 .procname
= "min_free_kbytes",
1224 .data
= &min_free_kbytes
,
1225 .maxlen
= sizeof(min_free_kbytes
),
1227 .proc_handler
= &min_free_kbytes_sysctl_handler
,
1228 .strategy
= &sysctl_intvec
,
1232 .ctl_name
= VM_PERCPU_PAGELIST_FRACTION
,
1233 .procname
= "percpu_pagelist_fraction",
1234 .data
= &percpu_pagelist_fraction
,
1235 .maxlen
= sizeof(percpu_pagelist_fraction
),
1237 .proc_handler
= &percpu_pagelist_fraction_sysctl_handler
,
1238 .strategy
= &sysctl_intvec
,
1239 .extra1
= &min_percpu_pagelist_fract
,
1243 .ctl_name
= VM_MAX_MAP_COUNT
,
1244 .procname
= "max_map_count",
1245 .data
= &sysctl_max_map_count
,
1246 .maxlen
= sizeof(sysctl_max_map_count
),
1248 .proc_handler
= &proc_dointvec
1252 .ctl_name
= CTL_UNNUMBERED
,
1253 .procname
= "nr_trim_pages",
1254 .data
= &sysctl_nr_trim_pages
,
1255 .maxlen
= sizeof(sysctl_nr_trim_pages
),
1257 .proc_handler
= &proc_dointvec_minmax
,
1258 .strategy
= &sysctl_intvec
,
1263 .ctl_name
= VM_LAPTOP_MODE
,
1264 .procname
= "laptop_mode",
1265 .data
= &laptop_mode
,
1266 .maxlen
= sizeof(laptop_mode
),
1268 .proc_handler
= &proc_dointvec_jiffies
,
1269 .strategy
= &sysctl_jiffies
,
1272 .ctl_name
= VM_BLOCK_DUMP
,
1273 .procname
= "block_dump",
1274 .data
= &block_dump
,
1275 .maxlen
= sizeof(block_dump
),
1277 .proc_handler
= &proc_dointvec
,
1278 .strategy
= &sysctl_intvec
,
1282 .ctl_name
= VM_VFS_CACHE_PRESSURE
,
1283 .procname
= "vfs_cache_pressure",
1284 .data
= &sysctl_vfs_cache_pressure
,
1285 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1287 .proc_handler
= &proc_dointvec
,
1288 .strategy
= &sysctl_intvec
,
1291 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1293 .ctl_name
= VM_LEGACY_VA_LAYOUT
,
1294 .procname
= "legacy_va_layout",
1295 .data
= &sysctl_legacy_va_layout
,
1296 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1298 .proc_handler
= &proc_dointvec
,
1299 .strategy
= &sysctl_intvec
,
1305 .ctl_name
= VM_ZONE_RECLAIM_MODE
,
1306 .procname
= "zone_reclaim_mode",
1307 .data
= &zone_reclaim_mode
,
1308 .maxlen
= sizeof(zone_reclaim_mode
),
1310 .proc_handler
= &proc_dointvec
,
1311 .strategy
= &sysctl_intvec
,
1315 .ctl_name
= VM_MIN_UNMAPPED
,
1316 .procname
= "min_unmapped_ratio",
1317 .data
= &sysctl_min_unmapped_ratio
,
1318 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1320 .proc_handler
= &sysctl_min_unmapped_ratio_sysctl_handler
,
1321 .strategy
= &sysctl_intvec
,
1323 .extra2
= &one_hundred
,
1326 .ctl_name
= VM_MIN_SLAB
,
1327 .procname
= "min_slab_ratio",
1328 .data
= &sysctl_min_slab_ratio
,
1329 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1331 .proc_handler
= &sysctl_min_slab_ratio_sysctl_handler
,
1332 .strategy
= &sysctl_intvec
,
1334 .extra2
= &one_hundred
,
1339 .ctl_name
= CTL_UNNUMBERED
,
1340 .procname
= "stat_interval",
1341 .data
= &sysctl_stat_interval
,
1342 .maxlen
= sizeof(sysctl_stat_interval
),
1344 .proc_handler
= &proc_dointvec_jiffies
,
1345 .strategy
= &sysctl_jiffies
,
1350 .ctl_name
= CTL_UNNUMBERED
,
1351 .procname
= "mmap_min_addr",
1352 .data
= &dac_mmap_min_addr
,
1353 .maxlen
= sizeof(unsigned long),
1355 .proc_handler
= &mmap_min_addr_handler
,
1360 .ctl_name
= CTL_UNNUMBERED
,
1361 .procname
= "numa_zonelist_order",
1362 .data
= &numa_zonelist_order
,
1363 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1365 .proc_handler
= &numa_zonelist_order_handler
,
1366 .strategy
= &sysctl_string
,
1369 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1370 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1372 .ctl_name
= VM_VDSO_ENABLED
,
1373 .procname
= "vdso_enabled",
1374 .data
= &vdso_enabled
,
1375 .maxlen
= sizeof(vdso_enabled
),
1377 .proc_handler
= &proc_dointvec
,
1378 .strategy
= &sysctl_intvec
,
1382 #ifdef CONFIG_HIGHMEM
1384 .ctl_name
= CTL_UNNUMBERED
,
1385 .procname
= "highmem_is_dirtyable",
1386 .data
= &vm_highmem_is_dirtyable
,
1387 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
1389 .proc_handler
= &proc_dointvec_minmax
,
1390 .strategy
= &sysctl_intvec
,
1396 .ctl_name
= CTL_UNNUMBERED
,
1397 .procname
= "scan_unevictable_pages",
1398 .data
= &scan_unevictable_pages
,
1399 .maxlen
= sizeof(scan_unevictable_pages
),
1401 .proc_handler
= &scan_unevictable_handler
,
1403 #ifdef CONFIG_MEMORY_FAILURE
1405 .ctl_name
= CTL_UNNUMBERED
,
1406 .procname
= "memory_failure_early_kill",
1407 .data
= &sysctl_memory_failure_early_kill
,
1408 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
1410 .proc_handler
= &proc_dointvec_minmax
,
1411 .strategy
= &sysctl_intvec
,
1416 .ctl_name
= CTL_UNNUMBERED
,
1417 .procname
= "memory_failure_recovery",
1418 .data
= &sysctl_memory_failure_recovery
,
1419 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
1421 .proc_handler
= &proc_dointvec_minmax
,
1422 .strategy
= &sysctl_intvec
,
1429 * NOTE: do not add new entries to this table unless you have read
1430 * Documentation/sysctl/ctl_unnumbered.txt
1435 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1436 static struct ctl_table binfmt_misc_table
[] = {
1441 static struct ctl_table fs_table
[] = {
1443 .ctl_name
= FS_NRINODE
,
1444 .procname
= "inode-nr",
1445 .data
= &inodes_stat
,
1446 .maxlen
= 2*sizeof(int),
1448 .proc_handler
= &proc_dointvec
,
1451 .ctl_name
= FS_STATINODE
,
1452 .procname
= "inode-state",
1453 .data
= &inodes_stat
,
1454 .maxlen
= 7*sizeof(int),
1456 .proc_handler
= &proc_dointvec
,
1459 .procname
= "file-nr",
1460 .data
= &files_stat
,
1461 .maxlen
= 3*sizeof(int),
1463 .proc_handler
= &proc_nr_files
,
1466 .ctl_name
= FS_MAXFILE
,
1467 .procname
= "file-max",
1468 .data
= &files_stat
.max_files
,
1469 .maxlen
= sizeof(int),
1471 .proc_handler
= &proc_dointvec
,
1474 .ctl_name
= CTL_UNNUMBERED
,
1475 .procname
= "nr_open",
1476 .data
= &sysctl_nr_open
,
1477 .maxlen
= sizeof(int),
1479 .proc_handler
= &proc_dointvec_minmax
,
1480 .extra1
= &sysctl_nr_open_min
,
1481 .extra2
= &sysctl_nr_open_max
,
1484 .ctl_name
= FS_DENTRY
,
1485 .procname
= "dentry-state",
1486 .data
= &dentry_stat
,
1487 .maxlen
= 6*sizeof(int),
1489 .proc_handler
= &proc_dointvec
,
1492 .ctl_name
= FS_OVERFLOWUID
,
1493 .procname
= "overflowuid",
1494 .data
= &fs_overflowuid
,
1495 .maxlen
= sizeof(int),
1497 .proc_handler
= &proc_dointvec_minmax
,
1498 .strategy
= &sysctl_intvec
,
1499 .extra1
= &minolduid
,
1500 .extra2
= &maxolduid
,
1503 .ctl_name
= FS_OVERFLOWGID
,
1504 .procname
= "overflowgid",
1505 .data
= &fs_overflowgid
,
1506 .maxlen
= sizeof(int),
1508 .proc_handler
= &proc_dointvec_minmax
,
1509 .strategy
= &sysctl_intvec
,
1510 .extra1
= &minolduid
,
1511 .extra2
= &maxolduid
,
1513 #ifdef CONFIG_FILE_LOCKING
1515 .ctl_name
= FS_LEASES
,
1516 .procname
= "leases-enable",
1517 .data
= &leases_enable
,
1518 .maxlen
= sizeof(int),
1520 .proc_handler
= &proc_dointvec
,
1523 #ifdef CONFIG_DNOTIFY
1525 .ctl_name
= FS_DIR_NOTIFY
,
1526 .procname
= "dir-notify-enable",
1527 .data
= &dir_notify_enable
,
1528 .maxlen
= sizeof(int),
1530 .proc_handler
= &proc_dointvec
,
1534 #ifdef CONFIG_FILE_LOCKING
1536 .ctl_name
= FS_LEASE_TIME
,
1537 .procname
= "lease-break-time",
1538 .data
= &lease_break_time
,
1539 .maxlen
= sizeof(int),
1541 .proc_handler
= &proc_dointvec
,
1546 .procname
= "aio-nr",
1548 .maxlen
= sizeof(aio_nr
),
1550 .proc_handler
= &proc_doulongvec_minmax
,
1553 .procname
= "aio-max-nr",
1554 .data
= &aio_max_nr
,
1555 .maxlen
= sizeof(aio_max_nr
),
1557 .proc_handler
= &proc_doulongvec_minmax
,
1559 #endif /* CONFIG_AIO */
1560 #ifdef CONFIG_INOTIFY_USER
1562 .ctl_name
= FS_INOTIFY
,
1563 .procname
= "inotify",
1565 .child
= inotify_table
,
1570 .procname
= "epoll",
1572 .child
= epoll_table
,
1577 .ctl_name
= KERN_SETUID_DUMPABLE
,
1578 .procname
= "suid_dumpable",
1579 .data
= &suid_dumpable
,
1580 .maxlen
= sizeof(int),
1582 .proc_handler
= &proc_dointvec_minmax
,
1583 .strategy
= &sysctl_intvec
,
1587 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1589 .ctl_name
= CTL_UNNUMBERED
,
1590 .procname
= "binfmt_misc",
1592 .child
= binfmt_misc_table
,
1596 * NOTE: do not add new entries to this table unless you have read
1597 * Documentation/sysctl/ctl_unnumbered.txt
1602 static struct ctl_table debug_table
[] = {
1603 #if defined(CONFIG_X86) || defined(CONFIG_PPC)
1605 .ctl_name
= CTL_UNNUMBERED
,
1606 .procname
= "exception-trace",
1607 .data
= &show_unhandled_signals
,
1608 .maxlen
= sizeof(int),
1610 .proc_handler
= proc_dointvec_minmax
,
1617 static struct ctl_table dev_table
[] = {
1621 static DEFINE_SPINLOCK(sysctl_lock
);
1623 /* called under sysctl_lock */
1624 static int use_table(struct ctl_table_header
*p
)
1626 if (unlikely(p
->unregistering
))
1632 /* called under sysctl_lock */
1633 static void unuse_table(struct ctl_table_header
*p
)
1636 if (unlikely(p
->unregistering
))
1637 complete(p
->unregistering
);
1640 /* called under sysctl_lock, will reacquire if has to wait */
1641 static void start_unregistering(struct ctl_table_header
*p
)
1644 * if p->used is 0, nobody will ever touch that entry again;
1645 * we'll eliminate all paths to it before dropping sysctl_lock
1647 if (unlikely(p
->used
)) {
1648 struct completion wait
;
1649 init_completion(&wait
);
1650 p
->unregistering
= &wait
;
1651 spin_unlock(&sysctl_lock
);
1652 wait_for_completion(&wait
);
1653 spin_lock(&sysctl_lock
);
1655 /* anything non-NULL; we'll never dereference it */
1656 p
->unregistering
= ERR_PTR(-EINVAL
);
1659 * do not remove from the list until nobody holds it; walking the
1660 * list in do_sysctl() relies on that.
1662 list_del_init(&p
->ctl_entry
);
1665 void sysctl_head_get(struct ctl_table_header
*head
)
1667 spin_lock(&sysctl_lock
);
1669 spin_unlock(&sysctl_lock
);
1672 void sysctl_head_put(struct ctl_table_header
*head
)
1674 spin_lock(&sysctl_lock
);
1677 spin_unlock(&sysctl_lock
);
1680 struct ctl_table_header
*sysctl_head_grab(struct ctl_table_header
*head
)
1684 spin_lock(&sysctl_lock
);
1685 if (!use_table(head
))
1686 head
= ERR_PTR(-ENOENT
);
1687 spin_unlock(&sysctl_lock
);
1691 void sysctl_head_finish(struct ctl_table_header
*head
)
1695 spin_lock(&sysctl_lock
);
1697 spin_unlock(&sysctl_lock
);
1700 static struct ctl_table_set
*
1701 lookup_header_set(struct ctl_table_root
*root
, struct nsproxy
*namespaces
)
1703 struct ctl_table_set
*set
= &root
->default_set
;
1705 set
= root
->lookup(root
, namespaces
);
1709 static struct list_head
*
1710 lookup_header_list(struct ctl_table_root
*root
, struct nsproxy
*namespaces
)
1712 struct ctl_table_set
*set
= lookup_header_set(root
, namespaces
);
1716 struct ctl_table_header
*__sysctl_head_next(struct nsproxy
*namespaces
,
1717 struct ctl_table_header
*prev
)
1719 struct ctl_table_root
*root
;
1720 struct list_head
*header_list
;
1721 struct ctl_table_header
*head
;
1722 struct list_head
*tmp
;
1724 spin_lock(&sysctl_lock
);
1727 tmp
= &prev
->ctl_entry
;
1731 tmp
= &root_table_header
.ctl_entry
;
1733 head
= list_entry(tmp
, struct ctl_table_header
, ctl_entry
);
1735 if (!use_table(head
))
1737 spin_unlock(&sysctl_lock
);
1742 header_list
= lookup_header_list(root
, namespaces
);
1743 if (tmp
!= header_list
)
1747 root
= list_entry(root
->root_list
.next
,
1748 struct ctl_table_root
, root_list
);
1749 if (root
== &sysctl_table_root
)
1751 header_list
= lookup_header_list(root
, namespaces
);
1752 } while (list_empty(header_list
));
1753 tmp
= header_list
->next
;
1756 spin_unlock(&sysctl_lock
);
1760 struct ctl_table_header
*sysctl_head_next(struct ctl_table_header
*prev
)
1762 return __sysctl_head_next(current
->nsproxy
, prev
);
1765 void register_sysctl_root(struct ctl_table_root
*root
)
1767 spin_lock(&sysctl_lock
);
1768 list_add_tail(&root
->root_list
, &sysctl_table_root
.root_list
);
1769 spin_unlock(&sysctl_lock
);
1772 #ifdef CONFIG_SYSCTL_SYSCALL
1773 /* Perform the actual read/write of a sysctl table entry. */
1774 static int do_sysctl_strategy(struct ctl_table_root
*root
,
1775 struct ctl_table
*table
,
1776 void __user
*oldval
, size_t __user
*oldlenp
,
1777 void __user
*newval
, size_t newlen
)
1785 if (sysctl_perm(root
, table
, op
))
1788 if (table
->strategy
) {
1789 rc
= table
->strategy(table
, oldval
, oldlenp
, newval
, newlen
);
1796 /* If there is no strategy routine, or if the strategy returns
1797 * zero, proceed with automatic r/w */
1798 if (table
->data
&& table
->maxlen
) {
1799 rc
= sysctl_data(table
, oldval
, oldlenp
, newval
, newlen
);
1806 static int parse_table(int __user
*name
, int nlen
,
1807 void __user
*oldval
, size_t __user
*oldlenp
,
1808 void __user
*newval
, size_t newlen
,
1809 struct ctl_table_root
*root
,
1810 struct ctl_table
*table
)
1816 if (get_user(n
, name
))
1818 for ( ; table
->ctl_name
|| table
->procname
; table
++) {
1819 if (!table
->ctl_name
)
1821 if (n
== table
->ctl_name
) {
1824 if (sysctl_perm(root
, table
, MAY_EXEC
))
1828 table
= table
->child
;
1831 error
= do_sysctl_strategy(root
, table
,
1840 int do_sysctl(int __user
*name
, int nlen
, void __user
*oldval
, size_t __user
*oldlenp
,
1841 void __user
*newval
, size_t newlen
)
1843 struct ctl_table_header
*head
;
1844 int error
= -ENOTDIR
;
1846 if (nlen
<= 0 || nlen
>= CTL_MAXNAME
)
1850 if (!oldlenp
|| get_user(old_len
, oldlenp
))
1854 for (head
= sysctl_head_next(NULL
); head
;
1855 head
= sysctl_head_next(head
)) {
1856 error
= parse_table(name
, nlen
, oldval
, oldlenp
,
1858 head
->root
, head
->ctl_table
);
1859 if (error
!= -ENOTDIR
) {
1860 sysctl_head_finish(head
);
1867 SYSCALL_DEFINE1(sysctl
, struct __sysctl_args __user
*, args
)
1869 struct __sysctl_args tmp
;
1872 if (copy_from_user(&tmp
, args
, sizeof(tmp
)))
1875 error
= deprecated_sysctl_warning(&tmp
);
1880 error
= do_sysctl(tmp
.name
, tmp
.nlen
, tmp
.oldval
, tmp
.oldlenp
,
1881 tmp
.newval
, tmp
.newlen
);
1886 #endif /* CONFIG_SYSCTL_SYSCALL */
1889 * sysctl_perm does NOT grant the superuser all rights automatically, because
1890 * some sysctl variables are readonly even to root.
1893 static int test_perm(int mode
, int op
)
1895 if (!current_euid())
1897 else if (in_egroup_p(0))
1899 if ((op
& ~mode
& (MAY_READ
|MAY_WRITE
|MAY_EXEC
)) == 0)
1904 int sysctl_perm(struct ctl_table_root
*root
, struct ctl_table
*table
, int op
)
1909 error
= security_sysctl(table
, op
& (MAY_READ
| MAY_WRITE
| MAY_EXEC
));
1913 if (root
->permissions
)
1914 mode
= root
->permissions(root
, current
->nsproxy
, table
);
1918 return test_perm(mode
, op
);
1921 static void sysctl_set_parent(struct ctl_table
*parent
, struct ctl_table
*table
)
1923 for (; table
->ctl_name
|| table
->procname
; table
++) {
1924 table
->parent
= parent
;
1926 sysctl_set_parent(table
, table
->child
);
1930 static __init
int sysctl_init(void)
1932 sysctl_set_parent(NULL
, root_table
);
1933 #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1936 err
= sysctl_check_table(current
->nsproxy
, root_table
);
1942 core_initcall(sysctl_init
);
1944 static struct ctl_table
*is_branch_in(struct ctl_table
*branch
,
1945 struct ctl_table
*table
)
1947 struct ctl_table
*p
;
1948 const char *s
= branch
->procname
;
1950 /* branch should have named subdirectory as its first element */
1951 if (!s
|| !branch
->child
)
1954 /* ... and nothing else */
1955 if (branch
[1].procname
|| branch
[1].ctl_name
)
1958 /* table should contain subdirectory with the same name */
1959 for (p
= table
; p
->procname
|| p
->ctl_name
; p
++) {
1962 if (p
->procname
&& strcmp(p
->procname
, s
) == 0)
1968 /* see if attaching q to p would be an improvement */
1969 static void try_attach(struct ctl_table_header
*p
, struct ctl_table_header
*q
)
1971 struct ctl_table
*to
= p
->ctl_table
, *by
= q
->ctl_table
;
1972 struct ctl_table
*next
;
1974 int not_in_parent
= !p
->attached_by
;
1976 while ((next
= is_branch_in(by
, to
)) != NULL
) {
1977 if (by
== q
->attached_by
)
1979 if (to
== p
->attached_by
)
1985 if (is_better
&& not_in_parent
) {
1986 q
->attached_by
= by
;
1987 q
->attached_to
= to
;
1993 * __register_sysctl_paths - register a sysctl hierarchy
1994 * @root: List of sysctl headers to register on
1995 * @namespaces: Data to compute which lists of sysctl entries are visible
1996 * @path: The path to the directory the sysctl table is in.
1997 * @table: the top-level table structure
1999 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2000 * array. A completely 0 filled entry terminates the table.
2002 * The members of the &struct ctl_table structure are used as follows:
2004 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
2005 * must be unique within that level of sysctl
2007 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
2008 * enter a sysctl file
2010 * data - a pointer to data for use by proc_handler
2012 * maxlen - the maximum size in bytes of the data
2014 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
2016 * child - a pointer to the child sysctl table if this entry is a directory, or
2019 * proc_handler - the text handler routine (described below)
2021 * strategy - the strategy routine (described below)
2023 * de - for internal use by the sysctl routines
2025 * extra1, extra2 - extra pointers usable by the proc handler routines
2027 * Leaf nodes in the sysctl tree will be represented by a single file
2028 * under /proc; non-leaf nodes will be represented by directories.
2030 * sysctl(2) can automatically manage read and write requests through
2031 * the sysctl table. The data and maxlen fields of the ctl_table
2032 * struct enable minimal validation of the values being written to be
2033 * performed, and the mode field allows minimal authentication.
2035 * More sophisticated management can be enabled by the provision of a
2036 * strategy routine with the table entry. This will be called before
2037 * any automatic read or write of the data is performed.
2039 * The strategy routine may return
2041 * < 0 - Error occurred (error is passed to user process)
2043 * 0 - OK - proceed with automatic read or write.
2045 * > 0 - OK - read or write has been done by the strategy routine, so
2046 * return immediately.
2048 * There must be a proc_handler routine for any terminal nodes
2049 * mirrored under /proc/sys (non-terminals are handled by a built-in
2050 * directory handler). Several default handlers are available to
2051 * cover common cases -
2053 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
2054 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
2055 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
2057 * It is the handler's job to read the input buffer from user memory
2058 * and process it. The handler should return 0 on success.
2060 * This routine returns %NULL on a failure to register, and a pointer
2061 * to the table header on success.
2063 struct ctl_table_header
*__register_sysctl_paths(
2064 struct ctl_table_root
*root
,
2065 struct nsproxy
*namespaces
,
2066 const struct ctl_path
*path
, struct ctl_table
*table
)
2068 struct ctl_table_header
*header
;
2069 struct ctl_table
*new, **prevp
;
2070 unsigned int n
, npath
;
2071 struct ctl_table_set
*set
;
2073 /* Count the path components */
2074 for (npath
= 0; path
[npath
].ctl_name
|| path
[npath
].procname
; ++npath
)
2078 * For each path component, allocate a 2-element ctl_table array.
2079 * The first array element will be filled with the sysctl entry
2080 * for this, the second will be the sentinel (ctl_name == 0).
2082 * We allocate everything in one go so that we don't have to
2083 * worry about freeing additional memory in unregister_sysctl_table.
2085 header
= kzalloc(sizeof(struct ctl_table_header
) +
2086 (2 * npath
* sizeof(struct ctl_table
)), GFP_KERNEL
);
2090 new = (struct ctl_table
*) (header
+ 1);
2092 /* Now connect the dots */
2093 prevp
= &header
->ctl_table
;
2094 for (n
= 0; n
< npath
; ++n
, ++path
) {
2095 /* Copy the procname */
2096 new->procname
= path
->procname
;
2097 new->ctl_name
= path
->ctl_name
;
2101 prevp
= &new->child
;
2106 header
->ctl_table_arg
= table
;
2108 INIT_LIST_HEAD(&header
->ctl_entry
);
2110 header
->unregistering
= NULL
;
2111 header
->root
= root
;
2112 sysctl_set_parent(NULL
, header
->ctl_table
);
2114 #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
2115 if (sysctl_check_table(namespaces
, header
->ctl_table
)) {
2120 spin_lock(&sysctl_lock
);
2121 header
->set
= lookup_header_set(root
, namespaces
);
2122 header
->attached_by
= header
->ctl_table
;
2123 header
->attached_to
= root_table
;
2124 header
->parent
= &root_table_header
;
2125 for (set
= header
->set
; set
; set
= set
->parent
) {
2126 struct ctl_table_header
*p
;
2127 list_for_each_entry(p
, &set
->list
, ctl_entry
) {
2128 if (p
->unregistering
)
2130 try_attach(p
, header
);
2133 header
->parent
->count
++;
2134 list_add_tail(&header
->ctl_entry
, &header
->set
->list
);
2135 spin_unlock(&sysctl_lock
);
2141 * register_sysctl_table_path - register a sysctl table hierarchy
2142 * @path: The path to the directory the sysctl table is in.
2143 * @table: the top-level table structure
2145 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2146 * array. A completely 0 filled entry terminates the table.
2148 * See __register_sysctl_paths for more details.
2150 struct ctl_table_header
*register_sysctl_paths(const struct ctl_path
*path
,
2151 struct ctl_table
*table
)
2153 return __register_sysctl_paths(&sysctl_table_root
, current
->nsproxy
,
2158 * register_sysctl_table - register a sysctl table hierarchy
2159 * @table: the top-level table structure
2161 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2162 * array. A completely 0 filled entry terminates the table.
2164 * See register_sysctl_paths for more details.
2166 struct ctl_table_header
*register_sysctl_table(struct ctl_table
*table
)
2168 static const struct ctl_path null_path
[] = { {} };
2170 return register_sysctl_paths(null_path
, table
);
2174 * unregister_sysctl_table - unregister a sysctl table hierarchy
2175 * @header: the header returned from register_sysctl_table
2177 * Unregisters the sysctl table and all children. proc entries may not
2178 * actually be removed until they are no longer used by anyone.
2180 void unregister_sysctl_table(struct ctl_table_header
* header
)
2187 spin_lock(&sysctl_lock
);
2188 start_unregistering(header
);
2189 if (!--header
->parent
->count
) {
2191 kfree(header
->parent
);
2193 if (!--header
->count
)
2195 spin_unlock(&sysctl_lock
);
2198 int sysctl_is_seen(struct ctl_table_header
*p
)
2200 struct ctl_table_set
*set
= p
->set
;
2202 spin_lock(&sysctl_lock
);
2203 if (p
->unregistering
)
2205 else if (!set
->is_seen
)
2208 res
= set
->is_seen(set
);
2209 spin_unlock(&sysctl_lock
);
2213 void setup_sysctl_set(struct ctl_table_set
*p
,
2214 struct ctl_table_set
*parent
,
2215 int (*is_seen
)(struct ctl_table_set
*))
2217 INIT_LIST_HEAD(&p
->list
);
2218 p
->parent
= parent
? parent
: &sysctl_table_root
.default_set
;
2219 p
->is_seen
= is_seen
;
2222 #else /* !CONFIG_SYSCTL */
2223 struct ctl_table_header
*register_sysctl_table(struct ctl_table
* table
)
2228 struct ctl_table_header
*register_sysctl_paths(const struct ctl_path
*path
,
2229 struct ctl_table
*table
)
2234 void unregister_sysctl_table(struct ctl_table_header
* table
)
2238 void setup_sysctl_set(struct ctl_table_set
*p
,
2239 struct ctl_table_set
*parent
,
2240 int (*is_seen
)(struct ctl_table_set
*))
2244 void sysctl_head_put(struct ctl_table_header
*head
)
2248 #endif /* CONFIG_SYSCTL */
2254 #ifdef CONFIG_PROC_SYSCTL
2256 static int _proc_do_string(void* data
, int maxlen
, int write
,
2257 void __user
*buffer
,
2258 size_t *lenp
, loff_t
*ppos
)
2264 if (!data
|| !maxlen
|| !*lenp
) {
2272 while (len
< *lenp
) {
2273 if (get_user(c
, p
++))
2275 if (c
== 0 || c
== '\n')
2281 if(copy_from_user(data
, buffer
, len
))
2283 ((char *) data
)[len
] = 0;
2301 if(copy_to_user(buffer
, data
, len
))
2304 if(put_user('\n', ((char __user
*) buffer
) + len
))
2315 * proc_dostring - read a string sysctl
2316 * @table: the sysctl table
2317 * @write: %TRUE if this is a write to the sysctl file
2318 * @buffer: the user buffer
2319 * @lenp: the size of the user buffer
2320 * @ppos: file position
2322 * Reads/writes a string from/to the user buffer. If the kernel
2323 * buffer provided is not large enough to hold the string, the
2324 * string is truncated. The copied string is %NULL-terminated.
2325 * If the string is being read by the user process, it is copied
2326 * and a newline '\n' is added. It is truncated if the buffer is
2329 * Returns 0 on success.
2331 int proc_dostring(struct ctl_table
*table
, int write
,
2332 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2334 return _proc_do_string(table
->data
, table
->maxlen
, write
,
2335 buffer
, lenp
, ppos
);
2339 static int do_proc_dointvec_conv(int *negp
, unsigned long *lvalp
,
2341 int write
, void *data
)
2344 *valp
= *negp
? -*lvalp
: *lvalp
;
2349 *lvalp
= (unsigned long)-val
;
2352 *lvalp
= (unsigned long)val
;
2358 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2359 int write
, void __user
*buffer
,
2360 size_t *lenp
, loff_t
*ppos
,
2361 int (*conv
)(int *negp
, unsigned long *lvalp
, int *valp
,
2362 int write
, void *data
),
2365 #define TMPBUFLEN 21
2366 int *i
, vleft
, first
= 1, neg
;
2370 char buf
[TMPBUFLEN
], *p
;
2371 char __user
*s
= buffer
;
2373 if (!tbl_data
|| !table
->maxlen
|| !*lenp
||
2374 (*ppos
&& !write
)) {
2379 i
= (int *) tbl_data
;
2380 vleft
= table
->maxlen
/ sizeof(*i
);
2384 conv
= do_proc_dointvec_conv
;
2386 for (; left
&& vleft
--; i
++, first
=0) {
2401 if (len
> sizeof(buf
) - 1)
2402 len
= sizeof(buf
) - 1;
2403 if (copy_from_user(buf
, s
, len
))
2407 if (*p
== '-' && left
> 1) {
2411 if (*p
< '0' || *p
> '9')
2414 lval
= simple_strtoul(p
, &p
, 0);
2417 if ((len
< left
) && *p
&& !isspace(*p
))
2422 if (conv(&neg
, &lval
, i
, 1, data
))
2429 if (conv(&neg
, &lval
, i
, 0, data
))
2432 sprintf(p
, "%s%lu", neg
? "-" : "", lval
);
2436 if(copy_to_user(s
, buf
, len
))
2443 if (!write
&& !first
&& left
) {
2444 if(put_user('\n', s
))
2451 if (get_user(c
, s
++))
2466 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2467 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2468 int (*conv
)(int *negp
, unsigned long *lvalp
, int *valp
,
2469 int write
, void *data
),
2472 return __do_proc_dointvec(table
->data
, table
, write
,
2473 buffer
, lenp
, ppos
, conv
, data
);
2477 * proc_dointvec - read a vector of integers
2478 * @table: the sysctl table
2479 * @write: %TRUE if this is a write to the sysctl file
2480 * @buffer: the user buffer
2481 * @lenp: the size of the user buffer
2482 * @ppos: file position
2484 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2485 * values from/to the user buffer, treated as an ASCII string.
2487 * Returns 0 on success.
2489 int proc_dointvec(struct ctl_table
*table
, int write
,
2490 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2492 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2497 * Taint values can only be increased
2498 * This means we can safely use a temporary.
2500 static int proc_taint(struct ctl_table
*table
, int write
,
2501 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2504 unsigned long tmptaint
= get_taint();
2507 if (write
&& !capable(CAP_SYS_ADMIN
))
2512 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2518 * Poor man's atomic or. Not worth adding a primitive
2519 * to everyone's atomic.h for this
2522 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2523 if ((tmptaint
>> i
) & 1)
2531 struct do_proc_dointvec_minmax_conv_param
{
2536 static int do_proc_dointvec_minmax_conv(int *negp
, unsigned long *lvalp
,
2538 int write
, void *data
)
2540 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2542 int val
= *negp
? -*lvalp
: *lvalp
;
2543 if ((param
->min
&& *param
->min
> val
) ||
2544 (param
->max
&& *param
->max
< val
))
2551 *lvalp
= (unsigned long)-val
;
2554 *lvalp
= (unsigned long)val
;
2561 * proc_dointvec_minmax - read a vector of integers with min/max values
2562 * @table: the sysctl table
2563 * @write: %TRUE if this is a write to the sysctl file
2564 * @buffer: the user buffer
2565 * @lenp: the size of the user buffer
2566 * @ppos: file position
2568 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2569 * values from/to the user buffer, treated as an ASCII string.
2571 * This routine will ensure the values are within the range specified by
2572 * table->extra1 (min) and table->extra2 (max).
2574 * Returns 0 on success.
2576 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2577 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2579 struct do_proc_dointvec_minmax_conv_param param
= {
2580 .min
= (int *) table
->extra1
,
2581 .max
= (int *) table
->extra2
,
2583 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2584 do_proc_dointvec_minmax_conv
, ¶m
);
2587 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2588 void __user
*buffer
,
2589 size_t *lenp
, loff_t
*ppos
,
2590 unsigned long convmul
,
2591 unsigned long convdiv
)
2593 #define TMPBUFLEN 21
2594 unsigned long *i
, *min
, *max
, val
;
2595 int vleft
, first
=1, neg
;
2597 char buf
[TMPBUFLEN
], *p
;
2598 char __user
*s
= buffer
;
2600 if (!data
|| !table
->maxlen
|| !*lenp
||
2601 (*ppos
&& !write
)) {
2606 i
= (unsigned long *) data
;
2607 min
= (unsigned long *) table
->extra1
;
2608 max
= (unsigned long *) table
->extra2
;
2609 vleft
= table
->maxlen
/ sizeof(unsigned long);
2612 for (; left
&& vleft
--; i
++, min
++, max
++, first
=0) {
2627 if (len
> TMPBUFLEN
-1)
2629 if (copy_from_user(buf
, s
, len
))
2633 if (*p
== '-' && left
> 1) {
2637 if (*p
< '0' || *p
> '9')
2639 val
= simple_strtoul(p
, &p
, 0) * convmul
/ convdiv
;
2641 if ((len
< left
) && *p
&& !isspace(*p
))
2650 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2657 sprintf(p
, "%lu", convdiv
* (*i
) / convmul
);
2661 if(copy_to_user(s
, buf
, len
))
2668 if (!write
&& !first
&& left
) {
2669 if(put_user('\n', s
))
2676 if (get_user(c
, s
++))
2691 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2692 void __user
*buffer
,
2693 size_t *lenp
, loff_t
*ppos
,
2694 unsigned long convmul
,
2695 unsigned long convdiv
)
2697 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2698 buffer
, lenp
, ppos
, convmul
, convdiv
);
2702 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2703 * @table: the sysctl table
2704 * @write: %TRUE if this is a write to the sysctl file
2705 * @buffer: the user buffer
2706 * @lenp: the size of the user buffer
2707 * @ppos: file position
2709 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2710 * values from/to the user buffer, treated as an ASCII string.
2712 * This routine will ensure the values are within the range specified by
2713 * table->extra1 (min) and table->extra2 (max).
2715 * Returns 0 on success.
2717 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2718 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2720 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2724 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2725 * @table: the sysctl table
2726 * @write: %TRUE if this is a write to the sysctl file
2727 * @buffer: the user buffer
2728 * @lenp: the size of the user buffer
2729 * @ppos: file position
2731 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2732 * values from/to the user buffer, treated as an ASCII string. The values
2733 * are treated as milliseconds, and converted to jiffies when they are stored.
2735 * This routine will ensure the values are within the range specified by
2736 * table->extra1 (min) and table->extra2 (max).
2738 * Returns 0 on success.
2740 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2741 void __user
*buffer
,
2742 size_t *lenp
, loff_t
*ppos
)
2744 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2745 lenp
, ppos
, HZ
, 1000l);
2749 static int do_proc_dointvec_jiffies_conv(int *negp
, unsigned long *lvalp
,
2751 int write
, void *data
)
2754 if (*lvalp
> LONG_MAX
/ HZ
)
2756 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2762 lval
= (unsigned long)-val
;
2765 lval
= (unsigned long)val
;
2772 static int do_proc_dointvec_userhz_jiffies_conv(int *negp
, unsigned long *lvalp
,
2774 int write
, void *data
)
2777 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2779 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2785 lval
= (unsigned long)-val
;
2788 lval
= (unsigned long)val
;
2790 *lvalp
= jiffies_to_clock_t(lval
);
2795 static int do_proc_dointvec_ms_jiffies_conv(int *negp
, unsigned long *lvalp
,
2797 int write
, void *data
)
2800 *valp
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2806 lval
= (unsigned long)-val
;
2809 lval
= (unsigned long)val
;
2811 *lvalp
= jiffies_to_msecs(lval
);
2817 * proc_dointvec_jiffies - read a vector of integers as seconds
2818 * @table: the sysctl table
2819 * @write: %TRUE if this is a write to the sysctl file
2820 * @buffer: the user buffer
2821 * @lenp: the size of the user buffer
2822 * @ppos: file position
2824 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2825 * values from/to the user buffer, treated as an ASCII string.
2826 * The values read are assumed to be in seconds, and are converted into
2829 * Returns 0 on success.
2831 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2832 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2834 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2835 do_proc_dointvec_jiffies_conv
,NULL
);
2839 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2840 * @table: the sysctl table
2841 * @write: %TRUE if this is a write to the sysctl file
2842 * @buffer: the user buffer
2843 * @lenp: the size of the user buffer
2844 * @ppos: pointer to the file position
2846 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2847 * values from/to the user buffer, treated as an ASCII string.
2848 * The values read are assumed to be in 1/USER_HZ seconds, and
2849 * are converted into jiffies.
2851 * Returns 0 on success.
2853 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2854 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2856 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2857 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2861 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2862 * @table: the sysctl table
2863 * @write: %TRUE if this is a write to the sysctl file
2864 * @buffer: the user buffer
2865 * @lenp: the size of the user buffer
2866 * @ppos: file position
2867 * @ppos: the current position in the file
2869 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2870 * values from/to the user buffer, treated as an ASCII string.
2871 * The values read are assumed to be in 1/1000 seconds, and
2872 * are converted into jiffies.
2874 * Returns 0 on success.
2876 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2877 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2879 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2880 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2883 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
2884 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2886 struct pid
*new_pid
;
2890 tmp
= pid_vnr(cad_pid
);
2892 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
2893 lenp
, ppos
, NULL
, NULL
);
2897 new_pid
= find_get_pid(tmp
);
2901 put_pid(xchg(&cad_pid
, new_pid
));
2905 #else /* CONFIG_PROC_FS */
2907 int proc_dostring(struct ctl_table
*table
, int write
,
2908 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2913 int proc_dointvec(struct ctl_table
*table
, int write
,
2914 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2919 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2920 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2925 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2926 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2931 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2932 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2937 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2938 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2943 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2944 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2949 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2950 void __user
*buffer
,
2951 size_t *lenp
, loff_t
*ppos
)
2957 #endif /* CONFIG_PROC_FS */
2960 #ifdef CONFIG_SYSCTL_SYSCALL
2962 * General sysctl support routines
2965 /* The generic sysctl data routine (used if no strategy routine supplied) */
2966 int sysctl_data(struct ctl_table
*table
,
2967 void __user
*oldval
, size_t __user
*oldlenp
,
2968 void __user
*newval
, size_t newlen
)
2972 /* Get out of I don't have a variable */
2973 if (!table
->data
|| !table
->maxlen
)
2976 if (oldval
&& oldlenp
) {
2977 if (get_user(len
, oldlenp
))
2980 if (len
> table
->maxlen
)
2981 len
= table
->maxlen
;
2982 if (copy_to_user(oldval
, table
->data
, len
))
2984 if (put_user(len
, oldlenp
))
2989 if (newval
&& newlen
) {
2990 if (newlen
> table
->maxlen
)
2991 newlen
= table
->maxlen
;
2993 if (copy_from_user(table
->data
, newval
, newlen
))
2999 /* The generic string strategy routine: */
3000 int sysctl_string(struct ctl_table
*table
,
3001 void __user
*oldval
, size_t __user
*oldlenp
,
3002 void __user
*newval
, size_t newlen
)
3004 if (!table
->data
|| !table
->maxlen
)
3007 if (oldval
&& oldlenp
) {
3009 if (get_user(bufsize
, oldlenp
))
3012 size_t len
= strlen(table
->data
), copied
;
3014 /* This shouldn't trigger for a well-formed sysctl */
3015 if (len
> table
->maxlen
)
3016 len
= table
->maxlen
;
3018 /* Copy up to a max of bufsize-1 bytes of the string */
3019 copied
= (len
>= bufsize
) ? bufsize
- 1 : len
;
3021 if (copy_to_user(oldval
, table
->data
, copied
) ||
3022 put_user(0, (char __user
*)(oldval
+ copied
)))
3024 if (put_user(len
, oldlenp
))
3028 if (newval
&& newlen
) {
3029 size_t len
= newlen
;
3030 if (len
> table
->maxlen
)
3031 len
= table
->maxlen
;
3032 if(copy_from_user(table
->data
, newval
, len
))
3034 if (len
== table
->maxlen
)
3036 ((char *) table
->data
)[len
] = 0;
3042 * This function makes sure that all of the integers in the vector
3043 * are between the minimum and maximum values given in the arrays
3044 * table->extra1 and table->extra2, respectively.
3046 int sysctl_intvec(struct ctl_table
*table
,
3047 void __user
*oldval
, size_t __user
*oldlenp
,
3048 void __user
*newval
, size_t newlen
)
3051 if (newval
&& newlen
) {
3052 int __user
*vec
= (int __user
*) newval
;
3053 int *min
= (int *) table
->extra1
;
3054 int *max
= (int *) table
->extra2
;
3058 if (newlen
% sizeof(int) != 0)
3061 if (!table
->extra1
&& !table
->extra2
)
3064 if (newlen
> table
->maxlen
)
3065 newlen
= table
->maxlen
;
3066 length
= newlen
/ sizeof(int);
3068 for (i
= 0; i
< length
; i
++) {
3070 if (get_user(value
, vec
+ i
))
3072 if (min
&& value
< min
[i
])
3074 if (max
&& value
> max
[i
])
3081 /* Strategy function to convert jiffies to seconds */
3082 int sysctl_jiffies(struct ctl_table
*table
,
3083 void __user
*oldval
, size_t __user
*oldlenp
,
3084 void __user
*newval
, size_t newlen
)
3086 if (oldval
&& oldlenp
) {
3089 if (get_user(olen
, oldlenp
))
3094 if (olen
< sizeof(int))
3097 val
= *(int *)(table
->data
) / HZ
;
3098 if (put_user(val
, (int __user
*)oldval
))
3100 if (put_user(sizeof(int), oldlenp
))
3104 if (newval
&& newlen
) {
3106 if (newlen
!= sizeof(int))
3108 if (get_user(new, (int __user
*)newval
))
3110 *(int *)(table
->data
) = new*HZ
;
3115 /* Strategy function to convert jiffies to seconds */
3116 int sysctl_ms_jiffies(struct ctl_table
*table
,
3117 void __user
*oldval
, size_t __user
*oldlenp
,
3118 void __user
*newval
, size_t newlen
)
3120 if (oldval
&& oldlenp
) {
3123 if (get_user(olen
, oldlenp
))
3128 if (olen
< sizeof(int))
3131 val
= jiffies_to_msecs(*(int *)(table
->data
));
3132 if (put_user(val
, (int __user
*)oldval
))
3134 if (put_user(sizeof(int), oldlenp
))
3138 if (newval
&& newlen
) {
3140 if (newlen
!= sizeof(int))
3142 if (get_user(new, (int __user
*)newval
))
3144 *(int *)(table
->data
) = msecs_to_jiffies(new);
3151 #else /* CONFIG_SYSCTL_SYSCALL */
3154 SYSCALL_DEFINE1(sysctl
, struct __sysctl_args __user
*, args
)
3156 struct __sysctl_args tmp
;
3159 if (copy_from_user(&tmp
, args
, sizeof(tmp
)))
3162 error
= deprecated_sysctl_warning(&tmp
);
3164 /* If no error reading the parameters then just -ENOSYS ... */
3171 int sysctl_data(struct ctl_table
*table
,
3172 void __user
*oldval
, size_t __user
*oldlenp
,
3173 void __user
*newval
, size_t newlen
)
3178 int sysctl_string(struct ctl_table
*table
,
3179 void __user
*oldval
, size_t __user
*oldlenp
,
3180 void __user
*newval
, size_t newlen
)
3185 int sysctl_intvec(struct ctl_table
*table
,
3186 void __user
*oldval
, size_t __user
*oldlenp
,
3187 void __user
*newval
, size_t newlen
)
3192 int sysctl_jiffies(struct ctl_table
*table
,
3193 void __user
*oldval
, size_t __user
*oldlenp
,
3194 void __user
*newval
, size_t newlen
)
3199 int sysctl_ms_jiffies(struct ctl_table
*table
,
3200 void __user
*oldval
, size_t __user
*oldlenp
,
3201 void __user
*newval
, size_t newlen
)
3206 #endif /* CONFIG_SYSCTL_SYSCALL */
3208 static int deprecated_sysctl_warning(struct __sysctl_args
*args
)
3210 static int msg_count
;
3211 int name
[CTL_MAXNAME
];
3214 /* Check args->nlen. */
3215 if (args
->nlen
< 0 || args
->nlen
> CTL_MAXNAME
)
3218 /* Read in the sysctl name for better debug message logging */
3219 for (i
= 0; i
< args
->nlen
; i
++)
3220 if (get_user(name
[i
], args
->name
+ i
))
3223 /* Ignore accesses to kernel.version */
3224 if ((args
->nlen
== 2) && (name
[0] == CTL_KERN
) && (name
[1] == KERN_VERSION
))
3227 if (msg_count
< 5) {
3230 "warning: process `%s' used the deprecated sysctl "
3231 "system call with ", current
->comm
);
3232 for (i
= 0; i
< args
->nlen
; i
++)
3233 printk("%d.", name
[i
]);
3240 * No sense putting this after each symbol definition, twice,
3241 * exception granted :-)
3243 EXPORT_SYMBOL(proc_dointvec
);
3244 EXPORT_SYMBOL(proc_dointvec_jiffies
);
3245 EXPORT_SYMBOL(proc_dointvec_minmax
);
3246 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
3247 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
3248 EXPORT_SYMBOL(proc_dostring
);
3249 EXPORT_SYMBOL(proc_doulongvec_minmax
);
3250 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);
3251 EXPORT_SYMBOL(register_sysctl_table
);
3252 EXPORT_SYMBOL(register_sysctl_paths
);
3253 EXPORT_SYMBOL(sysctl_intvec
);
3254 EXPORT_SYMBOL(sysctl_jiffies
);
3255 EXPORT_SYMBOL(sysctl_ms_jiffies
);
3256 EXPORT_SYMBOL(sysctl_string
);
3257 EXPORT_SYMBOL(sysctl_data
);
3258 EXPORT_SYMBOL(unregister_sysctl_table
);