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