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;
148 /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
149 #ifdef CONFIG_DETECT_HUNG_TASK
150 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
153 #ifdef CONFIG_INOTIFY_USER
154 #include <linux/inotify.h>
160 extern int pwrsw_enabled;
163 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
164 extern int unaligned_enabled;
168 extern int unaligned_dump_stack;
171 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
172 extern int no_unaligned_warning;
175 #ifdef CONFIG_PROC_SYSCTL
178 * enum sysctl_writes_mode - supported sysctl write modes
180 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
181 * to be written, and multiple writes on the same sysctl file descriptor
182 * will rewrite the sysctl value, regardless of file position. No warning
183 * is issued when the initial position is not 0.
184 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
186 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
187 * file position 0 and the value must be fully contained in the buffer
188 * sent to the write syscall. If dealing with strings respect the file
189 * position, but restrict this to the max length of the buffer, anything
190 * passed the max lenght will be ignored. Multiple writes will append
193 * These write modes control how current file position affects the behavior of
194 * updating sysctl values through the proc interface on each write.
196 enum sysctl_writes_mode {
197 SYSCTL_WRITES_LEGACY = -1,
198 SYSCTL_WRITES_WARN = 0,
199 SYSCTL_WRITES_STRICT = 1,
202 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
204 static int proc_do_cad_pid(struct ctl_table *table, int write,
205 void __user *buffer, size_t *lenp, loff_t *ppos);
206 static int proc_taint(struct ctl_table *table, int write,
207 void __user *buffer, size_t *lenp, loff_t *ppos);
211 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
212 void __user *buffer, size_t *lenp, loff_t *ppos);
215 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
216 void __user *buffer, size_t *lenp, loff_t *ppos);
217 #ifdef CONFIG_COREDUMP
218 static int proc_dostring_coredump(struct ctl_table *table, int write,
219 void __user *buffer, size_t *lenp, loff_t *ppos);
221 static int proc_dopipe_max_size(struct ctl_table *table, int write,
222 void __user *buffer, size_t *lenp, loff_t *ppos);
224 #ifdef CONFIG_MAGIC_SYSRQ
225 /* Note: sysrq code uses it's own private copy */
226 static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
228 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
229 void __user *buffer, size_t *lenp,
234 error = proc_dointvec(table, write, buffer, lenp, ppos);
239 sysrq_toggle_support(__sysrq_enabled);
246 static struct ctl_table kern_table[];
247 static struct ctl_table vm_table[];
248 static struct ctl_table fs_table[];
249 static struct ctl_table debug_table[];
250 static struct ctl_table dev_table[];
251 extern struct ctl_table random_table[];
253 extern struct ctl_table epoll_table[];
256 #ifdef CONFIG_FW_LOADER_USER_HELPER
257 extern struct ctl_table firmware_config_table[];
260 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
261 int sysctl_legacy_va_layout;
264 /* The default sysctl tables: */
266 static struct ctl_table sysctl_base_table[] = {
268 .procname = "kernel",
285 .child = debug_table,
295 #ifdef CONFIG_SCHED_DEBUG
296 static int min_sched_granularity_ns = 100000; /* 100 usecs */
297 static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
298 static int min_wakeup_granularity_ns; /* 0 usecs */
299 static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
301 static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
302 static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
303 #endif /* CONFIG_SMP */
304 #endif /* CONFIG_SCHED_DEBUG */
306 #ifdef CONFIG_COMPACTION
307 static int min_extfrag_threshold;
308 static int max_extfrag_threshold = 1000;
311 static struct ctl_table kern_table[] = {
313 .procname = "sched_child_runs_first",
314 .data = &sysctl_sched_child_runs_first,
315 .maxlen = sizeof(unsigned int),
317 .proc_handler = proc_dointvec,
319 #ifdef CONFIG_SCHED_DEBUG
321 .procname = "sched_min_granularity_ns",
322 .data = &sysctl_sched_min_granularity,
323 .maxlen = sizeof(unsigned int),
325 .proc_handler = sched_proc_update_handler,
326 .extra1 = &min_sched_granularity_ns,
327 .extra2 = &max_sched_granularity_ns,
330 .procname = "sched_latency_ns",
331 .data = &sysctl_sched_latency,
332 .maxlen = sizeof(unsigned int),
334 .proc_handler = sched_proc_update_handler,
335 .extra1 = &min_sched_granularity_ns,
336 .extra2 = &max_sched_granularity_ns,
339 .procname = "sched_wakeup_granularity_ns",
340 .data = &sysctl_sched_wakeup_granularity,
341 .maxlen = sizeof(unsigned int),
343 .proc_handler = sched_proc_update_handler,
344 .extra1 = &min_wakeup_granularity_ns,
345 .extra2 = &max_wakeup_granularity_ns,
349 .procname = "sched_tunable_scaling",
350 .data = &sysctl_sched_tunable_scaling,
351 .maxlen = sizeof(enum sched_tunable_scaling),
353 .proc_handler = sched_proc_update_handler,
354 .extra1 = &min_sched_tunable_scaling,
355 .extra2 = &max_sched_tunable_scaling,
358 .procname = "sched_migration_cost_ns",
359 .data = &sysctl_sched_migration_cost,
360 .maxlen = sizeof(unsigned int),
362 .proc_handler = proc_dointvec,
365 .procname = "sched_nr_migrate",
366 .data = &sysctl_sched_nr_migrate,
367 .maxlen = sizeof(unsigned int),
369 .proc_handler = proc_dointvec,
371 #ifdef CONFIG_SCHEDSTATS
373 .procname = "sched_schedstats",
375 .maxlen = sizeof(unsigned int),
377 .proc_handler = sysctl_schedstats,
381 #endif /* CONFIG_SCHEDSTATS */
382 #endif /* CONFIG_SMP */
383 #ifdef CONFIG_NUMA_BALANCING
385 .procname = "numa_balancing_scan_delay_ms",
386 .data = &sysctl_numa_balancing_scan_delay,
387 .maxlen = sizeof(unsigned int),
389 .proc_handler = proc_dointvec,
392 .procname = "numa_balancing_scan_period_min_ms",
393 .data = &sysctl_numa_balancing_scan_period_min,
394 .maxlen = sizeof(unsigned int),
396 .proc_handler = proc_dointvec,
399 .procname = "numa_balancing_scan_period_max_ms",
400 .data = &sysctl_numa_balancing_scan_period_max,
401 .maxlen = sizeof(unsigned int),
403 .proc_handler = proc_dointvec,
406 .procname = "numa_balancing_scan_size_mb",
407 .data = &sysctl_numa_balancing_scan_size,
408 .maxlen = sizeof(unsigned int),
410 .proc_handler = proc_dointvec_minmax,
414 .procname = "numa_balancing",
415 .data = NULL, /* filled in by handler */
416 .maxlen = sizeof(unsigned int),
418 .proc_handler = sysctl_numa_balancing,
422 #endif /* CONFIG_NUMA_BALANCING */
423 #endif /* CONFIG_SCHED_DEBUG */
425 .procname = "sched_rt_period_us",
426 .data = &sysctl_sched_rt_period,
427 .maxlen = sizeof(unsigned int),
429 .proc_handler = sched_rt_handler,
432 .procname = "sched_rt_runtime_us",
433 .data = &sysctl_sched_rt_runtime,
434 .maxlen = sizeof(int),
436 .proc_handler = sched_rt_handler,
439 .procname = "sched_rr_timeslice_ms",
440 .data = &sysctl_sched_rr_timeslice,
441 .maxlen = sizeof(int),
443 .proc_handler = sched_rr_handler,
445 #ifdef CONFIG_SCHED_AUTOGROUP
447 .procname = "sched_autogroup_enabled",
448 .data = &sysctl_sched_autogroup_enabled,
449 .maxlen = sizeof(unsigned int),
451 .proc_handler = proc_dointvec_minmax,
456 #ifdef CONFIG_CFS_BANDWIDTH
458 .procname = "sched_cfs_bandwidth_slice_us",
459 .data = &sysctl_sched_cfs_bandwidth_slice,
460 .maxlen = sizeof(unsigned int),
462 .proc_handler = proc_dointvec_minmax,
466 #ifdef CONFIG_PROVE_LOCKING
468 .procname = "prove_locking",
469 .data = &prove_locking,
470 .maxlen = sizeof(int),
472 .proc_handler = proc_dointvec,
475 #ifdef CONFIG_LOCK_STAT
477 .procname = "lock_stat",
479 .maxlen = sizeof(int),
481 .proc_handler = proc_dointvec,
486 .data = &panic_timeout,
487 .maxlen = sizeof(int),
489 .proc_handler = proc_dointvec,
491 #ifdef CONFIG_COREDUMP
493 .procname = "core_uses_pid",
494 .data = &core_uses_pid,
495 .maxlen = sizeof(int),
497 .proc_handler = proc_dointvec,
500 .procname = "core_pattern",
501 .data = core_pattern,
502 .maxlen = CORENAME_MAX_SIZE,
504 .proc_handler = proc_dostring_coredump,
507 .procname = "core_pipe_limit",
508 .data = &core_pipe_limit,
509 .maxlen = sizeof(unsigned int),
511 .proc_handler = proc_dointvec,
514 #ifdef CONFIG_PROC_SYSCTL
516 .procname = "tainted",
517 .maxlen = sizeof(long),
519 .proc_handler = proc_taint,
522 .procname = "sysctl_writes_strict",
523 .data = &sysctl_writes_strict,
524 .maxlen = sizeof(int),
526 .proc_handler = proc_dointvec_minmax,
531 #ifdef CONFIG_LATENCYTOP
533 .procname = "latencytop",
534 .data = &latencytop_enabled,
535 .maxlen = sizeof(int),
537 .proc_handler = sysctl_latencytop,
540 #ifdef CONFIG_BLK_DEV_INITRD
542 .procname = "real-root-dev",
543 .data = &real_root_dev,
544 .maxlen = sizeof(int),
546 .proc_handler = proc_dointvec,
550 .procname = "print-fatal-signals",
551 .data = &print_fatal_signals,
552 .maxlen = sizeof(int),
554 .proc_handler = proc_dointvec,
558 .procname = "reboot-cmd",
559 .data = reboot_command,
562 .proc_handler = proc_dostring,
565 .procname = "stop-a",
566 .data = &stop_a_enabled,
567 .maxlen = sizeof (int),
569 .proc_handler = proc_dointvec,
572 .procname = "scons-poweroff",
573 .data = &scons_pwroff,
574 .maxlen = sizeof (int),
576 .proc_handler = proc_dointvec,
579 #ifdef CONFIG_SPARC64
581 .procname = "tsb-ratio",
582 .data = &sysctl_tsb_ratio,
583 .maxlen = sizeof (int),
585 .proc_handler = proc_dointvec,
590 .procname = "soft-power",
591 .data = &pwrsw_enabled,
592 .maxlen = sizeof (int),
594 .proc_handler = proc_dointvec,
597 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
599 .procname = "unaligned-trap",
600 .data = &unaligned_enabled,
601 .maxlen = sizeof (int),
603 .proc_handler = proc_dointvec,
607 .procname = "ctrl-alt-del",
609 .maxlen = sizeof(int),
611 .proc_handler = proc_dointvec,
613 #ifdef CONFIG_FUNCTION_TRACER
615 .procname = "ftrace_enabled",
616 .data = &ftrace_enabled,
617 .maxlen = sizeof(int),
619 .proc_handler = ftrace_enable_sysctl,
622 #ifdef CONFIG_STACK_TRACER
624 .procname = "stack_tracer_enabled",
625 .data = &stack_tracer_enabled,
626 .maxlen = sizeof(int),
628 .proc_handler = stack_trace_sysctl,
631 #ifdef CONFIG_TRACING
633 .procname = "ftrace_dump_on_oops",
634 .data = &ftrace_dump_on_oops,
635 .maxlen = sizeof(int),
637 .proc_handler = proc_dointvec,
640 .procname = "traceoff_on_warning",
641 .data = &__disable_trace_on_warning,
642 .maxlen = sizeof(__disable_trace_on_warning),
644 .proc_handler = proc_dointvec,
647 .procname = "tracepoint_printk",
648 .data = &tracepoint_printk,
649 .maxlen = sizeof(tracepoint_printk),
651 .proc_handler = tracepoint_printk_sysctl,
654 #ifdef CONFIG_KEXEC_CORE
656 .procname = "kexec_load_disabled",
657 .data = &kexec_load_disabled,
658 .maxlen = sizeof(int),
660 /* only handle a transition from default "0" to "1" */
661 .proc_handler = proc_dointvec_minmax,
666 #ifdef CONFIG_MODULES
668 .procname = "modprobe",
669 .data = &modprobe_path,
670 .maxlen = KMOD_PATH_LEN,
672 .proc_handler = proc_dostring,
675 .procname = "modules_disabled",
676 .data = &modules_disabled,
677 .maxlen = sizeof(int),
679 /* only handle a transition from default "0" to "1" */
680 .proc_handler = proc_dointvec_minmax,
685 #ifdef CONFIG_UEVENT_HELPER
687 .procname = "hotplug",
688 .data = &uevent_helper,
689 .maxlen = UEVENT_HELPER_PATH_LEN,
691 .proc_handler = proc_dostring,
694 #ifdef CONFIG_CHR_DEV_SG
696 .procname = "sg-big-buff",
697 .data = &sg_big_buff,
698 .maxlen = sizeof (int),
700 .proc_handler = proc_dointvec,
703 #ifdef CONFIG_BSD_PROCESS_ACCT
707 .maxlen = 3*sizeof(int),
709 .proc_handler = proc_dointvec,
712 #ifdef CONFIG_MAGIC_SYSRQ
715 .data = &__sysrq_enabled,
716 .maxlen = sizeof (int),
718 .proc_handler = sysrq_sysctl_handler,
721 #ifdef CONFIG_PROC_SYSCTL
723 .procname = "cad_pid",
725 .maxlen = sizeof (int),
727 .proc_handler = proc_do_cad_pid,
731 .procname = "threads-max",
733 .maxlen = sizeof(int),
735 .proc_handler = sysctl_max_threads,
738 .procname = "random",
740 .child = random_table,
743 .procname = "usermodehelper",
745 .child = usermodehelper_table,
747 #ifdef CONFIG_FW_LOADER_USER_HELPER
749 .procname = "firmware_config",
751 .child = firmware_config_table,
755 .procname = "overflowuid",
756 .data = &overflowuid,
757 .maxlen = sizeof(int),
759 .proc_handler = proc_dointvec_minmax,
760 .extra1 = &minolduid,
761 .extra2 = &maxolduid,
764 .procname = "overflowgid",
765 .data = &overflowgid,
766 .maxlen = sizeof(int),
768 .proc_handler = proc_dointvec_minmax,
769 .extra1 = &minolduid,
770 .extra2 = &maxolduid,
773 #ifdef CONFIG_MATHEMU
775 .procname = "ieee_emulation_warnings",
776 .data = &sysctl_ieee_emulation_warnings,
777 .maxlen = sizeof(int),
779 .proc_handler = proc_dointvec,
783 .procname = "userprocess_debug",
784 .data = &show_unhandled_signals,
785 .maxlen = sizeof(int),
787 .proc_handler = proc_dointvec,
791 .procname = "pid_max",
793 .maxlen = sizeof (int),
795 .proc_handler = proc_dointvec_minmax,
796 .extra1 = &pid_max_min,
797 .extra2 = &pid_max_max,
800 .procname = "panic_on_oops",
801 .data = &panic_on_oops,
802 .maxlen = sizeof(int),
804 .proc_handler = proc_dointvec,
806 #if defined CONFIG_PRINTK
808 .procname = "printk",
809 .data = &console_loglevel,
810 .maxlen = 4*sizeof(int),
812 .proc_handler = proc_dointvec,
815 .procname = "printk_ratelimit",
816 .data = &printk_ratelimit_state.interval,
817 .maxlen = sizeof(int),
819 .proc_handler = proc_dointvec_jiffies,
822 .procname = "printk_ratelimit_burst",
823 .data = &printk_ratelimit_state.burst,
824 .maxlen = sizeof(int),
826 .proc_handler = proc_dointvec,
829 .procname = "printk_delay",
830 .data = &printk_delay_msec,
831 .maxlen = sizeof(int),
833 .proc_handler = proc_dointvec_minmax,
835 .extra2 = &ten_thousand,
838 .procname = "printk_devkmsg",
839 .data = devkmsg_log_str,
840 .maxlen = DEVKMSG_STR_MAX_SIZE,
842 .proc_handler = devkmsg_sysctl_set_loglvl,
845 .procname = "dmesg_restrict",
846 .data = &dmesg_restrict,
847 .maxlen = sizeof(int),
849 .proc_handler = proc_dointvec_minmax_sysadmin,
854 .procname = "kptr_restrict",
855 .data = &kptr_restrict,
856 .maxlen = sizeof(int),
858 .proc_handler = proc_dointvec_minmax_sysadmin,
864 .procname = "ngroups_max",
865 .data = &ngroups_max,
866 .maxlen = sizeof (int),
868 .proc_handler = proc_dointvec,
871 .procname = "cap_last_cap",
872 .data = (void *)&cap_last_cap,
873 .maxlen = sizeof(int),
875 .proc_handler = proc_dointvec,
877 #if defined(CONFIG_LOCKUP_DETECTOR)
879 .procname = "watchdog",
880 .data = &watchdog_user_enabled,
881 .maxlen = sizeof(int),
883 .proc_handler = proc_watchdog,
888 .procname = "watchdog_thresh",
889 .data = &watchdog_thresh,
890 .maxlen = sizeof(int),
892 .proc_handler = proc_watchdog_thresh,
897 .procname = "nmi_watchdog",
898 .data = &nmi_watchdog_user_enabled,
899 .maxlen = sizeof(int),
900 .mode = NMI_WATCHDOG_SYSCTL_PERM,
901 .proc_handler = proc_nmi_watchdog,
906 .procname = "watchdog_cpumask",
907 .data = &watchdog_cpumask_bits,
910 .proc_handler = proc_watchdog_cpumask,
912 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
914 .procname = "soft_watchdog",
915 .data = &soft_watchdog_user_enabled,
916 .maxlen = sizeof(int),
918 .proc_handler = proc_soft_watchdog,
923 .procname = "softlockup_panic",
924 .data = &softlockup_panic,
925 .maxlen = sizeof(int),
927 .proc_handler = proc_dointvec_minmax,
933 .procname = "softlockup_all_cpu_backtrace",
934 .data = &sysctl_softlockup_all_cpu_backtrace,
935 .maxlen = sizeof(int),
937 .proc_handler = proc_dointvec_minmax,
941 #endif /* CONFIG_SMP */
943 #ifdef CONFIG_HARDLOCKUP_DETECTOR
945 .procname = "hardlockup_panic",
946 .data = &hardlockup_panic,
947 .maxlen = sizeof(int),
949 .proc_handler = proc_dointvec_minmax,
955 .procname = "hardlockup_all_cpu_backtrace",
956 .data = &sysctl_hardlockup_all_cpu_backtrace,
957 .maxlen = sizeof(int),
959 .proc_handler = proc_dointvec_minmax,
963 #endif /* CONFIG_SMP */
967 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
969 .procname = "unknown_nmi_panic",
970 .data = &unknown_nmi_panic,
971 .maxlen = sizeof (int),
973 .proc_handler = proc_dointvec,
976 #if defined(CONFIG_X86)
978 .procname = "panic_on_unrecovered_nmi",
979 .data = &panic_on_unrecovered_nmi,
980 .maxlen = sizeof(int),
982 .proc_handler = proc_dointvec,
985 .procname = "panic_on_io_nmi",
986 .data = &panic_on_io_nmi,
987 .maxlen = sizeof(int),
989 .proc_handler = proc_dointvec,
991 #ifdef CONFIG_DEBUG_STACKOVERFLOW
993 .procname = "panic_on_stackoverflow",
994 .data = &sysctl_panic_on_stackoverflow,
995 .maxlen = sizeof(int),
997 .proc_handler = proc_dointvec,
1001 .procname = "bootloader_type",
1002 .data = &bootloader_type,
1003 .maxlen = sizeof (int),
1005 .proc_handler = proc_dointvec,
1008 .procname = "bootloader_version",
1009 .data = &bootloader_version,
1010 .maxlen = sizeof (int),
1012 .proc_handler = proc_dointvec,
1015 .procname = "io_delay_type",
1016 .data = &io_delay_type,
1017 .maxlen = sizeof(int),
1019 .proc_handler = proc_dointvec,
1022 #if defined(CONFIG_MMU)
1024 .procname = "randomize_va_space",
1025 .data = &randomize_va_space,
1026 .maxlen = sizeof(int),
1028 .proc_handler = proc_dointvec,
1031 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1033 .procname = "spin_retry",
1034 .data = &spin_retry,
1035 .maxlen = sizeof (int),
1037 .proc_handler = proc_dointvec,
1040 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1042 .procname = "acpi_video_flags",
1043 .data = &acpi_realmode_flags,
1044 .maxlen = sizeof (unsigned long),
1046 .proc_handler = proc_doulongvec_minmax,
1049 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1051 .procname = "ignore-unaligned-usertrap",
1052 .data = &no_unaligned_warning,
1053 .maxlen = sizeof (int),
1055 .proc_handler = proc_dointvec,
1060 .procname = "unaligned-dump-stack",
1061 .data = &unaligned_dump_stack,
1062 .maxlen = sizeof (int),
1064 .proc_handler = proc_dointvec,
1067 #ifdef CONFIG_DETECT_HUNG_TASK
1069 .procname = "hung_task_panic",
1070 .data = &sysctl_hung_task_panic,
1071 .maxlen = sizeof(int),
1073 .proc_handler = proc_dointvec_minmax,
1078 .procname = "hung_task_check_count",
1079 .data = &sysctl_hung_task_check_count,
1080 .maxlen = sizeof(int),
1082 .proc_handler = proc_dointvec_minmax,
1086 .procname = "hung_task_timeout_secs",
1087 .data = &sysctl_hung_task_timeout_secs,
1088 .maxlen = sizeof(unsigned long),
1090 .proc_handler = proc_dohung_task_timeout_secs,
1091 .extra2 = &hung_task_timeout_max,
1094 .procname = "hung_task_warnings",
1095 .data = &sysctl_hung_task_warnings,
1096 .maxlen = sizeof(int),
1098 .proc_handler = proc_dointvec_minmax,
1102 #ifdef CONFIG_RT_MUTEXES
1104 .procname = "max_lock_depth",
1105 .data = &max_lock_depth,
1106 .maxlen = sizeof(int),
1108 .proc_handler = proc_dointvec,
1112 .procname = "poweroff_cmd",
1113 .data = &poweroff_cmd,
1114 .maxlen = POWEROFF_CMD_PATH_LEN,
1116 .proc_handler = proc_dostring,
1122 .child = key_sysctls,
1125 #ifdef CONFIG_PERF_EVENTS
1127 * User-space scripts rely on the existence of this file
1128 * as a feature check for perf_events being enabled.
1130 * So it's an ABI, do not remove!
1133 .procname = "perf_event_paranoid",
1134 .data = &sysctl_perf_event_paranoid,
1135 .maxlen = sizeof(sysctl_perf_event_paranoid),
1137 .proc_handler = proc_dointvec,
1140 .procname = "perf_event_mlock_kb",
1141 .data = &sysctl_perf_event_mlock,
1142 .maxlen = sizeof(sysctl_perf_event_mlock),
1144 .proc_handler = proc_dointvec,
1147 .procname = "perf_event_max_sample_rate",
1148 .data = &sysctl_perf_event_sample_rate,
1149 .maxlen = sizeof(sysctl_perf_event_sample_rate),
1151 .proc_handler = perf_proc_update_handler,
1155 .procname = "perf_cpu_time_max_percent",
1156 .data = &sysctl_perf_cpu_time_max_percent,
1157 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1159 .proc_handler = perf_cpu_time_max_percent_handler,
1161 .extra2 = &one_hundred,
1164 .procname = "perf_event_max_stack",
1165 .data = &sysctl_perf_event_max_stack,
1166 .maxlen = sizeof(sysctl_perf_event_max_stack),
1168 .proc_handler = perf_event_max_stack_handler,
1170 .extra2 = &six_hundred_forty_kb,
1173 .procname = "perf_event_max_contexts_per_stack",
1174 .data = &sysctl_perf_event_max_contexts_per_stack,
1175 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1177 .proc_handler = perf_event_max_stack_handler,
1179 .extra2 = &one_thousand,
1183 .procname = "panic_on_warn",
1184 .data = &panic_on_warn,
1185 .maxlen = sizeof(int),
1187 .proc_handler = proc_dointvec_minmax,
1191 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1193 .procname = "timer_migration",
1194 .data = &sysctl_timer_migration,
1195 .maxlen = sizeof(unsigned int),
1197 .proc_handler = timer_migration_handler,
1202 #ifdef CONFIG_BPF_SYSCALL
1204 .procname = "unprivileged_bpf_disabled",
1205 .data = &sysctl_unprivileged_bpf_disabled,
1206 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1208 /* only handle a transition from default "0" to "1" */
1209 .proc_handler = proc_dointvec_minmax,
1214 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1216 .procname = "panic_on_rcu_stall",
1217 .data = &sysctl_panic_on_rcu_stall,
1218 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1220 .proc_handler = proc_dointvec_minmax,
1228 static struct ctl_table vm_table[] = {
1230 .procname = "overcommit_memory",
1231 .data = &sysctl_overcommit_memory,
1232 .maxlen = sizeof(sysctl_overcommit_memory),
1234 .proc_handler = proc_dointvec_minmax,
1239 .procname = "panic_on_oom",
1240 .data = &sysctl_panic_on_oom,
1241 .maxlen = sizeof(sysctl_panic_on_oom),
1243 .proc_handler = proc_dointvec_minmax,
1248 .procname = "oom_kill_allocating_task",
1249 .data = &sysctl_oom_kill_allocating_task,
1250 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1252 .proc_handler = proc_dointvec,
1255 .procname = "oom_dump_tasks",
1256 .data = &sysctl_oom_dump_tasks,
1257 .maxlen = sizeof(sysctl_oom_dump_tasks),
1259 .proc_handler = proc_dointvec,
1262 .procname = "overcommit_ratio",
1263 .data = &sysctl_overcommit_ratio,
1264 .maxlen = sizeof(sysctl_overcommit_ratio),
1266 .proc_handler = overcommit_ratio_handler,
1269 .procname = "overcommit_kbytes",
1270 .data = &sysctl_overcommit_kbytes,
1271 .maxlen = sizeof(sysctl_overcommit_kbytes),
1273 .proc_handler = overcommit_kbytes_handler,
1276 .procname = "page-cluster",
1277 .data = &page_cluster,
1278 .maxlen = sizeof(int),
1280 .proc_handler = proc_dointvec_minmax,
1284 .procname = "dirty_background_ratio",
1285 .data = &dirty_background_ratio,
1286 .maxlen = sizeof(dirty_background_ratio),
1288 .proc_handler = dirty_background_ratio_handler,
1290 .extra2 = &one_hundred,
1293 .procname = "dirty_background_bytes",
1294 .data = &dirty_background_bytes,
1295 .maxlen = sizeof(dirty_background_bytes),
1297 .proc_handler = dirty_background_bytes_handler,
1301 .procname = "dirty_ratio",
1302 .data = &vm_dirty_ratio,
1303 .maxlen = sizeof(vm_dirty_ratio),
1305 .proc_handler = dirty_ratio_handler,
1307 .extra2 = &one_hundred,
1310 .procname = "dirty_bytes",
1311 .data = &vm_dirty_bytes,
1312 .maxlen = sizeof(vm_dirty_bytes),
1314 .proc_handler = dirty_bytes_handler,
1315 .extra1 = &dirty_bytes_min,
1318 .procname = "dirty_writeback_centisecs",
1319 .data = &dirty_writeback_interval,
1320 .maxlen = sizeof(dirty_writeback_interval),
1322 .proc_handler = dirty_writeback_centisecs_handler,
1325 .procname = "dirty_expire_centisecs",
1326 .data = &dirty_expire_interval,
1327 .maxlen = sizeof(dirty_expire_interval),
1329 .proc_handler = proc_dointvec_minmax,
1333 .procname = "dirtytime_expire_seconds",
1334 .data = &dirtytime_expire_interval,
1335 .maxlen = sizeof(dirtytime_expire_interval),
1337 .proc_handler = dirtytime_interval_handler,
1341 .procname = "swappiness",
1342 .data = &vm_swappiness,
1343 .maxlen = sizeof(vm_swappiness),
1345 .proc_handler = proc_dointvec_minmax,
1347 .extra2 = &one_hundred,
1349 #ifdef CONFIG_HUGETLB_PAGE
1351 .procname = "nr_hugepages",
1353 .maxlen = sizeof(unsigned long),
1355 .proc_handler = hugetlb_sysctl_handler,
1359 .procname = "nr_hugepages_mempolicy",
1361 .maxlen = sizeof(unsigned long),
1363 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1366 .procname = "numa_stat",
1367 .data = &sysctl_vm_numa_stat,
1368 .maxlen = sizeof(int),
1370 .proc_handler = sysctl_vm_numa_stat_handler,
1376 .procname = "hugetlb_shm_group",
1377 .data = &sysctl_hugetlb_shm_group,
1378 .maxlen = sizeof(gid_t),
1380 .proc_handler = proc_dointvec,
1383 .procname = "nr_overcommit_hugepages",
1385 .maxlen = sizeof(unsigned long),
1387 .proc_handler = hugetlb_overcommit_handler,
1391 .procname = "lowmem_reserve_ratio",
1392 .data = &sysctl_lowmem_reserve_ratio,
1393 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1395 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
1398 .procname = "drop_caches",
1399 .data = &sysctl_drop_caches,
1400 .maxlen = sizeof(int),
1402 .proc_handler = drop_caches_sysctl_handler,
1406 #ifdef CONFIG_COMPACTION
1408 .procname = "compact_memory",
1409 .data = &sysctl_compact_memory,
1410 .maxlen = sizeof(int),
1412 .proc_handler = sysctl_compaction_handler,
1415 .procname = "extfrag_threshold",
1416 .data = &sysctl_extfrag_threshold,
1417 .maxlen = sizeof(int),
1419 .proc_handler = sysctl_extfrag_handler,
1420 .extra1 = &min_extfrag_threshold,
1421 .extra2 = &max_extfrag_threshold,
1424 .procname = "compact_unevictable_allowed",
1425 .data = &sysctl_compact_unevictable_allowed,
1426 .maxlen = sizeof(int),
1428 .proc_handler = proc_dointvec,
1433 #endif /* CONFIG_COMPACTION */
1435 .procname = "min_free_kbytes",
1436 .data = &min_free_kbytes,
1437 .maxlen = sizeof(min_free_kbytes),
1439 .proc_handler = min_free_kbytes_sysctl_handler,
1443 .procname = "watermark_scale_factor",
1444 .data = &watermark_scale_factor,
1445 .maxlen = sizeof(watermark_scale_factor),
1447 .proc_handler = watermark_scale_factor_sysctl_handler,
1449 .extra2 = &one_thousand,
1452 .procname = "percpu_pagelist_fraction",
1453 .data = &percpu_pagelist_fraction,
1454 .maxlen = sizeof(percpu_pagelist_fraction),
1456 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
1461 .procname = "max_map_count",
1462 .data = &sysctl_max_map_count,
1463 .maxlen = sizeof(sysctl_max_map_count),
1465 .proc_handler = proc_dointvec_minmax,
1470 .procname = "nr_trim_pages",
1471 .data = &sysctl_nr_trim_pages,
1472 .maxlen = sizeof(sysctl_nr_trim_pages),
1474 .proc_handler = proc_dointvec_minmax,
1479 .procname = "laptop_mode",
1480 .data = &laptop_mode,
1481 .maxlen = sizeof(laptop_mode),
1483 .proc_handler = proc_dointvec_jiffies,
1486 .procname = "block_dump",
1487 .data = &block_dump,
1488 .maxlen = sizeof(block_dump),
1490 .proc_handler = proc_dointvec,
1494 .procname = "vfs_cache_pressure",
1495 .data = &sysctl_vfs_cache_pressure,
1496 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1498 .proc_handler = proc_dointvec,
1501 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1503 .procname = "legacy_va_layout",
1504 .data = &sysctl_legacy_va_layout,
1505 .maxlen = sizeof(sysctl_legacy_va_layout),
1507 .proc_handler = proc_dointvec,
1513 .procname = "zone_reclaim_mode",
1514 .data = &node_reclaim_mode,
1515 .maxlen = sizeof(node_reclaim_mode),
1517 .proc_handler = proc_dointvec,
1521 .procname = "min_unmapped_ratio",
1522 .data = &sysctl_min_unmapped_ratio,
1523 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1525 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
1527 .extra2 = &one_hundred,
1530 .procname = "min_slab_ratio",
1531 .data = &sysctl_min_slab_ratio,
1532 .maxlen = sizeof(sysctl_min_slab_ratio),
1534 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
1536 .extra2 = &one_hundred,
1541 .procname = "stat_interval",
1542 .data = &sysctl_stat_interval,
1543 .maxlen = sizeof(sysctl_stat_interval),
1545 .proc_handler = proc_dointvec_jiffies,
1548 .procname = "stat_refresh",
1552 .proc_handler = vmstat_refresh,
1557 .procname = "mmap_min_addr",
1558 .data = &dac_mmap_min_addr,
1559 .maxlen = sizeof(unsigned long),
1561 .proc_handler = mmap_min_addr_handler,
1566 .procname = "numa_zonelist_order",
1567 .data = &numa_zonelist_order,
1568 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1570 .proc_handler = numa_zonelist_order_handler,
1573 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1574 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1576 .procname = "vdso_enabled",
1577 #ifdef CONFIG_X86_32
1578 .data = &vdso32_enabled,
1579 .maxlen = sizeof(vdso32_enabled),
1581 .data = &vdso_enabled,
1582 .maxlen = sizeof(vdso_enabled),
1585 .proc_handler = proc_dointvec,
1589 #ifdef CONFIG_HIGHMEM
1591 .procname = "highmem_is_dirtyable",
1592 .data = &vm_highmem_is_dirtyable,
1593 .maxlen = sizeof(vm_highmem_is_dirtyable),
1595 .proc_handler = proc_dointvec_minmax,
1600 #ifdef CONFIG_MEMORY_FAILURE
1602 .procname = "memory_failure_early_kill",
1603 .data = &sysctl_memory_failure_early_kill,
1604 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1606 .proc_handler = proc_dointvec_minmax,
1611 .procname = "memory_failure_recovery",
1612 .data = &sysctl_memory_failure_recovery,
1613 .maxlen = sizeof(sysctl_memory_failure_recovery),
1615 .proc_handler = proc_dointvec_minmax,
1621 .procname = "user_reserve_kbytes",
1622 .data = &sysctl_user_reserve_kbytes,
1623 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1625 .proc_handler = proc_doulongvec_minmax,
1628 .procname = "admin_reserve_kbytes",
1629 .data = &sysctl_admin_reserve_kbytes,
1630 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1632 .proc_handler = proc_doulongvec_minmax,
1634 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1636 .procname = "mmap_rnd_bits",
1637 .data = &mmap_rnd_bits,
1638 .maxlen = sizeof(mmap_rnd_bits),
1640 .proc_handler = proc_dointvec_minmax,
1641 .extra1 = (void *)&mmap_rnd_bits_min,
1642 .extra2 = (void *)&mmap_rnd_bits_max,
1645 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1647 .procname = "mmap_rnd_compat_bits",
1648 .data = &mmap_rnd_compat_bits,
1649 .maxlen = sizeof(mmap_rnd_compat_bits),
1651 .proc_handler = proc_dointvec_minmax,
1652 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1653 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1659 static struct ctl_table fs_table[] = {
1661 .procname = "inode-nr",
1662 .data = &inodes_stat,
1663 .maxlen = 2*sizeof(long),
1665 .proc_handler = proc_nr_inodes,
1668 .procname = "inode-state",
1669 .data = &inodes_stat,
1670 .maxlen = 7*sizeof(long),
1672 .proc_handler = proc_nr_inodes,
1675 .procname = "file-nr",
1676 .data = &files_stat,
1677 .maxlen = sizeof(files_stat),
1679 .proc_handler = proc_nr_files,
1682 .procname = "file-max",
1683 .data = &files_stat.max_files,
1684 .maxlen = sizeof(files_stat.max_files),
1686 .proc_handler = proc_doulongvec_minmax,
1689 .procname = "nr_open",
1690 .data = &sysctl_nr_open,
1691 .maxlen = sizeof(unsigned int),
1693 .proc_handler = proc_dointvec_minmax,
1694 .extra1 = &sysctl_nr_open_min,
1695 .extra2 = &sysctl_nr_open_max,
1698 .procname = "dentry-state",
1699 .data = &dentry_stat,
1700 .maxlen = 6*sizeof(long),
1702 .proc_handler = proc_nr_dentry,
1705 .procname = "overflowuid",
1706 .data = &fs_overflowuid,
1707 .maxlen = sizeof(int),
1709 .proc_handler = proc_dointvec_minmax,
1710 .extra1 = &minolduid,
1711 .extra2 = &maxolduid,
1714 .procname = "overflowgid",
1715 .data = &fs_overflowgid,
1716 .maxlen = sizeof(int),
1718 .proc_handler = proc_dointvec_minmax,
1719 .extra1 = &minolduid,
1720 .extra2 = &maxolduid,
1722 #ifdef CONFIG_FILE_LOCKING
1724 .procname = "leases-enable",
1725 .data = &leases_enable,
1726 .maxlen = sizeof(int),
1728 .proc_handler = proc_dointvec,
1731 #ifdef CONFIG_DNOTIFY
1733 .procname = "dir-notify-enable",
1734 .data = &dir_notify_enable,
1735 .maxlen = sizeof(int),
1737 .proc_handler = proc_dointvec,
1741 #ifdef CONFIG_FILE_LOCKING
1743 .procname = "lease-break-time",
1744 .data = &lease_break_time,
1745 .maxlen = sizeof(int),
1747 .proc_handler = proc_dointvec,
1752 .procname = "aio-nr",
1754 .maxlen = sizeof(aio_nr),
1756 .proc_handler = proc_doulongvec_minmax,
1759 .procname = "aio-max-nr",
1760 .data = &aio_max_nr,
1761 .maxlen = sizeof(aio_max_nr),
1763 .proc_handler = proc_doulongvec_minmax,
1765 #endif /* CONFIG_AIO */
1766 #ifdef CONFIG_INOTIFY_USER
1768 .procname = "inotify",
1770 .child = inotify_table,
1775 .procname = "epoll",
1777 .child = epoll_table,
1782 .procname = "protected_symlinks",
1783 .data = &sysctl_protected_symlinks,
1784 .maxlen = sizeof(int),
1786 .proc_handler = proc_dointvec_minmax,
1791 .procname = "protected_hardlinks",
1792 .data = &sysctl_protected_hardlinks,
1793 .maxlen = sizeof(int),
1795 .proc_handler = proc_dointvec_minmax,
1800 .procname = "suid_dumpable",
1801 .data = &suid_dumpable,
1802 .maxlen = sizeof(int),
1804 .proc_handler = proc_dointvec_minmax_coredump,
1808 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1810 .procname = "binfmt_misc",
1812 .child = sysctl_mount_point,
1816 .procname = "pipe-max-size",
1817 .data = &pipe_max_size,
1818 .maxlen = sizeof(pipe_max_size),
1820 .proc_handler = proc_dopipe_max_size,
1823 .procname = "pipe-user-pages-hard",
1824 .data = &pipe_user_pages_hard,
1825 .maxlen = sizeof(pipe_user_pages_hard),
1827 .proc_handler = proc_doulongvec_minmax,
1830 .procname = "pipe-user-pages-soft",
1831 .data = &pipe_user_pages_soft,
1832 .maxlen = sizeof(pipe_user_pages_soft),
1834 .proc_handler = proc_doulongvec_minmax,
1837 .procname = "mount-max",
1838 .data = &sysctl_mount_max,
1839 .maxlen = sizeof(unsigned int),
1841 .proc_handler = proc_dointvec_minmax,
1847 static struct ctl_table debug_table[] = {
1848 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1850 .procname = "exception-trace",
1851 .data = &show_unhandled_signals,
1852 .maxlen = sizeof(int),
1854 .proc_handler = proc_dointvec
1857 #if defined(CONFIG_OPTPROBES)
1859 .procname = "kprobes-optimization",
1860 .data = &sysctl_kprobes_optimization,
1861 .maxlen = sizeof(int),
1863 .proc_handler = proc_kprobes_optimization_handler,
1871 static struct ctl_table dev_table[] = {
1875 int __init sysctl_init(void)
1877 struct ctl_table_header *hdr;
1879 hdr = register_sysctl_table(sysctl_base_table);
1880 kmemleak_not_leak(hdr);
1884 #endif /* CONFIG_SYSCTL */
1890 #ifdef CONFIG_PROC_SYSCTL
1892 static int _proc_do_string(char *data, int maxlen, int write,
1893 char __user *buffer,
1894 size_t *lenp, loff_t *ppos)
1900 if (!data || !maxlen || !*lenp) {
1906 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1907 /* Only continue writes not past the end of buffer. */
1909 if (len > maxlen - 1)
1916 /* Start writing from beginning of buffer. */
1922 while ((p - buffer) < *lenp && len < maxlen - 1) {
1923 if (get_user(c, p++))
1925 if (c == 0 || c == '\n')
1946 if (copy_to_user(buffer, data, len))
1949 if (put_user('\n', buffer + len))
1959 static void warn_sysctl_write(struct ctl_table *table)
1961 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1962 "This will not be supported in the future. To silence this\n"
1963 "warning, set kernel.sysctl_writes_strict = -1\n",
1964 current->comm, table->procname);
1968 * proc_first_pos_non_zero_ignore - check if firs position is allowed
1969 * @ppos: file position
1970 * @table: the sysctl table
1972 * Returns true if the first position is non-zero and the sysctl_writes_strict
1973 * mode indicates this is not allowed for numeric input types. String proc
1974 * hadlers can ignore the return value.
1976 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
1977 struct ctl_table *table)
1982 switch (sysctl_writes_strict) {
1983 case SYSCTL_WRITES_STRICT:
1985 case SYSCTL_WRITES_WARN:
1986 warn_sysctl_write(table);
1994 * proc_dostring - read a string sysctl
1995 * @table: the sysctl table
1996 * @write: %TRUE if this is a write to the sysctl file
1997 * @buffer: the user buffer
1998 * @lenp: the size of the user buffer
1999 * @ppos: file position
2001 * Reads/writes a string from/to the user buffer. If the kernel
2002 * buffer provided is not large enough to hold the string, the
2003 * string is truncated. The copied string is %NULL-terminated.
2004 * If the string is being read by the user process, it is copied
2005 * and a newline '\n' is added. It is truncated if the buffer is
2008 * Returns 0 on success.
2010 int proc_dostring(struct ctl_table *table, int write,
2011 void __user *buffer, size_t *lenp, loff_t *ppos)
2014 proc_first_pos_non_zero_ignore(ppos, table);
2016 return _proc_do_string((char *)(table->data), table->maxlen, write,
2017 (char __user *)buffer, lenp, ppos);
2020 static size_t proc_skip_spaces(char **buf)
2023 char *tmp = skip_spaces(*buf);
2029 static void proc_skip_char(char **buf, size_t *size, const char v)
2039 #define TMPBUFLEN 22
2041 * proc_get_long - reads an ASCII formatted integer from a user buffer
2043 * @buf: a kernel buffer
2044 * @size: size of the kernel buffer
2045 * @val: this is where the number will be stored
2046 * @neg: set to %TRUE if number is negative
2047 * @perm_tr: a vector which contains the allowed trailers
2048 * @perm_tr_len: size of the perm_tr vector
2049 * @tr: pointer to store the trailer character
2051 * In case of success %0 is returned and @buf and @size are updated with
2052 * the amount of bytes read. If @tr is non-NULL and a trailing
2053 * character exists (size is non-zero after returning from this
2054 * function), @tr is updated with the trailing character.
2056 static int proc_get_long(char **buf, size_t *size,
2057 unsigned long *val, bool *neg,
2058 const char *perm_tr, unsigned perm_tr_len, char *tr)
2061 char *p, tmp[TMPBUFLEN];
2067 if (len > TMPBUFLEN - 1)
2068 len = TMPBUFLEN - 1;
2070 memcpy(tmp, *buf, len);
2074 if (*p == '-' && *size > 1) {
2082 *val = simple_strtoul(p, &p, 0);
2086 /* We don't know if the next char is whitespace thus we may accept
2087 * invalid integers (e.g. 1234...a) or two integers instead of one
2088 * (e.g. 123...1). So lets not allow such large numbers. */
2089 if (len == TMPBUFLEN - 1)
2092 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2095 if (tr && (len < *size))
2105 * proc_put_long - converts an integer to a decimal ASCII formatted string
2107 * @buf: the user buffer
2108 * @size: the size of the user buffer
2109 * @val: the integer to be converted
2110 * @neg: sign of the number, %TRUE for negative
2112 * In case of success %0 is returned and @buf and @size are updated with
2113 * the amount of bytes written.
2115 static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2119 char tmp[TMPBUFLEN], *p = tmp;
2121 sprintf(p, "%s%lu", neg ? "-" : "", val);
2125 if (copy_to_user(*buf, tmp, len))
2133 static int proc_put_char(void __user **buf, size_t *size, char c)
2136 char __user **buffer = (char __user **)buf;
2137 if (put_user(c, *buffer))
2139 (*size)--, (*buffer)++;
2145 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
2147 int write, void *data)
2151 if (*lvalp > (unsigned long) INT_MAX + 1)
2155 if (*lvalp > (unsigned long) INT_MAX)
2163 *lvalp = -(unsigned long)val;
2166 *lvalp = (unsigned long)val;
2172 static int do_proc_douintvec_conv(unsigned long *lvalp,
2174 int write, void *data)
2177 if (*lvalp > UINT_MAX)
2181 unsigned int val = *valp;
2182 *lvalp = (unsigned long)val;
2187 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2189 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
2190 int write, void __user *buffer,
2191 size_t *lenp, loff_t *ppos,
2192 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2193 int write, void *data),
2196 int *i, vleft, first = 1, err = 0;
2198 char *kbuf = NULL, *p;
2200 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2205 i = (int *) tbl_data;
2206 vleft = table->maxlen / sizeof(*i);
2210 conv = do_proc_dointvec_conv;
2213 if (proc_first_pos_non_zero_ignore(ppos, table))
2216 if (left > PAGE_SIZE - 1)
2217 left = PAGE_SIZE - 1;
2218 p = kbuf = memdup_user_nul(buffer, left);
2220 return PTR_ERR(kbuf);
2223 for (; left && vleft--; i++, first=0) {
2228 left -= proc_skip_spaces(&p);
2232 err = proc_get_long(&p, &left, &lval, &neg,
2234 sizeof(proc_wspace_sep), NULL);
2237 if (conv(&neg, &lval, i, 1, data)) {
2242 if (conv(&neg, &lval, i, 0, data)) {
2247 err = proc_put_char(&buffer, &left, '\t');
2250 err = proc_put_long(&buffer, &left, lval, neg);
2256 if (!write && !first && left && !err)
2257 err = proc_put_char(&buffer, &left, '\n');
2258 if (write && !err && left)
2259 left -= proc_skip_spaces(&p);
2263 return err ? : -EINVAL;
2271 static int do_proc_dointvec(struct ctl_table *table, int write,
2272 void __user *buffer, size_t *lenp, loff_t *ppos,
2273 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2274 int write, void *data),
2277 return __do_proc_dointvec(table->data, table, write,
2278 buffer, lenp, ppos, conv, data);
2281 static int do_proc_douintvec_w(unsigned int *tbl_data,
2282 struct ctl_table *table,
2283 void __user *buffer,
2284 size_t *lenp, loff_t *ppos,
2285 int (*conv)(unsigned long *lvalp,
2287 int write, void *data),
2294 char *kbuf = NULL, *p;
2298 if (proc_first_pos_non_zero_ignore(ppos, table))
2301 if (left > PAGE_SIZE - 1)
2302 left = PAGE_SIZE - 1;
2304 p = kbuf = memdup_user_nul(buffer, left);
2308 left -= proc_skip_spaces(&p);
2314 err = proc_get_long(&p, &left, &lval, &neg,
2316 sizeof(proc_wspace_sep), NULL);
2322 if (conv(&lval, tbl_data, 1, data)) {
2328 left -= proc_skip_spaces(&p);
2337 /* This is in keeping with old __do_proc_dointvec() */
2343 static int do_proc_douintvec_r(unsigned int *tbl_data, void __user *buffer,
2344 size_t *lenp, loff_t *ppos,
2345 int (*conv)(unsigned long *lvalp,
2347 int write, void *data),
2356 if (conv(&lval, tbl_data, 0, data)) {
2361 err = proc_put_long(&buffer, &left, lval, false);
2365 err = proc_put_char(&buffer, &left, '\n');
2374 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
2375 int write, void __user *buffer,
2376 size_t *lenp, loff_t *ppos,
2377 int (*conv)(unsigned long *lvalp,
2379 int write, void *data),
2382 unsigned int *i, vleft;
2384 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2389 i = (unsigned int *) tbl_data;
2390 vleft = table->maxlen / sizeof(*i);
2393 * Arrays are not supported, keep this simple. *Do not* add
2402 conv = do_proc_douintvec_conv;
2405 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
2407 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
2410 static int do_proc_douintvec(struct ctl_table *table, int write,
2411 void __user *buffer, size_t *lenp, loff_t *ppos,
2412 int (*conv)(unsigned long *lvalp,
2414 int write, void *data),
2417 return __do_proc_douintvec(table->data, table, write,
2418 buffer, lenp, ppos, conv, data);
2422 * proc_dointvec - read a vector of integers
2423 * @table: the sysctl table
2424 * @write: %TRUE if this is a write to the sysctl file
2425 * @buffer: the user buffer
2426 * @lenp: the size of the user buffer
2427 * @ppos: file position
2429 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2430 * values from/to the user buffer, treated as an ASCII string.
2432 * Returns 0 on success.
2434 int proc_dointvec(struct ctl_table *table, int write,
2435 void __user *buffer, size_t *lenp, loff_t *ppos)
2437 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2441 * proc_douintvec - read a vector of unsigned integers
2442 * @table: the sysctl table
2443 * @write: %TRUE if this is a write to the sysctl file
2444 * @buffer: the user buffer
2445 * @lenp: the size of the user buffer
2446 * @ppos: file position
2448 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2449 * values from/to the user buffer, treated as an ASCII string.
2451 * Returns 0 on success.
2453 int proc_douintvec(struct ctl_table *table, int write,
2454 void __user *buffer, size_t *lenp, loff_t *ppos)
2456 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2457 do_proc_douintvec_conv, NULL);
2461 * Taint values can only be increased
2462 * This means we can safely use a temporary.
2464 static int proc_taint(struct ctl_table *table, int write,
2465 void __user *buffer, size_t *lenp, loff_t *ppos)
2468 unsigned long tmptaint = get_taint();
2471 if (write && !capable(CAP_SYS_ADMIN))
2476 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
2482 * Poor man's atomic or. Not worth adding a primitive
2483 * to everyone's atomic.h for this
2486 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2487 if ((tmptaint >> i) & 1)
2488 add_taint(i, LOCKDEP_STILL_OK);
2495 #ifdef CONFIG_PRINTK
2496 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
2497 void __user *buffer, size_t *lenp, loff_t *ppos)
2499 if (write && !capable(CAP_SYS_ADMIN))
2502 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2507 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
2508 * @min: pointer to minimum allowable value
2509 * @max: pointer to maximum allowable value
2511 * The do_proc_dointvec_minmax_conv_param structure provides the
2512 * minimum and maximum values for doing range checking for those sysctl
2513 * parameters that use the proc_dointvec_minmax() handler.
2515 struct do_proc_dointvec_minmax_conv_param {
2520 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2522 int write, void *data)
2524 struct do_proc_dointvec_minmax_conv_param *param = data;
2526 int val = *negp ? -*lvalp : *lvalp;
2527 if ((param->min && *param->min > val) ||
2528 (param->max && *param->max < val))
2535 *lvalp = -(unsigned long)val;
2538 *lvalp = (unsigned long)val;
2545 * proc_dointvec_minmax - read a vector of integers with min/max values
2546 * @table: the sysctl table
2547 * @write: %TRUE if this is a write to the sysctl file
2548 * @buffer: the user buffer
2549 * @lenp: the size of the user buffer
2550 * @ppos: file position
2552 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2553 * values from/to the user buffer, treated as an ASCII string.
2555 * This routine will ensure the values are within the range specified by
2556 * table->extra1 (min) and table->extra2 (max).
2558 * Returns 0 on success or -EINVAL on write when the range check fails.
2560 int proc_dointvec_minmax(struct ctl_table *table, int write,
2561 void __user *buffer, size_t *lenp, loff_t *ppos)
2563 struct do_proc_dointvec_minmax_conv_param param = {
2564 .min = (int *) table->extra1,
2565 .max = (int *) table->extra2,
2567 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2568 do_proc_dointvec_minmax_conv, ¶m);
2572 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
2573 * @min: pointer to minimum allowable value
2574 * @max: pointer to maximum allowable value
2576 * The do_proc_douintvec_minmax_conv_param structure provides the
2577 * minimum and maximum values for doing range checking for those sysctl
2578 * parameters that use the proc_douintvec_minmax() handler.
2580 struct do_proc_douintvec_minmax_conv_param {
2585 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
2587 int write, void *data)
2589 struct do_proc_douintvec_minmax_conv_param *param = data;
2592 unsigned int val = *lvalp;
2594 if (*lvalp > UINT_MAX)
2597 if ((param->min && *param->min > val) ||
2598 (param->max && *param->max < val))
2603 unsigned int val = *valp;
2604 *lvalp = (unsigned long) val;
2611 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2612 * @table: the sysctl table
2613 * @write: %TRUE if this is a write to the sysctl file
2614 * @buffer: the user buffer
2615 * @lenp: the size of the user buffer
2616 * @ppos: file position
2618 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2619 * values from/to the user buffer, treated as an ASCII string. Negative
2620 * strings are not allowed.
2622 * This routine will ensure the values are within the range specified by
2623 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2624 * check for UINT_MAX to avoid having to support wrap around uses from
2627 * Returns 0 on success or -ERANGE on write when the range check fails.
2629 int proc_douintvec_minmax(struct ctl_table *table, int write,
2630 void __user *buffer, size_t *lenp, loff_t *ppos)
2632 struct do_proc_douintvec_minmax_conv_param param = {
2633 .min = (unsigned int *) table->extra1,
2634 .max = (unsigned int *) table->extra2,
2636 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2637 do_proc_douintvec_minmax_conv, ¶m);
2640 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
2642 int write, void *data)
2647 val = round_pipe_size(*lvalp);
2653 unsigned int val = *valp;
2654 *lvalp = (unsigned long) val;
2660 static int proc_dopipe_max_size(struct ctl_table *table, int write,
2661 void __user *buffer, size_t *lenp, loff_t *ppos)
2663 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2664 do_proc_dopipe_max_size_conv, NULL);
2667 static void validate_coredump_safety(void)
2669 #ifdef CONFIG_COREDUMP
2670 if (suid_dumpable == SUID_DUMP_ROOT &&
2671 core_pattern[0] != '/' && core_pattern[0] != '|') {
2673 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2674 "Pipe handler or fully qualified core dump path required.\n"
2675 "Set kernel.core_pattern before fs.suid_dumpable.\n"
2681 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2682 void __user *buffer, size_t *lenp, loff_t *ppos)
2684 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2686 validate_coredump_safety();
2690 #ifdef CONFIG_COREDUMP
2691 static int proc_dostring_coredump(struct ctl_table *table, int write,
2692 void __user *buffer, size_t *lenp, loff_t *ppos)
2694 int error = proc_dostring(table, write, buffer, lenp, ppos);
2696 validate_coredump_safety();
2701 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
2702 void __user *buffer,
2703 size_t *lenp, loff_t *ppos,
2704 unsigned long convmul,
2705 unsigned long convdiv)
2707 unsigned long *i, *min, *max;
2708 int vleft, first = 1, err = 0;
2710 char *kbuf = NULL, *p;
2712 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
2717 i = (unsigned long *) data;
2718 min = (unsigned long *) table->extra1;
2719 max = (unsigned long *) table->extra2;
2720 vleft = table->maxlen / sizeof(unsigned long);
2724 if (proc_first_pos_non_zero_ignore(ppos, table))
2727 if (left > PAGE_SIZE - 1)
2728 left = PAGE_SIZE - 1;
2729 p = kbuf = memdup_user_nul(buffer, left);
2731 return PTR_ERR(kbuf);
2734 for (; left && vleft--; i++, first = 0) {
2740 left -= proc_skip_spaces(&p);
2742 err = proc_get_long(&p, &left, &val, &neg,
2744 sizeof(proc_wspace_sep), NULL);
2749 val = convmul * val / convdiv;
2750 if ((min && val < *min) || (max && val > *max))
2754 val = convdiv * (*i) / convmul;
2756 err = proc_put_char(&buffer, &left, '\t');
2760 err = proc_put_long(&buffer, &left, val, false);
2766 if (!write && !first && left && !err)
2767 err = proc_put_char(&buffer, &left, '\n');
2769 left -= proc_skip_spaces(&p);
2773 return err ? : -EINVAL;
2781 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2782 void __user *buffer,
2783 size_t *lenp, loff_t *ppos,
2784 unsigned long convmul,
2785 unsigned long convdiv)
2787 return __do_proc_doulongvec_minmax(table->data, table, write,
2788 buffer, lenp, ppos, convmul, convdiv);
2792 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2793 * @table: the sysctl table
2794 * @write: %TRUE if this is a write to the sysctl file
2795 * @buffer: the user buffer
2796 * @lenp: the size of the user buffer
2797 * @ppos: file position
2799 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2800 * values from/to the user buffer, treated as an ASCII string.
2802 * This routine will ensure the values are within the range specified by
2803 * table->extra1 (min) and table->extra2 (max).
2805 * Returns 0 on success.
2807 int proc_doulongvec_minmax(struct ctl_table *table, int write,
2808 void __user *buffer, size_t *lenp, loff_t *ppos)
2810 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
2814 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2815 * @table: the sysctl table
2816 * @write: %TRUE if this is a write to the sysctl file
2817 * @buffer: the user buffer
2818 * @lenp: the size of the user buffer
2819 * @ppos: file position
2821 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2822 * values from/to the user buffer, treated as an ASCII string. The values
2823 * are treated as milliseconds, and converted to jiffies when they are stored.
2825 * This routine will ensure the values are within the range specified by
2826 * table->extra1 (min) and table->extra2 (max).
2828 * Returns 0 on success.
2830 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2831 void __user *buffer,
2832 size_t *lenp, loff_t *ppos)
2834 return do_proc_doulongvec_minmax(table, write, buffer,
2835 lenp, ppos, HZ, 1000l);
2839 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
2841 int write, void *data)
2844 if (*lvalp > INT_MAX / HZ)
2846 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2852 lval = -(unsigned long)val;
2855 lval = (unsigned long)val;
2862 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
2864 int write, void *data)
2867 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2869 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2875 lval = -(unsigned long)val;
2878 lval = (unsigned long)val;
2880 *lvalp = jiffies_to_clock_t(lval);
2885 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
2887 int write, void *data)
2890 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2900 lval = -(unsigned long)val;
2903 lval = (unsigned long)val;
2905 *lvalp = jiffies_to_msecs(lval);
2911 * proc_dointvec_jiffies - read a vector of integers as seconds
2912 * @table: the sysctl table
2913 * @write: %TRUE if this is a write to the sysctl file
2914 * @buffer: the user buffer
2915 * @lenp: the size of the user buffer
2916 * @ppos: file position
2918 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2919 * values from/to the user buffer, treated as an ASCII string.
2920 * The values read are assumed to be in seconds, and are converted into
2923 * Returns 0 on success.
2925 int proc_dointvec_jiffies(struct ctl_table *table, int write,
2926 void __user *buffer, size_t *lenp, loff_t *ppos)
2928 return do_proc_dointvec(table,write,buffer,lenp,ppos,
2929 do_proc_dointvec_jiffies_conv,NULL);
2933 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2934 * @table: the sysctl table
2935 * @write: %TRUE if this is a write to the sysctl file
2936 * @buffer: the user buffer
2937 * @lenp: the size of the user buffer
2938 * @ppos: pointer to the file position
2940 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2941 * values from/to the user buffer, treated as an ASCII string.
2942 * The values read are assumed to be in 1/USER_HZ seconds, and
2943 * are converted into jiffies.
2945 * Returns 0 on success.
2947 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
2948 void __user *buffer, size_t *lenp, loff_t *ppos)
2950 return do_proc_dointvec(table,write,buffer,lenp,ppos,
2951 do_proc_dointvec_userhz_jiffies_conv,NULL);
2955 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2956 * @table: the sysctl table
2957 * @write: %TRUE if this is a write to the sysctl file
2958 * @buffer: the user buffer
2959 * @lenp: the size of the user buffer
2960 * @ppos: file position
2961 * @ppos: the current position in the file
2963 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2964 * values from/to the user buffer, treated as an ASCII string.
2965 * The values read are assumed to be in 1/1000 seconds, and
2966 * are converted into jiffies.
2968 * Returns 0 on success.
2970 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
2971 void __user *buffer, size_t *lenp, loff_t *ppos)
2973 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2974 do_proc_dointvec_ms_jiffies_conv, NULL);
2977 static int proc_do_cad_pid(struct ctl_table *table, int write,
2978 void __user *buffer, size_t *lenp, loff_t *ppos)
2980 struct pid *new_pid;
2984 tmp = pid_vnr(cad_pid);
2986 r = __do_proc_dointvec(&tmp, table, write, buffer,
2987 lenp, ppos, NULL, NULL);
2991 new_pid = find_get_pid(tmp);
2995 put_pid(xchg(&cad_pid, new_pid));
3000 * proc_do_large_bitmap - read/write from/to a large bitmap
3001 * @table: the sysctl table
3002 * @write: %TRUE if this is a write to the sysctl file
3003 * @buffer: the user buffer
3004 * @lenp: the size of the user buffer
3005 * @ppos: file position
3007 * The bitmap is stored at table->data and the bitmap length (in bits)
3010 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
3011 * large bitmaps may be represented in a compact manner. Writing into
3012 * the file will clear the bitmap then update it with the given input.
3014 * Returns 0 on success.
3016 int proc_do_large_bitmap(struct ctl_table *table, int write,
3017 void __user *buffer, size_t *lenp, loff_t *ppos)
3021 size_t left = *lenp;
3022 unsigned long bitmap_len = table->maxlen;
3023 unsigned long *bitmap = *(unsigned long **) table->data;
3024 unsigned long *tmp_bitmap = NULL;
3025 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
3027 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
3035 if (left > PAGE_SIZE - 1)
3036 left = PAGE_SIZE - 1;
3038 p = kbuf = memdup_user_nul(buffer, left);
3040 return PTR_ERR(kbuf);
3042 tmp_bitmap = kcalloc(BITS_TO_LONGS(bitmap_len),
3043 sizeof(unsigned long),
3049 proc_skip_char(&p, &left, '\n');
3050 while (!err && left) {
3051 unsigned long val_a, val_b;
3054 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
3058 if (val_a >= bitmap_len || neg) {
3070 err = proc_get_long(&p, &left, &val_b,
3071 &neg, tr_b, sizeof(tr_b),
3075 if (val_b >= bitmap_len || neg ||
3086 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
3088 proc_skip_char(&p, &left, '\n');
3092 unsigned long bit_a, bit_b = 0;
3095 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3096 if (bit_a >= bitmap_len)
3098 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3102 err = proc_put_char(&buffer, &left, ',');
3106 err = proc_put_long(&buffer, &left, bit_a, false);
3109 if (bit_a != bit_b) {
3110 err = proc_put_char(&buffer, &left, '-');
3113 err = proc_put_long(&buffer, &left, bit_b, false);
3121 err = proc_put_char(&buffer, &left, '\n');
3127 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3129 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
3139 #else /* CONFIG_PROC_SYSCTL */
3141 int proc_dostring(struct ctl_table *table, int write,
3142 void __user *buffer, size_t *lenp, loff_t *ppos)
3147 int proc_dointvec(struct ctl_table *table, int write,
3148 void __user *buffer, size_t *lenp, loff_t *ppos)
3153 int proc_douintvec(struct ctl_table *table, int write,
3154 void __user *buffer, size_t *lenp, loff_t *ppos)
3159 int proc_dointvec_minmax(struct ctl_table *table, int write,
3160 void __user *buffer, size_t *lenp, loff_t *ppos)
3165 int proc_douintvec_minmax(struct ctl_table *table, int write,
3166 void __user *buffer, size_t *lenp, loff_t *ppos)
3171 int proc_dointvec_jiffies(struct ctl_table *table, int write,
3172 void __user *buffer, size_t *lenp, loff_t *ppos)
3177 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
3178 void __user *buffer, size_t *lenp, loff_t *ppos)
3183 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
3184 void __user *buffer, size_t *lenp, loff_t *ppos)
3189 int proc_doulongvec_minmax(struct ctl_table *table, int write,
3190 void __user *buffer, size_t *lenp, loff_t *ppos)
3195 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
3196 void __user *buffer,
3197 size_t *lenp, loff_t *ppos)
3203 #endif /* CONFIG_PROC_SYSCTL */
3206 * No sense putting this after each symbol definition, twice,
3207 * exception granted :-)
3209 EXPORT_SYMBOL(proc_dointvec);
3210 EXPORT_SYMBOL(proc_douintvec);
3211 EXPORT_SYMBOL(proc_dointvec_jiffies);
3212 EXPORT_SYMBOL(proc_dointvec_minmax);
3213 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3214 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3215 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3216 EXPORT_SYMBOL(proc_dostring);
3217 EXPORT_SYMBOL(proc_doulongvec_minmax);
3218 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);