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>
70 #include <linux/uaccess.h>
71 #include <asm/processor.h>
75 #include <asm/stacktrace.h>
79 #include <asm/setup.h>
81 #ifdef CONFIG_BSD_PROCESS_ACCT
82 #include <linux/acct.h>
84 #ifdef CONFIG_RT_MUTEXES
85 #include <linux/rtmutex.h>
87 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
88 #include <linux/lockdep.h>
90 #ifdef CONFIG_CHR_DEV_SG
94 #ifdef CONFIG_LOCKUP_DETECTOR
95 #include <linux/nmi.h>
98 #if defined(CONFIG_SYSCTL)
100 /* External variables not in a header file. */
101 extern int suid_dumpable;
102 #ifdef CONFIG_COREDUMP
103 extern int core_uses_pid;
104 extern char core_pattern[];
105 extern unsigned int core_pipe_limit;
108 extern int pid_max_min, pid_max_max;
109 extern int percpu_pagelist_fraction;
110 extern int latencytop_enabled;
111 extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
113 extern int sysctl_nr_trim_pages;
116 /* Constants used for minimum and maximum */
117 #ifdef CONFIG_LOCKUP_DETECTOR
118 static int sixty = 60;
121 static int __maybe_unused neg_one = -1;
124 static int __maybe_unused one = 1;
125 static int __maybe_unused two = 2;
126 static int __maybe_unused four = 4;
127 static unsigned long zero_ul;
128 static unsigned long one_ul = 1;
129 static unsigned long long_max = LONG_MAX;
130 static int one_hundred = 100;
131 static int one_thousand = 1000;
133 static int ten_thousand = 10000;
135 #ifdef CONFIG_PERF_EVENTS
136 static int six_hundred_forty_kb = 640 * 1024;
139 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
140 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
142 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
143 static int maxolduid = 65535;
144 static int minolduid;
146 static int ngroups_max = NGROUPS_MAX;
147 static const int cap_last_cap = CAP_LAST_CAP;
149 /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
150 #ifdef CONFIG_DETECT_HUNG_TASK
151 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
154 #ifdef CONFIG_INOTIFY_USER
155 #include <linux/inotify.h>
161 extern int pwrsw_enabled;
164 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
165 extern int unaligned_enabled;
169 extern int unaligned_dump_stack;
172 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
173 extern int no_unaligned_warning;
176 #ifdef CONFIG_PROC_SYSCTL
179 * enum sysctl_writes_mode - supported sysctl write modes
181 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
182 * to be written, and multiple writes on the same sysctl file descriptor
183 * will rewrite the sysctl value, regardless of file position. No warning
184 * is issued when the initial position is not 0.
185 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
187 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
188 * file position 0 and the value must be fully contained in the buffer
189 * sent to the write syscall. If dealing with strings respect the file
190 * position, but restrict this to the max length of the buffer, anything
191 * passed the max lenght will be ignored. Multiple writes will append
194 * These write modes control how current file position affects the behavior of
195 * updating sysctl values through the proc interface on each write.
197 enum sysctl_writes_mode {
198 SYSCTL_WRITES_LEGACY = -1,
199 SYSCTL_WRITES_WARN = 0,
200 SYSCTL_WRITES_STRICT = 1,
203 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
205 static int proc_do_cad_pid(struct ctl_table *table, int write,
206 void __user *buffer, size_t *lenp, loff_t *ppos);
207 static int proc_taint(struct ctl_table *table, int write,
208 void __user *buffer, size_t *lenp, loff_t *ppos);
212 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
213 void __user *buffer, size_t *lenp, loff_t *ppos);
216 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
217 void __user *buffer, size_t *lenp, loff_t *ppos);
218 #ifdef CONFIG_COREDUMP
219 static int proc_dostring_coredump(struct ctl_table *table, int write,
220 void __user *buffer, size_t *lenp, loff_t *ppos);
223 #ifdef CONFIG_MAGIC_SYSRQ
224 /* Note: sysrq code uses it's own private copy */
225 static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
227 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
228 void __user *buffer, size_t *lenp,
233 error = proc_dointvec(table, write, buffer, lenp, ppos);
238 sysrq_toggle_support(__sysrq_enabled);
245 static struct ctl_table kern_table[];
246 static struct ctl_table vm_table[];
247 static struct ctl_table fs_table[];
248 static struct ctl_table debug_table[];
249 static struct ctl_table dev_table[];
250 extern struct ctl_table random_table[];
252 extern struct ctl_table epoll_table[];
255 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
256 int sysctl_legacy_va_layout;
259 /* The default sysctl tables: */
261 static struct ctl_table sysctl_base_table[] = {
263 .procname = "kernel",
280 .child = debug_table,
290 #ifdef CONFIG_SCHED_DEBUG
291 static int min_sched_granularity_ns = 100000; /* 100 usecs */
292 static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
293 static int min_wakeup_granularity_ns; /* 0 usecs */
294 static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
296 static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
297 static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
298 #endif /* CONFIG_SMP */
299 #endif /* CONFIG_SCHED_DEBUG */
301 #ifdef CONFIG_COMPACTION
302 static int min_extfrag_threshold;
303 static int max_extfrag_threshold = 1000;
306 static struct ctl_table kern_table[] = {
308 .procname = "sched_child_runs_first",
309 .data = &sysctl_sched_child_runs_first,
310 .maxlen = sizeof(unsigned int),
312 .proc_handler = proc_dointvec,
314 #ifdef CONFIG_SCHED_DEBUG
316 .procname = "sched_min_granularity_ns",
317 .data = &sysctl_sched_min_granularity,
318 .maxlen = sizeof(unsigned int),
320 .proc_handler = sched_proc_update_handler,
321 .extra1 = &min_sched_granularity_ns,
322 .extra2 = &max_sched_granularity_ns,
325 .procname = "sched_latency_ns",
326 .data = &sysctl_sched_latency,
327 .maxlen = sizeof(unsigned int),
329 .proc_handler = sched_proc_update_handler,
330 .extra1 = &min_sched_granularity_ns,
331 .extra2 = &max_sched_granularity_ns,
334 .procname = "sched_wakeup_granularity_ns",
335 .data = &sysctl_sched_wakeup_granularity,
336 .maxlen = sizeof(unsigned int),
338 .proc_handler = sched_proc_update_handler,
339 .extra1 = &min_wakeup_granularity_ns,
340 .extra2 = &max_wakeup_granularity_ns,
344 .procname = "sched_tunable_scaling",
345 .data = &sysctl_sched_tunable_scaling,
346 .maxlen = sizeof(enum sched_tunable_scaling),
348 .proc_handler = sched_proc_update_handler,
349 .extra1 = &min_sched_tunable_scaling,
350 .extra2 = &max_sched_tunable_scaling,
353 .procname = "sched_migration_cost_ns",
354 .data = &sysctl_sched_migration_cost,
355 .maxlen = sizeof(unsigned int),
357 .proc_handler = proc_dointvec,
360 .procname = "sched_nr_migrate",
361 .data = &sysctl_sched_nr_migrate,
362 .maxlen = sizeof(unsigned int),
364 .proc_handler = proc_dointvec,
367 .procname = "sched_time_avg_ms",
368 .data = &sysctl_sched_time_avg,
369 .maxlen = sizeof(unsigned int),
371 .proc_handler = proc_dointvec_minmax,
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,
751 .procname = "overflowuid",
752 .data = &overflowuid,
753 .maxlen = sizeof(int),
755 .proc_handler = proc_dointvec_minmax,
756 .extra1 = &minolduid,
757 .extra2 = &maxolduid,
760 .procname = "overflowgid",
761 .data = &overflowgid,
762 .maxlen = sizeof(int),
764 .proc_handler = proc_dointvec_minmax,
765 .extra1 = &minolduid,
766 .extra2 = &maxolduid,
769 #ifdef CONFIG_MATHEMU
771 .procname = "ieee_emulation_warnings",
772 .data = &sysctl_ieee_emulation_warnings,
773 .maxlen = sizeof(int),
775 .proc_handler = proc_dointvec,
779 .procname = "userprocess_debug",
780 .data = &show_unhandled_signals,
781 .maxlen = sizeof(int),
783 .proc_handler = proc_dointvec,
787 .procname = "pid_max",
789 .maxlen = sizeof (int),
791 .proc_handler = proc_dointvec_minmax,
792 .extra1 = &pid_max_min,
793 .extra2 = &pid_max_max,
796 .procname = "panic_on_oops",
797 .data = &panic_on_oops,
798 .maxlen = sizeof(int),
800 .proc_handler = proc_dointvec,
802 #if defined CONFIG_PRINTK
804 .procname = "printk",
805 .data = &console_loglevel,
806 .maxlen = 4*sizeof(int),
808 .proc_handler = proc_dointvec,
811 .procname = "printk_ratelimit",
812 .data = &printk_ratelimit_state.interval,
813 .maxlen = sizeof(int),
815 .proc_handler = proc_dointvec_jiffies,
818 .procname = "printk_ratelimit_burst",
819 .data = &printk_ratelimit_state.burst,
820 .maxlen = sizeof(int),
822 .proc_handler = proc_dointvec,
825 .procname = "printk_delay",
826 .data = &printk_delay_msec,
827 .maxlen = sizeof(int),
829 .proc_handler = proc_dointvec_minmax,
831 .extra2 = &ten_thousand,
834 .procname = "printk_devkmsg",
835 .data = devkmsg_log_str,
836 .maxlen = DEVKMSG_STR_MAX_SIZE,
838 .proc_handler = devkmsg_sysctl_set_loglvl,
841 .procname = "dmesg_restrict",
842 .data = &dmesg_restrict,
843 .maxlen = sizeof(int),
845 .proc_handler = proc_dointvec_minmax_sysadmin,
850 .procname = "kptr_restrict",
851 .data = &kptr_restrict,
852 .maxlen = sizeof(int),
854 .proc_handler = proc_dointvec_minmax_sysadmin,
860 .procname = "ngroups_max",
861 .data = &ngroups_max,
862 .maxlen = sizeof (int),
864 .proc_handler = proc_dointvec,
867 .procname = "cap_last_cap",
868 .data = (void *)&cap_last_cap,
869 .maxlen = sizeof(int),
871 .proc_handler = proc_dointvec,
873 #if defined(CONFIG_LOCKUP_DETECTOR)
875 .procname = "watchdog",
876 .data = &watchdog_user_enabled,
877 .maxlen = sizeof(int),
879 .proc_handler = proc_watchdog,
884 .procname = "watchdog_thresh",
885 .data = &watchdog_thresh,
886 .maxlen = sizeof(int),
888 .proc_handler = proc_watchdog_thresh,
893 .procname = "nmi_watchdog",
894 .data = &nmi_watchdog_user_enabled,
895 .maxlen = sizeof(int),
896 .mode = NMI_WATCHDOG_SYSCTL_PERM,
897 .proc_handler = proc_nmi_watchdog,
902 .procname = "watchdog_cpumask",
903 .data = &watchdog_cpumask_bits,
906 .proc_handler = proc_watchdog_cpumask,
908 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
910 .procname = "soft_watchdog",
911 .data = &soft_watchdog_user_enabled,
912 .maxlen = sizeof(int),
914 .proc_handler = proc_soft_watchdog,
919 .procname = "softlockup_panic",
920 .data = &softlockup_panic,
921 .maxlen = sizeof(int),
923 .proc_handler = proc_dointvec_minmax,
929 .procname = "softlockup_all_cpu_backtrace",
930 .data = &sysctl_softlockup_all_cpu_backtrace,
931 .maxlen = sizeof(int),
933 .proc_handler = proc_dointvec_minmax,
937 #endif /* CONFIG_SMP */
939 #ifdef CONFIG_HARDLOCKUP_DETECTOR
941 .procname = "hardlockup_panic",
942 .data = &hardlockup_panic,
943 .maxlen = sizeof(int),
945 .proc_handler = proc_dointvec_minmax,
951 .procname = "hardlockup_all_cpu_backtrace",
952 .data = &sysctl_hardlockup_all_cpu_backtrace,
953 .maxlen = sizeof(int),
955 .proc_handler = proc_dointvec_minmax,
959 #endif /* CONFIG_SMP */
963 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
965 .procname = "unknown_nmi_panic",
966 .data = &unknown_nmi_panic,
967 .maxlen = sizeof (int),
969 .proc_handler = proc_dointvec,
972 #if defined(CONFIG_X86)
974 .procname = "panic_on_unrecovered_nmi",
975 .data = &panic_on_unrecovered_nmi,
976 .maxlen = sizeof(int),
978 .proc_handler = proc_dointvec,
981 .procname = "panic_on_io_nmi",
982 .data = &panic_on_io_nmi,
983 .maxlen = sizeof(int),
985 .proc_handler = proc_dointvec,
987 #ifdef CONFIG_DEBUG_STACKOVERFLOW
989 .procname = "panic_on_stackoverflow",
990 .data = &sysctl_panic_on_stackoverflow,
991 .maxlen = sizeof(int),
993 .proc_handler = proc_dointvec,
997 .procname = "bootloader_type",
998 .data = &bootloader_type,
999 .maxlen = sizeof (int),
1001 .proc_handler = proc_dointvec,
1004 .procname = "bootloader_version",
1005 .data = &bootloader_version,
1006 .maxlen = sizeof (int),
1008 .proc_handler = proc_dointvec,
1011 .procname = "io_delay_type",
1012 .data = &io_delay_type,
1013 .maxlen = sizeof(int),
1015 .proc_handler = proc_dointvec,
1018 #if defined(CONFIG_MMU)
1020 .procname = "randomize_va_space",
1021 .data = &randomize_va_space,
1022 .maxlen = sizeof(int),
1024 .proc_handler = proc_dointvec,
1027 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1029 .procname = "spin_retry",
1030 .data = &spin_retry,
1031 .maxlen = sizeof (int),
1033 .proc_handler = proc_dointvec,
1036 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1038 .procname = "acpi_video_flags",
1039 .data = &acpi_realmode_flags,
1040 .maxlen = sizeof (unsigned long),
1042 .proc_handler = proc_doulongvec_minmax,
1045 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1047 .procname = "ignore-unaligned-usertrap",
1048 .data = &no_unaligned_warning,
1049 .maxlen = sizeof (int),
1051 .proc_handler = proc_dointvec,
1056 .procname = "unaligned-dump-stack",
1057 .data = &unaligned_dump_stack,
1058 .maxlen = sizeof (int),
1060 .proc_handler = proc_dointvec,
1063 #ifdef CONFIG_DETECT_HUNG_TASK
1065 .procname = "hung_task_panic",
1066 .data = &sysctl_hung_task_panic,
1067 .maxlen = sizeof(int),
1069 .proc_handler = proc_dointvec_minmax,
1074 .procname = "hung_task_check_count",
1075 .data = &sysctl_hung_task_check_count,
1076 .maxlen = sizeof(int),
1078 .proc_handler = proc_dointvec_minmax,
1082 .procname = "hung_task_timeout_secs",
1083 .data = &sysctl_hung_task_timeout_secs,
1084 .maxlen = sizeof(unsigned long),
1086 .proc_handler = proc_dohung_task_timeout_secs,
1087 .extra2 = &hung_task_timeout_max,
1090 .procname = "hung_task_warnings",
1091 .data = &sysctl_hung_task_warnings,
1092 .maxlen = sizeof(int),
1094 .proc_handler = proc_dointvec_minmax,
1098 #ifdef CONFIG_RT_MUTEXES
1100 .procname = "max_lock_depth",
1101 .data = &max_lock_depth,
1102 .maxlen = sizeof(int),
1104 .proc_handler = proc_dointvec,
1108 .procname = "poweroff_cmd",
1109 .data = &poweroff_cmd,
1110 .maxlen = POWEROFF_CMD_PATH_LEN,
1112 .proc_handler = proc_dostring,
1118 .child = key_sysctls,
1121 #ifdef CONFIG_PERF_EVENTS
1123 * User-space scripts rely on the existence of this file
1124 * as a feature check for perf_events being enabled.
1126 * So it's an ABI, do not remove!
1129 .procname = "perf_event_paranoid",
1130 .data = &sysctl_perf_event_paranoid,
1131 .maxlen = sizeof(sysctl_perf_event_paranoid),
1133 .proc_handler = proc_dointvec,
1136 .procname = "perf_event_mlock_kb",
1137 .data = &sysctl_perf_event_mlock,
1138 .maxlen = sizeof(sysctl_perf_event_mlock),
1140 .proc_handler = proc_dointvec,
1143 .procname = "perf_event_max_sample_rate",
1144 .data = &sysctl_perf_event_sample_rate,
1145 .maxlen = sizeof(sysctl_perf_event_sample_rate),
1147 .proc_handler = perf_proc_update_handler,
1151 .procname = "perf_cpu_time_max_percent",
1152 .data = &sysctl_perf_cpu_time_max_percent,
1153 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1155 .proc_handler = perf_cpu_time_max_percent_handler,
1157 .extra2 = &one_hundred,
1160 .procname = "perf_event_max_stack",
1161 .data = &sysctl_perf_event_max_stack,
1162 .maxlen = sizeof(sysctl_perf_event_max_stack),
1164 .proc_handler = perf_event_max_stack_handler,
1166 .extra2 = &six_hundred_forty_kb,
1169 .procname = "perf_event_max_contexts_per_stack",
1170 .data = &sysctl_perf_event_max_contexts_per_stack,
1171 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1173 .proc_handler = perf_event_max_stack_handler,
1175 .extra2 = &one_thousand,
1179 .procname = "panic_on_warn",
1180 .data = &panic_on_warn,
1181 .maxlen = sizeof(int),
1183 .proc_handler = proc_dointvec_minmax,
1187 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1189 .procname = "timer_migration",
1190 .data = &sysctl_timer_migration,
1191 .maxlen = sizeof(unsigned int),
1193 .proc_handler = timer_migration_handler,
1198 #ifdef CONFIG_BPF_SYSCALL
1200 .procname = "unprivileged_bpf_disabled",
1201 .data = &sysctl_unprivileged_bpf_disabled,
1202 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1204 /* only handle a transition from default "0" to "1" */
1205 .proc_handler = proc_dointvec_minmax,
1210 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1212 .procname = "panic_on_rcu_stall",
1213 .data = &sysctl_panic_on_rcu_stall,
1214 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1216 .proc_handler = proc_dointvec_minmax,
1224 static struct ctl_table vm_table[] = {
1226 .procname = "overcommit_memory",
1227 .data = &sysctl_overcommit_memory,
1228 .maxlen = sizeof(sysctl_overcommit_memory),
1230 .proc_handler = proc_dointvec_minmax,
1235 .procname = "panic_on_oom",
1236 .data = &sysctl_panic_on_oom,
1237 .maxlen = sizeof(sysctl_panic_on_oom),
1239 .proc_handler = proc_dointvec_minmax,
1244 .procname = "oom_kill_allocating_task",
1245 .data = &sysctl_oom_kill_allocating_task,
1246 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1248 .proc_handler = proc_dointvec,
1251 .procname = "oom_dump_tasks",
1252 .data = &sysctl_oom_dump_tasks,
1253 .maxlen = sizeof(sysctl_oom_dump_tasks),
1255 .proc_handler = proc_dointvec,
1258 .procname = "overcommit_ratio",
1259 .data = &sysctl_overcommit_ratio,
1260 .maxlen = sizeof(sysctl_overcommit_ratio),
1262 .proc_handler = overcommit_ratio_handler,
1265 .procname = "overcommit_kbytes",
1266 .data = &sysctl_overcommit_kbytes,
1267 .maxlen = sizeof(sysctl_overcommit_kbytes),
1269 .proc_handler = overcommit_kbytes_handler,
1272 .procname = "page-cluster",
1273 .data = &page_cluster,
1274 .maxlen = sizeof(int),
1276 .proc_handler = proc_dointvec_minmax,
1280 .procname = "dirty_background_ratio",
1281 .data = &dirty_background_ratio,
1282 .maxlen = sizeof(dirty_background_ratio),
1284 .proc_handler = dirty_background_ratio_handler,
1286 .extra2 = &one_hundred,
1289 .procname = "dirty_background_bytes",
1290 .data = &dirty_background_bytes,
1291 .maxlen = sizeof(dirty_background_bytes),
1293 .proc_handler = dirty_background_bytes_handler,
1297 .procname = "dirty_ratio",
1298 .data = &vm_dirty_ratio,
1299 .maxlen = sizeof(vm_dirty_ratio),
1301 .proc_handler = dirty_ratio_handler,
1303 .extra2 = &one_hundred,
1306 .procname = "dirty_bytes",
1307 .data = &vm_dirty_bytes,
1308 .maxlen = sizeof(vm_dirty_bytes),
1310 .proc_handler = dirty_bytes_handler,
1311 .extra1 = &dirty_bytes_min,
1314 .procname = "dirty_writeback_centisecs",
1315 .data = &dirty_writeback_interval,
1316 .maxlen = sizeof(dirty_writeback_interval),
1318 .proc_handler = dirty_writeback_centisecs_handler,
1321 .procname = "dirty_expire_centisecs",
1322 .data = &dirty_expire_interval,
1323 .maxlen = sizeof(dirty_expire_interval),
1325 .proc_handler = proc_dointvec_minmax,
1329 .procname = "dirtytime_expire_seconds",
1330 .data = &dirtytime_expire_interval,
1331 .maxlen = sizeof(dirty_expire_interval),
1333 .proc_handler = dirtytime_interval_handler,
1337 .procname = "nr_pdflush_threads",
1338 .mode = 0444 /* read-only */,
1339 .proc_handler = pdflush_proc_obsolete,
1342 .procname = "swappiness",
1343 .data = &vm_swappiness,
1344 .maxlen = sizeof(vm_swappiness),
1346 .proc_handler = proc_dointvec_minmax,
1348 .extra2 = &one_hundred,
1350 #ifdef CONFIG_HUGETLB_PAGE
1352 .procname = "nr_hugepages",
1354 .maxlen = sizeof(unsigned long),
1356 .proc_handler = hugetlb_sysctl_handler,
1360 .procname = "nr_hugepages_mempolicy",
1362 .maxlen = sizeof(unsigned long),
1364 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1368 .procname = "hugetlb_shm_group",
1369 .data = &sysctl_hugetlb_shm_group,
1370 .maxlen = sizeof(gid_t),
1372 .proc_handler = proc_dointvec,
1375 .procname = "hugepages_treat_as_movable",
1376 .data = &hugepages_treat_as_movable,
1377 .maxlen = sizeof(int),
1379 .proc_handler = proc_dointvec,
1382 .procname = "nr_overcommit_hugepages",
1384 .maxlen = sizeof(unsigned long),
1386 .proc_handler = hugetlb_overcommit_handler,
1390 .procname = "lowmem_reserve_ratio",
1391 .data = &sysctl_lowmem_reserve_ratio,
1392 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1394 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
1397 .procname = "drop_caches",
1398 .data = &sysctl_drop_caches,
1399 .maxlen = sizeof(int),
1401 .proc_handler = drop_caches_sysctl_handler,
1405 #ifdef CONFIG_COMPACTION
1407 .procname = "compact_memory",
1408 .data = &sysctl_compact_memory,
1409 .maxlen = sizeof(int),
1411 .proc_handler = sysctl_compaction_handler,
1414 .procname = "extfrag_threshold",
1415 .data = &sysctl_extfrag_threshold,
1416 .maxlen = sizeof(int),
1418 .proc_handler = sysctl_extfrag_handler,
1419 .extra1 = &min_extfrag_threshold,
1420 .extra2 = &max_extfrag_threshold,
1423 .procname = "compact_unevictable_allowed",
1424 .data = &sysctl_compact_unevictable_allowed,
1425 .maxlen = sizeof(int),
1427 .proc_handler = proc_dointvec,
1432 #endif /* CONFIG_COMPACTION */
1434 .procname = "min_free_kbytes",
1435 .data = &min_free_kbytes,
1436 .maxlen = sizeof(min_free_kbytes),
1438 .proc_handler = min_free_kbytes_sysctl_handler,
1442 .procname = "watermark_scale_factor",
1443 .data = &watermark_scale_factor,
1444 .maxlen = sizeof(watermark_scale_factor),
1446 .proc_handler = watermark_scale_factor_sysctl_handler,
1448 .extra2 = &one_thousand,
1451 .procname = "percpu_pagelist_fraction",
1452 .data = &percpu_pagelist_fraction,
1453 .maxlen = sizeof(percpu_pagelist_fraction),
1455 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
1460 .procname = "max_map_count",
1461 .data = &sysctl_max_map_count,
1462 .maxlen = sizeof(sysctl_max_map_count),
1464 .proc_handler = proc_dointvec_minmax,
1469 .procname = "nr_trim_pages",
1470 .data = &sysctl_nr_trim_pages,
1471 .maxlen = sizeof(sysctl_nr_trim_pages),
1473 .proc_handler = proc_dointvec_minmax,
1478 .procname = "laptop_mode",
1479 .data = &laptop_mode,
1480 .maxlen = sizeof(laptop_mode),
1482 .proc_handler = proc_dointvec_jiffies,
1485 .procname = "block_dump",
1486 .data = &block_dump,
1487 .maxlen = sizeof(block_dump),
1489 .proc_handler = proc_dointvec,
1493 .procname = "vfs_cache_pressure",
1494 .data = &sysctl_vfs_cache_pressure,
1495 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1497 .proc_handler = proc_dointvec,
1500 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1502 .procname = "legacy_va_layout",
1503 .data = &sysctl_legacy_va_layout,
1504 .maxlen = sizeof(sysctl_legacy_va_layout),
1506 .proc_handler = proc_dointvec,
1512 .procname = "zone_reclaim_mode",
1513 .data = &node_reclaim_mode,
1514 .maxlen = sizeof(node_reclaim_mode),
1516 .proc_handler = proc_dointvec,
1520 .procname = "min_unmapped_ratio",
1521 .data = &sysctl_min_unmapped_ratio,
1522 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1524 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
1526 .extra2 = &one_hundred,
1529 .procname = "min_slab_ratio",
1530 .data = &sysctl_min_slab_ratio,
1531 .maxlen = sizeof(sysctl_min_slab_ratio),
1533 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
1535 .extra2 = &one_hundred,
1540 .procname = "stat_interval",
1541 .data = &sysctl_stat_interval,
1542 .maxlen = sizeof(sysctl_stat_interval),
1544 .proc_handler = proc_dointvec_jiffies,
1547 .procname = "stat_refresh",
1551 .proc_handler = vmstat_refresh,
1556 .procname = "mmap_min_addr",
1557 .data = &dac_mmap_min_addr,
1558 .maxlen = sizeof(unsigned long),
1560 .proc_handler = mmap_min_addr_handler,
1565 .procname = "numa_zonelist_order",
1566 .data = &numa_zonelist_order,
1567 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1569 .proc_handler = numa_zonelist_order_handler,
1572 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1573 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1575 .procname = "vdso_enabled",
1576 #ifdef CONFIG_X86_32
1577 .data = &vdso32_enabled,
1578 .maxlen = sizeof(vdso32_enabled),
1580 .data = &vdso_enabled,
1581 .maxlen = sizeof(vdso_enabled),
1584 .proc_handler = proc_dointvec,
1588 #ifdef CONFIG_HIGHMEM
1590 .procname = "highmem_is_dirtyable",
1591 .data = &vm_highmem_is_dirtyable,
1592 .maxlen = sizeof(vm_highmem_is_dirtyable),
1594 .proc_handler = proc_dointvec_minmax,
1599 #ifdef CONFIG_MEMORY_FAILURE
1601 .procname = "memory_failure_early_kill",
1602 .data = &sysctl_memory_failure_early_kill,
1603 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1605 .proc_handler = proc_dointvec_minmax,
1610 .procname = "memory_failure_recovery",
1611 .data = &sysctl_memory_failure_recovery,
1612 .maxlen = sizeof(sysctl_memory_failure_recovery),
1614 .proc_handler = proc_dointvec_minmax,
1620 .procname = "user_reserve_kbytes",
1621 .data = &sysctl_user_reserve_kbytes,
1622 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1624 .proc_handler = proc_doulongvec_minmax,
1627 .procname = "admin_reserve_kbytes",
1628 .data = &sysctl_admin_reserve_kbytes,
1629 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1631 .proc_handler = proc_doulongvec_minmax,
1633 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1635 .procname = "mmap_rnd_bits",
1636 .data = &mmap_rnd_bits,
1637 .maxlen = sizeof(mmap_rnd_bits),
1639 .proc_handler = proc_dointvec_minmax,
1640 .extra1 = (void *)&mmap_rnd_bits_min,
1641 .extra2 = (void *)&mmap_rnd_bits_max,
1644 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1646 .procname = "mmap_rnd_compat_bits",
1647 .data = &mmap_rnd_compat_bits,
1648 .maxlen = sizeof(mmap_rnd_compat_bits),
1650 .proc_handler = proc_dointvec_minmax,
1651 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1652 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1658 static struct ctl_table fs_table[] = {
1660 .procname = "inode-nr",
1661 .data = &inodes_stat,
1662 .maxlen = 2*sizeof(long),
1664 .proc_handler = proc_nr_inodes,
1667 .procname = "inode-state",
1668 .data = &inodes_stat,
1669 .maxlen = 7*sizeof(long),
1671 .proc_handler = proc_nr_inodes,
1674 .procname = "file-nr",
1675 .data = &files_stat,
1676 .maxlen = sizeof(files_stat),
1678 .proc_handler = proc_nr_files,
1681 .procname = "file-max",
1682 .data = &files_stat.max_files,
1683 .maxlen = sizeof(files_stat.max_files),
1685 .proc_handler = proc_doulongvec_minmax,
1687 .extra2 = &long_max,
1690 .procname = "nr_open",
1691 .data = &sysctl_nr_open,
1692 .maxlen = sizeof(unsigned int),
1694 .proc_handler = proc_dointvec_minmax,
1695 .extra1 = &sysctl_nr_open_min,
1696 .extra2 = &sysctl_nr_open_max,
1699 .procname = "dentry-state",
1700 .data = &dentry_stat,
1701 .maxlen = 6*sizeof(long),
1703 .proc_handler = proc_nr_dentry,
1706 .procname = "overflowuid",
1707 .data = &fs_overflowuid,
1708 .maxlen = sizeof(int),
1710 .proc_handler = proc_dointvec_minmax,
1711 .extra1 = &minolduid,
1712 .extra2 = &maxolduid,
1715 .procname = "overflowgid",
1716 .data = &fs_overflowgid,
1717 .maxlen = sizeof(int),
1719 .proc_handler = proc_dointvec_minmax,
1720 .extra1 = &minolduid,
1721 .extra2 = &maxolduid,
1723 #ifdef CONFIG_FILE_LOCKING
1725 .procname = "leases-enable",
1726 .data = &leases_enable,
1727 .maxlen = sizeof(int),
1729 .proc_handler = proc_dointvec,
1732 #ifdef CONFIG_DNOTIFY
1734 .procname = "dir-notify-enable",
1735 .data = &dir_notify_enable,
1736 .maxlen = sizeof(int),
1738 .proc_handler = proc_dointvec,
1742 #ifdef CONFIG_FILE_LOCKING
1744 .procname = "lease-break-time",
1745 .data = &lease_break_time,
1746 .maxlen = sizeof(int),
1748 .proc_handler = proc_dointvec,
1753 .procname = "aio-nr",
1755 .maxlen = sizeof(aio_nr),
1757 .proc_handler = proc_doulongvec_minmax,
1760 .procname = "aio-max-nr",
1761 .data = &aio_max_nr,
1762 .maxlen = sizeof(aio_max_nr),
1764 .proc_handler = proc_doulongvec_minmax,
1766 #endif /* CONFIG_AIO */
1767 #ifdef CONFIG_INOTIFY_USER
1769 .procname = "inotify",
1771 .child = inotify_table,
1776 .procname = "epoll",
1778 .child = epoll_table,
1783 .procname = "protected_symlinks",
1784 .data = &sysctl_protected_symlinks,
1785 .maxlen = sizeof(int),
1787 .proc_handler = proc_dointvec_minmax,
1792 .procname = "protected_hardlinks",
1793 .data = &sysctl_protected_hardlinks,
1794 .maxlen = sizeof(int),
1796 .proc_handler = proc_dointvec_minmax,
1801 .procname = "protected_fifos",
1802 .data = &sysctl_protected_fifos,
1803 .maxlen = sizeof(int),
1805 .proc_handler = proc_dointvec_minmax,
1810 .procname = "protected_regular",
1811 .data = &sysctl_protected_regular,
1812 .maxlen = sizeof(int),
1814 .proc_handler = proc_dointvec_minmax,
1819 .procname = "suid_dumpable",
1820 .data = &suid_dumpable,
1821 .maxlen = sizeof(int),
1823 .proc_handler = proc_dointvec_minmax_coredump,
1827 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1829 .procname = "binfmt_misc",
1831 .child = sysctl_mount_point,
1835 .procname = "pipe-max-size",
1836 .data = &pipe_max_size,
1837 .maxlen = sizeof(pipe_max_size),
1839 .proc_handler = &pipe_proc_fn,
1840 .extra1 = &pipe_min_size,
1843 .procname = "pipe-user-pages-hard",
1844 .data = &pipe_user_pages_hard,
1845 .maxlen = sizeof(pipe_user_pages_hard),
1847 .proc_handler = proc_doulongvec_minmax,
1850 .procname = "pipe-user-pages-soft",
1851 .data = &pipe_user_pages_soft,
1852 .maxlen = sizeof(pipe_user_pages_soft),
1854 .proc_handler = proc_doulongvec_minmax,
1857 .procname = "mount-max",
1858 .data = &sysctl_mount_max,
1859 .maxlen = sizeof(unsigned int),
1861 .proc_handler = proc_dointvec_minmax,
1867 static struct ctl_table debug_table[] = {
1868 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1870 .procname = "exception-trace",
1871 .data = &show_unhandled_signals,
1872 .maxlen = sizeof(int),
1874 .proc_handler = proc_dointvec
1877 #if defined(CONFIG_OPTPROBES)
1879 .procname = "kprobes-optimization",
1880 .data = &sysctl_kprobes_optimization,
1881 .maxlen = sizeof(int),
1883 .proc_handler = proc_kprobes_optimization_handler,
1891 static struct ctl_table dev_table[] = {
1895 int __init sysctl_init(void)
1897 struct ctl_table_header *hdr;
1899 hdr = register_sysctl_table(sysctl_base_table);
1900 kmemleak_not_leak(hdr);
1904 #endif /* CONFIG_SYSCTL */
1910 #ifdef CONFIG_PROC_SYSCTL
1912 static int _proc_do_string(char *data, int maxlen, int write,
1913 char __user *buffer,
1914 size_t *lenp, loff_t *ppos)
1920 if (!data || !maxlen || !*lenp) {
1926 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1927 /* Only continue writes not past the end of buffer. */
1929 if (len > maxlen - 1)
1936 /* Start writing from beginning of buffer. */
1942 while ((p - buffer) < *lenp && len < maxlen - 1) {
1943 if (get_user(c, p++))
1945 if (c == 0 || c == '\n')
1966 if (copy_to_user(buffer, data, len))
1969 if (put_user('\n', buffer + len))
1979 static void warn_sysctl_write(struct ctl_table *table)
1981 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1982 "This will not be supported in the future. To silence this\n"
1983 "warning, set kernel.sysctl_writes_strict = -1\n",
1984 current->comm, table->procname);
1988 * proc_first_pos_non_zero_ignore - check if firs position is allowed
1989 * @ppos: file position
1990 * @table: the sysctl table
1992 * Returns true if the first position is non-zero and the sysctl_writes_strict
1993 * mode indicates this is not allowed for numeric input types. String proc
1994 * hadlers can ignore the return value.
1996 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
1997 struct ctl_table *table)
2002 switch (sysctl_writes_strict) {
2003 case SYSCTL_WRITES_STRICT:
2005 case SYSCTL_WRITES_WARN:
2006 warn_sysctl_write(table);
2014 * proc_dostring - read a string sysctl
2015 * @table: the sysctl table
2016 * @write: %TRUE if this is a write to the sysctl file
2017 * @buffer: the user buffer
2018 * @lenp: the size of the user buffer
2019 * @ppos: file position
2021 * Reads/writes a string from/to the user buffer. If the kernel
2022 * buffer provided is not large enough to hold the string, the
2023 * string is truncated. The copied string is %NULL-terminated.
2024 * If the string is being read by the user process, it is copied
2025 * and a newline '\n' is added. It is truncated if the buffer is
2028 * Returns 0 on success.
2030 int proc_dostring(struct ctl_table *table, int write,
2031 void __user *buffer, size_t *lenp, loff_t *ppos)
2034 proc_first_pos_non_zero_ignore(ppos, table);
2036 return _proc_do_string((char *)(table->data), table->maxlen, write,
2037 (char __user *)buffer, lenp, ppos);
2040 static size_t proc_skip_spaces(char **buf)
2043 char *tmp = skip_spaces(*buf);
2049 static void proc_skip_char(char **buf, size_t *size, const char v)
2059 #define TMPBUFLEN 22
2061 * proc_get_long - reads an ASCII formatted integer from a user buffer
2063 * @buf: a kernel buffer
2064 * @size: size of the kernel buffer
2065 * @val: this is where the number will be stored
2066 * @neg: set to %TRUE if number is negative
2067 * @perm_tr: a vector which contains the allowed trailers
2068 * @perm_tr_len: size of the perm_tr vector
2069 * @tr: pointer to store the trailer character
2071 * In case of success %0 is returned and @buf and @size are updated with
2072 * the amount of bytes read. If @tr is non-NULL and a trailing
2073 * character exists (size is non-zero after returning from this
2074 * function), @tr is updated with the trailing character.
2076 static int proc_get_long(char **buf, size_t *size,
2077 unsigned long *val, bool *neg,
2078 const char *perm_tr, unsigned perm_tr_len, char *tr)
2081 char *p, tmp[TMPBUFLEN];
2087 if (len > TMPBUFLEN - 1)
2088 len = TMPBUFLEN - 1;
2090 memcpy(tmp, *buf, len);
2094 if (*p == '-' && *size > 1) {
2102 *val = simple_strtoul(p, &p, 0);
2106 /* We don't know if the next char is whitespace thus we may accept
2107 * invalid integers (e.g. 1234...a) or two integers instead of one
2108 * (e.g. 123...1). So lets not allow such large numbers. */
2109 if (len == TMPBUFLEN - 1)
2112 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2115 if (tr && (len < *size))
2125 * proc_put_long - converts an integer to a decimal ASCII formatted string
2127 * @buf: the user buffer
2128 * @size: the size of the user buffer
2129 * @val: the integer to be converted
2130 * @neg: sign of the number, %TRUE for negative
2132 * In case of success %0 is returned and @buf and @size are updated with
2133 * the amount of bytes written.
2135 static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2139 char tmp[TMPBUFLEN], *p = tmp;
2141 sprintf(p, "%s%lu", neg ? "-" : "", val);
2145 if (copy_to_user(*buf, tmp, len))
2153 static int proc_put_char(void __user **buf, size_t *size, char c)
2156 char __user **buffer = (char __user **)buf;
2157 if (put_user(c, *buffer))
2159 (*size)--, (*buffer)++;
2165 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
2167 int write, void *data)
2171 if (*lvalp > (unsigned long) INT_MAX + 1)
2175 if (*lvalp > (unsigned long) INT_MAX)
2183 *lvalp = -(unsigned long)val;
2186 *lvalp = (unsigned long)val;
2192 static int do_proc_douintvec_conv(unsigned long *lvalp,
2194 int write, void *data)
2197 if (*lvalp > UINT_MAX)
2201 unsigned int val = *valp;
2202 *lvalp = (unsigned long)val;
2207 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2209 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
2210 int write, void __user *buffer,
2211 size_t *lenp, loff_t *ppos,
2212 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2213 int write, void *data),
2216 int *i, vleft, first = 1, err = 0;
2218 char *kbuf = NULL, *p;
2220 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2225 i = (int *) tbl_data;
2226 vleft = table->maxlen / sizeof(*i);
2230 conv = do_proc_dointvec_conv;
2233 if (proc_first_pos_non_zero_ignore(ppos, table))
2236 if (left > PAGE_SIZE - 1)
2237 left = PAGE_SIZE - 1;
2238 p = kbuf = memdup_user_nul(buffer, left);
2240 return PTR_ERR(kbuf);
2243 for (; left && vleft--; i++, first=0) {
2248 left -= proc_skip_spaces(&p);
2252 err = proc_get_long(&p, &left, &lval, &neg,
2254 sizeof(proc_wspace_sep), NULL);
2257 if (conv(&neg, &lval, i, 1, data)) {
2262 if (conv(&neg, &lval, i, 0, data)) {
2267 err = proc_put_char(&buffer, &left, '\t');
2270 err = proc_put_long(&buffer, &left, lval, neg);
2276 if (!write && !first && left && !err)
2277 err = proc_put_char(&buffer, &left, '\n');
2278 if (write && !err && left)
2279 left -= proc_skip_spaces(&p);
2283 return err ? : -EINVAL;
2291 static int do_proc_dointvec(struct ctl_table *table, int write,
2292 void __user *buffer, size_t *lenp, loff_t *ppos,
2293 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2294 int write, void *data),
2297 return __do_proc_dointvec(table->data, table, write,
2298 buffer, lenp, ppos, conv, data);
2301 static int do_proc_douintvec_w(unsigned int *tbl_data,
2302 struct ctl_table *table,
2303 void __user *buffer,
2304 size_t *lenp, loff_t *ppos,
2305 int (*conv)(unsigned long *lvalp,
2307 int write, void *data),
2314 char *kbuf = NULL, *p;
2318 if (proc_first_pos_non_zero_ignore(ppos, table))
2321 if (left > PAGE_SIZE - 1)
2322 left = PAGE_SIZE - 1;
2324 p = kbuf = memdup_user_nul(buffer, left);
2328 left -= proc_skip_spaces(&p);
2334 err = proc_get_long(&p, &left, &lval, &neg,
2336 sizeof(proc_wspace_sep), NULL);
2342 if (conv(&lval, tbl_data, 1, data)) {
2348 left -= proc_skip_spaces(&p);
2357 /* This is in keeping with old __do_proc_dointvec() */
2363 static int do_proc_douintvec_r(unsigned int *tbl_data, void __user *buffer,
2364 size_t *lenp, loff_t *ppos,
2365 int (*conv)(unsigned long *lvalp,
2367 int write, void *data),
2376 if (conv(&lval, tbl_data, 0, data)) {
2381 err = proc_put_long(&buffer, &left, lval, false);
2385 err = proc_put_char(&buffer, &left, '\n');
2394 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
2395 int write, void __user *buffer,
2396 size_t *lenp, loff_t *ppos,
2397 int (*conv)(unsigned long *lvalp,
2399 int write, void *data),
2402 unsigned int *i, vleft;
2404 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2409 i = (unsigned int *) tbl_data;
2410 vleft = table->maxlen / sizeof(*i);
2413 * Arrays are not supported, keep this simple. *Do not* add
2422 conv = do_proc_douintvec_conv;
2425 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
2427 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
2430 static int do_proc_douintvec(struct ctl_table *table, int write,
2431 void __user *buffer, size_t *lenp, loff_t *ppos,
2432 int (*conv)(unsigned long *lvalp,
2434 int write, void *data),
2437 return __do_proc_douintvec(table->data, table, write,
2438 buffer, lenp, ppos, conv, data);
2442 * proc_dointvec - read a vector of integers
2443 * @table: the sysctl table
2444 * @write: %TRUE if this is a write to the sysctl file
2445 * @buffer: the user buffer
2446 * @lenp: the size of the user buffer
2447 * @ppos: file position
2449 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2450 * values from/to the user buffer, treated as an ASCII string.
2452 * Returns 0 on success.
2454 int proc_dointvec(struct ctl_table *table, int write,
2455 void __user *buffer, size_t *lenp, loff_t *ppos)
2457 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2461 * proc_douintvec - read a vector of unsigned integers
2462 * @table: the sysctl table
2463 * @write: %TRUE if this is a write to the sysctl file
2464 * @buffer: the user buffer
2465 * @lenp: the size of the user buffer
2466 * @ppos: file position
2468 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2469 * values from/to the user buffer, treated as an ASCII string.
2471 * Returns 0 on success.
2473 int proc_douintvec(struct ctl_table *table, int write,
2474 void __user *buffer, size_t *lenp, loff_t *ppos)
2476 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2477 do_proc_douintvec_conv, NULL);
2481 * Taint values can only be increased
2482 * This means we can safely use a temporary.
2484 static int proc_taint(struct ctl_table *table, int write,
2485 void __user *buffer, size_t *lenp, loff_t *ppos)
2488 unsigned long tmptaint = get_taint();
2491 if (write && !capable(CAP_SYS_ADMIN))
2496 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
2502 * Poor man's atomic or. Not worth adding a primitive
2503 * to everyone's atomic.h for this
2506 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2507 if ((tmptaint >> i) & 1)
2508 add_taint(i, LOCKDEP_STILL_OK);
2515 #ifdef CONFIG_PRINTK
2516 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
2517 void __user *buffer, size_t *lenp, loff_t *ppos)
2519 if (write && !capable(CAP_SYS_ADMIN))
2522 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2526 struct do_proc_dointvec_minmax_conv_param {
2531 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2533 int write, void *data)
2535 struct do_proc_dointvec_minmax_conv_param *param = data;
2539 if (*lvalp > (unsigned long) INT_MAX + 1)
2543 if (*lvalp > (unsigned long) INT_MAX)
2547 if ((param->min && *param->min > val) ||
2548 (param->max && *param->max < val))
2555 *lvalp = -(unsigned long)val;
2558 *lvalp = (unsigned long)val;
2565 * proc_dointvec_minmax - read a vector of integers with min/max values
2566 * @table: the sysctl table
2567 * @write: %TRUE if this is a write to the sysctl file
2568 * @buffer: the user buffer
2569 * @lenp: the size of the user buffer
2570 * @ppos: file position
2572 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2573 * values from/to the user buffer, treated as an ASCII string.
2575 * This routine will ensure the values are within the range specified by
2576 * table->extra1 (min) and table->extra2 (max).
2578 * Returns 0 on success.
2580 int proc_dointvec_minmax(struct ctl_table *table, int write,
2581 void __user *buffer, size_t *lenp, loff_t *ppos)
2583 struct do_proc_dointvec_minmax_conv_param param = {
2584 .min = (int *) table->extra1,
2585 .max = (int *) table->extra2,
2587 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2588 do_proc_dointvec_minmax_conv, ¶m);
2591 struct do_proc_douintvec_minmax_conv_param {
2596 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
2598 int write, void *data)
2600 struct do_proc_douintvec_minmax_conv_param *param = data;
2603 unsigned int val = *lvalp;
2605 if ((param->min && *param->min > val) ||
2606 (param->max && *param->max < val))
2609 if (*lvalp > UINT_MAX)
2613 unsigned int val = *valp;
2614 *lvalp = (unsigned long) val;
2621 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2622 * @table: the sysctl table
2623 * @write: %TRUE if this is a write to the sysctl file
2624 * @buffer: the user buffer
2625 * @lenp: the size of the user buffer
2626 * @ppos: file position
2628 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2629 * values from/to the user buffer, treated as an ASCII string. Negative
2630 * strings are not allowed.
2632 * This routine will ensure the values are within the range specified by
2633 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2634 * check for UINT_MAX to avoid having to support wrap around uses from
2637 * Returns 0 on success.
2639 int proc_douintvec_minmax(struct ctl_table *table, int write,
2640 void __user *buffer, size_t *lenp, loff_t *ppos)
2642 struct do_proc_douintvec_minmax_conv_param param = {
2643 .min = (unsigned int *) table->extra1,
2644 .max = (unsigned int *) table->extra2,
2646 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2647 do_proc_douintvec_minmax_conv, ¶m);
2650 static void validate_coredump_safety(void)
2652 #ifdef CONFIG_COREDUMP
2653 if (suid_dumpable == SUID_DUMP_ROOT &&
2654 core_pattern[0] != '/' && core_pattern[0] != '|') {
2656 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2657 "Pipe handler or fully qualified core dump path required.\n"
2658 "Set kernel.core_pattern before fs.suid_dumpable.\n"
2664 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2665 void __user *buffer, size_t *lenp, loff_t *ppos)
2667 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2669 validate_coredump_safety();
2673 #ifdef CONFIG_COREDUMP
2674 static int proc_dostring_coredump(struct ctl_table *table, int write,
2675 void __user *buffer, size_t *lenp, loff_t *ppos)
2677 int error = proc_dostring(table, write, buffer, lenp, ppos);
2679 validate_coredump_safety();
2684 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
2685 void __user *buffer,
2686 size_t *lenp, loff_t *ppos,
2687 unsigned long convmul,
2688 unsigned long convdiv)
2690 unsigned long *i, *min, *max;
2691 int vleft, first = 1, err = 0;
2693 char *kbuf = NULL, *p;
2695 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
2700 i = (unsigned long *) data;
2701 min = (unsigned long *) table->extra1;
2702 max = (unsigned long *) table->extra2;
2703 vleft = table->maxlen / sizeof(unsigned long);
2707 if (proc_first_pos_non_zero_ignore(ppos, table))
2710 if (left > PAGE_SIZE - 1)
2711 left = PAGE_SIZE - 1;
2712 p = kbuf = memdup_user_nul(buffer, left);
2714 return PTR_ERR(kbuf);
2717 for (; left && vleft--; i++, first = 0) {
2723 left -= proc_skip_spaces(&p);
2727 err = proc_get_long(&p, &left, &val, &neg,
2729 sizeof(proc_wspace_sep), NULL);
2734 val = convmul * val / convdiv;
2735 if ((min && val < *min) || (max && val > *max)) {
2741 val = convdiv * (*i) / convmul;
2743 err = proc_put_char(&buffer, &left, '\t');
2747 err = proc_put_long(&buffer, &left, val, false);
2753 if (!write && !first && left && !err)
2754 err = proc_put_char(&buffer, &left, '\n');
2756 left -= proc_skip_spaces(&p);
2760 return err ? : -EINVAL;
2768 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2769 void __user *buffer,
2770 size_t *lenp, loff_t *ppos,
2771 unsigned long convmul,
2772 unsigned long convdiv)
2774 return __do_proc_doulongvec_minmax(table->data, table, write,
2775 buffer, lenp, ppos, convmul, convdiv);
2779 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2780 * @table: the sysctl table
2781 * @write: %TRUE if this is a write to the sysctl file
2782 * @buffer: the user buffer
2783 * @lenp: the size of the user buffer
2784 * @ppos: file position
2786 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2787 * values from/to the user buffer, treated as an ASCII string.
2789 * This routine will ensure the values are within the range specified by
2790 * table->extra1 (min) and table->extra2 (max).
2792 * Returns 0 on success.
2794 int proc_doulongvec_minmax(struct ctl_table *table, int write,
2795 void __user *buffer, size_t *lenp, loff_t *ppos)
2797 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
2801 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2802 * @table: the sysctl table
2803 * @write: %TRUE if this is a write to the sysctl file
2804 * @buffer: the user buffer
2805 * @lenp: the size of the user buffer
2806 * @ppos: file position
2808 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2809 * values from/to the user buffer, treated as an ASCII string. The values
2810 * are treated as milliseconds, and converted to jiffies when they are stored.
2812 * This routine will ensure the values are within the range specified by
2813 * table->extra1 (min) and table->extra2 (max).
2815 * Returns 0 on success.
2817 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2818 void __user *buffer,
2819 size_t *lenp, loff_t *ppos)
2821 return do_proc_doulongvec_minmax(table, write, buffer,
2822 lenp, ppos, HZ, 1000l);
2826 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
2828 int write, void *data)
2831 if (*lvalp > INT_MAX / HZ)
2833 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2839 lval = -(unsigned long)val;
2842 lval = (unsigned long)val;
2849 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
2851 int write, void *data)
2854 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2856 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2862 lval = -(unsigned long)val;
2865 lval = (unsigned long)val;
2867 *lvalp = jiffies_to_clock_t(lval);
2872 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
2874 int write, void *data)
2877 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2887 lval = -(unsigned long)val;
2890 lval = (unsigned long)val;
2892 *lvalp = jiffies_to_msecs(lval);
2898 * proc_dointvec_jiffies - read a vector of integers as seconds
2899 * @table: the sysctl table
2900 * @write: %TRUE if this is a write to the sysctl file
2901 * @buffer: the user buffer
2902 * @lenp: the size of the user buffer
2903 * @ppos: file position
2905 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2906 * values from/to the user buffer, treated as an ASCII string.
2907 * The values read are assumed to be in seconds, and are converted into
2910 * Returns 0 on success.
2912 int proc_dointvec_jiffies(struct ctl_table *table, int write,
2913 void __user *buffer, size_t *lenp, loff_t *ppos)
2915 return do_proc_dointvec(table,write,buffer,lenp,ppos,
2916 do_proc_dointvec_jiffies_conv,NULL);
2920 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2921 * @table: the sysctl table
2922 * @write: %TRUE if this is a write to the sysctl file
2923 * @buffer: the user buffer
2924 * @lenp: the size of the user buffer
2925 * @ppos: pointer to the file position
2927 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2928 * values from/to the user buffer, treated as an ASCII string.
2929 * The values read are assumed to be in 1/USER_HZ seconds, and
2930 * are converted into jiffies.
2932 * Returns 0 on success.
2934 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
2935 void __user *buffer, size_t *lenp, loff_t *ppos)
2937 return do_proc_dointvec(table,write,buffer,lenp,ppos,
2938 do_proc_dointvec_userhz_jiffies_conv,NULL);
2942 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2943 * @table: the sysctl table
2944 * @write: %TRUE if this is a write to the sysctl file
2945 * @buffer: the user buffer
2946 * @lenp: the size of the user buffer
2947 * @ppos: file position
2948 * @ppos: the current position in the file
2950 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2951 * values from/to the user buffer, treated as an ASCII string.
2952 * The values read are assumed to be in 1/1000 seconds, and
2953 * are converted into jiffies.
2955 * Returns 0 on success.
2957 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
2958 void __user *buffer, size_t *lenp, loff_t *ppos)
2960 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2961 do_proc_dointvec_ms_jiffies_conv, NULL);
2964 static int proc_do_cad_pid(struct ctl_table *table, int write,
2965 void __user *buffer, size_t *lenp, loff_t *ppos)
2967 struct pid *new_pid;
2971 tmp = pid_vnr(cad_pid);
2973 r = __do_proc_dointvec(&tmp, table, write, buffer,
2974 lenp, ppos, NULL, NULL);
2978 new_pid = find_get_pid(tmp);
2982 put_pid(xchg(&cad_pid, new_pid));
2987 * proc_do_large_bitmap - read/write from/to a large bitmap
2988 * @table: the sysctl table
2989 * @write: %TRUE if this is a write to the sysctl file
2990 * @buffer: the user buffer
2991 * @lenp: the size of the user buffer
2992 * @ppos: file position
2994 * The bitmap is stored at table->data and the bitmap length (in bits)
2997 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2998 * large bitmaps may be represented in a compact manner. Writing into
2999 * the file will clear the bitmap then update it with the given input.
3001 * Returns 0 on success.
3003 int proc_do_large_bitmap(struct ctl_table *table, int write,
3004 void __user *buffer, size_t *lenp, loff_t *ppos)
3008 size_t left = *lenp;
3009 unsigned long bitmap_len = table->maxlen;
3010 unsigned long *bitmap = *(unsigned long **) table->data;
3011 unsigned long *tmp_bitmap = NULL;
3012 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
3014 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
3022 if (left > PAGE_SIZE - 1)
3023 left = PAGE_SIZE - 1;
3025 p = kbuf = memdup_user_nul(buffer, left);
3027 return PTR_ERR(kbuf);
3029 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
3035 proc_skip_char(&p, &left, '\n');
3036 while (!err && left) {
3037 unsigned long val_a, val_b;
3040 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
3044 if (val_a >= bitmap_len || neg) {
3056 err = proc_get_long(&p, &left, &val_b,
3057 &neg, tr_b, sizeof(tr_b),
3061 if (val_b >= bitmap_len || neg ||
3072 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
3074 proc_skip_char(&p, &left, '\n');
3078 unsigned long bit_a, bit_b = 0;
3081 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3082 if (bit_a >= bitmap_len)
3084 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3088 err = proc_put_char(&buffer, &left, ',');
3092 err = proc_put_long(&buffer, &left, bit_a, false);
3095 if (bit_a != bit_b) {
3096 err = proc_put_char(&buffer, &left, '-');
3099 err = proc_put_long(&buffer, &left, bit_b, false);
3107 err = proc_put_char(&buffer, &left, '\n');
3113 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3115 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
3127 #else /* CONFIG_PROC_SYSCTL */
3129 int proc_dostring(struct ctl_table *table, int write,
3130 void __user *buffer, size_t *lenp, loff_t *ppos)
3135 int proc_dointvec(struct ctl_table *table, int write,
3136 void __user *buffer, size_t *lenp, loff_t *ppos)
3141 int proc_douintvec(struct ctl_table *table, int write,
3142 void __user *buffer, size_t *lenp, loff_t *ppos)
3147 int proc_dointvec_minmax(struct ctl_table *table, int write,
3148 void __user *buffer, size_t *lenp, loff_t *ppos)
3153 int proc_douintvec_minmax(struct ctl_table *table, int write,
3154 void __user *buffer, size_t *lenp, loff_t *ppos)
3159 int proc_dointvec_jiffies(struct ctl_table *table, int write,
3160 void __user *buffer, size_t *lenp, loff_t *ppos)
3165 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
3166 void __user *buffer, size_t *lenp, loff_t *ppos)
3171 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
3172 void __user *buffer, size_t *lenp, loff_t *ppos)
3177 int proc_doulongvec_minmax(struct ctl_table *table, int write,
3178 void __user *buffer, size_t *lenp, loff_t *ppos)
3183 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
3184 void __user *buffer,
3185 size_t *lenp, loff_t *ppos)
3191 #endif /* CONFIG_PROC_SYSCTL */
3194 * No sense putting this after each symbol definition, twice,
3195 * exception granted :-)
3197 EXPORT_SYMBOL(proc_dointvec);
3198 EXPORT_SYMBOL(proc_douintvec);
3199 EXPORT_SYMBOL(proc_dointvec_jiffies);
3200 EXPORT_SYMBOL(proc_dointvec_minmax);
3201 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3202 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3203 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3204 EXPORT_SYMBOL(proc_dostring);
3205 EXPORT_SYMBOL(proc_doulongvec_minmax);
3206 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);