xref: /linux-6.15/kernel/sysctl.c (revision 9f269900)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * sysctl.c: General linux system control interface
4  *
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
13  *  Horn.
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
17  *  Wendling.
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
20  */
21 
22 #include <linux/module.h>
23 #include <linux/aio.h>
24 #include <linux/mm.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>
35 #include <linux/fs.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>
74 #include <linux/delayacct.h>
75 
76 #include "../lib/kstrtox.h"
77 
78 #include <linux/uaccess.h>
79 #include <asm/processor.h>
80 
81 #ifdef CONFIG_X86
82 #include <asm/nmi.h>
83 #include <asm/stacktrace.h>
84 #include <asm/io.h>
85 #endif
86 #ifdef CONFIG_SPARC
87 #include <asm/setup.h>
88 #endif
89 #ifdef CONFIG_BSD_PROCESS_ACCT
90 #include <linux/acct.h>
91 #endif
92 #ifdef CONFIG_RT_MUTEXES
93 #include <linux/rtmutex.h>
94 #endif
95 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
96 #include <linux/lockdep.h>
97 #endif
98 #ifdef CONFIG_CHR_DEV_SG
99 #include <scsi/sg.h>
100 #endif
101 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
102 #include <linux/stackleak.h>
103 #endif
104 #ifdef CONFIG_LOCKUP_DETECTOR
105 #include <linux/nmi.h>
106 #endif
107 
108 #if defined(CONFIG_SYSCTL)
109 
110 /* Constants used for minimum and  maximum */
111 #ifdef CONFIG_LOCKUP_DETECTOR
112 static int sixty = 60;
113 #endif
114 
115 static int __maybe_unused neg_one = -1;
116 static int __maybe_unused two = 2;
117 static int __maybe_unused four = 4;
118 static unsigned long zero_ul;
119 static unsigned long one_ul = 1;
120 static unsigned long long_max = LONG_MAX;
121 static int one_hundred = 100;
122 static int two_hundred = 200;
123 static int one_thousand = 1000;
124 #ifdef CONFIG_PRINTK
125 static int ten_thousand = 10000;
126 #endif
127 #ifdef CONFIG_PERF_EVENTS
128 static int six_hundred_forty_kb = 640 * 1024;
129 #endif
130 
131 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
132 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
133 
134 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
135 static int maxolduid = 65535;
136 static int minolduid;
137 
138 static int ngroups_max = NGROUPS_MAX;
139 static const int cap_last_cap = CAP_LAST_CAP;
140 
141 /*
142  * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
143  * and hung_task_check_interval_secs
144  */
145 #ifdef CONFIG_DETECT_HUNG_TASK
146 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
147 #endif
148 
149 #ifdef CONFIG_INOTIFY_USER
150 #include <linux/inotify.h>
151 #endif
152 #ifdef CONFIG_FANOTIFY
153 #include <linux/fanotify.h>
154 #endif
155 
156 #ifdef CONFIG_PROC_SYSCTL
157 
158 /**
159  * enum sysctl_writes_mode - supported sysctl write modes
160  *
161  * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
162  *	to be written, and multiple writes on the same sysctl file descriptor
163  *	will rewrite the sysctl value, regardless of file position. No warning
164  *	is issued when the initial position is not 0.
165  * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
166  *	not 0.
167  * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
168  *	file position 0 and the value must be fully contained in the buffer
169  *	sent to the write syscall. If dealing with strings respect the file
170  *	position, but restrict this to the max length of the buffer, anything
171  *	passed the max length will be ignored. Multiple writes will append
172  *	to the buffer.
173  *
174  * These write modes control how current file position affects the behavior of
175  * updating sysctl values through the proc interface on each write.
176  */
177 enum sysctl_writes_mode {
178 	SYSCTL_WRITES_LEGACY		= -1,
179 	SYSCTL_WRITES_WARN		= 0,
180 	SYSCTL_WRITES_STRICT		= 1,
181 };
182 
183 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
184 #endif /* CONFIG_PROC_SYSCTL */
185 
186 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
187     defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
188 int sysctl_legacy_va_layout;
189 #endif
190 
191 #ifdef CONFIG_COMPACTION
192 static int min_extfrag_threshold;
193 static int max_extfrag_threshold = 1000;
194 #endif
195 
196 #endif /* CONFIG_SYSCTL */
197 
198 #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
199 static int bpf_stats_handler(struct ctl_table *table, int write,
200 			     void *buffer, size_t *lenp, loff_t *ppos)
201 {
202 	struct static_key *key = (struct static_key *)table->data;
203 	static int saved_val;
204 	int val, ret;
205 	struct ctl_table tmp = {
206 		.data   = &val,
207 		.maxlen = sizeof(val),
208 		.mode   = table->mode,
209 		.extra1 = SYSCTL_ZERO,
210 		.extra2 = SYSCTL_ONE,
211 	};
212 
213 	if (write && !capable(CAP_SYS_ADMIN))
214 		return -EPERM;
215 
216 	mutex_lock(&bpf_stats_enabled_mutex);
217 	val = saved_val;
218 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
219 	if (write && !ret && val != saved_val) {
220 		if (val)
221 			static_key_slow_inc(key);
222 		else
223 			static_key_slow_dec(key);
224 		saved_val = val;
225 	}
226 	mutex_unlock(&bpf_stats_enabled_mutex);
227 	return ret;
228 }
229 #endif
230 
231 /*
232  * /proc/sys support
233  */
234 
235 #ifdef CONFIG_PROC_SYSCTL
236 
237 static int _proc_do_string(char *data, int maxlen, int write,
238 		char *buffer, size_t *lenp, loff_t *ppos)
239 {
240 	size_t len;
241 	char c, *p;
242 
243 	if (!data || !maxlen || !*lenp) {
244 		*lenp = 0;
245 		return 0;
246 	}
247 
248 	if (write) {
249 		if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
250 			/* Only continue writes not past the end of buffer. */
251 			len = strlen(data);
252 			if (len > maxlen - 1)
253 				len = maxlen - 1;
254 
255 			if (*ppos > len)
256 				return 0;
257 			len = *ppos;
258 		} else {
259 			/* Start writing from beginning of buffer. */
260 			len = 0;
261 		}
262 
263 		*ppos += *lenp;
264 		p = buffer;
265 		while ((p - buffer) < *lenp && len < maxlen - 1) {
266 			c = *(p++);
267 			if (c == 0 || c == '\n')
268 				break;
269 			data[len++] = c;
270 		}
271 		data[len] = 0;
272 	} else {
273 		len = strlen(data);
274 		if (len > maxlen)
275 			len = maxlen;
276 
277 		if (*ppos > len) {
278 			*lenp = 0;
279 			return 0;
280 		}
281 
282 		data += *ppos;
283 		len  -= *ppos;
284 
285 		if (len > *lenp)
286 			len = *lenp;
287 		if (len)
288 			memcpy(buffer, data, len);
289 		if (len < *lenp) {
290 			buffer[len] = '\n';
291 			len++;
292 		}
293 		*lenp = len;
294 		*ppos += len;
295 	}
296 	return 0;
297 }
298 
299 static void warn_sysctl_write(struct ctl_table *table)
300 {
301 	pr_warn_once("%s wrote to %s when file position was not 0!\n"
302 		"This will not be supported in the future. To silence this\n"
303 		"warning, set kernel.sysctl_writes_strict = -1\n",
304 		current->comm, table->procname);
305 }
306 
307 /**
308  * proc_first_pos_non_zero_ignore - check if first position is allowed
309  * @ppos: file position
310  * @table: the sysctl table
311  *
312  * Returns true if the first position is non-zero and the sysctl_writes_strict
313  * mode indicates this is not allowed for numeric input types. String proc
314  * handlers can ignore the return value.
315  */
316 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
317 					   struct ctl_table *table)
318 {
319 	if (!*ppos)
320 		return false;
321 
322 	switch (sysctl_writes_strict) {
323 	case SYSCTL_WRITES_STRICT:
324 		return true;
325 	case SYSCTL_WRITES_WARN:
326 		warn_sysctl_write(table);
327 		return false;
328 	default:
329 		return false;
330 	}
331 }
332 
333 /**
334  * proc_dostring - read a string sysctl
335  * @table: the sysctl table
336  * @write: %TRUE if this is a write to the sysctl file
337  * @buffer: the user buffer
338  * @lenp: the size of the user buffer
339  * @ppos: file position
340  *
341  * Reads/writes a string from/to the user buffer. If the kernel
342  * buffer provided is not large enough to hold the string, the
343  * string is truncated. The copied string is %NULL-terminated.
344  * If the string is being read by the user process, it is copied
345  * and a newline '\n' is added. It is truncated if the buffer is
346  * not large enough.
347  *
348  * Returns 0 on success.
349  */
350 int proc_dostring(struct ctl_table *table, int write,
351 		  void *buffer, size_t *lenp, loff_t *ppos)
352 {
353 	if (write)
354 		proc_first_pos_non_zero_ignore(ppos, table);
355 
356 	return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
357 			ppos);
358 }
359 
360 static size_t proc_skip_spaces(char **buf)
361 {
362 	size_t ret;
363 	char *tmp = skip_spaces(*buf);
364 	ret = tmp - *buf;
365 	*buf = tmp;
366 	return ret;
367 }
368 
369 static void proc_skip_char(char **buf, size_t *size, const char v)
370 {
371 	while (*size) {
372 		if (**buf != v)
373 			break;
374 		(*size)--;
375 		(*buf)++;
376 	}
377 }
378 
379 /**
380  * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
381  *                   fail on overflow
382  *
383  * @cp: kernel buffer containing the string to parse
384  * @endp: pointer to store the trailing characters
385  * @base: the base to use
386  * @res: where the parsed integer will be stored
387  *
388  * In case of success 0 is returned and @res will contain the parsed integer,
389  * @endp will hold any trailing characters.
390  * This function will fail the parse on overflow. If there wasn't an overflow
391  * the function will defer the decision what characters count as invalid to the
392  * caller.
393  */
394 static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
395 			   unsigned long *res)
396 {
397 	unsigned long long result;
398 	unsigned int rv;
399 
400 	cp = _parse_integer_fixup_radix(cp, &base);
401 	rv = _parse_integer(cp, base, &result);
402 	if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
403 		return -ERANGE;
404 
405 	cp += rv;
406 
407 	if (endp)
408 		*endp = (char *)cp;
409 
410 	*res = (unsigned long)result;
411 	return 0;
412 }
413 
414 #define TMPBUFLEN 22
415 /**
416  * proc_get_long - reads an ASCII formatted integer from a user buffer
417  *
418  * @buf: a kernel buffer
419  * @size: size of the kernel buffer
420  * @val: this is where the number will be stored
421  * @neg: set to %TRUE if number is negative
422  * @perm_tr: a vector which contains the allowed trailers
423  * @perm_tr_len: size of the perm_tr vector
424  * @tr: pointer to store the trailer character
425  *
426  * In case of success %0 is returned and @buf and @size are updated with
427  * the amount of bytes read. If @tr is non-NULL and a trailing
428  * character exists (size is non-zero after returning from this
429  * function), @tr is updated with the trailing character.
430  */
431 static int proc_get_long(char **buf, size_t *size,
432 			  unsigned long *val, bool *neg,
433 			  const char *perm_tr, unsigned perm_tr_len, char *tr)
434 {
435 	int len;
436 	char *p, tmp[TMPBUFLEN];
437 
438 	if (!*size)
439 		return -EINVAL;
440 
441 	len = *size;
442 	if (len > TMPBUFLEN - 1)
443 		len = TMPBUFLEN - 1;
444 
445 	memcpy(tmp, *buf, len);
446 
447 	tmp[len] = 0;
448 	p = tmp;
449 	if (*p == '-' && *size > 1) {
450 		*neg = true;
451 		p++;
452 	} else
453 		*neg = false;
454 	if (!isdigit(*p))
455 		return -EINVAL;
456 
457 	if (strtoul_lenient(p, &p, 0, val))
458 		return -EINVAL;
459 
460 	len = p - tmp;
461 
462 	/* We don't know if the next char is whitespace thus we may accept
463 	 * invalid integers (e.g. 1234...a) or two integers instead of one
464 	 * (e.g. 123...1). So lets not allow such large numbers. */
465 	if (len == TMPBUFLEN - 1)
466 		return -EINVAL;
467 
468 	if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
469 		return -EINVAL;
470 
471 	if (tr && (len < *size))
472 		*tr = *p;
473 
474 	*buf += len;
475 	*size -= len;
476 
477 	return 0;
478 }
479 
480 /**
481  * proc_put_long - converts an integer to a decimal ASCII formatted string
482  *
483  * @buf: the user buffer
484  * @size: the size of the user buffer
485  * @val: the integer to be converted
486  * @neg: sign of the number, %TRUE for negative
487  *
488  * In case of success @buf and @size are updated with the amount of bytes
489  * written.
490  */
491 static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
492 {
493 	int len;
494 	char tmp[TMPBUFLEN], *p = tmp;
495 
496 	sprintf(p, "%s%lu", neg ? "-" : "", val);
497 	len = strlen(tmp);
498 	if (len > *size)
499 		len = *size;
500 	memcpy(*buf, tmp, len);
501 	*size -= len;
502 	*buf += len;
503 }
504 #undef TMPBUFLEN
505 
506 static void proc_put_char(void **buf, size_t *size, char c)
507 {
508 	if (*size) {
509 		char **buffer = (char **)buf;
510 		**buffer = c;
511 
512 		(*size)--;
513 		(*buffer)++;
514 		*buf = *buffer;
515 	}
516 }
517 
518 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
519 				 int *valp,
520 				 int write, void *data)
521 {
522 	if (write) {
523 		if (*negp) {
524 			if (*lvalp > (unsigned long) INT_MAX + 1)
525 				return -EINVAL;
526 			*valp = -*lvalp;
527 		} else {
528 			if (*lvalp > (unsigned long) INT_MAX)
529 				return -EINVAL;
530 			*valp = *lvalp;
531 		}
532 	} else {
533 		int val = *valp;
534 		if (val < 0) {
535 			*negp = true;
536 			*lvalp = -(unsigned long)val;
537 		} else {
538 			*negp = false;
539 			*lvalp = (unsigned long)val;
540 		}
541 	}
542 	return 0;
543 }
544 
545 static int do_proc_douintvec_conv(unsigned long *lvalp,
546 				  unsigned int *valp,
547 				  int write, void *data)
548 {
549 	if (write) {
550 		if (*lvalp > UINT_MAX)
551 			return -EINVAL;
552 		*valp = *lvalp;
553 	} else {
554 		unsigned int val = *valp;
555 		*lvalp = (unsigned long)val;
556 	}
557 	return 0;
558 }
559 
560 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
561 
562 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
563 		  int write, void *buffer,
564 		  size_t *lenp, loff_t *ppos,
565 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
566 			      int write, void *data),
567 		  void *data)
568 {
569 	int *i, vleft, first = 1, err = 0;
570 	size_t left;
571 	char *p;
572 
573 	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
574 		*lenp = 0;
575 		return 0;
576 	}
577 
578 	i = (int *) tbl_data;
579 	vleft = table->maxlen / sizeof(*i);
580 	left = *lenp;
581 
582 	if (!conv)
583 		conv = do_proc_dointvec_conv;
584 
585 	if (write) {
586 		if (proc_first_pos_non_zero_ignore(ppos, table))
587 			goto out;
588 
589 		if (left > PAGE_SIZE - 1)
590 			left = PAGE_SIZE - 1;
591 		p = buffer;
592 	}
593 
594 	for (; left && vleft--; i++, first=0) {
595 		unsigned long lval;
596 		bool neg;
597 
598 		if (write) {
599 			left -= proc_skip_spaces(&p);
600 
601 			if (!left)
602 				break;
603 			err = proc_get_long(&p, &left, &lval, &neg,
604 					     proc_wspace_sep,
605 					     sizeof(proc_wspace_sep), NULL);
606 			if (err)
607 				break;
608 			if (conv(&neg, &lval, i, 1, data)) {
609 				err = -EINVAL;
610 				break;
611 			}
612 		} else {
613 			if (conv(&neg, &lval, i, 0, data)) {
614 				err = -EINVAL;
615 				break;
616 			}
617 			if (!first)
618 				proc_put_char(&buffer, &left, '\t');
619 			proc_put_long(&buffer, &left, lval, neg);
620 		}
621 	}
622 
623 	if (!write && !first && left && !err)
624 		proc_put_char(&buffer, &left, '\n');
625 	if (write && !err && left)
626 		left -= proc_skip_spaces(&p);
627 	if (write && first)
628 		return err ? : -EINVAL;
629 	*lenp -= left;
630 out:
631 	*ppos += *lenp;
632 	return err;
633 }
634 
635 static int do_proc_dointvec(struct ctl_table *table, int write,
636 		  void *buffer, size_t *lenp, loff_t *ppos,
637 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
638 			      int write, void *data),
639 		  void *data)
640 {
641 	return __do_proc_dointvec(table->data, table, write,
642 			buffer, lenp, ppos, conv, data);
643 }
644 
645 static int do_proc_douintvec_w(unsigned int *tbl_data,
646 			       struct ctl_table *table,
647 			       void *buffer,
648 			       size_t *lenp, loff_t *ppos,
649 			       int (*conv)(unsigned long *lvalp,
650 					   unsigned int *valp,
651 					   int write, void *data),
652 			       void *data)
653 {
654 	unsigned long lval;
655 	int err = 0;
656 	size_t left;
657 	bool neg;
658 	char *p = buffer;
659 
660 	left = *lenp;
661 
662 	if (proc_first_pos_non_zero_ignore(ppos, table))
663 		goto bail_early;
664 
665 	if (left > PAGE_SIZE - 1)
666 		left = PAGE_SIZE - 1;
667 
668 	left -= proc_skip_spaces(&p);
669 	if (!left) {
670 		err = -EINVAL;
671 		goto out_free;
672 	}
673 
674 	err = proc_get_long(&p, &left, &lval, &neg,
675 			     proc_wspace_sep,
676 			     sizeof(proc_wspace_sep), NULL);
677 	if (err || neg) {
678 		err = -EINVAL;
679 		goto out_free;
680 	}
681 
682 	if (conv(&lval, tbl_data, 1, data)) {
683 		err = -EINVAL;
684 		goto out_free;
685 	}
686 
687 	if (!err && left)
688 		left -= proc_skip_spaces(&p);
689 
690 out_free:
691 	if (err)
692 		return -EINVAL;
693 
694 	return 0;
695 
696 	/* This is in keeping with old __do_proc_dointvec() */
697 bail_early:
698 	*ppos += *lenp;
699 	return err;
700 }
701 
702 static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
703 			       size_t *lenp, loff_t *ppos,
704 			       int (*conv)(unsigned long *lvalp,
705 					   unsigned int *valp,
706 					   int write, void *data),
707 			       void *data)
708 {
709 	unsigned long lval;
710 	int err = 0;
711 	size_t left;
712 
713 	left = *lenp;
714 
715 	if (conv(&lval, tbl_data, 0, data)) {
716 		err = -EINVAL;
717 		goto out;
718 	}
719 
720 	proc_put_long(&buffer, &left, lval, false);
721 	if (!left)
722 		goto out;
723 
724 	proc_put_char(&buffer, &left, '\n');
725 
726 out:
727 	*lenp -= left;
728 	*ppos += *lenp;
729 
730 	return err;
731 }
732 
733 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
734 			       int write, void *buffer,
735 			       size_t *lenp, loff_t *ppos,
736 			       int (*conv)(unsigned long *lvalp,
737 					   unsigned int *valp,
738 					   int write, void *data),
739 			       void *data)
740 {
741 	unsigned int *i, vleft;
742 
743 	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
744 		*lenp = 0;
745 		return 0;
746 	}
747 
748 	i = (unsigned int *) tbl_data;
749 	vleft = table->maxlen / sizeof(*i);
750 
751 	/*
752 	 * Arrays are not supported, keep this simple. *Do not* add
753 	 * support for them.
754 	 */
755 	if (vleft != 1) {
756 		*lenp = 0;
757 		return -EINVAL;
758 	}
759 
760 	if (!conv)
761 		conv = do_proc_douintvec_conv;
762 
763 	if (write)
764 		return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
765 					   conv, data);
766 	return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
767 }
768 
769 static int do_proc_douintvec(struct ctl_table *table, int write,
770 			     void *buffer, size_t *lenp, loff_t *ppos,
771 			     int (*conv)(unsigned long *lvalp,
772 					 unsigned int *valp,
773 					 int write, void *data),
774 			     void *data)
775 {
776 	return __do_proc_douintvec(table->data, table, write,
777 				   buffer, lenp, ppos, conv, data);
778 }
779 
780 /**
781  * proc_dointvec - read a vector of integers
782  * @table: the sysctl table
783  * @write: %TRUE if this is a write to the sysctl file
784  * @buffer: the user buffer
785  * @lenp: the size of the user buffer
786  * @ppos: file position
787  *
788  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
789  * values from/to the user buffer, treated as an ASCII string.
790  *
791  * Returns 0 on success.
792  */
793 int proc_dointvec(struct ctl_table *table, int write, void *buffer,
794 		  size_t *lenp, loff_t *ppos)
795 {
796 	return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
797 }
798 
799 #ifdef CONFIG_COMPACTION
800 static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
801 		int write, void *buffer, size_t *lenp, loff_t *ppos)
802 {
803 	int ret, old;
804 
805 	if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
806 		return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
807 
808 	old = *(int *)table->data;
809 	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
810 	if (ret)
811 		return ret;
812 	if (old != *(int *)table->data)
813 		pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
814 			     table->procname, current->comm,
815 			     task_pid_nr(current));
816 	return ret;
817 }
818 #endif
819 
820 /**
821  * proc_douintvec - read a vector of unsigned integers
822  * @table: the sysctl table
823  * @write: %TRUE if this is a write to the sysctl file
824  * @buffer: the user buffer
825  * @lenp: the size of the user buffer
826  * @ppos: file position
827  *
828  * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
829  * values from/to the user buffer, treated as an ASCII string.
830  *
831  * Returns 0 on success.
832  */
833 int proc_douintvec(struct ctl_table *table, int write, void *buffer,
834 		size_t *lenp, loff_t *ppos)
835 {
836 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
837 				 do_proc_douintvec_conv, NULL);
838 }
839 
840 /*
841  * Taint values can only be increased
842  * This means we can safely use a temporary.
843  */
844 static int proc_taint(struct ctl_table *table, int write,
845 			       void *buffer, size_t *lenp, loff_t *ppos)
846 {
847 	struct ctl_table t;
848 	unsigned long tmptaint = get_taint();
849 	int err;
850 
851 	if (write && !capable(CAP_SYS_ADMIN))
852 		return -EPERM;
853 
854 	t = *table;
855 	t.data = &tmptaint;
856 	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
857 	if (err < 0)
858 		return err;
859 
860 	if (write) {
861 		int i;
862 
863 		/*
864 		 * If we are relying on panic_on_taint not producing
865 		 * false positives due to userspace input, bail out
866 		 * before setting the requested taint flags.
867 		 */
868 		if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
869 			return -EINVAL;
870 
871 		/*
872 		 * Poor man's atomic or. Not worth adding a primitive
873 		 * to everyone's atomic.h for this
874 		 */
875 		for (i = 0; i < TAINT_FLAGS_COUNT; i++)
876 			if ((1UL << i) & tmptaint)
877 				add_taint(i, LOCKDEP_STILL_OK);
878 	}
879 
880 	return err;
881 }
882 
883 #ifdef CONFIG_PRINTK
884 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
885 				void *buffer, size_t *lenp, loff_t *ppos)
886 {
887 	if (write && !capable(CAP_SYS_ADMIN))
888 		return -EPERM;
889 
890 	return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
891 }
892 #endif
893 
894 /**
895  * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
896  * @min: pointer to minimum allowable value
897  * @max: pointer to maximum allowable value
898  *
899  * The do_proc_dointvec_minmax_conv_param structure provides the
900  * minimum and maximum values for doing range checking for those sysctl
901  * parameters that use the proc_dointvec_minmax() handler.
902  */
903 struct do_proc_dointvec_minmax_conv_param {
904 	int *min;
905 	int *max;
906 };
907 
908 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
909 					int *valp,
910 					int write, void *data)
911 {
912 	int tmp, ret;
913 	struct do_proc_dointvec_minmax_conv_param *param = data;
914 	/*
915 	 * If writing, first do so via a temporary local int so we can
916 	 * bounds-check it before touching *valp.
917 	 */
918 	int *ip = write ? &tmp : valp;
919 
920 	ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
921 	if (ret)
922 		return ret;
923 
924 	if (write) {
925 		if ((param->min && *param->min > tmp) ||
926 		    (param->max && *param->max < tmp))
927 			return -EINVAL;
928 		*valp = tmp;
929 	}
930 
931 	return 0;
932 }
933 
934 /**
935  * proc_dointvec_minmax - read a vector of integers with min/max values
936  * @table: the sysctl table
937  * @write: %TRUE if this is a write to the sysctl file
938  * @buffer: the user buffer
939  * @lenp: the size of the user buffer
940  * @ppos: file position
941  *
942  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
943  * values from/to the user buffer, treated as an ASCII string.
944  *
945  * This routine will ensure the values are within the range specified by
946  * table->extra1 (min) and table->extra2 (max).
947  *
948  * Returns 0 on success or -EINVAL on write when the range check fails.
949  */
950 int proc_dointvec_minmax(struct ctl_table *table, int write,
951 		  void *buffer, size_t *lenp, loff_t *ppos)
952 {
953 	struct do_proc_dointvec_minmax_conv_param param = {
954 		.min = (int *) table->extra1,
955 		.max = (int *) table->extra2,
956 	};
957 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
958 				do_proc_dointvec_minmax_conv, &param);
959 }
960 
961 /**
962  * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
963  * @min: pointer to minimum allowable value
964  * @max: pointer to maximum allowable value
965  *
966  * The do_proc_douintvec_minmax_conv_param structure provides the
967  * minimum and maximum values for doing range checking for those sysctl
968  * parameters that use the proc_douintvec_minmax() handler.
969  */
970 struct do_proc_douintvec_minmax_conv_param {
971 	unsigned int *min;
972 	unsigned int *max;
973 };
974 
975 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
976 					 unsigned int *valp,
977 					 int write, void *data)
978 {
979 	int ret;
980 	unsigned int tmp;
981 	struct do_proc_douintvec_minmax_conv_param *param = data;
982 	/* write via temporary local uint for bounds-checking */
983 	unsigned int *up = write ? &tmp : valp;
984 
985 	ret = do_proc_douintvec_conv(lvalp, up, write, data);
986 	if (ret)
987 		return ret;
988 
989 	if (write) {
990 		if ((param->min && *param->min > tmp) ||
991 		    (param->max && *param->max < tmp))
992 			return -ERANGE;
993 
994 		*valp = tmp;
995 	}
996 
997 	return 0;
998 }
999 
1000 /**
1001  * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1002  * @table: the sysctl table
1003  * @write: %TRUE if this is a write to the sysctl file
1004  * @buffer: the user buffer
1005  * @lenp: the size of the user buffer
1006  * @ppos: file position
1007  *
1008  * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1009  * values from/to the user buffer, treated as an ASCII string. Negative
1010  * strings are not allowed.
1011  *
1012  * This routine will ensure the values are within the range specified by
1013  * table->extra1 (min) and table->extra2 (max). There is a final sanity
1014  * check for UINT_MAX to avoid having to support wrap around uses from
1015  * userspace.
1016  *
1017  * Returns 0 on success or -ERANGE on write when the range check fails.
1018  */
1019 int proc_douintvec_minmax(struct ctl_table *table, int write,
1020 			  void *buffer, size_t *lenp, loff_t *ppos)
1021 {
1022 	struct do_proc_douintvec_minmax_conv_param param = {
1023 		.min = (unsigned int *) table->extra1,
1024 		.max = (unsigned int *) table->extra2,
1025 	};
1026 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
1027 				 do_proc_douintvec_minmax_conv, &param);
1028 }
1029 
1030 /**
1031  * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1032  * @table: the sysctl table
1033  * @write: %TRUE if this is a write to the sysctl file
1034  * @buffer: the user buffer
1035  * @lenp: the size of the user buffer
1036  * @ppos: file position
1037  *
1038  * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1039  * values from/to the user buffer, treated as an ASCII string. Negative
1040  * strings are not allowed.
1041  *
1042  * This routine will ensure the values are within the range specified by
1043  * table->extra1 (min) and table->extra2 (max).
1044  *
1045  * Returns 0 on success or an error on write when the range check fails.
1046  */
1047 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1048 			void *buffer, size_t *lenp, loff_t *ppos)
1049 {
1050 	struct ctl_table tmp;
1051 	unsigned int min = 0, max = 255U, val;
1052 	u8 *data = table->data;
1053 	struct do_proc_douintvec_minmax_conv_param param = {
1054 		.min = &min,
1055 		.max = &max,
1056 	};
1057 	int res;
1058 
1059 	/* Do not support arrays yet. */
1060 	if (table->maxlen != sizeof(u8))
1061 		return -EINVAL;
1062 
1063 	if (table->extra1) {
1064 		min = *(unsigned int *) table->extra1;
1065 		if (min > 255U)
1066 			return -EINVAL;
1067 	}
1068 	if (table->extra2) {
1069 		max = *(unsigned int *) table->extra2;
1070 		if (max > 255U)
1071 			return -EINVAL;
1072 	}
1073 
1074 	tmp = *table;
1075 
1076 	tmp.maxlen = sizeof(val);
1077 	tmp.data = &val;
1078 	val = *data;
1079 	res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1080 				do_proc_douintvec_minmax_conv, &param);
1081 	if (res)
1082 		return res;
1083 	if (write)
1084 		*data = val;
1085 	return 0;
1086 }
1087 EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1088 
1089 static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1090 					unsigned int *valp,
1091 					int write, void *data)
1092 {
1093 	if (write) {
1094 		unsigned int val;
1095 
1096 		val = round_pipe_size(*lvalp);
1097 		if (val == 0)
1098 			return -EINVAL;
1099 
1100 		*valp = val;
1101 	} else {
1102 		unsigned int val = *valp;
1103 		*lvalp = (unsigned long) val;
1104 	}
1105 
1106 	return 0;
1107 }
1108 
1109 static int proc_dopipe_max_size(struct ctl_table *table, int write,
1110 				void *buffer, size_t *lenp, loff_t *ppos)
1111 {
1112 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
1113 				 do_proc_dopipe_max_size_conv, NULL);
1114 }
1115 
1116 static void validate_coredump_safety(void)
1117 {
1118 #ifdef CONFIG_COREDUMP
1119 	if (suid_dumpable == SUID_DUMP_ROOT &&
1120 	    core_pattern[0] != '/' && core_pattern[0] != '|') {
1121 		printk(KERN_WARNING
1122 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1123 "Pipe handler or fully qualified core dump path required.\n"
1124 "Set kernel.core_pattern before fs.suid_dumpable.\n"
1125 		);
1126 	}
1127 #endif
1128 }
1129 
1130 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
1131 		void *buffer, size_t *lenp, loff_t *ppos)
1132 {
1133 	int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1134 	if (!error)
1135 		validate_coredump_safety();
1136 	return error;
1137 }
1138 
1139 #ifdef CONFIG_COREDUMP
1140 static int proc_dostring_coredump(struct ctl_table *table, int write,
1141 		  void *buffer, size_t *lenp, loff_t *ppos)
1142 {
1143 	int error = proc_dostring(table, write, buffer, lenp, ppos);
1144 	if (!error)
1145 		validate_coredump_safety();
1146 	return error;
1147 }
1148 #endif
1149 
1150 #ifdef CONFIG_MAGIC_SYSRQ
1151 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
1152 				void *buffer, size_t *lenp, loff_t *ppos)
1153 {
1154 	int tmp, ret;
1155 
1156 	tmp = sysrq_mask();
1157 
1158 	ret = __do_proc_dointvec(&tmp, table, write, buffer,
1159 			       lenp, ppos, NULL, NULL);
1160 	if (ret || !write)
1161 		return ret;
1162 
1163 	if (write)
1164 		sysrq_toggle_support(tmp);
1165 
1166 	return 0;
1167 }
1168 #endif
1169 
1170 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
1171 		int write, void *buffer, size_t *lenp, loff_t *ppos,
1172 		unsigned long convmul, unsigned long convdiv)
1173 {
1174 	unsigned long *i, *min, *max;
1175 	int vleft, first = 1, err = 0;
1176 	size_t left;
1177 	char *p;
1178 
1179 	if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1180 		*lenp = 0;
1181 		return 0;
1182 	}
1183 
1184 	i = (unsigned long *) data;
1185 	min = (unsigned long *) table->extra1;
1186 	max = (unsigned long *) table->extra2;
1187 	vleft = table->maxlen / sizeof(unsigned long);
1188 	left = *lenp;
1189 
1190 	if (write) {
1191 		if (proc_first_pos_non_zero_ignore(ppos, table))
1192 			goto out;
1193 
1194 		if (left > PAGE_SIZE - 1)
1195 			left = PAGE_SIZE - 1;
1196 		p = buffer;
1197 	}
1198 
1199 	for (; left && vleft--; i++, first = 0) {
1200 		unsigned long val;
1201 
1202 		if (write) {
1203 			bool neg;
1204 
1205 			left -= proc_skip_spaces(&p);
1206 			if (!left)
1207 				break;
1208 
1209 			err = proc_get_long(&p, &left, &val, &neg,
1210 					     proc_wspace_sep,
1211 					     sizeof(proc_wspace_sep), NULL);
1212 			if (err)
1213 				break;
1214 			if (neg)
1215 				continue;
1216 			val = convmul * val / convdiv;
1217 			if ((min && val < *min) || (max && val > *max)) {
1218 				err = -EINVAL;
1219 				break;
1220 			}
1221 			*i = val;
1222 		} else {
1223 			val = convdiv * (*i) / convmul;
1224 			if (!first)
1225 				proc_put_char(&buffer, &left, '\t');
1226 			proc_put_long(&buffer, &left, val, false);
1227 		}
1228 	}
1229 
1230 	if (!write && !first && left && !err)
1231 		proc_put_char(&buffer, &left, '\n');
1232 	if (write && !err)
1233 		left -= proc_skip_spaces(&p);
1234 	if (write && first)
1235 		return err ? : -EINVAL;
1236 	*lenp -= left;
1237 out:
1238 	*ppos += *lenp;
1239 	return err;
1240 }
1241 
1242 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
1243 		void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1244 		unsigned long convdiv)
1245 {
1246 	return __do_proc_doulongvec_minmax(table->data, table, write,
1247 			buffer, lenp, ppos, convmul, convdiv);
1248 }
1249 
1250 /**
1251  * proc_doulongvec_minmax - read a vector of long integers with min/max values
1252  * @table: the sysctl table
1253  * @write: %TRUE if this is a write to the sysctl file
1254  * @buffer: the user buffer
1255  * @lenp: the size of the user buffer
1256  * @ppos: file position
1257  *
1258  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1259  * values from/to the user buffer, treated as an ASCII string.
1260  *
1261  * This routine will ensure the values are within the range specified by
1262  * table->extra1 (min) and table->extra2 (max).
1263  *
1264  * Returns 0 on success.
1265  */
1266 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1267 			   void *buffer, size_t *lenp, loff_t *ppos)
1268 {
1269     return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1270 }
1271 
1272 /**
1273  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1274  * @table: the sysctl table
1275  * @write: %TRUE if this is a write to the sysctl file
1276  * @buffer: the user buffer
1277  * @lenp: the size of the user buffer
1278  * @ppos: file position
1279  *
1280  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1281  * values from/to the user buffer, treated as an ASCII string. The values
1282  * are treated as milliseconds, and converted to jiffies when they are stored.
1283  *
1284  * This routine will ensure the values are within the range specified by
1285  * table->extra1 (min) and table->extra2 (max).
1286  *
1287  * Returns 0 on success.
1288  */
1289 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1290 				      void *buffer, size_t *lenp, loff_t *ppos)
1291 {
1292     return do_proc_doulongvec_minmax(table, write, buffer,
1293 				     lenp, ppos, HZ, 1000l);
1294 }
1295 
1296 
1297 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1298 					 int *valp,
1299 					 int write, void *data)
1300 {
1301 	if (write) {
1302 		if (*lvalp > INT_MAX / HZ)
1303 			return 1;
1304 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1305 	} else {
1306 		int val = *valp;
1307 		unsigned long lval;
1308 		if (val < 0) {
1309 			*negp = true;
1310 			lval = -(unsigned long)val;
1311 		} else {
1312 			*negp = false;
1313 			lval = (unsigned long)val;
1314 		}
1315 		*lvalp = lval / HZ;
1316 	}
1317 	return 0;
1318 }
1319 
1320 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1321 						int *valp,
1322 						int write, void *data)
1323 {
1324 	if (write) {
1325 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1326 			return 1;
1327 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1328 	} else {
1329 		int val = *valp;
1330 		unsigned long lval;
1331 		if (val < 0) {
1332 			*negp = true;
1333 			lval = -(unsigned long)val;
1334 		} else {
1335 			*negp = false;
1336 			lval = (unsigned long)val;
1337 		}
1338 		*lvalp = jiffies_to_clock_t(lval);
1339 	}
1340 	return 0;
1341 }
1342 
1343 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1344 					    int *valp,
1345 					    int write, void *data)
1346 {
1347 	if (write) {
1348 		unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1349 
1350 		if (jif > INT_MAX)
1351 			return 1;
1352 		*valp = (int)jif;
1353 	} else {
1354 		int val = *valp;
1355 		unsigned long lval;
1356 		if (val < 0) {
1357 			*negp = true;
1358 			lval = -(unsigned long)val;
1359 		} else {
1360 			*negp = false;
1361 			lval = (unsigned long)val;
1362 		}
1363 		*lvalp = jiffies_to_msecs(lval);
1364 	}
1365 	return 0;
1366 }
1367 
1368 /**
1369  * proc_dointvec_jiffies - read a vector of integers as seconds
1370  * @table: the sysctl table
1371  * @write: %TRUE if this is a write to the sysctl file
1372  * @buffer: the user buffer
1373  * @lenp: the size of the user buffer
1374  * @ppos: file position
1375  *
1376  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1377  * values from/to the user buffer, treated as an ASCII string.
1378  * The values read are assumed to be in seconds, and are converted into
1379  * jiffies.
1380  *
1381  * Returns 0 on success.
1382  */
1383 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1384 			  void *buffer, size_t *lenp, loff_t *ppos)
1385 {
1386     return do_proc_dointvec(table,write,buffer,lenp,ppos,
1387 		    	    do_proc_dointvec_jiffies_conv,NULL);
1388 }
1389 
1390 /**
1391  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1392  * @table: the sysctl table
1393  * @write: %TRUE if this is a write to the sysctl file
1394  * @buffer: the user buffer
1395  * @lenp: the size of the user buffer
1396  * @ppos: pointer to the file position
1397  *
1398  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1399  * values from/to the user buffer, treated as an ASCII string.
1400  * The values read are assumed to be in 1/USER_HZ seconds, and
1401  * are converted into jiffies.
1402  *
1403  * Returns 0 on success.
1404  */
1405 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1406 				 void *buffer, size_t *lenp, loff_t *ppos)
1407 {
1408     return do_proc_dointvec(table,write,buffer,lenp,ppos,
1409 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
1410 }
1411 
1412 /**
1413  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1414  * @table: the sysctl table
1415  * @write: %TRUE if this is a write to the sysctl file
1416  * @buffer: the user buffer
1417  * @lenp: the size of the user buffer
1418  * @ppos: file position
1419  * @ppos: the current position in the file
1420  *
1421  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1422  * values from/to the user buffer, treated as an ASCII string.
1423  * The values read are assumed to be in 1/1000 seconds, and
1424  * are converted into jiffies.
1425  *
1426  * Returns 0 on success.
1427  */
1428 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
1429 		size_t *lenp, loff_t *ppos)
1430 {
1431 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
1432 				do_proc_dointvec_ms_jiffies_conv, NULL);
1433 }
1434 
1435 static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
1436 		size_t *lenp, loff_t *ppos)
1437 {
1438 	struct pid *new_pid;
1439 	pid_t tmp;
1440 	int r;
1441 
1442 	tmp = pid_vnr(cad_pid);
1443 
1444 	r = __do_proc_dointvec(&tmp, table, write, buffer,
1445 			       lenp, ppos, NULL, NULL);
1446 	if (r || !write)
1447 		return r;
1448 
1449 	new_pid = find_get_pid(tmp);
1450 	if (!new_pid)
1451 		return -ESRCH;
1452 
1453 	put_pid(xchg(&cad_pid, new_pid));
1454 	return 0;
1455 }
1456 
1457 /**
1458  * proc_do_large_bitmap - read/write from/to a large bitmap
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: file position
1464  *
1465  * The bitmap is stored at table->data and the bitmap length (in bits)
1466  * in table->maxlen.
1467  *
1468  * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1469  * large bitmaps may be represented in a compact manner. Writing into
1470  * the file will clear the bitmap then update it with the given input.
1471  *
1472  * Returns 0 on success.
1473  */
1474 int proc_do_large_bitmap(struct ctl_table *table, int write,
1475 			 void *buffer, size_t *lenp, loff_t *ppos)
1476 {
1477 	int err = 0;
1478 	bool first = 1;
1479 	size_t left = *lenp;
1480 	unsigned long bitmap_len = table->maxlen;
1481 	unsigned long *bitmap = *(unsigned long **) table->data;
1482 	unsigned long *tmp_bitmap = NULL;
1483 	char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1484 
1485 	if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1486 		*lenp = 0;
1487 		return 0;
1488 	}
1489 
1490 	if (write) {
1491 		char *p = buffer;
1492 		size_t skipped = 0;
1493 
1494 		if (left > PAGE_SIZE - 1) {
1495 			left = PAGE_SIZE - 1;
1496 			/* How much of the buffer we'll skip this pass */
1497 			skipped = *lenp - left;
1498 		}
1499 
1500 		tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
1501 		if (!tmp_bitmap)
1502 			return -ENOMEM;
1503 		proc_skip_char(&p, &left, '\n');
1504 		while (!err && left) {
1505 			unsigned long val_a, val_b;
1506 			bool neg;
1507 			size_t saved_left;
1508 
1509 			/* In case we stop parsing mid-number, we can reset */
1510 			saved_left = left;
1511 			err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1512 					     sizeof(tr_a), &c);
1513 			/*
1514 			 * If we consumed the entirety of a truncated buffer or
1515 			 * only one char is left (may be a "-"), then stop here,
1516 			 * reset, & come back for more.
1517 			 */
1518 			if ((left <= 1) && skipped) {
1519 				left = saved_left;
1520 				break;
1521 			}
1522 
1523 			if (err)
1524 				break;
1525 			if (val_a >= bitmap_len || neg) {
1526 				err = -EINVAL;
1527 				break;
1528 			}
1529 
1530 			val_b = val_a;
1531 			if (left) {
1532 				p++;
1533 				left--;
1534 			}
1535 
1536 			if (c == '-') {
1537 				err = proc_get_long(&p, &left, &val_b,
1538 						     &neg, tr_b, sizeof(tr_b),
1539 						     &c);
1540 				/*
1541 				 * If we consumed all of a truncated buffer or
1542 				 * then stop here, reset, & come back for more.
1543 				 */
1544 				if (!left && skipped) {
1545 					left = saved_left;
1546 					break;
1547 				}
1548 
1549 				if (err)
1550 					break;
1551 				if (val_b >= bitmap_len || neg ||
1552 				    val_a > val_b) {
1553 					err = -EINVAL;
1554 					break;
1555 				}
1556 				if (left) {
1557 					p++;
1558 					left--;
1559 				}
1560 			}
1561 
1562 			bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1563 			first = 0;
1564 			proc_skip_char(&p, &left, '\n');
1565 		}
1566 		left += skipped;
1567 	} else {
1568 		unsigned long bit_a, bit_b = 0;
1569 
1570 		while (left) {
1571 			bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1572 			if (bit_a >= bitmap_len)
1573 				break;
1574 			bit_b = find_next_zero_bit(bitmap, bitmap_len,
1575 						   bit_a + 1) - 1;
1576 
1577 			if (!first)
1578 				proc_put_char(&buffer, &left, ',');
1579 			proc_put_long(&buffer, &left, bit_a, false);
1580 			if (bit_a != bit_b) {
1581 				proc_put_char(&buffer, &left, '-');
1582 				proc_put_long(&buffer, &left, bit_b, false);
1583 			}
1584 
1585 			first = 0; bit_b++;
1586 		}
1587 		proc_put_char(&buffer, &left, '\n');
1588 	}
1589 
1590 	if (!err) {
1591 		if (write) {
1592 			if (*ppos)
1593 				bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1594 			else
1595 				bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1596 		}
1597 		*lenp -= left;
1598 		*ppos += *lenp;
1599 	}
1600 
1601 	bitmap_free(tmp_bitmap);
1602 	return err;
1603 }
1604 
1605 #else /* CONFIG_PROC_SYSCTL */
1606 
1607 int proc_dostring(struct ctl_table *table, int write,
1608 		  void *buffer, size_t *lenp, loff_t *ppos)
1609 {
1610 	return -ENOSYS;
1611 }
1612 
1613 int proc_dointvec(struct ctl_table *table, int write,
1614 		  void *buffer, size_t *lenp, loff_t *ppos)
1615 {
1616 	return -ENOSYS;
1617 }
1618 
1619 int proc_douintvec(struct ctl_table *table, int write,
1620 		  void *buffer, size_t *lenp, loff_t *ppos)
1621 {
1622 	return -ENOSYS;
1623 }
1624 
1625 int proc_dointvec_minmax(struct ctl_table *table, int write,
1626 		    void *buffer, size_t *lenp, loff_t *ppos)
1627 {
1628 	return -ENOSYS;
1629 }
1630 
1631 int proc_douintvec_minmax(struct ctl_table *table, int write,
1632 			  void *buffer, size_t *lenp, loff_t *ppos)
1633 {
1634 	return -ENOSYS;
1635 }
1636 
1637 int proc_dou8vec_minmax(struct ctl_table *table, int write,
1638 			void *buffer, size_t *lenp, loff_t *ppos)
1639 {
1640 	return -ENOSYS;
1641 }
1642 
1643 int proc_dointvec_jiffies(struct ctl_table *table, int write,
1644 		    void *buffer, size_t *lenp, loff_t *ppos)
1645 {
1646 	return -ENOSYS;
1647 }
1648 
1649 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
1650 		    void *buffer, size_t *lenp, loff_t *ppos)
1651 {
1652 	return -ENOSYS;
1653 }
1654 
1655 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
1656 			     void *buffer, size_t *lenp, loff_t *ppos)
1657 {
1658 	return -ENOSYS;
1659 }
1660 
1661 int proc_doulongvec_minmax(struct ctl_table *table, int write,
1662 		    void *buffer, size_t *lenp, loff_t *ppos)
1663 {
1664 	return -ENOSYS;
1665 }
1666 
1667 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
1668 				      void *buffer, size_t *lenp, loff_t *ppos)
1669 {
1670 	return -ENOSYS;
1671 }
1672 
1673 int proc_do_large_bitmap(struct ctl_table *table, int write,
1674 			 void *buffer, size_t *lenp, loff_t *ppos)
1675 {
1676 	return -ENOSYS;
1677 }
1678 
1679 #endif /* CONFIG_PROC_SYSCTL */
1680 
1681 #if defined(CONFIG_SYSCTL)
1682 int proc_do_static_key(struct ctl_table *table, int write,
1683 		       void *buffer, size_t *lenp, loff_t *ppos)
1684 {
1685 	struct static_key *key = (struct static_key *)table->data;
1686 	static DEFINE_MUTEX(static_key_mutex);
1687 	int val, ret;
1688 	struct ctl_table tmp = {
1689 		.data   = &val,
1690 		.maxlen = sizeof(val),
1691 		.mode   = table->mode,
1692 		.extra1 = SYSCTL_ZERO,
1693 		.extra2 = SYSCTL_ONE,
1694 	};
1695 
1696 	if (write && !capable(CAP_SYS_ADMIN))
1697 		return -EPERM;
1698 
1699 	mutex_lock(&static_key_mutex);
1700 	val = static_key_enabled(key);
1701 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1702 	if (write && !ret) {
1703 		if (val)
1704 			static_key_enable(key);
1705 		else
1706 			static_key_disable(key);
1707 	}
1708 	mutex_unlock(&static_key_mutex);
1709 	return ret;
1710 }
1711 
1712 static struct ctl_table kern_table[] = {
1713 	{
1714 		.procname	= "sched_child_runs_first",
1715 		.data		= &sysctl_sched_child_runs_first,
1716 		.maxlen		= sizeof(unsigned int),
1717 		.mode		= 0644,
1718 		.proc_handler	= proc_dointvec,
1719 	},
1720 #ifdef CONFIG_SCHEDSTATS
1721 	{
1722 		.procname	= "sched_schedstats",
1723 		.data		= NULL,
1724 		.maxlen		= sizeof(unsigned int),
1725 		.mode		= 0644,
1726 		.proc_handler	= sysctl_schedstats,
1727 		.extra1		= SYSCTL_ZERO,
1728 		.extra2		= SYSCTL_ONE,
1729 	},
1730 #endif /* CONFIG_SCHEDSTATS */
1731 #ifdef CONFIG_TASK_DELAY_ACCT
1732 	{
1733 		.procname	= "task_delayacct",
1734 		.data		= NULL,
1735 		.maxlen		= sizeof(unsigned int),
1736 		.mode		= 0644,
1737 		.proc_handler	= sysctl_delayacct,
1738 		.extra1		= SYSCTL_ZERO,
1739 		.extra2		= SYSCTL_ONE,
1740 	},
1741 #endif /* CONFIG_TASK_DELAY_ACCT */
1742 #ifdef CONFIG_NUMA_BALANCING
1743 	{
1744 		.procname	= "numa_balancing",
1745 		.data		= NULL, /* filled in by handler */
1746 		.maxlen		= sizeof(unsigned int),
1747 		.mode		= 0644,
1748 		.proc_handler	= sysctl_numa_balancing,
1749 		.extra1		= SYSCTL_ZERO,
1750 		.extra2		= SYSCTL_ONE,
1751 	},
1752 #endif /* CONFIG_NUMA_BALANCING */
1753 	{
1754 		.procname	= "sched_rt_period_us",
1755 		.data		= &sysctl_sched_rt_period,
1756 		.maxlen		= sizeof(unsigned int),
1757 		.mode		= 0644,
1758 		.proc_handler	= sched_rt_handler,
1759 	},
1760 	{
1761 		.procname	= "sched_rt_runtime_us",
1762 		.data		= &sysctl_sched_rt_runtime,
1763 		.maxlen		= sizeof(int),
1764 		.mode		= 0644,
1765 		.proc_handler	= sched_rt_handler,
1766 	},
1767 	{
1768 		.procname	= "sched_deadline_period_max_us",
1769 		.data		= &sysctl_sched_dl_period_max,
1770 		.maxlen		= sizeof(unsigned int),
1771 		.mode		= 0644,
1772 		.proc_handler	= proc_dointvec,
1773 	},
1774 	{
1775 		.procname	= "sched_deadline_period_min_us",
1776 		.data		= &sysctl_sched_dl_period_min,
1777 		.maxlen		= sizeof(unsigned int),
1778 		.mode		= 0644,
1779 		.proc_handler	= proc_dointvec,
1780 	},
1781 	{
1782 		.procname	= "sched_rr_timeslice_ms",
1783 		.data		= &sysctl_sched_rr_timeslice,
1784 		.maxlen		= sizeof(int),
1785 		.mode		= 0644,
1786 		.proc_handler	= sched_rr_handler,
1787 	},
1788 #ifdef CONFIG_UCLAMP_TASK
1789 	{
1790 		.procname	= "sched_util_clamp_min",
1791 		.data		= &sysctl_sched_uclamp_util_min,
1792 		.maxlen		= sizeof(unsigned int),
1793 		.mode		= 0644,
1794 		.proc_handler	= sysctl_sched_uclamp_handler,
1795 	},
1796 	{
1797 		.procname	= "sched_util_clamp_max",
1798 		.data		= &sysctl_sched_uclamp_util_max,
1799 		.maxlen		= sizeof(unsigned int),
1800 		.mode		= 0644,
1801 		.proc_handler	= sysctl_sched_uclamp_handler,
1802 	},
1803 	{
1804 		.procname	= "sched_util_clamp_min_rt_default",
1805 		.data		= &sysctl_sched_uclamp_util_min_rt_default,
1806 		.maxlen		= sizeof(unsigned int),
1807 		.mode		= 0644,
1808 		.proc_handler	= sysctl_sched_uclamp_handler,
1809 	},
1810 #endif
1811 #ifdef CONFIG_SCHED_AUTOGROUP
1812 	{
1813 		.procname	= "sched_autogroup_enabled",
1814 		.data		= &sysctl_sched_autogroup_enabled,
1815 		.maxlen		= sizeof(unsigned int),
1816 		.mode		= 0644,
1817 		.proc_handler	= proc_dointvec_minmax,
1818 		.extra1		= SYSCTL_ZERO,
1819 		.extra2		= SYSCTL_ONE,
1820 	},
1821 #endif
1822 #ifdef CONFIG_CFS_BANDWIDTH
1823 	{
1824 		.procname	= "sched_cfs_bandwidth_slice_us",
1825 		.data		= &sysctl_sched_cfs_bandwidth_slice,
1826 		.maxlen		= sizeof(unsigned int),
1827 		.mode		= 0644,
1828 		.proc_handler	= proc_dointvec_minmax,
1829 		.extra1		= SYSCTL_ONE,
1830 	},
1831 #endif
1832 #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
1833 	{
1834 		.procname	= "sched_energy_aware",
1835 		.data		= &sysctl_sched_energy_aware,
1836 		.maxlen		= sizeof(unsigned int),
1837 		.mode		= 0644,
1838 		.proc_handler	= sched_energy_aware_handler,
1839 		.extra1		= SYSCTL_ZERO,
1840 		.extra2		= SYSCTL_ONE,
1841 	},
1842 #endif
1843 #ifdef CONFIG_PROVE_LOCKING
1844 	{
1845 		.procname	= "prove_locking",
1846 		.data		= &prove_locking,
1847 		.maxlen		= sizeof(int),
1848 		.mode		= 0644,
1849 		.proc_handler	= proc_dointvec,
1850 	},
1851 #endif
1852 #ifdef CONFIG_LOCK_STAT
1853 	{
1854 		.procname	= "lock_stat",
1855 		.data		= &lock_stat,
1856 		.maxlen		= sizeof(int),
1857 		.mode		= 0644,
1858 		.proc_handler	= proc_dointvec,
1859 	},
1860 #endif
1861 	{
1862 		.procname	= "panic",
1863 		.data		= &panic_timeout,
1864 		.maxlen		= sizeof(int),
1865 		.mode		= 0644,
1866 		.proc_handler	= proc_dointvec,
1867 	},
1868 #ifdef CONFIG_COREDUMP
1869 	{
1870 		.procname	= "core_uses_pid",
1871 		.data		= &core_uses_pid,
1872 		.maxlen		= sizeof(int),
1873 		.mode		= 0644,
1874 		.proc_handler	= proc_dointvec,
1875 	},
1876 	{
1877 		.procname	= "core_pattern",
1878 		.data		= core_pattern,
1879 		.maxlen		= CORENAME_MAX_SIZE,
1880 		.mode		= 0644,
1881 		.proc_handler	= proc_dostring_coredump,
1882 	},
1883 	{
1884 		.procname	= "core_pipe_limit",
1885 		.data		= &core_pipe_limit,
1886 		.maxlen		= sizeof(unsigned int),
1887 		.mode		= 0644,
1888 		.proc_handler	= proc_dointvec,
1889 	},
1890 #endif
1891 #ifdef CONFIG_PROC_SYSCTL
1892 	{
1893 		.procname	= "tainted",
1894 		.maxlen 	= sizeof(long),
1895 		.mode		= 0644,
1896 		.proc_handler	= proc_taint,
1897 	},
1898 	{
1899 		.procname	= "sysctl_writes_strict",
1900 		.data		= &sysctl_writes_strict,
1901 		.maxlen		= sizeof(int),
1902 		.mode		= 0644,
1903 		.proc_handler	= proc_dointvec_minmax,
1904 		.extra1		= &neg_one,
1905 		.extra2		= SYSCTL_ONE,
1906 	},
1907 #endif
1908 #ifdef CONFIG_LATENCYTOP
1909 	{
1910 		.procname	= "latencytop",
1911 		.data		= &latencytop_enabled,
1912 		.maxlen		= sizeof(int),
1913 		.mode		= 0644,
1914 		.proc_handler	= sysctl_latencytop,
1915 	},
1916 #endif
1917 #ifdef CONFIG_BLK_DEV_INITRD
1918 	{
1919 		.procname	= "real-root-dev",
1920 		.data		= &real_root_dev,
1921 		.maxlen		= sizeof(int),
1922 		.mode		= 0644,
1923 		.proc_handler	= proc_dointvec,
1924 	},
1925 #endif
1926 	{
1927 		.procname	= "print-fatal-signals",
1928 		.data		= &print_fatal_signals,
1929 		.maxlen		= sizeof(int),
1930 		.mode		= 0644,
1931 		.proc_handler	= proc_dointvec,
1932 	},
1933 #ifdef CONFIG_SPARC
1934 	{
1935 		.procname	= "reboot-cmd",
1936 		.data		= reboot_command,
1937 		.maxlen		= 256,
1938 		.mode		= 0644,
1939 		.proc_handler	= proc_dostring,
1940 	},
1941 	{
1942 		.procname	= "stop-a",
1943 		.data		= &stop_a_enabled,
1944 		.maxlen		= sizeof (int),
1945 		.mode		= 0644,
1946 		.proc_handler	= proc_dointvec,
1947 	},
1948 	{
1949 		.procname	= "scons-poweroff",
1950 		.data		= &scons_pwroff,
1951 		.maxlen		= sizeof (int),
1952 		.mode		= 0644,
1953 		.proc_handler	= proc_dointvec,
1954 	},
1955 #endif
1956 #ifdef CONFIG_SPARC64
1957 	{
1958 		.procname	= "tsb-ratio",
1959 		.data		= &sysctl_tsb_ratio,
1960 		.maxlen		= sizeof (int),
1961 		.mode		= 0644,
1962 		.proc_handler	= proc_dointvec,
1963 	},
1964 #endif
1965 #ifdef CONFIG_PARISC
1966 	{
1967 		.procname	= "soft-power",
1968 		.data		= &pwrsw_enabled,
1969 		.maxlen		= sizeof (int),
1970 		.mode		= 0644,
1971 		.proc_handler	= proc_dointvec,
1972 	},
1973 #endif
1974 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
1975 	{
1976 		.procname	= "unaligned-trap",
1977 		.data		= &unaligned_enabled,
1978 		.maxlen		= sizeof (int),
1979 		.mode		= 0644,
1980 		.proc_handler	= proc_dointvec,
1981 	},
1982 #endif
1983 	{
1984 		.procname	= "ctrl-alt-del",
1985 		.data		= &C_A_D,
1986 		.maxlen		= sizeof(int),
1987 		.mode		= 0644,
1988 		.proc_handler	= proc_dointvec,
1989 	},
1990 #ifdef CONFIG_FUNCTION_TRACER
1991 	{
1992 		.procname	= "ftrace_enabled",
1993 		.data		= &ftrace_enabled,
1994 		.maxlen		= sizeof(int),
1995 		.mode		= 0644,
1996 		.proc_handler	= ftrace_enable_sysctl,
1997 	},
1998 #endif
1999 #ifdef CONFIG_STACK_TRACER
2000 	{
2001 		.procname	= "stack_tracer_enabled",
2002 		.data		= &stack_tracer_enabled,
2003 		.maxlen		= sizeof(int),
2004 		.mode		= 0644,
2005 		.proc_handler	= stack_trace_sysctl,
2006 	},
2007 #endif
2008 #ifdef CONFIG_TRACING
2009 	{
2010 		.procname	= "ftrace_dump_on_oops",
2011 		.data		= &ftrace_dump_on_oops,
2012 		.maxlen		= sizeof(int),
2013 		.mode		= 0644,
2014 		.proc_handler	= proc_dointvec,
2015 	},
2016 	{
2017 		.procname	= "traceoff_on_warning",
2018 		.data		= &__disable_trace_on_warning,
2019 		.maxlen		= sizeof(__disable_trace_on_warning),
2020 		.mode		= 0644,
2021 		.proc_handler	= proc_dointvec,
2022 	},
2023 	{
2024 		.procname	= "tracepoint_printk",
2025 		.data		= &tracepoint_printk,
2026 		.maxlen		= sizeof(tracepoint_printk),
2027 		.mode		= 0644,
2028 		.proc_handler	= tracepoint_printk_sysctl,
2029 	},
2030 #endif
2031 #ifdef CONFIG_KEXEC_CORE
2032 	{
2033 		.procname	= "kexec_load_disabled",
2034 		.data		= &kexec_load_disabled,
2035 		.maxlen		= sizeof(int),
2036 		.mode		= 0644,
2037 		/* only handle a transition from default "0" to "1" */
2038 		.proc_handler	= proc_dointvec_minmax,
2039 		.extra1		= SYSCTL_ONE,
2040 		.extra2		= SYSCTL_ONE,
2041 	},
2042 #endif
2043 #ifdef CONFIG_MODULES
2044 	{
2045 		.procname	= "modprobe",
2046 		.data		= &modprobe_path,
2047 		.maxlen		= KMOD_PATH_LEN,
2048 		.mode		= 0644,
2049 		.proc_handler	= proc_dostring,
2050 	},
2051 	{
2052 		.procname	= "modules_disabled",
2053 		.data		= &modules_disabled,
2054 		.maxlen		= sizeof(int),
2055 		.mode		= 0644,
2056 		/* only handle a transition from default "0" to "1" */
2057 		.proc_handler	= proc_dointvec_minmax,
2058 		.extra1		= SYSCTL_ONE,
2059 		.extra2		= SYSCTL_ONE,
2060 	},
2061 #endif
2062 #ifdef CONFIG_UEVENT_HELPER
2063 	{
2064 		.procname	= "hotplug",
2065 		.data		= &uevent_helper,
2066 		.maxlen		= UEVENT_HELPER_PATH_LEN,
2067 		.mode		= 0644,
2068 		.proc_handler	= proc_dostring,
2069 	},
2070 #endif
2071 #ifdef CONFIG_CHR_DEV_SG
2072 	{
2073 		.procname	= "sg-big-buff",
2074 		.data		= &sg_big_buff,
2075 		.maxlen		= sizeof (int),
2076 		.mode		= 0444,
2077 		.proc_handler	= proc_dointvec,
2078 	},
2079 #endif
2080 #ifdef CONFIG_BSD_PROCESS_ACCT
2081 	{
2082 		.procname	= "acct",
2083 		.data		= &acct_parm,
2084 		.maxlen		= 3*sizeof(int),
2085 		.mode		= 0644,
2086 		.proc_handler	= proc_dointvec,
2087 	},
2088 #endif
2089 #ifdef CONFIG_MAGIC_SYSRQ
2090 	{
2091 		.procname	= "sysrq",
2092 		.data		= NULL,
2093 		.maxlen		= sizeof (int),
2094 		.mode		= 0644,
2095 		.proc_handler	= sysrq_sysctl_handler,
2096 	},
2097 #endif
2098 #ifdef CONFIG_PROC_SYSCTL
2099 	{
2100 		.procname	= "cad_pid",
2101 		.data		= NULL,
2102 		.maxlen		= sizeof (int),
2103 		.mode		= 0600,
2104 		.proc_handler	= proc_do_cad_pid,
2105 	},
2106 #endif
2107 	{
2108 		.procname	= "threads-max",
2109 		.data		= NULL,
2110 		.maxlen		= sizeof(int),
2111 		.mode		= 0644,
2112 		.proc_handler	= sysctl_max_threads,
2113 	},
2114 	{
2115 		.procname	= "random",
2116 		.mode		= 0555,
2117 		.child		= random_table,
2118 	},
2119 	{
2120 		.procname	= "usermodehelper",
2121 		.mode		= 0555,
2122 		.child		= usermodehelper_table,
2123 	},
2124 #ifdef CONFIG_FW_LOADER_USER_HELPER
2125 	{
2126 		.procname	= "firmware_config",
2127 		.mode		= 0555,
2128 		.child		= firmware_config_table,
2129 	},
2130 #endif
2131 	{
2132 		.procname	= "overflowuid",
2133 		.data		= &overflowuid,
2134 		.maxlen		= sizeof(int),
2135 		.mode		= 0644,
2136 		.proc_handler	= proc_dointvec_minmax,
2137 		.extra1		= &minolduid,
2138 		.extra2		= &maxolduid,
2139 	},
2140 	{
2141 		.procname	= "overflowgid",
2142 		.data		= &overflowgid,
2143 		.maxlen		= sizeof(int),
2144 		.mode		= 0644,
2145 		.proc_handler	= proc_dointvec_minmax,
2146 		.extra1		= &minolduid,
2147 		.extra2		= &maxolduid,
2148 	},
2149 #ifdef CONFIG_S390
2150 	{
2151 		.procname	= "userprocess_debug",
2152 		.data		= &show_unhandled_signals,
2153 		.maxlen		= sizeof(int),
2154 		.mode		= 0644,
2155 		.proc_handler	= proc_dointvec,
2156 	},
2157 #endif
2158 #ifdef CONFIG_SMP
2159 	{
2160 		.procname	= "oops_all_cpu_backtrace",
2161 		.data		= &sysctl_oops_all_cpu_backtrace,
2162 		.maxlen		= sizeof(int),
2163 		.mode		= 0644,
2164 		.proc_handler	= proc_dointvec_minmax,
2165 		.extra1		= SYSCTL_ZERO,
2166 		.extra2		= SYSCTL_ONE,
2167 	},
2168 #endif /* CONFIG_SMP */
2169 	{
2170 		.procname	= "pid_max",
2171 		.data		= &pid_max,
2172 		.maxlen		= sizeof (int),
2173 		.mode		= 0644,
2174 		.proc_handler	= proc_dointvec_minmax,
2175 		.extra1		= &pid_max_min,
2176 		.extra2		= &pid_max_max,
2177 	},
2178 	{
2179 		.procname	= "panic_on_oops",
2180 		.data		= &panic_on_oops,
2181 		.maxlen		= sizeof(int),
2182 		.mode		= 0644,
2183 		.proc_handler	= proc_dointvec,
2184 	},
2185 	{
2186 		.procname	= "panic_print",
2187 		.data		= &panic_print,
2188 		.maxlen		= sizeof(unsigned long),
2189 		.mode		= 0644,
2190 		.proc_handler	= proc_doulongvec_minmax,
2191 	},
2192 #if defined CONFIG_PRINTK
2193 	{
2194 		.procname	= "printk",
2195 		.data		= &console_loglevel,
2196 		.maxlen		= 4*sizeof(int),
2197 		.mode		= 0644,
2198 		.proc_handler	= proc_dointvec,
2199 	},
2200 	{
2201 		.procname	= "printk_ratelimit",
2202 		.data		= &printk_ratelimit_state.interval,
2203 		.maxlen		= sizeof(int),
2204 		.mode		= 0644,
2205 		.proc_handler	= proc_dointvec_jiffies,
2206 	},
2207 	{
2208 		.procname	= "printk_ratelimit_burst",
2209 		.data		= &printk_ratelimit_state.burst,
2210 		.maxlen		= sizeof(int),
2211 		.mode		= 0644,
2212 		.proc_handler	= proc_dointvec,
2213 	},
2214 	{
2215 		.procname	= "printk_delay",
2216 		.data		= &printk_delay_msec,
2217 		.maxlen		= sizeof(int),
2218 		.mode		= 0644,
2219 		.proc_handler	= proc_dointvec_minmax,
2220 		.extra1		= SYSCTL_ZERO,
2221 		.extra2		= &ten_thousand,
2222 	},
2223 	{
2224 		.procname	= "printk_devkmsg",
2225 		.data		= devkmsg_log_str,
2226 		.maxlen		= DEVKMSG_STR_MAX_SIZE,
2227 		.mode		= 0644,
2228 		.proc_handler	= devkmsg_sysctl_set_loglvl,
2229 	},
2230 	{
2231 		.procname	= "dmesg_restrict",
2232 		.data		= &dmesg_restrict,
2233 		.maxlen		= sizeof(int),
2234 		.mode		= 0644,
2235 		.proc_handler	= proc_dointvec_minmax_sysadmin,
2236 		.extra1		= SYSCTL_ZERO,
2237 		.extra2		= SYSCTL_ONE,
2238 	},
2239 	{
2240 		.procname	= "kptr_restrict",
2241 		.data		= &kptr_restrict,
2242 		.maxlen		= sizeof(int),
2243 		.mode		= 0644,
2244 		.proc_handler	= proc_dointvec_minmax_sysadmin,
2245 		.extra1		= SYSCTL_ZERO,
2246 		.extra2		= &two,
2247 	},
2248 #endif
2249 	{
2250 		.procname	= "ngroups_max",
2251 		.data		= &ngroups_max,
2252 		.maxlen		= sizeof (int),
2253 		.mode		= 0444,
2254 		.proc_handler	= proc_dointvec,
2255 	},
2256 	{
2257 		.procname	= "cap_last_cap",
2258 		.data		= (void *)&cap_last_cap,
2259 		.maxlen		= sizeof(int),
2260 		.mode		= 0444,
2261 		.proc_handler	= proc_dointvec,
2262 	},
2263 #if defined(CONFIG_LOCKUP_DETECTOR)
2264 	{
2265 		.procname       = "watchdog",
2266 		.data		= &watchdog_user_enabled,
2267 		.maxlen		= sizeof(int),
2268 		.mode		= 0644,
2269 		.proc_handler   = proc_watchdog,
2270 		.extra1		= SYSCTL_ZERO,
2271 		.extra2		= SYSCTL_ONE,
2272 	},
2273 	{
2274 		.procname	= "watchdog_thresh",
2275 		.data		= &watchdog_thresh,
2276 		.maxlen		= sizeof(int),
2277 		.mode		= 0644,
2278 		.proc_handler	= proc_watchdog_thresh,
2279 		.extra1		= SYSCTL_ZERO,
2280 		.extra2		= &sixty,
2281 	},
2282 	{
2283 		.procname       = "nmi_watchdog",
2284 		.data		= &nmi_watchdog_user_enabled,
2285 		.maxlen		= sizeof(int),
2286 		.mode		= NMI_WATCHDOG_SYSCTL_PERM,
2287 		.proc_handler   = proc_nmi_watchdog,
2288 		.extra1		= SYSCTL_ZERO,
2289 		.extra2		= SYSCTL_ONE,
2290 	},
2291 	{
2292 		.procname	= "watchdog_cpumask",
2293 		.data		= &watchdog_cpumask_bits,
2294 		.maxlen		= NR_CPUS,
2295 		.mode		= 0644,
2296 		.proc_handler	= proc_watchdog_cpumask,
2297 	},
2298 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
2299 	{
2300 		.procname       = "soft_watchdog",
2301 		.data		= &soft_watchdog_user_enabled,
2302 		.maxlen		= sizeof(int),
2303 		.mode		= 0644,
2304 		.proc_handler   = proc_soft_watchdog,
2305 		.extra1		= SYSCTL_ZERO,
2306 		.extra2		= SYSCTL_ONE,
2307 	},
2308 	{
2309 		.procname	= "softlockup_panic",
2310 		.data		= &softlockup_panic,
2311 		.maxlen		= sizeof(int),
2312 		.mode		= 0644,
2313 		.proc_handler	= proc_dointvec_minmax,
2314 		.extra1		= SYSCTL_ZERO,
2315 		.extra2		= SYSCTL_ONE,
2316 	},
2317 #ifdef CONFIG_SMP
2318 	{
2319 		.procname	= "softlockup_all_cpu_backtrace",
2320 		.data		= &sysctl_softlockup_all_cpu_backtrace,
2321 		.maxlen		= sizeof(int),
2322 		.mode		= 0644,
2323 		.proc_handler	= proc_dointvec_minmax,
2324 		.extra1		= SYSCTL_ZERO,
2325 		.extra2		= SYSCTL_ONE,
2326 	},
2327 #endif /* CONFIG_SMP */
2328 #endif
2329 #ifdef CONFIG_HARDLOCKUP_DETECTOR
2330 	{
2331 		.procname	= "hardlockup_panic",
2332 		.data		= &hardlockup_panic,
2333 		.maxlen		= sizeof(int),
2334 		.mode		= 0644,
2335 		.proc_handler	= proc_dointvec_minmax,
2336 		.extra1		= SYSCTL_ZERO,
2337 		.extra2		= SYSCTL_ONE,
2338 	},
2339 #ifdef CONFIG_SMP
2340 	{
2341 		.procname	= "hardlockup_all_cpu_backtrace",
2342 		.data		= &sysctl_hardlockup_all_cpu_backtrace,
2343 		.maxlen		= sizeof(int),
2344 		.mode		= 0644,
2345 		.proc_handler	= proc_dointvec_minmax,
2346 		.extra1		= SYSCTL_ZERO,
2347 		.extra2		= SYSCTL_ONE,
2348 	},
2349 #endif /* CONFIG_SMP */
2350 #endif
2351 #endif
2352 
2353 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
2354 	{
2355 		.procname       = "unknown_nmi_panic",
2356 		.data           = &unknown_nmi_panic,
2357 		.maxlen         = sizeof (int),
2358 		.mode           = 0644,
2359 		.proc_handler   = proc_dointvec,
2360 	},
2361 #endif
2362 
2363 #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2364 	defined(CONFIG_DEBUG_STACKOVERFLOW)
2365 	{
2366 		.procname	= "panic_on_stackoverflow",
2367 		.data		= &sysctl_panic_on_stackoverflow,
2368 		.maxlen		= sizeof(int),
2369 		.mode		= 0644,
2370 		.proc_handler	= proc_dointvec,
2371 	},
2372 #endif
2373 #if defined(CONFIG_X86)
2374 	{
2375 		.procname	= "panic_on_unrecovered_nmi",
2376 		.data		= &panic_on_unrecovered_nmi,
2377 		.maxlen		= sizeof(int),
2378 		.mode		= 0644,
2379 		.proc_handler	= proc_dointvec,
2380 	},
2381 	{
2382 		.procname	= "panic_on_io_nmi",
2383 		.data		= &panic_on_io_nmi,
2384 		.maxlen		= sizeof(int),
2385 		.mode		= 0644,
2386 		.proc_handler	= proc_dointvec,
2387 	},
2388 	{
2389 		.procname	= "bootloader_type",
2390 		.data		= &bootloader_type,
2391 		.maxlen		= sizeof (int),
2392 		.mode		= 0444,
2393 		.proc_handler	= proc_dointvec,
2394 	},
2395 	{
2396 		.procname	= "bootloader_version",
2397 		.data		= &bootloader_version,
2398 		.maxlen		= sizeof (int),
2399 		.mode		= 0444,
2400 		.proc_handler	= proc_dointvec,
2401 	},
2402 	{
2403 		.procname	= "io_delay_type",
2404 		.data		= &io_delay_type,
2405 		.maxlen		= sizeof(int),
2406 		.mode		= 0644,
2407 		.proc_handler	= proc_dointvec,
2408 	},
2409 #endif
2410 #if defined(CONFIG_MMU)
2411 	{
2412 		.procname	= "randomize_va_space",
2413 		.data		= &randomize_va_space,
2414 		.maxlen		= sizeof(int),
2415 		.mode		= 0644,
2416 		.proc_handler	= proc_dointvec,
2417 	},
2418 #endif
2419 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2420 	{
2421 		.procname	= "spin_retry",
2422 		.data		= &spin_retry,
2423 		.maxlen		= sizeof (int),
2424 		.mode		= 0644,
2425 		.proc_handler	= proc_dointvec,
2426 	},
2427 #endif
2428 #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2429 	{
2430 		.procname	= "acpi_video_flags",
2431 		.data		= &acpi_realmode_flags,
2432 		.maxlen		= sizeof (unsigned long),
2433 		.mode		= 0644,
2434 		.proc_handler	= proc_doulongvec_minmax,
2435 	},
2436 #endif
2437 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2438 	{
2439 		.procname	= "ignore-unaligned-usertrap",
2440 		.data		= &no_unaligned_warning,
2441 		.maxlen		= sizeof (int),
2442 		.mode		= 0644,
2443 		.proc_handler	= proc_dointvec,
2444 	},
2445 #endif
2446 #ifdef CONFIG_IA64
2447 	{
2448 		.procname	= "unaligned-dump-stack",
2449 		.data		= &unaligned_dump_stack,
2450 		.maxlen		= sizeof (int),
2451 		.mode		= 0644,
2452 		.proc_handler	= proc_dointvec,
2453 	},
2454 #endif
2455 #ifdef CONFIG_DETECT_HUNG_TASK
2456 #ifdef CONFIG_SMP
2457 	{
2458 		.procname	= "hung_task_all_cpu_backtrace",
2459 		.data		= &sysctl_hung_task_all_cpu_backtrace,
2460 		.maxlen		= sizeof(int),
2461 		.mode		= 0644,
2462 		.proc_handler	= proc_dointvec_minmax,
2463 		.extra1		= SYSCTL_ZERO,
2464 		.extra2		= SYSCTL_ONE,
2465 	},
2466 #endif /* CONFIG_SMP */
2467 	{
2468 		.procname	= "hung_task_panic",
2469 		.data		= &sysctl_hung_task_panic,
2470 		.maxlen		= sizeof(int),
2471 		.mode		= 0644,
2472 		.proc_handler	= proc_dointvec_minmax,
2473 		.extra1		= SYSCTL_ZERO,
2474 		.extra2		= SYSCTL_ONE,
2475 	},
2476 	{
2477 		.procname	= "hung_task_check_count",
2478 		.data		= &sysctl_hung_task_check_count,
2479 		.maxlen		= sizeof(int),
2480 		.mode		= 0644,
2481 		.proc_handler	= proc_dointvec_minmax,
2482 		.extra1		= SYSCTL_ZERO,
2483 	},
2484 	{
2485 		.procname	= "hung_task_timeout_secs",
2486 		.data		= &sysctl_hung_task_timeout_secs,
2487 		.maxlen		= sizeof(unsigned long),
2488 		.mode		= 0644,
2489 		.proc_handler	= proc_dohung_task_timeout_secs,
2490 		.extra2		= &hung_task_timeout_max,
2491 	},
2492 	{
2493 		.procname	= "hung_task_check_interval_secs",
2494 		.data		= &sysctl_hung_task_check_interval_secs,
2495 		.maxlen		= sizeof(unsigned long),
2496 		.mode		= 0644,
2497 		.proc_handler	= proc_dohung_task_timeout_secs,
2498 		.extra2		= &hung_task_timeout_max,
2499 	},
2500 	{
2501 		.procname	= "hung_task_warnings",
2502 		.data		= &sysctl_hung_task_warnings,
2503 		.maxlen		= sizeof(int),
2504 		.mode		= 0644,
2505 		.proc_handler	= proc_dointvec_minmax,
2506 		.extra1		= &neg_one,
2507 	},
2508 #endif
2509 #ifdef CONFIG_RT_MUTEXES
2510 	{
2511 		.procname	= "max_lock_depth",
2512 		.data		= &max_lock_depth,
2513 		.maxlen		= sizeof(int),
2514 		.mode		= 0644,
2515 		.proc_handler	= proc_dointvec,
2516 	},
2517 #endif
2518 	{
2519 		.procname	= "poweroff_cmd",
2520 		.data		= &poweroff_cmd,
2521 		.maxlen		= POWEROFF_CMD_PATH_LEN,
2522 		.mode		= 0644,
2523 		.proc_handler	= proc_dostring,
2524 	},
2525 #ifdef CONFIG_KEYS
2526 	{
2527 		.procname	= "keys",
2528 		.mode		= 0555,
2529 		.child		= key_sysctls,
2530 	},
2531 #endif
2532 #ifdef CONFIG_PERF_EVENTS
2533 	/*
2534 	 * User-space scripts rely on the existence of this file
2535 	 * as a feature check for perf_events being enabled.
2536 	 *
2537 	 * So it's an ABI, do not remove!
2538 	 */
2539 	{
2540 		.procname	= "perf_event_paranoid",
2541 		.data		= &sysctl_perf_event_paranoid,
2542 		.maxlen		= sizeof(sysctl_perf_event_paranoid),
2543 		.mode		= 0644,
2544 		.proc_handler	= proc_dointvec,
2545 	},
2546 	{
2547 		.procname	= "perf_event_mlock_kb",
2548 		.data		= &sysctl_perf_event_mlock,
2549 		.maxlen		= sizeof(sysctl_perf_event_mlock),
2550 		.mode		= 0644,
2551 		.proc_handler	= proc_dointvec,
2552 	},
2553 	{
2554 		.procname	= "perf_event_max_sample_rate",
2555 		.data		= &sysctl_perf_event_sample_rate,
2556 		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
2557 		.mode		= 0644,
2558 		.proc_handler	= perf_proc_update_handler,
2559 		.extra1		= SYSCTL_ONE,
2560 	},
2561 	{
2562 		.procname	= "perf_cpu_time_max_percent",
2563 		.data		= &sysctl_perf_cpu_time_max_percent,
2564 		.maxlen		= sizeof(sysctl_perf_cpu_time_max_percent),
2565 		.mode		= 0644,
2566 		.proc_handler	= perf_cpu_time_max_percent_handler,
2567 		.extra1		= SYSCTL_ZERO,
2568 		.extra2		= &one_hundred,
2569 	},
2570 	{
2571 		.procname	= "perf_event_max_stack",
2572 		.data		= &sysctl_perf_event_max_stack,
2573 		.maxlen		= sizeof(sysctl_perf_event_max_stack),
2574 		.mode		= 0644,
2575 		.proc_handler	= perf_event_max_stack_handler,
2576 		.extra1		= SYSCTL_ZERO,
2577 		.extra2		= &six_hundred_forty_kb,
2578 	},
2579 	{
2580 		.procname	= "perf_event_max_contexts_per_stack",
2581 		.data		= &sysctl_perf_event_max_contexts_per_stack,
2582 		.maxlen		= sizeof(sysctl_perf_event_max_contexts_per_stack),
2583 		.mode		= 0644,
2584 		.proc_handler	= perf_event_max_stack_handler,
2585 		.extra1		= SYSCTL_ZERO,
2586 		.extra2		= &one_thousand,
2587 	},
2588 #endif
2589 	{
2590 		.procname	= "panic_on_warn",
2591 		.data		= &panic_on_warn,
2592 		.maxlen		= sizeof(int),
2593 		.mode		= 0644,
2594 		.proc_handler	= proc_dointvec_minmax,
2595 		.extra1		= SYSCTL_ZERO,
2596 		.extra2		= SYSCTL_ONE,
2597 	},
2598 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2599 	{
2600 		.procname	= "timer_migration",
2601 		.data		= &sysctl_timer_migration,
2602 		.maxlen		= sizeof(unsigned int),
2603 		.mode		= 0644,
2604 		.proc_handler	= timer_migration_handler,
2605 		.extra1		= SYSCTL_ZERO,
2606 		.extra2		= SYSCTL_ONE,
2607 	},
2608 #endif
2609 #ifdef CONFIG_BPF_SYSCALL
2610 	{
2611 		.procname	= "unprivileged_bpf_disabled",
2612 		.data		= &sysctl_unprivileged_bpf_disabled,
2613 		.maxlen		= sizeof(sysctl_unprivileged_bpf_disabled),
2614 		.mode		= 0644,
2615 		/* only handle a transition from default "0" to "1" */
2616 		.proc_handler	= proc_dointvec_minmax,
2617 		.extra1		= SYSCTL_ONE,
2618 		.extra2		= SYSCTL_ONE,
2619 	},
2620 	{
2621 		.procname	= "bpf_stats_enabled",
2622 		.data		= &bpf_stats_enabled_key.key,
2623 		.maxlen		= sizeof(bpf_stats_enabled_key),
2624 		.mode		= 0644,
2625 		.proc_handler	= bpf_stats_handler,
2626 	},
2627 #endif
2628 #if defined(CONFIG_TREE_RCU)
2629 	{
2630 		.procname	= "panic_on_rcu_stall",
2631 		.data		= &sysctl_panic_on_rcu_stall,
2632 		.maxlen		= sizeof(sysctl_panic_on_rcu_stall),
2633 		.mode		= 0644,
2634 		.proc_handler	= proc_dointvec_minmax,
2635 		.extra1		= SYSCTL_ZERO,
2636 		.extra2		= SYSCTL_ONE,
2637 	},
2638 #endif
2639 #if defined(CONFIG_TREE_RCU)
2640 	{
2641 		.procname	= "max_rcu_stall_to_panic",
2642 		.data		= &sysctl_max_rcu_stall_to_panic,
2643 		.maxlen		= sizeof(sysctl_max_rcu_stall_to_panic),
2644 		.mode		= 0644,
2645 		.proc_handler	= proc_dointvec_minmax,
2646 		.extra1		= SYSCTL_ONE,
2647 		.extra2		= SYSCTL_INT_MAX,
2648 	},
2649 #endif
2650 #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2651 	{
2652 		.procname	= "stack_erasing",
2653 		.data		= NULL,
2654 		.maxlen		= sizeof(int),
2655 		.mode		= 0600,
2656 		.proc_handler	= stack_erasing_sysctl,
2657 		.extra1		= SYSCTL_ZERO,
2658 		.extra2		= SYSCTL_ONE,
2659 	},
2660 #endif
2661 	{ }
2662 };
2663 
2664 static struct ctl_table vm_table[] = {
2665 	{
2666 		.procname	= "overcommit_memory",
2667 		.data		= &sysctl_overcommit_memory,
2668 		.maxlen		= sizeof(sysctl_overcommit_memory),
2669 		.mode		= 0644,
2670 		.proc_handler	= overcommit_policy_handler,
2671 		.extra1		= SYSCTL_ZERO,
2672 		.extra2		= &two,
2673 	},
2674 	{
2675 		.procname	= "panic_on_oom",
2676 		.data		= &sysctl_panic_on_oom,
2677 		.maxlen		= sizeof(sysctl_panic_on_oom),
2678 		.mode		= 0644,
2679 		.proc_handler	= proc_dointvec_minmax,
2680 		.extra1		= SYSCTL_ZERO,
2681 		.extra2		= &two,
2682 	},
2683 	{
2684 		.procname	= "oom_kill_allocating_task",
2685 		.data		= &sysctl_oom_kill_allocating_task,
2686 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
2687 		.mode		= 0644,
2688 		.proc_handler	= proc_dointvec,
2689 	},
2690 	{
2691 		.procname	= "oom_dump_tasks",
2692 		.data		= &sysctl_oom_dump_tasks,
2693 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
2694 		.mode		= 0644,
2695 		.proc_handler	= proc_dointvec,
2696 	},
2697 	{
2698 		.procname	= "overcommit_ratio",
2699 		.data		= &sysctl_overcommit_ratio,
2700 		.maxlen		= sizeof(sysctl_overcommit_ratio),
2701 		.mode		= 0644,
2702 		.proc_handler	= overcommit_ratio_handler,
2703 	},
2704 	{
2705 		.procname	= "overcommit_kbytes",
2706 		.data		= &sysctl_overcommit_kbytes,
2707 		.maxlen		= sizeof(sysctl_overcommit_kbytes),
2708 		.mode		= 0644,
2709 		.proc_handler	= overcommit_kbytes_handler,
2710 	},
2711 	{
2712 		.procname	= "page-cluster",
2713 		.data		= &page_cluster,
2714 		.maxlen		= sizeof(int),
2715 		.mode		= 0644,
2716 		.proc_handler	= proc_dointvec_minmax,
2717 		.extra1		= SYSCTL_ZERO,
2718 	},
2719 	{
2720 		.procname	= "dirty_background_ratio",
2721 		.data		= &dirty_background_ratio,
2722 		.maxlen		= sizeof(dirty_background_ratio),
2723 		.mode		= 0644,
2724 		.proc_handler	= dirty_background_ratio_handler,
2725 		.extra1		= SYSCTL_ZERO,
2726 		.extra2		= &one_hundred,
2727 	},
2728 	{
2729 		.procname	= "dirty_background_bytes",
2730 		.data		= &dirty_background_bytes,
2731 		.maxlen		= sizeof(dirty_background_bytes),
2732 		.mode		= 0644,
2733 		.proc_handler	= dirty_background_bytes_handler,
2734 		.extra1		= &one_ul,
2735 	},
2736 	{
2737 		.procname	= "dirty_ratio",
2738 		.data		= &vm_dirty_ratio,
2739 		.maxlen		= sizeof(vm_dirty_ratio),
2740 		.mode		= 0644,
2741 		.proc_handler	= dirty_ratio_handler,
2742 		.extra1		= SYSCTL_ZERO,
2743 		.extra2		= &one_hundred,
2744 	},
2745 	{
2746 		.procname	= "dirty_bytes",
2747 		.data		= &vm_dirty_bytes,
2748 		.maxlen		= sizeof(vm_dirty_bytes),
2749 		.mode		= 0644,
2750 		.proc_handler	= dirty_bytes_handler,
2751 		.extra1		= &dirty_bytes_min,
2752 	},
2753 	{
2754 		.procname	= "dirty_writeback_centisecs",
2755 		.data		= &dirty_writeback_interval,
2756 		.maxlen		= sizeof(dirty_writeback_interval),
2757 		.mode		= 0644,
2758 		.proc_handler	= dirty_writeback_centisecs_handler,
2759 	},
2760 	{
2761 		.procname	= "dirty_expire_centisecs",
2762 		.data		= &dirty_expire_interval,
2763 		.maxlen		= sizeof(dirty_expire_interval),
2764 		.mode		= 0644,
2765 		.proc_handler	= proc_dointvec_minmax,
2766 		.extra1		= SYSCTL_ZERO,
2767 	},
2768 	{
2769 		.procname	= "dirtytime_expire_seconds",
2770 		.data		= &dirtytime_expire_interval,
2771 		.maxlen		= sizeof(dirtytime_expire_interval),
2772 		.mode		= 0644,
2773 		.proc_handler	= dirtytime_interval_handler,
2774 		.extra1		= SYSCTL_ZERO,
2775 	},
2776 	{
2777 		.procname	= "swappiness",
2778 		.data		= &vm_swappiness,
2779 		.maxlen		= sizeof(vm_swappiness),
2780 		.mode		= 0644,
2781 		.proc_handler	= proc_dointvec_minmax,
2782 		.extra1		= SYSCTL_ZERO,
2783 		.extra2		= &two_hundred,
2784 	},
2785 #ifdef CONFIG_HUGETLB_PAGE
2786 	{
2787 		.procname	= "nr_hugepages",
2788 		.data		= NULL,
2789 		.maxlen		= sizeof(unsigned long),
2790 		.mode		= 0644,
2791 		.proc_handler	= hugetlb_sysctl_handler,
2792 	},
2793 #ifdef CONFIG_NUMA
2794 	{
2795 		.procname       = "nr_hugepages_mempolicy",
2796 		.data           = NULL,
2797 		.maxlen         = sizeof(unsigned long),
2798 		.mode           = 0644,
2799 		.proc_handler   = &hugetlb_mempolicy_sysctl_handler,
2800 	},
2801 	{
2802 		.procname		= "numa_stat",
2803 		.data			= &sysctl_vm_numa_stat,
2804 		.maxlen			= sizeof(int),
2805 		.mode			= 0644,
2806 		.proc_handler	= sysctl_vm_numa_stat_handler,
2807 		.extra1			= SYSCTL_ZERO,
2808 		.extra2			= SYSCTL_ONE,
2809 	},
2810 #endif
2811 	 {
2812 		.procname	= "hugetlb_shm_group",
2813 		.data		= &sysctl_hugetlb_shm_group,
2814 		.maxlen		= sizeof(gid_t),
2815 		.mode		= 0644,
2816 		.proc_handler	= proc_dointvec,
2817 	 },
2818 	{
2819 		.procname	= "nr_overcommit_hugepages",
2820 		.data		= NULL,
2821 		.maxlen		= sizeof(unsigned long),
2822 		.mode		= 0644,
2823 		.proc_handler	= hugetlb_overcommit_handler,
2824 	},
2825 #endif
2826 	{
2827 		.procname	= "lowmem_reserve_ratio",
2828 		.data		= &sysctl_lowmem_reserve_ratio,
2829 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
2830 		.mode		= 0644,
2831 		.proc_handler	= lowmem_reserve_ratio_sysctl_handler,
2832 	},
2833 	{
2834 		.procname	= "drop_caches",
2835 		.data		= &sysctl_drop_caches,
2836 		.maxlen		= sizeof(int),
2837 		.mode		= 0200,
2838 		.proc_handler	= drop_caches_sysctl_handler,
2839 		.extra1		= SYSCTL_ONE,
2840 		.extra2		= &four,
2841 	},
2842 #ifdef CONFIG_COMPACTION
2843 	{
2844 		.procname	= "compact_memory",
2845 		.data		= NULL,
2846 		.maxlen		= sizeof(int),
2847 		.mode		= 0200,
2848 		.proc_handler	= sysctl_compaction_handler,
2849 	},
2850 	{
2851 		.procname	= "compaction_proactiveness",
2852 		.data		= &sysctl_compaction_proactiveness,
2853 		.maxlen		= sizeof(sysctl_compaction_proactiveness),
2854 		.mode		= 0644,
2855 		.proc_handler	= proc_dointvec_minmax,
2856 		.extra1		= SYSCTL_ZERO,
2857 		.extra2		= &one_hundred,
2858 	},
2859 	{
2860 		.procname	= "extfrag_threshold",
2861 		.data		= &sysctl_extfrag_threshold,
2862 		.maxlen		= sizeof(int),
2863 		.mode		= 0644,
2864 		.proc_handler	= proc_dointvec_minmax,
2865 		.extra1		= &min_extfrag_threshold,
2866 		.extra2		= &max_extfrag_threshold,
2867 	},
2868 	{
2869 		.procname	= "compact_unevictable_allowed",
2870 		.data		= &sysctl_compact_unevictable_allowed,
2871 		.maxlen		= sizeof(int),
2872 		.mode		= 0644,
2873 		.proc_handler	= proc_dointvec_minmax_warn_RT_change,
2874 		.extra1		= SYSCTL_ZERO,
2875 		.extra2		= SYSCTL_ONE,
2876 	},
2877 
2878 #endif /* CONFIG_COMPACTION */
2879 	{
2880 		.procname	= "min_free_kbytes",
2881 		.data		= &min_free_kbytes,
2882 		.maxlen		= sizeof(min_free_kbytes),
2883 		.mode		= 0644,
2884 		.proc_handler	= min_free_kbytes_sysctl_handler,
2885 		.extra1		= SYSCTL_ZERO,
2886 	},
2887 	{
2888 		.procname	= "watermark_boost_factor",
2889 		.data		= &watermark_boost_factor,
2890 		.maxlen		= sizeof(watermark_boost_factor),
2891 		.mode		= 0644,
2892 		.proc_handler	= proc_dointvec_minmax,
2893 		.extra1		= SYSCTL_ZERO,
2894 	},
2895 	{
2896 		.procname	= "watermark_scale_factor",
2897 		.data		= &watermark_scale_factor,
2898 		.maxlen		= sizeof(watermark_scale_factor),
2899 		.mode		= 0644,
2900 		.proc_handler	= watermark_scale_factor_sysctl_handler,
2901 		.extra1		= SYSCTL_ONE,
2902 		.extra2		= &one_thousand,
2903 	},
2904 	{
2905 		.procname	= "percpu_pagelist_fraction",
2906 		.data		= &percpu_pagelist_fraction,
2907 		.maxlen		= sizeof(percpu_pagelist_fraction),
2908 		.mode		= 0644,
2909 		.proc_handler	= percpu_pagelist_fraction_sysctl_handler,
2910 		.extra1		= SYSCTL_ZERO,
2911 	},
2912 	{
2913 		.procname	= "page_lock_unfairness",
2914 		.data		= &sysctl_page_lock_unfairness,
2915 		.maxlen		= sizeof(sysctl_page_lock_unfairness),
2916 		.mode		= 0644,
2917 		.proc_handler	= proc_dointvec_minmax,
2918 		.extra1		= SYSCTL_ZERO,
2919 	},
2920 #ifdef CONFIG_MMU
2921 	{
2922 		.procname	= "max_map_count",
2923 		.data		= &sysctl_max_map_count,
2924 		.maxlen		= sizeof(sysctl_max_map_count),
2925 		.mode		= 0644,
2926 		.proc_handler	= proc_dointvec_minmax,
2927 		.extra1		= SYSCTL_ZERO,
2928 	},
2929 #else
2930 	{
2931 		.procname	= "nr_trim_pages",
2932 		.data		= &sysctl_nr_trim_pages,
2933 		.maxlen		= sizeof(sysctl_nr_trim_pages),
2934 		.mode		= 0644,
2935 		.proc_handler	= proc_dointvec_minmax,
2936 		.extra1		= SYSCTL_ZERO,
2937 	},
2938 #endif
2939 	{
2940 		.procname	= "laptop_mode",
2941 		.data		= &laptop_mode,
2942 		.maxlen		= sizeof(laptop_mode),
2943 		.mode		= 0644,
2944 		.proc_handler	= proc_dointvec_jiffies,
2945 	},
2946 	{
2947 		.procname	= "block_dump",
2948 		.data		= &block_dump,
2949 		.maxlen		= sizeof(block_dump),
2950 		.mode		= 0644,
2951 		.proc_handler	= proc_dointvec_minmax,
2952 		.extra1		= SYSCTL_ZERO,
2953 	},
2954 	{
2955 		.procname	= "vfs_cache_pressure",
2956 		.data		= &sysctl_vfs_cache_pressure,
2957 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
2958 		.mode		= 0644,
2959 		.proc_handler	= proc_dointvec_minmax,
2960 		.extra1		= SYSCTL_ZERO,
2961 	},
2962 #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
2963     defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
2964 	{
2965 		.procname	= "legacy_va_layout",
2966 		.data		= &sysctl_legacy_va_layout,
2967 		.maxlen		= sizeof(sysctl_legacy_va_layout),
2968 		.mode		= 0644,
2969 		.proc_handler	= proc_dointvec_minmax,
2970 		.extra1		= SYSCTL_ZERO,
2971 	},
2972 #endif
2973 #ifdef CONFIG_NUMA
2974 	{
2975 		.procname	= "zone_reclaim_mode",
2976 		.data		= &node_reclaim_mode,
2977 		.maxlen		= sizeof(node_reclaim_mode),
2978 		.mode		= 0644,
2979 		.proc_handler	= proc_dointvec_minmax,
2980 		.extra1		= SYSCTL_ZERO,
2981 	},
2982 	{
2983 		.procname	= "min_unmapped_ratio",
2984 		.data		= &sysctl_min_unmapped_ratio,
2985 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
2986 		.mode		= 0644,
2987 		.proc_handler	= sysctl_min_unmapped_ratio_sysctl_handler,
2988 		.extra1		= SYSCTL_ZERO,
2989 		.extra2		= &one_hundred,
2990 	},
2991 	{
2992 		.procname	= "min_slab_ratio",
2993 		.data		= &sysctl_min_slab_ratio,
2994 		.maxlen		= sizeof(sysctl_min_slab_ratio),
2995 		.mode		= 0644,
2996 		.proc_handler	= sysctl_min_slab_ratio_sysctl_handler,
2997 		.extra1		= SYSCTL_ZERO,
2998 		.extra2		= &one_hundred,
2999 	},
3000 #endif
3001 #ifdef CONFIG_SMP
3002 	{
3003 		.procname	= "stat_interval",
3004 		.data		= &sysctl_stat_interval,
3005 		.maxlen		= sizeof(sysctl_stat_interval),
3006 		.mode		= 0644,
3007 		.proc_handler	= proc_dointvec_jiffies,
3008 	},
3009 	{
3010 		.procname	= "stat_refresh",
3011 		.data		= NULL,
3012 		.maxlen		= 0,
3013 		.mode		= 0600,
3014 		.proc_handler	= vmstat_refresh,
3015 	},
3016 #endif
3017 #ifdef CONFIG_MMU
3018 	{
3019 		.procname	= "mmap_min_addr",
3020 		.data		= &dac_mmap_min_addr,
3021 		.maxlen		= sizeof(unsigned long),
3022 		.mode		= 0644,
3023 		.proc_handler	= mmap_min_addr_handler,
3024 	},
3025 #endif
3026 #ifdef CONFIG_NUMA
3027 	{
3028 		.procname	= "numa_zonelist_order",
3029 		.data		= &numa_zonelist_order,
3030 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
3031 		.mode		= 0644,
3032 		.proc_handler	= numa_zonelist_order_handler,
3033 	},
3034 #endif
3035 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
3036    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3037 	{
3038 		.procname	= "vdso_enabled",
3039 #ifdef CONFIG_X86_32
3040 		.data		= &vdso32_enabled,
3041 		.maxlen		= sizeof(vdso32_enabled),
3042 #else
3043 		.data		= &vdso_enabled,
3044 		.maxlen		= sizeof(vdso_enabled),
3045 #endif
3046 		.mode		= 0644,
3047 		.proc_handler	= proc_dointvec,
3048 		.extra1		= SYSCTL_ZERO,
3049 	},
3050 #endif
3051 #ifdef CONFIG_HIGHMEM
3052 	{
3053 		.procname	= "highmem_is_dirtyable",
3054 		.data		= &vm_highmem_is_dirtyable,
3055 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
3056 		.mode		= 0644,
3057 		.proc_handler	= proc_dointvec_minmax,
3058 		.extra1		= SYSCTL_ZERO,
3059 		.extra2		= SYSCTL_ONE,
3060 	},
3061 #endif
3062 #ifdef CONFIG_MEMORY_FAILURE
3063 	{
3064 		.procname	= "memory_failure_early_kill",
3065 		.data		= &sysctl_memory_failure_early_kill,
3066 		.maxlen		= sizeof(sysctl_memory_failure_early_kill),
3067 		.mode		= 0644,
3068 		.proc_handler	= proc_dointvec_minmax,
3069 		.extra1		= SYSCTL_ZERO,
3070 		.extra2		= SYSCTL_ONE,
3071 	},
3072 	{
3073 		.procname	= "memory_failure_recovery",
3074 		.data		= &sysctl_memory_failure_recovery,
3075 		.maxlen		= sizeof(sysctl_memory_failure_recovery),
3076 		.mode		= 0644,
3077 		.proc_handler	= proc_dointvec_minmax,
3078 		.extra1		= SYSCTL_ZERO,
3079 		.extra2		= SYSCTL_ONE,
3080 	},
3081 #endif
3082 	{
3083 		.procname	= "user_reserve_kbytes",
3084 		.data		= &sysctl_user_reserve_kbytes,
3085 		.maxlen		= sizeof(sysctl_user_reserve_kbytes),
3086 		.mode		= 0644,
3087 		.proc_handler	= proc_doulongvec_minmax,
3088 	},
3089 	{
3090 		.procname	= "admin_reserve_kbytes",
3091 		.data		= &sysctl_admin_reserve_kbytes,
3092 		.maxlen		= sizeof(sysctl_admin_reserve_kbytes),
3093 		.mode		= 0644,
3094 		.proc_handler	= proc_doulongvec_minmax,
3095 	},
3096 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3097 	{
3098 		.procname	= "mmap_rnd_bits",
3099 		.data		= &mmap_rnd_bits,
3100 		.maxlen		= sizeof(mmap_rnd_bits),
3101 		.mode		= 0600,
3102 		.proc_handler	= proc_dointvec_minmax,
3103 		.extra1		= (void *)&mmap_rnd_bits_min,
3104 		.extra2		= (void *)&mmap_rnd_bits_max,
3105 	},
3106 #endif
3107 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3108 	{
3109 		.procname	= "mmap_rnd_compat_bits",
3110 		.data		= &mmap_rnd_compat_bits,
3111 		.maxlen		= sizeof(mmap_rnd_compat_bits),
3112 		.mode		= 0600,
3113 		.proc_handler	= proc_dointvec_minmax,
3114 		.extra1		= (void *)&mmap_rnd_compat_bits_min,
3115 		.extra2		= (void *)&mmap_rnd_compat_bits_max,
3116 	},
3117 #endif
3118 #ifdef CONFIG_USERFAULTFD
3119 	{
3120 		.procname	= "unprivileged_userfaultfd",
3121 		.data		= &sysctl_unprivileged_userfaultfd,
3122 		.maxlen		= sizeof(sysctl_unprivileged_userfaultfd),
3123 		.mode		= 0644,
3124 		.proc_handler	= proc_dointvec_minmax,
3125 		.extra1		= SYSCTL_ZERO,
3126 		.extra2		= SYSCTL_ONE,
3127 	},
3128 #endif
3129 	{ }
3130 };
3131 
3132 static struct ctl_table fs_table[] = {
3133 	{
3134 		.procname	= "inode-nr",
3135 		.data		= &inodes_stat,
3136 		.maxlen		= 2*sizeof(long),
3137 		.mode		= 0444,
3138 		.proc_handler	= proc_nr_inodes,
3139 	},
3140 	{
3141 		.procname	= "inode-state",
3142 		.data		= &inodes_stat,
3143 		.maxlen		= 7*sizeof(long),
3144 		.mode		= 0444,
3145 		.proc_handler	= proc_nr_inodes,
3146 	},
3147 	{
3148 		.procname	= "file-nr",
3149 		.data		= &files_stat,
3150 		.maxlen		= sizeof(files_stat),
3151 		.mode		= 0444,
3152 		.proc_handler	= proc_nr_files,
3153 	},
3154 	{
3155 		.procname	= "file-max",
3156 		.data		= &files_stat.max_files,
3157 		.maxlen		= sizeof(files_stat.max_files),
3158 		.mode		= 0644,
3159 		.proc_handler	= proc_doulongvec_minmax,
3160 		.extra1		= &zero_ul,
3161 		.extra2		= &long_max,
3162 	},
3163 	{
3164 		.procname	= "nr_open",
3165 		.data		= &sysctl_nr_open,
3166 		.maxlen		= sizeof(unsigned int),
3167 		.mode		= 0644,
3168 		.proc_handler	= proc_dointvec_minmax,
3169 		.extra1		= &sysctl_nr_open_min,
3170 		.extra2		= &sysctl_nr_open_max,
3171 	},
3172 	{
3173 		.procname	= "dentry-state",
3174 		.data		= &dentry_stat,
3175 		.maxlen		= 6*sizeof(long),
3176 		.mode		= 0444,
3177 		.proc_handler	= proc_nr_dentry,
3178 	},
3179 	{
3180 		.procname	= "overflowuid",
3181 		.data		= &fs_overflowuid,
3182 		.maxlen		= sizeof(int),
3183 		.mode		= 0644,
3184 		.proc_handler	= proc_dointvec_minmax,
3185 		.extra1		= &minolduid,
3186 		.extra2		= &maxolduid,
3187 	},
3188 	{
3189 		.procname	= "overflowgid",
3190 		.data		= &fs_overflowgid,
3191 		.maxlen		= sizeof(int),
3192 		.mode		= 0644,
3193 		.proc_handler	= proc_dointvec_minmax,
3194 		.extra1		= &minolduid,
3195 		.extra2		= &maxolduid,
3196 	},
3197 #ifdef CONFIG_FILE_LOCKING
3198 	{
3199 		.procname	= "leases-enable",
3200 		.data		= &leases_enable,
3201 		.maxlen		= sizeof(int),
3202 		.mode		= 0644,
3203 		.proc_handler	= proc_dointvec,
3204 	},
3205 #endif
3206 #ifdef CONFIG_DNOTIFY
3207 	{
3208 		.procname	= "dir-notify-enable",
3209 		.data		= &dir_notify_enable,
3210 		.maxlen		= sizeof(int),
3211 		.mode		= 0644,
3212 		.proc_handler	= proc_dointvec,
3213 	},
3214 #endif
3215 #ifdef CONFIG_MMU
3216 #ifdef CONFIG_FILE_LOCKING
3217 	{
3218 		.procname	= "lease-break-time",
3219 		.data		= &lease_break_time,
3220 		.maxlen		= sizeof(int),
3221 		.mode		= 0644,
3222 		.proc_handler	= proc_dointvec,
3223 	},
3224 #endif
3225 #ifdef CONFIG_AIO
3226 	{
3227 		.procname	= "aio-nr",
3228 		.data		= &aio_nr,
3229 		.maxlen		= sizeof(aio_nr),
3230 		.mode		= 0444,
3231 		.proc_handler	= proc_doulongvec_minmax,
3232 	},
3233 	{
3234 		.procname	= "aio-max-nr",
3235 		.data		= &aio_max_nr,
3236 		.maxlen		= sizeof(aio_max_nr),
3237 		.mode		= 0644,
3238 		.proc_handler	= proc_doulongvec_minmax,
3239 	},
3240 #endif /* CONFIG_AIO */
3241 #ifdef CONFIG_INOTIFY_USER
3242 	{
3243 		.procname	= "inotify",
3244 		.mode		= 0555,
3245 		.child		= inotify_table,
3246 	},
3247 #endif
3248 #ifdef CONFIG_FANOTIFY
3249 	{
3250 		.procname	= "fanotify",
3251 		.mode		= 0555,
3252 		.child		= fanotify_table,
3253 	},
3254 #endif
3255 #ifdef CONFIG_EPOLL
3256 	{
3257 		.procname	= "epoll",
3258 		.mode		= 0555,
3259 		.child		= epoll_table,
3260 	},
3261 #endif
3262 #endif
3263 	{
3264 		.procname	= "protected_symlinks",
3265 		.data		= &sysctl_protected_symlinks,
3266 		.maxlen		= sizeof(int),
3267 		.mode		= 0600,
3268 		.proc_handler	= proc_dointvec_minmax,
3269 		.extra1		= SYSCTL_ZERO,
3270 		.extra2		= SYSCTL_ONE,
3271 	},
3272 	{
3273 		.procname	= "protected_hardlinks",
3274 		.data		= &sysctl_protected_hardlinks,
3275 		.maxlen		= sizeof(int),
3276 		.mode		= 0600,
3277 		.proc_handler	= proc_dointvec_minmax,
3278 		.extra1		= SYSCTL_ZERO,
3279 		.extra2		= SYSCTL_ONE,
3280 	},
3281 	{
3282 		.procname	= "protected_fifos",
3283 		.data		= &sysctl_protected_fifos,
3284 		.maxlen		= sizeof(int),
3285 		.mode		= 0600,
3286 		.proc_handler	= proc_dointvec_minmax,
3287 		.extra1		= SYSCTL_ZERO,
3288 		.extra2		= &two,
3289 	},
3290 	{
3291 		.procname	= "protected_regular",
3292 		.data		= &sysctl_protected_regular,
3293 		.maxlen		= sizeof(int),
3294 		.mode		= 0600,
3295 		.proc_handler	= proc_dointvec_minmax,
3296 		.extra1		= SYSCTL_ZERO,
3297 		.extra2		= &two,
3298 	},
3299 	{
3300 		.procname	= "suid_dumpable",
3301 		.data		= &suid_dumpable,
3302 		.maxlen		= sizeof(int),
3303 		.mode		= 0644,
3304 		.proc_handler	= proc_dointvec_minmax_coredump,
3305 		.extra1		= SYSCTL_ZERO,
3306 		.extra2		= &two,
3307 	},
3308 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
3309 	{
3310 		.procname	= "binfmt_misc",
3311 		.mode		= 0555,
3312 		.child		= sysctl_mount_point,
3313 	},
3314 #endif
3315 	{
3316 		.procname	= "pipe-max-size",
3317 		.data		= &pipe_max_size,
3318 		.maxlen		= sizeof(pipe_max_size),
3319 		.mode		= 0644,
3320 		.proc_handler	= proc_dopipe_max_size,
3321 	},
3322 	{
3323 		.procname	= "pipe-user-pages-hard",
3324 		.data		= &pipe_user_pages_hard,
3325 		.maxlen		= sizeof(pipe_user_pages_hard),
3326 		.mode		= 0644,
3327 		.proc_handler	= proc_doulongvec_minmax,
3328 	},
3329 	{
3330 		.procname	= "pipe-user-pages-soft",
3331 		.data		= &pipe_user_pages_soft,
3332 		.maxlen		= sizeof(pipe_user_pages_soft),
3333 		.mode		= 0644,
3334 		.proc_handler	= proc_doulongvec_minmax,
3335 	},
3336 	{
3337 		.procname	= "mount-max",
3338 		.data		= &sysctl_mount_max,
3339 		.maxlen		= sizeof(unsigned int),
3340 		.mode		= 0644,
3341 		.proc_handler	= proc_dointvec_minmax,
3342 		.extra1		= SYSCTL_ONE,
3343 	},
3344 	{ }
3345 };
3346 
3347 static struct ctl_table debug_table[] = {
3348 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3349 	{
3350 		.procname	= "exception-trace",
3351 		.data		= &show_unhandled_signals,
3352 		.maxlen		= sizeof(int),
3353 		.mode		= 0644,
3354 		.proc_handler	= proc_dointvec
3355 	},
3356 #endif
3357 #if defined(CONFIG_OPTPROBES)
3358 	{
3359 		.procname	= "kprobes-optimization",
3360 		.data		= &sysctl_kprobes_optimization,
3361 		.maxlen		= sizeof(int),
3362 		.mode		= 0644,
3363 		.proc_handler	= proc_kprobes_optimization_handler,
3364 		.extra1		= SYSCTL_ZERO,
3365 		.extra2		= SYSCTL_ONE,
3366 	},
3367 #endif
3368 	{ }
3369 };
3370 
3371 static struct ctl_table dev_table[] = {
3372 	{ }
3373 };
3374 
3375 static struct ctl_table sysctl_base_table[] = {
3376 	{
3377 		.procname	= "kernel",
3378 		.mode		= 0555,
3379 		.child		= kern_table,
3380 	},
3381 	{
3382 		.procname	= "vm",
3383 		.mode		= 0555,
3384 		.child		= vm_table,
3385 	},
3386 	{
3387 		.procname	= "fs",
3388 		.mode		= 0555,
3389 		.child		= fs_table,
3390 	},
3391 	{
3392 		.procname	= "debug",
3393 		.mode		= 0555,
3394 		.child		= debug_table,
3395 	},
3396 	{
3397 		.procname	= "dev",
3398 		.mode		= 0555,
3399 		.child		= dev_table,
3400 	},
3401 	{ }
3402 };
3403 
3404 int __init sysctl_init(void)
3405 {
3406 	struct ctl_table_header *hdr;
3407 
3408 	hdr = register_sysctl_table(sysctl_base_table);
3409 	kmemleak_not_leak(hdr);
3410 	return 0;
3411 }
3412 #endif /* CONFIG_SYSCTL */
3413 /*
3414  * No sense putting this after each symbol definition, twice,
3415  * exception granted :-)
3416  */
3417 EXPORT_SYMBOL(proc_dointvec);
3418 EXPORT_SYMBOL(proc_douintvec);
3419 EXPORT_SYMBOL(proc_dointvec_jiffies);
3420 EXPORT_SYMBOL(proc_dointvec_minmax);
3421 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3422 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3423 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3424 EXPORT_SYMBOL(proc_dostring);
3425 EXPORT_SYMBOL(proc_doulongvec_minmax);
3426 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3427 EXPORT_SYMBOL(proc_do_large_bitmap);
3428