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
93 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
94 #include <linux/stackleak.h>
96 #ifdef CONFIG_LOCKUP_DETECTOR
97 #include <linux/nmi.h>
100 #if defined(CONFIG_SYSCTL)
102 /* External variables not in a header file. */
103 extern int suid_dumpable;
104 #ifdef CONFIG_COREDUMP
105 extern int core_uses_pid;
106 extern char core_pattern[];
107 extern unsigned int core_pipe_limit;
110 extern int pid_max_min, pid_max_max;
111 extern int percpu_pagelist_fraction;
112 extern int latencytop_enabled;
113 extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
115 extern int sysctl_nr_trim_pages;
118 /* Constants used for minimum and maximum */
119 #ifdef CONFIG_LOCKUP_DETECTOR
120 static int sixty = 60;
123 static int __maybe_unused neg_one = -1;
126 static int __maybe_unused one = 1;
127 static int __maybe_unused two = 2;
128 static int __maybe_unused four = 4;
129 static unsigned long one_ul = 1;
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;
150 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
151 * and hung_task_check_interval_secs
153 #ifdef CONFIG_DETECT_HUNG_TASK
154 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
157 #ifdef CONFIG_INOTIFY_USER
158 #include <linux/inotify.h>
164 extern int pwrsw_enabled;
167 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
168 extern int unaligned_enabled;
172 extern int unaligned_dump_stack;
175 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
176 extern int no_unaligned_warning;
179 #ifdef CONFIG_PROC_SYSCTL
182 * enum sysctl_writes_mode - supported sysctl write modes
184 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
185 * to be written, and multiple writes on the same sysctl file descriptor
186 * will rewrite the sysctl value, regardless of file position. No warning
187 * is issued when the initial position is not 0.
188 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
190 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
191 * file position 0 and the value must be fully contained in the buffer
192 * sent to the write syscall. If dealing with strings respect the file
193 * position, but restrict this to the max length of the buffer, anything
194 * passed the max lenght will be ignored. Multiple writes will append
197 * These write modes control how current file position affects the behavior of
198 * updating sysctl values through the proc interface on each write.
200 enum sysctl_writes_mode {
201 SYSCTL_WRITES_LEGACY = -1,
202 SYSCTL_WRITES_WARN = 0,
203 SYSCTL_WRITES_STRICT = 1,
206 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
208 static int proc_do_cad_pid(struct ctl_table *table, int write,
209 void __user *buffer, size_t *lenp, loff_t *ppos);
210 static int proc_taint(struct ctl_table *table, int write,
211 void __user *buffer, size_t *lenp, loff_t *ppos);
215 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
216 void __user *buffer, size_t *lenp, loff_t *ppos);
219 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
220 void __user *buffer, size_t *lenp, loff_t *ppos);
221 #ifdef CONFIG_COREDUMP
222 static int proc_dostring_coredump(struct ctl_table *table, int write,
223 void __user *buffer, size_t *lenp, loff_t *ppos);
225 static int proc_dopipe_max_size(struct ctl_table *table, int write,
226 void __user *buffer, size_t *lenp, loff_t *ppos);
227 #ifdef CONFIG_BPF_SYSCALL
228 static int proc_dointvec_minmax_bpf_stats(struct ctl_table *table, int write,
229 void __user *buffer, size_t *lenp,
233 #ifdef CONFIG_MAGIC_SYSRQ
234 /* Note: sysrq code uses its own private copy */
235 static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
237 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
238 void __user *buffer, size_t *lenp,
243 error = proc_dointvec(table, write, buffer, lenp, ppos);
248 sysrq_toggle_support(__sysrq_enabled);
255 static struct ctl_table kern_table[];
256 static struct ctl_table vm_table[];
257 static struct ctl_table fs_table[];
258 static struct ctl_table debug_table[];
259 static struct ctl_table dev_table[];
260 extern struct ctl_table random_table[];
262 extern struct ctl_table epoll_table[];
265 #ifdef CONFIG_FW_LOADER_USER_HELPER
266 extern struct ctl_table firmware_config_table[];
269 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
270 int sysctl_legacy_va_layout;
273 /* The default sysctl tables: */
275 static struct ctl_table sysctl_base_table[] = {
277 .procname = "kernel",
294 .child = debug_table,
304 #ifdef CONFIG_SCHED_DEBUG
305 static int min_sched_granularity_ns = 100000; /* 100 usecs */
306 static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
307 static int min_wakeup_granularity_ns; /* 0 usecs */
308 static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
310 static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
311 static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
312 #endif /* CONFIG_SMP */
313 #endif /* CONFIG_SCHED_DEBUG */
315 #ifdef CONFIG_COMPACTION
316 static int min_extfrag_threshold;
317 static int max_extfrag_threshold = 1000;
320 static struct ctl_table kern_table[] = {
322 .procname = "sched_child_runs_first",
323 .data = &sysctl_sched_child_runs_first,
324 .maxlen = sizeof(unsigned int),
326 .proc_handler = proc_dointvec,
328 #ifdef CONFIG_SCHED_DEBUG
330 .procname = "sched_min_granularity_ns",
331 .data = &sysctl_sched_min_granularity,
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_latency_ns",
340 .data = &sysctl_sched_latency,
341 .maxlen = sizeof(unsigned int),
343 .proc_handler = sched_proc_update_handler,
344 .extra1 = &min_sched_granularity_ns,
345 .extra2 = &max_sched_granularity_ns,
348 .procname = "sched_wakeup_granularity_ns",
349 .data = &sysctl_sched_wakeup_granularity,
350 .maxlen = sizeof(unsigned int),
352 .proc_handler = sched_proc_update_handler,
353 .extra1 = &min_wakeup_granularity_ns,
354 .extra2 = &max_wakeup_granularity_ns,
358 .procname = "sched_tunable_scaling",
359 .data = &sysctl_sched_tunable_scaling,
360 .maxlen = sizeof(enum sched_tunable_scaling),
362 .proc_handler = sched_proc_update_handler,
363 .extra1 = &min_sched_tunable_scaling,
364 .extra2 = &max_sched_tunable_scaling,
367 .procname = "sched_migration_cost_ns",
368 .data = &sysctl_sched_migration_cost,
369 .maxlen = sizeof(unsigned int),
371 .proc_handler = proc_dointvec,
374 .procname = "sched_nr_migrate",
375 .data = &sysctl_sched_nr_migrate,
376 .maxlen = sizeof(unsigned int),
378 .proc_handler = proc_dointvec,
380 #ifdef CONFIG_SCHEDSTATS
382 .procname = "sched_schedstats",
384 .maxlen = sizeof(unsigned int),
386 .proc_handler = sysctl_schedstats,
390 #endif /* CONFIG_SCHEDSTATS */
391 #endif /* CONFIG_SMP */
392 #ifdef CONFIG_NUMA_BALANCING
394 .procname = "numa_balancing_scan_delay_ms",
395 .data = &sysctl_numa_balancing_scan_delay,
396 .maxlen = sizeof(unsigned int),
398 .proc_handler = proc_dointvec,
401 .procname = "numa_balancing_scan_period_min_ms",
402 .data = &sysctl_numa_balancing_scan_period_min,
403 .maxlen = sizeof(unsigned int),
405 .proc_handler = proc_dointvec,
408 .procname = "numa_balancing_scan_period_max_ms",
409 .data = &sysctl_numa_balancing_scan_period_max,
410 .maxlen = sizeof(unsigned int),
412 .proc_handler = proc_dointvec,
415 .procname = "numa_balancing_scan_size_mb",
416 .data = &sysctl_numa_balancing_scan_size,
417 .maxlen = sizeof(unsigned int),
419 .proc_handler = proc_dointvec_minmax,
423 .procname = "numa_balancing",
424 .data = NULL, /* filled in by handler */
425 .maxlen = sizeof(unsigned int),
427 .proc_handler = sysctl_numa_balancing,
431 #endif /* CONFIG_NUMA_BALANCING */
432 #endif /* CONFIG_SCHED_DEBUG */
434 .procname = "sched_rt_period_us",
435 .data = &sysctl_sched_rt_period,
436 .maxlen = sizeof(unsigned int),
438 .proc_handler = sched_rt_handler,
441 .procname = "sched_rt_runtime_us",
442 .data = &sysctl_sched_rt_runtime,
443 .maxlen = sizeof(int),
445 .proc_handler = sched_rt_handler,
448 .procname = "sched_rr_timeslice_ms",
449 .data = &sysctl_sched_rr_timeslice,
450 .maxlen = sizeof(int),
452 .proc_handler = sched_rr_handler,
454 #ifdef CONFIG_SCHED_AUTOGROUP
456 .procname = "sched_autogroup_enabled",
457 .data = &sysctl_sched_autogroup_enabled,
458 .maxlen = sizeof(unsigned int),
460 .proc_handler = proc_dointvec_minmax,
465 #ifdef CONFIG_CFS_BANDWIDTH
467 .procname = "sched_cfs_bandwidth_slice_us",
468 .data = &sysctl_sched_cfs_bandwidth_slice,
469 .maxlen = sizeof(unsigned int),
471 .proc_handler = proc_dointvec_minmax,
475 #ifdef CONFIG_PROVE_LOCKING
477 .procname = "prove_locking",
478 .data = &prove_locking,
479 .maxlen = sizeof(int),
481 .proc_handler = proc_dointvec,
484 #ifdef CONFIG_LOCK_STAT
486 .procname = "lock_stat",
488 .maxlen = sizeof(int),
490 .proc_handler = proc_dointvec,
495 .data = &panic_timeout,
496 .maxlen = sizeof(int),
498 .proc_handler = proc_dointvec,
500 #ifdef CONFIG_COREDUMP
502 .procname = "core_uses_pid",
503 .data = &core_uses_pid,
504 .maxlen = sizeof(int),
506 .proc_handler = proc_dointvec,
509 .procname = "core_pattern",
510 .data = core_pattern,
511 .maxlen = CORENAME_MAX_SIZE,
513 .proc_handler = proc_dostring_coredump,
516 .procname = "core_pipe_limit",
517 .data = &core_pipe_limit,
518 .maxlen = sizeof(unsigned int),
520 .proc_handler = proc_dointvec,
523 #ifdef CONFIG_PROC_SYSCTL
525 .procname = "tainted",
526 .maxlen = sizeof(long),
528 .proc_handler = proc_taint,
531 .procname = "sysctl_writes_strict",
532 .data = &sysctl_writes_strict,
533 .maxlen = sizeof(int),
535 .proc_handler = proc_dointvec_minmax,
540 #ifdef CONFIG_LATENCYTOP
542 .procname = "latencytop",
543 .data = &latencytop_enabled,
544 .maxlen = sizeof(int),
546 .proc_handler = sysctl_latencytop,
549 #ifdef CONFIG_BLK_DEV_INITRD
551 .procname = "real-root-dev",
552 .data = &real_root_dev,
553 .maxlen = sizeof(int),
555 .proc_handler = proc_dointvec,
559 .procname = "print-fatal-signals",
560 .data = &print_fatal_signals,
561 .maxlen = sizeof(int),
563 .proc_handler = proc_dointvec,
567 .procname = "reboot-cmd",
568 .data = reboot_command,
571 .proc_handler = proc_dostring,
574 .procname = "stop-a",
575 .data = &stop_a_enabled,
576 .maxlen = sizeof (int),
578 .proc_handler = proc_dointvec,
581 .procname = "scons-poweroff",
582 .data = &scons_pwroff,
583 .maxlen = sizeof (int),
585 .proc_handler = proc_dointvec,
588 #ifdef CONFIG_SPARC64
590 .procname = "tsb-ratio",
591 .data = &sysctl_tsb_ratio,
592 .maxlen = sizeof (int),
594 .proc_handler = proc_dointvec,
599 .procname = "soft-power",
600 .data = &pwrsw_enabled,
601 .maxlen = sizeof (int),
603 .proc_handler = proc_dointvec,
606 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
608 .procname = "unaligned-trap",
609 .data = &unaligned_enabled,
610 .maxlen = sizeof (int),
612 .proc_handler = proc_dointvec,
616 .procname = "ctrl-alt-del",
618 .maxlen = sizeof(int),
620 .proc_handler = proc_dointvec,
622 #ifdef CONFIG_FUNCTION_TRACER
624 .procname = "ftrace_enabled",
625 .data = &ftrace_enabled,
626 .maxlen = sizeof(int),
628 .proc_handler = ftrace_enable_sysctl,
631 #ifdef CONFIG_STACK_TRACER
633 .procname = "stack_tracer_enabled",
634 .data = &stack_tracer_enabled,
635 .maxlen = sizeof(int),
637 .proc_handler = stack_trace_sysctl,
640 #ifdef CONFIG_TRACING
642 .procname = "ftrace_dump_on_oops",
643 .data = &ftrace_dump_on_oops,
644 .maxlen = sizeof(int),
646 .proc_handler = proc_dointvec,
649 .procname = "traceoff_on_warning",
650 .data = &__disable_trace_on_warning,
651 .maxlen = sizeof(__disable_trace_on_warning),
653 .proc_handler = proc_dointvec,
656 .procname = "tracepoint_printk",
657 .data = &tracepoint_printk,
658 .maxlen = sizeof(tracepoint_printk),
660 .proc_handler = tracepoint_printk_sysctl,
663 #ifdef CONFIG_KEXEC_CORE
665 .procname = "kexec_load_disabled",
666 .data = &kexec_load_disabled,
667 .maxlen = sizeof(int),
669 /* only handle a transition from default "0" to "1" */
670 .proc_handler = proc_dointvec_minmax,
675 #ifdef CONFIG_MODULES
677 .procname = "modprobe",
678 .data = &modprobe_path,
679 .maxlen = KMOD_PATH_LEN,
681 .proc_handler = proc_dostring,
684 .procname = "modules_disabled",
685 .data = &modules_disabled,
686 .maxlen = sizeof(int),
688 /* only handle a transition from default "0" to "1" */
689 .proc_handler = proc_dointvec_minmax,
694 #ifdef CONFIG_UEVENT_HELPER
696 .procname = "hotplug",
697 .data = &uevent_helper,
698 .maxlen = UEVENT_HELPER_PATH_LEN,
700 .proc_handler = proc_dostring,
703 #ifdef CONFIG_CHR_DEV_SG
705 .procname = "sg-big-buff",
706 .data = &sg_big_buff,
707 .maxlen = sizeof (int),
709 .proc_handler = proc_dointvec,
712 #ifdef CONFIG_BSD_PROCESS_ACCT
716 .maxlen = 3*sizeof(int),
718 .proc_handler = proc_dointvec,
721 #ifdef CONFIG_MAGIC_SYSRQ
724 .data = &__sysrq_enabled,
725 .maxlen = sizeof (int),
727 .proc_handler = sysrq_sysctl_handler,
730 #ifdef CONFIG_PROC_SYSCTL
732 .procname = "cad_pid",
734 .maxlen = sizeof (int),
736 .proc_handler = proc_do_cad_pid,
740 .procname = "threads-max",
742 .maxlen = sizeof(int),
744 .proc_handler = sysctl_max_threads,
747 .procname = "random",
749 .child = random_table,
752 .procname = "usermodehelper",
754 .child = usermodehelper_table,
756 #ifdef CONFIG_FW_LOADER_USER_HELPER
758 .procname = "firmware_config",
760 .child = firmware_config_table,
764 .procname = "overflowuid",
765 .data = &overflowuid,
766 .maxlen = sizeof(int),
768 .proc_handler = proc_dointvec_minmax,
769 .extra1 = &minolduid,
770 .extra2 = &maxolduid,
773 .procname = "overflowgid",
774 .data = &overflowgid,
775 .maxlen = sizeof(int),
777 .proc_handler = proc_dointvec_minmax,
778 .extra1 = &minolduid,
779 .extra2 = &maxolduid,
782 #ifdef CONFIG_MATHEMU
784 .procname = "ieee_emulation_warnings",
785 .data = &sysctl_ieee_emulation_warnings,
786 .maxlen = sizeof(int),
788 .proc_handler = proc_dointvec,
792 .procname = "userprocess_debug",
793 .data = &show_unhandled_signals,
794 .maxlen = sizeof(int),
796 .proc_handler = proc_dointvec,
800 .procname = "pid_max",
802 .maxlen = sizeof (int),
804 .proc_handler = proc_dointvec_minmax,
805 .extra1 = &pid_max_min,
806 .extra2 = &pid_max_max,
809 .procname = "panic_on_oops",
810 .data = &panic_on_oops,
811 .maxlen = sizeof(int),
813 .proc_handler = proc_dointvec,
816 .procname = "panic_print",
817 .data = &panic_print,
818 .maxlen = sizeof(unsigned long),
820 .proc_handler = proc_doulongvec_minmax,
822 #if defined CONFIG_PRINTK
824 .procname = "printk",
825 .data = &console_loglevel,
826 .maxlen = 4*sizeof(int),
828 .proc_handler = proc_dointvec,
831 .procname = "printk_ratelimit",
832 .data = &printk_ratelimit_state.interval,
833 .maxlen = sizeof(int),
835 .proc_handler = proc_dointvec_jiffies,
838 .procname = "printk_ratelimit_burst",
839 .data = &printk_ratelimit_state.burst,
840 .maxlen = sizeof(int),
842 .proc_handler = proc_dointvec,
845 .procname = "printk_delay",
846 .data = &printk_delay_msec,
847 .maxlen = sizeof(int),
849 .proc_handler = proc_dointvec_minmax,
851 .extra2 = &ten_thousand,
854 .procname = "printk_devkmsg",
855 .data = devkmsg_log_str,
856 .maxlen = DEVKMSG_STR_MAX_SIZE,
858 .proc_handler = devkmsg_sysctl_set_loglvl,
861 .procname = "dmesg_restrict",
862 .data = &dmesg_restrict,
863 .maxlen = sizeof(int),
865 .proc_handler = proc_dointvec_minmax_sysadmin,
870 .procname = "kptr_restrict",
871 .data = &kptr_restrict,
872 .maxlen = sizeof(int),
874 .proc_handler = proc_dointvec_minmax_sysadmin,
880 .procname = "ngroups_max",
881 .data = &ngroups_max,
882 .maxlen = sizeof (int),
884 .proc_handler = proc_dointvec,
887 .procname = "cap_last_cap",
888 .data = (void *)&cap_last_cap,
889 .maxlen = sizeof(int),
891 .proc_handler = proc_dointvec,
893 #if defined(CONFIG_LOCKUP_DETECTOR)
895 .procname = "watchdog",
896 .data = &watchdog_user_enabled,
897 .maxlen = sizeof(int),
899 .proc_handler = proc_watchdog,
904 .procname = "watchdog_thresh",
905 .data = &watchdog_thresh,
906 .maxlen = sizeof(int),
908 .proc_handler = proc_watchdog_thresh,
913 .procname = "nmi_watchdog",
914 .data = &nmi_watchdog_user_enabled,
915 .maxlen = sizeof(int),
916 .mode = NMI_WATCHDOG_SYSCTL_PERM,
917 .proc_handler = proc_nmi_watchdog,
922 .procname = "watchdog_cpumask",
923 .data = &watchdog_cpumask_bits,
926 .proc_handler = proc_watchdog_cpumask,
928 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
930 .procname = "soft_watchdog",
931 .data = &soft_watchdog_user_enabled,
932 .maxlen = sizeof(int),
934 .proc_handler = proc_soft_watchdog,
939 .procname = "softlockup_panic",
940 .data = &softlockup_panic,
941 .maxlen = sizeof(int),
943 .proc_handler = proc_dointvec_minmax,
949 .procname = "softlockup_all_cpu_backtrace",
950 .data = &sysctl_softlockup_all_cpu_backtrace,
951 .maxlen = sizeof(int),
953 .proc_handler = proc_dointvec_minmax,
957 #endif /* CONFIG_SMP */
959 #ifdef CONFIG_HARDLOCKUP_DETECTOR
961 .procname = "hardlockup_panic",
962 .data = &hardlockup_panic,
963 .maxlen = sizeof(int),
965 .proc_handler = proc_dointvec_minmax,
971 .procname = "hardlockup_all_cpu_backtrace",
972 .data = &sysctl_hardlockup_all_cpu_backtrace,
973 .maxlen = sizeof(int),
975 .proc_handler = proc_dointvec_minmax,
979 #endif /* CONFIG_SMP */
983 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
985 .procname = "unknown_nmi_panic",
986 .data = &unknown_nmi_panic,
987 .maxlen = sizeof (int),
989 .proc_handler = proc_dointvec,
992 #if defined(CONFIG_X86)
994 .procname = "panic_on_unrecovered_nmi",
995 .data = &panic_on_unrecovered_nmi,
996 .maxlen = sizeof(int),
998 .proc_handler = proc_dointvec,
1001 .procname = "panic_on_io_nmi",
1002 .data = &panic_on_io_nmi,
1003 .maxlen = sizeof(int),
1005 .proc_handler = proc_dointvec,
1007 #ifdef CONFIG_DEBUG_STACKOVERFLOW
1009 .procname = "panic_on_stackoverflow",
1010 .data = &sysctl_panic_on_stackoverflow,
1011 .maxlen = sizeof(int),
1013 .proc_handler = proc_dointvec,
1017 .procname = "bootloader_type",
1018 .data = &bootloader_type,
1019 .maxlen = sizeof (int),
1021 .proc_handler = proc_dointvec,
1024 .procname = "bootloader_version",
1025 .data = &bootloader_version,
1026 .maxlen = sizeof (int),
1028 .proc_handler = proc_dointvec,
1031 .procname = "io_delay_type",
1032 .data = &io_delay_type,
1033 .maxlen = sizeof(int),
1035 .proc_handler = proc_dointvec,
1038 #if defined(CONFIG_MMU)
1040 .procname = "randomize_va_space",
1041 .data = &randomize_va_space,
1042 .maxlen = sizeof(int),
1044 .proc_handler = proc_dointvec,
1047 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1049 .procname = "spin_retry",
1050 .data = &spin_retry,
1051 .maxlen = sizeof (int),
1053 .proc_handler = proc_dointvec,
1056 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1058 .procname = "acpi_video_flags",
1059 .data = &acpi_realmode_flags,
1060 .maxlen = sizeof (unsigned long),
1062 .proc_handler = proc_doulongvec_minmax,
1065 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1067 .procname = "ignore-unaligned-usertrap",
1068 .data = &no_unaligned_warning,
1069 .maxlen = sizeof (int),
1071 .proc_handler = proc_dointvec,
1076 .procname = "unaligned-dump-stack",
1077 .data = &unaligned_dump_stack,
1078 .maxlen = sizeof (int),
1080 .proc_handler = proc_dointvec,
1083 #ifdef CONFIG_DETECT_HUNG_TASK
1085 .procname = "hung_task_panic",
1086 .data = &sysctl_hung_task_panic,
1087 .maxlen = sizeof(int),
1089 .proc_handler = proc_dointvec_minmax,
1094 .procname = "hung_task_check_count",
1095 .data = &sysctl_hung_task_check_count,
1096 .maxlen = sizeof(int),
1098 .proc_handler = proc_dointvec_minmax,
1102 .procname = "hung_task_timeout_secs",
1103 .data = &sysctl_hung_task_timeout_secs,
1104 .maxlen = sizeof(unsigned long),
1106 .proc_handler = proc_dohung_task_timeout_secs,
1107 .extra2 = &hung_task_timeout_max,
1110 .procname = "hung_task_check_interval_secs",
1111 .data = &sysctl_hung_task_check_interval_secs,
1112 .maxlen = sizeof(unsigned long),
1114 .proc_handler = proc_dohung_task_timeout_secs,
1115 .extra2 = &hung_task_timeout_max,
1118 .procname = "hung_task_warnings",
1119 .data = &sysctl_hung_task_warnings,
1120 .maxlen = sizeof(int),
1122 .proc_handler = proc_dointvec_minmax,
1126 #ifdef CONFIG_RT_MUTEXES
1128 .procname = "max_lock_depth",
1129 .data = &max_lock_depth,
1130 .maxlen = sizeof(int),
1132 .proc_handler = proc_dointvec,
1136 .procname = "poweroff_cmd",
1137 .data = &poweroff_cmd,
1138 .maxlen = POWEROFF_CMD_PATH_LEN,
1140 .proc_handler = proc_dostring,
1146 .child = key_sysctls,
1149 #ifdef CONFIG_PERF_EVENTS
1151 * User-space scripts rely on the existence of this file
1152 * as a feature check for perf_events being enabled.
1154 * So it's an ABI, do not remove!
1157 .procname = "perf_event_paranoid",
1158 .data = &sysctl_perf_event_paranoid,
1159 .maxlen = sizeof(sysctl_perf_event_paranoid),
1161 .proc_handler = proc_dointvec,
1164 .procname = "perf_event_mlock_kb",
1165 .data = &sysctl_perf_event_mlock,
1166 .maxlen = sizeof(sysctl_perf_event_mlock),
1168 .proc_handler = proc_dointvec,
1171 .procname = "perf_event_max_sample_rate",
1172 .data = &sysctl_perf_event_sample_rate,
1173 .maxlen = sizeof(sysctl_perf_event_sample_rate),
1175 .proc_handler = perf_proc_update_handler,
1179 .procname = "perf_cpu_time_max_percent",
1180 .data = &sysctl_perf_cpu_time_max_percent,
1181 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1183 .proc_handler = perf_cpu_time_max_percent_handler,
1185 .extra2 = &one_hundred,
1188 .procname = "perf_event_max_stack",
1189 .data = &sysctl_perf_event_max_stack,
1190 .maxlen = sizeof(sysctl_perf_event_max_stack),
1192 .proc_handler = perf_event_max_stack_handler,
1194 .extra2 = &six_hundred_forty_kb,
1197 .procname = "perf_event_max_contexts_per_stack",
1198 .data = &sysctl_perf_event_max_contexts_per_stack,
1199 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1201 .proc_handler = perf_event_max_stack_handler,
1203 .extra2 = &one_thousand,
1207 .procname = "panic_on_warn",
1208 .data = &panic_on_warn,
1209 .maxlen = sizeof(int),
1211 .proc_handler = proc_dointvec_minmax,
1215 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1217 .procname = "timer_migration",
1218 .data = &sysctl_timer_migration,
1219 .maxlen = sizeof(unsigned int),
1221 .proc_handler = timer_migration_handler,
1226 #ifdef CONFIG_BPF_SYSCALL
1228 .procname = "unprivileged_bpf_disabled",
1229 .data = &sysctl_unprivileged_bpf_disabled,
1230 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1232 /* only handle a transition from default "0" to "1" */
1233 .proc_handler = proc_dointvec_minmax,
1238 .procname = "bpf_stats_enabled",
1239 .data = &sysctl_bpf_stats_enabled,
1240 .maxlen = sizeof(sysctl_bpf_stats_enabled),
1242 .proc_handler = proc_dointvec_minmax_bpf_stats,
1247 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1249 .procname = "panic_on_rcu_stall",
1250 .data = &sysctl_panic_on_rcu_stall,
1251 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1253 .proc_handler = proc_dointvec_minmax,
1258 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
1260 .procname = "stack_erasing",
1262 .maxlen = sizeof(int),
1264 .proc_handler = stack_erasing_sysctl,
1272 static struct ctl_table vm_table[] = {
1274 .procname = "overcommit_memory",
1275 .data = &sysctl_overcommit_memory,
1276 .maxlen = sizeof(sysctl_overcommit_memory),
1278 .proc_handler = proc_dointvec_minmax,
1283 .procname = "panic_on_oom",
1284 .data = &sysctl_panic_on_oom,
1285 .maxlen = sizeof(sysctl_panic_on_oom),
1287 .proc_handler = proc_dointvec_minmax,
1292 .procname = "oom_kill_allocating_task",
1293 .data = &sysctl_oom_kill_allocating_task,
1294 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1296 .proc_handler = proc_dointvec,
1299 .procname = "oom_dump_tasks",
1300 .data = &sysctl_oom_dump_tasks,
1301 .maxlen = sizeof(sysctl_oom_dump_tasks),
1303 .proc_handler = proc_dointvec,
1306 .procname = "overcommit_ratio",
1307 .data = &sysctl_overcommit_ratio,
1308 .maxlen = sizeof(sysctl_overcommit_ratio),
1310 .proc_handler = overcommit_ratio_handler,
1313 .procname = "overcommit_kbytes",
1314 .data = &sysctl_overcommit_kbytes,
1315 .maxlen = sizeof(sysctl_overcommit_kbytes),
1317 .proc_handler = overcommit_kbytes_handler,
1320 .procname = "page-cluster",
1321 .data = &page_cluster,
1322 .maxlen = sizeof(int),
1324 .proc_handler = proc_dointvec_minmax,
1328 .procname = "dirty_background_ratio",
1329 .data = &dirty_background_ratio,
1330 .maxlen = sizeof(dirty_background_ratio),
1332 .proc_handler = dirty_background_ratio_handler,
1334 .extra2 = &one_hundred,
1337 .procname = "dirty_background_bytes",
1338 .data = &dirty_background_bytes,
1339 .maxlen = sizeof(dirty_background_bytes),
1341 .proc_handler = dirty_background_bytes_handler,
1345 .procname = "dirty_ratio",
1346 .data = &vm_dirty_ratio,
1347 .maxlen = sizeof(vm_dirty_ratio),
1349 .proc_handler = dirty_ratio_handler,
1351 .extra2 = &one_hundred,
1354 .procname = "dirty_bytes",
1355 .data = &vm_dirty_bytes,
1356 .maxlen = sizeof(vm_dirty_bytes),
1358 .proc_handler = dirty_bytes_handler,
1359 .extra1 = &dirty_bytes_min,
1362 .procname = "dirty_writeback_centisecs",
1363 .data = &dirty_writeback_interval,
1364 .maxlen = sizeof(dirty_writeback_interval),
1366 .proc_handler = dirty_writeback_centisecs_handler,
1369 .procname = "dirty_expire_centisecs",
1370 .data = &dirty_expire_interval,
1371 .maxlen = sizeof(dirty_expire_interval),
1373 .proc_handler = proc_dointvec_minmax,
1377 .procname = "dirtytime_expire_seconds",
1378 .data = &dirtytime_expire_interval,
1379 .maxlen = sizeof(dirtytime_expire_interval),
1381 .proc_handler = dirtytime_interval_handler,
1385 .procname = "swappiness",
1386 .data = &vm_swappiness,
1387 .maxlen = sizeof(vm_swappiness),
1389 .proc_handler = proc_dointvec_minmax,
1391 .extra2 = &one_hundred,
1393 #ifdef CONFIG_HUGETLB_PAGE
1395 .procname = "nr_hugepages",
1397 .maxlen = sizeof(unsigned long),
1399 .proc_handler = hugetlb_sysctl_handler,
1403 .procname = "nr_hugepages_mempolicy",
1405 .maxlen = sizeof(unsigned long),
1407 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1410 .procname = "numa_stat",
1411 .data = &sysctl_vm_numa_stat,
1412 .maxlen = sizeof(int),
1414 .proc_handler = sysctl_vm_numa_stat_handler,
1420 .procname = "hugetlb_shm_group",
1421 .data = &sysctl_hugetlb_shm_group,
1422 .maxlen = sizeof(gid_t),
1424 .proc_handler = proc_dointvec,
1427 .procname = "nr_overcommit_hugepages",
1429 .maxlen = sizeof(unsigned long),
1431 .proc_handler = hugetlb_overcommit_handler,
1435 .procname = "lowmem_reserve_ratio",
1436 .data = &sysctl_lowmem_reserve_ratio,
1437 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1439 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
1442 .procname = "drop_caches",
1443 .data = &sysctl_drop_caches,
1444 .maxlen = sizeof(int),
1446 .proc_handler = drop_caches_sysctl_handler,
1450 #ifdef CONFIG_COMPACTION
1452 .procname = "compact_memory",
1453 .data = &sysctl_compact_memory,
1454 .maxlen = sizeof(int),
1456 .proc_handler = sysctl_compaction_handler,
1459 .procname = "extfrag_threshold",
1460 .data = &sysctl_extfrag_threshold,
1461 .maxlen = sizeof(int),
1463 .proc_handler = proc_dointvec_minmax,
1464 .extra1 = &min_extfrag_threshold,
1465 .extra2 = &max_extfrag_threshold,
1468 .procname = "compact_unevictable_allowed",
1469 .data = &sysctl_compact_unevictable_allowed,
1470 .maxlen = sizeof(int),
1472 .proc_handler = proc_dointvec,
1477 #endif /* CONFIG_COMPACTION */
1479 .procname = "min_free_kbytes",
1480 .data = &min_free_kbytes,
1481 .maxlen = sizeof(min_free_kbytes),
1483 .proc_handler = min_free_kbytes_sysctl_handler,
1487 .procname = "watermark_boost_factor",
1488 .data = &watermark_boost_factor,
1489 .maxlen = sizeof(watermark_boost_factor),
1491 .proc_handler = watermark_boost_factor_sysctl_handler,
1495 .procname = "watermark_scale_factor",
1496 .data = &watermark_scale_factor,
1497 .maxlen = sizeof(watermark_scale_factor),
1499 .proc_handler = watermark_scale_factor_sysctl_handler,
1501 .extra2 = &one_thousand,
1504 .procname = "percpu_pagelist_fraction",
1505 .data = &percpu_pagelist_fraction,
1506 .maxlen = sizeof(percpu_pagelist_fraction),
1508 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
1513 .procname = "max_map_count",
1514 .data = &sysctl_max_map_count,
1515 .maxlen = sizeof(sysctl_max_map_count),
1517 .proc_handler = proc_dointvec_minmax,
1522 .procname = "nr_trim_pages",
1523 .data = &sysctl_nr_trim_pages,
1524 .maxlen = sizeof(sysctl_nr_trim_pages),
1526 .proc_handler = proc_dointvec_minmax,
1531 .procname = "laptop_mode",
1532 .data = &laptop_mode,
1533 .maxlen = sizeof(laptop_mode),
1535 .proc_handler = proc_dointvec_jiffies,
1538 .procname = "block_dump",
1539 .data = &block_dump,
1540 .maxlen = sizeof(block_dump),
1542 .proc_handler = proc_dointvec,
1546 .procname = "vfs_cache_pressure",
1547 .data = &sysctl_vfs_cache_pressure,
1548 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1550 .proc_handler = proc_dointvec,
1553 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1555 .procname = "legacy_va_layout",
1556 .data = &sysctl_legacy_va_layout,
1557 .maxlen = sizeof(sysctl_legacy_va_layout),
1559 .proc_handler = proc_dointvec,
1565 .procname = "zone_reclaim_mode",
1566 .data = &node_reclaim_mode,
1567 .maxlen = sizeof(node_reclaim_mode),
1569 .proc_handler = proc_dointvec,
1573 .procname = "min_unmapped_ratio",
1574 .data = &sysctl_min_unmapped_ratio,
1575 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1577 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
1579 .extra2 = &one_hundred,
1582 .procname = "min_slab_ratio",
1583 .data = &sysctl_min_slab_ratio,
1584 .maxlen = sizeof(sysctl_min_slab_ratio),
1586 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
1588 .extra2 = &one_hundred,
1593 .procname = "stat_interval",
1594 .data = &sysctl_stat_interval,
1595 .maxlen = sizeof(sysctl_stat_interval),
1597 .proc_handler = proc_dointvec_jiffies,
1600 .procname = "stat_refresh",
1604 .proc_handler = vmstat_refresh,
1609 .procname = "mmap_min_addr",
1610 .data = &dac_mmap_min_addr,
1611 .maxlen = sizeof(unsigned long),
1613 .proc_handler = mmap_min_addr_handler,
1618 .procname = "numa_zonelist_order",
1619 .data = &numa_zonelist_order,
1620 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1622 .proc_handler = numa_zonelist_order_handler,
1625 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1626 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1628 .procname = "vdso_enabled",
1629 #ifdef CONFIG_X86_32
1630 .data = &vdso32_enabled,
1631 .maxlen = sizeof(vdso32_enabled),
1633 .data = &vdso_enabled,
1634 .maxlen = sizeof(vdso_enabled),
1637 .proc_handler = proc_dointvec,
1641 #ifdef CONFIG_HIGHMEM
1643 .procname = "highmem_is_dirtyable",
1644 .data = &vm_highmem_is_dirtyable,
1645 .maxlen = sizeof(vm_highmem_is_dirtyable),
1647 .proc_handler = proc_dointvec_minmax,
1652 #ifdef CONFIG_MEMORY_FAILURE
1654 .procname = "memory_failure_early_kill",
1655 .data = &sysctl_memory_failure_early_kill,
1656 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1658 .proc_handler = proc_dointvec_minmax,
1663 .procname = "memory_failure_recovery",
1664 .data = &sysctl_memory_failure_recovery,
1665 .maxlen = sizeof(sysctl_memory_failure_recovery),
1667 .proc_handler = proc_dointvec_minmax,
1673 .procname = "user_reserve_kbytes",
1674 .data = &sysctl_user_reserve_kbytes,
1675 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1677 .proc_handler = proc_doulongvec_minmax,
1680 .procname = "admin_reserve_kbytes",
1681 .data = &sysctl_admin_reserve_kbytes,
1682 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1684 .proc_handler = proc_doulongvec_minmax,
1686 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1688 .procname = "mmap_rnd_bits",
1689 .data = &mmap_rnd_bits,
1690 .maxlen = sizeof(mmap_rnd_bits),
1692 .proc_handler = proc_dointvec_minmax,
1693 .extra1 = (void *)&mmap_rnd_bits_min,
1694 .extra2 = (void *)&mmap_rnd_bits_max,
1697 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1699 .procname = "mmap_rnd_compat_bits",
1700 .data = &mmap_rnd_compat_bits,
1701 .maxlen = sizeof(mmap_rnd_compat_bits),
1703 .proc_handler = proc_dointvec_minmax,
1704 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1705 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1711 static struct ctl_table fs_table[] = {
1713 .procname = "inode-nr",
1714 .data = &inodes_stat,
1715 .maxlen = 2*sizeof(long),
1717 .proc_handler = proc_nr_inodes,
1720 .procname = "inode-state",
1721 .data = &inodes_stat,
1722 .maxlen = 7*sizeof(long),
1724 .proc_handler = proc_nr_inodes,
1727 .procname = "file-nr",
1728 .data = &files_stat,
1729 .maxlen = sizeof(files_stat),
1731 .proc_handler = proc_nr_files,
1734 .procname = "file-max",
1735 .data = &files_stat.max_files,
1736 .maxlen = sizeof(files_stat.max_files),
1738 .proc_handler = proc_doulongvec_minmax,
1741 .procname = "nr_open",
1742 .data = &sysctl_nr_open,
1743 .maxlen = sizeof(unsigned int),
1745 .proc_handler = proc_dointvec_minmax,
1746 .extra1 = &sysctl_nr_open_min,
1747 .extra2 = &sysctl_nr_open_max,
1750 .procname = "dentry-state",
1751 .data = &dentry_stat,
1752 .maxlen = 6*sizeof(long),
1754 .proc_handler = proc_nr_dentry,
1757 .procname = "overflowuid",
1758 .data = &fs_overflowuid,
1759 .maxlen = sizeof(int),
1761 .proc_handler = proc_dointvec_minmax,
1762 .extra1 = &minolduid,
1763 .extra2 = &maxolduid,
1766 .procname = "overflowgid",
1767 .data = &fs_overflowgid,
1768 .maxlen = sizeof(int),
1770 .proc_handler = proc_dointvec_minmax,
1771 .extra1 = &minolduid,
1772 .extra2 = &maxolduid,
1774 #ifdef CONFIG_FILE_LOCKING
1776 .procname = "leases-enable",
1777 .data = &leases_enable,
1778 .maxlen = sizeof(int),
1780 .proc_handler = proc_dointvec,
1783 #ifdef CONFIG_DNOTIFY
1785 .procname = "dir-notify-enable",
1786 .data = &dir_notify_enable,
1787 .maxlen = sizeof(int),
1789 .proc_handler = proc_dointvec,
1793 #ifdef CONFIG_FILE_LOCKING
1795 .procname = "lease-break-time",
1796 .data = &lease_break_time,
1797 .maxlen = sizeof(int),
1799 .proc_handler = proc_dointvec,
1804 .procname = "aio-nr",
1806 .maxlen = sizeof(aio_nr),
1808 .proc_handler = proc_doulongvec_minmax,
1811 .procname = "aio-max-nr",
1812 .data = &aio_max_nr,
1813 .maxlen = sizeof(aio_max_nr),
1815 .proc_handler = proc_doulongvec_minmax,
1817 #endif /* CONFIG_AIO */
1818 #ifdef CONFIG_INOTIFY_USER
1820 .procname = "inotify",
1822 .child = inotify_table,
1827 .procname = "epoll",
1829 .child = epoll_table,
1834 .procname = "protected_symlinks",
1835 .data = &sysctl_protected_symlinks,
1836 .maxlen = sizeof(int),
1838 .proc_handler = proc_dointvec_minmax,
1843 .procname = "protected_hardlinks",
1844 .data = &sysctl_protected_hardlinks,
1845 .maxlen = sizeof(int),
1847 .proc_handler = proc_dointvec_minmax,
1852 .procname = "protected_fifos",
1853 .data = &sysctl_protected_fifos,
1854 .maxlen = sizeof(int),
1856 .proc_handler = proc_dointvec_minmax,
1861 .procname = "protected_regular",
1862 .data = &sysctl_protected_regular,
1863 .maxlen = sizeof(int),
1865 .proc_handler = proc_dointvec_minmax,
1870 .procname = "suid_dumpable",
1871 .data = &suid_dumpable,
1872 .maxlen = sizeof(int),
1874 .proc_handler = proc_dointvec_minmax_coredump,
1878 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1880 .procname = "binfmt_misc",
1882 .child = sysctl_mount_point,
1886 .procname = "pipe-max-size",
1887 .data = &pipe_max_size,
1888 .maxlen = sizeof(pipe_max_size),
1890 .proc_handler = proc_dopipe_max_size,
1893 .procname = "pipe-user-pages-hard",
1894 .data = &pipe_user_pages_hard,
1895 .maxlen = sizeof(pipe_user_pages_hard),
1897 .proc_handler = proc_doulongvec_minmax,
1900 .procname = "pipe-user-pages-soft",
1901 .data = &pipe_user_pages_soft,
1902 .maxlen = sizeof(pipe_user_pages_soft),
1904 .proc_handler = proc_doulongvec_minmax,
1907 .procname = "mount-max",
1908 .data = &sysctl_mount_max,
1909 .maxlen = sizeof(unsigned int),
1911 .proc_handler = proc_dointvec_minmax,
1917 static struct ctl_table debug_table[] = {
1918 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1920 .procname = "exception-trace",
1921 .data = &show_unhandled_signals,
1922 .maxlen = sizeof(int),
1924 .proc_handler = proc_dointvec
1927 #if defined(CONFIG_OPTPROBES)
1929 .procname = "kprobes-optimization",
1930 .data = &sysctl_kprobes_optimization,
1931 .maxlen = sizeof(int),
1933 .proc_handler = proc_kprobes_optimization_handler,
1941 static struct ctl_table dev_table[] = {
1945 int __init sysctl_init(void)
1947 struct ctl_table_header *hdr;
1949 hdr = register_sysctl_table(sysctl_base_table);
1950 kmemleak_not_leak(hdr);
1954 #endif /* CONFIG_SYSCTL */
1960 #ifdef CONFIG_PROC_SYSCTL
1962 static int _proc_do_string(char *data, int maxlen, int write,
1963 char __user *buffer,
1964 size_t *lenp, loff_t *ppos)
1970 if (!data || !maxlen || !*lenp) {
1976 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1977 /* Only continue writes not past the end of buffer. */
1979 if (len > maxlen - 1)
1986 /* Start writing from beginning of buffer. */
1992 while ((p - buffer) < *lenp && len < maxlen - 1) {
1993 if (get_user(c, p++))
1995 if (c == 0 || c == '\n')
2016 if (copy_to_user(buffer, data, len))
2019 if (put_user('\n', buffer + len))
2029 static void warn_sysctl_write(struct ctl_table *table)
2031 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2032 "This will not be supported in the future. To silence this\n"
2033 "warning, set kernel.sysctl_writes_strict = -1\n",
2034 current->comm, table->procname);
2038 * proc_first_pos_non_zero_ignore - check if first position is allowed
2039 * @ppos: file position
2040 * @table: the sysctl table
2042 * Returns true if the first position is non-zero and the sysctl_writes_strict
2043 * mode indicates this is not allowed for numeric input types. String proc
2044 * handlers can ignore the return value.
2046 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
2047 struct ctl_table *table)
2052 switch (sysctl_writes_strict) {
2053 case SYSCTL_WRITES_STRICT:
2055 case SYSCTL_WRITES_WARN:
2056 warn_sysctl_write(table);
2064 * proc_dostring - read a string sysctl
2065 * @table: the sysctl table
2066 * @write: %TRUE if this is a write to the sysctl file
2067 * @buffer: the user buffer
2068 * @lenp: the size of the user buffer
2069 * @ppos: file position
2071 * Reads/writes a string from/to the user buffer. If the kernel
2072 * buffer provided is not large enough to hold the string, the
2073 * string is truncated. The copied string is %NULL-terminated.
2074 * If the string is being read by the user process, it is copied
2075 * and a newline '\n' is added. It is truncated if the buffer is
2078 * Returns 0 on success.
2080 int proc_dostring(struct ctl_table *table, int write,
2081 void __user *buffer, size_t *lenp, loff_t *ppos)
2084 proc_first_pos_non_zero_ignore(ppos, table);
2086 return _proc_do_string((char *)(table->data), table->maxlen, write,
2087 (char __user *)buffer, lenp, ppos);
2090 static size_t proc_skip_spaces(char **buf)
2093 char *tmp = skip_spaces(*buf);
2099 static void proc_skip_char(char **buf, size_t *size, const char v)
2109 #define TMPBUFLEN 22
2111 * proc_get_long - reads an ASCII formatted integer from a user buffer
2113 * @buf: a kernel buffer
2114 * @size: size of the kernel buffer
2115 * @val: this is where the number will be stored
2116 * @neg: set to %TRUE if number is negative
2117 * @perm_tr: a vector which contains the allowed trailers
2118 * @perm_tr_len: size of the perm_tr vector
2119 * @tr: pointer to store the trailer character
2121 * In case of success %0 is returned and @buf and @size are updated with
2122 * the amount of bytes read. If @tr is non-NULL and a trailing
2123 * character exists (size is non-zero after returning from this
2124 * function), @tr is updated with the trailing character.
2126 static int proc_get_long(char **buf, size_t *size,
2127 unsigned long *val, bool *neg,
2128 const char *perm_tr, unsigned perm_tr_len, char *tr)
2131 char *p, tmp[TMPBUFLEN];
2137 if (len > TMPBUFLEN - 1)
2138 len = TMPBUFLEN - 1;
2140 memcpy(tmp, *buf, len);
2144 if (*p == '-' && *size > 1) {
2152 *val = simple_strtoul(p, &p, 0);
2156 /* We don't know if the next char is whitespace thus we may accept
2157 * invalid integers (e.g. 1234...a) or two integers instead of one
2158 * (e.g. 123...1). So lets not allow such large numbers. */
2159 if (len == TMPBUFLEN - 1)
2162 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2165 if (tr && (len < *size))
2175 * proc_put_long - converts an integer to a decimal ASCII formatted string
2177 * @buf: the user buffer
2178 * @size: the size of the user buffer
2179 * @val: the integer to be converted
2180 * @neg: sign of the number, %TRUE for negative
2182 * In case of success %0 is returned and @buf and @size are updated with
2183 * the amount of bytes written.
2185 static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2189 char tmp[TMPBUFLEN], *p = tmp;
2191 sprintf(p, "%s%lu", neg ? "-" : "", val);
2195 if (copy_to_user(*buf, tmp, len))
2203 static int proc_put_char(void __user **buf, size_t *size, char c)
2206 char __user **buffer = (char __user **)buf;
2207 if (put_user(c, *buffer))
2209 (*size)--, (*buffer)++;
2215 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
2217 int write, void *data)
2221 if (*lvalp > (unsigned long) INT_MAX + 1)
2225 if (*lvalp > (unsigned long) INT_MAX)
2233 *lvalp = -(unsigned long)val;
2236 *lvalp = (unsigned long)val;
2242 static int do_proc_douintvec_conv(unsigned long *lvalp,
2244 int write, void *data)
2247 if (*lvalp > UINT_MAX)
2251 unsigned int val = *valp;
2252 *lvalp = (unsigned long)val;
2257 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2259 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
2260 int write, void __user *buffer,
2261 size_t *lenp, loff_t *ppos,
2262 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2263 int write, void *data),
2266 int *i, vleft, first = 1, err = 0;
2268 char *kbuf = NULL, *p;
2270 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2275 i = (int *) tbl_data;
2276 vleft = table->maxlen / sizeof(*i);
2280 conv = do_proc_dointvec_conv;
2283 if (proc_first_pos_non_zero_ignore(ppos, table))
2286 if (left > PAGE_SIZE - 1)
2287 left = PAGE_SIZE - 1;
2288 p = kbuf = memdup_user_nul(buffer, left);
2290 return PTR_ERR(kbuf);
2293 for (; left && vleft--; i++, first=0) {
2298 left -= proc_skip_spaces(&p);
2302 err = proc_get_long(&p, &left, &lval, &neg,
2304 sizeof(proc_wspace_sep), NULL);
2307 if (conv(&neg, &lval, i, 1, data)) {
2312 if (conv(&neg, &lval, i, 0, data)) {
2317 err = proc_put_char(&buffer, &left, '\t');
2320 err = proc_put_long(&buffer, &left, lval, neg);
2326 if (!write && !first && left && !err)
2327 err = proc_put_char(&buffer, &left, '\n');
2328 if (write && !err && left)
2329 left -= proc_skip_spaces(&p);
2333 return err ? : -EINVAL;
2341 static int do_proc_dointvec(struct ctl_table *table, int write,
2342 void __user *buffer, size_t *lenp, loff_t *ppos,
2343 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2344 int write, void *data),
2347 return __do_proc_dointvec(table->data, table, write,
2348 buffer, lenp, ppos, conv, data);
2351 static int do_proc_douintvec_w(unsigned int *tbl_data,
2352 struct ctl_table *table,
2353 void __user *buffer,
2354 size_t *lenp, loff_t *ppos,
2355 int (*conv)(unsigned long *lvalp,
2357 int write, void *data),
2364 char *kbuf = NULL, *p;
2368 if (proc_first_pos_non_zero_ignore(ppos, table))
2371 if (left > PAGE_SIZE - 1)
2372 left = PAGE_SIZE - 1;
2374 p = kbuf = memdup_user_nul(buffer, left);
2378 left -= proc_skip_spaces(&p);
2384 err = proc_get_long(&p, &left, &lval, &neg,
2386 sizeof(proc_wspace_sep), NULL);
2392 if (conv(&lval, tbl_data, 1, data)) {
2398 left -= proc_skip_spaces(&p);
2407 /* This is in keeping with old __do_proc_dointvec() */
2413 static int do_proc_douintvec_r(unsigned int *tbl_data, void __user *buffer,
2414 size_t *lenp, loff_t *ppos,
2415 int (*conv)(unsigned long *lvalp,
2417 int write, void *data),
2426 if (conv(&lval, tbl_data, 0, data)) {
2431 err = proc_put_long(&buffer, &left, lval, false);
2435 err = proc_put_char(&buffer, &left, '\n');
2444 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
2445 int write, void __user *buffer,
2446 size_t *lenp, loff_t *ppos,
2447 int (*conv)(unsigned long *lvalp,
2449 int write, void *data),
2452 unsigned int *i, vleft;
2454 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2459 i = (unsigned int *) tbl_data;
2460 vleft = table->maxlen / sizeof(*i);
2463 * Arrays are not supported, keep this simple. *Do not* add
2472 conv = do_proc_douintvec_conv;
2475 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
2477 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
2480 static int do_proc_douintvec(struct ctl_table *table, int write,
2481 void __user *buffer, size_t *lenp, loff_t *ppos,
2482 int (*conv)(unsigned long *lvalp,
2484 int write, void *data),
2487 return __do_proc_douintvec(table->data, table, write,
2488 buffer, lenp, ppos, conv, data);
2492 * proc_dointvec - read a vector of integers
2493 * @table: the sysctl table
2494 * @write: %TRUE if this is a write to the sysctl file
2495 * @buffer: the user buffer
2496 * @lenp: the size of the user buffer
2497 * @ppos: file position
2499 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2500 * values from/to the user buffer, treated as an ASCII string.
2502 * Returns 0 on success.
2504 int proc_dointvec(struct ctl_table *table, int write,
2505 void __user *buffer, size_t *lenp, loff_t *ppos)
2507 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2511 * proc_douintvec - read a vector of unsigned integers
2512 * @table: the sysctl table
2513 * @write: %TRUE if this is a write to the sysctl file
2514 * @buffer: the user buffer
2515 * @lenp: the size of the user buffer
2516 * @ppos: file position
2518 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2519 * values from/to the user buffer, treated as an ASCII string.
2521 * Returns 0 on success.
2523 int proc_douintvec(struct ctl_table *table, int write,
2524 void __user *buffer, size_t *lenp, loff_t *ppos)
2526 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2527 do_proc_douintvec_conv, NULL);
2531 * Taint values can only be increased
2532 * This means we can safely use a temporary.
2534 static int proc_taint(struct ctl_table *table, int write,
2535 void __user *buffer, size_t *lenp, loff_t *ppos)
2538 unsigned long tmptaint = get_taint();
2541 if (write && !capable(CAP_SYS_ADMIN))
2546 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
2552 * Poor man's atomic or. Not worth adding a primitive
2553 * to everyone's atomic.h for this
2556 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2557 if ((tmptaint >> i) & 1)
2558 add_taint(i, LOCKDEP_STILL_OK);
2565 #ifdef CONFIG_PRINTK
2566 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
2567 void __user *buffer, size_t *lenp, loff_t *ppos)
2569 if (write && !capable(CAP_SYS_ADMIN))
2572 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2577 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
2578 * @min: pointer to minimum allowable value
2579 * @max: pointer to maximum allowable value
2581 * The do_proc_dointvec_minmax_conv_param structure provides the
2582 * minimum and maximum values for doing range checking for those sysctl
2583 * parameters that use the proc_dointvec_minmax() handler.
2585 struct do_proc_dointvec_minmax_conv_param {
2590 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2592 int write, void *data)
2594 struct do_proc_dointvec_minmax_conv_param *param = data;
2596 int val = *negp ? -*lvalp : *lvalp;
2597 if ((param->min && *param->min > val) ||
2598 (param->max && *param->max < val))
2605 *lvalp = -(unsigned long)val;
2608 *lvalp = (unsigned long)val;
2615 * proc_dointvec_minmax - read a vector of integers with min/max values
2616 * @table: the sysctl table
2617 * @write: %TRUE if this is a write to the sysctl file
2618 * @buffer: the user buffer
2619 * @lenp: the size of the user buffer
2620 * @ppos: file position
2622 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2623 * values from/to the user buffer, treated as an ASCII string.
2625 * This routine will ensure the values are within the range specified by
2626 * table->extra1 (min) and table->extra2 (max).
2628 * Returns 0 on success or -EINVAL on write when the range check fails.
2630 int proc_dointvec_minmax(struct ctl_table *table, int write,
2631 void __user *buffer, size_t *lenp, loff_t *ppos)
2633 struct do_proc_dointvec_minmax_conv_param param = {
2634 .min = (int *) table->extra1,
2635 .max = (int *) table->extra2,
2637 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2638 do_proc_dointvec_minmax_conv, ¶m);
2642 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
2643 * @min: pointer to minimum allowable value
2644 * @max: pointer to maximum allowable value
2646 * The do_proc_douintvec_minmax_conv_param structure provides the
2647 * minimum and maximum values for doing range checking for those sysctl
2648 * parameters that use the proc_douintvec_minmax() handler.
2650 struct do_proc_douintvec_minmax_conv_param {
2655 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
2657 int write, void *data)
2659 struct do_proc_douintvec_minmax_conv_param *param = data;
2662 unsigned int val = *lvalp;
2664 if (*lvalp > UINT_MAX)
2667 if ((param->min && *param->min > val) ||
2668 (param->max && *param->max < val))
2673 unsigned int val = *valp;
2674 *lvalp = (unsigned long) val;
2681 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2682 * @table: the sysctl table
2683 * @write: %TRUE if this is a write to the sysctl file
2684 * @buffer: the user buffer
2685 * @lenp: the size of the user buffer
2686 * @ppos: file position
2688 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2689 * values from/to the user buffer, treated as an ASCII string. Negative
2690 * strings are not allowed.
2692 * This routine will ensure the values are within the range specified by
2693 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2694 * check for UINT_MAX to avoid having to support wrap around uses from
2697 * Returns 0 on success or -ERANGE on write when the range check fails.
2699 int proc_douintvec_minmax(struct ctl_table *table, int write,
2700 void __user *buffer, size_t *lenp, loff_t *ppos)
2702 struct do_proc_douintvec_minmax_conv_param param = {
2703 .min = (unsigned int *) table->extra1,
2704 .max = (unsigned int *) table->extra2,
2706 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2707 do_proc_douintvec_minmax_conv, ¶m);
2710 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
2712 int write, void *data)
2717 val = round_pipe_size(*lvalp);
2723 unsigned int val = *valp;
2724 *lvalp = (unsigned long) val;
2730 static int proc_dopipe_max_size(struct ctl_table *table, int write,
2731 void __user *buffer, size_t *lenp, loff_t *ppos)
2733 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2734 do_proc_dopipe_max_size_conv, NULL);
2737 static void validate_coredump_safety(void)
2739 #ifdef CONFIG_COREDUMP
2740 if (suid_dumpable == SUID_DUMP_ROOT &&
2741 core_pattern[0] != '/' && core_pattern[0] != '|') {
2743 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2744 "Pipe handler or fully qualified core dump path required.\n"
2745 "Set kernel.core_pattern before fs.suid_dumpable.\n"
2751 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2752 void __user *buffer, size_t *lenp, loff_t *ppos)
2754 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2756 validate_coredump_safety();
2760 #ifdef CONFIG_COREDUMP
2761 static int proc_dostring_coredump(struct ctl_table *table, int write,
2762 void __user *buffer, size_t *lenp, loff_t *ppos)
2764 int error = proc_dostring(table, write, buffer, lenp, ppos);
2766 validate_coredump_safety();
2771 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
2772 void __user *buffer,
2773 size_t *lenp, loff_t *ppos,
2774 unsigned long convmul,
2775 unsigned long convdiv)
2777 unsigned long *i, *min, *max;
2778 int vleft, first = 1, err = 0;
2780 char *kbuf = NULL, *p;
2782 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
2787 i = (unsigned long *) data;
2788 min = (unsigned long *) table->extra1;
2789 max = (unsigned long *) table->extra2;
2790 vleft = table->maxlen / sizeof(unsigned long);
2794 if (proc_first_pos_non_zero_ignore(ppos, table))
2797 if (left > PAGE_SIZE - 1)
2798 left = PAGE_SIZE - 1;
2799 p = kbuf = memdup_user_nul(buffer, left);
2801 return PTR_ERR(kbuf);
2804 for (; left && vleft--; i++, first = 0) {
2810 left -= proc_skip_spaces(&p);
2814 err = proc_get_long(&p, &left, &val, &neg,
2816 sizeof(proc_wspace_sep), NULL);
2821 val = convmul * val / convdiv;
2822 if ((min && val < *min) || (max && val > *max))
2826 val = convdiv * (*i) / convmul;
2828 err = proc_put_char(&buffer, &left, '\t');
2832 err = proc_put_long(&buffer, &left, val, false);
2838 if (!write && !first && left && !err)
2839 err = proc_put_char(&buffer, &left, '\n');
2841 left -= proc_skip_spaces(&p);
2845 return err ? : -EINVAL;
2853 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2854 void __user *buffer,
2855 size_t *lenp, loff_t *ppos,
2856 unsigned long convmul,
2857 unsigned long convdiv)
2859 return __do_proc_doulongvec_minmax(table->data, table, write,
2860 buffer, lenp, ppos, convmul, convdiv);
2864 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2865 * @table: the sysctl table
2866 * @write: %TRUE if this is a write to the sysctl file
2867 * @buffer: the user buffer
2868 * @lenp: the size of the user buffer
2869 * @ppos: file position
2871 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2872 * values from/to the user buffer, treated as an ASCII string.
2874 * This routine will ensure the values are within the range specified by
2875 * table->extra1 (min) and table->extra2 (max).
2877 * Returns 0 on success.
2879 int proc_doulongvec_minmax(struct ctl_table *table, int write,
2880 void __user *buffer, size_t *lenp, loff_t *ppos)
2882 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
2886 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2887 * @table: the sysctl table
2888 * @write: %TRUE if this is a write to the sysctl file
2889 * @buffer: the user buffer
2890 * @lenp: the size of the user buffer
2891 * @ppos: file position
2893 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2894 * values from/to the user buffer, treated as an ASCII string. The values
2895 * are treated as milliseconds, and converted to jiffies when they are stored.
2897 * This routine will ensure the values are within the range specified by
2898 * table->extra1 (min) and table->extra2 (max).
2900 * Returns 0 on success.
2902 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2903 void __user *buffer,
2904 size_t *lenp, loff_t *ppos)
2906 return do_proc_doulongvec_minmax(table, write, buffer,
2907 lenp, ppos, HZ, 1000l);
2911 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
2913 int write, void *data)
2916 if (*lvalp > INT_MAX / HZ)
2918 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2924 lval = -(unsigned long)val;
2927 lval = (unsigned long)val;
2934 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
2936 int write, void *data)
2939 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2941 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2947 lval = -(unsigned long)val;
2950 lval = (unsigned long)val;
2952 *lvalp = jiffies_to_clock_t(lval);
2957 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
2959 int write, void *data)
2962 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2972 lval = -(unsigned long)val;
2975 lval = (unsigned long)val;
2977 *lvalp = jiffies_to_msecs(lval);
2983 * proc_dointvec_jiffies - read a vector of integers as seconds
2984 * @table: the sysctl table
2985 * @write: %TRUE if this is a write to the sysctl file
2986 * @buffer: the user buffer
2987 * @lenp: the size of the user buffer
2988 * @ppos: file position
2990 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2991 * values from/to the user buffer, treated as an ASCII string.
2992 * The values read are assumed to be in seconds, and are converted into
2995 * Returns 0 on success.
2997 int proc_dointvec_jiffies(struct ctl_table *table, int write,
2998 void __user *buffer, size_t *lenp, loff_t *ppos)
3000 return do_proc_dointvec(table,write,buffer,lenp,ppos,
3001 do_proc_dointvec_jiffies_conv,NULL);
3005 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
3006 * @table: the sysctl table
3007 * @write: %TRUE if this is a write to the sysctl file
3008 * @buffer: the user buffer
3009 * @lenp: the size of the user buffer
3010 * @ppos: pointer to the file position
3012 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3013 * values from/to the user buffer, treated as an ASCII string.
3014 * The values read are assumed to be in 1/USER_HZ seconds, and
3015 * are converted into jiffies.
3017 * Returns 0 on success.
3019 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
3020 void __user *buffer, size_t *lenp, loff_t *ppos)
3022 return do_proc_dointvec(table,write,buffer,lenp,ppos,
3023 do_proc_dointvec_userhz_jiffies_conv,NULL);
3027 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
3028 * @table: the sysctl table
3029 * @write: %TRUE if this is a write to the sysctl file
3030 * @buffer: the user buffer
3031 * @lenp: the size of the user buffer
3032 * @ppos: file position
3033 * @ppos: the current position in the file
3035 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3036 * values from/to the user buffer, treated as an ASCII string.
3037 * The values read are assumed to be in 1/1000 seconds, and
3038 * are converted into jiffies.
3040 * Returns 0 on success.
3042 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
3043 void __user *buffer, size_t *lenp, loff_t *ppos)
3045 return do_proc_dointvec(table, write, buffer, lenp, ppos,
3046 do_proc_dointvec_ms_jiffies_conv, NULL);
3049 static int proc_do_cad_pid(struct ctl_table *table, int write,
3050 void __user *buffer, size_t *lenp, loff_t *ppos)
3052 struct pid *new_pid;
3056 tmp = pid_vnr(cad_pid);
3058 r = __do_proc_dointvec(&tmp, table, write, buffer,
3059 lenp, ppos, NULL, NULL);
3063 new_pid = find_get_pid(tmp);
3067 put_pid(xchg(&cad_pid, new_pid));
3072 * proc_do_large_bitmap - read/write from/to a large bitmap
3073 * @table: the sysctl table
3074 * @write: %TRUE if this is a write to the sysctl file
3075 * @buffer: the user buffer
3076 * @lenp: the size of the user buffer
3077 * @ppos: file position
3079 * The bitmap is stored at table->data and the bitmap length (in bits)
3082 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
3083 * large bitmaps may be represented in a compact manner. Writing into
3084 * the file will clear the bitmap then update it with the given input.
3086 * Returns 0 on success.
3088 int proc_do_large_bitmap(struct ctl_table *table, int write,
3089 void __user *buffer, size_t *lenp, loff_t *ppos)
3093 size_t left = *lenp;
3094 unsigned long bitmap_len = table->maxlen;
3095 unsigned long *bitmap = *(unsigned long **) table->data;
3096 unsigned long *tmp_bitmap = NULL;
3097 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
3099 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
3107 if (left > PAGE_SIZE - 1)
3108 left = PAGE_SIZE - 1;
3110 p = kbuf = memdup_user_nul(buffer, left);
3112 return PTR_ERR(kbuf);
3114 tmp_bitmap = kcalloc(BITS_TO_LONGS(bitmap_len),
3115 sizeof(unsigned long),
3121 proc_skip_char(&p, &left, '\n');
3122 while (!err && left) {
3123 unsigned long val_a, val_b;
3126 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
3130 if (val_a >= bitmap_len || neg) {
3142 err = proc_get_long(&p, &left, &val_b,
3143 &neg, tr_b, sizeof(tr_b),