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/kmemcheck.h>
34 #include <linux/kmemleak.h>
36 #include <linux/init.h>
37 #include <linux/kernel.h>
38 #include <linux/kobject.h>
39 #include <linux/net.h>
40 #include <linux/sysrq.h>
41 #include <linux/highuid.h>
42 #include <linux/writeback.h>
43 #include <linux/ratelimit.h>
44 #include <linux/compaction.h>
45 #include <linux/hugetlb.h>
46 #include <linux/initrd.h>
47 #include <linux/key.h>
48 #include <linux/times.h>
49 #include <linux/limits.h>
50 #include <linux/dcache.h>
51 #include <linux/dnotify.h>
52 #include <linux/syscalls.h>
53 #include <linux/vmstat.h>
54 #include <linux/nfs_fs.h>
55 #include <linux/acpi.h>
56 #include <linux/reboot.h>
57 #include <linux/ftrace.h>
58 #include <linux/perf_event.h>
59 #include <linux/kprobes.h>
60 #include <linux/pipe_fs_i.h>
61 #include <linux/oom.h>
62 #include <linux/kmod.h>
63 #include <linux/capability.h>
64 #include <linux/binfmts.h>
65 #include <linux/sched/sysctl.h>
66 #include <linux/sched/coredump.h>
67 #include <linux/kexec.h>
68 #include <linux/bpf.h>
69 #include <linux/mount.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
;
108 #ifdef CONFIG_USER_NS
109 extern int unprivileged_userns_clone
;
112 extern int pid_max_min
, pid_max_max
;
113 extern int percpu_pagelist_fraction
;
114 extern int latencytop_enabled
;
115 extern unsigned int sysctl_nr_open_min
, sysctl_nr_open_max
;
117 extern int sysctl_nr_trim_pages
;
120 /* Constants used for minimum and maximum */
121 #ifdef CONFIG_LOCKUP_DETECTOR
122 static int sixty
= 60;
125 static int __maybe_unused neg_one
= -1;
128 static int __maybe_unused one
= 1;
129 static int __maybe_unused two
= 2;
130 static int __maybe_unused four
= 4;
131 static unsigned long one_ul
= 1;
132 static int one_hundred
= 100;
133 static int one_thousand
= 1000;
135 static int ten_thousand
= 10000;
137 #ifdef CONFIG_PERF_EVENTS
138 static int six_hundred_forty_kb
= 640 * 1024;
141 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
142 static unsigned long dirty_bytes_min
= 2 * PAGE_SIZE
;
144 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
145 static int maxolduid
= 65535;
146 static int minolduid
;
148 static int ngroups_max
= NGROUPS_MAX
;
149 static const int cap_last_cap
= CAP_LAST_CAP
;
151 /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
152 #ifdef CONFIG_DETECT_HUNG_TASK
153 static unsigned long hung_task_timeout_max
= (LONG_MAX
/HZ
);
156 #ifdef CONFIG_INOTIFY_USER
157 #include <linux/inotify.h>
163 extern int pwrsw_enabled
;
166 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
167 extern int unaligned_enabled
;
171 extern int unaligned_dump_stack
;
174 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
175 extern int no_unaligned_warning
;
178 #ifdef CONFIG_PROC_SYSCTL
181 * enum sysctl_writes_mode - supported sysctl write modes
183 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
184 * to be written, and multiple writes on the same sysctl file descriptor
185 * will rewrite the sysctl value, regardless of file position. No warning
186 * is issued when the initial position is not 0.
187 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
189 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
190 * file position 0 and the value must be fully contained in the buffer
191 * sent to the write syscall. If dealing with strings respect the file
192 * position, but restrict this to the max length of the buffer, anything
193 * passed the max lenght will be ignored. Multiple writes will append
196 * These write modes control how current file position affects the behavior of
197 * updating sysctl values through the proc interface on each write.
199 enum sysctl_writes_mode
{
200 SYSCTL_WRITES_LEGACY
= -1,
201 SYSCTL_WRITES_WARN
= 0,
202 SYSCTL_WRITES_STRICT
= 1,
205 static enum sysctl_writes_mode sysctl_writes_strict
= SYSCTL_WRITES_STRICT
;
207 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
208 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
209 static int proc_taint(struct ctl_table
*table
, int write
,
210 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
214 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
215 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
218 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
219 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
220 #ifdef CONFIG_COREDUMP
221 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
222 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
225 #ifdef CONFIG_MAGIC_SYSRQ
226 /* Note: sysrq code uses it's own private copy */
227 static int __sysrq_enabled
= CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE
;
229 static int sysrq_sysctl_handler(struct ctl_table
*table
, int write
,
230 void __user
*buffer
, size_t *lenp
,
235 error
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
240 sysrq_toggle_support(__sysrq_enabled
);
247 static struct ctl_table kern_table
[];
248 static struct ctl_table vm_table
[];
249 static struct ctl_table fs_table
[];
250 static struct ctl_table debug_table
[];
251 static struct ctl_table dev_table
[];
252 extern struct ctl_table random_table
[];
254 extern struct ctl_table epoll_table
[];
257 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
258 int sysctl_legacy_va_layout
;
261 /* The default sysctl tables: */
263 static struct ctl_table sysctl_base_table
[] = {
265 .procname
= "kernel",
282 .child
= debug_table
,
292 #ifdef CONFIG_SCHED_DEBUG
293 static int min_sched_granularity_ns
= 100000; /* 100 usecs */
294 static int max_sched_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
295 static int min_wakeup_granularity_ns
; /* 0 usecs */
296 static int max_wakeup_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
298 static int min_sched_tunable_scaling
= SCHED_TUNABLESCALING_NONE
;
299 static int max_sched_tunable_scaling
= SCHED_TUNABLESCALING_END
-1;
300 #endif /* CONFIG_SMP */
301 #endif /* CONFIG_SCHED_DEBUG */
303 #ifdef CONFIG_COMPACTION
304 static int min_extfrag_threshold
;
305 static int max_extfrag_threshold
= 1000;
308 static struct ctl_table kern_table
[] = {
310 .procname
= "sched_child_runs_first",
311 .data
= &sysctl_sched_child_runs_first
,
312 .maxlen
= sizeof(unsigned int),
314 .proc_handler
= proc_dointvec
,
316 #ifdef CONFIG_SCHED_DEBUG
318 .procname
= "sched_min_granularity_ns",
319 .data
= &sysctl_sched_min_granularity
,
320 .maxlen
= sizeof(unsigned int),
322 .proc_handler
= sched_proc_update_handler
,
323 .extra1
= &min_sched_granularity_ns
,
324 .extra2
= &max_sched_granularity_ns
,
327 .procname
= "sched_latency_ns",
328 .data
= &sysctl_sched_latency
,
329 .maxlen
= sizeof(unsigned int),
331 .proc_handler
= sched_proc_update_handler
,
332 .extra1
= &min_sched_granularity_ns
,
333 .extra2
= &max_sched_granularity_ns
,
336 .procname
= "sched_wakeup_granularity_ns",
337 .data
= &sysctl_sched_wakeup_granularity
,
338 .maxlen
= sizeof(unsigned int),
340 .proc_handler
= sched_proc_update_handler
,
341 .extra1
= &min_wakeup_granularity_ns
,
342 .extra2
= &max_wakeup_granularity_ns
,
346 .procname
= "sched_tunable_scaling",
347 .data
= &sysctl_sched_tunable_scaling
,
348 .maxlen
= sizeof(enum sched_tunable_scaling
),
350 .proc_handler
= sched_proc_update_handler
,
351 .extra1
= &min_sched_tunable_scaling
,
352 .extra2
= &max_sched_tunable_scaling
,
355 .procname
= "sched_migration_cost_ns",
356 .data
= &sysctl_sched_migration_cost
,
357 .maxlen
= sizeof(unsigned int),
359 .proc_handler
= proc_dointvec
,
362 .procname
= "sched_nr_migrate",
363 .data
= &sysctl_sched_nr_migrate
,
364 .maxlen
= sizeof(unsigned int),
366 .proc_handler
= proc_dointvec
,
369 .procname
= "sched_time_avg_ms",
370 .data
= &sysctl_sched_time_avg
,
371 .maxlen
= sizeof(unsigned int),
373 .proc_handler
= proc_dointvec
,
375 #ifdef CONFIG_SCHEDSTATS
377 .procname
= "sched_schedstats",
379 .maxlen
= sizeof(unsigned int),
381 .proc_handler
= sysctl_schedstats
,
385 #endif /* CONFIG_SCHEDSTATS */
386 #endif /* CONFIG_SMP */
387 #ifdef CONFIG_NUMA_BALANCING
389 .procname
= "numa_balancing_scan_delay_ms",
390 .data
= &sysctl_numa_balancing_scan_delay
,
391 .maxlen
= sizeof(unsigned int),
393 .proc_handler
= proc_dointvec
,
396 .procname
= "numa_balancing_scan_period_min_ms",
397 .data
= &sysctl_numa_balancing_scan_period_min
,
398 .maxlen
= sizeof(unsigned int),
400 .proc_handler
= proc_dointvec
,
403 .procname
= "numa_balancing_scan_period_max_ms",
404 .data
= &sysctl_numa_balancing_scan_period_max
,
405 .maxlen
= sizeof(unsigned int),
407 .proc_handler
= proc_dointvec
,
410 .procname
= "numa_balancing_scan_size_mb",
411 .data
= &sysctl_numa_balancing_scan_size
,
412 .maxlen
= sizeof(unsigned int),
414 .proc_handler
= proc_dointvec_minmax
,
418 .procname
= "numa_balancing",
419 .data
= NULL
, /* filled in by handler */
420 .maxlen
= sizeof(unsigned int),
422 .proc_handler
= sysctl_numa_balancing
,
426 #endif /* CONFIG_NUMA_BALANCING */
427 #endif /* CONFIG_SCHED_DEBUG */
429 .procname
= "sched_rt_period_us",
430 .data
= &sysctl_sched_rt_period
,
431 .maxlen
= sizeof(unsigned int),
433 .proc_handler
= sched_rt_handler
,
436 .procname
= "sched_rt_runtime_us",
437 .data
= &sysctl_sched_rt_runtime
,
438 .maxlen
= sizeof(int),
440 .proc_handler
= sched_rt_handler
,
443 .procname
= "sched_rr_timeslice_ms",
444 .data
= &sysctl_sched_rr_timeslice
,
445 .maxlen
= sizeof(int),
447 .proc_handler
= sched_rr_handler
,
449 #ifdef CONFIG_SCHED_AUTOGROUP
451 .procname
= "sched_autogroup_enabled",
452 .data
= &sysctl_sched_autogroup_enabled
,
453 .maxlen
= sizeof(unsigned int),
455 .proc_handler
= proc_dointvec_minmax
,
460 #ifdef CONFIG_CFS_BANDWIDTH
462 .procname
= "sched_cfs_bandwidth_slice_us",
463 .data
= &sysctl_sched_cfs_bandwidth_slice
,
464 .maxlen
= sizeof(unsigned int),
466 .proc_handler
= proc_dointvec_minmax
,
470 #ifdef CONFIG_PROVE_LOCKING
472 .procname
= "prove_locking",
473 .data
= &prove_locking
,
474 .maxlen
= sizeof(int),
476 .proc_handler
= proc_dointvec
,
479 #ifdef CONFIG_LOCK_STAT
481 .procname
= "lock_stat",
483 .maxlen
= sizeof(int),
485 .proc_handler
= proc_dointvec
,
490 .data
= &panic_timeout
,
491 .maxlen
= sizeof(int),
493 .proc_handler
= proc_dointvec
,
495 #ifdef CONFIG_COREDUMP
497 .procname
= "core_uses_pid",
498 .data
= &core_uses_pid
,
499 .maxlen
= sizeof(int),
501 .proc_handler
= proc_dointvec
,
504 .procname
= "core_pattern",
505 .data
= core_pattern
,
506 .maxlen
= CORENAME_MAX_SIZE
,
508 .proc_handler
= proc_dostring_coredump
,
511 .procname
= "core_pipe_limit",
512 .data
= &core_pipe_limit
,
513 .maxlen
= sizeof(unsigned int),
515 .proc_handler
= proc_dointvec
,
518 #ifdef CONFIG_USER_NS
520 .procname
= "unprivileged_userns_clone",
521 .data
= &unprivileged_userns_clone
,
522 .maxlen
= sizeof(int),
524 .proc_handler
= proc_dointvec
,
527 #ifdef CONFIG_PROC_SYSCTL
529 .procname
= "tainted",
530 .maxlen
= sizeof(long),
532 .proc_handler
= proc_taint
,
535 .procname
= "sysctl_writes_strict",
536 .data
= &sysctl_writes_strict
,
537 .maxlen
= sizeof(int),
539 .proc_handler
= proc_dointvec_minmax
,
544 #ifdef CONFIG_LATENCYTOP
546 .procname
= "latencytop",
547 .data
= &latencytop_enabled
,
548 .maxlen
= sizeof(int),
550 .proc_handler
= sysctl_latencytop
,
553 #ifdef CONFIG_BLK_DEV_INITRD
555 .procname
= "real-root-dev",
556 .data
= &real_root_dev
,
557 .maxlen
= sizeof(int),
559 .proc_handler
= proc_dointvec
,
563 .procname
= "print-fatal-signals",
564 .data
= &print_fatal_signals
,
565 .maxlen
= sizeof(int),
567 .proc_handler
= proc_dointvec
,
571 .procname
= "reboot-cmd",
572 .data
= reboot_command
,
575 .proc_handler
= proc_dostring
,
578 .procname
= "stop-a",
579 .data
= &stop_a_enabled
,
580 .maxlen
= sizeof (int),
582 .proc_handler
= proc_dointvec
,
585 .procname
= "scons-poweroff",
586 .data
= &scons_pwroff
,
587 .maxlen
= sizeof (int),
589 .proc_handler
= proc_dointvec
,
592 #ifdef CONFIG_SPARC64
594 .procname
= "tsb-ratio",
595 .data
= &sysctl_tsb_ratio
,
596 .maxlen
= sizeof (int),
598 .proc_handler
= proc_dointvec
,
603 .procname
= "soft-power",
604 .data
= &pwrsw_enabled
,
605 .maxlen
= sizeof (int),
607 .proc_handler
= proc_dointvec
,
610 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
612 .procname
= "unaligned-trap",
613 .data
= &unaligned_enabled
,
614 .maxlen
= sizeof (int),
616 .proc_handler
= proc_dointvec
,
620 .procname
= "ctrl-alt-del",
622 .maxlen
= sizeof(int),
624 .proc_handler
= proc_dointvec
,
626 #ifdef CONFIG_FUNCTION_TRACER
628 .procname
= "ftrace_enabled",
629 .data
= &ftrace_enabled
,
630 .maxlen
= sizeof(int),
632 .proc_handler
= ftrace_enable_sysctl
,
635 #ifdef CONFIG_STACK_TRACER
637 .procname
= "stack_tracer_enabled",
638 .data
= &stack_tracer_enabled
,
639 .maxlen
= sizeof(int),
641 .proc_handler
= stack_trace_sysctl
,
644 #ifdef CONFIG_TRACING
646 .procname
= "ftrace_dump_on_oops",
647 .data
= &ftrace_dump_on_oops
,
648 .maxlen
= sizeof(int),
650 .proc_handler
= proc_dointvec
,
653 .procname
= "traceoff_on_warning",
654 .data
= &__disable_trace_on_warning
,
655 .maxlen
= sizeof(__disable_trace_on_warning
),
657 .proc_handler
= proc_dointvec
,
660 .procname
= "tracepoint_printk",
661 .data
= &tracepoint_printk
,
662 .maxlen
= sizeof(tracepoint_printk
),
664 .proc_handler
= tracepoint_printk_sysctl
,
667 #ifdef CONFIG_KEXEC_CORE
669 .procname
= "kexec_load_disabled",
670 .data
= &kexec_load_disabled
,
671 .maxlen
= sizeof(int),
673 /* only handle a transition from default "0" to "1" */
674 .proc_handler
= proc_dointvec_minmax
,
679 #ifdef CONFIG_MODULES
681 .procname
= "modprobe",
682 .data
= &modprobe_path
,
683 .maxlen
= KMOD_PATH_LEN
,
685 .proc_handler
= proc_dostring
,
688 .procname
= "modules_disabled",
689 .data
= &modules_disabled
,
690 .maxlen
= sizeof(int),
692 /* only handle a transition from default "0" to "1" */
693 .proc_handler
= proc_dointvec_minmax
,
698 #ifdef CONFIG_UEVENT_HELPER
700 .procname
= "hotplug",
701 .data
= &uevent_helper
,
702 .maxlen
= UEVENT_HELPER_PATH_LEN
,
704 .proc_handler
= proc_dostring
,
707 #ifdef CONFIG_CHR_DEV_SG
709 .procname
= "sg-big-buff",
710 .data
= &sg_big_buff
,
711 .maxlen
= sizeof (int),
713 .proc_handler
= proc_dointvec
,
716 #ifdef CONFIG_BSD_PROCESS_ACCT
720 .maxlen
= 3*sizeof(int),
722 .proc_handler
= proc_dointvec
,
725 #ifdef CONFIG_MAGIC_SYSRQ
728 .data
= &__sysrq_enabled
,
729 .maxlen
= sizeof (int),
731 .proc_handler
= sysrq_sysctl_handler
,
734 #ifdef CONFIG_PROC_SYSCTL
736 .procname
= "cad_pid",
738 .maxlen
= sizeof (int),
740 .proc_handler
= proc_do_cad_pid
,
744 .procname
= "threads-max",
746 .maxlen
= sizeof(int),
748 .proc_handler
= sysctl_max_threads
,
751 .procname
= "random",
753 .child
= random_table
,
756 .procname
= "usermodehelper",
758 .child
= usermodehelper_table
,
761 .procname
= "overflowuid",
762 .data
= &overflowuid
,
763 .maxlen
= sizeof(int),
765 .proc_handler
= proc_dointvec_minmax
,
766 .extra1
= &minolduid
,
767 .extra2
= &maxolduid
,
770 .procname
= "overflowgid",
771 .data
= &overflowgid
,
772 .maxlen
= sizeof(int),
774 .proc_handler
= proc_dointvec_minmax
,
775 .extra1
= &minolduid
,
776 .extra2
= &maxolduid
,
779 #ifdef CONFIG_MATHEMU
781 .procname
= "ieee_emulation_warnings",
782 .data
= &sysctl_ieee_emulation_warnings
,
783 .maxlen
= sizeof(int),
785 .proc_handler
= proc_dointvec
,
789 .procname
= "userprocess_debug",
790 .data
= &show_unhandled_signals
,
791 .maxlen
= sizeof(int),
793 .proc_handler
= proc_dointvec
,
797 .procname
= "pid_max",
799 .maxlen
= sizeof (int),
801 .proc_handler
= proc_dointvec_minmax
,
802 .extra1
= &pid_max_min
,
803 .extra2
= &pid_max_max
,
806 .procname
= "panic_on_oops",
807 .data
= &panic_on_oops
,
808 .maxlen
= sizeof(int),
810 .proc_handler
= proc_dointvec
,
812 #if defined CONFIG_PRINTK
814 .procname
= "printk",
815 .data
= &console_loglevel
,
816 .maxlen
= 4*sizeof(int),
818 .proc_handler
= proc_dointvec
,
821 .procname
= "printk_ratelimit",
822 .data
= &printk_ratelimit_state
.interval
,
823 .maxlen
= sizeof(int),
825 .proc_handler
= proc_dointvec_jiffies
,
828 .procname
= "printk_ratelimit_burst",
829 .data
= &printk_ratelimit_state
.burst
,
830 .maxlen
= sizeof(int),
832 .proc_handler
= proc_dointvec
,
835 .procname
= "printk_delay",
836 .data
= &printk_delay_msec
,
837 .maxlen
= sizeof(int),
839 .proc_handler
= proc_dointvec_minmax
,
841 .extra2
= &ten_thousand
,
844 .procname
= "printk_devkmsg",
845 .data
= devkmsg_log_str
,
846 .maxlen
= DEVKMSG_STR_MAX_SIZE
,
848 .proc_handler
= devkmsg_sysctl_set_loglvl
,
851 .procname
= "dmesg_restrict",
852 .data
= &dmesg_restrict
,
853 .maxlen
= sizeof(int),
855 .proc_handler
= proc_dointvec_minmax_sysadmin
,
860 .procname
= "kptr_restrict",
861 .data
= &kptr_restrict
,
862 .maxlen
= sizeof(int),
864 .proc_handler
= proc_dointvec_minmax_sysadmin
,
870 .procname
= "ngroups_max",
871 .data
= &ngroups_max
,
872 .maxlen
= sizeof (int),
874 .proc_handler
= proc_dointvec
,
877 .procname
= "cap_last_cap",
878 .data
= (void *)&cap_last_cap
,
879 .maxlen
= sizeof(int),
881 .proc_handler
= proc_dointvec
,
883 #if defined(CONFIG_LOCKUP_DETECTOR)
885 .procname
= "watchdog",
886 .data
= &watchdog_user_enabled
,
887 .maxlen
= sizeof (int),
889 .proc_handler
= proc_watchdog
,
894 .procname
= "watchdog_thresh",
895 .data
= &watchdog_thresh
,
896 .maxlen
= sizeof(int),
898 .proc_handler
= proc_watchdog_thresh
,
903 .procname
= "nmi_watchdog",
904 .data
= &nmi_watchdog_enabled
,
905 .maxlen
= sizeof (int),
907 .proc_handler
= proc_nmi_watchdog
,
909 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
916 .procname
= "watchdog_cpumask",
917 .data
= &watchdog_cpumask_bits
,
920 .proc_handler
= proc_watchdog_cpumask
,
922 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
924 .procname
= "soft_watchdog",
925 .data
= &soft_watchdog_enabled
,
926 .maxlen
= sizeof (int),
928 .proc_handler
= proc_soft_watchdog
,
933 .procname
= "softlockup_panic",
934 .data
= &softlockup_panic
,
935 .maxlen
= sizeof(int),
937 .proc_handler
= proc_dointvec_minmax
,
943 .procname
= "softlockup_all_cpu_backtrace",
944 .data
= &sysctl_softlockup_all_cpu_backtrace
,
945 .maxlen
= sizeof(int),
947 .proc_handler
= proc_dointvec_minmax
,
951 #endif /* CONFIG_SMP */
953 #ifdef CONFIG_HARDLOCKUP_DETECTOR
955 .procname
= "hardlockup_panic",
956 .data
= &hardlockup_panic
,
957 .maxlen
= sizeof(int),
959 .proc_handler
= proc_dointvec_minmax
,
965 .procname
= "hardlockup_all_cpu_backtrace",
966 .data
= &sysctl_hardlockup_all_cpu_backtrace
,
967 .maxlen
= sizeof(int),
969 .proc_handler
= proc_dointvec_minmax
,
973 #endif /* CONFIG_SMP */
977 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
979 .procname
= "unknown_nmi_panic",
980 .data
= &unknown_nmi_panic
,
981 .maxlen
= sizeof (int),
983 .proc_handler
= proc_dointvec
,
986 #if defined(CONFIG_X86)
988 .procname
= "panic_on_unrecovered_nmi",
989 .data
= &panic_on_unrecovered_nmi
,
990 .maxlen
= sizeof(int),
992 .proc_handler
= proc_dointvec
,
995 .procname
= "panic_on_io_nmi",
996 .data
= &panic_on_io_nmi
,
997 .maxlen
= sizeof(int),
999 .proc_handler
= proc_dointvec
,
1001 #ifdef CONFIG_DEBUG_STACKOVERFLOW
1003 .procname
= "panic_on_stackoverflow",
1004 .data
= &sysctl_panic_on_stackoverflow
,
1005 .maxlen
= sizeof(int),
1007 .proc_handler
= proc_dointvec
,
1011 .procname
= "bootloader_type",
1012 .data
= &bootloader_type
,
1013 .maxlen
= sizeof (int),
1015 .proc_handler
= proc_dointvec
,
1018 .procname
= "bootloader_version",
1019 .data
= &bootloader_version
,
1020 .maxlen
= sizeof (int),
1022 .proc_handler
= proc_dointvec
,
1025 .procname
= "io_delay_type",
1026 .data
= &io_delay_type
,
1027 .maxlen
= sizeof(int),
1029 .proc_handler
= proc_dointvec
,
1032 #if defined(CONFIG_MMU)
1034 .procname
= "randomize_va_space",
1035 .data
= &randomize_va_space
,
1036 .maxlen
= sizeof(int),
1038 .proc_handler
= proc_dointvec
,
1041 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1043 .procname
= "spin_retry",
1044 .data
= &spin_retry
,
1045 .maxlen
= sizeof (int),
1047 .proc_handler
= proc_dointvec
,
1050 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1052 .procname
= "acpi_video_flags",
1053 .data
= &acpi_realmode_flags
,
1054 .maxlen
= sizeof (unsigned long),
1056 .proc_handler
= proc_doulongvec_minmax
,
1059 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1061 .procname
= "ignore-unaligned-usertrap",
1062 .data
= &no_unaligned_warning
,
1063 .maxlen
= sizeof (int),
1065 .proc_handler
= proc_dointvec
,
1070 .procname
= "unaligned-dump-stack",
1071 .data
= &unaligned_dump_stack
,
1072 .maxlen
= sizeof (int),
1074 .proc_handler
= proc_dointvec
,
1077 #ifdef CONFIG_DETECT_HUNG_TASK
1079 .procname
= "hung_task_panic",
1080 .data
= &sysctl_hung_task_panic
,
1081 .maxlen
= sizeof(int),
1083 .proc_handler
= proc_dointvec_minmax
,
1088 .procname
= "hung_task_check_count",
1089 .data
= &sysctl_hung_task_check_count
,
1090 .maxlen
= sizeof(int),
1092 .proc_handler
= proc_dointvec_minmax
,
1096 .procname
= "hung_task_timeout_secs",
1097 .data
= &sysctl_hung_task_timeout_secs
,
1098 .maxlen
= sizeof(unsigned long),
1100 .proc_handler
= proc_dohung_task_timeout_secs
,
1101 .extra2
= &hung_task_timeout_max
,
1104 .procname
= "hung_task_warnings",
1105 .data
= &sysctl_hung_task_warnings
,
1106 .maxlen
= sizeof(int),
1108 .proc_handler
= proc_dointvec_minmax
,
1112 #ifdef CONFIG_RT_MUTEXES
1114 .procname
= "max_lock_depth",
1115 .data
= &max_lock_depth
,
1116 .maxlen
= sizeof(int),
1118 .proc_handler
= proc_dointvec
,
1122 .procname
= "poweroff_cmd",
1123 .data
= &poweroff_cmd
,
1124 .maxlen
= POWEROFF_CMD_PATH_LEN
,
1126 .proc_handler
= proc_dostring
,
1132 .child
= key_sysctls
,
1135 #ifdef CONFIG_PERF_EVENTS
1137 * User-space scripts rely on the existence of this file
1138 * as a feature check for perf_events being enabled.
1140 * So it's an ABI, do not remove!
1143 .procname
= "perf_event_paranoid",
1144 .data
= &sysctl_perf_event_paranoid
,
1145 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
1147 .proc_handler
= proc_dointvec
,
1150 .procname
= "perf_event_mlock_kb",
1151 .data
= &sysctl_perf_event_mlock
,
1152 .maxlen
= sizeof(sysctl_perf_event_mlock
),
1154 .proc_handler
= proc_dointvec
,
1157 .procname
= "perf_event_max_sample_rate",
1158 .data
= &sysctl_perf_event_sample_rate
,
1159 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1161 .proc_handler
= perf_proc_update_handler
,
1165 .procname
= "perf_cpu_time_max_percent",
1166 .data
= &sysctl_perf_cpu_time_max_percent
,
1167 .maxlen
= sizeof(sysctl_perf_cpu_time_max_percent
),
1169 .proc_handler
= perf_cpu_time_max_percent_handler
,
1171 .extra2
= &one_hundred
,
1174 .procname
= "perf_event_max_stack",
1175 .data
= &sysctl_perf_event_max_stack
,
1176 .maxlen
= sizeof(sysctl_perf_event_max_stack
),
1178 .proc_handler
= perf_event_max_stack_handler
,
1180 .extra2
= &six_hundred_forty_kb
,
1183 .procname
= "perf_event_max_contexts_per_stack",
1184 .data
= &sysctl_perf_event_max_contexts_per_stack
,
1185 .maxlen
= sizeof(sysctl_perf_event_max_contexts_per_stack
),
1187 .proc_handler
= perf_event_max_stack_handler
,
1189 .extra2
= &one_thousand
,
1192 #ifdef CONFIG_KMEMCHECK
1194 .procname
= "kmemcheck",
1195 .data
= &kmemcheck_enabled
,
1196 .maxlen
= sizeof(int),
1198 .proc_handler
= proc_dointvec
,
1202 .procname
= "panic_on_warn",
1203 .data
= &panic_on_warn
,
1204 .maxlen
= sizeof(int),
1206 .proc_handler
= proc_dointvec_minmax
,
1210 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1212 .procname
= "timer_migration",
1213 .data
= &sysctl_timer_migration
,
1214 .maxlen
= sizeof(unsigned int),
1216 .proc_handler
= timer_migration_handler
,
1221 #ifdef CONFIG_BPF_SYSCALL
1223 .procname
= "unprivileged_bpf_disabled",
1224 .data
= &sysctl_unprivileged_bpf_disabled
,
1225 .maxlen
= sizeof(sysctl_unprivileged_bpf_disabled
),
1227 /* only handle a transition from default "0" to "1" */
1228 .proc_handler
= proc_dointvec_minmax
,
1233 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1235 .procname
= "panic_on_rcu_stall",
1236 .data
= &sysctl_panic_on_rcu_stall
,
1237 .maxlen
= sizeof(sysctl_panic_on_rcu_stall
),
1239 .proc_handler
= proc_dointvec_minmax
,
1247 static struct ctl_table vm_table
[] = {
1249 .procname
= "overcommit_memory",
1250 .data
= &sysctl_overcommit_memory
,
1251 .maxlen
= sizeof(sysctl_overcommit_memory
),
1253 .proc_handler
= proc_dointvec_minmax
,
1258 .procname
= "panic_on_oom",
1259 .data
= &sysctl_panic_on_oom
,
1260 .maxlen
= sizeof(sysctl_panic_on_oom
),
1262 .proc_handler
= proc_dointvec_minmax
,
1267 .procname
= "oom_kill_allocating_task",
1268 .data
= &sysctl_oom_kill_allocating_task
,
1269 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
1271 .proc_handler
= proc_dointvec
,
1274 .procname
= "oom_dump_tasks",
1275 .data
= &sysctl_oom_dump_tasks
,
1276 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
1278 .proc_handler
= proc_dointvec
,
1281 .procname
= "overcommit_ratio",
1282 .data
= &sysctl_overcommit_ratio
,
1283 .maxlen
= sizeof(sysctl_overcommit_ratio
),
1285 .proc_handler
= overcommit_ratio_handler
,
1288 .procname
= "overcommit_kbytes",
1289 .data
= &sysctl_overcommit_kbytes
,
1290 .maxlen
= sizeof(sysctl_overcommit_kbytes
),
1292 .proc_handler
= overcommit_kbytes_handler
,
1295 .procname
= "page-cluster",
1296 .data
= &page_cluster
,
1297 .maxlen
= sizeof(int),
1299 .proc_handler
= proc_dointvec_minmax
,
1303 .procname
= "dirty_background_ratio",
1304 .data
= &dirty_background_ratio
,
1305 .maxlen
= sizeof(dirty_background_ratio
),
1307 .proc_handler
= dirty_background_ratio_handler
,
1309 .extra2
= &one_hundred
,
1312 .procname
= "dirty_background_bytes",
1313 .data
= &dirty_background_bytes
,
1314 .maxlen
= sizeof(dirty_background_bytes
),
1316 .proc_handler
= dirty_background_bytes_handler
,
1320 .procname
= "dirty_ratio",
1321 .data
= &vm_dirty_ratio
,
1322 .maxlen
= sizeof(vm_dirty_ratio
),
1324 .proc_handler
= dirty_ratio_handler
,
1326 .extra2
= &one_hundred
,
1329 .procname
= "dirty_bytes",
1330 .data
= &vm_dirty_bytes
,
1331 .maxlen
= sizeof(vm_dirty_bytes
),
1333 .proc_handler
= dirty_bytes_handler
,
1334 .extra1
= &dirty_bytes_min
,
1337 .procname
= "dirty_writeback_centisecs",
1338 .data
= &dirty_writeback_interval
,
1339 .maxlen
= sizeof(dirty_writeback_interval
),
1341 .proc_handler
= dirty_writeback_centisecs_handler
,
1344 .procname
= "dirty_expire_centisecs",
1345 .data
= &dirty_expire_interval
,
1346 .maxlen
= sizeof(dirty_expire_interval
),
1348 .proc_handler
= proc_dointvec_minmax
,
1352 .procname
= "dirtytime_expire_seconds",
1353 .data
= &dirtytime_expire_interval
,
1354 .maxlen
= sizeof(dirty_expire_interval
),
1356 .proc_handler
= dirtytime_interval_handler
,
1360 .procname
= "nr_pdflush_threads",
1361 .mode
= 0444 /* read-only */,
1362 .proc_handler
= pdflush_proc_obsolete
,
1365 .procname
= "swappiness",
1366 .data
= &vm_swappiness
,
1367 .maxlen
= sizeof(vm_swappiness
),
1369 .proc_handler
= proc_dointvec_minmax
,
1371 .extra2
= &one_hundred
,
1373 #ifdef CONFIG_HUGETLB_PAGE
1375 .procname
= "nr_hugepages",
1377 .maxlen
= sizeof(unsigned long),
1379 .proc_handler
= hugetlb_sysctl_handler
,
1383 .procname
= "nr_hugepages_mempolicy",
1385 .maxlen
= sizeof(unsigned long),
1387 .proc_handler
= &hugetlb_mempolicy_sysctl_handler
,
1391 .procname
= "hugetlb_shm_group",
1392 .data
= &sysctl_hugetlb_shm_group
,
1393 .maxlen
= sizeof(gid_t
),
1395 .proc_handler
= proc_dointvec
,
1398 .procname
= "hugepages_treat_as_movable",
1399 .data
= &hugepages_treat_as_movable
,
1400 .maxlen
= sizeof(int),
1402 .proc_handler
= proc_dointvec
,
1405 .procname
= "nr_overcommit_hugepages",
1407 .maxlen
= sizeof(unsigned long),
1409 .proc_handler
= hugetlb_overcommit_handler
,
1413 .procname
= "lowmem_reserve_ratio",
1414 .data
= &sysctl_lowmem_reserve_ratio
,
1415 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
1417 .proc_handler
= lowmem_reserve_ratio_sysctl_handler
,
1420 .procname
= "drop_caches",
1421 .data
= &sysctl_drop_caches
,
1422 .maxlen
= sizeof(int),
1424 .proc_handler
= drop_caches_sysctl_handler
,
1428 #ifdef CONFIG_COMPACTION
1430 .procname
= "compact_memory",
1431 .data
= &sysctl_compact_memory
,
1432 .maxlen
= sizeof(int),
1434 .proc_handler
= sysctl_compaction_handler
,
1437 .procname
= "extfrag_threshold",
1438 .data
= &sysctl_extfrag_threshold
,
1439 .maxlen
= sizeof(int),
1441 .proc_handler
= sysctl_extfrag_handler
,
1442 .extra1
= &min_extfrag_threshold
,
1443 .extra2
= &max_extfrag_threshold
,
1446 .procname
= "compact_unevictable_allowed",
1447 .data
= &sysctl_compact_unevictable_allowed
,
1448 .maxlen
= sizeof(int),
1450 .proc_handler
= proc_dointvec
,
1455 #endif /* CONFIG_COMPACTION */
1457 .procname
= "min_free_kbytes",
1458 .data
= &min_free_kbytes
,
1459 .maxlen
= sizeof(min_free_kbytes
),
1461 .proc_handler
= min_free_kbytes_sysctl_handler
,
1465 .procname
= "watermark_scale_factor",
1466 .data
= &watermark_scale_factor
,
1467 .maxlen
= sizeof(watermark_scale_factor
),
1469 .proc_handler
= watermark_scale_factor_sysctl_handler
,
1471 .extra2
= &one_thousand
,
1474 .procname
= "percpu_pagelist_fraction",
1475 .data
= &percpu_pagelist_fraction
,
1476 .maxlen
= sizeof(percpu_pagelist_fraction
),
1478 .proc_handler
= percpu_pagelist_fraction_sysctl_handler
,
1483 .procname
= "max_map_count",
1484 .data
= &sysctl_max_map_count
,
1485 .maxlen
= sizeof(sysctl_max_map_count
),
1487 .proc_handler
= proc_dointvec_minmax
,
1492 .procname
= "nr_trim_pages",
1493 .data
= &sysctl_nr_trim_pages
,
1494 .maxlen
= sizeof(sysctl_nr_trim_pages
),
1496 .proc_handler
= proc_dointvec_minmax
,
1501 .procname
= "laptop_mode",
1502 .data
= &laptop_mode
,
1503 .maxlen
= sizeof(laptop_mode
),
1505 .proc_handler
= proc_dointvec_jiffies
,
1508 .procname
= "block_dump",
1509 .data
= &block_dump
,
1510 .maxlen
= sizeof(block_dump
),
1512 .proc_handler
= proc_dointvec
,
1516 .procname
= "vfs_cache_pressure",
1517 .data
= &sysctl_vfs_cache_pressure
,
1518 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1520 .proc_handler
= proc_dointvec
,
1523 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1525 .procname
= "legacy_va_layout",
1526 .data
= &sysctl_legacy_va_layout
,
1527 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1529 .proc_handler
= proc_dointvec
,
1535 .procname
= "zone_reclaim_mode",
1536 .data
= &node_reclaim_mode
,
1537 .maxlen
= sizeof(node_reclaim_mode
),
1539 .proc_handler
= proc_dointvec
,
1543 .procname
= "min_unmapped_ratio",
1544 .data
= &sysctl_min_unmapped_ratio
,
1545 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1547 .proc_handler
= sysctl_min_unmapped_ratio_sysctl_handler
,
1549 .extra2
= &one_hundred
,
1552 .procname
= "min_slab_ratio",
1553 .data
= &sysctl_min_slab_ratio
,
1554 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1556 .proc_handler
= sysctl_min_slab_ratio_sysctl_handler
,
1558 .extra2
= &one_hundred
,
1563 .procname
= "stat_interval",
1564 .data
= &sysctl_stat_interval
,
1565 .maxlen
= sizeof(sysctl_stat_interval
),
1567 .proc_handler
= proc_dointvec_jiffies
,
1570 .procname
= "stat_refresh",
1574 .proc_handler
= vmstat_refresh
,
1579 .procname
= "mmap_min_addr",
1580 .data
= &dac_mmap_min_addr
,
1581 .maxlen
= sizeof(unsigned long),
1583 .proc_handler
= mmap_min_addr_handler
,
1588 .procname
= "numa_zonelist_order",
1589 .data
= &numa_zonelist_order
,
1590 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1592 .proc_handler
= numa_zonelist_order_handler
,
1595 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1596 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1598 .procname
= "vdso_enabled",
1599 #ifdef CONFIG_X86_32
1600 .data
= &vdso32_enabled
,
1601 .maxlen
= sizeof(vdso32_enabled
),
1603 .data
= &vdso_enabled
,
1604 .maxlen
= sizeof(vdso_enabled
),
1607 .proc_handler
= proc_dointvec
,
1611 #ifdef CONFIG_HIGHMEM
1613 .procname
= "highmem_is_dirtyable",
1614 .data
= &vm_highmem_is_dirtyable
,
1615 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
1617 .proc_handler
= proc_dointvec_minmax
,
1622 #ifdef CONFIG_MEMORY_FAILURE
1624 .procname
= "memory_failure_early_kill",
1625 .data
= &sysctl_memory_failure_early_kill
,
1626 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
1628 .proc_handler
= proc_dointvec_minmax
,
1633 .procname
= "memory_failure_recovery",
1634 .data
= &sysctl_memory_failure_recovery
,
1635 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
1637 .proc_handler
= proc_dointvec_minmax
,
1643 .procname
= "user_reserve_kbytes",
1644 .data
= &sysctl_user_reserve_kbytes
,
1645 .maxlen
= sizeof(sysctl_user_reserve_kbytes
),
1647 .proc_handler
= proc_doulongvec_minmax
,
1650 .procname
= "admin_reserve_kbytes",
1651 .data
= &sysctl_admin_reserve_kbytes
,
1652 .maxlen
= sizeof(sysctl_admin_reserve_kbytes
),
1654 .proc_handler
= proc_doulongvec_minmax
,
1656 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1658 .procname
= "mmap_rnd_bits",
1659 .data
= &mmap_rnd_bits
,
1660 .maxlen
= sizeof(mmap_rnd_bits
),
1662 .proc_handler
= proc_dointvec_minmax
,
1663 .extra1
= (void *)&mmap_rnd_bits_min
,
1664 .extra2
= (void *)&mmap_rnd_bits_max
,
1667 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1669 .procname
= "mmap_rnd_compat_bits",
1670 .data
= &mmap_rnd_compat_bits
,
1671 .maxlen
= sizeof(mmap_rnd_compat_bits
),
1673 .proc_handler
= proc_dointvec_minmax
,
1674 .extra1
= (void *)&mmap_rnd_compat_bits_min
,
1675 .extra2
= (void *)&mmap_rnd_compat_bits_max
,
1681 static struct ctl_table fs_table
[] = {
1683 .procname
= "inode-nr",
1684 .data
= &inodes_stat
,
1685 .maxlen
= 2*sizeof(long),
1687 .proc_handler
= proc_nr_inodes
,
1690 .procname
= "inode-state",
1691 .data
= &inodes_stat
,
1692 .maxlen
= 7*sizeof(long),
1694 .proc_handler
= proc_nr_inodes
,
1697 .procname
= "file-nr",
1698 .data
= &files_stat
,
1699 .maxlen
= sizeof(files_stat
),
1701 .proc_handler
= proc_nr_files
,
1704 .procname
= "file-max",
1705 .data
= &files_stat
.max_files
,
1706 .maxlen
= sizeof(files_stat
.max_files
),
1708 .proc_handler
= proc_doulongvec_minmax
,
1711 .procname
= "nr_open",
1712 .data
= &sysctl_nr_open
,
1713 .maxlen
= sizeof(unsigned int),
1715 .proc_handler
= proc_dointvec_minmax
,
1716 .extra1
= &sysctl_nr_open_min
,
1717 .extra2
= &sysctl_nr_open_max
,
1720 .procname
= "dentry-state",
1721 .data
= &dentry_stat
,
1722 .maxlen
= 6*sizeof(long),
1724 .proc_handler
= proc_nr_dentry
,
1727 .procname
= "overflowuid",
1728 .data
= &fs_overflowuid
,
1729 .maxlen
= sizeof(int),
1731 .proc_handler
= proc_dointvec_minmax
,
1732 .extra1
= &minolduid
,
1733 .extra2
= &maxolduid
,
1736 .procname
= "overflowgid",
1737 .data
= &fs_overflowgid
,
1738 .maxlen
= sizeof(int),
1740 .proc_handler
= proc_dointvec_minmax
,
1741 .extra1
= &minolduid
,
1742 .extra2
= &maxolduid
,
1744 #ifdef CONFIG_FILE_LOCKING
1746 .procname
= "leases-enable",
1747 .data
= &leases_enable
,
1748 .maxlen
= sizeof(int),
1750 .proc_handler
= proc_dointvec
,
1753 #ifdef CONFIG_DNOTIFY
1755 .procname
= "dir-notify-enable",
1756 .data
= &dir_notify_enable
,
1757 .maxlen
= sizeof(int),
1759 .proc_handler
= proc_dointvec
,
1763 #ifdef CONFIG_FILE_LOCKING
1765 .procname
= "lease-break-time",
1766 .data
= &lease_break_time
,
1767 .maxlen
= sizeof(int),
1769 .proc_handler
= proc_dointvec
,
1774 .procname
= "aio-nr",
1776 .maxlen
= sizeof(aio_nr
),
1778 .proc_handler
= proc_doulongvec_minmax
,
1781 .procname
= "aio-max-nr",
1782 .data
= &aio_max_nr
,
1783 .maxlen
= sizeof(aio_max_nr
),
1785 .proc_handler
= proc_doulongvec_minmax
,
1787 #endif /* CONFIG_AIO */
1788 #ifdef CONFIG_INOTIFY_USER
1790 .procname
= "inotify",
1792 .child
= inotify_table
,
1797 .procname
= "epoll",
1799 .child
= epoll_table
,
1804 .procname
= "protected_symlinks",
1805 .data
= &sysctl_protected_symlinks
,
1806 .maxlen
= sizeof(int),
1808 .proc_handler
= proc_dointvec_minmax
,
1813 .procname
= "protected_hardlinks",
1814 .data
= &sysctl_protected_hardlinks
,
1815 .maxlen
= sizeof(int),
1817 .proc_handler
= proc_dointvec_minmax
,
1822 .procname
= "suid_dumpable",
1823 .data
= &suid_dumpable
,
1824 .maxlen
= sizeof(int),
1826 .proc_handler
= proc_dointvec_minmax_coredump
,
1830 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1832 .procname
= "binfmt_misc",
1834 .child
= sysctl_mount_point
,
1838 .procname
= "pipe-max-size",
1839 .data
= &pipe_max_size
,
1840 .maxlen
= sizeof(int),
1842 .proc_handler
= &pipe_proc_fn
,
1843 .extra1
= &pipe_min_size
,
1846 .procname
= "pipe-user-pages-hard",
1847 .data
= &pipe_user_pages_hard
,
1848 .maxlen
= sizeof(pipe_user_pages_hard
),
1850 .proc_handler
= proc_doulongvec_minmax
,
1853 .procname
= "pipe-user-pages-soft",
1854 .data
= &pipe_user_pages_soft
,
1855 .maxlen
= sizeof(pipe_user_pages_soft
),
1857 .proc_handler
= proc_doulongvec_minmax
,
1860 .procname
= "mount-max",
1861 .data
= &sysctl_mount_max
,
1862 .maxlen
= sizeof(unsigned int),
1864 .proc_handler
= proc_dointvec_minmax
,
1870 static struct ctl_table debug_table
[] = {
1871 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1873 .procname
= "exception-trace",
1874 .data
= &show_unhandled_signals
,
1875 .maxlen
= sizeof(int),
1877 .proc_handler
= proc_dointvec
1880 #if defined(CONFIG_OPTPROBES)
1882 .procname
= "kprobes-optimization",
1883 .data
= &sysctl_kprobes_optimization
,
1884 .maxlen
= sizeof(int),
1886 .proc_handler
= proc_kprobes_optimization_handler
,
1894 static struct ctl_table dev_table
[] = {
1898 int __init
sysctl_init(void)
1900 struct ctl_table_header
*hdr
;
1902 hdr
= register_sysctl_table(sysctl_base_table
);
1903 kmemleak_not_leak(hdr
);
1907 #endif /* CONFIG_SYSCTL */
1913 #ifdef CONFIG_PROC_SYSCTL
1915 static int _proc_do_string(char *data
, int maxlen
, int write
,
1916 char __user
*buffer
,
1917 size_t *lenp
, loff_t
*ppos
)
1923 if (!data
|| !maxlen
|| !*lenp
) {
1929 if (sysctl_writes_strict
== SYSCTL_WRITES_STRICT
) {
1930 /* Only continue writes not past the end of buffer. */
1932 if (len
> maxlen
- 1)
1939 /* Start writing from beginning of buffer. */
1945 while ((p
- buffer
) < *lenp
&& len
< maxlen
- 1) {
1946 if (get_user(c
, p
++))
1948 if (c
== 0 || c
== '\n')
1969 if (copy_to_user(buffer
, data
, len
))
1972 if (put_user('\n', buffer
+ len
))
1982 static void warn_sysctl_write(struct ctl_table
*table
)
1984 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1985 "This will not be supported in the future. To silence this\n"
1986 "warning, set kernel.sysctl_writes_strict = -1\n",
1987 current
->comm
, table
->procname
);
1991 * proc_first_pos_non_zero_ignore - check if firs position is allowed
1992 * @ppos: file position
1993 * @table: the sysctl table
1995 * Returns true if the first position is non-zero and the sysctl_writes_strict
1996 * mode indicates this is not allowed for numeric input types. String proc
1997 * hadlers can ignore the return value.
1999 static bool proc_first_pos_non_zero_ignore(loff_t
*ppos
,
2000 struct ctl_table
*table
)
2005 switch (sysctl_writes_strict
) {
2006 case SYSCTL_WRITES_STRICT
:
2008 case SYSCTL_WRITES_WARN
:
2009 warn_sysctl_write(table
);
2017 * proc_dostring - read a string sysctl
2018 * @table: the sysctl table
2019 * @write: %TRUE if this is a write to the sysctl file
2020 * @buffer: the user buffer
2021 * @lenp: the size of the user buffer
2022 * @ppos: file position
2024 * Reads/writes a string from/to the user buffer. If the kernel
2025 * buffer provided is not large enough to hold the string, the
2026 * string is truncated. The copied string is %NULL-terminated.
2027 * If the string is being read by the user process, it is copied
2028 * and a newline '\n' is added. It is truncated if the buffer is
2031 * Returns 0 on success.
2033 int proc_dostring(struct ctl_table
*table
, int write
,
2034 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2037 proc_first_pos_non_zero_ignore(ppos
, table
);
2039 return _proc_do_string((char *)(table
->data
), table
->maxlen
, write
,
2040 (char __user
*)buffer
, lenp
, ppos
);
2043 static size_t proc_skip_spaces(char **buf
)
2046 char *tmp
= skip_spaces(*buf
);
2052 static void proc_skip_char(char **buf
, size_t *size
, const char v
)
2062 #define TMPBUFLEN 22
2064 * proc_get_long - reads an ASCII formatted integer from a user buffer
2066 * @buf: a kernel buffer
2067 * @size: size of the kernel buffer
2068 * @val: this is where the number will be stored
2069 * @neg: set to %TRUE if number is negative
2070 * @perm_tr: a vector which contains the allowed trailers
2071 * @perm_tr_len: size of the perm_tr vector
2072 * @tr: pointer to store the trailer character
2074 * In case of success %0 is returned and @buf and @size are updated with
2075 * the amount of bytes read. If @tr is non-NULL and a trailing
2076 * character exists (size is non-zero after returning from this
2077 * function), @tr is updated with the trailing character.
2079 static int proc_get_long(char **buf
, size_t *size
,
2080 unsigned long *val
, bool *neg
,
2081 const char *perm_tr
, unsigned perm_tr_len
, char *tr
)
2084 char *p
, tmp
[TMPBUFLEN
];
2090 if (len
> TMPBUFLEN
- 1)
2091 len
= TMPBUFLEN
- 1;
2093 memcpy(tmp
, *buf
, len
);
2097 if (*p
== '-' && *size
> 1) {
2105 *val
= simple_strtoul(p
, &p
, 0);
2109 /* We don't know if the next char is whitespace thus we may accept
2110 * invalid integers (e.g. 1234...a) or two integers instead of one
2111 * (e.g. 123...1). So lets not allow such large numbers. */
2112 if (len
== TMPBUFLEN
- 1)
2115 if (len
< *size
&& perm_tr_len
&& !memchr(perm_tr
, *p
, perm_tr_len
))
2118 if (tr
&& (len
< *size
))
2128 * proc_put_long - converts an integer to a decimal ASCII formatted string
2130 * @buf: the user buffer
2131 * @size: the size of the user buffer
2132 * @val: the integer to be converted
2133 * @neg: sign of the number, %TRUE for negative
2135 * In case of success %0 is returned and @buf and @size are updated with
2136 * the amount of bytes written.
2138 static int proc_put_long(void __user
**buf
, size_t *size
, unsigned long val
,
2142 char tmp
[TMPBUFLEN
], *p
= tmp
;
2144 sprintf(p
, "%s%lu", neg
? "-" : "", val
);
2148 if (copy_to_user(*buf
, tmp
, len
))
2156 static int proc_put_char(void __user
**buf
, size_t *size
, char c
)
2159 char __user
**buffer
= (char __user
**)buf
;
2160 if (put_user(c
, *buffer
))
2162 (*size
)--, (*buffer
)++;
2168 static int do_proc_dointvec_conv(bool *negp
, unsigned long *lvalp
,
2170 int write
, void *data
)
2174 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2178 if (*lvalp
> (unsigned long) INT_MAX
)
2186 *lvalp
= -(unsigned long)val
;
2189 *lvalp
= (unsigned long)val
;
2195 static int do_proc_douintvec_conv(unsigned long *lvalp
,
2197 int write
, void *data
)
2200 if (*lvalp
> UINT_MAX
)
2202 if (*lvalp
> UINT_MAX
)
2206 unsigned int val
= *valp
;
2207 *lvalp
= (unsigned long)val
;
2212 static const char proc_wspace_sep
[] = { ' ', '\t', '\n' };
2214 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2215 int write
, void __user
*buffer
,
2216 size_t *lenp
, loff_t
*ppos
,
2217 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2218 int write
, void *data
),
2221 int *i
, vleft
, first
= 1, err
= 0;
2223 char *kbuf
= NULL
, *p
;
2225 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2230 i
= (int *) tbl_data
;
2231 vleft
= table
->maxlen
/ sizeof(*i
);
2235 conv
= do_proc_dointvec_conv
;
2238 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2241 if (left
> PAGE_SIZE
- 1)
2242 left
= PAGE_SIZE
- 1;
2243 p
= kbuf
= memdup_user_nul(buffer
, left
);
2245 return PTR_ERR(kbuf
);
2248 for (; left
&& vleft
--; i
++, first
=0) {
2253 left
-= proc_skip_spaces(&p
);
2257 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2259 sizeof(proc_wspace_sep
), NULL
);
2262 if (conv(&neg
, &lval
, i
, 1, data
)) {
2267 if (conv(&neg
, &lval
, i
, 0, data
)) {
2272 err
= proc_put_char(&buffer
, &left
, '\t');
2275 err
= proc_put_long(&buffer
, &left
, lval
, neg
);
2281 if (!write
&& !first
&& left
&& !err
)
2282 err
= proc_put_char(&buffer
, &left
, '\n');
2283 if (write
&& !err
&& left
)
2284 left
-= proc_skip_spaces(&p
);
2288 return err
? : -EINVAL
;
2296 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2297 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2298 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2299 int write
, void *data
),
2302 return __do_proc_dointvec(table
->data
, table
, write
,
2303 buffer
, lenp
, ppos
, conv
, data
);
2306 static int do_proc_douintvec_w(unsigned int *tbl_data
,
2307 struct ctl_table
*table
,
2308 void __user
*buffer
,
2309 size_t *lenp
, loff_t
*ppos
,
2310 int (*conv
)(unsigned long *lvalp
,
2312 int write
, void *data
),
2319 char *kbuf
= NULL
, *p
;
2323 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2326 if (left
> PAGE_SIZE
- 1)
2327 left
= PAGE_SIZE
- 1;
2329 p
= kbuf
= memdup_user_nul(buffer
, left
);
2333 left
-= proc_skip_spaces(&p
);
2339 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2341 sizeof(proc_wspace_sep
), NULL
);
2347 if (conv(&lval
, tbl_data
, 1, data
)) {
2353 left
-= proc_skip_spaces(&p
);
2362 /* This is in keeping with old __do_proc_dointvec() */
2368 static int do_proc_douintvec_r(unsigned int *tbl_data
, void __user
*buffer
,
2369 size_t *lenp
, loff_t
*ppos
,
2370 int (*conv
)(unsigned long *lvalp
,
2372 int write
, void *data
),
2381 if (conv(&lval
, tbl_data
, 0, data
)) {
2386 err
= proc_put_long(&buffer
, &left
, lval
, false);
2390 err
= proc_put_char(&buffer
, &left
, '\n');
2399 static int __do_proc_douintvec(void *tbl_data
, struct ctl_table
*table
,
2400 int write
, void __user
*buffer
,
2401 size_t *lenp
, loff_t
*ppos
,
2402 int (*conv
)(unsigned long *lvalp
,
2404 int write
, void *data
),
2407 unsigned int *i
, vleft
;
2409 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2414 i
= (unsigned int *) tbl_data
;
2415 vleft
= table
->maxlen
/ sizeof(*i
);
2418 * Arrays are not supported, keep this simple. *Do not* add
2427 conv
= do_proc_douintvec_conv
;
2430 return do_proc_douintvec_w(i
, table
, buffer
, lenp
, ppos
,
2432 return do_proc_douintvec_r(i
, buffer
, lenp
, ppos
, conv
, data
);
2435 static int do_proc_douintvec(struct ctl_table
*table
, int write
,
2436 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2437 int (*conv
)(unsigned long *lvalp
,
2439 int write
, void *data
),
2442 return __do_proc_douintvec(table
->data
, table
, write
,
2443 buffer
, lenp
, ppos
, conv
, data
);
2447 * proc_dointvec - read a vector of integers
2448 * @table: the sysctl table
2449 * @write: %TRUE if this is a write to the sysctl file
2450 * @buffer: the user buffer
2451 * @lenp: the size of the user buffer
2452 * @ppos: file position
2454 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2455 * values from/to the user buffer, treated as an ASCII string.
2457 * Returns 0 on success.
2459 int proc_dointvec(struct ctl_table
*table
, int write
,
2460 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2462 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
, NULL
, NULL
);
2466 * proc_douintvec - read a vector of unsigned integers
2467 * @table: the sysctl table
2468 * @write: %TRUE if this is a write to the sysctl file
2469 * @buffer: the user buffer
2470 * @lenp: the size of the user buffer
2471 * @ppos: file position
2473 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2474 * values from/to the user buffer, treated as an ASCII string.
2476 * Returns 0 on success.
2478 int proc_douintvec(struct ctl_table
*table
, int write
,
2479 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2481 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2482 do_proc_douintvec_conv
, NULL
);
2486 * Taint values can only be increased
2487 * This means we can safely use a temporary.
2489 static int proc_taint(struct ctl_table
*table
, int write
,
2490 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2493 unsigned long tmptaint
= get_taint();
2496 if (write
&& !capable(CAP_SYS_ADMIN
))
2501 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2507 * Poor man's atomic or. Not worth adding a primitive
2508 * to everyone's atomic.h for this
2511 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2512 if ((tmptaint
>> i
) & 1)
2513 add_taint(i
, LOCKDEP_STILL_OK
);
2520 #ifdef CONFIG_PRINTK
2521 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
2522 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2524 if (write
&& !capable(CAP_SYS_ADMIN
))
2527 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2531 struct do_proc_dointvec_minmax_conv_param
{
2536 static int do_proc_dointvec_minmax_conv(bool *negp
, unsigned long *lvalp
,
2538 int write
, void *data
)
2540 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2542 int val
= *negp
? -*lvalp
: *lvalp
;
2543 if ((param
->min
&& *param
->min
> val
) ||
2544 (param
->max
&& *param
->max
< val
))
2551 *lvalp
= -(unsigned long)val
;
2554 *lvalp
= (unsigned long)val
;
2561 * proc_dointvec_minmax - read a vector of integers with min/max values
2562 * @table: the sysctl table
2563 * @write: %TRUE if this is a write to the sysctl file
2564 * @buffer: the user buffer
2565 * @lenp: the size of the user buffer
2566 * @ppos: file position
2568 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2569 * values from/to the user buffer, treated as an ASCII string.
2571 * This routine will ensure the values are within the range specified by
2572 * table->extra1 (min) and table->extra2 (max).
2574 * Returns 0 on success.
2576 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2577 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2579 struct do_proc_dointvec_minmax_conv_param param
= {
2580 .min
= (int *) table
->extra1
,
2581 .max
= (int *) table
->extra2
,
2583 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2584 do_proc_dointvec_minmax_conv
, ¶m
);
2587 struct do_proc_douintvec_minmax_conv_param
{
2592 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp
,
2594 int write
, void *data
)
2596 struct do_proc_douintvec_minmax_conv_param
*param
= data
;
2599 unsigned int val
= *lvalp
;
2601 if ((param
->min
&& *param
->min
> val
) ||
2602 (param
->max
&& *param
->max
< val
))
2605 if (*lvalp
> UINT_MAX
)
2609 unsigned int val
= *valp
;
2610 *lvalp
= (unsigned long) val
;
2617 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2618 * @table: the sysctl table
2619 * @write: %TRUE if this is a write to the sysctl file
2620 * @buffer: the user buffer
2621 * @lenp: the size of the user buffer
2622 * @ppos: file position
2624 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2625 * values from/to the user buffer, treated as an ASCII string. Negative
2626 * strings are not allowed.
2628 * This routine will ensure the values are within the range specified by
2629 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2630 * check for UINT_MAX to avoid having to support wrap around uses from
2633 * Returns 0 on success.
2635 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
2636 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2638 struct do_proc_douintvec_minmax_conv_param param
= {
2639 .min
= (unsigned int *) table
->extra1
,
2640 .max
= (unsigned int *) table
->extra2
,
2642 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2643 do_proc_douintvec_minmax_conv
, ¶m
);
2646 static void validate_coredump_safety(void)
2648 #ifdef CONFIG_COREDUMP
2649 if (suid_dumpable
== SUID_DUMP_ROOT
&&
2650 core_pattern
[0] != '/' && core_pattern
[0] != '|') {
2652 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2653 "Pipe handler or fully qualified core dump path required.\n"
2654 "Set kernel.core_pattern before fs.suid_dumpable.\n"
2660 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
2661 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2663 int error
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2665 validate_coredump_safety();
2669 #ifdef CONFIG_COREDUMP
2670 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
2671 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2673 int error
= proc_dostring(table
, write
, buffer
, lenp
, ppos
);
2675 validate_coredump_safety();
2680 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2681 void __user
*buffer
,
2682 size_t *lenp
, loff_t
*ppos
,
2683 unsigned long convmul
,
2684 unsigned long convdiv
)
2686 unsigned long *i
, *min
, *max
;
2687 int vleft
, first
= 1, err
= 0;
2689 char *kbuf
= NULL
, *p
;
2691 if (!data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2696 i
= (unsigned long *) data
;
2697 min
= (unsigned long *) table
->extra1
;
2698 max
= (unsigned long *) table
->extra2
;
2699 vleft
= table
->maxlen
/ sizeof(unsigned long);
2703 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2706 if (left
> PAGE_SIZE
- 1)
2707 left
= PAGE_SIZE
- 1;
2708 p
= kbuf
= memdup_user_nul(buffer
, left
);
2710 return PTR_ERR(kbuf
);
2713 for (; left
&& vleft
--; i
++, first
= 0) {
2719 left
-= proc_skip_spaces(&p
);
2721 err
= proc_get_long(&p
, &left
, &val
, &neg
,
2723 sizeof(proc_wspace_sep
), NULL
);
2728 val
= convmul
* val
/ convdiv
;
2729 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2733 val
= convdiv
* (*i
) / convmul
;
2735 err
= proc_put_char(&buffer
, &left
, '\t');
2739 err
= proc_put_long(&buffer
, &left
, val
, false);
2745 if (!write
&& !first
&& left
&& !err
)
2746 err
= proc_put_char(&buffer
, &left
, '\n');
2748 left
-= proc_skip_spaces(&p
);
2752 return err
? : -EINVAL
;
2760 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2761 void __user
*buffer
,
2762 size_t *lenp
, loff_t
*ppos
,
2763 unsigned long convmul
,
2764 unsigned long convdiv
)
2766 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2767 buffer
, lenp
, ppos
, convmul
, convdiv
);
2771 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2772 * @table: the sysctl table
2773 * @write: %TRUE if this is a write to the sysctl file
2774 * @buffer: the user buffer
2775 * @lenp: the size of the user buffer
2776 * @ppos: file position
2778 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2779 * values from/to the user buffer, treated as an ASCII string.
2781 * This routine will ensure the values are within the range specified by
2782 * table->extra1 (min) and table->extra2 (max).
2784 * Returns 0 on success.
2786 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2787 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2789 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2793 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2794 * @table: the sysctl table
2795 * @write: %TRUE if this is a write to the sysctl file
2796 * @buffer: the user buffer
2797 * @lenp: the size of the user buffer
2798 * @ppos: file position
2800 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2801 * values from/to the user buffer, treated as an ASCII string. The values
2802 * are treated as milliseconds, and converted to jiffies when they are stored.
2804 * This routine will ensure the values are within the range specified by
2805 * table->extra1 (min) and table->extra2 (max).
2807 * Returns 0 on success.
2809 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2810 void __user
*buffer
,
2811 size_t *lenp
, loff_t
*ppos
)
2813 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2814 lenp
, ppos
, HZ
, 1000l);
2818 static int do_proc_dointvec_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2820 int write
, void *data
)
2823 if (*lvalp
> INT_MAX
/ HZ
)
2825 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2831 lval
= -(unsigned long)val
;
2834 lval
= (unsigned long)val
;
2841 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2843 int write
, void *data
)
2846 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2848 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2854 lval
= -(unsigned long)val
;
2857 lval
= (unsigned long)val
;
2859 *lvalp
= jiffies_to_clock_t(lval
);
2864 static int do_proc_dointvec_ms_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2866 int write
, void *data
)
2869 unsigned long jif
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2879 lval
= -(unsigned long)val
;
2882 lval
= (unsigned long)val
;
2884 *lvalp
= jiffies_to_msecs(lval
);
2890 * proc_dointvec_jiffies - read a vector of integers as seconds
2891 * @table: the sysctl table
2892 * @write: %TRUE if this is a write to the sysctl file
2893 * @buffer: the user buffer
2894 * @lenp: the size of the user buffer
2895 * @ppos: file position
2897 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2898 * values from/to the user buffer, treated as an ASCII string.
2899 * The values read are assumed to be in seconds, and are converted into
2902 * Returns 0 on success.
2904 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2905 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2907 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2908 do_proc_dointvec_jiffies_conv
,NULL
);
2912 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2913 * @table: the sysctl table
2914 * @write: %TRUE if this is a write to the sysctl file
2915 * @buffer: the user buffer
2916 * @lenp: the size of the user buffer
2917 * @ppos: pointer to the file position
2919 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2920 * values from/to the user buffer, treated as an ASCII string.
2921 * The values read are assumed to be in 1/USER_HZ seconds, and
2922 * are converted into jiffies.
2924 * Returns 0 on success.
2926 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2927 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2929 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2930 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2934 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2935 * @table: the sysctl table
2936 * @write: %TRUE if this is a write to the sysctl file
2937 * @buffer: the user buffer
2938 * @lenp: the size of the user buffer
2939 * @ppos: file position
2940 * @ppos: the current position in the file
2942 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2943 * values from/to the user buffer, treated as an ASCII string.
2944 * The values read are assumed to be in 1/1000 seconds, and
2945 * are converted into jiffies.
2947 * Returns 0 on success.
2949 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2950 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2952 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2953 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2956 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
2957 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2959 struct pid
*new_pid
;
2963 tmp
= pid_vnr(cad_pid
);
2965 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
2966 lenp
, ppos
, NULL
, NULL
);
2970 new_pid
= find_get_pid(tmp
);
2974 put_pid(xchg(&cad_pid
, new_pid
));
2979 * proc_do_large_bitmap - read/write from/to a large bitmap
2980 * @table: the sysctl table
2981 * @write: %TRUE if this is a write to the sysctl file
2982 * @buffer: the user buffer
2983 * @lenp: the size of the user buffer
2984 * @ppos: file position
2986 * The bitmap is stored at table->data and the bitmap length (in bits)
2989 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2990 * large bitmaps may be represented in a compact manner. Writing into
2991 * the file will clear the bitmap then update it with the given input.
2993 * Returns 0 on success.
2995 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
2996 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3000 size_t left
= *lenp
;
3001 unsigned long bitmap_len
= table
->maxlen
;
3002 unsigned long *bitmap
= *(unsigned long **) table
->data
;
3003 unsigned long *tmp_bitmap
= NULL
;
3004 char tr_a
[] = { '-', ',', '\n' }, tr_b
[] = { ',', '\n', 0 }, c
;
3006 if (!bitmap
|| !bitmap_len
|| !left
|| (*ppos
&& !write
)) {
3014 if (left
> PAGE_SIZE
- 1)
3015 left
= PAGE_SIZE
- 1;
3017 p
= kbuf
= memdup_user_nul(buffer
, left
);
3019 return PTR_ERR(kbuf
);
3021 tmp_bitmap
= kzalloc(BITS_TO_LONGS(bitmap_len
) * sizeof(unsigned long),
3027 proc_skip_char(&p
, &left
, '\n');
3028 while (!err
&& left
) {
3029 unsigned long val_a
, val_b
;
3032 err
= proc_get_long(&p
, &left
, &val_a
, &neg
, tr_a
,
3036 if (val_a
>= bitmap_len
|| neg
) {
3048 err
= proc_get_long(&p
, &left
, &val_b
,
3049 &neg
, tr_b
, sizeof(tr_b
),
3053 if (val_b
>= bitmap_len
|| neg
||
3064 bitmap_set(tmp_bitmap
, val_a
, val_b
- val_a
+ 1);
3066 proc_skip_char(&p
, &left
, '\n');
3070 unsigned long bit_a
, bit_b
= 0;
3073 bit_a
= find_next_bit(bitmap
, bitmap_len
, bit_b
);
3074 if (bit_a
>= bitmap_len
)
3076 bit_b
= find_next_zero_bit(bitmap
, bitmap_len
,
3080 err
= proc_put_char(&buffer
, &left
, ',');
3084 err
= proc_put_long(&buffer
, &left
, bit_a
, false);
3087 if (bit_a
!= bit_b
) {
3088 err
= proc_put_char(&buffer
, &left
, '-');
3091 err
= proc_put_long(&buffer
, &left
, bit_b
, false);
3099 err
= proc_put_char(&buffer
, &left
, '\n');
3105 bitmap_or(bitmap
, bitmap
, tmp_bitmap
, bitmap_len
);
3107 bitmap_copy(bitmap
, tmp_bitmap
, bitmap_len
);
3119 #else /* CONFIG_PROC_SYSCTL */
3121 int proc_dostring(struct ctl_table
*table
, int write
,
3122 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3127 int proc_dointvec(struct ctl_table
*table
, int write
,
3128 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3133 int proc_douintvec(struct ctl_table
*table
, int write
,
3134 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3139 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
3140 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3145 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
3146 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3151 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
3152 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3157 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
3158 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3163 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
3164 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3169 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
3170 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3175 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
3176 void __user
*buffer
,
3177 size_t *lenp
, loff_t
*ppos
)
3183 #endif /* CONFIG_PROC_SYSCTL */
3186 * No sense putting this after each symbol definition, twice,
3187 * exception granted :-)
3189 EXPORT_SYMBOL(proc_dointvec
);
3190 EXPORT_SYMBOL(proc_douintvec
);
3191 EXPORT_SYMBOL(proc_dointvec_jiffies
);
3192 EXPORT_SYMBOL(proc_dointvec_minmax
);
3193 EXPORT_SYMBOL_GPL(proc_douintvec_minmax
);
3194 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
3195 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
3196 EXPORT_SYMBOL(proc_dostring
);
3197 EXPORT_SYMBOL(proc_doulongvec_minmax
);
3198 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);