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>
22 #include <linux/aio.h>
24 #include <linux/swap.h>
25 #include <linux/slab.h>
26 #include <linux/sysctl.h>
27 #include <linux/bitmap.h>
28 #include <linux/signal.h>
29 #include <linux/printk.h>
30 #include <linux/proc_fs.h>
31 #include <linux/security.h>
32 #include <linux/ctype.h>
33 #include <linux/kmemcheck.h>
34 #include <linux/kmemleak.h>
36 #include <linux/init.h>
37 #include <linux/kernel.h>
38 #include <linux/kobject.h>
39 #include <linux/net.h>
40 #include <linux/sysrq.h>
41 #include <linux/highuid.h>
42 #include <linux/writeback.h>
43 #include <linux/ratelimit.h>
44 #include <linux/compaction.h>
45 #include <linux/hugetlb.h>
46 #include <linux/initrd.h>
47 #include <linux/key.h>
48 #include <linux/times.h>
49 #include <linux/limits.h>
50 #include <linux/dcache.h>
51 #include <linux/dnotify.h>
52 #include <linux/syscalls.h>
53 #include <linux/vmstat.h>
54 #include <linux/nfs_fs.h>
55 #include <linux/acpi.h>
56 #include <linux/reboot.h>
57 #include <linux/ftrace.h>
58 #include <linux/perf_event.h>
59 #include <linux/kprobes.h>
60 #include <linux/pipe_fs_i.h>
61 #include <linux/oom.h>
62 #include <linux/kmod.h>
63 #include <linux/capability.h>
64 #include <linux/binfmts.h>
65 #include <linux/sched/sysctl.h>
66 #include <linux/kexec.h>
67 #include <linux/bpf.h>
68 #include <linux/mount.h>
70 #include <asm/uaccess.h>
71 #include <asm/processor.h>
75 #include <asm/stacktrace.h>
79 #include <asm/setup.h>
81 #ifdef CONFIG_BSD_PROCESS_ACCT
82 #include <linux/acct.h>
84 #ifdef CONFIG_RT_MUTEXES
85 #include <linux/rtmutex.h>
87 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
88 #include <linux/lockdep.h>
90 #ifdef CONFIG_CHR_DEV_SG
94 #ifdef CONFIG_LOCKUP_DETECTOR
95 #include <linux/nmi.h>
98 #if defined(CONFIG_SYSCTL)
100 /* External variables not in a header file. */
101 extern int suid_dumpable
;
102 #ifdef CONFIG_COREDUMP
103 extern int core_uses_pid
;
104 extern char core_pattern
[];
105 extern unsigned int core_pipe_limit
;
108 extern int pid_max_min
, pid_max_max
;
109 extern int percpu_pagelist_fraction
;
110 extern int latencytop_enabled
;
111 extern unsigned int sysctl_nr_open_min
, sysctl_nr_open_max
;
113 extern int sysctl_nr_trim_pages
;
116 /* Constants used for minimum and maximum */
117 #ifdef CONFIG_LOCKUP_DETECTOR
118 static int sixty
= 60;
121 static int __maybe_unused neg_one
= -1;
124 static int __maybe_unused one
= 1;
125 static int __maybe_unused two
= 2;
126 static int __maybe_unused four
= 4;
127 static unsigned long zero_ul
;
128 static unsigned long one_ul
= 1;
129 static unsigned long long_max
= LONG_MAX
;
130 static int one_hundred
= 100;
131 static int one_thousand
= 1000;
133 static int ten_thousand
= 10000;
135 #ifdef CONFIG_PERF_EVENTS
136 static int six_hundred_forty_kb
= 640 * 1024;
139 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
140 static unsigned long dirty_bytes_min
= 2 * PAGE_SIZE
;
142 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
143 static int maxolduid
= 65535;
144 static int minolduid
;
146 static int ngroups_max
= NGROUPS_MAX
;
147 static const int cap_last_cap
= CAP_LAST_CAP
;
149 /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
150 #ifdef CONFIG_DETECT_HUNG_TASK
151 static unsigned long hung_task_timeout_max
= (LONG_MAX
/HZ
);
154 #ifdef CONFIG_INOTIFY_USER
155 #include <linux/inotify.h>
161 extern int pwrsw_enabled
;
164 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
165 extern int unaligned_enabled
;
169 extern int unaligned_dump_stack
;
172 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
173 extern int no_unaligned_warning
;
176 #ifdef CONFIG_PROC_SYSCTL
178 #define SYSCTL_WRITES_LEGACY -1
179 #define SYSCTL_WRITES_WARN 0
180 #define SYSCTL_WRITES_STRICT 1
182 static int sysctl_writes_strict
= SYSCTL_WRITES_STRICT
;
184 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
185 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
186 static int proc_taint(struct ctl_table
*table
, int write
,
187 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
191 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
192 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
195 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
196 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
197 #ifdef CONFIG_COREDUMP
198 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
199 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
202 #ifdef CONFIG_MAGIC_SYSRQ
203 /* Note: sysrq code uses it's own private copy */
204 static int __sysrq_enabled
= CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE
;
206 static int sysrq_sysctl_handler(struct ctl_table
*table
, int write
,
207 void __user
*buffer
, size_t *lenp
,
212 error
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
217 sysrq_toggle_support(__sysrq_enabled
);
224 static struct ctl_table kern_table
[];
225 static struct ctl_table vm_table
[];
226 static struct ctl_table fs_table
[];
227 static struct ctl_table debug_table
[];
228 static struct ctl_table dev_table
[];
229 extern struct ctl_table random_table
[];
231 extern struct ctl_table epoll_table
[];
234 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
235 int sysctl_legacy_va_layout
;
238 /* The default sysctl tables: */
240 static struct ctl_table sysctl_base_table
[] = {
242 .procname
= "kernel",
259 .child
= debug_table
,
269 #ifdef CONFIG_SCHED_DEBUG
270 static int min_sched_granularity_ns
= 100000; /* 100 usecs */
271 static int max_sched_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
272 static int min_wakeup_granularity_ns
; /* 0 usecs */
273 static int max_wakeup_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
275 static int min_sched_tunable_scaling
= SCHED_TUNABLESCALING_NONE
;
276 static int max_sched_tunable_scaling
= SCHED_TUNABLESCALING_END
-1;
277 #endif /* CONFIG_SMP */
278 #endif /* CONFIG_SCHED_DEBUG */
280 #ifdef CONFIG_COMPACTION
281 static int min_extfrag_threshold
;
282 static int max_extfrag_threshold
= 1000;
285 static struct ctl_table kern_table
[] = {
287 .procname
= "sched_child_runs_first",
288 .data
= &sysctl_sched_child_runs_first
,
289 .maxlen
= sizeof(unsigned int),
291 .proc_handler
= proc_dointvec
,
293 #ifdef CONFIG_SCHED_DEBUG
295 .procname
= "sched_min_granularity_ns",
296 .data
= &sysctl_sched_min_granularity
,
297 .maxlen
= sizeof(unsigned int),
299 .proc_handler
= sched_proc_update_handler
,
300 .extra1
= &min_sched_granularity_ns
,
301 .extra2
= &max_sched_granularity_ns
,
304 .procname
= "sched_latency_ns",
305 .data
= &sysctl_sched_latency
,
306 .maxlen
= sizeof(unsigned int),
308 .proc_handler
= sched_proc_update_handler
,
309 .extra1
= &min_sched_granularity_ns
,
310 .extra2
= &max_sched_granularity_ns
,
313 .procname
= "sched_wakeup_granularity_ns",
314 .data
= &sysctl_sched_wakeup_granularity
,
315 .maxlen
= sizeof(unsigned int),
317 .proc_handler
= sched_proc_update_handler
,
318 .extra1
= &min_wakeup_granularity_ns
,
319 .extra2
= &max_wakeup_granularity_ns
,
323 .procname
= "sched_tunable_scaling",
324 .data
= &sysctl_sched_tunable_scaling
,
325 .maxlen
= sizeof(enum sched_tunable_scaling
),
327 .proc_handler
= sched_proc_update_handler
,
328 .extra1
= &min_sched_tunable_scaling
,
329 .extra2
= &max_sched_tunable_scaling
,
332 .procname
= "sched_migration_cost_ns",
333 .data
= &sysctl_sched_migration_cost
,
334 .maxlen
= sizeof(unsigned int),
336 .proc_handler
= proc_dointvec
,
339 .procname
= "sched_nr_migrate",
340 .data
= &sysctl_sched_nr_migrate
,
341 .maxlen
= sizeof(unsigned int),
343 .proc_handler
= proc_dointvec
,
346 .procname
= "sched_time_avg_ms",
347 .data
= &sysctl_sched_time_avg
,
348 .maxlen
= sizeof(unsigned int),
350 .proc_handler
= proc_dointvec_minmax
,
354 .procname
= "sched_shares_window_ns",
355 .data
= &sysctl_sched_shares_window
,
356 .maxlen
= sizeof(unsigned int),
358 .proc_handler
= proc_dointvec
,
360 #ifdef CONFIG_SCHEDSTATS
362 .procname
= "sched_schedstats",
364 .maxlen
= sizeof(unsigned int),
366 .proc_handler
= sysctl_schedstats
,
370 #endif /* CONFIG_SCHEDSTATS */
371 #endif /* CONFIG_SMP */
372 #ifdef CONFIG_NUMA_BALANCING
374 .procname
= "numa_balancing_scan_delay_ms",
375 .data
= &sysctl_numa_balancing_scan_delay
,
376 .maxlen
= sizeof(unsigned int),
378 .proc_handler
= proc_dointvec
,
381 .procname
= "numa_balancing_scan_period_min_ms",
382 .data
= &sysctl_numa_balancing_scan_period_min
,
383 .maxlen
= sizeof(unsigned int),
385 .proc_handler
= proc_dointvec
,
388 .procname
= "numa_balancing_scan_period_max_ms",
389 .data
= &sysctl_numa_balancing_scan_period_max
,
390 .maxlen
= sizeof(unsigned int),
392 .proc_handler
= proc_dointvec
,
395 .procname
= "numa_balancing_scan_size_mb",
396 .data
= &sysctl_numa_balancing_scan_size
,
397 .maxlen
= sizeof(unsigned int),
399 .proc_handler
= proc_dointvec_minmax
,
403 .procname
= "numa_balancing",
404 .data
= NULL
, /* filled in by handler */
405 .maxlen
= sizeof(unsigned int),
407 .proc_handler
= sysctl_numa_balancing
,
411 #endif /* CONFIG_NUMA_BALANCING */
412 #endif /* CONFIG_SCHED_DEBUG */
414 .procname
= "sched_rt_period_us",
415 .data
= &sysctl_sched_rt_period
,
416 .maxlen
= sizeof(unsigned int),
418 .proc_handler
= sched_rt_handler
,
421 .procname
= "sched_rt_runtime_us",
422 .data
= &sysctl_sched_rt_runtime
,
423 .maxlen
= sizeof(int),
425 .proc_handler
= sched_rt_handler
,
428 .procname
= "sched_rr_timeslice_ms",
429 .data
= &sysctl_sched_rr_timeslice
,
430 .maxlen
= sizeof(int),
432 .proc_handler
= sched_rr_handler
,
434 #ifdef CONFIG_SCHED_AUTOGROUP
436 .procname
= "sched_autogroup_enabled",
437 .data
= &sysctl_sched_autogroup_enabled
,
438 .maxlen
= sizeof(unsigned int),
440 .proc_handler
= proc_dointvec_minmax
,
445 #ifdef CONFIG_CFS_BANDWIDTH
447 .procname
= "sched_cfs_bandwidth_slice_us",
448 .data
= &sysctl_sched_cfs_bandwidth_slice
,
449 .maxlen
= sizeof(unsigned int),
451 .proc_handler
= proc_dointvec_minmax
,
455 #ifdef CONFIG_PROVE_LOCKING
457 .procname
= "prove_locking",
458 .data
= &prove_locking
,
459 .maxlen
= sizeof(int),
461 .proc_handler
= proc_dointvec
,
464 #ifdef CONFIG_LOCK_STAT
466 .procname
= "lock_stat",
468 .maxlen
= sizeof(int),
470 .proc_handler
= proc_dointvec
,
475 .data
= &panic_timeout
,
476 .maxlen
= sizeof(int),
478 .proc_handler
= proc_dointvec
,
480 #ifdef CONFIG_COREDUMP
482 .procname
= "core_uses_pid",
483 .data
= &core_uses_pid
,
484 .maxlen
= sizeof(int),
486 .proc_handler
= proc_dointvec
,
489 .procname
= "core_pattern",
490 .data
= core_pattern
,
491 .maxlen
= CORENAME_MAX_SIZE
,
493 .proc_handler
= proc_dostring_coredump
,
496 .procname
= "core_pipe_limit",
497 .data
= &core_pipe_limit
,
498 .maxlen
= sizeof(unsigned int),
500 .proc_handler
= proc_dointvec
,
503 #ifdef CONFIG_PROC_SYSCTL
505 .procname
= "tainted",
506 .maxlen
= sizeof(long),
508 .proc_handler
= proc_taint
,
511 .procname
= "sysctl_writes_strict",
512 .data
= &sysctl_writes_strict
,
513 .maxlen
= sizeof(int),
515 .proc_handler
= proc_dointvec_minmax
,
520 #ifdef CONFIG_LATENCYTOP
522 .procname
= "latencytop",
523 .data
= &latencytop_enabled
,
524 .maxlen
= sizeof(int),
526 .proc_handler
= sysctl_latencytop
,
529 #ifdef CONFIG_BLK_DEV_INITRD
531 .procname
= "real-root-dev",
532 .data
= &real_root_dev
,
533 .maxlen
= sizeof(int),
535 .proc_handler
= proc_dointvec
,
539 .procname
= "print-fatal-signals",
540 .data
= &print_fatal_signals
,
541 .maxlen
= sizeof(int),
543 .proc_handler
= proc_dointvec
,
547 .procname
= "reboot-cmd",
548 .data
= reboot_command
,
551 .proc_handler
= proc_dostring
,
554 .procname
= "stop-a",
555 .data
= &stop_a_enabled
,
556 .maxlen
= sizeof (int),
558 .proc_handler
= proc_dointvec
,
561 .procname
= "scons-poweroff",
562 .data
= &scons_pwroff
,
563 .maxlen
= sizeof (int),
565 .proc_handler
= proc_dointvec
,
568 #ifdef CONFIG_SPARC64
570 .procname
= "tsb-ratio",
571 .data
= &sysctl_tsb_ratio
,
572 .maxlen
= sizeof (int),
574 .proc_handler
= proc_dointvec
,
579 .procname
= "soft-power",
580 .data
= &pwrsw_enabled
,
581 .maxlen
= sizeof (int),
583 .proc_handler
= proc_dointvec
,
586 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
588 .procname
= "unaligned-trap",
589 .data
= &unaligned_enabled
,
590 .maxlen
= sizeof (int),
592 .proc_handler
= proc_dointvec
,
596 .procname
= "ctrl-alt-del",
598 .maxlen
= sizeof(int),
600 .proc_handler
= proc_dointvec
,
602 #ifdef CONFIG_FUNCTION_TRACER
604 .procname
= "ftrace_enabled",
605 .data
= &ftrace_enabled
,
606 .maxlen
= sizeof(int),
608 .proc_handler
= ftrace_enable_sysctl
,
611 #ifdef CONFIG_STACK_TRACER
613 .procname
= "stack_tracer_enabled",
614 .data
= &stack_tracer_enabled
,
615 .maxlen
= sizeof(int),
617 .proc_handler
= stack_trace_sysctl
,
620 #ifdef CONFIG_TRACING
622 .procname
= "ftrace_dump_on_oops",
623 .data
= &ftrace_dump_on_oops
,
624 .maxlen
= sizeof(int),
626 .proc_handler
= proc_dointvec
,
629 .procname
= "traceoff_on_warning",
630 .data
= &__disable_trace_on_warning
,
631 .maxlen
= sizeof(__disable_trace_on_warning
),
633 .proc_handler
= proc_dointvec
,
636 .procname
= "tracepoint_printk",
637 .data
= &tracepoint_printk
,
638 .maxlen
= sizeof(tracepoint_printk
),
640 .proc_handler
= proc_dointvec
,
643 #ifdef CONFIG_KEXEC_CORE
645 .procname
= "kexec_load_disabled",
646 .data
= &kexec_load_disabled
,
647 .maxlen
= sizeof(int),
649 /* only handle a transition from default "0" to "1" */
650 .proc_handler
= proc_dointvec_minmax
,
655 #ifdef CONFIG_MODULES
657 .procname
= "modprobe",
658 .data
= &modprobe_path
,
659 .maxlen
= KMOD_PATH_LEN
,
661 .proc_handler
= proc_dostring
,
664 .procname
= "modules_disabled",
665 .data
= &modules_disabled
,
666 .maxlen
= sizeof(int),
668 /* only handle a transition from default "0" to "1" */
669 .proc_handler
= proc_dointvec_minmax
,
674 #ifdef CONFIG_UEVENT_HELPER
676 .procname
= "hotplug",
677 .data
= &uevent_helper
,
678 .maxlen
= UEVENT_HELPER_PATH_LEN
,
680 .proc_handler
= proc_dostring
,
683 #ifdef CONFIG_CHR_DEV_SG
685 .procname
= "sg-big-buff",
686 .data
= &sg_big_buff
,
687 .maxlen
= sizeof (int),
689 .proc_handler
= proc_dointvec
,
692 #ifdef CONFIG_BSD_PROCESS_ACCT
696 .maxlen
= 3*sizeof(int),
698 .proc_handler
= proc_dointvec
,
701 #ifdef CONFIG_MAGIC_SYSRQ
704 .data
= &__sysrq_enabled
,
705 .maxlen
= sizeof (int),
707 .proc_handler
= sysrq_sysctl_handler
,
710 #ifdef CONFIG_PROC_SYSCTL
712 .procname
= "cad_pid",
714 .maxlen
= sizeof (int),
716 .proc_handler
= proc_do_cad_pid
,
720 .procname
= "threads-max",
722 .maxlen
= sizeof(int),
724 .proc_handler
= sysctl_max_threads
,
727 .procname
= "random",
729 .child
= random_table
,
732 .procname
= "usermodehelper",
734 .child
= usermodehelper_table
,
737 .procname
= "overflowuid",
738 .data
= &overflowuid
,
739 .maxlen
= sizeof(int),
741 .proc_handler
= proc_dointvec_minmax
,
742 .extra1
= &minolduid
,
743 .extra2
= &maxolduid
,
746 .procname
= "overflowgid",
747 .data
= &overflowgid
,
748 .maxlen
= sizeof(int),
750 .proc_handler
= proc_dointvec_minmax
,
751 .extra1
= &minolduid
,
752 .extra2
= &maxolduid
,
755 #ifdef CONFIG_MATHEMU
757 .procname
= "ieee_emulation_warnings",
758 .data
= &sysctl_ieee_emulation_warnings
,
759 .maxlen
= sizeof(int),
761 .proc_handler
= proc_dointvec
,
765 .procname
= "userprocess_debug",
766 .data
= &show_unhandled_signals
,
767 .maxlen
= sizeof(int),
769 .proc_handler
= proc_dointvec
,
773 .procname
= "pid_max",
775 .maxlen
= sizeof (int),
777 .proc_handler
= proc_dointvec_minmax
,
778 .extra1
= &pid_max_min
,
779 .extra2
= &pid_max_max
,
782 .procname
= "panic_on_oops",
783 .data
= &panic_on_oops
,
784 .maxlen
= sizeof(int),
786 .proc_handler
= proc_dointvec
,
788 #if defined CONFIG_PRINTK
790 .procname
= "printk",
791 .data
= &console_loglevel
,
792 .maxlen
= 4*sizeof(int),
794 .proc_handler
= proc_dointvec
,
797 .procname
= "printk_ratelimit",
798 .data
= &printk_ratelimit_state
.interval
,
799 .maxlen
= sizeof(int),
801 .proc_handler
= proc_dointvec_jiffies
,
804 .procname
= "printk_ratelimit_burst",
805 .data
= &printk_ratelimit_state
.burst
,
806 .maxlen
= sizeof(int),
808 .proc_handler
= proc_dointvec
,
811 .procname
= "printk_delay",
812 .data
= &printk_delay_msec
,
813 .maxlen
= sizeof(int),
815 .proc_handler
= proc_dointvec_minmax
,
817 .extra2
= &ten_thousand
,
820 .procname
= "printk_devkmsg",
821 .data
= devkmsg_log_str
,
822 .maxlen
= DEVKMSG_STR_MAX_SIZE
,
824 .proc_handler
= devkmsg_sysctl_set_loglvl
,
827 .procname
= "dmesg_restrict",
828 .data
= &dmesg_restrict
,
829 .maxlen
= sizeof(int),
831 .proc_handler
= proc_dointvec_minmax_sysadmin
,
836 .procname
= "kptr_restrict",
837 .data
= &kptr_restrict
,
838 .maxlen
= sizeof(int),
840 .proc_handler
= proc_dointvec_minmax_sysadmin
,
846 .procname
= "ngroups_max",
847 .data
= &ngroups_max
,
848 .maxlen
= sizeof (int),
850 .proc_handler
= proc_dointvec
,
853 .procname
= "cap_last_cap",
854 .data
= (void *)&cap_last_cap
,
855 .maxlen
= sizeof(int),
857 .proc_handler
= proc_dointvec
,
859 #if defined(CONFIG_LOCKUP_DETECTOR)
861 .procname
= "watchdog",
862 .data
= &watchdog_user_enabled
,
863 .maxlen
= sizeof (int),
865 .proc_handler
= proc_watchdog
,
870 .procname
= "watchdog_thresh",
871 .data
= &watchdog_thresh
,
872 .maxlen
= sizeof(int),
874 .proc_handler
= proc_watchdog_thresh
,
879 .procname
= "nmi_watchdog",
880 .data
= &nmi_watchdog_enabled
,
881 .maxlen
= sizeof (int),
883 .proc_handler
= proc_nmi_watchdog
,
885 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
892 .procname
= "soft_watchdog",
893 .data
= &soft_watchdog_enabled
,
894 .maxlen
= sizeof (int),
896 .proc_handler
= proc_soft_watchdog
,
901 .procname
= "watchdog_cpumask",
902 .data
= &watchdog_cpumask_bits
,
905 .proc_handler
= proc_watchdog_cpumask
,
908 .procname
= "softlockup_panic",
909 .data
= &softlockup_panic
,
910 .maxlen
= sizeof(int),
912 .proc_handler
= proc_dointvec_minmax
,
916 #ifdef CONFIG_HARDLOCKUP_DETECTOR
918 .procname
= "hardlockup_panic",
919 .data
= &hardlockup_panic
,
920 .maxlen
= sizeof(int),
922 .proc_handler
= proc_dointvec_minmax
,
929 .procname
= "softlockup_all_cpu_backtrace",
930 .data
= &sysctl_softlockup_all_cpu_backtrace
,
931 .maxlen
= sizeof(int),
933 .proc_handler
= proc_dointvec_minmax
,
938 .procname
= "hardlockup_all_cpu_backtrace",
939 .data
= &sysctl_hardlockup_all_cpu_backtrace
,
940 .maxlen
= sizeof(int),
942 .proc_handler
= proc_dointvec_minmax
,
946 #endif /* CONFIG_SMP */
948 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
950 .procname
= "unknown_nmi_panic",
951 .data
= &unknown_nmi_panic
,
952 .maxlen
= sizeof (int),
954 .proc_handler
= proc_dointvec
,
957 #if defined(CONFIG_X86)
959 .procname
= "panic_on_unrecovered_nmi",
960 .data
= &panic_on_unrecovered_nmi
,
961 .maxlen
= sizeof(int),
963 .proc_handler
= proc_dointvec
,
966 .procname
= "panic_on_io_nmi",
967 .data
= &panic_on_io_nmi
,
968 .maxlen
= sizeof(int),
970 .proc_handler
= proc_dointvec
,
972 #ifdef CONFIG_DEBUG_STACKOVERFLOW
974 .procname
= "panic_on_stackoverflow",
975 .data
= &sysctl_panic_on_stackoverflow
,
976 .maxlen
= sizeof(int),
978 .proc_handler
= proc_dointvec
,
982 .procname
= "bootloader_type",
983 .data
= &bootloader_type
,
984 .maxlen
= sizeof (int),
986 .proc_handler
= proc_dointvec
,
989 .procname
= "bootloader_version",
990 .data
= &bootloader_version
,
991 .maxlen
= sizeof (int),
993 .proc_handler
= proc_dointvec
,
996 .procname
= "kstack_depth_to_print",
997 .data
= &kstack_depth_to_print
,
998 .maxlen
= sizeof(int),
1000 .proc_handler
= proc_dointvec
,
1003 .procname
= "io_delay_type",
1004 .data
= &io_delay_type
,
1005 .maxlen
= sizeof(int),
1007 .proc_handler
= proc_dointvec
,
1010 #if defined(CONFIG_MMU)
1012 .procname
= "randomize_va_space",
1013 .data
= &randomize_va_space
,
1014 .maxlen
= sizeof(int),
1016 .proc_handler
= proc_dointvec
,
1019 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1021 .procname
= "spin_retry",
1022 .data
= &spin_retry
,
1023 .maxlen
= sizeof (int),
1025 .proc_handler
= proc_dointvec
,
1028 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1030 .procname
= "acpi_video_flags",
1031 .data
= &acpi_realmode_flags
,
1032 .maxlen
= sizeof (unsigned long),
1034 .proc_handler
= proc_doulongvec_minmax
,
1037 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1039 .procname
= "ignore-unaligned-usertrap",
1040 .data
= &no_unaligned_warning
,
1041 .maxlen
= sizeof (int),
1043 .proc_handler
= proc_dointvec
,
1048 .procname
= "unaligned-dump-stack",
1049 .data
= &unaligned_dump_stack
,
1050 .maxlen
= sizeof (int),
1052 .proc_handler
= proc_dointvec
,
1055 #ifdef CONFIG_DETECT_HUNG_TASK
1057 .procname
= "hung_task_panic",
1058 .data
= &sysctl_hung_task_panic
,
1059 .maxlen
= sizeof(int),
1061 .proc_handler
= proc_dointvec_minmax
,
1066 .procname
= "hung_task_check_count",
1067 .data
= &sysctl_hung_task_check_count
,
1068 .maxlen
= sizeof(int),
1070 .proc_handler
= proc_dointvec_minmax
,
1074 .procname
= "hung_task_timeout_secs",
1075 .data
= &sysctl_hung_task_timeout_secs
,
1076 .maxlen
= sizeof(unsigned long),
1078 .proc_handler
= proc_dohung_task_timeout_secs
,
1079 .extra2
= &hung_task_timeout_max
,
1082 .procname
= "hung_task_warnings",
1083 .data
= &sysctl_hung_task_warnings
,
1084 .maxlen
= sizeof(int),
1086 .proc_handler
= proc_dointvec_minmax
,
1090 #ifdef CONFIG_RT_MUTEXES
1092 .procname
= "max_lock_depth",
1093 .data
= &max_lock_depth
,
1094 .maxlen
= sizeof(int),
1096 .proc_handler
= proc_dointvec
,
1100 .procname
= "poweroff_cmd",
1101 .data
= &poweroff_cmd
,
1102 .maxlen
= POWEROFF_CMD_PATH_LEN
,
1104 .proc_handler
= proc_dostring
,
1110 .child
= key_sysctls
,
1113 #ifdef CONFIG_PERF_EVENTS
1115 * User-space scripts rely on the existence of this file
1116 * as a feature check for perf_events being enabled.
1118 * So it's an ABI, do not remove!
1121 .procname
= "perf_event_paranoid",
1122 .data
= &sysctl_perf_event_paranoid
,
1123 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
1125 .proc_handler
= proc_dointvec
,
1128 .procname
= "perf_event_mlock_kb",
1129 .data
= &sysctl_perf_event_mlock
,
1130 .maxlen
= sizeof(sysctl_perf_event_mlock
),
1132 .proc_handler
= proc_dointvec
,
1135 .procname
= "perf_event_max_sample_rate",
1136 .data
= &sysctl_perf_event_sample_rate
,
1137 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1139 .proc_handler
= perf_proc_update_handler
,
1143 .procname
= "perf_cpu_time_max_percent",
1144 .data
= &sysctl_perf_cpu_time_max_percent
,
1145 .maxlen
= sizeof(sysctl_perf_cpu_time_max_percent
),
1147 .proc_handler
= perf_cpu_time_max_percent_handler
,
1149 .extra2
= &one_hundred
,
1152 .procname
= "perf_event_max_stack",
1153 .data
= &sysctl_perf_event_max_stack
,
1154 .maxlen
= sizeof(sysctl_perf_event_max_stack
),
1156 .proc_handler
= perf_event_max_stack_handler
,
1158 .extra2
= &six_hundred_forty_kb
,
1161 .procname
= "perf_event_max_contexts_per_stack",
1162 .data
= &sysctl_perf_event_max_contexts_per_stack
,
1163 .maxlen
= sizeof(sysctl_perf_event_max_contexts_per_stack
),
1165 .proc_handler
= perf_event_max_stack_handler
,
1167 .extra2
= &one_thousand
,
1170 #ifdef CONFIG_KMEMCHECK
1172 .procname
= "kmemcheck",
1173 .data
= &kmemcheck_enabled
,
1174 .maxlen
= sizeof(int),
1176 .proc_handler
= proc_dointvec
,
1180 .procname
= "panic_on_warn",
1181 .data
= &panic_on_warn
,
1182 .maxlen
= sizeof(int),
1184 .proc_handler
= proc_dointvec_minmax
,
1188 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1190 .procname
= "timer_migration",
1191 .data
= &sysctl_timer_migration
,
1192 .maxlen
= sizeof(unsigned int),
1194 .proc_handler
= timer_migration_handler
,
1199 #ifdef CONFIG_BPF_SYSCALL
1201 .procname
= "unprivileged_bpf_disabled",
1202 .data
= &sysctl_unprivileged_bpf_disabled
,
1203 .maxlen
= sizeof(sysctl_unprivileged_bpf_disabled
),
1205 /* only handle a transition from default "0" to "1" */
1206 .proc_handler
= proc_dointvec_minmax
,
1211 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1213 .procname
= "panic_on_rcu_stall",
1214 .data
= &sysctl_panic_on_rcu_stall
,
1215 .maxlen
= sizeof(sysctl_panic_on_rcu_stall
),
1217 .proc_handler
= proc_dointvec_minmax
,
1225 static struct ctl_table vm_table
[] = {
1227 .procname
= "overcommit_memory",
1228 .data
= &sysctl_overcommit_memory
,
1229 .maxlen
= sizeof(sysctl_overcommit_memory
),
1231 .proc_handler
= proc_dointvec_minmax
,
1236 .procname
= "panic_on_oom",
1237 .data
= &sysctl_panic_on_oom
,
1238 .maxlen
= sizeof(sysctl_panic_on_oom
),
1240 .proc_handler
= proc_dointvec_minmax
,
1245 .procname
= "oom_kill_allocating_task",
1246 .data
= &sysctl_oom_kill_allocating_task
,
1247 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
1249 .proc_handler
= proc_dointvec
,
1252 .procname
= "oom_dump_tasks",
1253 .data
= &sysctl_oom_dump_tasks
,
1254 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
1256 .proc_handler
= proc_dointvec
,
1259 .procname
= "overcommit_ratio",
1260 .data
= &sysctl_overcommit_ratio
,
1261 .maxlen
= sizeof(sysctl_overcommit_ratio
),
1263 .proc_handler
= overcommit_ratio_handler
,
1266 .procname
= "overcommit_kbytes",
1267 .data
= &sysctl_overcommit_kbytes
,
1268 .maxlen
= sizeof(sysctl_overcommit_kbytes
),
1270 .proc_handler
= overcommit_kbytes_handler
,
1273 .procname
= "page-cluster",
1274 .data
= &page_cluster
,
1275 .maxlen
= sizeof(int),
1277 .proc_handler
= proc_dointvec_minmax
,
1281 .procname
= "dirty_background_ratio",
1282 .data
= &dirty_background_ratio
,
1283 .maxlen
= sizeof(dirty_background_ratio
),
1285 .proc_handler
= dirty_background_ratio_handler
,
1287 .extra2
= &one_hundred
,
1290 .procname
= "dirty_background_bytes",
1291 .data
= &dirty_background_bytes
,
1292 .maxlen
= sizeof(dirty_background_bytes
),
1294 .proc_handler
= dirty_background_bytes_handler
,
1298 .procname
= "dirty_ratio",
1299 .data
= &vm_dirty_ratio
,
1300 .maxlen
= sizeof(vm_dirty_ratio
),
1302 .proc_handler
= dirty_ratio_handler
,
1304 .extra2
= &one_hundred
,
1307 .procname
= "dirty_bytes",
1308 .data
= &vm_dirty_bytes
,
1309 .maxlen
= sizeof(vm_dirty_bytes
),
1311 .proc_handler
= dirty_bytes_handler
,
1312 .extra1
= &dirty_bytes_min
,
1315 .procname
= "dirty_writeback_centisecs",
1316 .data
= &dirty_writeback_interval
,
1317 .maxlen
= sizeof(dirty_writeback_interval
),
1319 .proc_handler
= dirty_writeback_centisecs_handler
,
1322 .procname
= "dirty_expire_centisecs",
1323 .data
= &dirty_expire_interval
,
1324 .maxlen
= sizeof(dirty_expire_interval
),
1326 .proc_handler
= proc_dointvec_minmax
,
1330 .procname
= "dirtytime_expire_seconds",
1331 .data
= &dirtytime_expire_interval
,
1332 .maxlen
= sizeof(dirty_expire_interval
),
1334 .proc_handler
= dirtytime_interval_handler
,
1338 .procname
= "nr_pdflush_threads",
1339 .mode
= 0444 /* read-only */,
1340 .proc_handler
= pdflush_proc_obsolete
,
1343 .procname
= "swappiness",
1344 .data
= &vm_swappiness
,
1345 .maxlen
= sizeof(vm_swappiness
),
1347 .proc_handler
= proc_dointvec_minmax
,
1349 .extra2
= &one_hundred
,
1351 #ifdef CONFIG_HUGETLB_PAGE
1353 .procname
= "nr_hugepages",
1355 .maxlen
= sizeof(unsigned long),
1357 .proc_handler
= hugetlb_sysctl_handler
,
1361 .procname
= "nr_hugepages_mempolicy",
1363 .maxlen
= sizeof(unsigned long),
1365 .proc_handler
= &hugetlb_mempolicy_sysctl_handler
,
1369 .procname
= "hugetlb_shm_group",
1370 .data
= &sysctl_hugetlb_shm_group
,
1371 .maxlen
= sizeof(gid_t
),
1373 .proc_handler
= proc_dointvec
,
1376 .procname
= "hugepages_treat_as_movable",
1377 .data
= &hugepages_treat_as_movable
,
1378 .maxlen
= sizeof(int),
1380 .proc_handler
= proc_dointvec
,
1383 .procname
= "nr_overcommit_hugepages",
1385 .maxlen
= sizeof(unsigned long),
1387 .proc_handler
= hugetlb_overcommit_handler
,
1391 .procname
= "lowmem_reserve_ratio",
1392 .data
= &sysctl_lowmem_reserve_ratio
,
1393 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
1395 .proc_handler
= lowmem_reserve_ratio_sysctl_handler
,
1398 .procname
= "drop_caches",
1399 .data
= &sysctl_drop_caches
,
1400 .maxlen
= sizeof(int),
1402 .proc_handler
= drop_caches_sysctl_handler
,
1406 #ifdef CONFIG_COMPACTION
1408 .procname
= "compact_memory",
1409 .data
= &sysctl_compact_memory
,
1410 .maxlen
= sizeof(int),
1412 .proc_handler
= sysctl_compaction_handler
,
1415 .procname
= "extfrag_threshold",
1416 .data
= &sysctl_extfrag_threshold
,
1417 .maxlen
= sizeof(int),
1419 .proc_handler
= sysctl_extfrag_handler
,
1420 .extra1
= &min_extfrag_threshold
,
1421 .extra2
= &max_extfrag_threshold
,
1424 .procname
= "compact_unevictable_allowed",
1425 .data
= &sysctl_compact_unevictable_allowed
,
1426 .maxlen
= sizeof(int),
1428 .proc_handler
= proc_dointvec
,
1433 #endif /* CONFIG_COMPACTION */
1435 .procname
= "min_free_kbytes",
1436 .data
= &min_free_kbytes
,
1437 .maxlen
= sizeof(min_free_kbytes
),
1439 .proc_handler
= min_free_kbytes_sysctl_handler
,
1443 .procname
= "watermark_scale_factor",
1444 .data
= &watermark_scale_factor
,
1445 .maxlen
= sizeof(watermark_scale_factor
),
1447 .proc_handler
= watermark_scale_factor_sysctl_handler
,
1449 .extra2
= &one_thousand
,
1452 .procname
= "percpu_pagelist_fraction",
1453 .data
= &percpu_pagelist_fraction
,
1454 .maxlen
= sizeof(percpu_pagelist_fraction
),
1456 .proc_handler
= percpu_pagelist_fraction_sysctl_handler
,
1461 .procname
= "max_map_count",
1462 .data
= &sysctl_max_map_count
,
1463 .maxlen
= sizeof(sysctl_max_map_count
),
1465 .proc_handler
= proc_dointvec_minmax
,
1470 .procname
= "nr_trim_pages",
1471 .data
= &sysctl_nr_trim_pages
,
1472 .maxlen
= sizeof(sysctl_nr_trim_pages
),
1474 .proc_handler
= proc_dointvec_minmax
,
1479 .procname
= "laptop_mode",
1480 .data
= &laptop_mode
,
1481 .maxlen
= sizeof(laptop_mode
),
1483 .proc_handler
= proc_dointvec_jiffies
,
1486 .procname
= "block_dump",
1487 .data
= &block_dump
,
1488 .maxlen
= sizeof(block_dump
),
1490 .proc_handler
= proc_dointvec
,
1494 .procname
= "vfs_cache_pressure",
1495 .data
= &sysctl_vfs_cache_pressure
,
1496 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1498 .proc_handler
= proc_dointvec
,
1501 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1503 .procname
= "legacy_va_layout",
1504 .data
= &sysctl_legacy_va_layout
,
1505 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1507 .proc_handler
= proc_dointvec
,
1513 .procname
= "zone_reclaim_mode",
1514 .data
= &node_reclaim_mode
,
1515 .maxlen
= sizeof(node_reclaim_mode
),
1517 .proc_handler
= proc_dointvec
,
1521 .procname
= "min_unmapped_ratio",
1522 .data
= &sysctl_min_unmapped_ratio
,
1523 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1525 .proc_handler
= sysctl_min_unmapped_ratio_sysctl_handler
,
1527 .extra2
= &one_hundred
,
1530 .procname
= "min_slab_ratio",
1531 .data
= &sysctl_min_slab_ratio
,
1532 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1534 .proc_handler
= sysctl_min_slab_ratio_sysctl_handler
,
1536 .extra2
= &one_hundred
,
1541 .procname
= "stat_interval",
1542 .data
= &sysctl_stat_interval
,
1543 .maxlen
= sizeof(sysctl_stat_interval
),
1545 .proc_handler
= proc_dointvec_jiffies
,
1548 .procname
= "stat_refresh",
1552 .proc_handler
= vmstat_refresh
,
1557 .procname
= "mmap_min_addr",
1558 .data
= &dac_mmap_min_addr
,
1559 .maxlen
= sizeof(unsigned long),
1561 .proc_handler
= mmap_min_addr_handler
,
1566 .procname
= "numa_zonelist_order",
1567 .data
= &numa_zonelist_order
,
1568 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1570 .proc_handler
= numa_zonelist_order_handler
,
1573 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1574 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1576 .procname
= "vdso_enabled",
1577 #ifdef CONFIG_X86_32
1578 .data
= &vdso32_enabled
,
1579 .maxlen
= sizeof(vdso32_enabled
),
1581 .data
= &vdso_enabled
,
1582 .maxlen
= sizeof(vdso_enabled
),
1585 .proc_handler
= proc_dointvec
,
1589 #ifdef CONFIG_HIGHMEM
1591 .procname
= "highmem_is_dirtyable",
1592 .data
= &vm_highmem_is_dirtyable
,
1593 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
1595 .proc_handler
= proc_dointvec_minmax
,
1600 #ifdef CONFIG_MEMORY_FAILURE
1602 .procname
= "memory_failure_early_kill",
1603 .data
= &sysctl_memory_failure_early_kill
,
1604 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
1606 .proc_handler
= proc_dointvec_minmax
,
1611 .procname
= "memory_failure_recovery",
1612 .data
= &sysctl_memory_failure_recovery
,
1613 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
1615 .proc_handler
= proc_dointvec_minmax
,
1621 .procname
= "user_reserve_kbytes",
1622 .data
= &sysctl_user_reserve_kbytes
,
1623 .maxlen
= sizeof(sysctl_user_reserve_kbytes
),
1625 .proc_handler
= proc_doulongvec_minmax
,
1628 .procname
= "admin_reserve_kbytes",
1629 .data
= &sysctl_admin_reserve_kbytes
,
1630 .maxlen
= sizeof(sysctl_admin_reserve_kbytes
),
1632 .proc_handler
= proc_doulongvec_minmax
,
1634 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1636 .procname
= "mmap_rnd_bits",
1637 .data
= &mmap_rnd_bits
,
1638 .maxlen
= sizeof(mmap_rnd_bits
),
1640 .proc_handler
= proc_dointvec_minmax
,
1641 .extra1
= (void *)&mmap_rnd_bits_min
,
1642 .extra2
= (void *)&mmap_rnd_bits_max
,
1645 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1647 .procname
= "mmap_rnd_compat_bits",
1648 .data
= &mmap_rnd_compat_bits
,
1649 .maxlen
= sizeof(mmap_rnd_compat_bits
),
1651 .proc_handler
= proc_dointvec_minmax
,
1652 .extra1
= (void *)&mmap_rnd_compat_bits_min
,
1653 .extra2
= (void *)&mmap_rnd_compat_bits_max
,
1659 static struct ctl_table fs_table
[] = {
1661 .procname
= "inode-nr",
1662 .data
= &inodes_stat
,
1663 .maxlen
= 2*sizeof(long),
1665 .proc_handler
= proc_nr_inodes
,
1668 .procname
= "inode-state",
1669 .data
= &inodes_stat
,
1670 .maxlen
= 7*sizeof(long),
1672 .proc_handler
= proc_nr_inodes
,
1675 .procname
= "file-nr",
1676 .data
= &files_stat
,
1677 .maxlen
= sizeof(files_stat
),
1679 .proc_handler
= proc_nr_files
,
1682 .procname
= "file-max",
1683 .data
= &files_stat
.max_files
,
1684 .maxlen
= sizeof(files_stat
.max_files
),
1686 .proc_handler
= proc_doulongvec_minmax
,
1688 .extra2
= &long_max
,
1691 .procname
= "nr_open",
1692 .data
= &sysctl_nr_open
,
1693 .maxlen
= sizeof(unsigned int),
1695 .proc_handler
= proc_dointvec_minmax
,
1696 .extra1
= &sysctl_nr_open_min
,
1697 .extra2
= &sysctl_nr_open_max
,
1700 .procname
= "dentry-state",
1701 .data
= &dentry_stat
,
1702 .maxlen
= 6*sizeof(long),
1704 .proc_handler
= proc_nr_dentry
,
1707 .procname
= "overflowuid",
1708 .data
= &fs_overflowuid
,
1709 .maxlen
= sizeof(int),
1711 .proc_handler
= proc_dointvec_minmax
,
1712 .extra1
= &minolduid
,
1713 .extra2
= &maxolduid
,
1716 .procname
= "overflowgid",
1717 .data
= &fs_overflowgid
,
1718 .maxlen
= sizeof(int),
1720 .proc_handler
= proc_dointvec_minmax
,
1721 .extra1
= &minolduid
,
1722 .extra2
= &maxolduid
,
1724 #ifdef CONFIG_FILE_LOCKING
1726 .procname
= "leases-enable",
1727 .data
= &leases_enable
,
1728 .maxlen
= sizeof(int),
1730 .proc_handler
= proc_dointvec
,
1733 #ifdef CONFIG_DNOTIFY
1735 .procname
= "dir-notify-enable",
1736 .data
= &dir_notify_enable
,
1737 .maxlen
= sizeof(int),
1739 .proc_handler
= proc_dointvec
,
1743 #ifdef CONFIG_FILE_LOCKING
1745 .procname
= "lease-break-time",
1746 .data
= &lease_break_time
,
1747 .maxlen
= sizeof(int),
1749 .proc_handler
= proc_dointvec
,
1754 .procname
= "aio-nr",
1756 .maxlen
= sizeof(aio_nr
),
1758 .proc_handler
= proc_doulongvec_minmax
,
1761 .procname
= "aio-max-nr",
1762 .data
= &aio_max_nr
,
1763 .maxlen
= sizeof(aio_max_nr
),
1765 .proc_handler
= proc_doulongvec_minmax
,
1767 #endif /* CONFIG_AIO */
1768 #ifdef CONFIG_INOTIFY_USER
1770 .procname
= "inotify",
1772 .child
= inotify_table
,
1777 .procname
= "epoll",
1779 .child
= epoll_table
,
1784 .procname
= "protected_symlinks",
1785 .data
= &sysctl_protected_symlinks
,
1786 .maxlen
= sizeof(int),
1788 .proc_handler
= proc_dointvec_minmax
,
1793 .procname
= "protected_hardlinks",
1794 .data
= &sysctl_protected_hardlinks
,
1795 .maxlen
= sizeof(int),
1797 .proc_handler
= proc_dointvec_minmax
,
1802 .procname
= "protected_fifos",
1803 .data
= &sysctl_protected_fifos
,
1804 .maxlen
= sizeof(int),
1806 .proc_handler
= proc_dointvec_minmax
,
1811 .procname
= "protected_regular",
1812 .data
= &sysctl_protected_regular
,
1813 .maxlen
= sizeof(int),
1815 .proc_handler
= proc_dointvec_minmax
,
1820 .procname
= "suid_dumpable",
1821 .data
= &suid_dumpable
,
1822 .maxlen
= sizeof(int),
1824 .proc_handler
= proc_dointvec_minmax_coredump
,
1828 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1830 .procname
= "binfmt_misc",
1832 .child
= sysctl_mount_point
,
1836 .procname
= "pipe-max-size",
1837 .data
= &pipe_max_size
,
1838 .maxlen
= sizeof(int),
1840 .proc_handler
= &pipe_proc_fn
,
1841 .extra1
= &pipe_min_size
,
1844 .procname
= "pipe-user-pages-hard",
1845 .data
= &pipe_user_pages_hard
,
1846 .maxlen
= sizeof(pipe_user_pages_hard
),
1848 .proc_handler
= proc_doulongvec_minmax
,
1851 .procname
= "pipe-user-pages-soft",
1852 .data
= &pipe_user_pages_soft
,
1853 .maxlen
= sizeof(pipe_user_pages_soft
),
1855 .proc_handler
= proc_doulongvec_minmax
,
1858 .procname
= "mount-max",
1859 .data
= &sysctl_mount_max
,
1860 .maxlen
= sizeof(unsigned int),
1862 .proc_handler
= proc_dointvec_minmax
,
1868 static struct ctl_table debug_table
[] = {
1869 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1871 .procname
= "exception-trace",
1872 .data
= &show_unhandled_signals
,
1873 .maxlen
= sizeof(int),
1875 .proc_handler
= proc_dointvec
1878 #if defined(CONFIG_OPTPROBES)
1880 .procname
= "kprobes-optimization",
1881 .data
= &sysctl_kprobes_optimization
,
1882 .maxlen
= sizeof(int),
1884 .proc_handler
= proc_kprobes_optimization_handler
,
1892 static struct ctl_table dev_table
[] = {
1896 int __init
sysctl_init(void)
1898 struct ctl_table_header
*hdr
;
1900 hdr
= register_sysctl_table(sysctl_base_table
);
1901 kmemleak_not_leak(hdr
);
1905 #endif /* CONFIG_SYSCTL */
1911 #ifdef CONFIG_PROC_SYSCTL
1913 static int _proc_do_string(char *data
, int maxlen
, int write
,
1914 char __user
*buffer
,
1915 size_t *lenp
, loff_t
*ppos
)
1921 if (!data
|| !maxlen
|| !*lenp
) {
1927 if (sysctl_writes_strict
== SYSCTL_WRITES_STRICT
) {
1928 /* Only continue writes not past the end of buffer. */
1930 if (len
> maxlen
- 1)
1937 /* Start writing from beginning of buffer. */
1943 while ((p
- buffer
) < *lenp
&& len
< maxlen
- 1) {
1944 if (get_user(c
, p
++))
1946 if (c
== 0 || c
== '\n')
1967 if (copy_to_user(buffer
, data
, len
))
1970 if (put_user('\n', buffer
+ len
))
1980 static void warn_sysctl_write(struct ctl_table
*table
)
1982 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1983 "This will not be supported in the future. To silence this\n"
1984 "warning, set kernel.sysctl_writes_strict = -1\n",
1985 current
->comm
, table
->procname
);
1989 * proc_dostring - read a string sysctl
1990 * @table: the sysctl table
1991 * @write: %TRUE if this is a write to the sysctl file
1992 * @buffer: the user buffer
1993 * @lenp: the size of the user buffer
1994 * @ppos: file position
1996 * Reads/writes a string from/to the user buffer. If the kernel
1997 * buffer provided is not large enough to hold the string, the
1998 * string is truncated. The copied string is %NULL-terminated.
1999 * If the string is being read by the user process, it is copied
2000 * and a newline '\n' is added. It is truncated if the buffer is
2003 * Returns 0 on success.
2005 int proc_dostring(struct ctl_table
*table
, int write
,
2006 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2008 if (write
&& *ppos
&& sysctl_writes_strict
== SYSCTL_WRITES_WARN
)
2009 warn_sysctl_write(table
);
2011 return _proc_do_string((char *)(table
->data
), table
->maxlen
, write
,
2012 (char __user
*)buffer
, lenp
, ppos
);
2015 static size_t proc_skip_spaces(char **buf
)
2018 char *tmp
= skip_spaces(*buf
);
2024 static void proc_skip_char(char **buf
, size_t *size
, const char v
)
2034 #define TMPBUFLEN 22
2036 * proc_get_long - reads an ASCII formatted integer from a user buffer
2038 * @buf: a kernel buffer
2039 * @size: size of the kernel buffer
2040 * @val: this is where the number will be stored
2041 * @neg: set to %TRUE if number is negative
2042 * @perm_tr: a vector which contains the allowed trailers
2043 * @perm_tr_len: size of the perm_tr vector
2044 * @tr: pointer to store the trailer character
2046 * In case of success %0 is returned and @buf and @size are updated with
2047 * the amount of bytes read. If @tr is non-NULL and a trailing
2048 * character exists (size is non-zero after returning from this
2049 * function), @tr is updated with the trailing character.
2051 static int proc_get_long(char **buf
, size_t *size
,
2052 unsigned long *val
, bool *neg
,
2053 const char *perm_tr
, unsigned perm_tr_len
, char *tr
)
2056 char *p
, tmp
[TMPBUFLEN
];
2062 if (len
> TMPBUFLEN
- 1)
2063 len
= TMPBUFLEN
- 1;
2065 memcpy(tmp
, *buf
, len
);
2069 if (*p
== '-' && *size
> 1) {
2077 *val
= simple_strtoul(p
, &p
, 0);
2081 /* We don't know if the next char is whitespace thus we may accept
2082 * invalid integers (e.g. 1234...a) or two integers instead of one
2083 * (e.g. 123...1). So lets not allow such large numbers. */
2084 if (len
== TMPBUFLEN
- 1)
2087 if (len
< *size
&& perm_tr_len
&& !memchr(perm_tr
, *p
, perm_tr_len
))
2090 if (tr
&& (len
< *size
))
2100 * proc_put_long - converts an integer to a decimal ASCII formatted string
2102 * @buf: the user buffer
2103 * @size: the size of the user buffer
2104 * @val: the integer to be converted
2105 * @neg: sign of the number, %TRUE for negative
2107 * In case of success %0 is returned and @buf and @size are updated with
2108 * the amount of bytes written.
2110 static int proc_put_long(void __user
**buf
, size_t *size
, unsigned long val
,
2114 char tmp
[TMPBUFLEN
], *p
= tmp
;
2116 sprintf(p
, "%s%lu", neg
? "-" : "", val
);
2120 if (copy_to_user(*buf
, tmp
, len
))
2128 static int proc_put_char(void __user
**buf
, size_t *size
, char c
)
2131 char __user
**buffer
= (char __user
**)buf
;
2132 if (put_user(c
, *buffer
))
2134 (*size
)--, (*buffer
)++;
2140 static int do_proc_dointvec_conv(bool *negp
, unsigned long *lvalp
,
2142 int write
, void *data
)
2146 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2150 if (*lvalp
> (unsigned long) INT_MAX
)
2158 *lvalp
= -(unsigned long)val
;
2161 *lvalp
= (unsigned long)val
;
2167 static int do_proc_douintvec_conv(bool *negp
, unsigned long *lvalp
,
2169 int write
, void *data
)
2174 if (*lvalp
> UINT_MAX
)
2178 unsigned int val
= *valp
;
2180 *lvalp
= (unsigned long)val
;
2185 static const char proc_wspace_sep
[] = { ' ', '\t', '\n' };
2187 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2188 int write
, void __user
*buffer
,
2189 size_t *lenp
, loff_t
*ppos
,
2190 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2191 int write
, void *data
),
2194 int *i
, vleft
, first
= 1, err
= 0;
2196 char *kbuf
= NULL
, *p
;
2198 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2203 i
= (int *) tbl_data
;
2204 vleft
= table
->maxlen
/ sizeof(*i
);
2208 conv
= do_proc_dointvec_conv
;
2212 switch (sysctl_writes_strict
) {
2213 case SYSCTL_WRITES_STRICT
:
2215 case SYSCTL_WRITES_WARN
:
2216 warn_sysctl_write(table
);
2223 if (left
> PAGE_SIZE
- 1)
2224 left
= PAGE_SIZE
- 1;
2225 p
= kbuf
= memdup_user_nul(buffer
, left
);
2227 return PTR_ERR(kbuf
);
2230 for (; left
&& vleft
--; i
++, first
=0) {
2235 left
-= proc_skip_spaces(&p
);
2239 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2241 sizeof(proc_wspace_sep
), NULL
);
2244 if (conv(&neg
, &lval
, i
, 1, data
)) {
2249 if (conv(&neg
, &lval
, i
, 0, data
)) {
2254 err
= proc_put_char(&buffer
, &left
, '\t');
2257 err
= proc_put_long(&buffer
, &left
, lval
, neg
);
2263 if (!write
&& !first
&& left
&& !err
)
2264 err
= proc_put_char(&buffer
, &left
, '\n');
2265 if (write
&& !err
&& left
)
2266 left
-= proc_skip_spaces(&p
);
2270 return err
? : -EINVAL
;
2278 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2279 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2280 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2281 int write
, void *data
),
2284 return __do_proc_dointvec(table
->data
, table
, write
,
2285 buffer
, lenp
, ppos
, conv
, data
);
2289 * proc_dointvec - read a vector of integers
2290 * @table: the sysctl table
2291 * @write: %TRUE if this is a write to the sysctl file
2292 * @buffer: the user buffer
2293 * @lenp: the size of the user buffer
2294 * @ppos: file position
2296 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2297 * values from/to the user buffer, treated as an ASCII string.
2299 * Returns 0 on success.
2301 int proc_dointvec(struct ctl_table
*table
, int write
,
2302 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2304 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
, NULL
, NULL
);
2308 * proc_douintvec - read a vector of unsigned integers
2309 * @table: the sysctl table
2310 * @write: %TRUE if this is a write to the sysctl file
2311 * @buffer: the user buffer
2312 * @lenp: the size of the user buffer
2313 * @ppos: file position
2315 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2316 * values from/to the user buffer, treated as an ASCII string.
2318 * Returns 0 on success.
2320 int proc_douintvec(struct ctl_table
*table
, int write
,
2321 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2323 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2324 do_proc_douintvec_conv
, NULL
);
2328 * Taint values can only be increased
2329 * This means we can safely use a temporary.
2331 static int proc_taint(struct ctl_table
*table
, int write
,
2332 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2335 unsigned long tmptaint
= get_taint();
2338 if (write
&& !capable(CAP_SYS_ADMIN
))
2343 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2349 * Poor man's atomic or. Not worth adding a primitive
2350 * to everyone's atomic.h for this
2353 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2354 if ((tmptaint
>> i
) & 1)
2355 add_taint(i
, LOCKDEP_STILL_OK
);
2362 #ifdef CONFIG_PRINTK
2363 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
2364 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2366 if (write
&& !capable(CAP_SYS_ADMIN
))
2369 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2373 struct do_proc_dointvec_minmax_conv_param
{
2378 static int do_proc_dointvec_minmax_conv(bool *negp
, unsigned long *lvalp
,
2380 int write
, void *data
)
2382 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2386 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2390 if (*lvalp
> (unsigned long) INT_MAX
)
2394 if ((param
->min
&& *param
->min
> val
) ||
2395 (param
->max
&& *param
->max
< val
))
2402 *lvalp
= -(unsigned long)val
;
2405 *lvalp
= (unsigned long)val
;
2412 * proc_dointvec_minmax - read a vector of integers with min/max values
2413 * @table: the sysctl table
2414 * @write: %TRUE if this is a write to the sysctl file
2415 * @buffer: the user buffer
2416 * @lenp: the size of the user buffer
2417 * @ppos: file position
2419 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2420 * values from/to the user buffer, treated as an ASCII string.
2422 * This routine will ensure the values are within the range specified by
2423 * table->extra1 (min) and table->extra2 (max).
2425 * Returns 0 on success.
2427 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2428 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2430 struct do_proc_dointvec_minmax_conv_param param
= {
2431 .min
= (int *) table
->extra1
,
2432 .max
= (int *) table
->extra2
,
2434 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2435 do_proc_dointvec_minmax_conv
, ¶m
);
2438 static void validate_coredump_safety(void)
2440 #ifdef CONFIG_COREDUMP
2441 if (suid_dumpable
== SUID_DUMP_ROOT
&&
2442 core_pattern
[0] != '/' && core_pattern
[0] != '|') {
2443 printk(KERN_WARNING
"Unsafe core_pattern used with "\
2444 "suid_dumpable=2. Pipe handler or fully qualified "\
2445 "core dump path required.\n");
2450 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
2451 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2453 int error
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2455 validate_coredump_safety();
2459 #ifdef CONFIG_COREDUMP
2460 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
2461 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2463 int error
= proc_dostring(table
, write
, buffer
, lenp
, ppos
);
2465 validate_coredump_safety();
2470 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2471 void __user
*buffer
,
2472 size_t *lenp
, loff_t
*ppos
,
2473 unsigned long convmul
,
2474 unsigned long convdiv
)
2476 unsigned long *i
, *min
, *max
;
2477 int vleft
, first
= 1, err
= 0;
2479 char *kbuf
= NULL
, *p
;
2481 if (!data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2486 i
= (unsigned long *) data
;
2487 min
= (unsigned long *) table
->extra1
;
2488 max
= (unsigned long *) table
->extra2
;
2489 vleft
= table
->maxlen
/ sizeof(unsigned long);
2494 switch (sysctl_writes_strict
) {
2495 case SYSCTL_WRITES_STRICT
:
2497 case SYSCTL_WRITES_WARN
:
2498 warn_sysctl_write(table
);
2505 if (left
> PAGE_SIZE
- 1)
2506 left
= PAGE_SIZE
- 1;
2507 p
= kbuf
= memdup_user_nul(buffer
, left
);
2509 return PTR_ERR(kbuf
);
2512 for (; left
&& vleft
--; i
++, first
= 0) {
2518 left
-= proc_skip_spaces(&p
);
2522 err
= proc_get_long(&p
, &left
, &val
, &neg
,
2524 sizeof(proc_wspace_sep
), NULL
);
2529 val
= convmul
* val
/ convdiv
;
2530 if ((min
&& val
< *min
) || (max
&& val
> *max
)) {
2536 val
= convdiv
* (*i
) / convmul
;
2538 err
= proc_put_char(&buffer
, &left
, '\t');
2542 err
= proc_put_long(&buffer
, &left
, val
, false);
2548 if (!write
&& !first
&& left
&& !err
)
2549 err
= proc_put_char(&buffer
, &left
, '\n');
2551 left
-= proc_skip_spaces(&p
);
2555 return err
? : -EINVAL
;
2563 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2564 void __user
*buffer
,
2565 size_t *lenp
, loff_t
*ppos
,
2566 unsigned long convmul
,
2567 unsigned long convdiv
)
2569 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2570 buffer
, lenp
, ppos
, convmul
, convdiv
);
2574 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2575 * @table: the sysctl table
2576 * @write: %TRUE if this is a write to the sysctl file
2577 * @buffer: the user buffer
2578 * @lenp: the size of the user buffer
2579 * @ppos: file position
2581 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2582 * values from/to the user buffer, treated as an ASCII string.
2584 * This routine will ensure the values are within the range specified by
2585 * table->extra1 (min) and table->extra2 (max).
2587 * Returns 0 on success.
2589 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2590 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2592 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2596 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2597 * @table: the sysctl table
2598 * @write: %TRUE if this is a write to the sysctl file
2599 * @buffer: the user buffer
2600 * @lenp: the size of the user buffer
2601 * @ppos: file position
2603 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2604 * values from/to the user buffer, treated as an ASCII string. The values
2605 * are treated as milliseconds, and converted to jiffies when they are stored.
2607 * This routine will ensure the values are within the range specified by
2608 * table->extra1 (min) and table->extra2 (max).
2610 * Returns 0 on success.
2612 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2613 void __user
*buffer
,
2614 size_t *lenp
, loff_t
*ppos
)
2616 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2617 lenp
, ppos
, HZ
, 1000l);
2621 static int do_proc_dointvec_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2623 int write
, void *data
)
2626 if (*lvalp
> LONG_MAX
/ HZ
)
2628 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2634 lval
= -(unsigned long)val
;
2637 lval
= (unsigned long)val
;
2644 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2646 int write
, void *data
)
2649 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2651 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2657 lval
= -(unsigned long)val
;
2660 lval
= (unsigned long)val
;
2662 *lvalp
= jiffies_to_clock_t(lval
);
2667 static int do_proc_dointvec_ms_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2669 int write
, void *data
)
2672 unsigned long jif
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2682 lval
= -(unsigned long)val
;
2685 lval
= (unsigned long)val
;
2687 *lvalp
= jiffies_to_msecs(lval
);
2693 * proc_dointvec_jiffies - read a vector of integers as seconds
2694 * @table: the sysctl table
2695 * @write: %TRUE if this is a write to the sysctl file
2696 * @buffer: the user buffer
2697 * @lenp: the size of the user buffer
2698 * @ppos: file position
2700 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2701 * values from/to the user buffer, treated as an ASCII string.
2702 * The values read are assumed to be in seconds, and are converted into
2705 * Returns 0 on success.
2707 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2708 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2710 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2711 do_proc_dointvec_jiffies_conv
,NULL
);
2715 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2716 * @table: the sysctl table
2717 * @write: %TRUE if this is a write to the sysctl file
2718 * @buffer: the user buffer
2719 * @lenp: the size of the user buffer
2720 * @ppos: pointer to the file position
2722 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2723 * values from/to the user buffer, treated as an ASCII string.
2724 * The values read are assumed to be in 1/USER_HZ seconds, and
2725 * are converted into jiffies.
2727 * Returns 0 on success.
2729 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2730 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2732 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2733 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2737 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2738 * @table: the sysctl table
2739 * @write: %TRUE if this is a write to the sysctl file
2740 * @buffer: the user buffer
2741 * @lenp: the size of the user buffer
2742 * @ppos: file position
2743 * @ppos: the current position in the file
2745 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2746 * values from/to the user buffer, treated as an ASCII string.
2747 * The values read are assumed to be in 1/1000 seconds, and
2748 * are converted into jiffies.
2750 * Returns 0 on success.
2752 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2753 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2755 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2756 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2759 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
2760 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2762 struct pid
*new_pid
;
2766 tmp
= pid_vnr(cad_pid
);
2768 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
2769 lenp
, ppos
, NULL
, NULL
);
2773 new_pid
= find_get_pid(tmp
);
2777 put_pid(xchg(&cad_pid
, new_pid
));
2782 * proc_do_large_bitmap - read/write from/to a large bitmap
2783 * @table: the sysctl table
2784 * @write: %TRUE if this is a write to the sysctl file
2785 * @buffer: the user buffer
2786 * @lenp: the size of the user buffer
2787 * @ppos: file position
2789 * The bitmap is stored at table->data and the bitmap length (in bits)
2792 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2793 * large bitmaps may be represented in a compact manner. Writing into
2794 * the file will clear the bitmap then update it with the given input.
2796 * Returns 0 on success.
2798 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
2799 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2803 size_t left
= *lenp
;
2804 unsigned long bitmap_len
= table
->maxlen
;
2805 unsigned long *bitmap
= *(unsigned long **) table
->data
;
2806 unsigned long *tmp_bitmap
= NULL
;
2807 char tr_a
[] = { '-', ',', '\n' }, tr_b
[] = { ',', '\n', 0 }, c
;
2809 if (!bitmap
|| !bitmap_len
|| !left
|| (*ppos
&& !write
)) {
2817 if (left
> PAGE_SIZE
- 1)
2818 left
= PAGE_SIZE
- 1;
2820 p
= kbuf
= memdup_user_nul(buffer
, left
);
2822 return PTR_ERR(kbuf
);
2824 tmp_bitmap
= kzalloc(BITS_TO_LONGS(bitmap_len
) * sizeof(unsigned long),
2830 proc_skip_char(&p
, &left
, '\n');
2831 while (!err
&& left
) {
2832 unsigned long val_a
, val_b
;
2835 err
= proc_get_long(&p
, &left
, &val_a
, &neg
, tr_a
,
2839 if (val_a
>= bitmap_len
|| neg
) {
2851 err
= proc_get_long(&p
, &left
, &val_b
,
2852 &neg
, tr_b
, sizeof(tr_b
),
2856 if (val_b
>= bitmap_len
|| neg
||
2867 bitmap_set(tmp_bitmap
, val_a
, val_b
- val_a
+ 1);
2869 proc_skip_char(&p
, &left
, '\n');
2873 unsigned long bit_a
, bit_b
= 0;
2876 bit_a
= find_next_bit(bitmap
, bitmap_len
, bit_b
);
2877 if (bit_a
>= bitmap_len
)
2879 bit_b
= find_next_zero_bit(bitmap
, bitmap_len
,
2883 err
= proc_put_char(&buffer
, &left
, ',');
2887 err
= proc_put_long(&buffer
, &left
, bit_a
, false);
2890 if (bit_a
!= bit_b
) {
2891 err
= proc_put_char(&buffer
, &left
, '-');
2894 err
= proc_put_long(&buffer
, &left
, bit_b
, false);
2902 err
= proc_put_char(&buffer
, &left
, '\n');
2908 bitmap_or(bitmap
, bitmap
, tmp_bitmap
, bitmap_len
);
2910 bitmap_copy(bitmap
, tmp_bitmap
, bitmap_len
);
2922 #else /* CONFIG_PROC_SYSCTL */
2924 int proc_dostring(struct ctl_table
*table
, int write
,
2925 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2930 int proc_dointvec(struct ctl_table
*table
, int write
,
2931 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2936 int proc_douintvec(struct ctl_table
*table
, int write
,
2937 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2942 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2943 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2948 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2949 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2954 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2955 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2960 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2961 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2966 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2967 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2972 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2973 void __user
*buffer
,
2974 size_t *lenp
, loff_t
*ppos
)
2980 #endif /* CONFIG_PROC_SYSCTL */
2983 * No sense putting this after each symbol definition, twice,
2984 * exception granted :-)
2986 EXPORT_SYMBOL(proc_dointvec
);
2987 EXPORT_SYMBOL(proc_douintvec
);
2988 EXPORT_SYMBOL(proc_dointvec_jiffies
);
2989 EXPORT_SYMBOL(proc_dointvec_minmax
);
2990 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
2991 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
2992 EXPORT_SYMBOL(proc_dostring
);
2993 EXPORT_SYMBOL(proc_doulongvec_minmax
);
2994 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);