xref: /openbmc/linux/kernel/sysctl.c (revision a2071573d6346819cc4e5787b4206f2184985160)
1457c8996SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * sysctl.c: General linux system control interface
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  * Begun 24 March 1995, Stephen Tweedie
61da177e4SLinus Torvalds  * Added /proc support, Dec 1995
71da177e4SLinus Torvalds  * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
81da177e4SLinus Torvalds  * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
91da177e4SLinus Torvalds  * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
101da177e4SLinus Torvalds  * Dynamic registration fixes, Stephen Tweedie.
111da177e4SLinus Torvalds  * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
121da177e4SLinus Torvalds  * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
131da177e4SLinus Torvalds  *  Horn.
141da177e4SLinus Torvalds  * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
151da177e4SLinus Torvalds  * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
161da177e4SLinus Torvalds  * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
171da177e4SLinus Torvalds  *  Wendling.
181da177e4SLinus Torvalds  * The list_for_each() macro wasn't appropriate for the sysctl loop.
191da177e4SLinus Torvalds  *  Removed it and replaced it with older style, 03/23/00, Bill Wendling
201da177e4SLinus Torvalds  */
211da177e4SLinus Torvalds 
221da177e4SLinus Torvalds #include <linux/module.h>
23e2e40f2cSChristoph Hellwig #include <linux/aio.h>
241da177e4SLinus Torvalds #include <linux/mm.h>
251da177e4SLinus Torvalds #include <linux/swap.h>
261da177e4SLinus Torvalds #include <linux/slab.h>
271da177e4SLinus Torvalds #include <linux/sysctl.h>
285a04cca6SAkinobu Mita #include <linux/bitmap.h>
29d33ed52dSDave Young #include <linux/signal.h>
30f39650deSAndy Shevchenko #include <linux/panic.h>
31455cd5abSDan Rosenberg #include <linux/printk.h>
321da177e4SLinus Torvalds #include <linux/proc_fs.h>
3372c2d582SAndrew Morgan #include <linux/security.h>
341da177e4SLinus Torvalds #include <linux/ctype.h>
35fd4b616bSSteven Rostedt #include <linux/kmemleak.h>
3662239ac2SAdrian Bunk #include <linux/fs.h>
371da177e4SLinus Torvalds #include <linux/init.h>
381da177e4SLinus Torvalds #include <linux/kernel.h>
390296b228SKay Sievers #include <linux/kobject.h>
4020380731SArnaldo Carvalho de Melo #include <linux/net.h>
411da177e4SLinus Torvalds #include <linux/sysrq.h>
421da177e4SLinus Torvalds #include <linux/highuid.h>
431da177e4SLinus Torvalds #include <linux/writeback.h>
443fff4c42SIngo Molnar #include <linux/ratelimit.h>
4576ab0f53SMel Gorman #include <linux/compaction.h>
461da177e4SLinus Torvalds #include <linux/hugetlb.h>
471da177e4SLinus Torvalds #include <linux/initrd.h>
480b77f5bfSDavid Howells #include <linux/key.h>
491da177e4SLinus Torvalds #include <linux/times.h>
501da177e4SLinus Torvalds #include <linux/limits.h>
511da177e4SLinus Torvalds #include <linux/dcache.h>
526e006701SAlexey Dobriyan #include <linux/dnotify.h>
531da177e4SLinus Torvalds #include <linux/syscalls.h>
54c748e134SAdrian Bunk #include <linux/vmstat.h>
55c255d844SPavel Machek #include <linux/nfs_fs.h>
56c255d844SPavel Machek #include <linux/acpi.h>
5710a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h>
58b0fc494fSSteven Rostedt #include <linux/ftrace.h>
59cdd6c482SIngo Molnar #include <linux/perf_event.h>
60b2be84dfSMasami Hiramatsu #include <linux/kprobes.h>
61b492e95bSJens Axboe #include <linux/pipe_fs_i.h>
628e4228e1SDavid Rientjes #include <linux/oom.h>
6317f60a7dSEric Paris #include <linux/kmod.h>
6473efc039SDan Ballard #include <linux/capability.h>
6540401530SAl Viro #include <linux/binfmts.h>
66cf4aebc2SClark Williams #include <linux/sched/sysctl.h>
67f7ccbae4SIngo Molnar #include <linux/sched/coredump.h>
687984754bSKees Cook #include <linux/kexec.h>
691be7f75dSAlexei Starovoitov #include <linux/bpf.h>
70d2921684SEric W. Biederman #include <linux/mount.h>
71cefdca0aSPeter Xu #include <linux/userfaultfd_k.h>
722374c09bSChristoph Hellwig #include <linux/coredump.h>
732374c09bSChristoph Hellwig #include <linux/latencytop.h>
742374c09bSChristoph Hellwig #include <linux/pid.h>
750cd7c741SPeter Zijlstra #include <linux/delayacct.h>
761da177e4SLinus Torvalds 
777f2923c4SChristian Brauner #include "../lib/kstrtox.h"
787f2923c4SChristian Brauner 
797c0f6ba6SLinus Torvalds #include <linux/uaccess.h>
801da177e4SLinus Torvalds #include <asm/processor.h>
811da177e4SLinus Torvalds 
8229cbc78bSAndi Kleen #ifdef CONFIG_X86
8329cbc78bSAndi Kleen #include <asm/nmi.h>
840741f4d2SChuck Ebbert #include <asm/stacktrace.h>
856e7c4025SIngo Molnar #include <asm/io.h>
8629cbc78bSAndi Kleen #endif
87d550bbd4SDavid Howells #ifdef CONFIG_SPARC
88d550bbd4SDavid Howells #include <asm/setup.h>
89d550bbd4SDavid Howells #endif
90c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT
91c55b7c3eSDave Young #include <linux/acct.h>
92c55b7c3eSDave Young #endif
934f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES
944f0e056fSDave Young #include <linux/rtmutex.h>
954f0e056fSDave Young #endif
962edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
972edf5e49SDave Young #include <linux/lockdep.h>
982edf5e49SDave Young #endif
9915485a46SDave Young #ifdef CONFIG_CHR_DEV_SG
10015485a46SDave Young #include <scsi/sg.h>
10115485a46SDave Young #endif
102964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
103964c9dffSAlexander Popov #include <linux/stackleak.h>
104964c9dffSAlexander Popov #endif
10558687acbSDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR
106504d7cf1SDon Zickus #include <linux/nmi.h>
107504d7cf1SDon Zickus #endif
108504d7cf1SDon Zickus 
1091da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL)
1101da177e4SLinus Torvalds 
111c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and  maximum */
1122508ce18SDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR
113c4f3b63fSRavikiran G Thirumalai static int sixty = 60;
114c4f3b63fSRavikiran G Thirumalai #endif
115c4f3b63fSRavikiran G Thirumalai 
116270750dbSAaron Tomlin static int __maybe_unused neg_one = -1;
117cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2;
1185509a5d2SDave Hansen static int __maybe_unused four = 4;
1199002b214SWill Deacon static unsigned long zero_ul;
120fc3501d4SSven Wegener static unsigned long one_ul = 1;
12132a5ad9cSChristian Brauner static unsigned long long_max = LONG_MAX;
122c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100;
123c843966cSJohannes Weiner static int two_hundred = 200;
124795ae7a0SJohannes Weiner static int one_thousand = 1000;
125af91322eSDave Young #ifdef CONFIG_PRINTK
126af91322eSDave Young static int ten_thousand = 10000;
127af91322eSDave Young #endif
128c5dfd78eSArnaldo Carvalho de Melo #ifdef CONFIG_PERF_EVENTS
129c5dfd78eSArnaldo Carvalho de Melo static int six_hundred_forty_kb = 640 * 1024;
130c5dfd78eSArnaldo Carvalho de Melo #endif
131c4f3b63fSRavikiran G Thirumalai 
1329e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
1339e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1349e4a5bdaSAndrea Righi 
1351da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1361da177e4SLinus Torvalds static int maxolduid = 65535;
1371da177e4SLinus Torvalds static int minolduid;
1381da177e4SLinus Torvalds 
1391da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
14073efc039SDan Ballard static const int cap_last_cap = CAP_LAST_CAP;
1411da177e4SLinus Torvalds 
142a2e51445SDmitry Vyukov /*
143a2e51445SDmitry Vyukov  * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
144a2e51445SDmitry Vyukov  * and hung_task_check_interval_secs
145a2e51445SDmitry Vyukov  */
14680df2847SLiu Hua #ifdef CONFIG_DETECT_HUNG_TASK
14780df2847SLiu Hua static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
14880df2847SLiu Hua #endif
14980df2847SLiu Hua 
150d14f1729SDave Young #ifdef CONFIG_INOTIFY_USER
151d14f1729SDave Young #include <linux/inotify.h>
152d14f1729SDave Young #endif
1535b8fea65SAmir Goldstein #ifdef CONFIG_FANOTIFY
1545b8fea65SAmir Goldstein #include <linux/fanotify.h>
1555b8fea65SAmir Goldstein #endif
156b6fca725SVineet Gupta 
157d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
158f4aacea2SKees Cook 
159a19ac337SLuis R. Rodriguez /**
160a19ac337SLuis R. Rodriguez  * enum sysctl_writes_mode - supported sysctl write modes
161a19ac337SLuis R. Rodriguez  *
162a19ac337SLuis R. Rodriguez  * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
163a19ac337SLuis R. Rodriguez  *	to be written, and multiple writes on the same sysctl file descriptor
164a19ac337SLuis R. Rodriguez  *	will rewrite the sysctl value, regardless of file position. No warning
165a19ac337SLuis R. Rodriguez  *	is issued when the initial position is not 0.
166a19ac337SLuis R. Rodriguez  * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
167a19ac337SLuis R. Rodriguez  *	not 0.
168a19ac337SLuis R. Rodriguez  * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
169a19ac337SLuis R. Rodriguez  *	file position 0 and the value must be fully contained in the buffer
170a19ac337SLuis R. Rodriguez  *	sent to the write syscall. If dealing with strings respect the file
171a19ac337SLuis R. Rodriguez  *	position, but restrict this to the max length of the buffer, anything
17265f50f25SWeitao Hou  *	passed the max length will be ignored. Multiple writes will append
173a19ac337SLuis R. Rodriguez  *	to the buffer.
174a19ac337SLuis R. Rodriguez  *
175a19ac337SLuis R. Rodriguez  * These write modes control how current file position affects the behavior of
176a19ac337SLuis R. Rodriguez  * updating sysctl values through the proc interface on each write.
177a19ac337SLuis R. Rodriguez  */
178a19ac337SLuis R. Rodriguez enum sysctl_writes_mode {
179a19ac337SLuis R. Rodriguez 	SYSCTL_WRITES_LEGACY		= -1,
180a19ac337SLuis R. Rodriguez 	SYSCTL_WRITES_WARN		= 0,
181a19ac337SLuis R. Rodriguez 	SYSCTL_WRITES_STRICT		= 1,
182a19ac337SLuis R. Rodriguez };
183f4aacea2SKees Cook 
184a19ac337SLuis R. Rodriguez static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
185f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */
186ceb18132SLuis R. Rodriguez 
18767f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
18867f3977fSAlexandre Ghiti     defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
1891da177e4SLinus Torvalds int sysctl_legacy_va_layout;
1901da177e4SLinus Torvalds #endif
1911da177e4SLinus Torvalds 
1925e771905SMel Gorman #ifdef CONFIG_COMPACTION
1935e771905SMel Gorman static int min_extfrag_threshold;
1945e771905SMel Gorman static int max_extfrag_threshold = 1000;
1955e771905SMel Gorman #endif
1965e771905SMel Gorman 
197f461d2dcSChristoph Hellwig #endif /* CONFIG_SYSCTL */
198f461d2dcSChristoph Hellwig 
1995447e8e0SArnd Bergmann #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
200d46edd67SSong Liu static int bpf_stats_handler(struct ctl_table *table, int write,
2017787b6fcSTobias Klauser 			     void *buffer, size_t *lenp, loff_t *ppos)
202d46edd67SSong Liu {
203d46edd67SSong Liu 	struct static_key *key = (struct static_key *)table->data;
204d46edd67SSong Liu 	static int saved_val;
205d46edd67SSong Liu 	int val, ret;
206d46edd67SSong Liu 	struct ctl_table tmp = {
207d46edd67SSong Liu 		.data   = &val,
208d46edd67SSong Liu 		.maxlen = sizeof(val),
209d46edd67SSong Liu 		.mode   = table->mode,
210d46edd67SSong Liu 		.extra1 = SYSCTL_ZERO,
211d46edd67SSong Liu 		.extra2 = SYSCTL_ONE,
212d46edd67SSong Liu 	};
213d46edd67SSong Liu 
214d46edd67SSong Liu 	if (write && !capable(CAP_SYS_ADMIN))
215d46edd67SSong Liu 		return -EPERM;
216d46edd67SSong Liu 
217d46edd67SSong Liu 	mutex_lock(&bpf_stats_enabled_mutex);
218d46edd67SSong Liu 	val = saved_val;
219d46edd67SSong Liu 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
220d46edd67SSong Liu 	if (write && !ret && val != saved_val) {
221d46edd67SSong Liu 		if (val)
222d46edd67SSong Liu 			static_key_slow_inc(key);
223d46edd67SSong Liu 		else
224d46edd67SSong Liu 			static_key_slow_dec(key);
225d46edd67SSong Liu 		saved_val = val;
226d46edd67SSong Liu 	}
227d46edd67SSong Liu 	mutex_unlock(&bpf_stats_enabled_mutex);
228d46edd67SSong Liu 	return ret;
229d46edd67SSong Liu }
23008389d88SDaniel Borkmann 
23108389d88SDaniel Borkmann static int bpf_unpriv_handler(struct ctl_table *table, int write,
23208389d88SDaniel Borkmann 			      void *buffer, size_t *lenp, loff_t *ppos)
23308389d88SDaniel Borkmann {
23408389d88SDaniel Borkmann 	int ret, unpriv_enable = *(int *)table->data;
23508389d88SDaniel Borkmann 	bool locked_state = unpriv_enable == 1;
23608389d88SDaniel Borkmann 	struct ctl_table tmp = *table;
23708389d88SDaniel Borkmann 
23808389d88SDaniel Borkmann 	if (write && !capable(CAP_SYS_ADMIN))
23908389d88SDaniel Borkmann 		return -EPERM;
24008389d88SDaniel Borkmann 
24108389d88SDaniel Borkmann 	tmp.data = &unpriv_enable;
24208389d88SDaniel Borkmann 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
24308389d88SDaniel Borkmann 	if (write && !ret) {
24408389d88SDaniel Borkmann 		if (locked_state && unpriv_enable != 1)
24508389d88SDaniel Borkmann 			return -EPERM;
24608389d88SDaniel Borkmann 		*(int *)table->data = unpriv_enable;
24708389d88SDaniel Borkmann 	}
24808389d88SDaniel Borkmann 	return ret;
24908389d88SDaniel Borkmann }
25008389d88SDaniel Borkmann #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */
251d46edd67SSong Liu 
252f461d2dcSChristoph Hellwig /*
253f461d2dcSChristoph Hellwig  * /proc/sys support
254f461d2dcSChristoph Hellwig  */
255f461d2dcSChristoph Hellwig 
256f461d2dcSChristoph Hellwig #ifdef CONFIG_PROC_SYSCTL
257f461d2dcSChristoph Hellwig 
258f461d2dcSChristoph Hellwig static int _proc_do_string(char *data, int maxlen, int write,
25932927393SChristoph Hellwig 		char *buffer, size_t *lenp, loff_t *ppos)
260f461d2dcSChristoph Hellwig {
261f461d2dcSChristoph Hellwig 	size_t len;
26232927393SChristoph Hellwig 	char c, *p;
263f461d2dcSChristoph Hellwig 
264f461d2dcSChristoph Hellwig 	if (!data || !maxlen || !*lenp) {
265f461d2dcSChristoph Hellwig 		*lenp = 0;
266f461d2dcSChristoph Hellwig 		return 0;
267f461d2dcSChristoph Hellwig 	}
268f461d2dcSChristoph Hellwig 
269f461d2dcSChristoph Hellwig 	if (write) {
270f461d2dcSChristoph Hellwig 		if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
271f461d2dcSChristoph Hellwig 			/* Only continue writes not past the end of buffer. */
272f461d2dcSChristoph Hellwig 			len = strlen(data);
273f461d2dcSChristoph Hellwig 			if (len > maxlen - 1)
274f461d2dcSChristoph Hellwig 				len = maxlen - 1;
275f461d2dcSChristoph Hellwig 
276f461d2dcSChristoph Hellwig 			if (*ppos > len)
277f461d2dcSChristoph Hellwig 				return 0;
278f461d2dcSChristoph Hellwig 			len = *ppos;
279f461d2dcSChristoph Hellwig 		} else {
280f461d2dcSChristoph Hellwig 			/* Start writing from beginning of buffer. */
281f461d2dcSChristoph Hellwig 			len = 0;
282f461d2dcSChristoph Hellwig 		}
283f461d2dcSChristoph Hellwig 
284f461d2dcSChristoph Hellwig 		*ppos += *lenp;
285f461d2dcSChristoph Hellwig 		p = buffer;
286f461d2dcSChristoph Hellwig 		while ((p - buffer) < *lenp && len < maxlen - 1) {
28732927393SChristoph Hellwig 			c = *(p++);
288f461d2dcSChristoph Hellwig 			if (c == 0 || c == '\n')
289f461d2dcSChristoph Hellwig 				break;
290f461d2dcSChristoph Hellwig 			data[len++] = c;
291f461d2dcSChristoph Hellwig 		}
292f461d2dcSChristoph Hellwig 		data[len] = 0;
293f461d2dcSChristoph Hellwig 	} else {
294f461d2dcSChristoph Hellwig 		len = strlen(data);
295f461d2dcSChristoph Hellwig 		if (len > maxlen)
296f461d2dcSChristoph Hellwig 			len = maxlen;
297f461d2dcSChristoph Hellwig 
298f461d2dcSChristoph Hellwig 		if (*ppos > len) {
299f461d2dcSChristoph Hellwig 			*lenp = 0;
300f461d2dcSChristoph Hellwig 			return 0;
301f461d2dcSChristoph Hellwig 		}
302f461d2dcSChristoph Hellwig 
303f461d2dcSChristoph Hellwig 		data += *ppos;
304f461d2dcSChristoph Hellwig 		len  -= *ppos;
305f461d2dcSChristoph Hellwig 
306f461d2dcSChristoph Hellwig 		if (len > *lenp)
307f461d2dcSChristoph Hellwig 			len = *lenp;
308f461d2dcSChristoph Hellwig 		if (len)
30932927393SChristoph Hellwig 			memcpy(buffer, data, len);
310f461d2dcSChristoph Hellwig 		if (len < *lenp) {
31132927393SChristoph Hellwig 			buffer[len] = '\n';
312f461d2dcSChristoph Hellwig 			len++;
313f461d2dcSChristoph Hellwig 		}
314f461d2dcSChristoph Hellwig 		*lenp = len;
315f461d2dcSChristoph Hellwig 		*ppos += len;
316f461d2dcSChristoph Hellwig 	}
317f461d2dcSChristoph Hellwig 	return 0;
318f461d2dcSChristoph Hellwig }
319f461d2dcSChristoph Hellwig 
320f461d2dcSChristoph Hellwig static void warn_sysctl_write(struct ctl_table *table)
321f461d2dcSChristoph Hellwig {
322f461d2dcSChristoph Hellwig 	pr_warn_once("%s wrote to %s when file position was not 0!\n"
323f461d2dcSChristoph Hellwig 		"This will not be supported in the future. To silence this\n"
324f461d2dcSChristoph Hellwig 		"warning, set kernel.sysctl_writes_strict = -1\n",
325f461d2dcSChristoph Hellwig 		current->comm, table->procname);
326f461d2dcSChristoph Hellwig }
327f461d2dcSChristoph Hellwig 
328f461d2dcSChristoph Hellwig /**
329f461d2dcSChristoph Hellwig  * proc_first_pos_non_zero_ignore - check if first position is allowed
330f461d2dcSChristoph Hellwig  * @ppos: file position
331f461d2dcSChristoph Hellwig  * @table: the sysctl table
332f461d2dcSChristoph Hellwig  *
333f461d2dcSChristoph Hellwig  * Returns true if the first position is non-zero and the sysctl_writes_strict
334f461d2dcSChristoph Hellwig  * mode indicates this is not allowed for numeric input types. String proc
335f461d2dcSChristoph Hellwig  * handlers can ignore the return value.
336f461d2dcSChristoph Hellwig  */
337f461d2dcSChristoph Hellwig static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
338f461d2dcSChristoph Hellwig 					   struct ctl_table *table)
339f461d2dcSChristoph Hellwig {
340f461d2dcSChristoph Hellwig 	if (!*ppos)
341f461d2dcSChristoph Hellwig 		return false;
342f461d2dcSChristoph Hellwig 
343f461d2dcSChristoph Hellwig 	switch (sysctl_writes_strict) {
344f461d2dcSChristoph Hellwig 	case SYSCTL_WRITES_STRICT:
345f461d2dcSChristoph Hellwig 		return true;
346f461d2dcSChristoph Hellwig 	case SYSCTL_WRITES_WARN:
347f461d2dcSChristoph Hellwig 		warn_sysctl_write(table);
348f461d2dcSChristoph Hellwig 		return false;
349f461d2dcSChristoph Hellwig 	default:
350f461d2dcSChristoph Hellwig 		return false;
351f461d2dcSChristoph Hellwig 	}
352f461d2dcSChristoph Hellwig }
353f461d2dcSChristoph Hellwig 
354f461d2dcSChristoph Hellwig /**
355f461d2dcSChristoph Hellwig  * proc_dostring - read a string sysctl
356f461d2dcSChristoph Hellwig  * @table: the sysctl table
357f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
358f461d2dcSChristoph Hellwig  * @buffer: the user buffer
359f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
360f461d2dcSChristoph Hellwig  * @ppos: file position
361f461d2dcSChristoph Hellwig  *
362f461d2dcSChristoph Hellwig  * Reads/writes a string from/to the user buffer. If the kernel
363f461d2dcSChristoph Hellwig  * buffer provided is not large enough to hold the string, the
364f461d2dcSChristoph Hellwig  * string is truncated. The copied string is %NULL-terminated.
365f461d2dcSChristoph Hellwig  * If the string is being read by the user process, it is copied
366f461d2dcSChristoph Hellwig  * and a newline '\n' is added. It is truncated if the buffer is
367f461d2dcSChristoph Hellwig  * not large enough.
368f461d2dcSChristoph Hellwig  *
369f461d2dcSChristoph Hellwig  * Returns 0 on success.
370f461d2dcSChristoph Hellwig  */
371f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write,
37232927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
373f461d2dcSChristoph Hellwig {
374f461d2dcSChristoph Hellwig 	if (write)
375f461d2dcSChristoph Hellwig 		proc_first_pos_non_zero_ignore(ppos, table);
376f461d2dcSChristoph Hellwig 
37732927393SChristoph Hellwig 	return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
37832927393SChristoph Hellwig 			ppos);
379f461d2dcSChristoph Hellwig }
380f461d2dcSChristoph Hellwig 
381f461d2dcSChristoph Hellwig static size_t proc_skip_spaces(char **buf)
382f461d2dcSChristoph Hellwig {
383f461d2dcSChristoph Hellwig 	size_t ret;
384f461d2dcSChristoph Hellwig 	char *tmp = skip_spaces(*buf);
385f461d2dcSChristoph Hellwig 	ret = tmp - *buf;
386f461d2dcSChristoph Hellwig 	*buf = tmp;
387f461d2dcSChristoph Hellwig 	return ret;
388f461d2dcSChristoph Hellwig }
389f461d2dcSChristoph Hellwig 
390f461d2dcSChristoph Hellwig static void proc_skip_char(char **buf, size_t *size, const char v)
391f461d2dcSChristoph Hellwig {
392f461d2dcSChristoph Hellwig 	while (*size) {
393f461d2dcSChristoph Hellwig 		if (**buf != v)
394f461d2dcSChristoph Hellwig 			break;
395f461d2dcSChristoph Hellwig 		(*size)--;
396f461d2dcSChristoph Hellwig 		(*buf)++;
397f461d2dcSChristoph Hellwig 	}
398f461d2dcSChristoph Hellwig }
399f461d2dcSChristoph Hellwig 
400f461d2dcSChristoph Hellwig /**
401f461d2dcSChristoph Hellwig  * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
402f461d2dcSChristoph Hellwig  *                   fail on overflow
403f461d2dcSChristoph Hellwig  *
404f461d2dcSChristoph Hellwig  * @cp: kernel buffer containing the string to parse
405f461d2dcSChristoph Hellwig  * @endp: pointer to store the trailing characters
406f461d2dcSChristoph Hellwig  * @base: the base to use
407f461d2dcSChristoph Hellwig  * @res: where the parsed integer will be stored
408f461d2dcSChristoph Hellwig  *
409f461d2dcSChristoph Hellwig  * In case of success 0 is returned and @res will contain the parsed integer,
410f461d2dcSChristoph Hellwig  * @endp will hold any trailing characters.
411f461d2dcSChristoph Hellwig  * This function will fail the parse on overflow. If there wasn't an overflow
412f461d2dcSChristoph Hellwig  * the function will defer the decision what characters count as invalid to the
413f461d2dcSChristoph Hellwig  * caller.
414f461d2dcSChristoph Hellwig  */
415f461d2dcSChristoph Hellwig static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
416f461d2dcSChristoph Hellwig 			   unsigned long *res)
417f461d2dcSChristoph Hellwig {
418f461d2dcSChristoph Hellwig 	unsigned long long result;
419f461d2dcSChristoph Hellwig 	unsigned int rv;
420f461d2dcSChristoph Hellwig 
421f461d2dcSChristoph Hellwig 	cp = _parse_integer_fixup_radix(cp, &base);
422f461d2dcSChristoph Hellwig 	rv = _parse_integer(cp, base, &result);
423f461d2dcSChristoph Hellwig 	if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
424f461d2dcSChristoph Hellwig 		return -ERANGE;
425f461d2dcSChristoph Hellwig 
426f461d2dcSChristoph Hellwig 	cp += rv;
427f461d2dcSChristoph Hellwig 
428f461d2dcSChristoph Hellwig 	if (endp)
429f461d2dcSChristoph Hellwig 		*endp = (char *)cp;
430f461d2dcSChristoph Hellwig 
431f461d2dcSChristoph Hellwig 	*res = (unsigned long)result;
432f461d2dcSChristoph Hellwig 	return 0;
433f461d2dcSChristoph Hellwig }
434f461d2dcSChristoph Hellwig 
435f461d2dcSChristoph Hellwig #define TMPBUFLEN 22
436f461d2dcSChristoph Hellwig /**
437f461d2dcSChristoph Hellwig  * proc_get_long - reads an ASCII formatted integer from a user buffer
438f461d2dcSChristoph Hellwig  *
439f461d2dcSChristoph Hellwig  * @buf: a kernel buffer
440f461d2dcSChristoph Hellwig  * @size: size of the kernel buffer
441f461d2dcSChristoph Hellwig  * @val: this is where the number will be stored
442f461d2dcSChristoph Hellwig  * @neg: set to %TRUE if number is negative
443f461d2dcSChristoph Hellwig  * @perm_tr: a vector which contains the allowed trailers
444f461d2dcSChristoph Hellwig  * @perm_tr_len: size of the perm_tr vector
445f461d2dcSChristoph Hellwig  * @tr: pointer to store the trailer character
446f461d2dcSChristoph Hellwig  *
447f461d2dcSChristoph Hellwig  * In case of success %0 is returned and @buf and @size are updated with
448f461d2dcSChristoph Hellwig  * the amount of bytes read. If @tr is non-NULL and a trailing
449f461d2dcSChristoph Hellwig  * character exists (size is non-zero after returning from this
450f461d2dcSChristoph Hellwig  * function), @tr is updated with the trailing character.
451f461d2dcSChristoph Hellwig  */
452f461d2dcSChristoph Hellwig static int proc_get_long(char **buf, size_t *size,
453f461d2dcSChristoph Hellwig 			  unsigned long *val, bool *neg,
454f461d2dcSChristoph Hellwig 			  const char *perm_tr, unsigned perm_tr_len, char *tr)
455f461d2dcSChristoph Hellwig {
456f461d2dcSChristoph Hellwig 	int len;
457f461d2dcSChristoph Hellwig 	char *p, tmp[TMPBUFLEN];
458f461d2dcSChristoph Hellwig 
459f461d2dcSChristoph Hellwig 	if (!*size)
460f461d2dcSChristoph Hellwig 		return -EINVAL;
461f461d2dcSChristoph Hellwig 
462f461d2dcSChristoph Hellwig 	len = *size;
463f461d2dcSChristoph Hellwig 	if (len > TMPBUFLEN - 1)
464f461d2dcSChristoph Hellwig 		len = TMPBUFLEN - 1;
465f461d2dcSChristoph Hellwig 
466f461d2dcSChristoph Hellwig 	memcpy(tmp, *buf, len);
467f461d2dcSChristoph Hellwig 
468f461d2dcSChristoph Hellwig 	tmp[len] = 0;
469f461d2dcSChristoph Hellwig 	p = tmp;
470f461d2dcSChristoph Hellwig 	if (*p == '-' && *size > 1) {
471f461d2dcSChristoph Hellwig 		*neg = true;
472f461d2dcSChristoph Hellwig 		p++;
473f461d2dcSChristoph Hellwig 	} else
474f461d2dcSChristoph Hellwig 		*neg = false;
475f461d2dcSChristoph Hellwig 	if (!isdigit(*p))
476f461d2dcSChristoph Hellwig 		return -EINVAL;
477f461d2dcSChristoph Hellwig 
478f461d2dcSChristoph Hellwig 	if (strtoul_lenient(p, &p, 0, val))
479f461d2dcSChristoph Hellwig 		return -EINVAL;
480f461d2dcSChristoph Hellwig 
481f461d2dcSChristoph Hellwig 	len = p - tmp;
482f461d2dcSChristoph Hellwig 
483f461d2dcSChristoph Hellwig 	/* We don't know if the next char is whitespace thus we may accept
484f461d2dcSChristoph Hellwig 	 * invalid integers (e.g. 1234...a) or two integers instead of one
485f461d2dcSChristoph Hellwig 	 * (e.g. 123...1). So lets not allow such large numbers. */
486f461d2dcSChristoph Hellwig 	if (len == TMPBUFLEN - 1)
487f461d2dcSChristoph Hellwig 		return -EINVAL;
488f461d2dcSChristoph Hellwig 
489f461d2dcSChristoph Hellwig 	if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
490f461d2dcSChristoph Hellwig 		return -EINVAL;
491f461d2dcSChristoph Hellwig 
492f461d2dcSChristoph Hellwig 	if (tr && (len < *size))
493f461d2dcSChristoph Hellwig 		*tr = *p;
494f461d2dcSChristoph Hellwig 
495f461d2dcSChristoph Hellwig 	*buf += len;
496f461d2dcSChristoph Hellwig 	*size -= len;
497f461d2dcSChristoph Hellwig 
498f461d2dcSChristoph Hellwig 	return 0;
499f461d2dcSChristoph Hellwig }
500f461d2dcSChristoph Hellwig 
501f461d2dcSChristoph Hellwig /**
502f461d2dcSChristoph Hellwig  * proc_put_long - converts an integer to a decimal ASCII formatted string
503f461d2dcSChristoph Hellwig  *
504f461d2dcSChristoph Hellwig  * @buf: the user buffer
505f461d2dcSChristoph Hellwig  * @size: the size of the user buffer
506f461d2dcSChristoph Hellwig  * @val: the integer to be converted
507f461d2dcSChristoph Hellwig  * @neg: sign of the number, %TRUE for negative
508f461d2dcSChristoph Hellwig  *
50932927393SChristoph Hellwig  * In case of success @buf and @size are updated with the amount of bytes
51032927393SChristoph Hellwig  * written.
511f461d2dcSChristoph Hellwig  */
51232927393SChristoph Hellwig static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
513f461d2dcSChristoph Hellwig {
514f461d2dcSChristoph Hellwig 	int len;
515f461d2dcSChristoph Hellwig 	char tmp[TMPBUFLEN], *p = tmp;
516f461d2dcSChristoph Hellwig 
517f461d2dcSChristoph Hellwig 	sprintf(p, "%s%lu", neg ? "-" : "", val);
518f461d2dcSChristoph Hellwig 	len = strlen(tmp);
519f461d2dcSChristoph Hellwig 	if (len > *size)
520f461d2dcSChristoph Hellwig 		len = *size;
52132927393SChristoph Hellwig 	memcpy(*buf, tmp, len);
522f461d2dcSChristoph Hellwig 	*size -= len;
523f461d2dcSChristoph Hellwig 	*buf += len;
524f461d2dcSChristoph Hellwig }
525f461d2dcSChristoph Hellwig #undef TMPBUFLEN
526f461d2dcSChristoph Hellwig 
52732927393SChristoph Hellwig static void proc_put_char(void **buf, size_t *size, char c)
528f461d2dcSChristoph Hellwig {
529f461d2dcSChristoph Hellwig 	if (*size) {
53032927393SChristoph Hellwig 		char **buffer = (char **)buf;
53132927393SChristoph Hellwig 		**buffer = c;
53232927393SChristoph Hellwig 
53332927393SChristoph Hellwig 		(*size)--;
53432927393SChristoph Hellwig 		(*buffer)++;
535f461d2dcSChristoph Hellwig 		*buf = *buffer;
536f461d2dcSChristoph Hellwig 	}
537f461d2dcSChristoph Hellwig }
538f461d2dcSChristoph Hellwig 
539*a2071573SJia He static int do_proc_dobool_conv(bool *negp, unsigned long *lvalp,
540*a2071573SJia He 				int *valp,
541*a2071573SJia He 				int write, void *data)
542*a2071573SJia He {
543*a2071573SJia He 	if (write) {
544*a2071573SJia He 		*(bool *)valp = *lvalp;
545*a2071573SJia He 	} else {
546*a2071573SJia He 		int val = *(bool *)valp;
547*a2071573SJia He 
548*a2071573SJia He 		*lvalp = (unsigned long)val;
549*a2071573SJia He 		*negp = false;
550*a2071573SJia He 	}
551*a2071573SJia He 	return 0;
552*a2071573SJia He }
553*a2071573SJia He 
554f461d2dcSChristoph Hellwig static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
555f461d2dcSChristoph Hellwig 				 int *valp,
556f461d2dcSChristoph Hellwig 				 int write, void *data)
557f461d2dcSChristoph Hellwig {
558f461d2dcSChristoph Hellwig 	if (write) {
559f461d2dcSChristoph Hellwig 		if (*negp) {
560f461d2dcSChristoph Hellwig 			if (*lvalp > (unsigned long) INT_MAX + 1)
561f461d2dcSChristoph Hellwig 				return -EINVAL;
562f461d2dcSChristoph Hellwig 			*valp = -*lvalp;
563f461d2dcSChristoph Hellwig 		} else {
564f461d2dcSChristoph Hellwig 			if (*lvalp > (unsigned long) INT_MAX)
565f461d2dcSChristoph Hellwig 				return -EINVAL;
566f461d2dcSChristoph Hellwig 			*valp = *lvalp;
567f461d2dcSChristoph Hellwig 		}
568f461d2dcSChristoph Hellwig 	} else {
569f461d2dcSChristoph Hellwig 		int val = *valp;
570f461d2dcSChristoph Hellwig 		if (val < 0) {
571f461d2dcSChristoph Hellwig 			*negp = true;
572f461d2dcSChristoph Hellwig 			*lvalp = -(unsigned long)val;
573f461d2dcSChristoph Hellwig 		} else {
574f461d2dcSChristoph Hellwig 			*negp = false;
575f461d2dcSChristoph Hellwig 			*lvalp = (unsigned long)val;
576f461d2dcSChristoph Hellwig 		}
577f461d2dcSChristoph Hellwig 	}
578f461d2dcSChristoph Hellwig 	return 0;
579f461d2dcSChristoph Hellwig }
580f461d2dcSChristoph Hellwig 
581f461d2dcSChristoph Hellwig static int do_proc_douintvec_conv(unsigned long *lvalp,
582f461d2dcSChristoph Hellwig 				  unsigned int *valp,
583f461d2dcSChristoph Hellwig 				  int write, void *data)
584f461d2dcSChristoph Hellwig {
585f461d2dcSChristoph Hellwig 	if (write) {
586f461d2dcSChristoph Hellwig 		if (*lvalp > UINT_MAX)
587f461d2dcSChristoph Hellwig 			return -EINVAL;
588f461d2dcSChristoph Hellwig 		*valp = *lvalp;
589f461d2dcSChristoph Hellwig 	} else {
590f461d2dcSChristoph Hellwig 		unsigned int val = *valp;
591f461d2dcSChristoph Hellwig 		*lvalp = (unsigned long)val;
592f461d2dcSChristoph Hellwig 	}
593f461d2dcSChristoph Hellwig 	return 0;
594f461d2dcSChristoph Hellwig }
595f461d2dcSChristoph Hellwig 
596f461d2dcSChristoph Hellwig static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
597f461d2dcSChristoph Hellwig 
598f461d2dcSChristoph Hellwig static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
59932927393SChristoph Hellwig 		  int write, void *buffer,
600f461d2dcSChristoph Hellwig 		  size_t *lenp, loff_t *ppos,
601f461d2dcSChristoph Hellwig 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
602f461d2dcSChristoph Hellwig 			      int write, void *data),
603f461d2dcSChristoph Hellwig 		  void *data)
604f461d2dcSChristoph Hellwig {
605f461d2dcSChristoph Hellwig 	int *i, vleft, first = 1, err = 0;
606f461d2dcSChristoph Hellwig 	size_t left;
60732927393SChristoph Hellwig 	char *p;
608f461d2dcSChristoph Hellwig 
609f461d2dcSChristoph Hellwig 	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
610f461d2dcSChristoph Hellwig 		*lenp = 0;
611f461d2dcSChristoph Hellwig 		return 0;
612f461d2dcSChristoph Hellwig 	}
613f461d2dcSChristoph Hellwig 
614f461d2dcSChristoph Hellwig 	i = (int *) tbl_data;
615f461d2dcSChristoph Hellwig 	vleft = table->maxlen / sizeof(*i);
616f461d2dcSChristoph Hellwig 	left = *lenp;
617f461d2dcSChristoph Hellwig 
618f461d2dcSChristoph Hellwig 	if (!conv)
619f461d2dcSChristoph Hellwig 		conv = do_proc_dointvec_conv;
620f461d2dcSChristoph Hellwig 
621f461d2dcSChristoph Hellwig 	if (write) {
622f461d2dcSChristoph Hellwig 		if (proc_first_pos_non_zero_ignore(ppos, table))
623f461d2dcSChristoph Hellwig 			goto out;
624f461d2dcSChristoph Hellwig 
625f461d2dcSChristoph Hellwig 		if (left > PAGE_SIZE - 1)
626f461d2dcSChristoph Hellwig 			left = PAGE_SIZE - 1;
62732927393SChristoph Hellwig 		p = buffer;
628f461d2dcSChristoph Hellwig 	}
629f461d2dcSChristoph Hellwig 
630f461d2dcSChristoph Hellwig 	for (; left && vleft--; i++, first=0) {
631f461d2dcSChristoph Hellwig 		unsigned long lval;
632f461d2dcSChristoph Hellwig 		bool neg;
633f461d2dcSChristoph Hellwig 
634f461d2dcSChristoph Hellwig 		if (write) {
635f461d2dcSChristoph Hellwig 			left -= proc_skip_spaces(&p);
636f461d2dcSChristoph Hellwig 
637f461d2dcSChristoph Hellwig 			if (!left)
638f461d2dcSChristoph Hellwig 				break;
639f461d2dcSChristoph Hellwig 			err = proc_get_long(&p, &left, &lval, &neg,
640f461d2dcSChristoph Hellwig 					     proc_wspace_sep,
641f461d2dcSChristoph Hellwig 					     sizeof(proc_wspace_sep), NULL);
642f461d2dcSChristoph Hellwig 			if (err)
643f461d2dcSChristoph Hellwig 				break;
644f461d2dcSChristoph Hellwig 			if (conv(&neg, &lval, i, 1, data)) {
645f461d2dcSChristoph Hellwig 				err = -EINVAL;
646f461d2dcSChristoph Hellwig 				break;
647f461d2dcSChristoph Hellwig 			}
648f461d2dcSChristoph Hellwig 		} else {
649f461d2dcSChristoph Hellwig 			if (conv(&neg, &lval, i, 0, data)) {
650f461d2dcSChristoph Hellwig 				err = -EINVAL;
651f461d2dcSChristoph Hellwig 				break;
652f461d2dcSChristoph Hellwig 			}
653f461d2dcSChristoph Hellwig 			if (!first)
65432927393SChristoph Hellwig 				proc_put_char(&buffer, &left, '\t');
65532927393SChristoph Hellwig 			proc_put_long(&buffer, &left, lval, neg);
656f461d2dcSChristoph Hellwig 		}
657f461d2dcSChristoph Hellwig 	}
658f461d2dcSChristoph Hellwig 
659f461d2dcSChristoph Hellwig 	if (!write && !first && left && !err)
66032927393SChristoph Hellwig 		proc_put_char(&buffer, &left, '\n');
661f461d2dcSChristoph Hellwig 	if (write && !err && left)
662f461d2dcSChristoph Hellwig 		left -= proc_skip_spaces(&p);
66332927393SChristoph Hellwig 	if (write && first)
664f461d2dcSChristoph Hellwig 		return err ? : -EINVAL;
665f461d2dcSChristoph Hellwig 	*lenp -= left;
666f461d2dcSChristoph Hellwig out:
667f461d2dcSChristoph Hellwig 	*ppos += *lenp;
668f461d2dcSChristoph Hellwig 	return err;
669f461d2dcSChristoph Hellwig }
670f461d2dcSChristoph Hellwig 
671f461d2dcSChristoph Hellwig static int do_proc_dointvec(struct ctl_table *table, int write,
67232927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos,
673f461d2dcSChristoph Hellwig 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
674f461d2dcSChristoph Hellwig 			      int write, void *data),
675f461d2dcSChristoph Hellwig 		  void *data)
676f461d2dcSChristoph Hellwig {
677f461d2dcSChristoph Hellwig 	return __do_proc_dointvec(table->data, table, write,
678f461d2dcSChristoph Hellwig 			buffer, lenp, ppos, conv, data);
679f461d2dcSChristoph Hellwig }
680f461d2dcSChristoph Hellwig 
681f461d2dcSChristoph Hellwig static int do_proc_douintvec_w(unsigned int *tbl_data,
682f461d2dcSChristoph Hellwig 			       struct ctl_table *table,
68332927393SChristoph Hellwig 			       void *buffer,
684f461d2dcSChristoph Hellwig 			       size_t *lenp, loff_t *ppos,
685f461d2dcSChristoph Hellwig 			       int (*conv)(unsigned long *lvalp,
686f461d2dcSChristoph Hellwig 					   unsigned int *valp,
687f461d2dcSChristoph Hellwig 					   int write, void *data),
688f461d2dcSChristoph Hellwig 			       void *data)
689f461d2dcSChristoph Hellwig {
690f461d2dcSChristoph Hellwig 	unsigned long lval;
691f461d2dcSChristoph Hellwig 	int err = 0;
692f461d2dcSChristoph Hellwig 	size_t left;
693f461d2dcSChristoph Hellwig 	bool neg;
69432927393SChristoph Hellwig 	char *p = buffer;
695f461d2dcSChristoph Hellwig 
696f461d2dcSChristoph Hellwig 	left = *lenp;
697f461d2dcSChristoph Hellwig 
698f461d2dcSChristoph Hellwig 	if (proc_first_pos_non_zero_ignore(ppos, table))
699f461d2dcSChristoph Hellwig 		goto bail_early;
700f461d2dcSChristoph Hellwig 
701f461d2dcSChristoph Hellwig 	if (left > PAGE_SIZE - 1)
702f461d2dcSChristoph Hellwig 		left = PAGE_SIZE - 1;
703f461d2dcSChristoph Hellwig 
704f461d2dcSChristoph Hellwig 	left -= proc_skip_spaces(&p);
705f461d2dcSChristoph Hellwig 	if (!left) {
706f461d2dcSChristoph Hellwig 		err = -EINVAL;
707f461d2dcSChristoph Hellwig 		goto out_free;
708f461d2dcSChristoph Hellwig 	}
709f461d2dcSChristoph Hellwig 
710f461d2dcSChristoph Hellwig 	err = proc_get_long(&p, &left, &lval, &neg,
711f461d2dcSChristoph Hellwig 			     proc_wspace_sep,
712f461d2dcSChristoph Hellwig 			     sizeof(proc_wspace_sep), NULL);
713f461d2dcSChristoph Hellwig 	if (err || neg) {
714f461d2dcSChristoph Hellwig 		err = -EINVAL;
715f461d2dcSChristoph Hellwig 		goto out_free;
716f461d2dcSChristoph Hellwig 	}
717f461d2dcSChristoph Hellwig 
718f461d2dcSChristoph Hellwig 	if (conv(&lval, tbl_data, 1, data)) {
719f461d2dcSChristoph Hellwig 		err = -EINVAL;
720f461d2dcSChristoph Hellwig 		goto out_free;
721f461d2dcSChristoph Hellwig 	}
722f461d2dcSChristoph Hellwig 
723f461d2dcSChristoph Hellwig 	if (!err && left)
724f461d2dcSChristoph Hellwig 		left -= proc_skip_spaces(&p);
725f461d2dcSChristoph Hellwig 
726f461d2dcSChristoph Hellwig out_free:
727f461d2dcSChristoph Hellwig 	if (err)
728f461d2dcSChristoph Hellwig 		return -EINVAL;
729f461d2dcSChristoph Hellwig 
730f461d2dcSChristoph Hellwig 	return 0;
731f461d2dcSChristoph Hellwig 
732f461d2dcSChristoph Hellwig 	/* This is in keeping with old __do_proc_dointvec() */
733f461d2dcSChristoph Hellwig bail_early:
734f461d2dcSChristoph Hellwig 	*ppos += *lenp;
735f461d2dcSChristoph Hellwig 	return err;
736f461d2dcSChristoph Hellwig }
737f461d2dcSChristoph Hellwig 
73832927393SChristoph Hellwig static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
739f461d2dcSChristoph Hellwig 			       size_t *lenp, loff_t *ppos,
740f461d2dcSChristoph Hellwig 			       int (*conv)(unsigned long *lvalp,
741f461d2dcSChristoph Hellwig 					   unsigned int *valp,
742f461d2dcSChristoph Hellwig 					   int write, void *data),
743f461d2dcSChristoph Hellwig 			       void *data)
744f461d2dcSChristoph Hellwig {
745f461d2dcSChristoph Hellwig 	unsigned long lval;
746f461d2dcSChristoph Hellwig 	int err = 0;
747f461d2dcSChristoph Hellwig 	size_t left;
748f461d2dcSChristoph Hellwig 
749f461d2dcSChristoph Hellwig 	left = *lenp;
750f461d2dcSChristoph Hellwig 
751f461d2dcSChristoph Hellwig 	if (conv(&lval, tbl_data, 0, data)) {
752f461d2dcSChristoph Hellwig 		err = -EINVAL;
753f461d2dcSChristoph Hellwig 		goto out;
754f461d2dcSChristoph Hellwig 	}
755f461d2dcSChristoph Hellwig 
75632927393SChristoph Hellwig 	proc_put_long(&buffer, &left, lval, false);
75732927393SChristoph Hellwig 	if (!left)
758f461d2dcSChristoph Hellwig 		goto out;
759f461d2dcSChristoph Hellwig 
76032927393SChristoph Hellwig 	proc_put_char(&buffer, &left, '\n');
761f461d2dcSChristoph Hellwig 
762f461d2dcSChristoph Hellwig out:
763f461d2dcSChristoph Hellwig 	*lenp -= left;
764f461d2dcSChristoph Hellwig 	*ppos += *lenp;
765f461d2dcSChristoph Hellwig 
766f461d2dcSChristoph Hellwig 	return err;
767f461d2dcSChristoph Hellwig }
768f461d2dcSChristoph Hellwig 
769f461d2dcSChristoph Hellwig static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
77032927393SChristoph Hellwig 			       int write, void *buffer,
771f461d2dcSChristoph Hellwig 			       size_t *lenp, loff_t *ppos,
772f461d2dcSChristoph Hellwig 			       int (*conv)(unsigned long *lvalp,
773f461d2dcSChristoph Hellwig 					   unsigned int *valp,
774f461d2dcSChristoph Hellwig 					   int write, void *data),
775f461d2dcSChristoph Hellwig 			       void *data)
776f461d2dcSChristoph Hellwig {
777f461d2dcSChristoph Hellwig 	unsigned int *i, vleft;
778f461d2dcSChristoph Hellwig 
779f461d2dcSChristoph Hellwig 	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
780f461d2dcSChristoph Hellwig 		*lenp = 0;
781f461d2dcSChristoph Hellwig 		return 0;
782f461d2dcSChristoph Hellwig 	}
783f461d2dcSChristoph Hellwig 
784f461d2dcSChristoph Hellwig 	i = (unsigned int *) tbl_data;
785f461d2dcSChristoph Hellwig 	vleft = table->maxlen / sizeof(*i);
786f461d2dcSChristoph Hellwig 
787f461d2dcSChristoph Hellwig 	/*
788f461d2dcSChristoph Hellwig 	 * Arrays are not supported, keep this simple. *Do not* add
789f461d2dcSChristoph Hellwig 	 * support for them.
790f461d2dcSChristoph Hellwig 	 */
791f461d2dcSChristoph Hellwig 	if (vleft != 1) {
792f461d2dcSChristoph Hellwig 		*lenp = 0;
793f461d2dcSChristoph Hellwig 		return -EINVAL;
794f461d2dcSChristoph Hellwig 	}
795f461d2dcSChristoph Hellwig 
796f461d2dcSChristoph Hellwig 	if (!conv)
797f461d2dcSChristoph Hellwig 		conv = do_proc_douintvec_conv;
798f461d2dcSChristoph Hellwig 
799f461d2dcSChristoph Hellwig 	if (write)
800f461d2dcSChristoph Hellwig 		return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
801f461d2dcSChristoph Hellwig 					   conv, data);
802f461d2dcSChristoph Hellwig 	return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
803f461d2dcSChristoph Hellwig }
804f461d2dcSChristoph Hellwig 
805f461d2dcSChristoph Hellwig static int do_proc_douintvec(struct ctl_table *table, int write,
80632927393SChristoph Hellwig 			     void *buffer, size_t *lenp, loff_t *ppos,
807f461d2dcSChristoph Hellwig 			     int (*conv)(unsigned long *lvalp,
808f461d2dcSChristoph Hellwig 					 unsigned int *valp,
809f461d2dcSChristoph Hellwig 					 int write, void *data),
810f461d2dcSChristoph Hellwig 			     void *data)
811f461d2dcSChristoph Hellwig {
812f461d2dcSChristoph Hellwig 	return __do_proc_douintvec(table->data, table, write,
813f461d2dcSChristoph Hellwig 				   buffer, lenp, ppos, conv, data);
814f461d2dcSChristoph Hellwig }
815f461d2dcSChristoph Hellwig 
816f461d2dcSChristoph Hellwig /**
817*a2071573SJia He  * proc_dobool - read/write a bool
818*a2071573SJia He  * @table: the sysctl table
819*a2071573SJia He  * @write: %TRUE if this is a write to the sysctl file
820*a2071573SJia He  * @buffer: the user buffer
821*a2071573SJia He  * @lenp: the size of the user buffer
822*a2071573SJia He  * @ppos: file position
823*a2071573SJia He  *
824*a2071573SJia He  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
825*a2071573SJia He  * values from/to the user buffer, treated as an ASCII string.
826*a2071573SJia He  *
827*a2071573SJia He  * Returns 0 on success.
828*a2071573SJia He  */
829*a2071573SJia He int proc_dobool(struct ctl_table *table, int write, void *buffer,
830*a2071573SJia He 		size_t *lenp, loff_t *ppos)
831*a2071573SJia He {
832*a2071573SJia He 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
833*a2071573SJia He 				do_proc_dobool_conv, NULL);
834*a2071573SJia He }
835*a2071573SJia He 
836*a2071573SJia He /**
837f461d2dcSChristoph Hellwig  * proc_dointvec - read a vector of integers
838f461d2dcSChristoph Hellwig  * @table: the sysctl table
839f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
840f461d2dcSChristoph Hellwig  * @buffer: the user buffer
841f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
842f461d2dcSChristoph Hellwig  * @ppos: file position
843f461d2dcSChristoph Hellwig  *
844f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
845f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
846f461d2dcSChristoph Hellwig  *
847f461d2dcSChristoph Hellwig  * Returns 0 on success.
848f461d2dcSChristoph Hellwig  */
84932927393SChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, void *buffer,
85032927393SChristoph Hellwig 		  size_t *lenp, loff_t *ppos)
851f461d2dcSChristoph Hellwig {
852f461d2dcSChristoph Hellwig 	return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
853f461d2dcSChristoph Hellwig }
854f461d2dcSChristoph Hellwig 
855f461d2dcSChristoph Hellwig #ifdef CONFIG_COMPACTION
856f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
85732927393SChristoph Hellwig 		int write, void *buffer, size_t *lenp, loff_t *ppos)
858f461d2dcSChristoph Hellwig {
859f461d2dcSChristoph Hellwig 	int ret, old;
860f461d2dcSChristoph Hellwig 
861f461d2dcSChristoph Hellwig 	if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
862f461d2dcSChristoph Hellwig 		return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
863f461d2dcSChristoph Hellwig 
864f461d2dcSChristoph Hellwig 	old = *(int *)table->data;
865f461d2dcSChristoph Hellwig 	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
866f461d2dcSChristoph Hellwig 	if (ret)
867f461d2dcSChristoph Hellwig 		return ret;
868f461d2dcSChristoph Hellwig 	if (old != *(int *)table->data)
869f461d2dcSChristoph Hellwig 		pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
870f461d2dcSChristoph Hellwig 			     table->procname, current->comm,
871f461d2dcSChristoph Hellwig 			     task_pid_nr(current));
872f461d2dcSChristoph Hellwig 	return ret;
873f461d2dcSChristoph Hellwig }
874f461d2dcSChristoph Hellwig #endif
875f461d2dcSChristoph Hellwig 
876f461d2dcSChristoph Hellwig /**
877f461d2dcSChristoph Hellwig  * proc_douintvec - read a vector of unsigned integers
878f461d2dcSChristoph Hellwig  * @table: the sysctl table
879f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
880f461d2dcSChristoph Hellwig  * @buffer: the user buffer
881f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
882f461d2dcSChristoph Hellwig  * @ppos: file position
883f461d2dcSChristoph Hellwig  *
884f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
885f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
886f461d2dcSChristoph Hellwig  *
887f461d2dcSChristoph Hellwig  * Returns 0 on success.
888f461d2dcSChristoph Hellwig  */
88932927393SChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, void *buffer,
89032927393SChristoph Hellwig 		size_t *lenp, loff_t *ppos)
891f461d2dcSChristoph Hellwig {
892f461d2dcSChristoph Hellwig 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
893f461d2dcSChristoph Hellwig 				 do_proc_douintvec_conv, NULL);
894f461d2dcSChristoph Hellwig }
895f461d2dcSChristoph Hellwig 
896f461d2dcSChristoph Hellwig /*
897f461d2dcSChristoph Hellwig  * Taint values can only be increased
898f461d2dcSChristoph Hellwig  * This means we can safely use a temporary.
899f461d2dcSChristoph Hellwig  */
900f461d2dcSChristoph Hellwig static int proc_taint(struct ctl_table *table, int write,
90132927393SChristoph Hellwig 			       void *buffer, size_t *lenp, loff_t *ppos)
902f461d2dcSChristoph Hellwig {
903f461d2dcSChristoph Hellwig 	struct ctl_table t;
904f461d2dcSChristoph Hellwig 	unsigned long tmptaint = get_taint();
905f461d2dcSChristoph Hellwig 	int err;
906f461d2dcSChristoph Hellwig 
907f461d2dcSChristoph Hellwig 	if (write && !capable(CAP_SYS_ADMIN))
908f461d2dcSChristoph Hellwig 		return -EPERM;
909f461d2dcSChristoph Hellwig 
910f461d2dcSChristoph Hellwig 	t = *table;
911f461d2dcSChristoph Hellwig 	t.data = &tmptaint;
912f461d2dcSChristoph Hellwig 	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
913f461d2dcSChristoph Hellwig 	if (err < 0)
914f461d2dcSChristoph Hellwig 		return err;
915f461d2dcSChristoph Hellwig 
916f461d2dcSChristoph Hellwig 	if (write) {
917db38d5c1SRafael Aquini 		int i;
918db38d5c1SRafael Aquini 
919db38d5c1SRafael Aquini 		/*
920db38d5c1SRafael Aquini 		 * If we are relying on panic_on_taint not producing
921db38d5c1SRafael Aquini 		 * false positives due to userspace input, bail out
922db38d5c1SRafael Aquini 		 * before setting the requested taint flags.
923db38d5c1SRafael Aquini 		 */
924db38d5c1SRafael Aquini 		if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
925db38d5c1SRafael Aquini 			return -EINVAL;
926db38d5c1SRafael Aquini 
927f461d2dcSChristoph Hellwig 		/*
928f461d2dcSChristoph Hellwig 		 * Poor man's atomic or. Not worth adding a primitive
929f461d2dcSChristoph Hellwig 		 * to everyone's atomic.h for this
930f461d2dcSChristoph Hellwig 		 */
931e77132e7SRafael Aquini 		for (i = 0; i < TAINT_FLAGS_COUNT; i++)
932e77132e7SRafael Aquini 			if ((1UL << i) & tmptaint)
933f461d2dcSChristoph Hellwig 				add_taint(i, LOCKDEP_STILL_OK);
934f461d2dcSChristoph Hellwig 	}
935f461d2dcSChristoph Hellwig 
936f461d2dcSChristoph Hellwig 	return err;
937f461d2dcSChristoph Hellwig }
938f461d2dcSChristoph Hellwig 
939f461d2dcSChristoph Hellwig #ifdef CONFIG_PRINTK
940f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
94132927393SChristoph Hellwig 				void *buffer, size_t *lenp, loff_t *ppos)
942f461d2dcSChristoph Hellwig {
943f461d2dcSChristoph Hellwig 	if (write && !capable(CAP_SYS_ADMIN))
944f461d2dcSChristoph Hellwig 		return -EPERM;
945f461d2dcSChristoph Hellwig 
946f461d2dcSChristoph Hellwig 	return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
947f461d2dcSChristoph Hellwig }
948f461d2dcSChristoph Hellwig #endif
949f461d2dcSChristoph Hellwig 
950f461d2dcSChristoph Hellwig /**
951f461d2dcSChristoph Hellwig  * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
952f461d2dcSChristoph Hellwig  * @min: pointer to minimum allowable value
953f461d2dcSChristoph Hellwig  * @max: pointer to maximum allowable value
954f461d2dcSChristoph Hellwig  *
955f461d2dcSChristoph Hellwig  * The do_proc_dointvec_minmax_conv_param structure provides the
956f461d2dcSChristoph Hellwig  * minimum and maximum values for doing range checking for those sysctl
957f461d2dcSChristoph Hellwig  * parameters that use the proc_dointvec_minmax() handler.
958f461d2dcSChristoph Hellwig  */
959f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param {
960f461d2dcSChristoph Hellwig 	int *min;
961f461d2dcSChristoph Hellwig 	int *max;
962f461d2dcSChristoph Hellwig };
963f461d2dcSChristoph Hellwig 
964f461d2dcSChristoph Hellwig static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
965f461d2dcSChristoph Hellwig 					int *valp,
966f461d2dcSChristoph Hellwig 					int write, void *data)
967f461d2dcSChristoph Hellwig {
968f461d2dcSChristoph Hellwig 	int tmp, ret;
969f461d2dcSChristoph Hellwig 	struct do_proc_dointvec_minmax_conv_param *param = data;
970f461d2dcSChristoph Hellwig 	/*
971f461d2dcSChristoph Hellwig 	 * If writing, first do so via a temporary local int so we can
972f461d2dcSChristoph Hellwig 	 * bounds-check it before touching *valp.
973f461d2dcSChristoph Hellwig 	 */
974f461d2dcSChristoph Hellwig 	int *ip = write ? &tmp : valp;
975f461d2dcSChristoph Hellwig 
976f461d2dcSChristoph Hellwig 	ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
977f461d2dcSChristoph Hellwig 	if (ret)
978f461d2dcSChristoph Hellwig 		return ret;
979f461d2dcSChristoph Hellwig 
980f461d2dcSChristoph Hellwig 	if (write) {
981f461d2dcSChristoph Hellwig 		if ((param->min && *param->min > tmp) ||
982f461d2dcSChristoph Hellwig 		    (param->max && *param->max < tmp))
983f461d2dcSChristoph Hellwig 			return -EINVAL;
984f461d2dcSChristoph Hellwig 		*valp = tmp;
985f461d2dcSChristoph Hellwig 	}
986f461d2dcSChristoph Hellwig 
987f461d2dcSChristoph Hellwig 	return 0;
988f461d2dcSChristoph Hellwig }
989f461d2dcSChristoph Hellwig 
990f461d2dcSChristoph Hellwig /**
991f461d2dcSChristoph Hellwig  * proc_dointvec_minmax - read a vector of integers with min/max values
992f461d2dcSChristoph Hellwig  * @table: the sysctl table
993f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
994f461d2dcSChristoph Hellwig  * @buffer: the user buffer
995f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
996f461d2dcSChristoph Hellwig  * @ppos: file position
997f461d2dcSChristoph Hellwig  *
998f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
999f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1000f461d2dcSChristoph Hellwig  *
1001f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1002f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max).
1003f461d2dcSChristoph Hellwig  *
1004f461d2dcSChristoph Hellwig  * Returns 0 on success or -EINVAL on write when the range check fails.
1005f461d2dcSChristoph Hellwig  */
1006f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write,
100732927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1008f461d2dcSChristoph Hellwig {
1009f461d2dcSChristoph Hellwig 	struct do_proc_dointvec_minmax_conv_param param = {
1010f461d2dcSChristoph Hellwig 		.min = (int *) table->extra1,
1011f461d2dcSChristoph Hellwig 		.max = (int *) table->extra2,
1012f461d2dcSChristoph Hellwig 	};
1013f461d2dcSChristoph Hellwig 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
1014f461d2dcSChristoph Hellwig 				do_proc_dointvec_minmax_conv, &param);
1015f461d2dcSChristoph Hellwig }
1016f461d2dcSChristoph Hellwig 
1017f461d2dcSChristoph Hellwig /**
1018f461d2dcSChristoph Hellwig  * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
1019f461d2dcSChristoph Hellwig  * @min: pointer to minimum allowable value
1020f461d2dcSChristoph Hellwig  * @max: pointer to maximum allowable value
1021f461d2dcSChristoph Hellwig  *
1022f461d2dcSChristoph Hellwig  * The do_proc_douintvec_minmax_conv_param structure provides the
1023f461d2dcSChristoph Hellwig  * minimum and maximum values for doing range checking for those sysctl
1024f461d2dcSChristoph Hellwig  * parameters that use the proc_douintvec_minmax() handler.
1025f461d2dcSChristoph Hellwig  */
1026f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param {
1027f461d2dcSChristoph Hellwig 	unsigned int *min;
1028f461d2dcSChristoph Hellwig 	unsigned int *max;
1029f461d2dcSChristoph Hellwig };
1030f461d2dcSChristoph Hellwig 
1031f461d2dcSChristoph Hellwig static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
1032f461d2dcSChristoph Hellwig 					 unsigned int *valp,
1033f461d2dcSChristoph Hellwig 					 int write, void *data)
1034f461d2dcSChristoph Hellwig {
1035f461d2dcSChristoph Hellwig 	int ret;
1036f461d2dcSChristoph Hellwig 	unsigned int tmp;
1037f461d2dcSChristoph Hellwig 	struct do_proc_douintvec_minmax_conv_param *param = data;
1038f461d2dcSChristoph Hellwig 	/* write via temporary local uint for bounds-checking */
1039f461d2dcSChristoph Hellwig 	unsigned int *up = write ? &tmp : valp;
1040f461d2dcSChristoph Hellwig 
1041f461d2dcSChristoph Hellwig 	ret = do_proc_douintvec_conv(lvalp, up, write, data);
1042f461d2dcSChristoph Hellwig 	if (ret)
1043f461d2dcSChristoph Hellwig 		return ret;
1044f461d2dcSChristoph Hellwig 
1045f461d2dcSChristoph Hellwig 	if (write) {
1046f461d2dcSChristoph Hellwig 		if ((param->min && *param->min > tmp) ||
1047f461d2dcSChristoph Hellwig 		    (param->max && *param->max < tmp))
1048f461d2dcSChristoph Hellwig 			return -ERANGE;
1049f461d2dcSChristoph Hellwig 
1050f461d2dcSChristoph Hellwig 		*valp = tmp;
1051f461d2dcSChristoph Hellwig 	}
1052f461d2dcSChristoph Hellwig 
1053f461d2dcSChristoph Hellwig 	return 0;
1054f461d2dcSChristoph Hellwig }
1055f461d2dcSChristoph Hellwig 
1056f461d2dcSChristoph Hellwig /**
1057f461d2dcSChristoph Hellwig  * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1058f461d2dcSChristoph Hellwig  * @table: the sysctl table
1059f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1060f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1061f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1062f461d2dcSChristoph Hellwig  * @ppos: file position
1063f461d2dcSChristoph Hellwig  *
1064f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1065f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string. Negative
1066f461d2dcSChristoph Hellwig  * strings are not allowed.
1067f461d2dcSChristoph Hellwig  *
1068f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1069f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max). There is a final sanity
1070f461d2dcSChristoph Hellwig  * check for UINT_MAX to avoid having to support wrap around uses from
1071f461d2dcSChristoph Hellwig  * userspace.
1072f461d2dcSChristoph Hellwig  *
1073f461d2dcSChristoph Hellwig  * Returns 0 on success or -ERANGE on write when the range check fails.
1074f461d2dcSChristoph Hellwig  */
1075f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write,
107632927393SChristoph Hellwig 			  void *buffer, size_t *lenp, loff_t *ppos)
1077f461d2dcSChristoph Hellwig {
1078f461d2dcSChristoph Hellwig 	struct do_proc_douintvec_minmax_conv_param param = {
1079f461d2dcSChristoph Hellwig 		.min = (unsigned int *) table->extra1,
1080f461d2dcSChristoph Hellwig 		.max = (unsigned int *) table->extra2,
1081f461d2dcSChristoph Hellwig 	};
1082f461d2dcSChristoph Hellwig 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
1083f461d2dcSChristoph Hellwig 				 do_proc_douintvec_minmax_conv, &param);
1084f461d2dcSChristoph Hellwig }
1085f461d2dcSChristoph Hellwig 
1086cb944413SEric Dumazet /**
1087cb944413SEric Dumazet  * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1088cb944413SEric Dumazet  * @table: the sysctl table
1089cb944413SEric Dumazet  * @write: %TRUE if this is a write to the sysctl file
1090cb944413SEric Dumazet  * @buffer: the user buffer
1091cb944413SEric Dumazet  * @lenp: the size of the user buffer
1092cb944413SEric Dumazet  * @ppos: file position
1093cb944413SEric Dumazet  *
1094cb944413SEric Dumazet  * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1095cb944413SEric Dumazet  * values from/to the user buffer, treated as an ASCII string. Negative
1096cb944413SEric Dumazet  * strings are not allowed.
1097cb944413SEric Dumazet  *
1098cb944413SEric Dumazet  * This routine will ensure the values are within the range specified by
1099cb944413SEric Dumazet  * table->extra1 (min) and table->extra2 (max).
1100cb944413SEric Dumazet  *
1101cb944413SEric Dumazet  * Returns 0 on success or an error on write when the range check fails.
1102cb944413SEric Dumazet  */
1103cb944413SEric Dumazet int proc_dou8vec_minmax(struct ctl_table *table, int write,
1104cb944413SEric Dumazet 			void *buffer, size_t *lenp, loff_t *ppos)
1105cb944413SEric Dumazet {
1106cb944413SEric Dumazet 	struct ctl_table tmp;
1107cb944413SEric Dumazet 	unsigned int min = 0, max = 255U, val;
1108cb944413SEric Dumazet 	u8 *data = table->data;
1109cb944413SEric Dumazet 	struct do_proc_douintvec_minmax_conv_param param = {
1110cb944413SEric Dumazet 		.min = &min,
1111cb944413SEric Dumazet 		.max = &max,
1112cb944413SEric Dumazet 	};
1113cb944413SEric Dumazet 	int res;
1114cb944413SEric Dumazet 
1115cb944413SEric Dumazet 	/* Do not support arrays yet. */
1116cb944413SEric Dumazet 	if (table->maxlen != sizeof(u8))
1117cb944413SEric Dumazet 		return -EINVAL;
1118cb944413SEric Dumazet 
1119cb944413SEric Dumazet 	if (table->extra1) {
1120cb944413SEric Dumazet 		min = *(unsigned int *) table->extra1;
1121cb944413SEric Dumazet 		if (min > 255U)
1122cb944413SEric Dumazet 			return -EINVAL;
1123cb944413SEric Dumazet 	}
1124cb944413SEric Dumazet 	if (table->extra2) {
1125cb944413SEric Dumazet 		max = *(unsigned int *) table->extra2;
1126cb944413SEric Dumazet 		if (max > 255U)
1127cb944413SEric Dumazet 			return -EINVAL;
1128cb944413SEric Dumazet 	}
1129cb944413SEric Dumazet 
1130cb944413SEric Dumazet 	tmp = *table;
1131cb944413SEric Dumazet 
1132cb944413SEric Dumazet 	tmp.maxlen = sizeof(val);
1133cb944413SEric Dumazet 	tmp.data = &val;
1134cb944413SEric Dumazet 	val = *data;
1135cb944413SEric Dumazet 	res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1136cb944413SEric Dumazet 				do_proc_douintvec_minmax_conv, &param);
1137cb944413SEric Dumazet 	if (res)
1138cb944413SEric Dumazet 		return res;
1139cb944413SEric Dumazet 	if (write)
1140cb944413SEric Dumazet 		*data = val;
1141cb944413SEric Dumazet 	return 0;
1142cb944413SEric Dumazet }
1143cb944413SEric Dumazet EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1144cb944413SEric Dumazet 
1145f461d2dcSChristoph Hellwig static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1146f461d2dcSChristoph Hellwig 					unsigned int *valp,
1147f461d2dcSChristoph Hellwig 					int write, void *data)
1148f461d2dcSChristoph Hellwig {
1149f461d2dcSChristoph Hellwig 	if (write) {
1150f461d2dcSChristoph Hellwig 		unsigned int val;
1151f461d2dcSChristoph Hellwig 
1152f461d2dcSChristoph Hellwig 		val = round_pipe_size(*lvalp);
1153f461d2dcSChristoph Hellwig 		if (val == 0)
1154f461d2dcSChristoph Hellwig 			return -EINVAL;
1155f461d2dcSChristoph Hellwig 
1156f461d2dcSChristoph Hellwig 		*valp = val;
1157f461d2dcSChristoph Hellwig 	} else {
1158f461d2dcSChristoph Hellwig 		unsigned int val = *valp;
1159f461d2dcSChristoph Hellwig 		*lvalp = (unsigned long) val;
1160f461d2dcSChristoph Hellwig 	}
1161f461d2dcSChristoph Hellwig 
1162f461d2dcSChristoph Hellwig 	return 0;
1163f461d2dcSChristoph Hellwig }
1164f461d2dcSChristoph Hellwig 
1165f461d2dcSChristoph Hellwig static int proc_dopipe_max_size(struct ctl_table *table, int write,
116632927393SChristoph Hellwig 				void *buffer, size_t *lenp, loff_t *ppos)
1167f461d2dcSChristoph Hellwig {
1168f461d2dcSChristoph Hellwig 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
1169f461d2dcSChristoph Hellwig 				 do_proc_dopipe_max_size_conv, NULL);
1170f461d2dcSChristoph Hellwig }
1171f461d2dcSChristoph Hellwig 
1172f461d2dcSChristoph Hellwig static void validate_coredump_safety(void)
1173f461d2dcSChristoph Hellwig {
1174f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP
1175f461d2dcSChristoph Hellwig 	if (suid_dumpable == SUID_DUMP_ROOT &&
1176f461d2dcSChristoph Hellwig 	    core_pattern[0] != '/' && core_pattern[0] != '|') {
1177f461d2dcSChristoph Hellwig 		printk(KERN_WARNING
1178f461d2dcSChristoph Hellwig "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1179f461d2dcSChristoph Hellwig "Pipe handler or fully qualified core dump path required.\n"
1180f461d2dcSChristoph Hellwig "Set kernel.core_pattern before fs.suid_dumpable.\n"
1181f461d2dcSChristoph Hellwig 		);
1182f461d2dcSChristoph Hellwig 	}
1183f461d2dcSChristoph Hellwig #endif
1184f461d2dcSChristoph Hellwig }
1185f461d2dcSChristoph Hellwig 
1186f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
118732927393SChristoph Hellwig 		void *buffer, size_t *lenp, loff_t *ppos)
1188f461d2dcSChristoph Hellwig {
1189f461d2dcSChristoph Hellwig 	int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1190f461d2dcSChristoph Hellwig 	if (!error)
1191f461d2dcSChristoph Hellwig 		validate_coredump_safety();
1192f461d2dcSChristoph Hellwig 	return error;
1193f461d2dcSChristoph Hellwig }
1194f461d2dcSChristoph Hellwig 
1195f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP
1196f461d2dcSChristoph Hellwig static int proc_dostring_coredump(struct ctl_table *table, int write,
119732927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1198f461d2dcSChristoph Hellwig {
1199f461d2dcSChristoph Hellwig 	int error = proc_dostring(table, write, buffer, lenp, ppos);
1200f461d2dcSChristoph Hellwig 	if (!error)
1201f461d2dcSChristoph Hellwig 		validate_coredump_safety();
1202f461d2dcSChristoph Hellwig 	return error;
1203f461d2dcSChristoph Hellwig }
1204f461d2dcSChristoph Hellwig #endif
1205f461d2dcSChristoph Hellwig 
1206f461d2dcSChristoph Hellwig #ifdef CONFIG_MAGIC_SYSRQ
1207f461d2dcSChristoph Hellwig static int sysrq_sysctl_handler(struct ctl_table *table, int write,
120832927393SChristoph Hellwig 				void *buffer, size_t *lenp, loff_t *ppos)
1209f461d2dcSChristoph Hellwig {
1210f461d2dcSChristoph Hellwig 	int tmp, ret;
1211f461d2dcSChristoph Hellwig 
1212f461d2dcSChristoph Hellwig 	tmp = sysrq_mask();
1213f461d2dcSChristoph Hellwig 
1214f461d2dcSChristoph Hellwig 	ret = __do_proc_dointvec(&tmp, table, write, buffer,
1215f461d2dcSChristoph Hellwig 			       lenp, ppos, NULL, NULL);
1216f461d2dcSChristoph Hellwig 	if (ret || !write)
1217f461d2dcSChristoph Hellwig 		return ret;
1218f461d2dcSChristoph Hellwig 
1219f461d2dcSChristoph Hellwig 	if (write)
1220f461d2dcSChristoph Hellwig 		sysrq_toggle_support(tmp);
1221f461d2dcSChristoph Hellwig 
1222f461d2dcSChristoph Hellwig 	return 0;
1223f461d2dcSChristoph Hellwig }
1224f461d2dcSChristoph Hellwig #endif
1225f461d2dcSChristoph Hellwig 
122632927393SChristoph Hellwig static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
122732927393SChristoph Hellwig 		int write, void *buffer, size_t *lenp, loff_t *ppos,
122832927393SChristoph Hellwig 		unsigned long convmul, unsigned long convdiv)
1229f461d2dcSChristoph Hellwig {
1230f461d2dcSChristoph Hellwig 	unsigned long *i, *min, *max;
1231f461d2dcSChristoph Hellwig 	int vleft, first = 1, err = 0;
1232f461d2dcSChristoph Hellwig 	size_t left;
123332927393SChristoph Hellwig 	char *p;
1234f461d2dcSChristoph Hellwig 
1235f461d2dcSChristoph Hellwig 	if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1236f461d2dcSChristoph Hellwig 		*lenp = 0;
1237f461d2dcSChristoph Hellwig 		return 0;
1238f461d2dcSChristoph Hellwig 	}
1239f461d2dcSChristoph Hellwig 
1240f461d2dcSChristoph Hellwig 	i = (unsigned long *) data;
1241f461d2dcSChristoph Hellwig 	min = (unsigned long *) table->extra1;
1242f461d2dcSChristoph Hellwig 	max = (unsigned long *) table->extra2;
1243f461d2dcSChristoph Hellwig 	vleft = table->maxlen / sizeof(unsigned long);
1244f461d2dcSChristoph Hellwig 	left = *lenp;
1245f461d2dcSChristoph Hellwig 
1246f461d2dcSChristoph Hellwig 	if (write) {
1247f461d2dcSChristoph Hellwig 		if (proc_first_pos_non_zero_ignore(ppos, table))
1248f461d2dcSChristoph Hellwig 			goto out;
1249f461d2dcSChristoph Hellwig 
1250f461d2dcSChristoph Hellwig 		if (left > PAGE_SIZE - 1)
1251f461d2dcSChristoph Hellwig 			left = PAGE_SIZE - 1;
125232927393SChristoph Hellwig 		p = buffer;
1253f461d2dcSChristoph Hellwig 	}
1254f461d2dcSChristoph Hellwig 
1255f461d2dcSChristoph Hellwig 	for (; left && vleft--; i++, first = 0) {
1256f461d2dcSChristoph Hellwig 		unsigned long val;
1257f461d2dcSChristoph Hellwig 
1258f461d2dcSChristoph Hellwig 		if (write) {
1259f461d2dcSChristoph Hellwig 			bool neg;
1260f461d2dcSChristoph Hellwig 
1261f461d2dcSChristoph Hellwig 			left -= proc_skip_spaces(&p);
1262f461d2dcSChristoph Hellwig 			if (!left)
1263f461d2dcSChristoph Hellwig 				break;
1264f461d2dcSChristoph Hellwig 
1265f461d2dcSChristoph Hellwig 			err = proc_get_long(&p, &left, &val, &neg,
1266f461d2dcSChristoph Hellwig 					     proc_wspace_sep,
1267f461d2dcSChristoph Hellwig 					     sizeof(proc_wspace_sep), NULL);
1268f461d2dcSChristoph Hellwig 			if (err)
1269f461d2dcSChristoph Hellwig 				break;
1270f461d2dcSChristoph Hellwig 			if (neg)
1271f461d2dcSChristoph Hellwig 				continue;
1272f461d2dcSChristoph Hellwig 			val = convmul * val / convdiv;
1273f461d2dcSChristoph Hellwig 			if ((min && val < *min) || (max && val > *max)) {
1274f461d2dcSChristoph Hellwig 				err = -EINVAL;
1275f461d2dcSChristoph Hellwig 				break;
1276f461d2dcSChristoph Hellwig 			}
1277f461d2dcSChristoph Hellwig 			*i = val;
1278f461d2dcSChristoph Hellwig 		} else {
1279f461d2dcSChristoph Hellwig 			val = convdiv * (*i) / convmul;
128032927393SChristoph Hellwig 			if (!first)
128132927393SChristoph Hellwig 				proc_put_char(&buffer, &left, '\t');
128232927393SChristoph Hellwig 			proc_put_long(&buffer, &left, val, false);
1283f461d2dcSChristoph Hellwig 		}
1284f461d2dcSChristoph Hellwig 	}
1285f461d2dcSChristoph Hellwig 
1286f461d2dcSChristoph Hellwig 	if (!write && !first && left && !err)
128732927393SChristoph Hellwig 		proc_put_char(&buffer, &left, '\n');
1288f461d2dcSChristoph Hellwig 	if (write && !err)
1289f461d2dcSChristoph Hellwig 		left -= proc_skip_spaces(&p);
129032927393SChristoph Hellwig 	if (write && first)
1291f461d2dcSChristoph Hellwig 		return err ? : -EINVAL;
1292f461d2dcSChristoph Hellwig 	*lenp -= left;
1293f461d2dcSChristoph Hellwig out:
1294f461d2dcSChristoph Hellwig 	*ppos += *lenp;
1295f461d2dcSChristoph Hellwig 	return err;
1296f461d2dcSChristoph Hellwig }
1297f461d2dcSChristoph Hellwig 
1298f461d2dcSChristoph Hellwig static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
129932927393SChristoph Hellwig 		void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1300f461d2dcSChristoph Hellwig 		unsigned long convdiv)
1301f461d2dcSChristoph Hellwig {
1302f461d2dcSChristoph Hellwig 	return __do_proc_doulongvec_minmax(table->data, table, write,
1303f461d2dcSChristoph Hellwig 			buffer, lenp, ppos, convmul, convdiv);
1304f461d2dcSChristoph Hellwig }
1305f461d2dcSChristoph Hellwig 
1306f461d2dcSChristoph Hellwig /**
1307f461d2dcSChristoph Hellwig  * proc_doulongvec_minmax - read a vector of long integers with min/max values
1308f461d2dcSChristoph Hellwig  * @table: the sysctl table
1309f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1310f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1311f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1312f461d2dcSChristoph Hellwig  * @ppos: file position
1313f461d2dcSChristoph Hellwig  *
1314f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1315f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1316f461d2dcSChristoph Hellwig  *
1317f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1318f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max).
1319f461d2dcSChristoph Hellwig  *
1320f461d2dcSChristoph Hellwig  * Returns 0 on success.
1321f461d2dcSChristoph Hellwig  */
1322f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write,
132332927393SChristoph Hellwig 			   void *buffer, size_t *lenp, loff_t *ppos)
1324f461d2dcSChristoph Hellwig {
1325f461d2dcSChristoph Hellwig     return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1326f461d2dcSChristoph Hellwig }
1327f461d2dcSChristoph Hellwig 
1328f461d2dcSChristoph Hellwig /**
1329f461d2dcSChristoph Hellwig  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1330f461d2dcSChristoph Hellwig  * @table: the sysctl table
1331f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1332f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1333f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1334f461d2dcSChristoph Hellwig  * @ppos: file position
1335f461d2dcSChristoph Hellwig  *
1336f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1337f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string. The values
1338f461d2dcSChristoph Hellwig  * are treated as milliseconds, and converted to jiffies when they are stored.
1339f461d2dcSChristoph Hellwig  *
1340f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1341f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max).
1342f461d2dcSChristoph Hellwig  *
1343f461d2dcSChristoph Hellwig  * Returns 0 on success.
1344f461d2dcSChristoph Hellwig  */
1345f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
134632927393SChristoph Hellwig 				      void *buffer, size_t *lenp, loff_t *ppos)
1347f461d2dcSChristoph Hellwig {
1348f461d2dcSChristoph Hellwig     return do_proc_doulongvec_minmax(table, write, buffer,
1349f461d2dcSChristoph Hellwig 				     lenp, ppos, HZ, 1000l);
1350f461d2dcSChristoph Hellwig }
1351f461d2dcSChristoph Hellwig 
1352f461d2dcSChristoph Hellwig 
1353f461d2dcSChristoph Hellwig static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1354f461d2dcSChristoph Hellwig 					 int *valp,
1355f461d2dcSChristoph Hellwig 					 int write, void *data)
1356f461d2dcSChristoph Hellwig {
1357f461d2dcSChristoph Hellwig 	if (write) {
1358f461d2dcSChristoph Hellwig 		if (*lvalp > INT_MAX / HZ)
1359f461d2dcSChristoph Hellwig 			return 1;
1360f461d2dcSChristoph Hellwig 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1361f461d2dcSChristoph Hellwig 	} else {
1362f461d2dcSChristoph Hellwig 		int val = *valp;
1363f461d2dcSChristoph Hellwig 		unsigned long lval;
1364f461d2dcSChristoph Hellwig 		if (val < 0) {
1365f461d2dcSChristoph Hellwig 			*negp = true;
1366f461d2dcSChristoph Hellwig 			lval = -(unsigned long)val;
1367f461d2dcSChristoph Hellwig 		} else {
1368f461d2dcSChristoph Hellwig 			*negp = false;
1369f461d2dcSChristoph Hellwig 			lval = (unsigned long)val;
1370f461d2dcSChristoph Hellwig 		}
1371f461d2dcSChristoph Hellwig 		*lvalp = lval / HZ;
1372f461d2dcSChristoph Hellwig 	}
1373f461d2dcSChristoph Hellwig 	return 0;
1374f461d2dcSChristoph Hellwig }
1375f461d2dcSChristoph Hellwig 
1376f461d2dcSChristoph Hellwig static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1377f461d2dcSChristoph Hellwig 						int *valp,
1378f461d2dcSChristoph Hellwig 						int write, void *data)
1379f461d2dcSChristoph Hellwig {
1380f461d2dcSChristoph Hellwig 	if (write) {
1381f461d2dcSChristoph Hellwig 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1382f461d2dcSChristoph Hellwig 			return 1;
1383f461d2dcSChristoph Hellwig 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1384f461d2dcSChristoph Hellwig 	} else {
1385f461d2dcSChristoph Hellwig 		int val = *valp;
1386f461d2dcSChristoph Hellwig 		unsigned long lval;
1387f461d2dcSChristoph Hellwig 		if (val < 0) {
1388f461d2dcSChristoph Hellwig 			*negp = true;
1389f461d2dcSChristoph Hellwig 			lval = -(unsigned long)val;
1390f461d2dcSChristoph Hellwig 		} else {
1391f461d2dcSChristoph Hellwig 			*negp = false;
1392f461d2dcSChristoph Hellwig 			lval = (unsigned long)val;
1393f461d2dcSChristoph Hellwig 		}
1394f461d2dcSChristoph Hellwig 		*lvalp = jiffies_to_clock_t(lval);
1395f461d2dcSChristoph Hellwig 	}
1396f461d2dcSChristoph Hellwig 	return 0;
1397f461d2dcSChristoph Hellwig }
1398f461d2dcSChristoph Hellwig 
1399f461d2dcSChristoph Hellwig static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1400f461d2dcSChristoph Hellwig 					    int *valp,
1401f461d2dcSChristoph Hellwig 					    int write, void *data)
1402f461d2dcSChristoph Hellwig {
1403f461d2dcSChristoph Hellwig 	if (write) {
1404f461d2dcSChristoph Hellwig 		unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1405f461d2dcSChristoph Hellwig 
1406f461d2dcSChristoph Hellwig 		if (jif > INT_MAX)
1407f461d2dcSChristoph Hellwig 			return 1;
1408f461d2dcSChristoph Hellwig 		*valp = (int)jif;
1409f461d2dcSChristoph Hellwig 	} else {
1410f461d2dcSChristoph Hellwig 		int val = *valp;
1411f461d2dcSChristoph Hellwig 		unsigned long lval;
1412f461d2dcSChristoph Hellwig 		if (val < 0) {
1413f461d2dcSChristoph Hellwig 			*negp = true;
1414f461d2dcSChristoph Hellwig 			lval = -(unsigned long)val;
1415f461d2dcSChristoph Hellwig 		} else {
1416f461d2dcSChristoph Hellwig 			*negp = false;
1417f461d2dcSChristoph Hellwig 			lval = (unsigned long)val;
1418f461d2dcSChristoph Hellwig 		}
1419f461d2dcSChristoph Hellwig 		*lvalp = jiffies_to_msecs(lval);
1420f461d2dcSChristoph Hellwig 	}
1421f461d2dcSChristoph Hellwig 	return 0;
1422f461d2dcSChristoph Hellwig }
1423f461d2dcSChristoph Hellwig 
1424f461d2dcSChristoph Hellwig /**
1425f461d2dcSChristoph Hellwig  * proc_dointvec_jiffies - read a vector of integers as seconds
1426f461d2dcSChristoph Hellwig  * @table: the sysctl table
1427f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1428f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1429f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1430f461d2dcSChristoph Hellwig  * @ppos: file position
1431f461d2dcSChristoph Hellwig  *
1432f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1433f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1434f461d2dcSChristoph Hellwig  * The values read are assumed to be in seconds, and are converted into
1435f461d2dcSChristoph Hellwig  * jiffies.
1436f461d2dcSChristoph Hellwig  *
1437f461d2dcSChristoph Hellwig  * Returns 0 on success.
1438f461d2dcSChristoph Hellwig  */
1439f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write,
144032927393SChristoph Hellwig 			  void *buffer, size_t *lenp, loff_t *ppos)
1441f461d2dcSChristoph Hellwig {
1442f461d2dcSChristoph Hellwig     return do_proc_dointvec(table,write,buffer,lenp,ppos,
1443f461d2dcSChristoph Hellwig 		    	    do_proc_dointvec_jiffies_conv,NULL);
1444f461d2dcSChristoph Hellwig }
1445f461d2dcSChristoph Hellwig 
1446f461d2dcSChristoph Hellwig /**
1447f461d2dcSChristoph Hellwig  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1448f461d2dcSChristoph Hellwig  * @table: the sysctl table
1449f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1450f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1451f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1452f461d2dcSChristoph Hellwig  * @ppos: pointer to the file position
1453f461d2dcSChristoph Hellwig  *
1454f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1455f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1456f461d2dcSChristoph Hellwig  * The values read are assumed to be in 1/USER_HZ seconds, and
1457f461d2dcSChristoph Hellwig  * are converted into jiffies.
1458f461d2dcSChristoph Hellwig  *
1459f461d2dcSChristoph Hellwig  * Returns 0 on success.
1460f461d2dcSChristoph Hellwig  */
1461f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
146232927393SChristoph Hellwig 				 void *buffer, size_t *lenp, loff_t *ppos)
1463f461d2dcSChristoph Hellwig {
1464f461d2dcSChristoph Hellwig     return do_proc_dointvec(table,write,buffer,lenp,ppos,
1465f461d2dcSChristoph Hellwig 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
1466f461d2dcSChristoph Hellwig }
1467f461d2dcSChristoph Hellwig 
1468f461d2dcSChristoph Hellwig /**
1469f461d2dcSChristoph Hellwig  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1470f461d2dcSChristoph Hellwig  * @table: the sysctl table
1471f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1472f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1473f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1474f461d2dcSChristoph Hellwig  * @ppos: file position
1475f461d2dcSChristoph Hellwig  * @ppos: the current position in the file
1476f461d2dcSChristoph Hellwig  *
1477f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1478f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1479f461d2dcSChristoph Hellwig  * The values read are assumed to be in 1/1000 seconds, and
1480f461d2dcSChristoph Hellwig  * are converted into jiffies.
1481f461d2dcSChristoph Hellwig  *
1482f461d2dcSChristoph Hellwig  * Returns 0 on success.
1483f461d2dcSChristoph Hellwig  */
148432927393SChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
148532927393SChristoph Hellwig 		size_t *lenp, loff_t *ppos)
1486f461d2dcSChristoph Hellwig {
1487f461d2dcSChristoph Hellwig 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
1488f461d2dcSChristoph Hellwig 				do_proc_dointvec_ms_jiffies_conv, NULL);
1489f461d2dcSChristoph Hellwig }
1490f461d2dcSChristoph Hellwig 
149132927393SChristoph Hellwig static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
149232927393SChristoph Hellwig 		size_t *lenp, loff_t *ppos)
1493f461d2dcSChristoph Hellwig {
1494f461d2dcSChristoph Hellwig 	struct pid *new_pid;
1495f461d2dcSChristoph Hellwig 	pid_t tmp;
1496f461d2dcSChristoph Hellwig 	int r;
1497f461d2dcSChristoph Hellwig 
1498f461d2dcSChristoph Hellwig 	tmp = pid_vnr(cad_pid);
1499f461d2dcSChristoph Hellwig 
1500f461d2dcSChristoph Hellwig 	r = __do_proc_dointvec(&tmp, table, write, buffer,
1501f461d2dcSChristoph Hellwig 			       lenp, ppos, NULL, NULL);
1502f461d2dcSChristoph Hellwig 	if (r || !write)
1503f461d2dcSChristoph Hellwig 		return r;
1504f461d2dcSChristoph Hellwig 
1505f461d2dcSChristoph Hellwig 	new_pid = find_get_pid(tmp);
1506f461d2dcSChristoph Hellwig 	if (!new_pid)
1507f461d2dcSChristoph Hellwig 		return -ESRCH;
1508f461d2dcSChristoph Hellwig 
1509f461d2dcSChristoph Hellwig 	put_pid(xchg(&cad_pid, new_pid));
1510f461d2dcSChristoph Hellwig 	return 0;
1511f461d2dcSChristoph Hellwig }
1512f461d2dcSChristoph Hellwig 
1513f461d2dcSChristoph Hellwig /**
1514f461d2dcSChristoph Hellwig  * proc_do_large_bitmap - read/write from/to a large bitmap
1515f461d2dcSChristoph Hellwig  * @table: the sysctl table
1516f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1517f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1518f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1519f461d2dcSChristoph Hellwig  * @ppos: file position
1520f461d2dcSChristoph Hellwig  *
1521f461d2dcSChristoph Hellwig  * The bitmap is stored at table->data and the bitmap length (in bits)
1522f461d2dcSChristoph Hellwig  * in table->maxlen.
1523f461d2dcSChristoph Hellwig  *
1524f461d2dcSChristoph Hellwig  * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1525f461d2dcSChristoph Hellwig  * large bitmaps may be represented in a compact manner. Writing into
1526f461d2dcSChristoph Hellwig  * the file will clear the bitmap then update it with the given input.
1527f461d2dcSChristoph Hellwig  *
1528f461d2dcSChristoph Hellwig  * Returns 0 on success.
1529f461d2dcSChristoph Hellwig  */
1530f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write,
153132927393SChristoph Hellwig 			 void *buffer, size_t *lenp, loff_t *ppos)
1532f461d2dcSChristoph Hellwig {
1533f461d2dcSChristoph Hellwig 	int err = 0;
1534f461d2dcSChristoph Hellwig 	size_t left = *lenp;
1535f461d2dcSChristoph Hellwig 	unsigned long bitmap_len = table->maxlen;
1536f461d2dcSChristoph Hellwig 	unsigned long *bitmap = *(unsigned long **) table->data;
1537f461d2dcSChristoph Hellwig 	unsigned long *tmp_bitmap = NULL;
1538f461d2dcSChristoph Hellwig 	char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1539f461d2dcSChristoph Hellwig 
1540f461d2dcSChristoph Hellwig 	if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1541f461d2dcSChristoph Hellwig 		*lenp = 0;
1542f461d2dcSChristoph Hellwig 		return 0;
1543f461d2dcSChristoph Hellwig 	}
1544f461d2dcSChristoph Hellwig 
1545f461d2dcSChristoph Hellwig 	if (write) {
154632927393SChristoph Hellwig 		char *p = buffer;
1547f461d2dcSChristoph Hellwig 		size_t skipped = 0;
1548f461d2dcSChristoph Hellwig 
1549f461d2dcSChristoph Hellwig 		if (left > PAGE_SIZE - 1) {
1550f461d2dcSChristoph Hellwig 			left = PAGE_SIZE - 1;
1551f461d2dcSChristoph Hellwig 			/* How much of the buffer we'll skip this pass */
1552f461d2dcSChristoph Hellwig 			skipped = *lenp - left;
1553f461d2dcSChristoph Hellwig 		}
1554f461d2dcSChristoph Hellwig 
1555f461d2dcSChristoph Hellwig 		tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
155632927393SChristoph Hellwig 		if (!tmp_bitmap)
1557f461d2dcSChristoph Hellwig 			return -ENOMEM;
1558f461d2dcSChristoph Hellwig 		proc_skip_char(&p, &left, '\n');
1559f461d2dcSChristoph Hellwig 		while (!err && left) {
1560f461d2dcSChristoph Hellwig 			unsigned long val_a, val_b;
1561f461d2dcSChristoph Hellwig 			bool neg;
1562f461d2dcSChristoph Hellwig 			size_t saved_left;
1563f461d2dcSChristoph Hellwig 
1564f461d2dcSChristoph Hellwig 			/* In case we stop parsing mid-number, we can reset */
1565f461d2dcSChristoph Hellwig 			saved_left = left;
1566f461d2dcSChristoph Hellwig 			err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1567f461d2dcSChristoph Hellwig 					     sizeof(tr_a), &c);
1568f461d2dcSChristoph Hellwig 			/*
1569f461d2dcSChristoph Hellwig 			 * If we consumed the entirety of a truncated buffer or
1570f461d2dcSChristoph Hellwig 			 * only one char is left (may be a "-"), then stop here,
1571f461d2dcSChristoph Hellwig 			 * reset, & come back for more.
1572f461d2dcSChristoph Hellwig 			 */
1573f461d2dcSChristoph Hellwig 			if ((left <= 1) && skipped) {
1574f461d2dcSChristoph Hellwig 				left = saved_left;
1575f461d2dcSChristoph Hellwig 				break;
1576f461d2dcSChristoph Hellwig 			}
1577f461d2dcSChristoph Hellwig 
1578f461d2dcSChristoph Hellwig 			if (err)
1579f461d2dcSChristoph Hellwig 				break;
1580f461d2dcSChristoph Hellwig 			if (val_a >= bitmap_len || neg) {
1581f461d2dcSChristoph Hellwig 				err = -EINVAL;
1582f461d2dcSChristoph Hellwig 				break;
1583f461d2dcSChristoph Hellwig 			}
1584f461d2dcSChristoph Hellwig 
1585f461d2dcSChristoph Hellwig 			val_b = val_a;
1586f461d2dcSChristoph Hellwig 			if (left) {
1587f461d2dcSChristoph Hellwig 				p++;
1588f461d2dcSChristoph Hellwig 				left--;
1589f461d2dcSChristoph Hellwig 			}
1590f461d2dcSChristoph Hellwig 
1591f461d2dcSChristoph Hellwig 			if (c == '-') {
1592f461d2dcSChristoph Hellwig 				err = proc_get_long(&p, &left, &val_b,
1593f461d2dcSChristoph Hellwig 						     &neg, tr_b, sizeof(tr_b),
1594f461d2dcSChristoph Hellwig 						     &c);
1595f461d2dcSChristoph Hellwig 				/*
1596f461d2dcSChristoph Hellwig 				 * If we consumed all of a truncated buffer or
1597f461d2dcSChristoph Hellwig 				 * then stop here, reset, & come back for more.
1598f461d2dcSChristoph Hellwig 				 */
1599f461d2dcSChristoph Hellwig 				if (!left && skipped) {
1600f461d2dcSChristoph Hellwig 					left = saved_left;
1601f461d2dcSChristoph Hellwig 					break;
1602f461d2dcSChristoph Hellwig 				}
1603f461d2dcSChristoph Hellwig 
1604f461d2dcSChristoph Hellwig 				if (err)
1605f461d2dcSChristoph Hellwig 					break;
1606f461d2dcSChristoph Hellwig 				if (val_b >= bitmap_len || neg ||
1607f461d2dcSChristoph Hellwig 				    val_a > val_b) {
1608f461d2dcSChristoph Hellwig 					err = -EINVAL;
1609f461d2dcSChristoph Hellwig 					break;
1610f461d2dcSChristoph Hellwig 				}
1611f461d2dcSChristoph Hellwig 				if (left) {
1612f461d2dcSChristoph Hellwig 					p++;
1613f461d2dcSChristoph Hellwig 					left--;
1614f461d2dcSChristoph Hellwig 				}
1615f461d2dcSChristoph Hellwig 			}
1616f461d2dcSChristoph Hellwig 
1617f461d2dcSChristoph Hellwig 			bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1618f461d2dcSChristoph Hellwig 			proc_skip_char(&p, &left, '\n');
1619f461d2dcSChristoph Hellwig 		}
1620f461d2dcSChristoph Hellwig 		left += skipped;
1621f461d2dcSChristoph Hellwig 	} else {
1622f461d2dcSChristoph Hellwig 		unsigned long bit_a, bit_b = 0;
16239a52c5f3SJiapeng Chong 		bool first = 1;
1624f461d2dcSChristoph Hellwig 
1625f461d2dcSChristoph Hellwig 		while (left) {
1626f461d2dcSChristoph Hellwig 			bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1627f461d2dcSChristoph Hellwig 			if (bit_a >= bitmap_len)
1628f461d2dcSChristoph Hellwig 				break;
1629f461d2dcSChristoph Hellwig 			bit_b = find_next_zero_bit(bitmap, bitmap_len,
1630f461d2dcSChristoph Hellwig 						   bit_a + 1) - 1;
1631f461d2dcSChristoph Hellwig 
163232927393SChristoph Hellwig 			if (!first)
163332927393SChristoph Hellwig 				proc_put_char(&buffer, &left, ',');
163432927393SChristoph Hellwig 			proc_put_long(&buffer, &left, bit_a, false);
1635f461d2dcSChristoph Hellwig 			if (bit_a != bit_b) {
163632927393SChristoph Hellwig 				proc_put_char(&buffer, &left, '-');
163732927393SChristoph Hellwig 				proc_put_long(&buffer, &left, bit_b, false);
1638f461d2dcSChristoph Hellwig 			}
1639f461d2dcSChristoph Hellwig 
1640f461d2dcSChristoph Hellwig 			first = 0; bit_b++;
1641f461d2dcSChristoph Hellwig 		}
164232927393SChristoph Hellwig 		proc_put_char(&buffer, &left, '\n');
1643f461d2dcSChristoph Hellwig 	}
1644f461d2dcSChristoph Hellwig 
1645f461d2dcSChristoph Hellwig 	if (!err) {
1646f461d2dcSChristoph Hellwig 		if (write) {
1647f461d2dcSChristoph Hellwig 			if (*ppos)
1648f461d2dcSChristoph Hellwig 				bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1649f461d2dcSChristoph Hellwig 			else
1650f461d2dcSChristoph Hellwig 				bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1651f461d2dcSChristoph Hellwig 		}
1652f461d2dcSChristoph Hellwig 		*lenp -= left;
1653f461d2dcSChristoph Hellwig 		*ppos += *lenp;
1654f461d2dcSChristoph Hellwig 	}
1655f461d2dcSChristoph Hellwig 
1656f461d2dcSChristoph Hellwig 	bitmap_free(tmp_bitmap);
1657f461d2dcSChristoph Hellwig 	return err;
1658f461d2dcSChristoph Hellwig }
1659f461d2dcSChristoph Hellwig 
1660f461d2dcSChristoph Hellwig #else /* CONFIG_PROC_SYSCTL */
1661f461d2dcSChristoph Hellwig 
1662f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write,
166332927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1664f461d2dcSChristoph Hellwig {
1665f461d2dcSChristoph Hellwig 	return -ENOSYS;
1666f461d2dcSChristoph Hellwig }
1667f461d2dcSChristoph Hellwig 
1668*a2071573SJia He int proc_dobool(struct ctl_table *table, int write,
1669*a2071573SJia He 		void *buffer, size_t *lenp, loff_t *ppos)
1670*a2071573SJia He {
1671*a2071573SJia He 	return -ENOSYS;
1672*a2071573SJia He }
1673*a2071573SJia He 
1674f461d2dcSChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write,
167532927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1676f461d2dcSChristoph Hellwig {
1677f461d2dcSChristoph Hellwig 	return -ENOSYS;
1678f461d2dcSChristoph Hellwig }
1679f461d2dcSChristoph Hellwig 
1680f461d2dcSChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write,
168132927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1682f461d2dcSChristoph Hellwig {
1683f461d2dcSChristoph Hellwig 	return -ENOSYS;
1684f461d2dcSChristoph Hellwig }
1685f461d2dcSChristoph Hellwig 
1686f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write,
168732927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1688f461d2dcSChristoph Hellwig {
1689f461d2dcSChristoph Hellwig 	return -ENOSYS;
1690f461d2dcSChristoph Hellwig }
1691f461d2dcSChristoph Hellwig 
1692f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write,
169332927393SChristoph Hellwig 			  void *buffer, size_t *lenp, loff_t *ppos)
1694f461d2dcSChristoph Hellwig {
1695f461d2dcSChristoph Hellwig 	return -ENOSYS;
1696f461d2dcSChristoph Hellwig }
1697f461d2dcSChristoph Hellwig 
1698cb944413SEric Dumazet int proc_dou8vec_minmax(struct ctl_table *table, int write,
1699cb944413SEric Dumazet 			void *buffer, size_t *lenp, loff_t *ppos)
1700cb944413SEric Dumazet {
1701cb944413SEric Dumazet 	return -ENOSYS;
1702cb944413SEric Dumazet }
1703cb944413SEric Dumazet 
1704f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write,
170532927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1706f461d2dcSChristoph Hellwig {
1707f461d2dcSChristoph Hellwig 	return -ENOSYS;
1708f461d2dcSChristoph Hellwig }
1709f461d2dcSChristoph Hellwig 
1710f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
171132927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1712f461d2dcSChristoph Hellwig {
1713f461d2dcSChristoph Hellwig 	return -ENOSYS;
1714f461d2dcSChristoph Hellwig }
1715f461d2dcSChristoph Hellwig 
1716f461d2dcSChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
171732927393SChristoph Hellwig 			     void *buffer, size_t *lenp, loff_t *ppos)
1718f461d2dcSChristoph Hellwig {
1719f461d2dcSChristoph Hellwig 	return -ENOSYS;
1720f461d2dcSChristoph Hellwig }
1721f461d2dcSChristoph Hellwig 
1722f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write,
172332927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1724f461d2dcSChristoph Hellwig {
1725f461d2dcSChristoph Hellwig 	return -ENOSYS;
1726f461d2dcSChristoph Hellwig }
1727f461d2dcSChristoph Hellwig 
1728f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
172932927393SChristoph Hellwig 				      void *buffer, size_t *lenp, loff_t *ppos)
1730f461d2dcSChristoph Hellwig {
1731f461d2dcSChristoph Hellwig 	return -ENOSYS;
1732f461d2dcSChristoph Hellwig }
1733f461d2dcSChristoph Hellwig 
1734f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write,
173532927393SChristoph Hellwig 			 void *buffer, size_t *lenp, loff_t *ppos)
1736f461d2dcSChristoph Hellwig {
1737f461d2dcSChristoph Hellwig 	return -ENOSYS;
1738f461d2dcSChristoph Hellwig }
1739f461d2dcSChristoph Hellwig 
1740f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */
1741f461d2dcSChristoph Hellwig 
1742f461d2dcSChristoph Hellwig #if defined(CONFIG_SYSCTL)
1743f461d2dcSChristoph Hellwig int proc_do_static_key(struct ctl_table *table, int write,
174432927393SChristoph Hellwig 		       void *buffer, size_t *lenp, loff_t *ppos)
1745f461d2dcSChristoph Hellwig {
1746f461d2dcSChristoph Hellwig 	struct static_key *key = (struct static_key *)table->data;
1747f461d2dcSChristoph Hellwig 	static DEFINE_MUTEX(static_key_mutex);
1748f461d2dcSChristoph Hellwig 	int val, ret;
1749f461d2dcSChristoph Hellwig 	struct ctl_table tmp = {
1750f461d2dcSChristoph Hellwig 		.data   = &val,
1751f461d2dcSChristoph Hellwig 		.maxlen = sizeof(val),
1752f461d2dcSChristoph Hellwig 		.mode   = table->mode,
1753f461d2dcSChristoph Hellwig 		.extra1 = SYSCTL_ZERO,
1754f461d2dcSChristoph Hellwig 		.extra2 = SYSCTL_ONE,
1755f461d2dcSChristoph Hellwig 	};
1756f461d2dcSChristoph Hellwig 
1757f461d2dcSChristoph Hellwig 	if (write && !capable(CAP_SYS_ADMIN))
1758f461d2dcSChristoph Hellwig 		return -EPERM;
1759f461d2dcSChristoph Hellwig 
1760f461d2dcSChristoph Hellwig 	mutex_lock(&static_key_mutex);
1761f461d2dcSChristoph Hellwig 	val = static_key_enabled(key);
1762f461d2dcSChristoph Hellwig 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1763f461d2dcSChristoph Hellwig 	if (write && !ret) {
1764f461d2dcSChristoph Hellwig 		if (val)
1765f461d2dcSChristoph Hellwig 			static_key_enable(key);
1766f461d2dcSChristoph Hellwig 		else
1767f461d2dcSChristoph Hellwig 			static_key_disable(key);
1768f461d2dcSChristoph Hellwig 	}
1769f461d2dcSChristoph Hellwig 	mutex_unlock(&static_key_mutex);
1770f461d2dcSChristoph Hellwig 	return ret;
1771f461d2dcSChristoph Hellwig }
1772f461d2dcSChristoph Hellwig 
1773d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
17742bba22c5SMike Galbraith 	{
17752bba22c5SMike Galbraith 		.procname	= "sched_child_runs_first",
17762bba22c5SMike Galbraith 		.data		= &sysctl_sched_child_runs_first,
17772bba22c5SMike Galbraith 		.maxlen		= sizeof(unsigned int),
17782bba22c5SMike Galbraith 		.mode		= 0644,
17796d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
17802bba22c5SMike Galbraith 	},
17811d1c2509SPeter Zijlstra #ifdef CONFIG_SCHEDSTATS
17821d1c2509SPeter Zijlstra 	{
17831d1c2509SPeter Zijlstra 		.procname	= "sched_schedstats",
17841d1c2509SPeter Zijlstra 		.data		= NULL,
17851d1c2509SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
17861d1c2509SPeter Zijlstra 		.mode		= 0644,
17871d1c2509SPeter Zijlstra 		.proc_handler	= sysctl_schedstats,
17881d1c2509SPeter Zijlstra 		.extra1		= SYSCTL_ZERO,
17891d1c2509SPeter Zijlstra 		.extra2		= SYSCTL_ONE,
17901d1c2509SPeter Zijlstra 	},
17911d1c2509SPeter Zijlstra #endif /* CONFIG_SCHEDSTATS */
17920cd7c741SPeter Zijlstra #ifdef CONFIG_TASK_DELAY_ACCT
17930cd7c741SPeter Zijlstra 	{
17940cd7c741SPeter Zijlstra 		.procname	= "task_delayacct",
17950cd7c741SPeter Zijlstra 		.data		= NULL,
17960cd7c741SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
17970cd7c741SPeter Zijlstra 		.mode		= 0644,
17980cd7c741SPeter Zijlstra 		.proc_handler	= sysctl_delayacct,
17990cd7c741SPeter Zijlstra 		.extra1		= SYSCTL_ZERO,
18000cd7c741SPeter Zijlstra 		.extra2		= SYSCTL_ONE,
18010cd7c741SPeter Zijlstra 	},
18020cd7c741SPeter Zijlstra #endif /* CONFIG_TASK_DELAY_ACCT */
1803b7cc6ec7SMel Gorman #ifdef CONFIG_NUMA_BALANCING
18043a7053b3SMel Gorman 	{
180554a43d54SAndi Kleen 		.procname	= "numa_balancing",
180654a43d54SAndi Kleen 		.data		= NULL, /* filled in by handler */
180754a43d54SAndi Kleen 		.maxlen		= sizeof(unsigned int),
180854a43d54SAndi Kleen 		.mode		= 0644,
180954a43d54SAndi Kleen 		.proc_handler	= sysctl_numa_balancing,
1810eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1811eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
181254a43d54SAndi Kleen 	},
1813cbee9f88SPeter Zijlstra #endif /* CONFIG_NUMA_BALANCING */
18141799e35dSIngo Molnar 	{
18159f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
18169f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
18179f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
18189f0c1e56SPeter Zijlstra 		.mode		= 0644,
18196d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
18209f0c1e56SPeter Zijlstra 	},
18219f0c1e56SPeter Zijlstra 	{
18229f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
18239f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
18249f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
18259f0c1e56SPeter Zijlstra 		.mode		= 0644,
18266d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
18279f0c1e56SPeter Zijlstra 	},
1828ce0dbbbbSClark Williams 	{
1829b4098bfcSPeter Zijlstra 		.procname	= "sched_deadline_period_max_us",
1830b4098bfcSPeter Zijlstra 		.data		= &sysctl_sched_dl_period_max,
1831b4098bfcSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
1832b4098bfcSPeter Zijlstra 		.mode		= 0644,
1833b4098bfcSPeter Zijlstra 		.proc_handler	= proc_dointvec,
1834b4098bfcSPeter Zijlstra 	},
1835b4098bfcSPeter Zijlstra 	{
1836b4098bfcSPeter Zijlstra 		.procname	= "sched_deadline_period_min_us",
1837b4098bfcSPeter Zijlstra 		.data		= &sysctl_sched_dl_period_min,
1838b4098bfcSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
1839b4098bfcSPeter Zijlstra 		.mode		= 0644,
1840b4098bfcSPeter Zijlstra 		.proc_handler	= proc_dointvec,
1841b4098bfcSPeter Zijlstra 	},
1842b4098bfcSPeter Zijlstra 	{
1843ce0dbbbbSClark Williams 		.procname	= "sched_rr_timeslice_ms",
1844975e155eSShile Zhang 		.data		= &sysctl_sched_rr_timeslice,
1845ce0dbbbbSClark Williams 		.maxlen		= sizeof(int),
1846ce0dbbbbSClark Williams 		.mode		= 0644,
1847ce0dbbbbSClark Williams 		.proc_handler	= sched_rr_handler,
1848ce0dbbbbSClark Williams 	},
1849e8f14172SPatrick Bellasi #ifdef CONFIG_UCLAMP_TASK
1850e8f14172SPatrick Bellasi 	{
1851e8f14172SPatrick Bellasi 		.procname	= "sched_util_clamp_min",
1852e8f14172SPatrick Bellasi 		.data		= &sysctl_sched_uclamp_util_min,
1853e8f14172SPatrick Bellasi 		.maxlen		= sizeof(unsigned int),
1854e8f14172SPatrick Bellasi 		.mode		= 0644,
1855e8f14172SPatrick Bellasi 		.proc_handler	= sysctl_sched_uclamp_handler,
1856e8f14172SPatrick Bellasi 	},
1857e8f14172SPatrick Bellasi 	{
1858e8f14172SPatrick Bellasi 		.procname	= "sched_util_clamp_max",
1859e8f14172SPatrick Bellasi 		.data		= &sysctl_sched_uclamp_util_max,
1860e8f14172SPatrick Bellasi 		.maxlen		= sizeof(unsigned int),
1861e8f14172SPatrick Bellasi 		.mode		= 0644,
1862e8f14172SPatrick Bellasi 		.proc_handler	= sysctl_sched_uclamp_handler,
1863e8f14172SPatrick Bellasi 	},
186413685c4aSQais Yousef 	{
186513685c4aSQais Yousef 		.procname	= "sched_util_clamp_min_rt_default",
186613685c4aSQais Yousef 		.data		= &sysctl_sched_uclamp_util_min_rt_default,
186713685c4aSQais Yousef 		.maxlen		= sizeof(unsigned int),
186813685c4aSQais Yousef 		.mode		= 0644,
186913685c4aSQais Yousef 		.proc_handler	= sysctl_sched_uclamp_handler,
187013685c4aSQais Yousef 	},
1871e8f14172SPatrick Bellasi #endif
18725091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP
18735091faa4SMike Galbraith 	{
18745091faa4SMike Galbraith 		.procname	= "sched_autogroup_enabled",
18755091faa4SMike Galbraith 		.data		= &sysctl_sched_autogroup_enabled,
18765091faa4SMike Galbraith 		.maxlen		= sizeof(unsigned int),
18775091faa4SMike Galbraith 		.mode		= 0644,
18781747b21fSYong Zhang 		.proc_handler	= proc_dointvec_minmax,
1879eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1880eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
18815091faa4SMike Galbraith 	},
18825091faa4SMike Galbraith #endif
1883ec12cb7fSPaul Turner #ifdef CONFIG_CFS_BANDWIDTH
1884ec12cb7fSPaul Turner 	{
1885ec12cb7fSPaul Turner 		.procname	= "sched_cfs_bandwidth_slice_us",
1886ec12cb7fSPaul Turner 		.data		= &sysctl_sched_cfs_bandwidth_slice,
1887ec12cb7fSPaul Turner 		.maxlen		= sizeof(unsigned int),
1888ec12cb7fSPaul Turner 		.mode		= 0644,
1889ec12cb7fSPaul Turner 		.proc_handler	= proc_dointvec_minmax,
1890eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
1891ec12cb7fSPaul Turner 	},
1892ec12cb7fSPaul Turner #endif
18938d5d0cfbSQuentin Perret #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
18948d5d0cfbSQuentin Perret 	{
18958d5d0cfbSQuentin Perret 		.procname	= "sched_energy_aware",
18968d5d0cfbSQuentin Perret 		.data		= &sysctl_sched_energy_aware,
18978d5d0cfbSQuentin Perret 		.maxlen		= sizeof(unsigned int),
18988d5d0cfbSQuentin Perret 		.mode		= 0644,
18998d5d0cfbSQuentin Perret 		.proc_handler	= sched_energy_aware_handler,
1900eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1901eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
19028d5d0cfbSQuentin Perret 	},
19038d5d0cfbSQuentin Perret #endif
1904f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
1905f20786ffSPeter Zijlstra 	{
1906f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
1907f20786ffSPeter Zijlstra 		.data		= &prove_locking,
1908f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
1909f20786ffSPeter Zijlstra 		.mode		= 0644,
19106d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1911f20786ffSPeter Zijlstra 	},
1912f20786ffSPeter Zijlstra #endif
1913f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
1914f20786ffSPeter Zijlstra 	{
1915f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
1916f20786ffSPeter Zijlstra 		.data		= &lock_stat,
1917f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
1918f20786ffSPeter Zijlstra 		.mode		= 0644,
19196d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1920f20786ffSPeter Zijlstra 	},
1921f20786ffSPeter Zijlstra #endif
192277e54a1fSIngo Molnar 	{
19231da177e4SLinus Torvalds 		.procname	= "panic",
19241da177e4SLinus Torvalds 		.data		= &panic_timeout,
19251da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
19261da177e4SLinus Torvalds 		.mode		= 0644,
19276d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19281da177e4SLinus Torvalds 	},
1929046d662fSAlex Kelly #ifdef CONFIG_COREDUMP
19301da177e4SLinus Torvalds 	{
19311da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
19321da177e4SLinus Torvalds 		.data		= &core_uses_pid,
19331da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
19341da177e4SLinus Torvalds 		.mode		= 0644,
19356d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19361da177e4SLinus Torvalds 	},
19371da177e4SLinus Torvalds 	{
19381da177e4SLinus Torvalds 		.procname	= "core_pattern",
19391da177e4SLinus Torvalds 		.data		= core_pattern,
194071ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
19411da177e4SLinus Torvalds 		.mode		= 0644,
194254b50199SKees Cook 		.proc_handler	= proc_dostring_coredump,
19431da177e4SLinus Torvalds 	},
1944a293980cSNeil Horman 	{
1945a293980cSNeil Horman 		.procname	= "core_pipe_limit",
1946a293980cSNeil Horman 		.data		= &core_pipe_limit,
1947a293980cSNeil Horman 		.maxlen		= sizeof(unsigned int),
1948a293980cSNeil Horman 		.mode		= 0644,
19496d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1950a293980cSNeil Horman 	},
1951046d662fSAlex Kelly #endif
195234f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
19531da177e4SLinus Torvalds 	{
19541da177e4SLinus Torvalds 		.procname	= "tainted",
195525ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
195634f5a398STheodore Ts'o 		.mode		= 0644,
19576d456111SEric W. Biederman 		.proc_handler	= proc_taint,
19581da177e4SLinus Torvalds 	},
1959f4aacea2SKees Cook 	{
1960f4aacea2SKees Cook 		.procname	= "sysctl_writes_strict",
1961f4aacea2SKees Cook 		.data		= &sysctl_writes_strict,
1962f4aacea2SKees Cook 		.maxlen		= sizeof(int),
1963f4aacea2SKees Cook 		.mode		= 0644,
1964f4aacea2SKees Cook 		.proc_handler	= proc_dointvec_minmax,
1965f4aacea2SKees Cook 		.extra1		= &neg_one,
1966eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
1967f4aacea2SKees Cook 	},
196834f5a398STheodore Ts'o #endif
19699745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
19709745512cSArjan van de Ven 	{
19719745512cSArjan van de Ven 		.procname	= "latencytop",
19729745512cSArjan van de Ven 		.data		= &latencytop_enabled,
19739745512cSArjan van de Ven 		.maxlen		= sizeof(int),
19749745512cSArjan van de Ven 		.mode		= 0644,
1975cb251765SMel Gorman 		.proc_handler	= sysctl_latencytop,
19769745512cSArjan van de Ven 	},
19779745512cSArjan van de Ven #endif
19781da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
19791da177e4SLinus Torvalds 	{
19801da177e4SLinus Torvalds 		.procname	= "real-root-dev",
19811da177e4SLinus Torvalds 		.data		= &real_root_dev,
19821da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
19831da177e4SLinus Torvalds 		.mode		= 0644,
19846d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19851da177e4SLinus Torvalds 	},
19861da177e4SLinus Torvalds #endif
198745807a1dSIngo Molnar 	{
198845807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
198945807a1dSIngo Molnar 		.data		= &print_fatal_signals,
199045807a1dSIngo Molnar 		.maxlen		= sizeof(int),
199145807a1dSIngo Molnar 		.mode		= 0644,
19926d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
199345807a1dSIngo Molnar 	},
199472c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
19951da177e4SLinus Torvalds 	{
19961da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
19971da177e4SLinus Torvalds 		.data		= reboot_command,
19981da177e4SLinus Torvalds 		.maxlen		= 256,
19991da177e4SLinus Torvalds 		.mode		= 0644,
20006d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
20011da177e4SLinus Torvalds 	},
20021da177e4SLinus Torvalds 	{
20031da177e4SLinus Torvalds 		.procname	= "stop-a",
20041da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
20051da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
20061da177e4SLinus Torvalds 		.mode		= 0644,
20076d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
20081da177e4SLinus Torvalds 	},
20091da177e4SLinus Torvalds 	{
20101da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
20111da177e4SLinus Torvalds 		.data		= &scons_pwroff,
20121da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
20131da177e4SLinus Torvalds 		.mode		= 0644,
20146d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
20151da177e4SLinus Torvalds 	},
20161da177e4SLinus Torvalds #endif
20170871420fSDavid S. Miller #ifdef CONFIG_SPARC64
20180871420fSDavid S. Miller 	{
20190871420fSDavid S. Miller 		.procname	= "tsb-ratio",
20200871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
20210871420fSDavid S. Miller 		.maxlen		= sizeof (int),
20220871420fSDavid S. Miller 		.mode		= 0644,
20236d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
20240871420fSDavid S. Miller 	},
20250871420fSDavid S. Miller #endif
2026b67114dbSHelge Deller #ifdef CONFIG_PARISC
20271da177e4SLinus Torvalds 	{
20281da177e4SLinus Torvalds 		.procname	= "soft-power",
20291da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
20301da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
20311da177e4SLinus Torvalds 		.mode		= 0644,
20326d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
20331da177e4SLinus Torvalds 	},
2034bf14e3b9SVineet Gupta #endif
2035bf14e3b9SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
20361da177e4SLinus Torvalds 	{
20371da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
20381da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
20391da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
20401da177e4SLinus Torvalds 		.mode		= 0644,
20416d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
20421da177e4SLinus Torvalds 	},
20431da177e4SLinus Torvalds #endif
20441da177e4SLinus Torvalds 	{
20451da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
20461da177e4SLinus Torvalds 		.data		= &C_A_D,
20471da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
20481da177e4SLinus Torvalds 		.mode		= 0644,
20496d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
20501da177e4SLinus Torvalds 	},
2051606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
2052b0fc494fSSteven Rostedt 	{
2053b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
2054b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
2055b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
2056b0fc494fSSteven Rostedt 		.mode		= 0644,
20576d456111SEric W. Biederman 		.proc_handler	= ftrace_enable_sysctl,
2058b0fc494fSSteven Rostedt 	},
2059b0fc494fSSteven Rostedt #endif
2060f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
2061f38f1d2aSSteven Rostedt 	{
2062f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
2063f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
2064f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
2065f38f1d2aSSteven Rostedt 		.mode		= 0644,
20666d456111SEric W. Biederman 		.proc_handler	= stack_trace_sysctl,
2067f38f1d2aSSteven Rostedt 	},
2068f38f1d2aSSteven Rostedt #endif
2069944ac425SSteven Rostedt #ifdef CONFIG_TRACING
2070944ac425SSteven Rostedt 	{
20713299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
2072944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
2073944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
2074944ac425SSteven Rostedt 		.mode		= 0644,
20756d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2076944ac425SSteven Rostedt 	},
2077de7edd31SSteven Rostedt (Red Hat) 	{
2078de7edd31SSteven Rostedt (Red Hat) 		.procname	= "traceoff_on_warning",
2079de7edd31SSteven Rostedt (Red Hat) 		.data		= &__disable_trace_on_warning,
2080de7edd31SSteven Rostedt (Red Hat) 		.maxlen		= sizeof(__disable_trace_on_warning),
2081de7edd31SSteven Rostedt (Red Hat) 		.mode		= 0644,
2082de7edd31SSteven Rostedt (Red Hat) 		.proc_handler	= proc_dointvec,
2083de7edd31SSteven Rostedt (Red Hat) 	},
20840daa2302SSteven Rostedt (Red Hat) 	{
20850daa2302SSteven Rostedt (Red Hat) 		.procname	= "tracepoint_printk",
20860daa2302SSteven Rostedt (Red Hat) 		.data		= &tracepoint_printk,
20870daa2302SSteven Rostedt (Red Hat) 		.maxlen		= sizeof(tracepoint_printk),
20880daa2302SSteven Rostedt (Red Hat) 		.mode		= 0644,
208942391745SSteven Rostedt (Red Hat) 		.proc_handler	= tracepoint_printk_sysctl,
20900daa2302SSteven Rostedt (Red Hat) 	},
2091944ac425SSteven Rostedt #endif
20922965faa5SDave Young #ifdef CONFIG_KEXEC_CORE
20937984754bSKees Cook 	{
20947984754bSKees Cook 		.procname	= "kexec_load_disabled",
20957984754bSKees Cook 		.data		= &kexec_load_disabled,
20967984754bSKees Cook 		.maxlen		= sizeof(int),
20977984754bSKees Cook 		.mode		= 0644,
20987984754bSKees Cook 		/* only handle a transition from default "0" to "1" */
20997984754bSKees Cook 		.proc_handler	= proc_dointvec_minmax,
2100eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2101eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
21027984754bSKees Cook 	},
21037984754bSKees Cook #endif
2104a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
21051da177e4SLinus Torvalds 	{
21061da177e4SLinus Torvalds 		.procname	= "modprobe",
21071da177e4SLinus Torvalds 		.data		= &modprobe_path,
21081da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
21091da177e4SLinus Torvalds 		.mode		= 0644,
21106d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
21111da177e4SLinus Torvalds 	},
21123d43321bSKees Cook 	{
21133d43321bSKees Cook 		.procname	= "modules_disabled",
21143d43321bSKees Cook 		.data		= &modules_disabled,
21153d43321bSKees Cook 		.maxlen		= sizeof(int),
21163d43321bSKees Cook 		.mode		= 0644,
21173d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
21186d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2119eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2120eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
21213d43321bSKees Cook 	},
21221da177e4SLinus Torvalds #endif
212386d56134SMichael Marineau #ifdef CONFIG_UEVENT_HELPER
21241da177e4SLinus Torvalds 	{
21251da177e4SLinus Torvalds 		.procname	= "hotplug",
2126312c004dSKay Sievers 		.data		= &uevent_helper,
2127312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
21281da177e4SLinus Torvalds 		.mode		= 0644,
21296d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
21301da177e4SLinus Torvalds 	},
213186d56134SMichael Marineau #endif
21321da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
21331da177e4SLinus Torvalds 	{
21341da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
21351da177e4SLinus Torvalds 		.data		= &sg_big_buff,
21361da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
21371da177e4SLinus Torvalds 		.mode		= 0444,
21386d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
21391da177e4SLinus Torvalds 	},
21401da177e4SLinus Torvalds #endif
21411da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
21421da177e4SLinus Torvalds 	{
21431da177e4SLinus Torvalds 		.procname	= "acct",
21441da177e4SLinus Torvalds 		.data		= &acct_parm,
21451da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
21461da177e4SLinus Torvalds 		.mode		= 0644,
21476d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
21481da177e4SLinus Torvalds 	},
21491da177e4SLinus Torvalds #endif
21501da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
21511da177e4SLinus Torvalds 	{
21521da177e4SLinus Torvalds 		.procname	= "sysrq",
2153eaee4172SDmitry Safonov 		.data		= NULL,
21541da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
21551da177e4SLinus Torvalds 		.mode		= 0644,
215697f5f0cdSDmitry Torokhov 		.proc_handler	= sysrq_sysctl_handler,
21571da177e4SLinus Torvalds 	},
21581da177e4SLinus Torvalds #endif
2159d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
21601da177e4SLinus Torvalds 	{
21611da177e4SLinus Torvalds 		.procname	= "cad_pid",
21629ec52099SCedric Le Goater 		.data		= NULL,
21631da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
21641da177e4SLinus Torvalds 		.mode		= 0600,
21656d456111SEric W. Biederman 		.proc_handler	= proc_do_cad_pid,
21661da177e4SLinus Torvalds 	},
2167d6f8ff73SRandy Dunlap #endif
21681da177e4SLinus Torvalds 	{
21691da177e4SLinus Torvalds 		.procname	= "threads-max",
217016db3d3fSHeinrich Schuchardt 		.data		= NULL,
21711da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21721da177e4SLinus Torvalds 		.mode		= 0644,
217316db3d3fSHeinrich Schuchardt 		.proc_handler	= sysctl_max_threads,
21741da177e4SLinus Torvalds 	},
21751da177e4SLinus Torvalds 	{
21761da177e4SLinus Torvalds 		.procname	= "random",
21771da177e4SLinus Torvalds 		.mode		= 0555,
21781da177e4SLinus Torvalds 		.child		= random_table,
21791da177e4SLinus Torvalds 	},
21801da177e4SLinus Torvalds 	{
218117f60a7dSEric Paris 		.procname	= "usermodehelper",
218217f60a7dSEric Paris 		.mode		= 0555,
218317f60a7dSEric Paris 		.child		= usermodehelper_table,
218417f60a7dSEric Paris 	},
2185ceb18132SLuis R. Rodriguez #ifdef CONFIG_FW_LOADER_USER_HELPER
2186ceb18132SLuis R. Rodriguez 	{
2187ceb18132SLuis R. Rodriguez 		.procname	= "firmware_config",
2188ceb18132SLuis R. Rodriguez 		.mode		= 0555,
2189ceb18132SLuis R. Rodriguez 		.child		= firmware_config_table,
2190ceb18132SLuis R. Rodriguez 	},
2191ceb18132SLuis R. Rodriguez #endif
219217f60a7dSEric Paris 	{
21931da177e4SLinus Torvalds 		.procname	= "overflowuid",
21941da177e4SLinus Torvalds 		.data		= &overflowuid,
21951da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21961da177e4SLinus Torvalds 		.mode		= 0644,
21976d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
21981da177e4SLinus Torvalds 		.extra1		= &minolduid,
21991da177e4SLinus Torvalds 		.extra2		= &maxolduid,
22001da177e4SLinus Torvalds 	},
22011da177e4SLinus Torvalds 	{
22021da177e4SLinus Torvalds 		.procname	= "overflowgid",
22031da177e4SLinus Torvalds 		.data		= &overflowgid,
22041da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
22051da177e4SLinus Torvalds 		.mode		= 0644,
22066d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
22071da177e4SLinus Torvalds 		.extra1		= &minolduid,
22081da177e4SLinus Torvalds 		.extra2		= &maxolduid,
22091da177e4SLinus Torvalds 	},
2210347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
22111da177e4SLinus Torvalds 	{
22121da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
2213ab3c68eeSHeiko Carstens 		.data		= &show_unhandled_signals,
22141da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
22151da177e4SLinus Torvalds 		.mode		= 0644,
22166d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22171da177e4SLinus Torvalds 	},
22181da177e4SLinus Torvalds #endif
221960c958d8SGuilherme G. Piccoli #ifdef CONFIG_SMP
222060c958d8SGuilherme G. Piccoli 	{
222160c958d8SGuilherme G. Piccoli 		.procname	= "oops_all_cpu_backtrace",
222260c958d8SGuilherme G. Piccoli 		.data		= &sysctl_oops_all_cpu_backtrace,
222360c958d8SGuilherme G. Piccoli 		.maxlen		= sizeof(int),
222460c958d8SGuilherme G. Piccoli 		.mode		= 0644,
222560c958d8SGuilherme G. Piccoli 		.proc_handler	= proc_dointvec_minmax,
222660c958d8SGuilherme G. Piccoli 		.extra1		= SYSCTL_ZERO,
222760c958d8SGuilherme G. Piccoli 		.extra2		= SYSCTL_ONE,
222860c958d8SGuilherme G. Piccoli 	},
222960c958d8SGuilherme G. Piccoli #endif /* CONFIG_SMP */
22301da177e4SLinus Torvalds 	{
22311da177e4SLinus Torvalds 		.procname	= "pid_max",
22321da177e4SLinus Torvalds 		.data		= &pid_max,
22331da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
22341da177e4SLinus Torvalds 		.mode		= 0644,
22356d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
22361da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
22371da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
22381da177e4SLinus Torvalds 	},
22391da177e4SLinus Torvalds 	{
22401da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
22411da177e4SLinus Torvalds 		.data		= &panic_on_oops,
22421da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
22431da177e4SLinus Torvalds 		.mode		= 0644,
22446d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22451da177e4SLinus Torvalds 	},
224681c9d43fSFeng Tang 	{
224781c9d43fSFeng Tang 		.procname	= "panic_print",
224881c9d43fSFeng Tang 		.data		= &panic_print,
224981c9d43fSFeng Tang 		.maxlen		= sizeof(unsigned long),
225081c9d43fSFeng Tang 		.mode		= 0644,
225181c9d43fSFeng Tang 		.proc_handler	= proc_doulongvec_minmax,
225281c9d43fSFeng Tang 	},
22537ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
22547ef3d2fdSJoe Perches 	{
22557ef3d2fdSJoe Perches 		.procname	= "printk",
22567ef3d2fdSJoe Perches 		.data		= &console_loglevel,
22577ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
22587ef3d2fdSJoe Perches 		.mode		= 0644,
22596d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22607ef3d2fdSJoe Perches 	},
22611da177e4SLinus Torvalds 	{
22621da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
2263717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
22641da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
22651da177e4SLinus Torvalds 		.mode		= 0644,
22666d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
22671da177e4SLinus Torvalds 	},
22681da177e4SLinus Torvalds 	{
22691da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
2270717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
22711da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
22721da177e4SLinus Torvalds 		.mode		= 0644,
22736d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22741da177e4SLinus Torvalds 	},
2275af91322eSDave Young 	{
2276af91322eSDave Young 		.procname	= "printk_delay",
2277af91322eSDave Young 		.data		= &printk_delay_msec,
2278af91322eSDave Young 		.maxlen		= sizeof(int),
2279af91322eSDave Young 		.mode		= 0644,
22806d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2281eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2282af91322eSDave Young 		.extra2		= &ten_thousand,
2283af91322eSDave Young 	},
22841da177e4SLinus Torvalds 	{
2285750afe7bSBorislav Petkov 		.procname	= "printk_devkmsg",
2286750afe7bSBorislav Petkov 		.data		= devkmsg_log_str,
2287750afe7bSBorislav Petkov 		.maxlen		= DEVKMSG_STR_MAX_SIZE,
2288750afe7bSBorislav Petkov 		.mode		= 0644,
2289750afe7bSBorislav Petkov 		.proc_handler	= devkmsg_sysctl_set_loglvl,
2290750afe7bSBorislav Petkov 	},
2291750afe7bSBorislav Petkov 	{
2292eaf06b24SDan Rosenberg 		.procname	= "dmesg_restrict",
2293eaf06b24SDan Rosenberg 		.data		= &dmesg_restrict,
2294eaf06b24SDan Rosenberg 		.maxlen		= sizeof(int),
2295eaf06b24SDan Rosenberg 		.mode		= 0644,
2296620f6e8eSKees Cook 		.proc_handler	= proc_dointvec_minmax_sysadmin,
2297eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2298eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2299eaf06b24SDan Rosenberg 	},
2300455cd5abSDan Rosenberg 	{
2301455cd5abSDan Rosenberg 		.procname	= "kptr_restrict",
2302455cd5abSDan Rosenberg 		.data		= &kptr_restrict,
2303455cd5abSDan Rosenberg 		.maxlen		= sizeof(int),
2304455cd5abSDan Rosenberg 		.mode		= 0644,
2305620f6e8eSKees Cook 		.proc_handler	= proc_dointvec_minmax_sysadmin,
2306eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2307455cd5abSDan Rosenberg 		.extra2		= &two,
2308455cd5abSDan Rosenberg 	},
2309df6e61d4SJoe Perches #endif
2310eaf06b24SDan Rosenberg 	{
23111da177e4SLinus Torvalds 		.procname	= "ngroups_max",
23121da177e4SLinus Torvalds 		.data		= &ngroups_max,
23131da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
23141da177e4SLinus Torvalds 		.mode		= 0444,
23156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
23161da177e4SLinus Torvalds 	},
231773efc039SDan Ballard 	{
231873efc039SDan Ballard 		.procname	= "cap_last_cap",
231973efc039SDan Ballard 		.data		= (void *)&cap_last_cap,
232073efc039SDan Ballard 		.maxlen		= sizeof(int),
232173efc039SDan Ballard 		.mode		= 0444,
232273efc039SDan Ballard 		.proc_handler	= proc_dointvec,
232373efc039SDan Ballard 	},
232458687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR)
2325504d7cf1SDon Zickus 	{
232658687acbSDon Zickus 		.procname       = "watchdog",
23273c00ea82SFrederic Weisbecker 		.data		= &watchdog_user_enabled,
2328504d7cf1SDon Zickus 		.maxlen		= sizeof(int),
2329504d7cf1SDon Zickus 		.mode		= 0644,
2330195daf66SUlrich Obergfell 		.proc_handler   = proc_watchdog,
2331eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2332eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
233358687acbSDon Zickus 	},
233458687acbSDon Zickus 	{
233558687acbSDon Zickus 		.procname	= "watchdog_thresh",
2336586692a5SMandeep Singh Baines 		.data		= &watchdog_thresh,
233758687acbSDon Zickus 		.maxlen		= sizeof(int),
233858687acbSDon Zickus 		.mode		= 0644,
2339195daf66SUlrich Obergfell 		.proc_handler	= proc_watchdog_thresh,
2340eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
234158687acbSDon Zickus 		.extra2		= &sixty,
2342504d7cf1SDon Zickus 	},
23432508ce18SDon Zickus 	{
2344195daf66SUlrich Obergfell 		.procname       = "nmi_watchdog",
23457feeb9cdSThomas Gleixner 		.data		= &nmi_watchdog_user_enabled,
2346195daf66SUlrich Obergfell 		.maxlen		= sizeof(int),
234751d4052bSThomas Gleixner 		.mode		= NMI_WATCHDOG_SYSCTL_PERM,
2348195daf66SUlrich Obergfell 		.proc_handler   = proc_nmi_watchdog,
2349eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2350eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2351195daf66SUlrich Obergfell 	},
2352195daf66SUlrich Obergfell 	{
235305a4a952SNicholas Piggin 		.procname	= "watchdog_cpumask",
235405a4a952SNicholas Piggin 		.data		= &watchdog_cpumask_bits,
235505a4a952SNicholas Piggin 		.maxlen		= NR_CPUS,
235605a4a952SNicholas Piggin 		.mode		= 0644,
235705a4a952SNicholas Piggin 		.proc_handler	= proc_watchdog_cpumask,
235805a4a952SNicholas Piggin 	},
235905a4a952SNicholas Piggin #ifdef CONFIG_SOFTLOCKUP_DETECTOR
236005a4a952SNicholas Piggin 	{
2361195daf66SUlrich Obergfell 		.procname       = "soft_watchdog",
23627feeb9cdSThomas Gleixner 		.data		= &soft_watchdog_user_enabled,
2363195daf66SUlrich Obergfell 		.maxlen		= sizeof(int),
2364195daf66SUlrich Obergfell 		.mode		= 0644,
2365195daf66SUlrich Obergfell 		.proc_handler   = proc_soft_watchdog,
2366eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2367eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2368195daf66SUlrich Obergfell 	},
2369195daf66SUlrich Obergfell 	{
23702508ce18SDon Zickus 		.procname	= "softlockup_panic",
23712508ce18SDon Zickus 		.data		= &softlockup_panic,
23722508ce18SDon Zickus 		.maxlen		= sizeof(int),
23732508ce18SDon Zickus 		.mode		= 0644,
23742508ce18SDon Zickus 		.proc_handler	= proc_dointvec_minmax,
2375eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2376eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
23772508ce18SDon Zickus 	},
2378ed235875SAaron Tomlin #ifdef CONFIG_SMP
2379ed235875SAaron Tomlin 	{
2380ed235875SAaron Tomlin 		.procname	= "softlockup_all_cpu_backtrace",
2381ed235875SAaron Tomlin 		.data		= &sysctl_softlockup_all_cpu_backtrace,
2382ed235875SAaron Tomlin 		.maxlen		= sizeof(int),
2383ed235875SAaron Tomlin 		.mode		= 0644,
2384ed235875SAaron Tomlin 		.proc_handler	= proc_dointvec_minmax,
2385eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2386eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2387ed235875SAaron Tomlin 	},
238805a4a952SNicholas Piggin #endif /* CONFIG_SMP */
238905a4a952SNicholas Piggin #endif
239005a4a952SNicholas Piggin #ifdef CONFIG_HARDLOCKUP_DETECTOR
239105a4a952SNicholas Piggin 	{
239205a4a952SNicholas Piggin 		.procname	= "hardlockup_panic",
239305a4a952SNicholas Piggin 		.data		= &hardlockup_panic,
239405a4a952SNicholas Piggin 		.maxlen		= sizeof(int),
239505a4a952SNicholas Piggin 		.mode		= 0644,
239605a4a952SNicholas Piggin 		.proc_handler	= proc_dointvec_minmax,
2397eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2398eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
239905a4a952SNicholas Piggin 	},
240005a4a952SNicholas Piggin #ifdef CONFIG_SMP
240155537871SJiri Kosina 	{
240255537871SJiri Kosina 		.procname	= "hardlockup_all_cpu_backtrace",
240355537871SJiri Kosina 		.data		= &sysctl_hardlockup_all_cpu_backtrace,
240455537871SJiri Kosina 		.maxlen		= sizeof(int),
240555537871SJiri Kosina 		.mode		= 0644,
240655537871SJiri Kosina 		.proc_handler	= proc_dointvec_minmax,
2407eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2408eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
240955537871SJiri Kosina 	},
2410ed235875SAaron Tomlin #endif /* CONFIG_SMP */
24115dc30558SDon Zickus #endif
241205a4a952SNicholas Piggin #endif
241305a4a952SNicholas Piggin 
24145dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
24155dc30558SDon Zickus 	{
24165dc30558SDon Zickus 		.procname       = "unknown_nmi_panic",
24175dc30558SDon Zickus 		.data           = &unknown_nmi_panic,
24185dc30558SDon Zickus 		.maxlen         = sizeof (int),
24195dc30558SDon Zickus 		.mode           = 0644,
24205dc30558SDon Zickus 		.proc_handler   = proc_dointvec,
24215dc30558SDon Zickus 	},
2422504d7cf1SDon Zickus #endif
2423b6522fa4SXiaoming Ni 
2424b6522fa4SXiaoming Ni #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2425b6522fa4SXiaoming Ni 	defined(CONFIG_DEBUG_STACKOVERFLOW)
2426b6522fa4SXiaoming Ni 	{
2427b6522fa4SXiaoming Ni 		.procname	= "panic_on_stackoverflow",
2428b6522fa4SXiaoming Ni 		.data		= &sysctl_panic_on_stackoverflow,
2429b6522fa4SXiaoming Ni 		.maxlen		= sizeof(int),
2430b6522fa4SXiaoming Ni 		.mode		= 0644,
2431b6522fa4SXiaoming Ni 		.proc_handler	= proc_dointvec,
2432b6522fa4SXiaoming Ni 	},
2433b6522fa4SXiaoming Ni #endif
24341da177e4SLinus Torvalds #if defined(CONFIG_X86)
24351da177e4SLinus Torvalds 	{
24368da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
24378da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
24388da5addaSDon Zickus 		.maxlen		= sizeof(int),
24398da5addaSDon Zickus 		.mode		= 0644,
24406d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24418da5addaSDon Zickus 	},
24428da5addaSDon Zickus 	{
24435211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
24445211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
24455211a242SKurt Garloff 		.maxlen		= sizeof(int),
24465211a242SKurt Garloff 		.mode		= 0644,
24476d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24485211a242SKurt Garloff 	},
24495211a242SKurt Garloff 	{
24501da177e4SLinus Torvalds 		.procname	= "bootloader_type",
24511da177e4SLinus Torvalds 		.data		= &bootloader_type,
24521da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
24531da177e4SLinus Torvalds 		.mode		= 0444,
24546d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24551da177e4SLinus Torvalds 	},
24560741f4d2SChuck Ebbert 	{
24575031296cSH. Peter Anvin 		.procname	= "bootloader_version",
24585031296cSH. Peter Anvin 		.data		= &bootloader_version,
24595031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
24605031296cSH. Peter Anvin 		.mode		= 0444,
24616d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24625031296cSH. Peter Anvin 	},
24635031296cSH. Peter Anvin 	{
24646e7c4025SIngo Molnar 		.procname	= "io_delay_type",
24656e7c4025SIngo Molnar 		.data		= &io_delay_type,
24666e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
24676e7c4025SIngo Molnar 		.mode		= 0644,
24686d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24696e7c4025SIngo Molnar 	},
24701da177e4SLinus Torvalds #endif
24717a9166e3SLuke Yang #if defined(CONFIG_MMU)
24721da177e4SLinus Torvalds 	{
24731da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
24741da177e4SLinus Torvalds 		.data		= &randomize_va_space,
24751da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
24761da177e4SLinus Torvalds 		.mode		= 0644,
24776d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24781da177e4SLinus Torvalds 	},
24797a9166e3SLuke Yang #endif
24800152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2481951f22d5SMartin Schwidefsky 	{
2482951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
2483951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
2484951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
2485951f22d5SMartin Schwidefsky 		.mode		= 0644,
24866d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2487951f22d5SMartin Schwidefsky 	},
2488951f22d5SMartin Schwidefsky #endif
2489673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2490c255d844SPavel Machek 	{
2491c255d844SPavel Machek 		.procname	= "acpi_video_flags",
249277afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
2493c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
2494c255d844SPavel Machek 		.mode		= 0644,
24956d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
2496c255d844SPavel Machek 	},
2497c255d844SPavel Machek #endif
2498b6fca725SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2499d2b176edSJes Sorensen 	{
2500d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
2501d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
2502d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
2503d2b176edSJes Sorensen 		.mode		= 0644,
25046d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2505d2b176edSJes Sorensen 	},
2506b6fca725SVineet Gupta #endif
2507b6fca725SVineet Gupta #ifdef CONFIG_IA64
250888fc241fSDoug Chapman 	{
250988fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
251088fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
251188fc241fSDoug Chapman 		.maxlen		= sizeof (int),
251288fc241fSDoug Chapman 		.mode		= 0644,
25136d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
251488fc241fSDoug Chapman 	},
2515d2b176edSJes Sorensen #endif
2516e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
25170ec9dc9bSGuilherme G. Piccoli #ifdef CONFIG_SMP
25180ec9dc9bSGuilherme G. Piccoli 	{
25190ec9dc9bSGuilherme G. Piccoli 		.procname	= "hung_task_all_cpu_backtrace",
25200ec9dc9bSGuilherme G. Piccoli 		.data		= &sysctl_hung_task_all_cpu_backtrace,
25210ec9dc9bSGuilherme G. Piccoli 		.maxlen		= sizeof(int),
25220ec9dc9bSGuilherme G. Piccoli 		.mode		= 0644,
25230ec9dc9bSGuilherme G. Piccoli 		.proc_handler	= proc_dointvec_minmax,
25240ec9dc9bSGuilherme G. Piccoli 		.extra1		= SYSCTL_ZERO,
25250ec9dc9bSGuilherme G. Piccoli 		.extra2		= SYSCTL_ONE,
25260ec9dc9bSGuilherme G. Piccoli 	},
25270ec9dc9bSGuilherme G. Piccoli #endif /* CONFIG_SMP */
2528e162b39aSMandeep Singh Baines 	{
2529e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
2530e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
2531e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
2532e162b39aSMandeep Singh Baines 		.mode		= 0644,
25336d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2534eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2535eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2536e162b39aSMandeep Singh Baines 	},
253782a1fcb9SIngo Molnar 	{
253882a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
253982a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
2540cd64647fSLi Zefan 		.maxlen		= sizeof(int),
254182a1fcb9SIngo Molnar 		.mode		= 0644,
2542cd64647fSLi Zefan 		.proc_handler	= proc_dointvec_minmax,
2543eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
254482a1fcb9SIngo Molnar 	},
254582a1fcb9SIngo Molnar 	{
254682a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
254782a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
254890739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
254982a1fcb9SIngo Molnar 		.mode		= 0644,
25506d456111SEric W. Biederman 		.proc_handler	= proc_dohung_task_timeout_secs,
255180df2847SLiu Hua 		.extra2		= &hung_task_timeout_max,
255282a1fcb9SIngo Molnar 	},
255382a1fcb9SIngo Molnar 	{
2554a2e51445SDmitry Vyukov 		.procname	= "hung_task_check_interval_secs",
2555a2e51445SDmitry Vyukov 		.data		= &sysctl_hung_task_check_interval_secs,
2556a2e51445SDmitry Vyukov 		.maxlen		= sizeof(unsigned long),
2557a2e51445SDmitry Vyukov 		.mode		= 0644,
2558a2e51445SDmitry Vyukov 		.proc_handler	= proc_dohung_task_timeout_secs,
2559a2e51445SDmitry Vyukov 		.extra2		= &hung_task_timeout_max,
2560a2e51445SDmitry Vyukov 	},
2561a2e51445SDmitry Vyukov 	{
256282a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
256382a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
2564270750dbSAaron Tomlin 		.maxlen		= sizeof(int),
256582a1fcb9SIngo Molnar 		.mode		= 0644,
2566270750dbSAaron Tomlin 		.proc_handler	= proc_dointvec_minmax,
2567270750dbSAaron Tomlin 		.extra1		= &neg_one,
256882a1fcb9SIngo Molnar 	},
2569c4f3b63fSRavikiran G Thirumalai #endif
257023f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
257123f78d4aSIngo Molnar 	{
257223f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
257323f78d4aSIngo Molnar 		.data		= &max_lock_depth,
257423f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
257523f78d4aSIngo Molnar 		.mode		= 0644,
25766d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
257723f78d4aSIngo Molnar 	},
257823f78d4aSIngo Molnar #endif
257910a0a8d4SJeremy Fitzhardinge 	{
258010a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
258110a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
258210a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
258310a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
25846d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
258510a0a8d4SJeremy Fitzhardinge 	},
25860b77f5bfSDavid Howells #ifdef CONFIG_KEYS
25870b77f5bfSDavid Howells 	{
25880b77f5bfSDavid Howells 		.procname	= "keys",
25890b77f5bfSDavid Howells 		.mode		= 0555,
25900b77f5bfSDavid Howells 		.child		= key_sysctls,
25910b77f5bfSDavid Howells 	},
25920b77f5bfSDavid Howells #endif
2593cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS
2594aa4a2218SVince Weaver 	/*
2595aa4a2218SVince Weaver 	 * User-space scripts rely on the existence of this file
2596aa4a2218SVince Weaver 	 * as a feature check for perf_events being enabled.
2597aa4a2218SVince Weaver 	 *
2598aa4a2218SVince Weaver 	 * So it's an ABI, do not remove!
2599aa4a2218SVince Weaver 	 */
26001ccd1549SPeter Zijlstra 	{
2601cdd6c482SIngo Molnar 		.procname	= "perf_event_paranoid",
2602cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_paranoid,
2603cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_paranoid),
26041ccd1549SPeter Zijlstra 		.mode		= 0644,
26056d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
26061ccd1549SPeter Zijlstra 	},
2607c5078f78SPeter Zijlstra 	{
2608cdd6c482SIngo Molnar 		.procname	= "perf_event_mlock_kb",
2609cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_mlock,
2610cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_mlock),
2611c5078f78SPeter Zijlstra 		.mode		= 0644,
26126d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2613c5078f78SPeter Zijlstra 	},
2614a78ac325SPeter Zijlstra 	{
2615cdd6c482SIngo Molnar 		.procname	= "perf_event_max_sample_rate",
2616cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_sample_rate,
2617cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
2618a78ac325SPeter Zijlstra 		.mode		= 0644,
2619163ec435SPeter Zijlstra 		.proc_handler	= perf_proc_update_handler,
2620eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2621a78ac325SPeter Zijlstra 	},
262214c63f17SDave Hansen 	{
262314c63f17SDave Hansen 		.procname	= "perf_cpu_time_max_percent",
262414c63f17SDave Hansen 		.data		= &sysctl_perf_cpu_time_max_percent,
262514c63f17SDave Hansen 		.maxlen		= sizeof(sysctl_perf_cpu_time_max_percent),
262614c63f17SDave Hansen 		.mode		= 0644,
262714c63f17SDave Hansen 		.proc_handler	= perf_cpu_time_max_percent_handler,
2628eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
262914c63f17SDave Hansen 		.extra2		= &one_hundred,
263014c63f17SDave Hansen 	},
2631c5dfd78eSArnaldo Carvalho de Melo 	{
2632c5dfd78eSArnaldo Carvalho de Melo 		.procname	= "perf_event_max_stack",
2633a831100aSArnaldo Carvalho de Melo 		.data		= &sysctl_perf_event_max_stack,
2634c5dfd78eSArnaldo Carvalho de Melo 		.maxlen		= sizeof(sysctl_perf_event_max_stack),
2635c5dfd78eSArnaldo Carvalho de Melo 		.mode		= 0644,
2636c5dfd78eSArnaldo Carvalho de Melo 		.proc_handler	= perf_event_max_stack_handler,
2637eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2638c5dfd78eSArnaldo Carvalho de Melo 		.extra2		= &six_hundred_forty_kb,
2639c5dfd78eSArnaldo Carvalho de Melo 	},
2640c85b0334SArnaldo Carvalho de Melo 	{
2641c85b0334SArnaldo Carvalho de Melo 		.procname	= "perf_event_max_contexts_per_stack",
2642c85b0334SArnaldo Carvalho de Melo 		.data		= &sysctl_perf_event_max_contexts_per_stack,
2643c85b0334SArnaldo Carvalho de Melo 		.maxlen		= sizeof(sysctl_perf_event_max_contexts_per_stack),
2644c85b0334SArnaldo Carvalho de Melo 		.mode		= 0644,
2645c85b0334SArnaldo Carvalho de Melo 		.proc_handler	= perf_event_max_stack_handler,
2646eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2647c85b0334SArnaldo Carvalho de Melo 		.extra2		= &one_thousand,
2648c85b0334SArnaldo Carvalho de Melo 	},
26491ccd1549SPeter Zijlstra #endif
26509e3961a0SPrarit Bhargava 	{
26519e3961a0SPrarit Bhargava 		.procname	= "panic_on_warn",
26529e3961a0SPrarit Bhargava 		.data		= &panic_on_warn,
26539e3961a0SPrarit Bhargava 		.maxlen		= sizeof(int),
26549e3961a0SPrarit Bhargava 		.mode		= 0644,
26559e3961a0SPrarit Bhargava 		.proc_handler	= proc_dointvec_minmax,
2656eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2657eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
26589e3961a0SPrarit Bhargava 	},
2659bc7a34b8SThomas Gleixner #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2660bc7a34b8SThomas Gleixner 	{
2661bc7a34b8SThomas Gleixner 		.procname	= "timer_migration",
2662bc7a34b8SThomas Gleixner 		.data		= &sysctl_timer_migration,
2663bc7a34b8SThomas Gleixner 		.maxlen		= sizeof(unsigned int),
2664bc7a34b8SThomas Gleixner 		.mode		= 0644,
2665bc7a34b8SThomas Gleixner 		.proc_handler	= timer_migration_handler,
2666eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2667eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2668bc7a34b8SThomas Gleixner 	},
2669bc7a34b8SThomas Gleixner #endif
26701be7f75dSAlexei Starovoitov #ifdef CONFIG_BPF_SYSCALL
26711be7f75dSAlexei Starovoitov 	{
26721be7f75dSAlexei Starovoitov 		.procname	= "unprivileged_bpf_disabled",
26731be7f75dSAlexei Starovoitov 		.data		= &sysctl_unprivileged_bpf_disabled,
26741be7f75dSAlexei Starovoitov 		.maxlen		= sizeof(sysctl_unprivileged_bpf_disabled),
26751be7f75dSAlexei Starovoitov 		.mode		= 0644,
267608389d88SDaniel Borkmann 		.proc_handler	= bpf_unpriv_handler,
267708389d88SDaniel Borkmann 		.extra1		= SYSCTL_ZERO,
267808389d88SDaniel Borkmann 		.extra2		= &two,
26791be7f75dSAlexei Starovoitov 	},
2680492ecee8SAlexei Starovoitov 	{
2681492ecee8SAlexei Starovoitov 		.procname	= "bpf_stats_enabled",
2682a8e11e5cSEric Dumazet 		.data		= &bpf_stats_enabled_key.key,
2683a8e11e5cSEric Dumazet 		.maxlen		= sizeof(bpf_stats_enabled_key),
2684492ecee8SAlexei Starovoitov 		.mode		= 0644,
2685d46edd67SSong Liu 		.proc_handler	= bpf_stats_handler,
2686492ecee8SAlexei Starovoitov 	},
26873fcc5530SAlexei Starovoitov #endif
2688b3e627d3SLai Jiangshan #if defined(CONFIG_TREE_RCU)
2689088e9d25SDaniel Bristot de Oliveira 	{
2690088e9d25SDaniel Bristot de Oliveira 		.procname	= "panic_on_rcu_stall",
2691088e9d25SDaniel Bristot de Oliveira 		.data		= &sysctl_panic_on_rcu_stall,
2692088e9d25SDaniel Bristot de Oliveira 		.maxlen		= sizeof(sysctl_panic_on_rcu_stall),
2693088e9d25SDaniel Bristot de Oliveira 		.mode		= 0644,
2694088e9d25SDaniel Bristot de Oliveira 		.proc_handler	= proc_dointvec_minmax,
2695eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2696eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2697088e9d25SDaniel Bristot de Oliveira 	},
2698088e9d25SDaniel Bristot de Oliveira #endif
2699dfe56404Schao #if defined(CONFIG_TREE_RCU)
2700dfe56404Schao 	{
2701dfe56404Schao 		.procname	= "max_rcu_stall_to_panic",
2702dfe56404Schao 		.data		= &sysctl_max_rcu_stall_to_panic,
2703dfe56404Schao 		.maxlen		= sizeof(sysctl_max_rcu_stall_to_panic),
2704dfe56404Schao 		.mode		= 0644,
2705dfe56404Schao 		.proc_handler	= proc_dointvec_minmax,
2706dfe56404Schao 		.extra1		= SYSCTL_ONE,
2707dfe56404Schao 		.extra2		= SYSCTL_INT_MAX,
2708dfe56404Schao 	},
2709dfe56404Schao #endif
2710964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2711964c9dffSAlexander Popov 	{
2712964c9dffSAlexander Popov 		.procname	= "stack_erasing",
2713964c9dffSAlexander Popov 		.data		= NULL,
2714964c9dffSAlexander Popov 		.maxlen		= sizeof(int),
2715964c9dffSAlexander Popov 		.mode		= 0600,
2716964c9dffSAlexander Popov 		.proc_handler	= stack_erasing_sysctl,
2717eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2718eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2719964c9dffSAlexander Popov 	},
2720964c9dffSAlexander Popov #endif
27216fce56ecSEric W. Biederman 	{ }
27221da177e4SLinus Torvalds };
27231da177e4SLinus Torvalds 
2724d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
27251da177e4SLinus Torvalds 	{
27261da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
27271da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
27281da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
27291da177e4SLinus Torvalds 		.mode		= 0644,
273056f3547bSFeng Tang 		.proc_handler	= overcommit_policy_handler,
2731eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2732cb16e95fSPetr Holasek 		.extra2		= &two,
27331da177e4SLinus Torvalds 	},
27341da177e4SLinus Torvalds 	{
2735fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
2736fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
2737fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
2738fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
2739cb16e95fSPetr Holasek 		.proc_handler	= proc_dointvec_minmax,
2740eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2741cb16e95fSPetr Holasek 		.extra2		= &two,
2742fadd8fbdSKAMEZAWA Hiroyuki 	},
2743fadd8fbdSKAMEZAWA Hiroyuki 	{
2744fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
2745fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
2746fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
2747fe071d7eSDavid Rientjes 		.mode		= 0644,
27486d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2749fe071d7eSDavid Rientjes 	},
2750fe071d7eSDavid Rientjes 	{
2751fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
2752fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
2753fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
2754fef1bdd6SDavid Rientjes 		.mode		= 0644,
27556d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2756fef1bdd6SDavid Rientjes 	},
2757fef1bdd6SDavid Rientjes 	{
27581da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
27591da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
27601da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
27611da177e4SLinus Torvalds 		.mode		= 0644,
276249f0ce5fSJerome Marchand 		.proc_handler	= overcommit_ratio_handler,
276349f0ce5fSJerome Marchand 	},
276449f0ce5fSJerome Marchand 	{
276549f0ce5fSJerome Marchand 		.procname	= "overcommit_kbytes",
276649f0ce5fSJerome Marchand 		.data		= &sysctl_overcommit_kbytes,
276749f0ce5fSJerome Marchand 		.maxlen		= sizeof(sysctl_overcommit_kbytes),
276849f0ce5fSJerome Marchand 		.mode		= 0644,
276949f0ce5fSJerome Marchand 		.proc_handler	= overcommit_kbytes_handler,
27701da177e4SLinus Torvalds 	},
27711da177e4SLinus Torvalds 	{
27721da177e4SLinus Torvalds 		.procname	= "page-cluster",
27731da177e4SLinus Torvalds 		.data		= &page_cluster,
27741da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
27751da177e4SLinus Torvalds 		.mode		= 0644,
2776cb16e95fSPetr Holasek 		.proc_handler	= proc_dointvec_minmax,
2777eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27781da177e4SLinus Torvalds 	},
27791da177e4SLinus Torvalds 	{
27801da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
27811da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
27821da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
27831da177e4SLinus Torvalds 		.mode		= 0644,
27846d456111SEric W. Biederman 		.proc_handler	= dirty_background_ratio_handler,
2785eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27861da177e4SLinus Torvalds 		.extra2		= &one_hundred,
27871da177e4SLinus Torvalds 	},
27881da177e4SLinus Torvalds 	{
27892da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
27902da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
27912da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
27922da02997SDavid Rientjes 		.mode		= 0644,
27936d456111SEric W. Biederman 		.proc_handler	= dirty_background_bytes_handler,
2794fc3501d4SSven Wegener 		.extra1		= &one_ul,
27952da02997SDavid Rientjes 	},
27962da02997SDavid Rientjes 	{
27971da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
27981da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
27991da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
28001da177e4SLinus Torvalds 		.mode		= 0644,
28016d456111SEric W. Biederman 		.proc_handler	= dirty_ratio_handler,
2802eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
28031da177e4SLinus Torvalds 		.extra2		= &one_hundred,
28041da177e4SLinus Torvalds 	},
28051da177e4SLinus Torvalds 	{
28062da02997SDavid Rientjes 		.procname	= "dirty_bytes",
28072da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
28082da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
28092da02997SDavid Rientjes 		.mode		= 0644,
28106d456111SEric W. Biederman 		.proc_handler	= dirty_bytes_handler,
28119e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
28122da02997SDavid Rientjes 	},
28132da02997SDavid Rientjes 	{
28141da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
2815f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
2816f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
28171da177e4SLinus Torvalds 		.mode		= 0644,
28186d456111SEric W. Biederman 		.proc_handler	= dirty_writeback_centisecs_handler,
28191da177e4SLinus Torvalds 	},
28201da177e4SLinus Torvalds 	{
28211da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
2822f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
2823f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
28241da177e4SLinus Torvalds 		.mode		= 0644,
2825cb16e95fSPetr Holasek 		.proc_handler	= proc_dointvec_minmax,
2826eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
28271da177e4SLinus Torvalds 	},
28281da177e4SLinus Torvalds 	{
28291efff914STheodore Ts'o 		.procname	= "dirtytime_expire_seconds",
28301efff914STheodore Ts'o 		.data		= &dirtytime_expire_interval,
28312d87b309SRandy Dunlap 		.maxlen		= sizeof(dirtytime_expire_interval),
28321efff914STheodore Ts'o 		.mode		= 0644,
28331efff914STheodore Ts'o 		.proc_handler	= dirtytime_interval_handler,
2834eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
28351efff914STheodore Ts'o 	},
28361efff914STheodore Ts'o 	{
28371da177e4SLinus Torvalds 		.procname	= "swappiness",
28381da177e4SLinus Torvalds 		.data		= &vm_swappiness,
28391da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
28401da177e4SLinus Torvalds 		.mode		= 0644,
28416d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2842eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2843c843966cSJohannes Weiner 		.extra2		= &two_hundred,
28441da177e4SLinus Torvalds 	},
28451da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
28461da177e4SLinus Torvalds 	{
28471da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
2848e5ff2159SAndi Kleen 		.data		= NULL,
28491da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
28501da177e4SLinus Torvalds 		.mode		= 0644,
28516d456111SEric W. Biederman 		.proc_handler	= hugetlb_sysctl_handler,
28521da177e4SLinus Torvalds 	},
285306808b08SLee Schermerhorn #ifdef CONFIG_NUMA
285406808b08SLee Schermerhorn 	{
285506808b08SLee Schermerhorn 		.procname       = "nr_hugepages_mempolicy",
285606808b08SLee Schermerhorn 		.data           = NULL,
285706808b08SLee Schermerhorn 		.maxlen         = sizeof(unsigned long),
285806808b08SLee Schermerhorn 		.mode           = 0644,
285906808b08SLee Schermerhorn 		.proc_handler   = &hugetlb_mempolicy_sysctl_handler,
286006808b08SLee Schermerhorn 	},
28614518085eSKemi Wang 	{
28624518085eSKemi Wang 		.procname		= "numa_stat",
28634518085eSKemi Wang 		.data			= &sysctl_vm_numa_stat,
28644518085eSKemi Wang 		.maxlen			= sizeof(int),
28654518085eSKemi Wang 		.mode			= 0644,
28664518085eSKemi Wang 		.proc_handler	= sysctl_vm_numa_stat_handler,
2867eec4844fSMatteo Croce 		.extra1			= SYSCTL_ZERO,
2868eec4844fSMatteo Croce 		.extra2			= SYSCTL_ONE,
28694518085eSKemi Wang 	},
287006808b08SLee Schermerhorn #endif
28711da177e4SLinus Torvalds 	 {
28721da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
28731da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
28741da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
28751da177e4SLinus Torvalds 		.mode		= 0644,
28766d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
28771da177e4SLinus Torvalds 	 },
2878396faf03SMel Gorman 	{
2879d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
2880e5ff2159SAndi Kleen 		.data		= NULL,
2881e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
2882d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
28836d456111SEric W. Biederman 		.proc_handler	= hugetlb_overcommit_handler,
2884d1c3fb1fSNishanth Aravamudan 	},
28851da177e4SLinus Torvalds #endif
28861da177e4SLinus Torvalds 	{
28871da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
28881da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
28891da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
28901da177e4SLinus Torvalds 		.mode		= 0644,
28916d456111SEric W. Biederman 		.proc_handler	= lowmem_reserve_ratio_sysctl_handler,
28921da177e4SLinus Torvalds 	},
28931da177e4SLinus Torvalds 	{
28949d0243bcSAndrew Morton 		.procname	= "drop_caches",
28959d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
28969d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
2897204cb79aSJohannes Weiner 		.mode		= 0200,
28989d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
2899eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
29005509a5d2SDave Hansen 		.extra2		= &four,
29019d0243bcSAndrew Morton 	},
290276ab0f53SMel Gorman #ifdef CONFIG_COMPACTION
290376ab0f53SMel Gorman 	{
290476ab0f53SMel Gorman 		.procname	= "compact_memory",
2905ef498438SPintu Kumar 		.data		= NULL,
290676ab0f53SMel Gorman 		.maxlen		= sizeof(int),
290776ab0f53SMel Gorman 		.mode		= 0200,
290876ab0f53SMel Gorman 		.proc_handler	= sysctl_compaction_handler,
290976ab0f53SMel Gorman 	},
29105e771905SMel Gorman 	{
2911facdaa91SNitin Gupta 		.procname	= "compaction_proactiveness",
2912facdaa91SNitin Gupta 		.data		= &sysctl_compaction_proactiveness,
2913d34c0a75SNitin Gupta 		.maxlen		= sizeof(sysctl_compaction_proactiveness),
2914facdaa91SNitin Gupta 		.mode		= 0644,
2915facdaa91SNitin Gupta 		.proc_handler	= proc_dointvec_minmax,
2916facdaa91SNitin Gupta 		.extra1		= SYSCTL_ZERO,
2917facdaa91SNitin Gupta 		.extra2		= &one_hundred,
2918facdaa91SNitin Gupta 	},
2919facdaa91SNitin Gupta 	{
29205e771905SMel Gorman 		.procname	= "extfrag_threshold",
29215e771905SMel Gorman 		.data		= &sysctl_extfrag_threshold,
29225e771905SMel Gorman 		.maxlen		= sizeof(int),
29235e771905SMel Gorman 		.mode		= 0644,
29246b7e5cadSMatthew Wilcox 		.proc_handler	= proc_dointvec_minmax,
29255e771905SMel Gorman 		.extra1		= &min_extfrag_threshold,
29265e771905SMel Gorman 		.extra2		= &max_extfrag_threshold,
29275e771905SMel Gorman 	},
29285bbe3547SEric B Munson 	{
29295bbe3547SEric B Munson 		.procname	= "compact_unevictable_allowed",
29305bbe3547SEric B Munson 		.data		= &sysctl_compact_unevictable_allowed,
29315bbe3547SEric B Munson 		.maxlen		= sizeof(int),
29325bbe3547SEric B Munson 		.mode		= 0644,
29336923aa0dSSebastian Andrzej Siewior 		.proc_handler	= proc_dointvec_minmax_warn_RT_change,
2934eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2935eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
29365bbe3547SEric B Munson 	},
29375e771905SMel Gorman 
293876ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */
29399d0243bcSAndrew Morton 	{
29401da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
29411da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
29421da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
29431da177e4SLinus Torvalds 		.mode		= 0644,
29446d456111SEric W. Biederman 		.proc_handler	= min_free_kbytes_sysctl_handler,
2945eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29461da177e4SLinus Torvalds 	},
29478ad4b1fbSRohit Seth 	{
29481c30844dSMel Gorman 		.procname	= "watermark_boost_factor",
29491c30844dSMel Gorman 		.data		= &watermark_boost_factor,
29501c30844dSMel Gorman 		.maxlen		= sizeof(watermark_boost_factor),
29511c30844dSMel Gorman 		.mode		= 0644,
295226363af5SChristoph Hellwig 		.proc_handler	= proc_dointvec_minmax,
2953eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29541c30844dSMel Gorman 	},
29551c30844dSMel Gorman 	{
2956795ae7a0SJohannes Weiner 		.procname	= "watermark_scale_factor",
2957795ae7a0SJohannes Weiner 		.data		= &watermark_scale_factor,
2958795ae7a0SJohannes Weiner 		.maxlen		= sizeof(watermark_scale_factor),
2959795ae7a0SJohannes Weiner 		.mode		= 0644,
2960795ae7a0SJohannes Weiner 		.proc_handler	= watermark_scale_factor_sysctl_handler,
2961eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2962795ae7a0SJohannes Weiner 		.extra2		= &one_thousand,
2963795ae7a0SJohannes Weiner 	},
2964795ae7a0SJohannes Weiner 	{
296574f44822SMel Gorman 		.procname	= "percpu_pagelist_high_fraction",
296674f44822SMel Gorman 		.data		= &percpu_pagelist_high_fraction,
296774f44822SMel Gorman 		.maxlen		= sizeof(percpu_pagelist_high_fraction),
29688ad4b1fbSRohit Seth 		.mode		= 0644,
296974f44822SMel Gorman 		.proc_handler	= percpu_pagelist_high_fraction_sysctl_handler,
2970eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29718ad4b1fbSRohit Seth 	},
29725ef64cc8SLinus Torvalds 	{
29735ef64cc8SLinus Torvalds 		.procname	= "page_lock_unfairness",
29745ef64cc8SLinus Torvalds 		.data		= &sysctl_page_lock_unfairness,
29755ef64cc8SLinus Torvalds 		.maxlen		= sizeof(sysctl_page_lock_unfairness),
29765ef64cc8SLinus Torvalds 		.mode		= 0644,
29775ef64cc8SLinus Torvalds 		.proc_handler	= proc_dointvec_minmax,
29785ef64cc8SLinus Torvalds 		.extra1		= SYSCTL_ZERO,
29795ef64cc8SLinus Torvalds 	},
29801da177e4SLinus Torvalds #ifdef CONFIG_MMU
29811da177e4SLinus Torvalds 	{
29821da177e4SLinus Torvalds 		.procname	= "max_map_count",
29831da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
29841da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
29851da177e4SLinus Torvalds 		.mode		= 0644,
29863e26120cSWANG Cong 		.proc_handler	= proc_dointvec_minmax,
2987eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29881da177e4SLinus Torvalds 	},
2989dd8632a1SPaul Mundt #else
2990dd8632a1SPaul Mundt 	{
2991dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
2992dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
2993dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
2994dd8632a1SPaul Mundt 		.mode		= 0644,
29956d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2996eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2997dd8632a1SPaul Mundt 	},
29981da177e4SLinus Torvalds #endif
29991da177e4SLinus Torvalds 	{
30001da177e4SLinus Torvalds 		.procname	= "laptop_mode",
30011da177e4SLinus Torvalds 		.data		= &laptop_mode,
30021da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
30031da177e4SLinus Torvalds 		.mode		= 0644,
30046d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
30051da177e4SLinus Torvalds 	},
30061da177e4SLinus Torvalds 	{
30071da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
30081da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
30091da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
30101da177e4SLinus Torvalds 		.mode		= 0644,
30113b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
3012eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
30131da177e4SLinus Torvalds 	},
301467f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
301567f3977fSAlexandre Ghiti     defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
30161da177e4SLinus Torvalds 	{
30171da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
30181da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
30191da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
30201da177e4SLinus Torvalds 		.mode		= 0644,
30213b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
3022eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
30231da177e4SLinus Torvalds 	},
30241da177e4SLinus Torvalds #endif
30251743660bSChristoph Lameter #ifdef CONFIG_NUMA
30261743660bSChristoph Lameter 	{
30271743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
3028a5f5f91dSMel Gorman 		.data		= &node_reclaim_mode,
3029a5f5f91dSMel Gorman 		.maxlen		= sizeof(node_reclaim_mode),
30301743660bSChristoph Lameter 		.mode		= 0644,
30313b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
3032eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
30331743660bSChristoph Lameter 	},
30349614634fSChristoph Lameter 	{
30359614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
30369614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
30379614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
30389614634fSChristoph Lameter 		.mode		= 0644,
30396d456111SEric W. Biederman 		.proc_handler	= sysctl_min_unmapped_ratio_sysctl_handler,
3040eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
30419614634fSChristoph Lameter 		.extra2		= &one_hundred,
30429614634fSChristoph Lameter 	},
30430ff38490SChristoph Lameter 	{
30440ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
30450ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
30460ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
30470ff38490SChristoph Lameter 		.mode		= 0644,
30486d456111SEric W. Biederman 		.proc_handler	= sysctl_min_slab_ratio_sysctl_handler,
3049eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
30500ff38490SChristoph Lameter 		.extra2		= &one_hundred,
30510ff38490SChristoph Lameter 	},
30521743660bSChristoph Lameter #endif
305377461ab3SChristoph Lameter #ifdef CONFIG_SMP
305477461ab3SChristoph Lameter 	{
305577461ab3SChristoph Lameter 		.procname	= "stat_interval",
305677461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
305777461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
305877461ab3SChristoph Lameter 		.mode		= 0644,
30596d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
306077461ab3SChristoph Lameter 	},
306152b6f46bSHugh Dickins 	{
306252b6f46bSHugh Dickins 		.procname	= "stat_refresh",
306352b6f46bSHugh Dickins 		.data		= NULL,
306452b6f46bSHugh Dickins 		.maxlen		= 0,
306552b6f46bSHugh Dickins 		.mode		= 0600,
306652b6f46bSHugh Dickins 		.proc_handler	= vmstat_refresh,
306752b6f46bSHugh Dickins 	},
306877461ab3SChristoph Lameter #endif
30696e141546SDavid Howells #ifdef CONFIG_MMU
3070ed032189SEric Paris 	{
3071ed032189SEric Paris 		.procname	= "mmap_min_addr",
3072788084abSEric Paris 		.data		= &dac_mmap_min_addr,
3073ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
3074ed032189SEric Paris 		.mode		= 0644,
30756d456111SEric W. Biederman 		.proc_handler	= mmap_min_addr_handler,
3076ed032189SEric Paris 	},
30776e141546SDavid Howells #endif
3078f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
3079f0c0b2b8SKAMEZAWA Hiroyuki 	{
3080f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
3081f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
3082f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
3083f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
30846d456111SEric W. Biederman 		.proc_handler	= numa_zonelist_order_handler,
3085f0c0b2b8SKAMEZAWA Hiroyuki 	},
3086f0c0b2b8SKAMEZAWA Hiroyuki #endif
30872b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
30885c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3089e6e5494cSIngo Molnar 	{
3090e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
30913d7ee969SAndy Lutomirski #ifdef CONFIG_X86_32
30923d7ee969SAndy Lutomirski 		.data		= &vdso32_enabled,
30933d7ee969SAndy Lutomirski 		.maxlen		= sizeof(vdso32_enabled),
30943d7ee969SAndy Lutomirski #else
3095e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
3096e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
30973d7ee969SAndy Lutomirski #endif
3098e6e5494cSIngo Molnar 		.mode		= 0644,
30996d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3100eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3101e6e5494cSIngo Molnar 	},
3102e6e5494cSIngo Molnar #endif
3103195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
3104195cf453SBron Gondwana 	{
3105195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
3106195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
3107195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
3108195cf453SBron Gondwana 		.mode		= 0644,
31096d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3110eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3111eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3112195cf453SBron Gondwana 	},
3113195cf453SBron Gondwana #endif
31146a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE
31156a46079cSAndi Kleen 	{
31166a46079cSAndi Kleen 		.procname	= "memory_failure_early_kill",
31176a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_early_kill,
31186a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_early_kill),
31196a46079cSAndi Kleen 		.mode		= 0644,
31206d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3121eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3122eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
31236a46079cSAndi Kleen 	},
31246a46079cSAndi Kleen 	{
31256a46079cSAndi Kleen 		.procname	= "memory_failure_recovery",
31266a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_recovery,
31276a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_recovery),
31286a46079cSAndi Kleen 		.mode		= 0644,
31296d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3130eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3131eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
31326a46079cSAndi Kleen 	},
31336a46079cSAndi Kleen #endif
3134c9b1d098SAndrew Shewmaker 	{
3135c9b1d098SAndrew Shewmaker 		.procname	= "user_reserve_kbytes",
3136c9b1d098SAndrew Shewmaker 		.data		= &sysctl_user_reserve_kbytes,
3137c9b1d098SAndrew Shewmaker 		.maxlen		= sizeof(sysctl_user_reserve_kbytes),
3138c9b1d098SAndrew Shewmaker 		.mode		= 0644,
3139c9b1d098SAndrew Shewmaker 		.proc_handler	= proc_doulongvec_minmax,
3140c9b1d098SAndrew Shewmaker 	},
31414eeab4f5SAndrew Shewmaker 	{
31424eeab4f5SAndrew Shewmaker 		.procname	= "admin_reserve_kbytes",
31434eeab4f5SAndrew Shewmaker 		.data		= &sysctl_admin_reserve_kbytes,
31444eeab4f5SAndrew Shewmaker 		.maxlen		= sizeof(sysctl_admin_reserve_kbytes),
31454eeab4f5SAndrew Shewmaker 		.mode		= 0644,
31464eeab4f5SAndrew Shewmaker 		.proc_handler	= proc_doulongvec_minmax,
31474eeab4f5SAndrew Shewmaker 	},
3148d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3149d07e2259SDaniel Cashman 	{
3150d07e2259SDaniel Cashman 		.procname	= "mmap_rnd_bits",
3151d07e2259SDaniel Cashman 		.data		= &mmap_rnd_bits,
3152d07e2259SDaniel Cashman 		.maxlen		= sizeof(mmap_rnd_bits),
3153d07e2259SDaniel Cashman 		.mode		= 0600,
3154d07e2259SDaniel Cashman 		.proc_handler	= proc_dointvec_minmax,
3155d07e2259SDaniel Cashman 		.extra1		= (void *)&mmap_rnd_bits_min,
3156d07e2259SDaniel Cashman 		.extra2		= (void *)&mmap_rnd_bits_max,
3157d07e2259SDaniel Cashman 	},
3158d07e2259SDaniel Cashman #endif
3159d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3160d07e2259SDaniel Cashman 	{
3161d07e2259SDaniel Cashman 		.procname	= "mmap_rnd_compat_bits",
3162d07e2259SDaniel Cashman 		.data		= &mmap_rnd_compat_bits,
3163d07e2259SDaniel Cashman 		.maxlen		= sizeof(mmap_rnd_compat_bits),
3164d07e2259SDaniel Cashman 		.mode		= 0600,
3165d07e2259SDaniel Cashman 		.proc_handler	= proc_dointvec_minmax,
3166d07e2259SDaniel Cashman 		.extra1		= (void *)&mmap_rnd_compat_bits_min,
3167d07e2259SDaniel Cashman 		.extra2		= (void *)&mmap_rnd_compat_bits_max,
3168d07e2259SDaniel Cashman 	},
3169d07e2259SDaniel Cashman #endif
3170cefdca0aSPeter Xu #ifdef CONFIG_USERFAULTFD
3171cefdca0aSPeter Xu 	{
3172cefdca0aSPeter Xu 		.procname	= "unprivileged_userfaultfd",
3173cefdca0aSPeter Xu 		.data		= &sysctl_unprivileged_userfaultfd,
3174cefdca0aSPeter Xu 		.maxlen		= sizeof(sysctl_unprivileged_userfaultfd),
3175cefdca0aSPeter Xu 		.mode		= 0644,
3176cefdca0aSPeter Xu 		.proc_handler	= proc_dointvec_minmax,
3177eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3178eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3179cefdca0aSPeter Xu 	},
3180cefdca0aSPeter Xu #endif
31816fce56ecSEric W. Biederman 	{ }
31821da177e4SLinus Torvalds };
31831da177e4SLinus Torvalds 
3184d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
31851da177e4SLinus Torvalds 	{
31861da177e4SLinus Torvalds 		.procname	= "inode-nr",
31871da177e4SLinus Torvalds 		.data		= &inodes_stat,
31883942c07cSGlauber Costa 		.maxlen		= 2*sizeof(long),
31891da177e4SLinus Torvalds 		.mode		= 0444,
3190cffbc8aaSDave Chinner 		.proc_handler	= proc_nr_inodes,
31911da177e4SLinus Torvalds 	},
31921da177e4SLinus Torvalds 	{
31931da177e4SLinus Torvalds 		.procname	= "inode-state",
31941da177e4SLinus Torvalds 		.data		= &inodes_stat,
31953942c07cSGlauber Costa 		.maxlen		= 7*sizeof(long),
31961da177e4SLinus Torvalds 		.mode		= 0444,
3197cffbc8aaSDave Chinner 		.proc_handler	= proc_nr_inodes,
31981da177e4SLinus Torvalds 	},
31991da177e4SLinus Torvalds 	{
32001da177e4SLinus Torvalds 		.procname	= "file-nr",
32011da177e4SLinus Torvalds 		.data		= &files_stat,
3202518de9b3SEric Dumazet 		.maxlen		= sizeof(files_stat),
32031da177e4SLinus Torvalds 		.mode		= 0444,
32046d456111SEric W. Biederman 		.proc_handler	= proc_nr_files,
32051da177e4SLinus Torvalds 	},
32061da177e4SLinus Torvalds 	{
32071da177e4SLinus Torvalds 		.procname	= "file-max",
32081da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
3209518de9b3SEric Dumazet 		.maxlen		= sizeof(files_stat.max_files),
32101da177e4SLinus Torvalds 		.mode		= 0644,
3211518de9b3SEric Dumazet 		.proc_handler	= proc_doulongvec_minmax,
32129002b214SWill Deacon 		.extra1		= &zero_ul,
321332a5ad9cSChristian Brauner 		.extra2		= &long_max,
32141da177e4SLinus Torvalds 	},
32151da177e4SLinus Torvalds 	{
32169cfe015aSEric Dumazet 		.procname	= "nr_open",
32179cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
32189b80a184SAlexey Dobriyan 		.maxlen		= sizeof(unsigned int),
32199cfe015aSEric Dumazet 		.mode		= 0644,
32206d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3221eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
3222eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
32239cfe015aSEric Dumazet 	},
32249cfe015aSEric Dumazet 	{
32251da177e4SLinus Torvalds 		.procname	= "dentry-state",
32261da177e4SLinus Torvalds 		.data		= &dentry_stat,
32273942c07cSGlauber Costa 		.maxlen		= 6*sizeof(long),
32281da177e4SLinus Torvalds 		.mode		= 0444,
3229312d3ca8SChristoph Hellwig 		.proc_handler	= proc_nr_dentry,
32301da177e4SLinus Torvalds 	},
32311da177e4SLinus Torvalds 	{
32321da177e4SLinus Torvalds 		.procname	= "overflowuid",
32331da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
32341da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32351da177e4SLinus Torvalds 		.mode		= 0644,
32366d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
32371da177e4SLinus Torvalds 		.extra1		= &minolduid,
32381da177e4SLinus Torvalds 		.extra2		= &maxolduid,
32391da177e4SLinus Torvalds 	},
32401da177e4SLinus Torvalds 	{
32411da177e4SLinus Torvalds 		.procname	= "overflowgid",
32421da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
32431da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32441da177e4SLinus Torvalds 		.mode		= 0644,
32456d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
32461da177e4SLinus Torvalds 		.extra1		= &minolduid,
32471da177e4SLinus Torvalds 		.extra2		= &maxolduid,
32481da177e4SLinus Torvalds 	},
3249bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
32501da177e4SLinus Torvalds 	{
32511da177e4SLinus Torvalds 		.procname	= "leases-enable",
32521da177e4SLinus Torvalds 		.data		= &leases_enable,
32531da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32541da177e4SLinus Torvalds 		.mode		= 0644,
32556d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
32561da177e4SLinus Torvalds 	},
3257bfcd17a6SThomas Petazzoni #endif
32581da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
32591da177e4SLinus Torvalds 	{
32601da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
32611da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
32621da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32631da177e4SLinus Torvalds 		.mode		= 0644,
32646d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
32651da177e4SLinus Torvalds 	},
32661da177e4SLinus Torvalds #endif
32671da177e4SLinus Torvalds #ifdef CONFIG_MMU
3268bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
32691da177e4SLinus Torvalds 	{
32701da177e4SLinus Torvalds 		.procname	= "lease-break-time",
32711da177e4SLinus Torvalds 		.data		= &lease_break_time,
32721da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32731da177e4SLinus Torvalds 		.mode		= 0644,
32746d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
32751da177e4SLinus Torvalds 	},
3276bfcd17a6SThomas Petazzoni #endif
3277ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
32781da177e4SLinus Torvalds 	{
32791da177e4SLinus Torvalds 		.procname	= "aio-nr",
32801da177e4SLinus Torvalds 		.data		= &aio_nr,
32811da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
32821da177e4SLinus Torvalds 		.mode		= 0444,
32836d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
32841da177e4SLinus Torvalds 	},
32851da177e4SLinus Torvalds 	{
32861da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
32871da177e4SLinus Torvalds 		.data		= &aio_max_nr,
32881da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
32891da177e4SLinus Torvalds 		.mode		= 0644,
32906d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
32911da177e4SLinus Torvalds 	},
3292ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
32932d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
32940399cb08SRobert Love 	{
32950399cb08SRobert Love 		.procname	= "inotify",
32960399cb08SRobert Love 		.mode		= 0555,
32970399cb08SRobert Love 		.child		= inotify_table,
32980399cb08SRobert Love 	},
32990399cb08SRobert Love #endif
33005b8fea65SAmir Goldstein #ifdef CONFIG_FANOTIFY
33015b8fea65SAmir Goldstein 	{
33025b8fea65SAmir Goldstein 		.procname	= "fanotify",
33035b8fea65SAmir Goldstein 		.mode		= 0555,
33045b8fea65SAmir Goldstein 		.child		= fanotify_table,
33055b8fea65SAmir Goldstein 	},
33065b8fea65SAmir Goldstein #endif
33077ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
33087ef9964eSDavide Libenzi 	{
33097ef9964eSDavide Libenzi 		.procname	= "epoll",
33107ef9964eSDavide Libenzi 		.mode		= 0555,
33117ef9964eSDavide Libenzi 		.child		= epoll_table,
33127ef9964eSDavide Libenzi 	},
33137ef9964eSDavide Libenzi #endif
33141da177e4SLinus Torvalds #endif
3315d6e71144SAlan Cox 	{
3316800179c9SKees Cook 		.procname	= "protected_symlinks",
3317800179c9SKees Cook 		.data		= &sysctl_protected_symlinks,
3318800179c9SKees Cook 		.maxlen		= sizeof(int),
3319800179c9SKees Cook 		.mode		= 0600,
3320800179c9SKees Cook 		.proc_handler	= proc_dointvec_minmax,
3321eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3322eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3323800179c9SKees Cook 	},
3324800179c9SKees Cook 	{
3325800179c9SKees Cook 		.procname	= "protected_hardlinks",
3326800179c9SKees Cook 		.data		= &sysctl_protected_hardlinks,
3327800179c9SKees Cook 		.maxlen		= sizeof(int),
3328800179c9SKees Cook 		.mode		= 0600,
3329800179c9SKees Cook 		.proc_handler	= proc_dointvec_minmax,
3330eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3331eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3332800179c9SKees Cook 	},
3333800179c9SKees Cook 	{
333430aba665SSalvatore Mesoraca 		.procname	= "protected_fifos",
333530aba665SSalvatore Mesoraca 		.data		= &sysctl_protected_fifos,
333630aba665SSalvatore Mesoraca 		.maxlen		= sizeof(int),
333730aba665SSalvatore Mesoraca 		.mode		= 0600,
333830aba665SSalvatore Mesoraca 		.proc_handler	= proc_dointvec_minmax,
3339eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
334030aba665SSalvatore Mesoraca 		.extra2		= &two,
334130aba665SSalvatore Mesoraca 	},
334230aba665SSalvatore Mesoraca 	{
334330aba665SSalvatore Mesoraca 		.procname	= "protected_regular",
334430aba665SSalvatore Mesoraca 		.data		= &sysctl_protected_regular,
334530aba665SSalvatore Mesoraca 		.maxlen		= sizeof(int),
334630aba665SSalvatore Mesoraca 		.mode		= 0600,
334730aba665SSalvatore Mesoraca 		.proc_handler	= proc_dointvec_minmax,
3348eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
334930aba665SSalvatore Mesoraca 		.extra2		= &two,
335030aba665SSalvatore Mesoraca 	},
335130aba665SSalvatore Mesoraca 	{
3352d6e71144SAlan Cox 		.procname	= "suid_dumpable",
3353d6e71144SAlan Cox 		.data		= &suid_dumpable,
3354d6e71144SAlan Cox 		.maxlen		= sizeof(int),
3355d6e71144SAlan Cox 		.mode		= 0644,
335654b50199SKees Cook 		.proc_handler	= proc_dointvec_minmax_coredump,
3357eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
33588e654fbaSMatthew Wilcox 		.extra2		= &two,
3359d6e71144SAlan Cox 	},
33602abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
33612abc26fcSEric W. Biederman 	{
33622abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
33632abc26fcSEric W. Biederman 		.mode		= 0555,
3364f9bd6733SEric W. Biederman 		.child		= sysctl_mount_point,
33652abc26fcSEric W. Biederman 	},
33662abc26fcSEric W. Biederman #endif
3367b492e95bSJens Axboe 	{
3368ff9da691SJens Axboe 		.procname	= "pipe-max-size",
3369ff9da691SJens Axboe 		.data		= &pipe_max_size,
337098159d97SJoe Lawrence 		.maxlen		= sizeof(pipe_max_size),
3371b492e95bSJens Axboe 		.mode		= 0644,
3372319e0a21SEric Biggers 		.proc_handler	= proc_dopipe_max_size,
3373b492e95bSJens Axboe 	},
3374759c0114SWilly Tarreau 	{
3375759c0114SWilly Tarreau 		.procname	= "pipe-user-pages-hard",
3376759c0114SWilly Tarreau 		.data		= &pipe_user_pages_hard,
3377759c0114SWilly Tarreau 		.maxlen		= sizeof(pipe_user_pages_hard),
3378759c0114SWilly Tarreau 		.mode		= 0644,
3379759c0114SWilly Tarreau 		.proc_handler	= proc_doulongvec_minmax,
3380759c0114SWilly Tarreau 	},
3381759c0114SWilly Tarreau 	{
3382759c0114SWilly Tarreau 		.procname	= "pipe-user-pages-soft",
3383759c0114SWilly Tarreau 		.data		= &pipe_user_pages_soft,
3384759c0114SWilly Tarreau 		.maxlen		= sizeof(pipe_user_pages_soft),
3385759c0114SWilly Tarreau 		.mode		= 0644,
3386759c0114SWilly Tarreau 		.proc_handler	= proc_doulongvec_minmax,
3387759c0114SWilly Tarreau 	},
3388d2921684SEric W. Biederman 	{
3389d2921684SEric W. Biederman 		.procname	= "mount-max",
3390d2921684SEric W. Biederman 		.data		= &sysctl_mount_max,
3391d2921684SEric W. Biederman 		.maxlen		= sizeof(unsigned int),
3392d2921684SEric W. Biederman 		.mode		= 0644,
3393d2921684SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3394eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
3395d2921684SEric W. Biederman 	},
33966fce56ecSEric W. Biederman 	{ }
33971da177e4SLinus Torvalds };
33981da177e4SLinus Torvalds 
3399d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
34007ac57a89SCatalin Marinas #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3401abd4f750SMasoud Asgharifard Sharbiani 	{
3402abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
3403abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
3404abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
3405abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
3406abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
3407abd4f750SMasoud Asgharifard Sharbiani 	},
3408abd4f750SMasoud Asgharifard Sharbiani #endif
3409b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES)
3410b2be84dfSMasami Hiramatsu 	{
3411b2be84dfSMasami Hiramatsu 		.procname	= "kprobes-optimization",
3412b2be84dfSMasami Hiramatsu 		.data		= &sysctl_kprobes_optimization,
3413b2be84dfSMasami Hiramatsu 		.maxlen		= sizeof(int),
3414b2be84dfSMasami Hiramatsu 		.mode		= 0644,
3415b2be84dfSMasami Hiramatsu 		.proc_handler	= proc_kprobes_optimization_handler,
3416eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3417eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3418b2be84dfSMasami Hiramatsu 	},
3419b2be84dfSMasami Hiramatsu #endif
34206fce56ecSEric W. Biederman 	{ }
34211da177e4SLinus Torvalds };
34221da177e4SLinus Torvalds 
3423d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
34246fce56ecSEric W. Biederman 	{ }
34251da177e4SLinus Torvalds };
34261da177e4SLinus Torvalds 
3427f461d2dcSChristoph Hellwig static struct ctl_table sysctl_base_table[] = {
3428f461d2dcSChristoph Hellwig 	{
3429f461d2dcSChristoph Hellwig 		.procname	= "kernel",
3430f461d2dcSChristoph Hellwig 		.mode		= 0555,
3431f461d2dcSChristoph Hellwig 		.child		= kern_table,
3432f461d2dcSChristoph Hellwig 	},
3433f461d2dcSChristoph Hellwig 	{
3434f461d2dcSChristoph Hellwig 		.procname	= "vm",
3435f461d2dcSChristoph Hellwig 		.mode		= 0555,
3436f461d2dcSChristoph Hellwig 		.child		= vm_table,
3437f461d2dcSChristoph Hellwig 	},
3438f461d2dcSChristoph Hellwig 	{
3439f461d2dcSChristoph Hellwig 		.procname	= "fs",
3440f461d2dcSChristoph Hellwig 		.mode		= 0555,
3441f461d2dcSChristoph Hellwig 		.child		= fs_table,
3442f461d2dcSChristoph Hellwig 	},
3443f461d2dcSChristoph Hellwig 	{
3444f461d2dcSChristoph Hellwig 		.procname	= "debug",
3445f461d2dcSChristoph Hellwig 		.mode		= 0555,
3446f461d2dcSChristoph Hellwig 		.child		= debug_table,
3447f461d2dcSChristoph Hellwig 	},
3448f461d2dcSChristoph Hellwig 	{
3449f461d2dcSChristoph Hellwig 		.procname	= "dev",
3450f461d2dcSChristoph Hellwig 		.mode		= 0555,
3451f461d2dcSChristoph Hellwig 		.child		= dev_table,
3452f461d2dcSChristoph Hellwig 	},
3453f461d2dcSChristoph Hellwig 	{ }
3454f461d2dcSChristoph Hellwig };
3455f461d2dcSChristoph Hellwig 
3456de4e83bdSEric W. Biederman int __init sysctl_init(void)
3457330d57fbSAl Viro {
3458fd4b616bSSteven Rostedt 	struct ctl_table_header *hdr;
3459fd4b616bSSteven Rostedt 
3460fd4b616bSSteven Rostedt 	hdr = register_sysctl_table(sysctl_base_table);
3461fd4b616bSSteven Rostedt 	kmemleak_not_leak(hdr);
3462330d57fbSAl Viro 	return 0;
3463f7e6ced4SAl Viro }
3464b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
34651da177e4SLinus Torvalds /*
34661da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
34671da177e4SLinus Torvalds  * exception granted :-)
34681da177e4SLinus Torvalds  */
3469*a2071573SJia He EXPORT_SYMBOL(proc_dobool);
34701da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
3471e7d316a0SSubash Abhinov Kasiviswanathan EXPORT_SYMBOL(proc_douintvec);
34721da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
34731da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
347461d9b56aSLuis R. Rodriguez EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
34751da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
34761da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
34771da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
34781da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
34791da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
34800bc19985SStephen Suryaputra EXPORT_SYMBOL(proc_do_large_bitmap);
3481