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/panic.h>
31 #include <linux/printk.h>
32 #include <linux/proc_fs.h>
33 #include <linux/security.h>
34 #include <linux/ctype.h>
35 #include <linux/kmemleak.h>
37 #include <linux/init.h>
38 #include <linux/kernel.h>
39 #include <linux/kobject.h>
40 #include <linux/net.h>
41 #include <linux/sysrq.h>
42 #include <linux/highuid.h>
43 #include <linux/writeback.h>
44 #include <linux/ratelimit.h>
45 #include <linux/compaction.h>
46 #include <linux/hugetlb.h>
47 #include <linux/initrd.h>
48 #include <linux/key.h>
49 #include <linux/times.h>
50 #include <linux/limits.h>
51 #include <linux/dcache.h>
52 #include <linux/dnotify.h>
53 #include <linux/syscalls.h>
54 #include <linux/vmstat.h>
55 #include <linux/nfs_fs.h>
56 #include <linux/acpi.h>
57 #include <linux/reboot.h>
58 #include <linux/ftrace.h>
59 #include <linux/perf_event.h>
60 #include <linux/kprobes.h>
61 #include <linux/pipe_fs_i.h>
62 #include <linux/oom.h>
63 #include <linux/kmod.h>
64 #include <linux/capability.h>
65 #include <linux/binfmts.h>
66 #include <linux/sched/sysctl.h>
67 #include <linux/sched/coredump.h>
68 #include <linux/kexec.h>
69 #include <linux/bpf.h>
70 #include <linux/mount.h>
71 #include <linux/userfaultfd_k.h>
72 #include <linux/coredump.h>
73 #include <linux/latencytop.h>
74 #include <linux/pid.h>
75 #include <linux/delayacct.h>
77 #include "../lib/kstrtox.h"
79 #include <linux/uaccess.h>
80 #include <asm/processor.h>
84 #include <asm/stacktrace.h>
88 #include <asm/setup.h>
90 #ifdef CONFIG_BSD_PROCESS_ACCT
91 #include <linux/acct.h>
93 #ifdef CONFIG_RT_MUTEXES
94 #include <linux/rtmutex.h>
96 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
97 #include <linux/lockdep.h>
99 #ifdef CONFIG_CHR_DEV_SG
102 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
103 #include <linux/stackleak.h>
105 #ifdef CONFIG_LOCKUP_DETECTOR
106 #include <linux/nmi.h>
109 #if defined(CONFIG_SYSCTL)
111 /* Constants used for minimum and maximum */
112 #ifdef CONFIG_LOCKUP_DETECTOR
113 static int sixty = 60;
116 static int __maybe_unused neg_one = -1;
117 static int __maybe_unused two = 2;
118 static int __maybe_unused four = 4;
119 static unsigned long zero_ul;
120 static unsigned long one_ul = 1;
121 static unsigned long long_max = LONG_MAX;
122 static int one_hundred = 100;
123 static int two_hundred = 200;
124 static int one_thousand = 1000;
125 static int three_thousand = 3000;
127 static int ten_thousand = 10000;
129 #ifdef CONFIG_PERF_EVENTS
130 static int six_hundred_forty_kb = 640 * 1024;
133 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
134 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
136 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
137 static int maxolduid = 65535;
138 static int minolduid;
140 static int ngroups_max = NGROUPS_MAX;
141 static const int cap_last_cap = CAP_LAST_CAP;
144 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
145 * and hung_task_check_interval_secs
147 #ifdef CONFIG_DETECT_HUNG_TASK
148 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
151 #ifdef CONFIG_INOTIFY_USER
152 #include <linux/inotify.h>
154 #ifdef CONFIG_FANOTIFY
155 #include <linux/fanotify.h>
158 #ifdef CONFIG_PROC_SYSCTL
161 * enum sysctl_writes_mode - supported sysctl write modes
163 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
164 * to be written, and multiple writes on the same sysctl file descriptor
165 * will rewrite the sysctl value, regardless of file position. No warning
166 * is issued when the initial position is not 0.
167 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
169 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
170 * file position 0 and the value must be fully contained in the buffer
171 * sent to the write syscall. If dealing with strings respect the file
172 * position, but restrict this to the max length of the buffer, anything
173 * passed the max length will be ignored. Multiple writes will append
176 * These write modes control how current file position affects the behavior of
177 * updating sysctl values through the proc interface on each write.
179 enum sysctl_writes_mode {
180 SYSCTL_WRITES_LEGACY = -1,
181 SYSCTL_WRITES_WARN = 0,
182 SYSCTL_WRITES_STRICT = 1,
185 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
186 #endif /* CONFIG_PROC_SYSCTL */
188 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
189 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
190 int sysctl_legacy_va_layout;
193 #ifdef CONFIG_COMPACTION
194 static int min_extfrag_threshold;
195 static int max_extfrag_threshold = 1000;
198 #endif /* CONFIG_SYSCTL */
200 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
201 static int bpf_stats_handler(struct ctl_table *table, int write,
202 void *buffer, size_t *lenp, loff_t *ppos)
204 struct static_key *key = (struct static_key *)table->data;
205 static int saved_val;
207 struct ctl_table tmp = {
209 .maxlen = sizeof(val),
211 .extra1 = SYSCTL_ZERO,
212 .extra2 = SYSCTL_ONE,
215 if (write && !capable(CAP_SYS_ADMIN))
218 mutex_lock(&bpf_stats_enabled_mutex);
220 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
221 if (write && !ret && val != saved_val) {
223 static_key_slow_inc(key);
225 static_key_slow_dec(key);
228 mutex_unlock(&bpf_stats_enabled_mutex);
232 void __weak unpriv_ebpf_notify(int new_state)
236 static int bpf_unpriv_handler(struct ctl_table *table, int write,
237 void *buffer, size_t *lenp, loff_t *ppos)
239 int ret, unpriv_enable = *(int *)table->data;
240 bool locked_state = unpriv_enable == 1;
241 struct ctl_table tmp = *table;
243 if (write && !capable(CAP_SYS_ADMIN))
246 tmp.data = &unpriv_enable;
247 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
249 if (locked_state && unpriv_enable != 1)
251 *(int *)table->data = unpriv_enable;
254 unpriv_ebpf_notify(unpriv_enable);
258 #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */
264 #ifdef CONFIG_PROC_SYSCTL
266 static int _proc_do_string(char *data, int maxlen, int write,
267 char *buffer, size_t *lenp, loff_t *ppos)
272 if (!data || !maxlen || !*lenp) {
278 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
279 /* Only continue writes not past the end of buffer. */
281 if (len > maxlen - 1)
288 /* Start writing from beginning of buffer. */
294 while ((p - buffer) < *lenp && len < maxlen - 1) {
296 if (c == 0 || c == '\n')
317 memcpy(buffer, data, len);
328 static void warn_sysctl_write(struct ctl_table *table)
330 pr_warn_once("%s wrote to %s when file position was not 0!\n"
331 "This will not be supported in the future. To silence this\n"
332 "warning, set kernel.sysctl_writes_strict = -1\n",
333 current->comm, table->procname);
337 * proc_first_pos_non_zero_ignore - check if first position is allowed
338 * @ppos: file position
339 * @table: the sysctl table
341 * Returns true if the first position is non-zero and the sysctl_writes_strict
342 * mode indicates this is not allowed for numeric input types. String proc
343 * handlers can ignore the return value.
345 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
346 struct ctl_table *table)
351 switch (sysctl_writes_strict) {
352 case SYSCTL_WRITES_STRICT:
354 case SYSCTL_WRITES_WARN:
355 warn_sysctl_write(table);
363 * proc_dostring - read a string sysctl
364 * @table: the sysctl table
365 * @write: %TRUE if this is a write to the sysctl file
366 * @buffer: the user buffer
367 * @lenp: the size of the user buffer
368 * @ppos: file position
370 * Reads/writes a string from/to the user buffer. If the kernel
371 * buffer provided is not large enough to hold the string, the
372 * string is truncated. The copied string is %NULL-terminated.
373 * If the string is being read by the user process, it is copied
374 * and a newline '\n' is added. It is truncated if the buffer is
377 * Returns 0 on success.
379 int proc_dostring(struct ctl_table *table, int write,
380 void *buffer, size_t *lenp, loff_t *ppos)
383 proc_first_pos_non_zero_ignore(ppos, table);
385 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
389 static size_t proc_skip_spaces(char **buf)
392 char *tmp = skip_spaces(*buf);
398 static void proc_skip_char(char **buf, size_t *size, const char v)
409 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
412 * @cp: kernel buffer containing the string to parse
413 * @endp: pointer to store the trailing characters
414 * @base: the base to use
415 * @res: where the parsed integer will be stored
417 * In case of success 0 is returned and @res will contain the parsed integer,
418 * @endp will hold any trailing characters.
419 * This function will fail the parse on overflow. If there wasn't an overflow
420 * the function will defer the decision what characters count as invalid to the
423 static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
426 unsigned long long result;
429 cp = _parse_integer_fixup_radix(cp, &base);
430 rv = _parse_integer(cp, base, &result);
431 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
439 *res = (unsigned long)result;
445 * proc_get_long - reads an ASCII formatted integer from a user buffer
447 * @buf: a kernel buffer
448 * @size: size of the kernel buffer
449 * @val: this is where the number will be stored
450 * @neg: set to %TRUE if number is negative
451 * @perm_tr: a vector which contains the allowed trailers
452 * @perm_tr_len: size of the perm_tr vector
453 * @tr: pointer to store the trailer character
455 * In case of success %0 is returned and @buf and @size are updated with
456 * the amount of bytes read. If @tr is non-NULL and a trailing
457 * character exists (size is non-zero after returning from this
458 * function), @tr is updated with the trailing character.
460 static int proc_get_long(char **buf, size_t *size,
461 unsigned long *val, bool *neg,
462 const char *perm_tr, unsigned perm_tr_len, char *tr)
465 char *p, tmp[TMPBUFLEN];
471 if (len > TMPBUFLEN - 1)
474 memcpy(tmp, *buf, len);
478 if (*p == '-' && *size > 1) {
486 if (strtoul_lenient(p, &p, 0, val))
491 /* We don't know if the next char is whitespace thus we may accept
492 * invalid integers (e.g. 1234...a) or two integers instead of one
493 * (e.g. 123...1). So lets not allow such large numbers. */
494 if (len == TMPBUFLEN - 1)
497 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
500 if (tr && (len < *size))
510 * proc_put_long - converts an integer to a decimal ASCII formatted string
512 * @buf: the user buffer
513 * @size: the size of the user buffer
514 * @val: the integer to be converted
515 * @neg: sign of the number, %TRUE for negative
517 * In case of success @buf and @size are updated with the amount of bytes
520 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
523 char tmp[TMPBUFLEN], *p = tmp;
525 sprintf(p, "%s%lu", neg ? "-" : "", val);
529 memcpy(*buf, tmp, len);
535 static void proc_put_char(void **buf, size_t *size, char c)
538 char **buffer = (char **)buf;
547 static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp,
549 int write, void *data)
552 *(bool *)valp = *lvalp;
554 int val = *(bool *)valp;
556 *lvalp = (unsigned long)val;
562 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
564 int write, void *data)
568 if (*lvalp > (unsigned long) INT_MAX + 1)
570 WRITE_ONCE(*valp, -*lvalp);
572 if (*lvalp > (unsigned long) INT_MAX)
574 WRITE_ONCE(*valp, *lvalp);
577 int val = READ_ONCE(*valp);
580 *lvalp = -(unsigned long)val;
583 *lvalp = (unsigned long)val;
589 static int do_proc_douintvec_conv(unsigned long *lvalp,
591 int write, void *data)
594 if (*lvalp > UINT_MAX)
596 WRITE_ONCE(*valp, *lvalp);
598 unsigned int val = READ_ONCE(*valp);
599 *lvalp = (unsigned long)val;
604 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
606 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
607 int write, void *buffer,
608 size_t *lenp, loff_t *ppos,
609 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
610 int write, void *data),
613 int *i, vleft, first = 1, err = 0;
617 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
622 i = (int *) tbl_data;
623 vleft = table->maxlen / sizeof(*i);
627 conv = do_proc_dointvec_conv;
630 if (proc_first_pos_non_zero_ignore(ppos, table))
633 if (left > PAGE_SIZE - 1)
634 left = PAGE_SIZE - 1;
638 for (; left && vleft--; i++, first=0) {
643 left -= proc_skip_spaces(&p);
647 err = proc_get_long(&p, &left, &lval, &neg,
649 sizeof(proc_wspace_sep), NULL);
652 if (conv(&neg, &lval, i, 1, data)) {
657 if (conv(&neg, &lval, i, 0, data)) {
662 proc_put_char(&buffer, &left, '\t');
663 proc_put_long(&buffer, &left, lval, neg);
667 if (!write && !first && left && !err)
668 proc_put_char(&buffer, &left, '\n');
669 if (write && !err && left)
670 left -= proc_skip_spaces(&p);
672 return err ? : -EINVAL;
679 static int do_proc_dointvec(struct ctl_table *table, int write,
680 void *buffer, size_t *lenp, loff_t *ppos,
681 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
682 int write, void *data),
685 return __do_proc_dointvec(table->data, table, write,
686 buffer, lenp, ppos, conv, data);
689 static int do_proc_douintvec_w(unsigned int *tbl_data,
690 struct ctl_table *table,
692 size_t *lenp, loff_t *ppos,
693 int (*conv)(unsigned long *lvalp,
695 int write, void *data),
706 if (proc_first_pos_non_zero_ignore(ppos, table))
709 if (left > PAGE_SIZE - 1)
710 left = PAGE_SIZE - 1;
712 left -= proc_skip_spaces(&p);
718 err = proc_get_long(&p, &left, &lval, &neg,
720 sizeof(proc_wspace_sep), NULL);
726 if (conv(&lval, tbl_data, 1, data)) {
732 left -= proc_skip_spaces(&p);
740 /* This is in keeping with old __do_proc_dointvec() */
746 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
747 size_t *lenp, loff_t *ppos,
748 int (*conv)(unsigned long *lvalp,
750 int write, void *data),
759 if (conv(&lval, tbl_data, 0, data)) {
764 proc_put_long(&buffer, &left, lval, false);
768 proc_put_char(&buffer, &left, '\n');
777 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
778 int write, void *buffer,
779 size_t *lenp, loff_t *ppos,
780 int (*conv)(unsigned long *lvalp,
782 int write, void *data),
785 unsigned int *i, vleft;
787 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
792 i = (unsigned int *) tbl_data;
793 vleft = table->maxlen / sizeof(*i);
796 * Arrays are not supported, keep this simple. *Do not* add
805 conv = do_proc_douintvec_conv;
808 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
810 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
813 static int do_proc_douintvec(struct ctl_table *table, int write,
814 void *buffer, size_t *lenp, loff_t *ppos,
815 int (*conv)(unsigned long *lvalp,
817 int write, void *data),
820 return __do_proc_douintvec(table->data, table, write,
821 buffer, lenp, ppos, conv, data);
825 * proc_dobool - read/write a bool
826 * @table: the sysctl table
827 * @write: %TRUE if this is a write to the sysctl file
828 * @buffer: the user buffer
829 * @lenp: the size of the user buffer
830 * @ppos: file position
832 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
833 * values from/to the user buffer, treated as an ASCII string.
835 * Returns 0 on success.
837 int proc_dobool(struct ctl_table *table, int write, void *buffer,
838 size_t *lenp, loff_t *ppos)
840 return do_proc_dointvec(table, write, buffer, lenp, ppos,
841 do_proc_dobool_conv, NULL);
845 * proc_dointvec - read a vector of integers
846 * @table: the sysctl table
847 * @write: %TRUE if this is a write to the sysctl file
848 * @buffer: the user buffer
849 * @lenp: the size of the user buffer
850 * @ppos: file position
852 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
853 * values from/to the user buffer, treated as an ASCII string.
855 * Returns 0 on success.
857 int proc_dointvec(struct ctl_table *table, int write, void *buffer,
858 size_t *lenp, loff_t *ppos)
860 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
863 #ifdef CONFIG_COMPACTION
864 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
865 int write, void *buffer, size_t *lenp, loff_t *ppos)
869 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
870 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
872 old = *(int *)table->data;
873 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
876 if (old != *(int *)table->data)
877 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
878 table->procname, current->comm,
879 task_pid_nr(current));
885 * proc_douintvec - read a vector of unsigned integers
886 * @table: the sysctl table
887 * @write: %TRUE if this is a write to the sysctl file
888 * @buffer: the user buffer
889 * @lenp: the size of the user buffer
890 * @ppos: file position
892 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
893 * values from/to the user buffer, treated as an ASCII string.
895 * Returns 0 on success.
897 int proc_douintvec(struct ctl_table *table, int write, void *buffer,
898 size_t *lenp, loff_t *ppos)
900 return do_proc_douintvec(table, write, buffer, lenp, ppos,
901 do_proc_douintvec_conv, NULL);
905 * Taint values can only be increased
906 * This means we can safely use a temporary.
908 static int proc_taint(struct ctl_table *table, int write,
909 void *buffer, size_t *lenp, loff_t *ppos)
912 unsigned long tmptaint = get_taint();
915 if (write && !capable(CAP_SYS_ADMIN))
920 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
928 * If we are relying on panic_on_taint not producing
929 * false positives due to userspace input, bail out
930 * before setting the requested taint flags.
932 if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
936 * Poor man's atomic or. Not worth adding a primitive
937 * to everyone's atomic.h for this
939 for (i = 0; i < TAINT_FLAGS_COUNT; i++)
940 if ((1UL << i) & tmptaint)
941 add_taint(i, LOCKDEP_STILL_OK);
948 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
949 void *buffer, size_t *lenp, loff_t *ppos)
951 if (write && !capable(CAP_SYS_ADMIN))
954 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
959 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
960 * @min: pointer to minimum allowable value
961 * @max: pointer to maximum allowable value
963 * The do_proc_dointvec_minmax_conv_param structure provides the
964 * minimum and maximum values for doing range checking for those sysctl
965 * parameters that use the proc_dointvec_minmax() handler.
967 struct do_proc_dointvec_minmax_conv_param {
972 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
974 int write, void *data)
977 struct do_proc_dointvec_minmax_conv_param *param = data;
979 * If writing, first do so via a temporary local int so we can
980 * bounds-check it before touching *valp.
982 int *ip = write ? &tmp : valp;
984 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
989 if ((param->min && *param->min > tmp) ||
990 (param->max && *param->max < tmp))
992 WRITE_ONCE(*valp, tmp);
999 * proc_dointvec_minmax - read a vector of integers with min/max values
1000 * @table: the sysctl table
1001 * @write: %TRUE if this is a write to the sysctl file
1002 * @buffer: the user buffer
1003 * @lenp: the size of the user buffer
1004 * @ppos: file position
1006 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1007 * values from/to the user buffer, treated as an ASCII string.
1009 * This routine will ensure the values are within the range specified by
1010 * table->extra1 (min) and table->extra2 (max).
1012 * Returns 0 on success or -EINVAL on write when the range check fails.
1014 int proc_dointvec_minmax(struct ctl_table *table, int write,
1015 void *buffer, size_t *lenp, loff_t *ppos)
1017 struct do_proc_dointvec_minmax_conv_param param = {
1018 .min = (int *) table->extra1,
1019 .max = (int *) table->extra2,
1021 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1022 do_proc_dointvec_minmax_conv, ¶m);
1026 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
1027 * @min: pointer to minimum allowable value
1028 * @max: pointer to maximum allowable value
1030 * The do_proc_douintvec_minmax_conv_param structure provides the
1031 * minimum and maximum values for doing range checking for those sysctl
1032 * parameters that use the proc_douintvec_minmax() handler.
1034 struct do_proc_douintvec_minmax_conv_param {
1039 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
1041 int write, void *data)
1045 struct do_proc_douintvec_minmax_conv_param *param = data;
1046 /* write via temporary local uint for bounds-checking */
1047 unsigned int *up = write ? &tmp : valp;
1049 ret = do_proc_douintvec_conv(lvalp, up, write, data);
1054 if ((param->min && *param->min > tmp) ||
1055 (param->max && *param->max < tmp))
1058 WRITE_ONCE(*valp, tmp);
1065 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1066 * @table: the sysctl table
1067 * @write: %TRUE if this is a write to the sysctl file
1068 * @buffer: the user buffer
1069 * @lenp: the size of the user buffer
1070 * @ppos: file position
1072 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1073 * values from/to the user buffer, treated as an ASCII string. Negative
1074 * strings are not allowed.
1076 * This routine will ensure the values are within the range specified by
1077 * table->extra1 (min) and table->extra2 (max). There is a final sanity
1078 * check for UINT_MAX to avoid having to support wrap around uses from
1081 * Returns 0 on success or -ERANGE on write when the range check fails.
1083 int proc_douintvec_minmax(struct ctl_table *table, int write,
1084 void *buffer, size_t *lenp, loff_t *ppos)
1086 struct do_proc_douintvec_minmax_conv_param param = {
1087 .min = (unsigned int *) table->extra1,
1088 .max = (unsigned int *) table->extra2,
1090 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1091 do_proc_douintvec_minmax_conv, ¶m);
1095 * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1096 * @table: the sysctl table
1097 * @write: %TRUE if this is a write to the sysctl file
1098 * @buffer: the user buffer
1099 * @lenp: the size of the user buffer
1100 * @ppos: file position
1102 * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1103 * values from/to the user buffer, treated as an ASCII string. Negative
1104 * strings are not allowed.
1106 * This routine will ensure the values are within the range specified by
1107 * table->extra1 (min) and table->extra2 (max).
1109 * Returns 0 on success or an error on write when the range check fails.
1111 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1112 void *buffer, size_t *lenp, loff_t *ppos)
1114 struct ctl_table tmp;
1115 unsigned int min = 0, max = 255U, val;
1116 u8 *data = table->data;
1117 struct do_proc_douintvec_minmax_conv_param param = {
1123 /* Do not support arrays yet. */
1124 if (table->maxlen != sizeof(u8))
1127 if (table->extra1) {
1128 min = *(unsigned int *) table->extra1;
1132 if (table->extra2) {
1133 max = *(unsigned int *) table->extra2;
1140 tmp.maxlen = sizeof(val);
1142 val = READ_ONCE(*data);
1143 res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1144 do_proc_douintvec_minmax_conv, ¶m);
1148 WRITE_ONCE(*data, val);
1151 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1153 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1155 int write, void *data)
1160 val = round_pipe_size(*lvalp);
1166 unsigned int val = *valp;
1167 *lvalp = (unsigned long) val;
1173 static int proc_dopipe_max_size(struct ctl_table *table, int write,
1174 void *buffer, size_t *lenp, loff_t *ppos)
1176 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1177 do_proc_dopipe_max_size_conv, NULL);
1180 static void validate_coredump_safety(void)
1182 #ifdef CONFIG_COREDUMP
1183 if (suid_dumpable == SUID_DUMP_ROOT &&
1184 core_pattern[0] != '/' && core_pattern[0] != '|') {
1186 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1187 "Pipe handler or fully qualified core dump path required.\n"
1188 "Set kernel.core_pattern before fs.suid_dumpable.\n"
1194 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
1195 void *buffer, size_t *lenp, loff_t *ppos)
1197 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1199 validate_coredump_safety();
1203 #ifdef CONFIG_COREDUMP
1204 static int proc_dostring_coredump(struct ctl_table *table, int write,
1205 void *buffer, size_t *lenp, loff_t *ppos)
1207 int error = proc_dostring(table, write, buffer, lenp, ppos);
1209 validate_coredump_safety();
1214 #ifdef CONFIG_MAGIC_SYSRQ
1215 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1216 void *buffer, size_t *lenp, loff_t *ppos)
1222 ret = __do_proc_dointvec(&tmp, table, write, buffer,
1223 lenp, ppos, NULL, NULL);
1228 sysrq_toggle_support(tmp);
1234 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1235 int write, void *buffer, size_t *lenp, loff_t *ppos,
1236 unsigned long convmul, unsigned long convdiv)
1238 unsigned long *i, *min, *max;
1239 int vleft, first = 1, err = 0;
1243 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1248 i = (unsigned long *) data;
1249 min = (unsigned long *) table->extra1;
1250 max = (unsigned long *) table->extra2;
1251 vleft = table->maxlen / sizeof(unsigned long);
1255 if (proc_first_pos_non_zero_ignore(ppos, table))
1258 if (left > PAGE_SIZE - 1)
1259 left = PAGE_SIZE - 1;
1263 for (; left && vleft--; i++, first = 0) {
1269 left -= proc_skip_spaces(&p);
1273 err = proc_get_long(&p, &left, &val, &neg,
1275 sizeof(proc_wspace_sep), NULL);
1280 val = convmul * val / convdiv;
1281 if ((min && val < *min) || (max && val > *max)) {
1285 WRITE_ONCE(*i, val);
1287 val = convdiv * READ_ONCE(*i) / convmul;
1289 proc_put_char(&buffer, &left, '\t');
1290 proc_put_long(&buffer, &left, val, false);
1294 if (!write && !first && left && !err)
1295 proc_put_char(&buffer, &left, '\n');
1297 left -= proc_skip_spaces(&p);
1299 return err ? : -EINVAL;
1306 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1307 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1308 unsigned long convdiv)
1310 return __do_proc_doulongvec_minmax(table->data, table, write,
1311 buffer, lenp, ppos, convmul, convdiv);
1315 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1316 * @table: the sysctl table
1317 * @write: %TRUE if this is a write to the sysctl file
1318 * @buffer: the user buffer
1319 * @lenp: the size of the user buffer
1320 * @ppos: file position
1322 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1323 * values from/to the user buffer, treated as an ASCII string.
1325 * This routine will ensure the values are within the range specified by
1326 * table->extra1 (min) and table->extra2 (max).
1328 * Returns 0 on success.
1330 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1331 void *buffer, size_t *lenp, loff_t *ppos)
1333 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1337 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1338 * @table: the sysctl table
1339 * @write: %TRUE if this is a write to the sysctl file
1340 * @buffer: the user buffer
1341 * @lenp: the size of the user buffer
1342 * @ppos: file position
1344 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1345 * values from/to the user buffer, treated as an ASCII string. The values
1346 * are treated as milliseconds, and converted to jiffies when they are stored.
1348 * This routine will ensure the values are within the range specified by
1349 * table->extra1 (min) and table->extra2 (max).
1351 * Returns 0 on success.
1353 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1354 void *buffer, size_t *lenp, loff_t *ppos)
1356 return do_proc_doulongvec_minmax(table, write, buffer,
1357 lenp, ppos, HZ, 1000l);
1361 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1363 int write, void *data)
1366 if (*lvalp > INT_MAX / HZ)
1369 WRITE_ONCE(*valp, -*lvalp * HZ);
1371 WRITE_ONCE(*valp, *lvalp * HZ);
1373 int val = READ_ONCE(*valp);
1377 lval = -(unsigned long)val;
1380 lval = (unsigned long)val;
1387 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1389 int write, void *data)
1392 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1394 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1400 lval = -(unsigned long)val;
1403 lval = (unsigned long)val;
1405 *lvalp = jiffies_to_clock_t(lval);
1410 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1412 int write, void *data)
1415 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1419 WRITE_ONCE(*valp, (int)jif);
1421 int val = READ_ONCE(*valp);
1425 lval = -(unsigned long)val;
1428 lval = (unsigned long)val;
1430 *lvalp = jiffies_to_msecs(lval);
1436 * proc_dointvec_jiffies - read a vector of integers as seconds
1437 * @table: the sysctl table
1438 * @write: %TRUE if this is a write to the sysctl file
1439 * @buffer: the user buffer
1440 * @lenp: the size of the user buffer
1441 * @ppos: file position
1443 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1444 * values from/to the user buffer, treated as an ASCII string.
1445 * The values read are assumed to be in seconds, and are converted into
1448 * Returns 0 on success.
1450 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1451 void *buffer, size_t *lenp, loff_t *ppos)
1453 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1454 do_proc_dointvec_jiffies_conv,NULL);
1458 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1459 * @table: the sysctl table
1460 * @write: %TRUE if this is a write to the sysctl file
1461 * @buffer: the user buffer
1462 * @lenp: the size of the user buffer
1463 * @ppos: pointer to the file position
1465 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1466 * values from/to the user buffer, treated as an ASCII string.
1467 * The values read are assumed to be in 1/USER_HZ seconds, and
1468 * are converted into jiffies.
1470 * Returns 0 on success.
1472 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1473 void *buffer, size_t *lenp, loff_t *ppos)
1475 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1476 do_proc_dointvec_userhz_jiffies_conv,NULL);
1480 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1481 * @table: the sysctl table
1482 * @write: %TRUE if this is a write to the sysctl file
1483 * @buffer: the user buffer
1484 * @lenp: the size of the user buffer
1485 * @ppos: file position
1486 * @ppos: the current position in the file
1488 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1489 * values from/to the user buffer, treated as an ASCII string.
1490 * The values read are assumed to be in 1/1000 seconds, and
1491 * are converted into jiffies.
1493 * Returns 0 on success.
1495 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1496 size_t *lenp, loff_t *ppos)
1498 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1499 do_proc_dointvec_ms_jiffies_conv, NULL);
1502 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1503 size_t *lenp, loff_t *ppos)
1505 struct pid *new_pid;
1509 tmp = pid_vnr(cad_pid);
1511 r = __do_proc_dointvec(&tmp, table, write, buffer,
1512 lenp, ppos, NULL, NULL);
1516 new_pid = find_get_pid(tmp);
1520 put_pid(xchg(&cad_pid, new_pid));
1525 * proc_do_large_bitmap - read/write from/to a large bitmap
1526 * @table: the sysctl table
1527 * @write: %TRUE if this is a write to the sysctl file
1528 * @buffer: the user buffer
1529 * @lenp: the size of the user buffer
1530 * @ppos: file position
1532 * The bitmap is stored at table->data and the bitmap length (in bits)
1535 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1536 * large bitmaps may be represented in a compact manner. Writing into
1537 * the file will clear the bitmap then update it with the given input.
1539 * Returns 0 on success.
1541 int proc_do_large_bitmap(struct ctl_table *table, int write,
1542 void *buffer, size_t *lenp, loff_t *ppos)
1545 size_t left = *lenp;
1546 unsigned long bitmap_len = table->maxlen;
1547 unsigned long *bitmap = *(unsigned long **) table->data;
1548 unsigned long *tmp_bitmap = NULL;
1549 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1551 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1560 if (left > PAGE_SIZE - 1) {
1561 left = PAGE_SIZE - 1;
1562 /* How much of the buffer we'll skip this pass */
1563 skipped = *lenp - left;
1566 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
1569 proc_skip_char(&p, &left, '\n');
1570 while (!err && left) {
1571 unsigned long val_a, val_b;
1575 /* In case we stop parsing mid-number, we can reset */
1577 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1580 * If we consumed the entirety of a truncated buffer or
1581 * only one char is left (may be a "-"), then stop here,
1582 * reset, & come back for more.
1584 if ((left <= 1) && skipped) {
1591 if (val_a >= bitmap_len || neg) {
1603 err = proc_get_long(&p, &left, &val_b,
1604 &neg, tr_b, sizeof(tr_b),
1607 * If we consumed all of a truncated buffer or
1608 * then stop here, reset, & come back for more.
1610 if (!left && skipped) {
1617 if (val_b >= bitmap_len || neg ||
1628 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1629 proc_skip_char(&p, &left, '\n');
1633 unsigned long bit_a, bit_b = 0;
1637 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1638 if (bit_a >= bitmap_len)
1640 bit_b = find_next_zero_bit(bitmap, bitmap_len,
1644 proc_put_char(&buffer, &left, ',');
1645 proc_put_long(&buffer, &left, bit_a, false);
1646 if (bit_a != bit_b) {
1647 proc_put_char(&buffer, &left, '-');
1648 proc_put_long(&buffer, &left, bit_b, false);
1653 proc_put_char(&buffer, &left, '\n');
1659 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1661 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1667 bitmap_free(tmp_bitmap);
1671 #else /* CONFIG_PROC_SYSCTL */
1673 int proc_dostring(struct ctl_table *table, int write,
1674 void *buffer, size_t *lenp, loff_t *ppos)
1679 int proc_dobool(struct ctl_table *table, int write,
1680 void *buffer, size_t *lenp, loff_t *ppos)
1685 int proc_dointvec(struct ctl_table *table, int write,
1686 void *buffer, size_t *lenp, loff_t *ppos)
1691 int proc_douintvec(struct ctl_table *table, int write,
1692 void *buffer, size_t *lenp, loff_t *ppos)
1697 int proc_dointvec_minmax(struct ctl_table *table, int write,
1698 void *buffer, size_t *lenp, loff_t *ppos)
1703 int proc_douintvec_minmax(struct ctl_table *table, int write,
1704 void *buffer, size_t *lenp, loff_t *ppos)
1709 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1710 void *buffer, size_t *lenp, loff_t *ppos)
1715 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1716 void *buffer, size_t *lenp, loff_t *ppos)
1721 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1722 void *buffer, size_t *lenp, loff_t *ppos)
1727 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1728 void *buffer, size_t *lenp, loff_t *ppos)
1733 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1734 void *buffer, size_t *lenp, loff_t *ppos)
1739 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1740 void *buffer, size_t *lenp, loff_t *ppos)
1745 int proc_do_large_bitmap(struct ctl_table *table, int write,
1746 void *buffer, size_t *lenp, loff_t *ppos)
1751 #endif /* CONFIG_PROC_SYSCTL */
1753 #if defined(CONFIG_SYSCTL)
1754 int proc_do_static_key(struct ctl_table *table, int write,
1755 void *buffer, size_t *lenp, loff_t *ppos)
1757 struct static_key *key = (struct static_key *)table->data;
1758 static DEFINE_MUTEX(static_key_mutex);
1760 struct ctl_table tmp = {
1762 .maxlen = sizeof(val),
1763 .mode = table->mode,
1764 .extra1 = SYSCTL_ZERO,
1765 .extra2 = SYSCTL_ONE,
1768 if (write && !capable(CAP_SYS_ADMIN))
1771 mutex_lock(&static_key_mutex);
1772 val = static_key_enabled(key);
1773 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1774 if (write && !ret) {
1776 static_key_enable(key);
1778 static_key_disable(key);
1780 mutex_unlock(&static_key_mutex);
1784 static struct ctl_table kern_table[] = {
1786 .procname = "sched_child_runs_first",
1787 .data = &sysctl_sched_child_runs_first,
1788 .maxlen = sizeof(unsigned int),
1790 .proc_handler = proc_dointvec,
1792 #ifdef CONFIG_SCHEDSTATS
1794 .procname = "sched_schedstats",
1796 .maxlen = sizeof(unsigned int),
1798 .proc_handler = sysctl_schedstats,
1799 .extra1 = SYSCTL_ZERO,
1800 .extra2 = SYSCTL_ONE,
1802 #endif /* CONFIG_SCHEDSTATS */
1803 #ifdef CONFIG_TASK_DELAY_ACCT
1805 .procname = "task_delayacct",
1807 .maxlen = sizeof(unsigned int),
1809 .proc_handler = sysctl_delayacct,
1810 .extra1 = SYSCTL_ZERO,
1811 .extra2 = SYSCTL_ONE,
1813 #endif /* CONFIG_TASK_DELAY_ACCT */
1814 #ifdef CONFIG_NUMA_BALANCING
1816 .procname = "numa_balancing",
1817 .data = NULL, /* filled in by handler */
1818 .maxlen = sizeof(unsigned int),
1820 .proc_handler = sysctl_numa_balancing,
1821 .extra1 = SYSCTL_ZERO,
1822 .extra2 = SYSCTL_ONE,
1824 #endif /* CONFIG_NUMA_BALANCING */
1826 .procname = "sched_rt_period_us",
1827 .data = &sysctl_sched_rt_period,
1828 .maxlen = sizeof(unsigned int),
1830 .proc_handler = sched_rt_handler,
1833 .procname = "sched_rt_runtime_us",
1834 .data = &sysctl_sched_rt_runtime,
1835 .maxlen = sizeof(int),
1837 .proc_handler = sched_rt_handler,
1840 .procname = "sched_deadline_period_max_us",
1841 .data = &sysctl_sched_dl_period_max,
1842 .maxlen = sizeof(unsigned int),
1844 .proc_handler = proc_dointvec,
1847 .procname = "sched_deadline_period_min_us",
1848 .data = &sysctl_sched_dl_period_min,
1849 .maxlen = sizeof(unsigned int),
1851 .proc_handler = proc_dointvec,
1854 .procname = "sched_rr_timeslice_ms",
1855 .data = &sysctl_sched_rr_timeslice,
1856 .maxlen = sizeof(int),
1858 .proc_handler = sched_rr_handler,
1860 #ifdef CONFIG_UCLAMP_TASK
1862 .procname = "sched_util_clamp_min",
1863 .data = &sysctl_sched_uclamp_util_min,
1864 .maxlen = sizeof(unsigned int),
1866 .proc_handler = sysctl_sched_uclamp_handler,
1869 .procname = "sched_util_clamp_max",
1870 .data = &sysctl_sched_uclamp_util_max,
1871 .maxlen = sizeof(unsigned int),
1873 .proc_handler = sysctl_sched_uclamp_handler,
1876 .procname = "sched_util_clamp_min_rt_default",
1877 .data = &sysctl_sched_uclamp_util_min_rt_default,
1878 .maxlen = sizeof(unsigned int),
1880 .proc_handler = sysctl_sched_uclamp_handler,
1883 #ifdef CONFIG_SCHED_AUTOGROUP
1885 .procname = "sched_autogroup_enabled",
1886 .data = &sysctl_sched_autogroup_enabled,
1887 .maxlen = sizeof(unsigned int),
1889 .proc_handler = proc_dointvec_minmax,
1890 .extra1 = SYSCTL_ZERO,
1891 .extra2 = SYSCTL_ONE,
1894 #ifdef CONFIG_CFS_BANDWIDTH
1896 .procname = "sched_cfs_bandwidth_slice_us",
1897 .data = &sysctl_sched_cfs_bandwidth_slice,
1898 .maxlen = sizeof(unsigned int),
1900 .proc_handler = proc_dointvec_minmax,
1901 .extra1 = SYSCTL_ONE,
1904 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1906 .procname = "sched_energy_aware",
1907 .data = &sysctl_sched_energy_aware,
1908 .maxlen = sizeof(unsigned int),
1910 .proc_handler = sched_energy_aware_handler,
1911 .extra1 = SYSCTL_ZERO,
1912 .extra2 = SYSCTL_ONE,
1915 #ifdef CONFIG_PROVE_LOCKING
1917 .procname = "prove_locking",
1918 .data = &prove_locking,
1919 .maxlen = sizeof(int),
1921 .proc_handler = proc_dointvec,
1924 #ifdef CONFIG_LOCK_STAT
1926 .procname = "lock_stat",
1928 .maxlen = sizeof(int),
1930 .proc_handler = proc_dointvec,
1934 .procname = "panic",
1935 .data = &panic_timeout,
1936 .maxlen = sizeof(int),
1938 .proc_handler = proc_dointvec,
1940 #ifdef CONFIG_COREDUMP
1942 .procname = "core_uses_pid",
1943 .data = &core_uses_pid,
1944 .maxlen = sizeof(int),
1946 .proc_handler = proc_dointvec,
1949 .procname = "core_pattern",
1950 .data = core_pattern,
1951 .maxlen = CORENAME_MAX_SIZE,
1953 .proc_handler = proc_dostring_coredump,
1956 .procname = "core_pipe_limit",
1957 .data = &core_pipe_limit,
1958 .maxlen = sizeof(unsigned int),
1960 .proc_handler = proc_dointvec,
1963 #ifdef CONFIG_PROC_SYSCTL
1965 .procname = "tainted",
1966 .maxlen = sizeof(long),
1968 .proc_handler = proc_taint,
1971 .procname = "sysctl_writes_strict",
1972 .data = &sysctl_writes_strict,
1973 .maxlen = sizeof(int),
1975 .proc_handler = proc_dointvec_minmax,
1977 .extra2 = SYSCTL_ONE,
1980 #ifdef CONFIG_LATENCYTOP
1982 .procname = "latencytop",
1983 .data = &latencytop_enabled,
1984 .maxlen = sizeof(int),
1986 .proc_handler = sysctl_latencytop,
1989 #ifdef CONFIG_BLK_DEV_INITRD
1991 .procname = "real-root-dev",
1992 .data = &real_root_dev,
1993 .maxlen = sizeof(int),
1995 .proc_handler = proc_dointvec,
1999 .procname = "print-fatal-signals",
2000 .data = &print_fatal_signals,
2001 .maxlen = sizeof(int),
2003 .proc_handler = proc_dointvec,
2007 .procname = "reboot-cmd",
2008 .data = reboot_command,
2011 .proc_handler = proc_dostring,
2014 .procname = "stop-a",
2015 .data = &stop_a_enabled,
2016 .maxlen = sizeof (int),
2018 .proc_handler = proc_dointvec,
2021 .procname = "scons-poweroff",
2022 .data = &scons_pwroff,
2023 .maxlen = sizeof (int),
2025 .proc_handler = proc_dointvec,
2028 #ifdef CONFIG_SPARC64
2030 .procname = "tsb-ratio",
2031 .data = &sysctl_tsb_ratio,
2032 .maxlen = sizeof (int),
2034 .proc_handler = proc_dointvec,
2037 #ifdef CONFIG_PARISC
2039 .procname = "soft-power",
2040 .data = &pwrsw_enabled,
2041 .maxlen = sizeof (int),
2043 .proc_handler = proc_dointvec,
2046 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
2048 .procname = "unaligned-trap",
2049 .data = &unaligned_enabled,
2050 .maxlen = sizeof (int),
2052 .proc_handler = proc_dointvec,
2056 .procname = "ctrl-alt-del",
2058 .maxlen = sizeof(int),
2060 .proc_handler = proc_dointvec,
2062 #ifdef CONFIG_FUNCTION_TRACER
2064 .procname = "ftrace_enabled",
2065 .data = &ftrace_enabled,
2066 .maxlen = sizeof(int),
2068 .proc_handler = ftrace_enable_sysctl,
2071 #ifdef CONFIG_STACK_TRACER
2073 .procname = "stack_tracer_enabled",
2074 .data = &stack_tracer_enabled,
2075 .maxlen = sizeof(int),
2077 .proc_handler = stack_trace_sysctl,
2080 #ifdef CONFIG_TRACING
2082 .procname = "ftrace_dump_on_oops",
2083 .data = &ftrace_dump_on_oops,
2084 .maxlen = sizeof(int),
2086 .proc_handler = proc_dointvec,
2089 .procname = "traceoff_on_warning",
2090 .data = &__disable_trace_on_warning,
2091 .maxlen = sizeof(__disable_trace_on_warning),
2093 .proc_handler = proc_dointvec,
2096 .procname = "tracepoint_printk",
2097 .data = &tracepoint_printk,
2098 .maxlen = sizeof(tracepoint_printk),
2100 .proc_handler = tracepoint_printk_sysctl,
2103 #ifdef CONFIG_KEXEC_CORE
2105 .procname = "kexec_load_disabled",
2106 .data = &kexec_load_disabled,
2107 .maxlen = sizeof(int),
2109 /* only handle a transition from default "0" to "1" */
2110 .proc_handler = proc_dointvec_minmax,
2111 .extra1 = SYSCTL_ONE,
2112 .extra2 = SYSCTL_ONE,
2115 #ifdef CONFIG_MODULES
2117 .procname = "modprobe",
2118 .data = &modprobe_path,
2119 .maxlen = KMOD_PATH_LEN,
2121 .proc_handler = proc_dostring,
2124 .procname = "modules_disabled",
2125 .data = &modules_disabled,
2126 .maxlen = sizeof(int),
2128 /* only handle a transition from default "0" to "1" */
2129 .proc_handler = proc_dointvec_minmax,
2130 .extra1 = SYSCTL_ONE,
2131 .extra2 = SYSCTL_ONE,
2134 #ifdef CONFIG_UEVENT_HELPER
2136 .procname = "hotplug",
2137 .data = &uevent_helper,
2138 .maxlen = UEVENT_HELPER_PATH_LEN,
2140 .proc_handler = proc_dostring,
2143 #ifdef CONFIG_CHR_DEV_SG
2145 .procname = "sg-big-buff",
2146 .data = &sg_big_buff,
2147 .maxlen = sizeof (int),
2149 .proc_handler = proc_dointvec,
2152 #ifdef CONFIG_BSD_PROCESS_ACCT
2156 .maxlen = 3*sizeof(int),
2158 .proc_handler = proc_dointvec,
2161 #ifdef CONFIG_MAGIC_SYSRQ
2163 .procname = "sysrq",
2165 .maxlen = sizeof (int),
2167 .proc_handler = sysrq_sysctl_handler,
2170 #ifdef CONFIG_PROC_SYSCTL
2172 .procname = "cad_pid",
2174 .maxlen = sizeof (int),
2176 .proc_handler = proc_do_cad_pid,
2180 .procname = "threads-max",
2182 .maxlen = sizeof(int),
2184 .proc_handler = sysctl_max_threads,
2187 .procname = "random",
2189 .child = random_table,
2192 .procname = "usermodehelper",
2194 .child = usermodehelper_table,
2196 #ifdef CONFIG_FW_LOADER_USER_HELPER
2198 .procname = "firmware_config",
2200 .child = firmware_config_table,
2204 .procname = "overflowuid",
2205 .data = &overflowuid,
2206 .maxlen = sizeof(int),
2208 .proc_handler = proc_dointvec_minmax,
2209 .extra1 = &minolduid,
2210 .extra2 = &maxolduid,
2213 .procname = "overflowgid",
2214 .data = &overflowgid,
2215 .maxlen = sizeof(int),
2217 .proc_handler = proc_dointvec_minmax,
2218 .extra1 = &minolduid,
2219 .extra2 = &maxolduid,
2223 .procname = "userprocess_debug",
2224 .data = &show_unhandled_signals,
2225 .maxlen = sizeof(int),
2227 .proc_handler = proc_dointvec,
2232 .procname = "oops_all_cpu_backtrace",
2233 .data = &sysctl_oops_all_cpu_backtrace,
2234 .maxlen = sizeof(int),
2236 .proc_handler = proc_dointvec_minmax,
2237 .extra1 = SYSCTL_ZERO,
2238 .extra2 = SYSCTL_ONE,
2240 #endif /* CONFIG_SMP */
2242 .procname = "pid_max",
2244 .maxlen = sizeof (int),
2246 .proc_handler = proc_dointvec_minmax,
2247 .extra1 = &pid_max_min,
2248 .extra2 = &pid_max_max,
2251 .procname = "panic_on_oops",
2252 .data = &panic_on_oops,
2253 .maxlen = sizeof(int),
2255 .proc_handler = proc_dointvec,
2258 .procname = "panic_print",
2259 .data = &panic_print,
2260 .maxlen = sizeof(unsigned long),
2262 .proc_handler = proc_doulongvec_minmax,
2264 #if defined CONFIG_PRINTK
2266 .procname = "printk",
2267 .data = &console_loglevel,
2268 .maxlen = 4*sizeof(int),
2270 .proc_handler = proc_dointvec,
2273 .procname = "printk_ratelimit",
2274 .data = &printk_ratelimit_state.interval,
2275 .maxlen = sizeof(int),
2277 .proc_handler = proc_dointvec_jiffies,
2280 .procname = "printk_ratelimit_burst",
2281 .data = &printk_ratelimit_state.burst,
2282 .maxlen = sizeof(int),
2284 .proc_handler = proc_dointvec,
2287 .procname = "printk_delay",
2288 .data = &printk_delay_msec,
2289 .maxlen = sizeof(int),
2291 .proc_handler = proc_dointvec_minmax,
2292 .extra1 = SYSCTL_ZERO,
2293 .extra2 = &ten_thousand,
2296 .procname = "printk_devkmsg",
2297 .data = devkmsg_log_str,
2298 .maxlen = DEVKMSG_STR_MAX_SIZE,
2300 .proc_handler = devkmsg_sysctl_set_loglvl,
2303 .procname = "dmesg_restrict",
2304 .data = &dmesg_restrict,
2305 .maxlen = sizeof(int),
2307 .proc_handler = proc_dointvec_minmax_sysadmin,
2308 .extra1 = SYSCTL_ZERO,
2309 .extra2 = SYSCTL_ONE,
2312 .procname = "kptr_restrict",
2313 .data = &kptr_restrict,
2314 .maxlen = sizeof(int),
2316 .proc_handler = proc_dointvec_minmax_sysadmin,
2317 .extra1 = SYSCTL_ZERO,
2322 .procname = "ngroups_max",
2323 .data = &ngroups_max,
2324 .maxlen = sizeof (int),
2326 .proc_handler = proc_dointvec,
2329 .procname = "cap_last_cap",
2330 .data = (void *)&cap_last_cap,
2331 .maxlen = sizeof(int),
2333 .proc_handler = proc_dointvec,
2335 #if defined(CONFIG_LOCKUP_DETECTOR)
2337 .procname = "watchdog",
2338 .data = &watchdog_user_enabled,
2339 .maxlen = sizeof(int),
2341 .proc_handler = proc_watchdog,
2342 .extra1 = SYSCTL_ZERO,
2343 .extra2 = SYSCTL_ONE,
2346 .procname = "watchdog_thresh",
2347 .data = &watchdog_thresh,
2348 .maxlen = sizeof(int),
2350 .proc_handler = proc_watchdog_thresh,
2351 .extra1 = SYSCTL_ZERO,
2355 .procname = "nmi_watchdog",
2356 .data = &nmi_watchdog_user_enabled,
2357 .maxlen = sizeof(int),
2358 .mode = NMI_WATCHDOG_SYSCTL_PERM,
2359 .proc_handler = proc_nmi_watchdog,
2360 .extra1 = SYSCTL_ZERO,
2361 .extra2 = SYSCTL_ONE,
2364 .procname = "watchdog_cpumask",
2365 .data = &watchdog_cpumask_bits,
2368 .proc_handler = proc_watchdog_cpumask,
2370 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
2372 .procname = "soft_watchdog",
2373 .data = &soft_watchdog_user_enabled,
2374 .maxlen = sizeof(int),
2376 .proc_handler = proc_soft_watchdog,
2377 .extra1 = SYSCTL_ZERO,
2378 .extra2 = SYSCTL_ONE,
2381 .procname = "softlockup_panic",
2382 .data = &softlockup_panic,
2383 .maxlen = sizeof(int),
2385 .proc_handler = proc_dointvec_minmax,
2386 .extra1 = SYSCTL_ZERO,
2387 .extra2 = SYSCTL_ONE,
2391 .procname = "softlockup_all_cpu_backtrace",
2392 .data = &sysctl_softlockup_all_cpu_backtrace,
2393 .maxlen = sizeof(int),
2395 .proc_handler = proc_dointvec_minmax,
2396 .extra1 = SYSCTL_ZERO,
2397 .extra2 = SYSCTL_ONE,
2399 #endif /* CONFIG_SMP */
2401 #ifdef CONFIG_HARDLOCKUP_DETECTOR
2403 .procname = "hardlockup_panic",
2404 .data = &hardlockup_panic,
2405 .maxlen = sizeof(int),
2407 .proc_handler = proc_dointvec_minmax,
2408 .extra1 = SYSCTL_ZERO,
2409 .extra2 = SYSCTL_ONE,
2413 .procname = "hardlockup_all_cpu_backtrace",
2414 .data = &sysctl_hardlockup_all_cpu_backtrace,
2415 .maxlen = sizeof(int),
2417 .proc_handler = proc_dointvec_minmax,
2418 .extra1 = SYSCTL_ZERO,
2419 .extra2 = SYSCTL_ONE,
2421 #endif /* CONFIG_SMP */
2425 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2427 .procname = "unknown_nmi_panic",
2428 .data = &unknown_nmi_panic,
2429 .maxlen = sizeof (int),
2431 .proc_handler = proc_dointvec,
2435 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2436 defined(CONFIG_DEBUG_STACKOVERFLOW)
2438 .procname = "panic_on_stackoverflow",
2439 .data = &sysctl_panic_on_stackoverflow,
2440 .maxlen = sizeof(int),
2442 .proc_handler = proc_dointvec,
2445 #if defined(CONFIG_X86)
2447 .procname = "panic_on_unrecovered_nmi",
2448 .data = &panic_on_unrecovered_nmi,
2449 .maxlen = sizeof(int),
2451 .proc_handler = proc_dointvec,
2454 .procname = "panic_on_io_nmi",
2455 .data = &panic_on_io_nmi,
2456 .maxlen = sizeof(int),
2458 .proc_handler = proc_dointvec,
2461 .procname = "bootloader_type",
2462 .data = &bootloader_type,
2463 .maxlen = sizeof (int),
2465 .proc_handler = proc_dointvec,
2468 .procname = "bootloader_version",
2469 .data = &bootloader_version,
2470 .maxlen = sizeof (int),
2472 .proc_handler = proc_dointvec,
2475 .procname = "io_delay_type",
2476 .data = &io_delay_type,
2477 .maxlen = sizeof(int),
2479 .proc_handler = proc_dointvec,
2482 #if defined(CONFIG_MMU)
2484 .procname = "randomize_va_space",
2485 .data = &randomize_va_space,
2486 .maxlen = sizeof(int),
2488 .proc_handler = proc_dointvec,
2491 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2493 .procname = "spin_retry",
2494 .data = &spin_retry,
2495 .maxlen = sizeof (int),
2497 .proc_handler = proc_dointvec,
2500 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2502 .procname = "acpi_video_flags",
2503 .data = &acpi_realmode_flags,
2504 .maxlen = sizeof (unsigned long),
2506 .proc_handler = proc_doulongvec_minmax,
2509 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2511 .procname = "ignore-unaligned-usertrap",
2512 .data = &no_unaligned_warning,
2513 .maxlen = sizeof (int),
2515 .proc_handler = proc_dointvec,
2520 .procname = "unaligned-dump-stack",
2521 .data = &unaligned_dump_stack,
2522 .maxlen = sizeof (int),
2524 .proc_handler = proc_dointvec,
2527 #ifdef CONFIG_DETECT_HUNG_TASK
2530 .procname = "hung_task_all_cpu_backtrace",
2531 .data = &sysctl_hung_task_all_cpu_backtrace,
2532 .maxlen = sizeof(int),
2534 .proc_handler = proc_dointvec_minmax,
2535 .extra1 = SYSCTL_ZERO,
2536 .extra2 = SYSCTL_ONE,
2538 #endif /* CONFIG_SMP */
2540 .procname = "hung_task_panic",
2541 .data = &sysctl_hung_task_panic,
2542 .maxlen = sizeof(int),
2544 .proc_handler = proc_dointvec_minmax,
2545 .extra1 = SYSCTL_ZERO,
2546 .extra2 = SYSCTL_ONE,
2549 .procname = "hung_task_check_count",
2550 .data = &sysctl_hung_task_check_count,
2551 .maxlen = sizeof(int),
2553 .proc_handler = proc_dointvec_minmax,
2554 .extra1 = SYSCTL_ZERO,
2557 .procname = "hung_task_timeout_secs",
2558 .data = &sysctl_hung_task_timeout_secs,
2559 .maxlen = sizeof(unsigned long),
2561 .proc_handler = proc_dohung_task_timeout_secs,
2562 .extra2 = &hung_task_timeout_max,
2565 .procname = "hung_task_check_interval_secs",
2566 .data = &sysctl_hung_task_check_interval_secs,
2567 .maxlen = sizeof(unsigned long),
2569 .proc_handler = proc_dohung_task_timeout_secs,
2570 .extra2 = &hung_task_timeout_max,
2573 .procname = "hung_task_warnings",
2574 .data = &sysctl_hung_task_warnings,
2575 .maxlen = sizeof(int),
2577 .proc_handler = proc_dointvec_minmax,
2581 #ifdef CONFIG_RT_MUTEXES
2583 .procname = "max_lock_depth",
2584 .data = &max_lock_depth,
2585 .maxlen = sizeof(int),
2587 .proc_handler = proc_dointvec,
2591 .procname = "poweroff_cmd",
2592 .data = &poweroff_cmd,
2593 .maxlen = POWEROFF_CMD_PATH_LEN,
2595 .proc_handler = proc_dostring,
2601 .child = key_sysctls,
2604 #ifdef CONFIG_PERF_EVENTS
2606 * User-space scripts rely on the existence of this file
2607 * as a feature check for perf_events being enabled.
2609 * So it's an ABI, do not remove!
2612 .procname = "perf_event_paranoid",
2613 .data = &sysctl_perf_event_paranoid,
2614 .maxlen = sizeof(sysctl_perf_event_paranoid),
2616 .proc_handler = proc_dointvec,
2619 .procname = "perf_event_mlock_kb",
2620 .data = &sysctl_perf_event_mlock,
2621 .maxlen = sizeof(sysctl_perf_event_mlock),
2623 .proc_handler = proc_dointvec,
2626 .procname = "perf_event_max_sample_rate",
2627 .data = &sysctl_perf_event_sample_rate,
2628 .maxlen = sizeof(sysctl_perf_event_sample_rate),
2630 .proc_handler = perf_proc_update_handler,
2631 .extra1 = SYSCTL_ONE,
2634 .procname = "perf_cpu_time_max_percent",
2635 .data = &sysctl_perf_cpu_time_max_percent,
2636 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
2638 .proc_handler = perf_cpu_time_max_percent_handler,
2639 .extra1 = SYSCTL_ZERO,
2640 .extra2 = &one_hundred,
2643 .procname = "perf_event_max_stack",
2644 .data = &sysctl_perf_event_max_stack,
2645 .maxlen = sizeof(sysctl_perf_event_max_stack),
2647 .proc_handler = perf_event_max_stack_handler,
2648 .extra1 = SYSCTL_ZERO,
2649 .extra2 = &six_hundred_forty_kb,
2652 .procname = "perf_event_max_contexts_per_stack",
2653 .data = &sysctl_perf_event_max_contexts_per_stack,
2654 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
2656 .proc_handler = perf_event_max_stack_handler,
2657 .extra1 = SYSCTL_ZERO,
2658 .extra2 = &one_thousand,
2662 .procname = "panic_on_warn",
2663 .data = &panic_on_warn,
2664 .maxlen = sizeof(int),
2666 .proc_handler = proc_dointvec_minmax,
2667 .extra1 = SYSCTL_ZERO,
2668 .extra2 = SYSCTL_ONE,
2670 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2672 .procname = "timer_migration",
2673 .data = &sysctl_timer_migration,
2674 .maxlen = sizeof(unsigned int),
2676 .proc_handler = timer_migration_handler,
2677 .extra1 = SYSCTL_ZERO,
2678 .extra2 = SYSCTL_ONE,
2681 #ifdef CONFIG_BPF_SYSCALL
2683 .procname = "unprivileged_bpf_disabled",
2684 .data = &sysctl_unprivileged_bpf_disabled,
2685 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
2687 .proc_handler = bpf_unpriv_handler,
2688 .extra1 = SYSCTL_ZERO,
2692 .procname = "bpf_stats_enabled",
2693 .data = &bpf_stats_enabled_key.key,
2694 .maxlen = sizeof(bpf_stats_enabled_key),
2696 .proc_handler = bpf_stats_handler,
2699 #if defined(CONFIG_TREE_RCU)
2701 .procname = "panic_on_rcu_stall",
2702 .data = &sysctl_panic_on_rcu_stall,
2703 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
2705 .proc_handler = proc_dointvec_minmax,
2706 .extra1 = SYSCTL_ZERO,
2707 .extra2 = SYSCTL_ONE,
2710 #if defined(CONFIG_TREE_RCU)
2712 .procname = "max_rcu_stall_to_panic",
2713 .data = &sysctl_max_rcu_stall_to_panic,
2714 .maxlen = sizeof(sysctl_max_rcu_stall_to_panic),
2716 .proc_handler = proc_dointvec_minmax,
2717 .extra1 = SYSCTL_ONE,
2718 .extra2 = SYSCTL_INT_MAX,
2721 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2723 .procname = "stack_erasing",
2725 .maxlen = sizeof(int),
2727 .proc_handler = stack_erasing_sysctl,
2728 .extra1 = SYSCTL_ZERO,
2729 .extra2 = SYSCTL_ONE,
2735 static struct ctl_table vm_table[] = {
2737 .procname = "overcommit_memory",
2738 .data = &sysctl_overcommit_memory,
2739 .maxlen = sizeof(sysctl_overcommit_memory),
2741 .proc_handler = overcommit_policy_handler,
2742 .extra1 = SYSCTL_ZERO,
2746 .procname = "panic_on_oom",
2747 .data = &sysctl_panic_on_oom,
2748 .maxlen = sizeof(sysctl_panic_on_oom),
2750 .proc_handler = proc_dointvec_minmax,
2751 .extra1 = SYSCTL_ZERO,
2755 .procname = "oom_kill_allocating_task",
2756 .data = &sysctl_oom_kill_allocating_task,
2757 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
2759 .proc_handler = proc_dointvec,
2762 .procname = "oom_dump_tasks",
2763 .data = &sysctl_oom_dump_tasks,
2764 .maxlen = sizeof(sysctl_oom_dump_tasks),
2766 .proc_handler = proc_dointvec,
2769 .procname = "overcommit_ratio",
2770 .data = &sysctl_overcommit_ratio,
2771 .maxlen = sizeof(sysctl_overcommit_ratio),
2773 .proc_handler = overcommit_ratio_handler,
2776 .procname = "overcommit_kbytes",
2777 .data = &sysctl_overcommit_kbytes,
2778 .maxlen = sizeof(sysctl_overcommit_kbytes),
2780 .proc_handler = overcommit_kbytes_handler,
2783 .procname = "page-cluster",
2784 .data = &page_cluster,
2785 .maxlen = sizeof(int),
2787 .proc_handler = proc_dointvec_minmax,
2788 .extra1 = SYSCTL_ZERO,
2791 .procname = "dirty_background_ratio",
2792 .data = &dirty_background_ratio,
2793 .maxlen = sizeof(dirty_background_ratio),
2795 .proc_handler = dirty_background_ratio_handler,
2796 .extra1 = SYSCTL_ZERO,
2797 .extra2 = &one_hundred,
2800 .procname = "dirty_background_bytes",
2801 .data = &dirty_background_bytes,
2802 .maxlen = sizeof(dirty_background_bytes),
2804 .proc_handler = dirty_background_bytes_handler,
2808 .procname = "dirty_ratio",
2809 .data = &vm_dirty_ratio,
2810 .maxlen = sizeof(vm_dirty_ratio),
2812 .proc_handler = dirty_ratio_handler,
2813 .extra1 = SYSCTL_ZERO,
2814 .extra2 = &one_hundred,
2817 .procname = "dirty_bytes",
2818 .data = &vm_dirty_bytes,
2819 .maxlen = sizeof(vm_dirty_bytes),
2821 .proc_handler = dirty_bytes_handler,
2822 .extra1 = &dirty_bytes_min,
2825 .procname = "dirty_writeback_centisecs",
2826 .data = &dirty_writeback_interval,
2827 .maxlen = sizeof(dirty_writeback_interval),
2829 .proc_handler = dirty_writeback_centisecs_handler,
2832 .procname = "dirty_expire_centisecs",
2833 .data = &dirty_expire_interval,
2834 .maxlen = sizeof(dirty_expire_interval),
2836 .proc_handler = proc_dointvec_minmax,
2837 .extra1 = SYSCTL_ZERO,
2840 .procname = "dirtytime_expire_seconds",
2841 .data = &dirtytime_expire_interval,
2842 .maxlen = sizeof(dirtytime_expire_interval),
2844 .proc_handler = dirtytime_interval_handler,
2845 .extra1 = SYSCTL_ZERO,
2848 .procname = "swappiness",
2849 .data = &vm_swappiness,
2850 .maxlen = sizeof(vm_swappiness),
2852 .proc_handler = proc_dointvec_minmax,
2853 .extra1 = SYSCTL_ZERO,
2854 .extra2 = &two_hundred,
2858 .procname = "numa_stat",
2859 .data = &sysctl_vm_numa_stat,
2860 .maxlen = sizeof(int),
2862 .proc_handler = sysctl_vm_numa_stat_handler,
2863 .extra1 = SYSCTL_ZERO,
2864 .extra2 = SYSCTL_ONE,
2867 #ifdef CONFIG_HUGETLB_PAGE
2869 .procname = "nr_hugepages",
2871 .maxlen = sizeof(unsigned long),
2873 .proc_handler = hugetlb_sysctl_handler,
2877 .procname = "nr_hugepages_mempolicy",
2879 .maxlen = sizeof(unsigned long),
2881 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
2885 .procname = "hugetlb_shm_group",
2886 .data = &sysctl_hugetlb_shm_group,
2887 .maxlen = sizeof(gid_t),
2889 .proc_handler = proc_dointvec,
2892 .procname = "nr_overcommit_hugepages",
2894 .maxlen = sizeof(unsigned long),
2896 .proc_handler = hugetlb_overcommit_handler,
2900 .procname = "lowmem_reserve_ratio",
2901 .data = &sysctl_lowmem_reserve_ratio,
2902 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
2904 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
2907 .procname = "drop_caches",
2908 .data = &sysctl_drop_caches,
2909 .maxlen = sizeof(int),
2911 .proc_handler = drop_caches_sysctl_handler,
2912 .extra1 = SYSCTL_ONE,
2915 #ifdef CONFIG_COMPACTION
2917 .procname = "compact_memory",
2919 .maxlen = sizeof(int),
2921 .proc_handler = sysctl_compaction_handler,
2924 .procname = "compaction_proactiveness",
2925 .data = &sysctl_compaction_proactiveness,
2926 .maxlen = sizeof(sysctl_compaction_proactiveness),
2928 .proc_handler = compaction_proactiveness_sysctl_handler,
2929 .extra1 = SYSCTL_ZERO,
2930 .extra2 = &one_hundred,
2933 .procname = "extfrag_threshold",
2934 .data = &sysctl_extfrag_threshold,
2935 .maxlen = sizeof(int),
2937 .proc_handler = proc_dointvec_minmax,
2938 .extra1 = &min_extfrag_threshold,
2939 .extra2 = &max_extfrag_threshold,
2942 .procname = "compact_unevictable_allowed",
2943 .data = &sysctl_compact_unevictable_allowed,
2944 .maxlen = sizeof(int),
2946 .proc_handler = proc_dointvec_minmax_warn_RT_change,
2947 .extra1 = SYSCTL_ZERO,
2948 .extra2 = SYSCTL_ONE,
2951 #endif /* CONFIG_COMPACTION */
2953 .procname = "min_free_kbytes",
2954 .data = &min_free_kbytes,
2955 .maxlen = sizeof(min_free_kbytes),
2957 .proc_handler = min_free_kbytes_sysctl_handler,
2958 .extra1 = SYSCTL_ZERO,
2961 .procname = "watermark_boost_factor",
2962 .data = &watermark_boost_factor,
2963 .maxlen = sizeof(watermark_boost_factor),
2965 .proc_handler = proc_dointvec_minmax,
2966 .extra1 = SYSCTL_ZERO,
2969 .procname = "watermark_scale_factor",
2970 .data = &watermark_scale_factor,
2971 .maxlen = sizeof(watermark_scale_factor),
2973 .proc_handler = watermark_scale_factor_sysctl_handler,
2974 .extra1 = SYSCTL_ONE,
2975 .extra2 = &three_thousand,
2978 .procname = "percpu_pagelist_high_fraction",
2979 .data = &percpu_pagelist_high_fraction,
2980 .maxlen = sizeof(percpu_pagelist_high_fraction),
2982 .proc_handler = percpu_pagelist_high_fraction_sysctl_handler,
2983 .extra1 = SYSCTL_ZERO,
2986 .procname = "page_lock_unfairness",
2987 .data = &sysctl_page_lock_unfairness,
2988 .maxlen = sizeof(sysctl_page_lock_unfairness),
2990 .proc_handler = proc_dointvec_minmax,
2991 .extra1 = SYSCTL_ZERO,
2995 .procname = "max_map_count",
2996 .data = &sysctl_max_map_count,
2997 .maxlen = sizeof(sysctl_max_map_count),
2999 .proc_handler = proc_dointvec_minmax,
3000 .extra1 = SYSCTL_ZERO,
3004 .procname = "nr_trim_pages",
3005 .data = &sysctl_nr_trim_pages,
3006 .maxlen = sizeof(sysctl_nr_trim_pages),
3008 .proc_handler = proc_dointvec_minmax,
3009 .extra1 = SYSCTL_ZERO,
3013 .procname = "laptop_mode",
3014 .data = &laptop_mode,
3015 .maxlen = sizeof(laptop_mode),
3017 .proc_handler = proc_dointvec_jiffies,
3020 .procname = "vfs_cache_pressure",
3021 .data = &sysctl_vfs_cache_pressure,
3022 .maxlen = sizeof(sysctl_vfs_cache_pressure),
3024 .proc_handler = proc_dointvec_minmax,
3025 .extra1 = SYSCTL_ZERO,
3027 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
3028 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
3030 .procname = "legacy_va_layout",
3031 .data = &sysctl_legacy_va_layout,
3032 .maxlen = sizeof(sysctl_legacy_va_layout),
3034 .proc_handler = proc_dointvec_minmax,
3035 .extra1 = SYSCTL_ZERO,
3040 .procname = "zone_reclaim_mode",
3041 .data = &node_reclaim_mode,
3042 .maxlen = sizeof(node_reclaim_mode),
3044 .proc_handler = proc_dointvec_minmax,
3045 .extra1 = SYSCTL_ZERO,
3048 .procname = "min_unmapped_ratio",
3049 .data = &sysctl_min_unmapped_ratio,
3050 .maxlen = sizeof(sysctl_min_unmapped_ratio),
3052 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
3053 .extra1 = SYSCTL_ZERO,
3054 .extra2 = &one_hundred,
3057 .procname = "min_slab_ratio",
3058 .data = &sysctl_min_slab_ratio,
3059 .maxlen = sizeof(sysctl_min_slab_ratio),
3061 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
3062 .extra1 = SYSCTL_ZERO,
3063 .extra2 = &one_hundred,
3068 .procname = "stat_interval",
3069 .data = &sysctl_stat_interval,
3070 .maxlen = sizeof(sysctl_stat_interval),
3072 .proc_handler = proc_dointvec_jiffies,
3075 .procname = "stat_refresh",
3079 .proc_handler = vmstat_refresh,
3084 .procname = "mmap_min_addr",
3085 .data = &dac_mmap_min_addr,
3086 .maxlen = sizeof(unsigned long),
3088 .proc_handler = mmap_min_addr_handler,
3093 .procname = "numa_zonelist_order",
3094 .data = &numa_zonelist_order,
3095 .maxlen = NUMA_ZONELIST_ORDER_LEN,
3097 .proc_handler = numa_zonelist_order_handler,
3100 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
3101 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3103 .procname = "vdso_enabled",
3104 #ifdef CONFIG_X86_32
3105 .data = &vdso32_enabled,
3106 .maxlen = sizeof(vdso32_enabled),
3108 .data = &vdso_enabled,
3109 .maxlen = sizeof(vdso_enabled),
3112 .proc_handler = proc_dointvec,
3113 .extra1 = SYSCTL_ZERO,
3116 #ifdef CONFIG_HIGHMEM
3118 .procname = "highmem_is_dirtyable",
3119 .data = &vm_highmem_is_dirtyable,
3120 .maxlen = sizeof(vm_highmem_is_dirtyable),
3122 .proc_handler = proc_dointvec_minmax,
3123 .extra1 = SYSCTL_ZERO,
3124 .extra2 = SYSCTL_ONE,
3127 #ifdef CONFIG_MEMORY_FAILURE
3129 .procname = "memory_failure_early_kill",
3130 .data = &sysctl_memory_failure_early_kill,
3131 .maxlen = sizeof(sysctl_memory_failure_early_kill),
3133 .proc_handler = proc_dointvec_minmax,
3134 .extra1 = SYSCTL_ZERO,
3135 .extra2 = SYSCTL_ONE,
3138 .procname = "memory_failure_recovery",
3139 .data = &sysctl_memory_failure_recovery,
3140 .maxlen = sizeof(sysctl_memory_failure_recovery),
3142 .proc_handler = proc_dointvec_minmax,
3143 .extra1 = SYSCTL_ZERO,
3144 .extra2 = SYSCTL_ONE,
3148 .procname = "user_reserve_kbytes",
3149 .data = &sysctl_user_reserve_kbytes,
3150 .maxlen = sizeof(sysctl_user_reserve_kbytes),
3152 .proc_handler = proc_doulongvec_minmax,
3155 .procname = "admin_reserve_kbytes",
3156 .data = &sysctl_admin_reserve_kbytes,
3157 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
3159 .proc_handler = proc_doulongvec_minmax,
3161 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3163 .procname = "mmap_rnd_bits",
3164 .data = &mmap_rnd_bits,
3165 .maxlen = sizeof(mmap_rnd_bits),
3167 .proc_handler = proc_dointvec_minmax,
3168 .extra1 = (void *)&mmap_rnd_bits_min,
3169 .extra2 = (void *)&mmap_rnd_bits_max,
3172 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3174 .procname = "mmap_rnd_compat_bits",
3175 .data = &mmap_rnd_compat_bits,
3176 .maxlen = sizeof(mmap_rnd_compat_bits),
3178 .proc_handler = proc_dointvec_minmax,
3179 .extra1 = (void *)&mmap_rnd_compat_bits_min,
3180 .extra2 = (void *)&mmap_rnd_compat_bits_max,
3183 #ifdef CONFIG_USERFAULTFD
3185 .procname = "unprivileged_userfaultfd",
3186 .data = &sysctl_unprivileged_userfaultfd,
3187 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
3189 .proc_handler = proc_dointvec_minmax,
3190 .extra1 = SYSCTL_ZERO,
3191 .extra2 = SYSCTL_ONE,
3197 static struct ctl_table fs_table[] = {
3199 .procname = "inode-nr",
3200 .data = &inodes_stat,
3201 .maxlen = 2*sizeof(long),
3203 .proc_handler = proc_nr_inodes,
3206 .procname = "inode-state",
3207 .data = &inodes_stat,
3208 .maxlen = 7*sizeof(long),
3210 .proc_handler = proc_nr_inodes,
3213 .procname = "file-nr",
3214 .data = &files_stat,
3215 .maxlen = sizeof(files_stat),
3217 .proc_handler = proc_nr_files,
3220 .procname = "file-max",
3221 .data = &files_stat.max_files,
3222 .maxlen = sizeof(files_stat.max_files),
3224 .proc_handler = proc_doulongvec_minmax,
3226 .extra2 = &long_max,
3229 .procname = "nr_open",
3230 .data = &sysctl_nr_open,
3231 .maxlen = sizeof(unsigned int),
3233 .proc_handler = proc_dointvec_minmax,
3234 .extra1 = &sysctl_nr_open_min,
3235 .extra2 = &sysctl_nr_open_max,
3238 .procname = "dentry-state",
3239 .data = &dentry_stat,
3240 .maxlen = 6*sizeof(long),
3242 .proc_handler = proc_nr_dentry,
3245 .procname = "overflowuid",
3246 .data = &fs_overflowuid,
3247 .maxlen = sizeof(int),
3249 .proc_handler = proc_dointvec_minmax,
3250 .extra1 = &minolduid,
3251 .extra2 = &maxolduid,
3254 .procname = "overflowgid",
3255 .data = &fs_overflowgid,
3256 .maxlen = sizeof(int),
3258 .proc_handler = proc_dointvec_minmax,
3259 .extra1 = &minolduid,
3260 .extra2 = &maxolduid,
3262 #ifdef CONFIG_FILE_LOCKING
3264 .procname = "leases-enable",
3265 .data = &leases_enable,
3266 .maxlen = sizeof(int),
3268 .proc_handler = proc_dointvec,
3271 #ifdef CONFIG_DNOTIFY
3273 .procname = "dir-notify-enable",
3274 .data = &dir_notify_enable,
3275 .maxlen = sizeof(int),
3277 .proc_handler = proc_dointvec,
3281 #ifdef CONFIG_FILE_LOCKING
3283 .procname = "lease-break-time",
3284 .data = &lease_break_time,
3285 .maxlen = sizeof(int),
3287 .proc_handler = proc_dointvec,
3292 .procname = "aio-nr",
3294 .maxlen = sizeof(aio_nr),
3296 .proc_handler = proc_doulongvec_minmax,
3299 .procname = "aio-max-nr",
3300 .data = &aio_max_nr,
3301 .maxlen = sizeof(aio_max_nr),
3303 .proc_handler = proc_doulongvec_minmax,
3305 #endif /* CONFIG_AIO */
3306 #ifdef CONFIG_INOTIFY_USER
3308 .procname = "inotify",
3310 .child = inotify_table,
3313 #ifdef CONFIG_FANOTIFY
3315 .procname = "fanotify",
3317 .child = fanotify_table,
3322 .procname = "epoll",
3324 .child = epoll_table,
3329 .procname = "protected_symlinks",
3330 .data = &sysctl_protected_symlinks,
3331 .maxlen = sizeof(int),
3333 .proc_handler = proc_dointvec_minmax,
3334 .extra1 = SYSCTL_ZERO,
3335 .extra2 = SYSCTL_ONE,
3338 .procname = "protected_hardlinks",
3339 .data = &sysctl_protected_hardlinks,
3340 .maxlen = sizeof(int),
3342 .proc_handler = proc_dointvec_minmax,
3343 .extra1 = SYSCTL_ZERO,
3344 .extra2 = SYSCTL_ONE,
3347 .procname = "protected_fifos",
3348 .data = &sysctl_protected_fifos,
3349 .maxlen = sizeof(int),
3351 .proc_handler = proc_dointvec_minmax,
3352 .extra1 = SYSCTL_ZERO,
3356 .procname = "protected_regular",
3357 .data = &sysctl_protected_regular,
3358 .maxlen = sizeof(int),
3360 .proc_handler = proc_dointvec_minmax,
3361 .extra1 = SYSCTL_ZERO,
3365 .procname = "suid_dumpable",
3366 .data = &suid_dumpable,
3367 .maxlen = sizeof(int),
3369 .proc_handler = proc_dointvec_minmax_coredump,
3370 .extra1 = SYSCTL_ZERO,
3373 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
3375 .procname = "binfmt_misc",
3377 .child = sysctl_mount_point,
3381 .procname = "pipe-max-size",
3382 .data = &pipe_max_size,
3383 .maxlen = sizeof(pipe_max_size),
3385 .proc_handler = proc_dopipe_max_size,
3388 .procname = "pipe-user-pages-hard",
3389 .data = &pipe_user_pages_hard,
3390 .maxlen = sizeof(pipe_user_pages_hard),
3392 .proc_handler = proc_doulongvec_minmax,
3395 .procname = "pipe-user-pages-soft",
3396 .data = &pipe_user_pages_soft,
3397 .maxlen = sizeof(pipe_user_pages_soft),
3399 .proc_handler = proc_doulongvec_minmax,
3402 .procname = "mount-max",
3403 .data = &sysctl_mount_max,
3404 .maxlen = sizeof(unsigned int),
3406 .proc_handler = proc_dointvec_minmax,
3407 .extra1 = SYSCTL_ONE,
3412 static struct ctl_table debug_table[] = {
3413 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3415 .procname = "exception-trace",
3416 .data = &show_unhandled_signals,
3417 .maxlen = sizeof(int),
3419 .proc_handler = proc_dointvec
3422 #if defined(CONFIG_OPTPROBES)
3424 .procname = "kprobes-optimization",
3425 .data = &sysctl_kprobes_optimization,
3426 .maxlen = sizeof(int),
3428 .proc_handler = proc_kprobes_optimization_handler,
3429 .extra1 = SYSCTL_ZERO,
3430 .extra2 = SYSCTL_ONE,
3436 static struct ctl_table dev_table[] = {
3440 static struct ctl_table sysctl_base_table[] = {
3442 .procname = "kernel",
3444 .child = kern_table,
3457 .procname = "debug",
3459 .child = debug_table,
3469 int __init sysctl_init(void)
3471 struct ctl_table_header *hdr;
3473 hdr = register_sysctl_table(sysctl_base_table);
3474 kmemleak_not_leak(hdr);
3477 #endif /* CONFIG_SYSCTL */
3479 * No sense putting this after each symbol definition, twice,
3480 * exception granted :-)
3482 EXPORT_SYMBOL(proc_dobool);
3483 EXPORT_SYMBOL(proc_dointvec);
3484 EXPORT_SYMBOL(proc_douintvec);
3485 EXPORT_SYMBOL(proc_dointvec_jiffies);
3486 EXPORT_SYMBOL(proc_dointvec_minmax);
3487 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3488 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3489 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3490 EXPORT_SYMBOL(proc_dostring);
3491 EXPORT_SYMBOL(proc_doulongvec_minmax);
3492 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3493 EXPORT_SYMBOL(proc_do_large_bitmap);