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