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