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
);
232 int proc_dointvec_ibrs_dump(struct ctl_table
*table
, int write
,
233 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
236 #ifdef CONFIG_MAGIC_SYSRQ
237 /* Note: sysrq code uses it's own private copy */
238 static int __sysrq_enabled
= CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE
;
240 static int sysrq_sysctl_handler(struct ctl_table
*table
, int write
,
241 void __user
*buffer
, size_t *lenp
,
246 error
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
251 sysrq_toggle_support(__sysrq_enabled
);
258 static struct ctl_table kern_table
[];
259 static struct ctl_table vm_table
[];
260 static struct ctl_table fs_table
[];
261 static struct ctl_table debug_table
[];
262 static struct ctl_table dev_table
[];
263 extern struct ctl_table random_table
[];
265 extern struct ctl_table epoll_table
[];
268 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
269 int sysctl_legacy_va_layout
;
272 u32 sysctl_ibrs_dump
= 0;
273 u32 sysctl_ibrs_enabled
= 0;
274 EXPORT_SYMBOL(sysctl_ibrs_enabled
);
275 u32 sysctl_ibpb_enabled
= 0;
276 EXPORT_SYMBOL(sysctl_ibpb_enabled
);
278 /* The default sysctl tables: */
280 static struct ctl_table sysctl_base_table
[] = {
282 .procname
= "kernel",
299 .child
= debug_table
,
309 #ifdef CONFIG_SCHED_DEBUG
310 static int min_sched_granularity_ns
= 100000; /* 100 usecs */
311 static int max_sched_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
312 static int min_wakeup_granularity_ns
; /* 0 usecs */
313 static int max_wakeup_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
315 static int min_sched_tunable_scaling
= SCHED_TUNABLESCALING_NONE
;
316 static int max_sched_tunable_scaling
= SCHED_TUNABLESCALING_END
-1;
317 #endif /* CONFIG_SMP */
318 #endif /* CONFIG_SCHED_DEBUG */
320 #ifdef CONFIG_COMPACTION
321 static int min_extfrag_threshold
;
322 static int max_extfrag_threshold
= 1000;
325 static struct ctl_table kern_table
[] = {
327 .procname
= "sched_child_runs_first",
328 .data
= &sysctl_sched_child_runs_first
,
329 .maxlen
= sizeof(unsigned int),
331 .proc_handler
= proc_dointvec
,
333 #ifdef CONFIG_SCHED_DEBUG
335 .procname
= "sched_min_granularity_ns",
336 .data
= &sysctl_sched_min_granularity
,
337 .maxlen
= sizeof(unsigned int),
339 .proc_handler
= sched_proc_update_handler
,
340 .extra1
= &min_sched_granularity_ns
,
341 .extra2
= &max_sched_granularity_ns
,
344 .procname
= "sched_latency_ns",
345 .data
= &sysctl_sched_latency
,
346 .maxlen
= sizeof(unsigned int),
348 .proc_handler
= sched_proc_update_handler
,
349 .extra1
= &min_sched_granularity_ns
,
350 .extra2
= &max_sched_granularity_ns
,
353 .procname
= "sched_wakeup_granularity_ns",
354 .data
= &sysctl_sched_wakeup_granularity
,
355 .maxlen
= sizeof(unsigned int),
357 .proc_handler
= sched_proc_update_handler
,
358 .extra1
= &min_wakeup_granularity_ns
,
359 .extra2
= &max_wakeup_granularity_ns
,
363 .procname
= "sched_tunable_scaling",
364 .data
= &sysctl_sched_tunable_scaling
,
365 .maxlen
= sizeof(enum sched_tunable_scaling
),
367 .proc_handler
= sched_proc_update_handler
,
368 .extra1
= &min_sched_tunable_scaling
,
369 .extra2
= &max_sched_tunable_scaling
,
372 .procname
= "sched_migration_cost_ns",
373 .data
= &sysctl_sched_migration_cost
,
374 .maxlen
= sizeof(unsigned int),
376 .proc_handler
= proc_dointvec
,
379 .procname
= "sched_nr_migrate",
380 .data
= &sysctl_sched_nr_migrate
,
381 .maxlen
= sizeof(unsigned int),
383 .proc_handler
= proc_dointvec
,
386 .procname
= "sched_time_avg_ms",
387 .data
= &sysctl_sched_time_avg
,
388 .maxlen
= sizeof(unsigned int),
390 .proc_handler
= proc_dointvec_minmax
,
393 #ifdef CONFIG_SCHEDSTATS
395 .procname
= "sched_schedstats",
397 .maxlen
= sizeof(unsigned int),
399 .proc_handler
= sysctl_schedstats
,
403 #endif /* CONFIG_SCHEDSTATS */
404 #endif /* CONFIG_SMP */
405 #ifdef CONFIG_NUMA_BALANCING
407 .procname
= "numa_balancing_scan_delay_ms",
408 .data
= &sysctl_numa_balancing_scan_delay
,
409 .maxlen
= sizeof(unsigned int),
411 .proc_handler
= proc_dointvec
,
414 .procname
= "numa_balancing_scan_period_min_ms",
415 .data
= &sysctl_numa_balancing_scan_period_min
,
416 .maxlen
= sizeof(unsigned int),
418 .proc_handler
= proc_dointvec
,
421 .procname
= "numa_balancing_scan_period_max_ms",
422 .data
= &sysctl_numa_balancing_scan_period_max
,
423 .maxlen
= sizeof(unsigned int),
425 .proc_handler
= proc_dointvec
,
428 .procname
= "numa_balancing_scan_size_mb",
429 .data
= &sysctl_numa_balancing_scan_size
,
430 .maxlen
= sizeof(unsigned int),
432 .proc_handler
= proc_dointvec_minmax
,
436 .procname
= "numa_balancing",
437 .data
= NULL
, /* filled in by handler */
438 .maxlen
= sizeof(unsigned int),
440 .proc_handler
= sysctl_numa_balancing
,
444 #endif /* CONFIG_NUMA_BALANCING */
445 #endif /* CONFIG_SCHED_DEBUG */
447 .procname
= "sched_rt_period_us",
448 .data
= &sysctl_sched_rt_period
,
449 .maxlen
= sizeof(unsigned int),
451 .proc_handler
= sched_rt_handler
,
454 .procname
= "sched_rt_runtime_us",
455 .data
= &sysctl_sched_rt_runtime
,
456 .maxlen
= sizeof(int),
458 .proc_handler
= sched_rt_handler
,
461 .procname
= "sched_rr_timeslice_ms",
462 .data
= &sysctl_sched_rr_timeslice
,
463 .maxlen
= sizeof(int),
465 .proc_handler
= sched_rr_handler
,
467 #ifdef CONFIG_SCHED_AUTOGROUP
469 .procname
= "sched_autogroup_enabled",
470 .data
= &sysctl_sched_autogroup_enabled
,
471 .maxlen
= sizeof(unsigned int),
473 .proc_handler
= proc_dointvec_minmax
,
478 #ifdef CONFIG_CFS_BANDWIDTH
480 .procname
= "sched_cfs_bandwidth_slice_us",
481 .data
= &sysctl_sched_cfs_bandwidth_slice
,
482 .maxlen
= sizeof(unsigned int),
484 .proc_handler
= proc_dointvec_minmax
,
488 #ifdef CONFIG_PROVE_LOCKING
490 .procname
= "prove_locking",
491 .data
= &prove_locking
,
492 .maxlen
= sizeof(int),
494 .proc_handler
= proc_dointvec
,
497 #ifdef CONFIG_LOCK_STAT
499 .procname
= "lock_stat",
501 .maxlen
= sizeof(int),
503 .proc_handler
= proc_dointvec
,
508 .data
= &panic_timeout
,
509 .maxlen
= sizeof(int),
511 .proc_handler
= proc_dointvec
,
513 #ifdef CONFIG_COREDUMP
515 .procname
= "core_uses_pid",
516 .data
= &core_uses_pid
,
517 .maxlen
= sizeof(int),
519 .proc_handler
= proc_dointvec
,
522 .procname
= "core_pattern",
523 .data
= core_pattern
,
524 .maxlen
= CORENAME_MAX_SIZE
,
526 .proc_handler
= proc_dostring_coredump
,
529 .procname
= "core_pipe_limit",
530 .data
= &core_pipe_limit
,
531 .maxlen
= sizeof(unsigned int),
533 .proc_handler
= proc_dointvec
,
536 #ifdef CONFIG_USER_NS
538 .procname
= "unprivileged_userns_clone",
539 .data
= &unprivileged_userns_clone
,
540 .maxlen
= sizeof(int),
542 .proc_handler
= proc_dointvec
,
545 #ifdef CONFIG_PROC_SYSCTL
547 .procname
= "tainted",
548 .maxlen
= sizeof(long),
550 .proc_handler
= proc_taint
,
553 .procname
= "sysctl_writes_strict",
554 .data
= &sysctl_writes_strict
,
555 .maxlen
= sizeof(int),
557 .proc_handler
= proc_dointvec_minmax
,
562 #ifdef CONFIG_LATENCYTOP
564 .procname
= "latencytop",
565 .data
= &latencytop_enabled
,
566 .maxlen
= sizeof(int),
568 .proc_handler
= sysctl_latencytop
,
571 #ifdef CONFIG_BLK_DEV_INITRD
573 .procname
= "real-root-dev",
574 .data
= &real_root_dev
,
575 .maxlen
= sizeof(int),
577 .proc_handler
= proc_dointvec
,
581 .procname
= "print-fatal-signals",
582 .data
= &print_fatal_signals
,
583 .maxlen
= sizeof(int),
585 .proc_handler
= proc_dointvec
,
589 .procname
= "reboot-cmd",
590 .data
= reboot_command
,
593 .proc_handler
= proc_dostring
,
596 .procname
= "stop-a",
597 .data
= &stop_a_enabled
,
598 .maxlen
= sizeof (int),
600 .proc_handler
= proc_dointvec
,
603 .procname
= "scons-poweroff",
604 .data
= &scons_pwroff
,
605 .maxlen
= sizeof (int),
607 .proc_handler
= proc_dointvec
,
610 #ifdef CONFIG_SPARC64
612 .procname
= "tsb-ratio",
613 .data
= &sysctl_tsb_ratio
,
614 .maxlen
= sizeof (int),
616 .proc_handler
= proc_dointvec
,
621 .procname
= "soft-power",
622 .data
= &pwrsw_enabled
,
623 .maxlen
= sizeof (int),
625 .proc_handler
= proc_dointvec
,
628 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
630 .procname
= "unaligned-trap",
631 .data
= &unaligned_enabled
,
632 .maxlen
= sizeof (int),
634 .proc_handler
= proc_dointvec
,
638 .procname
= "ctrl-alt-del",
640 .maxlen
= sizeof(int),
642 .proc_handler
= proc_dointvec
,
644 #ifdef CONFIG_FUNCTION_TRACER
646 .procname
= "ftrace_enabled",
647 .data
= &ftrace_enabled
,
648 .maxlen
= sizeof(int),
650 .proc_handler
= ftrace_enable_sysctl
,
653 #ifdef CONFIG_STACK_TRACER
655 .procname
= "stack_tracer_enabled",
656 .data
= &stack_tracer_enabled
,
657 .maxlen
= sizeof(int),
659 .proc_handler
= stack_trace_sysctl
,
662 #ifdef CONFIG_TRACING
664 .procname
= "ftrace_dump_on_oops",
665 .data
= &ftrace_dump_on_oops
,
666 .maxlen
= sizeof(int),
668 .proc_handler
= proc_dointvec
,
671 .procname
= "traceoff_on_warning",
672 .data
= &__disable_trace_on_warning
,
673 .maxlen
= sizeof(__disable_trace_on_warning
),
675 .proc_handler
= proc_dointvec
,
678 .procname
= "tracepoint_printk",
679 .data
= &tracepoint_printk
,
680 .maxlen
= sizeof(tracepoint_printk
),
682 .proc_handler
= tracepoint_printk_sysctl
,
685 #ifdef CONFIG_KEXEC_CORE
687 .procname
= "kexec_load_disabled",
688 .data
= &kexec_load_disabled
,
689 .maxlen
= sizeof(int),
691 /* only handle a transition from default "0" to "1" */
692 .proc_handler
= proc_dointvec_minmax
,
697 #ifdef CONFIG_MODULES
699 .procname
= "modprobe",
700 .data
= &modprobe_path
,
701 .maxlen
= KMOD_PATH_LEN
,
703 .proc_handler
= proc_dostring
,
706 .procname
= "modules_disabled",
707 .data
= &modules_disabled
,
708 .maxlen
= sizeof(int),
710 /* only handle a transition from default "0" to "1" */
711 .proc_handler
= proc_dointvec_minmax
,
716 #ifdef CONFIG_UEVENT_HELPER
718 .procname
= "hotplug",
719 .data
= &uevent_helper
,
720 .maxlen
= UEVENT_HELPER_PATH_LEN
,
722 .proc_handler
= proc_dostring
,
725 #ifdef CONFIG_CHR_DEV_SG
727 .procname
= "sg-big-buff",
728 .data
= &sg_big_buff
,
729 .maxlen
= sizeof (int),
731 .proc_handler
= proc_dointvec
,
734 #ifdef CONFIG_BSD_PROCESS_ACCT
738 .maxlen
= 3*sizeof(int),
740 .proc_handler
= proc_dointvec
,
743 #ifdef CONFIG_MAGIC_SYSRQ
746 .data
= &__sysrq_enabled
,
747 .maxlen
= sizeof (int),
749 .proc_handler
= sysrq_sysctl_handler
,
752 #ifdef CONFIG_PROC_SYSCTL
754 .procname
= "cad_pid",
756 .maxlen
= sizeof (int),
758 .proc_handler
= proc_do_cad_pid
,
762 .procname
= "threads-max",
764 .maxlen
= sizeof(int),
766 .proc_handler
= sysctl_max_threads
,
769 .procname
= "random",
771 .child
= random_table
,
774 .procname
= "usermodehelper",
776 .child
= usermodehelper_table
,
779 .procname
= "overflowuid",
780 .data
= &overflowuid
,
781 .maxlen
= sizeof(int),
783 .proc_handler
= proc_dointvec_minmax
,
784 .extra1
= &minolduid
,
785 .extra2
= &maxolduid
,
788 .procname
= "overflowgid",
789 .data
= &overflowgid
,
790 .maxlen
= sizeof(int),
792 .proc_handler
= proc_dointvec_minmax
,
793 .extra1
= &minolduid
,
794 .extra2
= &maxolduid
,
797 #ifdef CONFIG_MATHEMU
799 .procname
= "ieee_emulation_warnings",
800 .data
= &sysctl_ieee_emulation_warnings
,
801 .maxlen
= sizeof(int),
803 .proc_handler
= proc_dointvec
,
807 .procname
= "userprocess_debug",
808 .data
= &show_unhandled_signals
,
809 .maxlen
= sizeof(int),
811 .proc_handler
= proc_dointvec
,
815 .procname
= "pid_max",
817 .maxlen
= sizeof (int),
819 .proc_handler
= proc_dointvec_minmax
,
820 .extra1
= &pid_max_min
,
821 .extra2
= &pid_max_max
,
824 .procname
= "panic_on_oops",
825 .data
= &panic_on_oops
,
826 .maxlen
= sizeof(int),
828 .proc_handler
= proc_dointvec
,
830 #if defined CONFIG_PRINTK
832 .procname
= "printk",
833 .data
= &console_loglevel
,
834 .maxlen
= 4*sizeof(int),
836 .proc_handler
= proc_dointvec
,
839 .procname
= "printk_ratelimit",
840 .data
= &printk_ratelimit_state
.interval
,
841 .maxlen
= sizeof(int),
843 .proc_handler
= proc_dointvec_jiffies
,
846 .procname
= "printk_ratelimit_burst",
847 .data
= &printk_ratelimit_state
.burst
,
848 .maxlen
= sizeof(int),
850 .proc_handler
= proc_dointvec
,
853 .procname
= "printk_delay",
854 .data
= &printk_delay_msec
,
855 .maxlen
= sizeof(int),
857 .proc_handler
= proc_dointvec_minmax
,
859 .extra2
= &ten_thousand
,
862 .procname
= "printk_devkmsg",
863 .data
= devkmsg_log_str
,
864 .maxlen
= DEVKMSG_STR_MAX_SIZE
,
866 .proc_handler
= devkmsg_sysctl_set_loglvl
,
869 .procname
= "dmesg_restrict",
870 .data
= &dmesg_restrict
,
871 .maxlen
= sizeof(int),
873 .proc_handler
= proc_dointvec_minmax_sysadmin
,
878 .procname
= "kptr_restrict",
879 .data
= &kptr_restrict
,
880 .maxlen
= sizeof(int),
882 .proc_handler
= proc_dointvec_minmax_sysadmin
,
888 .procname
= "ngroups_max",
889 .data
= &ngroups_max
,
890 .maxlen
= sizeof (int),
892 .proc_handler
= proc_dointvec
,
895 .procname
= "cap_last_cap",
896 .data
= (void *)&cap_last_cap
,
897 .maxlen
= sizeof(int),
899 .proc_handler
= proc_dointvec
,
901 #if defined(CONFIG_LOCKUP_DETECTOR)
903 .procname
= "watchdog",
904 .data
= &watchdog_user_enabled
,
905 .maxlen
= sizeof (int),
907 .proc_handler
= proc_watchdog
,
912 .procname
= "watchdog_thresh",
913 .data
= &watchdog_thresh
,
914 .maxlen
= sizeof(int),
916 .proc_handler
= proc_watchdog_thresh
,
921 .procname
= "nmi_watchdog",
922 .data
= &nmi_watchdog_enabled
,
923 .maxlen
= sizeof (int),
925 .proc_handler
= proc_nmi_watchdog
,
927 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
934 .procname
= "watchdog_cpumask",
935 .data
= &watchdog_cpumask_bits
,
938 .proc_handler
= proc_watchdog_cpumask
,
940 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
942 .procname
= "soft_watchdog",
943 .data
= &soft_watchdog_enabled
,
944 .maxlen
= sizeof (int),
946 .proc_handler
= proc_soft_watchdog
,
951 .procname
= "softlockup_panic",
952 .data
= &softlockup_panic
,
953 .maxlen
= sizeof(int),
955 .proc_handler
= proc_dointvec_minmax
,
961 .procname
= "softlockup_all_cpu_backtrace",
962 .data
= &sysctl_softlockup_all_cpu_backtrace
,
963 .maxlen
= sizeof(int),
965 .proc_handler
= proc_dointvec_minmax
,
969 #endif /* CONFIG_SMP */
971 #ifdef CONFIG_HARDLOCKUP_DETECTOR
973 .procname
= "hardlockup_panic",
974 .data
= &hardlockup_panic
,
975 .maxlen
= sizeof(int),
977 .proc_handler
= proc_dointvec_minmax
,
983 .procname
= "hardlockup_all_cpu_backtrace",
984 .data
= &sysctl_hardlockup_all_cpu_backtrace
,
985 .maxlen
= sizeof(int),
987 .proc_handler
= proc_dointvec_minmax
,
991 #endif /* CONFIG_SMP */
995 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
997 .procname
= "unknown_nmi_panic",
998 .data
= &unknown_nmi_panic
,
999 .maxlen
= sizeof (int),
1001 .proc_handler
= proc_dointvec
,
1004 #if defined(CONFIG_X86)
1006 .procname
= "panic_on_unrecovered_nmi",
1007 .data
= &panic_on_unrecovered_nmi
,
1008 .maxlen
= sizeof(int),
1010 .proc_handler
= proc_dointvec
,
1013 .procname
= "panic_on_io_nmi",
1014 .data
= &panic_on_io_nmi
,
1015 .maxlen
= sizeof(int),
1017 .proc_handler
= proc_dointvec
,
1019 #ifdef CONFIG_DEBUG_STACKOVERFLOW
1021 .procname
= "panic_on_stackoverflow",
1022 .data
= &sysctl_panic_on_stackoverflow
,
1023 .maxlen
= sizeof(int),
1025 .proc_handler
= proc_dointvec
,
1029 .procname
= "bootloader_type",
1030 .data
= &bootloader_type
,
1031 .maxlen
= sizeof (int),
1033 .proc_handler
= proc_dointvec
,
1036 .procname
= "bootloader_version",
1037 .data
= &bootloader_version
,
1038 .maxlen
= sizeof (int),
1040 .proc_handler
= proc_dointvec
,
1043 .procname
= "io_delay_type",
1044 .data
= &io_delay_type
,
1045 .maxlen
= sizeof(int),
1047 .proc_handler
= proc_dointvec
,
1050 #if defined(CONFIG_MMU)
1052 .procname
= "randomize_va_space",
1053 .data
= &randomize_va_space
,
1054 .maxlen
= sizeof(int),
1056 .proc_handler
= proc_dointvec
,
1059 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1061 .procname
= "spin_retry",
1062 .data
= &spin_retry
,
1063 .maxlen
= sizeof (int),
1065 .proc_handler
= proc_dointvec
,
1068 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1070 .procname
= "acpi_video_flags",
1071 .data
= &acpi_realmode_flags
,
1072 .maxlen
= sizeof (unsigned long),
1074 .proc_handler
= proc_doulongvec_minmax
,
1077 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1079 .procname
= "ignore-unaligned-usertrap",
1080 .data
= &no_unaligned_warning
,
1081 .maxlen
= sizeof (int),
1083 .proc_handler
= proc_dointvec
,
1088 .procname
= "unaligned-dump-stack",
1089 .data
= &unaligned_dump_stack
,
1090 .maxlen
= sizeof (int),
1092 .proc_handler
= proc_dointvec
,
1095 #ifdef CONFIG_DETECT_HUNG_TASK
1097 .procname
= "hung_task_panic",
1098 .data
= &sysctl_hung_task_panic
,
1099 .maxlen
= sizeof(int),
1101 .proc_handler
= proc_dointvec_minmax
,
1106 .procname
= "hung_task_check_count",
1107 .data
= &sysctl_hung_task_check_count
,
1108 .maxlen
= sizeof(int),
1110 .proc_handler
= proc_dointvec_minmax
,
1114 .procname
= "hung_task_timeout_secs",
1115 .data
= &sysctl_hung_task_timeout_secs
,
1116 .maxlen
= sizeof(unsigned long),
1118 .proc_handler
= proc_dohung_task_timeout_secs
,
1119 .extra2
= &hung_task_timeout_max
,
1122 .procname
= "hung_task_warnings",
1123 .data
= &sysctl_hung_task_warnings
,
1124 .maxlen
= sizeof(int),
1126 .proc_handler
= proc_dointvec_minmax
,
1130 #ifdef CONFIG_RT_MUTEXES
1132 .procname
= "max_lock_depth",
1133 .data
= &max_lock_depth
,
1134 .maxlen
= sizeof(int),
1136 .proc_handler
= proc_dointvec
,
1140 .procname
= "poweroff_cmd",
1141 .data
= &poweroff_cmd
,
1142 .maxlen
= POWEROFF_CMD_PATH_LEN
,
1144 .proc_handler
= proc_dostring
,
1150 .child
= key_sysctls
,
1153 #ifdef CONFIG_PERF_EVENTS
1155 * User-space scripts rely on the existence of this file
1156 * as a feature check for perf_events being enabled.
1158 * So it's an ABI, do not remove!
1161 .procname
= "perf_event_paranoid",
1162 .data
= &sysctl_perf_event_paranoid
,
1163 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
1165 .proc_handler
= proc_dointvec
,
1168 .procname
= "perf_event_mlock_kb",
1169 .data
= &sysctl_perf_event_mlock
,
1170 .maxlen
= sizeof(sysctl_perf_event_mlock
),
1172 .proc_handler
= proc_dointvec
,
1175 .procname
= "perf_event_max_sample_rate",
1176 .data
= &sysctl_perf_event_sample_rate
,
1177 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1179 .proc_handler
= perf_proc_update_handler
,
1183 .procname
= "perf_cpu_time_max_percent",
1184 .data
= &sysctl_perf_cpu_time_max_percent
,
1185 .maxlen
= sizeof(sysctl_perf_cpu_time_max_percent
),
1187 .proc_handler
= perf_cpu_time_max_percent_handler
,
1189 .extra2
= &one_hundred
,
1192 .procname
= "perf_event_max_stack",
1193 .data
= &sysctl_perf_event_max_stack
,
1194 .maxlen
= sizeof(sysctl_perf_event_max_stack
),
1196 .proc_handler
= perf_event_max_stack_handler
,
1198 .extra2
= &six_hundred_forty_kb
,
1201 .procname
= "perf_event_max_contexts_per_stack",
1202 .data
= &sysctl_perf_event_max_contexts_per_stack
,
1203 .maxlen
= sizeof(sysctl_perf_event_max_contexts_per_stack
),
1205 .proc_handler
= perf_event_max_stack_handler
,
1207 .extra2
= &one_thousand
,
1210 #ifdef CONFIG_KMEMCHECK
1212 .procname
= "kmemcheck",
1213 .data
= &kmemcheck_enabled
,
1214 .maxlen
= sizeof(int),
1216 .proc_handler
= proc_dointvec
,
1220 .procname
= "panic_on_warn",
1221 .data
= &panic_on_warn
,
1222 .maxlen
= sizeof(int),
1224 .proc_handler
= proc_dointvec_minmax
,
1228 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1230 .procname
= "timer_migration",
1231 .data
= &sysctl_timer_migration
,
1232 .maxlen
= sizeof(unsigned int),
1234 .proc_handler
= timer_migration_handler
,
1239 #ifdef CONFIG_BPF_SYSCALL
1241 .procname
= "unprivileged_bpf_disabled",
1242 .data
= &sysctl_unprivileged_bpf_disabled
,
1243 .maxlen
= sizeof(sysctl_unprivileged_bpf_disabled
),
1245 /* only handle a transition from default "0" to "1" */
1246 .proc_handler
= proc_dointvec_minmax
,
1251 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1253 .procname
= "panic_on_rcu_stall",
1254 .data
= &sysctl_panic_on_rcu_stall
,
1255 .maxlen
= sizeof(sysctl_panic_on_rcu_stall
),
1257 .proc_handler
= proc_dointvec_minmax
,
1264 .procname
= "ibrs_enabled",
1265 .data
= &sysctl_ibrs_enabled
,
1266 .maxlen
= sizeof(unsigned int),
1268 .proc_handler
= proc_dointvec_ibrs_ctrl
,
1273 .procname
= "ibpb_enabled",
1274 .data
= &sysctl_ibpb_enabled
,
1275 .maxlen
= sizeof(unsigned int),
1277 .proc_handler
= proc_dointvec_ibpb_ctrl
,
1282 .procname
= "ibrs_dump",
1283 .data
= &sysctl_ibrs_dump
,
1284 .maxlen
= sizeof(unsigned int),
1286 .proc_handler
= proc_dointvec_ibrs_dump
,
1294 static struct ctl_table vm_table
[] = {
1296 .procname
= "overcommit_memory",
1297 .data
= &sysctl_overcommit_memory
,
1298 .maxlen
= sizeof(sysctl_overcommit_memory
),
1300 .proc_handler
= proc_dointvec_minmax
,
1305 .procname
= "panic_on_oom",
1306 .data
= &sysctl_panic_on_oom
,
1307 .maxlen
= sizeof(sysctl_panic_on_oom
),
1309 .proc_handler
= proc_dointvec_minmax
,
1314 .procname
= "oom_kill_allocating_task",
1315 .data
= &sysctl_oom_kill_allocating_task
,
1316 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
1318 .proc_handler
= proc_dointvec
,
1321 .procname
= "oom_dump_tasks",
1322 .data
= &sysctl_oom_dump_tasks
,
1323 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
1325 .proc_handler
= proc_dointvec
,
1328 .procname
= "overcommit_ratio",
1329 .data
= &sysctl_overcommit_ratio
,
1330 .maxlen
= sizeof(sysctl_overcommit_ratio
),
1332 .proc_handler
= overcommit_ratio_handler
,
1335 .procname
= "overcommit_kbytes",
1336 .data
= &sysctl_overcommit_kbytes
,
1337 .maxlen
= sizeof(sysctl_overcommit_kbytes
),
1339 .proc_handler
= overcommit_kbytes_handler
,
1342 .procname
= "page-cluster",
1343 .data
= &page_cluster
,
1344 .maxlen
= sizeof(int),
1346 .proc_handler
= proc_dointvec_minmax
,
1350 .procname
= "dirty_background_ratio",
1351 .data
= &dirty_background_ratio
,
1352 .maxlen
= sizeof(dirty_background_ratio
),
1354 .proc_handler
= dirty_background_ratio_handler
,
1356 .extra2
= &one_hundred
,
1359 .procname
= "dirty_background_bytes",
1360 .data
= &dirty_background_bytes
,
1361 .maxlen
= sizeof(dirty_background_bytes
),
1363 .proc_handler
= dirty_background_bytes_handler
,
1367 .procname
= "dirty_ratio",
1368 .data
= &vm_dirty_ratio
,
1369 .maxlen
= sizeof(vm_dirty_ratio
),
1371 .proc_handler
= dirty_ratio_handler
,
1373 .extra2
= &one_hundred
,
1376 .procname
= "dirty_bytes",
1377 .data
= &vm_dirty_bytes
,
1378 .maxlen
= sizeof(vm_dirty_bytes
),
1380 .proc_handler
= dirty_bytes_handler
,
1381 .extra1
= &dirty_bytes_min
,
1384 .procname
= "dirty_writeback_centisecs",
1385 .data
= &dirty_writeback_interval
,
1386 .maxlen
= sizeof(dirty_writeback_interval
),
1388 .proc_handler
= dirty_writeback_centisecs_handler
,
1391 .procname
= "dirty_expire_centisecs",
1392 .data
= &dirty_expire_interval
,
1393 .maxlen
= sizeof(dirty_expire_interval
),
1395 .proc_handler
= proc_dointvec_minmax
,
1399 .procname
= "dirtytime_expire_seconds",
1400 .data
= &dirtytime_expire_interval
,
1401 .maxlen
= sizeof(dirty_expire_interval
),
1403 .proc_handler
= dirtytime_interval_handler
,
1407 .procname
= "nr_pdflush_threads",
1408 .mode
= 0444 /* read-only */,
1409 .proc_handler
= pdflush_proc_obsolete
,
1412 .procname
= "swappiness",
1413 .data
= &vm_swappiness
,
1414 .maxlen
= sizeof(vm_swappiness
),
1416 .proc_handler
= proc_dointvec_minmax
,
1418 .extra2
= &one_hundred
,
1420 #ifdef CONFIG_HUGETLB_PAGE
1422 .procname
= "nr_hugepages",
1424 .maxlen
= sizeof(unsigned long),
1426 .proc_handler
= hugetlb_sysctl_handler
,
1430 .procname
= "nr_hugepages_mempolicy",
1432 .maxlen
= sizeof(unsigned long),
1434 .proc_handler
= &hugetlb_mempolicy_sysctl_handler
,
1438 .procname
= "hugetlb_shm_group",
1439 .data
= &sysctl_hugetlb_shm_group
,
1440 .maxlen
= sizeof(gid_t
),
1442 .proc_handler
= proc_dointvec
,
1445 .procname
= "hugepages_treat_as_movable",
1446 .data
= &hugepages_treat_as_movable
,
1447 .maxlen
= sizeof(int),
1449 .proc_handler
= proc_dointvec
,
1452 .procname
= "nr_overcommit_hugepages",
1454 .maxlen
= sizeof(unsigned long),
1456 .proc_handler
= hugetlb_overcommit_handler
,
1460 .procname
= "lowmem_reserve_ratio",
1461 .data
= &sysctl_lowmem_reserve_ratio
,
1462 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
1464 .proc_handler
= lowmem_reserve_ratio_sysctl_handler
,
1467 .procname
= "drop_caches",
1468 .data
= &sysctl_drop_caches
,
1469 .maxlen
= sizeof(int),
1471 .proc_handler
= drop_caches_sysctl_handler
,
1475 #ifdef CONFIG_COMPACTION
1477 .procname
= "compact_memory",
1478 .data
= &sysctl_compact_memory
,
1479 .maxlen
= sizeof(int),
1481 .proc_handler
= sysctl_compaction_handler
,
1484 .procname
= "extfrag_threshold",
1485 .data
= &sysctl_extfrag_threshold
,
1486 .maxlen
= sizeof(int),
1488 .proc_handler
= sysctl_extfrag_handler
,
1489 .extra1
= &min_extfrag_threshold
,
1490 .extra2
= &max_extfrag_threshold
,
1493 .procname
= "compact_unevictable_allowed",
1494 .data
= &sysctl_compact_unevictable_allowed
,
1495 .maxlen
= sizeof(int),
1497 .proc_handler
= proc_dointvec
,
1502 #endif /* CONFIG_COMPACTION */
1504 .procname
= "min_free_kbytes",
1505 .data
= &min_free_kbytes
,
1506 .maxlen
= sizeof(min_free_kbytes
),
1508 .proc_handler
= min_free_kbytes_sysctl_handler
,
1512 .procname
= "watermark_scale_factor",
1513 .data
= &watermark_scale_factor
,
1514 .maxlen
= sizeof(watermark_scale_factor
),
1516 .proc_handler
= watermark_scale_factor_sysctl_handler
,
1518 .extra2
= &one_thousand
,
1521 .procname
= "percpu_pagelist_fraction",
1522 .data
= &percpu_pagelist_fraction
,
1523 .maxlen
= sizeof(percpu_pagelist_fraction
),
1525 .proc_handler
= percpu_pagelist_fraction_sysctl_handler
,
1530 .procname
= "max_map_count",
1531 .data
= &sysctl_max_map_count
,
1532 .maxlen
= sizeof(sysctl_max_map_count
),
1534 .proc_handler
= proc_dointvec_minmax
,
1539 .procname
= "nr_trim_pages",
1540 .data
= &sysctl_nr_trim_pages
,
1541 .maxlen
= sizeof(sysctl_nr_trim_pages
),
1543 .proc_handler
= proc_dointvec_minmax
,
1548 .procname
= "laptop_mode",
1549 .data
= &laptop_mode
,
1550 .maxlen
= sizeof(laptop_mode
),
1552 .proc_handler
= proc_dointvec_jiffies
,
1555 .procname
= "block_dump",
1556 .data
= &block_dump
,
1557 .maxlen
= sizeof(block_dump
),
1559 .proc_handler
= proc_dointvec
,
1563 .procname
= "vfs_cache_pressure",
1564 .data
= &sysctl_vfs_cache_pressure
,
1565 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1567 .proc_handler
= proc_dointvec
,
1570 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1572 .procname
= "legacy_va_layout",
1573 .data
= &sysctl_legacy_va_layout
,
1574 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1576 .proc_handler
= proc_dointvec
,
1582 .procname
= "zone_reclaim_mode",
1583 .data
= &node_reclaim_mode
,
1584 .maxlen
= sizeof(node_reclaim_mode
),
1586 .proc_handler
= proc_dointvec
,
1590 .procname
= "min_unmapped_ratio",
1591 .data
= &sysctl_min_unmapped_ratio
,
1592 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1594 .proc_handler
= sysctl_min_unmapped_ratio_sysctl_handler
,
1596 .extra2
= &one_hundred
,
1599 .procname
= "min_slab_ratio",
1600 .data
= &sysctl_min_slab_ratio
,
1601 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1603 .proc_handler
= sysctl_min_slab_ratio_sysctl_handler
,
1605 .extra2
= &one_hundred
,
1610 .procname
= "stat_interval",
1611 .data
= &sysctl_stat_interval
,
1612 .maxlen
= sizeof(sysctl_stat_interval
),
1614 .proc_handler
= proc_dointvec_jiffies
,
1617 .procname
= "stat_refresh",
1621 .proc_handler
= vmstat_refresh
,
1626 .procname
= "mmap_min_addr",
1627 .data
= &dac_mmap_min_addr
,
1628 .maxlen
= sizeof(unsigned long),
1630 .proc_handler
= mmap_min_addr_handler
,
1635 .procname
= "numa_zonelist_order",
1636 .data
= &numa_zonelist_order
,
1637 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1639 .proc_handler
= numa_zonelist_order_handler
,
1642 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1643 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1645 .procname
= "vdso_enabled",
1646 #ifdef CONFIG_X86_32
1647 .data
= &vdso32_enabled
,
1648 .maxlen
= sizeof(vdso32_enabled
),
1650 .data
= &vdso_enabled
,
1651 .maxlen
= sizeof(vdso_enabled
),
1654 .proc_handler
= proc_dointvec
,
1658 #ifdef CONFIG_HIGHMEM
1660 .procname
= "highmem_is_dirtyable",
1661 .data
= &vm_highmem_is_dirtyable
,
1662 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
1664 .proc_handler
= proc_dointvec_minmax
,
1669 #ifdef CONFIG_MEMORY_FAILURE
1671 .procname
= "memory_failure_early_kill",
1672 .data
= &sysctl_memory_failure_early_kill
,
1673 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
1675 .proc_handler
= proc_dointvec_minmax
,
1680 .procname
= "memory_failure_recovery",
1681 .data
= &sysctl_memory_failure_recovery
,
1682 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
1684 .proc_handler
= proc_dointvec_minmax
,
1690 .procname
= "user_reserve_kbytes",
1691 .data
= &sysctl_user_reserve_kbytes
,
1692 .maxlen
= sizeof(sysctl_user_reserve_kbytes
),
1694 .proc_handler
= proc_doulongvec_minmax
,
1697 .procname
= "admin_reserve_kbytes",
1698 .data
= &sysctl_admin_reserve_kbytes
,
1699 .maxlen
= sizeof(sysctl_admin_reserve_kbytes
),
1701 .proc_handler
= proc_doulongvec_minmax
,
1703 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1705 .procname
= "mmap_rnd_bits",
1706 .data
= &mmap_rnd_bits
,
1707 .maxlen
= sizeof(mmap_rnd_bits
),
1709 .proc_handler
= proc_dointvec_minmax
,
1710 .extra1
= (void *)&mmap_rnd_bits_min
,
1711 .extra2
= (void *)&mmap_rnd_bits_max
,
1714 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1716 .procname
= "mmap_rnd_compat_bits",
1717 .data
= &mmap_rnd_compat_bits
,
1718 .maxlen
= sizeof(mmap_rnd_compat_bits
),
1720 .proc_handler
= proc_dointvec_minmax
,
1721 .extra1
= (void *)&mmap_rnd_compat_bits_min
,
1722 .extra2
= (void *)&mmap_rnd_compat_bits_max
,
1728 static struct ctl_table fs_table
[] = {
1730 .procname
= "inode-nr",
1731 .data
= &inodes_stat
,
1732 .maxlen
= 2*sizeof(long),
1734 .proc_handler
= proc_nr_inodes
,
1737 .procname
= "inode-state",
1738 .data
= &inodes_stat
,
1739 .maxlen
= 7*sizeof(long),
1741 .proc_handler
= proc_nr_inodes
,
1744 .procname
= "file-nr",
1745 .data
= &files_stat
,
1746 .maxlen
= sizeof(files_stat
),
1748 .proc_handler
= proc_nr_files
,
1751 .procname
= "file-max",
1752 .data
= &files_stat
.max_files
,
1753 .maxlen
= sizeof(files_stat
.max_files
),
1755 .proc_handler
= proc_doulongvec_minmax
,
1758 .procname
= "nr_open",
1759 .data
= &sysctl_nr_open
,
1760 .maxlen
= sizeof(unsigned int),
1762 .proc_handler
= proc_dointvec_minmax
,
1763 .extra1
= &sysctl_nr_open_min
,
1764 .extra2
= &sysctl_nr_open_max
,
1767 .procname
= "dentry-state",
1768 .data
= &dentry_stat
,
1769 .maxlen
= 6*sizeof(long),
1771 .proc_handler
= proc_nr_dentry
,
1774 .procname
= "overflowuid",
1775 .data
= &fs_overflowuid
,
1776 .maxlen
= sizeof(int),
1778 .proc_handler
= proc_dointvec_minmax
,
1779 .extra1
= &minolduid
,
1780 .extra2
= &maxolduid
,
1783 .procname
= "overflowgid",
1784 .data
= &fs_overflowgid
,
1785 .maxlen
= sizeof(int),
1787 .proc_handler
= proc_dointvec_minmax
,
1788 .extra1
= &minolduid
,
1789 .extra2
= &maxolduid
,
1791 #ifdef CONFIG_FILE_LOCKING
1793 .procname
= "leases-enable",
1794 .data
= &leases_enable
,
1795 .maxlen
= sizeof(int),
1797 .proc_handler
= proc_dointvec
,
1800 #ifdef CONFIG_DNOTIFY
1802 .procname
= "dir-notify-enable",
1803 .data
= &dir_notify_enable
,
1804 .maxlen
= sizeof(int),
1806 .proc_handler
= proc_dointvec
,
1810 #ifdef CONFIG_FILE_LOCKING
1812 .procname
= "lease-break-time",
1813 .data
= &lease_break_time
,
1814 .maxlen
= sizeof(int),
1816 .proc_handler
= proc_dointvec
,
1821 .procname
= "aio-nr",
1823 .maxlen
= sizeof(aio_nr
),
1825 .proc_handler
= proc_doulongvec_minmax
,
1828 .procname
= "aio-max-nr",
1829 .data
= &aio_max_nr
,
1830 .maxlen
= sizeof(aio_max_nr
),
1832 .proc_handler
= proc_doulongvec_minmax
,
1834 #endif /* CONFIG_AIO */
1835 #ifdef CONFIG_INOTIFY_USER
1837 .procname
= "inotify",
1839 .child
= inotify_table
,
1844 .procname
= "epoll",
1846 .child
= epoll_table
,
1851 .procname
= "protected_symlinks",
1852 .data
= &sysctl_protected_symlinks
,
1853 .maxlen
= sizeof(int),
1855 .proc_handler
= proc_dointvec_minmax
,
1860 .procname
= "protected_hardlinks",
1861 .data
= &sysctl_protected_hardlinks
,
1862 .maxlen
= sizeof(int),
1864 .proc_handler
= proc_dointvec_minmax
,
1869 .procname
= "suid_dumpable",
1870 .data
= &suid_dumpable
,
1871 .maxlen
= sizeof(int),
1873 .proc_handler
= proc_dointvec_minmax_coredump
,
1877 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1879 .procname
= "binfmt_misc",
1881 .child
= sysctl_mount_point
,
1885 .procname
= "pipe-max-size",
1886 .data
= &pipe_max_size
,
1887 .maxlen
= sizeof(int),
1889 .proc_handler
= &pipe_proc_fn
,
1890 .extra1
= &pipe_min_size
,
1893 .procname
= "pipe-user-pages-hard",
1894 .data
= &pipe_user_pages_hard
,
1895 .maxlen
= sizeof(pipe_user_pages_hard
),
1897 .proc_handler
= proc_doulongvec_minmax
,
1900 .procname
= "pipe-user-pages-soft",
1901 .data
= &pipe_user_pages_soft
,
1902 .maxlen
= sizeof(pipe_user_pages_soft
),
1904 .proc_handler
= proc_doulongvec_minmax
,
1907 .procname
= "mount-max",
1908 .data
= &sysctl_mount_max
,
1909 .maxlen
= sizeof(unsigned int),
1911 .proc_handler
= proc_dointvec_minmax
,
1917 static struct ctl_table debug_table
[] = {
1918 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1920 .procname
= "exception-trace",
1921 .data
= &show_unhandled_signals
,
1922 .maxlen
= sizeof(int),
1924 .proc_handler
= proc_dointvec
1927 #if defined(CONFIG_OPTPROBES)
1929 .procname
= "kprobes-optimization",
1930 .data
= &sysctl_kprobes_optimization
,
1931 .maxlen
= sizeof(int),
1933 .proc_handler
= proc_kprobes_optimization_handler
,
1941 static struct ctl_table dev_table
[] = {
1945 int __init
sysctl_init(void)
1947 struct ctl_table_header
*hdr
;
1949 hdr
= register_sysctl_table(sysctl_base_table
);
1950 kmemleak_not_leak(hdr
);
1954 #endif /* CONFIG_SYSCTL */
1960 #ifdef CONFIG_PROC_SYSCTL
1962 static int _proc_do_string(char *data
, int maxlen
, int write
,
1963 char __user
*buffer
,
1964 size_t *lenp
, loff_t
*ppos
)
1970 if (!data
|| !maxlen
|| !*lenp
) {
1976 if (sysctl_writes_strict
== SYSCTL_WRITES_STRICT
) {
1977 /* Only continue writes not past the end of buffer. */
1979 if (len
> maxlen
- 1)
1986 /* Start writing from beginning of buffer. */
1992 while ((p
- buffer
) < *lenp
&& len
< maxlen
- 1) {
1993 if (get_user(c
, p
++))
1995 if (c
== 0 || c
== '\n')
2016 if (copy_to_user(buffer
, data
, len
))
2019 if (put_user('\n', buffer
+ len
))
2029 static void warn_sysctl_write(struct ctl_table
*table
)
2031 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2032 "This will not be supported in the future. To silence this\n"
2033 "warning, set kernel.sysctl_writes_strict = -1\n",
2034 current
->comm
, table
->procname
);
2038 * proc_first_pos_non_zero_ignore - check if firs position is allowed
2039 * @ppos: file position
2040 * @table: the sysctl table
2042 * Returns true if the first position is non-zero and the sysctl_writes_strict
2043 * mode indicates this is not allowed for numeric input types. String proc
2044 * hadlers can ignore the return value.
2046 static bool proc_first_pos_non_zero_ignore(loff_t
*ppos
,
2047 struct ctl_table
*table
)
2052 switch (sysctl_writes_strict
) {
2053 case SYSCTL_WRITES_STRICT
:
2055 case SYSCTL_WRITES_WARN
:
2056 warn_sysctl_write(table
);
2064 * proc_dostring - read a string sysctl
2065 * @table: the sysctl table
2066 * @write: %TRUE if this is a write to the sysctl file
2067 * @buffer: the user buffer
2068 * @lenp: the size of the user buffer
2069 * @ppos: file position
2071 * Reads/writes a string from/to the user buffer. If the kernel
2072 * buffer provided is not large enough to hold the string, the
2073 * string is truncated. The copied string is %NULL-terminated.
2074 * If the string is being read by the user process, it is copied
2075 * and a newline '\n' is added. It is truncated if the buffer is
2078 * Returns 0 on success.
2080 int proc_dostring(struct ctl_table
*table
, int write
,
2081 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2084 proc_first_pos_non_zero_ignore(ppos
, table
);
2086 return _proc_do_string((char *)(table
->data
), table
->maxlen
, write
,
2087 (char __user
*)buffer
, lenp
, ppos
);
2090 static size_t proc_skip_spaces(char **buf
)
2093 char *tmp
= skip_spaces(*buf
);
2099 static void proc_skip_char(char **buf
, size_t *size
, const char v
)
2109 #define TMPBUFLEN 22
2111 * proc_get_long - reads an ASCII formatted integer from a user buffer
2113 * @buf: a kernel buffer
2114 * @size: size of the kernel buffer
2115 * @val: this is where the number will be stored
2116 * @neg: set to %TRUE if number is negative
2117 * @perm_tr: a vector which contains the allowed trailers
2118 * @perm_tr_len: size of the perm_tr vector
2119 * @tr: pointer to store the trailer character
2121 * In case of success %0 is returned and @buf and @size are updated with
2122 * the amount of bytes read. If @tr is non-NULL and a trailing
2123 * character exists (size is non-zero after returning from this
2124 * function), @tr is updated with the trailing character.
2126 static int proc_get_long(char **buf
, size_t *size
,
2127 unsigned long *val
, bool *neg
,
2128 const char *perm_tr
, unsigned perm_tr_len
, char *tr
)
2131 char *p
, tmp
[TMPBUFLEN
];
2137 if (len
> TMPBUFLEN
- 1)
2138 len
= TMPBUFLEN
- 1;
2140 memcpy(tmp
, *buf
, len
);
2144 if (*p
== '-' && *size
> 1) {
2152 *val
= simple_strtoul(p
, &p
, 0);
2156 /* We don't know if the next char is whitespace thus we may accept
2157 * invalid integers (e.g. 1234...a) or two integers instead of one
2158 * (e.g. 123...1). So lets not allow such large numbers. */
2159 if (len
== TMPBUFLEN
- 1)
2162 if (len
< *size
&& perm_tr_len
&& !memchr(perm_tr
, *p
, perm_tr_len
))
2165 if (tr
&& (len
< *size
))
2175 * proc_put_long - converts an integer to a decimal ASCII formatted string
2177 * @buf: the user buffer
2178 * @size: the size of the user buffer
2179 * @val: the integer to be converted
2180 * @neg: sign of the number, %TRUE for negative
2182 * In case of success %0 is returned and @buf and @size are updated with
2183 * the amount of bytes written.
2185 static int proc_put_long(void __user
**buf
, size_t *size
, unsigned long val
,
2189 char tmp
[TMPBUFLEN
], *p
= tmp
;
2191 sprintf(p
, "%s%lu", neg
? "-" : "", val
);
2195 if (copy_to_user(*buf
, tmp
, len
))
2203 static int proc_put_char(void __user
**buf
, size_t *size
, char c
)
2206 char __user
**buffer
= (char __user
**)buf
;
2207 if (put_user(c
, *buffer
))
2209 (*size
)--, (*buffer
)++;
2215 static int do_proc_dointvec_conv(bool *negp
, unsigned long *lvalp
,
2217 int write
, void *data
)
2221 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2225 if (*lvalp
> (unsigned long) INT_MAX
)
2233 *lvalp
= -(unsigned long)val
;
2236 *lvalp
= (unsigned long)val
;
2242 static int do_proc_douintvec_conv(unsigned long *lvalp
,
2244 int write
, void *data
)
2247 if (*lvalp
> UINT_MAX
)
2249 if (*lvalp
> UINT_MAX
)
2253 unsigned int val
= *valp
;
2254 *lvalp
= (unsigned long)val
;
2259 static const char proc_wspace_sep
[] = { ' ', '\t', '\n' };
2261 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2262 int write
, void __user
*buffer
,
2263 size_t *lenp
, loff_t
*ppos
,
2264 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2265 int write
, void *data
),
2268 int *i
, vleft
, first
= 1, err
= 0;
2270 char *kbuf
= NULL
, *p
;
2272 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2277 i
= (int *) tbl_data
;
2278 vleft
= table
->maxlen
/ sizeof(*i
);
2282 conv
= do_proc_dointvec_conv
;
2285 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2288 if (left
> PAGE_SIZE
- 1)
2289 left
= PAGE_SIZE
- 1;
2290 p
= kbuf
= memdup_user_nul(buffer
, left
);
2292 return PTR_ERR(kbuf
);
2295 for (; left
&& vleft
--; i
++, first
=0) {
2300 left
-= proc_skip_spaces(&p
);
2304 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2306 sizeof(proc_wspace_sep
), NULL
);
2309 if (conv(&neg
, &lval
, i
, 1, data
)) {
2314 if (conv(&neg
, &lval
, i
, 0, data
)) {
2319 err
= proc_put_char(&buffer
, &left
, '\t');
2322 err
= proc_put_long(&buffer
, &left
, lval
, neg
);
2328 if (!write
&& !first
&& left
&& !err
)
2329 err
= proc_put_char(&buffer
, &left
, '\n');
2330 if (write
&& !err
&& left
)
2331 left
-= proc_skip_spaces(&p
);
2335 return err
? : -EINVAL
;
2343 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2344 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2345 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2346 int write
, void *data
),
2349 return __do_proc_dointvec(table
->data
, table
, write
,
2350 buffer
, lenp
, ppos
, conv
, data
);
2353 static int do_proc_douintvec_w(unsigned int *tbl_data
,
2354 struct ctl_table
*table
,
2355 void __user
*buffer
,
2356 size_t *lenp
, loff_t
*ppos
,
2357 int (*conv
)(unsigned long *lvalp
,
2359 int write
, void *data
),
2366 char *kbuf
= NULL
, *p
;
2370 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2373 if (left
> PAGE_SIZE
- 1)
2374 left
= PAGE_SIZE
- 1;
2376 p
= kbuf
= memdup_user_nul(buffer
, left
);
2380 left
-= proc_skip_spaces(&p
);
2386 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2388 sizeof(proc_wspace_sep
), NULL
);
2394 if (conv(&lval
, tbl_data
, 1, data
)) {
2400 left
-= proc_skip_spaces(&p
);
2409 /* This is in keeping with old __do_proc_dointvec() */
2415 static int do_proc_douintvec_r(unsigned int *tbl_data
, void __user
*buffer
,
2416 size_t *lenp
, loff_t
*ppos
,
2417 int (*conv
)(unsigned long *lvalp
,
2419 int write
, void *data
),
2428 if (conv(&lval
, tbl_data
, 0, data
)) {
2433 err
= proc_put_long(&buffer
, &left
, lval
, false);
2437 err
= proc_put_char(&buffer
, &left
, '\n');
2446 static int __do_proc_douintvec(void *tbl_data
, struct ctl_table
*table
,
2447 int write
, void __user
*buffer
,
2448 size_t *lenp
, loff_t
*ppos
,
2449 int (*conv
)(unsigned long *lvalp
,
2451 int write
, void *data
),
2454 unsigned int *i
, vleft
;
2456 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2461 i
= (unsigned int *) tbl_data
;
2462 vleft
= table
->maxlen
/ sizeof(*i
);
2465 * Arrays are not supported, keep this simple. *Do not* add
2474 conv
= do_proc_douintvec_conv
;
2477 return do_proc_douintvec_w(i
, table
, buffer
, lenp
, ppos
,
2479 return do_proc_douintvec_r(i
, buffer
, lenp
, ppos
, conv
, data
);
2482 static int do_proc_douintvec(struct ctl_table
*table
, int write
,
2483 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2484 int (*conv
)(unsigned long *lvalp
,
2486 int write
, void *data
),
2489 return __do_proc_douintvec(table
->data
, table
, write
,
2490 buffer
, lenp
, ppos
, conv
, data
);
2494 * proc_dointvec - read a vector of integers
2495 * @table: the sysctl table
2496 * @write: %TRUE if this is a write to the sysctl file
2497 * @buffer: the user buffer
2498 * @lenp: the size of the user buffer
2499 * @ppos: file position
2501 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2502 * values from/to the user buffer, treated as an ASCII string.
2504 * Returns 0 on success.
2506 int proc_dointvec(struct ctl_table
*table
, int write
,
2507 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2509 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
, NULL
, NULL
);
2513 * proc_douintvec - read a vector of unsigned integers
2514 * @table: the sysctl table
2515 * @write: %TRUE if this is a write to the sysctl file
2516 * @buffer: the user buffer
2517 * @lenp: the size of the user buffer
2518 * @ppos: file position
2520 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2521 * values from/to the user buffer, treated as an ASCII string.
2523 * Returns 0 on success.
2525 int proc_douintvec(struct ctl_table
*table
, int write
,
2526 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2528 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2529 do_proc_douintvec_conv
, NULL
);
2533 * Taint values can only be increased
2534 * This means we can safely use a temporary.
2536 static int proc_taint(struct ctl_table
*table
, int write
,
2537 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2540 unsigned long tmptaint
= get_taint();
2543 if (write
&& !capable(CAP_SYS_ADMIN
))
2548 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2554 * Poor man's atomic or. Not worth adding a primitive
2555 * to everyone's atomic.h for this
2558 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2559 if ((tmptaint
>> i
) & 1)
2560 add_taint(i
, LOCKDEP_STILL_OK
);
2567 #ifdef CONFIG_PRINTK
2568 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
2569 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2571 if (write
&& !capable(CAP_SYS_ADMIN
))
2574 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2578 struct do_proc_dointvec_minmax_conv_param
{
2583 static int do_proc_dointvec_minmax_conv(bool *negp
, unsigned long *lvalp
,
2585 int write
, void *data
)
2587 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2589 int val
= *negp
? -*lvalp
: *lvalp
;
2590 if ((param
->min
&& *param
->min
> val
) ||
2591 (param
->max
&& *param
->max
< val
))
2598 *lvalp
= -(unsigned long)val
;
2601 *lvalp
= (unsigned long)val
;
2608 * proc_dointvec_minmax - read a vector of integers with min/max values
2609 * @table: the sysctl table
2610 * @write: %TRUE if this is a write to the sysctl file
2611 * @buffer: the user buffer
2612 * @lenp: the size of the user buffer
2613 * @ppos: file position
2615 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2616 * values from/to the user buffer, treated as an ASCII string.
2618 * This routine will ensure the values are within the range specified by
2619 * table->extra1 (min) and table->extra2 (max).
2621 * Returns 0 on success.
2623 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2624 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2626 struct do_proc_dointvec_minmax_conv_param param
= {
2627 .min
= (int *) table
->extra1
,
2628 .max
= (int *) table
->extra2
,
2630 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2631 do_proc_dointvec_minmax_conv
, ¶m
);
2635 int proc_dointvec_ibrs_dump(struct ctl_table
*table
, int write
,
2636 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2638 int ret
, orig_inuse
;
2642 ret
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2643 printk("sysctl_ibrs_enabled = %u, sysctl_ibpb_enabled = %u\n", sysctl_ibrs_enabled
, sysctl_ibpb_enabled
);
2644 printk("use_ibrs = %d, use_ibpb = %d\n", use_ibrs
, use_ibpb
);
2645 mutex_lock(&spec_ctrl_mutex
);
2646 orig_inuse
= use_ibrs
;
2647 /* temporary halt to ibrs usage to dump ibrs values */
2649 for_each_online_cpu(cpu
) {
2652 if (boot_cpu_has(X86_FEATURE_SPEC_CTRL
))
2653 rdmsrl_on_cpu(cpu
, MSR_IA32_SPEC_CTRL
, &val
);
2656 printk("read cpu %d ibrs val %lu\n", cpu
, (unsigned long) val
);
2658 use_ibrs
= orig_inuse
;
2659 mutex_unlock(&spec_ctrl_mutex
);
2663 int proc_dointvec_ibrs_ctrl(struct ctl_table
*table
, int write
,
2664 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2669 ret
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2670 pr_debug("sysctl_ibrs_enabled = %u, sysctl_ibpb_enabled = %u\n", sysctl_ibrs_enabled
, sysctl_ibpb_enabled
);
2671 pr_debug("before:use_ibrs = %d, use_ibpb = %d\n", use_ibrs
, use_ibpb
);
2672 mutex_lock(&spec_ctrl_mutex
);
2673 if (sysctl_ibrs_enabled
== 0) {
2674 /* always set IBRS off */
2675 set_ibrs_disabled();
2676 if (ibrs_supported
) {
2677 for_each_online_cpu(cpu
)
2678 wrmsrl_on_cpu(cpu
, MSR_IA32_SPEC_CTRL
, 0x0);
2680 } else if (sysctl_ibrs_enabled
== 2) {
2681 /* always set IBRS on, even in user space */
2682 clear_ibrs_disabled();
2683 if (ibrs_supported
) {
2684 for_each_online_cpu(cpu
)
2685 wrmsrl_on_cpu(cpu
, MSR_IA32_SPEC_CTRL
, FEATURE_ENABLE_IBRS
);
2687 sysctl_ibrs_enabled
= 0;
2689 } else if (sysctl_ibrs_enabled
== 1) {
2690 /* use IBRS in kernel */
2691 clear_ibrs_disabled();
2693 /* platform don't support ibrs */
2694 sysctl_ibrs_enabled
= 0;
2696 mutex_unlock(&spec_ctrl_mutex
);
2697 pr_debug("after:use_ibrs = %d, use_ibpb = %d\n", use_ibrs
, use_ibpb
);
2701 int proc_dointvec_ibpb_ctrl(struct ctl_table
*table
, int write
,
2702 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2706 ret
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2707 pr_debug("sysctl_ibrs_enabled = %u, sysctl_ibpb_enabled = %u\n", sysctl_ibrs_enabled
, sysctl_ibpb_enabled
);
2708 pr_debug("before:use_ibrs = %d, use_ibpb = %d\n", use_ibrs
, use_ibpb
);
2709 mutex_lock(&spec_ctrl_mutex
);
2710 if (sysctl_ibpb_enabled
== 0)
2711 set_ibpb_disabled();
2712 else if (sysctl_ibpb_enabled
== 1) {
2713 clear_ibpb_disabled();
2715 /* platform don't support ibpb */
2716 sysctl_ibpb_enabled
= 0;
2718 mutex_unlock(&spec_ctrl_mutex
);
2719 pr_debug("after:use_ibrs = %d, use_ibpb = %d\n", use_ibrs
, use_ibpb
);
2725 struct do_proc_douintvec_minmax_conv_param
{
2730 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp
,
2732 int write
, void *data
)
2734 struct do_proc_douintvec_minmax_conv_param
*param
= data
;
2737 unsigned int val
= *lvalp
;
2739 if ((param
->min
&& *param
->min
> val
) ||
2740 (param
->max
&& *param
->max
< val
))
2743 if (*lvalp
> UINT_MAX
)
2747 unsigned int val
= *valp
;
2748 *lvalp
= (unsigned long) val
;
2755 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2756 * @table: the sysctl table
2757 * @write: %TRUE if this is a write to the sysctl file
2758 * @buffer: the user buffer
2759 * @lenp: the size of the user buffer
2760 * @ppos: file position
2762 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2763 * values from/to the user buffer, treated as an ASCII string. Negative
2764 * strings are not allowed.
2766 * This routine will ensure the values are within the range specified by
2767 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2768 * check for UINT_MAX to avoid having to support wrap around uses from
2771 * Returns 0 on success.
2773 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
2774 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2776 struct do_proc_douintvec_minmax_conv_param param
= {
2777 .min
= (unsigned int *) table
->extra1
,
2778 .max
= (unsigned int *) table
->extra2
,
2780 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2781 do_proc_douintvec_minmax_conv
, ¶m
);
2784 static void validate_coredump_safety(void)
2786 #ifdef CONFIG_COREDUMP
2787 if (suid_dumpable
== SUID_DUMP_ROOT
&&
2788 core_pattern
[0] != '/' && core_pattern
[0] != '|') {
2790 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2791 "Pipe handler or fully qualified core dump path required.\n"
2792 "Set kernel.core_pattern before fs.suid_dumpable.\n"
2798 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
2799 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2801 int error
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2803 validate_coredump_safety();
2807 #ifdef CONFIG_COREDUMP
2808 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
2809 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2811 int error
= proc_dostring(table
, write
, buffer
, lenp
, ppos
);
2813 validate_coredump_safety();
2818 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2819 void __user
*buffer
,
2820 size_t *lenp
, loff_t
*ppos
,
2821 unsigned long convmul
,
2822 unsigned long convdiv
)
2824 unsigned long *i
, *min
, *max
;
2825 int vleft
, first
= 1, err
= 0;
2827 char *kbuf
= NULL
, *p
;
2829 if (!data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2834 i
= (unsigned long *) data
;
2835 min
= (unsigned long *) table
->extra1
;
2836 max
= (unsigned long *) table
->extra2
;
2837 vleft
= table
->maxlen
/ sizeof(unsigned long);
2841 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2844 if (left
> PAGE_SIZE
- 1)
2845 left
= PAGE_SIZE
- 1;
2846 p
= kbuf
= memdup_user_nul(buffer
, left
);
2848 return PTR_ERR(kbuf
);
2851 for (; left
&& vleft
--; i
++, first
= 0) {
2857 left
-= proc_skip_spaces(&p
);
2859 err
= proc_get_long(&p
, &left
, &val
, &neg
,
2861 sizeof(proc_wspace_sep
), NULL
);
2866 val
= convmul
* val
/ convdiv
;
2867 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2871 val
= convdiv
* (*i
) / convmul
;
2873 err
= proc_put_char(&buffer
, &left
, '\t');
2877 err
= proc_put_long(&buffer
, &left
, val
, false);
2883 if (!write
&& !first
&& left
&& !err
)
2884 err
= proc_put_char(&buffer
, &left
, '\n');
2886 left
-= proc_skip_spaces(&p
);
2890 return err
? : -EINVAL
;
2898 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2899 void __user
*buffer
,
2900 size_t *lenp
, loff_t
*ppos
,
2901 unsigned long convmul
,
2902 unsigned long convdiv
)
2904 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2905 buffer
, lenp
, ppos
, convmul
, convdiv
);
2909 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2910 * @table: the sysctl table
2911 * @write: %TRUE if this is a write to the sysctl file
2912 * @buffer: the user buffer
2913 * @lenp: the size of the user buffer
2914 * @ppos: file position
2916 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2917 * values from/to the user buffer, treated as an ASCII string.
2919 * This routine will ensure the values are within the range specified by
2920 * table->extra1 (min) and table->extra2 (max).
2922 * Returns 0 on success.
2924 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2925 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2927 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2931 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2932 * @table: the sysctl table
2933 * @write: %TRUE if this is a write to the sysctl file
2934 * @buffer: the user buffer
2935 * @lenp: the size of the user buffer
2936 * @ppos: file position
2938 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2939 * values from/to the user buffer, treated as an ASCII string. The values
2940 * are treated as milliseconds, and converted to jiffies when they are stored.
2942 * This routine will ensure the values are within the range specified by
2943 * table->extra1 (min) and table->extra2 (max).
2945 * Returns 0 on success.
2947 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2948 void __user
*buffer
,
2949 size_t *lenp
, loff_t
*ppos
)
2951 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2952 lenp
, ppos
, HZ
, 1000l);
2956 static int do_proc_dointvec_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2958 int write
, void *data
)
2961 if (*lvalp
> INT_MAX
/ HZ
)
2963 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2969 lval
= -(unsigned long)val
;
2972 lval
= (unsigned long)val
;
2979 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2981 int write
, void *data
)
2984 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2986 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2992 lval
= -(unsigned long)val
;
2995 lval
= (unsigned long)val
;
2997 *lvalp
= jiffies_to_clock_t(lval
);
3002 static int do_proc_dointvec_ms_jiffies_conv(bool *negp
, unsigned long *lvalp
,
3004 int write
, void *data
)
3007 unsigned long jif
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
3017 lval
= -(unsigned long)val
;
3020 lval
= (unsigned long)val
;
3022 *lvalp
= jiffies_to_msecs(lval
);
3028 * proc_dointvec_jiffies - read a vector of integers as seconds
3029 * @table: the sysctl table
3030 * @write: %TRUE if this is a write to the sysctl file
3031 * @buffer: the user buffer
3032 * @lenp: the size of the user buffer
3033 * @ppos: file position
3035 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3036 * values from/to the user buffer, treated as an ASCII string.
3037 * The values read are assumed to be in seconds, and are converted into
3040 * Returns 0 on success.
3042 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
3043 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3045 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
3046 do_proc_dointvec_jiffies_conv
,NULL
);
3050 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
3051 * @table: the sysctl table
3052 * @write: %TRUE if this is a write to the sysctl file
3053 * @buffer: the user buffer
3054 * @lenp: the size of the user buffer
3055 * @ppos: pointer to the file position
3057 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3058 * values from/to the user buffer, treated as an ASCII string.
3059 * The values read are assumed to be in 1/USER_HZ seconds, and
3060 * are converted into jiffies.
3062 * Returns 0 on success.
3064 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
3065 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3067 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
3068 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
3072 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
3073 * @table: the sysctl table
3074 * @write: %TRUE if this is a write to the sysctl file
3075 * @buffer: the user buffer
3076 * @lenp: the size of the user buffer
3077 * @ppos: file position
3078 * @ppos: the current position in the file
3080 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3081 * values from/to the user buffer, treated as an ASCII string.
3082 * The values read are assumed to be in 1/1000 seconds, and
3083 * are converted into jiffies.
3085 * Returns 0 on success.
3087 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
3088 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3090 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
3091 do_proc_dointvec_ms_jiffies_conv
, NULL
);
3094 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
3095 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3097 struct pid
*new_pid
;
3101 tmp
= pid_vnr(cad_pid
);
3103 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
3104 lenp
, ppos
, NULL
, NULL
);
3108 new_pid
= find_get_pid(tmp
);
3112 put_pid(xchg(&cad_pid
, new_pid
));
3117 * proc_do_large_bitmap - read/write from/to a large bitmap
3118 * @table: the sysctl table
3119 * @write: %TRUE if this is a write to the sysctl file
3120 * @buffer: the user buffer
3121 * @lenp: the size of the user buffer
3122 * @ppos: file position
3124 * The bitmap is stored at table->data and the bitmap length (in bits)
3127 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
3128 * large bitmaps may be represented in a compact manner. Writing into
3129 * the file will clear the bitmap then update it with the given input.
3131 * Returns 0 on success.
3133 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
3134 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3138 size_t left
= *lenp
;
3139 unsigned long bitmap_len
= table
->maxlen
;
3140 unsigned long *bitmap
= *(unsigned long **) table
->data
;
3141 unsigned long *tmp_bitmap
= NULL
;
3142 char tr_a
[] = { '-', ',', '\n' }, tr_b
[] = { ',', '\n', 0 }, c
;
3144 if (!bitmap
|| !bitmap_len
|| !left
|| (*ppos
&& !write
)) {
3152 if (left
> PAGE_SIZE
- 1)
3153 left
= PAGE_SIZE
- 1;
3155 p
= kbuf
= memdup_user_nul(buffer
, left
);
3157 return PTR_ERR(kbuf
);
3159 tmp_bitmap
= kzalloc(BITS_TO_LONGS(bitmap_len
) * sizeof(unsigned long),
3165 proc_skip_char(&p
, &left
, '\n');
3166 while (!err
&& left
) {
3167 unsigned long val_a
, val_b
;
3170 err
= proc_get_long(&p
, &left
, &val_a
, &neg
, tr_a
,
3174 if (val_a
>= bitmap_len
|| neg
) {
3186 err
= proc_get_long(&p
, &left
, &val_b
,
3187 &neg
, tr_b
, sizeof(tr_b
),
3191 if (val_b
>= bitmap_len
|| neg
||
3202 bitmap_set(tmp_bitmap
, val_a
, val_b
- val_a
+ 1);
3204 proc_skip_char(&p
, &left
, '\n');
3208 unsigned long bit_a
, bit_b
= 0;
3211 bit_a
= find_next_bit(bitmap
, bitmap_len
, bit_b
);
3212 if (bit_a
>= bitmap_len
)
3214 bit_b
= find_next_zero_bit(bitmap
, bitmap_len
,
3218 err
= proc_put_char(&buffer
, &left
, ',');
3222 err
= proc_put_long(&buffer
, &left
, bit_a
, false);
3225 if (bit_a
!= bit_b
) {
3226 err
= proc_put_char(&buffer
, &left
, '-');
3229 err
= proc_put_long(&buffer
, &left
, bit_b
, false);
3237 err
= proc_put_char(&buffer
, &left
, '\n');
3243 bitmap_or(bitmap
, bitmap
, tmp_bitmap
, bitmap_len
);
3245 bitmap_copy(bitmap
, tmp_bitmap
, bitmap_len
);
3257 #else /* CONFIG_PROC_SYSCTL */
3259 int proc_dostring(struct ctl_table
*table
, int write
,
3260 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3265 int proc_dointvec(struct ctl_table
*table
, int write
,
3266 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3271 int proc_douintvec(struct ctl_table
*table
, int write
,
3272 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3277 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
3278 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3283 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
3284 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3289 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
3290 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3295 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
3296 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3301 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
3302 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3307 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
3308 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3313 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
3314 void __user
*buffer
,
3315 size_t *lenp
, loff_t
*ppos
)
3321 #endif /* CONFIG_PROC_SYSCTL */
3324 * No sense putting this after each symbol definition, twice,
3325 * exception granted :-)
3327 EXPORT_SYMBOL(proc_dointvec
);
3328 EXPORT_SYMBOL(proc_douintvec
);
3329 EXPORT_SYMBOL(proc_dointvec_jiffies
);
3330 EXPORT_SYMBOL(proc_dointvec_minmax
);
3331 EXPORT_SYMBOL_GPL(proc_douintvec_minmax
);
3332 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
3333 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
3334 EXPORT_SYMBOL(proc_dostring
);
3335 EXPORT_SYMBOL(proc_doulongvec_minmax
);
3336 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);