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/kmemleak.h>
35 #include <linux/init.h>
36 #include <linux/kernel.h>
37 #include <linux/kobject.h>
38 #include <linux/net.h>
39 #include <linux/sysrq.h>
40 #include <linux/highuid.h>
41 #include <linux/writeback.h>
42 #include <linux/ratelimit.h>
43 #include <linux/compaction.h>
44 #include <linux/hugetlb.h>
45 #include <linux/initrd.h>
46 #include <linux/key.h>
47 #include <linux/times.h>
48 #include <linux/limits.h>
49 #include <linux/dcache.h>
50 #include <linux/dnotify.h>
51 #include <linux/syscalls.h>
52 #include <linux/vmstat.h>
53 #include <linux/nfs_fs.h>
54 #include <linux/acpi.h>
55 #include <linux/reboot.h>
56 #include <linux/ftrace.h>
57 #include <linux/perf_event.h>
58 #include <linux/kprobes.h>
59 #include <linux/pipe_fs_i.h>
60 #include <linux/oom.h>
61 #include <linux/kmod.h>
62 #include <linux/capability.h>
63 #include <linux/binfmts.h>
64 #include <linux/sched/sysctl.h>
65 #include <linux/sched/coredump.h>
66 #include <linux/kexec.h>
67 #include <linux/bpf.h>
68 #include <linux/mount.h>
70 #include <linux/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 one_ul
= 1;
128 static int one_hundred
= 100;
129 static int one_thousand
= 1000;
131 static int ten_thousand
= 10000;
133 #ifdef CONFIG_PERF_EVENTS
134 static int six_hundred_forty_kb
= 640 * 1024;
137 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
138 static unsigned long dirty_bytes_min
= 2 * PAGE_SIZE
;
140 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
141 static int maxolduid
= 65535;
142 static int minolduid
;
144 static int ngroups_max
= NGROUPS_MAX
;
145 static const int cap_last_cap
= CAP_LAST_CAP
;
147 /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
148 #ifdef CONFIG_DETECT_HUNG_TASK
149 static unsigned long hung_task_timeout_max
= (LONG_MAX
/HZ
);
152 #ifdef CONFIG_INOTIFY_USER
153 #include <linux/inotify.h>
159 extern int pwrsw_enabled
;
162 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
163 extern int unaligned_enabled
;
167 extern int unaligned_dump_stack
;
170 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
171 extern int no_unaligned_warning
;
174 #ifdef CONFIG_PROC_SYSCTL
177 * enum sysctl_writes_mode - supported sysctl write modes
179 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
180 * to be written, and multiple writes on the same sysctl file descriptor
181 * will rewrite the sysctl value, regardless of file position. No warning
182 * is issued when the initial position is not 0.
183 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
185 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
186 * file position 0 and the value must be fully contained in the buffer
187 * sent to the write syscall. If dealing with strings respect the file
188 * position, but restrict this to the max length of the buffer, anything
189 * passed the max lenght will be ignored. Multiple writes will append
192 * These write modes control how current file position affects the behavior of
193 * updating sysctl values through the proc interface on each write.
195 enum sysctl_writes_mode
{
196 SYSCTL_WRITES_LEGACY
= -1,
197 SYSCTL_WRITES_WARN
= 0,
198 SYSCTL_WRITES_STRICT
= 1,
201 static enum sysctl_writes_mode sysctl_writes_strict
= SYSCTL_WRITES_STRICT
;
203 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
204 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
205 static int proc_taint(struct ctl_table
*table
, int write
,
206 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
210 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
211 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
214 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
215 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
216 #ifdef CONFIG_COREDUMP
217 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
218 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
221 #ifdef CONFIG_MAGIC_SYSRQ
222 /* Note: sysrq code uses it's own private copy */
223 static int __sysrq_enabled
= CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE
;
225 static int sysrq_sysctl_handler(struct ctl_table
*table
, int write
,
226 void __user
*buffer
, size_t *lenp
,
231 error
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
236 sysrq_toggle_support(__sysrq_enabled
);
243 static struct ctl_table kern_table
[];
244 static struct ctl_table vm_table
[];
245 static struct ctl_table fs_table
[];
246 static struct ctl_table debug_table
[];
247 static struct ctl_table dev_table
[];
248 extern struct ctl_table random_table
[];
250 extern struct ctl_table epoll_table
[];
253 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
254 int sysctl_legacy_va_layout
;
257 /* The default sysctl tables: */
259 static struct ctl_table sysctl_base_table
[] = {
261 .procname
= "kernel",
278 .child
= debug_table
,
288 #ifdef CONFIG_SCHED_DEBUG
289 static int min_sched_granularity_ns
= 100000; /* 100 usecs */
290 static int max_sched_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
291 static int min_wakeup_granularity_ns
; /* 0 usecs */
292 static int max_wakeup_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
294 static int min_sched_tunable_scaling
= SCHED_TUNABLESCALING_NONE
;
295 static int max_sched_tunable_scaling
= SCHED_TUNABLESCALING_END
-1;
296 #endif /* CONFIG_SMP */
297 #endif /* CONFIG_SCHED_DEBUG */
299 #ifdef CONFIG_COMPACTION
300 static int min_extfrag_threshold
;
301 static int max_extfrag_threshold
= 1000;
304 static struct ctl_table kern_table
[] = {
306 .procname
= "sched_child_runs_first",
307 .data
= &sysctl_sched_child_runs_first
,
308 .maxlen
= sizeof(unsigned int),
310 .proc_handler
= proc_dointvec
,
312 #ifdef CONFIG_SCHED_DEBUG
314 .procname
= "sched_min_granularity_ns",
315 .data
= &sysctl_sched_min_granularity
,
316 .maxlen
= sizeof(unsigned int),
318 .proc_handler
= sched_proc_update_handler
,
319 .extra1
= &min_sched_granularity_ns
,
320 .extra2
= &max_sched_granularity_ns
,
323 .procname
= "sched_latency_ns",
324 .data
= &sysctl_sched_latency
,
325 .maxlen
= sizeof(unsigned int),
327 .proc_handler
= sched_proc_update_handler
,
328 .extra1
= &min_sched_granularity_ns
,
329 .extra2
= &max_sched_granularity_ns
,
332 .procname
= "sched_wakeup_granularity_ns",
333 .data
= &sysctl_sched_wakeup_granularity
,
334 .maxlen
= sizeof(unsigned int),
336 .proc_handler
= sched_proc_update_handler
,
337 .extra1
= &min_wakeup_granularity_ns
,
338 .extra2
= &max_wakeup_granularity_ns
,
342 .procname
= "sched_tunable_scaling",
343 .data
= &sysctl_sched_tunable_scaling
,
344 .maxlen
= sizeof(enum sched_tunable_scaling
),
346 .proc_handler
= sched_proc_update_handler
,
347 .extra1
= &min_sched_tunable_scaling
,
348 .extra2
= &max_sched_tunable_scaling
,
351 .procname
= "sched_migration_cost_ns",
352 .data
= &sysctl_sched_migration_cost
,
353 .maxlen
= sizeof(unsigned int),
355 .proc_handler
= proc_dointvec
,
358 .procname
= "sched_nr_migrate",
359 .data
= &sysctl_sched_nr_migrate
,
360 .maxlen
= sizeof(unsigned int),
362 .proc_handler
= proc_dointvec
,
365 .procname
= "sched_time_avg_ms",
366 .data
= &sysctl_sched_time_avg
,
367 .maxlen
= sizeof(unsigned int),
369 .proc_handler
= proc_dointvec_minmax
,
372 #ifdef CONFIG_SCHEDSTATS
374 .procname
= "sched_schedstats",
376 .maxlen
= sizeof(unsigned int),
378 .proc_handler
= sysctl_schedstats
,
382 #endif /* CONFIG_SCHEDSTATS */
383 #endif /* CONFIG_SMP */
384 #ifdef CONFIG_NUMA_BALANCING
386 .procname
= "numa_balancing_scan_delay_ms",
387 .data
= &sysctl_numa_balancing_scan_delay
,
388 .maxlen
= sizeof(unsigned int),
390 .proc_handler
= proc_dointvec
,
393 .procname
= "numa_balancing_scan_period_min_ms",
394 .data
= &sysctl_numa_balancing_scan_period_min
,
395 .maxlen
= sizeof(unsigned int),
397 .proc_handler
= proc_dointvec
,
400 .procname
= "numa_balancing_scan_period_max_ms",
401 .data
= &sysctl_numa_balancing_scan_period_max
,
402 .maxlen
= sizeof(unsigned int),
404 .proc_handler
= proc_dointvec
,
407 .procname
= "numa_balancing_scan_size_mb",
408 .data
= &sysctl_numa_balancing_scan_size
,
409 .maxlen
= sizeof(unsigned int),
411 .proc_handler
= proc_dointvec_minmax
,
415 .procname
= "numa_balancing",
416 .data
= NULL
, /* filled in by handler */
417 .maxlen
= sizeof(unsigned int),
419 .proc_handler
= sysctl_numa_balancing
,
423 #endif /* CONFIG_NUMA_BALANCING */
424 #endif /* CONFIG_SCHED_DEBUG */
426 .procname
= "sched_rt_period_us",
427 .data
= &sysctl_sched_rt_period
,
428 .maxlen
= sizeof(unsigned int),
430 .proc_handler
= sched_rt_handler
,
433 .procname
= "sched_rt_runtime_us",
434 .data
= &sysctl_sched_rt_runtime
,
435 .maxlen
= sizeof(int),
437 .proc_handler
= sched_rt_handler
,
440 .procname
= "sched_rr_timeslice_ms",
441 .data
= &sysctl_sched_rr_timeslice
,
442 .maxlen
= sizeof(int),
444 .proc_handler
= sched_rr_handler
,
446 #ifdef CONFIG_SCHED_AUTOGROUP
448 .procname
= "sched_autogroup_enabled",
449 .data
= &sysctl_sched_autogroup_enabled
,
450 .maxlen
= sizeof(unsigned int),
452 .proc_handler
= proc_dointvec_minmax
,
457 #ifdef CONFIG_CFS_BANDWIDTH
459 .procname
= "sched_cfs_bandwidth_slice_us",
460 .data
= &sysctl_sched_cfs_bandwidth_slice
,
461 .maxlen
= sizeof(unsigned int),
463 .proc_handler
= proc_dointvec_minmax
,
467 #ifdef CONFIG_PROVE_LOCKING
469 .procname
= "prove_locking",
470 .data
= &prove_locking
,
471 .maxlen
= sizeof(int),
473 .proc_handler
= proc_dointvec
,
476 #ifdef CONFIG_LOCK_STAT
478 .procname
= "lock_stat",
480 .maxlen
= sizeof(int),
482 .proc_handler
= proc_dointvec
,
487 .data
= &panic_timeout
,
488 .maxlen
= sizeof(int),
490 .proc_handler
= proc_dointvec
,
492 #ifdef CONFIG_COREDUMP
494 .procname
= "core_uses_pid",
495 .data
= &core_uses_pid
,
496 .maxlen
= sizeof(int),
498 .proc_handler
= proc_dointvec
,
501 .procname
= "core_pattern",
502 .data
= core_pattern
,
503 .maxlen
= CORENAME_MAX_SIZE
,
505 .proc_handler
= proc_dostring_coredump
,
508 .procname
= "core_pipe_limit",
509 .data
= &core_pipe_limit
,
510 .maxlen
= sizeof(unsigned int),
512 .proc_handler
= proc_dointvec
,
515 #ifdef CONFIG_PROC_SYSCTL
517 .procname
= "tainted",
518 .maxlen
= sizeof(long),
520 .proc_handler
= proc_taint
,
523 .procname
= "sysctl_writes_strict",
524 .data
= &sysctl_writes_strict
,
525 .maxlen
= sizeof(int),
527 .proc_handler
= proc_dointvec_minmax
,
532 #ifdef CONFIG_LATENCYTOP
534 .procname
= "latencytop",
535 .data
= &latencytop_enabled
,
536 .maxlen
= sizeof(int),
538 .proc_handler
= sysctl_latencytop
,
541 #ifdef CONFIG_BLK_DEV_INITRD
543 .procname
= "real-root-dev",
544 .data
= &real_root_dev
,
545 .maxlen
= sizeof(int),
547 .proc_handler
= proc_dointvec
,
551 .procname
= "print-fatal-signals",
552 .data
= &print_fatal_signals
,
553 .maxlen
= sizeof(int),
555 .proc_handler
= proc_dointvec
,
559 .procname
= "reboot-cmd",
560 .data
= reboot_command
,
563 .proc_handler
= proc_dostring
,
566 .procname
= "stop-a",
567 .data
= &stop_a_enabled
,
568 .maxlen
= sizeof (int),
570 .proc_handler
= proc_dointvec
,
573 .procname
= "scons-poweroff",
574 .data
= &scons_pwroff
,
575 .maxlen
= sizeof (int),
577 .proc_handler
= proc_dointvec
,
580 #ifdef CONFIG_SPARC64
582 .procname
= "tsb-ratio",
583 .data
= &sysctl_tsb_ratio
,
584 .maxlen
= sizeof (int),
586 .proc_handler
= proc_dointvec
,
591 .procname
= "soft-power",
592 .data
= &pwrsw_enabled
,
593 .maxlen
= sizeof (int),
595 .proc_handler
= proc_dointvec
,
598 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
600 .procname
= "unaligned-trap",
601 .data
= &unaligned_enabled
,
602 .maxlen
= sizeof (int),
604 .proc_handler
= proc_dointvec
,
608 .procname
= "ctrl-alt-del",
610 .maxlen
= sizeof(int),
612 .proc_handler
= proc_dointvec
,
614 #ifdef CONFIG_FUNCTION_TRACER
616 .procname
= "ftrace_enabled",
617 .data
= &ftrace_enabled
,
618 .maxlen
= sizeof(int),
620 .proc_handler
= ftrace_enable_sysctl
,
623 #ifdef CONFIG_STACK_TRACER
625 .procname
= "stack_tracer_enabled",
626 .data
= &stack_tracer_enabled
,
627 .maxlen
= sizeof(int),
629 .proc_handler
= stack_trace_sysctl
,
632 #ifdef CONFIG_TRACING
634 .procname
= "ftrace_dump_on_oops",
635 .data
= &ftrace_dump_on_oops
,
636 .maxlen
= sizeof(int),
638 .proc_handler
= proc_dointvec
,
641 .procname
= "traceoff_on_warning",
642 .data
= &__disable_trace_on_warning
,
643 .maxlen
= sizeof(__disable_trace_on_warning
),
645 .proc_handler
= proc_dointvec
,
648 .procname
= "tracepoint_printk",
649 .data
= &tracepoint_printk
,
650 .maxlen
= sizeof(tracepoint_printk
),
652 .proc_handler
= tracepoint_printk_sysctl
,
655 #ifdef CONFIG_KEXEC_CORE
657 .procname
= "kexec_load_disabled",
658 .data
= &kexec_load_disabled
,
659 .maxlen
= sizeof(int),
661 /* only handle a transition from default "0" to "1" */
662 .proc_handler
= proc_dointvec_minmax
,
667 #ifdef CONFIG_MODULES
669 .procname
= "modprobe",
670 .data
= &modprobe_path
,
671 .maxlen
= KMOD_PATH_LEN
,
673 .proc_handler
= proc_dostring
,
676 .procname
= "modules_disabled",
677 .data
= &modules_disabled
,
678 .maxlen
= sizeof(int),
680 /* only handle a transition from default "0" to "1" */
681 .proc_handler
= proc_dointvec_minmax
,
686 #ifdef CONFIG_UEVENT_HELPER
688 .procname
= "hotplug",
689 .data
= &uevent_helper
,
690 .maxlen
= UEVENT_HELPER_PATH_LEN
,
692 .proc_handler
= proc_dostring
,
695 #ifdef CONFIG_CHR_DEV_SG
697 .procname
= "sg-big-buff",
698 .data
= &sg_big_buff
,
699 .maxlen
= sizeof (int),
701 .proc_handler
= proc_dointvec
,
704 #ifdef CONFIG_BSD_PROCESS_ACCT
708 .maxlen
= 3*sizeof(int),
710 .proc_handler
= proc_dointvec
,
713 #ifdef CONFIG_MAGIC_SYSRQ
716 .data
= &__sysrq_enabled
,
717 .maxlen
= sizeof (int),
719 .proc_handler
= sysrq_sysctl_handler
,
722 #ifdef CONFIG_PROC_SYSCTL
724 .procname
= "cad_pid",
726 .maxlen
= sizeof (int),
728 .proc_handler
= proc_do_cad_pid
,
732 .procname
= "threads-max",
734 .maxlen
= sizeof(int),
736 .proc_handler
= sysctl_max_threads
,
739 .procname
= "random",
741 .child
= random_table
,
744 .procname
= "usermodehelper",
746 .child
= usermodehelper_table
,
749 .procname
= "overflowuid",
750 .data
= &overflowuid
,
751 .maxlen
= sizeof(int),
753 .proc_handler
= proc_dointvec_minmax
,
754 .extra1
= &minolduid
,
755 .extra2
= &maxolduid
,
758 .procname
= "overflowgid",
759 .data
= &overflowgid
,
760 .maxlen
= sizeof(int),
762 .proc_handler
= proc_dointvec_minmax
,
763 .extra1
= &minolduid
,
764 .extra2
= &maxolduid
,
767 #ifdef CONFIG_MATHEMU
769 .procname
= "ieee_emulation_warnings",
770 .data
= &sysctl_ieee_emulation_warnings
,
771 .maxlen
= sizeof(int),
773 .proc_handler
= proc_dointvec
,
777 .procname
= "userprocess_debug",
778 .data
= &show_unhandled_signals
,
779 .maxlen
= sizeof(int),
781 .proc_handler
= proc_dointvec
,
785 .procname
= "pid_max",
787 .maxlen
= sizeof (int),
789 .proc_handler
= proc_dointvec_minmax
,
790 .extra1
= &pid_max_min
,
791 .extra2
= &pid_max_max
,
794 .procname
= "panic_on_oops",
795 .data
= &panic_on_oops
,
796 .maxlen
= sizeof(int),
798 .proc_handler
= proc_dointvec
,
800 #if defined CONFIG_PRINTK
802 .procname
= "printk",
803 .data
= &console_loglevel
,
804 .maxlen
= 4*sizeof(int),
806 .proc_handler
= proc_dointvec
,
809 .procname
= "printk_ratelimit",
810 .data
= &printk_ratelimit_state
.interval
,
811 .maxlen
= sizeof(int),
813 .proc_handler
= proc_dointvec_jiffies
,
816 .procname
= "printk_ratelimit_burst",
817 .data
= &printk_ratelimit_state
.burst
,
818 .maxlen
= sizeof(int),
820 .proc_handler
= proc_dointvec
,
823 .procname
= "printk_delay",
824 .data
= &printk_delay_msec
,
825 .maxlen
= sizeof(int),
827 .proc_handler
= proc_dointvec_minmax
,
829 .extra2
= &ten_thousand
,
832 .procname
= "printk_devkmsg",
833 .data
= devkmsg_log_str
,
834 .maxlen
= DEVKMSG_STR_MAX_SIZE
,
836 .proc_handler
= devkmsg_sysctl_set_loglvl
,
839 .procname
= "dmesg_restrict",
840 .data
= &dmesg_restrict
,
841 .maxlen
= sizeof(int),
843 .proc_handler
= proc_dointvec_minmax_sysadmin
,
848 .procname
= "kptr_restrict",
849 .data
= &kptr_restrict
,
850 .maxlen
= sizeof(int),
852 .proc_handler
= proc_dointvec_minmax_sysadmin
,
858 .procname
= "ngroups_max",
859 .data
= &ngroups_max
,
860 .maxlen
= sizeof (int),
862 .proc_handler
= proc_dointvec
,
865 .procname
= "cap_last_cap",
866 .data
= (void *)&cap_last_cap
,
867 .maxlen
= sizeof(int),
869 .proc_handler
= proc_dointvec
,
871 #if defined(CONFIG_LOCKUP_DETECTOR)
873 .procname
= "watchdog",
874 .data
= &watchdog_user_enabled
,
875 .maxlen
= sizeof(int),
877 .proc_handler
= proc_watchdog
,
882 .procname
= "watchdog_thresh",
883 .data
= &watchdog_thresh
,
884 .maxlen
= sizeof(int),
886 .proc_handler
= proc_watchdog_thresh
,
891 .procname
= "nmi_watchdog",
892 .data
= &nmi_watchdog_user_enabled
,
893 .maxlen
= sizeof(int),
894 .mode
= NMI_WATCHDOG_SYSCTL_PERM
,
895 .proc_handler
= proc_nmi_watchdog
,
900 .procname
= "watchdog_cpumask",
901 .data
= &watchdog_cpumask_bits
,
904 .proc_handler
= proc_watchdog_cpumask
,
906 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
908 .procname
= "soft_watchdog",
909 .data
= &soft_watchdog_user_enabled
,
910 .maxlen
= sizeof(int),
912 .proc_handler
= proc_soft_watchdog
,
917 .procname
= "softlockup_panic",
918 .data
= &softlockup_panic
,
919 .maxlen
= sizeof(int),
921 .proc_handler
= proc_dointvec_minmax
,
927 .procname
= "softlockup_all_cpu_backtrace",
928 .data
= &sysctl_softlockup_all_cpu_backtrace
,
929 .maxlen
= sizeof(int),
931 .proc_handler
= proc_dointvec_minmax
,
935 #endif /* CONFIG_SMP */
937 #ifdef CONFIG_HARDLOCKUP_DETECTOR
939 .procname
= "hardlockup_panic",
940 .data
= &hardlockup_panic
,
941 .maxlen
= sizeof(int),
943 .proc_handler
= proc_dointvec_minmax
,
949 .procname
= "hardlockup_all_cpu_backtrace",
950 .data
= &sysctl_hardlockup_all_cpu_backtrace
,
951 .maxlen
= sizeof(int),
953 .proc_handler
= proc_dointvec_minmax
,
957 #endif /* CONFIG_SMP */
961 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
963 .procname
= "unknown_nmi_panic",
964 .data
= &unknown_nmi_panic
,
965 .maxlen
= sizeof (int),
967 .proc_handler
= proc_dointvec
,
970 #if defined(CONFIG_X86)
972 .procname
= "panic_on_unrecovered_nmi",
973 .data
= &panic_on_unrecovered_nmi
,
974 .maxlen
= sizeof(int),
976 .proc_handler
= proc_dointvec
,
979 .procname
= "panic_on_io_nmi",
980 .data
= &panic_on_io_nmi
,
981 .maxlen
= sizeof(int),
983 .proc_handler
= proc_dointvec
,
985 #ifdef CONFIG_DEBUG_STACKOVERFLOW
987 .procname
= "panic_on_stackoverflow",
988 .data
= &sysctl_panic_on_stackoverflow
,
989 .maxlen
= sizeof(int),
991 .proc_handler
= proc_dointvec
,
995 .procname
= "bootloader_type",
996 .data
= &bootloader_type
,
997 .maxlen
= sizeof (int),
999 .proc_handler
= proc_dointvec
,
1002 .procname
= "bootloader_version",
1003 .data
= &bootloader_version
,
1004 .maxlen
= sizeof (int),
1006 .proc_handler
= proc_dointvec
,
1009 .procname
= "io_delay_type",
1010 .data
= &io_delay_type
,
1011 .maxlen
= sizeof(int),
1013 .proc_handler
= proc_dointvec
,
1016 #if defined(CONFIG_MMU)
1018 .procname
= "randomize_va_space",
1019 .data
= &randomize_va_space
,
1020 .maxlen
= sizeof(int),
1022 .proc_handler
= proc_dointvec
,
1025 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1027 .procname
= "spin_retry",
1028 .data
= &spin_retry
,
1029 .maxlen
= sizeof (int),
1031 .proc_handler
= proc_dointvec
,
1034 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1036 .procname
= "acpi_video_flags",
1037 .data
= &acpi_realmode_flags
,
1038 .maxlen
= sizeof (unsigned long),
1040 .proc_handler
= proc_doulongvec_minmax
,
1043 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1045 .procname
= "ignore-unaligned-usertrap",
1046 .data
= &no_unaligned_warning
,
1047 .maxlen
= sizeof (int),
1049 .proc_handler
= proc_dointvec
,
1054 .procname
= "unaligned-dump-stack",
1055 .data
= &unaligned_dump_stack
,
1056 .maxlen
= sizeof (int),
1058 .proc_handler
= proc_dointvec
,
1061 #ifdef CONFIG_DETECT_HUNG_TASK
1063 .procname
= "hung_task_panic",
1064 .data
= &sysctl_hung_task_panic
,
1065 .maxlen
= sizeof(int),
1067 .proc_handler
= proc_dointvec_minmax
,
1072 .procname
= "hung_task_check_count",
1073 .data
= &sysctl_hung_task_check_count
,
1074 .maxlen
= sizeof(int),
1076 .proc_handler
= proc_dointvec_minmax
,
1080 .procname
= "hung_task_timeout_secs",
1081 .data
= &sysctl_hung_task_timeout_secs
,
1082 .maxlen
= sizeof(unsigned long),
1084 .proc_handler
= proc_dohung_task_timeout_secs
,
1085 .extra2
= &hung_task_timeout_max
,
1088 .procname
= "hung_task_warnings",
1089 .data
= &sysctl_hung_task_warnings
,
1090 .maxlen
= sizeof(int),
1092 .proc_handler
= proc_dointvec_minmax
,
1096 #ifdef CONFIG_RT_MUTEXES
1098 .procname
= "max_lock_depth",
1099 .data
= &max_lock_depth
,
1100 .maxlen
= sizeof(int),
1102 .proc_handler
= proc_dointvec
,
1106 .procname
= "poweroff_cmd",
1107 .data
= &poweroff_cmd
,
1108 .maxlen
= POWEROFF_CMD_PATH_LEN
,
1110 .proc_handler
= proc_dostring
,
1116 .child
= key_sysctls
,
1119 #ifdef CONFIG_PERF_EVENTS
1121 * User-space scripts rely on the existence of this file
1122 * as a feature check for perf_events being enabled.
1124 * So it's an ABI, do not remove!
1127 .procname
= "perf_event_paranoid",
1128 .data
= &sysctl_perf_event_paranoid
,
1129 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
1131 .proc_handler
= proc_dointvec
,
1134 .procname
= "perf_event_mlock_kb",
1135 .data
= &sysctl_perf_event_mlock
,
1136 .maxlen
= sizeof(sysctl_perf_event_mlock
),
1138 .proc_handler
= proc_dointvec
,
1141 .procname
= "perf_event_max_sample_rate",
1142 .data
= &sysctl_perf_event_sample_rate
,
1143 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1145 .proc_handler
= perf_proc_update_handler
,
1149 .procname
= "perf_cpu_time_max_percent",
1150 .data
= &sysctl_perf_cpu_time_max_percent
,
1151 .maxlen
= sizeof(sysctl_perf_cpu_time_max_percent
),
1153 .proc_handler
= perf_cpu_time_max_percent_handler
,
1155 .extra2
= &one_hundred
,
1158 .procname
= "perf_event_max_stack",
1159 .data
= &sysctl_perf_event_max_stack
,
1160 .maxlen
= sizeof(sysctl_perf_event_max_stack
),
1162 .proc_handler
= perf_event_max_stack_handler
,
1164 .extra2
= &six_hundred_forty_kb
,
1167 .procname
= "perf_event_max_contexts_per_stack",
1168 .data
= &sysctl_perf_event_max_contexts_per_stack
,
1169 .maxlen
= sizeof(sysctl_perf_event_max_contexts_per_stack
),
1171 .proc_handler
= perf_event_max_stack_handler
,
1173 .extra2
= &one_thousand
,
1177 .procname
= "panic_on_warn",
1178 .data
= &panic_on_warn
,
1179 .maxlen
= sizeof(int),
1181 .proc_handler
= proc_dointvec_minmax
,
1185 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1187 .procname
= "timer_migration",
1188 .data
= &sysctl_timer_migration
,
1189 .maxlen
= sizeof(unsigned int),
1191 .proc_handler
= timer_migration_handler
,
1196 #ifdef CONFIG_BPF_SYSCALL
1198 .procname
= "unprivileged_bpf_disabled",
1199 .data
= &sysctl_unprivileged_bpf_disabled
,
1200 .maxlen
= sizeof(sysctl_unprivileged_bpf_disabled
),
1202 /* only handle a transition from default "0" to "1" */
1203 .proc_handler
= proc_dointvec_minmax
,
1208 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1210 .procname
= "panic_on_rcu_stall",
1211 .data
= &sysctl_panic_on_rcu_stall
,
1212 .maxlen
= sizeof(sysctl_panic_on_rcu_stall
),
1214 .proc_handler
= proc_dointvec_minmax
,
1222 static struct ctl_table vm_table
[] = {
1224 .procname
= "overcommit_memory",
1225 .data
= &sysctl_overcommit_memory
,
1226 .maxlen
= sizeof(sysctl_overcommit_memory
),
1228 .proc_handler
= proc_dointvec_minmax
,
1233 .procname
= "panic_on_oom",
1234 .data
= &sysctl_panic_on_oom
,
1235 .maxlen
= sizeof(sysctl_panic_on_oom
),
1237 .proc_handler
= proc_dointvec_minmax
,
1242 .procname
= "oom_kill_allocating_task",
1243 .data
= &sysctl_oom_kill_allocating_task
,
1244 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
1246 .proc_handler
= proc_dointvec
,
1249 .procname
= "oom_dump_tasks",
1250 .data
= &sysctl_oom_dump_tasks
,
1251 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
1253 .proc_handler
= proc_dointvec
,
1256 .procname
= "overcommit_ratio",
1257 .data
= &sysctl_overcommit_ratio
,
1258 .maxlen
= sizeof(sysctl_overcommit_ratio
),
1260 .proc_handler
= overcommit_ratio_handler
,
1263 .procname
= "overcommit_kbytes",
1264 .data
= &sysctl_overcommit_kbytes
,
1265 .maxlen
= sizeof(sysctl_overcommit_kbytes
),
1267 .proc_handler
= overcommit_kbytes_handler
,
1270 .procname
= "page-cluster",
1271 .data
= &page_cluster
,
1272 .maxlen
= sizeof(int),
1274 .proc_handler
= proc_dointvec_minmax
,
1278 .procname
= "dirty_background_ratio",
1279 .data
= &dirty_background_ratio
,
1280 .maxlen
= sizeof(dirty_background_ratio
),
1282 .proc_handler
= dirty_background_ratio_handler
,
1284 .extra2
= &one_hundred
,
1287 .procname
= "dirty_background_bytes",
1288 .data
= &dirty_background_bytes
,
1289 .maxlen
= sizeof(dirty_background_bytes
),
1291 .proc_handler
= dirty_background_bytes_handler
,
1295 .procname
= "dirty_ratio",
1296 .data
= &vm_dirty_ratio
,
1297 .maxlen
= sizeof(vm_dirty_ratio
),
1299 .proc_handler
= dirty_ratio_handler
,
1301 .extra2
= &one_hundred
,
1304 .procname
= "dirty_bytes",
1305 .data
= &vm_dirty_bytes
,
1306 .maxlen
= sizeof(vm_dirty_bytes
),
1308 .proc_handler
= dirty_bytes_handler
,
1309 .extra1
= &dirty_bytes_min
,
1312 .procname
= "dirty_writeback_centisecs",
1313 .data
= &dirty_writeback_interval
,
1314 .maxlen
= sizeof(dirty_writeback_interval
),
1316 .proc_handler
= dirty_writeback_centisecs_handler
,
1319 .procname
= "dirty_expire_centisecs",
1320 .data
= &dirty_expire_interval
,
1321 .maxlen
= sizeof(dirty_expire_interval
),
1323 .proc_handler
= proc_dointvec_minmax
,
1327 .procname
= "dirtytime_expire_seconds",
1328 .data
= &dirtytime_expire_interval
,
1329 .maxlen
= sizeof(dirty_expire_interval
),
1331 .proc_handler
= dirtytime_interval_handler
,
1335 .procname
= "nr_pdflush_threads",
1336 .mode
= 0444 /* read-only */,
1337 .proc_handler
= pdflush_proc_obsolete
,
1340 .procname
= "swappiness",
1341 .data
= &vm_swappiness
,
1342 .maxlen
= sizeof(vm_swappiness
),
1344 .proc_handler
= proc_dointvec_minmax
,
1346 .extra2
= &one_hundred
,
1348 #ifdef CONFIG_HUGETLB_PAGE
1350 .procname
= "nr_hugepages",
1352 .maxlen
= sizeof(unsigned long),
1354 .proc_handler
= hugetlb_sysctl_handler
,
1358 .procname
= "nr_hugepages_mempolicy",
1360 .maxlen
= sizeof(unsigned long),
1362 .proc_handler
= &hugetlb_mempolicy_sysctl_handler
,
1366 .procname
= "hugetlb_shm_group",
1367 .data
= &sysctl_hugetlb_shm_group
,
1368 .maxlen
= sizeof(gid_t
),
1370 .proc_handler
= proc_dointvec
,
1373 .procname
= "hugepages_treat_as_movable",
1374 .data
= &hugepages_treat_as_movable
,
1375 .maxlen
= sizeof(int),
1377 .proc_handler
= proc_dointvec
,
1380 .procname
= "nr_overcommit_hugepages",
1382 .maxlen
= sizeof(unsigned long),
1384 .proc_handler
= hugetlb_overcommit_handler
,
1388 .procname
= "lowmem_reserve_ratio",
1389 .data
= &sysctl_lowmem_reserve_ratio
,
1390 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
1392 .proc_handler
= lowmem_reserve_ratio_sysctl_handler
,
1395 .procname
= "drop_caches",
1396 .data
= &sysctl_drop_caches
,
1397 .maxlen
= sizeof(int),
1399 .proc_handler
= drop_caches_sysctl_handler
,
1403 #ifdef CONFIG_COMPACTION
1405 .procname
= "compact_memory",
1406 .data
= &sysctl_compact_memory
,
1407 .maxlen
= sizeof(int),
1409 .proc_handler
= sysctl_compaction_handler
,
1412 .procname
= "extfrag_threshold",
1413 .data
= &sysctl_extfrag_threshold
,
1414 .maxlen
= sizeof(int),
1416 .proc_handler
= sysctl_extfrag_handler
,
1417 .extra1
= &min_extfrag_threshold
,
1418 .extra2
= &max_extfrag_threshold
,
1421 .procname
= "compact_unevictable_allowed",
1422 .data
= &sysctl_compact_unevictable_allowed
,
1423 .maxlen
= sizeof(int),
1425 .proc_handler
= proc_dointvec
,
1430 #endif /* CONFIG_COMPACTION */
1432 .procname
= "min_free_kbytes",
1433 .data
= &min_free_kbytes
,
1434 .maxlen
= sizeof(min_free_kbytes
),
1436 .proc_handler
= min_free_kbytes_sysctl_handler
,
1440 .procname
= "watermark_scale_factor",
1441 .data
= &watermark_scale_factor
,
1442 .maxlen
= sizeof(watermark_scale_factor
),
1444 .proc_handler
= watermark_scale_factor_sysctl_handler
,
1446 .extra2
= &one_thousand
,
1449 .procname
= "percpu_pagelist_fraction",
1450 .data
= &percpu_pagelist_fraction
,
1451 .maxlen
= sizeof(percpu_pagelist_fraction
),
1453 .proc_handler
= percpu_pagelist_fraction_sysctl_handler
,
1458 .procname
= "max_map_count",
1459 .data
= &sysctl_max_map_count
,
1460 .maxlen
= sizeof(sysctl_max_map_count
),
1462 .proc_handler
= proc_dointvec_minmax
,
1467 .procname
= "nr_trim_pages",
1468 .data
= &sysctl_nr_trim_pages
,
1469 .maxlen
= sizeof(sysctl_nr_trim_pages
),
1471 .proc_handler
= proc_dointvec_minmax
,
1476 .procname
= "laptop_mode",
1477 .data
= &laptop_mode
,
1478 .maxlen
= sizeof(laptop_mode
),
1480 .proc_handler
= proc_dointvec_jiffies
,
1483 .procname
= "block_dump",
1484 .data
= &block_dump
,
1485 .maxlen
= sizeof(block_dump
),
1487 .proc_handler
= proc_dointvec
,
1491 .procname
= "vfs_cache_pressure",
1492 .data
= &sysctl_vfs_cache_pressure
,
1493 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1495 .proc_handler
= proc_dointvec
,
1498 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1500 .procname
= "legacy_va_layout",
1501 .data
= &sysctl_legacy_va_layout
,
1502 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1504 .proc_handler
= proc_dointvec
,
1510 .procname
= "zone_reclaim_mode",
1511 .data
= &node_reclaim_mode
,
1512 .maxlen
= sizeof(node_reclaim_mode
),
1514 .proc_handler
= proc_dointvec
,
1518 .procname
= "min_unmapped_ratio",
1519 .data
= &sysctl_min_unmapped_ratio
,
1520 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1522 .proc_handler
= sysctl_min_unmapped_ratio_sysctl_handler
,
1524 .extra2
= &one_hundred
,
1527 .procname
= "min_slab_ratio",
1528 .data
= &sysctl_min_slab_ratio
,
1529 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1531 .proc_handler
= sysctl_min_slab_ratio_sysctl_handler
,
1533 .extra2
= &one_hundred
,
1538 .procname
= "stat_interval",
1539 .data
= &sysctl_stat_interval
,
1540 .maxlen
= sizeof(sysctl_stat_interval
),
1542 .proc_handler
= proc_dointvec_jiffies
,
1545 .procname
= "stat_refresh",
1549 .proc_handler
= vmstat_refresh
,
1554 .procname
= "mmap_min_addr",
1555 .data
= &dac_mmap_min_addr
,
1556 .maxlen
= sizeof(unsigned long),
1558 .proc_handler
= mmap_min_addr_handler
,
1563 .procname
= "numa_zonelist_order",
1564 .data
= &numa_zonelist_order
,
1565 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1567 .proc_handler
= numa_zonelist_order_handler
,
1570 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1571 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1573 .procname
= "vdso_enabled",
1574 #ifdef CONFIG_X86_32
1575 .data
= &vdso32_enabled
,
1576 .maxlen
= sizeof(vdso32_enabled
),
1578 .data
= &vdso_enabled
,
1579 .maxlen
= sizeof(vdso_enabled
),
1582 .proc_handler
= proc_dointvec
,
1586 #ifdef CONFIG_HIGHMEM
1588 .procname
= "highmem_is_dirtyable",
1589 .data
= &vm_highmem_is_dirtyable
,
1590 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
1592 .proc_handler
= proc_dointvec_minmax
,
1597 #ifdef CONFIG_MEMORY_FAILURE
1599 .procname
= "memory_failure_early_kill",
1600 .data
= &sysctl_memory_failure_early_kill
,
1601 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
1603 .proc_handler
= proc_dointvec_minmax
,
1608 .procname
= "memory_failure_recovery",
1609 .data
= &sysctl_memory_failure_recovery
,
1610 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
1612 .proc_handler
= proc_dointvec_minmax
,
1618 .procname
= "user_reserve_kbytes",
1619 .data
= &sysctl_user_reserve_kbytes
,
1620 .maxlen
= sizeof(sysctl_user_reserve_kbytes
),
1622 .proc_handler
= proc_doulongvec_minmax
,
1625 .procname
= "admin_reserve_kbytes",
1626 .data
= &sysctl_admin_reserve_kbytes
,
1627 .maxlen
= sizeof(sysctl_admin_reserve_kbytes
),
1629 .proc_handler
= proc_doulongvec_minmax
,
1631 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1633 .procname
= "mmap_rnd_bits",
1634 .data
= &mmap_rnd_bits
,
1635 .maxlen
= sizeof(mmap_rnd_bits
),
1637 .proc_handler
= proc_dointvec_minmax
,
1638 .extra1
= (void *)&mmap_rnd_bits_min
,
1639 .extra2
= (void *)&mmap_rnd_bits_max
,
1642 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1644 .procname
= "mmap_rnd_compat_bits",
1645 .data
= &mmap_rnd_compat_bits
,
1646 .maxlen
= sizeof(mmap_rnd_compat_bits
),
1648 .proc_handler
= proc_dointvec_minmax
,
1649 .extra1
= (void *)&mmap_rnd_compat_bits_min
,
1650 .extra2
= (void *)&mmap_rnd_compat_bits_max
,
1656 static struct ctl_table fs_table
[] = {
1658 .procname
= "inode-nr",
1659 .data
= &inodes_stat
,
1660 .maxlen
= 2*sizeof(long),
1662 .proc_handler
= proc_nr_inodes
,
1665 .procname
= "inode-state",
1666 .data
= &inodes_stat
,
1667 .maxlen
= 7*sizeof(long),
1669 .proc_handler
= proc_nr_inodes
,
1672 .procname
= "file-nr",
1673 .data
= &files_stat
,
1674 .maxlen
= sizeof(files_stat
),
1676 .proc_handler
= proc_nr_files
,
1679 .procname
= "file-max",
1680 .data
= &files_stat
.max_files
,
1681 .maxlen
= sizeof(files_stat
.max_files
),
1683 .proc_handler
= proc_doulongvec_minmax
,
1686 .procname
= "nr_open",
1687 .data
= &sysctl_nr_open
,
1688 .maxlen
= sizeof(unsigned int),
1690 .proc_handler
= proc_dointvec_minmax
,
1691 .extra1
= &sysctl_nr_open_min
,
1692 .extra2
= &sysctl_nr_open_max
,
1695 .procname
= "dentry-state",
1696 .data
= &dentry_stat
,
1697 .maxlen
= 6*sizeof(long),
1699 .proc_handler
= proc_nr_dentry
,
1702 .procname
= "overflowuid",
1703 .data
= &fs_overflowuid
,
1704 .maxlen
= sizeof(int),
1706 .proc_handler
= proc_dointvec_minmax
,
1707 .extra1
= &minolduid
,
1708 .extra2
= &maxolduid
,
1711 .procname
= "overflowgid",
1712 .data
= &fs_overflowgid
,
1713 .maxlen
= sizeof(int),
1715 .proc_handler
= proc_dointvec_minmax
,
1716 .extra1
= &minolduid
,
1717 .extra2
= &maxolduid
,
1719 #ifdef CONFIG_FILE_LOCKING
1721 .procname
= "leases-enable",
1722 .data
= &leases_enable
,
1723 .maxlen
= sizeof(int),
1725 .proc_handler
= proc_dointvec
,
1728 #ifdef CONFIG_DNOTIFY
1730 .procname
= "dir-notify-enable",
1731 .data
= &dir_notify_enable
,
1732 .maxlen
= sizeof(int),
1734 .proc_handler
= proc_dointvec
,
1738 #ifdef CONFIG_FILE_LOCKING
1740 .procname
= "lease-break-time",
1741 .data
= &lease_break_time
,
1742 .maxlen
= sizeof(int),
1744 .proc_handler
= proc_dointvec
,
1749 .procname
= "aio-nr",
1751 .maxlen
= sizeof(aio_nr
),
1753 .proc_handler
= proc_doulongvec_minmax
,
1756 .procname
= "aio-max-nr",
1757 .data
= &aio_max_nr
,
1758 .maxlen
= sizeof(aio_max_nr
),
1760 .proc_handler
= proc_doulongvec_minmax
,
1762 #endif /* CONFIG_AIO */
1763 #ifdef CONFIG_INOTIFY_USER
1765 .procname
= "inotify",
1767 .child
= inotify_table
,
1772 .procname
= "epoll",
1774 .child
= epoll_table
,
1779 .procname
= "protected_symlinks",
1780 .data
= &sysctl_protected_symlinks
,
1781 .maxlen
= sizeof(int),
1783 .proc_handler
= proc_dointvec_minmax
,
1788 .procname
= "protected_hardlinks",
1789 .data
= &sysctl_protected_hardlinks
,
1790 .maxlen
= sizeof(int),
1792 .proc_handler
= proc_dointvec_minmax
,
1797 .procname
= "protected_fifos",
1798 .data
= &sysctl_protected_fifos
,
1799 .maxlen
= sizeof(int),
1801 .proc_handler
= proc_dointvec_minmax
,
1806 .procname
= "protected_regular",
1807 .data
= &sysctl_protected_regular
,
1808 .maxlen
= sizeof(int),
1810 .proc_handler
= proc_dointvec_minmax
,
1815 .procname
= "suid_dumpable",
1816 .data
= &suid_dumpable
,
1817 .maxlen
= sizeof(int),
1819 .proc_handler
= proc_dointvec_minmax_coredump
,
1823 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1825 .procname
= "binfmt_misc",
1827 .child
= sysctl_mount_point
,
1831 .procname
= "pipe-max-size",
1832 .data
= &pipe_max_size
,
1833 .maxlen
= sizeof(pipe_max_size
),
1835 .proc_handler
= &pipe_proc_fn
,
1836 .extra1
= &pipe_min_size
,
1839 .procname
= "pipe-user-pages-hard",
1840 .data
= &pipe_user_pages_hard
,
1841 .maxlen
= sizeof(pipe_user_pages_hard
),
1843 .proc_handler
= proc_doulongvec_minmax
,
1846 .procname
= "pipe-user-pages-soft",
1847 .data
= &pipe_user_pages_soft
,
1848 .maxlen
= sizeof(pipe_user_pages_soft
),
1850 .proc_handler
= proc_doulongvec_minmax
,
1853 .procname
= "mount-max",
1854 .data
= &sysctl_mount_max
,
1855 .maxlen
= sizeof(unsigned int),
1857 .proc_handler
= proc_dointvec_minmax
,
1863 static struct ctl_table debug_table
[] = {
1864 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1866 .procname
= "exception-trace",
1867 .data
= &show_unhandled_signals
,
1868 .maxlen
= sizeof(int),
1870 .proc_handler
= proc_dointvec
1873 #if defined(CONFIG_OPTPROBES)
1875 .procname
= "kprobes-optimization",
1876 .data
= &sysctl_kprobes_optimization
,
1877 .maxlen
= sizeof(int),
1879 .proc_handler
= proc_kprobes_optimization_handler
,
1887 static struct ctl_table dev_table
[] = {
1891 int __init
sysctl_init(void)
1893 struct ctl_table_header
*hdr
;
1895 hdr
= register_sysctl_table(sysctl_base_table
);
1896 kmemleak_not_leak(hdr
);
1900 #endif /* CONFIG_SYSCTL */
1906 #ifdef CONFIG_PROC_SYSCTL
1908 static int _proc_do_string(char *data
, int maxlen
, int write
,
1909 char __user
*buffer
,
1910 size_t *lenp
, loff_t
*ppos
)
1916 if (!data
|| !maxlen
|| !*lenp
) {
1922 if (sysctl_writes_strict
== SYSCTL_WRITES_STRICT
) {
1923 /* Only continue writes not past the end of buffer. */
1925 if (len
> maxlen
- 1)
1932 /* Start writing from beginning of buffer. */
1938 while ((p
- buffer
) < *lenp
&& len
< maxlen
- 1) {
1939 if (get_user(c
, p
++))
1941 if (c
== 0 || c
== '\n')
1962 if (copy_to_user(buffer
, data
, len
))
1965 if (put_user('\n', buffer
+ len
))
1975 static void warn_sysctl_write(struct ctl_table
*table
)
1977 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1978 "This will not be supported in the future. To silence this\n"
1979 "warning, set kernel.sysctl_writes_strict = -1\n",
1980 current
->comm
, table
->procname
);
1984 * proc_first_pos_non_zero_ignore - check if firs position is allowed
1985 * @ppos: file position
1986 * @table: the sysctl table
1988 * Returns true if the first position is non-zero and the sysctl_writes_strict
1989 * mode indicates this is not allowed for numeric input types. String proc
1990 * hadlers can ignore the return value.
1992 static bool proc_first_pos_non_zero_ignore(loff_t
*ppos
,
1993 struct ctl_table
*table
)
1998 switch (sysctl_writes_strict
) {
1999 case SYSCTL_WRITES_STRICT
:
2001 case SYSCTL_WRITES_WARN
:
2002 warn_sysctl_write(table
);
2010 * proc_dostring - read a string sysctl
2011 * @table: the sysctl table
2012 * @write: %TRUE if this is a write to the sysctl file
2013 * @buffer: the user buffer
2014 * @lenp: the size of the user buffer
2015 * @ppos: file position
2017 * Reads/writes a string from/to the user buffer. If the kernel
2018 * buffer provided is not large enough to hold the string, the
2019 * string is truncated. The copied string is %NULL-terminated.
2020 * If the string is being read by the user process, it is copied
2021 * and a newline '\n' is added. It is truncated if the buffer is
2024 * Returns 0 on success.
2026 int proc_dostring(struct ctl_table
*table
, int write
,
2027 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2030 proc_first_pos_non_zero_ignore(ppos
, table
);
2032 return _proc_do_string((char *)(table
->data
), table
->maxlen
, write
,
2033 (char __user
*)buffer
, lenp
, ppos
);
2036 static size_t proc_skip_spaces(char **buf
)
2039 char *tmp
= skip_spaces(*buf
);
2045 static void proc_skip_char(char **buf
, size_t *size
, const char v
)
2055 #define TMPBUFLEN 22
2057 * proc_get_long - reads an ASCII formatted integer from a user buffer
2059 * @buf: a kernel buffer
2060 * @size: size of the kernel buffer
2061 * @val: this is where the number will be stored
2062 * @neg: set to %TRUE if number is negative
2063 * @perm_tr: a vector which contains the allowed trailers
2064 * @perm_tr_len: size of the perm_tr vector
2065 * @tr: pointer to store the trailer character
2067 * In case of success %0 is returned and @buf and @size are updated with
2068 * the amount of bytes read. If @tr is non-NULL and a trailing
2069 * character exists (size is non-zero after returning from this
2070 * function), @tr is updated with the trailing character.
2072 static int proc_get_long(char **buf
, size_t *size
,
2073 unsigned long *val
, bool *neg
,
2074 const char *perm_tr
, unsigned perm_tr_len
, char *tr
)
2077 char *p
, tmp
[TMPBUFLEN
];
2083 if (len
> TMPBUFLEN
- 1)
2084 len
= TMPBUFLEN
- 1;
2086 memcpy(tmp
, *buf
, len
);
2090 if (*p
== '-' && *size
> 1) {
2098 *val
= simple_strtoul(p
, &p
, 0);
2102 /* We don't know if the next char is whitespace thus we may accept
2103 * invalid integers (e.g. 1234...a) or two integers instead of one
2104 * (e.g. 123...1). So lets not allow such large numbers. */
2105 if (len
== TMPBUFLEN
- 1)
2108 if (len
< *size
&& perm_tr_len
&& !memchr(perm_tr
, *p
, perm_tr_len
))
2111 if (tr
&& (len
< *size
))
2121 * proc_put_long - converts an integer to a decimal ASCII formatted string
2123 * @buf: the user buffer
2124 * @size: the size of the user buffer
2125 * @val: the integer to be converted
2126 * @neg: sign of the number, %TRUE for negative
2128 * In case of success %0 is returned and @buf and @size are updated with
2129 * the amount of bytes written.
2131 static int proc_put_long(void __user
**buf
, size_t *size
, unsigned long val
,
2135 char tmp
[TMPBUFLEN
], *p
= tmp
;
2137 sprintf(p
, "%s%lu", neg
? "-" : "", val
);
2141 if (copy_to_user(*buf
, tmp
, len
))
2149 static int proc_put_char(void __user
**buf
, size_t *size
, char c
)
2152 char __user
**buffer
= (char __user
**)buf
;
2153 if (put_user(c
, *buffer
))
2155 (*size
)--, (*buffer
)++;
2161 static int do_proc_dointvec_conv(bool *negp
, unsigned long *lvalp
,
2163 int write
, void *data
)
2167 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2171 if (*lvalp
> (unsigned long) INT_MAX
)
2179 *lvalp
= -(unsigned long)val
;
2182 *lvalp
= (unsigned long)val
;
2188 static int do_proc_douintvec_conv(unsigned long *lvalp
,
2190 int write
, void *data
)
2193 if (*lvalp
> UINT_MAX
)
2197 unsigned int val
= *valp
;
2198 *lvalp
= (unsigned long)val
;
2203 static const char proc_wspace_sep
[] = { ' ', '\t', '\n' };
2205 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2206 int write
, void __user
*buffer
,
2207 size_t *lenp
, loff_t
*ppos
,
2208 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2209 int write
, void *data
),
2212 int *i
, vleft
, first
= 1, err
= 0;
2214 char *kbuf
= NULL
, *p
;
2216 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2221 i
= (int *) tbl_data
;
2222 vleft
= table
->maxlen
/ sizeof(*i
);
2226 conv
= do_proc_dointvec_conv
;
2229 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2232 if (left
> PAGE_SIZE
- 1)
2233 left
= PAGE_SIZE
- 1;
2234 p
= kbuf
= memdup_user_nul(buffer
, left
);
2236 return PTR_ERR(kbuf
);
2239 for (; left
&& vleft
--; i
++, first
=0) {
2244 left
-= proc_skip_spaces(&p
);
2248 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2250 sizeof(proc_wspace_sep
), NULL
);
2253 if (conv(&neg
, &lval
, i
, 1, data
)) {
2258 if (conv(&neg
, &lval
, i
, 0, data
)) {
2263 err
= proc_put_char(&buffer
, &left
, '\t');
2266 err
= proc_put_long(&buffer
, &left
, lval
, neg
);
2272 if (!write
&& !first
&& left
&& !err
)
2273 err
= proc_put_char(&buffer
, &left
, '\n');
2274 if (write
&& !err
&& left
)
2275 left
-= proc_skip_spaces(&p
);
2279 return err
? : -EINVAL
;
2287 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2288 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2289 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2290 int write
, void *data
),
2293 return __do_proc_dointvec(table
->data
, table
, write
,
2294 buffer
, lenp
, ppos
, conv
, data
);
2297 static int do_proc_douintvec_w(unsigned int *tbl_data
,
2298 struct ctl_table
*table
,
2299 void __user
*buffer
,
2300 size_t *lenp
, loff_t
*ppos
,
2301 int (*conv
)(unsigned long *lvalp
,
2303 int write
, void *data
),
2310 char *kbuf
= NULL
, *p
;
2314 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2317 if (left
> PAGE_SIZE
- 1)
2318 left
= PAGE_SIZE
- 1;
2320 p
= kbuf
= memdup_user_nul(buffer
, left
);
2324 left
-= proc_skip_spaces(&p
);
2330 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2332 sizeof(proc_wspace_sep
), NULL
);
2338 if (conv(&lval
, tbl_data
, 1, data
)) {
2344 left
-= proc_skip_spaces(&p
);
2353 /* This is in keeping with old __do_proc_dointvec() */
2359 static int do_proc_douintvec_r(unsigned int *tbl_data
, void __user
*buffer
,
2360 size_t *lenp
, loff_t
*ppos
,
2361 int (*conv
)(unsigned long *lvalp
,
2363 int write
, void *data
),
2372 if (conv(&lval
, tbl_data
, 0, data
)) {
2377 err
= proc_put_long(&buffer
, &left
, lval
, false);
2381 err
= proc_put_char(&buffer
, &left
, '\n');
2390 static int __do_proc_douintvec(void *tbl_data
, struct ctl_table
*table
,
2391 int write
, void __user
*buffer
,
2392 size_t *lenp
, loff_t
*ppos
,
2393 int (*conv
)(unsigned long *lvalp
,
2395 int write
, void *data
),
2398 unsigned int *i
, vleft
;
2400 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2405 i
= (unsigned int *) tbl_data
;
2406 vleft
= table
->maxlen
/ sizeof(*i
);
2409 * Arrays are not supported, keep this simple. *Do not* add
2418 conv
= do_proc_douintvec_conv
;
2421 return do_proc_douintvec_w(i
, table
, buffer
, lenp
, ppos
,
2423 return do_proc_douintvec_r(i
, buffer
, lenp
, ppos
, conv
, data
);
2426 static int do_proc_douintvec(struct ctl_table
*table
, int write
,
2427 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2428 int (*conv
)(unsigned long *lvalp
,
2430 int write
, void *data
),
2433 return __do_proc_douintvec(table
->data
, table
, write
,
2434 buffer
, lenp
, ppos
, conv
, data
);
2438 * proc_dointvec - read a vector of integers
2439 * @table: the sysctl table
2440 * @write: %TRUE if this is a write to the sysctl file
2441 * @buffer: the user buffer
2442 * @lenp: the size of the user buffer
2443 * @ppos: file position
2445 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2446 * values from/to the user buffer, treated as an ASCII string.
2448 * Returns 0 on success.
2450 int proc_dointvec(struct ctl_table
*table
, int write
,
2451 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2453 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
, NULL
, NULL
);
2457 * proc_douintvec - read a vector of unsigned integers
2458 * @table: the sysctl table
2459 * @write: %TRUE if this is a write to the sysctl file
2460 * @buffer: the user buffer
2461 * @lenp: the size of the user buffer
2462 * @ppos: file position
2464 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2465 * values from/to the user buffer, treated as an ASCII string.
2467 * Returns 0 on success.
2469 int proc_douintvec(struct ctl_table
*table
, int write
,
2470 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2472 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2473 do_proc_douintvec_conv
, NULL
);
2477 * Taint values can only be increased
2478 * This means we can safely use a temporary.
2480 static int proc_taint(struct ctl_table
*table
, int write
,
2481 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2484 unsigned long tmptaint
= get_taint();
2487 if (write
&& !capable(CAP_SYS_ADMIN
))
2492 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2498 * Poor man's atomic or. Not worth adding a primitive
2499 * to everyone's atomic.h for this
2502 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2503 if ((tmptaint
>> i
) & 1)
2504 add_taint(i
, LOCKDEP_STILL_OK
);
2511 #ifdef CONFIG_PRINTK
2512 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
2513 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2515 if (write
&& !capable(CAP_SYS_ADMIN
))
2518 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2522 struct do_proc_dointvec_minmax_conv_param
{
2527 static int do_proc_dointvec_minmax_conv(bool *negp
, unsigned long *lvalp
,
2529 int write
, void *data
)
2531 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2535 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2539 if (*lvalp
> (unsigned long) INT_MAX
)
2543 if ((param
->min
&& *param
->min
> val
) ||
2544 (param
->max
&& *param
->max
< val
))
2551 *lvalp
= -(unsigned long)val
;
2554 *lvalp
= (unsigned long)val
;
2561 * proc_dointvec_minmax - read a vector of integers with min/max values
2562 * @table: the sysctl table
2563 * @write: %TRUE if this is a write to the sysctl file
2564 * @buffer: the user buffer
2565 * @lenp: the size of the user buffer
2566 * @ppos: file position
2568 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2569 * values from/to the user buffer, treated as an ASCII string.
2571 * This routine will ensure the values are within the range specified by
2572 * table->extra1 (min) and table->extra2 (max).
2574 * Returns 0 on success.
2576 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2577 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2579 struct do_proc_dointvec_minmax_conv_param param
= {
2580 .min
= (int *) table
->extra1
,
2581 .max
= (int *) table
->extra2
,
2583 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2584 do_proc_dointvec_minmax_conv
, ¶m
);
2587 struct do_proc_douintvec_minmax_conv_param
{
2592 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp
,
2594 int write
, void *data
)
2596 struct do_proc_douintvec_minmax_conv_param
*param
= data
;
2599 unsigned int val
= *lvalp
;
2601 if ((param
->min
&& *param
->min
> val
) ||
2602 (param
->max
&& *param
->max
< val
))
2605 if (*lvalp
> UINT_MAX
)
2609 unsigned int val
= *valp
;
2610 *lvalp
= (unsigned long) val
;
2617 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2618 * @table: the sysctl table
2619 * @write: %TRUE if this is a write to the sysctl file
2620 * @buffer: the user buffer
2621 * @lenp: the size of the user buffer
2622 * @ppos: file position
2624 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2625 * values from/to the user buffer, treated as an ASCII string. Negative
2626 * strings are not allowed.
2628 * This routine will ensure the values are within the range specified by
2629 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2630 * check for UINT_MAX to avoid having to support wrap around uses from
2633 * Returns 0 on success.
2635 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
2636 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2638 struct do_proc_douintvec_minmax_conv_param param
= {
2639 .min
= (unsigned int *) table
->extra1
,
2640 .max
= (unsigned int *) table
->extra2
,
2642 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2643 do_proc_douintvec_minmax_conv
, ¶m
);
2646 static void validate_coredump_safety(void)
2648 #ifdef CONFIG_COREDUMP
2649 if (suid_dumpable
== SUID_DUMP_ROOT
&&
2650 core_pattern
[0] != '/' && core_pattern
[0] != '|') {
2652 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2653 "Pipe handler or fully qualified core dump path required.\n"
2654 "Set kernel.core_pattern before fs.suid_dumpable.\n"
2660 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
2661 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2663 int error
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2665 validate_coredump_safety();
2669 #ifdef CONFIG_COREDUMP
2670 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
2671 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2673 int error
= proc_dostring(table
, write
, buffer
, lenp
, ppos
);
2675 validate_coredump_safety();
2680 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2681 void __user
*buffer
,
2682 size_t *lenp
, loff_t
*ppos
,
2683 unsigned long convmul
,
2684 unsigned long convdiv
)
2686 unsigned long *i
, *min
, *max
;
2687 int vleft
, first
= 1, err
= 0;
2689 char *kbuf
= NULL
, *p
;
2691 if (!data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2696 i
= (unsigned long *) data
;
2697 min
= (unsigned long *) table
->extra1
;
2698 max
= (unsigned long *) table
->extra2
;
2699 vleft
= table
->maxlen
/ sizeof(unsigned long);
2703 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2706 if (left
> PAGE_SIZE
- 1)
2707 left
= PAGE_SIZE
- 1;
2708 p
= kbuf
= memdup_user_nul(buffer
, left
);
2710 return PTR_ERR(kbuf
);
2713 for (; left
&& vleft
--; i
++, first
= 0) {
2719 left
-= proc_skip_spaces(&p
);
2723 err
= proc_get_long(&p
, &left
, &val
, &neg
,
2725 sizeof(proc_wspace_sep
), NULL
);
2730 val
= convmul
* val
/ convdiv
;
2731 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2735 val
= convdiv
* (*i
) / convmul
;
2737 err
= proc_put_char(&buffer
, &left
, '\t');
2741 err
= proc_put_long(&buffer
, &left
, val
, false);
2747 if (!write
&& !first
&& left
&& !err
)
2748 err
= proc_put_char(&buffer
, &left
, '\n');
2750 left
-= proc_skip_spaces(&p
);
2754 return err
? : -EINVAL
;
2762 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2763 void __user
*buffer
,
2764 size_t *lenp
, loff_t
*ppos
,
2765 unsigned long convmul
,
2766 unsigned long convdiv
)
2768 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2769 buffer
, lenp
, ppos
, convmul
, convdiv
);
2773 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2774 * @table: the sysctl table
2775 * @write: %TRUE if this is a write to the sysctl file
2776 * @buffer: the user buffer
2777 * @lenp: the size of the user buffer
2778 * @ppos: file position
2780 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2781 * values from/to the user buffer, treated as an ASCII string.
2783 * This routine will ensure the values are within the range specified by
2784 * table->extra1 (min) and table->extra2 (max).
2786 * Returns 0 on success.
2788 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2789 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2791 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2795 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2796 * @table: the sysctl table
2797 * @write: %TRUE if this is a write to the sysctl file
2798 * @buffer: the user buffer
2799 * @lenp: the size of the user buffer
2800 * @ppos: file position
2802 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2803 * values from/to the user buffer, treated as an ASCII string. The values
2804 * are treated as milliseconds, and converted to jiffies when they are stored.
2806 * This routine will ensure the values are within the range specified by
2807 * table->extra1 (min) and table->extra2 (max).
2809 * Returns 0 on success.
2811 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2812 void __user
*buffer
,
2813 size_t *lenp
, loff_t
*ppos
)
2815 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2816 lenp
, ppos
, HZ
, 1000l);
2820 static int do_proc_dointvec_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2822 int write
, void *data
)
2825 if (*lvalp
> INT_MAX
/ HZ
)
2827 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2833 lval
= -(unsigned long)val
;
2836 lval
= (unsigned long)val
;
2843 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2845 int write
, void *data
)
2848 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2850 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2856 lval
= -(unsigned long)val
;
2859 lval
= (unsigned long)val
;
2861 *lvalp
= jiffies_to_clock_t(lval
);
2866 static int do_proc_dointvec_ms_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2868 int write
, void *data
)
2871 unsigned long jif
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2881 lval
= -(unsigned long)val
;
2884 lval
= (unsigned long)val
;
2886 *lvalp
= jiffies_to_msecs(lval
);
2892 * proc_dointvec_jiffies - read a vector of integers as seconds
2893 * @table: the sysctl table
2894 * @write: %TRUE if this is a write to the sysctl file
2895 * @buffer: the user buffer
2896 * @lenp: the size of the user buffer
2897 * @ppos: file position
2899 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2900 * values from/to the user buffer, treated as an ASCII string.
2901 * The values read are assumed to be in seconds, and are converted into
2904 * Returns 0 on success.
2906 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2907 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2909 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2910 do_proc_dointvec_jiffies_conv
,NULL
);
2914 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2915 * @table: the sysctl table
2916 * @write: %TRUE if this is a write to the sysctl file
2917 * @buffer: the user buffer
2918 * @lenp: the size of the user buffer
2919 * @ppos: pointer to the file position
2921 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2922 * values from/to the user buffer, treated as an ASCII string.
2923 * The values read are assumed to be in 1/USER_HZ seconds, and
2924 * are converted into jiffies.
2926 * Returns 0 on success.
2928 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2929 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2931 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2932 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2936 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2937 * @table: the sysctl table
2938 * @write: %TRUE if this is a write to the sysctl file
2939 * @buffer: the user buffer
2940 * @lenp: the size of the user buffer
2941 * @ppos: file position
2942 * @ppos: the current position in the file
2944 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2945 * values from/to the user buffer, treated as an ASCII string.
2946 * The values read are assumed to be in 1/1000 seconds, and
2947 * are converted into jiffies.
2949 * Returns 0 on success.
2951 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2952 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2954 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2955 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2958 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
2959 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2961 struct pid
*new_pid
;
2965 tmp
= pid_vnr(cad_pid
);
2967 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
2968 lenp
, ppos
, NULL
, NULL
);
2972 new_pid
= find_get_pid(tmp
);
2976 put_pid(xchg(&cad_pid
, new_pid
));
2981 * proc_do_large_bitmap - read/write from/to a large bitmap
2982 * @table: the sysctl table
2983 * @write: %TRUE if this is a write to the sysctl file
2984 * @buffer: the user buffer
2985 * @lenp: the size of the user buffer
2986 * @ppos: file position
2988 * The bitmap is stored at table->data and the bitmap length (in bits)
2991 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2992 * large bitmaps may be represented in a compact manner. Writing into
2993 * the file will clear the bitmap then update it with the given input.
2995 * Returns 0 on success.
2997 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
2998 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3002 size_t left
= *lenp
;
3003 unsigned long bitmap_len
= table
->maxlen
;
3004 unsigned long *bitmap
= *(unsigned long **) table
->data
;
3005 unsigned long *tmp_bitmap
= NULL
;
3006 char tr_a
[] = { '-', ',', '\n' }, tr_b
[] = { ',', '\n', 0 }, c
;
3008 if (!bitmap
|| !bitmap_len
|| !left
|| (*ppos
&& !write
)) {
3016 if (left
> PAGE_SIZE
- 1)
3017 left
= PAGE_SIZE
- 1;
3019 p
= kbuf
= memdup_user_nul(buffer
, left
);
3021 return PTR_ERR(kbuf
);
3023 tmp_bitmap
= kzalloc(BITS_TO_LONGS(bitmap_len
) * sizeof(unsigned long),
3029 proc_skip_char(&p
, &left
, '\n');
3030 while (!err
&& left
) {
3031 unsigned long val_a
, val_b
;
3034 err
= proc_get_long(&p
, &left
, &val_a
, &neg
, tr_a
,
3038 if (val_a
>= bitmap_len
|| neg
) {
3050 err
= proc_get_long(&p
, &left
, &val_b
,
3051 &neg
, tr_b
, sizeof(tr_b
),
3055 if (val_b
>= bitmap_len
|| neg
||
3066 bitmap_set(tmp_bitmap
, val_a
, val_b
- val_a
+ 1);
3068 proc_skip_char(&p
, &left
, '\n');
3072 unsigned long bit_a
, bit_b
= 0;
3075 bit_a
= find_next_bit(bitmap
, bitmap_len
, bit_b
);
3076 if (bit_a
>= bitmap_len
)
3078 bit_b
= find_next_zero_bit(bitmap
, bitmap_len
,
3082 err
= proc_put_char(&buffer
, &left
, ',');
3086 err
= proc_put_long(&buffer
, &left
, bit_a
, false);
3089 if (bit_a
!= bit_b
) {
3090 err
= proc_put_char(&buffer
, &left
, '-');
3093 err
= proc_put_long(&buffer
, &left
, bit_b
, false);
3101 err
= proc_put_char(&buffer
, &left
, '\n');
3107 bitmap_or(bitmap
, bitmap
, tmp_bitmap
, bitmap_len
);
3109 bitmap_copy(bitmap
, tmp_bitmap
, bitmap_len
);
3121 #else /* CONFIG_PROC_SYSCTL */
3123 int proc_dostring(struct ctl_table
*table
, int write
,
3124 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3129 int proc_dointvec(struct ctl_table
*table
, int write
,
3130 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3135 int proc_douintvec(struct ctl_table
*table
, int write
,
3136 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3141 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
3142 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3147 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
3148 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3153 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
3154 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3159 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
3160 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3165 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
3166 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3171 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
3172 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3177 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
3178 void __user
*buffer
,
3179 size_t *lenp
, loff_t
*ppos
)
3185 #endif /* CONFIG_PROC_SYSCTL */
3188 * No sense putting this after each symbol definition, twice,
3189 * exception granted :-)
3191 EXPORT_SYMBOL(proc_dointvec
);
3192 EXPORT_SYMBOL(proc_douintvec
);
3193 EXPORT_SYMBOL(proc_dointvec_jiffies
);
3194 EXPORT_SYMBOL(proc_dointvec_minmax
);
3195 EXPORT_SYMBOL_GPL(proc_douintvec_minmax
);
3196 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
3197 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
3198 EXPORT_SYMBOL(proc_dostring
);
3199 EXPORT_SYMBOL(proc_doulongvec_minmax
);
3200 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);