1 // SPDX-License-Identifier: GPL-2.0-only
3 * sysctl.c: General linux system control interface
5 * Begun 24 March 1995, Stephen Tweedie
6 * Added /proc support, Dec 1995
7 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
8 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
9 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
10 * Dynamic registration fixes, Stephen Tweedie.
11 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
12 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
14 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
15 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
16 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
18 * The list_for_each() macro wasn't appropriate for the sysctl loop.
19 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
22 #include <linux/module.h>
23 #include <linux/aio.h>
25 #include <linux/swap.h>
26 #include <linux/slab.h>
27 #include <linux/sysctl.h>
28 #include <linux/bitmap.h>
29 #include <linux/signal.h>
30 #include <linux/printk.h>
31 #include <linux/proc_fs.h>
32 #include <linux/security.h>
33 #include <linux/ctype.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>
70 #include <linux/userfaultfd_k.h>
71 #include <linux/coredump.h>
72 #include <linux/latencytop.h>
73 #include <linux/pid.h>
75 #include "../lib/kstrtox.h"
77 #include <linux/uaccess.h>
78 #include <asm/processor.h>
82 #include <asm/stacktrace.h>
86 #include <asm/setup.h>
88 #ifdef CONFIG_BSD_PROCESS_ACCT
89 #include <linux/acct.h>
91 #ifdef CONFIG_RT_MUTEXES
92 #include <linux/rtmutex.h>
94 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
95 #include <linux/lockdep.h>
97 #ifdef CONFIG_CHR_DEV_SG
100 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
101 #include <linux/stackleak.h>
103 #ifdef CONFIG_LOCKUP_DETECTOR
104 #include <linux/nmi.h>
107 #if defined(CONFIG_SYSCTL)
109 /* Constants used for minimum and maximum */
110 #ifdef CONFIG_LOCKUP_DETECTOR
111 static int sixty
= 60;
114 static int __maybe_unused neg_one
= -1;
115 static int __maybe_unused two
= 2;
116 static int __maybe_unused four
= 4;
117 static unsigned long zero_ul
;
118 static unsigned long one_ul
= 1;
119 static unsigned long long_max
= LONG_MAX
;
120 static int one_hundred
= 100;
121 static int two_hundred
= 200;
122 static int one_thousand
= 1000;
124 static int ten_thousand
= 10000;
126 #ifdef CONFIG_PERF_EVENTS
127 static int six_hundred_forty_kb
= 640 * 1024;
130 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
131 static unsigned long dirty_bytes_min
= 2 * PAGE_SIZE
;
133 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
134 static int maxolduid
= 65535;
135 static int minolduid
;
137 static int ngroups_max
= NGROUPS_MAX
;
138 static const int cap_last_cap
= CAP_LAST_CAP
;
141 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
142 * and hung_task_check_interval_secs
144 #ifdef CONFIG_DETECT_HUNG_TASK
145 static unsigned long hung_task_timeout_max
= (LONG_MAX
/HZ
);
148 #ifdef CONFIG_INOTIFY_USER
149 #include <linux/inotify.h>
152 #ifdef CONFIG_PROC_SYSCTL
155 * enum sysctl_writes_mode - supported sysctl write modes
157 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
158 * to be written, and multiple writes on the same sysctl file descriptor
159 * will rewrite the sysctl value, regardless of file position. No warning
160 * is issued when the initial position is not 0.
161 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
163 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
164 * file position 0 and the value must be fully contained in the buffer
165 * sent to the write syscall. If dealing with strings respect the file
166 * position, but restrict this to the max length of the buffer, anything
167 * passed the max length will be ignored. Multiple writes will append
170 * These write modes control how current file position affects the behavior of
171 * updating sysctl values through the proc interface on each write.
173 enum sysctl_writes_mode
{
174 SYSCTL_WRITES_LEGACY
= -1,
175 SYSCTL_WRITES_WARN
= 0,
176 SYSCTL_WRITES_STRICT
= 1,
179 static enum sysctl_writes_mode sysctl_writes_strict
= SYSCTL_WRITES_STRICT
;
180 #endif /* CONFIG_PROC_SYSCTL */
182 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
183 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
184 int sysctl_legacy_va_layout
;
187 #ifdef CONFIG_SCHED_DEBUG
188 static int min_sched_granularity_ns
= 100000; /* 100 usecs */
189 static int max_sched_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
190 static int min_wakeup_granularity_ns
; /* 0 usecs */
191 static int max_wakeup_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
193 static int min_sched_tunable_scaling
= SCHED_TUNABLESCALING_NONE
;
194 static int max_sched_tunable_scaling
= SCHED_TUNABLESCALING_END
-1;
195 #endif /* CONFIG_SMP */
196 #endif /* CONFIG_SCHED_DEBUG */
198 #ifdef CONFIG_COMPACTION
199 static int min_extfrag_threshold
;
200 static int max_extfrag_threshold
= 1000;
203 #endif /* CONFIG_SYSCTL */
205 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
206 static int bpf_stats_handler(struct ctl_table
*table
, int write
,
207 void __user
*buffer
, size_t *lenp
,
210 struct static_key
*key
= (struct static_key
*)table
->data
;
211 static int saved_val
;
213 struct ctl_table tmp
= {
215 .maxlen
= sizeof(val
),
217 .extra1
= SYSCTL_ZERO
,
218 .extra2
= SYSCTL_ONE
,
221 if (write
&& !capable(CAP_SYS_ADMIN
))
224 mutex_lock(&bpf_stats_enabled_mutex
);
226 ret
= proc_dointvec_minmax(&tmp
, write
, buffer
, lenp
, ppos
);
227 if (write
&& !ret
&& val
!= saved_val
) {
229 static_key_slow_inc(key
);
231 static_key_slow_dec(key
);
234 mutex_unlock(&bpf_stats_enabled_mutex
);
243 #ifdef CONFIG_PROC_SYSCTL
245 static int _proc_do_string(char *data
, int maxlen
, int write
,
246 char *buffer
, size_t *lenp
, loff_t
*ppos
)
251 if (!data
|| !maxlen
|| !*lenp
) {
257 if (sysctl_writes_strict
== SYSCTL_WRITES_STRICT
) {
258 /* Only continue writes not past the end of buffer. */
260 if (len
> maxlen
- 1)
267 /* Start writing from beginning of buffer. */
273 while ((p
- buffer
) < *lenp
&& len
< maxlen
- 1) {
275 if (c
== 0 || c
== '\n')
296 memcpy(buffer
, data
, len
);
307 static void warn_sysctl_write(struct ctl_table
*table
)
309 pr_warn_once("%s wrote to %s when file position was not 0!\n"
310 "This will not be supported in the future. To silence this\n"
311 "warning, set kernel.sysctl_writes_strict = -1\n",
312 current
->comm
, table
->procname
);
316 * proc_first_pos_non_zero_ignore - check if first position is allowed
317 * @ppos: file position
318 * @table: the sysctl table
320 * Returns true if the first position is non-zero and the sysctl_writes_strict
321 * mode indicates this is not allowed for numeric input types. String proc
322 * handlers can ignore the return value.
324 static bool proc_first_pos_non_zero_ignore(loff_t
*ppos
,
325 struct ctl_table
*table
)
330 switch (sysctl_writes_strict
) {
331 case SYSCTL_WRITES_STRICT
:
333 case SYSCTL_WRITES_WARN
:
334 warn_sysctl_write(table
);
342 * proc_dostring - read a string sysctl
343 * @table: the sysctl table
344 * @write: %TRUE if this is a write to the sysctl file
345 * @buffer: the user buffer
346 * @lenp: the size of the user buffer
347 * @ppos: file position
349 * Reads/writes a string from/to the user buffer. If the kernel
350 * buffer provided is not large enough to hold the string, the
351 * string is truncated. The copied string is %NULL-terminated.
352 * If the string is being read by the user process, it is copied
353 * and a newline '\n' is added. It is truncated if the buffer is
356 * Returns 0 on success.
358 int proc_dostring(struct ctl_table
*table
, int write
,
359 void *buffer
, size_t *lenp
, loff_t
*ppos
)
362 proc_first_pos_non_zero_ignore(ppos
, table
);
364 return _proc_do_string(table
->data
, table
->maxlen
, write
, buffer
, lenp
,
368 static size_t proc_skip_spaces(char **buf
)
371 char *tmp
= skip_spaces(*buf
);
377 static void proc_skip_char(char **buf
, size_t *size
, const char v
)
388 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
391 * @cp: kernel buffer containing the string to parse
392 * @endp: pointer to store the trailing characters
393 * @base: the base to use
394 * @res: where the parsed integer will be stored
396 * In case of success 0 is returned and @res will contain the parsed integer,
397 * @endp will hold any trailing characters.
398 * This function will fail the parse on overflow. If there wasn't an overflow
399 * the function will defer the decision what characters count as invalid to the
402 static int strtoul_lenient(const char *cp
, char **endp
, unsigned int base
,
405 unsigned long long result
;
408 cp
= _parse_integer_fixup_radix(cp
, &base
);
409 rv
= _parse_integer(cp
, base
, &result
);
410 if ((rv
& KSTRTOX_OVERFLOW
) || (result
!= (unsigned long)result
))
418 *res
= (unsigned long)result
;
424 * proc_get_long - reads an ASCII formatted integer from a user buffer
426 * @buf: a kernel buffer
427 * @size: size of the kernel buffer
428 * @val: this is where the number will be stored
429 * @neg: set to %TRUE if number is negative
430 * @perm_tr: a vector which contains the allowed trailers
431 * @perm_tr_len: size of the perm_tr vector
432 * @tr: pointer to store the trailer character
434 * In case of success %0 is returned and @buf and @size are updated with
435 * the amount of bytes read. If @tr is non-NULL and a trailing
436 * character exists (size is non-zero after returning from this
437 * function), @tr is updated with the trailing character.
439 static int proc_get_long(char **buf
, size_t *size
,
440 unsigned long *val
, bool *neg
,
441 const char *perm_tr
, unsigned perm_tr_len
, char *tr
)
444 char *p
, tmp
[TMPBUFLEN
];
450 if (len
> TMPBUFLEN
- 1)
453 memcpy(tmp
, *buf
, len
);
457 if (*p
== '-' && *size
> 1) {
465 if (strtoul_lenient(p
, &p
, 0, val
))
470 /* We don't know if the next char is whitespace thus we may accept
471 * invalid integers (e.g. 1234...a) or two integers instead of one
472 * (e.g. 123...1). So lets not allow such large numbers. */
473 if (len
== TMPBUFLEN
- 1)
476 if (len
< *size
&& perm_tr_len
&& !memchr(perm_tr
, *p
, perm_tr_len
))
479 if (tr
&& (len
< *size
))
489 * proc_put_long - converts an integer to a decimal ASCII formatted string
491 * @buf: the user buffer
492 * @size: the size of the user buffer
493 * @val: the integer to be converted
494 * @neg: sign of the number, %TRUE for negative
496 * In case of success @buf and @size are updated with the amount of bytes
499 static void proc_put_long(void **buf
, size_t *size
, unsigned long val
, bool neg
)
502 char tmp
[TMPBUFLEN
], *p
= tmp
;
504 sprintf(p
, "%s%lu", neg
? "-" : "", val
);
508 memcpy(*buf
, tmp
, len
);
514 static void proc_put_char(void **buf
, size_t *size
, char c
)
517 char **buffer
= (char **)buf
;
526 static int do_proc_dointvec_conv(bool *negp
, unsigned long *lvalp
,
528 int write
, void *data
)
532 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
536 if (*lvalp
> (unsigned long) INT_MAX
)
544 *lvalp
= -(unsigned long)val
;
547 *lvalp
= (unsigned long)val
;
553 static int do_proc_douintvec_conv(unsigned long *lvalp
,
555 int write
, void *data
)
558 if (*lvalp
> UINT_MAX
)
562 unsigned int val
= *valp
;
563 *lvalp
= (unsigned long)val
;
568 static const char proc_wspace_sep
[] = { ' ', '\t', '\n' };
570 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
571 int write
, void *buffer
,
572 size_t *lenp
, loff_t
*ppos
,
573 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
574 int write
, void *data
),
577 int *i
, vleft
, first
= 1, err
= 0;
581 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
586 i
= (int *) tbl_data
;
587 vleft
= table
->maxlen
/ sizeof(*i
);
591 conv
= do_proc_dointvec_conv
;
594 if (proc_first_pos_non_zero_ignore(ppos
, table
))
597 if (left
> PAGE_SIZE
- 1)
598 left
= PAGE_SIZE
- 1;
602 for (; left
&& vleft
--; i
++, first
=0) {
607 left
-= proc_skip_spaces(&p
);
611 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
613 sizeof(proc_wspace_sep
), NULL
);
616 if (conv(&neg
, &lval
, i
, 1, data
)) {
621 if (conv(&neg
, &lval
, i
, 0, data
)) {
626 proc_put_char(&buffer
, &left
, '\t');
627 proc_put_long(&buffer
, &left
, lval
, neg
);
631 if (!write
&& !first
&& left
&& !err
)
632 proc_put_char(&buffer
, &left
, '\n');
633 if (write
&& !err
&& left
)
634 left
-= proc_skip_spaces(&p
);
636 return err
? : -EINVAL
;
643 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
644 void *buffer
, size_t *lenp
, loff_t
*ppos
,
645 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
646 int write
, void *data
),
649 return __do_proc_dointvec(table
->data
, table
, write
,
650 buffer
, lenp
, ppos
, conv
, data
);
653 static int do_proc_douintvec_w(unsigned int *tbl_data
,
654 struct ctl_table
*table
,
656 size_t *lenp
, loff_t
*ppos
,
657 int (*conv
)(unsigned long *lvalp
,
659 int write
, void *data
),
670 if (proc_first_pos_non_zero_ignore(ppos
, table
))
673 if (left
> PAGE_SIZE
- 1)
674 left
= PAGE_SIZE
- 1;
676 left
-= proc_skip_spaces(&p
);
682 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
684 sizeof(proc_wspace_sep
), NULL
);
690 if (conv(&lval
, tbl_data
, 1, data
)) {
696 left
-= proc_skip_spaces(&p
);
704 /* This is in keeping with old __do_proc_dointvec() */
710 static int do_proc_douintvec_r(unsigned int *tbl_data
, void *buffer
,
711 size_t *lenp
, loff_t
*ppos
,
712 int (*conv
)(unsigned long *lvalp
,
714 int write
, void *data
),
723 if (conv(&lval
, tbl_data
, 0, data
)) {
728 proc_put_long(&buffer
, &left
, lval
, false);
732 proc_put_char(&buffer
, &left
, '\n');
741 static int __do_proc_douintvec(void *tbl_data
, struct ctl_table
*table
,
742 int write
, void *buffer
,
743 size_t *lenp
, loff_t
*ppos
,
744 int (*conv
)(unsigned long *lvalp
,
746 int write
, void *data
),
749 unsigned int *i
, vleft
;
751 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
756 i
= (unsigned int *) tbl_data
;
757 vleft
= table
->maxlen
/ sizeof(*i
);
760 * Arrays are not supported, keep this simple. *Do not* add
769 conv
= do_proc_douintvec_conv
;
772 return do_proc_douintvec_w(i
, table
, buffer
, lenp
, ppos
,
774 return do_proc_douintvec_r(i
, buffer
, lenp
, ppos
, conv
, data
);
777 static int do_proc_douintvec(struct ctl_table
*table
, int write
,
778 void *buffer
, size_t *lenp
, loff_t
*ppos
,
779 int (*conv
)(unsigned long *lvalp
,
781 int write
, void *data
),
784 return __do_proc_douintvec(table
->data
, table
, write
,
785 buffer
, lenp
, ppos
, conv
, data
);
789 * proc_dointvec - read a vector of integers
790 * @table: the sysctl table
791 * @write: %TRUE if this is a write to the sysctl file
792 * @buffer: the user buffer
793 * @lenp: the size of the user buffer
794 * @ppos: file position
796 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
797 * values from/to the user buffer, treated as an ASCII string.
799 * Returns 0 on success.
801 int proc_dointvec(struct ctl_table
*table
, int write
, void *buffer
,
802 size_t *lenp
, loff_t
*ppos
)
804 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
, NULL
, NULL
);
807 #ifdef CONFIG_COMPACTION
808 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table
*table
,
809 int write
, void *buffer
, size_t *lenp
, loff_t
*ppos
)
813 if (!IS_ENABLED(CONFIG_PREEMPT_RT
) || !write
)
814 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
816 old
= *(int *)table
->data
;
817 ret
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
820 if (old
!= *(int *)table
->data
)
821 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
822 table
->procname
, current
->comm
,
823 task_pid_nr(current
));
829 * proc_douintvec - read a vector of unsigned integers
830 * @table: the sysctl table
831 * @write: %TRUE if this is a write to the sysctl file
832 * @buffer: the user buffer
833 * @lenp: the size of the user buffer
834 * @ppos: file position
836 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
837 * values from/to the user buffer, treated as an ASCII string.
839 * Returns 0 on success.
841 int proc_douintvec(struct ctl_table
*table
, int write
, void *buffer
,
842 size_t *lenp
, loff_t
*ppos
)
844 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
845 do_proc_douintvec_conv
, NULL
);
849 * Taint values can only be increased
850 * This means we can safely use a temporary.
852 static int proc_taint(struct ctl_table
*table
, int write
,
853 void *buffer
, size_t *lenp
, loff_t
*ppos
)
856 unsigned long tmptaint
= get_taint();
859 if (write
&& !capable(CAP_SYS_ADMIN
))
864 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
872 * If we are relying on panic_on_taint not producing
873 * false positives due to userspace input, bail out
874 * before setting the requested taint flags.
876 if (panic_on_taint_nousertaint
&& (tmptaint
& panic_on_taint
))
880 * Poor man's atomic or. Not worth adding a primitive
881 * to everyone's atomic.h for this
883 for (i
= 0; i
< TAINT_FLAGS_COUNT
; i
++)
884 if ((1UL << i
) & tmptaint
)
885 add_taint(i
, LOCKDEP_STILL_OK
);
892 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
893 void *buffer
, size_t *lenp
, loff_t
*ppos
)
895 if (write
&& !capable(CAP_SYS_ADMIN
))
898 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
903 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
904 * @min: pointer to minimum allowable value
905 * @max: pointer to maximum allowable value
907 * The do_proc_dointvec_minmax_conv_param structure provides the
908 * minimum and maximum values for doing range checking for those sysctl
909 * parameters that use the proc_dointvec_minmax() handler.
911 struct do_proc_dointvec_minmax_conv_param
{
916 static int do_proc_dointvec_minmax_conv(bool *negp
, unsigned long *lvalp
,
918 int write
, void *data
)
921 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
923 * If writing, first do so via a temporary local int so we can
924 * bounds-check it before touching *valp.
926 int *ip
= write
? &tmp
: valp
;
928 ret
= do_proc_dointvec_conv(negp
, lvalp
, ip
, write
, data
);
933 if ((param
->min
&& *param
->min
> tmp
) ||
934 (param
->max
&& *param
->max
< tmp
))
943 * proc_dointvec_minmax - read a vector of integers with min/max values
944 * @table: the sysctl table
945 * @write: %TRUE if this is a write to the sysctl file
946 * @buffer: the user buffer
947 * @lenp: the size of the user buffer
948 * @ppos: file position
950 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
951 * values from/to the user buffer, treated as an ASCII string.
953 * This routine will ensure the values are within the range specified by
954 * table->extra1 (min) and table->extra2 (max).
956 * Returns 0 on success or -EINVAL on write when the range check fails.
958 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
959 void *buffer
, size_t *lenp
, loff_t
*ppos
)
961 struct do_proc_dointvec_minmax_conv_param param
= {
962 .min
= (int *) table
->extra1
,
963 .max
= (int *) table
->extra2
,
965 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
966 do_proc_dointvec_minmax_conv
, ¶m
);
970 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
971 * @min: pointer to minimum allowable value
972 * @max: pointer to maximum allowable value
974 * The do_proc_douintvec_minmax_conv_param structure provides the
975 * minimum and maximum values for doing range checking for those sysctl
976 * parameters that use the proc_douintvec_minmax() handler.
978 struct do_proc_douintvec_minmax_conv_param
{
983 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp
,
985 int write
, void *data
)
989 struct do_proc_douintvec_minmax_conv_param
*param
= data
;
990 /* write via temporary local uint for bounds-checking */
991 unsigned int *up
= write
? &tmp
: valp
;
993 ret
= do_proc_douintvec_conv(lvalp
, up
, write
, data
);
998 if ((param
->min
&& *param
->min
> tmp
) ||
999 (param
->max
&& *param
->max
< tmp
))
1009 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1010 * @table: the sysctl table
1011 * @write: %TRUE if this is a write to the sysctl file
1012 * @buffer: the user buffer
1013 * @lenp: the size of the user buffer
1014 * @ppos: file position
1016 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1017 * values from/to the user buffer, treated as an ASCII string. Negative
1018 * strings are not allowed.
1020 * This routine will ensure the values are within the range specified by
1021 * table->extra1 (min) and table->extra2 (max). There is a final sanity
1022 * check for UINT_MAX to avoid having to support wrap around uses from
1025 * Returns 0 on success or -ERANGE on write when the range check fails.
1027 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
1028 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1030 struct do_proc_douintvec_minmax_conv_param param
= {
1031 .min
= (unsigned int *) table
->extra1
,
1032 .max
= (unsigned int *) table
->extra2
,
1034 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
1035 do_proc_douintvec_minmax_conv
, ¶m
);
1038 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp
,
1040 int write
, void *data
)
1045 val
= round_pipe_size(*lvalp
);
1051 unsigned int val
= *valp
;
1052 *lvalp
= (unsigned long) val
;
1058 static int proc_dopipe_max_size(struct ctl_table
*table
, int write
,
1059 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1061 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
1062 do_proc_dopipe_max_size_conv
, NULL
);
1065 static void validate_coredump_safety(void)
1067 #ifdef CONFIG_COREDUMP
1068 if (suid_dumpable
== SUID_DUMP_ROOT
&&
1069 core_pattern
[0] != '/' && core_pattern
[0] != '|') {
1071 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1072 "Pipe handler or fully qualified core dump path required.\n"
1073 "Set kernel.core_pattern before fs.suid_dumpable.\n"
1079 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
1080 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1082 int error
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
1084 validate_coredump_safety();
1088 #ifdef CONFIG_COREDUMP
1089 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
1090 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1092 int error
= proc_dostring(table
, write
, buffer
, lenp
, ppos
);
1094 validate_coredump_safety();
1099 #ifdef CONFIG_MAGIC_SYSRQ
1100 static int sysrq_sysctl_handler(struct ctl_table
*table
, int write
,
1101 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1107 ret
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
1108 lenp
, ppos
, NULL
, NULL
);
1113 sysrq_toggle_support(tmp
);
1119 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
,
1120 int write
, void *buffer
, size_t *lenp
, loff_t
*ppos
,
1121 unsigned long convmul
, unsigned long convdiv
)
1123 unsigned long *i
, *min
, *max
;
1124 int vleft
, first
= 1, err
= 0;
1128 if (!data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
1133 i
= (unsigned long *) data
;
1134 min
= (unsigned long *) table
->extra1
;
1135 max
= (unsigned long *) table
->extra2
;
1136 vleft
= table
->maxlen
/ sizeof(unsigned long);
1140 if (proc_first_pos_non_zero_ignore(ppos
, table
))
1143 if (left
> PAGE_SIZE
- 1)
1144 left
= PAGE_SIZE
- 1;
1148 for (; left
&& vleft
--; i
++, first
= 0) {
1154 left
-= proc_skip_spaces(&p
);
1158 err
= proc_get_long(&p
, &left
, &val
, &neg
,
1160 sizeof(proc_wspace_sep
), NULL
);
1165 val
= convmul
* val
/ convdiv
;
1166 if ((min
&& val
< *min
) || (max
&& val
> *max
)) {
1172 val
= convdiv
* (*i
) / convmul
;
1174 proc_put_char(&buffer
, &left
, '\t');
1175 proc_put_long(&buffer
, &left
, val
, false);
1179 if (!write
&& !first
&& left
&& !err
)
1180 proc_put_char(&buffer
, &left
, '\n');
1182 left
-= proc_skip_spaces(&p
);
1184 return err
? : -EINVAL
;
1191 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
1192 void *buffer
, size_t *lenp
, loff_t
*ppos
, unsigned long convmul
,
1193 unsigned long convdiv
)
1195 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
1196 buffer
, lenp
, ppos
, convmul
, convdiv
);
1200 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1201 * @table: the sysctl table
1202 * @write: %TRUE if this is a write to the sysctl file
1203 * @buffer: the user buffer
1204 * @lenp: the size of the user buffer
1205 * @ppos: file position
1207 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1208 * values from/to the user buffer, treated as an ASCII string.
1210 * This routine will ensure the values are within the range specified by
1211 * table->extra1 (min) and table->extra2 (max).
1213 * Returns 0 on success.
1215 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
1216 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1218 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
1222 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1223 * @table: the sysctl table
1224 * @write: %TRUE if this is a write to the sysctl file
1225 * @buffer: the user buffer
1226 * @lenp: the size of the user buffer
1227 * @ppos: file position
1229 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1230 * values from/to the user buffer, treated as an ASCII string. The values
1231 * are treated as milliseconds, and converted to jiffies when they are stored.
1233 * This routine will ensure the values are within the range specified by
1234 * table->extra1 (min) and table->extra2 (max).
1236 * Returns 0 on success.
1238 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
1239 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1241 return do_proc_doulongvec_minmax(table
, write
, buffer
,
1242 lenp
, ppos
, HZ
, 1000l);
1246 static int do_proc_dointvec_jiffies_conv(bool *negp
, unsigned long *lvalp
,
1248 int write
, void *data
)
1251 if (*lvalp
> INT_MAX
/ HZ
)
1253 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
1259 lval
= -(unsigned long)val
;
1262 lval
= (unsigned long)val
;
1269 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp
, unsigned long *lvalp
,
1271 int write
, void *data
)
1274 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
1276 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
1282 lval
= -(unsigned long)val
;
1285 lval
= (unsigned long)val
;
1287 *lvalp
= jiffies_to_clock_t(lval
);
1292 static int do_proc_dointvec_ms_jiffies_conv(bool *negp
, unsigned long *lvalp
,
1294 int write
, void *data
)
1297 unsigned long jif
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
1307 lval
= -(unsigned long)val
;
1310 lval
= (unsigned long)val
;
1312 *lvalp
= jiffies_to_msecs(lval
);
1318 * proc_dointvec_jiffies - read a vector of integers as seconds
1319 * @table: the sysctl table
1320 * @write: %TRUE if this is a write to the sysctl file
1321 * @buffer: the user buffer
1322 * @lenp: the size of the user buffer
1323 * @ppos: file position
1325 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1326 * values from/to the user buffer, treated as an ASCII string.
1327 * The values read are assumed to be in seconds, and are converted into
1330 * Returns 0 on success.
1332 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
1333 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1335 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
1336 do_proc_dointvec_jiffies_conv
,NULL
);
1340 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1341 * @table: the sysctl table
1342 * @write: %TRUE if this is a write to the sysctl file
1343 * @buffer: the user buffer
1344 * @lenp: the size of the user buffer
1345 * @ppos: pointer to the file position
1347 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1348 * values from/to the user buffer, treated as an ASCII string.
1349 * The values read are assumed to be in 1/USER_HZ seconds, and
1350 * are converted into jiffies.
1352 * Returns 0 on success.
1354 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
1355 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1357 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
1358 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
1362 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1363 * @table: the sysctl table
1364 * @write: %TRUE if this is a write to the sysctl file
1365 * @buffer: the user buffer
1366 * @lenp: the size of the user buffer
1367 * @ppos: file position
1368 * @ppos: the current position in the file
1370 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1371 * values from/to the user buffer, treated as an ASCII string.
1372 * The values read are assumed to be in 1/1000 seconds, and
1373 * are converted into jiffies.
1375 * Returns 0 on success.
1377 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
, void *buffer
,
1378 size_t *lenp
, loff_t
*ppos
)
1380 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
1381 do_proc_dointvec_ms_jiffies_conv
, NULL
);
1384 static int proc_do_cad_pid(struct ctl_table
*table
, int write
, void *buffer
,
1385 size_t *lenp
, loff_t
*ppos
)
1387 struct pid
*new_pid
;
1391 tmp
= pid_vnr(cad_pid
);
1393 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
1394 lenp
, ppos
, NULL
, NULL
);
1398 new_pid
= find_get_pid(tmp
);
1402 put_pid(xchg(&cad_pid
, new_pid
));
1407 * proc_do_large_bitmap - read/write from/to a large bitmap
1408 * @table: the sysctl table
1409 * @write: %TRUE if this is a write to the sysctl file
1410 * @buffer: the user buffer
1411 * @lenp: the size of the user buffer
1412 * @ppos: file position
1414 * The bitmap is stored at table->data and the bitmap length (in bits)
1417 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1418 * large bitmaps may be represented in a compact manner. Writing into
1419 * the file will clear the bitmap then update it with the given input.
1421 * Returns 0 on success.
1423 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
1424 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1428 size_t left
= *lenp
;
1429 unsigned long bitmap_len
= table
->maxlen
;
1430 unsigned long *bitmap
= *(unsigned long **) table
->data
;
1431 unsigned long *tmp_bitmap
= NULL
;
1432 char tr_a
[] = { '-', ',', '\n' }, tr_b
[] = { ',', '\n', 0 }, c
;
1434 if (!bitmap
|| !bitmap_len
|| !left
|| (*ppos
&& !write
)) {
1443 if (left
> PAGE_SIZE
- 1) {
1444 left
= PAGE_SIZE
- 1;
1445 /* How much of the buffer we'll skip this pass */
1446 skipped
= *lenp
- left
;
1449 tmp_bitmap
= bitmap_zalloc(bitmap_len
, GFP_KERNEL
);
1452 proc_skip_char(&p
, &left
, '\n');
1453 while (!err
&& left
) {
1454 unsigned long val_a
, val_b
;
1458 /* In case we stop parsing mid-number, we can reset */
1460 err
= proc_get_long(&p
, &left
, &val_a
, &neg
, tr_a
,
1463 * If we consumed the entirety of a truncated buffer or
1464 * only one char is left (may be a "-"), then stop here,
1465 * reset, & come back for more.
1467 if ((left
<= 1) && skipped
) {
1474 if (val_a
>= bitmap_len
|| neg
) {
1486 err
= proc_get_long(&p
, &left
, &val_b
,
1487 &neg
, tr_b
, sizeof(tr_b
),
1490 * If we consumed all of a truncated buffer or
1491 * then stop here, reset, & come back for more.
1493 if (!left
&& skipped
) {
1500 if (val_b
>= bitmap_len
|| neg
||
1511 bitmap_set(tmp_bitmap
, val_a
, val_b
- val_a
+ 1);
1513 proc_skip_char(&p
, &left
, '\n');
1517 unsigned long bit_a
, bit_b
= 0;
1520 bit_a
= find_next_bit(bitmap
, bitmap_len
, bit_b
);
1521 if (bit_a
>= bitmap_len
)
1523 bit_b
= find_next_zero_bit(bitmap
, bitmap_len
,
1527 proc_put_char(&buffer
, &left
, ',');
1528 proc_put_long(&buffer
, &left
, bit_a
, false);
1529 if (bit_a
!= bit_b
) {
1530 proc_put_char(&buffer
, &left
, '-');
1531 proc_put_long(&buffer
, &left
, bit_b
, false);
1536 proc_put_char(&buffer
, &left
, '\n');
1542 bitmap_or(bitmap
, bitmap
, tmp_bitmap
, bitmap_len
);
1544 bitmap_copy(bitmap
, tmp_bitmap
, bitmap_len
);
1550 bitmap_free(tmp_bitmap
);
1554 #else /* CONFIG_PROC_SYSCTL */
1556 int proc_dostring(struct ctl_table
*table
, int write
,
1557 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1562 int proc_dointvec(struct ctl_table
*table
, int write
,
1563 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1568 int proc_douintvec(struct ctl_table
*table
, int write
,
1569 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1574 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
1575 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1580 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
1581 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1586 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
1587 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1592 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
1593 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1598 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
1599 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1604 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
1605 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1610 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
1611 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1616 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
1617 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1622 #endif /* CONFIG_PROC_SYSCTL */
1624 #if defined(CONFIG_SYSCTL)
1625 int proc_do_static_key(struct ctl_table
*table
, int write
,
1626 void *buffer
, size_t *lenp
, loff_t
*ppos
)
1628 struct static_key
*key
= (struct static_key
*)table
->data
;
1629 static DEFINE_MUTEX(static_key_mutex
);
1631 struct ctl_table tmp
= {
1633 .maxlen
= sizeof(val
),
1634 .mode
= table
->mode
,
1635 .extra1
= SYSCTL_ZERO
,
1636 .extra2
= SYSCTL_ONE
,
1639 if (write
&& !capable(CAP_SYS_ADMIN
))
1642 mutex_lock(&static_key_mutex
);
1643 val
= static_key_enabled(key
);
1644 ret
= proc_dointvec_minmax(&tmp
, write
, buffer
, lenp
, ppos
);
1645 if (write
&& !ret
) {
1647 static_key_enable(key
);
1649 static_key_disable(key
);
1651 mutex_unlock(&static_key_mutex
);
1655 static struct ctl_table kern_table
[] = {
1657 .procname
= "sched_child_runs_first",
1658 .data
= &sysctl_sched_child_runs_first
,
1659 .maxlen
= sizeof(unsigned int),
1661 .proc_handler
= proc_dointvec
,
1663 #ifdef CONFIG_SCHED_DEBUG
1665 .procname
= "sched_min_granularity_ns",
1666 .data
= &sysctl_sched_min_granularity
,
1667 .maxlen
= sizeof(unsigned int),
1669 .proc_handler
= sched_proc_update_handler
,
1670 .extra1
= &min_sched_granularity_ns
,
1671 .extra2
= &max_sched_granularity_ns
,
1674 .procname
= "sched_latency_ns",
1675 .data
= &sysctl_sched_latency
,
1676 .maxlen
= sizeof(unsigned int),
1678 .proc_handler
= sched_proc_update_handler
,
1679 .extra1
= &min_sched_granularity_ns
,
1680 .extra2
= &max_sched_granularity_ns
,
1683 .procname
= "sched_wakeup_granularity_ns",
1684 .data
= &sysctl_sched_wakeup_granularity
,
1685 .maxlen
= sizeof(unsigned int),
1687 .proc_handler
= sched_proc_update_handler
,
1688 .extra1
= &min_wakeup_granularity_ns
,
1689 .extra2
= &max_wakeup_granularity_ns
,
1693 .procname
= "sched_tunable_scaling",
1694 .data
= &sysctl_sched_tunable_scaling
,
1695 .maxlen
= sizeof(enum sched_tunable_scaling
),
1697 .proc_handler
= sched_proc_update_handler
,
1698 .extra1
= &min_sched_tunable_scaling
,
1699 .extra2
= &max_sched_tunable_scaling
,
1702 .procname
= "sched_migration_cost_ns",
1703 .data
= &sysctl_sched_migration_cost
,
1704 .maxlen
= sizeof(unsigned int),
1706 .proc_handler
= proc_dointvec
,
1709 .procname
= "sched_nr_migrate",
1710 .data
= &sysctl_sched_nr_migrate
,
1711 .maxlen
= sizeof(unsigned int),
1713 .proc_handler
= proc_dointvec
,
1715 #ifdef CONFIG_SCHEDSTATS
1717 .procname
= "sched_schedstats",
1719 .maxlen
= sizeof(unsigned int),
1721 .proc_handler
= sysctl_schedstats
,
1722 .extra1
= SYSCTL_ZERO
,
1723 .extra2
= SYSCTL_ONE
,
1725 #endif /* CONFIG_SCHEDSTATS */
1726 #endif /* CONFIG_SMP */
1727 #ifdef CONFIG_NUMA_BALANCING
1729 .procname
= "numa_balancing_scan_delay_ms",
1730 .data
= &sysctl_numa_balancing_scan_delay
,
1731 .maxlen
= sizeof(unsigned int),
1733 .proc_handler
= proc_dointvec
,
1736 .procname
= "numa_balancing_scan_period_min_ms",
1737 .data
= &sysctl_numa_balancing_scan_period_min
,
1738 .maxlen
= sizeof(unsigned int),
1740 .proc_handler
= proc_dointvec
,
1743 .procname
= "numa_balancing_scan_period_max_ms",
1744 .data
= &sysctl_numa_balancing_scan_period_max
,
1745 .maxlen
= sizeof(unsigned int),
1747 .proc_handler
= proc_dointvec
,
1750 .procname
= "numa_balancing_scan_size_mb",
1751 .data
= &sysctl_numa_balancing_scan_size
,
1752 .maxlen
= sizeof(unsigned int),
1754 .proc_handler
= proc_dointvec_minmax
,
1755 .extra1
= SYSCTL_ONE
,
1758 .procname
= "numa_balancing",
1759 .data
= NULL
, /* filled in by handler */
1760 .maxlen
= sizeof(unsigned int),
1762 .proc_handler
= sysctl_numa_balancing
,
1763 .extra1
= SYSCTL_ZERO
,
1764 .extra2
= SYSCTL_ONE
,
1766 #endif /* CONFIG_NUMA_BALANCING */
1767 #endif /* CONFIG_SCHED_DEBUG */
1769 .procname
= "sched_rt_period_us",
1770 .data
= &sysctl_sched_rt_period
,
1771 .maxlen
= sizeof(unsigned int),
1773 .proc_handler
= sched_rt_handler
,
1776 .procname
= "sched_rt_runtime_us",
1777 .data
= &sysctl_sched_rt_runtime
,
1778 .maxlen
= sizeof(int),
1780 .proc_handler
= sched_rt_handler
,
1783 .procname
= "sched_rr_timeslice_ms",
1784 .data
= &sysctl_sched_rr_timeslice
,
1785 .maxlen
= sizeof(int),
1787 .proc_handler
= sched_rr_handler
,
1789 #ifdef CONFIG_UCLAMP_TASK
1791 .procname
= "sched_util_clamp_min",
1792 .data
= &sysctl_sched_uclamp_util_min
,
1793 .maxlen
= sizeof(unsigned int),
1795 .proc_handler
= sysctl_sched_uclamp_handler
,
1798 .procname
= "sched_util_clamp_max",
1799 .data
= &sysctl_sched_uclamp_util_max
,
1800 .maxlen
= sizeof(unsigned int),
1802 .proc_handler
= sysctl_sched_uclamp_handler
,
1805 #ifdef CONFIG_SCHED_AUTOGROUP
1807 .procname
= "sched_autogroup_enabled",
1808 .data
= &sysctl_sched_autogroup_enabled
,
1809 .maxlen
= sizeof(unsigned int),
1811 .proc_handler
= proc_dointvec_minmax
,
1812 .extra1
= SYSCTL_ZERO
,
1813 .extra2
= SYSCTL_ONE
,
1816 #ifdef CONFIG_CFS_BANDWIDTH
1818 .procname
= "sched_cfs_bandwidth_slice_us",
1819 .data
= &sysctl_sched_cfs_bandwidth_slice
,
1820 .maxlen
= sizeof(unsigned int),
1822 .proc_handler
= proc_dointvec_minmax
,
1823 .extra1
= SYSCTL_ONE
,
1826 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1828 .procname
= "sched_energy_aware",
1829 .data
= &sysctl_sched_energy_aware
,
1830 .maxlen
= sizeof(unsigned int),
1832 .proc_handler
= sched_energy_aware_handler
,
1833 .extra1
= SYSCTL_ZERO
,
1834 .extra2
= SYSCTL_ONE
,
1837 #ifdef CONFIG_PROVE_LOCKING
1839 .procname
= "prove_locking",
1840 .data
= &prove_locking
,
1841 .maxlen
= sizeof(int),
1843 .proc_handler
= proc_dointvec
,
1846 #ifdef CONFIG_LOCK_STAT
1848 .procname
= "lock_stat",
1850 .maxlen
= sizeof(int),
1852 .proc_handler
= proc_dointvec
,
1856 .procname
= "panic",
1857 .data
= &panic_timeout
,
1858 .maxlen
= sizeof(int),
1860 .proc_handler
= proc_dointvec
,
1862 #ifdef CONFIG_COREDUMP
1864 .procname
= "core_uses_pid",
1865 .data
= &core_uses_pid
,
1866 .maxlen
= sizeof(int),
1868 .proc_handler
= proc_dointvec
,
1871 .procname
= "core_pattern",
1872 .data
= core_pattern
,
1873 .maxlen
= CORENAME_MAX_SIZE
,
1875 .proc_handler
= proc_dostring_coredump
,
1878 .procname
= "core_pipe_limit",
1879 .data
= &core_pipe_limit
,
1880 .maxlen
= sizeof(unsigned int),
1882 .proc_handler
= proc_dointvec
,
1885 #ifdef CONFIG_PROC_SYSCTL
1887 .procname
= "tainted",
1888 .maxlen
= sizeof(long),
1890 .proc_handler
= proc_taint
,
1893 .procname
= "sysctl_writes_strict",
1894 .data
= &sysctl_writes_strict
,
1895 .maxlen
= sizeof(int),
1897 .proc_handler
= proc_dointvec_minmax
,
1899 .extra2
= SYSCTL_ONE
,
1902 #ifdef CONFIG_LATENCYTOP
1904 .procname
= "latencytop",
1905 .data
= &latencytop_enabled
,
1906 .maxlen
= sizeof(int),
1908 .proc_handler
= sysctl_latencytop
,
1911 #ifdef CONFIG_BLK_DEV_INITRD
1913 .procname
= "real-root-dev",
1914 .data
= &real_root_dev
,
1915 .maxlen
= sizeof(int),
1917 .proc_handler
= proc_dointvec
,
1921 .procname
= "print-fatal-signals",
1922 .data
= &print_fatal_signals
,
1923 .maxlen
= sizeof(int),
1925 .proc_handler
= proc_dointvec
,
1929 .procname
= "reboot-cmd",
1930 .data
= reboot_command
,
1933 .proc_handler
= proc_dostring
,
1936 .procname
= "stop-a",
1937 .data
= &stop_a_enabled
,
1938 .maxlen
= sizeof (int),
1940 .proc_handler
= proc_dointvec
,
1943 .procname
= "scons-poweroff",
1944 .data
= &scons_pwroff
,
1945 .maxlen
= sizeof (int),
1947 .proc_handler
= proc_dointvec
,
1950 #ifdef CONFIG_SPARC64
1952 .procname
= "tsb-ratio",
1953 .data
= &sysctl_tsb_ratio
,
1954 .maxlen
= sizeof (int),
1956 .proc_handler
= proc_dointvec
,
1959 #ifdef CONFIG_PARISC
1961 .procname
= "soft-power",
1962 .data
= &pwrsw_enabled
,
1963 .maxlen
= sizeof (int),
1965 .proc_handler
= proc_dointvec
,
1968 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
1970 .procname
= "unaligned-trap",
1971 .data
= &unaligned_enabled
,
1972 .maxlen
= sizeof (int),
1974 .proc_handler
= proc_dointvec
,
1978 .procname
= "ctrl-alt-del",
1980 .maxlen
= sizeof(int),
1982 .proc_handler
= proc_dointvec
,
1984 #ifdef CONFIG_FUNCTION_TRACER
1986 .procname
= "ftrace_enabled",
1987 .data
= &ftrace_enabled
,
1988 .maxlen
= sizeof(int),
1990 .proc_handler
= ftrace_enable_sysctl
,
1993 #ifdef CONFIG_STACK_TRACER
1995 .procname
= "stack_tracer_enabled",
1996 .data
= &stack_tracer_enabled
,
1997 .maxlen
= sizeof(int),
1999 .proc_handler
= stack_trace_sysctl
,
2002 #ifdef CONFIG_TRACING
2004 .procname
= "ftrace_dump_on_oops",
2005 .data
= &ftrace_dump_on_oops
,
2006 .maxlen
= sizeof(int),
2008 .proc_handler
= proc_dointvec
,
2011 .procname
= "traceoff_on_warning",
2012 .data
= &__disable_trace_on_warning
,
2013 .maxlen
= sizeof(__disable_trace_on_warning
),
2015 .proc_handler
= proc_dointvec
,
2018 .procname
= "tracepoint_printk",
2019 .data
= &tracepoint_printk
,
2020 .maxlen
= sizeof(tracepoint_printk
),
2022 .proc_handler
= tracepoint_printk_sysctl
,
2025 #ifdef CONFIG_KEXEC_CORE
2027 .procname
= "kexec_load_disabled",
2028 .data
= &kexec_load_disabled
,
2029 .maxlen
= sizeof(int),
2031 /* only handle a transition from default "0" to "1" */
2032 .proc_handler
= proc_dointvec_minmax
,
2033 .extra1
= SYSCTL_ONE
,
2034 .extra2
= SYSCTL_ONE
,
2037 #ifdef CONFIG_MODULES
2039 .procname
= "modprobe",
2040 .data
= &modprobe_path
,
2041 .maxlen
= KMOD_PATH_LEN
,
2043 .proc_handler
= proc_dostring
,
2046 .procname
= "modules_disabled",
2047 .data
= &modules_disabled
,
2048 .maxlen
= sizeof(int),
2050 /* only handle a transition from default "0" to "1" */
2051 .proc_handler
= proc_dointvec_minmax
,
2052 .extra1
= SYSCTL_ONE
,
2053 .extra2
= SYSCTL_ONE
,
2056 #ifdef CONFIG_UEVENT_HELPER
2058 .procname
= "hotplug",
2059 .data
= &uevent_helper
,
2060 .maxlen
= UEVENT_HELPER_PATH_LEN
,
2062 .proc_handler
= proc_dostring
,
2065 #ifdef CONFIG_CHR_DEV_SG
2067 .procname
= "sg-big-buff",
2068 .data
= &sg_big_buff
,
2069 .maxlen
= sizeof (int),
2071 .proc_handler
= proc_dointvec
,
2074 #ifdef CONFIG_BSD_PROCESS_ACCT
2078 .maxlen
= 3*sizeof(int),
2080 .proc_handler
= proc_dointvec
,
2083 #ifdef CONFIG_MAGIC_SYSRQ
2085 .procname
= "sysrq",
2087 .maxlen
= sizeof (int),
2089 .proc_handler
= sysrq_sysctl_handler
,
2092 #ifdef CONFIG_PROC_SYSCTL
2094 .procname
= "cad_pid",
2096 .maxlen
= sizeof (int),
2098 .proc_handler
= proc_do_cad_pid
,
2102 .procname
= "threads-max",
2104 .maxlen
= sizeof(int),
2106 .proc_handler
= sysctl_max_threads
,
2109 .procname
= "random",
2111 .child
= random_table
,
2114 .procname
= "usermodehelper",
2116 .child
= usermodehelper_table
,
2118 #ifdef CONFIG_FW_LOADER_USER_HELPER
2120 .procname
= "firmware_config",
2122 .child
= firmware_config_table
,
2126 .procname
= "overflowuid",
2127 .data
= &overflowuid
,
2128 .maxlen
= sizeof(int),
2130 .proc_handler
= proc_dointvec_minmax
,
2131 .extra1
= &minolduid
,
2132 .extra2
= &maxolduid
,
2135 .procname
= "overflowgid",
2136 .data
= &overflowgid
,
2137 .maxlen
= sizeof(int),
2139 .proc_handler
= proc_dointvec_minmax
,
2140 .extra1
= &minolduid
,
2141 .extra2
= &maxolduid
,
2145 .procname
= "userprocess_debug",
2146 .data
= &show_unhandled_signals
,
2147 .maxlen
= sizeof(int),
2149 .proc_handler
= proc_dointvec
,
2154 .procname
= "oops_all_cpu_backtrace",
2155 .data
= &sysctl_oops_all_cpu_backtrace
,
2156 .maxlen
= sizeof(int),
2158 .proc_handler
= proc_dointvec_minmax
,
2159 .extra1
= SYSCTL_ZERO
,
2160 .extra2
= SYSCTL_ONE
,
2162 #endif /* CONFIG_SMP */
2164 .procname
= "pid_max",
2166 .maxlen
= sizeof (int),
2168 .proc_handler
= proc_dointvec_minmax
,
2169 .extra1
= &pid_max_min
,
2170 .extra2
= &pid_max_max
,
2173 .procname
= "panic_on_oops",
2174 .data
= &panic_on_oops
,
2175 .maxlen
= sizeof(int),
2177 .proc_handler
= proc_dointvec
,
2180 .procname
= "panic_print",
2181 .data
= &panic_print
,
2182 .maxlen
= sizeof(unsigned long),
2184 .proc_handler
= proc_doulongvec_minmax
,
2186 #if defined CONFIG_PRINTK
2188 .procname
= "printk",
2189 .data
= &console_loglevel
,
2190 .maxlen
= 4*sizeof(int),
2192 .proc_handler
= proc_dointvec
,
2195 .procname
= "printk_ratelimit",
2196 .data
= &printk_ratelimit_state
.interval
,
2197 .maxlen
= sizeof(int),
2199 .proc_handler
= proc_dointvec_jiffies
,
2202 .procname
= "printk_ratelimit_burst",
2203 .data
= &printk_ratelimit_state
.burst
,
2204 .maxlen
= sizeof(int),
2206 .proc_handler
= proc_dointvec
,
2209 .procname
= "printk_delay",
2210 .data
= &printk_delay_msec
,
2211 .maxlen
= sizeof(int),
2213 .proc_handler
= proc_dointvec_minmax
,
2214 .extra1
= SYSCTL_ZERO
,
2215 .extra2
= &ten_thousand
,
2218 .procname
= "printk_devkmsg",
2219 .data
= devkmsg_log_str
,
2220 .maxlen
= DEVKMSG_STR_MAX_SIZE
,
2222 .proc_handler
= devkmsg_sysctl_set_loglvl
,
2225 .procname
= "dmesg_restrict",
2226 .data
= &dmesg_restrict
,
2227 .maxlen
= sizeof(int),
2229 .proc_handler
= proc_dointvec_minmax_sysadmin
,
2230 .extra1
= SYSCTL_ZERO
,
2231 .extra2
= SYSCTL_ONE
,
2234 .procname
= "kptr_restrict",
2235 .data
= &kptr_restrict
,
2236 .maxlen
= sizeof(int),
2238 .proc_handler
= proc_dointvec_minmax_sysadmin
,
2239 .extra1
= SYSCTL_ZERO
,
2244 .procname
= "ngroups_max",
2245 .data
= &ngroups_max
,
2246 .maxlen
= sizeof (int),
2248 .proc_handler
= proc_dointvec
,
2251 .procname
= "cap_last_cap",
2252 .data
= (void *)&cap_last_cap
,
2253 .maxlen
= sizeof(int),
2255 .proc_handler
= proc_dointvec
,
2257 #if defined(CONFIG_LOCKUP_DETECTOR)
2259 .procname
= "watchdog",
2260 .data
= &watchdog_user_enabled
,
2261 .maxlen
= sizeof(int),
2263 .proc_handler
= proc_watchdog
,
2264 .extra1
= SYSCTL_ZERO
,
2265 .extra2
= SYSCTL_ONE
,
2268 .procname
= "watchdog_thresh",
2269 .data
= &watchdog_thresh
,
2270 .maxlen
= sizeof(int),
2272 .proc_handler
= proc_watchdog_thresh
,
2273 .extra1
= SYSCTL_ZERO
,
2277 .procname
= "nmi_watchdog",
2278 .data
= &nmi_watchdog_user_enabled
,
2279 .maxlen
= sizeof(int),
2280 .mode
= NMI_WATCHDOG_SYSCTL_PERM
,
2281 .proc_handler
= proc_nmi_watchdog
,
2282 .extra1
= SYSCTL_ZERO
,
2283 .extra2
= SYSCTL_ONE
,
2286 .procname
= "watchdog_cpumask",
2287 .data
= &watchdog_cpumask_bits
,
2290 .proc_handler
= proc_watchdog_cpumask
,
2292 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
2294 .procname
= "soft_watchdog",
2295 .data
= &soft_watchdog_user_enabled
,
2296 .maxlen
= sizeof(int),
2298 .proc_handler
= proc_soft_watchdog
,
2299 .extra1
= SYSCTL_ZERO
,
2300 .extra2
= SYSCTL_ONE
,
2303 .procname
= "softlockup_panic",
2304 .data
= &softlockup_panic
,
2305 .maxlen
= sizeof(int),
2307 .proc_handler
= proc_dointvec_minmax
,
2308 .extra1
= SYSCTL_ZERO
,
2309 .extra2
= SYSCTL_ONE
,
2313 .procname
= "softlockup_all_cpu_backtrace",
2314 .data
= &sysctl_softlockup_all_cpu_backtrace
,
2315 .maxlen
= sizeof(int),
2317 .proc_handler
= proc_dointvec_minmax
,
2318 .extra1
= SYSCTL_ZERO
,
2319 .extra2
= SYSCTL_ONE
,
2321 #endif /* CONFIG_SMP */
2323 #ifdef CONFIG_HARDLOCKUP_DETECTOR
2325 .procname
= "hardlockup_panic",
2326 .data
= &hardlockup_panic
,
2327 .maxlen
= sizeof(int),
2329 .proc_handler
= proc_dointvec_minmax
,
2330 .extra1
= SYSCTL_ZERO
,
2331 .extra2
= SYSCTL_ONE
,
2335 .procname
= "hardlockup_all_cpu_backtrace",
2336 .data
= &sysctl_hardlockup_all_cpu_backtrace
,
2337 .maxlen
= sizeof(int),
2339 .proc_handler
= proc_dointvec_minmax
,
2340 .extra1
= SYSCTL_ZERO
,
2341 .extra2
= SYSCTL_ONE
,
2343 #endif /* CONFIG_SMP */
2347 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2349 .procname
= "unknown_nmi_panic",
2350 .data
= &unknown_nmi_panic
,
2351 .maxlen
= sizeof (int),
2353 .proc_handler
= proc_dointvec
,
2357 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2358 defined(CONFIG_DEBUG_STACKOVERFLOW)
2360 .procname
= "panic_on_stackoverflow",
2361 .data
= &sysctl_panic_on_stackoverflow
,
2362 .maxlen
= sizeof(int),
2364 .proc_handler
= proc_dointvec
,
2367 #if defined(CONFIG_X86)
2369 .procname
= "panic_on_unrecovered_nmi",
2370 .data
= &panic_on_unrecovered_nmi
,
2371 .maxlen
= sizeof(int),
2373 .proc_handler
= proc_dointvec
,
2376 .procname
= "panic_on_io_nmi",
2377 .data
= &panic_on_io_nmi
,
2378 .maxlen
= sizeof(int),
2380 .proc_handler
= proc_dointvec
,
2383 .procname
= "bootloader_type",
2384 .data
= &bootloader_type
,
2385 .maxlen
= sizeof (int),
2387 .proc_handler
= proc_dointvec
,
2390 .procname
= "bootloader_version",
2391 .data
= &bootloader_version
,
2392 .maxlen
= sizeof (int),
2394 .proc_handler
= proc_dointvec
,
2397 .procname
= "io_delay_type",
2398 .data
= &io_delay_type
,
2399 .maxlen
= sizeof(int),
2401 .proc_handler
= proc_dointvec
,
2404 #if defined(CONFIG_MMU)
2406 .procname
= "randomize_va_space",
2407 .data
= &randomize_va_space
,
2408 .maxlen
= sizeof(int),
2410 .proc_handler
= proc_dointvec
,
2413 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2415 .procname
= "spin_retry",
2416 .data
= &spin_retry
,
2417 .maxlen
= sizeof (int),
2419 .proc_handler
= proc_dointvec
,
2422 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2424 .procname
= "acpi_video_flags",
2425 .data
= &acpi_realmode_flags
,
2426 .maxlen
= sizeof (unsigned long),
2428 .proc_handler
= proc_doulongvec_minmax
,
2431 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2433 .procname
= "ignore-unaligned-usertrap",
2434 .data
= &no_unaligned_warning
,
2435 .maxlen
= sizeof (int),
2437 .proc_handler
= proc_dointvec
,
2442 .procname
= "unaligned-dump-stack",
2443 .data
= &unaligned_dump_stack
,
2444 .maxlen
= sizeof (int),
2446 .proc_handler
= proc_dointvec
,
2449 #ifdef CONFIG_DETECT_HUNG_TASK
2452 .procname
= "hung_task_all_cpu_backtrace",
2453 .data
= &sysctl_hung_task_all_cpu_backtrace
,
2454 .maxlen
= sizeof(int),
2456 .proc_handler
= proc_dointvec_minmax
,
2457 .extra1
= SYSCTL_ZERO
,
2458 .extra2
= SYSCTL_ONE
,
2460 #endif /* CONFIG_SMP */
2462 .procname
= "hung_task_panic",
2463 .data
= &sysctl_hung_task_panic
,
2464 .maxlen
= sizeof(int),
2466 .proc_handler
= proc_dointvec_minmax
,
2467 .extra1
= SYSCTL_ZERO
,
2468 .extra2
= SYSCTL_ONE
,
2471 .procname
= "hung_task_check_count",
2472 .data
= &sysctl_hung_task_check_count
,
2473 .maxlen
= sizeof(int),
2475 .proc_handler
= proc_dointvec_minmax
,
2476 .extra1
= SYSCTL_ZERO
,
2479 .procname
= "hung_task_timeout_secs",
2480 .data
= &sysctl_hung_task_timeout_secs
,
2481 .maxlen
= sizeof(unsigned long),
2483 .proc_handler
= proc_dohung_task_timeout_secs
,
2484 .extra2
= &hung_task_timeout_max
,
2487 .procname
= "hung_task_check_interval_secs",
2488 .data
= &sysctl_hung_task_check_interval_secs
,
2489 .maxlen
= sizeof(unsigned long),
2491 .proc_handler
= proc_dohung_task_timeout_secs
,
2492 .extra2
= &hung_task_timeout_max
,
2495 .procname
= "hung_task_warnings",
2496 .data
= &sysctl_hung_task_warnings
,
2497 .maxlen
= sizeof(int),
2499 .proc_handler
= proc_dointvec_minmax
,
2503 #ifdef CONFIG_RT_MUTEXES
2505 .procname
= "max_lock_depth",
2506 .data
= &max_lock_depth
,
2507 .maxlen
= sizeof(int),
2509 .proc_handler
= proc_dointvec
,
2513 .procname
= "poweroff_cmd",
2514 .data
= &poweroff_cmd
,
2515 .maxlen
= POWEROFF_CMD_PATH_LEN
,
2517 .proc_handler
= proc_dostring
,
2523 .child
= key_sysctls
,
2526 #ifdef CONFIG_PERF_EVENTS
2528 * User-space scripts rely on the existence of this file
2529 * as a feature check for perf_events being enabled.
2531 * So it's an ABI, do not remove!
2534 .procname
= "perf_event_paranoid",
2535 .data
= &sysctl_perf_event_paranoid
,
2536 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
2538 .proc_handler
= proc_dointvec
,
2541 .procname
= "perf_event_mlock_kb",
2542 .data
= &sysctl_perf_event_mlock
,
2543 .maxlen
= sizeof(sysctl_perf_event_mlock
),
2545 .proc_handler
= proc_dointvec
,
2548 .procname
= "perf_event_max_sample_rate",
2549 .data
= &sysctl_perf_event_sample_rate
,
2550 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
2552 .proc_handler
= perf_proc_update_handler
,
2553 .extra1
= SYSCTL_ONE
,
2556 .procname
= "perf_cpu_time_max_percent",
2557 .data
= &sysctl_perf_cpu_time_max_percent
,
2558 .maxlen
= sizeof(sysctl_perf_cpu_time_max_percent
),
2560 .proc_handler
= perf_cpu_time_max_percent_handler
,
2561 .extra1
= SYSCTL_ZERO
,
2562 .extra2
= &one_hundred
,
2565 .procname
= "perf_event_max_stack",
2566 .data
= &sysctl_perf_event_max_stack
,
2567 .maxlen
= sizeof(sysctl_perf_event_max_stack
),
2569 .proc_handler
= perf_event_max_stack_handler
,
2570 .extra1
= SYSCTL_ZERO
,
2571 .extra2
= &six_hundred_forty_kb
,
2574 .procname
= "perf_event_max_contexts_per_stack",
2575 .data
= &sysctl_perf_event_max_contexts_per_stack
,
2576 .maxlen
= sizeof(sysctl_perf_event_max_contexts_per_stack
),
2578 .proc_handler
= perf_event_max_stack_handler
,
2579 .extra1
= SYSCTL_ZERO
,
2580 .extra2
= &one_thousand
,
2584 .procname
= "panic_on_warn",
2585 .data
= &panic_on_warn
,
2586 .maxlen
= sizeof(int),
2588 .proc_handler
= proc_dointvec_minmax
,
2589 .extra1
= SYSCTL_ZERO
,
2590 .extra2
= SYSCTL_ONE
,
2592 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2594 .procname
= "timer_migration",
2595 .data
= &sysctl_timer_migration
,
2596 .maxlen
= sizeof(unsigned int),
2598 .proc_handler
= timer_migration_handler
,
2599 .extra1
= SYSCTL_ZERO
,
2600 .extra2
= SYSCTL_ONE
,
2603 #ifdef CONFIG_BPF_SYSCALL
2605 .procname
= "unprivileged_bpf_disabled",
2606 .data
= &sysctl_unprivileged_bpf_disabled
,
2607 .maxlen
= sizeof(sysctl_unprivileged_bpf_disabled
),
2609 /* only handle a transition from default "0" to "1" */
2610 .proc_handler
= proc_dointvec_minmax
,
2611 .extra1
= SYSCTL_ONE
,
2612 .extra2
= SYSCTL_ONE
,
2615 .procname
= "bpf_stats_enabled",
2616 .data
= &bpf_stats_enabled_key
.key
,
2617 .maxlen
= sizeof(bpf_stats_enabled_key
),
2619 .proc_handler
= bpf_stats_handler
,
2622 #if defined(CONFIG_TREE_RCU)
2624 .procname
= "panic_on_rcu_stall",
2625 .data
= &sysctl_panic_on_rcu_stall
,
2626 .maxlen
= sizeof(sysctl_panic_on_rcu_stall
),
2628 .proc_handler
= proc_dointvec_minmax
,
2629 .extra1
= SYSCTL_ZERO
,
2630 .extra2
= SYSCTL_ONE
,
2633 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2635 .procname
= "stack_erasing",
2637 .maxlen
= sizeof(int),
2639 .proc_handler
= stack_erasing_sysctl
,
2640 .extra1
= SYSCTL_ZERO
,
2641 .extra2
= SYSCTL_ONE
,
2647 static struct ctl_table vm_table
[] = {
2649 .procname
= "overcommit_memory",
2650 .data
= &sysctl_overcommit_memory
,
2651 .maxlen
= sizeof(sysctl_overcommit_memory
),
2653 .proc_handler
= proc_dointvec_minmax
,
2654 .extra1
= SYSCTL_ZERO
,
2658 .procname
= "panic_on_oom",
2659 .data
= &sysctl_panic_on_oom
,
2660 .maxlen
= sizeof(sysctl_panic_on_oom
),
2662 .proc_handler
= proc_dointvec_minmax
,
2663 .extra1
= SYSCTL_ZERO
,
2667 .procname
= "oom_kill_allocating_task",
2668 .data
= &sysctl_oom_kill_allocating_task
,
2669 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
2671 .proc_handler
= proc_dointvec
,
2674 .procname
= "oom_dump_tasks",
2675 .data
= &sysctl_oom_dump_tasks
,
2676 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
2678 .proc_handler
= proc_dointvec
,
2681 .procname
= "overcommit_ratio",
2682 .data
= &sysctl_overcommit_ratio
,
2683 .maxlen
= sizeof(sysctl_overcommit_ratio
),
2685 .proc_handler
= overcommit_ratio_handler
,
2688 .procname
= "overcommit_kbytes",
2689 .data
= &sysctl_overcommit_kbytes
,
2690 .maxlen
= sizeof(sysctl_overcommit_kbytes
),
2692 .proc_handler
= overcommit_kbytes_handler
,
2695 .procname
= "page-cluster",
2696 .data
= &page_cluster
,
2697 .maxlen
= sizeof(int),
2699 .proc_handler
= proc_dointvec_minmax
,
2700 .extra1
= SYSCTL_ZERO
,
2703 .procname
= "dirty_background_ratio",
2704 .data
= &dirty_background_ratio
,
2705 .maxlen
= sizeof(dirty_background_ratio
),
2707 .proc_handler
= dirty_background_ratio_handler
,
2708 .extra1
= SYSCTL_ZERO
,
2709 .extra2
= &one_hundred
,
2712 .procname
= "dirty_background_bytes",
2713 .data
= &dirty_background_bytes
,
2714 .maxlen
= sizeof(dirty_background_bytes
),
2716 .proc_handler
= dirty_background_bytes_handler
,
2720 .procname
= "dirty_ratio",
2721 .data
= &vm_dirty_ratio
,
2722 .maxlen
= sizeof(vm_dirty_ratio
),
2724 .proc_handler
= dirty_ratio_handler
,
2725 .extra1
= SYSCTL_ZERO
,
2726 .extra2
= &one_hundred
,
2729 .procname
= "dirty_bytes",
2730 .data
= &vm_dirty_bytes
,
2731 .maxlen
= sizeof(vm_dirty_bytes
),
2733 .proc_handler
= dirty_bytes_handler
,
2734 .extra1
= &dirty_bytes_min
,
2737 .procname
= "dirty_writeback_centisecs",
2738 .data
= &dirty_writeback_interval
,
2739 .maxlen
= sizeof(dirty_writeback_interval
),
2741 .proc_handler
= dirty_writeback_centisecs_handler
,
2744 .procname
= "dirty_expire_centisecs",
2745 .data
= &dirty_expire_interval
,
2746 .maxlen
= sizeof(dirty_expire_interval
),
2748 .proc_handler
= proc_dointvec_minmax
,
2749 .extra1
= SYSCTL_ZERO
,
2752 .procname
= "dirtytime_expire_seconds",
2753 .data
= &dirtytime_expire_interval
,
2754 .maxlen
= sizeof(dirtytime_expire_interval
),
2756 .proc_handler
= dirtytime_interval_handler
,
2757 .extra1
= SYSCTL_ZERO
,
2760 .procname
= "swappiness",
2761 .data
= &vm_swappiness
,
2762 .maxlen
= sizeof(vm_swappiness
),
2764 .proc_handler
= proc_dointvec_minmax
,
2765 .extra1
= SYSCTL_ZERO
,
2766 .extra2
= &two_hundred
,
2768 #ifdef CONFIG_HUGETLB_PAGE
2770 .procname
= "nr_hugepages",
2772 .maxlen
= sizeof(unsigned long),
2774 .proc_handler
= hugetlb_sysctl_handler
,
2778 .procname
= "nr_hugepages_mempolicy",
2780 .maxlen
= sizeof(unsigned long),
2782 .proc_handler
= &hugetlb_mempolicy_sysctl_handler
,
2785 .procname
= "numa_stat",
2786 .data
= &sysctl_vm_numa_stat
,
2787 .maxlen
= sizeof(int),
2789 .proc_handler
= sysctl_vm_numa_stat_handler
,
2790 .extra1
= SYSCTL_ZERO
,
2791 .extra2
= SYSCTL_ONE
,
2795 .procname
= "hugetlb_shm_group",
2796 .data
= &sysctl_hugetlb_shm_group
,
2797 .maxlen
= sizeof(gid_t
),
2799 .proc_handler
= proc_dointvec
,
2802 .procname
= "nr_overcommit_hugepages",
2804 .maxlen
= sizeof(unsigned long),
2806 .proc_handler
= hugetlb_overcommit_handler
,
2810 .procname
= "lowmem_reserve_ratio",
2811 .data
= &sysctl_lowmem_reserve_ratio
,
2812 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
2814 .proc_handler
= lowmem_reserve_ratio_sysctl_handler
,
2817 .procname
= "drop_caches",
2818 .data
= &sysctl_drop_caches
,
2819 .maxlen
= sizeof(int),
2821 .proc_handler
= drop_caches_sysctl_handler
,
2822 .extra1
= SYSCTL_ONE
,
2825 #ifdef CONFIG_COMPACTION
2827 .procname
= "compact_memory",
2828 .data
= &sysctl_compact_memory
,
2829 .maxlen
= sizeof(int),
2831 .proc_handler
= sysctl_compaction_handler
,
2834 .procname
= "extfrag_threshold",
2835 .data
= &sysctl_extfrag_threshold
,
2836 .maxlen
= sizeof(int),
2838 .proc_handler
= proc_dointvec_minmax
,
2839 .extra1
= &min_extfrag_threshold
,
2840 .extra2
= &max_extfrag_threshold
,
2843 .procname
= "compact_unevictable_allowed",
2844 .data
= &sysctl_compact_unevictable_allowed
,
2845 .maxlen
= sizeof(int),
2847 .proc_handler
= proc_dointvec_minmax_warn_RT_change
,
2848 .extra1
= SYSCTL_ZERO
,
2849 .extra2
= SYSCTL_ONE
,
2852 #endif /* CONFIG_COMPACTION */
2854 .procname
= "min_free_kbytes",
2855 .data
= &min_free_kbytes
,
2856 .maxlen
= sizeof(min_free_kbytes
),
2858 .proc_handler
= min_free_kbytes_sysctl_handler
,
2859 .extra1
= SYSCTL_ZERO
,
2862 .procname
= "watermark_boost_factor",
2863 .data
= &watermark_boost_factor
,
2864 .maxlen
= sizeof(watermark_boost_factor
),
2866 .proc_handler
= proc_dointvec_minmax
,
2867 .extra1
= SYSCTL_ZERO
,
2870 .procname
= "watermark_scale_factor",
2871 .data
= &watermark_scale_factor
,
2872 .maxlen
= sizeof(watermark_scale_factor
),
2874 .proc_handler
= watermark_scale_factor_sysctl_handler
,
2875 .extra1
= SYSCTL_ONE
,
2876 .extra2
= &one_thousand
,
2879 .procname
= "percpu_pagelist_fraction",
2880 .data
= &percpu_pagelist_fraction
,
2881 .maxlen
= sizeof(percpu_pagelist_fraction
),
2883 .proc_handler
= percpu_pagelist_fraction_sysctl_handler
,
2884 .extra1
= SYSCTL_ZERO
,
2888 .procname
= "max_map_count",
2889 .data
= &sysctl_max_map_count
,
2890 .maxlen
= sizeof(sysctl_max_map_count
),
2892 .proc_handler
= proc_dointvec_minmax
,
2893 .extra1
= SYSCTL_ZERO
,
2897 .procname
= "nr_trim_pages",
2898 .data
= &sysctl_nr_trim_pages
,
2899 .maxlen
= sizeof(sysctl_nr_trim_pages
),
2901 .proc_handler
= proc_dointvec_minmax
,
2902 .extra1
= SYSCTL_ZERO
,
2906 .procname
= "laptop_mode",
2907 .data
= &laptop_mode
,
2908 .maxlen
= sizeof(laptop_mode
),
2910 .proc_handler
= proc_dointvec_jiffies
,
2913 .procname
= "block_dump",
2914 .data
= &block_dump
,
2915 .maxlen
= sizeof(block_dump
),
2917 .proc_handler
= proc_dointvec
,
2918 .extra1
= SYSCTL_ZERO
,
2921 .procname
= "vfs_cache_pressure",
2922 .data
= &sysctl_vfs_cache_pressure
,
2923 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
2925 .proc_handler
= proc_dointvec
,
2926 .extra1
= SYSCTL_ZERO
,
2928 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
2929 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
2931 .procname
= "legacy_va_layout",
2932 .data
= &sysctl_legacy_va_layout
,
2933 .maxlen
= sizeof(sysctl_legacy_va_layout
),
2935 .proc_handler
= proc_dointvec
,
2936 .extra1
= SYSCTL_ZERO
,
2941 .procname
= "zone_reclaim_mode",
2942 .data
= &node_reclaim_mode
,
2943 .maxlen
= sizeof(node_reclaim_mode
),
2945 .proc_handler
= proc_dointvec
,
2946 .extra1
= SYSCTL_ZERO
,
2949 .procname
= "min_unmapped_ratio",
2950 .data
= &sysctl_min_unmapped_ratio
,
2951 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
2953 .proc_handler
= sysctl_min_unmapped_ratio_sysctl_handler
,
2954 .extra1
= SYSCTL_ZERO
,
2955 .extra2
= &one_hundred
,
2958 .procname
= "min_slab_ratio",
2959 .data
= &sysctl_min_slab_ratio
,
2960 .maxlen
= sizeof(sysctl_min_slab_ratio
),
2962 .proc_handler
= sysctl_min_slab_ratio_sysctl_handler
,
2963 .extra1
= SYSCTL_ZERO
,
2964 .extra2
= &one_hundred
,
2969 .procname
= "stat_interval",
2970 .data
= &sysctl_stat_interval
,
2971 .maxlen
= sizeof(sysctl_stat_interval
),
2973 .proc_handler
= proc_dointvec_jiffies
,
2976 .procname
= "stat_refresh",
2980 .proc_handler
= vmstat_refresh
,
2985 .procname
= "mmap_min_addr",
2986 .data
= &dac_mmap_min_addr
,
2987 .maxlen
= sizeof(unsigned long),
2989 .proc_handler
= mmap_min_addr_handler
,
2994 .procname
= "numa_zonelist_order",
2995 .data
= &numa_zonelist_order
,
2996 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
2998 .proc_handler
= numa_zonelist_order_handler
,
3001 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
3002 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3004 .procname
= "vdso_enabled",
3005 #ifdef CONFIG_X86_32
3006 .data
= &vdso32_enabled
,
3007 .maxlen
= sizeof(vdso32_enabled
),
3009 .data
= &vdso_enabled
,
3010 .maxlen
= sizeof(vdso_enabled
),
3013 .proc_handler
= proc_dointvec
,
3014 .extra1
= SYSCTL_ZERO
,
3017 #ifdef CONFIG_HIGHMEM
3019 .procname
= "highmem_is_dirtyable",
3020 .data
= &vm_highmem_is_dirtyable
,
3021 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
3023 .proc_handler
= proc_dointvec_minmax
,
3024 .extra1
= SYSCTL_ZERO
,
3025 .extra2
= SYSCTL_ONE
,
3028 #ifdef CONFIG_MEMORY_FAILURE
3030 .procname
= "memory_failure_early_kill",
3031 .data
= &sysctl_memory_failure_early_kill
,
3032 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
3034 .proc_handler
= proc_dointvec_minmax
,
3035 .extra1
= SYSCTL_ZERO
,
3036 .extra2
= SYSCTL_ONE
,
3039 .procname
= "memory_failure_recovery",
3040 .data
= &sysctl_memory_failure_recovery
,
3041 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
3043 .proc_handler
= proc_dointvec_minmax
,
3044 .extra1
= SYSCTL_ZERO
,
3045 .extra2
= SYSCTL_ONE
,
3049 .procname
= "user_reserve_kbytes",
3050 .data
= &sysctl_user_reserve_kbytes
,
3051 .maxlen
= sizeof(sysctl_user_reserve_kbytes
),
3053 .proc_handler
= proc_doulongvec_minmax
,
3056 .procname
= "admin_reserve_kbytes",
3057 .data
= &sysctl_admin_reserve_kbytes
,
3058 .maxlen
= sizeof(sysctl_admin_reserve_kbytes
),
3060 .proc_handler
= proc_doulongvec_minmax
,
3062 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3064 .procname
= "mmap_rnd_bits",
3065 .data
= &mmap_rnd_bits
,
3066 .maxlen
= sizeof(mmap_rnd_bits
),
3068 .proc_handler
= proc_dointvec_minmax
,
3069 .extra1
= (void *)&mmap_rnd_bits_min
,
3070 .extra2
= (void *)&mmap_rnd_bits_max
,
3073 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3075 .procname
= "mmap_rnd_compat_bits",
3076 .data
= &mmap_rnd_compat_bits
,
3077 .maxlen
= sizeof(mmap_rnd_compat_bits
),
3079 .proc_handler
= proc_dointvec_minmax
,
3080 .extra1
= (void *)&mmap_rnd_compat_bits_min
,
3081 .extra2
= (void *)&mmap_rnd_compat_bits_max
,
3084 #ifdef CONFIG_USERFAULTFD
3086 .procname
= "unprivileged_userfaultfd",
3087 .data
= &sysctl_unprivileged_userfaultfd
,
3088 .maxlen
= sizeof(sysctl_unprivileged_userfaultfd
),
3090 .proc_handler
= proc_dointvec_minmax
,
3091 .extra1
= SYSCTL_ZERO
,
3092 .extra2
= SYSCTL_ONE
,
3098 static struct ctl_table fs_table
[] = {
3100 .procname
= "inode-nr",
3101 .data
= &inodes_stat
,
3102 .maxlen
= 2*sizeof(long),
3104 .proc_handler
= proc_nr_inodes
,
3107 .procname
= "inode-state",
3108 .data
= &inodes_stat
,
3109 .maxlen
= 7*sizeof(long),
3111 .proc_handler
= proc_nr_inodes
,
3114 .procname
= "file-nr",
3115 .data
= &files_stat
,
3116 .maxlen
= sizeof(files_stat
),
3118 .proc_handler
= proc_nr_files
,
3121 .procname
= "file-max",
3122 .data
= &files_stat
.max_files
,
3123 .maxlen
= sizeof(files_stat
.max_files
),
3125 .proc_handler
= proc_doulongvec_minmax
,
3127 .extra2
= &long_max
,
3130 .procname
= "nr_open",
3131 .data
= &sysctl_nr_open
,
3132 .maxlen
= sizeof(unsigned int),
3134 .proc_handler
= proc_dointvec_minmax
,
3135 .extra1
= &sysctl_nr_open_min
,
3136 .extra2
= &sysctl_nr_open_max
,
3139 .procname
= "dentry-state",
3140 .data
= &dentry_stat
,
3141 .maxlen
= 6*sizeof(long),
3143 .proc_handler
= proc_nr_dentry
,
3146 .procname
= "overflowuid",
3147 .data
= &fs_overflowuid
,
3148 .maxlen
= sizeof(int),
3150 .proc_handler
= proc_dointvec_minmax
,
3151 .extra1
= &minolduid
,
3152 .extra2
= &maxolduid
,
3155 .procname
= "overflowgid",
3156 .data
= &fs_overflowgid
,
3157 .maxlen
= sizeof(int),
3159 .proc_handler
= proc_dointvec_minmax
,
3160 .extra1
= &minolduid
,
3161 .extra2
= &maxolduid
,
3163 #ifdef CONFIG_FILE_LOCKING
3165 .procname
= "leases-enable",
3166 .data
= &leases_enable
,
3167 .maxlen
= sizeof(int),
3169 .proc_handler
= proc_dointvec
,
3172 #ifdef CONFIG_DNOTIFY
3174 .procname
= "dir-notify-enable",
3175 .data
= &dir_notify_enable
,
3176 .maxlen
= sizeof(int),
3178 .proc_handler
= proc_dointvec
,
3182 #ifdef CONFIG_FILE_LOCKING
3184 .procname
= "lease-break-time",
3185 .data
= &lease_break_time
,
3186 .maxlen
= sizeof(int),
3188 .proc_handler
= proc_dointvec
,
3193 .procname
= "aio-nr",
3195 .maxlen
= sizeof(aio_nr
),
3197 .proc_handler
= proc_doulongvec_minmax
,
3200 .procname
= "aio-max-nr",
3201 .data
= &aio_max_nr
,
3202 .maxlen
= sizeof(aio_max_nr
),
3204 .proc_handler
= proc_doulongvec_minmax
,
3206 #endif /* CONFIG_AIO */
3207 #ifdef CONFIG_INOTIFY_USER
3209 .procname
= "inotify",
3211 .child
= inotify_table
,
3216 .procname
= "epoll",
3218 .child
= epoll_table
,
3223 .procname
= "protected_symlinks",
3224 .data
= &sysctl_protected_symlinks
,
3225 .maxlen
= sizeof(int),
3227 .proc_handler
= proc_dointvec_minmax
,
3228 .extra1
= SYSCTL_ZERO
,
3229 .extra2
= SYSCTL_ONE
,
3232 .procname
= "protected_hardlinks",
3233 .data
= &sysctl_protected_hardlinks
,
3234 .maxlen
= sizeof(int),
3236 .proc_handler
= proc_dointvec_minmax
,
3237 .extra1
= SYSCTL_ZERO
,
3238 .extra2
= SYSCTL_ONE
,
3241 .procname
= "protected_fifos",
3242 .data
= &sysctl_protected_fifos
,
3243 .maxlen
= sizeof(int),
3245 .proc_handler
= proc_dointvec_minmax
,
3246 .extra1
= SYSCTL_ZERO
,
3250 .procname
= "protected_regular",
3251 .data
= &sysctl_protected_regular
,
3252 .maxlen
= sizeof(int),
3254 .proc_handler
= proc_dointvec_minmax
,
3255 .extra1
= SYSCTL_ZERO
,
3259 .procname
= "suid_dumpable",
3260 .data
= &suid_dumpable
,
3261 .maxlen
= sizeof(int),
3263 .proc_handler
= proc_dointvec_minmax_coredump
,
3264 .extra1
= SYSCTL_ZERO
,
3267 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
3269 .procname
= "binfmt_misc",
3271 .child
= sysctl_mount_point
,
3275 .procname
= "pipe-max-size",
3276 .data
= &pipe_max_size
,
3277 .maxlen
= sizeof(pipe_max_size
),
3279 .proc_handler
= proc_dopipe_max_size
,
3282 .procname
= "pipe-user-pages-hard",
3283 .data
= &pipe_user_pages_hard
,
3284 .maxlen
= sizeof(pipe_user_pages_hard
),
3286 .proc_handler
= proc_doulongvec_minmax
,
3289 .procname
= "pipe-user-pages-soft",
3290 .data
= &pipe_user_pages_soft
,
3291 .maxlen
= sizeof(pipe_user_pages_soft
),
3293 .proc_handler
= proc_doulongvec_minmax
,
3296 .procname
= "mount-max",
3297 .data
= &sysctl_mount_max
,
3298 .maxlen
= sizeof(unsigned int),
3300 .proc_handler
= proc_dointvec_minmax
,
3301 .extra1
= SYSCTL_ONE
,
3306 static struct ctl_table debug_table
[] = {
3307 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3309 .procname
= "exception-trace",
3310 .data
= &show_unhandled_signals
,
3311 .maxlen
= sizeof(int),
3313 .proc_handler
= proc_dointvec
3316 #if defined(CONFIG_OPTPROBES)
3318 .procname
= "kprobes-optimization",
3319 .data
= &sysctl_kprobes_optimization
,
3320 .maxlen
= sizeof(int),
3322 .proc_handler
= proc_kprobes_optimization_handler
,
3323 .extra1
= SYSCTL_ZERO
,
3324 .extra2
= SYSCTL_ONE
,
3330 static struct ctl_table dev_table
[] = {
3334 static struct ctl_table sysctl_base_table
[] = {
3336 .procname
= "kernel",
3338 .child
= kern_table
,
3351 .procname
= "debug",
3353 .child
= debug_table
,
3363 int __init
sysctl_init(void)
3365 struct ctl_table_header
*hdr
;
3367 hdr
= register_sysctl_table(sysctl_base_table
);
3368 kmemleak_not_leak(hdr
);
3371 #endif /* CONFIG_SYSCTL */
3373 * No sense putting this after each symbol definition, twice,
3374 * exception granted :-)
3376 EXPORT_SYMBOL(proc_dointvec
);
3377 EXPORT_SYMBOL(proc_douintvec
);
3378 EXPORT_SYMBOL(proc_dointvec_jiffies
);
3379 EXPORT_SYMBOL(proc_dointvec_minmax
);
3380 EXPORT_SYMBOL_GPL(proc_douintvec_minmax
);
3381 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
3382 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
3383 EXPORT_SYMBOL(proc_dostring
);
3384 EXPORT_SYMBOL(proc_doulongvec_minmax
);
3385 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);
3386 EXPORT_SYMBOL(proc_do_large_bitmap
);