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_COMPACTION
188 static int min_extfrag_threshold;
189 static int max_extfrag_threshold = 1000;
192 #endif /* CONFIG_SYSCTL */
194 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
195 static int bpf_stats_handler(struct ctl_table *table, int write,
196 void *buffer, size_t *lenp, loff_t *ppos)
198 struct static_key *key = (struct static_key *)table->data;
199 static int saved_val;
201 struct ctl_table tmp = {
203 .maxlen = sizeof(val),
205 .extra1 = SYSCTL_ZERO,
206 .extra2 = SYSCTL_ONE,
209 if (write && !capable(CAP_SYS_ADMIN))
212 mutex_lock(&bpf_stats_enabled_mutex);
214 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
215 if (write && !ret && val != saved_val) {
217 static_key_slow_inc(key);
219 static_key_slow_dec(key);
222 mutex_unlock(&bpf_stats_enabled_mutex);
231 #ifdef CONFIG_PROC_SYSCTL
233 static int _proc_do_string(char *data, int maxlen, int write,
234 char *buffer, size_t *lenp, loff_t *ppos)
239 if (!data || !maxlen || !*lenp) {
245 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
246 /* Only continue writes not past the end of buffer. */
248 if (len > maxlen - 1)
255 /* Start writing from beginning of buffer. */
261 while ((p - buffer) < *lenp && len < maxlen - 1) {
263 if (c == 0 || c == '\n')
284 memcpy(buffer, data, len);
295 static void warn_sysctl_write(struct ctl_table *table)
297 pr_warn_once("%s wrote to %s when file position was not 0!\n"
298 "This will not be supported in the future. To silence this\n"
299 "warning, set kernel.sysctl_writes_strict = -1\n",
300 current->comm, table->procname);
304 * proc_first_pos_non_zero_ignore - check if first position is allowed
305 * @ppos: file position
306 * @table: the sysctl table
308 * Returns true if the first position is non-zero and the sysctl_writes_strict
309 * mode indicates this is not allowed for numeric input types. String proc
310 * handlers can ignore the return value.
312 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
313 struct ctl_table *table)
318 switch (sysctl_writes_strict) {
319 case SYSCTL_WRITES_STRICT:
321 case SYSCTL_WRITES_WARN:
322 warn_sysctl_write(table);
330 * proc_dostring - read a string sysctl
331 * @table: the sysctl table
332 * @write: %TRUE if this is a write to the sysctl file
333 * @buffer: the user buffer
334 * @lenp: the size of the user buffer
335 * @ppos: file position
337 * Reads/writes a string from/to the user buffer. If the kernel
338 * buffer provided is not large enough to hold the string, the
339 * string is truncated. The copied string is %NULL-terminated.
340 * If the string is being read by the user process, it is copied
341 * and a newline '\n' is added. It is truncated if the buffer is
344 * Returns 0 on success.
346 int proc_dostring(struct ctl_table *table, int write,
347 void *buffer, size_t *lenp, loff_t *ppos)
350 proc_first_pos_non_zero_ignore(ppos, table);
352 return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
356 static size_t proc_skip_spaces(char **buf)
359 char *tmp = skip_spaces(*buf);
365 static void proc_skip_char(char **buf, size_t *size, const char v)
376 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
379 * @cp: kernel buffer containing the string to parse
380 * @endp: pointer to store the trailing characters
381 * @base: the base to use
382 * @res: where the parsed integer will be stored
384 * In case of success 0 is returned and @res will contain the parsed integer,
385 * @endp will hold any trailing characters.
386 * This function will fail the parse on overflow. If there wasn't an overflow
387 * the function will defer the decision what characters count as invalid to the
390 static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
393 unsigned long long result;
396 cp = _parse_integer_fixup_radix(cp, &base);
397 rv = _parse_integer(cp, base, &result);
398 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
406 *res = (unsigned long)result;
412 * proc_get_long - reads an ASCII formatted integer from a user buffer
414 * @buf: a kernel buffer
415 * @size: size of the kernel buffer
416 * @val: this is where the number will be stored
417 * @neg: set to %TRUE if number is negative
418 * @perm_tr: a vector which contains the allowed trailers
419 * @perm_tr_len: size of the perm_tr vector
420 * @tr: pointer to store the trailer character
422 * In case of success %0 is returned and @buf and @size are updated with
423 * the amount of bytes read. If @tr is non-NULL and a trailing
424 * character exists (size is non-zero after returning from this
425 * function), @tr is updated with the trailing character.
427 static int proc_get_long(char **buf, size_t *size,
428 unsigned long *val, bool *neg,
429 const char *perm_tr, unsigned perm_tr_len, char *tr)
432 char *p, tmp[TMPBUFLEN];
438 if (len > TMPBUFLEN - 1)
441 memcpy(tmp, *buf, len);
445 if (*p == '-' && *size > 1) {
453 if (strtoul_lenient(p, &p, 0, val))
458 /* We don't know if the next char is whitespace thus we may accept
459 * invalid integers (e.g. 1234...a) or two integers instead of one
460 * (e.g. 123...1). So lets not allow such large numbers. */
461 if (len == TMPBUFLEN - 1)
464 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
467 if (tr && (len < *size))
477 * proc_put_long - converts an integer to a decimal ASCII formatted string
479 * @buf: the user buffer
480 * @size: the size of the user buffer
481 * @val: the integer to be converted
482 * @neg: sign of the number, %TRUE for negative
484 * In case of success @buf and @size are updated with the amount of bytes
487 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
490 char tmp[TMPBUFLEN], *p = tmp;
492 sprintf(p, "%s%lu", neg ? "-" : "", val);
496 memcpy(*buf, tmp, len);
502 static void proc_put_char(void **buf, size_t *size, char c)
505 char **buffer = (char **)buf;
514 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
516 int write, void *data)
520 if (*lvalp > (unsigned long) INT_MAX + 1)
524 if (*lvalp > (unsigned long) INT_MAX)
532 *lvalp = -(unsigned long)val;
535 *lvalp = (unsigned long)val;
541 static int do_proc_douintvec_conv(unsigned long *lvalp,
543 int write, void *data)
546 if (*lvalp > UINT_MAX)
550 unsigned int val = *valp;
551 *lvalp = (unsigned long)val;
556 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
558 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
559 int write, void *buffer,
560 size_t *lenp, loff_t *ppos,
561 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
562 int write, void *data),
565 int *i, vleft, first = 1, err = 0;
569 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
574 i = (int *) tbl_data;
575 vleft = table->maxlen / sizeof(*i);
579 conv = do_proc_dointvec_conv;
582 if (proc_first_pos_non_zero_ignore(ppos, table))
585 if (left > PAGE_SIZE - 1)
586 left = PAGE_SIZE - 1;
590 for (; left && vleft--; i++, first=0) {
595 left -= proc_skip_spaces(&p);
599 err = proc_get_long(&p, &left, &lval, &neg,
601 sizeof(proc_wspace_sep), NULL);
604 if (conv(&neg, &lval, i, 1, data)) {
609 if (conv(&neg, &lval, i, 0, data)) {
614 proc_put_char(&buffer, &left, '\t');
615 proc_put_long(&buffer, &left, lval, neg);
619 if (!write && !first && left && !err)
620 proc_put_char(&buffer, &left, '\n');
621 if (write && !err && left)
622 left -= proc_skip_spaces(&p);
624 return err ? : -EINVAL;
631 static int do_proc_dointvec(struct ctl_table *table, int write,
632 void *buffer, size_t *lenp, loff_t *ppos,
633 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
634 int write, void *data),
637 return __do_proc_dointvec(table->data, table, write,
638 buffer, lenp, ppos, conv, data);
641 static int do_proc_douintvec_w(unsigned int *tbl_data,
642 struct ctl_table *table,
644 size_t *lenp, loff_t *ppos,
645 int (*conv)(unsigned long *lvalp,
647 int write, void *data),
658 if (proc_first_pos_non_zero_ignore(ppos, table))
661 if (left > PAGE_SIZE - 1)
662 left = PAGE_SIZE - 1;
664 left -= proc_skip_spaces(&p);
670 err = proc_get_long(&p, &left, &lval, &neg,
672 sizeof(proc_wspace_sep), NULL);
678 if (conv(&lval, tbl_data, 1, data)) {
684 left -= proc_skip_spaces(&p);
692 /* This is in keeping with old __do_proc_dointvec() */
698 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
699 size_t *lenp, loff_t *ppos,
700 int (*conv)(unsigned long *lvalp,
702 int write, void *data),
711 if (conv(&lval, tbl_data, 0, data)) {
716 proc_put_long(&buffer, &left, lval, false);
720 proc_put_char(&buffer, &left, '\n');
729 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
730 int write, void *buffer,
731 size_t *lenp, loff_t *ppos,
732 int (*conv)(unsigned long *lvalp,
734 int write, void *data),
737 unsigned int *i, vleft;
739 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
744 i = (unsigned int *) tbl_data;
745 vleft = table->maxlen / sizeof(*i);
748 * Arrays are not supported, keep this simple. *Do not* add
757 conv = do_proc_douintvec_conv;
760 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
762 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
765 static int do_proc_douintvec(struct ctl_table *table, int write,
766 void *buffer, size_t *lenp, loff_t *ppos,
767 int (*conv)(unsigned long *lvalp,
769 int write, void *data),
772 return __do_proc_douintvec(table->data, table, write,
773 buffer, lenp, ppos, conv, data);
777 * proc_dointvec - read a vector of integers
778 * @table: the sysctl table
779 * @write: %TRUE if this is a write to the sysctl file
780 * @buffer: the user buffer
781 * @lenp: the size of the user buffer
782 * @ppos: file position
784 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
785 * values from/to the user buffer, treated as an ASCII string.
787 * Returns 0 on success.
789 int proc_dointvec(struct ctl_table *table, int write, void *buffer,
790 size_t *lenp, loff_t *ppos)
792 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
795 #ifdef CONFIG_COMPACTION
796 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
797 int write, void *buffer, size_t *lenp, loff_t *ppos)
801 if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
802 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
804 old = *(int *)table->data;
805 ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
808 if (old != *(int *)table->data)
809 pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
810 table->procname, current->comm,
811 task_pid_nr(current));
817 * proc_douintvec - read a vector of unsigned integers
818 * @table: the sysctl table
819 * @write: %TRUE if this is a write to the sysctl file
820 * @buffer: the user buffer
821 * @lenp: the size of the user buffer
822 * @ppos: file position
824 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
825 * values from/to the user buffer, treated as an ASCII string.
827 * Returns 0 on success.
829 int proc_douintvec(struct ctl_table *table, int write, void *buffer,
830 size_t *lenp, loff_t *ppos)
832 return do_proc_douintvec(table, write, buffer, lenp, ppos,
833 do_proc_douintvec_conv, NULL);
837 * Taint values can only be increased
838 * This means we can safely use a temporary.
840 static int proc_taint(struct ctl_table *table, int write,
841 void *buffer, size_t *lenp, loff_t *ppos)
844 unsigned long tmptaint = get_taint();
847 if (write && !capable(CAP_SYS_ADMIN))
852 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
860 * If we are relying on panic_on_taint not producing
861 * false positives due to userspace input, bail out
862 * before setting the requested taint flags.
864 if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
868 * Poor man's atomic or. Not worth adding a primitive
869 * to everyone's atomic.h for this
871 for (i = 0; i < TAINT_FLAGS_COUNT; i++)
872 if ((1UL << i) & tmptaint)
873 add_taint(i, LOCKDEP_STILL_OK);
880 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
881 void *buffer, size_t *lenp, loff_t *ppos)
883 if (write && !capable(CAP_SYS_ADMIN))
886 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
891 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
892 * @min: pointer to minimum allowable value
893 * @max: pointer to maximum allowable value
895 * The do_proc_dointvec_minmax_conv_param structure provides the
896 * minimum and maximum values for doing range checking for those sysctl
897 * parameters that use the proc_dointvec_minmax() handler.
899 struct do_proc_dointvec_minmax_conv_param {
904 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
906 int write, void *data)
909 struct do_proc_dointvec_minmax_conv_param *param = data;
911 * If writing, first do so via a temporary local int so we can
912 * bounds-check it before touching *valp.
914 int *ip = write ? &tmp : valp;
916 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
921 if ((param->min && *param->min > tmp) ||
922 (param->max && *param->max < tmp))
931 * proc_dointvec_minmax - read a vector of integers with min/max values
932 * @table: the sysctl table
933 * @write: %TRUE if this is a write to the sysctl file
934 * @buffer: the user buffer
935 * @lenp: the size of the user buffer
936 * @ppos: file position
938 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
939 * values from/to the user buffer, treated as an ASCII string.
941 * This routine will ensure the values are within the range specified by
942 * table->extra1 (min) and table->extra2 (max).
944 * Returns 0 on success or -EINVAL on write when the range check fails.
946 int proc_dointvec_minmax(struct ctl_table *table, int write,
947 void *buffer, size_t *lenp, loff_t *ppos)
949 struct do_proc_dointvec_minmax_conv_param param = {
950 .min = (int *) table->extra1,
951 .max = (int *) table->extra2,
953 return do_proc_dointvec(table, write, buffer, lenp, ppos,
954 do_proc_dointvec_minmax_conv, ¶m);
958 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
959 * @min: pointer to minimum allowable value
960 * @max: pointer to maximum allowable value
962 * The do_proc_douintvec_minmax_conv_param structure provides the
963 * minimum and maximum values for doing range checking for those sysctl
964 * parameters that use the proc_douintvec_minmax() handler.
966 struct do_proc_douintvec_minmax_conv_param {
971 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
973 int write, void *data)
977 struct do_proc_douintvec_minmax_conv_param *param = data;
978 /* write via temporary local uint for bounds-checking */
979 unsigned int *up = write ? &tmp : valp;
981 ret = do_proc_douintvec_conv(lvalp, up, write, data);
986 if ((param->min && *param->min > tmp) ||
987 (param->max && *param->max < tmp))
997 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
998 * @table: the sysctl table
999 * @write: %TRUE if this is a write to the sysctl file
1000 * @buffer: the user buffer
1001 * @lenp: the size of the user buffer
1002 * @ppos: file position
1004 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1005 * values from/to the user buffer, treated as an ASCII string. Negative
1006 * strings are not allowed.
1008 * This routine will ensure the values are within the range specified by
1009 * table->extra1 (min) and table->extra2 (max). There is a final sanity
1010 * check for UINT_MAX to avoid having to support wrap around uses from
1013 * Returns 0 on success or -ERANGE on write when the range check fails.
1015 int proc_douintvec_minmax(struct ctl_table *table, int write,
1016 void *buffer, size_t *lenp, loff_t *ppos)
1018 struct do_proc_douintvec_minmax_conv_param param = {
1019 .min = (unsigned int *) table->extra1,
1020 .max = (unsigned int *) table->extra2,
1022 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1023 do_proc_douintvec_minmax_conv, ¶m);
1026 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1028 int write, void *data)
1033 val = round_pipe_size(*lvalp);
1039 unsigned int val = *valp;
1040 *lvalp = (unsigned long) val;
1046 static int proc_dopipe_max_size(struct ctl_table *table, int write,
1047 void *buffer, size_t *lenp, loff_t *ppos)
1049 return do_proc_douintvec(table, write, buffer, lenp, ppos,
1050 do_proc_dopipe_max_size_conv, NULL);
1053 static void validate_coredump_safety(void)
1055 #ifdef CONFIG_COREDUMP
1056 if (suid_dumpable == SUID_DUMP_ROOT &&
1057 core_pattern[0] != '/' && core_pattern[0] != '|') {
1059 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1060 "Pipe handler or fully qualified core dump path required.\n"
1061 "Set kernel.core_pattern before fs.suid_dumpable.\n"
1067 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
1068 void *buffer, size_t *lenp, loff_t *ppos)
1070 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1072 validate_coredump_safety();
1076 #ifdef CONFIG_COREDUMP
1077 static int proc_dostring_coredump(struct ctl_table *table, int write,
1078 void *buffer, size_t *lenp, loff_t *ppos)
1080 int error = proc_dostring(table, write, buffer, lenp, ppos);
1082 validate_coredump_safety();
1087 #ifdef CONFIG_MAGIC_SYSRQ
1088 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1089 void *buffer, size_t *lenp, loff_t *ppos)
1095 ret = __do_proc_dointvec(&tmp, table, write, buffer,
1096 lenp, ppos, NULL, NULL);
1101 sysrq_toggle_support(tmp);
1107 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1108 int write, void *buffer, size_t *lenp, loff_t *ppos,
1109 unsigned long convmul, unsigned long convdiv)
1111 unsigned long *i, *min, *max;
1112 int vleft, first = 1, err = 0;
1116 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1121 i = (unsigned long *) data;
1122 min = (unsigned long *) table->extra1;
1123 max = (unsigned long *) table->extra2;
1124 vleft = table->maxlen / sizeof(unsigned long);
1128 if (proc_first_pos_non_zero_ignore(ppos, table))
1131 if (left > PAGE_SIZE - 1)
1132 left = PAGE_SIZE - 1;
1136 for (; left && vleft--; i++, first = 0) {
1142 left -= proc_skip_spaces(&p);
1146 err = proc_get_long(&p, &left, &val, &neg,
1148 sizeof(proc_wspace_sep), NULL);
1153 val = convmul * val / convdiv;
1154 if ((min && val < *min) || (max && val > *max)) {
1160 val = convdiv * (*i) / convmul;
1162 proc_put_char(&buffer, &left, '\t');
1163 proc_put_long(&buffer, &left, val, false);
1167 if (!write && !first && left && !err)
1168 proc_put_char(&buffer, &left, '\n');
1170 left -= proc_skip_spaces(&p);
1172 return err ? : -EINVAL;
1179 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1180 void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1181 unsigned long convdiv)
1183 return __do_proc_doulongvec_minmax(table->data, table, write,
1184 buffer, lenp, ppos, convmul, convdiv);
1188 * proc_doulongvec_minmax - read a vector of long integers with min/max values
1189 * @table: the sysctl table
1190 * @write: %TRUE if this is a write to the sysctl file
1191 * @buffer: the user buffer
1192 * @lenp: the size of the user buffer
1193 * @ppos: file position
1195 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1196 * values from/to the user buffer, treated as an ASCII string.
1198 * This routine will ensure the values are within the range specified by
1199 * table->extra1 (min) and table->extra2 (max).
1201 * Returns 0 on success.
1203 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1204 void *buffer, size_t *lenp, loff_t *ppos)
1206 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1210 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1211 * @table: the sysctl table
1212 * @write: %TRUE if this is a write to the sysctl file
1213 * @buffer: the user buffer
1214 * @lenp: the size of the user buffer
1215 * @ppos: file position
1217 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1218 * values from/to the user buffer, treated as an ASCII string. The values
1219 * are treated as milliseconds, and converted to jiffies when they are stored.
1221 * This routine will ensure the values are within the range specified by
1222 * table->extra1 (min) and table->extra2 (max).
1224 * Returns 0 on success.
1226 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1227 void *buffer, size_t *lenp, loff_t *ppos)
1229 return do_proc_doulongvec_minmax(table, write, buffer,
1230 lenp, ppos, HZ, 1000l);
1234 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1236 int write, void *data)
1239 if (*lvalp > INT_MAX / HZ)
1241 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1247 lval = -(unsigned long)val;
1250 lval = (unsigned long)val;
1257 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1259 int write, void *data)
1262 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1264 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1270 lval = -(unsigned long)val;
1273 lval = (unsigned long)val;
1275 *lvalp = jiffies_to_clock_t(lval);
1280 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1282 int write, void *data)
1285 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1295 lval = -(unsigned long)val;
1298 lval = (unsigned long)val;
1300 *lvalp = jiffies_to_msecs(lval);
1306 * proc_dointvec_jiffies - read a vector of integers as seconds
1307 * @table: the sysctl table
1308 * @write: %TRUE if this is a write to the sysctl file
1309 * @buffer: the user buffer
1310 * @lenp: the size of the user buffer
1311 * @ppos: file position
1313 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1314 * values from/to the user buffer, treated as an ASCII string.
1315 * The values read are assumed to be in seconds, and are converted into
1318 * Returns 0 on success.
1320 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1321 void *buffer, size_t *lenp, loff_t *ppos)
1323 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1324 do_proc_dointvec_jiffies_conv,NULL);
1328 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1329 * @table: the sysctl table
1330 * @write: %TRUE if this is a write to the sysctl file
1331 * @buffer: the user buffer
1332 * @lenp: the size of the user buffer
1333 * @ppos: pointer to the file position
1335 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1336 * values from/to the user buffer, treated as an ASCII string.
1337 * The values read are assumed to be in 1/USER_HZ seconds, and
1338 * are converted into jiffies.
1340 * Returns 0 on success.
1342 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1343 void *buffer, size_t *lenp, loff_t *ppos)
1345 return do_proc_dointvec(table,write,buffer,lenp,ppos,
1346 do_proc_dointvec_userhz_jiffies_conv,NULL);
1350 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1351 * @table: the sysctl table
1352 * @write: %TRUE if this is a write to the sysctl file
1353 * @buffer: the user buffer
1354 * @lenp: the size of the user buffer
1355 * @ppos: file position
1356 * @ppos: the current position in the file
1358 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1359 * values from/to the user buffer, treated as an ASCII string.
1360 * The values read are assumed to be in 1/1000 seconds, and
1361 * are converted into jiffies.
1363 * Returns 0 on success.
1365 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1366 size_t *lenp, loff_t *ppos)
1368 return do_proc_dointvec(table, write, buffer, lenp, ppos,
1369 do_proc_dointvec_ms_jiffies_conv, NULL);
1372 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1373 size_t *lenp, loff_t *ppos)
1375 struct pid *new_pid;
1379 tmp = pid_vnr(cad_pid);
1381 r = __do_proc_dointvec(&tmp, table, write, buffer,
1382 lenp, ppos, NULL, NULL);
1386 new_pid = find_get_pid(tmp);
1390 put_pid(xchg(&cad_pid, new_pid));
1395 * proc_do_large_bitmap - read/write from/to a large bitmap
1396 * @table: the sysctl table
1397 * @write: %TRUE if this is a write to the sysctl file
1398 * @buffer: the user buffer
1399 * @lenp: the size of the user buffer
1400 * @ppos: file position
1402 * The bitmap is stored at table->data and the bitmap length (in bits)
1405 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1406 * large bitmaps may be represented in a compact manner. Writing into
1407 * the file will clear the bitmap then update it with the given input.
1409 * Returns 0 on success.
1411 int proc_do_large_bitmap(struct ctl_table *table, int write,
1412 void *buffer, size_t *lenp, loff_t *ppos)
1416 size_t left = *lenp;
1417 unsigned long bitmap_len = table->maxlen;
1418 unsigned long *bitmap = *(unsigned long **) table->data;
1419 unsigned long *tmp_bitmap = NULL;
1420 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1422 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1431 if (left > PAGE_SIZE - 1) {
1432 left = PAGE_SIZE - 1;
1433 /* How much of the buffer we'll skip this pass */
1434 skipped = *lenp - left;
1437 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
1440 proc_skip_char(&p, &left, '\n');
1441 while (!err && left) {
1442 unsigned long val_a, val_b;
1446 /* In case we stop parsing mid-number, we can reset */
1448 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1451 * If we consumed the entirety of a truncated buffer or
1452 * only one char is left (may be a "-"), then stop here,
1453 * reset, & come back for more.
1455 if ((left <= 1) && skipped) {
1462 if (val_a >= bitmap_len || neg) {
1474 err = proc_get_long(&p, &left, &val_b,
1475 &neg, tr_b, sizeof(tr_b),
1478 * If we consumed all of a truncated buffer or
1479 * then stop here, reset, & come back for more.
1481 if (!left && skipped) {
1488 if (val_b >= bitmap_len || neg ||
1499 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1501 proc_skip_char(&p, &left, '\n');
1505 unsigned long bit_a, bit_b = 0;
1508 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1509 if (bit_a >= bitmap_len)
1511 bit_b = find_next_zero_bit(bitmap, bitmap_len,
1515 proc_put_char(&buffer, &left, ',');
1516 proc_put_long(&buffer, &left, bit_a, false);
1517 if (bit_a != bit_b) {
1518 proc_put_char(&buffer, &left, '-');
1519 proc_put_long(&buffer, &left, bit_b, false);
1524 proc_put_char(&buffer, &left, '\n');
1530 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1532 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1538 bitmap_free(tmp_bitmap);
1542 #else /* CONFIG_PROC_SYSCTL */
1544 int proc_dostring(struct ctl_table *table, int write,
1545 void *buffer, size_t *lenp, loff_t *ppos)
1550 int proc_dointvec(struct ctl_table *table, int write,
1551 void *buffer, size_t *lenp, loff_t *ppos)
1556 int proc_douintvec(struct ctl_table *table, int write,
1557 void *buffer, size_t *lenp, loff_t *ppos)
1562 int proc_dointvec_minmax(struct ctl_table *table, int write,
1563 void *buffer, size_t *lenp, loff_t *ppos)
1568 int proc_douintvec_minmax(struct ctl_table *table, int write,
1569 void *buffer, size_t *lenp, loff_t *ppos)
1574 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1575 void *buffer, size_t *lenp, loff_t *ppos)
1580 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1581 void *buffer, size_t *lenp, loff_t *ppos)
1586 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1587 void *buffer, size_t *lenp, loff_t *ppos)
1592 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1593 void *buffer, size_t *lenp, loff_t *ppos)
1598 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1599 void *buffer, size_t *lenp, loff_t *ppos)
1604 int proc_do_large_bitmap(struct ctl_table *table, int write,
1605 void *buffer, size_t *lenp, loff_t *ppos)
1610 #endif /* CONFIG_PROC_SYSCTL */
1612 #if defined(CONFIG_SYSCTL)
1613 int proc_do_static_key(struct ctl_table *table, int write,
1614 void *buffer, size_t *lenp, loff_t *ppos)
1616 struct static_key *key = (struct static_key *)table->data;
1617 static DEFINE_MUTEX(static_key_mutex);
1619 struct ctl_table tmp = {
1621 .maxlen = sizeof(val),
1622 .mode = table->mode,
1623 .extra1 = SYSCTL_ZERO,
1624 .extra2 = SYSCTL_ONE,
1627 if (write && !capable(CAP_SYS_ADMIN))
1630 mutex_lock(&static_key_mutex);
1631 val = static_key_enabled(key);
1632 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1633 if (write && !ret) {
1635 static_key_enable(key);
1637 static_key_disable(key);
1639 mutex_unlock(&static_key_mutex);
1643 static struct ctl_table kern_table[] = {
1645 .procname = "sched_child_runs_first",
1646 .data = &sysctl_sched_child_runs_first,
1647 .maxlen = sizeof(unsigned int),
1649 .proc_handler = proc_dointvec,
1651 #ifdef CONFIG_SCHEDSTATS
1653 .procname = "sched_schedstats",
1655 .maxlen = sizeof(unsigned int),
1657 .proc_handler = sysctl_schedstats,
1658 .extra1 = SYSCTL_ZERO,
1659 .extra2 = SYSCTL_ONE,
1661 #endif /* CONFIG_SCHEDSTATS */
1662 #ifdef CONFIG_NUMA_BALANCING
1664 .procname = "numa_balancing",
1665 .data = NULL, /* filled in by handler */
1666 .maxlen = sizeof(unsigned int),
1668 .proc_handler = sysctl_numa_balancing,
1669 .extra1 = SYSCTL_ZERO,
1670 .extra2 = SYSCTL_ONE,
1672 #endif /* CONFIG_NUMA_BALANCING */
1674 .procname = "sched_rt_period_us",
1675 .data = &sysctl_sched_rt_period,
1676 .maxlen = sizeof(unsigned int),
1678 .proc_handler = sched_rt_handler,
1681 .procname = "sched_rt_runtime_us",
1682 .data = &sysctl_sched_rt_runtime,
1683 .maxlen = sizeof(int),
1685 .proc_handler = sched_rt_handler,
1688 .procname = "sched_deadline_period_max_us",
1689 .data = &sysctl_sched_dl_period_max,
1690 .maxlen = sizeof(unsigned int),
1692 .proc_handler = proc_dointvec,
1695 .procname = "sched_deadline_period_min_us",
1696 .data = &sysctl_sched_dl_period_min,
1697 .maxlen = sizeof(unsigned int),
1699 .proc_handler = proc_dointvec,
1702 .procname = "sched_rr_timeslice_ms",
1703 .data = &sysctl_sched_rr_timeslice,
1704 .maxlen = sizeof(int),
1706 .proc_handler = sched_rr_handler,
1708 #ifdef CONFIG_UCLAMP_TASK
1710 .procname = "sched_util_clamp_min",
1711 .data = &sysctl_sched_uclamp_util_min,
1712 .maxlen = sizeof(unsigned int),
1714 .proc_handler = sysctl_sched_uclamp_handler,
1717 .procname = "sched_util_clamp_max",
1718 .data = &sysctl_sched_uclamp_util_max,
1719 .maxlen = sizeof(unsigned int),
1721 .proc_handler = sysctl_sched_uclamp_handler,
1724 .procname = "sched_util_clamp_min_rt_default",
1725 .data = &sysctl_sched_uclamp_util_min_rt_default,
1726 .maxlen = sizeof(unsigned int),
1728 .proc_handler = sysctl_sched_uclamp_handler,
1731 #ifdef CONFIG_SCHED_AUTOGROUP
1733 .procname = "sched_autogroup_enabled",
1734 .data = &sysctl_sched_autogroup_enabled,
1735 .maxlen = sizeof(unsigned int),
1737 .proc_handler = proc_dointvec_minmax,
1738 .extra1 = SYSCTL_ZERO,
1739 .extra2 = SYSCTL_ONE,
1742 #ifdef CONFIG_CFS_BANDWIDTH
1744 .procname = "sched_cfs_bandwidth_slice_us",
1745 .data = &sysctl_sched_cfs_bandwidth_slice,
1746 .maxlen = sizeof(unsigned int),
1748 .proc_handler = proc_dointvec_minmax,
1749 .extra1 = SYSCTL_ONE,
1752 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1754 .procname = "sched_energy_aware",
1755 .data = &sysctl_sched_energy_aware,
1756 .maxlen = sizeof(unsigned int),
1758 .proc_handler = sched_energy_aware_handler,
1759 .extra1 = SYSCTL_ZERO,
1760 .extra2 = SYSCTL_ONE,
1763 #ifdef CONFIG_PROVE_LOCKING
1765 .procname = "prove_locking",
1766 .data = &prove_locking,
1767 .maxlen = sizeof(int),
1769 .proc_handler = proc_dointvec,
1772 #ifdef CONFIG_LOCK_STAT
1774 .procname = "lock_stat",
1776 .maxlen = sizeof(int),
1778 .proc_handler = proc_dointvec,
1782 .procname = "panic",
1783 .data = &panic_timeout,
1784 .maxlen = sizeof(int),
1786 .proc_handler = proc_dointvec,
1788 #ifdef CONFIG_COREDUMP
1790 .procname = "core_uses_pid",
1791 .data = &core_uses_pid,
1792 .maxlen = sizeof(int),
1794 .proc_handler = proc_dointvec,
1797 .procname = "core_pattern",
1798 .data = core_pattern,
1799 .maxlen = CORENAME_MAX_SIZE,
1801 .proc_handler = proc_dostring_coredump,
1804 .procname = "core_pipe_limit",
1805 .data = &core_pipe_limit,
1806 .maxlen = sizeof(unsigned int),
1808 .proc_handler = proc_dointvec,
1811 #ifdef CONFIG_PROC_SYSCTL
1813 .procname = "tainted",
1814 .maxlen = sizeof(long),
1816 .proc_handler = proc_taint,
1819 .procname = "sysctl_writes_strict",
1820 .data = &sysctl_writes_strict,
1821 .maxlen = sizeof(int),
1823 .proc_handler = proc_dointvec_minmax,
1825 .extra2 = SYSCTL_ONE,
1828 #ifdef CONFIG_LATENCYTOP
1830 .procname = "latencytop",
1831 .data = &latencytop_enabled,
1832 .maxlen = sizeof(int),
1834 .proc_handler = sysctl_latencytop,
1837 #ifdef CONFIG_BLK_DEV_INITRD
1839 .procname = "real-root-dev",
1840 .data = &real_root_dev,
1841 .maxlen = sizeof(int),
1843 .proc_handler = proc_dointvec,
1847 .procname = "print-fatal-signals",
1848 .data = &print_fatal_signals,
1849 .maxlen = sizeof(int),
1851 .proc_handler = proc_dointvec,
1855 .procname = "reboot-cmd",
1856 .data = reboot_command,
1859 .proc_handler = proc_dostring,
1862 .procname = "stop-a",
1863 .data = &stop_a_enabled,
1864 .maxlen = sizeof (int),
1866 .proc_handler = proc_dointvec,
1869 .procname = "scons-poweroff",
1870 .data = &scons_pwroff,
1871 .maxlen = sizeof (int),
1873 .proc_handler = proc_dointvec,
1876 #ifdef CONFIG_SPARC64
1878 .procname = "tsb-ratio",
1879 .data = &sysctl_tsb_ratio,
1880 .maxlen = sizeof (int),
1882 .proc_handler = proc_dointvec,
1885 #ifdef CONFIG_PARISC
1887 .procname = "soft-power",
1888 .data = &pwrsw_enabled,
1889 .maxlen = sizeof (int),
1891 .proc_handler = proc_dointvec,
1894 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
1896 .procname = "unaligned-trap",
1897 .data = &unaligned_enabled,
1898 .maxlen = sizeof (int),
1900 .proc_handler = proc_dointvec,
1904 .procname = "ctrl-alt-del",
1906 .maxlen = sizeof(int),
1908 .proc_handler = proc_dointvec,
1910 #ifdef CONFIG_FUNCTION_TRACER
1912 .procname = "ftrace_enabled",
1913 .data = &ftrace_enabled,
1914 .maxlen = sizeof(int),
1916 .proc_handler = ftrace_enable_sysctl,
1919 #ifdef CONFIG_STACK_TRACER
1921 .procname = "stack_tracer_enabled",
1922 .data = &stack_tracer_enabled,
1923 .maxlen = sizeof(int),
1925 .proc_handler = stack_trace_sysctl,
1928 #ifdef CONFIG_TRACING
1930 .procname = "ftrace_dump_on_oops",
1931 .data = &ftrace_dump_on_oops,
1932 .maxlen = sizeof(int),
1934 .proc_handler = proc_dointvec,
1937 .procname = "traceoff_on_warning",
1938 .data = &__disable_trace_on_warning,
1939 .maxlen = sizeof(__disable_trace_on_warning),
1941 .proc_handler = proc_dointvec,
1944 .procname = "tracepoint_printk",
1945 .data = &tracepoint_printk,
1946 .maxlen = sizeof(tracepoint_printk),
1948 .proc_handler = tracepoint_printk_sysctl,
1951 #ifdef CONFIG_KEXEC_CORE
1953 .procname = "kexec_load_disabled",
1954 .data = &kexec_load_disabled,
1955 .maxlen = sizeof(int),
1957 /* only handle a transition from default "0" to "1" */
1958 .proc_handler = proc_dointvec_minmax,
1959 .extra1 = SYSCTL_ONE,
1960 .extra2 = SYSCTL_ONE,
1963 #ifdef CONFIG_MODULES
1965 .procname = "modprobe",
1966 .data = &modprobe_path,
1967 .maxlen = KMOD_PATH_LEN,
1969 .proc_handler = proc_dostring,
1972 .procname = "modules_disabled",
1973 .data = &modules_disabled,
1974 .maxlen = sizeof(int),
1976 /* only handle a transition from default "0" to "1" */
1977 .proc_handler = proc_dointvec_minmax,
1978 .extra1 = SYSCTL_ONE,
1979 .extra2 = SYSCTL_ONE,
1982 #ifdef CONFIG_UEVENT_HELPER
1984 .procname = "hotplug",
1985 .data = &uevent_helper,
1986 .maxlen = UEVENT_HELPER_PATH_LEN,
1988 .proc_handler = proc_dostring,
1991 #ifdef CONFIG_CHR_DEV_SG
1993 .procname = "sg-big-buff",
1994 .data = &sg_big_buff,
1995 .maxlen = sizeof (int),
1997 .proc_handler = proc_dointvec,
2000 #ifdef CONFIG_BSD_PROCESS_ACCT
2004 .maxlen = 3*sizeof(int),
2006 .proc_handler = proc_dointvec,
2009 #ifdef CONFIG_MAGIC_SYSRQ
2011 .procname = "sysrq",
2013 .maxlen = sizeof (int),
2015 .proc_handler = sysrq_sysctl_handler,
2018 #ifdef CONFIG_PROC_SYSCTL
2020 .procname = "cad_pid",
2022 .maxlen = sizeof (int),
2024 .proc_handler = proc_do_cad_pid,
2028 .procname = "threads-max",
2030 .maxlen = sizeof(int),
2032 .proc_handler = sysctl_max_threads,
2035 .procname = "random",
2037 .child = random_table,
2040 .procname = "usermodehelper",
2042 .child = usermodehelper_table,
2044 #ifdef CONFIG_FW_LOADER_USER_HELPER
2046 .procname = "firmware_config",
2048 .child = firmware_config_table,
2052 .procname = "overflowuid",
2053 .data = &overflowuid,
2054 .maxlen = sizeof(int),
2056 .proc_handler = proc_dointvec_minmax,
2057 .extra1 = &minolduid,
2058 .extra2 = &maxolduid,
2061 .procname = "overflowgid",
2062 .data = &overflowgid,
2063 .maxlen = sizeof(int),
2065 .proc_handler = proc_dointvec_minmax,
2066 .extra1 = &minolduid,
2067 .extra2 = &maxolduid,
2071 .procname = "userprocess_debug",
2072 .data = &show_unhandled_signals,
2073 .maxlen = sizeof(int),
2075 .proc_handler = proc_dointvec,
2080 .procname = "oops_all_cpu_backtrace",
2081 .data = &sysctl_oops_all_cpu_backtrace,
2082 .maxlen = sizeof(int),
2084 .proc_handler = proc_dointvec_minmax,
2085 .extra1 = SYSCTL_ZERO,
2086 .extra2 = SYSCTL_ONE,
2088 #endif /* CONFIG_SMP */
2090 .procname = "pid_max",
2092 .maxlen = sizeof (int),
2094 .proc_handler = proc_dointvec_minmax,
2095 .extra1 = &pid_max_min,
2096 .extra2 = &pid_max_max,
2099 .procname = "panic_on_oops",
2100 .data = &panic_on_oops,
2101 .maxlen = sizeof(int),
2103 .proc_handler = proc_dointvec,
2106 .procname = "panic_print",
2107 .data = &panic_print,
2108 .maxlen = sizeof(unsigned long),
2110 .proc_handler = proc_doulongvec_minmax,
2112 #if defined CONFIG_PRINTK
2114 .procname = "printk",
2115 .data = &console_loglevel,
2116 .maxlen = 4*sizeof(int),
2118 .proc_handler = proc_dointvec,
2121 .procname = "printk_ratelimit",
2122 .data = &printk_ratelimit_state.interval,
2123 .maxlen = sizeof(int),
2125 .proc_handler = proc_dointvec_jiffies,
2128 .procname = "printk_ratelimit_burst",
2129 .data = &printk_ratelimit_state.burst,
2130 .maxlen = sizeof(int),
2132 .proc_handler = proc_dointvec,
2135 .procname = "printk_delay",
2136 .data = &printk_delay_msec,
2137 .maxlen = sizeof(int),
2139 .proc_handler = proc_dointvec_minmax,
2140 .extra1 = SYSCTL_ZERO,
2141 .extra2 = &ten_thousand,
2144 .procname = "printk_devkmsg",
2145 .data = devkmsg_log_str,
2146 .maxlen = DEVKMSG_STR_MAX_SIZE,
2148 .proc_handler = devkmsg_sysctl_set_loglvl,
2151 .procname = "dmesg_restrict",
2152 .data = &dmesg_restrict,
2153 .maxlen = sizeof(int),
2155 .proc_handler = proc_dointvec_minmax_sysadmin,
2156 .extra1 = SYSCTL_ZERO,
2157 .extra2 = SYSCTL_ONE,
2160 .procname = "kptr_restrict",
2161 .data = &kptr_restrict,
2162 .maxlen = sizeof(int),
2164 .proc_handler = proc_dointvec_minmax_sysadmin,
2165 .extra1 = SYSCTL_ZERO,
2170 .procname = "ngroups_max",
2171 .data = &ngroups_max,
2172 .maxlen = sizeof (int),
2174 .proc_handler = proc_dointvec,
2177 .procname = "cap_last_cap",
2178 .data = (void *)&cap_last_cap,
2179 .maxlen = sizeof(int),
2181 .proc_handler = proc_dointvec,
2183 #if defined(CONFIG_LOCKUP_DETECTOR)
2185 .procname = "watchdog",
2186 .data = &watchdog_user_enabled,
2187 .maxlen = sizeof(int),
2189 .proc_handler = proc_watchdog,
2190 .extra1 = SYSCTL_ZERO,
2191 .extra2 = SYSCTL_ONE,
2194 .procname = "watchdog_thresh",
2195 .data = &watchdog_thresh,
2196 .maxlen = sizeof(int),
2198 .proc_handler = proc_watchdog_thresh,
2199 .extra1 = SYSCTL_ZERO,
2203 .procname = "nmi_watchdog",
2204 .data = &nmi_watchdog_user_enabled,
2205 .maxlen = sizeof(int),
2206 .mode = NMI_WATCHDOG_SYSCTL_PERM,
2207 .proc_handler = proc_nmi_watchdog,
2208 .extra1 = SYSCTL_ZERO,
2209 .extra2 = SYSCTL_ONE,
2212 .procname = "watchdog_cpumask",
2213 .data = &watchdog_cpumask_bits,
2216 .proc_handler = proc_watchdog_cpumask,
2218 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
2220 .procname = "soft_watchdog",
2221 .data = &soft_watchdog_user_enabled,
2222 .maxlen = sizeof(int),
2224 .proc_handler = proc_soft_watchdog,
2225 .extra1 = SYSCTL_ZERO,
2226 .extra2 = SYSCTL_ONE,
2229 .procname = "softlockup_panic",
2230 .data = &softlockup_panic,
2231 .maxlen = sizeof(int),
2233 .proc_handler = proc_dointvec_minmax,
2234 .extra1 = SYSCTL_ZERO,
2235 .extra2 = SYSCTL_ONE,
2239 .procname = "softlockup_all_cpu_backtrace",
2240 .data = &sysctl_softlockup_all_cpu_backtrace,
2241 .maxlen = sizeof(int),
2243 .proc_handler = proc_dointvec_minmax,
2244 .extra1 = SYSCTL_ZERO,
2245 .extra2 = SYSCTL_ONE,
2247 #endif /* CONFIG_SMP */
2249 #ifdef CONFIG_HARDLOCKUP_DETECTOR
2251 .procname = "hardlockup_panic",
2252 .data = &hardlockup_panic,
2253 .maxlen = sizeof(int),
2255 .proc_handler = proc_dointvec_minmax,
2256 .extra1 = SYSCTL_ZERO,
2257 .extra2 = SYSCTL_ONE,
2261 .procname = "hardlockup_all_cpu_backtrace",
2262 .data = &sysctl_hardlockup_all_cpu_backtrace,
2263 .maxlen = sizeof(int),
2265 .proc_handler = proc_dointvec_minmax,
2266 .extra1 = SYSCTL_ZERO,
2267 .extra2 = SYSCTL_ONE,
2269 #endif /* CONFIG_SMP */
2273 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2275 .procname = "unknown_nmi_panic",
2276 .data = &unknown_nmi_panic,
2277 .maxlen = sizeof (int),
2279 .proc_handler = proc_dointvec,
2283 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2284 defined(CONFIG_DEBUG_STACKOVERFLOW)
2286 .procname = "panic_on_stackoverflow",
2287 .data = &sysctl_panic_on_stackoverflow,
2288 .maxlen = sizeof(int),
2290 .proc_handler = proc_dointvec,
2293 #if defined(CONFIG_X86)
2295 .procname = "panic_on_unrecovered_nmi",
2296 .data = &panic_on_unrecovered_nmi,
2297 .maxlen = sizeof(int),
2299 .proc_handler = proc_dointvec,
2302 .procname = "panic_on_io_nmi",
2303 .data = &panic_on_io_nmi,
2304 .maxlen = sizeof(int),
2306 .proc_handler = proc_dointvec,
2309 .procname = "bootloader_type",
2310 .data = &bootloader_type,
2311 .maxlen = sizeof (int),
2313 .proc_handler = proc_dointvec,
2316 .procname = "bootloader_version",
2317 .data = &bootloader_version,
2318 .maxlen = sizeof (int),
2320 .proc_handler = proc_dointvec,
2323 .procname = "io_delay_type",
2324 .data = &io_delay_type,
2325 .maxlen = sizeof(int),
2327 .proc_handler = proc_dointvec,
2330 #if defined(CONFIG_MMU)
2332 .procname = "randomize_va_space",
2333 .data = &randomize_va_space,
2334 .maxlen = sizeof(int),
2336 .proc_handler = proc_dointvec,
2339 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2341 .procname = "spin_retry",
2342 .data = &spin_retry,
2343 .maxlen = sizeof (int),
2345 .proc_handler = proc_dointvec,
2348 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2350 .procname = "acpi_video_flags",
2351 .data = &acpi_realmode_flags,
2352 .maxlen = sizeof (unsigned long),
2354 .proc_handler = proc_doulongvec_minmax,
2357 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2359 .procname = "ignore-unaligned-usertrap",
2360 .data = &no_unaligned_warning,
2361 .maxlen = sizeof (int),
2363 .proc_handler = proc_dointvec,
2368 .procname = "unaligned-dump-stack",
2369 .data = &unaligned_dump_stack,
2370 .maxlen = sizeof (int),
2372 .proc_handler = proc_dointvec,
2375 #ifdef CONFIG_DETECT_HUNG_TASK
2378 .procname = "hung_task_all_cpu_backtrace",
2379 .data = &sysctl_hung_task_all_cpu_backtrace,
2380 .maxlen = sizeof(int),
2382 .proc_handler = proc_dointvec_minmax,
2383 .extra1 = SYSCTL_ZERO,
2384 .extra2 = SYSCTL_ONE,
2386 #endif /* CONFIG_SMP */
2388 .procname = "hung_task_panic",
2389 .data = &sysctl_hung_task_panic,
2390 .maxlen = sizeof(int),
2392 .proc_handler = proc_dointvec_minmax,
2393 .extra1 = SYSCTL_ZERO,
2394 .extra2 = SYSCTL_ONE,
2397 .procname = "hung_task_check_count",
2398 .data = &sysctl_hung_task_check_count,
2399 .maxlen = sizeof(int),
2401 .proc_handler = proc_dointvec_minmax,
2402 .extra1 = SYSCTL_ZERO,
2405 .procname = "hung_task_timeout_secs",
2406 .data = &sysctl_hung_task_timeout_secs,
2407 .maxlen = sizeof(unsigned long),
2409 .proc_handler = proc_dohung_task_timeout_secs,
2410 .extra2 = &hung_task_timeout_max,
2413 .procname = "hung_task_check_interval_secs",
2414 .data = &sysctl_hung_task_check_interval_secs,
2415 .maxlen = sizeof(unsigned long),
2417 .proc_handler = proc_dohung_task_timeout_secs,
2418 .extra2 = &hung_task_timeout_max,
2421 .procname = "hung_task_warnings",
2422 .data = &sysctl_hung_task_warnings,
2423 .maxlen = sizeof(int),
2425 .proc_handler = proc_dointvec_minmax,
2429 #ifdef CONFIG_RT_MUTEXES
2431 .procname = "max_lock_depth",
2432 .data = &max_lock_depth,
2433 .maxlen = sizeof(int),
2435 .proc_handler = proc_dointvec,
2439 .procname = "poweroff_cmd",
2440 .data = &poweroff_cmd,
2441 .maxlen = POWEROFF_CMD_PATH_LEN,
2443 .proc_handler = proc_dostring,
2449 .child = key_sysctls,
2452 #ifdef CONFIG_PERF_EVENTS
2454 * User-space scripts rely on the existence of this file
2455 * as a feature check for perf_events being enabled.
2457 * So it's an ABI, do not remove!
2460 .procname = "perf_event_paranoid",
2461 .data = &sysctl_perf_event_paranoid,
2462 .maxlen = sizeof(sysctl_perf_event_paranoid),
2464 .proc_handler = proc_dointvec,
2467 .procname = "perf_event_mlock_kb",
2468 .data = &sysctl_perf_event_mlock,
2469 .maxlen = sizeof(sysctl_perf_event_mlock),
2471 .proc_handler = proc_dointvec,
2474 .procname = "perf_event_max_sample_rate",
2475 .data = &sysctl_perf_event_sample_rate,
2476 .maxlen = sizeof(sysctl_perf_event_sample_rate),
2478 .proc_handler = perf_proc_update_handler,
2479 .extra1 = SYSCTL_ONE,
2482 .procname = "perf_cpu_time_max_percent",
2483 .data = &sysctl_perf_cpu_time_max_percent,
2484 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
2486 .proc_handler = perf_cpu_time_max_percent_handler,
2487 .extra1 = SYSCTL_ZERO,
2488 .extra2 = &one_hundred,
2491 .procname = "perf_event_max_stack",
2492 .data = &sysctl_perf_event_max_stack,
2493 .maxlen = sizeof(sysctl_perf_event_max_stack),
2495 .proc_handler = perf_event_max_stack_handler,
2496 .extra1 = SYSCTL_ZERO,
2497 .extra2 = &six_hundred_forty_kb,
2500 .procname = "perf_event_max_contexts_per_stack",
2501 .data = &sysctl_perf_event_max_contexts_per_stack,
2502 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
2504 .proc_handler = perf_event_max_stack_handler,
2505 .extra1 = SYSCTL_ZERO,
2506 .extra2 = &one_thousand,
2510 .procname = "panic_on_warn",
2511 .data = &panic_on_warn,
2512 .maxlen = sizeof(int),
2514 .proc_handler = proc_dointvec_minmax,
2515 .extra1 = SYSCTL_ZERO,
2516 .extra2 = SYSCTL_ONE,
2518 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2520 .procname = "timer_migration",
2521 .data = &sysctl_timer_migration,
2522 .maxlen = sizeof(unsigned int),
2524 .proc_handler = timer_migration_handler,
2525 .extra1 = SYSCTL_ZERO,
2526 .extra2 = SYSCTL_ONE,
2529 #ifdef CONFIG_BPF_SYSCALL
2531 .procname = "unprivileged_bpf_disabled",
2532 .data = &sysctl_unprivileged_bpf_disabled,
2533 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
2535 /* only handle a transition from default "0" to "1" */
2536 .proc_handler = proc_dointvec_minmax,
2537 .extra1 = SYSCTL_ONE,
2538 .extra2 = SYSCTL_ONE,
2541 .procname = "bpf_stats_enabled",
2542 .data = &bpf_stats_enabled_key.key,
2543 .maxlen = sizeof(bpf_stats_enabled_key),
2545 .proc_handler = bpf_stats_handler,
2548 #if defined(CONFIG_TREE_RCU)
2550 .procname = "panic_on_rcu_stall",
2551 .data = &sysctl_panic_on_rcu_stall,
2552 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
2554 .proc_handler = proc_dointvec_minmax,
2555 .extra1 = SYSCTL_ZERO,
2556 .extra2 = SYSCTL_ONE,
2559 #if defined(CONFIG_TREE_RCU)
2561 .procname = "max_rcu_stall_to_panic",
2562 .data = &sysctl_max_rcu_stall_to_panic,
2563 .maxlen = sizeof(sysctl_max_rcu_stall_to_panic),
2565 .proc_handler = proc_dointvec_minmax,
2566 .extra1 = SYSCTL_ONE,
2567 .extra2 = SYSCTL_INT_MAX,
2570 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2572 .procname = "stack_erasing",
2574 .maxlen = sizeof(int),
2576 .proc_handler = stack_erasing_sysctl,
2577 .extra1 = SYSCTL_ZERO,
2578 .extra2 = SYSCTL_ONE,
2584 static struct ctl_table vm_table[] = {
2586 .procname = "overcommit_memory",
2587 .data = &sysctl_overcommit_memory,
2588 .maxlen = sizeof(sysctl_overcommit_memory),
2590 .proc_handler = overcommit_policy_handler,
2591 .extra1 = SYSCTL_ZERO,
2595 .procname = "panic_on_oom",
2596 .data = &sysctl_panic_on_oom,
2597 .maxlen = sizeof(sysctl_panic_on_oom),
2599 .proc_handler = proc_dointvec_minmax,
2600 .extra1 = SYSCTL_ZERO,
2604 .procname = "oom_kill_allocating_task",
2605 .data = &sysctl_oom_kill_allocating_task,
2606 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
2608 .proc_handler = proc_dointvec,
2611 .procname = "oom_dump_tasks",
2612 .data = &sysctl_oom_dump_tasks,
2613 .maxlen = sizeof(sysctl_oom_dump_tasks),
2615 .proc_handler = proc_dointvec,
2618 .procname = "overcommit_ratio",
2619 .data = &sysctl_overcommit_ratio,
2620 .maxlen = sizeof(sysctl_overcommit_ratio),
2622 .proc_handler = overcommit_ratio_handler,
2625 .procname = "overcommit_kbytes",
2626 .data = &sysctl_overcommit_kbytes,
2627 .maxlen = sizeof(sysctl_overcommit_kbytes),
2629 .proc_handler = overcommit_kbytes_handler,
2632 .procname = "page-cluster",
2633 .data = &page_cluster,
2634 .maxlen = sizeof(int),
2636 .proc_handler = proc_dointvec_minmax,
2637 .extra1 = SYSCTL_ZERO,
2640 .procname = "dirty_background_ratio",
2641 .data = &dirty_background_ratio,
2642 .maxlen = sizeof(dirty_background_ratio),
2644 .proc_handler = dirty_background_ratio_handler,
2645 .extra1 = SYSCTL_ZERO,
2646 .extra2 = &one_hundred,
2649 .procname = "dirty_background_bytes",
2650 .data = &dirty_background_bytes,
2651 .maxlen = sizeof(dirty_background_bytes),
2653 .proc_handler = dirty_background_bytes_handler,
2657 .procname = "dirty_ratio",
2658 .data = &vm_dirty_ratio,
2659 .maxlen = sizeof(vm_dirty_ratio),
2661 .proc_handler = dirty_ratio_handler,
2662 .extra1 = SYSCTL_ZERO,
2663 .extra2 = &one_hundred,
2666 .procname = "dirty_bytes",
2667 .data = &vm_dirty_bytes,
2668 .maxlen = sizeof(vm_dirty_bytes),
2670 .proc_handler = dirty_bytes_handler,
2671 .extra1 = &dirty_bytes_min,
2674 .procname = "dirty_writeback_centisecs",
2675 .data = &dirty_writeback_interval,
2676 .maxlen = sizeof(dirty_writeback_interval),
2678 .proc_handler = dirty_writeback_centisecs_handler,
2681 .procname = "dirty_expire_centisecs",
2682 .data = &dirty_expire_interval,
2683 .maxlen = sizeof(dirty_expire_interval),
2685 .proc_handler = proc_dointvec_minmax,
2686 .extra1 = SYSCTL_ZERO,
2689 .procname = "dirtytime_expire_seconds",
2690 .data = &dirtytime_expire_interval,
2691 .maxlen = sizeof(dirtytime_expire_interval),
2693 .proc_handler = dirtytime_interval_handler,
2694 .extra1 = SYSCTL_ZERO,
2697 .procname = "swappiness",
2698 .data = &vm_swappiness,
2699 .maxlen = sizeof(vm_swappiness),
2701 .proc_handler = proc_dointvec_minmax,
2702 .extra1 = SYSCTL_ZERO,
2703 .extra2 = &two_hundred,
2705 #ifdef CONFIG_HUGETLB_PAGE
2707 .procname = "nr_hugepages",
2709 .maxlen = sizeof(unsigned long),
2711 .proc_handler = hugetlb_sysctl_handler,
2715 .procname = "nr_hugepages_mempolicy",
2717 .maxlen = sizeof(unsigned long),
2719 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
2722 .procname = "numa_stat",
2723 .data = &sysctl_vm_numa_stat,
2724 .maxlen = sizeof(int),
2726 .proc_handler = sysctl_vm_numa_stat_handler,
2727 .extra1 = SYSCTL_ZERO,
2728 .extra2 = SYSCTL_ONE,
2732 .procname = "hugetlb_shm_group",
2733 .data = &sysctl_hugetlb_shm_group,
2734 .maxlen = sizeof(gid_t),
2736 .proc_handler = proc_dointvec,
2739 .procname = "nr_overcommit_hugepages",
2741 .maxlen = sizeof(unsigned long),
2743 .proc_handler = hugetlb_overcommit_handler,
2747 .procname = "lowmem_reserve_ratio",
2748 .data = &sysctl_lowmem_reserve_ratio,
2749 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
2751 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
2754 .procname = "drop_caches",
2755 .data = &sysctl_drop_caches,
2756 .maxlen = sizeof(int),
2758 .proc_handler = drop_caches_sysctl_handler,
2759 .extra1 = SYSCTL_ONE,
2762 #ifdef CONFIG_COMPACTION
2764 .procname = "compact_memory",
2765 .data = &sysctl_compact_memory,
2766 .maxlen = sizeof(int),
2768 .proc_handler = sysctl_compaction_handler,
2771 .procname = "compaction_proactiveness",
2772 .data = &sysctl_compaction_proactiveness,
2773 .maxlen = sizeof(sysctl_compaction_proactiveness),
2775 .proc_handler = proc_dointvec_minmax,
2776 .extra1 = SYSCTL_ZERO,
2777 .extra2 = &one_hundred,
2780 .procname = "extfrag_threshold",
2781 .data = &sysctl_extfrag_threshold,
2782 .maxlen = sizeof(int),
2784 .proc_handler = proc_dointvec_minmax,
2785 .extra1 = &min_extfrag_threshold,
2786 .extra2 = &max_extfrag_threshold,
2789 .procname = "compact_unevictable_allowed",
2790 .data = &sysctl_compact_unevictable_allowed,
2791 .maxlen = sizeof(int),
2793 .proc_handler = proc_dointvec_minmax_warn_RT_change,
2794 .extra1 = SYSCTL_ZERO,
2795 .extra2 = SYSCTL_ONE,
2798 #endif /* CONFIG_COMPACTION */
2800 .procname = "min_free_kbytes",
2801 .data = &min_free_kbytes,
2802 .maxlen = sizeof(min_free_kbytes),
2804 .proc_handler = min_free_kbytes_sysctl_handler,
2805 .extra1 = SYSCTL_ZERO,
2808 .procname = "watermark_boost_factor",
2809 .data = &watermark_boost_factor,
2810 .maxlen = sizeof(watermark_boost_factor),
2812 .proc_handler = proc_dointvec_minmax,
2813 .extra1 = SYSCTL_ZERO,
2816 .procname = "watermark_scale_factor",
2817 .data = &watermark_scale_factor,
2818 .maxlen = sizeof(watermark_scale_factor),
2820 .proc_handler = watermark_scale_factor_sysctl_handler,
2821 .extra1 = SYSCTL_ONE,
2822 .extra2 = &one_thousand,
2825 .procname = "percpu_pagelist_fraction",
2826 .data = &percpu_pagelist_fraction,
2827 .maxlen = sizeof(percpu_pagelist_fraction),
2829 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
2830 .extra1 = SYSCTL_ZERO,
2833 .procname = "page_lock_unfairness",
2834 .data = &sysctl_page_lock_unfairness,
2835 .maxlen = sizeof(sysctl_page_lock_unfairness),
2837 .proc_handler = proc_dointvec_minmax,
2838 .extra1 = SYSCTL_ZERO,
2842 .procname = "max_map_count",
2843 .data = &sysctl_max_map_count,
2844 .maxlen = sizeof(sysctl_max_map_count),
2846 .proc_handler = proc_dointvec_minmax,
2847 .extra1 = SYSCTL_ZERO,
2851 .procname = "nr_trim_pages",
2852 .data = &sysctl_nr_trim_pages,
2853 .maxlen = sizeof(sysctl_nr_trim_pages),
2855 .proc_handler = proc_dointvec_minmax,
2856 .extra1 = SYSCTL_ZERO,
2860 .procname = "laptop_mode",
2861 .data = &laptop_mode,
2862 .maxlen = sizeof(laptop_mode),
2864 .proc_handler = proc_dointvec_jiffies,
2867 .procname = "block_dump",
2868 .data = &block_dump,
2869 .maxlen = sizeof(block_dump),
2871 .proc_handler = proc_dointvec_minmax,
2872 .extra1 = SYSCTL_ZERO,
2875 .procname = "vfs_cache_pressure",
2876 .data = &sysctl_vfs_cache_pressure,
2877 .maxlen = sizeof(sysctl_vfs_cache_pressure),
2879 .proc_handler = proc_dointvec_minmax,
2880 .extra1 = SYSCTL_ZERO,
2882 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
2883 defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
2885 .procname = "legacy_va_layout",
2886 .data = &sysctl_legacy_va_layout,
2887 .maxlen = sizeof(sysctl_legacy_va_layout),
2889 .proc_handler = proc_dointvec_minmax,
2890 .extra1 = SYSCTL_ZERO,
2895 .procname = "zone_reclaim_mode",
2896 .data = &node_reclaim_mode,
2897 .maxlen = sizeof(node_reclaim_mode),
2899 .proc_handler = proc_dointvec_minmax,
2900 .extra1 = SYSCTL_ZERO,
2903 .procname = "min_unmapped_ratio",
2904 .data = &sysctl_min_unmapped_ratio,
2905 .maxlen = sizeof(sysctl_min_unmapped_ratio),
2907 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
2908 .extra1 = SYSCTL_ZERO,
2909 .extra2 = &one_hundred,
2912 .procname = "min_slab_ratio",
2913 .data = &sysctl_min_slab_ratio,
2914 .maxlen = sizeof(sysctl_min_slab_ratio),
2916 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
2917 .extra1 = SYSCTL_ZERO,
2918 .extra2 = &one_hundred,
2923 .procname = "stat_interval",
2924 .data = &sysctl_stat_interval,
2925 .maxlen = sizeof(sysctl_stat_interval),
2927 .proc_handler = proc_dointvec_jiffies,
2930 .procname = "stat_refresh",
2934 .proc_handler = vmstat_refresh,
2939 .procname = "mmap_min_addr",
2940 .data = &dac_mmap_min_addr,
2941 .maxlen = sizeof(unsigned long),
2943 .proc_handler = mmap_min_addr_handler,
2948 .procname = "numa_zonelist_order",
2949 .data = &numa_zonelist_order,
2950 .maxlen = NUMA_ZONELIST_ORDER_LEN,
2952 .proc_handler = numa_zonelist_order_handler,
2955 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
2956 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
2958 .procname = "vdso_enabled",
2959 #ifdef CONFIG_X86_32
2960 .data = &vdso32_enabled,
2961 .maxlen = sizeof(vdso32_enabled),
2963 .data = &vdso_enabled,
2964 .maxlen = sizeof(vdso_enabled),
2967 .proc_handler = proc_dointvec,
2968 .extra1 = SYSCTL_ZERO,
2971 #ifdef CONFIG_HIGHMEM
2973 .procname = "highmem_is_dirtyable",
2974 .data = &vm_highmem_is_dirtyable,
2975 .maxlen = sizeof(vm_highmem_is_dirtyable),
2977 .proc_handler = proc_dointvec_minmax,
2978 .extra1 = SYSCTL_ZERO,
2979 .extra2 = SYSCTL_ONE,
2982 #ifdef CONFIG_MEMORY_FAILURE
2984 .procname = "memory_failure_early_kill",
2985 .data = &sysctl_memory_failure_early_kill,
2986 .maxlen = sizeof(sysctl_memory_failure_early_kill),
2988 .proc_handler = proc_dointvec_minmax,
2989 .extra1 = SYSCTL_ZERO,
2990 .extra2 = SYSCTL_ONE,
2993 .procname = "memory_failure_recovery",
2994 .data = &sysctl_memory_failure_recovery,
2995 .maxlen = sizeof(sysctl_memory_failure_recovery),
2997 .proc_handler = proc_dointvec_minmax,
2998 .extra1 = SYSCTL_ZERO,
2999 .extra2 = SYSCTL_ONE,
3003 .procname = "user_reserve_kbytes",
3004 .data = &sysctl_user_reserve_kbytes,
3005 .maxlen = sizeof(sysctl_user_reserve_kbytes),
3007 .proc_handler = proc_doulongvec_minmax,
3010 .procname = "admin_reserve_kbytes",
3011 .data = &sysctl_admin_reserve_kbytes,
3012 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
3014 .proc_handler = proc_doulongvec_minmax,
3016 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3018 .procname = "mmap_rnd_bits",
3019 .data = &mmap_rnd_bits,
3020 .maxlen = sizeof(mmap_rnd_bits),
3022 .proc_handler = proc_dointvec_minmax,
3023 .extra1 = (void *)&mmap_rnd_bits_min,
3024 .extra2 = (void *)&mmap_rnd_bits_max,
3027 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3029 .procname = "mmap_rnd_compat_bits",
3030 .data = &mmap_rnd_compat_bits,
3031 .maxlen = sizeof(mmap_rnd_compat_bits),
3033 .proc_handler = proc_dointvec_minmax,
3034 .extra1 = (void *)&mmap_rnd_compat_bits_min,
3035 .extra2 = (void *)&mmap_rnd_compat_bits_max,
3038 #ifdef CONFIG_USERFAULTFD
3040 .procname = "unprivileged_userfaultfd",
3041 .data = &sysctl_unprivileged_userfaultfd,
3042 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
3044 .proc_handler = proc_dointvec_minmax,
3045 .extra1 = SYSCTL_ZERO,
3046 .extra2 = SYSCTL_ONE,
3052 static struct ctl_table fs_table[] = {
3054 .procname = "inode-nr",
3055 .data = &inodes_stat,
3056 .maxlen = 2*sizeof(long),
3058 .proc_handler = proc_nr_inodes,
3061 .procname = "inode-state",
3062 .data = &inodes_stat,
3063 .maxlen = 7*sizeof(long),
3065 .proc_handler = proc_nr_inodes,
3068 .procname = "file-nr",
3069 .data = &files_stat,
3070 .maxlen = sizeof(files_stat),
3072 .proc_handler = proc_nr_files,
3075 .procname = "file-max",
3076 .data = &files_stat.max_files,
3077 .maxlen = sizeof(files_stat.max_files),
3079 .proc_handler = proc_doulongvec_minmax,
3081 .extra2 = &long_max,
3084 .procname = "nr_open",
3085 .data = &sysctl_nr_open,
3086 .maxlen = sizeof(unsigned int),
3088 .proc_handler = proc_dointvec_minmax,
3089 .extra1 = &sysctl_nr_open_min,
3090 .extra2 = &sysctl_nr_open_max,
3093 .procname = "dentry-state",
3094 .data = &dentry_stat,
3095 .maxlen = 6*sizeof(long),
3097 .proc_handler = proc_nr_dentry,
3100 .procname = "overflowuid",
3101 .data = &fs_overflowuid,
3102 .maxlen = sizeof(int),
3104 .proc_handler = proc_dointvec_minmax,
3105 .extra1 = &minolduid,
3106 .extra2 = &maxolduid,
3109 .procname = "overflowgid",
3110 .data = &fs_overflowgid,
3111 .maxlen = sizeof(int),
3113 .proc_handler = proc_dointvec_minmax,
3114 .extra1 = &minolduid,
3115 .extra2 = &maxolduid,
3117 #ifdef CONFIG_FILE_LOCKING
3119 .procname = "leases-enable",
3120 .data = &leases_enable,
3121 .maxlen = sizeof(int),
3123 .proc_handler = proc_dointvec,
3126 #ifdef CONFIG_DNOTIFY
3128 .procname = "dir-notify-enable",
3129 .data = &dir_notify_enable,
3130 .maxlen = sizeof(int),
3132 .proc_handler = proc_dointvec,
3136 #ifdef CONFIG_FILE_LOCKING
3138 .procname = "lease-break-time",
3139 .data = &lease_break_time,
3140 .maxlen = sizeof(int),
3142 .proc_handler = proc_dointvec,
3147 .procname = "aio-nr",
3149 .maxlen = sizeof(aio_nr),
3151 .proc_handler = proc_doulongvec_minmax,
3154 .procname = "aio-max-nr",
3155 .data = &aio_max_nr,
3156 .maxlen = sizeof(aio_max_nr),
3158 .proc_handler = proc_doulongvec_minmax,
3160 #endif /* CONFIG_AIO */
3161 #ifdef CONFIG_INOTIFY_USER
3163 .procname = "inotify",
3165 .child = inotify_table,
3170 .procname = "epoll",
3172 .child = epoll_table,
3177 .procname = "protected_symlinks",
3178 .data = &sysctl_protected_symlinks,
3179 .maxlen = sizeof(int),
3181 .proc_handler = proc_dointvec_minmax,
3182 .extra1 = SYSCTL_ZERO,
3183 .extra2 = SYSCTL_ONE,
3186 .procname = "protected_hardlinks",
3187 .data = &sysctl_protected_hardlinks,
3188 .maxlen = sizeof(int),
3190 .proc_handler = proc_dointvec_minmax,
3191 .extra1 = SYSCTL_ZERO,
3192 .extra2 = SYSCTL_ONE,
3195 .procname = "protected_fifos",
3196 .data = &sysctl_protected_fifos,
3197 .maxlen = sizeof(int),
3199 .proc_handler = proc_dointvec_minmax,
3200 .extra1 = SYSCTL_ZERO,
3204 .procname = "protected_regular",
3205 .data = &sysctl_protected_regular,
3206 .maxlen = sizeof(int),
3208 .proc_handler = proc_dointvec_minmax,
3209 .extra1 = SYSCTL_ZERO,
3213 .procname = "suid_dumpable",
3214 .data = &suid_dumpable,
3215 .maxlen = sizeof(int),
3217 .proc_handler = proc_dointvec_minmax_coredump,
3218 .extra1 = SYSCTL_ZERO,
3221 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
3223 .procname = "binfmt_misc",
3225 .child = sysctl_mount_point,
3229 .procname = "pipe-max-size",
3230 .data = &pipe_max_size,
3231 .maxlen = sizeof(pipe_max_size),
3233 .proc_handler = proc_dopipe_max_size,
3236 .procname = "pipe-user-pages-hard",
3237 .data = &pipe_user_pages_hard,
3238 .maxlen = sizeof(pipe_user_pages_hard),
3240 .proc_handler = proc_doulongvec_minmax,
3243 .procname = "pipe-user-pages-soft",
3244 .data = &pipe_user_pages_soft,
3245 .maxlen = sizeof(pipe_user_pages_soft),
3247 .proc_handler = proc_doulongvec_minmax,
3250 .procname = "mount-max",
3251 .data = &sysctl_mount_max,
3252 .maxlen = sizeof(unsigned int),
3254 .proc_handler = proc_dointvec_minmax,
3255 .extra1 = SYSCTL_ONE,
3260 static struct ctl_table debug_table[] = {
3261 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3263 .procname = "exception-trace",
3264 .data = &show_unhandled_signals,
3265 .maxlen = sizeof(int),
3267 .proc_handler = proc_dointvec
3270 #if defined(CONFIG_OPTPROBES)
3272 .procname = "kprobes-optimization",
3273 .data = &sysctl_kprobes_optimization,
3274 .maxlen = sizeof(int),
3276 .proc_handler = proc_kprobes_optimization_handler,
3277 .extra1 = SYSCTL_ZERO,
3278 .extra2 = SYSCTL_ONE,
3284 static struct ctl_table dev_table[] = {
3288 static struct ctl_table sysctl_base_table[] = {
3290 .procname = "kernel",
3292 .child = kern_table,
3305 .procname = "debug",
3307 .child = debug_table,
3317 int __init sysctl_init(void)
3319 struct ctl_table_header *hdr;
3321 hdr = register_sysctl_table(sysctl_base_table);
3322 kmemleak_not_leak(hdr);
3325 #endif /* CONFIG_SYSCTL */
3327 * No sense putting this after each symbol definition, twice,
3328 * exception granted :-)
3330 EXPORT_SYMBOL(proc_dointvec);
3331 EXPORT_SYMBOL(proc_douintvec);
3332 EXPORT_SYMBOL(proc_dointvec_jiffies);
3333 EXPORT_SYMBOL(proc_dointvec_minmax);
3334 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3335 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3336 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3337 EXPORT_SYMBOL(proc_dostring);
3338 EXPORT_SYMBOL(proc_doulongvec_minmax);
3339 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3340 EXPORT_SYMBOL(proc_do_large_bitmap);