2 * sysctl.c: General linux system control interface
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
21 #include <linux/module.h>
22 #include <linux/aio.h>
24 #include <linux/swap.h>
25 #include <linux/slab.h>
26 #include <linux/sysctl.h>
27 #include <linux/bitmap.h>
28 #include <linux/signal.h>
29 #include <linux/printk.h>
30 #include <linux/proc_fs.h>
31 #include <linux/security.h>
32 #include <linux/ctype.h>
33 #include <linux/kmemleak.h>
35 #include <linux/init.h>
36 #include <linux/kernel.h>
37 #include <linux/kobject.h>
38 #include <linux/net.h>
39 #include <linux/sysrq.h>
40 #include <linux/highuid.h>
41 #include <linux/writeback.h>
42 #include <linux/ratelimit.h>
43 #include <linux/compaction.h>
44 #include <linux/hugetlb.h>
45 #include <linux/initrd.h>
46 #include <linux/key.h>
47 #include <linux/times.h>
48 #include <linux/limits.h>
49 #include <linux/dcache.h>
50 #include <linux/dnotify.h>
51 #include <linux/syscalls.h>
52 #include <linux/vmstat.h>
53 #include <linux/nfs_fs.h>
54 #include <linux/acpi.h>
55 #include <linux/reboot.h>
56 #include <linux/ftrace.h>
57 #include <linux/perf_event.h>
58 #include <linux/kprobes.h>
59 #include <linux/pipe_fs_i.h>
60 #include <linux/oom.h>
61 #include <linux/kmod.h>
62 #include <linux/capability.h>
63 #include <linux/binfmts.h>
64 #include <linux/sched/sysctl.h>
65 #include <linux/sched/coredump.h>
66 #include <linux/kexec.h>
67 #include <linux/bpf.h>
68 #include <linux/mount.h>
69 #include <linux/pipe_fs_i.h>
71 #include <linux/uaccess.h>
72 #include <asm/processor.h>
76 #include <asm/stacktrace.h>
80 #include <asm/setup.h>
82 #ifdef CONFIG_BSD_PROCESS_ACCT
83 #include <linux/acct.h>
85 #ifdef CONFIG_RT_MUTEXES
86 #include <linux/rtmutex.h>
88 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
89 #include <linux/lockdep.h>
91 #ifdef CONFIG_CHR_DEV_SG
94 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
95 #include <linux/stackleak.h>
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;
111 extern int pid_max_min, pid_max_max;
112 extern int percpu_pagelist_fraction;
113 extern int latencytop_enabled;
114 extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
116 extern int sysctl_nr_trim_pages;
119 /* Constants used for minimum and maximum */
120 #ifdef CONFIG_LOCKUP_DETECTOR
121 static int sixty = 60;
124 static int __maybe_unused neg_one = -1;
127 static int __maybe_unused one = 1;
128 static int __maybe_unused two = 2;
129 static int __maybe_unused four = 4;
130 static unsigned long one_ul = 1;
131 static int one_hundred = 100;
132 static int one_thousand = 1000;
134 static int ten_thousand = 10000;
136 #ifdef CONFIG_PERF_EVENTS
137 static int six_hundred_forty_kb = 640 * 1024;
140 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
141 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
143 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
144 static int maxolduid = 65535;
145 static int minolduid;
147 static int ngroups_max = NGROUPS_MAX;
148 static const int cap_last_cap = CAP_LAST_CAP;
151 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
152 * and hung_task_check_interval_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);
226 static int proc_dopipe_max_size(struct ctl_table *table, int write,
227 void __user *buffer, size_t *lenp, loff_t *ppos);
229 #ifdef CONFIG_MAGIC_SYSRQ
230 /* Note: sysrq code uses its own private copy */
231 static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
233 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
234 void __user *buffer, size_t *lenp,
239 error = proc_dointvec(table, write, buffer, lenp, ppos);
244 sysrq_toggle_support(__sysrq_enabled);
251 static struct ctl_table kern_table[];
252 static struct ctl_table vm_table[];
253 static struct ctl_table fs_table[];
254 static struct ctl_table debug_table[];
255 static struct ctl_table dev_table[];
256 extern struct ctl_table random_table[];
258 extern struct ctl_table epoll_table[];
261 #ifdef CONFIG_FW_LOADER_USER_HELPER
262 extern struct ctl_table firmware_config_table[];
265 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
266 int sysctl_legacy_va_layout;
269 /* The default sysctl tables: */
271 static struct ctl_table sysctl_base_table[] = {
273 .procname = "kernel",
290 .child = debug_table,
300 #ifdef CONFIG_SCHED_DEBUG
301 static int min_sched_granularity_ns = 100000; /* 100 usecs */
302 static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
303 static int min_wakeup_granularity_ns; /* 0 usecs */
304 static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
306 static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
307 static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
308 #endif /* CONFIG_SMP */
309 #endif /* CONFIG_SCHED_DEBUG */
311 #ifdef CONFIG_COMPACTION
312 static int min_extfrag_threshold;
313 static int max_extfrag_threshold = 1000;
316 static struct ctl_table kern_table[] = {
318 .procname = "sched_child_runs_first",
319 .data = &sysctl_sched_child_runs_first,
320 .maxlen = sizeof(unsigned int),
322 .proc_handler = proc_dointvec,
324 #ifdef CONFIG_SCHED_DEBUG
326 .procname = "sched_min_granularity_ns",
327 .data = &sysctl_sched_min_granularity,
328 .maxlen = sizeof(unsigned int),
330 .proc_handler = sched_proc_update_handler,
331 .extra1 = &min_sched_granularity_ns,
332 .extra2 = &max_sched_granularity_ns,
335 .procname = "sched_latency_ns",
336 .data = &sysctl_sched_latency,
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_wakeup_granularity_ns",
345 .data = &sysctl_sched_wakeup_granularity,
346 .maxlen = sizeof(unsigned int),
348 .proc_handler = sched_proc_update_handler,
349 .extra1 = &min_wakeup_granularity_ns,
350 .extra2 = &max_wakeup_granularity_ns,
354 .procname = "sched_tunable_scaling",
355 .data = &sysctl_sched_tunable_scaling,
356 .maxlen = sizeof(enum sched_tunable_scaling),
358 .proc_handler = sched_proc_update_handler,
359 .extra1 = &min_sched_tunable_scaling,
360 .extra2 = &max_sched_tunable_scaling,
363 .procname = "sched_migration_cost_ns",
364 .data = &sysctl_sched_migration_cost,
365 .maxlen = sizeof(unsigned int),
367 .proc_handler = proc_dointvec,
370 .procname = "sched_nr_migrate",
371 .data = &sysctl_sched_nr_migrate,
372 .maxlen = sizeof(unsigned int),
374 .proc_handler = proc_dointvec,
376 #ifdef CONFIG_SCHEDSTATS
378 .procname = "sched_schedstats",
380 .maxlen = sizeof(unsigned int),
382 .proc_handler = sysctl_schedstats,
386 #endif /* CONFIG_SCHEDSTATS */
387 #endif /* CONFIG_SMP */
388 #ifdef CONFIG_NUMA_BALANCING
390 .procname = "numa_balancing_scan_delay_ms",
391 .data = &sysctl_numa_balancing_scan_delay,
392 .maxlen = sizeof(unsigned int),
394 .proc_handler = proc_dointvec,
397 .procname = "numa_balancing_scan_period_min_ms",
398 .data = &sysctl_numa_balancing_scan_period_min,
399 .maxlen = sizeof(unsigned int),
401 .proc_handler = proc_dointvec,
404 .procname = "numa_balancing_scan_period_max_ms",
405 .data = &sysctl_numa_balancing_scan_period_max,
406 .maxlen = sizeof(unsigned int),
408 .proc_handler = proc_dointvec,
411 .procname = "numa_balancing_scan_size_mb",
412 .data = &sysctl_numa_balancing_scan_size,
413 .maxlen = sizeof(unsigned int),
415 .proc_handler = proc_dointvec_minmax,
419 .procname = "numa_balancing",
420 .data = NULL, /* filled in by handler */
421 .maxlen = sizeof(unsigned int),
423 .proc_handler = sysctl_numa_balancing,
427 #endif /* CONFIG_NUMA_BALANCING */
428 #endif /* CONFIG_SCHED_DEBUG */
430 .procname = "sched_rt_period_us",
431 .data = &sysctl_sched_rt_period,
432 .maxlen = sizeof(unsigned int),
434 .proc_handler = sched_rt_handler,
437 .procname = "sched_rt_runtime_us",
438 .data = &sysctl_sched_rt_runtime,
439 .maxlen = sizeof(int),
441 .proc_handler = sched_rt_handler,
444 .procname = "sched_rr_timeslice_ms",
445 .data = &sysctl_sched_rr_timeslice,
446 .maxlen = sizeof(int),
448 .proc_handler = sched_rr_handler,
450 #ifdef CONFIG_SCHED_AUTOGROUP
452 .procname = "sched_autogroup_enabled",
453 .data = &sysctl_sched_autogroup_enabled,
454 .maxlen = sizeof(unsigned int),
456 .proc_handler = proc_dointvec_minmax,
461 #ifdef CONFIG_CFS_BANDWIDTH
463 .procname = "sched_cfs_bandwidth_slice_us",
464 .data = &sysctl_sched_cfs_bandwidth_slice,
465 .maxlen = sizeof(unsigned int),
467 .proc_handler = proc_dointvec_minmax,
471 #ifdef CONFIG_PROVE_LOCKING
473 .procname = "prove_locking",
474 .data = &prove_locking,
475 .maxlen = sizeof(int),
477 .proc_handler = proc_dointvec,
480 #ifdef CONFIG_LOCK_STAT
482 .procname = "lock_stat",
484 .maxlen = sizeof(int),
486 .proc_handler = proc_dointvec,
491 .data = &panic_timeout,
492 .maxlen = sizeof(int),
494 .proc_handler = proc_dointvec,
496 #ifdef CONFIG_COREDUMP
498 .procname = "core_uses_pid",
499 .data = &core_uses_pid,
500 .maxlen = sizeof(int),
502 .proc_handler = proc_dointvec,
505 .procname = "core_pattern",
506 .data = core_pattern,
507 .maxlen = CORENAME_MAX_SIZE,
509 .proc_handler = proc_dostring_coredump,
512 .procname = "core_pipe_limit",
513 .data = &core_pipe_limit,
514 .maxlen = sizeof(unsigned int),
516 .proc_handler = proc_dointvec,
519 #ifdef CONFIG_PROC_SYSCTL
521 .procname = "tainted",
522 .maxlen = sizeof(long),
524 .proc_handler = proc_taint,
527 .procname = "sysctl_writes_strict",
528 .data = &sysctl_writes_strict,
529 .maxlen = sizeof(int),
531 .proc_handler = proc_dointvec_minmax,
536 #ifdef CONFIG_LATENCYTOP
538 .procname = "latencytop",
539 .data = &latencytop_enabled,
540 .maxlen = sizeof(int),
542 .proc_handler = sysctl_latencytop,
545 #ifdef CONFIG_BLK_DEV_INITRD
547 .procname = "real-root-dev",
548 .data = &real_root_dev,
549 .maxlen = sizeof(int),
551 .proc_handler = proc_dointvec,
555 .procname = "print-fatal-signals",
556 .data = &print_fatal_signals,
557 .maxlen = sizeof(int),
559 .proc_handler = proc_dointvec,
563 .procname = "reboot-cmd",
564 .data = reboot_command,
567 .proc_handler = proc_dostring,
570 .procname = "stop-a",
571 .data = &stop_a_enabled,
572 .maxlen = sizeof (int),
574 .proc_handler = proc_dointvec,
577 .procname = "scons-poweroff",
578 .data = &scons_pwroff,
579 .maxlen = sizeof (int),
581 .proc_handler = proc_dointvec,
584 #ifdef CONFIG_SPARC64
586 .procname = "tsb-ratio",
587 .data = &sysctl_tsb_ratio,
588 .maxlen = sizeof (int),
590 .proc_handler = proc_dointvec,
595 .procname = "soft-power",
596 .data = &pwrsw_enabled,
597 .maxlen = sizeof (int),
599 .proc_handler = proc_dointvec,
602 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
604 .procname = "unaligned-trap",
605 .data = &unaligned_enabled,
606 .maxlen = sizeof (int),
608 .proc_handler = proc_dointvec,
612 .procname = "ctrl-alt-del",
614 .maxlen = sizeof(int),
616 .proc_handler = proc_dointvec,
618 #ifdef CONFIG_FUNCTION_TRACER
620 .procname = "ftrace_enabled",
621 .data = &ftrace_enabled,
622 .maxlen = sizeof(int),
624 .proc_handler = ftrace_enable_sysctl,
627 #ifdef CONFIG_STACK_TRACER
629 .procname = "stack_tracer_enabled",
630 .data = &stack_tracer_enabled,
631 .maxlen = sizeof(int),
633 .proc_handler = stack_trace_sysctl,
636 #ifdef CONFIG_TRACING
638 .procname = "ftrace_dump_on_oops",
639 .data = &ftrace_dump_on_oops,
640 .maxlen = sizeof(int),
642 .proc_handler = proc_dointvec,
645 .procname = "traceoff_on_warning",
646 .data = &__disable_trace_on_warning,
647 .maxlen = sizeof(__disable_trace_on_warning),
649 .proc_handler = proc_dointvec,
652 .procname = "tracepoint_printk",
653 .data = &tracepoint_printk,
654 .maxlen = sizeof(tracepoint_printk),
656 .proc_handler = tracepoint_printk_sysctl,
659 #ifdef CONFIG_KEXEC_CORE
661 .procname = "kexec_load_disabled",
662 .data = &kexec_load_disabled,
663 .maxlen = sizeof(int),
665 /* only handle a transition from default "0" to "1" */
666 .proc_handler = proc_dointvec_minmax,
671 #ifdef CONFIG_MODULES
673 .procname = "modprobe",
674 .data = &modprobe_path,
675 .maxlen = KMOD_PATH_LEN,
677 .proc_handler = proc_dostring,
680 .procname = "modules_disabled",
681 .data = &modules_disabled,
682 .maxlen = sizeof(int),
684 /* only handle a transition from default "0" to "1" */
685 .proc_handler = proc_dointvec_minmax,
690 #ifdef CONFIG_UEVENT_HELPER
692 .procname = "hotplug",
693 .data = &uevent_helper,
694 .maxlen = UEVENT_HELPER_PATH_LEN,
696 .proc_handler = proc_dostring,
699 #ifdef CONFIG_CHR_DEV_SG
701 .procname = "sg-big-buff",
702 .data = &sg_big_buff,
703 .maxlen = sizeof (int),
705 .proc_handler = proc_dointvec,
708 #ifdef CONFIG_BSD_PROCESS_ACCT
712 .maxlen = 3*sizeof(int),
714 .proc_handler = proc_dointvec,
717 #ifdef CONFIG_MAGIC_SYSRQ
720 .data = &__sysrq_enabled,
721 .maxlen = sizeof (int),
723 .proc_handler = sysrq_sysctl_handler,
726 #ifdef CONFIG_PROC_SYSCTL
728 .procname = "cad_pid",
730 .maxlen = sizeof (int),
732 .proc_handler = proc_do_cad_pid,
736 .procname = "threads-max",
738 .maxlen = sizeof(int),
740 .proc_handler = sysctl_max_threads,
743 .procname = "random",
745 .child = random_table,
748 .procname = "usermodehelper",
750 .child = usermodehelper_table,
752 #ifdef CONFIG_FW_LOADER_USER_HELPER
754 .procname = "firmware_config",
756 .child = firmware_config_table,
760 .procname = "overflowuid",
761 .data = &overflowuid,
762 .maxlen = sizeof(int),
764 .proc_handler = proc_dointvec_minmax,
765 .extra1 = &minolduid,
766 .extra2 = &maxolduid,
769 .procname = "overflowgid",
770 .data = &overflowgid,
771 .maxlen = sizeof(int),
773 .proc_handler = proc_dointvec_minmax,
774 .extra1 = &minolduid,
775 .extra2 = &maxolduid,
778 #ifdef CONFIG_MATHEMU
780 .procname = "ieee_emulation_warnings",
781 .data = &sysctl_ieee_emulation_warnings,
782 .maxlen = sizeof(int),
784 .proc_handler = proc_dointvec,
788 .procname = "userprocess_debug",
789 .data = &show_unhandled_signals,
790 .maxlen = sizeof(int),
792 .proc_handler = proc_dointvec,
796 .procname = "pid_max",
798 .maxlen = sizeof (int),
800 .proc_handler = proc_dointvec_minmax,
801 .extra1 = &pid_max_min,
802 .extra2 = &pid_max_max,
805 .procname = "panic_on_oops",
806 .data = &panic_on_oops,
807 .maxlen = sizeof(int),
809 .proc_handler = proc_dointvec,
811 #if defined CONFIG_PRINTK
813 .procname = "printk",
814 .data = &console_loglevel,
815 .maxlen = 4*sizeof(int),
817 .proc_handler = proc_dointvec,
820 .procname = "printk_ratelimit",
821 .data = &printk_ratelimit_state.interval,
822 .maxlen = sizeof(int),
824 .proc_handler = proc_dointvec_jiffies,
827 .procname = "printk_ratelimit_burst",
828 .data = &printk_ratelimit_state.burst,
829 .maxlen = sizeof(int),
831 .proc_handler = proc_dointvec,
834 .procname = "printk_delay",
835 .data = &printk_delay_msec,
836 .maxlen = sizeof(int),
838 .proc_handler = proc_dointvec_minmax,
840 .extra2 = &ten_thousand,
843 .procname = "printk_devkmsg",
844 .data = devkmsg_log_str,
845 .maxlen = DEVKMSG_STR_MAX_SIZE,
847 .proc_handler = devkmsg_sysctl_set_loglvl,
850 .procname = "dmesg_restrict",
851 .data = &dmesg_restrict,
852 .maxlen = sizeof(int),
854 .proc_handler = proc_dointvec_minmax_sysadmin,
859 .procname = "kptr_restrict",
860 .data = &kptr_restrict,
861 .maxlen = sizeof(int),
863 .proc_handler = proc_dointvec_minmax_sysadmin,
869 .procname = "ngroups_max",
870 .data = &ngroups_max,
871 .maxlen = sizeof (int),
873 .proc_handler = proc_dointvec,
876 .procname = "cap_last_cap",
877 .data = (void *)&cap_last_cap,
878 .maxlen = sizeof(int),
880 .proc_handler = proc_dointvec,
882 #if defined(CONFIG_LOCKUP_DETECTOR)
884 .procname = "watchdog",
885 .data = &watchdog_user_enabled,
886 .maxlen = sizeof(int),
888 .proc_handler = proc_watchdog,
893 .procname = "watchdog_thresh",
894 .data = &watchdog_thresh,
895 .maxlen = sizeof(int),
897 .proc_handler = proc_watchdog_thresh,
902 .procname = "nmi_watchdog",
903 .data = &nmi_watchdog_user_enabled,
904 .maxlen = sizeof(int),
905 .mode = NMI_WATCHDOG_SYSCTL_PERM,
906 .proc_handler = proc_nmi_watchdog,
911 .procname = "watchdog_cpumask",
912 .data = &watchdog_cpumask_bits,
915 .proc_handler = proc_watchdog_cpumask,
917 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
919 .procname = "soft_watchdog",
920 .data = &soft_watchdog_user_enabled,
921 .maxlen = sizeof(int),
923 .proc_handler = proc_soft_watchdog,
928 .procname = "softlockup_panic",
929 .data = &softlockup_panic,
930 .maxlen = sizeof(int),
932 .proc_handler = proc_dointvec_minmax,
938 .procname = "softlockup_all_cpu_backtrace",
939 .data = &sysctl_softlockup_all_cpu_backtrace,
940 .maxlen = sizeof(int),
942 .proc_handler = proc_dointvec_minmax,
946 #endif /* CONFIG_SMP */
948 #ifdef CONFIG_HARDLOCKUP_DETECTOR
950 .procname = "hardlockup_panic",
951 .data = &hardlockup_panic,
952 .maxlen = sizeof(int),
954 .proc_handler = proc_dointvec_minmax,
960 .procname = "hardlockup_all_cpu_backtrace",
961 .data = &sysctl_hardlockup_all_cpu_backtrace,
962 .maxlen = sizeof(int),
964 .proc_handler = proc_dointvec_minmax,
968 #endif /* CONFIG_SMP */
972 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
974 .procname = "unknown_nmi_panic",
975 .data = &unknown_nmi_panic,
976 .maxlen = sizeof (int),
978 .proc_handler = proc_dointvec,
981 #if defined(CONFIG_X86)
983 .procname = "panic_on_unrecovered_nmi",
984 .data = &panic_on_unrecovered_nmi,
985 .maxlen = sizeof(int),
987 .proc_handler = proc_dointvec,
990 .procname = "panic_on_io_nmi",
991 .data = &panic_on_io_nmi,
992 .maxlen = sizeof(int),
994 .proc_handler = proc_dointvec,
996 #ifdef CONFIG_DEBUG_STACKOVERFLOW
998 .procname = "panic_on_stackoverflow",
999 .data = &sysctl_panic_on_stackoverflow,
1000 .maxlen = sizeof(int),
1002 .proc_handler = proc_dointvec,
1006 .procname = "bootloader_type",
1007 .data = &bootloader_type,
1008 .maxlen = sizeof (int),
1010 .proc_handler = proc_dointvec,
1013 .procname = "bootloader_version",
1014 .data = &bootloader_version,
1015 .maxlen = sizeof (int),
1017 .proc_handler = proc_dointvec,
1020 .procname = "io_delay_type",
1021 .data = &io_delay_type,
1022 .maxlen = sizeof(int),
1024 .proc_handler = proc_dointvec,
1027 #if defined(CONFIG_MMU)
1029 .procname = "randomize_va_space",
1030 .data = &randomize_va_space,
1031 .maxlen = sizeof(int),
1033 .proc_handler = proc_dointvec,
1036 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1038 .procname = "spin_retry",
1039 .data = &spin_retry,
1040 .maxlen = sizeof (int),
1042 .proc_handler = proc_dointvec,
1045 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1047 .procname = "acpi_video_flags",
1048 .data = &acpi_realmode_flags,
1049 .maxlen = sizeof (unsigned long),
1051 .proc_handler = proc_doulongvec_minmax,
1054 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1056 .procname = "ignore-unaligned-usertrap",
1057 .data = &no_unaligned_warning,
1058 .maxlen = sizeof (int),
1060 .proc_handler = proc_dointvec,
1065 .procname = "unaligned-dump-stack",
1066 .data = &unaligned_dump_stack,
1067 .maxlen = sizeof (int),
1069 .proc_handler = proc_dointvec,
1072 #ifdef CONFIG_DETECT_HUNG_TASK
1074 .procname = "hung_task_panic",
1075 .data = &sysctl_hung_task_panic,
1076 .maxlen = sizeof(int),
1078 .proc_handler = proc_dointvec_minmax,
1083 .procname = "hung_task_check_count",
1084 .data = &sysctl_hung_task_check_count,
1085 .maxlen = sizeof(int),
1087 .proc_handler = proc_dointvec_minmax,
1091 .procname = "hung_task_timeout_secs",
1092 .data = &sysctl_hung_task_timeout_secs,
1093 .maxlen = sizeof(unsigned long),
1095 .proc_handler = proc_dohung_task_timeout_secs,
1096 .extra2 = &hung_task_timeout_max,
1099 .procname = "hung_task_check_interval_secs",
1100 .data = &sysctl_hung_task_check_interval_secs,
1101 .maxlen = sizeof(unsigned long),
1103 .proc_handler = proc_dohung_task_timeout_secs,
1104 .extra2 = &hung_task_timeout_max,
1107 .procname = "hung_task_warnings",
1108 .data = &sysctl_hung_task_warnings,
1109 .maxlen = sizeof(int),
1111 .proc_handler = proc_dointvec_minmax,
1115 #ifdef CONFIG_RT_MUTEXES
1117 .procname = "max_lock_depth",
1118 .data = &max_lock_depth,
1119 .maxlen = sizeof(int),
1121 .proc_handler = proc_dointvec,
1125 .procname = "poweroff_cmd",
1126 .data = &poweroff_cmd,
1127 .maxlen = POWEROFF_CMD_PATH_LEN,
1129 .proc_handler = proc_dostring,
1135 .child = key_sysctls,
1138 #ifdef CONFIG_PERF_EVENTS
1140 * User-space scripts rely on the existence of this file
1141 * as a feature check for perf_events being enabled.
1143 * So it's an ABI, do not remove!
1146 .procname = "perf_event_paranoid",
1147 .data = &sysctl_perf_event_paranoid,
1148 .maxlen = sizeof(sysctl_perf_event_paranoid),
1150 .proc_handler = proc_dointvec,
1153 .procname = "perf_event_mlock_kb",
1154 .data = &sysctl_perf_event_mlock,
1155 .maxlen = sizeof(sysctl_perf_event_mlock),
1157 .proc_handler = proc_dointvec,
1160 .procname = "perf_event_max_sample_rate",
1161 .data = &sysctl_perf_event_sample_rate,
1162 .maxlen = sizeof(sysctl_perf_event_sample_rate),
1164 .proc_handler = perf_proc_update_handler,
1168 .procname = "perf_cpu_time_max_percent",
1169 .data = &sysctl_perf_cpu_time_max_percent,
1170 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1172 .proc_handler = perf_cpu_time_max_percent_handler,
1174 .extra2 = &one_hundred,
1177 .procname = "perf_event_max_stack",
1178 .data = &sysctl_perf_event_max_stack,
1179 .maxlen = sizeof(sysctl_perf_event_max_stack),
1181 .proc_handler = perf_event_max_stack_handler,
1183 .extra2 = &six_hundred_forty_kb,
1186 .procname = "perf_event_max_contexts_per_stack",
1187 .data = &sysctl_perf_event_max_contexts_per_stack,
1188 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1190 .proc_handler = perf_event_max_stack_handler,
1192 .extra2 = &one_thousand,
1196 .procname = "panic_on_warn",
1197 .data = &panic_on_warn,
1198 .maxlen = sizeof(int),
1200 .proc_handler = proc_dointvec_minmax,
1204 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1206 .procname = "timer_migration",
1207 .data = &sysctl_timer_migration,
1208 .maxlen = sizeof(unsigned int),
1210 .proc_handler = timer_migration_handler,
1215 #ifdef CONFIG_BPF_SYSCALL
1217 .procname = "unprivileged_bpf_disabled",
1218 .data = &sysctl_unprivileged_bpf_disabled,
1219 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1221 /* only handle a transition from default "0" to "1" */
1222 .proc_handler = proc_dointvec_minmax,
1227 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1229 .procname = "panic_on_rcu_stall",
1230 .data = &sysctl_panic_on_rcu_stall,
1231 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1233 .proc_handler = proc_dointvec_minmax,
1238 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
1240 .procname = "stack_erasing",
1242 .maxlen = sizeof(int),
1244 .proc_handler = stack_erasing_sysctl,
1252 static struct ctl_table vm_table[] = {
1254 .procname = "overcommit_memory",
1255 .data = &sysctl_overcommit_memory,
1256 .maxlen = sizeof(sysctl_overcommit_memory),
1258 .proc_handler = proc_dointvec_minmax,
1263 .procname = "panic_on_oom",
1264 .data = &sysctl_panic_on_oom,
1265 .maxlen = sizeof(sysctl_panic_on_oom),
1267 .proc_handler = proc_dointvec_minmax,
1272 .procname = "oom_kill_allocating_task",
1273 .data = &sysctl_oom_kill_allocating_task,
1274 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1276 .proc_handler = proc_dointvec,
1279 .procname = "oom_dump_tasks",
1280 .data = &sysctl_oom_dump_tasks,
1281 .maxlen = sizeof(sysctl_oom_dump_tasks),
1283 .proc_handler = proc_dointvec,
1286 .procname = "overcommit_ratio",
1287 .data = &sysctl_overcommit_ratio,
1288 .maxlen = sizeof(sysctl_overcommit_ratio),
1290 .proc_handler = overcommit_ratio_handler,
1293 .procname = "overcommit_kbytes",
1294 .data = &sysctl_overcommit_kbytes,
1295 .maxlen = sizeof(sysctl_overcommit_kbytes),
1297 .proc_handler = overcommit_kbytes_handler,
1300 .procname = "page-cluster",
1301 .data = &page_cluster,
1302 .maxlen = sizeof(int),
1304 .proc_handler = proc_dointvec_minmax,
1308 .procname = "dirty_background_ratio",
1309 .data = &dirty_background_ratio,
1310 .maxlen = sizeof(dirty_background_ratio),
1312 .proc_handler = dirty_background_ratio_handler,
1314 .extra2 = &one_hundred,
1317 .procname = "dirty_background_bytes",
1318 .data = &dirty_background_bytes,
1319 .maxlen = sizeof(dirty_background_bytes),
1321 .proc_handler = dirty_background_bytes_handler,
1325 .procname = "dirty_ratio",
1326 .data = &vm_dirty_ratio,
1327 .maxlen = sizeof(vm_dirty_ratio),
1329 .proc_handler = dirty_ratio_handler,
1331 .extra2 = &one_hundred,
1334 .procname = "dirty_bytes",
1335 .data = &vm_dirty_bytes,
1336 .maxlen = sizeof(vm_dirty_bytes),
1338 .proc_handler = dirty_bytes_handler,
1339 .extra1 = &dirty_bytes_min,
1342 .procname = "dirty_writeback_centisecs",
1343 .data = &dirty_writeback_interval,
1344 .maxlen = sizeof(dirty_writeback_interval),
1346 .proc_handler = dirty_writeback_centisecs_handler,
1349 .procname = "dirty_expire_centisecs",
1350 .data = &dirty_expire_interval,
1351 .maxlen = sizeof(dirty_expire_interval),
1353 .proc_handler = proc_dointvec_minmax,
1357 .procname = "dirtytime_expire_seconds",
1358 .data = &dirtytime_expire_interval,
1359 .maxlen = sizeof(dirtytime_expire_interval),
1361 .proc_handler = dirtytime_interval_handler,
1365 .procname = "swappiness",
1366 .data = &vm_swappiness,
1367 .maxlen = sizeof(vm_swappiness),
1369 .proc_handler = proc_dointvec_minmax,
1371 .extra2 = &one_hundred,
1373 #ifdef CONFIG_HUGETLB_PAGE
1375 .procname = "nr_hugepages",
1377 .maxlen = sizeof(unsigned long),
1379 .proc_handler = hugetlb_sysctl_handler,
1383 .procname = "nr_hugepages_mempolicy",
1385 .maxlen = sizeof(unsigned long),
1387 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1390 .procname = "numa_stat",
1391 .data = &sysctl_vm_numa_stat,
1392 .maxlen = sizeof(int),
1394 .proc_handler = sysctl_vm_numa_stat_handler,
1400 .procname = "hugetlb_shm_group",
1401 .data = &sysctl_hugetlb_shm_group,
1402 .maxlen = sizeof(gid_t),
1404 .proc_handler = proc_dointvec,
1407 .procname = "nr_overcommit_hugepages",
1409 .maxlen = sizeof(unsigned long),
1411 .proc_handler = hugetlb_overcommit_handler,
1415 .procname = "lowmem_reserve_ratio",
1416 .data = &sysctl_lowmem_reserve_ratio,
1417 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1419 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
1422 .procname = "drop_caches",
1423 .data = &sysctl_drop_caches,
1424 .maxlen = sizeof(int),
1426 .proc_handler = drop_caches_sysctl_handler,
1430 #ifdef CONFIG_COMPACTION
1432 .procname = "compact_memory",
1433 .data = &sysctl_compact_memory,
1434 .maxlen = sizeof(int),
1436 .proc_handler = sysctl_compaction_handler,
1439 .procname = "extfrag_threshold",
1440 .data = &sysctl_extfrag_threshold,
1441 .maxlen = sizeof(int),
1443 .proc_handler = sysctl_extfrag_handler,
1444 .extra1 = &min_extfrag_threshold,
1445 .extra2 = &max_extfrag_threshold,
1448 .procname = "compact_unevictable_allowed",
1449 .data = &sysctl_compact_unevictable_allowed,
1450 .maxlen = sizeof(int),
1452 .proc_handler = proc_dointvec,
1457 #endif /* CONFIG_COMPACTION */
1459 .procname = "min_free_kbytes",
1460 .data = &min_free_kbytes,
1461 .maxlen = sizeof(min_free_kbytes),
1463 .proc_handler = min_free_kbytes_sysctl_handler,
1467 .procname = "watermark_scale_factor",
1468 .data = &watermark_scale_factor,
1469 .maxlen = sizeof(watermark_scale_factor),
1471 .proc_handler = watermark_scale_factor_sysctl_handler,
1473 .extra2 = &one_thousand,
1476 .procname = "percpu_pagelist_fraction",
1477 .data = &percpu_pagelist_fraction,
1478 .maxlen = sizeof(percpu_pagelist_fraction),
1480 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
1485 .procname = "max_map_count",
1486 .data = &sysctl_max_map_count,
1487 .maxlen = sizeof(sysctl_max_map_count),
1489 .proc_handler = proc_dointvec_minmax,
1494 .procname = "nr_trim_pages",
1495 .data = &sysctl_nr_trim_pages,
1496 .maxlen = sizeof(sysctl_nr_trim_pages),
1498 .proc_handler = proc_dointvec_minmax,
1503 .procname = "laptop_mode",
1504 .data = &laptop_mode,
1505 .maxlen = sizeof(laptop_mode),
1507 .proc_handler = proc_dointvec_jiffies,
1510 .procname = "block_dump",
1511 .data = &block_dump,
1512 .maxlen = sizeof(block_dump),
1514 .proc_handler = proc_dointvec,
1518 .procname = "vfs_cache_pressure",
1519 .data = &sysctl_vfs_cache_pressure,
1520 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1522 .proc_handler = proc_dointvec,
1525 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1527 .procname = "legacy_va_layout",
1528 .data = &sysctl_legacy_va_layout,
1529 .maxlen = sizeof(sysctl_legacy_va_layout),
1531 .proc_handler = proc_dointvec,
1537 .procname = "zone_reclaim_mode",
1538 .data = &node_reclaim_mode,
1539 .maxlen = sizeof(node_reclaim_mode),
1541 .proc_handler = proc_dointvec,
1545 .procname = "min_unmapped_ratio",
1546 .data = &sysctl_min_unmapped_ratio,
1547 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1549 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
1551 .extra2 = &one_hundred,
1554 .procname = "min_slab_ratio",
1555 .data = &sysctl_min_slab_ratio,
1556 .maxlen = sizeof(sysctl_min_slab_ratio),
1558 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
1560 .extra2 = &one_hundred,
1565 .procname = "stat_interval",
1566 .data = &sysctl_stat_interval,
1567 .maxlen = sizeof(sysctl_stat_interval),
1569 .proc_handler = proc_dointvec_jiffies,
1572 .procname = "stat_refresh",
1576 .proc_handler = vmstat_refresh,
1581 .procname = "mmap_min_addr",
1582 .data = &dac_mmap_min_addr,
1583 .maxlen = sizeof(unsigned long),
1585 .proc_handler = mmap_min_addr_handler,
1590 .procname = "numa_zonelist_order",
1591 .data = &numa_zonelist_order,
1592 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1594 .proc_handler = numa_zonelist_order_handler,
1597 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1598 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1600 .procname = "vdso_enabled",
1601 #ifdef CONFIG_X86_32
1602 .data = &vdso32_enabled,
1603 .maxlen = sizeof(vdso32_enabled),
1605 .data = &vdso_enabled,
1606 .maxlen = sizeof(vdso_enabled),
1609 .proc_handler = proc_dointvec,
1613 #ifdef CONFIG_HIGHMEM
1615 .procname = "highmem_is_dirtyable",
1616 .data = &vm_highmem_is_dirtyable,
1617 .maxlen = sizeof(vm_highmem_is_dirtyable),
1619 .proc_handler = proc_dointvec_minmax,
1624 #ifdef CONFIG_MEMORY_FAILURE
1626 .procname = "memory_failure_early_kill",
1627 .data = &sysctl_memory_failure_early_kill,
1628 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1630 .proc_handler = proc_dointvec_minmax,
1635 .procname = "memory_failure_recovery",
1636 .data = &sysctl_memory_failure_recovery,
1637 .maxlen = sizeof(sysctl_memory_failure_recovery),
1639 .proc_handler = proc_dointvec_minmax,
1645 .procname = "user_reserve_kbytes",
1646 .data = &sysctl_user_reserve_kbytes,
1647 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1649 .proc_handler = proc_doulongvec_minmax,
1652 .procname = "admin_reserve_kbytes",
1653 .data = &sysctl_admin_reserve_kbytes,
1654 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1656 .proc_handler = proc_doulongvec_minmax,
1658 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1660 .procname = "mmap_rnd_bits",
1661 .data = &mmap_rnd_bits,
1662 .maxlen = sizeof(mmap_rnd_bits),
1664 .proc_handler = proc_dointvec_minmax,
1665 .extra1 = (void *)&mmap_rnd_bits_min,
1666 .extra2 = (void *)&mmap_rnd_bits_max,
1669 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1671 .procname = "mmap_rnd_compat_bits",
1672 .data = &mmap_rnd_compat_bits,
1673 .maxlen = sizeof(mmap_rnd_compat_bits),
1675 .proc_handler = proc_dointvec_minmax,
1676 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1677 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1683 static struct ctl_table fs_table[] = {
1685 .procname = "inode-nr",
1686 .data = &inodes_stat,
1687 .maxlen = 2*sizeof(long),
1689 .proc_handler = proc_nr_inodes,
1692 .procname = "inode-state",
1693 .data = &inodes_stat,
1694 .maxlen = 7*sizeof(long),
1696 .proc_handler = proc_nr_inodes,
1699 .procname = "file-nr",
1700 .data = &files_stat,
1701 .maxlen = sizeof(files_stat),
1703 .proc_handler = proc_nr_files,
1706 .procname = "file-max",
1707 .data = &files_stat.max_files,
1708 .maxlen = sizeof(files_stat.max_files),
1710 .proc_handler = proc_doulongvec_minmax,
1713 .procname = "nr_open",
1714 .data = &sysctl_nr_open,
1715 .maxlen = sizeof(unsigned int),
1717 .proc_handler = proc_dointvec_minmax,
1718 .extra1 = &sysctl_nr_open_min,
1719 .extra2 = &sysctl_nr_open_max,
1722 .procname = "dentry-state",
1723 .data = &dentry_stat,
1724 .maxlen = 6*sizeof(long),
1726 .proc_handler = proc_nr_dentry,
1729 .procname = "overflowuid",
1730 .data = &fs_overflowuid,
1731 .maxlen = sizeof(int),
1733 .proc_handler = proc_dointvec_minmax,
1734 .extra1 = &minolduid,
1735 .extra2 = &maxolduid,
1738 .procname = "overflowgid",
1739 .data = &fs_overflowgid,
1740 .maxlen = sizeof(int),
1742 .proc_handler = proc_dointvec_minmax,
1743 .extra1 = &minolduid,
1744 .extra2 = &maxolduid,
1746 #ifdef CONFIG_FILE_LOCKING
1748 .procname = "leases-enable",
1749 .data = &leases_enable,
1750 .maxlen = sizeof(int),
1752 .proc_handler = proc_dointvec,
1755 #ifdef CONFIG_DNOTIFY
1757 .procname = "dir-notify-enable",
1758 .data = &dir_notify_enable,
1759 .maxlen = sizeof(int),
1761 .proc_handler = proc_dointvec,
1765 #ifdef CONFIG_FILE_LOCKING
1767 .procname = "lease-break-time",
1768 .data = &lease_break_time,
1769 .maxlen = sizeof(int),
1771 .proc_handler = proc_dointvec,
1776 .procname = "aio-nr",
1778 .maxlen = sizeof(aio_nr),
1780 .proc_handler = proc_doulongvec_minmax,
1783 .procname = "aio-max-nr",
1784 .data = &aio_max_nr,
1785 .maxlen = sizeof(aio_max_nr),
1787 .proc_handler = proc_doulongvec_minmax,
1789 #endif /* CONFIG_AIO */
1790 #ifdef CONFIG_INOTIFY_USER
1792 .procname = "inotify",
1794 .child = inotify_table,
1799 .procname = "epoll",
1801 .child = epoll_table,
1806 .procname = "protected_symlinks",
1807 .data = &sysctl_protected_symlinks,
1808 .maxlen = sizeof(int),
1810 .proc_handler = proc_dointvec_minmax,
1815 .procname = "protected_hardlinks",
1816 .data = &sysctl_protected_hardlinks,
1817 .maxlen = sizeof(int),
1819 .proc_handler = proc_dointvec_minmax,
1824 .procname = "protected_fifos",
1825 .data = &sysctl_protected_fifos,
1826 .maxlen = sizeof(int),
1828 .proc_handler = proc_dointvec_minmax,
1833 .procname = "protected_regular",
1834 .data = &sysctl_protected_regular,
1835 .maxlen = sizeof(int),
1837 .proc_handler = proc_dointvec_minmax,
1842 .procname = "suid_dumpable",
1843 .data = &suid_dumpable,
1844 .maxlen = sizeof(int),
1846 .proc_handler = proc_dointvec_minmax_coredump,
1850 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1852 .procname = "binfmt_misc",
1854 .child = sysctl_mount_point,
1858 .procname = "pipe-max-size",
1859 .data = &pipe_max_size,
1860 .maxlen = sizeof(pipe_max_size),
1862 .proc_handler = proc_dopipe_max_size,
1865 .procname = "pipe-user-pages-hard",
1866 .data = &pipe_user_pages_hard,
1867 .maxlen = sizeof(pipe_user_pages_hard),
1869 .proc_handler = proc_doulongvec_minmax,
1872 .procname = "pipe-user-pages-soft",
1873 .data = &pipe_user_pages_soft,
1874 .maxlen = sizeof(pipe_user_pages_soft),
1876 .proc_handler = proc_doulongvec_minmax,
1879 .procname = "mount-max",
1880 .data = &sysctl_mount_max,
1881 .maxlen = sizeof(unsigned int),
1883 .proc_handler = proc_dointvec_minmax,
1889 static struct ctl_table debug_table[] = {
1890 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1892 .procname = "exception-trace",
1893 .data = &show_unhandled_signals,
1894 .maxlen = sizeof(int),
1896 .proc_handler = proc_dointvec
1899 #if defined(CONFIG_OPTPROBES)
1901 .procname = "kprobes-optimization",
1902 .data = &sysctl_kprobes_optimization,
1903 .maxlen = sizeof(int),
1905 .proc_handler = proc_kprobes_optimization_handler,
1913 static struct ctl_table dev_table[] = {
1917 int __init sysctl_init(void)
1919 struct ctl_table_header *hdr;
1921 hdr = register_sysctl_table(sysctl_base_table);
1922 kmemleak_not_leak(hdr);
1926 #endif /* CONFIG_SYSCTL */
1932 #ifdef CONFIG_PROC_SYSCTL
1934 static int _proc_do_string(char *data, int maxlen, int write,
1935 char __user *buffer,
1936 size_t *lenp, loff_t *ppos)
1942 if (!data || !maxlen || !*lenp) {
1948 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1949 /* Only continue writes not past the end of buffer. */
1951 if (len > maxlen - 1)
1958 /* Start writing from beginning of buffer. */
1964 while ((p - buffer) < *lenp && len < maxlen - 1) {
1965 if (get_user(c, p++))
1967 if (c == 0 || c == '\n')
1988 if (copy_to_user(buffer, data, len))
1991 if (put_user('\n', buffer + len))
2001 static void warn_sysctl_write(struct ctl_table *table)
2003 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2004 "This will not be supported in the future. To silence this\n"
2005 "warning, set kernel.sysctl_writes_strict = -1\n",
2006 current->comm, table->procname);
2010 * proc_first_pos_non_zero_ignore - check if first position is allowed
2011 * @ppos: file position
2012 * @table: the sysctl table
2014 * Returns true if the first position is non-zero and the sysctl_writes_strict
2015 * mode indicates this is not allowed for numeric input types. String proc
2016 * handlers can ignore the return value.
2018 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
2019 struct ctl_table *table)
2024 switch (sysctl_writes_strict) {
2025 case SYSCTL_WRITES_STRICT:
2027 case SYSCTL_WRITES_WARN:
2028 warn_sysctl_write(table);
2036 * proc_dostring - read a string sysctl
2037 * @table: the sysctl table
2038 * @write: %TRUE if this is a write to the sysctl file
2039 * @buffer: the user buffer
2040 * @lenp: the size of the user buffer
2041 * @ppos: file position
2043 * Reads/writes a string from/to the user buffer. If the kernel
2044 * buffer provided is not large enough to hold the string, the
2045 * string is truncated. The copied string is %NULL-terminated.
2046 * If the string is being read by the user process, it is copied
2047 * and a newline '\n' is added. It is truncated if the buffer is
2050 * Returns 0 on success.
2052 int proc_dostring(struct ctl_table *table, int write,
2053 void __user *buffer, size_t *lenp, loff_t *ppos)
2056 proc_first_pos_non_zero_ignore(ppos, table);
2058 return _proc_do_string((char *)(table->data), table->maxlen, write,
2059 (char __user *)buffer, lenp, ppos);
2062 static size_t proc_skip_spaces(char **buf)
2065 char *tmp = skip_spaces(*buf);
2071 static void proc_skip_char(char **buf, size_t *size, const char v)
2081 #define TMPBUFLEN 22
2083 * proc_get_long - reads an ASCII formatted integer from a user buffer
2085 * @buf: a kernel buffer
2086 * @size: size of the kernel buffer
2087 * @val: this is where the number will be stored
2088 * @neg: set to %TRUE if number is negative
2089 * @perm_tr: a vector which contains the allowed trailers
2090 * @perm_tr_len: size of the perm_tr vector
2091 * @tr: pointer to store the trailer character
2093 * In case of success %0 is returned and @buf and @size are updated with
2094 * the amount of bytes read. If @tr is non-NULL and a trailing
2095 * character exists (size is non-zero after returning from this
2096 * function), @tr is updated with the trailing character.
2098 static int proc_get_long(char **buf, size_t *size,
2099 unsigned long *val, bool *neg,
2100 const char *perm_tr, unsigned perm_tr_len, char *tr)
2103 char *p, tmp[TMPBUFLEN];
2109 if (len > TMPBUFLEN - 1)
2110 len = TMPBUFLEN - 1;
2112 memcpy(tmp, *buf, len);
2116 if (*p == '-' && *size > 1) {
2124 *val = simple_strtoul(p, &p, 0);
2128 /* We don't know if the next char is whitespace thus we may accept
2129 * invalid integers (e.g. 1234...a) or two integers instead of one
2130 * (e.g. 123...1). So lets not allow such large numbers. */
2131 if (len == TMPBUFLEN - 1)
2134 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2137 if (tr && (len < *size))
2147 * proc_put_long - converts an integer to a decimal ASCII formatted string
2149 * @buf: the user buffer
2150 * @size: the size of the user buffer
2151 * @val: the integer to be converted
2152 * @neg: sign of the number, %TRUE for negative
2154 * In case of success %0 is returned and @buf and @size are updated with
2155 * the amount of bytes written.
2157 static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2161 char tmp[TMPBUFLEN], *p = tmp;
2163 sprintf(p, "%s%lu", neg ? "-" : "", val);
2167 if (copy_to_user(*buf, tmp, len))
2175 static int proc_put_char(void __user **buf, size_t *size, char c)
2178 char __user **buffer = (char __user **)buf;
2179 if (put_user(c, *buffer))
2181 (*size)--, (*buffer)++;
2187 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
2189 int write, void *data)
2193 if (*lvalp > (unsigned long) INT_MAX + 1)
2197 if (*lvalp > (unsigned long) INT_MAX)
2205 *lvalp = -(unsigned long)val;
2208 *lvalp = (unsigned long)val;
2214 static int do_proc_douintvec_conv(unsigned long *lvalp,
2216 int write, void *data)
2219 if (*lvalp > UINT_MAX)
2223 unsigned int val = *valp;
2224 *lvalp = (unsigned long)val;
2229 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2231 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
2232 int write, void __user *buffer,
2233 size_t *lenp, loff_t *ppos,
2234 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2235 int write, void *data),
2238 int *i, vleft, first = 1, err = 0;
2240 char *kbuf = NULL, *p;
2242 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2247 i = (int *) tbl_data;
2248 vleft = table->maxlen / sizeof(*i);
2252 conv = do_proc_dointvec_conv;
2255 if (proc_first_pos_non_zero_ignore(ppos, table))
2258 if (left > PAGE_SIZE - 1)
2259 left = PAGE_SIZE - 1;
2260 p = kbuf = memdup_user_nul(buffer, left);
2262 return PTR_ERR(kbuf);
2265 for (; left && vleft--; i++, first=0) {
2270 left -= proc_skip_spaces(&p);
2274 err = proc_get_long(&p, &left, &lval, &neg,
2276 sizeof(proc_wspace_sep), NULL);
2279 if (conv(&neg, &lval, i, 1, data)) {
2284 if (conv(&neg, &lval, i, 0, data)) {
2289 err = proc_put_char(&buffer, &left, '\t');
2292 err = proc_put_long(&buffer, &left, lval, neg);
2298 if (!write && !first && left && !err)
2299 err = proc_put_char(&buffer, &left, '\n');
2300 if (write && !err && left)
2301 left -= proc_skip_spaces(&p);
2305 return err ? : -EINVAL;
2313 static int do_proc_dointvec(struct ctl_table *table, int write,
2314 void __user *buffer, size_t *lenp, loff_t *ppos,
2315 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2316 int write, void *data),
2319 return __do_proc_dointvec(table->data, table, write,
2320 buffer, lenp, ppos, conv, data);
2323 static int do_proc_douintvec_w(unsigned int *tbl_data,
2324 struct ctl_table *table,
2325 void __user *buffer,
2326 size_t *lenp, loff_t *ppos,
2327 int (*conv)(unsigned long *lvalp,
2329 int write, void *data),
2336 char *kbuf = NULL, *p;
2340 if (proc_first_pos_non_zero_ignore(ppos, table))
2343 if (left > PAGE_SIZE - 1)
2344 left = PAGE_SIZE - 1;
2346 p = kbuf = memdup_user_nul(buffer, left);
2350 left -= proc_skip_spaces(&p);
2356 err = proc_get_long(&p, &left, &lval, &neg,
2358 sizeof(proc_wspace_sep), NULL);
2364 if (conv(&lval, tbl_data, 1, data)) {
2370 left -= proc_skip_spaces(&p);
2379 /* This is in keeping with old __do_proc_dointvec() */
2385 static int do_proc_douintvec_r(unsigned int *tbl_data, void __user *buffer,
2386 size_t *lenp, loff_t *ppos,
2387 int (*conv)(unsigned long *lvalp,
2389 int write, void *data),
2398 if (conv(&lval, tbl_data, 0, data)) {
2403 err = proc_put_long(&buffer, &left, lval, false);
2407 err = proc_put_char(&buffer, &left, '\n');
2416 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
2417 int write, void __user *buffer,
2418 size_t *lenp, loff_t *ppos,
2419 int (*conv)(unsigned long *lvalp,
2421 int write, void *data),
2424 unsigned int *i, vleft;
2426 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2431 i = (unsigned int *) tbl_data;
2432 vleft = table->maxlen / sizeof(*i);
2435 * Arrays are not supported, keep this simple. *Do not* add
2444 conv = do_proc_douintvec_conv;
2447 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
2449 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
2452 static int do_proc_douintvec(struct ctl_table *table, int write,
2453 void __user *buffer, size_t *lenp, loff_t *ppos,
2454 int (*conv)(unsigned long *lvalp,
2456 int write, void *data),
2459 return __do_proc_douintvec(table->data, table, write,
2460 buffer, lenp, ppos, conv, data);
2464 * proc_dointvec - read a vector of integers
2465 * @table: the sysctl table
2466 * @write: %TRUE if this is a write to the sysctl file
2467 * @buffer: the user buffer
2468 * @lenp: the size of the user buffer
2469 * @ppos: file position
2471 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2472 * values from/to the user buffer, treated as an ASCII string.
2474 * Returns 0 on success.
2476 int proc_dointvec(struct ctl_table *table, int write,
2477 void __user *buffer, size_t *lenp, loff_t *ppos)
2479 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2483 * proc_douintvec - read a vector of unsigned integers
2484 * @table: the sysctl table
2485 * @write: %TRUE if this is a write to the sysctl file
2486 * @buffer: the user buffer
2487 * @lenp: the size of the user buffer
2488 * @ppos: file position
2490 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2491 * values from/to the user buffer, treated as an ASCII string.
2493 * Returns 0 on success.
2495 int proc_douintvec(struct ctl_table *table, int write,
2496 void __user *buffer, size_t *lenp, loff_t *ppos)
2498 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2499 do_proc_douintvec_conv, NULL);
2503 * Taint values can only be increased
2504 * This means we can safely use a temporary.
2506 static int proc_taint(struct ctl_table *table, int write,
2507 void __user *buffer, size_t *lenp, loff_t *ppos)
2510 unsigned long tmptaint = get_taint();
2513 if (write && !capable(CAP_SYS_ADMIN))
2518 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
2524 * Poor man's atomic or. Not worth adding a primitive
2525 * to everyone's atomic.h for this
2528 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2529 if ((tmptaint >> i) & 1)
2530 add_taint(i, LOCKDEP_STILL_OK);
2537 #ifdef CONFIG_PRINTK
2538 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
2539 void __user *buffer, size_t *lenp, loff_t *ppos)
2541 if (write && !capable(CAP_SYS_ADMIN))
2544 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2549 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
2550 * @min: pointer to minimum allowable value
2551 * @max: pointer to maximum allowable value
2553 * The do_proc_dointvec_minmax_conv_param structure provides the
2554 * minimum and maximum values for doing range checking for those sysctl
2555 * parameters that use the proc_dointvec_minmax() handler.
2557 struct do_proc_dointvec_minmax_conv_param {
2562 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2564 int write, void *data)
2566 struct do_proc_dointvec_minmax_conv_param *param = data;
2568 int val = *negp ? -*lvalp : *lvalp;
2569 if ((param->min && *param->min > val) ||
2570 (param->max && *param->max < val))
2577 *lvalp = -(unsigned long)val;
2580 *lvalp = (unsigned long)val;
2587 * proc_dointvec_minmax - read a vector of integers with min/max values
2588 * @table: the sysctl table
2589 * @write: %TRUE if this is a write to the sysctl file
2590 * @buffer: the user buffer
2591 * @lenp: the size of the user buffer
2592 * @ppos: file position
2594 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2595 * values from/to the user buffer, treated as an ASCII string.
2597 * This routine will ensure the values are within the range specified by
2598 * table->extra1 (min) and table->extra2 (max).
2600 * Returns 0 on success or -EINVAL on write when the range check fails.
2602 int proc_dointvec_minmax(struct ctl_table *table, int write,
2603 void __user *buffer, size_t *lenp, loff_t *ppos)
2605 struct do_proc_dointvec_minmax_conv_param param = {
2606 .min = (int *) table->extra1,
2607 .max = (int *) table->extra2,
2609 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2610 do_proc_dointvec_minmax_conv, ¶m);
2614 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
2615 * @min: pointer to minimum allowable value
2616 * @max: pointer to maximum allowable value
2618 * The do_proc_douintvec_minmax_conv_param structure provides the
2619 * minimum and maximum values for doing range checking for those sysctl
2620 * parameters that use the proc_douintvec_minmax() handler.
2622 struct do_proc_douintvec_minmax_conv_param {
2627 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
2629 int write, void *data)
2631 struct do_proc_douintvec_minmax_conv_param *param = data;
2634 unsigned int val = *lvalp;
2636 if (*lvalp > UINT_MAX)
2639 if ((param->min && *param->min > val) ||
2640 (param->max && *param->max < val))
2645 unsigned int val = *valp;
2646 *lvalp = (unsigned long) val;
2653 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2654 * @table: the sysctl table
2655 * @write: %TRUE if this is a write to the sysctl file
2656 * @buffer: the user buffer
2657 * @lenp: the size of the user buffer
2658 * @ppos: file position
2660 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2661 * values from/to the user buffer, treated as an ASCII string. Negative
2662 * strings are not allowed.
2664 * This routine will ensure the values are within the range specified by
2665 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2666 * check for UINT_MAX to avoid having to support wrap around uses from
2669 * Returns 0 on success or -ERANGE on write when the range check fails.
2671 int proc_douintvec_minmax(struct ctl_table *table, int write,
2672 void __user *buffer, size_t *lenp, loff_t *ppos)
2674 struct do_proc_douintvec_minmax_conv_param param = {
2675 .min = (unsigned int *) table->extra1,
2676 .max = (unsigned int *) table->extra2,
2678 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2679 do_proc_douintvec_minmax_conv, ¶m);
2682 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
2684 int write, void *data)
2689 val = round_pipe_size(*lvalp);
2695 unsigned int val = *valp;
2696 *lvalp = (unsigned long) val;
2702 static int proc_dopipe_max_size(struct ctl_table *table, int write,
2703 void __user *buffer, size_t *lenp, loff_t *ppos)
2705 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2706 do_proc_dopipe_max_size_conv, NULL);
2709 static void validate_coredump_safety(void)
2711 #ifdef CONFIG_COREDUMP
2712 if (suid_dumpable == SUID_DUMP_ROOT &&
2713 core_pattern[0] != '/' && core_pattern[0] != '|') {
2715 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2716 "Pipe handler or fully qualified core dump path required.\n"
2717 "Set kernel.core_pattern before fs.suid_dumpable.\n"
2723 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2724 void __user *buffer, size_t *lenp, loff_t *ppos)
2726 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2728 validate_coredump_safety();
2732 #ifdef CONFIG_COREDUMP
2733 static int proc_dostring_coredump(struct ctl_table *table, int write,
2734 void __user *buffer, size_t *lenp, loff_t *ppos)
2736 int error = proc_dostring(table, write, buffer, lenp, ppos);
2738 validate_coredump_safety();
2743 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
2744 void __user *buffer,
2745 size_t *lenp, loff_t *ppos,
2746 unsigned long convmul,
2747 unsigned long convdiv)
2749 unsigned long *i, *min, *max;
2750 int vleft, first = 1, err = 0;
2752 char *kbuf = NULL, *p;
2754 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
2759 i = (unsigned long *) data;
2760 min = (unsigned long *) table->extra1;
2761 max = (unsigned long *) table->extra2;
2762 vleft = table->maxlen / sizeof(unsigned long);
2766 if (proc_first_pos_non_zero_ignore(ppos, table))
2769 if (left > PAGE_SIZE - 1)
2770 left = PAGE_SIZE - 1;
2771 p = kbuf = memdup_user_nul(buffer, left);
2773 return PTR_ERR(kbuf);
2776 for (; left && vleft--; i++, first = 0) {
2782 left -= proc_skip_spaces(&p);
2784 err = proc_get_long(&p, &left, &val, &neg,
2786 sizeof(proc_wspace_sep), NULL);
2791 val = convmul * val / convdiv;
2792 if ((min && val < *min) || (max && val > *max))
2796 val = convdiv * (*i) / convmul;
2798 err = proc_put_char(&buffer, &left, '\t');
2802 err = proc_put_long(&buffer, &left, val, false);
2808 if (!write && !first && left && !err)
2809 err = proc_put_char(&buffer, &left, '\n');
2811 left -= proc_skip_spaces(&p);
2815 return err ? : -EINVAL;
2823 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2824 void __user *buffer,
2825 size_t *lenp, loff_t *ppos,
2826 unsigned long convmul,
2827 unsigned long convdiv)
2829 return __do_proc_doulongvec_minmax(table->data, table, write,
2830 buffer, lenp, ppos, convmul, convdiv);
2834 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2835 * @table: the sysctl table
2836 * @write: %TRUE if this is a write to the sysctl file
2837 * @buffer: the user buffer
2838 * @lenp: the size of the user buffer
2839 * @ppos: file position
2841 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2842 * values from/to the user buffer, treated as an ASCII string.
2844 * This routine will ensure the values are within the range specified by
2845 * table->extra1 (min) and table->extra2 (max).
2847 * Returns 0 on success.
2849 int proc_doulongvec_minmax(struct ctl_table *table, int write,
2850 void __user *buffer, size_t *lenp, loff_t *ppos)
2852 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
2856 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2857 * @table: the sysctl table
2858 * @write: %TRUE if this is a write to the sysctl file
2859 * @buffer: the user buffer
2860 * @lenp: the size of the user buffer
2861 * @ppos: file position
2863 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2864 * values from/to the user buffer, treated as an ASCII string. The values
2865 * are treated as milliseconds, and converted to jiffies when they are stored.
2867 * This routine will ensure the values are within the range specified by
2868 * table->extra1 (min) and table->extra2 (max).
2870 * Returns 0 on success.
2872 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2873 void __user *buffer,
2874 size_t *lenp, loff_t *ppos)
2876 return do_proc_doulongvec_minmax(table, write, buffer,
2877 lenp, ppos, HZ, 1000l);
2881 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
2883 int write, void *data)
2886 if (*lvalp > INT_MAX / HZ)
2888 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2894 lval = -(unsigned long)val;
2897 lval = (unsigned long)val;
2904 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
2906 int write, void *data)
2909 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2911 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2917 lval = -(unsigned long)val;
2920 lval = (unsigned long)val;
2922 *lvalp = jiffies_to_clock_t(lval);
2927 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
2929 int write, void *data)
2932 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2942 lval = -(unsigned long)val;
2945 lval = (unsigned long)val;
2947 *lvalp = jiffies_to_msecs(lval);
2953 * proc_dointvec_jiffies - read a vector of integers as seconds
2954 * @table: the sysctl table
2955 * @write: %TRUE if this is a write to the sysctl file
2956 * @buffer: the user buffer
2957 * @lenp: the size of the user buffer
2958 * @ppos: file position
2960 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2961 * values from/to the user buffer, treated as an ASCII string.
2962 * The values read are assumed to be in seconds, and are converted into
2965 * Returns 0 on success.
2967 int proc_dointvec_jiffies(struct ctl_table *table, int write,
2968 void __user *buffer, size_t *lenp, loff_t *ppos)
2970 return do_proc_dointvec(table,write,buffer,lenp,ppos,
2971 do_proc_dointvec_jiffies_conv,NULL);
2975 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2976 * @table: the sysctl table
2977 * @write: %TRUE if this is a write to the sysctl file
2978 * @buffer: the user buffer
2979 * @lenp: the size of the user buffer
2980 * @ppos: pointer to the file position
2982 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2983 * values from/to the user buffer, treated as an ASCII string.
2984 * The values read are assumed to be in 1/USER_HZ seconds, and
2985 * are converted into jiffies.
2987 * Returns 0 on success.
2989 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
2990 void __user *buffer, size_t *lenp, loff_t *ppos)
2992 return do_proc_dointvec(table,write,buffer,lenp,ppos,
2993 do_proc_dointvec_userhz_jiffies_conv,NULL);
2997 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2998 * @table: the sysctl table
2999 * @write: %TRUE if this is a write to the sysctl file
3000 * @buffer: the user buffer
3001 * @lenp: the size of the user buffer
3002 * @ppos: file position
3003 * @ppos: the current position in the file
3005 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3006 * values from/to the user buffer, treated as an ASCII string.
3007 * The values read are assumed to be in 1/1000 seconds, and
3008 * are converted into jiffies.
3010 * Returns 0 on success.
3012 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
3013 void __user *buffer, size_t *lenp, loff_t *ppos)
3015 return do_proc_dointvec(table, write, buffer, lenp, ppos,
3016 do_proc_dointvec_ms_jiffies_conv, NULL);
3019 static int proc_do_cad_pid(struct ctl_table *table, int write,
3020 void __user *buffer, size_t *lenp, loff_t *ppos)
3022 struct pid *new_pid;
3026 tmp = pid_vnr(cad_pid);
3028 r = __do_proc_dointvec(&tmp, table, write, buffer,
3029 lenp, ppos, NULL, NULL);
3033 new_pid = find_get_pid(tmp);
3037 put_pid(xchg(&cad_pid, new_pid));
3042 * proc_do_large_bitmap - read/write from/to a large bitmap
3043 * @table: the sysctl table
3044 * @write: %TRUE if this is a write to the sysctl file
3045 * @buffer: the user buffer
3046 * @lenp: the size of the user buffer
3047 * @ppos: file position
3049 * The bitmap is stored at table->data and the bitmap length (in bits)
3052 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
3053 * large bitmaps may be represented in a compact manner. Writing into
3054 * the file will clear the bitmap then update it with the given input.
3056 * Returns 0 on success.
3058 int proc_do_large_bitmap(struct ctl_table *table, int write,
3059 void __user *buffer, size_t *lenp, loff_t *ppos)
3063 size_t left = *lenp;
3064 unsigned long bitmap_len = table->maxlen;
3065 unsigned long *bitmap = *(unsigned long **) table->data;
3066 unsigned long *tmp_bitmap = NULL;
3067 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
3069 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
3077 if (left > PAGE_SIZE - 1)
3078 left = PAGE_SIZE - 1;
3080 p = kbuf = memdup_user_nul(buffer, left);
3082 return PTR_ERR(kbuf);
3084 tmp_bitmap = kcalloc(BITS_TO_LONGS(bitmap_len),
3085 sizeof(unsigned long),
3091 proc_skip_char(&p, &left, '\n');
3092 while (!err && left) {
3093 unsigned long val_a, val_b;
3096 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
3100 if (val_a >= bitmap_len || neg) {
3112 err = proc_get_long(&p, &left, &val_b,
3113 &neg, tr_b, sizeof(tr_b),
3117 if (val_b >= bitmap_len || neg ||
3128 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
3130 proc_skip_char(&p, &left, '\n');
3134 unsigned long bit_a, bit_b = 0;
3137 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3138 if (bit_a >= bitmap_len)
3140 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3144 err = proc_put_char(&buffer, &left, ',');
3148 err = proc_put_long(&buffer, &left, bit_a, false);
3151 if (bit_a != bit_b) {
3152 err = proc_put_char(&buffer, &left, '-');
3155 err = proc_put_long(&buffer, &left, bit_b, false);
3163 err = proc_put_char(&buffer, &left, '\n');
3169 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3171 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
3181 #else /* CONFIG_PROC_SYSCTL */
3183 int proc_dostring(struct ctl_table *table, int write,
3184 void __user *buffer, size_t *lenp, loff_t *ppos)
3189 int proc_dointvec(struct ctl_table *table, int write,
3190 void __user *buffer, size_t *lenp, loff_t *ppos)
3195 int proc_douintvec(struct ctl_table *table, int write,
3196 void __user *buffer, size_t *lenp, loff_t *ppos)
3201 int proc_dointvec_minmax(struct ctl_table *table, int write,
3202 void __user *buffer, size_t *lenp, loff_t *ppos)
3207 int proc_douintvec_minmax(struct ctl_table *table, int write,
3208 void __user *buffer, size_t *lenp, loff_t *ppos)
3213 int proc_dointvec_jiffies(struct ctl_table *table, int write,
3214 void __user *buffer, size_t *lenp, loff_t *ppos)
3219 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
3220 void __user *buffer, size_t *lenp, loff_t *ppos)
3225 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
3226 void __user *buffer, size_t *lenp, loff_t *ppos)
3231 int proc_doulongvec_minmax(struct ctl_table *table, int write,
3232 void __user *buffer, size_t *lenp, loff_t *ppos)
3237 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
3238 void __user *buffer,
3239 size_t *lenp, loff_t *ppos)
3245 #endif /* CONFIG_PROC_SYSCTL */
3248 * No sense putting this after each symbol definition, twice,
3249 * exception granted :-)
3251 EXPORT_SYMBOL(proc_dointvec);
3252 EXPORT_SYMBOL(proc_douintvec);
3253 EXPORT_SYMBOL(proc_dointvec_jiffies);
3254 EXPORT_SYMBOL(proc_dointvec_minmax);
3255 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3256 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3257 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3258 EXPORT_SYMBOL(proc_dostring);
3259 EXPORT_SYMBOL(proc_doulongvec_minmax);
3260 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);