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/ratelimit.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>
60 #include <asm/stacktrace.h>
64 static int deprecated_sysctl_warning(struct __sysctl_args
*args
);
66 #if defined(CONFIG_SYSCTL)
68 /* External variables not in a header file. */
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 unsigned int core_pipe_limit
;
82 extern int min_free_kbytes
;
83 extern int pid_max_min
, pid_max_max
;
84 extern int sysctl_drop_caches
;
85 extern int percpu_pagelist_fraction
;
86 extern int compat_log
;
87 extern int latencytop_enabled
;
88 extern int sysctl_nr_open_min
, sysctl_nr_open_max
;
90 extern int sysctl_nr_trim_pages
;
92 #ifdef CONFIG_RCU_TORTURE_TEST
93 extern int rcutorture_runnable
;
94 #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
96 extern int blk_iopoll_enabled
;
99 /* Constants used for minimum and maximum */
100 #ifdef CONFIG_DETECT_SOFTLOCKUP
101 static int sixty
= 60;
102 static int neg_one
= -1;
106 static int __maybe_unused one
= 1;
107 static int __maybe_unused two
= 2;
108 static unsigned long one_ul
= 1;
109 static int one_hundred
= 100;
111 static int ten_thousand
= 10000;
114 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
115 static unsigned long dirty_bytes_min
= 2 * PAGE_SIZE
;
117 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
118 static int maxolduid
= 65535;
119 static int minolduid
;
120 static int min_percpu_pagelist_fract
= 8;
122 static int ngroups_max
= NGROUPS_MAX
;
124 #ifdef CONFIG_MODULES
125 extern char modprobe_path
[];
126 extern int modules_disabled
;
128 #ifdef CONFIG_CHR_DEV_SG
129 extern int sg_big_buff
;
133 #include <asm/system.h>
136 #ifdef CONFIG_SPARC64
137 extern int sysctl_tsb_ratio
;
141 extern int pwrsw_enabled
;
142 extern int unaligned_enabled
;
146 #ifdef CONFIG_MATHEMU
147 extern int sysctl_ieee_emulation_warnings
;
149 extern int sysctl_userprocess_debug
;
150 extern int spin_retry
;
153 #ifdef CONFIG_BSD_PROCESS_ACCT
154 extern int acct_parm
[];
158 extern int no_unaligned_warning
;
159 extern int unaligned_dump_stack
;
162 extern struct ratelimit_state printk_ratelimit_state
;
164 #ifdef CONFIG_RT_MUTEXES
165 extern int max_lock_depth
;
168 #ifdef CONFIG_PROC_SYSCTL
169 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
170 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
171 static int proc_taint(struct ctl_table
*table
, int write
,
172 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
175 static struct ctl_table root_table
[];
176 static struct ctl_table_root sysctl_table_root
;
177 static struct ctl_table_header root_table_header
= {
179 .ctl_table
= root_table
,
180 .ctl_entry
= LIST_HEAD_INIT(sysctl_table_root
.default_set
.list
),
181 .root
= &sysctl_table_root
,
182 .set
= &sysctl_table_root
.default_set
,
184 static struct ctl_table_root sysctl_table_root
= {
185 .root_list
= LIST_HEAD_INIT(sysctl_table_root
.root_list
),
186 .default_set
.list
= LIST_HEAD_INIT(root_table_header
.ctl_entry
),
189 static struct ctl_table kern_table
[];
190 static struct ctl_table vm_table
[];
191 static struct ctl_table fs_table
[];
192 static struct ctl_table debug_table
[];
193 static struct ctl_table dev_table
[];
194 extern struct ctl_table random_table
[];
195 #ifdef CONFIG_INOTIFY_USER
196 extern struct ctl_table inotify_table
[];
199 extern struct ctl_table epoll_table
[];
202 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
203 int sysctl_legacy_va_layout
;
206 extern int prove_locking
;
207 extern int lock_stat
;
209 /* The default sysctl tables: */
211 static struct ctl_table root_table
[] = {
213 .ctl_name
= CTL_KERN
,
214 .procname
= "kernel",
231 .ctl_name
= CTL_DEBUG
,
234 .child
= debug_table
,
243 * NOTE: do not add new entries to this table unless you have read
244 * Documentation/sysctl/ctl_unnumbered.txt
249 #ifdef CONFIG_SCHED_DEBUG
250 static int min_sched_granularity_ns
= 100000; /* 100 usecs */
251 static int max_sched_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
252 static int min_wakeup_granularity_ns
; /* 0 usecs */
253 static int max_wakeup_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
256 static struct ctl_table kern_table
[] = {
258 .ctl_name
= CTL_UNNUMBERED
,
259 .procname
= "sched_child_runs_first",
260 .data
= &sysctl_sched_child_runs_first
,
261 .maxlen
= sizeof(unsigned int),
263 .proc_handler
= &proc_dointvec
,
265 #ifdef CONFIG_SCHED_DEBUG
267 .ctl_name
= CTL_UNNUMBERED
,
268 .procname
= "sched_min_granularity_ns",
269 .data
= &sysctl_sched_min_granularity
,
270 .maxlen
= sizeof(unsigned int),
272 .proc_handler
= &sched_nr_latency_handler
,
273 .strategy
= &sysctl_intvec
,
274 .extra1
= &min_sched_granularity_ns
,
275 .extra2
= &max_sched_granularity_ns
,
278 .ctl_name
= CTL_UNNUMBERED
,
279 .procname
= "sched_latency_ns",
280 .data
= &sysctl_sched_latency
,
281 .maxlen
= sizeof(unsigned int),
283 .proc_handler
= &sched_nr_latency_handler
,
284 .strategy
= &sysctl_intvec
,
285 .extra1
= &min_sched_granularity_ns
,
286 .extra2
= &max_sched_granularity_ns
,
289 .ctl_name
= CTL_UNNUMBERED
,
290 .procname
= "sched_wakeup_granularity_ns",
291 .data
= &sysctl_sched_wakeup_granularity
,
292 .maxlen
= sizeof(unsigned int),
294 .proc_handler
= &proc_dointvec_minmax
,
295 .strategy
= &sysctl_intvec
,
296 .extra1
= &min_wakeup_granularity_ns
,
297 .extra2
= &max_wakeup_granularity_ns
,
300 .ctl_name
= CTL_UNNUMBERED
,
301 .procname
= "sched_shares_ratelimit",
302 .data
= &sysctl_sched_shares_ratelimit
,
303 .maxlen
= sizeof(unsigned int),
305 .proc_handler
= &proc_dointvec
,
308 .ctl_name
= CTL_UNNUMBERED
,
309 .procname
= "sched_shares_thresh",
310 .data
= &sysctl_sched_shares_thresh
,
311 .maxlen
= sizeof(unsigned int),
313 .proc_handler
= &proc_dointvec_minmax
,
314 .strategy
= &sysctl_intvec
,
318 .ctl_name
= CTL_UNNUMBERED
,
319 .procname
= "sched_migration_cost",
320 .data
= &sysctl_sched_migration_cost
,
321 .maxlen
= sizeof(unsigned int),
323 .proc_handler
= &proc_dointvec
,
326 .ctl_name
= CTL_UNNUMBERED
,
327 .procname
= "sched_nr_migrate",
328 .data
= &sysctl_sched_nr_migrate
,
329 .maxlen
= sizeof(unsigned int),
331 .proc_handler
= &proc_dointvec
,
334 .ctl_name
= CTL_UNNUMBERED
,
335 .procname
= "sched_time_avg",
336 .data
= &sysctl_sched_time_avg
,
337 .maxlen
= sizeof(unsigned int),
339 .proc_handler
= &proc_dointvec
,
342 .ctl_name
= CTL_UNNUMBERED
,
343 .procname
= "timer_migration",
344 .data
= &sysctl_timer_migration
,
345 .maxlen
= sizeof(unsigned int),
347 .proc_handler
= &proc_dointvec_minmax
,
348 .strategy
= &sysctl_intvec
,
354 .ctl_name
= CTL_UNNUMBERED
,
355 .procname
= "sched_rt_period_us",
356 .data
= &sysctl_sched_rt_period
,
357 .maxlen
= sizeof(unsigned int),
359 .proc_handler
= &sched_rt_handler
,
362 .ctl_name
= CTL_UNNUMBERED
,
363 .procname
= "sched_rt_runtime_us",
364 .data
= &sysctl_sched_rt_runtime
,
365 .maxlen
= sizeof(int),
367 .proc_handler
= &sched_rt_handler
,
370 .ctl_name
= CTL_UNNUMBERED
,
371 .procname
= "sched_compat_yield",
372 .data
= &sysctl_sched_compat_yield
,
373 .maxlen
= sizeof(unsigned int),
375 .proc_handler
= &proc_dointvec
,
377 #ifdef CONFIG_PROVE_LOCKING
379 .ctl_name
= CTL_UNNUMBERED
,
380 .procname
= "prove_locking",
381 .data
= &prove_locking
,
382 .maxlen
= sizeof(int),
384 .proc_handler
= &proc_dointvec
,
387 #ifdef CONFIG_LOCK_STAT
389 .ctl_name
= CTL_UNNUMBERED
,
390 .procname
= "lock_stat",
392 .maxlen
= sizeof(int),
394 .proc_handler
= &proc_dointvec
,
398 .ctl_name
= KERN_PANIC
,
400 .data
= &panic_timeout
,
401 .maxlen
= sizeof(int),
403 .proc_handler
= &proc_dointvec
,
406 .ctl_name
= KERN_CORE_USES_PID
,
407 .procname
= "core_uses_pid",
408 .data
= &core_uses_pid
,
409 .maxlen
= sizeof(int),
411 .proc_handler
= &proc_dointvec
,
414 .ctl_name
= KERN_CORE_PATTERN
,
415 .procname
= "core_pattern",
416 .data
= core_pattern
,
417 .maxlen
= CORENAME_MAX_SIZE
,
419 .proc_handler
= &proc_dostring
,
420 .strategy
= &sysctl_string
,
423 .ctl_name
= CTL_UNNUMBERED
,
424 .procname
= "core_pipe_limit",
425 .data
= &core_pipe_limit
,
426 .maxlen
= sizeof(unsigned int),
428 .proc_handler
= &proc_dointvec
,
430 #ifdef CONFIG_PROC_SYSCTL
432 .procname
= "tainted",
433 .maxlen
= sizeof(long),
435 .proc_handler
= &proc_taint
,
438 #ifdef CONFIG_LATENCYTOP
440 .procname
= "latencytop",
441 .data
= &latencytop_enabled
,
442 .maxlen
= sizeof(int),
444 .proc_handler
= &proc_dointvec
,
447 #ifdef CONFIG_BLK_DEV_INITRD
449 .ctl_name
= KERN_REALROOTDEV
,
450 .procname
= "real-root-dev",
451 .data
= &real_root_dev
,
452 .maxlen
= sizeof(int),
454 .proc_handler
= &proc_dointvec
,
458 .ctl_name
= CTL_UNNUMBERED
,
459 .procname
= "print-fatal-signals",
460 .data
= &print_fatal_signals
,
461 .maxlen
= sizeof(int),
463 .proc_handler
= &proc_dointvec
,
467 .ctl_name
= KERN_SPARC_REBOOT
,
468 .procname
= "reboot-cmd",
469 .data
= reboot_command
,
472 .proc_handler
= &proc_dostring
,
473 .strategy
= &sysctl_string
,
476 .ctl_name
= KERN_SPARC_STOP_A
,
477 .procname
= "stop-a",
478 .data
= &stop_a_enabled
,
479 .maxlen
= sizeof (int),
481 .proc_handler
= &proc_dointvec
,
484 .ctl_name
= KERN_SPARC_SCONS_PWROFF
,
485 .procname
= "scons-poweroff",
486 .data
= &scons_pwroff
,
487 .maxlen
= sizeof (int),
489 .proc_handler
= &proc_dointvec
,
492 #ifdef CONFIG_SPARC64
494 .ctl_name
= CTL_UNNUMBERED
,
495 .procname
= "tsb-ratio",
496 .data
= &sysctl_tsb_ratio
,
497 .maxlen
= sizeof (int),
499 .proc_handler
= &proc_dointvec
,
504 .ctl_name
= KERN_HPPA_PWRSW
,
505 .procname
= "soft-power",
506 .data
= &pwrsw_enabled
,
507 .maxlen
= sizeof (int),
509 .proc_handler
= &proc_dointvec
,
512 .ctl_name
= KERN_HPPA_UNALIGNED
,
513 .procname
= "unaligned-trap",
514 .data
= &unaligned_enabled
,
515 .maxlen
= sizeof (int),
517 .proc_handler
= &proc_dointvec
,
521 .ctl_name
= KERN_CTLALTDEL
,
522 .procname
= "ctrl-alt-del",
524 .maxlen
= sizeof(int),
526 .proc_handler
= &proc_dointvec
,
528 #ifdef CONFIG_FUNCTION_TRACER
530 .ctl_name
= CTL_UNNUMBERED
,
531 .procname
= "ftrace_enabled",
532 .data
= &ftrace_enabled
,
533 .maxlen
= sizeof(int),
535 .proc_handler
= &ftrace_enable_sysctl
,
538 #ifdef CONFIG_STACK_TRACER
540 .ctl_name
= CTL_UNNUMBERED
,
541 .procname
= "stack_tracer_enabled",
542 .data
= &stack_tracer_enabled
,
543 .maxlen
= sizeof(int),
545 .proc_handler
= &stack_trace_sysctl
,
548 #ifdef CONFIG_TRACING
550 .ctl_name
= CTL_UNNUMBERED
,
551 .procname
= "ftrace_dump_on_oops",
552 .data
= &ftrace_dump_on_oops
,
553 .maxlen
= sizeof(int),
555 .proc_handler
= &proc_dointvec
,
558 #ifdef CONFIG_MODULES
560 .ctl_name
= KERN_MODPROBE
,
561 .procname
= "modprobe",
562 .data
= &modprobe_path
,
563 .maxlen
= KMOD_PATH_LEN
,
565 .proc_handler
= &proc_dostring
,
566 .strategy
= &sysctl_string
,
569 .ctl_name
= CTL_UNNUMBERED
,
570 .procname
= "modules_disabled",
571 .data
= &modules_disabled
,
572 .maxlen
= sizeof(int),
574 /* only handle a transition from default "0" to "1" */
575 .proc_handler
= &proc_dointvec_minmax
,
580 #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
582 .ctl_name
= KERN_HOTPLUG
,
583 .procname
= "hotplug",
584 .data
= &uevent_helper
,
585 .maxlen
= UEVENT_HELPER_PATH_LEN
,
587 .proc_handler
= &proc_dostring
,
588 .strategy
= &sysctl_string
,
591 #ifdef CONFIG_CHR_DEV_SG
593 .ctl_name
= KERN_SG_BIG_BUFF
,
594 .procname
= "sg-big-buff",
595 .data
= &sg_big_buff
,
596 .maxlen
= sizeof (int),
598 .proc_handler
= &proc_dointvec
,
601 #ifdef CONFIG_BSD_PROCESS_ACCT
603 .ctl_name
= KERN_ACCT
,
606 .maxlen
= 3*sizeof(int),
608 .proc_handler
= &proc_dointvec
,
611 #ifdef CONFIG_MAGIC_SYSRQ
613 .ctl_name
= KERN_SYSRQ
,
615 .data
= &__sysrq_enabled
,
616 .maxlen
= sizeof (int),
618 .proc_handler
= &proc_dointvec
,
621 #ifdef CONFIG_PROC_SYSCTL
623 .procname
= "cad_pid",
625 .maxlen
= sizeof (int),
627 .proc_handler
= &proc_do_cad_pid
,
631 .ctl_name
= KERN_MAX_THREADS
,
632 .procname
= "threads-max",
633 .data
= &max_threads
,
634 .maxlen
= sizeof(int),
636 .proc_handler
= &proc_dointvec
,
639 .ctl_name
= KERN_RANDOM
,
640 .procname
= "random",
642 .child
= random_table
,
645 .ctl_name
= KERN_OVERFLOWUID
,
646 .procname
= "overflowuid",
647 .data
= &overflowuid
,
648 .maxlen
= sizeof(int),
650 .proc_handler
= &proc_dointvec_minmax
,
651 .strategy
= &sysctl_intvec
,
652 .extra1
= &minolduid
,
653 .extra2
= &maxolduid
,
656 .ctl_name
= KERN_OVERFLOWGID
,
657 .procname
= "overflowgid",
658 .data
= &overflowgid
,
659 .maxlen
= sizeof(int),
661 .proc_handler
= &proc_dointvec_minmax
,
662 .strategy
= &sysctl_intvec
,
663 .extra1
= &minolduid
,
664 .extra2
= &maxolduid
,
667 #ifdef CONFIG_MATHEMU
669 .ctl_name
= KERN_IEEE_EMULATION_WARNINGS
,
670 .procname
= "ieee_emulation_warnings",
671 .data
= &sysctl_ieee_emulation_warnings
,
672 .maxlen
= sizeof(int),
674 .proc_handler
= &proc_dointvec
,
678 .ctl_name
= KERN_S390_USER_DEBUG_LOGGING
,
679 .procname
= "userprocess_debug",
680 .data
= &sysctl_userprocess_debug
,
681 .maxlen
= sizeof(int),
683 .proc_handler
= &proc_dointvec
,
687 .ctl_name
= KERN_PIDMAX
,
688 .procname
= "pid_max",
690 .maxlen
= sizeof (int),
692 .proc_handler
= &proc_dointvec_minmax
,
693 .strategy
= sysctl_intvec
,
694 .extra1
= &pid_max_min
,
695 .extra2
= &pid_max_max
,
698 .ctl_name
= KERN_PANIC_ON_OOPS
,
699 .procname
= "panic_on_oops",
700 .data
= &panic_on_oops
,
701 .maxlen
= sizeof(int),
703 .proc_handler
= &proc_dointvec
,
705 #if defined CONFIG_PRINTK
707 .ctl_name
= KERN_PRINTK
,
708 .procname
= "printk",
709 .data
= &console_loglevel
,
710 .maxlen
= 4*sizeof(int),
712 .proc_handler
= &proc_dointvec
,
715 .ctl_name
= KERN_PRINTK_RATELIMIT
,
716 .procname
= "printk_ratelimit",
717 .data
= &printk_ratelimit_state
.interval
,
718 .maxlen
= sizeof(int),
720 .proc_handler
= &proc_dointvec_jiffies
,
721 .strategy
= &sysctl_jiffies
,
724 .ctl_name
= KERN_PRINTK_RATELIMIT_BURST
,
725 .procname
= "printk_ratelimit_burst",
726 .data
= &printk_ratelimit_state
.burst
,
727 .maxlen
= sizeof(int),
729 .proc_handler
= &proc_dointvec
,
732 .ctl_name
= CTL_UNNUMBERED
,
733 .procname
= "printk_delay",
734 .data
= &printk_delay_msec
,
735 .maxlen
= sizeof(int),
737 .proc_handler
= &proc_dointvec_minmax
,
738 .strategy
= &sysctl_intvec
,
740 .extra2
= &ten_thousand
,
744 .ctl_name
= KERN_NGROUPS_MAX
,
745 .procname
= "ngroups_max",
746 .data
= &ngroups_max
,
747 .maxlen
= sizeof (int),
749 .proc_handler
= &proc_dointvec
,
751 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
753 .ctl_name
= KERN_UNKNOWN_NMI_PANIC
,
754 .procname
= "unknown_nmi_panic",
755 .data
= &unknown_nmi_panic
,
756 .maxlen
= sizeof (int),
758 .proc_handler
= &proc_dointvec
,
761 .procname
= "nmi_watchdog",
762 .data
= &nmi_watchdog_enabled
,
763 .maxlen
= sizeof (int),
765 .proc_handler
= &proc_nmi_enabled
,
768 #if defined(CONFIG_X86)
770 .ctl_name
= KERN_PANIC_ON_NMI
,
771 .procname
= "panic_on_unrecovered_nmi",
772 .data
= &panic_on_unrecovered_nmi
,
773 .maxlen
= sizeof(int),
775 .proc_handler
= &proc_dointvec
,
778 .ctl_name
= CTL_UNNUMBERED
,
779 .procname
= "panic_on_io_nmi",
780 .data
= &panic_on_io_nmi
,
781 .maxlen
= sizeof(int),
783 .proc_handler
= &proc_dointvec
,
786 .ctl_name
= KERN_BOOTLOADER_TYPE
,
787 .procname
= "bootloader_type",
788 .data
= &bootloader_type
,
789 .maxlen
= sizeof (int),
791 .proc_handler
= &proc_dointvec
,
794 .ctl_name
= CTL_UNNUMBERED
,
795 .procname
= "bootloader_version",
796 .data
= &bootloader_version
,
797 .maxlen
= sizeof (int),
799 .proc_handler
= &proc_dointvec
,
802 .ctl_name
= CTL_UNNUMBERED
,
803 .procname
= "kstack_depth_to_print",
804 .data
= &kstack_depth_to_print
,
805 .maxlen
= sizeof(int),
807 .proc_handler
= &proc_dointvec
,
810 .ctl_name
= CTL_UNNUMBERED
,
811 .procname
= "io_delay_type",
812 .data
= &io_delay_type
,
813 .maxlen
= sizeof(int),
815 .proc_handler
= &proc_dointvec
,
818 #if defined(CONFIG_MMU)
820 .ctl_name
= KERN_RANDOMIZE
,
821 .procname
= "randomize_va_space",
822 .data
= &randomize_va_space
,
823 .maxlen
= sizeof(int),
825 .proc_handler
= &proc_dointvec
,
828 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
830 .ctl_name
= KERN_SPIN_RETRY
,
831 .procname
= "spin_retry",
833 .maxlen
= sizeof (int),
835 .proc_handler
= &proc_dointvec
,
838 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
840 .procname
= "acpi_video_flags",
841 .data
= &acpi_realmode_flags
,
842 .maxlen
= sizeof (unsigned long),
844 .proc_handler
= &proc_doulongvec_minmax
,
849 .ctl_name
= KERN_IA64_UNALIGNED
,
850 .procname
= "ignore-unaligned-usertrap",
851 .data
= &no_unaligned_warning
,
852 .maxlen
= sizeof (int),
854 .proc_handler
= &proc_dointvec
,
857 .ctl_name
= CTL_UNNUMBERED
,
858 .procname
= "unaligned-dump-stack",
859 .data
= &unaligned_dump_stack
,
860 .maxlen
= sizeof (int),
862 .proc_handler
= &proc_dointvec
,
865 #ifdef CONFIG_DETECT_SOFTLOCKUP
867 .ctl_name
= CTL_UNNUMBERED
,
868 .procname
= "softlockup_panic",
869 .data
= &softlockup_panic
,
870 .maxlen
= sizeof(int),
872 .proc_handler
= &proc_dointvec_minmax
,
873 .strategy
= &sysctl_intvec
,
878 .ctl_name
= CTL_UNNUMBERED
,
879 .procname
= "softlockup_thresh",
880 .data
= &softlockup_thresh
,
881 .maxlen
= sizeof(int),
883 .proc_handler
= &proc_dosoftlockup_thresh
,
884 .strategy
= &sysctl_intvec
,
889 #ifdef CONFIG_DETECT_HUNG_TASK
891 .ctl_name
= CTL_UNNUMBERED
,
892 .procname
= "hung_task_panic",
893 .data
= &sysctl_hung_task_panic
,
894 .maxlen
= sizeof(int),
896 .proc_handler
= &proc_dointvec_minmax
,
897 .strategy
= &sysctl_intvec
,
902 .ctl_name
= CTL_UNNUMBERED
,
903 .procname
= "hung_task_check_count",
904 .data
= &sysctl_hung_task_check_count
,
905 .maxlen
= sizeof(unsigned long),
907 .proc_handler
= &proc_doulongvec_minmax
,
908 .strategy
= &sysctl_intvec
,
911 .ctl_name
= CTL_UNNUMBERED
,
912 .procname
= "hung_task_timeout_secs",
913 .data
= &sysctl_hung_task_timeout_secs
,
914 .maxlen
= sizeof(unsigned long),
916 .proc_handler
= &proc_dohung_task_timeout_secs
,
917 .strategy
= &sysctl_intvec
,
920 .ctl_name
= CTL_UNNUMBERED
,
921 .procname
= "hung_task_warnings",
922 .data
= &sysctl_hung_task_warnings
,
923 .maxlen
= sizeof(unsigned long),
925 .proc_handler
= &proc_doulongvec_minmax
,
926 .strategy
= &sysctl_intvec
,
931 .ctl_name
= KERN_COMPAT_LOG
,
932 .procname
= "compat-log",
934 .maxlen
= sizeof (int),
936 .proc_handler
= &proc_dointvec
,
939 #ifdef CONFIG_RT_MUTEXES
941 .ctl_name
= KERN_MAX_LOCK_DEPTH
,
942 .procname
= "max_lock_depth",
943 .data
= &max_lock_depth
,
944 .maxlen
= sizeof(int),
946 .proc_handler
= &proc_dointvec
,
950 .ctl_name
= CTL_UNNUMBERED
,
951 .procname
= "poweroff_cmd",
952 .data
= &poweroff_cmd
,
953 .maxlen
= POWEROFF_CMD_PATH_LEN
,
955 .proc_handler
= &proc_dostring
,
956 .strategy
= &sysctl_string
,
960 .ctl_name
= CTL_UNNUMBERED
,
963 .child
= key_sysctls
,
966 #ifdef CONFIG_RCU_TORTURE_TEST
968 .ctl_name
= CTL_UNNUMBERED
,
969 .procname
= "rcutorture_runnable",
970 .data
= &rcutorture_runnable
,
971 .maxlen
= sizeof(int),
973 .proc_handler
= &proc_dointvec
,
976 #ifdef CONFIG_SLOW_WORK
978 .ctl_name
= CTL_UNNUMBERED
,
979 .procname
= "slow-work",
981 .child
= slow_work_sysctls
,
984 #ifdef CONFIG_PERF_EVENTS
986 .ctl_name
= CTL_UNNUMBERED
,
987 .procname
= "perf_event_paranoid",
988 .data
= &sysctl_perf_event_paranoid
,
989 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
991 .proc_handler
= &proc_dointvec
,
994 .ctl_name
= CTL_UNNUMBERED
,
995 .procname
= "perf_event_mlock_kb",
996 .data
= &sysctl_perf_event_mlock
,
997 .maxlen
= sizeof(sysctl_perf_event_mlock
),
999 .proc_handler
= &proc_dointvec
,
1002 .ctl_name
= CTL_UNNUMBERED
,
1003 .procname
= "perf_event_max_sample_rate",
1004 .data
= &sysctl_perf_event_sample_rate
,
1005 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1007 .proc_handler
= &proc_dointvec
,
1010 #ifdef CONFIG_KMEMCHECK
1012 .ctl_name
= CTL_UNNUMBERED
,
1013 .procname
= "kmemcheck",
1014 .data
= &kmemcheck_enabled
,
1015 .maxlen
= sizeof(int),
1017 .proc_handler
= &proc_dointvec
,
1022 .ctl_name
= CTL_UNNUMBERED
,
1023 .procname
= "blk_iopoll",
1024 .data
= &blk_iopoll_enabled
,
1025 .maxlen
= sizeof(int),
1027 .proc_handler
= &proc_dointvec
,
1031 * NOTE: do not add new entries to this table unless you have read
1032 * Documentation/sysctl/ctl_unnumbered.txt
1037 static struct ctl_table vm_table
[] = {
1039 .ctl_name
= VM_OVERCOMMIT_MEMORY
,
1040 .procname
= "overcommit_memory",
1041 .data
= &sysctl_overcommit_memory
,
1042 .maxlen
= sizeof(sysctl_overcommit_memory
),
1044 .proc_handler
= &proc_dointvec
,
1047 .ctl_name
= VM_PANIC_ON_OOM
,
1048 .procname
= "panic_on_oom",
1049 .data
= &sysctl_panic_on_oom
,
1050 .maxlen
= sizeof(sysctl_panic_on_oom
),
1052 .proc_handler
= &proc_dointvec
,
1055 .ctl_name
= CTL_UNNUMBERED
,
1056 .procname
= "oom_kill_allocating_task",
1057 .data
= &sysctl_oom_kill_allocating_task
,
1058 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
1060 .proc_handler
= &proc_dointvec
,
1063 .ctl_name
= CTL_UNNUMBERED
,
1064 .procname
= "oom_dump_tasks",
1065 .data
= &sysctl_oom_dump_tasks
,
1066 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
1068 .proc_handler
= &proc_dointvec
,
1071 .ctl_name
= VM_OVERCOMMIT_RATIO
,
1072 .procname
= "overcommit_ratio",
1073 .data
= &sysctl_overcommit_ratio
,
1074 .maxlen
= sizeof(sysctl_overcommit_ratio
),
1076 .proc_handler
= &proc_dointvec
,
1079 .ctl_name
= VM_PAGE_CLUSTER
,
1080 .procname
= "page-cluster",
1081 .data
= &page_cluster
,
1082 .maxlen
= sizeof(int),
1084 .proc_handler
= &proc_dointvec
,
1087 .ctl_name
= VM_DIRTY_BACKGROUND
,
1088 .procname
= "dirty_background_ratio",
1089 .data
= &dirty_background_ratio
,
1090 .maxlen
= sizeof(dirty_background_ratio
),
1092 .proc_handler
= &dirty_background_ratio_handler
,
1093 .strategy
= &sysctl_intvec
,
1095 .extra2
= &one_hundred
,
1098 .ctl_name
= CTL_UNNUMBERED
,
1099 .procname
= "dirty_background_bytes",
1100 .data
= &dirty_background_bytes
,
1101 .maxlen
= sizeof(dirty_background_bytes
),
1103 .proc_handler
= &dirty_background_bytes_handler
,
1104 .strategy
= &sysctl_intvec
,
1108 .ctl_name
= VM_DIRTY_RATIO
,
1109 .procname
= "dirty_ratio",
1110 .data
= &vm_dirty_ratio
,
1111 .maxlen
= sizeof(vm_dirty_ratio
),
1113 .proc_handler
= &dirty_ratio_handler
,
1114 .strategy
= &sysctl_intvec
,
1116 .extra2
= &one_hundred
,
1119 .ctl_name
= CTL_UNNUMBERED
,
1120 .procname
= "dirty_bytes",
1121 .data
= &vm_dirty_bytes
,
1122 .maxlen
= sizeof(vm_dirty_bytes
),
1124 .proc_handler
= &dirty_bytes_handler
,
1125 .strategy
= &sysctl_intvec
,
1126 .extra1
= &dirty_bytes_min
,
1129 .procname
= "dirty_writeback_centisecs",
1130 .data
= &dirty_writeback_interval
,
1131 .maxlen
= sizeof(dirty_writeback_interval
),
1133 .proc_handler
= &dirty_writeback_centisecs_handler
,
1136 .procname
= "dirty_expire_centisecs",
1137 .data
= &dirty_expire_interval
,
1138 .maxlen
= sizeof(dirty_expire_interval
),
1140 .proc_handler
= &proc_dointvec
,
1143 .ctl_name
= VM_NR_PDFLUSH_THREADS
,
1144 .procname
= "nr_pdflush_threads",
1145 .data
= &nr_pdflush_threads
,
1146 .maxlen
= sizeof nr_pdflush_threads
,
1147 .mode
= 0444 /* read-only*/,
1148 .proc_handler
= &proc_dointvec
,
1151 .ctl_name
= VM_SWAPPINESS
,
1152 .procname
= "swappiness",
1153 .data
= &vm_swappiness
,
1154 .maxlen
= sizeof(vm_swappiness
),
1156 .proc_handler
= &proc_dointvec_minmax
,
1157 .strategy
= &sysctl_intvec
,
1159 .extra2
= &one_hundred
,
1161 #ifdef CONFIG_HUGETLB_PAGE
1163 .procname
= "nr_hugepages",
1165 .maxlen
= sizeof(unsigned long),
1167 .proc_handler
= &hugetlb_sysctl_handler
,
1168 .extra1
= (void *)&hugetlb_zero
,
1169 .extra2
= (void *)&hugetlb_infinity
,
1172 .ctl_name
= VM_HUGETLB_GROUP
,
1173 .procname
= "hugetlb_shm_group",
1174 .data
= &sysctl_hugetlb_shm_group
,
1175 .maxlen
= sizeof(gid_t
),
1177 .proc_handler
= &proc_dointvec
,
1180 .ctl_name
= CTL_UNNUMBERED
,
1181 .procname
= "hugepages_treat_as_movable",
1182 .data
= &hugepages_treat_as_movable
,
1183 .maxlen
= sizeof(int),
1185 .proc_handler
= &hugetlb_treat_movable_handler
,
1188 .ctl_name
= CTL_UNNUMBERED
,
1189 .procname
= "nr_overcommit_hugepages",
1191 .maxlen
= sizeof(unsigned long),
1193 .proc_handler
= &hugetlb_overcommit_handler
,
1194 .extra1
= (void *)&hugetlb_zero
,
1195 .extra2
= (void *)&hugetlb_infinity
,
1199 .ctl_name
= VM_LOWMEM_RESERVE_RATIO
,
1200 .procname
= "lowmem_reserve_ratio",
1201 .data
= &sysctl_lowmem_reserve_ratio
,
1202 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
1204 .proc_handler
= &lowmem_reserve_ratio_sysctl_handler
,
1205 .strategy
= &sysctl_intvec
,
1208 .ctl_name
= VM_DROP_PAGECACHE
,
1209 .procname
= "drop_caches",
1210 .data
= &sysctl_drop_caches
,
1211 .maxlen
= sizeof(int),
1213 .proc_handler
= drop_caches_sysctl_handler
,
1214 .strategy
= &sysctl_intvec
,
1217 .ctl_name
= VM_MIN_FREE_KBYTES
,
1218 .procname
= "min_free_kbytes",
1219 .data
= &min_free_kbytes
,
1220 .maxlen
= sizeof(min_free_kbytes
),
1222 .proc_handler
= &min_free_kbytes_sysctl_handler
,
1223 .strategy
= &sysctl_intvec
,
1227 .ctl_name
= VM_PERCPU_PAGELIST_FRACTION
,
1228 .procname
= "percpu_pagelist_fraction",
1229 .data
= &percpu_pagelist_fraction
,
1230 .maxlen
= sizeof(percpu_pagelist_fraction
),
1232 .proc_handler
= &percpu_pagelist_fraction_sysctl_handler
,
1233 .strategy
= &sysctl_intvec
,
1234 .extra1
= &min_percpu_pagelist_fract
,
1238 .ctl_name
= VM_MAX_MAP_COUNT
,
1239 .procname
= "max_map_count",
1240 .data
= &sysctl_max_map_count
,
1241 .maxlen
= sizeof(sysctl_max_map_count
),
1243 .proc_handler
= &proc_dointvec
1247 .ctl_name
= CTL_UNNUMBERED
,
1248 .procname
= "nr_trim_pages",
1249 .data
= &sysctl_nr_trim_pages
,
1250 .maxlen
= sizeof(sysctl_nr_trim_pages
),
1252 .proc_handler
= &proc_dointvec_minmax
,
1253 .strategy
= &sysctl_intvec
,
1258 .ctl_name
= VM_LAPTOP_MODE
,
1259 .procname
= "laptop_mode",
1260 .data
= &laptop_mode
,
1261 .maxlen
= sizeof(laptop_mode
),
1263 .proc_handler
= &proc_dointvec_jiffies
,
1264 .strategy
= &sysctl_jiffies
,
1267 .ctl_name
= VM_BLOCK_DUMP
,
1268 .procname
= "block_dump",
1269 .data
= &block_dump
,
1270 .maxlen
= sizeof(block_dump
),
1272 .proc_handler
= &proc_dointvec
,
1273 .strategy
= &sysctl_intvec
,
1277 .ctl_name
= VM_VFS_CACHE_PRESSURE
,
1278 .procname
= "vfs_cache_pressure",
1279 .data
= &sysctl_vfs_cache_pressure
,
1280 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1282 .proc_handler
= &proc_dointvec
,
1283 .strategy
= &sysctl_intvec
,
1286 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1288 .ctl_name
= VM_LEGACY_VA_LAYOUT
,
1289 .procname
= "legacy_va_layout",
1290 .data
= &sysctl_legacy_va_layout
,
1291 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1293 .proc_handler
= &proc_dointvec
,
1294 .strategy
= &sysctl_intvec
,
1300 .ctl_name
= VM_ZONE_RECLAIM_MODE
,
1301 .procname
= "zone_reclaim_mode",
1302 .data
= &zone_reclaim_mode
,
1303 .maxlen
= sizeof(zone_reclaim_mode
),
1305 .proc_handler
= &proc_dointvec
,
1306 .strategy
= &sysctl_intvec
,
1310 .ctl_name
= VM_MIN_UNMAPPED
,
1311 .procname
= "min_unmapped_ratio",
1312 .data
= &sysctl_min_unmapped_ratio
,
1313 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1315 .proc_handler
= &sysctl_min_unmapped_ratio_sysctl_handler
,
1316 .strategy
= &sysctl_intvec
,
1318 .extra2
= &one_hundred
,
1321 .ctl_name
= VM_MIN_SLAB
,
1322 .procname
= "min_slab_ratio",
1323 .data
= &sysctl_min_slab_ratio
,
1324 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1326 .proc_handler
= &sysctl_min_slab_ratio_sysctl_handler
,
1327 .strategy
= &sysctl_intvec
,
1329 .extra2
= &one_hundred
,
1334 .ctl_name
= CTL_UNNUMBERED
,
1335 .procname
= "stat_interval",
1336 .data
= &sysctl_stat_interval
,
1337 .maxlen
= sizeof(sysctl_stat_interval
),
1339 .proc_handler
= &proc_dointvec_jiffies
,
1340 .strategy
= &sysctl_jiffies
,
1344 .ctl_name
= CTL_UNNUMBERED
,
1345 .procname
= "mmap_min_addr",
1346 .data
= &dac_mmap_min_addr
,
1347 .maxlen
= sizeof(unsigned long),
1349 .proc_handler
= &mmap_min_addr_handler
,
1353 .ctl_name
= CTL_UNNUMBERED
,
1354 .procname
= "numa_zonelist_order",
1355 .data
= &numa_zonelist_order
,
1356 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1358 .proc_handler
= &numa_zonelist_order_handler
,
1359 .strategy
= &sysctl_string
,
1362 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1363 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1365 .ctl_name
= VM_VDSO_ENABLED
,
1366 .procname
= "vdso_enabled",
1367 .data
= &vdso_enabled
,
1368 .maxlen
= sizeof(vdso_enabled
),
1370 .proc_handler
= &proc_dointvec
,
1371 .strategy
= &sysctl_intvec
,
1375 #ifdef CONFIG_HIGHMEM
1377 .ctl_name
= CTL_UNNUMBERED
,
1378 .procname
= "highmem_is_dirtyable",
1379 .data
= &vm_highmem_is_dirtyable
,
1380 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
1382 .proc_handler
= &proc_dointvec_minmax
,
1383 .strategy
= &sysctl_intvec
,
1389 .ctl_name
= CTL_UNNUMBERED
,
1390 .procname
= "scan_unevictable_pages",
1391 .data
= &scan_unevictable_pages
,
1392 .maxlen
= sizeof(scan_unevictable_pages
),
1394 .proc_handler
= &scan_unevictable_handler
,
1396 #ifdef CONFIG_MEMORY_FAILURE
1398 .ctl_name
= CTL_UNNUMBERED
,
1399 .procname
= "memory_failure_early_kill",
1400 .data
= &sysctl_memory_failure_early_kill
,
1401 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
1403 .proc_handler
= &proc_dointvec_minmax
,
1404 .strategy
= &sysctl_intvec
,
1409 .ctl_name
= CTL_UNNUMBERED
,
1410 .procname
= "memory_failure_recovery",
1411 .data
= &sysctl_memory_failure_recovery
,
1412 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
1414 .proc_handler
= &proc_dointvec_minmax
,
1415 .strategy
= &sysctl_intvec
,
1422 * NOTE: do not add new entries to this table unless you have read
1423 * Documentation/sysctl/ctl_unnumbered.txt
1428 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1429 static struct ctl_table binfmt_misc_table
[] = {
1434 static struct ctl_table fs_table
[] = {
1436 .ctl_name
= FS_NRINODE
,
1437 .procname
= "inode-nr",
1438 .data
= &inodes_stat
,
1439 .maxlen
= 2*sizeof(int),
1441 .proc_handler
= &proc_dointvec
,
1444 .ctl_name
= FS_STATINODE
,
1445 .procname
= "inode-state",
1446 .data
= &inodes_stat
,
1447 .maxlen
= 7*sizeof(int),
1449 .proc_handler
= &proc_dointvec
,
1452 .procname
= "file-nr",
1453 .data
= &files_stat
,
1454 .maxlen
= 3*sizeof(int),
1456 .proc_handler
= &proc_nr_files
,
1459 .ctl_name
= FS_MAXFILE
,
1460 .procname
= "file-max",
1461 .data
= &files_stat
.max_files
,
1462 .maxlen
= sizeof(int),
1464 .proc_handler
= &proc_dointvec
,
1467 .ctl_name
= CTL_UNNUMBERED
,
1468 .procname
= "nr_open",
1469 .data
= &sysctl_nr_open
,
1470 .maxlen
= sizeof(int),
1472 .proc_handler
= &proc_dointvec_minmax
,
1473 .extra1
= &sysctl_nr_open_min
,
1474 .extra2
= &sysctl_nr_open_max
,
1477 .ctl_name
= FS_DENTRY
,
1478 .procname
= "dentry-state",
1479 .data
= &dentry_stat
,
1480 .maxlen
= 6*sizeof(int),
1482 .proc_handler
= &proc_dointvec
,
1485 .ctl_name
= FS_OVERFLOWUID
,
1486 .procname
= "overflowuid",
1487 .data
= &fs_overflowuid
,
1488 .maxlen
= sizeof(int),
1490 .proc_handler
= &proc_dointvec_minmax
,
1491 .strategy
= &sysctl_intvec
,
1492 .extra1
= &minolduid
,
1493 .extra2
= &maxolduid
,
1496 .ctl_name
= FS_OVERFLOWGID
,
1497 .procname
= "overflowgid",
1498 .data
= &fs_overflowgid
,
1499 .maxlen
= sizeof(int),
1501 .proc_handler
= &proc_dointvec_minmax
,
1502 .strategy
= &sysctl_intvec
,
1503 .extra1
= &minolduid
,
1504 .extra2
= &maxolduid
,
1506 #ifdef CONFIG_FILE_LOCKING
1508 .ctl_name
= FS_LEASES
,
1509 .procname
= "leases-enable",
1510 .data
= &leases_enable
,
1511 .maxlen
= sizeof(int),
1513 .proc_handler
= &proc_dointvec
,
1516 #ifdef CONFIG_DNOTIFY
1518 .ctl_name
= FS_DIR_NOTIFY
,
1519 .procname
= "dir-notify-enable",
1520 .data
= &dir_notify_enable
,
1521 .maxlen
= sizeof(int),
1523 .proc_handler
= &proc_dointvec
,
1527 #ifdef CONFIG_FILE_LOCKING
1529 .ctl_name
= FS_LEASE_TIME
,
1530 .procname
= "lease-break-time",
1531 .data
= &lease_break_time
,
1532 .maxlen
= sizeof(int),
1534 .proc_handler
= &proc_dointvec
,
1539 .procname
= "aio-nr",
1541 .maxlen
= sizeof(aio_nr
),
1543 .proc_handler
= &proc_doulongvec_minmax
,
1546 .procname
= "aio-max-nr",
1547 .data
= &aio_max_nr
,
1548 .maxlen
= sizeof(aio_max_nr
),
1550 .proc_handler
= &proc_doulongvec_minmax
,
1552 #endif /* CONFIG_AIO */
1553 #ifdef CONFIG_INOTIFY_USER
1555 .ctl_name
= FS_INOTIFY
,
1556 .procname
= "inotify",
1558 .child
= inotify_table
,
1563 .procname
= "epoll",
1565 .child
= epoll_table
,
1570 .ctl_name
= KERN_SETUID_DUMPABLE
,
1571 .procname
= "suid_dumpable",
1572 .data
= &suid_dumpable
,
1573 .maxlen
= sizeof(int),
1575 .proc_handler
= &proc_dointvec_minmax
,
1576 .strategy
= &sysctl_intvec
,
1580 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1582 .ctl_name
= CTL_UNNUMBERED
,
1583 .procname
= "binfmt_misc",
1585 .child
= binfmt_misc_table
,
1589 * NOTE: do not add new entries to this table unless you have read
1590 * Documentation/sysctl/ctl_unnumbered.txt
1595 static struct ctl_table debug_table
[] = {
1596 #if defined(CONFIG_X86) || defined(CONFIG_PPC)
1598 .ctl_name
= CTL_UNNUMBERED
,
1599 .procname
= "exception-trace",
1600 .data
= &show_unhandled_signals
,
1601 .maxlen
= sizeof(int),
1603 .proc_handler
= proc_dointvec
1609 static struct ctl_table dev_table
[] = {
1613 static DEFINE_SPINLOCK(sysctl_lock
);
1615 /* called under sysctl_lock */
1616 static int use_table(struct ctl_table_header
*p
)
1618 if (unlikely(p
->unregistering
))
1624 /* called under sysctl_lock */
1625 static void unuse_table(struct ctl_table_header
*p
)
1628 if (unlikely(p
->unregistering
))
1629 complete(p
->unregistering
);
1632 /* called under sysctl_lock, will reacquire if has to wait */
1633 static void start_unregistering(struct ctl_table_header
*p
)
1636 * if p->used is 0, nobody will ever touch that entry again;
1637 * we'll eliminate all paths to it before dropping sysctl_lock
1639 if (unlikely(p
->used
)) {
1640 struct completion wait
;
1641 init_completion(&wait
);
1642 p
->unregistering
= &wait
;
1643 spin_unlock(&sysctl_lock
);
1644 wait_for_completion(&wait
);
1645 spin_lock(&sysctl_lock
);
1647 /* anything non-NULL; we'll never dereference it */
1648 p
->unregistering
= ERR_PTR(-EINVAL
);
1651 * do not remove from the list until nobody holds it; walking the
1652 * list in do_sysctl() relies on that.
1654 list_del_init(&p
->ctl_entry
);
1657 void sysctl_head_get(struct ctl_table_header
*head
)
1659 spin_lock(&sysctl_lock
);
1661 spin_unlock(&sysctl_lock
);
1664 void sysctl_head_put(struct ctl_table_header
*head
)
1666 spin_lock(&sysctl_lock
);
1669 spin_unlock(&sysctl_lock
);
1672 struct ctl_table_header
*sysctl_head_grab(struct ctl_table_header
*head
)
1676 spin_lock(&sysctl_lock
);
1677 if (!use_table(head
))
1678 head
= ERR_PTR(-ENOENT
);
1679 spin_unlock(&sysctl_lock
);
1683 void sysctl_head_finish(struct ctl_table_header
*head
)
1687 spin_lock(&sysctl_lock
);
1689 spin_unlock(&sysctl_lock
);
1692 static struct ctl_table_set
*
1693 lookup_header_set(struct ctl_table_root
*root
, struct nsproxy
*namespaces
)
1695 struct ctl_table_set
*set
= &root
->default_set
;
1697 set
= root
->lookup(root
, namespaces
);
1701 static struct list_head
*
1702 lookup_header_list(struct ctl_table_root
*root
, struct nsproxy
*namespaces
)
1704 struct ctl_table_set
*set
= lookup_header_set(root
, namespaces
);
1708 struct ctl_table_header
*__sysctl_head_next(struct nsproxy
*namespaces
,
1709 struct ctl_table_header
*prev
)
1711 struct ctl_table_root
*root
;
1712 struct list_head
*header_list
;
1713 struct ctl_table_header
*head
;
1714 struct list_head
*tmp
;
1716 spin_lock(&sysctl_lock
);
1719 tmp
= &prev
->ctl_entry
;
1723 tmp
= &root_table_header
.ctl_entry
;
1725 head
= list_entry(tmp
, struct ctl_table_header
, ctl_entry
);
1727 if (!use_table(head
))
1729 spin_unlock(&sysctl_lock
);
1734 header_list
= lookup_header_list(root
, namespaces
);
1735 if (tmp
!= header_list
)
1739 root
= list_entry(root
->root_list
.next
,
1740 struct ctl_table_root
, root_list
);
1741 if (root
== &sysctl_table_root
)
1743 header_list
= lookup_header_list(root
, namespaces
);
1744 } while (list_empty(header_list
));
1745 tmp
= header_list
->next
;
1748 spin_unlock(&sysctl_lock
);
1752 struct ctl_table_header
*sysctl_head_next(struct ctl_table_header
*prev
)
1754 return __sysctl_head_next(current
->nsproxy
, prev
);
1757 void register_sysctl_root(struct ctl_table_root
*root
)
1759 spin_lock(&sysctl_lock
);
1760 list_add_tail(&root
->root_list
, &sysctl_table_root
.root_list
);
1761 spin_unlock(&sysctl_lock
);
1764 #ifdef CONFIG_SYSCTL_SYSCALL
1765 /* Perform the actual read/write of a sysctl table entry. */
1766 static int do_sysctl_strategy(struct ctl_table_root
*root
,
1767 struct ctl_table
*table
,
1768 void __user
*oldval
, size_t __user
*oldlenp
,
1769 void __user
*newval
, size_t newlen
)
1777 if (sysctl_perm(root
, table
, op
))
1780 if (table
->strategy
) {
1781 rc
= table
->strategy(table
, oldval
, oldlenp
, newval
, newlen
);
1788 /* If there is no strategy routine, or if the strategy returns
1789 * zero, proceed with automatic r/w */
1790 if (table
->data
&& table
->maxlen
) {
1791 rc
= sysctl_data(table
, oldval
, oldlenp
, newval
, newlen
);
1798 static int parse_table(int __user
*name
, int nlen
,
1799 void __user
*oldval
, size_t __user
*oldlenp
,
1800 void __user
*newval
, size_t newlen
,
1801 struct ctl_table_root
*root
,
1802 struct ctl_table
*table
)
1808 if (get_user(n
, name
))
1810 for ( ; table
->ctl_name
|| table
->procname
; table
++) {
1811 if (!table
->ctl_name
)
1813 if (n
== table
->ctl_name
) {
1816 if (sysctl_perm(root
, table
, MAY_EXEC
))
1820 table
= table
->child
;
1823 error
= do_sysctl_strategy(root
, table
,
1832 int do_sysctl(int __user
*name
, int nlen
, void __user
*oldval
, size_t __user
*oldlenp
,
1833 void __user
*newval
, size_t newlen
)
1835 struct ctl_table_header
*head
;
1836 int error
= -ENOTDIR
;
1838 if (nlen
<= 0 || nlen
>= CTL_MAXNAME
)
1842 if (!oldlenp
|| get_user(old_len
, oldlenp
))
1846 for (head
= sysctl_head_next(NULL
); head
;
1847 head
= sysctl_head_next(head
)) {
1848 error
= parse_table(name
, nlen
, oldval
, oldlenp
,
1850 head
->root
, head
->ctl_table
);
1851 if (error
!= -ENOTDIR
) {
1852 sysctl_head_finish(head
);
1859 SYSCALL_DEFINE1(sysctl
, struct __sysctl_args __user
*, args
)
1861 struct __sysctl_args tmp
;
1864 if (copy_from_user(&tmp
, args
, sizeof(tmp
)))
1867 error
= deprecated_sysctl_warning(&tmp
);
1872 error
= do_sysctl(tmp
.name
, tmp
.nlen
, tmp
.oldval
, tmp
.oldlenp
,
1873 tmp
.newval
, tmp
.newlen
);
1878 #endif /* CONFIG_SYSCTL_SYSCALL */
1881 * sysctl_perm does NOT grant the superuser all rights automatically, because
1882 * some sysctl variables are readonly even to root.
1885 static int test_perm(int mode
, int op
)
1887 if (!current_euid())
1889 else if (in_egroup_p(0))
1891 if ((op
& ~mode
& (MAY_READ
|MAY_WRITE
|MAY_EXEC
)) == 0)
1896 int sysctl_perm(struct ctl_table_root
*root
, struct ctl_table
*table
, int op
)
1901 error
= security_sysctl(table
, op
& (MAY_READ
| MAY_WRITE
| MAY_EXEC
));
1905 if (root
->permissions
)
1906 mode
= root
->permissions(root
, current
->nsproxy
, table
);
1910 return test_perm(mode
, op
);
1913 static void sysctl_set_parent(struct ctl_table
*parent
, struct ctl_table
*table
)
1915 for (; table
->ctl_name
|| table
->procname
; table
++) {
1916 table
->parent
= parent
;
1918 sysctl_set_parent(table
, table
->child
);
1922 static __init
int sysctl_init(void)
1924 sysctl_set_parent(NULL
, root_table
);
1925 #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1928 err
= sysctl_check_table(current
->nsproxy
, root_table
);
1934 core_initcall(sysctl_init
);
1936 static struct ctl_table
*is_branch_in(struct ctl_table
*branch
,
1937 struct ctl_table
*table
)
1939 struct ctl_table
*p
;
1940 const char *s
= branch
->procname
;
1942 /* branch should have named subdirectory as its first element */
1943 if (!s
|| !branch
->child
)
1946 /* ... and nothing else */
1947 if (branch
[1].procname
|| branch
[1].ctl_name
)
1950 /* table should contain subdirectory with the same name */
1951 for (p
= table
; p
->procname
|| p
->ctl_name
; p
++) {
1954 if (p
->procname
&& strcmp(p
->procname
, s
) == 0)
1960 /* see if attaching q to p would be an improvement */
1961 static void try_attach(struct ctl_table_header
*p
, struct ctl_table_header
*q
)
1963 struct ctl_table
*to
= p
->ctl_table
, *by
= q
->ctl_table
;
1964 struct ctl_table
*next
;
1966 int not_in_parent
= !p
->attached_by
;
1968 while ((next
= is_branch_in(by
, to
)) != NULL
) {
1969 if (by
== q
->attached_by
)
1971 if (to
== p
->attached_by
)
1977 if (is_better
&& not_in_parent
) {
1978 q
->attached_by
= by
;
1979 q
->attached_to
= to
;
1985 * __register_sysctl_paths - register a sysctl hierarchy
1986 * @root: List of sysctl headers to register on
1987 * @namespaces: Data to compute which lists of sysctl entries are visible
1988 * @path: The path to the directory the sysctl table is in.
1989 * @table: the top-level table structure
1991 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1992 * array. A completely 0 filled entry terminates the table.
1994 * The members of the &struct ctl_table structure are used as follows:
1996 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1997 * must be unique within that level of sysctl
1999 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
2000 * enter a sysctl file
2002 * data - a pointer to data for use by proc_handler
2004 * maxlen - the maximum size in bytes of the data
2006 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
2008 * child - a pointer to the child sysctl table if this entry is a directory, or
2011 * proc_handler - the text handler routine (described below)
2013 * strategy - the strategy routine (described below)
2015 * de - for internal use by the sysctl routines
2017 * extra1, extra2 - extra pointers usable by the proc handler routines
2019 * Leaf nodes in the sysctl tree will be represented by a single file
2020 * under /proc; non-leaf nodes will be represented by directories.
2022 * sysctl(2) can automatically manage read and write requests through
2023 * the sysctl table. The data and maxlen fields of the ctl_table
2024 * struct enable minimal validation of the values being written to be
2025 * performed, and the mode field allows minimal authentication.
2027 * More sophisticated management can be enabled by the provision of a
2028 * strategy routine with the table entry. This will be called before
2029 * any automatic read or write of the data is performed.
2031 * The strategy routine may return
2033 * < 0 - Error occurred (error is passed to user process)
2035 * 0 - OK - proceed with automatic read or write.
2037 * > 0 - OK - read or write has been done by the strategy routine, so
2038 * return immediately.
2040 * There must be a proc_handler routine for any terminal nodes
2041 * mirrored under /proc/sys (non-terminals are handled by a built-in
2042 * directory handler). Several default handlers are available to
2043 * cover common cases -
2045 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
2046 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
2047 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
2049 * It is the handler's job to read the input buffer from user memory
2050 * and process it. The handler should return 0 on success.
2052 * This routine returns %NULL on a failure to register, and a pointer
2053 * to the table header on success.
2055 struct ctl_table_header
*__register_sysctl_paths(
2056 struct ctl_table_root
*root
,
2057 struct nsproxy
*namespaces
,
2058 const struct ctl_path
*path
, struct ctl_table
*table
)
2060 struct ctl_table_header
*header
;
2061 struct ctl_table
*new, **prevp
;
2062 unsigned int n
, npath
;
2063 struct ctl_table_set
*set
;
2065 /* Count the path components */
2066 for (npath
= 0; path
[npath
].ctl_name
|| path
[npath
].procname
; ++npath
)
2070 * For each path component, allocate a 2-element ctl_table array.
2071 * The first array element will be filled with the sysctl entry
2072 * for this, the second will be the sentinel (ctl_name == 0).
2074 * We allocate everything in one go so that we don't have to
2075 * worry about freeing additional memory in unregister_sysctl_table.
2077 header
= kzalloc(sizeof(struct ctl_table_header
) +
2078 (2 * npath
* sizeof(struct ctl_table
)), GFP_KERNEL
);
2082 new = (struct ctl_table
*) (header
+ 1);
2084 /* Now connect the dots */
2085 prevp
= &header
->ctl_table
;
2086 for (n
= 0; n
< npath
; ++n
, ++path
) {
2087 /* Copy the procname */
2088 new->procname
= path
->procname
;
2089 new->ctl_name
= path
->ctl_name
;
2093 prevp
= &new->child
;
2098 header
->ctl_table_arg
= table
;
2100 INIT_LIST_HEAD(&header
->ctl_entry
);
2102 header
->unregistering
= NULL
;
2103 header
->root
= root
;
2104 sysctl_set_parent(NULL
, header
->ctl_table
);
2106 #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
2107 if (sysctl_check_table(namespaces
, header
->ctl_table
)) {
2112 spin_lock(&sysctl_lock
);
2113 header
->set
= lookup_header_set(root
, namespaces
);
2114 header
->attached_by
= header
->ctl_table
;
2115 header
->attached_to
= root_table
;
2116 header
->parent
= &root_table_header
;
2117 for (set
= header
->set
; set
; set
= set
->parent
) {
2118 struct ctl_table_header
*p
;
2119 list_for_each_entry(p
, &set
->list
, ctl_entry
) {
2120 if (p
->unregistering
)
2122 try_attach(p
, header
);
2125 header
->parent
->count
++;
2126 list_add_tail(&header
->ctl_entry
, &header
->set
->list
);
2127 spin_unlock(&sysctl_lock
);
2133 * register_sysctl_table_path - register a sysctl table hierarchy
2134 * @path: The path to the directory the sysctl table is in.
2135 * @table: the top-level table structure
2137 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2138 * array. A completely 0 filled entry terminates the table.
2140 * See __register_sysctl_paths for more details.
2142 struct ctl_table_header
*register_sysctl_paths(const struct ctl_path
*path
,
2143 struct ctl_table
*table
)
2145 return __register_sysctl_paths(&sysctl_table_root
, current
->nsproxy
,
2150 * register_sysctl_table - register a sysctl table hierarchy
2151 * @table: the top-level table structure
2153 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2154 * array. A completely 0 filled entry terminates the table.
2156 * See register_sysctl_paths for more details.
2158 struct ctl_table_header
*register_sysctl_table(struct ctl_table
*table
)
2160 static const struct ctl_path null_path
[] = { {} };
2162 return register_sysctl_paths(null_path
, table
);
2166 * unregister_sysctl_table - unregister a sysctl table hierarchy
2167 * @header: the header returned from register_sysctl_table
2169 * Unregisters the sysctl table and all children. proc entries may not
2170 * actually be removed until they are no longer used by anyone.
2172 void unregister_sysctl_table(struct ctl_table_header
* header
)
2179 spin_lock(&sysctl_lock
);
2180 start_unregistering(header
);
2181 if (!--header
->parent
->count
) {
2183 kfree(header
->parent
);
2185 if (!--header
->count
)
2187 spin_unlock(&sysctl_lock
);
2190 int sysctl_is_seen(struct ctl_table_header
*p
)
2192 struct ctl_table_set
*set
= p
->set
;
2194 spin_lock(&sysctl_lock
);
2195 if (p
->unregistering
)
2197 else if (!set
->is_seen
)
2200 res
= set
->is_seen(set
);
2201 spin_unlock(&sysctl_lock
);
2205 void setup_sysctl_set(struct ctl_table_set
*p
,
2206 struct ctl_table_set
*parent
,
2207 int (*is_seen
)(struct ctl_table_set
*))
2209 INIT_LIST_HEAD(&p
->list
);
2210 p
->parent
= parent
? parent
: &sysctl_table_root
.default_set
;
2211 p
->is_seen
= is_seen
;
2214 #else /* !CONFIG_SYSCTL */
2215 struct ctl_table_header
*register_sysctl_table(struct ctl_table
* table
)
2220 struct ctl_table_header
*register_sysctl_paths(const struct ctl_path
*path
,
2221 struct ctl_table
*table
)
2226 void unregister_sysctl_table(struct ctl_table_header
* table
)
2230 void setup_sysctl_set(struct ctl_table_set
*p
,
2231 struct ctl_table_set
*parent
,
2232 int (*is_seen
)(struct ctl_table_set
*))
2236 void sysctl_head_put(struct ctl_table_header
*head
)
2240 #endif /* CONFIG_SYSCTL */
2246 #ifdef CONFIG_PROC_SYSCTL
2248 static int _proc_do_string(void* data
, int maxlen
, int write
,
2249 void __user
*buffer
,
2250 size_t *lenp
, loff_t
*ppos
)
2256 if (!data
|| !maxlen
|| !*lenp
) {
2264 while (len
< *lenp
) {
2265 if (get_user(c
, p
++))
2267 if (c
== 0 || c
== '\n')
2273 if(copy_from_user(data
, buffer
, len
))
2275 ((char *) data
)[len
] = 0;
2293 if(copy_to_user(buffer
, data
, len
))
2296 if(put_user('\n', ((char __user
*) buffer
) + len
))
2307 * proc_dostring - read a string sysctl
2308 * @table: the sysctl table
2309 * @write: %TRUE if this is a write to the sysctl file
2310 * @buffer: the user buffer
2311 * @lenp: the size of the user buffer
2312 * @ppos: file position
2314 * Reads/writes a string from/to the user buffer. If the kernel
2315 * buffer provided is not large enough to hold the string, the
2316 * string is truncated. The copied string is %NULL-terminated.
2317 * If the string is being read by the user process, it is copied
2318 * and a newline '\n' is added. It is truncated if the buffer is
2321 * Returns 0 on success.
2323 int proc_dostring(struct ctl_table
*table
, int write
,
2324 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2326 return _proc_do_string(table
->data
, table
->maxlen
, write
,
2327 buffer
, lenp
, ppos
);
2331 static int do_proc_dointvec_conv(int *negp
, unsigned long *lvalp
,
2333 int write
, void *data
)
2336 *valp
= *negp
? -*lvalp
: *lvalp
;
2341 *lvalp
= (unsigned long)-val
;
2344 *lvalp
= (unsigned long)val
;
2350 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2351 int write
, void __user
*buffer
,
2352 size_t *lenp
, loff_t
*ppos
,
2353 int (*conv
)(int *negp
, unsigned long *lvalp
, int *valp
,
2354 int write
, void *data
),
2357 #define TMPBUFLEN 21
2358 int *i
, vleft
, first
= 1, neg
;
2362 char buf
[TMPBUFLEN
], *p
;
2363 char __user
*s
= buffer
;
2365 if (!tbl_data
|| !table
->maxlen
|| !*lenp
||
2366 (*ppos
&& !write
)) {
2371 i
= (int *) tbl_data
;
2372 vleft
= table
->maxlen
/ sizeof(*i
);
2376 conv
= do_proc_dointvec_conv
;
2378 for (; left
&& vleft
--; i
++, first
=0) {
2393 if (len
> sizeof(buf
) - 1)
2394 len
= sizeof(buf
) - 1;
2395 if (copy_from_user(buf
, s
, len
))
2399 if (*p
== '-' && left
> 1) {
2403 if (*p
< '0' || *p
> '9')
2406 lval
= simple_strtoul(p
, &p
, 0);
2409 if ((len
< left
) && *p
&& !isspace(*p
))
2414 if (conv(&neg
, &lval
, i
, 1, data
))
2421 if (conv(&neg
, &lval
, i
, 0, data
))
2424 sprintf(p
, "%s%lu", neg
? "-" : "", lval
);
2428 if(copy_to_user(s
, buf
, len
))
2435 if (!write
&& !first
&& left
) {
2436 if(put_user('\n', s
))
2443 if (get_user(c
, s
++))
2458 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2459 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2460 int (*conv
)(int *negp
, unsigned long *lvalp
, int *valp
,
2461 int write
, void *data
),
2464 return __do_proc_dointvec(table
->data
, table
, write
,
2465 buffer
, lenp
, ppos
, conv
, data
);
2469 * proc_dointvec - read a vector of integers
2470 * @table: the sysctl table
2471 * @write: %TRUE if this is a write to the sysctl file
2472 * @buffer: the user buffer
2473 * @lenp: the size of the user buffer
2474 * @ppos: file position
2476 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2477 * values from/to the user buffer, treated as an ASCII string.
2479 * Returns 0 on success.
2481 int proc_dointvec(struct ctl_table
*table
, int write
,
2482 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2484 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2489 * Taint values can only be increased
2490 * This means we can safely use a temporary.
2492 static int proc_taint(struct ctl_table
*table
, int write
,
2493 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2496 unsigned long tmptaint
= get_taint();
2499 if (write
&& !capable(CAP_SYS_ADMIN
))
2504 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2510 * Poor man's atomic or. Not worth adding a primitive
2511 * to everyone's atomic.h for this
2514 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2515 if ((tmptaint
>> i
) & 1)
2523 struct do_proc_dointvec_minmax_conv_param
{
2528 static int do_proc_dointvec_minmax_conv(int *negp
, unsigned long *lvalp
,
2530 int write
, void *data
)
2532 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2534 int val
= *negp
? -*lvalp
: *lvalp
;
2535 if ((param
->min
&& *param
->min
> val
) ||
2536 (param
->max
&& *param
->max
< val
))
2543 *lvalp
= (unsigned long)-val
;
2546 *lvalp
= (unsigned long)val
;
2553 * proc_dointvec_minmax - read a vector of integers with min/max values
2554 * @table: the sysctl table
2555 * @write: %TRUE if this is a write to the sysctl file
2556 * @buffer: the user buffer
2557 * @lenp: the size of the user buffer
2558 * @ppos: file position
2560 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2561 * values from/to the user buffer, treated as an ASCII string.
2563 * This routine will ensure the values are within the range specified by
2564 * table->extra1 (min) and table->extra2 (max).
2566 * Returns 0 on success.
2568 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2569 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2571 struct do_proc_dointvec_minmax_conv_param param
= {
2572 .min
= (int *) table
->extra1
,
2573 .max
= (int *) table
->extra2
,
2575 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2576 do_proc_dointvec_minmax_conv
, ¶m
);
2579 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2580 void __user
*buffer
,
2581 size_t *lenp
, loff_t
*ppos
,
2582 unsigned long convmul
,
2583 unsigned long convdiv
)
2585 #define TMPBUFLEN 21
2586 unsigned long *i
, *min
, *max
, val
;
2587 int vleft
, first
=1, neg
;
2589 char buf
[TMPBUFLEN
], *p
;
2590 char __user
*s
= buffer
;
2592 if (!data
|| !table
->maxlen
|| !*lenp
||
2593 (*ppos
&& !write
)) {
2598 i
= (unsigned long *) data
;
2599 min
= (unsigned long *) table
->extra1
;
2600 max
= (unsigned long *) table
->extra2
;
2601 vleft
= table
->maxlen
/ sizeof(unsigned long);
2604 for (; left
&& vleft
--; i
++, min
++, max
++, first
=0) {
2619 if (len
> TMPBUFLEN
-1)
2621 if (copy_from_user(buf
, s
, len
))
2625 if (*p
== '-' && left
> 1) {
2629 if (*p
< '0' || *p
> '9')
2631 val
= simple_strtoul(p
, &p
, 0) * convmul
/ convdiv
;
2633 if ((len
< left
) && *p
&& !isspace(*p
))
2642 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2649 sprintf(p
, "%lu", convdiv
* (*i
) / convmul
);
2653 if(copy_to_user(s
, buf
, len
))
2660 if (!write
&& !first
&& left
) {
2661 if(put_user('\n', s
))
2668 if (get_user(c
, s
++))
2683 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2684 void __user
*buffer
,
2685 size_t *lenp
, loff_t
*ppos
,
2686 unsigned long convmul
,
2687 unsigned long convdiv
)
2689 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2690 buffer
, lenp
, ppos
, convmul
, convdiv
);
2694 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2695 * @table: the sysctl table
2696 * @write: %TRUE if this is a write to the sysctl file
2697 * @buffer: the user buffer
2698 * @lenp: the size of the user buffer
2699 * @ppos: file position
2701 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2702 * values from/to the user buffer, treated as an ASCII string.
2704 * This routine will ensure the values are within the range specified by
2705 * table->extra1 (min) and table->extra2 (max).
2707 * Returns 0 on success.
2709 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2710 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2712 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2716 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2717 * @table: the sysctl table
2718 * @write: %TRUE if this is a write to the sysctl file
2719 * @buffer: the user buffer
2720 * @lenp: the size of the user buffer
2721 * @ppos: file position
2723 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2724 * values from/to the user buffer, treated as an ASCII string. The values
2725 * are treated as milliseconds, and converted to jiffies when they are stored.
2727 * This routine will ensure the values are within the range specified by
2728 * table->extra1 (min) and table->extra2 (max).
2730 * Returns 0 on success.
2732 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2733 void __user
*buffer
,
2734 size_t *lenp
, loff_t
*ppos
)
2736 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2737 lenp
, ppos
, HZ
, 1000l);
2741 static int do_proc_dointvec_jiffies_conv(int *negp
, unsigned long *lvalp
,
2743 int write
, void *data
)
2746 if (*lvalp
> LONG_MAX
/ HZ
)
2748 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2754 lval
= (unsigned long)-val
;
2757 lval
= (unsigned long)val
;
2764 static int do_proc_dointvec_userhz_jiffies_conv(int *negp
, unsigned long *lvalp
,
2766 int write
, void *data
)
2769 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2771 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2777 lval
= (unsigned long)-val
;
2780 lval
= (unsigned long)val
;
2782 *lvalp
= jiffies_to_clock_t(lval
);
2787 static int do_proc_dointvec_ms_jiffies_conv(int *negp
, unsigned long *lvalp
,
2789 int write
, void *data
)
2792 *valp
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2798 lval
= (unsigned long)-val
;
2801 lval
= (unsigned long)val
;
2803 *lvalp
= jiffies_to_msecs(lval
);
2809 * proc_dointvec_jiffies - read a vector of integers as seconds
2810 * @table: the sysctl table
2811 * @write: %TRUE if this is a write to the sysctl file
2812 * @buffer: the user buffer
2813 * @lenp: the size of the user buffer
2814 * @ppos: file position
2816 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2817 * values from/to the user buffer, treated as an ASCII string.
2818 * The values read are assumed to be in seconds, and are converted into
2821 * Returns 0 on success.
2823 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2824 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2826 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2827 do_proc_dointvec_jiffies_conv
,NULL
);
2831 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2832 * @table: the sysctl table
2833 * @write: %TRUE if this is a write to the sysctl file
2834 * @buffer: the user buffer
2835 * @lenp: the size of the user buffer
2836 * @ppos: pointer to the file position
2838 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2839 * values from/to the user buffer, treated as an ASCII string.
2840 * The values read are assumed to be in 1/USER_HZ seconds, and
2841 * are converted into jiffies.
2843 * Returns 0 on success.
2845 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2846 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2848 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2849 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2853 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2854 * @table: the sysctl table
2855 * @write: %TRUE if this is a write to the sysctl file
2856 * @buffer: the user buffer
2857 * @lenp: the size of the user buffer
2858 * @ppos: file position
2859 * @ppos: the current position in the file
2861 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2862 * values from/to the user buffer, treated as an ASCII string.
2863 * The values read are assumed to be in 1/1000 seconds, and
2864 * are converted into jiffies.
2866 * Returns 0 on success.
2868 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2869 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2871 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2872 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2875 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
2876 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2878 struct pid
*new_pid
;
2882 tmp
= pid_vnr(cad_pid
);
2884 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
2885 lenp
, ppos
, NULL
, NULL
);
2889 new_pid
= find_get_pid(tmp
);
2893 put_pid(xchg(&cad_pid
, new_pid
));
2897 #else /* CONFIG_PROC_FS */
2899 int proc_dostring(struct ctl_table
*table
, int write
,
2900 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2905 int proc_dointvec(struct ctl_table
*table
, int write
,
2906 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2911 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2912 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2917 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2918 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2923 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2924 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2929 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2930 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2935 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2936 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2941 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2942 void __user
*buffer
,
2943 size_t *lenp
, loff_t
*ppos
)
2949 #endif /* CONFIG_PROC_FS */
2952 #ifdef CONFIG_SYSCTL_SYSCALL
2954 * General sysctl support routines
2957 /* The generic sysctl data routine (used if no strategy routine supplied) */
2958 int sysctl_data(struct ctl_table
*table
,
2959 void __user
*oldval
, size_t __user
*oldlenp
,
2960 void __user
*newval
, size_t newlen
)
2964 /* Get out of I don't have a variable */
2965 if (!table
->data
|| !table
->maxlen
)
2968 if (oldval
&& oldlenp
) {
2969 if (get_user(len
, oldlenp
))
2972 if (len
> table
->maxlen
)
2973 len
= table
->maxlen
;
2974 if (copy_to_user(oldval
, table
->data
, len
))
2976 if (put_user(len
, oldlenp
))
2981 if (newval
&& newlen
) {
2982 if (newlen
> table
->maxlen
)
2983 newlen
= table
->maxlen
;
2985 if (copy_from_user(table
->data
, newval
, newlen
))
2991 /* The generic string strategy routine: */
2992 int sysctl_string(struct ctl_table
*table
,
2993 void __user
*oldval
, size_t __user
*oldlenp
,
2994 void __user
*newval
, size_t newlen
)
2996 if (!table
->data
|| !table
->maxlen
)
2999 if (oldval
&& oldlenp
) {
3001 if (get_user(bufsize
, oldlenp
))
3004 size_t len
= strlen(table
->data
), copied
;
3006 /* This shouldn't trigger for a well-formed sysctl */
3007 if (len
> table
->maxlen
)
3008 len
= table
->maxlen
;
3010 /* Copy up to a max of bufsize-1 bytes of the string */
3011 copied
= (len
>= bufsize
) ? bufsize
- 1 : len
;
3013 if (copy_to_user(oldval
, table
->data
, copied
) ||
3014 put_user(0, (char __user
*)(oldval
+ copied
)))
3016 if (put_user(len
, oldlenp
))
3020 if (newval
&& newlen
) {
3021 size_t len
= newlen
;
3022 if (len
> table
->maxlen
)
3023 len
= table
->maxlen
;
3024 if(copy_from_user(table
->data
, newval
, len
))
3026 if (len
== table
->maxlen
)
3028 ((char *) table
->data
)[len
] = 0;
3034 * This function makes sure that all of the integers in the vector
3035 * are between the minimum and maximum values given in the arrays
3036 * table->extra1 and table->extra2, respectively.
3038 int sysctl_intvec(struct ctl_table
*table
,
3039 void __user
*oldval
, size_t __user
*oldlenp
,
3040 void __user
*newval
, size_t newlen
)
3043 if (newval
&& newlen
) {
3044 int __user
*vec
= (int __user
*) newval
;
3045 int *min
= (int *) table
->extra1
;
3046 int *max
= (int *) table
->extra2
;
3050 if (newlen
% sizeof(int) != 0)
3053 if (!table
->extra1
&& !table
->extra2
)
3056 if (newlen
> table
->maxlen
)
3057 newlen
= table
->maxlen
;
3058 length
= newlen
/ sizeof(int);
3060 for (i
= 0; i
< length
; i
++) {
3062 if (get_user(value
, vec
+ i
))
3064 if (min
&& value
< min
[i
])
3066 if (max
&& value
> max
[i
])
3073 /* Strategy function to convert jiffies to seconds */
3074 int sysctl_jiffies(struct ctl_table
*table
,
3075 void __user
*oldval
, size_t __user
*oldlenp
,
3076 void __user
*newval
, size_t newlen
)
3078 if (oldval
&& oldlenp
) {
3081 if (get_user(olen
, oldlenp
))
3086 if (olen
< sizeof(int))
3089 val
= *(int *)(table
->data
) / HZ
;
3090 if (put_user(val
, (int __user
*)oldval
))
3092 if (put_user(sizeof(int), oldlenp
))
3096 if (newval
&& newlen
) {
3098 if (newlen
!= sizeof(int))
3100 if (get_user(new, (int __user
*)newval
))
3102 *(int *)(table
->data
) = new*HZ
;
3107 /* Strategy function to convert jiffies to seconds */
3108 int sysctl_ms_jiffies(struct ctl_table
*table
,
3109 void __user
*oldval
, size_t __user
*oldlenp
,
3110 void __user
*newval
, size_t newlen
)
3112 if (oldval
&& oldlenp
) {
3115 if (get_user(olen
, oldlenp
))
3120 if (olen
< sizeof(int))
3123 val
= jiffies_to_msecs(*(int *)(table
->data
));
3124 if (put_user(val
, (int __user
*)oldval
))
3126 if (put_user(sizeof(int), oldlenp
))
3130 if (newval
&& newlen
) {
3132 if (newlen
!= sizeof(int))
3134 if (get_user(new, (int __user
*)newval
))
3136 *(int *)(table
->data
) = msecs_to_jiffies(new);
3143 #else /* CONFIG_SYSCTL_SYSCALL */
3146 SYSCALL_DEFINE1(sysctl
, struct __sysctl_args __user
*, args
)
3148 struct __sysctl_args tmp
;
3151 if (copy_from_user(&tmp
, args
, sizeof(tmp
)))
3154 error
= deprecated_sysctl_warning(&tmp
);
3156 /* If no error reading the parameters then just -ENOSYS ... */
3163 int sysctl_data(struct ctl_table
*table
,
3164 void __user
*oldval
, size_t __user
*oldlenp
,
3165 void __user
*newval
, size_t newlen
)
3170 int sysctl_string(struct ctl_table
*table
,
3171 void __user
*oldval
, size_t __user
*oldlenp
,
3172 void __user
*newval
, size_t newlen
)
3177 int sysctl_intvec(struct ctl_table
*table
,
3178 void __user
*oldval
, size_t __user
*oldlenp
,
3179 void __user
*newval
, size_t newlen
)
3184 int sysctl_jiffies(struct ctl_table
*table
,
3185 void __user
*oldval
, size_t __user
*oldlenp
,
3186 void __user
*newval
, size_t newlen
)
3191 int sysctl_ms_jiffies(struct ctl_table
*table
,
3192 void __user
*oldval
, size_t __user
*oldlenp
,
3193 void __user
*newval
, size_t newlen
)
3198 #endif /* CONFIG_SYSCTL_SYSCALL */
3200 static int deprecated_sysctl_warning(struct __sysctl_args
*args
)
3202 static int msg_count
;
3203 int name
[CTL_MAXNAME
];
3206 /* Check args->nlen. */
3207 if (args
->nlen
< 0 || args
->nlen
> CTL_MAXNAME
)
3210 /* Read in the sysctl name for better debug message logging */
3211 for (i
= 0; i
< args
->nlen
; i
++)
3212 if (get_user(name
[i
], args
->name
+ i
))
3215 /* Ignore accesses to kernel.version */
3216 if ((args
->nlen
== 2) && (name
[0] == CTL_KERN
) && (name
[1] == KERN_VERSION
))
3219 if (msg_count
< 5) {
3222 "warning: process `%s' used the deprecated sysctl "
3223 "system call with ", current
->comm
);
3224 for (i
= 0; i
< args
->nlen
; i
++)
3225 printk("%d.", name
[i
]);
3232 * No sense putting this after each symbol definition, twice,
3233 * exception granted :-)
3235 EXPORT_SYMBOL(proc_dointvec
);
3236 EXPORT_SYMBOL(proc_dointvec_jiffies
);
3237 EXPORT_SYMBOL(proc_dointvec_minmax
);
3238 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
3239 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
3240 EXPORT_SYMBOL(proc_dostring
);
3241 EXPORT_SYMBOL(proc_doulongvec_minmax
);
3242 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);
3243 EXPORT_SYMBOL(register_sysctl_table
);
3244 EXPORT_SYMBOL(register_sysctl_paths
);
3245 EXPORT_SYMBOL(sysctl_intvec
);
3246 EXPORT_SYMBOL(sysctl_jiffies
);
3247 EXPORT_SYMBOL(sysctl_ms_jiffies
);
3248 EXPORT_SYMBOL(sysctl_string
);
3249 EXPORT_SYMBOL(sysctl_data
);
3250 EXPORT_SYMBOL(unregister_sysctl_table
);