2 * sysctl.c: General linux system control interface
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
21 #include <linux/module.h>
22 #include <linux/aio.h>
24 #include <linux/swap.h>
25 #include <linux/slab.h>
26 #include <linux/sysctl.h>
27 #include <linux/bitmap.h>
28 #include <linux/signal.h>
29 #include <linux/printk.h>
30 #include <linux/proc_fs.h>
31 #include <linux/security.h>
32 #include <linux/ctype.h>
33 #include <linux/kmemleak.h>
35 #include <linux/init.h>
36 #include <linux/kernel.h>
37 #include <linux/kobject.h>
38 #include <linux/net.h>
39 #include <linux/sysrq.h>
40 #include <linux/highuid.h>
41 #include <linux/writeback.h>
42 #include <linux/ratelimit.h>
43 #include <linux/compaction.h>
44 #include <linux/hugetlb.h>
45 #include <linux/initrd.h>
46 #include <linux/key.h>
47 #include <linux/times.h>
48 #include <linux/limits.h>
49 #include <linux/dcache.h>
50 #include <linux/dnotify.h>
51 #include <linux/syscalls.h>
52 #include <linux/vmstat.h>
53 #include <linux/nfs_fs.h>
54 #include <linux/acpi.h>
55 #include <linux/reboot.h>
56 #include <linux/ftrace.h>
57 #include <linux/perf_event.h>
58 #include <linux/kprobes.h>
59 #include <linux/pipe_fs_i.h>
60 #include <linux/oom.h>
61 #include <linux/kmod.h>
62 #include <linux/capability.h>
63 #include <linux/binfmts.h>
64 #include <linux/sched/sysctl.h>
65 #include <linux/sched/coredump.h>
66 #include <linux/kexec.h>
67 #include <linux/bpf.h>
68 #include <linux/mount.h>
69 #include <linux/pipe_fs_i.h>
71 #include <linux/uaccess.h>
72 #include <asm/processor.h>
76 #include <asm/stacktrace.h>
80 #include <asm/setup.h>
82 #ifdef CONFIG_BSD_PROCESS_ACCT
83 #include <linux/acct.h>
85 #ifdef CONFIG_RT_MUTEXES
86 #include <linux/rtmutex.h>
88 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
89 #include <linux/lockdep.h>
91 #ifdef CONFIG_CHR_DEV_SG
95 #ifdef CONFIG_LOCKUP_DETECTOR
96 #include <linux/nmi.h>
99 #if defined(CONFIG_SYSCTL)
101 /* External variables not in a header file. */
102 extern int suid_dumpable
;
103 #ifdef CONFIG_COREDUMP
104 extern int core_uses_pid
;
105 extern char core_pattern
[];
106 extern unsigned int core_pipe_limit
;
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_minmax
,
376 #ifdef CONFIG_SCHEDSTATS
378 .procname
= "sched_schedstats",
380 .maxlen
= sizeof(unsigned int),
382 .proc_handler
= sysctl_schedstats
,
386 #endif /* CONFIG_SCHEDSTATS */
387 #endif /* CONFIG_SMP */
388 #ifdef CONFIG_NUMA_BALANCING
390 .procname
= "numa_balancing_scan_delay_ms",
391 .data
= &sysctl_numa_balancing_scan_delay
,
392 .maxlen
= sizeof(unsigned int),
394 .proc_handler
= proc_dointvec
,
397 .procname
= "numa_balancing_scan_period_min_ms",
398 .data
= &sysctl_numa_balancing_scan_period_min
,
399 .maxlen
= sizeof(unsigned int),
401 .proc_handler
= proc_dointvec
,
404 .procname
= "numa_balancing_scan_period_max_ms",
405 .data
= &sysctl_numa_balancing_scan_period_max
,
406 .maxlen
= sizeof(unsigned int),
408 .proc_handler
= proc_dointvec
,
411 .procname
= "numa_balancing_scan_size_mb",
412 .data
= &sysctl_numa_balancing_scan_size
,
413 .maxlen
= sizeof(unsigned int),
415 .proc_handler
= proc_dointvec_minmax
,
419 .procname
= "numa_balancing",
420 .data
= NULL
, /* filled in by handler */
421 .maxlen
= sizeof(unsigned int),
423 .proc_handler
= sysctl_numa_balancing
,
427 #endif /* CONFIG_NUMA_BALANCING */
428 #endif /* CONFIG_SCHED_DEBUG */
430 .procname
= "sched_rt_period_us",
431 .data
= &sysctl_sched_rt_period
,
432 .maxlen
= sizeof(unsigned int),
434 .proc_handler
= sched_rt_handler
,
437 .procname
= "sched_rt_runtime_us",
438 .data
= &sysctl_sched_rt_runtime
,
439 .maxlen
= sizeof(int),
441 .proc_handler
= sched_rt_handler
,
444 .procname
= "sched_rr_timeslice_ms",
445 .data
= &sysctl_sched_rr_timeslice
,
446 .maxlen
= sizeof(int),
448 .proc_handler
= sched_rr_handler
,
450 #ifdef CONFIG_SCHED_AUTOGROUP
452 .procname
= "sched_autogroup_enabled",
453 .data
= &sysctl_sched_autogroup_enabled
,
454 .maxlen
= sizeof(unsigned int),
456 .proc_handler
= proc_dointvec_minmax
,
461 #ifdef CONFIG_CFS_BANDWIDTH
463 .procname
= "sched_cfs_bandwidth_slice_us",
464 .data
= &sysctl_sched_cfs_bandwidth_slice
,
465 .maxlen
= sizeof(unsigned int),
467 .proc_handler
= proc_dointvec_minmax
,
471 #ifdef CONFIG_PROVE_LOCKING
473 .procname
= "prove_locking",
474 .data
= &prove_locking
,
475 .maxlen
= sizeof(int),
477 .proc_handler
= proc_dointvec
,
480 #ifdef CONFIG_LOCK_STAT
482 .procname
= "lock_stat",
484 .maxlen
= sizeof(int),
486 .proc_handler
= proc_dointvec
,
491 .data
= &panic_timeout
,
492 .maxlen
= sizeof(int),
494 .proc_handler
= proc_dointvec
,
496 #ifdef CONFIG_COREDUMP
498 .procname
= "core_uses_pid",
499 .data
= &core_uses_pid
,
500 .maxlen
= sizeof(int),
502 .proc_handler
= proc_dointvec
,
505 .procname
= "core_pattern",
506 .data
= core_pattern
,
507 .maxlen
= CORENAME_MAX_SIZE
,
509 .proc_handler
= proc_dostring_coredump
,
512 .procname
= "core_pipe_limit",
513 .data
= &core_pipe_limit
,
514 .maxlen
= sizeof(unsigned int),
516 .proc_handler
= proc_dointvec
,
519 #ifdef CONFIG_USER_NS
521 .procname
= "unprivileged_userns_clone",
522 .data
= &unprivileged_userns_clone
,
523 .maxlen
= sizeof(int),
525 .proc_handler
= proc_dointvec
,
528 #ifdef CONFIG_PROC_SYSCTL
530 .procname
= "tainted",
531 .maxlen
= sizeof(long),
533 .proc_handler
= proc_taint
,
536 .procname
= "sysctl_writes_strict",
537 .data
= &sysctl_writes_strict
,
538 .maxlen
= sizeof(int),
540 .proc_handler
= proc_dointvec_minmax
,
545 #ifdef CONFIG_LATENCYTOP
547 .procname
= "latencytop",
548 .data
= &latencytop_enabled
,
549 .maxlen
= sizeof(int),
551 .proc_handler
= sysctl_latencytop
,
554 #ifdef CONFIG_BLK_DEV_INITRD
556 .procname
= "real-root-dev",
557 .data
= &real_root_dev
,
558 .maxlen
= sizeof(int),
560 .proc_handler
= proc_dointvec
,
564 .procname
= "print-fatal-signals",
565 .data
= &print_fatal_signals
,
566 .maxlen
= sizeof(int),
568 .proc_handler
= proc_dointvec
,
572 .procname
= "reboot-cmd",
573 .data
= reboot_command
,
576 .proc_handler
= proc_dostring
,
579 .procname
= "stop-a",
580 .data
= &stop_a_enabled
,
581 .maxlen
= sizeof (int),
583 .proc_handler
= proc_dointvec
,
586 .procname
= "scons-poweroff",
587 .data
= &scons_pwroff
,
588 .maxlen
= sizeof (int),
590 .proc_handler
= proc_dointvec
,
593 #ifdef CONFIG_SPARC64
595 .procname
= "tsb-ratio",
596 .data
= &sysctl_tsb_ratio
,
597 .maxlen
= sizeof (int),
599 .proc_handler
= proc_dointvec
,
604 .procname
= "soft-power",
605 .data
= &pwrsw_enabled
,
606 .maxlen
= sizeof (int),
608 .proc_handler
= proc_dointvec
,
611 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
613 .procname
= "unaligned-trap",
614 .data
= &unaligned_enabled
,
615 .maxlen
= sizeof (int),
617 .proc_handler
= proc_dointvec
,
621 .procname
= "ctrl-alt-del",
623 .maxlen
= sizeof(int),
625 .proc_handler
= proc_dointvec
,
627 #ifdef CONFIG_FUNCTION_TRACER
629 .procname
= "ftrace_enabled",
630 .data
= &ftrace_enabled
,
631 .maxlen
= sizeof(int),
633 .proc_handler
= ftrace_enable_sysctl
,
636 #ifdef CONFIG_STACK_TRACER
638 .procname
= "stack_tracer_enabled",
639 .data
= &stack_tracer_enabled
,
640 .maxlen
= sizeof(int),
642 .proc_handler
= stack_trace_sysctl
,
645 #ifdef CONFIG_TRACING
647 .procname
= "ftrace_dump_on_oops",
648 .data
= &ftrace_dump_on_oops
,
649 .maxlen
= sizeof(int),
651 .proc_handler
= proc_dointvec
,
654 .procname
= "traceoff_on_warning",
655 .data
= &__disable_trace_on_warning
,
656 .maxlen
= sizeof(__disable_trace_on_warning
),
658 .proc_handler
= proc_dointvec
,
661 .procname
= "tracepoint_printk",
662 .data
= &tracepoint_printk
,
663 .maxlen
= sizeof(tracepoint_printk
),
665 .proc_handler
= tracepoint_printk_sysctl
,
668 #ifdef CONFIG_KEXEC_CORE
670 .procname
= "kexec_load_disabled",
671 .data
= &kexec_load_disabled
,
672 .maxlen
= sizeof(int),
674 /* only handle a transition from default "0" to "1" */
675 .proc_handler
= proc_dointvec_minmax
,
680 #ifdef CONFIG_MODULES
682 .procname
= "modprobe",
683 .data
= &modprobe_path
,
684 .maxlen
= KMOD_PATH_LEN
,
686 .proc_handler
= proc_dostring
,
689 .procname
= "modules_disabled",
690 .data
= &modules_disabled
,
691 .maxlen
= sizeof(int),
693 /* only handle a transition from default "0" to "1" */
694 .proc_handler
= proc_dointvec_minmax
,
699 #ifdef CONFIG_UEVENT_HELPER
701 .procname
= "hotplug",
702 .data
= &uevent_helper
,
703 .maxlen
= UEVENT_HELPER_PATH_LEN
,
705 .proc_handler
= proc_dostring
,
708 #ifdef CONFIG_CHR_DEV_SG
710 .procname
= "sg-big-buff",
711 .data
= &sg_big_buff
,
712 .maxlen
= sizeof (int),
714 .proc_handler
= proc_dointvec
,
717 #ifdef CONFIG_BSD_PROCESS_ACCT
721 .maxlen
= 3*sizeof(int),
723 .proc_handler
= proc_dointvec
,
726 #ifdef CONFIG_MAGIC_SYSRQ
729 .data
= &__sysrq_enabled
,
730 .maxlen
= sizeof (int),
732 .proc_handler
= sysrq_sysctl_handler
,
735 #ifdef CONFIG_PROC_SYSCTL
737 .procname
= "cad_pid",
739 .maxlen
= sizeof (int),
741 .proc_handler
= proc_do_cad_pid
,
745 .procname
= "threads-max",
747 .maxlen
= sizeof(int),
749 .proc_handler
= sysctl_max_threads
,
752 .procname
= "random",
754 .child
= random_table
,
757 .procname
= "usermodehelper",
759 .child
= usermodehelper_table
,
762 .procname
= "overflowuid",
763 .data
= &overflowuid
,
764 .maxlen
= sizeof(int),
766 .proc_handler
= proc_dointvec_minmax
,
767 .extra1
= &minolduid
,
768 .extra2
= &maxolduid
,
771 .procname
= "overflowgid",
772 .data
= &overflowgid
,
773 .maxlen
= sizeof(int),
775 .proc_handler
= proc_dointvec_minmax
,
776 .extra1
= &minolduid
,
777 .extra2
= &maxolduid
,
780 #ifdef CONFIG_MATHEMU
782 .procname
= "ieee_emulation_warnings",
783 .data
= &sysctl_ieee_emulation_warnings
,
784 .maxlen
= sizeof(int),
786 .proc_handler
= proc_dointvec
,
790 .procname
= "userprocess_debug",
791 .data
= &show_unhandled_signals
,
792 .maxlen
= sizeof(int),
794 .proc_handler
= proc_dointvec
,
798 .procname
= "pid_max",
800 .maxlen
= sizeof (int),
802 .proc_handler
= proc_dointvec_minmax
,
803 .extra1
= &pid_max_min
,
804 .extra2
= &pid_max_max
,
807 .procname
= "panic_on_oops",
808 .data
= &panic_on_oops
,
809 .maxlen
= sizeof(int),
811 .proc_handler
= proc_dointvec
,
813 #if defined CONFIG_PRINTK
815 .procname
= "printk",
816 .data
= &console_loglevel
,
817 .maxlen
= 4*sizeof(int),
819 .proc_handler
= proc_dointvec
,
822 .procname
= "printk_ratelimit",
823 .data
= &printk_ratelimit_state
.interval
,
824 .maxlen
= sizeof(int),
826 .proc_handler
= proc_dointvec_jiffies
,
829 .procname
= "printk_ratelimit_burst",
830 .data
= &printk_ratelimit_state
.burst
,
831 .maxlen
= sizeof(int),
833 .proc_handler
= proc_dointvec
,
836 .procname
= "printk_delay",
837 .data
= &printk_delay_msec
,
838 .maxlen
= sizeof(int),
840 .proc_handler
= proc_dointvec_minmax
,
842 .extra2
= &ten_thousand
,
845 .procname
= "printk_devkmsg",
846 .data
= devkmsg_log_str
,
847 .maxlen
= DEVKMSG_STR_MAX_SIZE
,
849 .proc_handler
= devkmsg_sysctl_set_loglvl
,
852 .procname
= "dmesg_restrict",
853 .data
= &dmesg_restrict
,
854 .maxlen
= sizeof(int),
856 .proc_handler
= proc_dointvec_minmax_sysadmin
,
861 .procname
= "kptr_restrict",
862 .data
= &kptr_restrict
,
863 .maxlen
= sizeof(int),
865 .proc_handler
= proc_dointvec_minmax_sysadmin
,
871 .procname
= "ngroups_max",
872 .data
= &ngroups_max
,
873 .maxlen
= sizeof (int),
875 .proc_handler
= proc_dointvec
,
878 .procname
= "cap_last_cap",
879 .data
= (void *)&cap_last_cap
,
880 .maxlen
= sizeof(int),
882 .proc_handler
= proc_dointvec
,
884 #if defined(CONFIG_LOCKUP_DETECTOR)
886 .procname
= "watchdog",
887 .data
= &watchdog_user_enabled
,
888 .maxlen
= sizeof(int),
890 .proc_handler
= proc_watchdog
,
895 .procname
= "watchdog_thresh",
896 .data
= &watchdog_thresh
,
897 .maxlen
= sizeof(int),
899 .proc_handler
= proc_watchdog_thresh
,
904 .procname
= "nmi_watchdog",
905 .data
= &nmi_watchdog_user_enabled
,
906 .maxlen
= sizeof(int),
907 .mode
= NMI_WATCHDOG_SYSCTL_PERM
,
908 .proc_handler
= proc_nmi_watchdog
,
913 .procname
= "watchdog_cpumask",
914 .data
= &watchdog_cpumask_bits
,
917 .proc_handler
= proc_watchdog_cpumask
,
919 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
921 .procname
= "soft_watchdog",
922 .data
= &soft_watchdog_user_enabled
,
923 .maxlen
= sizeof(int),
925 .proc_handler
= proc_soft_watchdog
,
930 .procname
= "softlockup_panic",
931 .data
= &softlockup_panic
,
932 .maxlen
= sizeof(int),
934 .proc_handler
= proc_dointvec_minmax
,
940 .procname
= "softlockup_all_cpu_backtrace",
941 .data
= &sysctl_softlockup_all_cpu_backtrace
,
942 .maxlen
= sizeof(int),
944 .proc_handler
= proc_dointvec_minmax
,
948 #endif /* CONFIG_SMP */
950 #ifdef CONFIG_HARDLOCKUP_DETECTOR
952 .procname
= "hardlockup_panic",
953 .data
= &hardlockup_panic
,
954 .maxlen
= sizeof(int),
956 .proc_handler
= proc_dointvec_minmax
,
962 .procname
= "hardlockup_all_cpu_backtrace",
963 .data
= &sysctl_hardlockup_all_cpu_backtrace
,
964 .maxlen
= sizeof(int),
966 .proc_handler
= proc_dointvec_minmax
,
970 #endif /* CONFIG_SMP */
974 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
976 .procname
= "unknown_nmi_panic",
977 .data
= &unknown_nmi_panic
,
978 .maxlen
= sizeof (int),
980 .proc_handler
= proc_dointvec
,
983 #if defined(CONFIG_X86)
985 .procname
= "panic_on_unrecovered_nmi",
986 .data
= &panic_on_unrecovered_nmi
,
987 .maxlen
= sizeof(int),
989 .proc_handler
= proc_dointvec
,
992 .procname
= "panic_on_io_nmi",
993 .data
= &panic_on_io_nmi
,
994 .maxlen
= sizeof(int),
996 .proc_handler
= proc_dointvec
,
998 #ifdef CONFIG_DEBUG_STACKOVERFLOW
1000 .procname
= "panic_on_stackoverflow",
1001 .data
= &sysctl_panic_on_stackoverflow
,
1002 .maxlen
= sizeof(int),
1004 .proc_handler
= proc_dointvec
,
1008 .procname
= "bootloader_type",
1009 .data
= &bootloader_type
,
1010 .maxlen
= sizeof (int),
1012 .proc_handler
= proc_dointvec
,
1015 .procname
= "bootloader_version",
1016 .data
= &bootloader_version
,
1017 .maxlen
= sizeof (int),
1019 .proc_handler
= proc_dointvec
,
1022 .procname
= "io_delay_type",
1023 .data
= &io_delay_type
,
1024 .maxlen
= sizeof(int),
1026 .proc_handler
= proc_dointvec
,
1029 #if defined(CONFIG_MMU)
1031 .procname
= "randomize_va_space",
1032 .data
= &randomize_va_space
,
1033 .maxlen
= sizeof(int),
1035 .proc_handler
= proc_dointvec
,
1038 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1040 .procname
= "spin_retry",
1041 .data
= &spin_retry
,
1042 .maxlen
= sizeof (int),
1044 .proc_handler
= proc_dointvec
,
1047 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1049 .procname
= "acpi_video_flags",
1050 .data
= &acpi_realmode_flags
,
1051 .maxlen
= sizeof (unsigned long),
1053 .proc_handler
= proc_doulongvec_minmax
,
1056 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1058 .procname
= "ignore-unaligned-usertrap",
1059 .data
= &no_unaligned_warning
,
1060 .maxlen
= sizeof (int),
1062 .proc_handler
= proc_dointvec
,
1067 .procname
= "unaligned-dump-stack",
1068 .data
= &unaligned_dump_stack
,
1069 .maxlen
= sizeof (int),
1071 .proc_handler
= proc_dointvec
,
1074 #ifdef CONFIG_DETECT_HUNG_TASK
1076 .procname
= "hung_task_panic",
1077 .data
= &sysctl_hung_task_panic
,
1078 .maxlen
= sizeof(int),
1080 .proc_handler
= proc_dointvec_minmax
,
1085 .procname
= "hung_task_check_count",
1086 .data
= &sysctl_hung_task_check_count
,
1087 .maxlen
= sizeof(int),
1089 .proc_handler
= proc_dointvec_minmax
,
1093 .procname
= "hung_task_timeout_secs",
1094 .data
= &sysctl_hung_task_timeout_secs
,
1095 .maxlen
= sizeof(unsigned long),
1097 .proc_handler
= proc_dohung_task_timeout_secs
,
1098 .extra2
= &hung_task_timeout_max
,
1101 .procname
= "hung_task_warnings",
1102 .data
= &sysctl_hung_task_warnings
,
1103 .maxlen
= sizeof(int),
1105 .proc_handler
= proc_dointvec_minmax
,
1109 #ifdef CONFIG_RT_MUTEXES
1111 .procname
= "max_lock_depth",
1112 .data
= &max_lock_depth
,
1113 .maxlen
= sizeof(int),
1115 .proc_handler
= proc_dointvec
,
1119 .procname
= "poweroff_cmd",
1120 .data
= &poweroff_cmd
,
1121 .maxlen
= POWEROFF_CMD_PATH_LEN
,
1123 .proc_handler
= proc_dostring
,
1129 .child
= key_sysctls
,
1132 #ifdef CONFIG_PERF_EVENTS
1134 * User-space scripts rely on the existence of this file
1135 * as a feature check for perf_events being enabled.
1137 * So it's an ABI, do not remove!
1140 .procname
= "perf_event_paranoid",
1141 .data
= &sysctl_perf_event_paranoid
,
1142 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
1144 .proc_handler
= proc_dointvec
,
1147 .procname
= "perf_event_mlock_kb",
1148 .data
= &sysctl_perf_event_mlock
,
1149 .maxlen
= sizeof(sysctl_perf_event_mlock
),
1151 .proc_handler
= proc_dointvec
,
1154 .procname
= "perf_event_max_sample_rate",
1155 .data
= &sysctl_perf_event_sample_rate
,
1156 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1158 .proc_handler
= perf_proc_update_handler
,
1162 .procname
= "perf_cpu_time_max_percent",
1163 .data
= &sysctl_perf_cpu_time_max_percent
,
1164 .maxlen
= sizeof(sysctl_perf_cpu_time_max_percent
),
1166 .proc_handler
= perf_cpu_time_max_percent_handler
,
1168 .extra2
= &one_hundred
,
1171 .procname
= "perf_event_max_stack",
1172 .data
= &sysctl_perf_event_max_stack
,
1173 .maxlen
= sizeof(sysctl_perf_event_max_stack
),
1175 .proc_handler
= perf_event_max_stack_handler
,
1177 .extra2
= &six_hundred_forty_kb
,
1180 .procname
= "perf_event_max_contexts_per_stack",
1181 .data
= &sysctl_perf_event_max_contexts_per_stack
,
1182 .maxlen
= sizeof(sysctl_perf_event_max_contexts_per_stack
),
1184 .proc_handler
= perf_event_max_stack_handler
,
1186 .extra2
= &one_thousand
,
1190 .procname
= "panic_on_warn",
1191 .data
= &panic_on_warn
,
1192 .maxlen
= sizeof(int),
1194 .proc_handler
= proc_dointvec_minmax
,
1198 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1200 .procname
= "timer_migration",
1201 .data
= &sysctl_timer_migration
,
1202 .maxlen
= sizeof(unsigned int),
1204 .proc_handler
= timer_migration_handler
,
1209 #ifdef CONFIG_BPF_SYSCALL
1211 .procname
= "unprivileged_bpf_disabled",
1212 .data
= &sysctl_unprivileged_bpf_disabled
,
1213 .maxlen
= sizeof(sysctl_unprivileged_bpf_disabled
),
1215 /* only handle a transition from default "0" to "1" */
1216 .proc_handler
= proc_dointvec_minmax
,
1221 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1223 .procname
= "panic_on_rcu_stall",
1224 .data
= &sysctl_panic_on_rcu_stall
,
1225 .maxlen
= sizeof(sysctl_panic_on_rcu_stall
),
1227 .proc_handler
= proc_dointvec_minmax
,
1235 static struct ctl_table vm_table
[] = {
1237 .procname
= "overcommit_memory",
1238 .data
= &sysctl_overcommit_memory
,
1239 .maxlen
= sizeof(sysctl_overcommit_memory
),
1241 .proc_handler
= proc_dointvec_minmax
,
1246 .procname
= "panic_on_oom",
1247 .data
= &sysctl_panic_on_oom
,
1248 .maxlen
= sizeof(sysctl_panic_on_oom
),
1250 .proc_handler
= proc_dointvec_minmax
,
1255 .procname
= "oom_kill_allocating_task",
1256 .data
= &sysctl_oom_kill_allocating_task
,
1257 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
1259 .proc_handler
= proc_dointvec
,
1262 .procname
= "oom_dump_tasks",
1263 .data
= &sysctl_oom_dump_tasks
,
1264 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
1266 .proc_handler
= proc_dointvec
,
1269 .procname
= "overcommit_ratio",
1270 .data
= &sysctl_overcommit_ratio
,
1271 .maxlen
= sizeof(sysctl_overcommit_ratio
),
1273 .proc_handler
= overcommit_ratio_handler
,
1276 .procname
= "overcommit_kbytes",
1277 .data
= &sysctl_overcommit_kbytes
,
1278 .maxlen
= sizeof(sysctl_overcommit_kbytes
),
1280 .proc_handler
= overcommit_kbytes_handler
,
1283 .procname
= "page-cluster",
1284 .data
= &page_cluster
,
1285 .maxlen
= sizeof(int),
1287 .proc_handler
= proc_dointvec_minmax
,
1291 .procname
= "dirty_background_ratio",
1292 .data
= &dirty_background_ratio
,
1293 .maxlen
= sizeof(dirty_background_ratio
),
1295 .proc_handler
= dirty_background_ratio_handler
,
1297 .extra2
= &one_hundred
,
1300 .procname
= "dirty_background_bytes",
1301 .data
= &dirty_background_bytes
,
1302 .maxlen
= sizeof(dirty_background_bytes
),
1304 .proc_handler
= dirty_background_bytes_handler
,
1308 .procname
= "dirty_ratio",
1309 .data
= &vm_dirty_ratio
,
1310 .maxlen
= sizeof(vm_dirty_ratio
),
1312 .proc_handler
= dirty_ratio_handler
,
1314 .extra2
= &one_hundred
,
1317 .procname
= "dirty_bytes",
1318 .data
= &vm_dirty_bytes
,
1319 .maxlen
= sizeof(vm_dirty_bytes
),
1321 .proc_handler
= dirty_bytes_handler
,
1322 .extra1
= &dirty_bytes_min
,
1325 .procname
= "dirty_writeback_centisecs",
1326 .data
= &dirty_writeback_interval
,
1327 .maxlen
= sizeof(dirty_writeback_interval
),
1329 .proc_handler
= dirty_writeback_centisecs_handler
,
1332 .procname
= "dirty_expire_centisecs",
1333 .data
= &dirty_expire_interval
,
1334 .maxlen
= sizeof(dirty_expire_interval
),
1336 .proc_handler
= proc_dointvec_minmax
,
1340 .procname
= "dirtytime_expire_seconds",
1341 .data
= &dirtytime_expire_interval
,
1342 .maxlen
= sizeof(dirty_expire_interval
),
1344 .proc_handler
= dirtytime_interval_handler
,
1348 .procname
= "swappiness",
1349 .data
= &vm_swappiness
,
1350 .maxlen
= sizeof(vm_swappiness
),
1352 .proc_handler
= proc_dointvec_minmax
,
1354 .extra2
= &one_hundred
,
1356 #ifdef CONFIG_HUGETLB_PAGE
1358 .procname
= "nr_hugepages",
1360 .maxlen
= sizeof(unsigned long),
1362 .proc_handler
= hugetlb_sysctl_handler
,
1366 .procname
= "nr_hugepages_mempolicy",
1368 .maxlen
= sizeof(unsigned long),
1370 .proc_handler
= &hugetlb_mempolicy_sysctl_handler
,
1373 .procname
= "numa_stat",
1374 .data
= &sysctl_vm_numa_stat
,
1375 .maxlen
= sizeof(int),
1377 .proc_handler
= sysctl_vm_numa_stat_handler
,
1383 .procname
= "hugetlb_shm_group",
1384 .data
= &sysctl_hugetlb_shm_group
,
1385 .maxlen
= sizeof(gid_t
),
1387 .proc_handler
= proc_dointvec
,
1390 .procname
= "hugepages_treat_as_movable",
1391 .data
= &hugepages_treat_as_movable
,
1392 .maxlen
= sizeof(int),
1394 .proc_handler
= proc_dointvec
,
1397 .procname
= "nr_overcommit_hugepages",
1399 .maxlen
= sizeof(unsigned long),
1401 .proc_handler
= hugetlb_overcommit_handler
,
1405 .procname
= "lowmem_reserve_ratio",
1406 .data
= &sysctl_lowmem_reserve_ratio
,
1407 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
1409 .proc_handler
= lowmem_reserve_ratio_sysctl_handler
,
1412 .procname
= "drop_caches",
1413 .data
= &sysctl_drop_caches
,
1414 .maxlen
= sizeof(int),
1416 .proc_handler
= drop_caches_sysctl_handler
,
1420 #ifdef CONFIG_COMPACTION
1422 .procname
= "compact_memory",
1423 .data
= &sysctl_compact_memory
,
1424 .maxlen
= sizeof(int),
1426 .proc_handler
= sysctl_compaction_handler
,
1429 .procname
= "extfrag_threshold",
1430 .data
= &sysctl_extfrag_threshold
,
1431 .maxlen
= sizeof(int),
1433 .proc_handler
= sysctl_extfrag_handler
,
1434 .extra1
= &min_extfrag_threshold
,
1435 .extra2
= &max_extfrag_threshold
,
1438 .procname
= "compact_unevictable_allowed",
1439 .data
= &sysctl_compact_unevictable_allowed
,
1440 .maxlen
= sizeof(int),
1442 .proc_handler
= proc_dointvec
,
1447 #endif /* CONFIG_COMPACTION */
1449 .procname
= "min_free_kbytes",
1450 .data
= &min_free_kbytes
,
1451 .maxlen
= sizeof(min_free_kbytes
),
1453 .proc_handler
= min_free_kbytes_sysctl_handler
,
1457 .procname
= "watermark_scale_factor",
1458 .data
= &watermark_scale_factor
,
1459 .maxlen
= sizeof(watermark_scale_factor
),
1461 .proc_handler
= watermark_scale_factor_sysctl_handler
,
1463 .extra2
= &one_thousand
,
1466 .procname
= "percpu_pagelist_fraction",
1467 .data
= &percpu_pagelist_fraction
,
1468 .maxlen
= sizeof(percpu_pagelist_fraction
),
1470 .proc_handler
= percpu_pagelist_fraction_sysctl_handler
,
1475 .procname
= "max_map_count",
1476 .data
= &sysctl_max_map_count
,
1477 .maxlen
= sizeof(sysctl_max_map_count
),
1479 .proc_handler
= proc_dointvec_minmax
,
1484 .procname
= "nr_trim_pages",
1485 .data
= &sysctl_nr_trim_pages
,
1486 .maxlen
= sizeof(sysctl_nr_trim_pages
),
1488 .proc_handler
= proc_dointvec_minmax
,
1493 .procname
= "laptop_mode",
1494 .data
= &laptop_mode
,
1495 .maxlen
= sizeof(laptop_mode
),
1497 .proc_handler
= proc_dointvec_jiffies
,
1500 .procname
= "block_dump",
1501 .data
= &block_dump
,
1502 .maxlen
= sizeof(block_dump
),
1504 .proc_handler
= proc_dointvec
,
1508 .procname
= "vfs_cache_pressure",
1509 .data
= &sysctl_vfs_cache_pressure
,
1510 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1512 .proc_handler
= proc_dointvec
,
1515 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1517 .procname
= "legacy_va_layout",
1518 .data
= &sysctl_legacy_va_layout
,
1519 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1521 .proc_handler
= proc_dointvec
,
1527 .procname
= "zone_reclaim_mode",
1528 .data
= &node_reclaim_mode
,
1529 .maxlen
= sizeof(node_reclaim_mode
),
1531 .proc_handler
= proc_dointvec
,
1535 .procname
= "min_unmapped_ratio",
1536 .data
= &sysctl_min_unmapped_ratio
,
1537 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1539 .proc_handler
= sysctl_min_unmapped_ratio_sysctl_handler
,
1541 .extra2
= &one_hundred
,
1544 .procname
= "min_slab_ratio",
1545 .data
= &sysctl_min_slab_ratio
,
1546 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1548 .proc_handler
= sysctl_min_slab_ratio_sysctl_handler
,
1550 .extra2
= &one_hundred
,
1555 .procname
= "stat_interval",
1556 .data
= &sysctl_stat_interval
,
1557 .maxlen
= sizeof(sysctl_stat_interval
),
1559 .proc_handler
= proc_dointvec_jiffies
,
1562 .procname
= "stat_refresh",
1566 .proc_handler
= vmstat_refresh
,
1571 .procname
= "mmap_min_addr",
1572 .data
= &dac_mmap_min_addr
,
1573 .maxlen
= sizeof(unsigned long),
1575 .proc_handler
= mmap_min_addr_handler
,
1580 .procname
= "numa_zonelist_order",
1581 .data
= &numa_zonelist_order
,
1582 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1584 .proc_handler
= numa_zonelist_order_handler
,
1587 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1588 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1590 .procname
= "vdso_enabled",
1591 #ifdef CONFIG_X86_32
1592 .data
= &vdso32_enabled
,
1593 .maxlen
= sizeof(vdso32_enabled
),
1595 .data
= &vdso_enabled
,
1596 .maxlen
= sizeof(vdso_enabled
),
1599 .proc_handler
= proc_dointvec
,
1603 #ifdef CONFIG_HIGHMEM
1605 .procname
= "highmem_is_dirtyable",
1606 .data
= &vm_highmem_is_dirtyable
,
1607 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
1609 .proc_handler
= proc_dointvec_minmax
,
1614 #ifdef CONFIG_MEMORY_FAILURE
1616 .procname
= "memory_failure_early_kill",
1617 .data
= &sysctl_memory_failure_early_kill
,
1618 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
1620 .proc_handler
= proc_dointvec_minmax
,
1625 .procname
= "memory_failure_recovery",
1626 .data
= &sysctl_memory_failure_recovery
,
1627 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
1629 .proc_handler
= proc_dointvec_minmax
,
1635 .procname
= "user_reserve_kbytes",
1636 .data
= &sysctl_user_reserve_kbytes
,
1637 .maxlen
= sizeof(sysctl_user_reserve_kbytes
),
1639 .proc_handler
= proc_doulongvec_minmax
,
1642 .procname
= "admin_reserve_kbytes",
1643 .data
= &sysctl_admin_reserve_kbytes
,
1644 .maxlen
= sizeof(sysctl_admin_reserve_kbytes
),
1646 .proc_handler
= proc_doulongvec_minmax
,
1648 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1650 .procname
= "mmap_rnd_bits",
1651 .data
= &mmap_rnd_bits
,
1652 .maxlen
= sizeof(mmap_rnd_bits
),
1654 .proc_handler
= proc_dointvec_minmax
,
1655 .extra1
= (void *)&mmap_rnd_bits_min
,
1656 .extra2
= (void *)&mmap_rnd_bits_max
,
1659 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1661 .procname
= "mmap_rnd_compat_bits",
1662 .data
= &mmap_rnd_compat_bits
,
1663 .maxlen
= sizeof(mmap_rnd_compat_bits
),
1665 .proc_handler
= proc_dointvec_minmax
,
1666 .extra1
= (void *)&mmap_rnd_compat_bits_min
,
1667 .extra2
= (void *)&mmap_rnd_compat_bits_max
,
1673 static struct ctl_table fs_table
[] = {
1675 .procname
= "inode-nr",
1676 .data
= &inodes_stat
,
1677 .maxlen
= 2*sizeof(long),
1679 .proc_handler
= proc_nr_inodes
,
1682 .procname
= "inode-state",
1683 .data
= &inodes_stat
,
1684 .maxlen
= 7*sizeof(long),
1686 .proc_handler
= proc_nr_inodes
,
1689 .procname
= "file-nr",
1690 .data
= &files_stat
,
1691 .maxlen
= sizeof(files_stat
),
1693 .proc_handler
= proc_nr_files
,
1696 .procname
= "file-max",
1697 .data
= &files_stat
.max_files
,
1698 .maxlen
= sizeof(files_stat
.max_files
),
1700 .proc_handler
= proc_doulongvec_minmax
,
1703 .procname
= "nr_open",
1704 .data
= &sysctl_nr_open
,
1705 .maxlen
= sizeof(unsigned int),
1707 .proc_handler
= proc_dointvec_minmax
,
1708 .extra1
= &sysctl_nr_open_min
,
1709 .extra2
= &sysctl_nr_open_max
,
1712 .procname
= "dentry-state",
1713 .data
= &dentry_stat
,
1714 .maxlen
= 6*sizeof(long),
1716 .proc_handler
= proc_nr_dentry
,
1719 .procname
= "overflowuid",
1720 .data
= &fs_overflowuid
,
1721 .maxlen
= sizeof(int),
1723 .proc_handler
= proc_dointvec_minmax
,
1724 .extra1
= &minolduid
,
1725 .extra2
= &maxolduid
,
1728 .procname
= "overflowgid",
1729 .data
= &fs_overflowgid
,
1730 .maxlen
= sizeof(int),
1732 .proc_handler
= proc_dointvec_minmax
,
1733 .extra1
= &minolduid
,
1734 .extra2
= &maxolduid
,
1736 #ifdef CONFIG_FILE_LOCKING
1738 .procname
= "leases-enable",
1739 .data
= &leases_enable
,
1740 .maxlen
= sizeof(int),
1742 .proc_handler
= proc_dointvec
,
1745 #ifdef CONFIG_DNOTIFY
1747 .procname
= "dir-notify-enable",
1748 .data
= &dir_notify_enable
,
1749 .maxlen
= sizeof(int),
1751 .proc_handler
= proc_dointvec
,
1755 #ifdef CONFIG_FILE_LOCKING
1757 .procname
= "lease-break-time",
1758 .data
= &lease_break_time
,
1759 .maxlen
= sizeof(int),
1761 .proc_handler
= proc_dointvec
,
1766 .procname
= "aio-nr",
1768 .maxlen
= sizeof(aio_nr
),
1770 .proc_handler
= proc_doulongvec_minmax
,
1773 .procname
= "aio-max-nr",
1774 .data
= &aio_max_nr
,
1775 .maxlen
= sizeof(aio_max_nr
),
1777 .proc_handler
= proc_doulongvec_minmax
,
1779 #endif /* CONFIG_AIO */
1780 #ifdef CONFIG_INOTIFY_USER
1782 .procname
= "inotify",
1784 .child
= inotify_table
,
1789 .procname
= "epoll",
1791 .child
= epoll_table
,
1796 .procname
= "protected_symlinks",
1797 .data
= &sysctl_protected_symlinks
,
1798 .maxlen
= sizeof(int),
1800 .proc_handler
= proc_dointvec_minmax
,
1805 .procname
= "protected_hardlinks",
1806 .data
= &sysctl_protected_hardlinks
,
1807 .maxlen
= sizeof(int),
1809 .proc_handler
= proc_dointvec_minmax
,
1814 .procname
= "suid_dumpable",
1815 .data
= &suid_dumpable
,
1816 .maxlen
= sizeof(int),
1818 .proc_handler
= proc_dointvec_minmax_coredump
,
1822 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1824 .procname
= "binfmt_misc",
1826 .child
= sysctl_mount_point
,
1830 .procname
= "pipe-max-size",
1831 .data
= &pipe_max_size
,
1832 .maxlen
= sizeof(pipe_max_size
),
1834 .proc_handler
= &pipe_proc_fn
,
1835 .extra1
= &pipe_min_size
,
1838 .procname
= "pipe-user-pages-hard",
1839 .data
= &pipe_user_pages_hard
,
1840 .maxlen
= sizeof(pipe_user_pages_hard
),
1842 .proc_handler
= proc_doulongvec_minmax
,
1845 .procname
= "pipe-user-pages-soft",
1846 .data
= &pipe_user_pages_soft
,
1847 .maxlen
= sizeof(pipe_user_pages_soft
),
1849 .proc_handler
= proc_doulongvec_minmax
,
1852 .procname
= "mount-max",
1853 .data
= &sysctl_mount_max
,
1854 .maxlen
= sizeof(unsigned int),
1856 .proc_handler
= proc_dointvec_minmax
,
1862 static struct ctl_table debug_table
[] = {
1863 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1865 .procname
= "exception-trace",
1866 .data
= &show_unhandled_signals
,
1867 .maxlen
= sizeof(int),
1869 .proc_handler
= proc_dointvec
1872 #if defined(CONFIG_OPTPROBES)
1874 .procname
= "kprobes-optimization",
1875 .data
= &sysctl_kprobes_optimization
,
1876 .maxlen
= sizeof(int),
1878 .proc_handler
= proc_kprobes_optimization_handler
,
1886 static struct ctl_table dev_table
[] = {
1890 int __init
sysctl_init(void)
1892 struct ctl_table_header
*hdr
;
1894 hdr
= register_sysctl_table(sysctl_base_table
);
1895 kmemleak_not_leak(hdr
);
1899 #endif /* CONFIG_SYSCTL */
1905 #ifdef CONFIG_PROC_SYSCTL
1907 static int _proc_do_string(char *data
, int maxlen
, int write
,
1908 char __user
*buffer
,
1909 size_t *lenp
, loff_t
*ppos
)
1915 if (!data
|| !maxlen
|| !*lenp
) {
1921 if (sysctl_writes_strict
== SYSCTL_WRITES_STRICT
) {
1922 /* Only continue writes not past the end of buffer. */
1924 if (len
> maxlen
- 1)
1931 /* Start writing from beginning of buffer. */
1937 while ((p
- buffer
) < *lenp
&& len
< maxlen
- 1) {
1938 if (get_user(c
, p
++))
1940 if (c
== 0 || c
== '\n')
1961 if (copy_to_user(buffer
, data
, len
))
1964 if (put_user('\n', buffer
+ len
))
1974 static void warn_sysctl_write(struct ctl_table
*table
)
1976 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1977 "This will not be supported in the future. To silence this\n"
1978 "warning, set kernel.sysctl_writes_strict = -1\n",
1979 current
->comm
, table
->procname
);
1983 * proc_first_pos_non_zero_ignore - check if firs position is allowed
1984 * @ppos: file position
1985 * @table: the sysctl table
1987 * Returns true if the first position is non-zero and the sysctl_writes_strict
1988 * mode indicates this is not allowed for numeric input types. String proc
1989 * hadlers can ignore the return value.
1991 static bool proc_first_pos_non_zero_ignore(loff_t
*ppos
,
1992 struct ctl_table
*table
)
1997 switch (sysctl_writes_strict
) {
1998 case SYSCTL_WRITES_STRICT
:
2000 case SYSCTL_WRITES_WARN
:
2001 warn_sysctl_write(table
);
2009 * proc_dostring - read a string sysctl
2010 * @table: the sysctl table
2011 * @write: %TRUE if this is a write to the sysctl file
2012 * @buffer: the user buffer
2013 * @lenp: the size of the user buffer
2014 * @ppos: file position
2016 * Reads/writes a string from/to the user buffer. If the kernel
2017 * buffer provided is not large enough to hold the string, the
2018 * string is truncated. The copied string is %NULL-terminated.
2019 * If the string is being read by the user process, it is copied
2020 * and a newline '\n' is added. It is truncated if the buffer is
2023 * Returns 0 on success.
2025 int proc_dostring(struct ctl_table
*table
, int write
,
2026 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2029 proc_first_pos_non_zero_ignore(ppos
, table
);
2031 return _proc_do_string((char *)(table
->data
), table
->maxlen
, write
,
2032 (char __user
*)buffer
, lenp
, ppos
);
2035 static size_t proc_skip_spaces(char **buf
)
2038 char *tmp
= skip_spaces(*buf
);
2044 static void proc_skip_char(char **buf
, size_t *size
, const char v
)
2054 #define TMPBUFLEN 22
2056 * proc_get_long - reads an ASCII formatted integer from a user buffer
2058 * @buf: a kernel buffer
2059 * @size: size of the kernel buffer
2060 * @val: this is where the number will be stored
2061 * @neg: set to %TRUE if number is negative
2062 * @perm_tr: a vector which contains the allowed trailers
2063 * @perm_tr_len: size of the perm_tr vector
2064 * @tr: pointer to store the trailer character
2066 * In case of success %0 is returned and @buf and @size are updated with
2067 * the amount of bytes read. If @tr is non-NULL and a trailing
2068 * character exists (size is non-zero after returning from this
2069 * function), @tr is updated with the trailing character.
2071 static int proc_get_long(char **buf
, size_t *size
,
2072 unsigned long *val
, bool *neg
,
2073 const char *perm_tr
, unsigned perm_tr_len
, char *tr
)
2076 char *p
, tmp
[TMPBUFLEN
];
2082 if (len
> TMPBUFLEN
- 1)
2083 len
= TMPBUFLEN
- 1;
2085 memcpy(tmp
, *buf
, len
);
2089 if (*p
== '-' && *size
> 1) {
2097 *val
= simple_strtoul(p
, &p
, 0);
2101 /* We don't know if the next char is whitespace thus we may accept
2102 * invalid integers (e.g. 1234...a) or two integers instead of one
2103 * (e.g. 123...1). So lets not allow such large numbers. */
2104 if (len
== TMPBUFLEN
- 1)
2107 if (len
< *size
&& perm_tr_len
&& !memchr(perm_tr
, *p
, perm_tr_len
))
2110 if (tr
&& (len
< *size
))
2120 * proc_put_long - converts an integer to a decimal ASCII formatted string
2122 * @buf: the user buffer
2123 * @size: the size of the user buffer
2124 * @val: the integer to be converted
2125 * @neg: sign of the number, %TRUE for negative
2127 * In case of success %0 is returned and @buf and @size are updated with
2128 * the amount of bytes written.
2130 static int proc_put_long(void __user
**buf
, size_t *size
, unsigned long val
,
2134 char tmp
[TMPBUFLEN
], *p
= tmp
;
2136 sprintf(p
, "%s%lu", neg
? "-" : "", val
);
2140 if (copy_to_user(*buf
, tmp
, len
))
2148 static int proc_put_char(void __user
**buf
, size_t *size
, char c
)
2151 char __user
**buffer
= (char __user
**)buf
;
2152 if (put_user(c
, *buffer
))
2154 (*size
)--, (*buffer
)++;
2160 static int do_proc_dointvec_conv(bool *negp
, unsigned long *lvalp
,
2162 int write
, void *data
)
2166 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2170 if (*lvalp
> (unsigned long) INT_MAX
)
2178 *lvalp
= -(unsigned long)val
;
2181 *lvalp
= (unsigned long)val
;
2187 static int do_proc_douintvec_conv(unsigned long *lvalp
,
2189 int write
, void *data
)
2192 if (*lvalp
> UINT_MAX
)
2196 unsigned int val
= *valp
;
2197 *lvalp
= (unsigned long)val
;
2202 static const char proc_wspace_sep
[] = { ' ', '\t', '\n' };
2204 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2205 int write
, void __user
*buffer
,
2206 size_t *lenp
, loff_t
*ppos
,
2207 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2208 int write
, void *data
),
2211 int *i
, vleft
, first
= 1, err
= 0;
2213 char *kbuf
= NULL
, *p
;
2215 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2220 i
= (int *) tbl_data
;
2221 vleft
= table
->maxlen
/ sizeof(*i
);
2225 conv
= do_proc_dointvec_conv
;
2228 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2231 if (left
> PAGE_SIZE
- 1)
2232 left
= PAGE_SIZE
- 1;
2233 p
= kbuf
= memdup_user_nul(buffer
, left
);
2235 return PTR_ERR(kbuf
);
2238 for (; left
&& vleft
--; i
++, first
=0) {
2243 left
-= proc_skip_spaces(&p
);
2247 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2249 sizeof(proc_wspace_sep
), NULL
);
2252 if (conv(&neg
, &lval
, i
, 1, data
)) {
2257 if (conv(&neg
, &lval
, i
, 0, data
)) {
2262 err
= proc_put_char(&buffer
, &left
, '\t');
2265 err
= proc_put_long(&buffer
, &left
, lval
, neg
);
2271 if (!write
&& !first
&& left
&& !err
)
2272 err
= proc_put_char(&buffer
, &left
, '\n');
2273 if (write
&& !err
&& left
)
2274 left
-= proc_skip_spaces(&p
);
2278 return err
? : -EINVAL
;
2286 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2287 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2288 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2289 int write
, void *data
),
2292 return __do_proc_dointvec(table
->data
, table
, write
,
2293 buffer
, lenp
, ppos
, conv
, data
);
2296 static int do_proc_douintvec_w(unsigned int *tbl_data
,
2297 struct ctl_table
*table
,
2298 void __user
*buffer
,
2299 size_t *lenp
, loff_t
*ppos
,
2300 int (*conv
)(unsigned long *lvalp
,
2302 int write
, void *data
),
2309 char *kbuf
= NULL
, *p
;
2313 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2316 if (left
> PAGE_SIZE
- 1)
2317 left
= PAGE_SIZE
- 1;
2319 p
= kbuf
= memdup_user_nul(buffer
, left
);
2323 left
-= proc_skip_spaces(&p
);
2329 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2331 sizeof(proc_wspace_sep
), NULL
);
2337 if (conv(&lval
, tbl_data
, 1, data
)) {
2343 left
-= proc_skip_spaces(&p
);
2352 /* This is in keeping with old __do_proc_dointvec() */
2358 static int do_proc_douintvec_r(unsigned int *tbl_data
, void __user
*buffer
,
2359 size_t *lenp
, loff_t
*ppos
,
2360 int (*conv
)(unsigned long *lvalp
,
2362 int write
, void *data
),
2371 if (conv(&lval
, tbl_data
, 0, data
)) {
2376 err
= proc_put_long(&buffer
, &left
, lval
, false);
2380 err
= proc_put_char(&buffer
, &left
, '\n');
2389 static int __do_proc_douintvec(void *tbl_data
, struct ctl_table
*table
,
2390 int write
, void __user
*buffer
,
2391 size_t *lenp
, loff_t
*ppos
,
2392 int (*conv
)(unsigned long *lvalp
,
2394 int write
, void *data
),
2397 unsigned int *i
, vleft
;
2399 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2404 i
= (unsigned int *) tbl_data
;
2405 vleft
= table
->maxlen
/ sizeof(*i
);
2408 * Arrays are not supported, keep this simple. *Do not* add
2417 conv
= do_proc_douintvec_conv
;
2420 return do_proc_douintvec_w(i
, table
, buffer
, lenp
, ppos
,
2422 return do_proc_douintvec_r(i
, buffer
, lenp
, ppos
, conv
, data
);
2425 static int do_proc_douintvec(struct ctl_table
*table
, int write
,
2426 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2427 int (*conv
)(unsigned long *lvalp
,
2429 int write
, void *data
),
2432 return __do_proc_douintvec(table
->data
, table
, write
,
2433 buffer
, lenp
, ppos
, conv
, data
);
2437 * proc_dointvec - read a vector of integers
2438 * @table: the sysctl table
2439 * @write: %TRUE if this is a write to the sysctl file
2440 * @buffer: the user buffer
2441 * @lenp: the size of the user buffer
2442 * @ppos: file position
2444 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2445 * values from/to the user buffer, treated as an ASCII string.
2447 * Returns 0 on success.
2449 int proc_dointvec(struct ctl_table
*table
, int write
,
2450 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2452 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
, NULL
, NULL
);
2456 * proc_douintvec - read a vector of unsigned integers
2457 * @table: the sysctl table
2458 * @write: %TRUE if this is a write to the sysctl file
2459 * @buffer: the user buffer
2460 * @lenp: the size of the user buffer
2461 * @ppos: file position
2463 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2464 * values from/to the user buffer, treated as an ASCII string.
2466 * Returns 0 on success.
2468 int proc_douintvec(struct ctl_table
*table
, int write
,
2469 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2471 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2472 do_proc_douintvec_conv
, NULL
);
2476 * Taint values can only be increased
2477 * This means we can safely use a temporary.
2479 static int proc_taint(struct ctl_table
*table
, int write
,
2480 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2483 unsigned long tmptaint
= get_taint();
2486 if (write
&& !capable(CAP_SYS_ADMIN
))
2491 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2497 * Poor man's atomic or. Not worth adding a primitive
2498 * to everyone's atomic.h for this
2501 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2502 if ((tmptaint
>> i
) & 1)
2503 add_taint(i
, LOCKDEP_STILL_OK
);
2510 #ifdef CONFIG_PRINTK
2511 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
2512 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2514 if (write
&& !capable(CAP_SYS_ADMIN
))
2517 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2521 struct do_proc_dointvec_minmax_conv_param
{
2526 static int do_proc_dointvec_minmax_conv(bool *negp
, unsigned long *lvalp
,
2528 int write
, void *data
)
2530 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2532 int val
= *negp
? -*lvalp
: *lvalp
;
2533 if ((param
->min
&& *param
->min
> val
) ||
2534 (param
->max
&& *param
->max
< val
))
2541 *lvalp
= -(unsigned long)val
;
2544 *lvalp
= (unsigned long)val
;
2551 * proc_dointvec_minmax - read a vector of integers with min/max values
2552 * @table: the sysctl table
2553 * @write: %TRUE if this is a write to the sysctl file
2554 * @buffer: the user buffer
2555 * @lenp: the size of the user buffer
2556 * @ppos: file position
2558 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2559 * values from/to the user buffer, treated as an ASCII string.
2561 * This routine will ensure the values are within the range specified by
2562 * table->extra1 (min) and table->extra2 (max).
2564 * Returns 0 on success.
2566 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2567 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2569 struct do_proc_dointvec_minmax_conv_param param
= {
2570 .min
= (int *) table
->extra1
,
2571 .max
= (int *) table
->extra2
,
2573 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2574 do_proc_dointvec_minmax_conv
, ¶m
);
2577 struct do_proc_douintvec_minmax_conv_param
{
2582 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp
,
2584 int write
, void *data
)
2586 struct do_proc_douintvec_minmax_conv_param
*param
= data
;
2589 unsigned int val
= *lvalp
;
2591 if (*lvalp
> UINT_MAX
)
2594 if ((param
->min
&& *param
->min
> val
) ||
2595 (param
->max
&& *param
->max
< val
))
2600 unsigned int val
= *valp
;
2601 *lvalp
= (unsigned long) val
;
2608 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2609 * @table: the sysctl table
2610 * @write: %TRUE if this is a write to the sysctl file
2611 * @buffer: the user buffer
2612 * @lenp: the size of the user buffer
2613 * @ppos: file position
2615 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2616 * values from/to the user buffer, treated as an ASCII string. Negative
2617 * strings are not allowed.
2619 * This routine will ensure the values are within the range specified by
2620 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2621 * check for UINT_MAX to avoid having to support wrap around uses from
2624 * Returns 0 on success.
2626 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
2627 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2629 struct do_proc_douintvec_minmax_conv_param param
= {
2630 .min
= (unsigned int *) table
->extra1
,
2631 .max
= (unsigned int *) table
->extra2
,
2633 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2634 do_proc_douintvec_minmax_conv
, ¶m
);
2637 struct do_proc_dopipe_max_size_conv_param
{
2641 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp
,
2643 int write
, void *data
)
2645 struct do_proc_dopipe_max_size_conv_param
*param
= data
;
2650 if (*lvalp
> UINT_MAX
)
2653 val
= round_pipe_size(*lvalp
);
2657 if (param
->min
&& *param
->min
> val
)
2662 unsigned int val
= *valp
;
2663 *lvalp
= (unsigned long) val
;
2669 int proc_dopipe_max_size(struct ctl_table
*table
, int write
,
2670 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2672 struct do_proc_dopipe_max_size_conv_param param
= {
2673 .min
= (unsigned int *) table
->extra1
,
2675 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2676 do_proc_dopipe_max_size_conv
, ¶m
);
2679 static void validate_coredump_safety(void)
2681 #ifdef CONFIG_COREDUMP
2682 if (suid_dumpable
== SUID_DUMP_ROOT
&&
2683 core_pattern
[0] != '/' && core_pattern
[0] != '|') {
2685 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2686 "Pipe handler or fully qualified core dump path required.\n"
2687 "Set kernel.core_pattern before fs.suid_dumpable.\n"
2693 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
2694 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2696 int error
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2698 validate_coredump_safety();
2702 #ifdef CONFIG_COREDUMP
2703 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
2704 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2706 int error
= proc_dostring(table
, write
, buffer
, lenp
, ppos
);
2708 validate_coredump_safety();
2713 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2714 void __user
*buffer
,
2715 size_t *lenp
, loff_t
*ppos
,
2716 unsigned long convmul
,
2717 unsigned long convdiv
)
2719 unsigned long *i
, *min
, *max
;
2720 int vleft
, first
= 1, err
= 0;
2722 char *kbuf
= NULL
, *p
;
2724 if (!data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2729 i
= (unsigned long *) data
;
2730 min
= (unsigned long *) table
->extra1
;
2731 max
= (unsigned long *) table
->extra2
;
2732 vleft
= table
->maxlen
/ sizeof(unsigned long);
2736 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2739 if (left
> PAGE_SIZE
- 1)
2740 left
= PAGE_SIZE
- 1;
2741 p
= kbuf
= memdup_user_nul(buffer
, left
);
2743 return PTR_ERR(kbuf
);
2746 for (; left
&& vleft
--; i
++, first
= 0) {
2752 left
-= proc_skip_spaces(&p
);
2754 err
= proc_get_long(&p
, &left
, &val
, &neg
,
2756 sizeof(proc_wspace_sep
), NULL
);
2761 val
= convmul
* val
/ convdiv
;
2762 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2766 val
= convdiv
* (*i
) / convmul
;
2768 err
= proc_put_char(&buffer
, &left
, '\t');
2772 err
= proc_put_long(&buffer
, &left
, val
, false);
2778 if (!write
&& !first
&& left
&& !err
)
2779 err
= proc_put_char(&buffer
, &left
, '\n');
2781 left
-= proc_skip_spaces(&p
);
2785 return err
? : -EINVAL
;
2793 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2794 void __user
*buffer
,
2795 size_t *lenp
, loff_t
*ppos
,
2796 unsigned long convmul
,
2797 unsigned long convdiv
)
2799 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2800 buffer
, lenp
, ppos
, convmul
, convdiv
);
2804 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2805 * @table: the sysctl table
2806 * @write: %TRUE if this is a write to the sysctl file
2807 * @buffer: the user buffer
2808 * @lenp: the size of the user buffer
2809 * @ppos: file position
2811 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2812 * values from/to the user buffer, treated as an ASCII string.
2814 * This routine will ensure the values are within the range specified by
2815 * table->extra1 (min) and table->extra2 (max).
2817 * Returns 0 on success.
2819 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2820 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2822 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2826 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2827 * @table: the sysctl table
2828 * @write: %TRUE if this is a write to the sysctl file
2829 * @buffer: the user buffer
2830 * @lenp: the size of the user buffer
2831 * @ppos: file position
2833 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2834 * values from/to the user buffer, treated as an ASCII string. The values
2835 * are treated as milliseconds, and converted to jiffies when they are stored.
2837 * This routine will ensure the values are within the range specified by
2838 * table->extra1 (min) and table->extra2 (max).
2840 * Returns 0 on success.
2842 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2843 void __user
*buffer
,
2844 size_t *lenp
, loff_t
*ppos
)
2846 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2847 lenp
, ppos
, HZ
, 1000l);
2851 static int do_proc_dointvec_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2853 int write
, void *data
)
2856 if (*lvalp
> INT_MAX
/ HZ
)
2858 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2864 lval
= -(unsigned long)val
;
2867 lval
= (unsigned long)val
;
2874 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2876 int write
, void *data
)
2879 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2881 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2887 lval
= -(unsigned long)val
;
2890 lval
= (unsigned long)val
;
2892 *lvalp
= jiffies_to_clock_t(lval
);
2897 static int do_proc_dointvec_ms_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2899 int write
, void *data
)
2902 unsigned long jif
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2912 lval
= -(unsigned long)val
;
2915 lval
= (unsigned long)val
;
2917 *lvalp
= jiffies_to_msecs(lval
);
2923 * proc_dointvec_jiffies - read a vector of integers as seconds
2924 * @table: the sysctl table
2925 * @write: %TRUE if this is a write to the sysctl file
2926 * @buffer: the user buffer
2927 * @lenp: the size of the user buffer
2928 * @ppos: file position
2930 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2931 * values from/to the user buffer, treated as an ASCII string.
2932 * The values read are assumed to be in seconds, and are converted into
2935 * Returns 0 on success.
2937 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2938 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2940 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2941 do_proc_dointvec_jiffies_conv
,NULL
);
2945 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2946 * @table: the sysctl table
2947 * @write: %TRUE if this is a write to the sysctl file
2948 * @buffer: the user buffer
2949 * @lenp: the size of the user buffer
2950 * @ppos: pointer to the file position
2952 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2953 * values from/to the user buffer, treated as an ASCII string.
2954 * The values read are assumed to be in 1/USER_HZ seconds, and
2955 * are converted into jiffies.
2957 * Returns 0 on success.
2959 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2960 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2962 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2963 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2967 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2968 * @table: the sysctl table
2969 * @write: %TRUE if this is a write to the sysctl file
2970 * @buffer: the user buffer
2971 * @lenp: the size of the user buffer
2972 * @ppos: file position
2973 * @ppos: the current position in the file
2975 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2976 * values from/to the user buffer, treated as an ASCII string.
2977 * The values read are assumed to be in 1/1000 seconds, and
2978 * are converted into jiffies.
2980 * Returns 0 on success.
2982 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2983 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2985 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2986 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2989 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
2990 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2992 struct pid
*new_pid
;
2996 tmp
= pid_vnr(cad_pid
);
2998 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
2999 lenp
, ppos
, NULL
, NULL
);
3003 new_pid
= find_get_pid(tmp
);
3007 put_pid(xchg(&cad_pid
, new_pid
));
3012 * proc_do_large_bitmap - read/write from/to a large bitmap
3013 * @table: the sysctl table
3014 * @write: %TRUE if this is a write to the sysctl file
3015 * @buffer: the user buffer
3016 * @lenp: the size of the user buffer
3017 * @ppos: file position
3019 * The bitmap is stored at table->data and the bitmap length (in bits)
3022 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
3023 * large bitmaps may be represented in a compact manner. Writing into
3024 * the file will clear the bitmap then update it with the given input.
3026 * Returns 0 on success.
3028 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
3029 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3033 size_t left
= *lenp
;
3034 unsigned long bitmap_len
= table
->maxlen
;
3035 unsigned long *bitmap
= *(unsigned long **) table
->data
;
3036 unsigned long *tmp_bitmap
= NULL
;
3037 char tr_a
[] = { '-', ',', '\n' }, tr_b
[] = { ',', '\n', 0 }, c
;
3039 if (!bitmap
|| !bitmap_len
|| !left
|| (*ppos
&& !write
)) {
3047 if (left
> PAGE_SIZE
- 1)
3048 left
= PAGE_SIZE
- 1;
3050 p
= kbuf
= memdup_user_nul(buffer
, left
);
3052 return PTR_ERR(kbuf
);
3054 tmp_bitmap
= kzalloc(BITS_TO_LONGS(bitmap_len
) * sizeof(unsigned long),
3060 proc_skip_char(&p
, &left
, '\n');
3061 while (!err
&& left
) {
3062 unsigned long val_a
, val_b
;
3065 err
= proc_get_long(&p
, &left
, &val_a
, &neg
, tr_a
,
3069 if (val_a
>= bitmap_len
|| neg
) {
3081 err
= proc_get_long(&p
, &left
, &val_b
,
3082 &neg
, tr_b
, sizeof(tr_b
),
3086 if (val_b
>= bitmap_len
|| neg
||
3097 bitmap_set(tmp_bitmap
, val_a
, val_b
- val_a
+ 1);
3099 proc_skip_char(&p
, &left
, '\n');
3103 unsigned long bit_a
, bit_b
= 0;
3106 bit_a
= find_next_bit(bitmap
, bitmap_len
, bit_b
);
3107 if (bit_a
>= bitmap_len
)
3109 bit_b
= find_next_zero_bit(bitmap
, bitmap_len
,
3113 err
= proc_put_char(&buffer
, &left
, ',');
3117 err
= proc_put_long(&buffer
, &left
, bit_a
, false);
3120 if (bit_a
!= bit_b
) {
3121 err
= proc_put_char(&buffer
, &left
, '-');
3124 err
= proc_put_long(&buffer
, &left
, bit_b
, false);
3132 err
= proc_put_char(&buffer
, &left
, '\n');
3138 bitmap_or(bitmap
, bitmap
, tmp_bitmap
, bitmap_len
);
3140 bitmap_copy(bitmap
, tmp_bitmap
, bitmap_len
);
3150 #else /* CONFIG_PROC_SYSCTL */
3152 int proc_dostring(struct ctl_table
*table
, int write
,
3153 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3158 int proc_dointvec(struct ctl_table
*table
, int write
,
3159 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3164 int proc_douintvec(struct ctl_table
*table
, int write
,
3165 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3170 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
3171 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3176 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
3177 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3182 int proc_dopipe_max_size(struct ctl_table
*table
, int write
,
3183 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3188 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
3189 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3194 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
3195 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3200 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
3201 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3206 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
3207 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3212 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
3213 void __user
*buffer
,
3214 size_t *lenp
, loff_t
*ppos
)
3220 #endif /* CONFIG_PROC_SYSCTL */
3223 * No sense putting this after each symbol definition, twice,
3224 * exception granted :-)
3226 EXPORT_SYMBOL(proc_dointvec
);
3227 EXPORT_SYMBOL(proc_douintvec
);
3228 EXPORT_SYMBOL(proc_dointvec_jiffies
);
3229 EXPORT_SYMBOL(proc_dointvec_minmax
);
3230 EXPORT_SYMBOL_GPL(proc_douintvec_minmax
);
3231 EXPORT_SYMBOL_GPL(proc_dopipe_max_size
);
3232 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
3233 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
3234 EXPORT_SYMBOL(proc_dostring
);
3235 EXPORT_SYMBOL(proc_doulongvec_minmax
);
3236 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);