2 * sysctl.c: General linux system control interface
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
21 #include <linux/module.h>
22 #include <linux/aio.h>
24 #include <linux/swap.h>
25 #include <linux/slab.h>
26 #include <linux/sysctl.h>
27 #include <linux/bitmap.h>
28 #include <linux/signal.h>
29 #include <linux/printk.h>
30 #include <linux/proc_fs.h>
31 #include <linux/security.h>
32 #include <linux/ctype.h>
33 #include <linux/kmemleak.h>
35 #include <linux/init.h>
36 #include <linux/kernel.h>
37 #include <linux/kobject.h>
38 #include <linux/net.h>
39 #include <linux/sysrq.h>
40 #include <linux/highuid.h>
41 #include <linux/writeback.h>
42 #include <linux/ratelimit.h>
43 #include <linux/compaction.h>
44 #include <linux/hugetlb.h>
45 #include <linux/initrd.h>
46 #include <linux/key.h>
47 #include <linux/times.h>
48 #include <linux/limits.h>
49 #include <linux/dcache.h>
50 #include <linux/dnotify.h>
51 #include <linux/syscalls.h>
52 #include <linux/vmstat.h>
53 #include <linux/nfs_fs.h>
54 #include <linux/acpi.h>
55 #include <linux/reboot.h>
56 #include <linux/ftrace.h>
57 #include <linux/perf_event.h>
58 #include <linux/kprobes.h>
59 #include <linux/pipe_fs_i.h>
60 #include <linux/oom.h>
61 #include <linux/kmod.h>
62 #include <linux/capability.h>
63 #include <linux/binfmts.h>
64 #include <linux/sched/sysctl.h>
65 #include <linux/sched/coredump.h>
66 #include <linux/kexec.h>
67 #include <linux/bpf.h>
68 #include <linux/mount.h>
69 #include <linux/pipe_fs_i.h>
71 #include <linux/uaccess.h>
72 #include <asm/processor.h>
76 #include <asm/stacktrace.h>
80 #include <asm/setup.h>
82 #ifdef CONFIG_BSD_PROCESS_ACCT
83 #include <linux/acct.h>
85 #ifdef CONFIG_RT_MUTEXES
86 #include <linux/rtmutex.h>
88 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
89 #include <linux/lockdep.h>
91 #ifdef CONFIG_CHR_DEV_SG
95 #ifdef CONFIG_LOCKUP_DETECTOR
96 #include <linux/nmi.h>
99 #if defined(CONFIG_SYSCTL)
101 /* External variables not in a header file. */
102 extern int suid_dumpable;
103 #ifdef CONFIG_COREDUMP
104 extern int core_uses_pid;
105 extern char core_pattern[];
106 extern unsigned int core_pipe_limit;
109 extern int pid_max_min, pid_max_max;
110 extern int percpu_pagelist_fraction;
111 extern int latencytop_enabled;
112 extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
114 extern int sysctl_nr_trim_pages;
117 /* Constants used for minimum and maximum */
118 #ifdef CONFIG_LOCKUP_DETECTOR
119 static int sixty = 60;
122 static int __maybe_unused neg_one = -1;
125 static int __maybe_unused one = 1;
126 static int __maybe_unused two = 2;
127 static int __maybe_unused four = 4;
128 static unsigned long one_ul = 1;
129 static int one_hundred = 100;
130 static int one_thousand = 1000;
132 static int ten_thousand = 10000;
134 #ifdef CONFIG_PERF_EVENTS
135 static int six_hundred_forty_kb = 640 * 1024;
138 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
139 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
141 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
142 static int maxolduid = 65535;
143 static int minolduid;
145 static int ngroups_max = NGROUPS_MAX;
146 static const int cap_last_cap = CAP_LAST_CAP;
149 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
150 * and hung_task_check_interval_secs
152 #ifdef CONFIG_DETECT_HUNG_TASK
153 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
156 #ifdef CONFIG_INOTIFY_USER
157 #include <linux/inotify.h>
163 extern int pwrsw_enabled;
166 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
167 extern int unaligned_enabled;
171 extern int unaligned_dump_stack;
174 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
175 extern int no_unaligned_warning;
178 #ifdef CONFIG_PROC_SYSCTL
181 * enum sysctl_writes_mode - supported sysctl write modes
183 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
184 * to be written, and multiple writes on the same sysctl file descriptor
185 * will rewrite the sysctl value, regardless of file position. No warning
186 * is issued when the initial position is not 0.
187 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
189 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
190 * file position 0 and the value must be fully contained in the buffer
191 * sent to the write syscall. If dealing with strings respect the file
192 * position, but restrict this to the max length of the buffer, anything
193 * passed the max lenght will be ignored. Multiple writes will append
196 * These write modes control how current file position affects the behavior of
197 * updating sysctl values through the proc interface on each write.
199 enum sysctl_writes_mode {
200 SYSCTL_WRITES_LEGACY = -1,
201 SYSCTL_WRITES_WARN = 0,
202 SYSCTL_WRITES_STRICT = 1,
205 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
207 static int proc_do_cad_pid(struct ctl_table *table, int write,
208 void __user *buffer, size_t *lenp, loff_t *ppos);
209 static int proc_taint(struct ctl_table *table, int write,
210 void __user *buffer, size_t *lenp, loff_t *ppos);
214 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
215 void __user *buffer, size_t *lenp, loff_t *ppos);
218 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
219 void __user *buffer, size_t *lenp, loff_t *ppos);
220 #ifdef CONFIG_COREDUMP
221 static int proc_dostring_coredump(struct ctl_table *table, int write,
222 void __user *buffer, size_t *lenp, loff_t *ppos);
224 static int proc_dopipe_max_size(struct ctl_table *table, int write,
225 void __user *buffer, size_t *lenp, loff_t *ppos);
227 #ifdef CONFIG_MAGIC_SYSRQ
228 /* Note: sysrq code uses its own private copy */
229 static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
231 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
232 void __user *buffer, size_t *lenp,
237 error = proc_dointvec(table, write, buffer, lenp, ppos);
242 sysrq_toggle_support(__sysrq_enabled);
249 static struct ctl_table kern_table[];
250 static struct ctl_table vm_table[];
251 static struct ctl_table fs_table[];
252 static struct ctl_table debug_table[];
253 static struct ctl_table dev_table[];
254 extern struct ctl_table random_table[];
256 extern struct ctl_table epoll_table[];
259 #ifdef CONFIG_FW_LOADER_USER_HELPER
260 extern struct ctl_table firmware_config_table[];
263 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
264 int sysctl_legacy_va_layout;
267 /* The default sysctl tables: */
269 static struct ctl_table sysctl_base_table[] = {
271 .procname = "kernel",
288 .child = debug_table,
298 #ifdef CONFIG_SCHED_DEBUG
299 static int min_sched_granularity_ns = 100000; /* 100 usecs */
300 static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
301 static int min_wakeup_granularity_ns; /* 0 usecs */
302 static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
304 static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
305 static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
306 #endif /* CONFIG_SMP */
307 #endif /* CONFIG_SCHED_DEBUG */
309 #ifdef CONFIG_COMPACTION
310 static int min_extfrag_threshold;
311 static int max_extfrag_threshold = 1000;
314 static struct ctl_table kern_table[] = {
316 .procname = "sched_child_runs_first",
317 .data = &sysctl_sched_child_runs_first,
318 .maxlen = sizeof(unsigned int),
320 .proc_handler = proc_dointvec,
322 #ifdef CONFIG_SCHED_DEBUG
324 .procname = "sched_min_granularity_ns",
325 .data = &sysctl_sched_min_granularity,
326 .maxlen = sizeof(unsigned int),
328 .proc_handler = sched_proc_update_handler,
329 .extra1 = &min_sched_granularity_ns,
330 .extra2 = &max_sched_granularity_ns,
333 .procname = "sched_latency_ns",
334 .data = &sysctl_sched_latency,
335 .maxlen = sizeof(unsigned int),
337 .proc_handler = sched_proc_update_handler,
338 .extra1 = &min_sched_granularity_ns,
339 .extra2 = &max_sched_granularity_ns,
342 .procname = "sched_wakeup_granularity_ns",
343 .data = &sysctl_sched_wakeup_granularity,
344 .maxlen = sizeof(unsigned int),
346 .proc_handler = sched_proc_update_handler,
347 .extra1 = &min_wakeup_granularity_ns,
348 .extra2 = &max_wakeup_granularity_ns,
352 .procname = "sched_tunable_scaling",
353 .data = &sysctl_sched_tunable_scaling,
354 .maxlen = sizeof(enum sched_tunable_scaling),
356 .proc_handler = sched_proc_update_handler,
357 .extra1 = &min_sched_tunable_scaling,
358 .extra2 = &max_sched_tunable_scaling,
361 .procname = "sched_migration_cost_ns",
362 .data = &sysctl_sched_migration_cost,
363 .maxlen = sizeof(unsigned int),
365 .proc_handler = proc_dointvec,
368 .procname = "sched_nr_migrate",
369 .data = &sysctl_sched_nr_migrate,
370 .maxlen = sizeof(unsigned int),
372 .proc_handler = proc_dointvec,
374 #ifdef CONFIG_SCHEDSTATS
376 .procname = "sched_schedstats",
378 .maxlen = sizeof(unsigned int),
380 .proc_handler = sysctl_schedstats,
384 #endif /* CONFIG_SCHEDSTATS */
385 #endif /* CONFIG_SMP */
386 #ifdef CONFIG_NUMA_BALANCING
388 .procname = "numa_balancing_scan_delay_ms",
389 .data = &sysctl_numa_balancing_scan_delay,
390 .maxlen = sizeof(unsigned int),
392 .proc_handler = proc_dointvec,
395 .procname = "numa_balancing_scan_period_min_ms",
396 .data = &sysctl_numa_balancing_scan_period_min,
397 .maxlen = sizeof(unsigned int),
399 .proc_handler = proc_dointvec,
402 .procname = "numa_balancing_scan_period_max_ms",
403 .data = &sysctl_numa_balancing_scan_period_max,
404 .maxlen = sizeof(unsigned int),
406 .proc_handler = proc_dointvec,
409 .procname = "numa_balancing_scan_size_mb",
410 .data = &sysctl_numa_balancing_scan_size,
411 .maxlen = sizeof(unsigned int),
413 .proc_handler = proc_dointvec_minmax,
417 .procname = "numa_balancing",
418 .data = NULL, /* filled in by handler */
419 .maxlen = sizeof(unsigned int),
421 .proc_handler = sysctl_numa_balancing,
425 #endif /* CONFIG_NUMA_BALANCING */
426 #endif /* CONFIG_SCHED_DEBUG */
428 .procname = "sched_rt_period_us",
429 .data = &sysctl_sched_rt_period,
430 .maxlen = sizeof(unsigned int),
432 .proc_handler = sched_rt_handler,
435 .procname = "sched_rt_runtime_us",
436 .data = &sysctl_sched_rt_runtime,
437 .maxlen = sizeof(int),
439 .proc_handler = sched_rt_handler,
442 .procname = "sched_rr_timeslice_ms",
443 .data = &sysctl_sched_rr_timeslice,
444 .maxlen = sizeof(int),
446 .proc_handler = sched_rr_handler,
448 #ifdef CONFIG_SCHED_AUTOGROUP
450 .procname = "sched_autogroup_enabled",
451 .data = &sysctl_sched_autogroup_enabled,
452 .maxlen = sizeof(unsigned int),
454 .proc_handler = proc_dointvec_minmax,
459 #ifdef CONFIG_CFS_BANDWIDTH
461 .procname = "sched_cfs_bandwidth_slice_us",
462 .data = &sysctl_sched_cfs_bandwidth_slice,
463 .maxlen = sizeof(unsigned int),
465 .proc_handler = proc_dointvec_minmax,
469 #ifdef CONFIG_PROVE_LOCKING
471 .procname = "prove_locking",
472 .data = &prove_locking,
473 .maxlen = sizeof(int),
475 .proc_handler = proc_dointvec,
478 #ifdef CONFIG_LOCK_STAT
480 .procname = "lock_stat",
482 .maxlen = sizeof(int),
484 .proc_handler = proc_dointvec,
489 .data = &panic_timeout,
490 .maxlen = sizeof(int),
492 .proc_handler = proc_dointvec,
494 #ifdef CONFIG_COREDUMP
496 .procname = "core_uses_pid",
497 .data = &core_uses_pid,
498 .maxlen = sizeof(int),
500 .proc_handler = proc_dointvec,
503 .procname = "core_pattern",
504 .data = core_pattern,
505 .maxlen = CORENAME_MAX_SIZE,
507 .proc_handler = proc_dostring_coredump,
510 .procname = "core_pipe_limit",
511 .data = &core_pipe_limit,
512 .maxlen = sizeof(unsigned int),
514 .proc_handler = proc_dointvec,
517 #ifdef CONFIG_PROC_SYSCTL
519 .procname = "tainted",
520 .maxlen = sizeof(long),
522 .proc_handler = proc_taint,
525 .procname = "sysctl_writes_strict",
526 .data = &sysctl_writes_strict,
527 .maxlen = sizeof(int),
529 .proc_handler = proc_dointvec_minmax,
534 #ifdef CONFIG_LATENCYTOP
536 .procname = "latencytop",
537 .data = &latencytop_enabled,
538 .maxlen = sizeof(int),
540 .proc_handler = sysctl_latencytop,
543 #ifdef CONFIG_BLK_DEV_INITRD
545 .procname = "real-root-dev",
546 .data = &real_root_dev,
547 .maxlen = sizeof(int),
549 .proc_handler = proc_dointvec,
553 .procname = "print-fatal-signals",
554 .data = &print_fatal_signals,
555 .maxlen = sizeof(int),
557 .proc_handler = proc_dointvec,
561 .procname = "reboot-cmd",
562 .data = reboot_command,
565 .proc_handler = proc_dostring,
568 .procname = "stop-a",
569 .data = &stop_a_enabled,
570 .maxlen = sizeof (int),
572 .proc_handler = proc_dointvec,
575 .procname = "scons-poweroff",
576 .data = &scons_pwroff,
577 .maxlen = sizeof (int),
579 .proc_handler = proc_dointvec,
582 #ifdef CONFIG_SPARC64
584 .procname = "tsb-ratio",
585 .data = &sysctl_tsb_ratio,
586 .maxlen = sizeof (int),
588 .proc_handler = proc_dointvec,
593 .procname = "soft-power",
594 .data = &pwrsw_enabled,
595 .maxlen = sizeof (int),
597 .proc_handler = proc_dointvec,
600 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
602 .procname = "unaligned-trap",
603 .data = &unaligned_enabled,
604 .maxlen = sizeof (int),
606 .proc_handler = proc_dointvec,
610 .procname = "ctrl-alt-del",
612 .maxlen = sizeof(int),
614 .proc_handler = proc_dointvec,
616 #ifdef CONFIG_FUNCTION_TRACER
618 .procname = "ftrace_enabled",
619 .data = &ftrace_enabled,
620 .maxlen = sizeof(int),
622 .proc_handler = ftrace_enable_sysctl,
625 #ifdef CONFIG_STACK_TRACER
627 .procname = "stack_tracer_enabled",
628 .data = &stack_tracer_enabled,
629 .maxlen = sizeof(int),
631 .proc_handler = stack_trace_sysctl,
634 #ifdef CONFIG_TRACING
636 .procname = "ftrace_dump_on_oops",
637 .data = &ftrace_dump_on_oops,
638 .maxlen = sizeof(int),
640 .proc_handler = proc_dointvec,
643 .procname = "traceoff_on_warning",
644 .data = &__disable_trace_on_warning,
645 .maxlen = sizeof(__disable_trace_on_warning),
647 .proc_handler = proc_dointvec,
650 .procname = "tracepoint_printk",
651 .data = &tracepoint_printk,
652 .maxlen = sizeof(tracepoint_printk),
654 .proc_handler = tracepoint_printk_sysctl,
657 #ifdef CONFIG_KEXEC_CORE
659 .procname = "kexec_load_disabled",
660 .data = &kexec_load_disabled,
661 .maxlen = sizeof(int),
663 /* only handle a transition from default "0" to "1" */
664 .proc_handler = proc_dointvec_minmax,
669 #ifdef CONFIG_MODULES
671 .procname = "modprobe",
672 .data = &modprobe_path,
673 .maxlen = KMOD_PATH_LEN,
675 .proc_handler = proc_dostring,
678 .procname = "modules_disabled",
679 .data = &modules_disabled,
680 .maxlen = sizeof(int),
682 /* only handle a transition from default "0" to "1" */
683 .proc_handler = proc_dointvec_minmax,
688 #ifdef CONFIG_UEVENT_HELPER
690 .procname = "hotplug",
691 .data = &uevent_helper,
692 .maxlen = UEVENT_HELPER_PATH_LEN,
694 .proc_handler = proc_dostring,
697 #ifdef CONFIG_CHR_DEV_SG
699 .procname = "sg-big-buff",
700 .data = &sg_big_buff,
701 .maxlen = sizeof (int),
703 .proc_handler = proc_dointvec,
706 #ifdef CONFIG_BSD_PROCESS_ACCT
710 .maxlen = 3*sizeof(int),
712 .proc_handler = proc_dointvec,
715 #ifdef CONFIG_MAGIC_SYSRQ
718 .data = &__sysrq_enabled,
719 .maxlen = sizeof (int),
721 .proc_handler = sysrq_sysctl_handler,
724 #ifdef CONFIG_PROC_SYSCTL
726 .procname = "cad_pid",
728 .maxlen = sizeof (int),
730 .proc_handler = proc_do_cad_pid,
734 .procname = "threads-max",
736 .maxlen = sizeof(int),
738 .proc_handler = sysctl_max_threads,
741 .procname = "random",
743 .child = random_table,
746 .procname = "usermodehelper",
748 .child = usermodehelper_table,
750 #ifdef CONFIG_FW_LOADER_USER_HELPER
752 .procname = "firmware_config",
754 .child = firmware_config_table,
758 .procname = "overflowuid",
759 .data = &overflowuid,
760 .maxlen = sizeof(int),
762 .proc_handler = proc_dointvec_minmax,
763 .extra1 = &minolduid,
764 .extra2 = &maxolduid,
767 .procname = "overflowgid",
768 .data = &overflowgid,
769 .maxlen = sizeof(int),
771 .proc_handler = proc_dointvec_minmax,
772 .extra1 = &minolduid,
773 .extra2 = &maxolduid,
776 #ifdef CONFIG_MATHEMU
778 .procname = "ieee_emulation_warnings",
779 .data = &sysctl_ieee_emulation_warnings,
780 .maxlen = sizeof(int),
782 .proc_handler = proc_dointvec,
786 .procname = "userprocess_debug",
787 .data = &show_unhandled_signals,
788 .maxlen = sizeof(int),
790 .proc_handler = proc_dointvec,
794 .procname = "pid_max",
796 .maxlen = sizeof (int),
798 .proc_handler = proc_dointvec_minmax,
799 .extra1 = &pid_max_min,
800 .extra2 = &pid_max_max,
803 .procname = "panic_on_oops",
804 .data = &panic_on_oops,
805 .maxlen = sizeof(int),
807 .proc_handler = proc_dointvec,
809 #if defined CONFIG_PRINTK
811 .procname = "printk",
812 .data = &console_loglevel,
813 .maxlen = 4*sizeof(int),
815 .proc_handler = proc_dointvec,
818 .procname = "printk_ratelimit",
819 .data = &printk_ratelimit_state.interval,
820 .maxlen = sizeof(int),
822 .proc_handler = proc_dointvec_jiffies,
825 .procname = "printk_ratelimit_burst",
826 .data = &printk_ratelimit_state.burst,
827 .maxlen = sizeof(int),
829 .proc_handler = proc_dointvec,
832 .procname = "printk_delay",
833 .data = &printk_delay_msec,
834 .maxlen = sizeof(int),
836 .proc_handler = proc_dointvec_minmax,
838 .extra2 = &ten_thousand,
841 .procname = "printk_devkmsg",
842 .data = devkmsg_log_str,
843 .maxlen = DEVKMSG_STR_MAX_SIZE,
845 .proc_handler = devkmsg_sysctl_set_loglvl,
848 .procname = "dmesg_restrict",
849 .data = &dmesg_restrict,
850 .maxlen = sizeof(int),
852 .proc_handler = proc_dointvec_minmax_sysadmin,
857 .procname = "kptr_restrict",
858 .data = &kptr_restrict,
859 .maxlen = sizeof(int),
861 .proc_handler = proc_dointvec_minmax_sysadmin,
867 .procname = "ngroups_max",
868 .data = &ngroups_max,
869 .maxlen = sizeof (int),
871 .proc_handler = proc_dointvec,
874 .procname = "cap_last_cap",
875 .data = (void *)&cap_last_cap,
876 .maxlen = sizeof(int),
878 .proc_handler = proc_dointvec,
880 #if defined(CONFIG_LOCKUP_DETECTOR)
882 .procname = "watchdog",
883 .data = &watchdog_user_enabled,
884 .maxlen = sizeof(int),
886 .proc_handler = proc_watchdog,
891 .procname = "watchdog_thresh",
892 .data = &watchdog_thresh,
893 .maxlen = sizeof(int),
895 .proc_handler = proc_watchdog_thresh,
900 .procname = "nmi_watchdog",
901 .data = &nmi_watchdog_user_enabled,
902 .maxlen = sizeof(int),
903 .mode = NMI_WATCHDOG_SYSCTL_PERM,
904 .proc_handler = proc_nmi_watchdog,
909 .procname = "watchdog_cpumask",
910 .data = &watchdog_cpumask_bits,
913 .proc_handler = proc_watchdog_cpumask,
915 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
917 .procname = "soft_watchdog",
918 .data = &soft_watchdog_user_enabled,
919 .maxlen = sizeof(int),
921 .proc_handler = proc_soft_watchdog,
926 .procname = "softlockup_panic",
927 .data = &softlockup_panic,
928 .maxlen = sizeof(int),
930 .proc_handler = proc_dointvec_minmax,
936 .procname = "softlockup_all_cpu_backtrace",
937 .data = &sysctl_softlockup_all_cpu_backtrace,
938 .maxlen = sizeof(int),
940 .proc_handler = proc_dointvec_minmax,
944 #endif /* CONFIG_SMP */
946 #ifdef CONFIG_HARDLOCKUP_DETECTOR
948 .procname = "hardlockup_panic",
949 .data = &hardlockup_panic,
950 .maxlen = sizeof(int),
952 .proc_handler = proc_dointvec_minmax,
958 .procname = "hardlockup_all_cpu_backtrace",
959 .data = &sysctl_hardlockup_all_cpu_backtrace,
960 .maxlen = sizeof(int),
962 .proc_handler = proc_dointvec_minmax,
966 #endif /* CONFIG_SMP */
970 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
972 .procname = "unknown_nmi_panic",
973 .data = &unknown_nmi_panic,
974 .maxlen = sizeof (int),
976 .proc_handler = proc_dointvec,
979 #if defined(CONFIG_X86)
981 .procname = "panic_on_unrecovered_nmi",
982 .data = &panic_on_unrecovered_nmi,
983 .maxlen = sizeof(int),
985 .proc_handler = proc_dointvec,
988 .procname = "panic_on_io_nmi",
989 .data = &panic_on_io_nmi,
990 .maxlen = sizeof(int),
992 .proc_handler = proc_dointvec,
994 #ifdef CONFIG_DEBUG_STACKOVERFLOW
996 .procname = "panic_on_stackoverflow",
997 .data = &sysctl_panic_on_stackoverflow,
998 .maxlen = sizeof(int),
1000 .proc_handler = proc_dointvec,
1004 .procname = "bootloader_type",
1005 .data = &bootloader_type,
1006 .maxlen = sizeof (int),
1008 .proc_handler = proc_dointvec,
1011 .procname = "bootloader_version",
1012 .data = &bootloader_version,
1013 .maxlen = sizeof (int),
1015 .proc_handler = proc_dointvec,
1018 .procname = "io_delay_type",
1019 .data = &io_delay_type,
1020 .maxlen = sizeof(int),
1022 .proc_handler = proc_dointvec,
1025 #if defined(CONFIG_MMU)
1027 .procname = "randomize_va_space",
1028 .data = &randomize_va_space,
1029 .maxlen = sizeof(int),
1031 .proc_handler = proc_dointvec,
1034 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1036 .procname = "spin_retry",
1037 .data = &spin_retry,
1038 .maxlen = sizeof (int),
1040 .proc_handler = proc_dointvec,
1043 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1045 .procname = "acpi_video_flags",
1046 .data = &acpi_realmode_flags,
1047 .maxlen = sizeof (unsigned long),
1049 .proc_handler = proc_doulongvec_minmax,
1052 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1054 .procname = "ignore-unaligned-usertrap",
1055 .data = &no_unaligned_warning,
1056 .maxlen = sizeof (int),
1058 .proc_handler = proc_dointvec,
1063 .procname = "unaligned-dump-stack",
1064 .data = &unaligned_dump_stack,
1065 .maxlen = sizeof (int),
1067 .proc_handler = proc_dointvec,
1070 #ifdef CONFIG_DETECT_HUNG_TASK
1072 .procname = "hung_task_panic",
1073 .data = &sysctl_hung_task_panic,
1074 .maxlen = sizeof(int),
1076 .proc_handler = proc_dointvec_minmax,
1081 .procname = "hung_task_check_count",
1082 .data = &sysctl_hung_task_check_count,
1083 .maxlen = sizeof(int),
1085 .proc_handler = proc_dointvec_minmax,
1089 .procname = "hung_task_timeout_secs",
1090 .data = &sysctl_hung_task_timeout_secs,
1091 .maxlen = sizeof(unsigned long),
1093 .proc_handler = proc_dohung_task_timeout_secs,
1094 .extra2 = &hung_task_timeout_max,
1097 .procname = "hung_task_check_interval_secs",
1098 .data = &sysctl_hung_task_check_interval_secs,
1099 .maxlen = sizeof(unsigned long),
1101 .proc_handler = proc_dohung_task_timeout_secs,
1102 .extra2 = &hung_task_timeout_max,
1105 .procname = "hung_task_warnings",
1106 .data = &sysctl_hung_task_warnings,
1107 .maxlen = sizeof(int),
1109 .proc_handler = proc_dointvec_minmax,
1113 #ifdef CONFIG_RT_MUTEXES
1115 .procname = "max_lock_depth",
1116 .data = &max_lock_depth,
1117 .maxlen = sizeof(int),
1119 .proc_handler = proc_dointvec,
1123 .procname = "poweroff_cmd",
1124 .data = &poweroff_cmd,
1125 .maxlen = POWEROFF_CMD_PATH_LEN,
1127 .proc_handler = proc_dostring,
1133 .child = key_sysctls,
1136 #ifdef CONFIG_PERF_EVENTS
1138 * User-space scripts rely on the existence of this file
1139 * as a feature check for perf_events being enabled.
1141 * So it's an ABI, do not remove!
1144 .procname = "perf_event_paranoid",
1145 .data = &sysctl_perf_event_paranoid,
1146 .maxlen = sizeof(sysctl_perf_event_paranoid),
1148 .proc_handler = proc_dointvec,
1151 .procname = "perf_event_mlock_kb",
1152 .data = &sysctl_perf_event_mlock,
1153 .maxlen = sizeof(sysctl_perf_event_mlock),
1155 .proc_handler = proc_dointvec,
1158 .procname = "perf_event_max_sample_rate",
1159 .data = &sysctl_perf_event_sample_rate,
1160 .maxlen = sizeof(sysctl_perf_event_sample_rate),
1162 .proc_handler = perf_proc_update_handler,
1166 .procname = "perf_cpu_time_max_percent",
1167 .data = &sysctl_perf_cpu_time_max_percent,
1168 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1170 .proc_handler = perf_cpu_time_max_percent_handler,
1172 .extra2 = &one_hundred,
1175 .procname = "perf_event_max_stack",
1176 .data = &sysctl_perf_event_max_stack,
1177 .maxlen = sizeof(sysctl_perf_event_max_stack),
1179 .proc_handler = perf_event_max_stack_handler,
1181 .extra2 = &six_hundred_forty_kb,
1184 .procname = "perf_event_max_contexts_per_stack",
1185 .data = &sysctl_perf_event_max_contexts_per_stack,
1186 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1188 .proc_handler = perf_event_max_stack_handler,
1190 .extra2 = &one_thousand,
1194 .procname = "panic_on_warn",
1195 .data = &panic_on_warn,
1196 .maxlen = sizeof(int),
1198 .proc_handler = proc_dointvec_minmax,
1202 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1204 .procname = "timer_migration",
1205 .data = &sysctl_timer_migration,
1206 .maxlen = sizeof(unsigned int),
1208 .proc_handler = timer_migration_handler,
1213 #ifdef CONFIG_BPF_SYSCALL
1215 .procname = "unprivileged_bpf_disabled",
1216 .data = &sysctl_unprivileged_bpf_disabled,
1217 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1219 /* only handle a transition from default "0" to "1" */
1220 .proc_handler = proc_dointvec_minmax,
1225 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1227 .procname = "panic_on_rcu_stall",
1228 .data = &sysctl_panic_on_rcu_stall,
1229 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1231 .proc_handler = proc_dointvec_minmax,
1239 static struct ctl_table vm_table[] = {
1241 .procname = "overcommit_memory",
1242 .data = &sysctl_overcommit_memory,
1243 .maxlen = sizeof(sysctl_overcommit_memory),
1245 .proc_handler = proc_dointvec_minmax,
1250 .procname = "panic_on_oom",
1251 .data = &sysctl_panic_on_oom,
1252 .maxlen = sizeof(sysctl_panic_on_oom),
1254 .proc_handler = proc_dointvec_minmax,
1259 .procname = "oom_kill_allocating_task",
1260 .data = &sysctl_oom_kill_allocating_task,
1261 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1263 .proc_handler = proc_dointvec,
1266 .procname = "oom_dump_tasks",
1267 .data = &sysctl_oom_dump_tasks,
1268 .maxlen = sizeof(sysctl_oom_dump_tasks),
1270 .proc_handler = proc_dointvec,
1273 .procname = "overcommit_ratio",
1274 .data = &sysctl_overcommit_ratio,
1275 .maxlen = sizeof(sysctl_overcommit_ratio),
1277 .proc_handler = overcommit_ratio_handler,
1280 .procname = "overcommit_kbytes",
1281 .data = &sysctl_overcommit_kbytes,
1282 .maxlen = sizeof(sysctl_overcommit_kbytes),
1284 .proc_handler = overcommit_kbytes_handler,
1287 .procname = "page-cluster",
1288 .data = &page_cluster,
1289 .maxlen = sizeof(int),
1291 .proc_handler = proc_dointvec_minmax,
1295 .procname = "dirty_background_ratio",
1296 .data = &dirty_background_ratio,
1297 .maxlen = sizeof(dirty_background_ratio),
1299 .proc_handler = dirty_background_ratio_handler,
1301 .extra2 = &one_hundred,
1304 .procname = "dirty_background_bytes",
1305 .data = &dirty_background_bytes,
1306 .maxlen = sizeof(dirty_background_bytes),
1308 .proc_handler = dirty_background_bytes_handler,
1312 .procname = "dirty_ratio",
1313 .data = &vm_dirty_ratio,
1314 .maxlen = sizeof(vm_dirty_ratio),
1316 .proc_handler = dirty_ratio_handler,
1318 .extra2 = &one_hundred,
1321 .procname = "dirty_bytes",
1322 .data = &vm_dirty_bytes,
1323 .maxlen = sizeof(vm_dirty_bytes),
1325 .proc_handler = dirty_bytes_handler,
1326 .extra1 = &dirty_bytes_min,
1329 .procname = "dirty_writeback_centisecs",
1330 .data = &dirty_writeback_interval,
1331 .maxlen = sizeof(dirty_writeback_interval),
1333 .proc_handler = dirty_writeback_centisecs_handler,
1336 .procname = "dirty_expire_centisecs",
1337 .data = &dirty_expire_interval,
1338 .maxlen = sizeof(dirty_expire_interval),
1340 .proc_handler = proc_dointvec_minmax,
1344 .procname = "dirtytime_expire_seconds",
1345 .data = &dirtytime_expire_interval,
1346 .maxlen = sizeof(dirtytime_expire_interval),
1348 .proc_handler = dirtytime_interval_handler,
1352 .procname = "swappiness",
1353 .data = &vm_swappiness,
1354 .maxlen = sizeof(vm_swappiness),
1356 .proc_handler = proc_dointvec_minmax,
1358 .extra2 = &one_hundred,
1360 #ifdef CONFIG_HUGETLB_PAGE
1362 .procname = "nr_hugepages",
1364 .maxlen = sizeof(unsigned long),
1366 .proc_handler = hugetlb_sysctl_handler,
1370 .procname = "nr_hugepages_mempolicy",
1372 .maxlen = sizeof(unsigned long),
1374 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1377 .procname = "numa_stat",
1378 .data = &sysctl_vm_numa_stat,
1379 .maxlen = sizeof(int),
1381 .proc_handler = sysctl_vm_numa_stat_handler,
1387 .procname = "hugetlb_shm_group",
1388 .data = &sysctl_hugetlb_shm_group,
1389 .maxlen = sizeof(gid_t),
1391 .proc_handler = proc_dointvec,
1394 .procname = "nr_overcommit_hugepages",
1396 .maxlen = sizeof(unsigned long),
1398 .proc_handler = hugetlb_overcommit_handler,
1402 .procname = "lowmem_reserve_ratio",
1403 .data = &sysctl_lowmem_reserve_ratio,
1404 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1406 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
1409 .procname = "drop_caches",
1410 .data = &sysctl_drop_caches,
1411 .maxlen = sizeof(int),
1413 .proc_handler = drop_caches_sysctl_handler,
1417 #ifdef CONFIG_COMPACTION
1419 .procname = "compact_memory",
1420 .data = &sysctl_compact_memory,
1421 .maxlen = sizeof(int),
1423 .proc_handler = sysctl_compaction_handler,
1426 .procname = "extfrag_threshold",
1427 .data = &sysctl_extfrag_threshold,
1428 .maxlen = sizeof(int),
1430 .proc_handler = sysctl_extfrag_handler,
1431 .extra1 = &min_extfrag_threshold,
1432 .extra2 = &max_extfrag_threshold,
1435 .procname = "compact_unevictable_allowed",
1436 .data = &sysctl_compact_unevictable_allowed,
1437 .maxlen = sizeof(int),
1439 .proc_handler = proc_dointvec,
1444 #endif /* CONFIG_COMPACTION */
1446 .procname = "min_free_kbytes",
1447 .data = &min_free_kbytes,
1448 .maxlen = sizeof(min_free_kbytes),
1450 .proc_handler = min_free_kbytes_sysctl_handler,
1454 .procname = "watermark_scale_factor",
1455 .data = &watermark_scale_factor,
1456 .maxlen = sizeof(watermark_scale_factor),
1458 .proc_handler = watermark_scale_factor_sysctl_handler,
1460 .extra2 = &one_thousand,
1463 .procname = "percpu_pagelist_fraction",
1464 .data = &percpu_pagelist_fraction,
1465 .maxlen = sizeof(percpu_pagelist_fraction),
1467 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
1472 .procname = "max_map_count",
1473 .data = &sysctl_max_map_count,
1474 .maxlen = sizeof(sysctl_max_map_count),
1476 .proc_handler = proc_dointvec_minmax,
1481 .procname = "nr_trim_pages",
1482 .data = &sysctl_nr_trim_pages,
1483 .maxlen = sizeof(sysctl_nr_trim_pages),
1485 .proc_handler = proc_dointvec_minmax,
1490 .procname = "laptop_mode",
1491 .data = &laptop_mode,
1492 .maxlen = sizeof(laptop_mode),
1494 .proc_handler = proc_dointvec_jiffies,
1497 .procname = "block_dump",
1498 .data = &block_dump,
1499 .maxlen = sizeof(block_dump),
1501 .proc_handler = proc_dointvec,
1505 .procname = "vfs_cache_pressure",
1506 .data = &sysctl_vfs_cache_pressure,
1507 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1509 .proc_handler = proc_dointvec,
1512 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1514 .procname = "legacy_va_layout",
1515 .data = &sysctl_legacy_va_layout,
1516 .maxlen = sizeof(sysctl_legacy_va_layout),
1518 .proc_handler = proc_dointvec,
1524 .procname = "zone_reclaim_mode",
1525 .data = &node_reclaim_mode,
1526 .maxlen = sizeof(node_reclaim_mode),
1528 .proc_handler = proc_dointvec,
1532 .procname = "min_unmapped_ratio",
1533 .data = &sysctl_min_unmapped_ratio,
1534 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1536 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
1538 .extra2 = &one_hundred,
1541 .procname = "min_slab_ratio",
1542 .data = &sysctl_min_slab_ratio,
1543 .maxlen = sizeof(sysctl_min_slab_ratio),
1545 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
1547 .extra2 = &one_hundred,
1552 .procname = "stat_interval",
1553 .data = &sysctl_stat_interval,
1554 .maxlen = sizeof(sysctl_stat_interval),
1556 .proc_handler = proc_dointvec_jiffies,
1559 .procname = "stat_refresh",
1563 .proc_handler = vmstat_refresh,
1568 .procname = "mmap_min_addr",
1569 .data = &dac_mmap_min_addr,
1570 .maxlen = sizeof(unsigned long),
1572 .proc_handler = mmap_min_addr_handler,
1577 .procname = "numa_zonelist_order",
1578 .data = &numa_zonelist_order,
1579 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1581 .proc_handler = numa_zonelist_order_handler,
1584 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1585 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1587 .procname = "vdso_enabled",
1588 #ifdef CONFIG_X86_32
1589 .data = &vdso32_enabled,
1590 .maxlen = sizeof(vdso32_enabled),
1592 .data = &vdso_enabled,
1593 .maxlen = sizeof(vdso_enabled),
1596 .proc_handler = proc_dointvec,
1600 #ifdef CONFIG_HIGHMEM
1602 .procname = "highmem_is_dirtyable",
1603 .data = &vm_highmem_is_dirtyable,
1604 .maxlen = sizeof(vm_highmem_is_dirtyable),
1606 .proc_handler = proc_dointvec_minmax,
1611 #ifdef CONFIG_MEMORY_FAILURE
1613 .procname = "memory_failure_early_kill",
1614 .data = &sysctl_memory_failure_early_kill,
1615 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1617 .proc_handler = proc_dointvec_minmax,
1622 .procname = "memory_failure_recovery",
1623 .data = &sysctl_memory_failure_recovery,
1624 .maxlen = sizeof(sysctl_memory_failure_recovery),
1626 .proc_handler = proc_dointvec_minmax,
1632 .procname = "user_reserve_kbytes",
1633 .data = &sysctl_user_reserve_kbytes,
1634 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1636 .proc_handler = proc_doulongvec_minmax,
1639 .procname = "admin_reserve_kbytes",
1640 .data = &sysctl_admin_reserve_kbytes,
1641 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1643 .proc_handler = proc_doulongvec_minmax,
1645 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1647 .procname = "mmap_rnd_bits",
1648 .data = &mmap_rnd_bits,
1649 .maxlen = sizeof(mmap_rnd_bits),
1651 .proc_handler = proc_dointvec_minmax,
1652 .extra1 = (void *)&mmap_rnd_bits_min,
1653 .extra2 = (void *)&mmap_rnd_bits_max,
1656 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1658 .procname = "mmap_rnd_compat_bits",
1659 .data = &mmap_rnd_compat_bits,
1660 .maxlen = sizeof(mmap_rnd_compat_bits),
1662 .proc_handler = proc_dointvec_minmax,
1663 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1664 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1670 static struct ctl_table fs_table[] = {
1672 .procname = "inode-nr",
1673 .data = &inodes_stat,
1674 .maxlen = 2*sizeof(long),
1676 .proc_handler = proc_nr_inodes,
1679 .procname = "inode-state",
1680 .data = &inodes_stat,
1681 .maxlen = 7*sizeof(long),
1683 .proc_handler = proc_nr_inodes,
1686 .procname = "file-nr",
1687 .data = &files_stat,
1688 .maxlen = sizeof(files_stat),
1690 .proc_handler = proc_nr_files,
1693 .procname = "file-max",
1694 .data = &files_stat.max_files,
1695 .maxlen = sizeof(files_stat.max_files),
1697 .proc_handler = proc_doulongvec_minmax,
1700 .procname = "nr_open",
1701 .data = &sysctl_nr_open,
1702 .maxlen = sizeof(unsigned int),
1704 .proc_handler = proc_dointvec_minmax,
1705 .extra1 = &sysctl_nr_open_min,
1706 .extra2 = &sysctl_nr_open_max,
1709 .procname = "dentry-state",
1710 .data = &dentry_stat,
1711 .maxlen = 6*sizeof(long),
1713 .proc_handler = proc_nr_dentry,
1716 .procname = "overflowuid",
1717 .data = &fs_overflowuid,
1718 .maxlen = sizeof(int),
1720 .proc_handler = proc_dointvec_minmax,
1721 .extra1 = &minolduid,
1722 .extra2 = &maxolduid,
1725 .procname = "overflowgid",
1726 .data = &fs_overflowgid,
1727 .maxlen = sizeof(int),
1729 .proc_handler = proc_dointvec_minmax,
1730 .extra1 = &minolduid,
1731 .extra2 = &maxolduid,
1733 #ifdef CONFIG_FILE_LOCKING
1735 .procname = "leases-enable",
1736 .data = &leases_enable,
1737 .maxlen = sizeof(int),
1739 .proc_handler = proc_dointvec,
1742 #ifdef CONFIG_DNOTIFY
1744 .procname = "dir-notify-enable",
1745 .data = &dir_notify_enable,
1746 .maxlen = sizeof(int),
1748 .proc_handler = proc_dointvec,
1752 #ifdef CONFIG_FILE_LOCKING
1754 .procname = "lease-break-time",
1755 .data = &lease_break_time,
1756 .maxlen = sizeof(int),
1758 .proc_handler = proc_dointvec,
1763 .procname = "aio-nr",
1765 .maxlen = sizeof(aio_nr),
1767 .proc_handler = proc_doulongvec_minmax,
1770 .procname = "aio-max-nr",
1771 .data = &aio_max_nr,
1772 .maxlen = sizeof(aio_max_nr),
1774 .proc_handler = proc_doulongvec_minmax,
1776 #endif /* CONFIG_AIO */
1777 #ifdef CONFIG_INOTIFY_USER
1779 .procname = "inotify",
1781 .child = inotify_table,
1786 .procname = "epoll",
1788 .child = epoll_table,
1793 .procname = "protected_symlinks",
1794 .data = &sysctl_protected_symlinks,
1795 .maxlen = sizeof(int),
1797 .proc_handler = proc_dointvec_minmax,
1802 .procname = "protected_hardlinks",
1803 .data = &sysctl_protected_hardlinks,
1804 .maxlen = sizeof(int),
1806 .proc_handler = proc_dointvec_minmax,
1811 .procname = "protected_fifos",
1812 .data = &sysctl_protected_fifos,
1813 .maxlen = sizeof(int),
1815 .proc_handler = proc_dointvec_minmax,
1820 .procname = "protected_regular",
1821 .data = &sysctl_protected_regular,
1822 .maxlen = sizeof(int),
1824 .proc_handler = proc_dointvec_minmax,
1829 .procname = "suid_dumpable",
1830 .data = &suid_dumpable,
1831 .maxlen = sizeof(int),
1833 .proc_handler = proc_dointvec_minmax_coredump,
1837 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1839 .procname = "binfmt_misc",
1841 .child = sysctl_mount_point,
1845 .procname = "pipe-max-size",
1846 .data = &pipe_max_size,
1847 .maxlen = sizeof(pipe_max_size),
1849 .proc_handler = proc_dopipe_max_size,
1852 .procname = "pipe-user-pages-hard",
1853 .data = &pipe_user_pages_hard,
1854 .maxlen = sizeof(pipe_user_pages_hard),
1856 .proc_handler = proc_doulongvec_minmax,
1859 .procname = "pipe-user-pages-soft",
1860 .data = &pipe_user_pages_soft,
1861 .maxlen = sizeof(pipe_user_pages_soft),
1863 .proc_handler = proc_doulongvec_minmax,
1866 .procname = "mount-max",
1867 .data = &sysctl_mount_max,
1868 .maxlen = sizeof(unsigned int),
1870 .proc_handler = proc_dointvec_minmax,
1876 static struct ctl_table debug_table[] = {
1877 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1879 .procname = "exception-trace",
1880 .data = &show_unhandled_signals,
1881 .maxlen = sizeof(int),
1883 .proc_handler = proc_dointvec
1886 #if defined(CONFIG_OPTPROBES)
1888 .procname = "kprobes-optimization",
1889 .data = &sysctl_kprobes_optimization,
1890 .maxlen = sizeof(int),
1892 .proc_handler = proc_kprobes_optimization_handler,
1900 static struct ctl_table dev_table[] = {
1904 int __init sysctl_init(void)
1906 struct ctl_table_header *hdr;
1908 hdr = register_sysctl_table(sysctl_base_table);
1909 kmemleak_not_leak(hdr);
1913 #endif /* CONFIG_SYSCTL */
1919 #ifdef CONFIG_PROC_SYSCTL
1921 static int _proc_do_string(char *data, int maxlen, int write,
1922 char __user *buffer,
1923 size_t *lenp, loff_t *ppos)
1929 if (!data || !maxlen || !*lenp) {
1935 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1936 /* Only continue writes not past the end of buffer. */
1938 if (len > maxlen - 1)
1945 /* Start writing from beginning of buffer. */
1951 while ((p - buffer) < *lenp && len < maxlen - 1) {
1952 if (get_user(c, p++))
1954 if (c == 0 || c == '\n')
1975 if (copy_to_user(buffer, data, len))
1978 if (put_user('\n', buffer + len))
1988 static void warn_sysctl_write(struct ctl_table *table)
1990 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1991 "This will not be supported in the future. To silence this\n"
1992 "warning, set kernel.sysctl_writes_strict = -1\n",
1993 current->comm, table->procname);
1997 * proc_first_pos_non_zero_ignore - check if first position is allowed
1998 * @ppos: file position
1999 * @table: the sysctl table
2001 * Returns true if the first position is non-zero and the sysctl_writes_strict
2002 * mode indicates this is not allowed for numeric input types. String proc
2003 * handlers can ignore the return value.
2005 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
2006 struct ctl_table *table)
2011 switch (sysctl_writes_strict) {
2012 case SYSCTL_WRITES_STRICT:
2014 case SYSCTL_WRITES_WARN:
2015 warn_sysctl_write(table);
2023 * proc_dostring - read a string sysctl
2024 * @table: the sysctl table
2025 * @write: %TRUE if this is a write to the sysctl file
2026 * @buffer: the user buffer
2027 * @lenp: the size of the user buffer
2028 * @ppos: file position
2030 * Reads/writes a string from/to the user buffer. If the kernel
2031 * buffer provided is not large enough to hold the string, the
2032 * string is truncated. The copied string is %NULL-terminated.
2033 * If the string is being read by the user process, it is copied
2034 * and a newline '\n' is added. It is truncated if the buffer is
2037 * Returns 0 on success.
2039 int proc_dostring(struct ctl_table *table, int write,
2040 void __user *buffer, size_t *lenp, loff_t *ppos)
2043 proc_first_pos_non_zero_ignore(ppos, table);
2045 return _proc_do_string((char *)(table->data), table->maxlen, write,
2046 (char __user *)buffer, lenp, ppos);
2049 static size_t proc_skip_spaces(char **buf)
2052 char *tmp = skip_spaces(*buf);
2058 static void proc_skip_char(char **buf, size_t *size, const char v)
2068 #define TMPBUFLEN 22
2070 * proc_get_long - reads an ASCII formatted integer from a user buffer
2072 * @buf: a kernel buffer
2073 * @size: size of the kernel buffer
2074 * @val: this is where the number will be stored
2075 * @neg: set to %TRUE if number is negative
2076 * @perm_tr: a vector which contains the allowed trailers
2077 * @perm_tr_len: size of the perm_tr vector
2078 * @tr: pointer to store the trailer character
2080 * In case of success %0 is returned and @buf and @size are updated with
2081 * the amount of bytes read. If @tr is non-NULL and a trailing
2082 * character exists (size is non-zero after returning from this
2083 * function), @tr is updated with the trailing character.
2085 static int proc_get_long(char **buf, size_t *size,
2086 unsigned long *val, bool *neg,
2087 const char *perm_tr, unsigned perm_tr_len, char *tr)
2090 char *p, tmp[TMPBUFLEN];
2096 if (len > TMPBUFLEN - 1)
2097 len = TMPBUFLEN - 1;
2099 memcpy(tmp, *buf, len);
2103 if (*p == '-' && *size > 1) {
2111 *val = simple_strtoul(p, &p, 0);
2115 /* We don't know if the next char is whitespace thus we may accept
2116 * invalid integers (e.g. 1234...a) or two integers instead of one
2117 * (e.g. 123...1). So lets not allow such large numbers. */
2118 if (len == TMPBUFLEN - 1)
2121 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2124 if (tr && (len < *size))
2134 * proc_put_long - converts an integer to a decimal ASCII formatted string
2136 * @buf: the user buffer
2137 * @size: the size of the user buffer
2138 * @val: the integer to be converted
2139 * @neg: sign of the number, %TRUE for negative
2141 * In case of success %0 is returned and @buf and @size are updated with
2142 * the amount of bytes written.
2144 static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2148 char tmp[TMPBUFLEN], *p = tmp;
2150 sprintf(p, "%s%lu", neg ? "-" : "", val);
2154 if (copy_to_user(*buf, tmp, len))
2162 static int proc_put_char(void __user **buf, size_t *size, char c)
2165 char __user **buffer = (char __user **)buf;
2166 if (put_user(c, *buffer))
2168 (*size)--, (*buffer)++;
2174 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
2176 int write, void *data)
2180 if (*lvalp > (unsigned long) INT_MAX + 1)
2184 if (*lvalp > (unsigned long) INT_MAX)
2192 *lvalp = -(unsigned long)val;
2195 *lvalp = (unsigned long)val;
2201 static int do_proc_douintvec_conv(unsigned long *lvalp,
2203 int write, void *data)
2206 if (*lvalp > UINT_MAX)
2210 unsigned int val = *valp;
2211 *lvalp = (unsigned long)val;
2216 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2218 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
2219 int write, void __user *buffer,
2220 size_t *lenp, loff_t *ppos,
2221 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2222 int write, void *data),
2225 int *i, vleft, first = 1, err = 0;
2227 char *kbuf = NULL, *p;
2229 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2234 i = (int *) tbl_data;
2235 vleft = table->maxlen / sizeof(*i);
2239 conv = do_proc_dointvec_conv;
2242 if (proc_first_pos_non_zero_ignore(ppos, table))
2245 if (left > PAGE_SIZE - 1)
2246 left = PAGE_SIZE - 1;
2247 p = kbuf = memdup_user_nul(buffer, left);
2249 return PTR_ERR(kbuf);
2252 for (; left && vleft--; i++, first=0) {
2257 left -= proc_skip_spaces(&p);
2261 err = proc_get_long(&p, &left, &lval, &neg,
2263 sizeof(proc_wspace_sep), NULL);
2266 if (conv(&neg, &lval, i, 1, data)) {
2271 if (conv(&neg, &lval, i, 0, data)) {
2276 err = proc_put_char(&buffer, &left, '\t');
2279 err = proc_put_long(&buffer, &left, lval, neg);
2285 if (!write && !first && left && !err)
2286 err = proc_put_char(&buffer, &left, '\n');
2287 if (write && !err && left)
2288 left -= proc_skip_spaces(&p);
2292 return err ? : -EINVAL;
2300 static int do_proc_dointvec(struct ctl_table *table, int write,
2301 void __user *buffer, size_t *lenp, loff_t *ppos,
2302 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2303 int write, void *data),
2306 return __do_proc_dointvec(table->data, table, write,
2307 buffer, lenp, ppos, conv, data);
2310 static int do_proc_douintvec_w(unsigned int *tbl_data,
2311 struct ctl_table *table,
2312 void __user *buffer,
2313 size_t *lenp, loff_t *ppos,
2314 int (*conv)(unsigned long *lvalp,
2316 int write, void *data),
2323 char *kbuf = NULL, *p;
2327 if (proc_first_pos_non_zero_ignore(ppos, table))
2330 if (left > PAGE_SIZE - 1)
2331 left = PAGE_SIZE - 1;
2333 p = kbuf = memdup_user_nul(buffer, left);
2337 left -= proc_skip_spaces(&p);
2343 err = proc_get_long(&p, &left, &lval, &neg,
2345 sizeof(proc_wspace_sep), NULL);
2351 if (conv(&lval, tbl_data, 1, data)) {
2357 left -= proc_skip_spaces(&p);
2366 /* This is in keeping with old __do_proc_dointvec() */
2372 static int do_proc_douintvec_r(unsigned int *tbl_data, void __user *buffer,
2373 size_t *lenp, loff_t *ppos,
2374 int (*conv)(unsigned long *lvalp,
2376 int write, void *data),
2385 if (conv(&lval, tbl_data, 0, data)) {
2390 err = proc_put_long(&buffer, &left, lval, false);
2394 err = proc_put_char(&buffer, &left, '\n');
2403 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
2404 int write, void __user *buffer,
2405 size_t *lenp, loff_t *ppos,
2406 int (*conv)(unsigned long *lvalp,
2408 int write, void *data),
2411 unsigned int *i, vleft;
2413 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2418 i = (unsigned int *) tbl_data;
2419 vleft = table->maxlen / sizeof(*i);
2422 * Arrays are not supported, keep this simple. *Do not* add
2431 conv = do_proc_douintvec_conv;
2434 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
2436 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
2439 static int do_proc_douintvec(struct ctl_table *table, int write,
2440 void __user *buffer, size_t *lenp, loff_t *ppos,
2441 int (*conv)(unsigned long *lvalp,
2443 int write, void *data),
2446 return __do_proc_douintvec(table->data, table, write,
2447 buffer, lenp, ppos, conv, data);
2451 * proc_dointvec - read a vector of integers
2452 * @table: the sysctl table
2453 * @write: %TRUE if this is a write to the sysctl file
2454 * @buffer: the user buffer
2455 * @lenp: the size of the user buffer
2456 * @ppos: file position
2458 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2459 * values from/to the user buffer, treated as an ASCII string.
2461 * Returns 0 on success.
2463 int proc_dointvec(struct ctl_table *table, int write,
2464 void __user *buffer, size_t *lenp, loff_t *ppos)
2466 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2470 * proc_douintvec - read a vector of unsigned integers
2471 * @table: the sysctl table
2472 * @write: %TRUE if this is a write to the sysctl file
2473 * @buffer: the user buffer
2474 * @lenp: the size of the user buffer
2475 * @ppos: file position
2477 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2478 * values from/to the user buffer, treated as an ASCII string.
2480 * Returns 0 on success.
2482 int proc_douintvec(struct ctl_table *table, int write,
2483 void __user *buffer, size_t *lenp, loff_t *ppos)
2485 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2486 do_proc_douintvec_conv, NULL);
2490 * Taint values can only be increased
2491 * This means we can safely use a temporary.
2493 static int proc_taint(struct ctl_table *table, int write,
2494 void __user *buffer, size_t *lenp, loff_t *ppos)
2497 unsigned long tmptaint = get_taint();
2500 if (write && !capable(CAP_SYS_ADMIN))
2505 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
2511 * Poor man's atomic or. Not worth adding a primitive
2512 * to everyone's atomic.h for this
2515 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2516 if ((tmptaint >> i) & 1)
2517 add_taint(i, LOCKDEP_STILL_OK);
2524 #ifdef CONFIG_PRINTK
2525 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
2526 void __user *buffer, size_t *lenp, loff_t *ppos)
2528 if (write && !capable(CAP_SYS_ADMIN))
2531 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2536 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
2537 * @min: pointer to minimum allowable value
2538 * @max: pointer to maximum allowable value
2540 * The do_proc_dointvec_minmax_conv_param structure provides the
2541 * minimum and maximum values for doing range checking for those sysctl
2542 * parameters that use the proc_dointvec_minmax() handler.
2544 struct do_proc_dointvec_minmax_conv_param {
2549 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2551 int write, void *data)
2553 struct do_proc_dointvec_minmax_conv_param *param = data;
2555 int val = *negp ? -*lvalp : *lvalp;
2556 if ((param->min && *param->min > val) ||
2557 (param->max && *param->max < val))
2564 *lvalp = -(unsigned long)val;
2567 *lvalp = (unsigned long)val;
2574 * proc_dointvec_minmax - read a vector of integers with min/max values
2575 * @table: the sysctl table
2576 * @write: %TRUE if this is a write to the sysctl file
2577 * @buffer: the user buffer
2578 * @lenp: the size of the user buffer
2579 * @ppos: file position
2581 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2582 * values from/to the user buffer, treated as an ASCII string.
2584 * This routine will ensure the values are within the range specified by
2585 * table->extra1 (min) and table->extra2 (max).
2587 * Returns 0 on success or -EINVAL on write when the range check fails.
2589 int proc_dointvec_minmax(struct ctl_table *table, int write,
2590 void __user *buffer, size_t *lenp, loff_t *ppos)
2592 struct do_proc_dointvec_minmax_conv_param param = {
2593 .min = (int *) table->extra1,
2594 .max = (int *) table->extra2,
2596 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2597 do_proc_dointvec_minmax_conv, ¶m);
2601 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
2602 * @min: pointer to minimum allowable value
2603 * @max: pointer to maximum allowable value
2605 * The do_proc_douintvec_minmax_conv_param structure provides the
2606 * minimum and maximum values for doing range checking for those sysctl
2607 * parameters that use the proc_douintvec_minmax() handler.
2609 struct do_proc_douintvec_minmax_conv_param {
2614 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
2616 int write, void *data)
2618 struct do_proc_douintvec_minmax_conv_param *param = data;
2621 unsigned int val = *lvalp;
2623 if (*lvalp > UINT_MAX)
2626 if ((param->min && *param->min > val) ||
2627 (param->max && *param->max < val))
2632 unsigned int val = *valp;
2633 *lvalp = (unsigned long) val;
2640 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2641 * @table: the sysctl table
2642 * @write: %TRUE if this is a write to the sysctl file
2643 * @buffer: the user buffer
2644 * @lenp: the size of the user buffer
2645 * @ppos: file position
2647 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2648 * values from/to the user buffer, treated as an ASCII string. Negative
2649 * strings are not allowed.
2651 * This routine will ensure the values are within the range specified by
2652 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2653 * check for UINT_MAX to avoid having to support wrap around uses from
2656 * Returns 0 on success or -ERANGE on write when the range check fails.
2658 int proc_douintvec_minmax(struct ctl_table *table, int write,
2659 void __user *buffer, size_t *lenp, loff_t *ppos)
2661 struct do_proc_douintvec_minmax_conv_param param = {
2662 .min = (unsigned int *) table->extra1,
2663 .max = (unsigned int *) table->extra2,
2665 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2666 do_proc_douintvec_minmax_conv, ¶m);
2669 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
2671 int write, void *data)
2676 val = round_pipe_size(*lvalp);
2682 unsigned int val = *valp;
2683 *lvalp = (unsigned long) val;
2689 static int proc_dopipe_max_size(struct ctl_table *table, int write,
2690 void __user *buffer, size_t *lenp, loff_t *ppos)
2692 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2693 do_proc_dopipe_max_size_conv, NULL);
2696 static void validate_coredump_safety(void)
2698 #ifdef CONFIG_COREDUMP
2699 if (suid_dumpable == SUID_DUMP_ROOT &&
2700 core_pattern[0] != '/' && core_pattern[0] != '|') {
2702 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2703 "Pipe handler or fully qualified core dump path required.\n"
2704 "Set kernel.core_pattern before fs.suid_dumpable.\n"
2710 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2711 void __user *buffer, size_t *lenp, loff_t *ppos)
2713 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2715 validate_coredump_safety();
2719 #ifdef CONFIG_COREDUMP
2720 static int proc_dostring_coredump(struct ctl_table *table, int write,
2721 void __user *buffer, size_t *lenp, loff_t *ppos)
2723 int error = proc_dostring(table, write, buffer, lenp, ppos);
2725 validate_coredump_safety();
2730 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
2731 void __user *buffer,
2732 size_t *lenp, loff_t *ppos,
2733 unsigned long convmul,
2734 unsigned long convdiv)
2736 unsigned long *i, *min, *max;
2737 int vleft, first = 1, err = 0;
2739 char *kbuf = NULL, *p;
2741 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
2746 i = (unsigned long *) data;
2747 min = (unsigned long *) table->extra1;
2748 max = (unsigned long *) table->extra2;
2749 vleft = table->maxlen / sizeof(unsigned long);
2753 if (proc_first_pos_non_zero_ignore(ppos, table))
2756 if (left > PAGE_SIZE - 1)
2757 left = PAGE_SIZE - 1;
2758 p = kbuf = memdup_user_nul(buffer, left);
2760 return PTR_ERR(kbuf);
2763 for (; left && vleft--; i++, first = 0) {
2769 left -= proc_skip_spaces(&p);
2771 err = proc_get_long(&p, &left, &val, &neg,
2773 sizeof(proc_wspace_sep), NULL);
2778 val = convmul * val / convdiv;
2779 if ((min && val < *min) || (max && val > *max))
2783 val = convdiv * (*i) / convmul;
2785 err = proc_put_char(&buffer, &left, '\t');
2789 err = proc_put_long(&buffer, &left, val, false);
2795 if (!write && !first && left && !err)
2796 err = proc_put_char(&buffer, &left, '\n');
2798 left -= proc_skip_spaces(&p);
2802 return err ? : -EINVAL;
2810 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2811 void __user *buffer,
2812 size_t *lenp, loff_t *ppos,
2813 unsigned long convmul,
2814 unsigned long convdiv)
2816 return __do_proc_doulongvec_minmax(table->data, table, write,
2817 buffer, lenp, ppos, convmul, convdiv);
2821 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2822 * @table: the sysctl table
2823 * @write: %TRUE if this is a write to the sysctl file
2824 * @buffer: the user buffer
2825 * @lenp: the size of the user buffer
2826 * @ppos: file position
2828 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2829 * values from/to the user buffer, treated as an ASCII string.
2831 * This routine will ensure the values are within the range specified by
2832 * table->extra1 (min) and table->extra2 (max).
2834 * Returns 0 on success.
2836 int proc_doulongvec_minmax(struct ctl_table *table, int write,
2837 void __user *buffer, size_t *lenp, loff_t *ppos)
2839 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
2843 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2844 * @table: the sysctl table
2845 * @write: %TRUE if this is a write to the sysctl file
2846 * @buffer: the user buffer
2847 * @lenp: the size of the user buffer
2848 * @ppos: file position
2850 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2851 * values from/to the user buffer, treated as an ASCII string. The values
2852 * are treated as milliseconds, and converted to jiffies when they are stored.
2854 * This routine will ensure the values are within the range specified by
2855 * table->extra1 (min) and table->extra2 (max).
2857 * Returns 0 on success.
2859 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2860 void __user *buffer,
2861 size_t *lenp, loff_t *ppos)
2863 return do_proc_doulongvec_minmax(table, write, buffer,
2864 lenp, ppos, HZ, 1000l);
2868 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
2870 int write, void *data)
2873 if (*lvalp > INT_MAX / HZ)
2875 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2881 lval = -(unsigned long)val;
2884 lval = (unsigned long)val;
2891 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
2893 int write, void *data)
2896 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2898 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2904 lval = -(unsigned long)val;
2907 lval = (unsigned long)val;
2909 *lvalp = jiffies_to_clock_t(lval);
2914 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
2916 int write, void *data)
2919 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2929 lval = -(unsigned long)val;
2932 lval = (unsigned long)val;
2934 *lvalp = jiffies_to_msecs(lval);
2940 * proc_dointvec_jiffies - read a vector of integers as seconds
2941 * @table: the sysctl table
2942 * @write: %TRUE if this is a write to the sysctl file
2943 * @buffer: the user buffer
2944 * @lenp: the size of the user buffer
2945 * @ppos: file position
2947 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2948 * values from/to the user buffer, treated as an ASCII string.
2949 * The values read are assumed to be in seconds, and are converted into
2952 * Returns 0 on success.
2954 int proc_dointvec_jiffies(struct ctl_table *table, int write,
2955 void __user *buffer, size_t *lenp, loff_t *ppos)
2957 return do_proc_dointvec(table,write,buffer,lenp,ppos,
2958 do_proc_dointvec_jiffies_conv,NULL);
2962 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2963 * @table: the sysctl table
2964 * @write: %TRUE if this is a write to the sysctl file
2965 * @buffer: the user buffer
2966 * @lenp: the size of the user buffer
2967 * @ppos: pointer to the file position
2969 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2970 * values from/to the user buffer, treated as an ASCII string.
2971 * The values read are assumed to be in 1/USER_HZ seconds, and
2972 * are converted into jiffies.
2974 * Returns 0 on success.
2976 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
2977 void __user *buffer, size_t *lenp, loff_t *ppos)
2979 return do_proc_dointvec(table,write,buffer,lenp,ppos,
2980 do_proc_dointvec_userhz_jiffies_conv,NULL);
2984 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2985 * @table: the sysctl table
2986 * @write: %TRUE if this is a write to the sysctl file
2987 * @buffer: the user buffer
2988 * @lenp: the size of the user buffer
2989 * @ppos: file position
2990 * @ppos: the current position in the file
2992 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2993 * values from/to the user buffer, treated as an ASCII string.
2994 * The values read are assumed to be in 1/1000 seconds, and
2995 * are converted into jiffies.
2997 * Returns 0 on success.
2999 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
3000 void __user *buffer, size_t *lenp, loff_t *ppos)
3002 return do_proc_dointvec(table, write, buffer, lenp, ppos,
3003 do_proc_dointvec_ms_jiffies_conv, NULL);
3006 static int proc_do_cad_pid(struct ctl_table *table, int write,
3007 void __user *buffer, size_t *lenp, loff_t *ppos)
3009 struct pid *new_pid;
3013 tmp = pid_vnr(cad_pid);
3015 r = __do_proc_dointvec(&tmp, table, write, buffer,
3016 lenp, ppos, NULL, NULL);
3020 new_pid = find_get_pid(tmp);
3024 put_pid(xchg(&cad_pid, new_pid));
3029 * proc_do_large_bitmap - read/write from/to a large bitmap
3030 * @table: the sysctl table
3031 * @write: %TRUE if this is a write to the sysctl file
3032 * @buffer: the user buffer
3033 * @lenp: the size of the user buffer
3034 * @ppos: file position
3036 * The bitmap is stored at table->data and the bitmap length (in bits)
3039 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
3040 * large bitmaps may be represented in a compact manner. Writing into
3041 * the file will clear the bitmap then update it with the given input.
3043 * Returns 0 on success.
3045 int proc_do_large_bitmap(struct ctl_table *table, int write,
3046 void __user *buffer, size_t *lenp, loff_t *ppos)
3050 size_t left = *lenp;
3051 unsigned long bitmap_len = table->maxlen;
3052 unsigned long *bitmap = *(unsigned long **) table->data;
3053 unsigned long *tmp_bitmap = NULL;
3054 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
3056 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
3064 if (left > PAGE_SIZE - 1)
3065 left = PAGE_SIZE - 1;
3067 p = kbuf = memdup_user_nul(buffer, left);
3069 return PTR_ERR(kbuf);
3071 tmp_bitmap = kcalloc(BITS_TO_LONGS(bitmap_len),
3072 sizeof(unsigned long),
3078 proc_skip_char(&p, &left, '\n');
3079 while (!err && left) {
3080 unsigned long val_a, val_b;
3083 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
3087 if (val_a >= bitmap_len || neg) {
3099 err = proc_get_long(&p, &left, &val_b,
3100 &neg, tr_b, sizeof(tr_b),
3104 if (val_b >= bitmap_len || neg ||
3115 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
3117 proc_skip_char(&p, &left, '\n');
3121 unsigned long bit_a, bit_b = 0;
3124 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3125 if (bit_a >= bitmap_len)
3127 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3131 err = proc_put_char(&buffer, &left, ',');
3135 err = proc_put_long(&buffer, &left, bit_a, false);
3138 if (bit_a != bit_b) {
3139 err = proc_put_char(&buffer, &left, '-');
3142 err = proc_put_long(&buffer, &left, bit_b, false);
3150 err = proc_put_char(&buffer, &left, '\n');
3156 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3158 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
3168 #else /* CONFIG_PROC_SYSCTL */
3170 int proc_dostring(struct ctl_table *table, int write,
3171 void __user *buffer, size_t *lenp, loff_t *ppos)
3176 int proc_dointvec(struct ctl_table *table, int write,
3177 void __user *buffer, size_t *lenp, loff_t *ppos)
3182 int proc_douintvec(struct ctl_table *table, int write,
3183 void __user *buffer, size_t *lenp, loff_t *ppos)
3188 int proc_dointvec_minmax(struct ctl_table *table, int write,
3189 void __user *buffer, size_t *lenp, loff_t *ppos)
3194 int proc_douintvec_minmax(struct ctl_table *table, int write,
3195 void __user *buffer, size_t *lenp, loff_t *ppos)
3200 int proc_dointvec_jiffies(struct ctl_table *table, int write,
3201 void __user *buffer, size_t *lenp, loff_t *ppos)
3206 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
3207 void __user *buffer, size_t *lenp, loff_t *ppos)
3212 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
3213 void __user *buffer, size_t *lenp, loff_t *ppos)
3218 int proc_doulongvec_minmax(struct ctl_table *table, int write,
3219 void __user *buffer, size_t *lenp, loff_t *ppos)
3224 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
3225 void __user *buffer,
3226 size_t *lenp, loff_t *ppos)
3232 #endif /* CONFIG_PROC_SYSCTL */
3235 * No sense putting this after each symbol definition, twice,
3236 * exception granted :-)
3238 EXPORT_SYMBOL(proc_dointvec);
3239 EXPORT_SYMBOL(proc_douintvec);
3240 EXPORT_SYMBOL(proc_dointvec_jiffies);
3241 EXPORT_SYMBOL(proc_dointvec_minmax);
3242 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3243 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3244 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3245 EXPORT_SYMBOL(proc_dostring);
3246 EXPORT_SYMBOL(proc_doulongvec_minmax);
3247 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);