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>
69 #include <linux/pipe_fs_i.h>
71 #include <linux/uaccess.h>
72 #include <asm/processor.h>
76 #include <asm/stacktrace.h>
80 #include <asm/setup.h>
82 #ifdef CONFIG_BSD_PROCESS_ACCT
83 #include <linux/acct.h>
85 #ifdef CONFIG_RT_MUTEXES
86 #include <linux/rtmutex.h>
88 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
89 #include <linux/lockdep.h>
91 #ifdef CONFIG_CHR_DEV_SG
95 #ifdef CONFIG_LOCKUP_DETECTOR
96 #include <linux/nmi.h>
99 #if defined(CONFIG_SYSCTL)
101 /* External variables not in a header file. */
102 extern int suid_dumpable
;
103 #ifdef CONFIG_COREDUMP
104 extern int core_uses_pid
;
105 extern char core_pattern
[];
106 extern unsigned int core_pipe_limit
;
109 extern int pid_max_min
, pid_max_max
;
110 extern int percpu_pagelist_fraction
;
111 extern int latencytop_enabled
;
112 extern unsigned int sysctl_nr_open_min
, sysctl_nr_open_max
;
114 extern int sysctl_nr_trim_pages
;
117 /* Constants used for minimum and maximum */
118 #ifdef CONFIG_LOCKUP_DETECTOR
119 static int sixty
= 60;
122 static int __maybe_unused neg_one
= -1;
125 static int __maybe_unused one
= 1;
126 static int __maybe_unused two
= 2;
127 static int __maybe_unused four
= 4;
128 static unsigned long one_ul
= 1;
129 static int one_hundred
= 100;
130 static int one_thousand
= 1000;
132 static int ten_thousand
= 10000;
134 #ifdef CONFIG_PERF_EVENTS
135 static int six_hundred_forty_kb
= 640 * 1024;
138 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
139 static unsigned long dirty_bytes_min
= 2 * PAGE_SIZE
;
141 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
142 static int maxolduid
= 65535;
143 static int minolduid
;
145 static int ngroups_max
= NGROUPS_MAX
;
146 static const int cap_last_cap
= CAP_LAST_CAP
;
148 /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
149 #ifdef CONFIG_DETECT_HUNG_TASK
150 static unsigned long hung_task_timeout_max
= (LONG_MAX
/HZ
);
153 #ifdef CONFIG_INOTIFY_USER
154 #include <linux/inotify.h>
160 extern int pwrsw_enabled
;
163 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
164 extern int unaligned_enabled
;
168 extern int unaligned_dump_stack
;
171 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
172 extern int no_unaligned_warning
;
175 #ifdef CONFIG_PROC_SYSCTL
178 * enum sysctl_writes_mode - supported sysctl write modes
180 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
181 * to be written, and multiple writes on the same sysctl file descriptor
182 * will rewrite the sysctl value, regardless of file position. No warning
183 * is issued when the initial position is not 0.
184 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
186 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
187 * file position 0 and the value must be fully contained in the buffer
188 * sent to the write syscall. If dealing with strings respect the file
189 * position, but restrict this to the max length of the buffer, anything
190 * passed the max lenght will be ignored. Multiple writes will append
193 * These write modes control how current file position affects the behavior of
194 * updating sysctl values through the proc interface on each write.
196 enum sysctl_writes_mode
{
197 SYSCTL_WRITES_LEGACY
= -1,
198 SYSCTL_WRITES_WARN
= 0,
199 SYSCTL_WRITES_STRICT
= 1,
202 static enum sysctl_writes_mode sysctl_writes_strict
= SYSCTL_WRITES_STRICT
;
204 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
205 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
206 static int proc_taint(struct ctl_table
*table
, int write
,
207 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
211 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
212 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
215 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
216 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
217 #ifdef CONFIG_COREDUMP
218 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
219 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
221 static int proc_dopipe_max_size(struct ctl_table
*table
, int write
,
222 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
224 #ifdef CONFIG_MAGIC_SYSRQ
225 /* Note: sysrq code uses it's own private copy */
226 static int __sysrq_enabled
= CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE
;
228 static int sysrq_sysctl_handler(struct ctl_table
*table
, int write
,
229 void __user
*buffer
, size_t *lenp
,
234 error
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
239 sysrq_toggle_support(__sysrq_enabled
);
246 static struct ctl_table kern_table
[];
247 static struct ctl_table vm_table
[];
248 static struct ctl_table fs_table
[];
249 static struct ctl_table debug_table
[];
250 static struct ctl_table dev_table
[];
251 extern struct ctl_table random_table
[];
253 extern struct ctl_table epoll_table
[];
256 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
257 int sysctl_legacy_va_layout
;
260 /* The default sysctl tables: */
262 static struct ctl_table sysctl_base_table
[] = {
264 .procname
= "kernel",
281 .child
= debug_table
,
291 #ifdef CONFIG_SCHED_DEBUG
292 static int min_sched_granularity_ns
= 100000; /* 100 usecs */
293 static int max_sched_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
294 static int min_wakeup_granularity_ns
; /* 0 usecs */
295 static int max_wakeup_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
297 static int min_sched_tunable_scaling
= SCHED_TUNABLESCALING_NONE
;
298 static int max_sched_tunable_scaling
= SCHED_TUNABLESCALING_END
-1;
299 #endif /* CONFIG_SMP */
300 #endif /* CONFIG_SCHED_DEBUG */
302 #ifdef CONFIG_COMPACTION
303 static int min_extfrag_threshold
;
304 static int max_extfrag_threshold
= 1000;
307 static struct ctl_table kern_table
[] = {
309 .procname
= "sched_child_runs_first",
310 .data
= &sysctl_sched_child_runs_first
,
311 .maxlen
= sizeof(unsigned int),
313 .proc_handler
= proc_dointvec
,
315 #ifdef CONFIG_SCHED_DEBUG
317 .procname
= "sched_min_granularity_ns",
318 .data
= &sysctl_sched_min_granularity
,
319 .maxlen
= sizeof(unsigned int),
321 .proc_handler
= sched_proc_update_handler
,
322 .extra1
= &min_sched_granularity_ns
,
323 .extra2
= &max_sched_granularity_ns
,
326 .procname
= "sched_latency_ns",
327 .data
= &sysctl_sched_latency
,
328 .maxlen
= sizeof(unsigned int),
330 .proc_handler
= sched_proc_update_handler
,
331 .extra1
= &min_sched_granularity_ns
,
332 .extra2
= &max_sched_granularity_ns
,
335 .procname
= "sched_wakeup_granularity_ns",
336 .data
= &sysctl_sched_wakeup_granularity
,
337 .maxlen
= sizeof(unsigned int),
339 .proc_handler
= sched_proc_update_handler
,
340 .extra1
= &min_wakeup_granularity_ns
,
341 .extra2
= &max_wakeup_granularity_ns
,
345 .procname
= "sched_tunable_scaling",
346 .data
= &sysctl_sched_tunable_scaling
,
347 .maxlen
= sizeof(enum sched_tunable_scaling
),
349 .proc_handler
= sched_proc_update_handler
,
350 .extra1
= &min_sched_tunable_scaling
,
351 .extra2
= &max_sched_tunable_scaling
,
354 .procname
= "sched_migration_cost_ns",
355 .data
= &sysctl_sched_migration_cost
,
356 .maxlen
= sizeof(unsigned int),
358 .proc_handler
= proc_dointvec
,
361 .procname
= "sched_nr_migrate",
362 .data
= &sysctl_sched_nr_migrate
,
363 .maxlen
= sizeof(unsigned int),
365 .proc_handler
= proc_dointvec
,
368 .procname
= "sched_time_avg_ms",
369 .data
= &sysctl_sched_time_avg
,
370 .maxlen
= sizeof(unsigned int),
372 .proc_handler
= proc_dointvec_minmax
,
375 #ifdef CONFIG_SCHEDSTATS
377 .procname
= "sched_schedstats",
379 .maxlen
= sizeof(unsigned int),
381 .proc_handler
= sysctl_schedstats
,
385 #endif /* CONFIG_SCHEDSTATS */
386 #endif /* CONFIG_SMP */
387 #ifdef CONFIG_NUMA_BALANCING
389 .procname
= "numa_balancing_scan_delay_ms",
390 .data
= &sysctl_numa_balancing_scan_delay
,
391 .maxlen
= sizeof(unsigned int),
393 .proc_handler
= proc_dointvec
,
396 .procname
= "numa_balancing_scan_period_min_ms",
397 .data
= &sysctl_numa_balancing_scan_period_min
,
398 .maxlen
= sizeof(unsigned int),
400 .proc_handler
= proc_dointvec
,
403 .procname
= "numa_balancing_scan_period_max_ms",
404 .data
= &sysctl_numa_balancing_scan_period_max
,
405 .maxlen
= sizeof(unsigned int),
407 .proc_handler
= proc_dointvec
,
410 .procname
= "numa_balancing_scan_size_mb",
411 .data
= &sysctl_numa_balancing_scan_size
,
412 .maxlen
= sizeof(unsigned int),
414 .proc_handler
= proc_dointvec_minmax
,
418 .procname
= "numa_balancing",
419 .data
= NULL
, /* filled in by handler */
420 .maxlen
= sizeof(unsigned int),
422 .proc_handler
= sysctl_numa_balancing
,
426 #endif /* CONFIG_NUMA_BALANCING */
427 #endif /* CONFIG_SCHED_DEBUG */
429 .procname
= "sched_rt_period_us",
430 .data
= &sysctl_sched_rt_period
,
431 .maxlen
= sizeof(unsigned int),
433 .proc_handler
= sched_rt_handler
,
436 .procname
= "sched_rt_runtime_us",
437 .data
= &sysctl_sched_rt_runtime
,
438 .maxlen
= sizeof(int),
440 .proc_handler
= sched_rt_handler
,
443 .procname
= "sched_rr_timeslice_ms",
444 .data
= &sysctl_sched_rr_timeslice
,
445 .maxlen
= sizeof(int),
447 .proc_handler
= sched_rr_handler
,
449 #ifdef CONFIG_SCHED_AUTOGROUP
451 .procname
= "sched_autogroup_enabled",
452 .data
= &sysctl_sched_autogroup_enabled
,
453 .maxlen
= sizeof(unsigned int),
455 .proc_handler
= proc_dointvec_minmax
,
460 #ifdef CONFIG_CFS_BANDWIDTH
462 .procname
= "sched_cfs_bandwidth_slice_us",
463 .data
= &sysctl_sched_cfs_bandwidth_slice
,
464 .maxlen
= sizeof(unsigned int),
466 .proc_handler
= proc_dointvec_minmax
,
470 #ifdef CONFIG_PROVE_LOCKING
472 .procname
= "prove_locking",
473 .data
= &prove_locking
,
474 .maxlen
= sizeof(int),
476 .proc_handler
= proc_dointvec
,
479 #ifdef CONFIG_LOCK_STAT
481 .procname
= "lock_stat",
483 .maxlen
= sizeof(int),
485 .proc_handler
= proc_dointvec
,
490 .data
= &panic_timeout
,
491 .maxlen
= sizeof(int),
493 .proc_handler
= proc_dointvec
,
495 #ifdef CONFIG_COREDUMP
497 .procname
= "core_uses_pid",
498 .data
= &core_uses_pid
,
499 .maxlen
= sizeof(int),
501 .proc_handler
= proc_dointvec
,
504 .procname
= "core_pattern",
505 .data
= core_pattern
,
506 .maxlen
= CORENAME_MAX_SIZE
,
508 .proc_handler
= proc_dostring_coredump
,
511 .procname
= "core_pipe_limit",
512 .data
= &core_pipe_limit
,
513 .maxlen
= sizeof(unsigned int),
515 .proc_handler
= proc_dointvec
,
518 #ifdef CONFIG_PROC_SYSCTL
520 .procname
= "tainted",
521 .maxlen
= sizeof(long),
523 .proc_handler
= proc_taint
,
526 .procname
= "sysctl_writes_strict",
527 .data
= &sysctl_writes_strict
,
528 .maxlen
= sizeof(int),
530 .proc_handler
= proc_dointvec_minmax
,
535 #ifdef CONFIG_LATENCYTOP
537 .procname
= "latencytop",
538 .data
= &latencytop_enabled
,
539 .maxlen
= sizeof(int),
541 .proc_handler
= sysctl_latencytop
,
544 #ifdef CONFIG_BLK_DEV_INITRD
546 .procname
= "real-root-dev",
547 .data
= &real_root_dev
,
548 .maxlen
= sizeof(int),
550 .proc_handler
= proc_dointvec
,
554 .procname
= "print-fatal-signals",
555 .data
= &print_fatal_signals
,
556 .maxlen
= sizeof(int),
558 .proc_handler
= proc_dointvec
,
562 .procname
= "reboot-cmd",
563 .data
= reboot_command
,
566 .proc_handler
= proc_dostring
,
569 .procname
= "stop-a",
570 .data
= &stop_a_enabled
,
571 .maxlen
= sizeof (int),
573 .proc_handler
= proc_dointvec
,
576 .procname
= "scons-poweroff",
577 .data
= &scons_pwroff
,
578 .maxlen
= sizeof (int),
580 .proc_handler
= proc_dointvec
,
583 #ifdef CONFIG_SPARC64
585 .procname
= "tsb-ratio",
586 .data
= &sysctl_tsb_ratio
,
587 .maxlen
= sizeof (int),
589 .proc_handler
= proc_dointvec
,
594 .procname
= "soft-power",
595 .data
= &pwrsw_enabled
,
596 .maxlen
= sizeof (int),
598 .proc_handler
= proc_dointvec
,
601 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
603 .procname
= "unaligned-trap",
604 .data
= &unaligned_enabled
,
605 .maxlen
= sizeof (int),
607 .proc_handler
= proc_dointvec
,
611 .procname
= "ctrl-alt-del",
613 .maxlen
= sizeof(int),
615 .proc_handler
= proc_dointvec
,
617 #ifdef CONFIG_FUNCTION_TRACER
619 .procname
= "ftrace_enabled",
620 .data
= &ftrace_enabled
,
621 .maxlen
= sizeof(int),
623 .proc_handler
= ftrace_enable_sysctl
,
626 #ifdef CONFIG_STACK_TRACER
628 .procname
= "stack_tracer_enabled",
629 .data
= &stack_tracer_enabled
,
630 .maxlen
= sizeof(int),
632 .proc_handler
= stack_trace_sysctl
,
635 #ifdef CONFIG_TRACING
637 .procname
= "ftrace_dump_on_oops",
638 .data
= &ftrace_dump_on_oops
,
639 .maxlen
= sizeof(int),
641 .proc_handler
= proc_dointvec
,
644 .procname
= "traceoff_on_warning",
645 .data
= &__disable_trace_on_warning
,
646 .maxlen
= sizeof(__disable_trace_on_warning
),
648 .proc_handler
= proc_dointvec
,
651 .procname
= "tracepoint_printk",
652 .data
= &tracepoint_printk
,
653 .maxlen
= sizeof(tracepoint_printk
),
655 .proc_handler
= tracepoint_printk_sysctl
,
658 #ifdef CONFIG_KEXEC_CORE
660 .procname
= "kexec_load_disabled",
661 .data
= &kexec_load_disabled
,
662 .maxlen
= sizeof(int),
664 /* only handle a transition from default "0" to "1" */
665 .proc_handler
= proc_dointvec_minmax
,
670 #ifdef CONFIG_MODULES
672 .procname
= "modprobe",
673 .data
= &modprobe_path
,
674 .maxlen
= KMOD_PATH_LEN
,
676 .proc_handler
= proc_dostring
,
679 .procname
= "modules_disabled",
680 .data
= &modules_disabled
,
681 .maxlen
= sizeof(int),
683 /* only handle a transition from default "0" to "1" */
684 .proc_handler
= proc_dointvec_minmax
,
689 #ifdef CONFIG_UEVENT_HELPER
691 .procname
= "hotplug",
692 .data
= &uevent_helper
,
693 .maxlen
= UEVENT_HELPER_PATH_LEN
,
695 .proc_handler
= proc_dostring
,
698 #ifdef CONFIG_CHR_DEV_SG
700 .procname
= "sg-big-buff",
701 .data
= &sg_big_buff
,
702 .maxlen
= sizeof (int),
704 .proc_handler
= proc_dointvec
,
707 #ifdef CONFIG_BSD_PROCESS_ACCT
711 .maxlen
= 3*sizeof(int),
713 .proc_handler
= proc_dointvec
,
716 #ifdef CONFIG_MAGIC_SYSRQ
719 .data
= &__sysrq_enabled
,
720 .maxlen
= sizeof (int),
722 .proc_handler
= sysrq_sysctl_handler
,
725 #ifdef CONFIG_PROC_SYSCTL
727 .procname
= "cad_pid",
729 .maxlen
= sizeof (int),
731 .proc_handler
= proc_do_cad_pid
,
735 .procname
= "threads-max",
737 .maxlen
= sizeof(int),
739 .proc_handler
= sysctl_max_threads
,
742 .procname
= "random",
744 .child
= random_table
,
747 .procname
= "usermodehelper",
749 .child
= usermodehelper_table
,
752 .procname
= "overflowuid",
753 .data
= &overflowuid
,
754 .maxlen
= sizeof(int),
756 .proc_handler
= proc_dointvec_minmax
,
757 .extra1
= &minolduid
,
758 .extra2
= &maxolduid
,
761 .procname
= "overflowgid",
762 .data
= &overflowgid
,
763 .maxlen
= sizeof(int),
765 .proc_handler
= proc_dointvec_minmax
,
766 .extra1
= &minolduid
,
767 .extra2
= &maxolduid
,
770 #ifdef CONFIG_MATHEMU
772 .procname
= "ieee_emulation_warnings",
773 .data
= &sysctl_ieee_emulation_warnings
,
774 .maxlen
= sizeof(int),
776 .proc_handler
= proc_dointvec
,
780 .procname
= "userprocess_debug",
781 .data
= &show_unhandled_signals
,
782 .maxlen
= sizeof(int),
784 .proc_handler
= proc_dointvec
,
788 .procname
= "pid_max",
790 .maxlen
= sizeof (int),
792 .proc_handler
= proc_dointvec_minmax
,
793 .extra1
= &pid_max_min
,
794 .extra2
= &pid_max_max
,
797 .procname
= "panic_on_oops",
798 .data
= &panic_on_oops
,
799 .maxlen
= sizeof(int),
801 .proc_handler
= proc_dointvec
,
803 #if defined CONFIG_PRINTK
805 .procname
= "printk",
806 .data
= &console_loglevel
,
807 .maxlen
= 4*sizeof(int),
809 .proc_handler
= proc_dointvec
,
812 .procname
= "printk_ratelimit",
813 .data
= &printk_ratelimit_state
.interval
,
814 .maxlen
= sizeof(int),
816 .proc_handler
= proc_dointvec_jiffies
,
819 .procname
= "printk_ratelimit_burst",
820 .data
= &printk_ratelimit_state
.burst
,
821 .maxlen
= sizeof(int),
823 .proc_handler
= proc_dointvec
,
826 .procname
= "printk_delay",
827 .data
= &printk_delay_msec
,
828 .maxlen
= sizeof(int),
830 .proc_handler
= proc_dointvec_minmax
,
832 .extra2
= &ten_thousand
,
835 .procname
= "printk_devkmsg",
836 .data
= devkmsg_log_str
,
837 .maxlen
= DEVKMSG_STR_MAX_SIZE
,
839 .proc_handler
= devkmsg_sysctl_set_loglvl
,
842 .procname
= "dmesg_restrict",
843 .data
= &dmesg_restrict
,
844 .maxlen
= sizeof(int),
846 .proc_handler
= proc_dointvec_minmax_sysadmin
,
851 .procname
= "kptr_restrict",
852 .data
= &kptr_restrict
,
853 .maxlen
= sizeof(int),
855 .proc_handler
= proc_dointvec_minmax_sysadmin
,
861 .procname
= "ngroups_max",
862 .data
= &ngroups_max
,
863 .maxlen
= sizeof (int),
865 .proc_handler
= proc_dointvec
,
868 .procname
= "cap_last_cap",
869 .data
= (void *)&cap_last_cap
,
870 .maxlen
= sizeof(int),
872 .proc_handler
= proc_dointvec
,
874 #if defined(CONFIG_LOCKUP_DETECTOR)
876 .procname
= "watchdog",
877 .data
= &watchdog_user_enabled
,
878 .maxlen
= sizeof(int),
880 .proc_handler
= proc_watchdog
,
885 .procname
= "watchdog_thresh",
886 .data
= &watchdog_thresh
,
887 .maxlen
= sizeof(int),
889 .proc_handler
= proc_watchdog_thresh
,
894 .procname
= "nmi_watchdog",
895 .data
= &nmi_watchdog_user_enabled
,
896 .maxlen
= sizeof(int),
897 .mode
= NMI_WATCHDOG_SYSCTL_PERM
,
898 .proc_handler
= proc_nmi_watchdog
,
903 .procname
= "watchdog_cpumask",
904 .data
= &watchdog_cpumask_bits
,
907 .proc_handler
= proc_watchdog_cpumask
,
909 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
911 .procname
= "soft_watchdog",
912 .data
= &soft_watchdog_user_enabled
,
913 .maxlen
= sizeof(int),
915 .proc_handler
= proc_soft_watchdog
,
920 .procname
= "softlockup_panic",
921 .data
= &softlockup_panic
,
922 .maxlen
= sizeof(int),
924 .proc_handler
= proc_dointvec_minmax
,
930 .procname
= "softlockup_all_cpu_backtrace",
931 .data
= &sysctl_softlockup_all_cpu_backtrace
,
932 .maxlen
= sizeof(int),
934 .proc_handler
= proc_dointvec_minmax
,
938 #endif /* CONFIG_SMP */
940 #ifdef CONFIG_HARDLOCKUP_DETECTOR
942 .procname
= "hardlockup_panic",
943 .data
= &hardlockup_panic
,
944 .maxlen
= sizeof(int),
946 .proc_handler
= proc_dointvec_minmax
,
952 .procname
= "hardlockup_all_cpu_backtrace",
953 .data
= &sysctl_hardlockup_all_cpu_backtrace
,
954 .maxlen
= sizeof(int),
956 .proc_handler
= proc_dointvec_minmax
,
960 #endif /* CONFIG_SMP */
964 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
966 .procname
= "unknown_nmi_panic",
967 .data
= &unknown_nmi_panic
,
968 .maxlen
= sizeof (int),
970 .proc_handler
= proc_dointvec
,
973 #if defined(CONFIG_X86)
975 .procname
= "panic_on_unrecovered_nmi",
976 .data
= &panic_on_unrecovered_nmi
,
977 .maxlen
= sizeof(int),
979 .proc_handler
= proc_dointvec
,
982 .procname
= "panic_on_io_nmi",
983 .data
= &panic_on_io_nmi
,
984 .maxlen
= sizeof(int),
986 .proc_handler
= proc_dointvec
,
988 #ifdef CONFIG_DEBUG_STACKOVERFLOW
990 .procname
= "panic_on_stackoverflow",
991 .data
= &sysctl_panic_on_stackoverflow
,
992 .maxlen
= sizeof(int),
994 .proc_handler
= proc_dointvec
,
998 .procname
= "bootloader_type",
999 .data
= &bootloader_type
,
1000 .maxlen
= sizeof (int),
1002 .proc_handler
= proc_dointvec
,
1005 .procname
= "bootloader_version",
1006 .data
= &bootloader_version
,
1007 .maxlen
= sizeof (int),
1009 .proc_handler
= proc_dointvec
,
1012 .procname
= "io_delay_type",
1013 .data
= &io_delay_type
,
1014 .maxlen
= sizeof(int),
1016 .proc_handler
= proc_dointvec
,
1019 #if defined(CONFIG_MMU)
1021 .procname
= "randomize_va_space",
1022 .data
= &randomize_va_space
,
1023 .maxlen
= sizeof(int),
1025 .proc_handler
= proc_dointvec
,
1028 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1030 .procname
= "spin_retry",
1031 .data
= &spin_retry
,
1032 .maxlen
= sizeof (int),
1034 .proc_handler
= proc_dointvec
,
1037 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1039 .procname
= "acpi_video_flags",
1040 .data
= &acpi_realmode_flags
,
1041 .maxlen
= sizeof (unsigned long),
1043 .proc_handler
= proc_doulongvec_minmax
,
1046 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1048 .procname
= "ignore-unaligned-usertrap",
1049 .data
= &no_unaligned_warning
,
1050 .maxlen
= sizeof (int),
1052 .proc_handler
= proc_dointvec
,
1057 .procname
= "unaligned-dump-stack",
1058 .data
= &unaligned_dump_stack
,
1059 .maxlen
= sizeof (int),
1061 .proc_handler
= proc_dointvec
,
1064 #ifdef CONFIG_DETECT_HUNG_TASK
1066 .procname
= "hung_task_panic",
1067 .data
= &sysctl_hung_task_panic
,
1068 .maxlen
= sizeof(int),
1070 .proc_handler
= proc_dointvec_minmax
,
1075 .procname
= "hung_task_check_count",
1076 .data
= &sysctl_hung_task_check_count
,
1077 .maxlen
= sizeof(int),
1079 .proc_handler
= proc_dointvec_minmax
,
1083 .procname
= "hung_task_timeout_secs",
1084 .data
= &sysctl_hung_task_timeout_secs
,
1085 .maxlen
= sizeof(unsigned long),
1087 .proc_handler
= proc_dohung_task_timeout_secs
,
1088 .extra2
= &hung_task_timeout_max
,
1091 .procname
= "hung_task_warnings",
1092 .data
= &sysctl_hung_task_warnings
,
1093 .maxlen
= sizeof(int),
1095 .proc_handler
= proc_dointvec_minmax
,
1099 #ifdef CONFIG_RT_MUTEXES
1101 .procname
= "max_lock_depth",
1102 .data
= &max_lock_depth
,
1103 .maxlen
= sizeof(int),
1105 .proc_handler
= proc_dointvec
,
1109 .procname
= "poweroff_cmd",
1110 .data
= &poweroff_cmd
,
1111 .maxlen
= POWEROFF_CMD_PATH_LEN
,
1113 .proc_handler
= proc_dostring
,
1119 .child
= key_sysctls
,
1122 #ifdef CONFIG_PERF_EVENTS
1124 * User-space scripts rely on the existence of this file
1125 * as a feature check for perf_events being enabled.
1127 * So it's an ABI, do not remove!
1130 .procname
= "perf_event_paranoid",
1131 .data
= &sysctl_perf_event_paranoid
,
1132 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
1134 .proc_handler
= proc_dointvec
,
1137 .procname
= "perf_event_mlock_kb",
1138 .data
= &sysctl_perf_event_mlock
,
1139 .maxlen
= sizeof(sysctl_perf_event_mlock
),
1141 .proc_handler
= proc_dointvec
,
1144 .procname
= "perf_event_max_sample_rate",
1145 .data
= &sysctl_perf_event_sample_rate
,
1146 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1148 .proc_handler
= perf_proc_update_handler
,
1152 .procname
= "perf_cpu_time_max_percent",
1153 .data
= &sysctl_perf_cpu_time_max_percent
,
1154 .maxlen
= sizeof(sysctl_perf_cpu_time_max_percent
),
1156 .proc_handler
= perf_cpu_time_max_percent_handler
,
1158 .extra2
= &one_hundred
,
1161 .procname
= "perf_event_max_stack",
1162 .data
= &sysctl_perf_event_max_stack
,
1163 .maxlen
= sizeof(sysctl_perf_event_max_stack
),
1165 .proc_handler
= perf_event_max_stack_handler
,
1167 .extra2
= &six_hundred_forty_kb
,
1170 .procname
= "perf_event_max_contexts_per_stack",
1171 .data
= &sysctl_perf_event_max_contexts_per_stack
,
1172 .maxlen
= sizeof(sysctl_perf_event_max_contexts_per_stack
),
1174 .proc_handler
= perf_event_max_stack_handler
,
1176 .extra2
= &one_thousand
,
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
= "swappiness",
1339 .data
= &vm_swappiness
,
1340 .maxlen
= sizeof(vm_swappiness
),
1342 .proc_handler
= proc_dointvec_minmax
,
1344 .extra2
= &one_hundred
,
1346 #ifdef CONFIG_HUGETLB_PAGE
1348 .procname
= "nr_hugepages",
1350 .maxlen
= sizeof(unsigned long),
1352 .proc_handler
= hugetlb_sysctl_handler
,
1356 .procname
= "nr_hugepages_mempolicy",
1358 .maxlen
= sizeof(unsigned long),
1360 .proc_handler
= &hugetlb_mempolicy_sysctl_handler
,
1363 .procname
= "numa_stat",
1364 .data
= &sysctl_vm_numa_stat
,
1365 .maxlen
= sizeof(int),
1367 .proc_handler
= sysctl_vm_numa_stat_handler
,
1373 .procname
= "hugetlb_shm_group",
1374 .data
= &sysctl_hugetlb_shm_group
,
1375 .maxlen
= sizeof(gid_t
),
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
= "suid_dumpable",
1798 .data
= &suid_dumpable
,
1799 .maxlen
= sizeof(int),
1801 .proc_handler
= proc_dointvec_minmax_coredump
,
1805 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1807 .procname
= "binfmt_misc",
1809 .child
= sysctl_mount_point
,
1813 .procname
= "pipe-max-size",
1814 .data
= &pipe_max_size
,
1815 .maxlen
= sizeof(pipe_max_size
),
1817 .proc_handler
= proc_dopipe_max_size
,
1820 .procname
= "pipe-user-pages-hard",
1821 .data
= &pipe_user_pages_hard
,
1822 .maxlen
= sizeof(pipe_user_pages_hard
),
1824 .proc_handler
= proc_doulongvec_minmax
,
1827 .procname
= "pipe-user-pages-soft",
1828 .data
= &pipe_user_pages_soft
,
1829 .maxlen
= sizeof(pipe_user_pages_soft
),
1831 .proc_handler
= proc_doulongvec_minmax
,
1834 .procname
= "mount-max",
1835 .data
= &sysctl_mount_max
,
1836 .maxlen
= sizeof(unsigned int),
1838 .proc_handler
= proc_dointvec_minmax
,
1844 static struct ctl_table debug_table
[] = {
1845 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1847 .procname
= "exception-trace",
1848 .data
= &show_unhandled_signals
,
1849 .maxlen
= sizeof(int),
1851 .proc_handler
= proc_dointvec
1854 #if defined(CONFIG_OPTPROBES)
1856 .procname
= "kprobes-optimization",
1857 .data
= &sysctl_kprobes_optimization
,
1858 .maxlen
= sizeof(int),
1860 .proc_handler
= proc_kprobes_optimization_handler
,
1868 static struct ctl_table dev_table
[] = {
1872 int __init
sysctl_init(void)
1874 struct ctl_table_header
*hdr
;
1876 hdr
= register_sysctl_table(sysctl_base_table
);
1877 kmemleak_not_leak(hdr
);
1881 #endif /* CONFIG_SYSCTL */
1887 #ifdef CONFIG_PROC_SYSCTL
1889 static int _proc_do_string(char *data
, int maxlen
, int write
,
1890 char __user
*buffer
,
1891 size_t *lenp
, loff_t
*ppos
)
1897 if (!data
|| !maxlen
|| !*lenp
) {
1903 if (sysctl_writes_strict
== SYSCTL_WRITES_STRICT
) {
1904 /* Only continue writes not past the end of buffer. */
1906 if (len
> maxlen
- 1)
1913 /* Start writing from beginning of buffer. */
1919 while ((p
- buffer
) < *lenp
&& len
< maxlen
- 1) {
1920 if (get_user(c
, p
++))
1922 if (c
== 0 || c
== '\n')
1943 if (copy_to_user(buffer
, data
, len
))
1946 if (put_user('\n', buffer
+ len
))
1956 static void warn_sysctl_write(struct ctl_table
*table
)
1958 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1959 "This will not be supported in the future. To silence this\n"
1960 "warning, set kernel.sysctl_writes_strict = -1\n",
1961 current
->comm
, table
->procname
);
1965 * proc_first_pos_non_zero_ignore - check if firs position is allowed
1966 * @ppos: file position
1967 * @table: the sysctl table
1969 * Returns true if the first position is non-zero and the sysctl_writes_strict
1970 * mode indicates this is not allowed for numeric input types. String proc
1971 * hadlers can ignore the return value.
1973 static bool proc_first_pos_non_zero_ignore(loff_t
*ppos
,
1974 struct ctl_table
*table
)
1979 switch (sysctl_writes_strict
) {
1980 case SYSCTL_WRITES_STRICT
:
1982 case SYSCTL_WRITES_WARN
:
1983 warn_sysctl_write(table
);
1991 * proc_dostring - read a string sysctl
1992 * @table: the sysctl table
1993 * @write: %TRUE if this is a write to the sysctl file
1994 * @buffer: the user buffer
1995 * @lenp: the size of the user buffer
1996 * @ppos: file position
1998 * Reads/writes a string from/to the user buffer. If the kernel
1999 * buffer provided is not large enough to hold the string, the
2000 * string is truncated. The copied string is %NULL-terminated.
2001 * If the string is being read by the user process, it is copied
2002 * and a newline '\n' is added. It is truncated if the buffer is
2005 * Returns 0 on success.
2007 int proc_dostring(struct ctl_table
*table
, int write
,
2008 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2011 proc_first_pos_non_zero_ignore(ppos
, table
);
2013 return _proc_do_string((char *)(table
->data
), table
->maxlen
, write
,
2014 (char __user
*)buffer
, lenp
, ppos
);
2017 static size_t proc_skip_spaces(char **buf
)
2020 char *tmp
= skip_spaces(*buf
);
2026 static void proc_skip_char(char **buf
, size_t *size
, const char v
)
2036 #define TMPBUFLEN 22
2038 * proc_get_long - reads an ASCII formatted integer from a user buffer
2040 * @buf: a kernel buffer
2041 * @size: size of the kernel buffer
2042 * @val: this is where the number will be stored
2043 * @neg: set to %TRUE if number is negative
2044 * @perm_tr: a vector which contains the allowed trailers
2045 * @perm_tr_len: size of the perm_tr vector
2046 * @tr: pointer to store the trailer character
2048 * In case of success %0 is returned and @buf and @size are updated with
2049 * the amount of bytes read. If @tr is non-NULL and a trailing
2050 * character exists (size is non-zero after returning from this
2051 * function), @tr is updated with the trailing character.
2053 static int proc_get_long(char **buf
, size_t *size
,
2054 unsigned long *val
, bool *neg
,
2055 const char *perm_tr
, unsigned perm_tr_len
, char *tr
)
2058 char *p
, tmp
[TMPBUFLEN
];
2064 if (len
> TMPBUFLEN
- 1)
2065 len
= TMPBUFLEN
- 1;
2067 memcpy(tmp
, *buf
, len
);
2071 if (*p
== '-' && *size
> 1) {
2079 *val
= simple_strtoul(p
, &p
, 0);
2083 /* We don't know if the next char is whitespace thus we may accept
2084 * invalid integers (e.g. 1234...a) or two integers instead of one
2085 * (e.g. 123...1). So lets not allow such large numbers. */
2086 if (len
== TMPBUFLEN
- 1)
2089 if (len
< *size
&& perm_tr_len
&& !memchr(perm_tr
, *p
, perm_tr_len
))
2092 if (tr
&& (len
< *size
))
2102 * proc_put_long - converts an integer to a decimal ASCII formatted string
2104 * @buf: the user buffer
2105 * @size: the size of the user buffer
2106 * @val: the integer to be converted
2107 * @neg: sign of the number, %TRUE for negative
2109 * In case of success %0 is returned and @buf and @size are updated with
2110 * the amount of bytes written.
2112 static int proc_put_long(void __user
**buf
, size_t *size
, unsigned long val
,
2116 char tmp
[TMPBUFLEN
], *p
= tmp
;
2118 sprintf(p
, "%s%lu", neg
? "-" : "", val
);
2122 if (copy_to_user(*buf
, tmp
, len
))
2130 static int proc_put_char(void __user
**buf
, size_t *size
, char c
)
2133 char __user
**buffer
= (char __user
**)buf
;
2134 if (put_user(c
, *buffer
))
2136 (*size
)--, (*buffer
)++;
2142 static int do_proc_dointvec_conv(bool *negp
, unsigned long *lvalp
,
2144 int write
, void *data
)
2148 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2152 if (*lvalp
> (unsigned long) INT_MAX
)
2160 *lvalp
= -(unsigned long)val
;
2163 *lvalp
= (unsigned long)val
;
2169 static int do_proc_douintvec_conv(unsigned long *lvalp
,
2171 int write
, void *data
)
2174 if (*lvalp
> UINT_MAX
)
2178 unsigned int val
= *valp
;
2179 *lvalp
= (unsigned long)val
;
2184 static const char proc_wspace_sep
[] = { ' ', '\t', '\n' };
2186 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2187 int write
, void __user
*buffer
,
2188 size_t *lenp
, loff_t
*ppos
,
2189 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2190 int write
, void *data
),
2193 int *i
, vleft
, first
= 1, err
= 0;
2195 char *kbuf
= NULL
, *p
;
2197 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2202 i
= (int *) tbl_data
;
2203 vleft
= table
->maxlen
/ sizeof(*i
);
2207 conv
= do_proc_dointvec_conv
;
2210 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2213 if (left
> PAGE_SIZE
- 1)
2214 left
= PAGE_SIZE
- 1;
2215 p
= kbuf
= memdup_user_nul(buffer
, left
);
2217 return PTR_ERR(kbuf
);
2220 for (; left
&& vleft
--; i
++, first
=0) {
2225 left
-= proc_skip_spaces(&p
);
2229 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2231 sizeof(proc_wspace_sep
), NULL
);
2234 if (conv(&neg
, &lval
, i
, 1, data
)) {
2239 if (conv(&neg
, &lval
, i
, 0, data
)) {
2244 err
= proc_put_char(&buffer
, &left
, '\t');
2247 err
= proc_put_long(&buffer
, &left
, lval
, neg
);
2253 if (!write
&& !first
&& left
&& !err
)
2254 err
= proc_put_char(&buffer
, &left
, '\n');
2255 if (write
&& !err
&& left
)
2256 left
-= proc_skip_spaces(&p
);
2260 return err
? : -EINVAL
;
2268 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2269 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2270 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2271 int write
, void *data
),
2274 return __do_proc_dointvec(table
->data
, table
, write
,
2275 buffer
, lenp
, ppos
, conv
, data
);
2278 static int do_proc_douintvec_w(unsigned int *tbl_data
,
2279 struct ctl_table
*table
,
2280 void __user
*buffer
,
2281 size_t *lenp
, loff_t
*ppos
,
2282 int (*conv
)(unsigned long *lvalp
,
2284 int write
, void *data
),
2291 char *kbuf
= NULL
, *p
;
2295 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2298 if (left
> PAGE_SIZE
- 1)
2299 left
= PAGE_SIZE
- 1;
2301 p
= kbuf
= memdup_user_nul(buffer
, left
);
2305 left
-= proc_skip_spaces(&p
);
2311 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2313 sizeof(proc_wspace_sep
), NULL
);
2319 if (conv(&lval
, tbl_data
, 1, data
)) {
2325 left
-= proc_skip_spaces(&p
);
2334 /* This is in keeping with old __do_proc_dointvec() */
2340 static int do_proc_douintvec_r(unsigned int *tbl_data
, void __user
*buffer
,
2341 size_t *lenp
, loff_t
*ppos
,
2342 int (*conv
)(unsigned long *lvalp
,
2344 int write
, void *data
),
2353 if (conv(&lval
, tbl_data
, 0, data
)) {
2358 err
= proc_put_long(&buffer
, &left
, lval
, false);
2362 err
= proc_put_char(&buffer
, &left
, '\n');
2371 static int __do_proc_douintvec(void *tbl_data
, struct ctl_table
*table
,
2372 int write
, void __user
*buffer
,
2373 size_t *lenp
, loff_t
*ppos
,
2374 int (*conv
)(unsigned long *lvalp
,
2376 int write
, void *data
),
2379 unsigned int *i
, vleft
;
2381 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2386 i
= (unsigned int *) tbl_data
;
2387 vleft
= table
->maxlen
/ sizeof(*i
);
2390 * Arrays are not supported, keep this simple. *Do not* add
2399 conv
= do_proc_douintvec_conv
;
2402 return do_proc_douintvec_w(i
, table
, buffer
, lenp
, ppos
,
2404 return do_proc_douintvec_r(i
, buffer
, lenp
, ppos
, conv
, data
);
2407 static int do_proc_douintvec(struct ctl_table
*table
, int write
,
2408 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2409 int (*conv
)(unsigned long *lvalp
,
2411 int write
, void *data
),
2414 return __do_proc_douintvec(table
->data
, table
, write
,
2415 buffer
, lenp
, ppos
, conv
, data
);
2419 * proc_dointvec - read a vector of integers
2420 * @table: the sysctl table
2421 * @write: %TRUE if this is a write to the sysctl file
2422 * @buffer: the user buffer
2423 * @lenp: the size of the user buffer
2424 * @ppos: file position
2426 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2427 * values from/to the user buffer, treated as an ASCII string.
2429 * Returns 0 on success.
2431 int proc_dointvec(struct ctl_table
*table
, int write
,
2432 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2434 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
, NULL
, NULL
);
2438 * proc_douintvec - read a vector of unsigned 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) unsigned integer
2446 * values from/to the user buffer, treated as an ASCII string.
2448 * Returns 0 on success.
2450 int proc_douintvec(struct ctl_table
*table
, int write
,
2451 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2453 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2454 do_proc_douintvec_conv
, NULL
);
2458 * Taint values can only be increased
2459 * This means we can safely use a temporary.
2461 static int proc_taint(struct ctl_table
*table
, int write
,
2462 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2465 unsigned long tmptaint
= get_taint();
2468 if (write
&& !capable(CAP_SYS_ADMIN
))
2473 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2479 * Poor man's atomic or. Not worth adding a primitive
2480 * to everyone's atomic.h for this
2483 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2484 if ((tmptaint
>> i
) & 1)
2485 add_taint(i
, LOCKDEP_STILL_OK
);
2492 #ifdef CONFIG_PRINTK
2493 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
2494 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2496 if (write
&& !capable(CAP_SYS_ADMIN
))
2499 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2503 struct do_proc_dointvec_minmax_conv_param
{
2508 static int do_proc_dointvec_minmax_conv(bool *negp
, unsigned long *lvalp
,
2510 int write
, void *data
)
2512 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2514 int val
= *negp
? -*lvalp
: *lvalp
;
2515 if ((param
->min
&& *param
->min
> val
) ||
2516 (param
->max
&& *param
->max
< val
))
2523 *lvalp
= -(unsigned long)val
;
2526 *lvalp
= (unsigned long)val
;
2533 * proc_dointvec_minmax - read a vector of integers with min/max values
2534 * @table: the sysctl table
2535 * @write: %TRUE if this is a write to the sysctl file
2536 * @buffer: the user buffer
2537 * @lenp: the size of the user buffer
2538 * @ppos: file position
2540 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2541 * values from/to the user buffer, treated as an ASCII string.
2543 * This routine will ensure the values are within the range specified by
2544 * table->extra1 (min) and table->extra2 (max).
2546 * Returns 0 on success.
2548 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2549 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2551 struct do_proc_dointvec_minmax_conv_param param
= {
2552 .min
= (int *) table
->extra1
,
2553 .max
= (int *) table
->extra2
,
2555 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2556 do_proc_dointvec_minmax_conv
, ¶m
);
2559 struct do_proc_douintvec_minmax_conv_param
{
2564 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp
,
2566 int write
, void *data
)
2568 struct do_proc_douintvec_minmax_conv_param
*param
= data
;
2571 unsigned int val
= *lvalp
;
2573 if (*lvalp
> UINT_MAX
)
2576 if ((param
->min
&& *param
->min
> val
) ||
2577 (param
->max
&& *param
->max
< val
))
2582 unsigned int val
= *valp
;
2583 *lvalp
= (unsigned long) val
;
2590 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2591 * @table: the sysctl table
2592 * @write: %TRUE if this is a write to the sysctl file
2593 * @buffer: the user buffer
2594 * @lenp: the size of the user buffer
2595 * @ppos: file position
2597 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2598 * values from/to the user buffer, treated as an ASCII string. Negative
2599 * strings are not allowed.
2601 * This routine will ensure the values are within the range specified by
2602 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2603 * check for UINT_MAX to avoid having to support wrap around uses from
2606 * Returns 0 on success.
2608 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
2609 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2611 struct do_proc_douintvec_minmax_conv_param param
= {
2612 .min
= (unsigned int *) table
->extra1
,
2613 .max
= (unsigned int *) table
->extra2
,
2615 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2616 do_proc_douintvec_minmax_conv
, ¶m
);
2619 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp
,
2621 int write
, void *data
)
2626 val
= round_pipe_size(*lvalp
);
2632 unsigned int val
= *valp
;
2633 *lvalp
= (unsigned long) val
;
2639 static int proc_dopipe_max_size(struct ctl_table
*table
, int write
,
2640 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2642 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2643 do_proc_dopipe_max_size_conv
, NULL
);
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
);
2721 err
= proc_get_long(&p
, &left
, &val
, &neg
,
2723 sizeof(proc_wspace_sep
), NULL
);
2728 val
= convmul
* val
/ convdiv
;
2729 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2733 val
= convdiv
* (*i
) / convmul
;
2735 err
= proc_put_char(&buffer
, &left
, '\t');
2739 err
= proc_put_long(&buffer
, &left
, val
, false);
2745 if (!write
&& !first
&& left
&& !err
)
2746 err
= proc_put_char(&buffer
, &left
, '\n');
2748 left
-= proc_skip_spaces(&p
);
2752 return err
? : -EINVAL
;
2760 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2761 void __user
*buffer
,
2762 size_t *lenp
, loff_t
*ppos
,
2763 unsigned long convmul
,
2764 unsigned long convdiv
)
2766 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2767 buffer
, lenp
, ppos
, convmul
, convdiv
);
2771 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2772 * @table: the sysctl table
2773 * @write: %TRUE if this is a write to the sysctl file
2774 * @buffer: the user buffer
2775 * @lenp: the size of the user buffer
2776 * @ppos: file position
2778 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2779 * values from/to the user buffer, treated as an ASCII string.
2781 * This routine will ensure the values are within the range specified by
2782 * table->extra1 (min) and table->extra2 (max).
2784 * Returns 0 on success.
2786 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2787 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2789 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2793 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2794 * @table: the sysctl table
2795 * @write: %TRUE if this is a write to the sysctl file
2796 * @buffer: the user buffer
2797 * @lenp: the size of the user buffer
2798 * @ppos: file position
2800 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2801 * values from/to the user buffer, treated as an ASCII string. The values
2802 * are treated as milliseconds, and converted to jiffies when they are stored.
2804 * This routine will ensure the values are within the range specified by
2805 * table->extra1 (min) and table->extra2 (max).
2807 * Returns 0 on success.
2809 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2810 void __user
*buffer
,
2811 size_t *lenp
, loff_t
*ppos
)
2813 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2814 lenp
, ppos
, HZ
, 1000l);
2818 static int do_proc_dointvec_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2820 int write
, void *data
)
2823 if (*lvalp
> INT_MAX
/ HZ
)
2825 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2831 lval
= -(unsigned long)val
;
2834 lval
= (unsigned long)val
;
2841 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2843 int write
, void *data
)
2846 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2848 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2854 lval
= -(unsigned long)val
;
2857 lval
= (unsigned long)val
;
2859 *lvalp
= jiffies_to_clock_t(lval
);
2864 static int do_proc_dointvec_ms_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2866 int write
, void *data
)
2869 unsigned long jif
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2879 lval
= -(unsigned long)val
;
2882 lval
= (unsigned long)val
;
2884 *lvalp
= jiffies_to_msecs(lval
);
2890 * proc_dointvec_jiffies - read a vector of integers as seconds
2891 * @table: the sysctl table
2892 * @write: %TRUE if this is a write to the sysctl file
2893 * @buffer: the user buffer
2894 * @lenp: the size of the user buffer
2895 * @ppos: file position
2897 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2898 * values from/to the user buffer, treated as an ASCII string.
2899 * The values read are assumed to be in seconds, and are converted into
2902 * Returns 0 on success.
2904 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2905 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2907 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2908 do_proc_dointvec_jiffies_conv
,NULL
);
2912 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2913 * @table: the sysctl table
2914 * @write: %TRUE if this is a write to the sysctl file
2915 * @buffer: the user buffer
2916 * @lenp: the size of the user buffer
2917 * @ppos: pointer to the file position
2919 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2920 * values from/to the user buffer, treated as an ASCII string.
2921 * The values read are assumed to be in 1/USER_HZ seconds, and
2922 * are converted into jiffies.
2924 * Returns 0 on success.
2926 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2927 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2929 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2930 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2934 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2935 * @table: the sysctl table
2936 * @write: %TRUE if this is a write to the sysctl file
2937 * @buffer: the user buffer
2938 * @lenp: the size of the user buffer
2939 * @ppos: file position
2940 * @ppos: the current position in the file
2942 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2943 * values from/to the user buffer, treated as an ASCII string.
2944 * The values read are assumed to be in 1/1000 seconds, and
2945 * are converted into jiffies.
2947 * Returns 0 on success.
2949 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2950 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2952 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2953 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2956 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
2957 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2959 struct pid
*new_pid
;
2963 tmp
= pid_vnr(cad_pid
);
2965 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
2966 lenp
, ppos
, NULL
, NULL
);
2970 new_pid
= find_get_pid(tmp
);
2974 put_pid(xchg(&cad_pid
, new_pid
));
2979 * proc_do_large_bitmap - read/write from/to a large bitmap
2980 * @table: the sysctl table
2981 * @write: %TRUE if this is a write to the sysctl file
2982 * @buffer: the user buffer
2983 * @lenp: the size of the user buffer
2984 * @ppos: file position
2986 * The bitmap is stored at table->data and the bitmap length (in bits)
2989 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2990 * large bitmaps may be represented in a compact manner. Writing into
2991 * the file will clear the bitmap then update it with the given input.
2993 * Returns 0 on success.
2995 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
2996 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3000 size_t left
= *lenp
;
3001 unsigned long bitmap_len
= table
->maxlen
;
3002 unsigned long *bitmap
= *(unsigned long **) table
->data
;
3003 unsigned long *tmp_bitmap
= NULL
;
3004 char tr_a
[] = { '-', ',', '\n' }, tr_b
[] = { ',', '\n', 0 }, c
;
3006 if (!bitmap
|| !bitmap_len
|| !left
|| (*ppos
&& !write
)) {
3014 if (left
> PAGE_SIZE
- 1)
3015 left
= PAGE_SIZE
- 1;
3017 p
= kbuf
= memdup_user_nul(buffer
, left
);
3019 return PTR_ERR(kbuf
);
3021 tmp_bitmap
= kzalloc(BITS_TO_LONGS(bitmap_len
) * sizeof(unsigned long),
3027 proc_skip_char(&p
, &left
, '\n');
3028 while (!err
&& left
) {
3029 unsigned long val_a
, val_b
;
3032 err
= proc_get_long(&p
, &left
, &val_a
, &neg
, tr_a
,
3036 if (val_a
>= bitmap_len
|| neg
) {
3048 err
= proc_get_long(&p
, &left
, &val_b
,
3049 &neg
, tr_b
, sizeof(tr_b
),
3053 if (val_b
>= bitmap_len
|| neg
||
3064 bitmap_set(tmp_bitmap
, val_a
, val_b
- val_a
+ 1);
3066 proc_skip_char(&p
, &left
, '\n');
3070 unsigned long bit_a
, bit_b
= 0;
3073 bit_a
= find_next_bit(bitmap
, bitmap_len
, bit_b
);
3074 if (bit_a
>= bitmap_len
)
3076 bit_b
= find_next_zero_bit(bitmap
, bitmap_len
,
3080 err
= proc_put_char(&buffer
, &left
, ',');
3084 err
= proc_put_long(&buffer
, &left
, bit_a
, false);
3087 if (bit_a
!= bit_b
) {
3088 err
= proc_put_char(&buffer
, &left
, '-');
3091 err
= proc_put_long(&buffer
, &left
, bit_b
, false);
3099 err
= proc_put_char(&buffer
, &left
, '\n');
3105 bitmap_or(bitmap
, bitmap
, tmp_bitmap
, bitmap_len
);
3107 bitmap_copy(bitmap
, tmp_bitmap
, bitmap_len
);
3117 #else /* CONFIG_PROC_SYSCTL */
3119 int proc_dostring(struct ctl_table
*table
, int write
,
3120 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3125 int proc_dointvec(struct ctl_table
*table
, int write
,
3126 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3131 int proc_douintvec(struct ctl_table
*table
, int write
,
3132 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3137 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
3138 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3143 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
3144 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3149 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
3150 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3155 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
3156 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3161 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
3162 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3167 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
3168 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3173 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
3174 void __user
*buffer
,
3175 size_t *lenp
, loff_t
*ppos
)
3181 #endif /* CONFIG_PROC_SYSCTL */
3184 * No sense putting this after each symbol definition, twice,
3185 * exception granted :-)
3187 EXPORT_SYMBOL(proc_dointvec
);
3188 EXPORT_SYMBOL(proc_douintvec
);
3189 EXPORT_SYMBOL(proc_dointvec_jiffies
);
3190 EXPORT_SYMBOL(proc_dointvec_minmax
);
3191 EXPORT_SYMBOL_GPL(proc_douintvec_minmax
);
3192 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
3193 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
3194 EXPORT_SYMBOL(proc_dostring
);
3195 EXPORT_SYMBOL(proc_doulongvec_minmax
);
3196 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);