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
;
109 extern int pid_max_min
, pid_max_max
;
110 extern int percpu_pagelist_fraction
;
111 extern int latencytop_enabled
;
112 extern unsigned int sysctl_nr_open_min
, sysctl_nr_open_max
;
114 extern int sysctl_nr_trim_pages
;
117 /* Constants used for minimum and maximum */
118 #ifdef CONFIG_LOCKUP_DETECTOR
119 static int sixty
= 60;
122 static int __maybe_unused neg_one
= -1;
125 static int __maybe_unused one
= 1;
126 static int __maybe_unused two
= 2;
127 static int __maybe_unused four
= 4;
128 static unsigned long one_ul
= 1;
129 static int one_hundred
= 100;
130 static int one_thousand
= 1000;
132 static int ten_thousand
= 10000;
134 #ifdef CONFIG_PERF_EVENTS
135 static int six_hundred_forty_kb
= 640 * 1024;
138 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
139 static unsigned long dirty_bytes_min
= 2 * PAGE_SIZE
;
141 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
142 static int maxolduid
= 65535;
143 static int minolduid
;
145 static int ngroups_max
= NGROUPS_MAX
;
146 static const int cap_last_cap
= CAP_LAST_CAP
;
148 /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
149 #ifdef CONFIG_DETECT_HUNG_TASK
150 static unsigned long hung_task_timeout_max
= (LONG_MAX
/HZ
);
153 #ifdef CONFIG_INOTIFY_USER
154 #include <linux/inotify.h>
160 extern int pwrsw_enabled
;
163 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
164 extern int unaligned_enabled
;
168 extern int unaligned_dump_stack
;
171 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
172 extern int no_unaligned_warning
;
175 #ifdef CONFIG_PROC_SYSCTL
178 * enum sysctl_writes_mode - supported sysctl write modes
180 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
181 * to be written, and multiple writes on the same sysctl file descriptor
182 * will rewrite the sysctl value, regardless of file position. No warning
183 * is issued when the initial position is not 0.
184 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
186 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
187 * file position 0 and the value must be fully contained in the buffer
188 * sent to the write syscall. If dealing with strings respect the file
189 * position, but restrict this to the max length of the buffer, anything
190 * passed the max lenght will be ignored. Multiple writes will append
193 * These write modes control how current file position affects the behavior of
194 * updating sysctl values through the proc interface on each write.
196 enum sysctl_writes_mode
{
197 SYSCTL_WRITES_LEGACY
= -1,
198 SYSCTL_WRITES_WARN
= 0,
199 SYSCTL_WRITES_STRICT
= 1,
202 static enum sysctl_writes_mode sysctl_writes_strict
= SYSCTL_WRITES_STRICT
;
204 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
205 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
206 static int proc_taint(struct ctl_table
*table
, int write
,
207 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
211 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
212 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
215 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
216 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
217 #ifdef CONFIG_COREDUMP
218 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
219 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
222 #ifdef CONFIG_MAGIC_SYSRQ
223 /* Note: sysrq code uses it's own private copy */
224 static int __sysrq_enabled
= CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE
;
226 static int sysrq_sysctl_handler(struct ctl_table
*table
, int write
,
227 void __user
*buffer
, size_t *lenp
,
232 error
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
237 sysrq_toggle_support(__sysrq_enabled
);
244 static struct ctl_table kern_table
[];
245 static struct ctl_table vm_table
[];
246 static struct ctl_table fs_table
[];
247 static struct ctl_table debug_table
[];
248 static struct ctl_table dev_table
[];
249 extern struct ctl_table random_table
[];
251 extern struct ctl_table epoll_table
[];
254 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
255 int sysctl_legacy_va_layout
;
258 /* The default sysctl tables: */
260 static struct ctl_table sysctl_base_table
[] = {
262 .procname
= "kernel",
279 .child
= debug_table
,
289 #ifdef CONFIG_SCHED_DEBUG
290 static int min_sched_granularity_ns
= 100000; /* 100 usecs */
291 static int max_sched_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
292 static int min_wakeup_granularity_ns
; /* 0 usecs */
293 static int max_wakeup_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
295 static int min_sched_tunable_scaling
= SCHED_TUNABLESCALING_NONE
;
296 static int max_sched_tunable_scaling
= SCHED_TUNABLESCALING_END
-1;
297 #endif /* CONFIG_SMP */
298 #endif /* CONFIG_SCHED_DEBUG */
300 #ifdef CONFIG_COMPACTION
301 static int min_extfrag_threshold
;
302 static int max_extfrag_threshold
= 1000;
305 static struct ctl_table kern_table
[] = {
307 .procname
= "sched_child_runs_first",
308 .data
= &sysctl_sched_child_runs_first
,
309 .maxlen
= sizeof(unsigned int),
311 .proc_handler
= proc_dointvec
,
313 #ifdef CONFIG_SCHED_DEBUG
315 .procname
= "sched_min_granularity_ns",
316 .data
= &sysctl_sched_min_granularity
,
317 .maxlen
= sizeof(unsigned int),
319 .proc_handler
= sched_proc_update_handler
,
320 .extra1
= &min_sched_granularity_ns
,
321 .extra2
= &max_sched_granularity_ns
,
324 .procname
= "sched_latency_ns",
325 .data
= &sysctl_sched_latency
,
326 .maxlen
= sizeof(unsigned int),
328 .proc_handler
= sched_proc_update_handler
,
329 .extra1
= &min_sched_granularity_ns
,
330 .extra2
= &max_sched_granularity_ns
,
333 .procname
= "sched_wakeup_granularity_ns",
334 .data
= &sysctl_sched_wakeup_granularity
,
335 .maxlen
= sizeof(unsigned int),
337 .proc_handler
= sched_proc_update_handler
,
338 .extra1
= &min_wakeup_granularity_ns
,
339 .extra2
= &max_wakeup_granularity_ns
,
343 .procname
= "sched_tunable_scaling",
344 .data
= &sysctl_sched_tunable_scaling
,
345 .maxlen
= sizeof(enum sched_tunable_scaling
),
347 .proc_handler
= sched_proc_update_handler
,
348 .extra1
= &min_sched_tunable_scaling
,
349 .extra2
= &max_sched_tunable_scaling
,
352 .procname
= "sched_migration_cost_ns",
353 .data
= &sysctl_sched_migration_cost
,
354 .maxlen
= sizeof(unsigned int),
356 .proc_handler
= proc_dointvec
,
359 .procname
= "sched_nr_migrate",
360 .data
= &sysctl_sched_nr_migrate
,
361 .maxlen
= sizeof(unsigned int),
363 .proc_handler
= proc_dointvec
,
366 .procname
= "sched_time_avg_ms",
367 .data
= &sysctl_sched_time_avg
,
368 .maxlen
= sizeof(unsigned int),
370 .proc_handler
= proc_dointvec_minmax
,
373 #ifdef CONFIG_SCHEDSTATS
375 .procname
= "sched_schedstats",
377 .maxlen
= sizeof(unsigned int),
379 .proc_handler
= sysctl_schedstats
,
383 #endif /* CONFIG_SCHEDSTATS */
384 #endif /* CONFIG_SMP */
385 #ifdef CONFIG_NUMA_BALANCING
387 .procname
= "numa_balancing_scan_delay_ms",
388 .data
= &sysctl_numa_balancing_scan_delay
,
389 .maxlen
= sizeof(unsigned int),
391 .proc_handler
= proc_dointvec
,
394 .procname
= "numa_balancing_scan_period_min_ms",
395 .data
= &sysctl_numa_balancing_scan_period_min
,
396 .maxlen
= sizeof(unsigned int),
398 .proc_handler
= proc_dointvec
,
401 .procname
= "numa_balancing_scan_period_max_ms",
402 .data
= &sysctl_numa_balancing_scan_period_max
,
403 .maxlen
= sizeof(unsigned int),
405 .proc_handler
= proc_dointvec
,
408 .procname
= "numa_balancing_scan_size_mb",
409 .data
= &sysctl_numa_balancing_scan_size
,
410 .maxlen
= sizeof(unsigned int),
412 .proc_handler
= proc_dointvec_minmax
,
416 .procname
= "numa_balancing",
417 .data
= NULL
, /* filled in by handler */
418 .maxlen
= sizeof(unsigned int),
420 .proc_handler
= sysctl_numa_balancing
,
424 #endif /* CONFIG_NUMA_BALANCING */
425 #endif /* CONFIG_SCHED_DEBUG */
427 .procname
= "sched_rt_period_us",
428 .data
= &sysctl_sched_rt_period
,
429 .maxlen
= sizeof(unsigned int),
431 .proc_handler
= sched_rt_handler
,
434 .procname
= "sched_rt_runtime_us",
435 .data
= &sysctl_sched_rt_runtime
,
436 .maxlen
= sizeof(int),
438 .proc_handler
= sched_rt_handler
,
441 .procname
= "sched_rr_timeslice_ms",
442 .data
= &sysctl_sched_rr_timeslice
,
443 .maxlen
= sizeof(int),
445 .proc_handler
= sched_rr_handler
,
447 #ifdef CONFIG_SCHED_AUTOGROUP
449 .procname
= "sched_autogroup_enabled",
450 .data
= &sysctl_sched_autogroup_enabled
,
451 .maxlen
= sizeof(unsigned int),
453 .proc_handler
= proc_dointvec_minmax
,
458 #ifdef CONFIG_CFS_BANDWIDTH
460 .procname
= "sched_cfs_bandwidth_slice_us",
461 .data
= &sysctl_sched_cfs_bandwidth_slice
,
462 .maxlen
= sizeof(unsigned int),
464 .proc_handler
= proc_dointvec_minmax
,
468 #ifdef CONFIG_PROVE_LOCKING
470 .procname
= "prove_locking",
471 .data
= &prove_locking
,
472 .maxlen
= sizeof(int),
474 .proc_handler
= proc_dointvec
,
477 #ifdef CONFIG_LOCK_STAT
479 .procname
= "lock_stat",
481 .maxlen
= sizeof(int),
483 .proc_handler
= proc_dointvec
,
488 .data
= &panic_timeout
,
489 .maxlen
= sizeof(int),
491 .proc_handler
= proc_dointvec
,
493 #ifdef CONFIG_COREDUMP
495 .procname
= "core_uses_pid",
496 .data
= &core_uses_pid
,
497 .maxlen
= sizeof(int),
499 .proc_handler
= proc_dointvec
,
502 .procname
= "core_pattern",
503 .data
= core_pattern
,
504 .maxlen
= CORENAME_MAX_SIZE
,
506 .proc_handler
= proc_dostring_coredump
,
509 .procname
= "core_pipe_limit",
510 .data
= &core_pipe_limit
,
511 .maxlen
= sizeof(unsigned int),
513 .proc_handler
= proc_dointvec
,
516 #ifdef CONFIG_PROC_SYSCTL
518 .procname
= "tainted",
519 .maxlen
= sizeof(long),
521 .proc_handler
= proc_taint
,
524 .procname
= "sysctl_writes_strict",
525 .data
= &sysctl_writes_strict
,
526 .maxlen
= sizeof(int),
528 .proc_handler
= proc_dointvec_minmax
,
533 #ifdef CONFIG_LATENCYTOP
535 .procname
= "latencytop",
536 .data
= &latencytop_enabled
,
537 .maxlen
= sizeof(int),
539 .proc_handler
= sysctl_latencytop
,
542 #ifdef CONFIG_BLK_DEV_INITRD
544 .procname
= "real-root-dev",
545 .data
= &real_root_dev
,
546 .maxlen
= sizeof(int),
548 .proc_handler
= proc_dointvec
,
552 .procname
= "print-fatal-signals",
553 .data
= &print_fatal_signals
,
554 .maxlen
= sizeof(int),
556 .proc_handler
= proc_dointvec
,
560 .procname
= "reboot-cmd",
561 .data
= reboot_command
,
564 .proc_handler
= proc_dostring
,
567 .procname
= "stop-a",
568 .data
= &stop_a_enabled
,
569 .maxlen
= sizeof (int),
571 .proc_handler
= proc_dointvec
,
574 .procname
= "scons-poweroff",
575 .data
= &scons_pwroff
,
576 .maxlen
= sizeof (int),
578 .proc_handler
= proc_dointvec
,
581 #ifdef CONFIG_SPARC64
583 .procname
= "tsb-ratio",
584 .data
= &sysctl_tsb_ratio
,
585 .maxlen
= sizeof (int),
587 .proc_handler
= proc_dointvec
,
592 .procname
= "soft-power",
593 .data
= &pwrsw_enabled
,
594 .maxlen
= sizeof (int),
596 .proc_handler
= proc_dointvec
,
599 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
601 .procname
= "unaligned-trap",
602 .data
= &unaligned_enabled
,
603 .maxlen
= sizeof (int),
605 .proc_handler
= proc_dointvec
,
609 .procname
= "ctrl-alt-del",
611 .maxlen
= sizeof(int),
613 .proc_handler
= proc_dointvec
,
615 #ifdef CONFIG_FUNCTION_TRACER
617 .procname
= "ftrace_enabled",
618 .data
= &ftrace_enabled
,
619 .maxlen
= sizeof(int),
621 .proc_handler
= ftrace_enable_sysctl
,
624 #ifdef CONFIG_STACK_TRACER
626 .procname
= "stack_tracer_enabled",
627 .data
= &stack_tracer_enabled
,
628 .maxlen
= sizeof(int),
630 .proc_handler
= stack_trace_sysctl
,
633 #ifdef CONFIG_TRACING
635 .procname
= "ftrace_dump_on_oops",
636 .data
= &ftrace_dump_on_oops
,
637 .maxlen
= sizeof(int),
639 .proc_handler
= proc_dointvec
,
642 .procname
= "traceoff_on_warning",
643 .data
= &__disable_trace_on_warning
,
644 .maxlen
= sizeof(__disable_trace_on_warning
),
646 .proc_handler
= proc_dointvec
,
649 .procname
= "tracepoint_printk",
650 .data
= &tracepoint_printk
,
651 .maxlen
= sizeof(tracepoint_printk
),
653 .proc_handler
= tracepoint_printk_sysctl
,
656 #ifdef CONFIG_KEXEC_CORE
658 .procname
= "kexec_load_disabled",
659 .data
= &kexec_load_disabled
,
660 .maxlen
= sizeof(int),
662 /* only handle a transition from default "0" to "1" */
663 .proc_handler
= proc_dointvec_minmax
,
668 #ifdef CONFIG_MODULES
670 .procname
= "modprobe",
671 .data
= &modprobe_path
,
672 .maxlen
= KMOD_PATH_LEN
,
674 .proc_handler
= proc_dostring
,
677 .procname
= "modules_disabled",
678 .data
= &modules_disabled
,
679 .maxlen
= sizeof(int),
681 /* only handle a transition from default "0" to "1" */
682 .proc_handler
= proc_dointvec_minmax
,
687 #ifdef CONFIG_UEVENT_HELPER
689 .procname
= "hotplug",
690 .data
= &uevent_helper
,
691 .maxlen
= UEVENT_HELPER_PATH_LEN
,
693 .proc_handler
= proc_dostring
,
696 #ifdef CONFIG_CHR_DEV_SG
698 .procname
= "sg-big-buff",
699 .data
= &sg_big_buff
,
700 .maxlen
= sizeof (int),
702 .proc_handler
= proc_dointvec
,
705 #ifdef CONFIG_BSD_PROCESS_ACCT
709 .maxlen
= 3*sizeof(int),
711 .proc_handler
= proc_dointvec
,
714 #ifdef CONFIG_MAGIC_SYSRQ
717 .data
= &__sysrq_enabled
,
718 .maxlen
= sizeof (int),
720 .proc_handler
= sysrq_sysctl_handler
,
723 #ifdef CONFIG_PROC_SYSCTL
725 .procname
= "cad_pid",
727 .maxlen
= sizeof (int),
729 .proc_handler
= proc_do_cad_pid
,
733 .procname
= "threads-max",
735 .maxlen
= sizeof(int),
737 .proc_handler
= sysctl_max_threads
,
740 .procname
= "random",
742 .child
= random_table
,
745 .procname
= "usermodehelper",
747 .child
= usermodehelper_table
,
750 .procname
= "overflowuid",
751 .data
= &overflowuid
,
752 .maxlen
= sizeof(int),
754 .proc_handler
= proc_dointvec_minmax
,
755 .extra1
= &minolduid
,
756 .extra2
= &maxolduid
,
759 .procname
= "overflowgid",
760 .data
= &overflowgid
,
761 .maxlen
= sizeof(int),
763 .proc_handler
= proc_dointvec_minmax
,
764 .extra1
= &minolduid
,
765 .extra2
= &maxolduid
,
768 #ifdef CONFIG_MATHEMU
770 .procname
= "ieee_emulation_warnings",
771 .data
= &sysctl_ieee_emulation_warnings
,
772 .maxlen
= sizeof(int),
774 .proc_handler
= proc_dointvec
,
778 .procname
= "userprocess_debug",
779 .data
= &show_unhandled_signals
,
780 .maxlen
= sizeof(int),
782 .proc_handler
= proc_dointvec
,
786 .procname
= "pid_max",
788 .maxlen
= sizeof (int),
790 .proc_handler
= proc_dointvec_minmax
,
791 .extra1
= &pid_max_min
,
792 .extra2
= &pid_max_max
,
795 .procname
= "panic_on_oops",
796 .data
= &panic_on_oops
,
797 .maxlen
= sizeof(int),
799 .proc_handler
= proc_dointvec
,
801 #if defined CONFIG_PRINTK
803 .procname
= "printk",
804 .data
= &console_loglevel
,
805 .maxlen
= 4*sizeof(int),
807 .proc_handler
= proc_dointvec
,
810 .procname
= "printk_ratelimit",
811 .data
= &printk_ratelimit_state
.interval
,
812 .maxlen
= sizeof(int),
814 .proc_handler
= proc_dointvec_jiffies
,
817 .procname
= "printk_ratelimit_burst",
818 .data
= &printk_ratelimit_state
.burst
,
819 .maxlen
= sizeof(int),
821 .proc_handler
= proc_dointvec
,
824 .procname
= "printk_delay",
825 .data
= &printk_delay_msec
,
826 .maxlen
= sizeof(int),
828 .proc_handler
= proc_dointvec_minmax
,
830 .extra2
= &ten_thousand
,
833 .procname
= "printk_devkmsg",
834 .data
= devkmsg_log_str
,
835 .maxlen
= DEVKMSG_STR_MAX_SIZE
,
837 .proc_handler
= devkmsg_sysctl_set_loglvl
,
840 .procname
= "dmesg_restrict",
841 .data
= &dmesg_restrict
,
842 .maxlen
= sizeof(int),
844 .proc_handler
= proc_dointvec_minmax_sysadmin
,
849 .procname
= "kptr_restrict",
850 .data
= &kptr_restrict
,
851 .maxlen
= sizeof(int),
853 .proc_handler
= proc_dointvec_minmax_sysadmin
,
859 .procname
= "ngroups_max",
860 .data
= &ngroups_max
,
861 .maxlen
= sizeof (int),
863 .proc_handler
= proc_dointvec
,
866 .procname
= "cap_last_cap",
867 .data
= (void *)&cap_last_cap
,
868 .maxlen
= sizeof(int),
870 .proc_handler
= proc_dointvec
,
872 #if defined(CONFIG_LOCKUP_DETECTOR)
874 .procname
= "watchdog",
875 .data
= &watchdog_user_enabled
,
876 .maxlen
= sizeof (int),
878 .proc_handler
= proc_watchdog
,
883 .procname
= "watchdog_thresh",
884 .data
= &watchdog_thresh
,
885 .maxlen
= sizeof(int),
887 .proc_handler
= proc_watchdog_thresh
,
892 .procname
= "nmi_watchdog",
893 .data
= &nmi_watchdog_enabled
,
894 .maxlen
= sizeof (int),
896 .proc_handler
= proc_nmi_watchdog
,
898 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
905 .procname
= "watchdog_cpumask",
906 .data
= &watchdog_cpumask_bits
,
909 .proc_handler
= proc_watchdog_cpumask
,
911 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
913 .procname
= "soft_watchdog",
914 .data
= &soft_watchdog_enabled
,
915 .maxlen
= sizeof (int),
917 .proc_handler
= proc_soft_watchdog
,
922 .procname
= "softlockup_panic",
923 .data
= &softlockup_panic
,
924 .maxlen
= sizeof(int),
926 .proc_handler
= proc_dointvec_minmax
,
932 .procname
= "softlockup_all_cpu_backtrace",
933 .data
= &sysctl_softlockup_all_cpu_backtrace
,
934 .maxlen
= sizeof(int),
936 .proc_handler
= proc_dointvec_minmax
,
940 #endif /* CONFIG_SMP */
942 #ifdef CONFIG_HARDLOCKUP_DETECTOR
944 .procname
= "hardlockup_panic",
945 .data
= &hardlockup_panic
,
946 .maxlen
= sizeof(int),
948 .proc_handler
= proc_dointvec_minmax
,
954 .procname
= "hardlockup_all_cpu_backtrace",
955 .data
= &sysctl_hardlockup_all_cpu_backtrace
,
956 .maxlen
= sizeof(int),
958 .proc_handler
= proc_dointvec_minmax
,
962 #endif /* CONFIG_SMP */
966 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
968 .procname
= "unknown_nmi_panic",
969 .data
= &unknown_nmi_panic
,
970 .maxlen
= sizeof (int),
972 .proc_handler
= proc_dointvec
,
975 #if defined(CONFIG_X86)
977 .procname
= "panic_on_unrecovered_nmi",
978 .data
= &panic_on_unrecovered_nmi
,
979 .maxlen
= sizeof(int),
981 .proc_handler
= proc_dointvec
,
984 .procname
= "panic_on_io_nmi",
985 .data
= &panic_on_io_nmi
,
986 .maxlen
= sizeof(int),
988 .proc_handler
= proc_dointvec
,
990 #ifdef CONFIG_DEBUG_STACKOVERFLOW
992 .procname
= "panic_on_stackoverflow",
993 .data
= &sysctl_panic_on_stackoverflow
,
994 .maxlen
= sizeof(int),
996 .proc_handler
= proc_dointvec
,
1000 .procname
= "bootloader_type",
1001 .data
= &bootloader_type
,
1002 .maxlen
= sizeof (int),
1004 .proc_handler
= proc_dointvec
,
1007 .procname
= "bootloader_version",
1008 .data
= &bootloader_version
,
1009 .maxlen
= sizeof (int),
1011 .proc_handler
= proc_dointvec
,
1014 .procname
= "io_delay_type",
1015 .data
= &io_delay_type
,
1016 .maxlen
= sizeof(int),
1018 .proc_handler
= proc_dointvec
,
1021 #if defined(CONFIG_MMU)
1023 .procname
= "randomize_va_space",
1024 .data
= &randomize_va_space
,
1025 .maxlen
= sizeof(int),
1027 .proc_handler
= proc_dointvec
,
1030 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1032 .procname
= "spin_retry",
1033 .data
= &spin_retry
,
1034 .maxlen
= sizeof (int),
1036 .proc_handler
= proc_dointvec
,
1039 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1041 .procname
= "acpi_video_flags",
1042 .data
= &acpi_realmode_flags
,
1043 .maxlen
= sizeof (unsigned long),
1045 .proc_handler
= proc_doulongvec_minmax
,
1048 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1050 .procname
= "ignore-unaligned-usertrap",
1051 .data
= &no_unaligned_warning
,
1052 .maxlen
= sizeof (int),
1054 .proc_handler
= proc_dointvec
,
1059 .procname
= "unaligned-dump-stack",
1060 .data
= &unaligned_dump_stack
,
1061 .maxlen
= sizeof (int),
1063 .proc_handler
= proc_dointvec
,
1066 #ifdef CONFIG_DETECT_HUNG_TASK
1068 .procname
= "hung_task_panic",
1069 .data
= &sysctl_hung_task_panic
,
1070 .maxlen
= sizeof(int),
1072 .proc_handler
= proc_dointvec_minmax
,
1077 .procname
= "hung_task_check_count",
1078 .data
= &sysctl_hung_task_check_count
,
1079 .maxlen
= sizeof(int),
1081 .proc_handler
= proc_dointvec_minmax
,
1085 .procname
= "hung_task_timeout_secs",
1086 .data
= &sysctl_hung_task_timeout_secs
,
1087 .maxlen
= sizeof(unsigned long),
1089 .proc_handler
= proc_dohung_task_timeout_secs
,
1090 .extra2
= &hung_task_timeout_max
,
1093 .procname
= "hung_task_warnings",
1094 .data
= &sysctl_hung_task_warnings
,
1095 .maxlen
= sizeof(int),
1097 .proc_handler
= proc_dointvec_minmax
,
1101 #ifdef CONFIG_RT_MUTEXES
1103 .procname
= "max_lock_depth",
1104 .data
= &max_lock_depth
,
1105 .maxlen
= sizeof(int),
1107 .proc_handler
= proc_dointvec
,
1111 .procname
= "poweroff_cmd",
1112 .data
= &poweroff_cmd
,
1113 .maxlen
= POWEROFF_CMD_PATH_LEN
,
1115 .proc_handler
= proc_dostring
,
1121 .child
= key_sysctls
,
1124 #ifdef CONFIG_PERF_EVENTS
1126 * User-space scripts rely on the existence of this file
1127 * as a feature check for perf_events being enabled.
1129 * So it's an ABI, do not remove!
1132 .procname
= "perf_event_paranoid",
1133 .data
= &sysctl_perf_event_paranoid
,
1134 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
1136 .proc_handler
= proc_dointvec
,
1139 .procname
= "perf_event_mlock_kb",
1140 .data
= &sysctl_perf_event_mlock
,
1141 .maxlen
= sizeof(sysctl_perf_event_mlock
),
1143 .proc_handler
= proc_dointvec
,
1146 .procname
= "perf_event_max_sample_rate",
1147 .data
= &sysctl_perf_event_sample_rate
,
1148 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1150 .proc_handler
= perf_proc_update_handler
,
1154 .procname
= "perf_cpu_time_max_percent",
1155 .data
= &sysctl_perf_cpu_time_max_percent
,
1156 .maxlen
= sizeof(sysctl_perf_cpu_time_max_percent
),
1158 .proc_handler
= perf_cpu_time_max_percent_handler
,
1160 .extra2
= &one_hundred
,
1163 .procname
= "perf_event_max_stack",
1164 .data
= &sysctl_perf_event_max_stack
,
1165 .maxlen
= sizeof(sysctl_perf_event_max_stack
),
1167 .proc_handler
= perf_event_max_stack_handler
,
1169 .extra2
= &six_hundred_forty_kb
,
1172 .procname
= "perf_event_max_contexts_per_stack",
1173 .data
= &sysctl_perf_event_max_contexts_per_stack
,
1174 .maxlen
= sizeof(sysctl_perf_event_max_contexts_per_stack
),
1176 .proc_handler
= perf_event_max_stack_handler
,
1178 .extra2
= &one_thousand
,
1181 #ifdef CONFIG_KMEMCHECK
1183 .procname
= "kmemcheck",
1184 .data
= &kmemcheck_enabled
,
1185 .maxlen
= sizeof(int),
1187 .proc_handler
= proc_dointvec
,
1191 .procname
= "panic_on_warn",
1192 .data
= &panic_on_warn
,
1193 .maxlen
= sizeof(int),
1195 .proc_handler
= proc_dointvec_minmax
,
1199 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1201 .procname
= "timer_migration",
1202 .data
= &sysctl_timer_migration
,
1203 .maxlen
= sizeof(unsigned int),
1205 .proc_handler
= timer_migration_handler
,
1210 #ifdef CONFIG_BPF_SYSCALL
1212 .procname
= "unprivileged_bpf_disabled",
1213 .data
= &sysctl_unprivileged_bpf_disabled
,
1214 .maxlen
= sizeof(sysctl_unprivileged_bpf_disabled
),
1216 /* only handle a transition from default "0" to "1" */
1217 .proc_handler
= proc_dointvec_minmax
,
1222 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1224 .procname
= "panic_on_rcu_stall",
1225 .data
= &sysctl_panic_on_rcu_stall
,
1226 .maxlen
= sizeof(sysctl_panic_on_rcu_stall
),
1228 .proc_handler
= proc_dointvec_minmax
,
1236 static struct ctl_table vm_table
[] = {
1238 .procname
= "overcommit_memory",
1239 .data
= &sysctl_overcommit_memory
,
1240 .maxlen
= sizeof(sysctl_overcommit_memory
),
1242 .proc_handler
= proc_dointvec_minmax
,
1247 .procname
= "panic_on_oom",
1248 .data
= &sysctl_panic_on_oom
,
1249 .maxlen
= sizeof(sysctl_panic_on_oom
),
1251 .proc_handler
= proc_dointvec_minmax
,
1256 .procname
= "oom_kill_allocating_task",
1257 .data
= &sysctl_oom_kill_allocating_task
,
1258 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
1260 .proc_handler
= proc_dointvec
,
1263 .procname
= "oom_dump_tasks",
1264 .data
= &sysctl_oom_dump_tasks
,
1265 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
1267 .proc_handler
= proc_dointvec
,
1270 .procname
= "overcommit_ratio",
1271 .data
= &sysctl_overcommit_ratio
,
1272 .maxlen
= sizeof(sysctl_overcommit_ratio
),
1274 .proc_handler
= overcommit_ratio_handler
,
1277 .procname
= "overcommit_kbytes",
1278 .data
= &sysctl_overcommit_kbytes
,
1279 .maxlen
= sizeof(sysctl_overcommit_kbytes
),
1281 .proc_handler
= overcommit_kbytes_handler
,
1284 .procname
= "page-cluster",
1285 .data
= &page_cluster
,
1286 .maxlen
= sizeof(int),
1288 .proc_handler
= proc_dointvec_minmax
,
1292 .procname
= "dirty_background_ratio",
1293 .data
= &dirty_background_ratio
,
1294 .maxlen
= sizeof(dirty_background_ratio
),
1296 .proc_handler
= dirty_background_ratio_handler
,
1298 .extra2
= &one_hundred
,
1301 .procname
= "dirty_background_bytes",
1302 .data
= &dirty_background_bytes
,
1303 .maxlen
= sizeof(dirty_background_bytes
),
1305 .proc_handler
= dirty_background_bytes_handler
,
1309 .procname
= "dirty_ratio",
1310 .data
= &vm_dirty_ratio
,
1311 .maxlen
= sizeof(vm_dirty_ratio
),
1313 .proc_handler
= dirty_ratio_handler
,
1315 .extra2
= &one_hundred
,
1318 .procname
= "dirty_bytes",
1319 .data
= &vm_dirty_bytes
,
1320 .maxlen
= sizeof(vm_dirty_bytes
),
1322 .proc_handler
= dirty_bytes_handler
,
1323 .extra1
= &dirty_bytes_min
,
1326 .procname
= "dirty_writeback_centisecs",
1327 .data
= &dirty_writeback_interval
,
1328 .maxlen
= sizeof(dirty_writeback_interval
),
1330 .proc_handler
= dirty_writeback_centisecs_handler
,
1333 .procname
= "dirty_expire_centisecs",
1334 .data
= &dirty_expire_interval
,
1335 .maxlen
= sizeof(dirty_expire_interval
),
1337 .proc_handler
= proc_dointvec_minmax
,
1341 .procname
= "dirtytime_expire_seconds",
1342 .data
= &dirtytime_expire_interval
,
1343 .maxlen
= sizeof(dirty_expire_interval
),
1345 .proc_handler
= dirtytime_interval_handler
,
1349 .procname
= "nr_pdflush_threads",
1350 .mode
= 0444 /* read-only */,
1351 .proc_handler
= pdflush_proc_obsolete
,
1354 .procname
= "swappiness",
1355 .data
= &vm_swappiness
,
1356 .maxlen
= sizeof(vm_swappiness
),
1358 .proc_handler
= proc_dointvec_minmax
,
1360 .extra2
= &one_hundred
,
1362 #ifdef CONFIG_HUGETLB_PAGE
1364 .procname
= "nr_hugepages",
1366 .maxlen
= sizeof(unsigned long),
1368 .proc_handler
= hugetlb_sysctl_handler
,
1372 .procname
= "nr_hugepages_mempolicy",
1374 .maxlen
= sizeof(unsigned long),
1376 .proc_handler
= &hugetlb_mempolicy_sysctl_handler
,
1380 .procname
= "hugetlb_shm_group",
1381 .data
= &sysctl_hugetlb_shm_group
,
1382 .maxlen
= sizeof(gid_t
),
1384 .proc_handler
= proc_dointvec
,
1387 .procname
= "hugepages_treat_as_movable",
1388 .data
= &hugepages_treat_as_movable
,
1389 .maxlen
= sizeof(int),
1391 .proc_handler
= proc_dointvec
,
1394 .procname
= "nr_overcommit_hugepages",
1396 .maxlen
= sizeof(unsigned long),
1398 .proc_handler
= hugetlb_overcommit_handler
,
1402 .procname
= "lowmem_reserve_ratio",
1403 .data
= &sysctl_lowmem_reserve_ratio
,
1404 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
1406 .proc_handler
= lowmem_reserve_ratio_sysctl_handler
,
1409 .procname
= "drop_caches",
1410 .data
= &sysctl_drop_caches
,
1411 .maxlen
= sizeof(int),
1413 .proc_handler
= drop_caches_sysctl_handler
,
1417 #ifdef CONFIG_COMPACTION
1419 .procname
= "compact_memory",
1420 .data
= &sysctl_compact_memory
,
1421 .maxlen
= sizeof(int),
1423 .proc_handler
= sysctl_compaction_handler
,
1426 .procname
= "extfrag_threshold",
1427 .data
= &sysctl_extfrag_threshold
,
1428 .maxlen
= sizeof(int),
1430 .proc_handler
= sysctl_extfrag_handler
,
1431 .extra1
= &min_extfrag_threshold
,
1432 .extra2
= &max_extfrag_threshold
,
1435 .procname
= "compact_unevictable_allowed",
1436 .data
= &sysctl_compact_unevictable_allowed
,
1437 .maxlen
= sizeof(int),
1439 .proc_handler
= proc_dointvec
,
1444 #endif /* CONFIG_COMPACTION */
1446 .procname
= "min_free_kbytes",
1447 .data
= &min_free_kbytes
,
1448 .maxlen
= sizeof(min_free_kbytes
),
1450 .proc_handler
= min_free_kbytes_sysctl_handler
,
1454 .procname
= "watermark_scale_factor",
1455 .data
= &watermark_scale_factor
,
1456 .maxlen
= sizeof(watermark_scale_factor
),
1458 .proc_handler
= watermark_scale_factor_sysctl_handler
,
1460 .extra2
= &one_thousand
,
1463 .procname
= "percpu_pagelist_fraction",
1464 .data
= &percpu_pagelist_fraction
,
1465 .maxlen
= sizeof(percpu_pagelist_fraction
),
1467 .proc_handler
= percpu_pagelist_fraction_sysctl_handler
,
1472 .procname
= "max_map_count",
1473 .data
= &sysctl_max_map_count
,
1474 .maxlen
= sizeof(sysctl_max_map_count
),
1476 .proc_handler
= proc_dointvec_minmax
,
1481 .procname
= "nr_trim_pages",
1482 .data
= &sysctl_nr_trim_pages
,
1483 .maxlen
= sizeof(sysctl_nr_trim_pages
),
1485 .proc_handler
= proc_dointvec_minmax
,
1490 .procname
= "laptop_mode",
1491 .data
= &laptop_mode
,
1492 .maxlen
= sizeof(laptop_mode
),
1494 .proc_handler
= proc_dointvec_jiffies
,
1497 .procname
= "block_dump",
1498 .data
= &block_dump
,
1499 .maxlen
= sizeof(block_dump
),
1501 .proc_handler
= proc_dointvec
,
1505 .procname
= "vfs_cache_pressure",
1506 .data
= &sysctl_vfs_cache_pressure
,
1507 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1509 .proc_handler
= proc_dointvec
,
1512 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1514 .procname
= "legacy_va_layout",
1515 .data
= &sysctl_legacy_va_layout
,
1516 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1518 .proc_handler
= proc_dointvec
,
1524 .procname
= "zone_reclaim_mode",
1525 .data
= &node_reclaim_mode
,
1526 .maxlen
= sizeof(node_reclaim_mode
),
1528 .proc_handler
= proc_dointvec
,
1532 .procname
= "min_unmapped_ratio",
1533 .data
= &sysctl_min_unmapped_ratio
,
1534 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1536 .proc_handler
= sysctl_min_unmapped_ratio_sysctl_handler
,
1538 .extra2
= &one_hundred
,
1541 .procname
= "min_slab_ratio",
1542 .data
= &sysctl_min_slab_ratio
,
1543 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1545 .proc_handler
= sysctl_min_slab_ratio_sysctl_handler
,
1547 .extra2
= &one_hundred
,
1552 .procname
= "stat_interval",
1553 .data
= &sysctl_stat_interval
,
1554 .maxlen
= sizeof(sysctl_stat_interval
),
1556 .proc_handler
= proc_dointvec_jiffies
,
1559 .procname
= "stat_refresh",
1563 .proc_handler
= vmstat_refresh
,
1568 .procname
= "mmap_min_addr",
1569 .data
= &dac_mmap_min_addr
,
1570 .maxlen
= sizeof(unsigned long),
1572 .proc_handler
= mmap_min_addr_handler
,
1577 .procname
= "numa_zonelist_order",
1578 .data
= &numa_zonelist_order
,
1579 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1581 .proc_handler
= numa_zonelist_order_handler
,
1584 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1585 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1587 .procname
= "vdso_enabled",
1588 #ifdef CONFIG_X86_32
1589 .data
= &vdso32_enabled
,
1590 .maxlen
= sizeof(vdso32_enabled
),
1592 .data
= &vdso_enabled
,
1593 .maxlen
= sizeof(vdso_enabled
),
1596 .proc_handler
= proc_dointvec
,
1600 #ifdef CONFIG_HIGHMEM
1602 .procname
= "highmem_is_dirtyable",
1603 .data
= &vm_highmem_is_dirtyable
,
1604 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
1606 .proc_handler
= proc_dointvec_minmax
,
1611 #ifdef CONFIG_MEMORY_FAILURE
1613 .procname
= "memory_failure_early_kill",
1614 .data
= &sysctl_memory_failure_early_kill
,
1615 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
1617 .proc_handler
= proc_dointvec_minmax
,
1622 .procname
= "memory_failure_recovery",
1623 .data
= &sysctl_memory_failure_recovery
,
1624 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
1626 .proc_handler
= proc_dointvec_minmax
,
1632 .procname
= "user_reserve_kbytes",
1633 .data
= &sysctl_user_reserve_kbytes
,
1634 .maxlen
= sizeof(sysctl_user_reserve_kbytes
),
1636 .proc_handler
= proc_doulongvec_minmax
,
1639 .procname
= "admin_reserve_kbytes",
1640 .data
= &sysctl_admin_reserve_kbytes
,
1641 .maxlen
= sizeof(sysctl_admin_reserve_kbytes
),
1643 .proc_handler
= proc_doulongvec_minmax
,
1645 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1647 .procname
= "mmap_rnd_bits",
1648 .data
= &mmap_rnd_bits
,
1649 .maxlen
= sizeof(mmap_rnd_bits
),
1651 .proc_handler
= proc_dointvec_minmax
,
1652 .extra1
= (void *)&mmap_rnd_bits_min
,
1653 .extra2
= (void *)&mmap_rnd_bits_max
,
1656 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1658 .procname
= "mmap_rnd_compat_bits",
1659 .data
= &mmap_rnd_compat_bits
,
1660 .maxlen
= sizeof(mmap_rnd_compat_bits
),
1662 .proc_handler
= proc_dointvec_minmax
,
1663 .extra1
= (void *)&mmap_rnd_compat_bits_min
,
1664 .extra2
= (void *)&mmap_rnd_compat_bits_max
,
1670 static struct ctl_table fs_table
[] = {
1672 .procname
= "inode-nr",
1673 .data
= &inodes_stat
,
1674 .maxlen
= 2*sizeof(long),
1676 .proc_handler
= proc_nr_inodes
,
1679 .procname
= "inode-state",
1680 .data
= &inodes_stat
,
1681 .maxlen
= 7*sizeof(long),
1683 .proc_handler
= proc_nr_inodes
,
1686 .procname
= "file-nr",
1687 .data
= &files_stat
,
1688 .maxlen
= sizeof(files_stat
),
1690 .proc_handler
= proc_nr_files
,
1693 .procname
= "file-max",
1694 .data
= &files_stat
.max_files
,
1695 .maxlen
= sizeof(files_stat
.max_files
),
1697 .proc_handler
= proc_doulongvec_minmax
,
1700 .procname
= "nr_open",
1701 .data
= &sysctl_nr_open
,
1702 .maxlen
= sizeof(unsigned int),
1704 .proc_handler
= proc_dointvec_minmax
,
1705 .extra1
= &sysctl_nr_open_min
,
1706 .extra2
= &sysctl_nr_open_max
,
1709 .procname
= "dentry-state",
1710 .data
= &dentry_stat
,
1711 .maxlen
= 6*sizeof(long),
1713 .proc_handler
= proc_nr_dentry
,
1716 .procname
= "overflowuid",
1717 .data
= &fs_overflowuid
,
1718 .maxlen
= sizeof(int),
1720 .proc_handler
= proc_dointvec_minmax
,
1721 .extra1
= &minolduid
,
1722 .extra2
= &maxolduid
,
1725 .procname
= "overflowgid",
1726 .data
= &fs_overflowgid
,
1727 .maxlen
= sizeof(int),
1729 .proc_handler
= proc_dointvec_minmax
,
1730 .extra1
= &minolduid
,
1731 .extra2
= &maxolduid
,
1733 #ifdef CONFIG_FILE_LOCKING
1735 .procname
= "leases-enable",
1736 .data
= &leases_enable
,
1737 .maxlen
= sizeof(int),
1739 .proc_handler
= proc_dointvec
,
1742 #ifdef CONFIG_DNOTIFY
1744 .procname
= "dir-notify-enable",
1745 .data
= &dir_notify_enable
,
1746 .maxlen
= sizeof(int),
1748 .proc_handler
= proc_dointvec
,
1752 #ifdef CONFIG_FILE_LOCKING
1754 .procname
= "lease-break-time",
1755 .data
= &lease_break_time
,
1756 .maxlen
= sizeof(int),
1758 .proc_handler
= proc_dointvec
,
1763 .procname
= "aio-nr",
1765 .maxlen
= sizeof(aio_nr
),
1767 .proc_handler
= proc_doulongvec_minmax
,
1770 .procname
= "aio-max-nr",
1771 .data
= &aio_max_nr
,
1772 .maxlen
= sizeof(aio_max_nr
),
1774 .proc_handler
= proc_doulongvec_minmax
,
1776 #endif /* CONFIG_AIO */
1777 #ifdef CONFIG_INOTIFY_USER
1779 .procname
= "inotify",
1781 .child
= inotify_table
,
1786 .procname
= "epoll",
1788 .child
= epoll_table
,
1793 .procname
= "protected_symlinks",
1794 .data
= &sysctl_protected_symlinks
,
1795 .maxlen
= sizeof(int),
1797 .proc_handler
= proc_dointvec_minmax
,
1802 .procname
= "protected_hardlinks",
1803 .data
= &sysctl_protected_hardlinks
,
1804 .maxlen
= sizeof(int),
1806 .proc_handler
= proc_dointvec_minmax
,
1811 .procname
= "suid_dumpable",
1812 .data
= &suid_dumpable
,
1813 .maxlen
= sizeof(int),
1815 .proc_handler
= proc_dointvec_minmax_coredump
,
1819 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1821 .procname
= "binfmt_misc",
1823 .child
= sysctl_mount_point
,
1827 .procname
= "pipe-max-size",
1828 .data
= &pipe_max_size
,
1829 .maxlen
= sizeof(int),
1831 .proc_handler
= &pipe_proc_fn
,
1832 .extra1
= &pipe_min_size
,
1835 .procname
= "pipe-user-pages-hard",
1836 .data
= &pipe_user_pages_hard
,
1837 .maxlen
= sizeof(pipe_user_pages_hard
),
1839 .proc_handler
= proc_doulongvec_minmax
,
1842 .procname
= "pipe-user-pages-soft",
1843 .data
= &pipe_user_pages_soft
,
1844 .maxlen
= sizeof(pipe_user_pages_soft
),
1846 .proc_handler
= proc_doulongvec_minmax
,
1849 .procname
= "mount-max",
1850 .data
= &sysctl_mount_max
,
1851 .maxlen
= sizeof(unsigned int),
1853 .proc_handler
= proc_dointvec_minmax
,
1859 static struct ctl_table debug_table
[] = {
1860 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1862 .procname
= "exception-trace",
1863 .data
= &show_unhandled_signals
,
1864 .maxlen
= sizeof(int),
1866 .proc_handler
= proc_dointvec
1869 #if defined(CONFIG_OPTPROBES)
1871 .procname
= "kprobes-optimization",
1872 .data
= &sysctl_kprobes_optimization
,
1873 .maxlen
= sizeof(int),
1875 .proc_handler
= proc_kprobes_optimization_handler
,
1883 static struct ctl_table dev_table
[] = {
1887 int __init
sysctl_init(void)
1889 struct ctl_table_header
*hdr
;
1891 hdr
= register_sysctl_table(sysctl_base_table
);
1892 kmemleak_not_leak(hdr
);
1896 #endif /* CONFIG_SYSCTL */
1902 #ifdef CONFIG_PROC_SYSCTL
1904 static int _proc_do_string(char *data
, int maxlen
, int write
,
1905 char __user
*buffer
,
1906 size_t *lenp
, loff_t
*ppos
)
1912 if (!data
|| !maxlen
|| !*lenp
) {
1918 if (sysctl_writes_strict
== SYSCTL_WRITES_STRICT
) {
1919 /* Only continue writes not past the end of buffer. */
1921 if (len
> maxlen
- 1)
1928 /* Start writing from beginning of buffer. */
1934 while ((p
- buffer
) < *lenp
&& len
< maxlen
- 1) {
1935 if (get_user(c
, p
++))
1937 if (c
== 0 || c
== '\n')
1958 if (copy_to_user(buffer
, data
, len
))
1961 if (put_user('\n', buffer
+ len
))
1971 static void warn_sysctl_write(struct ctl_table
*table
)
1973 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1974 "This will not be supported in the future. To silence this\n"
1975 "warning, set kernel.sysctl_writes_strict = -1\n",
1976 current
->comm
, table
->procname
);
1980 * proc_first_pos_non_zero_ignore - check if firs position is allowed
1981 * @ppos: file position
1982 * @table: the sysctl table
1984 * Returns true if the first position is non-zero and the sysctl_writes_strict
1985 * mode indicates this is not allowed for numeric input types. String proc
1986 * hadlers can ignore the return value.
1988 static bool proc_first_pos_non_zero_ignore(loff_t
*ppos
,
1989 struct ctl_table
*table
)
1994 switch (sysctl_writes_strict
) {
1995 case SYSCTL_WRITES_STRICT
:
1997 case SYSCTL_WRITES_WARN
:
1998 warn_sysctl_write(table
);
2006 * proc_dostring - read a string sysctl
2007 * @table: the sysctl table
2008 * @write: %TRUE if this is a write to the sysctl file
2009 * @buffer: the user buffer
2010 * @lenp: the size of the user buffer
2011 * @ppos: file position
2013 * Reads/writes a string from/to the user buffer. If the kernel
2014 * buffer provided is not large enough to hold the string, the
2015 * string is truncated. The copied string is %NULL-terminated.
2016 * If the string is being read by the user process, it is copied
2017 * and a newline '\n' is added. It is truncated if the buffer is
2020 * Returns 0 on success.
2022 int proc_dostring(struct ctl_table
*table
, int write
,
2023 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2026 proc_first_pos_non_zero_ignore(ppos
, table
);
2028 return _proc_do_string((char *)(table
->data
), table
->maxlen
, write
,
2029 (char __user
*)buffer
, lenp
, ppos
);
2032 static size_t proc_skip_spaces(char **buf
)
2035 char *tmp
= skip_spaces(*buf
);
2041 static void proc_skip_char(char **buf
, size_t *size
, const char v
)
2051 #define TMPBUFLEN 22
2053 * proc_get_long - reads an ASCII formatted integer from a user buffer
2055 * @buf: a kernel buffer
2056 * @size: size of the kernel buffer
2057 * @val: this is where the number will be stored
2058 * @neg: set to %TRUE if number is negative
2059 * @perm_tr: a vector which contains the allowed trailers
2060 * @perm_tr_len: size of the perm_tr vector
2061 * @tr: pointer to store the trailer character
2063 * In case of success %0 is returned and @buf and @size are updated with
2064 * the amount of bytes read. If @tr is non-NULL and a trailing
2065 * character exists (size is non-zero after returning from this
2066 * function), @tr is updated with the trailing character.
2068 static int proc_get_long(char **buf
, size_t *size
,
2069 unsigned long *val
, bool *neg
,
2070 const char *perm_tr
, unsigned perm_tr_len
, char *tr
)
2073 char *p
, tmp
[TMPBUFLEN
];
2079 if (len
> TMPBUFLEN
- 1)
2080 len
= TMPBUFLEN
- 1;
2082 memcpy(tmp
, *buf
, len
);
2086 if (*p
== '-' && *size
> 1) {
2094 *val
= simple_strtoul(p
, &p
, 0);
2098 /* We don't know if the next char is whitespace thus we may accept
2099 * invalid integers (e.g. 1234...a) or two integers instead of one
2100 * (e.g. 123...1). So lets not allow such large numbers. */
2101 if (len
== TMPBUFLEN
- 1)
2104 if (len
< *size
&& perm_tr_len
&& !memchr(perm_tr
, *p
, perm_tr_len
))
2107 if (tr
&& (len
< *size
))
2117 * proc_put_long - converts an integer to a decimal ASCII formatted string
2119 * @buf: the user buffer
2120 * @size: the size of the user buffer
2121 * @val: the integer to be converted
2122 * @neg: sign of the number, %TRUE for negative
2124 * In case of success %0 is returned and @buf and @size are updated with
2125 * the amount of bytes written.
2127 static int proc_put_long(void __user
**buf
, size_t *size
, unsigned long val
,
2131 char tmp
[TMPBUFLEN
], *p
= tmp
;
2133 sprintf(p
, "%s%lu", neg
? "-" : "", val
);
2137 if (copy_to_user(*buf
, tmp
, len
))
2145 static int proc_put_char(void __user
**buf
, size_t *size
, char c
)
2148 char __user
**buffer
= (char __user
**)buf
;
2149 if (put_user(c
, *buffer
))
2151 (*size
)--, (*buffer
)++;
2157 static int do_proc_dointvec_conv(bool *negp
, unsigned long *lvalp
,
2159 int write
, void *data
)
2163 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2167 if (*lvalp
> (unsigned long) INT_MAX
)
2175 *lvalp
= -(unsigned long)val
;
2178 *lvalp
= (unsigned long)val
;
2184 static int do_proc_douintvec_conv(unsigned long *lvalp
,
2186 int write
, void *data
)
2189 if (*lvalp
> UINT_MAX
)
2193 unsigned int val
= *valp
;
2194 *lvalp
= (unsigned long)val
;
2199 static const char proc_wspace_sep
[] = { ' ', '\t', '\n' };
2201 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2202 int write
, void __user
*buffer
,
2203 size_t *lenp
, loff_t
*ppos
,
2204 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2205 int write
, void *data
),
2208 int *i
, vleft
, first
= 1, err
= 0;
2210 char *kbuf
= NULL
, *p
;
2212 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2217 i
= (int *) tbl_data
;
2218 vleft
= table
->maxlen
/ sizeof(*i
);
2222 conv
= do_proc_dointvec_conv
;
2225 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2228 if (left
> PAGE_SIZE
- 1)
2229 left
= PAGE_SIZE
- 1;
2230 p
= kbuf
= memdup_user_nul(buffer
, left
);
2232 return PTR_ERR(kbuf
);
2235 for (; left
&& vleft
--; i
++, first
=0) {
2240 left
-= proc_skip_spaces(&p
);
2244 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2246 sizeof(proc_wspace_sep
), NULL
);
2249 if (conv(&neg
, &lval
, i
, 1, data
)) {
2254 if (conv(&neg
, &lval
, i
, 0, data
)) {
2259 err
= proc_put_char(&buffer
, &left
, '\t');
2262 err
= proc_put_long(&buffer
, &left
, lval
, neg
);
2268 if (!write
&& !first
&& left
&& !err
)
2269 err
= proc_put_char(&buffer
, &left
, '\n');
2270 if (write
&& !err
&& left
)
2271 left
-= proc_skip_spaces(&p
);
2275 return err
? : -EINVAL
;
2283 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2284 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2285 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2286 int write
, void *data
),
2289 return __do_proc_dointvec(table
->data
, table
, write
,
2290 buffer
, lenp
, ppos
, conv
, data
);
2293 static int do_proc_douintvec_w(unsigned int *tbl_data
,
2294 struct ctl_table
*table
,
2295 void __user
*buffer
,
2296 size_t *lenp
, loff_t
*ppos
,
2297 int (*conv
)(unsigned long *lvalp
,
2299 int write
, void *data
),
2306 char *kbuf
= NULL
, *p
;
2310 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2313 if (left
> PAGE_SIZE
- 1)
2314 left
= PAGE_SIZE
- 1;
2316 p
= kbuf
= memdup_user_nul(buffer
, left
);
2320 left
-= proc_skip_spaces(&p
);
2326 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2328 sizeof(proc_wspace_sep
), NULL
);
2334 if (conv(&lval
, tbl_data
, 1, data
)) {
2340 left
-= proc_skip_spaces(&p
);
2349 /* This is in keeping with old __do_proc_dointvec() */
2355 static int do_proc_douintvec_r(unsigned int *tbl_data
, void __user
*buffer
,
2356 size_t *lenp
, loff_t
*ppos
,
2357 int (*conv
)(unsigned long *lvalp
,
2359 int write
, void *data
),
2368 if (conv(&lval
, tbl_data
, 0, data
)) {
2373 err
= proc_put_long(&buffer
, &left
, lval
, false);
2377 err
= proc_put_char(&buffer
, &left
, '\n');
2386 static int __do_proc_douintvec(void *tbl_data
, struct ctl_table
*table
,
2387 int write
, void __user
*buffer
,
2388 size_t *lenp
, loff_t
*ppos
,
2389 int (*conv
)(unsigned long *lvalp
,
2391 int write
, void *data
),
2394 unsigned int *i
, vleft
;
2396 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2401 i
= (unsigned int *) tbl_data
;
2402 vleft
= table
->maxlen
/ sizeof(*i
);
2405 * Arrays are not supported, keep this simple. *Do not* add
2414 conv
= do_proc_douintvec_conv
;
2417 return do_proc_douintvec_w(i
, table
, buffer
, lenp
, ppos
,
2419 return do_proc_douintvec_r(i
, buffer
, lenp
, ppos
, conv
, data
);
2422 static int do_proc_douintvec(struct ctl_table
*table
, int write
,
2423 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2424 int (*conv
)(unsigned long *lvalp
,
2426 int write
, void *data
),
2429 return __do_proc_douintvec(table
->data
, table
, write
,
2430 buffer
, lenp
, ppos
, conv
, data
);
2434 * proc_dointvec - read a vector of integers
2435 * @table: the sysctl table
2436 * @write: %TRUE if this is a write to the sysctl file
2437 * @buffer: the user buffer
2438 * @lenp: the size of the user buffer
2439 * @ppos: file position
2441 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2442 * values from/to the user buffer, treated as an ASCII string.
2444 * Returns 0 on success.
2446 int proc_dointvec(struct ctl_table
*table
, int write
,
2447 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2449 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
, NULL
, NULL
);
2453 * proc_douintvec - read a vector of unsigned integers
2454 * @table: the sysctl table
2455 * @write: %TRUE if this is a write to the sysctl file
2456 * @buffer: the user buffer
2457 * @lenp: the size of the user buffer
2458 * @ppos: file position
2460 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2461 * values from/to the user buffer, treated as an ASCII string.
2463 * Returns 0 on success.
2465 int proc_douintvec(struct ctl_table
*table
, int write
,
2466 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2468 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2469 do_proc_douintvec_conv
, NULL
);
2473 * Taint values can only be increased
2474 * This means we can safely use a temporary.
2476 static int proc_taint(struct ctl_table
*table
, int write
,
2477 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2480 unsigned long tmptaint
= get_taint();
2483 if (write
&& !capable(CAP_SYS_ADMIN
))
2488 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2494 * Poor man's atomic or. Not worth adding a primitive
2495 * to everyone's atomic.h for this
2498 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2499 if ((tmptaint
>> i
) & 1)
2500 add_taint(i
, LOCKDEP_STILL_OK
);
2507 #ifdef CONFIG_PRINTK
2508 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
2509 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2511 if (write
&& !capable(CAP_SYS_ADMIN
))
2514 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2518 struct do_proc_dointvec_minmax_conv_param
{
2523 static int do_proc_dointvec_minmax_conv(bool *negp
, unsigned long *lvalp
,
2525 int write
, void *data
)
2527 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2529 int val
= *negp
? -*lvalp
: *lvalp
;
2530 if ((param
->min
&& *param
->min
> val
) ||
2531 (param
->max
&& *param
->max
< val
))
2538 *lvalp
= -(unsigned long)val
;
2541 *lvalp
= (unsigned long)val
;
2548 * proc_dointvec_minmax - read a vector of integers with min/max values
2549 * @table: the sysctl table
2550 * @write: %TRUE if this is a write to the sysctl file
2551 * @buffer: the user buffer
2552 * @lenp: the size of the user buffer
2553 * @ppos: file position
2555 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2556 * values from/to the user buffer, treated as an ASCII string.
2558 * This routine will ensure the values are within the range specified by
2559 * table->extra1 (min) and table->extra2 (max).
2561 * Returns 0 on success.
2563 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2564 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2566 struct do_proc_dointvec_minmax_conv_param param
= {
2567 .min
= (int *) table
->extra1
,
2568 .max
= (int *) table
->extra2
,
2570 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2571 do_proc_dointvec_minmax_conv
, ¶m
);
2574 struct do_proc_douintvec_minmax_conv_param
{
2579 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp
,
2581 int write
, void *data
)
2583 struct do_proc_douintvec_minmax_conv_param
*param
= data
;
2586 unsigned int val
= *lvalp
;
2588 if ((param
->min
&& *param
->min
> val
) ||
2589 (param
->max
&& *param
->max
< val
))
2592 if (*lvalp
> UINT_MAX
)
2596 unsigned int val
= *valp
;
2597 *lvalp
= (unsigned long) val
;
2604 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2605 * @table: the sysctl table
2606 * @write: %TRUE if this is a write to the sysctl file
2607 * @buffer: the user buffer
2608 * @lenp: the size of the user buffer
2609 * @ppos: file position
2611 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2612 * values from/to the user buffer, treated as an ASCII string. Negative
2613 * strings are not allowed.
2615 * This routine will ensure the values are within the range specified by
2616 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2617 * check for UINT_MAX to avoid having to support wrap around uses from
2620 * Returns 0 on success.
2622 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
2623 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2625 struct do_proc_douintvec_minmax_conv_param param
= {
2626 .min
= (unsigned int *) table
->extra1
,
2627 .max
= (unsigned int *) table
->extra2
,
2629 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2630 do_proc_douintvec_minmax_conv
, ¶m
);
2633 static void validate_coredump_safety(void)
2635 #ifdef CONFIG_COREDUMP
2636 if (suid_dumpable
== SUID_DUMP_ROOT
&&
2637 core_pattern
[0] != '/' && core_pattern
[0] != '|') {
2639 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2640 "Pipe handler or fully qualified core dump path required.\n"
2641 "Set kernel.core_pattern before fs.suid_dumpable.\n"
2647 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
2648 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2650 int error
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2652 validate_coredump_safety();
2656 #ifdef CONFIG_COREDUMP
2657 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
2658 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2660 int error
= proc_dostring(table
, write
, buffer
, lenp
, ppos
);
2662 validate_coredump_safety();
2667 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2668 void __user
*buffer
,
2669 size_t *lenp
, loff_t
*ppos
,
2670 unsigned long convmul
,
2671 unsigned long convdiv
)
2673 unsigned long *i
, *min
, *max
;
2674 int vleft
, first
= 1, err
= 0;
2676 char *kbuf
= NULL
, *p
;
2678 if (!data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2683 i
= (unsigned long *) data
;
2684 min
= (unsigned long *) table
->extra1
;
2685 max
= (unsigned long *) table
->extra2
;
2686 vleft
= table
->maxlen
/ sizeof(unsigned long);
2690 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2693 if (left
> PAGE_SIZE
- 1)
2694 left
= PAGE_SIZE
- 1;
2695 p
= kbuf
= memdup_user_nul(buffer
, left
);
2697 return PTR_ERR(kbuf
);
2700 for (; left
&& vleft
--; i
++, first
= 0) {
2706 left
-= proc_skip_spaces(&p
);
2708 err
= proc_get_long(&p
, &left
, &val
, &neg
,
2710 sizeof(proc_wspace_sep
), NULL
);
2715 val
= convmul
* val
/ convdiv
;
2716 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2720 val
= convdiv
* (*i
) / convmul
;
2722 err
= proc_put_char(&buffer
, &left
, '\t');
2726 err
= proc_put_long(&buffer
, &left
, val
, false);
2732 if (!write
&& !first
&& left
&& !err
)
2733 err
= proc_put_char(&buffer
, &left
, '\n');
2735 left
-= proc_skip_spaces(&p
);
2739 return err
? : -EINVAL
;
2747 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2748 void __user
*buffer
,
2749 size_t *lenp
, loff_t
*ppos
,
2750 unsigned long convmul
,
2751 unsigned long convdiv
)
2753 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2754 buffer
, lenp
, ppos
, convmul
, convdiv
);
2758 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2759 * @table: the sysctl table
2760 * @write: %TRUE if this is a write to the sysctl file
2761 * @buffer: the user buffer
2762 * @lenp: the size of the user buffer
2763 * @ppos: file position
2765 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2766 * values from/to the user buffer, treated as an ASCII string.
2768 * This routine will ensure the values are within the range specified by
2769 * table->extra1 (min) and table->extra2 (max).
2771 * Returns 0 on success.
2773 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2774 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2776 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2780 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2781 * @table: the sysctl table
2782 * @write: %TRUE if this is a write to the sysctl file
2783 * @buffer: the user buffer
2784 * @lenp: the size of the user buffer
2785 * @ppos: file position
2787 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2788 * values from/to the user buffer, treated as an ASCII string. The values
2789 * are treated as milliseconds, and converted to jiffies when they are stored.
2791 * This routine will ensure the values are within the range specified by
2792 * table->extra1 (min) and table->extra2 (max).
2794 * Returns 0 on success.
2796 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2797 void __user
*buffer
,
2798 size_t *lenp
, loff_t
*ppos
)
2800 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2801 lenp
, ppos
, HZ
, 1000l);
2805 static int do_proc_dointvec_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2807 int write
, void *data
)
2810 if (*lvalp
> INT_MAX
/ HZ
)
2812 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2818 lval
= -(unsigned long)val
;
2821 lval
= (unsigned long)val
;
2828 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2830 int write
, void *data
)
2833 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2835 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2841 lval
= -(unsigned long)val
;
2844 lval
= (unsigned long)val
;
2846 *lvalp
= jiffies_to_clock_t(lval
);
2851 static int do_proc_dointvec_ms_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2853 int write
, void *data
)
2856 unsigned long jif
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2866 lval
= -(unsigned long)val
;
2869 lval
= (unsigned long)val
;
2871 *lvalp
= jiffies_to_msecs(lval
);
2877 * proc_dointvec_jiffies - read a vector of integers as seconds
2878 * @table: the sysctl table
2879 * @write: %TRUE if this is a write to the sysctl file
2880 * @buffer: the user buffer
2881 * @lenp: the size of the user buffer
2882 * @ppos: file position
2884 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2885 * values from/to the user buffer, treated as an ASCII string.
2886 * The values read are assumed to be in seconds, and are converted into
2889 * Returns 0 on success.
2891 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2892 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2894 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2895 do_proc_dointvec_jiffies_conv
,NULL
);
2899 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2900 * @table: the sysctl table
2901 * @write: %TRUE if this is a write to the sysctl file
2902 * @buffer: the user buffer
2903 * @lenp: the size of the user buffer
2904 * @ppos: pointer to the file position
2906 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2907 * values from/to the user buffer, treated as an ASCII string.
2908 * The values read are assumed to be in 1/USER_HZ seconds, and
2909 * are converted into jiffies.
2911 * Returns 0 on success.
2913 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2914 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2916 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2917 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2921 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2922 * @table: the sysctl table
2923 * @write: %TRUE if this is a write to the sysctl file
2924 * @buffer: the user buffer
2925 * @lenp: the size of the user buffer
2926 * @ppos: file position
2927 * @ppos: the current position in the file
2929 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2930 * values from/to the user buffer, treated as an ASCII string.
2931 * The values read are assumed to be in 1/1000 seconds, and
2932 * are converted into jiffies.
2934 * Returns 0 on success.
2936 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2937 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2939 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2940 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2943 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
2944 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2946 struct pid
*new_pid
;
2950 tmp
= pid_vnr(cad_pid
);
2952 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
2953 lenp
, ppos
, NULL
, NULL
);
2957 new_pid
= find_get_pid(tmp
);
2961 put_pid(xchg(&cad_pid
, new_pid
));
2966 * proc_do_large_bitmap - read/write from/to a large bitmap
2967 * @table: the sysctl table
2968 * @write: %TRUE if this is a write to the sysctl file
2969 * @buffer: the user buffer
2970 * @lenp: the size of the user buffer
2971 * @ppos: file position
2973 * The bitmap is stored at table->data and the bitmap length (in bits)
2976 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2977 * large bitmaps may be represented in a compact manner. Writing into
2978 * the file will clear the bitmap then update it with the given input.
2980 * Returns 0 on success.
2982 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
2983 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2987 size_t left
= *lenp
;
2988 unsigned long bitmap_len
= table
->maxlen
;
2989 unsigned long *bitmap
= *(unsigned long **) table
->data
;
2990 unsigned long *tmp_bitmap
= NULL
;
2991 char tr_a
[] = { '-', ',', '\n' }, tr_b
[] = { ',', '\n', 0 }, c
;
2993 if (!bitmap
|| !bitmap_len
|| !left
|| (*ppos
&& !write
)) {
3001 if (left
> PAGE_SIZE
- 1)
3002 left
= PAGE_SIZE
- 1;
3004 p
= kbuf
= memdup_user_nul(buffer
, left
);
3006 return PTR_ERR(kbuf
);
3008 tmp_bitmap
= kzalloc(BITS_TO_LONGS(bitmap_len
) * sizeof(unsigned long),
3014 proc_skip_char(&p
, &left
, '\n');
3015 while (!err
&& left
) {
3016 unsigned long val_a
, val_b
;
3019 err
= proc_get_long(&p
, &left
, &val_a
, &neg
, tr_a
,
3023 if (val_a
>= bitmap_len
|| neg
) {
3035 err
= proc_get_long(&p
, &left
, &val_b
,
3036 &neg
, tr_b
, sizeof(tr_b
),
3040 if (val_b
>= bitmap_len
|| neg
||
3051 bitmap_set(tmp_bitmap
, val_a
, val_b
- val_a
+ 1);
3053 proc_skip_char(&p
, &left
, '\n');
3057 unsigned long bit_a
, bit_b
= 0;
3060 bit_a
= find_next_bit(bitmap
, bitmap_len
, bit_b
);
3061 if (bit_a
>= bitmap_len
)
3063 bit_b
= find_next_zero_bit(bitmap
, bitmap_len
,
3067 err
= proc_put_char(&buffer
, &left
, ',');
3071 err
= proc_put_long(&buffer
, &left
, bit_a
, false);
3074 if (bit_a
!= bit_b
) {
3075 err
= proc_put_char(&buffer
, &left
, '-');
3078 err
= proc_put_long(&buffer
, &left
, bit_b
, false);
3086 err
= proc_put_char(&buffer
, &left
, '\n');
3092 bitmap_or(bitmap
, bitmap
, tmp_bitmap
, bitmap_len
);
3094 bitmap_copy(bitmap
, tmp_bitmap
, bitmap_len
);
3106 #else /* CONFIG_PROC_SYSCTL */
3108 int proc_dostring(struct ctl_table
*table
, int write
,
3109 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3114 int proc_dointvec(struct ctl_table
*table
, int write
,
3115 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3120 int proc_douintvec(struct ctl_table
*table
, int write
,
3121 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3126 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
3127 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3132 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
3133 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3138 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
3139 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3144 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
3145 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3150 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
3151 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3156 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
3157 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3162 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
3163 void __user
*buffer
,
3164 size_t *lenp
, loff_t
*ppos
)
3170 #endif /* CONFIG_PROC_SYSCTL */
3173 * No sense putting this after each symbol definition, twice,
3174 * exception granted :-)
3176 EXPORT_SYMBOL(proc_dointvec
);
3177 EXPORT_SYMBOL(proc_douintvec
);
3178 EXPORT_SYMBOL(proc_dointvec_jiffies
);
3179 EXPORT_SYMBOL(proc_dointvec_minmax
);
3180 EXPORT_SYMBOL_GPL(proc_douintvec_minmax
);
3181 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
3182 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
3183 EXPORT_SYMBOL(proc_dostring
);
3184 EXPORT_SYMBOL(proc_doulongvec_minmax
);
3185 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);