2 * sysctl.c: General linux system control interface
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
21 #include <linux/module.h>
22 #include <linux/aio.h>
24 #include <linux/swap.h>
25 #include <linux/slab.h>
26 #include <linux/sysctl.h>
27 #include <linux/bitmap.h>
28 #include <linux/signal.h>
29 #include <linux/printk.h>
30 #include <linux/proc_fs.h>
31 #include <linux/security.h>
32 #include <linux/ctype.h>
33 #include <linux/kmemcheck.h>
34 #include <linux/kmemleak.h>
36 #include <linux/init.h>
37 #include <linux/kernel.h>
38 #include <linux/kobject.h>
39 #include <linux/net.h>
40 #include <linux/sysrq.h>
41 #include <linux/highuid.h>
42 #include <linux/writeback.h>
43 #include <linux/ratelimit.h>
44 #include <linux/compaction.h>
45 #include <linux/hugetlb.h>
46 #include <linux/initrd.h>
47 #include <linux/key.h>
48 #include <linux/times.h>
49 #include <linux/limits.h>
50 #include <linux/dcache.h>
51 #include <linux/dnotify.h>
52 #include <linux/syscalls.h>
53 #include <linux/vmstat.h>
54 #include <linux/nfs_fs.h>
55 #include <linux/acpi.h>
56 #include <linux/reboot.h>
57 #include <linux/ftrace.h>
58 #include <linux/perf_event.h>
59 #include <linux/kprobes.h>
60 #include <linux/pipe_fs_i.h>
61 #include <linux/oom.h>
62 #include <linux/kmod.h>
63 #include <linux/capability.h>
64 #include <linux/binfmts.h>
65 #include <linux/sched/sysctl.h>
66 #include <linux/sched/coredump.h>
67 #include <linux/kexec.h>
68 #include <linux/bpf.h>
69 #include <linux/mount.h>
71 #include <linux/uaccess.h>
72 #include <linux/mutex.h>
73 #include <asm/processor.h>
78 #include <asm/stacktrace.h>
82 #include <asm/setup.h>
84 #ifdef CONFIG_BSD_PROCESS_ACCT
85 #include <linux/acct.h>
87 #ifdef CONFIG_RT_MUTEXES
88 #include <linux/rtmutex.h>
90 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
91 #include <linux/lockdep.h>
93 #ifdef CONFIG_CHR_DEV_SG
97 #ifdef CONFIG_LOCKUP_DETECTOR
98 #include <linux/nmi.h>
101 #if defined(CONFIG_SYSCTL)
103 /* External variables not in a header file. */
104 extern int suid_dumpable
;
105 #ifdef CONFIG_COREDUMP
106 extern int core_uses_pid
;
107 extern char core_pattern
[];
108 extern unsigned int core_pipe_limit
;
110 #ifdef CONFIG_USER_NS
111 extern int unprivileged_userns_clone
;
114 extern int pid_max_min
, pid_max_max
;
115 extern int percpu_pagelist_fraction
;
116 extern int latencytop_enabled
;
117 extern unsigned int sysctl_nr_open_min
, sysctl_nr_open_max
;
119 extern int sysctl_nr_trim_pages
;
122 /* Constants used for minimum and maximum */
123 #ifdef CONFIG_LOCKUP_DETECTOR
124 static int sixty
= 60;
127 static int __maybe_unused neg_one
= -1;
130 static int __maybe_unused one
= 1;
131 static int __maybe_unused two
= 2;
132 static int __maybe_unused four
= 4;
133 static unsigned long one_ul
= 1;
134 static int one_hundred
= 100;
135 static int one_thousand
= 1000;
137 static int ten_thousand
= 10000;
139 #ifdef CONFIG_PERF_EVENTS
140 static int six_hundred_forty_kb
= 640 * 1024;
143 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
144 static unsigned long dirty_bytes_min
= 2 * PAGE_SIZE
;
146 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
147 static int maxolduid
= 65535;
148 static int minolduid
;
150 static int ngroups_max
= NGROUPS_MAX
;
151 static const int cap_last_cap
= CAP_LAST_CAP
;
153 /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
154 #ifdef CONFIG_DETECT_HUNG_TASK
155 static unsigned long hung_task_timeout_max
= (LONG_MAX
/HZ
);
158 #ifdef CONFIG_INOTIFY_USER
159 #include <linux/inotify.h>
165 extern int pwrsw_enabled
;
168 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
169 extern int unaligned_enabled
;
173 extern int unaligned_dump_stack
;
176 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
177 extern int no_unaligned_warning
;
180 #ifdef CONFIG_PROC_SYSCTL
183 * enum sysctl_writes_mode - supported sysctl write modes
185 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
186 * to be written, and multiple writes on the same sysctl file descriptor
187 * will rewrite the sysctl value, regardless of file position. No warning
188 * is issued when the initial position is not 0.
189 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
191 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
192 * file position 0 and the value must be fully contained in the buffer
193 * sent to the write syscall. If dealing with strings respect the file
194 * position, but restrict this to the max length of the buffer, anything
195 * passed the max lenght will be ignored. Multiple writes will append
198 * These write modes control how current file position affects the behavior of
199 * updating sysctl values through the proc interface on each write.
201 enum sysctl_writes_mode
{
202 SYSCTL_WRITES_LEGACY
= -1,
203 SYSCTL_WRITES_WARN
= 0,
204 SYSCTL_WRITES_STRICT
= 1,
207 static enum sysctl_writes_mode sysctl_writes_strict
= SYSCTL_WRITES_STRICT
;
209 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
210 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
211 static int proc_taint(struct ctl_table
*table
, int write
,
212 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
216 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
217 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
220 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
221 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
222 #ifdef CONFIG_COREDUMP
223 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
224 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
228 int proc_dointvec_ibrs_ctrl(struct ctl_table
*table
, int write
,
229 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
230 int proc_dointvec_ibpb_ctrl(struct ctl_table
*table
, int write
,
231 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
234 #ifdef CONFIG_MAGIC_SYSRQ
235 /* Note: sysrq code uses it's own private copy */
236 static int __sysrq_enabled
= CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE
;
238 static int sysrq_sysctl_handler(struct ctl_table
*table
, int write
,
239 void __user
*buffer
, size_t *lenp
,
244 error
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
249 sysrq_toggle_support(__sysrq_enabled
);
256 static struct ctl_table kern_table
[];
257 static struct ctl_table vm_table
[];
258 static struct ctl_table fs_table
[];
259 static struct ctl_table debug_table
[];
260 static struct ctl_table dev_table
[];
261 extern struct ctl_table random_table
[];
263 extern struct ctl_table epoll_table
[];
266 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
267 int sysctl_legacy_va_layout
;
270 u32 sysctl_ibrs_enabled
= 0;
271 EXPORT_SYMBOL(sysctl_ibrs_enabled
);
272 u32 sysctl_ibpb_enabled
= 0;
273 EXPORT_SYMBOL(sysctl_ibpb_enabled
);
275 /* The default sysctl tables: */
277 static struct ctl_table sysctl_base_table
[] = {
279 .procname
= "kernel",
296 .child
= debug_table
,
306 #ifdef CONFIG_SCHED_DEBUG
307 static int min_sched_granularity_ns
= 100000; /* 100 usecs */
308 static int max_sched_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
309 static int min_wakeup_granularity_ns
; /* 0 usecs */
310 static int max_wakeup_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
312 static int min_sched_tunable_scaling
= SCHED_TUNABLESCALING_NONE
;
313 static int max_sched_tunable_scaling
= SCHED_TUNABLESCALING_END
-1;
314 #endif /* CONFIG_SMP */
315 #endif /* CONFIG_SCHED_DEBUG */
317 #ifdef CONFIG_COMPACTION
318 static int min_extfrag_threshold
;
319 static int max_extfrag_threshold
= 1000;
322 static struct ctl_table kern_table
[] = {
324 .procname
= "sched_child_runs_first",
325 .data
= &sysctl_sched_child_runs_first
,
326 .maxlen
= sizeof(unsigned int),
328 .proc_handler
= proc_dointvec
,
330 #ifdef CONFIG_SCHED_DEBUG
332 .procname
= "sched_min_granularity_ns",
333 .data
= &sysctl_sched_min_granularity
,
334 .maxlen
= sizeof(unsigned int),
336 .proc_handler
= sched_proc_update_handler
,
337 .extra1
= &min_sched_granularity_ns
,
338 .extra2
= &max_sched_granularity_ns
,
341 .procname
= "sched_latency_ns",
342 .data
= &sysctl_sched_latency
,
343 .maxlen
= sizeof(unsigned int),
345 .proc_handler
= sched_proc_update_handler
,
346 .extra1
= &min_sched_granularity_ns
,
347 .extra2
= &max_sched_granularity_ns
,
350 .procname
= "sched_wakeup_granularity_ns",
351 .data
= &sysctl_sched_wakeup_granularity
,
352 .maxlen
= sizeof(unsigned int),
354 .proc_handler
= sched_proc_update_handler
,
355 .extra1
= &min_wakeup_granularity_ns
,
356 .extra2
= &max_wakeup_granularity_ns
,
360 .procname
= "sched_tunable_scaling",
361 .data
= &sysctl_sched_tunable_scaling
,
362 .maxlen
= sizeof(enum sched_tunable_scaling
),
364 .proc_handler
= sched_proc_update_handler
,
365 .extra1
= &min_sched_tunable_scaling
,
366 .extra2
= &max_sched_tunable_scaling
,
369 .procname
= "sched_migration_cost_ns",
370 .data
= &sysctl_sched_migration_cost
,
371 .maxlen
= sizeof(unsigned int),
373 .proc_handler
= proc_dointvec
,
376 .procname
= "sched_nr_migrate",
377 .data
= &sysctl_sched_nr_migrate
,
378 .maxlen
= sizeof(unsigned int),
380 .proc_handler
= proc_dointvec
,
383 .procname
= "sched_time_avg_ms",
384 .data
= &sysctl_sched_time_avg
,
385 .maxlen
= sizeof(unsigned int),
387 .proc_handler
= proc_dointvec_minmax
,
390 #ifdef CONFIG_SCHEDSTATS
392 .procname
= "sched_schedstats",
394 .maxlen
= sizeof(unsigned int),
396 .proc_handler
= sysctl_schedstats
,
400 #endif /* CONFIG_SCHEDSTATS */
401 #endif /* CONFIG_SMP */
402 #ifdef CONFIG_NUMA_BALANCING
404 .procname
= "numa_balancing_scan_delay_ms",
405 .data
= &sysctl_numa_balancing_scan_delay
,
406 .maxlen
= sizeof(unsigned int),
408 .proc_handler
= proc_dointvec
,
411 .procname
= "numa_balancing_scan_period_min_ms",
412 .data
= &sysctl_numa_balancing_scan_period_min
,
413 .maxlen
= sizeof(unsigned int),
415 .proc_handler
= proc_dointvec
,
418 .procname
= "numa_balancing_scan_period_max_ms",
419 .data
= &sysctl_numa_balancing_scan_period_max
,
420 .maxlen
= sizeof(unsigned int),
422 .proc_handler
= proc_dointvec
,
425 .procname
= "numa_balancing_scan_size_mb",
426 .data
= &sysctl_numa_balancing_scan_size
,
427 .maxlen
= sizeof(unsigned int),
429 .proc_handler
= proc_dointvec_minmax
,
433 .procname
= "numa_balancing",
434 .data
= NULL
, /* filled in by handler */
435 .maxlen
= sizeof(unsigned int),
437 .proc_handler
= sysctl_numa_balancing
,
441 #endif /* CONFIG_NUMA_BALANCING */
442 #endif /* CONFIG_SCHED_DEBUG */
444 .procname
= "sched_rt_period_us",
445 .data
= &sysctl_sched_rt_period
,
446 .maxlen
= sizeof(unsigned int),
448 .proc_handler
= sched_rt_handler
,
451 .procname
= "sched_rt_runtime_us",
452 .data
= &sysctl_sched_rt_runtime
,
453 .maxlen
= sizeof(int),
455 .proc_handler
= sched_rt_handler
,
458 .procname
= "sched_rr_timeslice_ms",
459 .data
= &sysctl_sched_rr_timeslice
,
460 .maxlen
= sizeof(int),
462 .proc_handler
= sched_rr_handler
,
464 #ifdef CONFIG_SCHED_AUTOGROUP
466 .procname
= "sched_autogroup_enabled",
467 .data
= &sysctl_sched_autogroup_enabled
,
468 .maxlen
= sizeof(unsigned int),
470 .proc_handler
= proc_dointvec_minmax
,
475 #ifdef CONFIG_CFS_BANDWIDTH
477 .procname
= "sched_cfs_bandwidth_slice_us",
478 .data
= &sysctl_sched_cfs_bandwidth_slice
,
479 .maxlen
= sizeof(unsigned int),
481 .proc_handler
= proc_dointvec_minmax
,
485 #ifdef CONFIG_PROVE_LOCKING
487 .procname
= "prove_locking",
488 .data
= &prove_locking
,
489 .maxlen
= sizeof(int),
491 .proc_handler
= proc_dointvec
,
494 #ifdef CONFIG_LOCK_STAT
496 .procname
= "lock_stat",
498 .maxlen
= sizeof(int),
500 .proc_handler
= proc_dointvec
,
505 .data
= &panic_timeout
,
506 .maxlen
= sizeof(int),
508 .proc_handler
= proc_dointvec
,
510 #ifdef CONFIG_COREDUMP
512 .procname
= "core_uses_pid",
513 .data
= &core_uses_pid
,
514 .maxlen
= sizeof(int),
516 .proc_handler
= proc_dointvec
,
519 .procname
= "core_pattern",
520 .data
= core_pattern
,
521 .maxlen
= CORENAME_MAX_SIZE
,
523 .proc_handler
= proc_dostring_coredump
,
526 .procname
= "core_pipe_limit",
527 .data
= &core_pipe_limit
,
528 .maxlen
= sizeof(unsigned int),
530 .proc_handler
= proc_dointvec
,
533 #ifdef CONFIG_USER_NS
535 .procname
= "unprivileged_userns_clone",
536 .data
= &unprivileged_userns_clone
,
537 .maxlen
= sizeof(int),
539 .proc_handler
= proc_dointvec
,
542 #ifdef CONFIG_PROC_SYSCTL
544 .procname
= "tainted",
545 .maxlen
= sizeof(long),
547 .proc_handler
= proc_taint
,
550 .procname
= "sysctl_writes_strict",
551 .data
= &sysctl_writes_strict
,
552 .maxlen
= sizeof(int),
554 .proc_handler
= proc_dointvec_minmax
,
559 #ifdef CONFIG_LATENCYTOP
561 .procname
= "latencytop",
562 .data
= &latencytop_enabled
,
563 .maxlen
= sizeof(int),
565 .proc_handler
= sysctl_latencytop
,
568 #ifdef CONFIG_BLK_DEV_INITRD
570 .procname
= "real-root-dev",
571 .data
= &real_root_dev
,
572 .maxlen
= sizeof(int),
574 .proc_handler
= proc_dointvec
,
578 .procname
= "print-fatal-signals",
579 .data
= &print_fatal_signals
,
580 .maxlen
= sizeof(int),
582 .proc_handler
= proc_dointvec
,
586 .procname
= "reboot-cmd",
587 .data
= reboot_command
,
590 .proc_handler
= proc_dostring
,
593 .procname
= "stop-a",
594 .data
= &stop_a_enabled
,
595 .maxlen
= sizeof (int),
597 .proc_handler
= proc_dointvec
,
600 .procname
= "scons-poweroff",
601 .data
= &scons_pwroff
,
602 .maxlen
= sizeof (int),
604 .proc_handler
= proc_dointvec
,
607 #ifdef CONFIG_SPARC64
609 .procname
= "tsb-ratio",
610 .data
= &sysctl_tsb_ratio
,
611 .maxlen
= sizeof (int),
613 .proc_handler
= proc_dointvec
,
618 .procname
= "soft-power",
619 .data
= &pwrsw_enabled
,
620 .maxlen
= sizeof (int),
622 .proc_handler
= proc_dointvec
,
625 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
627 .procname
= "unaligned-trap",
628 .data
= &unaligned_enabled
,
629 .maxlen
= sizeof (int),
631 .proc_handler
= proc_dointvec
,
635 .procname
= "ctrl-alt-del",
637 .maxlen
= sizeof(int),
639 .proc_handler
= proc_dointvec
,
641 #ifdef CONFIG_FUNCTION_TRACER
643 .procname
= "ftrace_enabled",
644 .data
= &ftrace_enabled
,
645 .maxlen
= sizeof(int),
647 .proc_handler
= ftrace_enable_sysctl
,
650 #ifdef CONFIG_STACK_TRACER
652 .procname
= "stack_tracer_enabled",
653 .data
= &stack_tracer_enabled
,
654 .maxlen
= sizeof(int),
656 .proc_handler
= stack_trace_sysctl
,
659 #ifdef CONFIG_TRACING
661 .procname
= "ftrace_dump_on_oops",
662 .data
= &ftrace_dump_on_oops
,
663 .maxlen
= sizeof(int),
665 .proc_handler
= proc_dointvec
,
668 .procname
= "traceoff_on_warning",
669 .data
= &__disable_trace_on_warning
,
670 .maxlen
= sizeof(__disable_trace_on_warning
),
672 .proc_handler
= proc_dointvec
,
675 .procname
= "tracepoint_printk",
676 .data
= &tracepoint_printk
,
677 .maxlen
= sizeof(tracepoint_printk
),
679 .proc_handler
= tracepoint_printk_sysctl
,
682 #ifdef CONFIG_KEXEC_CORE
684 .procname
= "kexec_load_disabled",
685 .data
= &kexec_load_disabled
,
686 .maxlen
= sizeof(int),
688 /* only handle a transition from default "0" to "1" */
689 .proc_handler
= proc_dointvec_minmax
,
694 #ifdef CONFIG_MODULES
696 .procname
= "modprobe",
697 .data
= &modprobe_path
,
698 .maxlen
= KMOD_PATH_LEN
,
700 .proc_handler
= proc_dostring
,
703 .procname
= "modules_disabled",
704 .data
= &modules_disabled
,
705 .maxlen
= sizeof(int),
707 /* only handle a transition from default "0" to "1" */
708 .proc_handler
= proc_dointvec_minmax
,
713 #ifdef CONFIG_UEVENT_HELPER
715 .procname
= "hotplug",
716 .data
= &uevent_helper
,
717 .maxlen
= UEVENT_HELPER_PATH_LEN
,
719 .proc_handler
= proc_dostring
,
722 #ifdef CONFIG_CHR_DEV_SG
724 .procname
= "sg-big-buff",
725 .data
= &sg_big_buff
,
726 .maxlen
= sizeof (int),
728 .proc_handler
= proc_dointvec
,
731 #ifdef CONFIG_BSD_PROCESS_ACCT
735 .maxlen
= 3*sizeof(int),
737 .proc_handler
= proc_dointvec
,
740 #ifdef CONFIG_MAGIC_SYSRQ
743 .data
= &__sysrq_enabled
,
744 .maxlen
= sizeof (int),
746 .proc_handler
= sysrq_sysctl_handler
,
749 #ifdef CONFIG_PROC_SYSCTL
751 .procname
= "cad_pid",
753 .maxlen
= sizeof (int),
755 .proc_handler
= proc_do_cad_pid
,
759 .procname
= "threads-max",
761 .maxlen
= sizeof(int),
763 .proc_handler
= sysctl_max_threads
,
766 .procname
= "random",
768 .child
= random_table
,
771 .procname
= "usermodehelper",
773 .child
= usermodehelper_table
,
776 .procname
= "overflowuid",
777 .data
= &overflowuid
,
778 .maxlen
= sizeof(int),
780 .proc_handler
= proc_dointvec_minmax
,
781 .extra1
= &minolduid
,
782 .extra2
= &maxolduid
,
785 .procname
= "overflowgid",
786 .data
= &overflowgid
,
787 .maxlen
= sizeof(int),
789 .proc_handler
= proc_dointvec_minmax
,
790 .extra1
= &minolduid
,
791 .extra2
= &maxolduid
,
794 #ifdef CONFIG_MATHEMU
796 .procname
= "ieee_emulation_warnings",
797 .data
= &sysctl_ieee_emulation_warnings
,
798 .maxlen
= sizeof(int),
800 .proc_handler
= proc_dointvec
,
804 .procname
= "userprocess_debug",
805 .data
= &show_unhandled_signals
,
806 .maxlen
= sizeof(int),
808 .proc_handler
= proc_dointvec
,
812 .procname
= "pid_max",
814 .maxlen
= sizeof (int),
816 .proc_handler
= proc_dointvec_minmax
,
817 .extra1
= &pid_max_min
,
818 .extra2
= &pid_max_max
,
821 .procname
= "panic_on_oops",
822 .data
= &panic_on_oops
,
823 .maxlen
= sizeof(int),
825 .proc_handler
= proc_dointvec
,
827 #if defined CONFIG_PRINTK
829 .procname
= "printk",
830 .data
= &console_loglevel
,
831 .maxlen
= 4*sizeof(int),
833 .proc_handler
= proc_dointvec
,
836 .procname
= "printk_ratelimit",
837 .data
= &printk_ratelimit_state
.interval
,
838 .maxlen
= sizeof(int),
840 .proc_handler
= proc_dointvec_jiffies
,
843 .procname
= "printk_ratelimit_burst",
844 .data
= &printk_ratelimit_state
.burst
,
845 .maxlen
= sizeof(int),
847 .proc_handler
= proc_dointvec
,
850 .procname
= "printk_delay",
851 .data
= &printk_delay_msec
,
852 .maxlen
= sizeof(int),
854 .proc_handler
= proc_dointvec_minmax
,
856 .extra2
= &ten_thousand
,
859 .procname
= "printk_devkmsg",
860 .data
= devkmsg_log_str
,
861 .maxlen
= DEVKMSG_STR_MAX_SIZE
,
863 .proc_handler
= devkmsg_sysctl_set_loglvl
,
866 .procname
= "dmesg_restrict",
867 .data
= &dmesg_restrict
,
868 .maxlen
= sizeof(int),
870 .proc_handler
= proc_dointvec_minmax_sysadmin
,
875 .procname
= "kptr_restrict",
876 .data
= &kptr_restrict
,
877 .maxlen
= sizeof(int),
879 .proc_handler
= proc_dointvec_minmax_sysadmin
,
885 .procname
= "ngroups_max",
886 .data
= &ngroups_max
,
887 .maxlen
= sizeof (int),
889 .proc_handler
= proc_dointvec
,
892 .procname
= "cap_last_cap",
893 .data
= (void *)&cap_last_cap
,
894 .maxlen
= sizeof(int),
896 .proc_handler
= proc_dointvec
,
898 #if defined(CONFIG_LOCKUP_DETECTOR)
900 .procname
= "watchdog",
901 .data
= &watchdog_user_enabled
,
902 .maxlen
= sizeof (int),
904 .proc_handler
= proc_watchdog
,
909 .procname
= "watchdog_thresh",
910 .data
= &watchdog_thresh
,
911 .maxlen
= sizeof(int),
913 .proc_handler
= proc_watchdog_thresh
,
918 .procname
= "nmi_watchdog",
919 .data
= &nmi_watchdog_enabled
,
920 .maxlen
= sizeof (int),
922 .proc_handler
= proc_nmi_watchdog
,
924 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
931 .procname
= "watchdog_cpumask",
932 .data
= &watchdog_cpumask_bits
,
935 .proc_handler
= proc_watchdog_cpumask
,
937 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
939 .procname
= "soft_watchdog",
940 .data
= &soft_watchdog_enabled
,
941 .maxlen
= sizeof (int),
943 .proc_handler
= proc_soft_watchdog
,
948 .procname
= "softlockup_panic",
949 .data
= &softlockup_panic
,
950 .maxlen
= sizeof(int),
952 .proc_handler
= proc_dointvec_minmax
,
958 .procname
= "softlockup_all_cpu_backtrace",
959 .data
= &sysctl_softlockup_all_cpu_backtrace
,
960 .maxlen
= sizeof(int),
962 .proc_handler
= proc_dointvec_minmax
,
966 #endif /* CONFIG_SMP */
968 #ifdef CONFIG_HARDLOCKUP_DETECTOR
970 .procname
= "hardlockup_panic",
971 .data
= &hardlockup_panic
,
972 .maxlen
= sizeof(int),
974 .proc_handler
= proc_dointvec_minmax
,
980 .procname
= "hardlockup_all_cpu_backtrace",
981 .data
= &sysctl_hardlockup_all_cpu_backtrace
,
982 .maxlen
= sizeof(int),
984 .proc_handler
= proc_dointvec_minmax
,
988 #endif /* CONFIG_SMP */
992 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
994 .procname
= "unknown_nmi_panic",
995 .data
= &unknown_nmi_panic
,
996 .maxlen
= sizeof (int),
998 .proc_handler
= proc_dointvec
,
1001 #if defined(CONFIG_X86)
1003 .procname
= "panic_on_unrecovered_nmi",
1004 .data
= &panic_on_unrecovered_nmi
,
1005 .maxlen
= sizeof(int),
1007 .proc_handler
= proc_dointvec
,
1010 .procname
= "panic_on_io_nmi",
1011 .data
= &panic_on_io_nmi
,
1012 .maxlen
= sizeof(int),
1014 .proc_handler
= proc_dointvec
,
1016 #ifdef CONFIG_DEBUG_STACKOVERFLOW
1018 .procname
= "panic_on_stackoverflow",
1019 .data
= &sysctl_panic_on_stackoverflow
,
1020 .maxlen
= sizeof(int),
1022 .proc_handler
= proc_dointvec
,
1026 .procname
= "bootloader_type",
1027 .data
= &bootloader_type
,
1028 .maxlen
= sizeof (int),
1030 .proc_handler
= proc_dointvec
,
1033 .procname
= "bootloader_version",
1034 .data
= &bootloader_version
,
1035 .maxlen
= sizeof (int),
1037 .proc_handler
= proc_dointvec
,
1040 .procname
= "io_delay_type",
1041 .data
= &io_delay_type
,
1042 .maxlen
= sizeof(int),
1044 .proc_handler
= proc_dointvec
,
1047 #if defined(CONFIG_MMU)
1049 .procname
= "randomize_va_space",
1050 .data
= &randomize_va_space
,
1051 .maxlen
= sizeof(int),
1053 .proc_handler
= proc_dointvec
,
1056 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1058 .procname
= "spin_retry",
1059 .data
= &spin_retry
,
1060 .maxlen
= sizeof (int),
1062 .proc_handler
= proc_dointvec
,
1065 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1067 .procname
= "acpi_video_flags",
1068 .data
= &acpi_realmode_flags
,
1069 .maxlen
= sizeof (unsigned long),
1071 .proc_handler
= proc_doulongvec_minmax
,
1074 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1076 .procname
= "ignore-unaligned-usertrap",
1077 .data
= &no_unaligned_warning
,
1078 .maxlen
= sizeof (int),
1080 .proc_handler
= proc_dointvec
,
1085 .procname
= "unaligned-dump-stack",
1086 .data
= &unaligned_dump_stack
,
1087 .maxlen
= sizeof (int),
1089 .proc_handler
= proc_dointvec
,
1092 #ifdef CONFIG_DETECT_HUNG_TASK
1094 .procname
= "hung_task_panic",
1095 .data
= &sysctl_hung_task_panic
,
1096 .maxlen
= sizeof(int),
1098 .proc_handler
= proc_dointvec_minmax
,
1103 .procname
= "hung_task_check_count",
1104 .data
= &sysctl_hung_task_check_count
,
1105 .maxlen
= sizeof(int),
1107 .proc_handler
= proc_dointvec_minmax
,
1111 .procname
= "hung_task_timeout_secs",
1112 .data
= &sysctl_hung_task_timeout_secs
,
1113 .maxlen
= sizeof(unsigned long),
1115 .proc_handler
= proc_dohung_task_timeout_secs
,
1116 .extra2
= &hung_task_timeout_max
,
1119 .procname
= "hung_task_warnings",
1120 .data
= &sysctl_hung_task_warnings
,
1121 .maxlen
= sizeof(int),
1123 .proc_handler
= proc_dointvec_minmax
,
1127 #ifdef CONFIG_RT_MUTEXES
1129 .procname
= "max_lock_depth",
1130 .data
= &max_lock_depth
,
1131 .maxlen
= sizeof(int),
1133 .proc_handler
= proc_dointvec
,
1137 .procname
= "poweroff_cmd",
1138 .data
= &poweroff_cmd
,
1139 .maxlen
= POWEROFF_CMD_PATH_LEN
,
1141 .proc_handler
= proc_dostring
,
1147 .child
= key_sysctls
,
1150 #ifdef CONFIG_PERF_EVENTS
1152 * User-space scripts rely on the existence of this file
1153 * as a feature check for perf_events being enabled.
1155 * So it's an ABI, do not remove!
1158 .procname
= "perf_event_paranoid",
1159 .data
= &sysctl_perf_event_paranoid
,
1160 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
1162 .proc_handler
= proc_dointvec
,
1165 .procname
= "perf_event_mlock_kb",
1166 .data
= &sysctl_perf_event_mlock
,
1167 .maxlen
= sizeof(sysctl_perf_event_mlock
),
1169 .proc_handler
= proc_dointvec
,
1172 .procname
= "perf_event_max_sample_rate",
1173 .data
= &sysctl_perf_event_sample_rate
,
1174 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1176 .proc_handler
= perf_proc_update_handler
,
1180 .procname
= "perf_cpu_time_max_percent",
1181 .data
= &sysctl_perf_cpu_time_max_percent
,
1182 .maxlen
= sizeof(sysctl_perf_cpu_time_max_percent
),
1184 .proc_handler
= perf_cpu_time_max_percent_handler
,
1186 .extra2
= &one_hundred
,
1189 .procname
= "perf_event_max_stack",
1190 .data
= &sysctl_perf_event_max_stack
,
1191 .maxlen
= sizeof(sysctl_perf_event_max_stack
),
1193 .proc_handler
= perf_event_max_stack_handler
,
1195 .extra2
= &six_hundred_forty_kb
,
1198 .procname
= "perf_event_max_contexts_per_stack",
1199 .data
= &sysctl_perf_event_max_contexts_per_stack
,
1200 .maxlen
= sizeof(sysctl_perf_event_max_contexts_per_stack
),
1202 .proc_handler
= perf_event_max_stack_handler
,
1204 .extra2
= &one_thousand
,
1207 #ifdef CONFIG_KMEMCHECK
1209 .procname
= "kmemcheck",
1210 .data
= &kmemcheck_enabled
,
1211 .maxlen
= sizeof(int),
1213 .proc_handler
= proc_dointvec
,
1217 .procname
= "panic_on_warn",
1218 .data
= &panic_on_warn
,
1219 .maxlen
= sizeof(int),
1221 .proc_handler
= proc_dointvec_minmax
,
1225 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1227 .procname
= "timer_migration",
1228 .data
= &sysctl_timer_migration
,
1229 .maxlen
= sizeof(unsigned int),
1231 .proc_handler
= timer_migration_handler
,
1236 #ifdef CONFIG_BPF_SYSCALL
1238 .procname
= "unprivileged_bpf_disabled",
1239 .data
= &sysctl_unprivileged_bpf_disabled
,
1240 .maxlen
= sizeof(sysctl_unprivileged_bpf_disabled
),
1242 /* only handle a transition from default "0" to "1" */
1243 .proc_handler
= proc_dointvec_minmax
,
1248 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1250 .procname
= "panic_on_rcu_stall",
1251 .data
= &sysctl_panic_on_rcu_stall
,
1252 .maxlen
= sizeof(sysctl_panic_on_rcu_stall
),
1254 .proc_handler
= proc_dointvec_minmax
,
1261 .procname
= "ibrs_enabled",
1262 .data
= &sysctl_ibrs_enabled
,
1263 .maxlen
= sizeof(unsigned int),
1265 .proc_handler
= proc_dointvec_ibrs_ctrl
,
1270 .procname
= "ibpb_enabled",
1271 .data
= &sysctl_ibpb_enabled
,
1272 .maxlen
= sizeof(unsigned int),
1274 .proc_handler
= proc_dointvec_ibpb_ctrl
,
1282 static struct ctl_table vm_table
[] = {
1284 .procname
= "overcommit_memory",
1285 .data
= &sysctl_overcommit_memory
,
1286 .maxlen
= sizeof(sysctl_overcommit_memory
),
1288 .proc_handler
= proc_dointvec_minmax
,
1293 .procname
= "panic_on_oom",
1294 .data
= &sysctl_panic_on_oom
,
1295 .maxlen
= sizeof(sysctl_panic_on_oom
),
1297 .proc_handler
= proc_dointvec_minmax
,
1302 .procname
= "oom_kill_allocating_task",
1303 .data
= &sysctl_oom_kill_allocating_task
,
1304 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
1306 .proc_handler
= proc_dointvec
,
1309 .procname
= "oom_dump_tasks",
1310 .data
= &sysctl_oom_dump_tasks
,
1311 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
1313 .proc_handler
= proc_dointvec
,
1316 .procname
= "overcommit_ratio",
1317 .data
= &sysctl_overcommit_ratio
,
1318 .maxlen
= sizeof(sysctl_overcommit_ratio
),
1320 .proc_handler
= overcommit_ratio_handler
,
1323 .procname
= "overcommit_kbytes",
1324 .data
= &sysctl_overcommit_kbytes
,
1325 .maxlen
= sizeof(sysctl_overcommit_kbytes
),
1327 .proc_handler
= overcommit_kbytes_handler
,
1330 .procname
= "page-cluster",
1331 .data
= &page_cluster
,
1332 .maxlen
= sizeof(int),
1334 .proc_handler
= proc_dointvec_minmax
,
1338 .procname
= "dirty_background_ratio",
1339 .data
= &dirty_background_ratio
,
1340 .maxlen
= sizeof(dirty_background_ratio
),
1342 .proc_handler
= dirty_background_ratio_handler
,
1344 .extra2
= &one_hundred
,
1347 .procname
= "dirty_background_bytes",
1348 .data
= &dirty_background_bytes
,
1349 .maxlen
= sizeof(dirty_background_bytes
),
1351 .proc_handler
= dirty_background_bytes_handler
,
1355 .procname
= "dirty_ratio",
1356 .data
= &vm_dirty_ratio
,
1357 .maxlen
= sizeof(vm_dirty_ratio
),
1359 .proc_handler
= dirty_ratio_handler
,
1361 .extra2
= &one_hundred
,
1364 .procname
= "dirty_bytes",
1365 .data
= &vm_dirty_bytes
,
1366 .maxlen
= sizeof(vm_dirty_bytes
),
1368 .proc_handler
= dirty_bytes_handler
,
1369 .extra1
= &dirty_bytes_min
,
1372 .procname
= "dirty_writeback_centisecs",
1373 .data
= &dirty_writeback_interval
,
1374 .maxlen
= sizeof(dirty_writeback_interval
),
1376 .proc_handler
= dirty_writeback_centisecs_handler
,
1379 .procname
= "dirty_expire_centisecs",
1380 .data
= &dirty_expire_interval
,
1381 .maxlen
= sizeof(dirty_expire_interval
),
1383 .proc_handler
= proc_dointvec_minmax
,
1387 .procname
= "dirtytime_expire_seconds",
1388 .data
= &dirtytime_expire_interval
,
1389 .maxlen
= sizeof(dirty_expire_interval
),
1391 .proc_handler
= dirtytime_interval_handler
,
1395 .procname
= "nr_pdflush_threads",
1396 .mode
= 0444 /* read-only */,
1397 .proc_handler
= pdflush_proc_obsolete
,
1400 .procname
= "swappiness",
1401 .data
= &vm_swappiness
,
1402 .maxlen
= sizeof(vm_swappiness
),
1404 .proc_handler
= proc_dointvec_minmax
,
1406 .extra2
= &one_hundred
,
1408 #ifdef CONFIG_HUGETLB_PAGE
1410 .procname
= "nr_hugepages",
1412 .maxlen
= sizeof(unsigned long),
1414 .proc_handler
= hugetlb_sysctl_handler
,
1418 .procname
= "nr_hugepages_mempolicy",
1420 .maxlen
= sizeof(unsigned long),
1422 .proc_handler
= &hugetlb_mempolicy_sysctl_handler
,
1426 .procname
= "hugetlb_shm_group",
1427 .data
= &sysctl_hugetlb_shm_group
,
1428 .maxlen
= sizeof(gid_t
),
1430 .proc_handler
= proc_dointvec
,
1433 .procname
= "hugepages_treat_as_movable",
1434 .data
= &hugepages_treat_as_movable
,
1435 .maxlen
= sizeof(int),
1437 .proc_handler
= proc_dointvec
,
1440 .procname
= "nr_overcommit_hugepages",
1442 .maxlen
= sizeof(unsigned long),
1444 .proc_handler
= hugetlb_overcommit_handler
,
1448 .procname
= "lowmem_reserve_ratio",
1449 .data
= &sysctl_lowmem_reserve_ratio
,
1450 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
1452 .proc_handler
= lowmem_reserve_ratio_sysctl_handler
,
1455 .procname
= "drop_caches",
1456 .data
= &sysctl_drop_caches
,
1457 .maxlen
= sizeof(int),
1459 .proc_handler
= drop_caches_sysctl_handler
,
1463 #ifdef CONFIG_COMPACTION
1465 .procname
= "compact_memory",
1466 .data
= &sysctl_compact_memory
,
1467 .maxlen
= sizeof(int),
1469 .proc_handler
= sysctl_compaction_handler
,
1472 .procname
= "extfrag_threshold",
1473 .data
= &sysctl_extfrag_threshold
,
1474 .maxlen
= sizeof(int),
1476 .proc_handler
= sysctl_extfrag_handler
,
1477 .extra1
= &min_extfrag_threshold
,
1478 .extra2
= &max_extfrag_threshold
,
1481 .procname
= "compact_unevictable_allowed",
1482 .data
= &sysctl_compact_unevictable_allowed
,
1483 .maxlen
= sizeof(int),
1485 .proc_handler
= proc_dointvec
,
1490 #endif /* CONFIG_COMPACTION */
1492 .procname
= "min_free_kbytes",
1493 .data
= &min_free_kbytes
,
1494 .maxlen
= sizeof(min_free_kbytes
),
1496 .proc_handler
= min_free_kbytes_sysctl_handler
,
1500 .procname
= "watermark_scale_factor",
1501 .data
= &watermark_scale_factor
,
1502 .maxlen
= sizeof(watermark_scale_factor
),
1504 .proc_handler
= watermark_scale_factor_sysctl_handler
,
1506 .extra2
= &one_thousand
,
1509 .procname
= "percpu_pagelist_fraction",
1510 .data
= &percpu_pagelist_fraction
,
1511 .maxlen
= sizeof(percpu_pagelist_fraction
),
1513 .proc_handler
= percpu_pagelist_fraction_sysctl_handler
,
1518 .procname
= "max_map_count",
1519 .data
= &sysctl_max_map_count
,
1520 .maxlen
= sizeof(sysctl_max_map_count
),
1522 .proc_handler
= proc_dointvec_minmax
,
1527 .procname
= "nr_trim_pages",
1528 .data
= &sysctl_nr_trim_pages
,
1529 .maxlen
= sizeof(sysctl_nr_trim_pages
),
1531 .proc_handler
= proc_dointvec_minmax
,
1536 .procname
= "laptop_mode",
1537 .data
= &laptop_mode
,
1538 .maxlen
= sizeof(laptop_mode
),
1540 .proc_handler
= proc_dointvec_jiffies
,
1543 .procname
= "block_dump",
1544 .data
= &block_dump
,
1545 .maxlen
= sizeof(block_dump
),
1547 .proc_handler
= proc_dointvec
,
1551 .procname
= "vfs_cache_pressure",
1552 .data
= &sysctl_vfs_cache_pressure
,
1553 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1555 .proc_handler
= proc_dointvec
,
1558 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1560 .procname
= "legacy_va_layout",
1561 .data
= &sysctl_legacy_va_layout
,
1562 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1564 .proc_handler
= proc_dointvec
,
1570 .procname
= "zone_reclaim_mode",
1571 .data
= &node_reclaim_mode
,
1572 .maxlen
= sizeof(node_reclaim_mode
),
1574 .proc_handler
= proc_dointvec
,
1578 .procname
= "min_unmapped_ratio",
1579 .data
= &sysctl_min_unmapped_ratio
,
1580 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1582 .proc_handler
= sysctl_min_unmapped_ratio_sysctl_handler
,
1584 .extra2
= &one_hundred
,
1587 .procname
= "min_slab_ratio",
1588 .data
= &sysctl_min_slab_ratio
,
1589 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1591 .proc_handler
= sysctl_min_slab_ratio_sysctl_handler
,
1593 .extra2
= &one_hundred
,
1598 .procname
= "stat_interval",
1599 .data
= &sysctl_stat_interval
,
1600 .maxlen
= sizeof(sysctl_stat_interval
),
1602 .proc_handler
= proc_dointvec_jiffies
,
1605 .procname
= "stat_refresh",
1609 .proc_handler
= vmstat_refresh
,
1614 .procname
= "mmap_min_addr",
1615 .data
= &dac_mmap_min_addr
,
1616 .maxlen
= sizeof(unsigned long),
1618 .proc_handler
= mmap_min_addr_handler
,
1623 .procname
= "numa_zonelist_order",
1624 .data
= &numa_zonelist_order
,
1625 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1627 .proc_handler
= numa_zonelist_order_handler
,
1630 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1631 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1633 .procname
= "vdso_enabled",
1634 #ifdef CONFIG_X86_32
1635 .data
= &vdso32_enabled
,
1636 .maxlen
= sizeof(vdso32_enabled
),
1638 .data
= &vdso_enabled
,
1639 .maxlen
= sizeof(vdso_enabled
),
1642 .proc_handler
= proc_dointvec
,
1646 #ifdef CONFIG_HIGHMEM
1648 .procname
= "highmem_is_dirtyable",
1649 .data
= &vm_highmem_is_dirtyable
,
1650 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
1652 .proc_handler
= proc_dointvec_minmax
,
1657 #ifdef CONFIG_MEMORY_FAILURE
1659 .procname
= "memory_failure_early_kill",
1660 .data
= &sysctl_memory_failure_early_kill
,
1661 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
1663 .proc_handler
= proc_dointvec_minmax
,
1668 .procname
= "memory_failure_recovery",
1669 .data
= &sysctl_memory_failure_recovery
,
1670 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
1672 .proc_handler
= proc_dointvec_minmax
,
1678 .procname
= "user_reserve_kbytes",
1679 .data
= &sysctl_user_reserve_kbytes
,
1680 .maxlen
= sizeof(sysctl_user_reserve_kbytes
),
1682 .proc_handler
= proc_doulongvec_minmax
,
1685 .procname
= "admin_reserve_kbytes",
1686 .data
= &sysctl_admin_reserve_kbytes
,
1687 .maxlen
= sizeof(sysctl_admin_reserve_kbytes
),
1689 .proc_handler
= proc_doulongvec_minmax
,
1691 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1693 .procname
= "mmap_rnd_bits",
1694 .data
= &mmap_rnd_bits
,
1695 .maxlen
= sizeof(mmap_rnd_bits
),
1697 .proc_handler
= proc_dointvec_minmax
,
1698 .extra1
= (void *)&mmap_rnd_bits_min
,
1699 .extra2
= (void *)&mmap_rnd_bits_max
,
1702 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1704 .procname
= "mmap_rnd_compat_bits",
1705 .data
= &mmap_rnd_compat_bits
,
1706 .maxlen
= sizeof(mmap_rnd_compat_bits
),
1708 .proc_handler
= proc_dointvec_minmax
,
1709 .extra1
= (void *)&mmap_rnd_compat_bits_min
,
1710 .extra2
= (void *)&mmap_rnd_compat_bits_max
,
1716 static struct ctl_table fs_table
[] = {
1718 .procname
= "inode-nr",
1719 .data
= &inodes_stat
,
1720 .maxlen
= 2*sizeof(long),
1722 .proc_handler
= proc_nr_inodes
,
1725 .procname
= "inode-state",
1726 .data
= &inodes_stat
,
1727 .maxlen
= 7*sizeof(long),
1729 .proc_handler
= proc_nr_inodes
,
1732 .procname
= "file-nr",
1733 .data
= &files_stat
,
1734 .maxlen
= sizeof(files_stat
),
1736 .proc_handler
= proc_nr_files
,
1739 .procname
= "file-max",
1740 .data
= &files_stat
.max_files
,
1741 .maxlen
= sizeof(files_stat
.max_files
),
1743 .proc_handler
= proc_doulongvec_minmax
,
1746 .procname
= "nr_open",
1747 .data
= &sysctl_nr_open
,
1748 .maxlen
= sizeof(unsigned int),
1750 .proc_handler
= proc_dointvec_minmax
,
1751 .extra1
= &sysctl_nr_open_min
,
1752 .extra2
= &sysctl_nr_open_max
,
1755 .procname
= "dentry-state",
1756 .data
= &dentry_stat
,
1757 .maxlen
= 6*sizeof(long),
1759 .proc_handler
= proc_nr_dentry
,
1762 .procname
= "overflowuid",
1763 .data
= &fs_overflowuid
,
1764 .maxlen
= sizeof(int),
1766 .proc_handler
= proc_dointvec_minmax
,
1767 .extra1
= &minolduid
,
1768 .extra2
= &maxolduid
,
1771 .procname
= "overflowgid",
1772 .data
= &fs_overflowgid
,
1773 .maxlen
= sizeof(int),
1775 .proc_handler
= proc_dointvec_minmax
,
1776 .extra1
= &minolduid
,
1777 .extra2
= &maxolduid
,
1779 #ifdef CONFIG_FILE_LOCKING
1781 .procname
= "leases-enable",
1782 .data
= &leases_enable
,
1783 .maxlen
= sizeof(int),
1785 .proc_handler
= proc_dointvec
,
1788 #ifdef CONFIG_DNOTIFY
1790 .procname
= "dir-notify-enable",
1791 .data
= &dir_notify_enable
,
1792 .maxlen
= sizeof(int),
1794 .proc_handler
= proc_dointvec
,
1798 #ifdef CONFIG_FILE_LOCKING
1800 .procname
= "lease-break-time",
1801 .data
= &lease_break_time
,
1802 .maxlen
= sizeof(int),
1804 .proc_handler
= proc_dointvec
,
1809 .procname
= "aio-nr",
1811 .maxlen
= sizeof(aio_nr
),
1813 .proc_handler
= proc_doulongvec_minmax
,
1816 .procname
= "aio-max-nr",
1817 .data
= &aio_max_nr
,
1818 .maxlen
= sizeof(aio_max_nr
),
1820 .proc_handler
= proc_doulongvec_minmax
,
1822 #endif /* CONFIG_AIO */
1823 #ifdef CONFIG_INOTIFY_USER
1825 .procname
= "inotify",
1827 .child
= inotify_table
,
1832 .procname
= "epoll",
1834 .child
= epoll_table
,
1839 .procname
= "protected_symlinks",
1840 .data
= &sysctl_protected_symlinks
,
1841 .maxlen
= sizeof(int),
1843 .proc_handler
= proc_dointvec_minmax
,
1848 .procname
= "protected_hardlinks",
1849 .data
= &sysctl_protected_hardlinks
,
1850 .maxlen
= sizeof(int),
1852 .proc_handler
= proc_dointvec_minmax
,
1857 .procname
= "suid_dumpable",
1858 .data
= &suid_dumpable
,
1859 .maxlen
= sizeof(int),
1861 .proc_handler
= proc_dointvec_minmax_coredump
,
1865 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1867 .procname
= "binfmt_misc",
1869 .child
= sysctl_mount_point
,
1873 .procname
= "pipe-max-size",
1874 .data
= &pipe_max_size
,
1875 .maxlen
= sizeof(int),
1877 .proc_handler
= &pipe_proc_fn
,
1878 .extra1
= &pipe_min_size
,
1881 .procname
= "pipe-user-pages-hard",
1882 .data
= &pipe_user_pages_hard
,
1883 .maxlen
= sizeof(pipe_user_pages_hard
),
1885 .proc_handler
= proc_doulongvec_minmax
,
1888 .procname
= "pipe-user-pages-soft",
1889 .data
= &pipe_user_pages_soft
,
1890 .maxlen
= sizeof(pipe_user_pages_soft
),
1892 .proc_handler
= proc_doulongvec_minmax
,
1895 .procname
= "mount-max",
1896 .data
= &sysctl_mount_max
,
1897 .maxlen
= sizeof(unsigned int),
1899 .proc_handler
= proc_dointvec_minmax
,
1905 static struct ctl_table debug_table
[] = {
1906 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1908 .procname
= "exception-trace",
1909 .data
= &show_unhandled_signals
,
1910 .maxlen
= sizeof(int),
1912 .proc_handler
= proc_dointvec
1915 #if defined(CONFIG_OPTPROBES)
1917 .procname
= "kprobes-optimization",
1918 .data
= &sysctl_kprobes_optimization
,
1919 .maxlen
= sizeof(int),
1921 .proc_handler
= proc_kprobes_optimization_handler
,
1929 static struct ctl_table dev_table
[] = {
1933 int __init
sysctl_init(void)
1935 struct ctl_table_header
*hdr
;
1937 hdr
= register_sysctl_table(sysctl_base_table
);
1938 kmemleak_not_leak(hdr
);
1942 #endif /* CONFIG_SYSCTL */
1948 #ifdef CONFIG_PROC_SYSCTL
1950 static int _proc_do_string(char *data
, int maxlen
, int write
,
1951 char __user
*buffer
,
1952 size_t *lenp
, loff_t
*ppos
)
1958 if (!data
|| !maxlen
|| !*lenp
) {
1964 if (sysctl_writes_strict
== SYSCTL_WRITES_STRICT
) {
1965 /* Only continue writes not past the end of buffer. */
1967 if (len
> maxlen
- 1)
1974 /* Start writing from beginning of buffer. */
1980 while ((p
- buffer
) < *lenp
&& len
< maxlen
- 1) {
1981 if (get_user(c
, p
++))
1983 if (c
== 0 || c
== '\n')
2004 if (copy_to_user(buffer
, data
, len
))
2007 if (put_user('\n', buffer
+ len
))
2017 static void warn_sysctl_write(struct ctl_table
*table
)
2019 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2020 "This will not be supported in the future. To silence this\n"
2021 "warning, set kernel.sysctl_writes_strict = -1\n",
2022 current
->comm
, table
->procname
);
2026 * proc_first_pos_non_zero_ignore - check if firs position is allowed
2027 * @ppos: file position
2028 * @table: the sysctl table
2030 * Returns true if the first position is non-zero and the sysctl_writes_strict
2031 * mode indicates this is not allowed for numeric input types. String proc
2032 * hadlers can ignore the return value.
2034 static bool proc_first_pos_non_zero_ignore(loff_t
*ppos
,
2035 struct ctl_table
*table
)
2040 switch (sysctl_writes_strict
) {
2041 case SYSCTL_WRITES_STRICT
:
2043 case SYSCTL_WRITES_WARN
:
2044 warn_sysctl_write(table
);
2052 * proc_dostring - read a string sysctl
2053 * @table: the sysctl table
2054 * @write: %TRUE if this is a write to the sysctl file
2055 * @buffer: the user buffer
2056 * @lenp: the size of the user buffer
2057 * @ppos: file position
2059 * Reads/writes a string from/to the user buffer. If the kernel
2060 * buffer provided is not large enough to hold the string, the
2061 * string is truncated. The copied string is %NULL-terminated.
2062 * If the string is being read by the user process, it is copied
2063 * and a newline '\n' is added. It is truncated if the buffer is
2066 * Returns 0 on success.
2068 int proc_dostring(struct ctl_table
*table
, int write
,
2069 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2072 proc_first_pos_non_zero_ignore(ppos
, table
);
2074 return _proc_do_string((char *)(table
->data
), table
->maxlen
, write
,
2075 (char __user
*)buffer
, lenp
, ppos
);
2078 static size_t proc_skip_spaces(char **buf
)
2081 char *tmp
= skip_spaces(*buf
);
2087 static void proc_skip_char(char **buf
, size_t *size
, const char v
)
2097 #define TMPBUFLEN 22
2099 * proc_get_long - reads an ASCII formatted integer from a user buffer
2101 * @buf: a kernel buffer
2102 * @size: size of the kernel buffer
2103 * @val: this is where the number will be stored
2104 * @neg: set to %TRUE if number is negative
2105 * @perm_tr: a vector which contains the allowed trailers
2106 * @perm_tr_len: size of the perm_tr vector
2107 * @tr: pointer to store the trailer character
2109 * In case of success %0 is returned and @buf and @size are updated with
2110 * the amount of bytes read. If @tr is non-NULL and a trailing
2111 * character exists (size is non-zero after returning from this
2112 * function), @tr is updated with the trailing character.
2114 static int proc_get_long(char **buf
, size_t *size
,
2115 unsigned long *val
, bool *neg
,
2116 const char *perm_tr
, unsigned perm_tr_len
, char *tr
)
2119 char *p
, tmp
[TMPBUFLEN
];
2125 if (len
> TMPBUFLEN
- 1)
2126 len
= TMPBUFLEN
- 1;
2128 memcpy(tmp
, *buf
, len
);
2132 if (*p
== '-' && *size
> 1) {
2140 *val
= simple_strtoul(p
, &p
, 0);
2144 /* We don't know if the next char is whitespace thus we may accept
2145 * invalid integers (e.g. 1234...a) or two integers instead of one
2146 * (e.g. 123...1). So lets not allow such large numbers. */
2147 if (len
== TMPBUFLEN
- 1)
2150 if (len
< *size
&& perm_tr_len
&& !memchr(perm_tr
, *p
, perm_tr_len
))
2153 if (tr
&& (len
< *size
))
2163 * proc_put_long - converts an integer to a decimal ASCII formatted string
2165 * @buf: the user buffer
2166 * @size: the size of the user buffer
2167 * @val: the integer to be converted
2168 * @neg: sign of the number, %TRUE for negative
2170 * In case of success %0 is returned and @buf and @size are updated with
2171 * the amount of bytes written.
2173 static int proc_put_long(void __user
**buf
, size_t *size
, unsigned long val
,
2177 char tmp
[TMPBUFLEN
], *p
= tmp
;
2179 sprintf(p
, "%s%lu", neg
? "-" : "", val
);
2183 if (copy_to_user(*buf
, tmp
, len
))
2191 static int proc_put_char(void __user
**buf
, size_t *size
, char c
)
2194 char __user
**buffer
= (char __user
**)buf
;
2195 if (put_user(c
, *buffer
))
2197 (*size
)--, (*buffer
)++;
2203 static int do_proc_dointvec_conv(bool *negp
, unsigned long *lvalp
,
2205 int write
, void *data
)
2209 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2213 if (*lvalp
> (unsigned long) INT_MAX
)
2221 *lvalp
= -(unsigned long)val
;
2224 *lvalp
= (unsigned long)val
;
2230 static int do_proc_douintvec_conv(unsigned long *lvalp
,
2232 int write
, void *data
)
2235 if (*lvalp
> UINT_MAX
)
2237 if (*lvalp
> UINT_MAX
)
2241 unsigned int val
= *valp
;
2242 *lvalp
= (unsigned long)val
;
2247 static const char proc_wspace_sep
[] = { ' ', '\t', '\n' };
2249 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2250 int write
, void __user
*buffer
,
2251 size_t *lenp
, loff_t
*ppos
,
2252 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2253 int write
, void *data
),
2256 int *i
, vleft
, first
= 1, err
= 0;
2258 char *kbuf
= NULL
, *p
;
2260 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2265 i
= (int *) tbl_data
;
2266 vleft
= table
->maxlen
/ sizeof(*i
);
2270 conv
= do_proc_dointvec_conv
;
2273 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2276 if (left
> PAGE_SIZE
- 1)
2277 left
= PAGE_SIZE
- 1;
2278 p
= kbuf
= memdup_user_nul(buffer
, left
);
2280 return PTR_ERR(kbuf
);
2283 for (; left
&& vleft
--; i
++, first
=0) {
2288 left
-= proc_skip_spaces(&p
);
2292 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2294 sizeof(proc_wspace_sep
), NULL
);
2297 if (conv(&neg
, &lval
, i
, 1, data
)) {
2302 if (conv(&neg
, &lval
, i
, 0, data
)) {
2307 err
= proc_put_char(&buffer
, &left
, '\t');
2310 err
= proc_put_long(&buffer
, &left
, lval
, neg
);
2316 if (!write
&& !first
&& left
&& !err
)
2317 err
= proc_put_char(&buffer
, &left
, '\n');
2318 if (write
&& !err
&& left
)
2319 left
-= proc_skip_spaces(&p
);
2323 return err
? : -EINVAL
;
2331 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2332 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2333 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2334 int write
, void *data
),
2337 return __do_proc_dointvec(table
->data
, table
, write
,
2338 buffer
, lenp
, ppos
, conv
, data
);
2341 static int do_proc_douintvec_w(unsigned int *tbl_data
,
2342 struct ctl_table
*table
,
2343 void __user
*buffer
,
2344 size_t *lenp
, loff_t
*ppos
,
2345 int (*conv
)(unsigned long *lvalp
,
2347 int write
, void *data
),
2354 char *kbuf
= NULL
, *p
;
2358 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2361 if (left
> PAGE_SIZE
- 1)
2362 left
= PAGE_SIZE
- 1;
2364 p
= kbuf
= memdup_user_nul(buffer
, left
);
2368 left
-= proc_skip_spaces(&p
);
2374 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2376 sizeof(proc_wspace_sep
), NULL
);
2382 if (conv(&lval
, tbl_data
, 1, data
)) {
2388 left
-= proc_skip_spaces(&p
);
2397 /* This is in keeping with old __do_proc_dointvec() */
2403 static int do_proc_douintvec_r(unsigned int *tbl_data
, void __user
*buffer
,
2404 size_t *lenp
, loff_t
*ppos
,
2405 int (*conv
)(unsigned long *lvalp
,
2407 int write
, void *data
),
2416 if (conv(&lval
, tbl_data
, 0, data
)) {
2421 err
= proc_put_long(&buffer
, &left
, lval
, false);
2425 err
= proc_put_char(&buffer
, &left
, '\n');
2434 static int __do_proc_douintvec(void *tbl_data
, struct ctl_table
*table
,
2435 int write
, void __user
*buffer
,
2436 size_t *lenp
, loff_t
*ppos
,
2437 int (*conv
)(unsigned long *lvalp
,
2439 int write
, void *data
),
2442 unsigned int *i
, vleft
;
2444 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2449 i
= (unsigned int *) tbl_data
;
2450 vleft
= table
->maxlen
/ sizeof(*i
);
2453 * Arrays are not supported, keep this simple. *Do not* add
2462 conv
= do_proc_douintvec_conv
;
2465 return do_proc_douintvec_w(i
, table
, buffer
, lenp
, ppos
,
2467 return do_proc_douintvec_r(i
, buffer
, lenp
, ppos
, conv
, data
);
2470 static int do_proc_douintvec(struct ctl_table
*table
, int write
,
2471 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2472 int (*conv
)(unsigned long *lvalp
,
2474 int write
, void *data
),
2477 return __do_proc_douintvec(table
->data
, table
, write
,
2478 buffer
, lenp
, ppos
, conv
, data
);
2482 * proc_dointvec - read a vector of integers
2483 * @table: the sysctl table
2484 * @write: %TRUE if this is a write to the sysctl file
2485 * @buffer: the user buffer
2486 * @lenp: the size of the user buffer
2487 * @ppos: file position
2489 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2490 * values from/to the user buffer, treated as an ASCII string.
2492 * Returns 0 on success.
2494 int proc_dointvec(struct ctl_table
*table
, int write
,
2495 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2497 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
, NULL
, NULL
);
2501 * proc_douintvec - read a vector of unsigned integers
2502 * @table: the sysctl table
2503 * @write: %TRUE if this is a write to the sysctl file
2504 * @buffer: the user buffer
2505 * @lenp: the size of the user buffer
2506 * @ppos: file position
2508 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2509 * values from/to the user buffer, treated as an ASCII string.
2511 * Returns 0 on success.
2513 int proc_douintvec(struct ctl_table
*table
, int write
,
2514 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2516 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2517 do_proc_douintvec_conv
, NULL
);
2521 * Taint values can only be increased
2522 * This means we can safely use a temporary.
2524 static int proc_taint(struct ctl_table
*table
, int write
,
2525 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2528 unsigned long tmptaint
= get_taint();
2531 if (write
&& !capable(CAP_SYS_ADMIN
))
2536 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2542 * Poor man's atomic or. Not worth adding a primitive
2543 * to everyone's atomic.h for this
2546 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2547 if ((tmptaint
>> i
) & 1)
2548 add_taint(i
, LOCKDEP_STILL_OK
);
2555 #ifdef CONFIG_PRINTK
2556 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
2557 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2559 if (write
&& !capable(CAP_SYS_ADMIN
))
2562 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2566 struct do_proc_dointvec_minmax_conv_param
{
2571 static int do_proc_dointvec_minmax_conv(bool *negp
, unsigned long *lvalp
,
2573 int write
, void *data
)
2575 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2577 int val
= *negp
? -*lvalp
: *lvalp
;
2578 if ((param
->min
&& *param
->min
> val
) ||
2579 (param
->max
&& *param
->max
< val
))
2586 *lvalp
= -(unsigned long)val
;
2589 *lvalp
= (unsigned long)val
;
2596 * proc_dointvec_minmax - read a vector of integers with min/max values
2597 * @table: the sysctl table
2598 * @write: %TRUE if this is a write to the sysctl file
2599 * @buffer: the user buffer
2600 * @lenp: the size of the user buffer
2601 * @ppos: file position
2603 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2604 * values from/to the user buffer, treated as an ASCII string.
2606 * This routine will ensure the values are within the range specified by
2607 * table->extra1 (min) and table->extra2 (max).
2609 * Returns 0 on success.
2611 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2612 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2614 struct do_proc_dointvec_minmax_conv_param param
= {
2615 .min
= (int *) table
->extra1
,
2616 .max
= (int *) table
->extra2
,
2618 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2619 do_proc_dointvec_minmax_conv
, ¶m
);
2623 int proc_dointvec_ibrs_ctrl(struct ctl_table
*table
, int write
,
2624 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2629 ret
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2630 pr_debug("sysctl_ibrs_enabled = %u, sysctl_ibpb_enabled = %u\n", sysctl_ibrs_enabled
, sysctl_ibpb_enabled
);
2631 pr_debug("before:use_ibrs = %d, use_ibpb = %d\n", use_ibrs
, use_ibpb
);
2632 mutex_lock(&spec_ctrl_mutex
);
2633 if (sysctl_ibrs_enabled
== 0) {
2634 /* always set IBRS off */
2635 set_ibrs_disabled();
2636 if (ibrs_supported
) {
2637 for_each_online_cpu(cpu
)
2638 wrmsrl_on_cpu(cpu
, MSR_IA32_SPEC_CTRL
, 0x0);
2640 } else if (sysctl_ibrs_enabled
== 2) {
2641 /* always set IBRS on, even in user space */
2642 clear_ibrs_disabled();
2643 if (ibrs_supported
) {
2644 for_each_online_cpu(cpu
)
2645 wrmsrl_on_cpu(cpu
, MSR_IA32_SPEC_CTRL
, FEATURE_ENABLE_IBRS
);
2647 sysctl_ibrs_enabled
= 0;
2649 } else if (sysctl_ibrs_enabled
== 1) {
2650 /* use IBRS in kernel */
2651 clear_ibrs_disabled();
2653 /* platform don't support ibrs */
2654 sysctl_ibrs_enabled
= 0;
2656 mutex_unlock(&spec_ctrl_mutex
);
2657 pr_debug("after:use_ibrs = %d, use_ibpb = %d\n", use_ibrs
, use_ibpb
);
2661 int proc_dointvec_ibpb_ctrl(struct ctl_table
*table
, int write
,
2662 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2666 ret
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2667 pr_debug("sysctl_ibrs_enabled = %u, sysctl_ibpb_enabled = %u\n", sysctl_ibrs_enabled
, sysctl_ibpb_enabled
);
2668 pr_debug("before:use_ibrs = %d, use_ibpb = %d\n", use_ibrs
, use_ibpb
);
2669 mutex_lock(&spec_ctrl_mutex
);
2670 if (sysctl_ibpb_enabled
== 0)
2671 set_ibpb_disabled();
2672 else if (sysctl_ibpb_enabled
== 1) {
2673 clear_ibpb_disabled();
2675 /* platform don't support ibpb */
2676 sysctl_ibpb_enabled
= 0;
2678 mutex_unlock(&spec_ctrl_mutex
);
2679 pr_debug("after:use_ibrs = %d, use_ibpb = %d\n", use_ibrs
, use_ibpb
);
2685 struct do_proc_douintvec_minmax_conv_param
{
2690 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp
,
2692 int write
, void *data
)
2694 struct do_proc_douintvec_minmax_conv_param
*param
= data
;
2697 unsigned int val
= *lvalp
;
2699 if ((param
->min
&& *param
->min
> val
) ||
2700 (param
->max
&& *param
->max
< val
))
2703 if (*lvalp
> UINT_MAX
)
2707 unsigned int val
= *valp
;
2708 *lvalp
= (unsigned long) val
;
2715 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2716 * @table: the sysctl table
2717 * @write: %TRUE if this is a write to the sysctl file
2718 * @buffer: the user buffer
2719 * @lenp: the size of the user buffer
2720 * @ppos: file position
2722 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2723 * values from/to the user buffer, treated as an ASCII string. Negative
2724 * strings are not allowed.
2726 * This routine will ensure the values are within the range specified by
2727 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2728 * check for UINT_MAX to avoid having to support wrap around uses from
2731 * Returns 0 on success.
2733 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
2734 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2736 struct do_proc_douintvec_minmax_conv_param param
= {
2737 .min
= (unsigned int *) table
->extra1
,
2738 .max
= (unsigned int *) table
->extra2
,
2740 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2741 do_proc_douintvec_minmax_conv
, ¶m
);
2744 static void validate_coredump_safety(void)
2746 #ifdef CONFIG_COREDUMP
2747 if (suid_dumpable
== SUID_DUMP_ROOT
&&
2748 core_pattern
[0] != '/' && core_pattern
[0] != '|') {
2750 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2751 "Pipe handler or fully qualified core dump path required.\n"
2752 "Set kernel.core_pattern before fs.suid_dumpable.\n"
2758 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
2759 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2761 int error
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2763 validate_coredump_safety();
2767 #ifdef CONFIG_COREDUMP
2768 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
2769 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2771 int error
= proc_dostring(table
, write
, buffer
, lenp
, ppos
);
2773 validate_coredump_safety();
2778 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2779 void __user
*buffer
,
2780 size_t *lenp
, loff_t
*ppos
,
2781 unsigned long convmul
,
2782 unsigned long convdiv
)
2784 unsigned long *i
, *min
, *max
;
2785 int vleft
, first
= 1, err
= 0;
2787 char *kbuf
= NULL
, *p
;
2789 if (!data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2794 i
= (unsigned long *) data
;
2795 min
= (unsigned long *) table
->extra1
;
2796 max
= (unsigned long *) table
->extra2
;
2797 vleft
= table
->maxlen
/ sizeof(unsigned long);
2801 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2804 if (left
> PAGE_SIZE
- 1)
2805 left
= PAGE_SIZE
- 1;
2806 p
= kbuf
= memdup_user_nul(buffer
, left
);
2808 return PTR_ERR(kbuf
);
2811 for (; left
&& vleft
--; i
++, first
= 0) {
2817 left
-= proc_skip_spaces(&p
);
2819 err
= proc_get_long(&p
, &left
, &val
, &neg
,
2821 sizeof(proc_wspace_sep
), NULL
);
2826 val
= convmul
* val
/ convdiv
;
2827 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2831 val
= convdiv
* (*i
) / convmul
;
2833 err
= proc_put_char(&buffer
, &left
, '\t');
2837 err
= proc_put_long(&buffer
, &left
, val
, false);
2843 if (!write
&& !first
&& left
&& !err
)
2844 err
= proc_put_char(&buffer
, &left
, '\n');
2846 left
-= proc_skip_spaces(&p
);
2850 return err
? : -EINVAL
;
2858 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2859 void __user
*buffer
,
2860 size_t *lenp
, loff_t
*ppos
,
2861 unsigned long convmul
,
2862 unsigned long convdiv
)
2864 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2865 buffer
, lenp
, ppos
, convmul
, convdiv
);
2869 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2870 * @table: the sysctl table
2871 * @write: %TRUE if this is a write to the sysctl file
2872 * @buffer: the user buffer
2873 * @lenp: the size of the user buffer
2874 * @ppos: file position
2876 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2877 * values from/to the user buffer, treated as an ASCII string.
2879 * This routine will ensure the values are within the range specified by
2880 * table->extra1 (min) and table->extra2 (max).
2882 * Returns 0 on success.
2884 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2885 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2887 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2891 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2892 * @table: the sysctl table
2893 * @write: %TRUE if this is a write to the sysctl file
2894 * @buffer: the user buffer
2895 * @lenp: the size of the user buffer
2896 * @ppos: file position
2898 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2899 * values from/to the user buffer, treated as an ASCII string. The values
2900 * are treated as milliseconds, and converted to jiffies when they are stored.
2902 * This routine will ensure the values are within the range specified by
2903 * table->extra1 (min) and table->extra2 (max).
2905 * Returns 0 on success.
2907 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2908 void __user
*buffer
,
2909 size_t *lenp
, loff_t
*ppos
)
2911 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2912 lenp
, ppos
, HZ
, 1000l);
2916 static int do_proc_dointvec_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2918 int write
, void *data
)
2921 if (*lvalp
> INT_MAX
/ HZ
)
2923 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2929 lval
= -(unsigned long)val
;
2932 lval
= (unsigned long)val
;
2939 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2941 int write
, void *data
)
2944 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2946 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2952 lval
= -(unsigned long)val
;
2955 lval
= (unsigned long)val
;
2957 *lvalp
= jiffies_to_clock_t(lval
);
2962 static int do_proc_dointvec_ms_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2964 int write
, void *data
)
2967 unsigned long jif
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2977 lval
= -(unsigned long)val
;
2980 lval
= (unsigned long)val
;
2982 *lvalp
= jiffies_to_msecs(lval
);
2988 * proc_dointvec_jiffies - read a vector of integers as seconds
2989 * @table: the sysctl table
2990 * @write: %TRUE if this is a write to the sysctl file
2991 * @buffer: the user buffer
2992 * @lenp: the size of the user buffer
2993 * @ppos: file position
2995 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2996 * values from/to the user buffer, treated as an ASCII string.
2997 * The values read are assumed to be in seconds, and are converted into
3000 * Returns 0 on success.
3002 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
3003 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3005 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
3006 do_proc_dointvec_jiffies_conv
,NULL
);
3010 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
3011 * @table: the sysctl table
3012 * @write: %TRUE if this is a write to the sysctl file
3013 * @buffer: the user buffer
3014 * @lenp: the size of the user buffer
3015 * @ppos: pointer to the file position
3017 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3018 * values from/to the user buffer, treated as an ASCII string.
3019 * The values read are assumed to be in 1/USER_HZ seconds, and
3020 * are converted into jiffies.
3022 * Returns 0 on success.
3024 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
3025 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3027 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
3028 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
3032 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
3033 * @table: the sysctl table
3034 * @write: %TRUE if this is a write to the sysctl file
3035 * @buffer: the user buffer
3036 * @lenp: the size of the user buffer
3037 * @ppos: file position
3038 * @ppos: the current position in the file
3040 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3041 * values from/to the user buffer, treated as an ASCII string.
3042 * The values read are assumed to be in 1/1000 seconds, and
3043 * are converted into jiffies.
3045 * Returns 0 on success.
3047 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
3048 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3050 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
3051 do_proc_dointvec_ms_jiffies_conv
, NULL
);
3054 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
3055 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3057 struct pid
*new_pid
;
3061 tmp
= pid_vnr(cad_pid
);
3063 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
3064 lenp
, ppos
, NULL
, NULL
);
3068 new_pid
= find_get_pid(tmp
);
3072 put_pid(xchg(&cad_pid
, new_pid
));
3077 * proc_do_large_bitmap - read/write from/to a large bitmap
3078 * @table: the sysctl table
3079 * @write: %TRUE if this is a write to the sysctl file
3080 * @buffer: the user buffer
3081 * @lenp: the size of the user buffer
3082 * @ppos: file position
3084 * The bitmap is stored at table->data and the bitmap length (in bits)
3087 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
3088 * large bitmaps may be represented in a compact manner. Writing into
3089 * the file will clear the bitmap then update it with the given input.
3091 * Returns 0 on success.
3093 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
3094 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3098 size_t left
= *lenp
;
3099 unsigned long bitmap_len
= table
->maxlen
;
3100 unsigned long *bitmap
= *(unsigned long **) table
->data
;
3101 unsigned long *tmp_bitmap
= NULL
;
3102 char tr_a
[] = { '-', ',', '\n' }, tr_b
[] = { ',', '\n', 0 }, c
;
3104 if (!bitmap
|| !bitmap_len
|| !left
|| (*ppos
&& !write
)) {
3112 if (left
> PAGE_SIZE
- 1)
3113 left
= PAGE_SIZE
- 1;
3115 p
= kbuf
= memdup_user_nul(buffer
, left
);
3117 return PTR_ERR(kbuf
);
3119 tmp_bitmap
= kzalloc(BITS_TO_LONGS(bitmap_len
) * sizeof(unsigned long),
3125 proc_skip_char(&p
, &left
, '\n');
3126 while (!err
&& left
) {
3127 unsigned long val_a
, val_b
;
3130 err
= proc_get_long(&p
, &left
, &val_a
, &neg
, tr_a
,
3134 if (val_a
>= bitmap_len
|| neg
) {
3146 err
= proc_get_long(&p
, &left
, &val_b
,
3147 &neg
, tr_b
, sizeof(tr_b
),
3151 if (val_b
>= bitmap_len
|| neg
||
3162 bitmap_set(tmp_bitmap
, val_a
, val_b
- val_a
+ 1);
3164 proc_skip_char(&p
, &left
, '\n');
3168 unsigned long bit_a
, bit_b
= 0;
3171 bit_a
= find_next_bit(bitmap
, bitmap_len
, bit_b
);
3172 if (bit_a
>= bitmap_len
)
3174 bit_b
= find_next_zero_bit(bitmap
, bitmap_len
,
3178 err
= proc_put_char(&buffer
, &left
, ',');
3182 err
= proc_put_long(&buffer
, &left
, bit_a
, false);
3185 if (bit_a
!= bit_b
) {
3186 err
= proc_put_char(&buffer
, &left
, '-');
3189 err
= proc_put_long(&buffer
, &left
, bit_b
, false);
3197 err
= proc_put_char(&buffer
, &left
, '\n');
3203 bitmap_or(bitmap
, bitmap
, tmp_bitmap
, bitmap_len
);
3205 bitmap_copy(bitmap
, tmp_bitmap
, bitmap_len
);
3217 #else /* CONFIG_PROC_SYSCTL */
3219 int proc_dostring(struct ctl_table
*table
, int write
,
3220 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3225 int proc_dointvec(struct ctl_table
*table
, int write
,
3226 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3231 int proc_douintvec(struct ctl_table
*table
, int write
,
3232 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3237 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
3238 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3243 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
3244 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3249 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
3250 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3255 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
3256 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3261 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
3262 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3267 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
3268 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3273 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
3274 void __user
*buffer
,
3275 size_t *lenp
, loff_t
*ppos
)
3281 #endif /* CONFIG_PROC_SYSCTL */
3284 * No sense putting this after each symbol definition, twice,
3285 * exception granted :-)
3287 EXPORT_SYMBOL(proc_dointvec
);
3288 EXPORT_SYMBOL(proc_douintvec
);
3289 EXPORT_SYMBOL(proc_dointvec_jiffies
);
3290 EXPORT_SYMBOL(proc_dointvec_minmax
);
3291 EXPORT_SYMBOL_GPL(proc_douintvec_minmax
);
3292 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
3293 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
3294 EXPORT_SYMBOL(proc_dostring
);
3295 EXPORT_SYMBOL(proc_doulongvec_minmax
);
3296 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);