2 * sysctl.c: General linux system control interface
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
21 #include <linux/module.h>
22 #include <linux/aio.h>
24 #include <linux/swap.h>
25 #include <linux/slab.h>
26 #include <linux/sysctl.h>
27 #include <linux/bitmap.h>
28 #include <linux/signal.h>
29 #include <linux/printk.h>
30 #include <linux/proc_fs.h>
31 #include <linux/security.h>
32 #include <linux/ctype.h>
33 #include <linux/kmemleak.h>
35 #include <linux/init.h>
36 #include <linux/kernel.h>
37 #include <linux/kobject.h>
38 #include <linux/net.h>
39 #include <linux/sysrq.h>
40 #include <linux/highuid.h>
41 #include <linux/writeback.h>
42 #include <linux/ratelimit.h>
43 #include <linux/compaction.h>
44 #include <linux/hugetlb.h>
45 #include <linux/initrd.h>
46 #include <linux/key.h>
47 #include <linux/times.h>
48 #include <linux/limits.h>
49 #include <linux/dcache.h>
50 #include <linux/dnotify.h>
51 #include <linux/syscalls.h>
52 #include <linux/vmstat.h>
53 #include <linux/nfs_fs.h>
54 #include <linux/acpi.h>
55 #include <linux/reboot.h>
56 #include <linux/ftrace.h>
57 #include <linux/perf_event.h>
58 #include <linux/kprobes.h>
59 #include <linux/pipe_fs_i.h>
60 #include <linux/oom.h>
61 #include <linux/kmod.h>
62 #include <linux/capability.h>
63 #include <linux/binfmts.h>
64 #include <linux/sched/sysctl.h>
65 #include <linux/sched/coredump.h>
66 #include <linux/kexec.h>
67 #include <linux/bpf.h>
68 #include <linux/mount.h>
70 #include <linux/uaccess.h>
71 #include <asm/processor.h>
75 #include <asm/stacktrace.h>
79 #include <asm/setup.h>
81 #ifdef CONFIG_BSD_PROCESS_ACCT
82 #include <linux/acct.h>
84 #ifdef CONFIG_RT_MUTEXES
85 #include <linux/rtmutex.h>
87 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
88 #include <linux/lockdep.h>
90 #ifdef CONFIG_CHR_DEV_SG
94 #ifdef CONFIG_LOCKUP_DETECTOR
95 #include <linux/nmi.h>
98 #if defined(CONFIG_SYSCTL)
100 /* External variables not in a header file. */
102 int deny_new_usb __read_mostly
= 0;
103 EXPORT_SYMBOL(deny_new_usb
);
105 extern int suid_dumpable
;
106 #ifdef CONFIG_COREDUMP
107 extern int core_uses_pid
;
108 extern char core_pattern
[];
109 extern unsigned int core_pipe_limit
;
112 extern int extra_free_kbytes
;
113 extern int pid_max_min
, pid_max_max
;
114 extern int percpu_pagelist_fraction
;
115 extern int latencytop_enabled
;
116 extern unsigned int sysctl_nr_open_min
, sysctl_nr_open_max
;
118 extern int sysctl_nr_trim_pages
;
121 /* Constants used for minimum and maximum */
122 #ifdef CONFIG_LOCKUP_DETECTOR
123 static int sixty
= 60;
126 static int __maybe_unused neg_one
= -1;
129 static int __maybe_unused one
= 1;
130 static int __maybe_unused two
= 2;
131 static int __maybe_unused four
= 4;
132 static unsigned long one_ul
= 1;
133 static unsigned long long_max
= LONG_MAX
;
134 static int one_hundred
= 100;
135 static int one_thousand
= 1000;
137 static int ten_thousand
= 10000;
139 #ifdef CONFIG_PERF_EVENTS
140 static int six_hundred_forty_kb
= 640 * 1024;
143 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
144 static unsigned long dirty_bytes_min
= 2 * PAGE_SIZE
;
146 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
147 static int maxolduid
= 65535;
148 static int minolduid
;
150 static int ngroups_max
= NGROUPS_MAX
;
151 static const int cap_last_cap
= CAP_LAST_CAP
;
153 /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
154 #ifdef CONFIG_DETECT_HUNG_TASK
155 static unsigned long hung_task_timeout_max
= (LONG_MAX
/HZ
);
158 #ifdef CONFIG_INOTIFY_USER
159 #include <linux/inotify.h>
165 extern int pwrsw_enabled
;
168 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
169 extern int unaligned_enabled
;
173 extern int unaligned_dump_stack
;
176 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
177 extern int no_unaligned_warning
;
180 #ifdef CONFIG_PROC_SYSCTL
183 * enum sysctl_writes_mode - supported sysctl write modes
185 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
186 * to be written, and multiple writes on the same sysctl file descriptor
187 * will rewrite the sysctl value, regardless of file position. No warning
188 * is issued when the initial position is not 0.
189 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
191 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
192 * file position 0 and the value must be fully contained in the buffer
193 * sent to the write syscall. If dealing with strings respect the file
194 * position, but restrict this to the max length of the buffer, anything
195 * passed the max lenght will be ignored. Multiple writes will append
198 * These write modes control how current file position affects the behavior of
199 * updating sysctl values through the proc interface on each write.
201 enum sysctl_writes_mode
{
202 SYSCTL_WRITES_LEGACY
= -1,
203 SYSCTL_WRITES_WARN
= 0,
204 SYSCTL_WRITES_STRICT
= 1,
207 static enum sysctl_writes_mode sysctl_writes_strict
= SYSCTL_WRITES_STRICT
;
209 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
210 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
211 static int proc_taint(struct ctl_table
*table
, int write
,
212 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
216 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
217 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
220 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
221 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
222 #ifdef CONFIG_COREDUMP
223 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
224 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
227 #ifdef CONFIG_MAGIC_SYSRQ
228 /* Note: sysrq code uses it's own private copy */
229 static int __sysrq_enabled
= CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE
;
231 static int sysrq_sysctl_handler(struct ctl_table
*table
, int write
,
232 void __user
*buffer
, size_t *lenp
,
237 error
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
242 sysrq_toggle_support(__sysrq_enabled
);
249 static struct ctl_table kern_table
[];
250 static struct ctl_table vm_table
[];
251 static struct ctl_table fs_table
[];
252 static struct ctl_table debug_table
[];
253 static struct ctl_table dev_table
[];
254 extern struct ctl_table random_table
[];
256 extern struct ctl_table epoll_table
[];
259 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
260 int sysctl_legacy_va_layout
;
263 /* The default sysctl tables: */
265 static struct ctl_table sysctl_base_table
[] = {
267 .procname
= "kernel",
284 .child
= debug_table
,
294 #ifdef CONFIG_SCHED_DEBUG
295 static int min_sched_granularity_ns
= 100000; /* 100 usecs */
296 static int max_sched_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
297 static int min_wakeup_granularity_ns
; /* 0 usecs */
298 static int max_wakeup_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
300 static int min_sched_tunable_scaling
= SCHED_TUNABLESCALING_NONE
;
301 static int max_sched_tunable_scaling
= SCHED_TUNABLESCALING_END
-1;
302 #endif /* CONFIG_SMP */
303 #endif /* CONFIG_SCHED_DEBUG */
305 #ifdef CONFIG_COMPACTION
306 static int min_extfrag_threshold
;
307 static int max_extfrag_threshold
= 1000;
310 static struct ctl_table kern_table
[] = {
312 .procname
= "sched_child_runs_first",
313 .data
= &sysctl_sched_child_runs_first
,
314 .maxlen
= sizeof(unsigned int),
316 .proc_handler
= proc_dointvec
,
318 #ifdef CONFIG_SCHED_DEBUG
320 .procname
= "sched_min_granularity_ns",
321 .data
= &sysctl_sched_min_granularity
,
322 .maxlen
= sizeof(unsigned int),
324 .proc_handler
= sched_proc_update_handler
,
325 .extra1
= &min_sched_granularity_ns
,
326 .extra2
= &max_sched_granularity_ns
,
329 .procname
= "sched_latency_ns",
330 .data
= &sysctl_sched_latency
,
331 .maxlen
= sizeof(unsigned int),
333 .proc_handler
= sched_proc_update_handler
,
334 .extra1
= &min_sched_granularity_ns
,
335 .extra2
= &max_sched_granularity_ns
,
337 #ifdef CONFIG_SCHED_WALT
339 .procname
= "sched_use_walt_cpu_util",
340 .data
= &sysctl_sched_use_walt_cpu_util
,
341 .maxlen
= sizeof(unsigned int),
343 .proc_handler
= proc_dointvec
,
346 .procname
= "sched_use_walt_task_util",
347 .data
= &sysctl_sched_use_walt_task_util
,
348 .maxlen
= sizeof(unsigned int),
350 .proc_handler
= proc_dointvec
,
353 .procname
= "sched_walt_init_task_load_pct",
354 .data
= &sysctl_sched_walt_init_task_load_pct
,
355 .maxlen
= sizeof(unsigned int),
357 .proc_handler
= proc_dointvec
,
360 .procname
= "sched_walt_cpu_high_irqload",
361 .data
= &sysctl_sched_walt_cpu_high_irqload
,
362 .maxlen
= sizeof(unsigned int),
364 .proc_handler
= proc_dointvec
,
368 .procname
= "sched_sync_hint_enable",
369 .data
= &sysctl_sched_sync_hint_enable
,
370 .maxlen
= sizeof(unsigned int),
372 .proc_handler
= proc_dointvec
,
375 .procname
= "sched_cstate_aware",
376 .data
= &sysctl_sched_cstate_aware
,
377 .maxlen
= sizeof(unsigned int),
379 .proc_handler
= proc_dointvec
,
382 .procname
= "sched_wakeup_granularity_ns",
383 .data
= &sysctl_sched_wakeup_granularity
,
384 .maxlen
= sizeof(unsigned int),
386 .proc_handler
= sched_proc_update_handler
,
387 .extra1
= &min_wakeup_granularity_ns
,
388 .extra2
= &max_wakeup_granularity_ns
,
392 .procname
= "sched_tunable_scaling",
393 .data
= &sysctl_sched_tunable_scaling
,
394 .maxlen
= sizeof(enum sched_tunable_scaling
),
396 .proc_handler
= sched_proc_update_handler
,
397 .extra1
= &min_sched_tunable_scaling
,
398 .extra2
= &max_sched_tunable_scaling
,
401 .procname
= "sched_migration_cost_ns",
402 .data
= &sysctl_sched_migration_cost
,
403 .maxlen
= sizeof(unsigned int),
405 .proc_handler
= proc_dointvec
,
408 .procname
= "sched_nr_migrate",
409 .data
= &sysctl_sched_nr_migrate
,
410 .maxlen
= sizeof(unsigned int),
412 .proc_handler
= proc_dointvec
,
415 .procname
= "sched_time_avg_ms",
416 .data
= &sysctl_sched_time_avg
,
417 .maxlen
= sizeof(unsigned int),
419 .proc_handler
= proc_dointvec_minmax
,
422 #ifdef CONFIG_SCHEDSTATS
424 .procname
= "sched_schedstats",
426 .maxlen
= sizeof(unsigned int),
428 .proc_handler
= sysctl_schedstats
,
432 #endif /* CONFIG_SCHEDSTATS */
433 #endif /* CONFIG_SMP */
434 #ifdef CONFIG_NUMA_BALANCING
436 .procname
= "numa_balancing_scan_delay_ms",
437 .data
= &sysctl_numa_balancing_scan_delay
,
438 .maxlen
= sizeof(unsigned int),
440 .proc_handler
= proc_dointvec
,
443 .procname
= "numa_balancing_scan_period_min_ms",
444 .data
= &sysctl_numa_balancing_scan_period_min
,
445 .maxlen
= sizeof(unsigned int),
447 .proc_handler
= proc_dointvec
,
450 .procname
= "numa_balancing_scan_period_max_ms",
451 .data
= &sysctl_numa_balancing_scan_period_max
,
452 .maxlen
= sizeof(unsigned int),
454 .proc_handler
= proc_dointvec
,
457 .procname
= "numa_balancing_scan_size_mb",
458 .data
= &sysctl_numa_balancing_scan_size
,
459 .maxlen
= sizeof(unsigned int),
461 .proc_handler
= proc_dointvec_minmax
,
465 .procname
= "numa_balancing",
466 .data
= NULL
, /* filled in by handler */
467 .maxlen
= sizeof(unsigned int),
469 .proc_handler
= sysctl_numa_balancing
,
473 #endif /* CONFIG_NUMA_BALANCING */
474 #endif /* CONFIG_SCHED_DEBUG */
476 .procname
= "sched_rt_period_us",
477 .data
= &sysctl_sched_rt_period
,
478 .maxlen
= sizeof(unsigned int),
480 .proc_handler
= sched_rt_handler
,
483 .procname
= "sched_rt_runtime_us",
484 .data
= &sysctl_sched_rt_runtime
,
485 .maxlen
= sizeof(int),
487 .proc_handler
= sched_rt_handler
,
490 .procname
= "sched_rr_timeslice_ms",
491 .data
= &sysctl_sched_rr_timeslice
,
492 .maxlen
= sizeof(int),
494 .proc_handler
= sched_rr_handler
,
496 #ifdef CONFIG_SCHED_AUTOGROUP
498 .procname
= "sched_autogroup_enabled",
499 .data
= &sysctl_sched_autogroup_enabled
,
500 .maxlen
= sizeof(unsigned int),
502 .proc_handler
= proc_dointvec_minmax
,
507 #ifdef CONFIG_CFS_BANDWIDTH
509 .procname
= "sched_cfs_bandwidth_slice_us",
510 .data
= &sysctl_sched_cfs_bandwidth_slice
,
511 .maxlen
= sizeof(unsigned int),
513 .proc_handler
= proc_dointvec_minmax
,
517 #ifdef CONFIG_PROVE_LOCKING
519 .procname
= "prove_locking",
520 .data
= &prove_locking
,
521 .maxlen
= sizeof(int),
523 .proc_handler
= proc_dointvec
,
526 #ifdef CONFIG_LOCK_STAT
528 .procname
= "lock_stat",
530 .maxlen
= sizeof(int),
532 .proc_handler
= proc_dointvec
,
537 .data
= &panic_timeout
,
538 .maxlen
= sizeof(int),
540 .proc_handler
= proc_dointvec
,
542 #ifdef CONFIG_COREDUMP
544 .procname
= "core_uses_pid",
545 .data
= &core_uses_pid
,
546 .maxlen
= sizeof(int),
548 .proc_handler
= proc_dointvec
,
551 .procname
= "core_pattern",
552 .data
= core_pattern
,
553 .maxlen
= CORENAME_MAX_SIZE
,
555 .proc_handler
= proc_dostring_coredump
,
558 .procname
= "core_pipe_limit",
559 .data
= &core_pipe_limit
,
560 .maxlen
= sizeof(unsigned int),
562 .proc_handler
= proc_dointvec
,
565 #ifdef CONFIG_PROC_SYSCTL
567 .procname
= "tainted",
568 .maxlen
= sizeof(long),
570 .proc_handler
= proc_taint
,
573 .procname
= "sysctl_writes_strict",
574 .data
= &sysctl_writes_strict
,
575 .maxlen
= sizeof(int),
577 .proc_handler
= proc_dointvec_minmax
,
582 #ifdef CONFIG_LATENCYTOP
584 .procname
= "latencytop",
585 .data
= &latencytop_enabled
,
586 .maxlen
= sizeof(int),
588 .proc_handler
= sysctl_latencytop
,
591 #ifdef CONFIG_BLK_DEV_INITRD
593 .procname
= "real-root-dev",
594 .data
= &real_root_dev
,
595 .maxlen
= sizeof(int),
597 .proc_handler
= proc_dointvec
,
601 .procname
= "print-fatal-signals",
602 .data
= &print_fatal_signals
,
603 .maxlen
= sizeof(int),
605 .proc_handler
= proc_dointvec
,
609 .procname
= "reboot-cmd",
610 .data
= reboot_command
,
613 .proc_handler
= proc_dostring
,
616 .procname
= "stop-a",
617 .data
= &stop_a_enabled
,
618 .maxlen
= sizeof (int),
620 .proc_handler
= proc_dointvec
,
623 .procname
= "scons-poweroff",
624 .data
= &scons_pwroff
,
625 .maxlen
= sizeof (int),
627 .proc_handler
= proc_dointvec
,
630 #ifdef CONFIG_SPARC64
632 .procname
= "tsb-ratio",
633 .data
= &sysctl_tsb_ratio
,
634 .maxlen
= sizeof (int),
636 .proc_handler
= proc_dointvec
,
641 .procname
= "soft-power",
642 .data
= &pwrsw_enabled
,
643 .maxlen
= sizeof (int),
645 .proc_handler
= proc_dointvec
,
648 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
650 .procname
= "unaligned-trap",
651 .data
= &unaligned_enabled
,
652 .maxlen
= sizeof (int),
654 .proc_handler
= proc_dointvec
,
658 .procname
= "ctrl-alt-del",
660 .maxlen
= sizeof(int),
662 .proc_handler
= proc_dointvec
,
664 #ifdef CONFIG_FUNCTION_TRACER
666 .procname
= "ftrace_enabled",
667 .data
= &ftrace_enabled
,
668 .maxlen
= sizeof(int),
670 .proc_handler
= ftrace_enable_sysctl
,
673 #ifdef CONFIG_STACK_TRACER
675 .procname
= "stack_tracer_enabled",
676 .data
= &stack_tracer_enabled
,
677 .maxlen
= sizeof(int),
679 .proc_handler
= stack_trace_sysctl
,
682 #ifdef CONFIG_TRACING
684 .procname
= "ftrace_dump_on_oops",
685 .data
= &ftrace_dump_on_oops
,
686 .maxlen
= sizeof(int),
688 .proc_handler
= proc_dointvec
,
691 .procname
= "traceoff_on_warning",
692 .data
= &__disable_trace_on_warning
,
693 .maxlen
= sizeof(__disable_trace_on_warning
),
695 .proc_handler
= proc_dointvec
,
698 .procname
= "tracepoint_printk",
699 .data
= &tracepoint_printk
,
700 .maxlen
= sizeof(tracepoint_printk
),
702 .proc_handler
= tracepoint_printk_sysctl
,
705 #ifdef CONFIG_KEXEC_CORE
707 .procname
= "kexec_load_disabled",
708 .data
= &kexec_load_disabled
,
709 .maxlen
= sizeof(int),
711 /* only handle a transition from default "0" to "1" */
712 .proc_handler
= proc_dointvec_minmax
,
717 #ifdef CONFIG_MODULES
719 .procname
= "modprobe",
720 .data
= &modprobe_path
,
721 .maxlen
= KMOD_PATH_LEN
,
723 .proc_handler
= proc_dostring
,
726 .procname
= "modules_disabled",
727 .data
= &modules_disabled
,
728 .maxlen
= sizeof(int),
730 /* only handle a transition from default "0" to "1" */
731 .proc_handler
= proc_dointvec_minmax
,
736 #ifdef CONFIG_UEVENT_HELPER
738 .procname
= "hotplug",
739 .data
= &uevent_helper
,
740 .maxlen
= UEVENT_HELPER_PATH_LEN
,
742 .proc_handler
= proc_dostring
,
745 #ifdef CONFIG_CHR_DEV_SG
747 .procname
= "sg-big-buff",
748 .data
= &sg_big_buff
,
749 .maxlen
= sizeof (int),
751 .proc_handler
= proc_dointvec
,
754 #ifdef CONFIG_BSD_PROCESS_ACCT
758 .maxlen
= 3*sizeof(int),
760 .proc_handler
= proc_dointvec
,
763 #ifdef CONFIG_MAGIC_SYSRQ
766 .data
= &__sysrq_enabled
,
767 .maxlen
= sizeof (int),
769 .proc_handler
= sysrq_sysctl_handler
,
772 #ifdef CONFIG_PROC_SYSCTL
774 .procname
= "cad_pid",
776 .maxlen
= sizeof (int),
778 .proc_handler
= proc_do_cad_pid
,
782 .procname
= "threads-max",
784 .maxlen
= sizeof(int),
786 .proc_handler
= sysctl_max_threads
,
789 .procname
= "random",
791 .child
= random_table
,
794 .procname
= "usermodehelper",
796 .child
= usermodehelper_table
,
799 .procname
= "overflowuid",
800 .data
= &overflowuid
,
801 .maxlen
= sizeof(int),
803 .proc_handler
= proc_dointvec_minmax
,
804 .extra1
= &minolduid
,
805 .extra2
= &maxolduid
,
808 .procname
= "overflowgid",
809 .data
= &overflowgid
,
810 .maxlen
= sizeof(int),
812 .proc_handler
= proc_dointvec_minmax
,
813 .extra1
= &minolduid
,
814 .extra2
= &maxolduid
,
817 #ifdef CONFIG_MATHEMU
819 .procname
= "ieee_emulation_warnings",
820 .data
= &sysctl_ieee_emulation_warnings
,
821 .maxlen
= sizeof(int),
823 .proc_handler
= proc_dointvec
,
827 .procname
= "userprocess_debug",
828 .data
= &show_unhandled_signals
,
829 .maxlen
= sizeof(int),
831 .proc_handler
= proc_dointvec
,
835 .procname
= "pid_max",
837 .maxlen
= sizeof (int),
839 .proc_handler
= proc_dointvec_minmax
,
840 .extra1
= &pid_max_min
,
841 .extra2
= &pid_max_max
,
844 .procname
= "panic_on_oops",
845 .data
= &panic_on_oops
,
846 .maxlen
= sizeof(int),
848 .proc_handler
= proc_dointvec
,
850 #if defined CONFIG_PRINTK
852 .procname
= "printk",
853 .data
= &console_loglevel
,
854 .maxlen
= 4*sizeof(int),
856 .proc_handler
= proc_dointvec
,
859 .procname
= "printk_ratelimit",
860 .data
= &printk_ratelimit_state
.interval
,
861 .maxlen
= sizeof(int),
863 .proc_handler
= proc_dointvec_jiffies
,
866 .procname
= "printk_ratelimit_burst",
867 .data
= &printk_ratelimit_state
.burst
,
868 .maxlen
= sizeof(int),
870 .proc_handler
= proc_dointvec
,
873 .procname
= "printk_delay",
874 .data
= &printk_delay_msec
,
875 .maxlen
= sizeof(int),
877 .proc_handler
= proc_dointvec_minmax
,
879 .extra2
= &ten_thousand
,
882 .procname
= "printk_devkmsg",
883 .data
= devkmsg_log_str
,
884 .maxlen
= DEVKMSG_STR_MAX_SIZE
,
886 .proc_handler
= devkmsg_sysctl_set_loglvl
,
889 .procname
= "dmesg_restrict",
890 .data
= &dmesg_restrict
,
891 .maxlen
= sizeof(int),
893 .proc_handler
= proc_dointvec_minmax_sysadmin
,
898 .procname
= "kptr_restrict",
899 .data
= &kptr_restrict
,
900 .maxlen
= sizeof(int),
902 .proc_handler
= proc_dointvec_minmax_sysadmin
,
910 .procname
= "deny_new_usb",
911 .data
= &deny_new_usb
,
912 .maxlen
= sizeof(int),
914 .proc_handler
= proc_dointvec_minmax_sysadmin
,
920 .procname
= "ngroups_max",
921 .data
= &ngroups_max
,
922 .maxlen
= sizeof (int),
924 .proc_handler
= proc_dointvec
,
927 .procname
= "cap_last_cap",
928 .data
= (void *)&cap_last_cap
,
929 .maxlen
= sizeof(int),
931 .proc_handler
= proc_dointvec
,
933 #if defined(CONFIG_LOCKUP_DETECTOR)
935 .procname
= "watchdog",
936 .data
= &watchdog_user_enabled
,
937 .maxlen
= sizeof(int),
939 .proc_handler
= proc_watchdog
,
944 .procname
= "watchdog_thresh",
945 .data
= &watchdog_thresh
,
946 .maxlen
= sizeof(int),
948 .proc_handler
= proc_watchdog_thresh
,
953 .procname
= "nmi_watchdog",
954 .data
= &nmi_watchdog_user_enabled
,
955 .maxlen
= sizeof(int),
956 .mode
= NMI_WATCHDOG_SYSCTL_PERM
,
957 .proc_handler
= proc_nmi_watchdog
,
962 .procname
= "watchdog_cpumask",
963 .data
= &watchdog_cpumask_bits
,
966 .proc_handler
= proc_watchdog_cpumask
,
968 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
970 .procname
= "soft_watchdog",
971 .data
= &soft_watchdog_user_enabled
,
972 .maxlen
= sizeof(int),
974 .proc_handler
= proc_soft_watchdog
,
979 .procname
= "softlockup_panic",
980 .data
= &softlockup_panic
,
981 .maxlen
= sizeof(int),
983 .proc_handler
= proc_dointvec_minmax
,
989 .procname
= "softlockup_all_cpu_backtrace",
990 .data
= &sysctl_softlockup_all_cpu_backtrace
,
991 .maxlen
= sizeof(int),
993 .proc_handler
= proc_dointvec_minmax
,
997 #endif /* CONFIG_SMP */
999 #ifdef CONFIG_HARDLOCKUP_DETECTOR
1001 .procname
= "hardlockup_panic",
1002 .data
= &hardlockup_panic
,
1003 .maxlen
= sizeof(int),
1005 .proc_handler
= proc_dointvec_minmax
,
1011 .procname
= "hardlockup_all_cpu_backtrace",
1012 .data
= &sysctl_hardlockup_all_cpu_backtrace
,
1013 .maxlen
= sizeof(int),
1015 .proc_handler
= proc_dointvec_minmax
,
1019 #endif /* CONFIG_SMP */
1023 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
1025 .procname
= "unknown_nmi_panic",
1026 .data
= &unknown_nmi_panic
,
1027 .maxlen
= sizeof (int),
1029 .proc_handler
= proc_dointvec
,
1032 #if defined(CONFIG_X86)
1034 .procname
= "panic_on_unrecovered_nmi",
1035 .data
= &panic_on_unrecovered_nmi
,
1036 .maxlen
= sizeof(int),
1038 .proc_handler
= proc_dointvec
,
1041 .procname
= "panic_on_io_nmi",
1042 .data
= &panic_on_io_nmi
,
1043 .maxlen
= sizeof(int),
1045 .proc_handler
= proc_dointvec
,
1047 #ifdef CONFIG_DEBUG_STACKOVERFLOW
1049 .procname
= "panic_on_stackoverflow",
1050 .data
= &sysctl_panic_on_stackoverflow
,
1051 .maxlen
= sizeof(int),
1053 .proc_handler
= proc_dointvec
,
1057 .procname
= "bootloader_type",
1058 .data
= &bootloader_type
,
1059 .maxlen
= sizeof (int),
1061 .proc_handler
= proc_dointvec
,
1064 .procname
= "bootloader_version",
1065 .data
= &bootloader_version
,
1066 .maxlen
= sizeof (int),
1068 .proc_handler
= proc_dointvec
,
1071 .procname
= "io_delay_type",
1072 .data
= &io_delay_type
,
1073 .maxlen
= sizeof(int),
1075 .proc_handler
= proc_dointvec
,
1078 #if defined(CONFIG_MMU)
1080 .procname
= "randomize_va_space",
1081 .data
= &randomize_va_space
,
1082 .maxlen
= sizeof(int),
1084 .proc_handler
= proc_dointvec
,
1087 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1089 .procname
= "spin_retry",
1090 .data
= &spin_retry
,
1091 .maxlen
= sizeof (int),
1093 .proc_handler
= proc_dointvec
,
1096 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1098 .procname
= "acpi_video_flags",
1099 .data
= &acpi_realmode_flags
,
1100 .maxlen
= sizeof (unsigned long),
1102 .proc_handler
= proc_doulongvec_minmax
,
1105 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1107 .procname
= "ignore-unaligned-usertrap",
1108 .data
= &no_unaligned_warning
,
1109 .maxlen
= sizeof (int),
1111 .proc_handler
= proc_dointvec
,
1116 .procname
= "unaligned-dump-stack",
1117 .data
= &unaligned_dump_stack
,
1118 .maxlen
= sizeof (int),
1120 .proc_handler
= proc_dointvec
,
1123 #ifdef CONFIG_DETECT_HUNG_TASK
1125 .procname
= "hung_task_panic",
1126 .data
= &sysctl_hung_task_panic
,
1127 .maxlen
= sizeof(int),
1129 .proc_handler
= proc_dointvec_minmax
,
1134 .procname
= "hung_task_check_count",
1135 .data
= &sysctl_hung_task_check_count
,
1136 .maxlen
= sizeof(int),
1138 .proc_handler
= proc_dointvec_minmax
,
1142 .procname
= "hung_task_timeout_secs",
1143 .data
= &sysctl_hung_task_timeout_secs
,
1144 .maxlen
= sizeof(unsigned long),
1146 .proc_handler
= proc_dohung_task_timeout_secs
,
1147 .extra2
= &hung_task_timeout_max
,
1150 .procname
= "hung_task_warnings",
1151 .data
= &sysctl_hung_task_warnings
,
1152 .maxlen
= sizeof(int),
1154 .proc_handler
= proc_dointvec_minmax
,
1158 #ifdef CONFIG_RT_MUTEXES
1160 .procname
= "max_lock_depth",
1161 .data
= &max_lock_depth
,
1162 .maxlen
= sizeof(int),
1164 .proc_handler
= proc_dointvec
,
1168 .procname
= "poweroff_cmd",
1169 .data
= &poweroff_cmd
,
1170 .maxlen
= POWEROFF_CMD_PATH_LEN
,
1172 .proc_handler
= proc_dostring
,
1178 .child
= key_sysctls
,
1181 #ifdef CONFIG_PERF_EVENTS
1183 * User-space scripts rely on the existence of this file
1184 * as a feature check for perf_events being enabled.
1186 * So it's an ABI, do not remove!
1189 .procname
= "perf_event_paranoid",
1190 .data
= &sysctl_perf_event_paranoid
,
1191 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
1193 .proc_handler
= proc_dointvec
,
1196 .procname
= "perf_event_mlock_kb",
1197 .data
= &sysctl_perf_event_mlock
,
1198 .maxlen
= sizeof(sysctl_perf_event_mlock
),
1200 .proc_handler
= proc_dointvec
,
1203 .procname
= "perf_event_max_sample_rate",
1204 .data
= &sysctl_perf_event_sample_rate
,
1205 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1207 .proc_handler
= perf_proc_update_handler
,
1211 .procname
= "perf_cpu_time_max_percent",
1212 .data
= &sysctl_perf_cpu_time_max_percent
,
1213 .maxlen
= sizeof(sysctl_perf_cpu_time_max_percent
),
1215 .proc_handler
= perf_cpu_time_max_percent_handler
,
1217 .extra2
= &one_hundred
,
1220 .procname
= "perf_event_max_stack",
1221 .data
= &sysctl_perf_event_max_stack
,
1222 .maxlen
= sizeof(sysctl_perf_event_max_stack
),
1224 .proc_handler
= perf_event_max_stack_handler
,
1226 .extra2
= &six_hundred_forty_kb
,
1229 .procname
= "perf_event_max_contexts_per_stack",
1230 .data
= &sysctl_perf_event_max_contexts_per_stack
,
1231 .maxlen
= sizeof(sysctl_perf_event_max_contexts_per_stack
),
1233 .proc_handler
= perf_event_max_stack_handler
,
1235 .extra2
= &one_thousand
,
1239 .procname
= "panic_on_warn",
1240 .data
= &panic_on_warn
,
1241 .maxlen
= sizeof(int),
1243 .proc_handler
= proc_dointvec_minmax
,
1247 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1249 .procname
= "timer_migration",
1250 .data
= &sysctl_timer_migration
,
1251 .maxlen
= sizeof(unsigned int),
1253 .proc_handler
= timer_migration_handler
,
1258 #ifdef CONFIG_BPF_SYSCALL
1260 .procname
= "unprivileged_bpf_disabled",
1261 .data
= &sysctl_unprivileged_bpf_disabled
,
1262 .maxlen
= sizeof(sysctl_unprivileged_bpf_disabled
),
1264 /* only handle a transition from default "0" to "1" */
1265 .proc_handler
= proc_dointvec_minmax
,
1270 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1272 .procname
= "panic_on_rcu_stall",
1273 .data
= &sysctl_panic_on_rcu_stall
,
1274 .maxlen
= sizeof(sysctl_panic_on_rcu_stall
),
1276 .proc_handler
= proc_dointvec_minmax
,
1284 static struct ctl_table vm_table
[] = {
1286 .procname
= "overcommit_memory",
1287 .data
= &sysctl_overcommit_memory
,
1288 .maxlen
= sizeof(sysctl_overcommit_memory
),
1290 .proc_handler
= proc_dointvec_minmax
,
1295 .procname
= "panic_on_oom",
1296 .data
= &sysctl_panic_on_oom
,
1297 .maxlen
= sizeof(sysctl_panic_on_oom
),
1299 .proc_handler
= proc_dointvec_minmax
,
1304 .procname
= "oom_kill_allocating_task",
1305 .data
= &sysctl_oom_kill_allocating_task
,
1306 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
1308 .proc_handler
= proc_dointvec
,
1311 .procname
= "oom_dump_tasks",
1312 .data
= &sysctl_oom_dump_tasks
,
1313 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
1315 .proc_handler
= proc_dointvec
,
1318 .procname
= "reap_mem_on_sigkill",
1319 .data
= &sysctl_reap_mem_on_sigkill
,
1320 .maxlen
= sizeof(sysctl_reap_mem_on_sigkill
),
1322 .proc_handler
= proc_dointvec
,
1325 .procname
= "overcommit_ratio",
1326 .data
= &sysctl_overcommit_ratio
,
1327 .maxlen
= sizeof(sysctl_overcommit_ratio
),
1329 .proc_handler
= overcommit_ratio_handler
,
1332 .procname
= "overcommit_kbytes",
1333 .data
= &sysctl_overcommit_kbytes
,
1334 .maxlen
= sizeof(sysctl_overcommit_kbytes
),
1336 .proc_handler
= overcommit_kbytes_handler
,
1339 .procname
= "page-cluster",
1340 .data
= &page_cluster
,
1341 .maxlen
= sizeof(int),
1343 .proc_handler
= proc_dointvec_minmax
,
1347 .procname
= "dirty_background_ratio",
1348 .data
= &dirty_background_ratio
,
1349 .maxlen
= sizeof(dirty_background_ratio
),
1351 .proc_handler
= dirty_background_ratio_handler
,
1353 .extra2
= &one_hundred
,
1356 .procname
= "dirty_background_bytes",
1357 .data
= &dirty_background_bytes
,
1358 .maxlen
= sizeof(dirty_background_bytes
),
1360 .proc_handler
= dirty_background_bytes_handler
,
1364 .procname
= "dirty_ratio",
1365 .data
= &vm_dirty_ratio
,
1366 .maxlen
= sizeof(vm_dirty_ratio
),
1368 .proc_handler
= dirty_ratio_handler
,
1370 .extra2
= &one_hundred
,
1373 .procname
= "dirty_bytes",
1374 .data
= &vm_dirty_bytes
,
1375 .maxlen
= sizeof(vm_dirty_bytes
),
1377 .proc_handler
= dirty_bytes_handler
,
1378 .extra1
= &dirty_bytes_min
,
1381 .procname
= "dirty_writeback_centisecs",
1382 .data
= &dirty_writeback_interval
,
1383 .maxlen
= sizeof(dirty_writeback_interval
),
1385 .proc_handler
= dirty_writeback_centisecs_handler
,
1388 .procname
= "dirty_expire_centisecs",
1389 .data
= &dirty_expire_interval
,
1390 .maxlen
= sizeof(dirty_expire_interval
),
1392 .proc_handler
= proc_dointvec_minmax
,
1396 .procname
= "dirtytime_expire_seconds",
1397 .data
= &dirtytime_expire_interval
,
1398 .maxlen
= sizeof(dirty_expire_interval
),
1400 .proc_handler
= dirtytime_interval_handler
,
1404 .procname
= "nr_pdflush_threads",
1405 .mode
= 0444 /* read-only */,
1406 .proc_handler
= pdflush_proc_obsolete
,
1409 .procname
= "swappiness",
1410 .data
= &vm_swappiness
,
1411 .maxlen
= sizeof(vm_swappiness
),
1413 .proc_handler
= proc_dointvec_minmax
,
1415 .extra2
= &one_hundred
,
1417 #ifdef CONFIG_HUGETLB_PAGE
1419 .procname
= "nr_hugepages",
1421 .maxlen
= sizeof(unsigned long),
1423 .proc_handler
= hugetlb_sysctl_handler
,
1427 .procname
= "nr_hugepages_mempolicy",
1429 .maxlen
= sizeof(unsigned long),
1431 .proc_handler
= &hugetlb_mempolicy_sysctl_handler
,
1435 .procname
= "hugetlb_shm_group",
1436 .data
= &sysctl_hugetlb_shm_group
,
1437 .maxlen
= sizeof(gid_t
),
1439 .proc_handler
= proc_dointvec
,
1442 .procname
= "hugepages_treat_as_movable",
1443 .data
= &hugepages_treat_as_movable
,
1444 .maxlen
= sizeof(int),
1446 .proc_handler
= proc_dointvec
,
1449 .procname
= "nr_overcommit_hugepages",
1451 .maxlen
= sizeof(unsigned long),
1453 .proc_handler
= hugetlb_overcommit_handler
,
1457 .procname
= "lowmem_reserve_ratio",
1458 .data
= &sysctl_lowmem_reserve_ratio
,
1459 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
1461 .proc_handler
= lowmem_reserve_ratio_sysctl_handler
,
1464 .procname
= "drop_caches",
1465 .data
= &sysctl_drop_caches
,
1466 .maxlen
= sizeof(int),
1468 .proc_handler
= drop_caches_sysctl_handler
,
1472 #ifdef CONFIG_COMPACTION
1474 .procname
= "compact_memory",
1475 .data
= &sysctl_compact_memory
,
1476 .maxlen
= sizeof(int),
1478 .proc_handler
= sysctl_compaction_handler
,
1481 .procname
= "extfrag_threshold",
1482 .data
= &sysctl_extfrag_threshold
,
1483 .maxlen
= sizeof(int),
1485 .proc_handler
= sysctl_extfrag_handler
,
1486 .extra1
= &min_extfrag_threshold
,
1487 .extra2
= &max_extfrag_threshold
,
1490 .procname
= "compact_unevictable_allowed",
1491 .data
= &sysctl_compact_unevictable_allowed
,
1492 .maxlen
= sizeof(int),
1494 .proc_handler
= proc_dointvec
,
1499 #endif /* CONFIG_COMPACTION */
1501 .procname
= "min_free_kbytes",
1502 .data
= &min_free_kbytes
,
1503 .maxlen
= sizeof(min_free_kbytes
),
1505 .proc_handler
= min_free_kbytes_sysctl_handler
,
1509 .procname
= "watermark_scale_factor",
1510 .data
= &watermark_scale_factor
,
1511 .maxlen
= sizeof(watermark_scale_factor
),
1513 .proc_handler
= watermark_scale_factor_sysctl_handler
,
1515 .extra2
= &one_thousand
,
1518 .procname
= "extra_free_kbytes",
1519 .data
= &extra_free_kbytes
,
1520 .maxlen
= sizeof(extra_free_kbytes
),
1522 .proc_handler
= min_free_kbytes_sysctl_handler
,
1526 .procname
= "percpu_pagelist_fraction",
1527 .data
= &percpu_pagelist_fraction
,
1528 .maxlen
= sizeof(percpu_pagelist_fraction
),
1530 .proc_handler
= percpu_pagelist_fraction_sysctl_handler
,
1535 .procname
= "max_map_count",
1536 .data
= &sysctl_max_map_count
,
1537 .maxlen
= sizeof(sysctl_max_map_count
),
1539 .proc_handler
= proc_dointvec_minmax
,
1544 .procname
= "nr_trim_pages",
1545 .data
= &sysctl_nr_trim_pages
,
1546 .maxlen
= sizeof(sysctl_nr_trim_pages
),
1548 .proc_handler
= proc_dointvec_minmax
,
1553 .procname
= "laptop_mode",
1554 .data
= &laptop_mode
,
1555 .maxlen
= sizeof(laptop_mode
),
1557 .proc_handler
= proc_dointvec_jiffies
,
1560 .procname
= "block_dump",
1561 .data
= &block_dump
,
1562 .maxlen
= sizeof(block_dump
),
1564 .proc_handler
= proc_dointvec
,
1568 .procname
= "vfs_cache_pressure",
1569 .data
= &sysctl_vfs_cache_pressure
,
1570 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1572 .proc_handler
= proc_dointvec
,
1575 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1577 .procname
= "legacy_va_layout",
1578 .data
= &sysctl_legacy_va_layout
,
1579 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1581 .proc_handler
= proc_dointvec
,
1587 .procname
= "zone_reclaim_mode",
1588 .data
= &node_reclaim_mode
,
1589 .maxlen
= sizeof(node_reclaim_mode
),
1591 .proc_handler
= proc_dointvec
,
1595 .procname
= "min_unmapped_ratio",
1596 .data
= &sysctl_min_unmapped_ratio
,
1597 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1599 .proc_handler
= sysctl_min_unmapped_ratio_sysctl_handler
,
1601 .extra2
= &one_hundred
,
1604 .procname
= "min_slab_ratio",
1605 .data
= &sysctl_min_slab_ratio
,
1606 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1608 .proc_handler
= sysctl_min_slab_ratio_sysctl_handler
,
1610 .extra2
= &one_hundred
,
1615 .procname
= "stat_interval",
1616 .data
= &sysctl_stat_interval
,
1617 .maxlen
= sizeof(sysctl_stat_interval
),
1619 .proc_handler
= proc_dointvec_jiffies
,
1622 .procname
= "stat_refresh",
1626 .proc_handler
= vmstat_refresh
,
1631 .procname
= "mmap_min_addr",
1632 .data
= &dac_mmap_min_addr
,
1633 .maxlen
= sizeof(unsigned long),
1635 .proc_handler
= mmap_min_addr_handler
,
1640 .procname
= "numa_zonelist_order",
1641 .data
= &numa_zonelist_order
,
1642 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1644 .proc_handler
= numa_zonelist_order_handler
,
1647 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1648 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1650 .procname
= "vdso_enabled",
1651 #ifdef CONFIG_X86_32
1652 .data
= &vdso32_enabled
,
1653 .maxlen
= sizeof(vdso32_enabled
),
1655 .data
= &vdso_enabled
,
1656 .maxlen
= sizeof(vdso_enabled
),
1659 .proc_handler
= proc_dointvec
,
1663 #ifdef CONFIG_HIGHMEM
1665 .procname
= "highmem_is_dirtyable",
1666 .data
= &vm_highmem_is_dirtyable
,
1667 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
1669 .proc_handler
= proc_dointvec_minmax
,
1674 #ifdef CONFIG_MEMORY_FAILURE
1676 .procname
= "memory_failure_early_kill",
1677 .data
= &sysctl_memory_failure_early_kill
,
1678 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
1680 .proc_handler
= proc_dointvec_minmax
,
1685 .procname
= "memory_failure_recovery",
1686 .data
= &sysctl_memory_failure_recovery
,
1687 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
1689 .proc_handler
= proc_dointvec_minmax
,
1695 .procname
= "user_reserve_kbytes",
1696 .data
= &sysctl_user_reserve_kbytes
,
1697 .maxlen
= sizeof(sysctl_user_reserve_kbytes
),
1699 .proc_handler
= proc_doulongvec_minmax
,
1702 .procname
= "admin_reserve_kbytes",
1703 .data
= &sysctl_admin_reserve_kbytes
,
1704 .maxlen
= sizeof(sysctl_admin_reserve_kbytes
),
1706 .proc_handler
= proc_doulongvec_minmax
,
1708 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1710 .procname
= "mmap_rnd_bits",
1711 .data
= &mmap_rnd_bits
,
1712 .maxlen
= sizeof(mmap_rnd_bits
),
1714 .proc_handler
= proc_dointvec_minmax
,
1715 .extra1
= (void *)&mmap_rnd_bits_min
,
1716 .extra2
= (void *)&mmap_rnd_bits_max
,
1719 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1721 .procname
= "mmap_rnd_compat_bits",
1722 .data
= &mmap_rnd_compat_bits
,
1723 .maxlen
= sizeof(mmap_rnd_compat_bits
),
1725 .proc_handler
= proc_dointvec_minmax
,
1726 .extra1
= (void *)&mmap_rnd_compat_bits_min
,
1727 .extra2
= (void *)&mmap_rnd_compat_bits_max
,
1733 static struct ctl_table fs_table
[] = {
1735 .procname
= "inode-nr",
1736 .data
= &inodes_stat
,
1737 .maxlen
= 2*sizeof(long),
1739 .proc_handler
= proc_nr_inodes
,
1742 .procname
= "inode-state",
1743 .data
= &inodes_stat
,
1744 .maxlen
= 7*sizeof(long),
1746 .proc_handler
= proc_nr_inodes
,
1749 .procname
= "file-nr",
1750 .data
= &files_stat
,
1751 .maxlen
= sizeof(files_stat
),
1753 .proc_handler
= proc_nr_files
,
1756 .procname
= "file-max",
1757 .data
= &files_stat
.max_files
,
1758 .maxlen
= sizeof(files_stat
.max_files
),
1760 .proc_handler
= proc_doulongvec_minmax
,
1762 .extra2
= &long_max
,
1765 .procname
= "nr_open",
1766 .data
= &sysctl_nr_open
,
1767 .maxlen
= sizeof(unsigned int),
1769 .proc_handler
= proc_dointvec_minmax
,
1770 .extra1
= &sysctl_nr_open_min
,
1771 .extra2
= &sysctl_nr_open_max
,
1774 .procname
= "dentry-state",
1775 .data
= &dentry_stat
,
1776 .maxlen
= 6*sizeof(long),
1778 .proc_handler
= proc_nr_dentry
,
1781 .procname
= "overflowuid",
1782 .data
= &fs_overflowuid
,
1783 .maxlen
= sizeof(int),
1785 .proc_handler
= proc_dointvec_minmax
,
1786 .extra1
= &minolduid
,
1787 .extra2
= &maxolduid
,
1790 .procname
= "overflowgid",
1791 .data
= &fs_overflowgid
,
1792 .maxlen
= sizeof(int),
1794 .proc_handler
= proc_dointvec_minmax
,
1795 .extra1
= &minolduid
,
1796 .extra2
= &maxolduid
,
1798 #ifdef CONFIG_FILE_LOCKING
1800 .procname
= "leases-enable",
1801 .data
= &leases_enable
,
1802 .maxlen
= sizeof(int),
1804 .proc_handler
= proc_dointvec
,
1807 #ifdef CONFIG_DNOTIFY
1809 .procname
= "dir-notify-enable",
1810 .data
= &dir_notify_enable
,
1811 .maxlen
= sizeof(int),
1813 .proc_handler
= proc_dointvec
,
1817 #ifdef CONFIG_FILE_LOCKING
1819 .procname
= "lease-break-time",
1820 .data
= &lease_break_time
,
1821 .maxlen
= sizeof(int),
1823 .proc_handler
= proc_dointvec
,
1828 .procname
= "aio-nr",
1830 .maxlen
= sizeof(aio_nr
),
1832 .proc_handler
= proc_doulongvec_minmax
,
1835 .procname
= "aio-max-nr",
1836 .data
= &aio_max_nr
,
1837 .maxlen
= sizeof(aio_max_nr
),
1839 .proc_handler
= proc_doulongvec_minmax
,
1841 #endif /* CONFIG_AIO */
1842 #ifdef CONFIG_INOTIFY_USER
1844 .procname
= "inotify",
1846 .child
= inotify_table
,
1851 .procname
= "epoll",
1853 .child
= epoll_table
,
1858 .procname
= "protected_symlinks",
1859 .data
= &sysctl_protected_symlinks
,
1860 .maxlen
= sizeof(int),
1862 .proc_handler
= proc_dointvec_minmax
,
1867 .procname
= "protected_hardlinks",
1868 .data
= &sysctl_protected_hardlinks
,
1869 .maxlen
= sizeof(int),
1871 .proc_handler
= proc_dointvec_minmax
,
1876 .procname
= "protected_fifos",
1877 .data
= &sysctl_protected_fifos
,
1878 .maxlen
= sizeof(int),
1880 .proc_handler
= proc_dointvec_minmax
,
1885 .procname
= "protected_regular",
1886 .data
= &sysctl_protected_regular
,
1887 .maxlen
= sizeof(int),
1889 .proc_handler
= proc_dointvec_minmax
,
1894 .procname
= "suid_dumpable",
1895 .data
= &suid_dumpable
,
1896 .maxlen
= sizeof(int),
1898 .proc_handler
= proc_dointvec_minmax_coredump
,
1902 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1904 .procname
= "binfmt_misc",
1906 .child
= sysctl_mount_point
,
1910 .procname
= "pipe-max-size",
1911 .data
= &pipe_max_size
,
1912 .maxlen
= sizeof(pipe_max_size
),
1914 .proc_handler
= &pipe_proc_fn
,
1915 .extra1
= &pipe_min_size
,
1918 .procname
= "pipe-user-pages-hard",
1919 .data
= &pipe_user_pages_hard
,
1920 .maxlen
= sizeof(pipe_user_pages_hard
),
1922 .proc_handler
= proc_doulongvec_minmax
,
1925 .procname
= "pipe-user-pages-soft",
1926 .data
= &pipe_user_pages_soft
,
1927 .maxlen
= sizeof(pipe_user_pages_soft
),
1929 .proc_handler
= proc_doulongvec_minmax
,
1932 .procname
= "mount-max",
1933 .data
= &sysctl_mount_max
,
1934 .maxlen
= sizeof(unsigned int),
1936 .proc_handler
= proc_dointvec_minmax
,
1942 static struct ctl_table debug_table
[] = {
1943 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1945 .procname
= "exception-trace",
1946 .data
= &show_unhandled_signals
,
1947 .maxlen
= sizeof(int),
1949 .proc_handler
= proc_dointvec
1952 #if defined(CONFIG_OPTPROBES)
1954 .procname
= "kprobes-optimization",
1955 .data
= &sysctl_kprobes_optimization
,
1956 .maxlen
= sizeof(int),
1958 .proc_handler
= proc_kprobes_optimization_handler
,
1966 static struct ctl_table dev_table
[] = {
1970 int __init
sysctl_init(void)
1972 struct ctl_table_header
*hdr
;
1974 hdr
= register_sysctl_table(sysctl_base_table
);
1975 kmemleak_not_leak(hdr
);
1979 #endif /* CONFIG_SYSCTL */
1985 #ifdef CONFIG_PROC_SYSCTL
1987 static int _proc_do_string(char *data
, int maxlen
, int write
,
1988 char __user
*buffer
,
1989 size_t *lenp
, loff_t
*ppos
)
1995 if (!data
|| !maxlen
|| !*lenp
) {
2001 if (sysctl_writes_strict
== SYSCTL_WRITES_STRICT
) {
2002 /* Only continue writes not past the end of buffer. */
2004 if (len
> maxlen
- 1)
2011 /* Start writing from beginning of buffer. */
2017 while ((p
- buffer
) < *lenp
&& len
< maxlen
- 1) {
2018 if (get_user(c
, p
++))
2020 if (c
== 0 || c
== '\n')
2041 if (copy_to_user(buffer
, data
, len
))
2044 if (put_user('\n', buffer
+ len
))
2054 static void warn_sysctl_write(struct ctl_table
*table
)
2056 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2057 "This will not be supported in the future. To silence this\n"
2058 "warning, set kernel.sysctl_writes_strict = -1\n",
2059 current
->comm
, table
->procname
);
2063 * proc_first_pos_non_zero_ignore - check if firs position is allowed
2064 * @ppos: file position
2065 * @table: the sysctl table
2067 * Returns true if the first position is non-zero and the sysctl_writes_strict
2068 * mode indicates this is not allowed for numeric input types. String proc
2069 * hadlers can ignore the return value.
2071 static bool proc_first_pos_non_zero_ignore(loff_t
*ppos
,
2072 struct ctl_table
*table
)
2077 switch (sysctl_writes_strict
) {
2078 case SYSCTL_WRITES_STRICT
:
2080 case SYSCTL_WRITES_WARN
:
2081 warn_sysctl_write(table
);
2089 * proc_dostring - read a string sysctl
2090 * @table: the sysctl table
2091 * @write: %TRUE if this is a write to the sysctl file
2092 * @buffer: the user buffer
2093 * @lenp: the size of the user buffer
2094 * @ppos: file position
2096 * Reads/writes a string from/to the user buffer. If the kernel
2097 * buffer provided is not large enough to hold the string, the
2098 * string is truncated. The copied string is %NULL-terminated.
2099 * If the string is being read by the user process, it is copied
2100 * and a newline '\n' is added. It is truncated if the buffer is
2103 * Returns 0 on success.
2105 int proc_dostring(struct ctl_table
*table
, int write
,
2106 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2109 proc_first_pos_non_zero_ignore(ppos
, table
);
2111 return _proc_do_string((char *)(table
->data
), table
->maxlen
, write
,
2112 (char __user
*)buffer
, lenp
, ppos
);
2115 static size_t proc_skip_spaces(char **buf
)
2118 char *tmp
= skip_spaces(*buf
);
2124 static void proc_skip_char(char **buf
, size_t *size
, const char v
)
2134 #define TMPBUFLEN 22
2136 * proc_get_long - reads an ASCII formatted integer from a user buffer
2138 * @buf: a kernel buffer
2139 * @size: size of the kernel buffer
2140 * @val: this is where the number will be stored
2141 * @neg: set to %TRUE if number is negative
2142 * @perm_tr: a vector which contains the allowed trailers
2143 * @perm_tr_len: size of the perm_tr vector
2144 * @tr: pointer to store the trailer character
2146 * In case of success %0 is returned and @buf and @size are updated with
2147 * the amount of bytes read. If @tr is non-NULL and a trailing
2148 * character exists (size is non-zero after returning from this
2149 * function), @tr is updated with the trailing character.
2151 static int proc_get_long(char **buf
, size_t *size
,
2152 unsigned long *val
, bool *neg
,
2153 const char *perm_tr
, unsigned perm_tr_len
, char *tr
)
2156 char *p
, tmp
[TMPBUFLEN
];
2162 if (len
> TMPBUFLEN
- 1)
2163 len
= TMPBUFLEN
- 1;
2165 memcpy(tmp
, *buf
, len
);
2169 if (*p
== '-' && *size
> 1) {
2177 *val
= simple_strtoul(p
, &p
, 0);
2181 /* We don't know if the next char is whitespace thus we may accept
2182 * invalid integers (e.g. 1234...a) or two integers instead of one
2183 * (e.g. 123...1). So lets not allow such large numbers. */
2184 if (len
== TMPBUFLEN
- 1)
2187 if (len
< *size
&& perm_tr_len
&& !memchr(perm_tr
, *p
, perm_tr_len
))
2190 if (tr
&& (len
< *size
))
2200 * proc_put_long - converts an integer to a decimal ASCII formatted string
2202 * @buf: the user buffer
2203 * @size: the size of the user buffer
2204 * @val: the integer to be converted
2205 * @neg: sign of the number, %TRUE for negative
2207 * In case of success %0 is returned and @buf and @size are updated with
2208 * the amount of bytes written.
2210 static int proc_put_long(void __user
**buf
, size_t *size
, unsigned long val
,
2214 char tmp
[TMPBUFLEN
], *p
= tmp
;
2216 sprintf(p
, "%s%lu", neg
? "-" : "", val
);
2220 if (copy_to_user(*buf
, tmp
, len
))
2228 static int proc_put_char(void __user
**buf
, size_t *size
, char c
)
2231 char __user
**buffer
= (char __user
**)buf
;
2232 if (put_user(c
, *buffer
))
2234 (*size
)--, (*buffer
)++;
2240 static int do_proc_dointvec_conv(bool *negp
, unsigned long *lvalp
,
2242 int write
, void *data
)
2246 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2250 if (*lvalp
> (unsigned long) INT_MAX
)
2258 *lvalp
= -(unsigned long)val
;
2261 *lvalp
= (unsigned long)val
;
2267 static int do_proc_douintvec_conv(unsigned long *lvalp
,
2269 int write
, void *data
)
2272 if (*lvalp
> UINT_MAX
)
2276 unsigned int val
= *valp
;
2277 *lvalp
= (unsigned long)val
;
2282 static const char proc_wspace_sep
[] = { ' ', '\t', '\n' };
2284 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2285 int write
, void __user
*buffer
,
2286 size_t *lenp
, loff_t
*ppos
,
2287 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2288 int write
, void *data
),
2291 int *i
, vleft
, first
= 1, err
= 0;
2293 char *kbuf
= NULL
, *p
;
2295 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2300 i
= (int *) tbl_data
;
2301 vleft
= table
->maxlen
/ sizeof(*i
);
2305 conv
= do_proc_dointvec_conv
;
2308 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2311 if (left
> PAGE_SIZE
- 1)
2312 left
= PAGE_SIZE
- 1;
2313 p
= kbuf
= memdup_user_nul(buffer
, left
);
2315 return PTR_ERR(kbuf
);
2318 for (; left
&& vleft
--; i
++, first
=0) {
2323 left
-= proc_skip_spaces(&p
);
2327 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2329 sizeof(proc_wspace_sep
), NULL
);
2332 if (conv(&neg
, &lval
, i
, 1, data
)) {
2337 if (conv(&neg
, &lval
, i
, 0, data
)) {
2342 err
= proc_put_char(&buffer
, &left
, '\t');
2345 err
= proc_put_long(&buffer
, &left
, lval
, neg
);
2351 if (!write
&& !first
&& left
&& !err
)
2352 err
= proc_put_char(&buffer
, &left
, '\n');
2353 if (write
&& !err
&& left
)
2354 left
-= proc_skip_spaces(&p
);
2358 return err
? : -EINVAL
;
2366 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2367 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2368 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2369 int write
, void *data
),
2372 return __do_proc_dointvec(table
->data
, table
, write
,
2373 buffer
, lenp
, ppos
, conv
, data
);
2376 static int do_proc_douintvec_w(unsigned int *tbl_data
,
2377 struct ctl_table
*table
,
2378 void __user
*buffer
,
2379 size_t *lenp
, loff_t
*ppos
,
2380 int (*conv
)(unsigned long *lvalp
,
2382 int write
, void *data
),
2389 char *kbuf
= NULL
, *p
;
2393 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2396 if (left
> PAGE_SIZE
- 1)
2397 left
= PAGE_SIZE
- 1;
2399 p
= kbuf
= memdup_user_nul(buffer
, left
);
2403 left
-= proc_skip_spaces(&p
);
2409 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2411 sizeof(proc_wspace_sep
), NULL
);
2417 if (conv(&lval
, tbl_data
, 1, data
)) {
2423 left
-= proc_skip_spaces(&p
);
2432 /* This is in keeping with old __do_proc_dointvec() */
2438 static int do_proc_douintvec_r(unsigned int *tbl_data
, void __user
*buffer
,
2439 size_t *lenp
, loff_t
*ppos
,
2440 int (*conv
)(unsigned long *lvalp
,
2442 int write
, void *data
),
2451 if (conv(&lval
, tbl_data
, 0, data
)) {
2456 err
= proc_put_long(&buffer
, &left
, lval
, false);
2460 err
= proc_put_char(&buffer
, &left
, '\n');
2469 static int __do_proc_douintvec(void *tbl_data
, struct ctl_table
*table
,
2470 int write
, void __user
*buffer
,
2471 size_t *lenp
, loff_t
*ppos
,
2472 int (*conv
)(unsigned long *lvalp
,
2474 int write
, void *data
),
2477 unsigned int *i
, vleft
;
2479 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2484 i
= (unsigned int *) tbl_data
;
2485 vleft
= table
->maxlen
/ sizeof(*i
);
2488 * Arrays are not supported, keep this simple. *Do not* add
2497 conv
= do_proc_douintvec_conv
;
2500 return do_proc_douintvec_w(i
, table
, buffer
, lenp
, ppos
,
2502 return do_proc_douintvec_r(i
, buffer
, lenp
, ppos
, conv
, data
);
2505 static int do_proc_douintvec(struct ctl_table
*table
, int write
,
2506 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2507 int (*conv
)(unsigned long *lvalp
,
2509 int write
, void *data
),
2512 return __do_proc_douintvec(table
->data
, table
, write
,
2513 buffer
, lenp
, ppos
, conv
, data
);
2517 * proc_dointvec - read a vector of integers
2518 * @table: the sysctl table
2519 * @write: %TRUE if this is a write to the sysctl file
2520 * @buffer: the user buffer
2521 * @lenp: the size of the user buffer
2522 * @ppos: file position
2524 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2525 * values from/to the user buffer, treated as an ASCII string.
2527 * Returns 0 on success.
2529 int proc_dointvec(struct ctl_table
*table
, int write
,
2530 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2532 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
, NULL
, NULL
);
2536 * proc_douintvec - read a vector of unsigned integers
2537 * @table: the sysctl table
2538 * @write: %TRUE if this is a write to the sysctl file
2539 * @buffer: the user buffer
2540 * @lenp: the size of the user buffer
2541 * @ppos: file position
2543 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2544 * values from/to the user buffer, treated as an ASCII string.
2546 * Returns 0 on success.
2548 int proc_douintvec(struct ctl_table
*table
, int write
,
2549 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2551 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2552 do_proc_douintvec_conv
, NULL
);
2556 * Taint values can only be increased
2557 * This means we can safely use a temporary.
2559 static int proc_taint(struct ctl_table
*table
, int write
,
2560 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2563 unsigned long tmptaint
= get_taint();
2566 if (write
&& !capable(CAP_SYS_ADMIN
))
2571 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2577 * Poor man's atomic or. Not worth adding a primitive
2578 * to everyone's atomic.h for this
2581 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2582 if ((tmptaint
>> i
) & 1)
2583 add_taint(i
, LOCKDEP_STILL_OK
);
2590 #ifdef CONFIG_PRINTK
2591 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
2592 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2594 if (write
&& !capable(CAP_SYS_ADMIN
))
2597 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2601 struct do_proc_dointvec_minmax_conv_param
{
2606 static int do_proc_dointvec_minmax_conv(bool *negp
, unsigned long *lvalp
,
2608 int write
, void *data
)
2610 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2614 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2618 if (*lvalp
> (unsigned long) INT_MAX
)
2622 if ((param
->min
&& *param
->min
> val
) ||
2623 (param
->max
&& *param
->max
< val
))
2630 *lvalp
= -(unsigned long)val
;
2633 *lvalp
= (unsigned long)val
;
2640 * proc_dointvec_minmax - read a vector of integers with min/max values
2641 * @table: the sysctl table
2642 * @write: %TRUE if this is a write to the sysctl file
2643 * @buffer: the user buffer
2644 * @lenp: the size of the user buffer
2645 * @ppos: file position
2647 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2648 * values from/to the user buffer, treated as an ASCII string.
2650 * This routine will ensure the values are within the range specified by
2651 * table->extra1 (min) and table->extra2 (max).
2653 * Returns 0 on success.
2655 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2656 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2658 struct do_proc_dointvec_minmax_conv_param param
= {
2659 .min
= (int *) table
->extra1
,
2660 .max
= (int *) table
->extra2
,
2662 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2663 do_proc_dointvec_minmax_conv
, ¶m
);
2666 struct do_proc_douintvec_minmax_conv_param
{
2671 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp
,
2673 int write
, void *data
)
2675 struct do_proc_douintvec_minmax_conv_param
*param
= data
;
2678 unsigned int val
= *lvalp
;
2680 if ((param
->min
&& *param
->min
> val
) ||
2681 (param
->max
&& *param
->max
< val
))
2684 if (*lvalp
> UINT_MAX
)
2688 unsigned int val
= *valp
;
2689 *lvalp
= (unsigned long) val
;
2696 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2697 * @table: the sysctl table
2698 * @write: %TRUE if this is a write to the sysctl file
2699 * @buffer: the user buffer
2700 * @lenp: the size of the user buffer
2701 * @ppos: file position
2703 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2704 * values from/to the user buffer, treated as an ASCII string. Negative
2705 * strings are not allowed.
2707 * This routine will ensure the values are within the range specified by
2708 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2709 * check for UINT_MAX to avoid having to support wrap around uses from
2712 * Returns 0 on success.
2714 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
2715 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2717 struct do_proc_douintvec_minmax_conv_param param
= {
2718 .min
= (unsigned int *) table
->extra1
,
2719 .max
= (unsigned int *) table
->extra2
,
2721 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2722 do_proc_douintvec_minmax_conv
, ¶m
);
2725 static void validate_coredump_safety(void)
2727 #ifdef CONFIG_COREDUMP
2728 if (suid_dumpable
== SUID_DUMP_ROOT
&&
2729 core_pattern
[0] != '/' && core_pattern
[0] != '|') {
2731 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2732 "Pipe handler or fully qualified core dump path required.\n"
2733 "Set kernel.core_pattern before fs.suid_dumpable.\n"
2739 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
2740 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2742 int error
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2744 validate_coredump_safety();
2748 #ifdef CONFIG_COREDUMP
2749 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
2750 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2752 int error
= proc_dostring(table
, write
, buffer
, lenp
, ppos
);
2754 validate_coredump_safety();
2759 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2760 void __user
*buffer
,
2761 size_t *lenp
, loff_t
*ppos
,
2762 unsigned long convmul
,
2763 unsigned long convdiv
)
2765 unsigned long *i
, *min
, *max
;
2766 int vleft
, first
= 1, err
= 0;
2768 char *kbuf
= NULL
, *p
;
2770 if (!data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2775 i
= (unsigned long *) data
;
2776 min
= (unsigned long *) table
->extra1
;
2777 max
= (unsigned long *) table
->extra2
;
2778 vleft
= table
->maxlen
/ sizeof(unsigned long);
2782 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2785 if (left
> PAGE_SIZE
- 1)
2786 left
= PAGE_SIZE
- 1;
2787 p
= kbuf
= memdup_user_nul(buffer
, left
);
2789 return PTR_ERR(kbuf
);
2792 for (; left
&& vleft
--; i
++, first
= 0) {
2798 left
-= proc_skip_spaces(&p
);
2802 err
= proc_get_long(&p
, &left
, &val
, &neg
,
2804 sizeof(proc_wspace_sep
), NULL
);
2809 val
= convmul
* val
/ convdiv
;
2810 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2814 val
= convdiv
* (*i
) / convmul
;
2816 err
= proc_put_char(&buffer
, &left
, '\t');
2820 err
= proc_put_long(&buffer
, &left
, val
, false);
2826 if (!write
&& !first
&& left
&& !err
)
2827 err
= proc_put_char(&buffer
, &left
, '\n');
2829 left
-= proc_skip_spaces(&p
);
2833 return err
? : -EINVAL
;
2841 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2842 void __user
*buffer
,
2843 size_t *lenp
, loff_t
*ppos
,
2844 unsigned long convmul
,
2845 unsigned long convdiv
)
2847 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2848 buffer
, lenp
, ppos
, convmul
, convdiv
);
2852 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2853 * @table: the sysctl table
2854 * @write: %TRUE if this is a write to the sysctl file
2855 * @buffer: the user buffer
2856 * @lenp: the size of the user buffer
2857 * @ppos: file position
2859 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2860 * values from/to the user buffer, treated as an ASCII string.
2862 * This routine will ensure the values are within the range specified by
2863 * table->extra1 (min) and table->extra2 (max).
2865 * Returns 0 on success.
2867 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2868 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2870 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2874 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2875 * @table: the sysctl table
2876 * @write: %TRUE if this is a write to the sysctl file
2877 * @buffer: the user buffer
2878 * @lenp: the size of the user buffer
2879 * @ppos: file position
2881 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2882 * values from/to the user buffer, treated as an ASCII string. The values
2883 * are treated as milliseconds, and converted to jiffies when they are stored.
2885 * This routine will ensure the values are within the range specified by
2886 * table->extra1 (min) and table->extra2 (max).
2888 * Returns 0 on success.
2890 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2891 void __user
*buffer
,
2892 size_t *lenp
, loff_t
*ppos
)
2894 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2895 lenp
, ppos
, HZ
, 1000l);
2899 static int do_proc_dointvec_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2901 int write
, void *data
)
2904 if (*lvalp
> INT_MAX
/ HZ
)
2906 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2912 lval
= -(unsigned long)val
;
2915 lval
= (unsigned long)val
;
2922 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2924 int write
, void *data
)
2927 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2929 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2935 lval
= -(unsigned long)val
;
2938 lval
= (unsigned long)val
;
2940 *lvalp
= jiffies_to_clock_t(lval
);
2945 static int do_proc_dointvec_ms_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2947 int write
, void *data
)
2950 unsigned long jif
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2960 lval
= -(unsigned long)val
;
2963 lval
= (unsigned long)val
;
2965 *lvalp
= jiffies_to_msecs(lval
);
2971 * proc_dointvec_jiffies - read a vector of integers as seconds
2972 * @table: the sysctl table
2973 * @write: %TRUE if this is a write to the sysctl file
2974 * @buffer: the user buffer
2975 * @lenp: the size of the user buffer
2976 * @ppos: file position
2978 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2979 * values from/to the user buffer, treated as an ASCII string.
2980 * The values read are assumed to be in seconds, and are converted into
2983 * Returns 0 on success.
2985 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2986 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2988 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2989 do_proc_dointvec_jiffies_conv
,NULL
);
2993 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2994 * @table: the sysctl table
2995 * @write: %TRUE if this is a write to the sysctl file
2996 * @buffer: the user buffer
2997 * @lenp: the size of the user buffer
2998 * @ppos: pointer to the file position
3000 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3001 * values from/to the user buffer, treated as an ASCII string.
3002 * The values read are assumed to be in 1/USER_HZ seconds, and
3003 * are converted into jiffies.
3005 * Returns 0 on success.
3007 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
3008 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3010 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
3011 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
3015 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
3016 * @table: the sysctl table
3017 * @write: %TRUE if this is a write to the sysctl file
3018 * @buffer: the user buffer
3019 * @lenp: the size of the user buffer
3020 * @ppos: file position
3021 * @ppos: the current position in the file
3023 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3024 * values from/to the user buffer, treated as an ASCII string.
3025 * The values read are assumed to be in 1/1000 seconds, and
3026 * are converted into jiffies.
3028 * Returns 0 on success.
3030 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
3031 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3033 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
3034 do_proc_dointvec_ms_jiffies_conv
, NULL
);
3037 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
3038 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3040 struct pid
*new_pid
;
3044 tmp
= pid_vnr(cad_pid
);
3046 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
3047 lenp
, ppos
, NULL
, NULL
);
3051 new_pid
= find_get_pid(tmp
);
3055 put_pid(xchg(&cad_pid
, new_pid
));
3060 * proc_do_large_bitmap - read/write from/to a large bitmap
3061 * @table: the sysctl table
3062 * @write: %TRUE if this is a write to the sysctl file
3063 * @buffer: the user buffer
3064 * @lenp: the size of the user buffer
3065 * @ppos: file position
3067 * The bitmap is stored at table->data and the bitmap length (in bits)
3070 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
3071 * large bitmaps may be represented in a compact manner. Writing into
3072 * the file will clear the bitmap then update it with the given input.
3074 * Returns 0 on success.
3076 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
3077 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3081 size_t left
= *lenp
;
3082 unsigned long bitmap_len
= table
->maxlen
;
3083 unsigned long *bitmap
= *(unsigned long **) table
->data
;
3084 unsigned long *tmp_bitmap
= NULL
;
3085 char tr_a
[] = { '-', ',', '\n' }, tr_b
[] = { ',', '\n', 0 }, c
;
3087 if (!bitmap
|| !bitmap_len
|| !left
|| (*ppos
&& !write
)) {
3095 if (left
> PAGE_SIZE
- 1)
3096 left
= PAGE_SIZE
- 1;
3098 p
= kbuf
= memdup_user_nul(buffer
, left
);
3100 return PTR_ERR(kbuf
);
3102 tmp_bitmap
= kzalloc(BITS_TO_LONGS(bitmap_len
) * sizeof(unsigned long),
3108 proc_skip_char(&p
, &left
, '\n');
3109 while (!err
&& left
) {
3110 unsigned long val_a
, val_b
;
3113 err
= proc_get_long(&p
, &left
, &val_a
, &neg
, tr_a
,
3117 if (val_a
>= bitmap_len
|| neg
) {
3129 err
= proc_get_long(&p
, &left
, &val_b
,
3130 &neg
, tr_b
, sizeof(tr_b
),
3134 if (val_b
>= bitmap_len
|| neg
||
3145 bitmap_set(tmp_bitmap
, val_a
, val_b
- val_a
+ 1);
3147 proc_skip_char(&p
, &left
, '\n');
3151 unsigned long bit_a
, bit_b
= 0;
3154 bit_a
= find_next_bit(bitmap
, bitmap_len
, bit_b
);
3155 if (bit_a
>= bitmap_len
)
3157 bit_b
= find_next_zero_bit(bitmap
, bitmap_len
,
3161 err
= proc_put_char(&buffer
, &left
, ',');
3165 err
= proc_put_long(&buffer
, &left
, bit_a
, false);
3168 if (bit_a
!= bit_b
) {
3169 err
= proc_put_char(&buffer
, &left
, '-');
3172 err
= proc_put_long(&buffer
, &left
, bit_b
, false);
3180 err
= proc_put_char(&buffer
, &left
, '\n');
3186 bitmap_or(bitmap
, bitmap
, tmp_bitmap
, bitmap_len
);
3188 bitmap_copy(bitmap
, tmp_bitmap
, bitmap_len
);
3200 #else /* CONFIG_PROC_SYSCTL */
3202 int proc_dostring(struct ctl_table
*table
, int write
,
3203 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3208 int proc_dointvec(struct ctl_table
*table
, int write
,
3209 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3214 int proc_douintvec(struct ctl_table
*table
, int write
,
3215 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3220 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
3221 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3226 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
3227 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3232 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
3233 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3238 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
3239 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3244 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
3245 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3250 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
3251 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3256 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
3257 void __user
*buffer
,
3258 size_t *lenp
, loff_t
*ppos
)
3264 #endif /* CONFIG_PROC_SYSCTL */
3267 * No sense putting this after each symbol definition, twice,
3268 * exception granted :-)
3270 EXPORT_SYMBOL(proc_dointvec
);
3271 EXPORT_SYMBOL(proc_douintvec
);
3272 EXPORT_SYMBOL(proc_dointvec_jiffies
);
3273 EXPORT_SYMBOL(proc_dointvec_minmax
);
3274 EXPORT_SYMBOL_GPL(proc_douintvec_minmax
);
3275 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
3276 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
3277 EXPORT_SYMBOL(proc_dostring
);
3278 EXPORT_SYMBOL(proc_doulongvec_minmax
);
3279 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);