xref: /openbmc/linux/kernel/sysctl.c (revision 5b8fea65d197f408bb00b251c70d842826d6b70b)
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>
30455cd5abSDan Rosenberg #include <linux/printk.h>
311da177e4SLinus Torvalds #include <linux/proc_fs.h>
3272c2d582SAndrew Morgan #include <linux/security.h>
331da177e4SLinus Torvalds #include <linux/ctype.h>
34fd4b616bSSteven Rostedt #include <linux/kmemleak.h>
3562239ac2SAdrian Bunk #include <linux/fs.h>
361da177e4SLinus Torvalds #include <linux/init.h>
371da177e4SLinus Torvalds #include <linux/kernel.h>
380296b228SKay Sievers #include <linux/kobject.h>
3920380731SArnaldo Carvalho de Melo #include <linux/net.h>
401da177e4SLinus Torvalds #include <linux/sysrq.h>
411da177e4SLinus Torvalds #include <linux/highuid.h>
421da177e4SLinus Torvalds #include <linux/writeback.h>
433fff4c42SIngo Molnar #include <linux/ratelimit.h>
4476ab0f53SMel Gorman #include <linux/compaction.h>
451da177e4SLinus Torvalds #include <linux/hugetlb.h>
461da177e4SLinus Torvalds #include <linux/initrd.h>
470b77f5bfSDavid Howells #include <linux/key.h>
481da177e4SLinus Torvalds #include <linux/times.h>
491da177e4SLinus Torvalds #include <linux/limits.h>
501da177e4SLinus Torvalds #include <linux/dcache.h>
516e006701SAlexey Dobriyan #include <linux/dnotify.h>
521da177e4SLinus Torvalds #include <linux/syscalls.h>
53c748e134SAdrian Bunk #include <linux/vmstat.h>
54c255d844SPavel Machek #include <linux/nfs_fs.h>
55c255d844SPavel Machek #include <linux/acpi.h>
5610a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h>
57b0fc494fSSteven Rostedt #include <linux/ftrace.h>
58cdd6c482SIngo Molnar #include <linux/perf_event.h>
59b2be84dfSMasami Hiramatsu #include <linux/kprobes.h>
60b492e95bSJens Axboe #include <linux/pipe_fs_i.h>
618e4228e1SDavid Rientjes #include <linux/oom.h>
6217f60a7dSEric Paris #include <linux/kmod.h>
6373efc039SDan Ballard #include <linux/capability.h>
6440401530SAl Viro #include <linux/binfmts.h>
65cf4aebc2SClark Williams #include <linux/sched/sysctl.h>
66f7ccbae4SIngo Molnar #include <linux/sched/coredump.h>
677984754bSKees Cook #include <linux/kexec.h>
681be7f75dSAlexei Starovoitov #include <linux/bpf.h>
69d2921684SEric W. Biederman #include <linux/mount.h>
70cefdca0aSPeter Xu #include <linux/userfaultfd_k.h>
712374c09bSChristoph Hellwig #include <linux/coredump.h>
722374c09bSChristoph Hellwig #include <linux/latencytop.h>
732374c09bSChristoph Hellwig #include <linux/pid.h>
741da177e4SLinus Torvalds 
757f2923c4SChristian Brauner #include "../lib/kstrtox.h"
767f2923c4SChristian Brauner 
777c0f6ba6SLinus Torvalds #include <linux/uaccess.h>
781da177e4SLinus Torvalds #include <asm/processor.h>
791da177e4SLinus Torvalds 
8029cbc78bSAndi Kleen #ifdef CONFIG_X86
8129cbc78bSAndi Kleen #include <asm/nmi.h>
820741f4d2SChuck Ebbert #include <asm/stacktrace.h>
836e7c4025SIngo Molnar #include <asm/io.h>
8429cbc78bSAndi Kleen #endif
85d550bbd4SDavid Howells #ifdef CONFIG_SPARC
86d550bbd4SDavid Howells #include <asm/setup.h>
87d550bbd4SDavid Howells #endif
88c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT
89c55b7c3eSDave Young #include <linux/acct.h>
90c55b7c3eSDave Young #endif
914f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES
924f0e056fSDave Young #include <linux/rtmutex.h>
934f0e056fSDave Young #endif
942edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
952edf5e49SDave Young #include <linux/lockdep.h>
962edf5e49SDave Young #endif
9715485a46SDave Young #ifdef CONFIG_CHR_DEV_SG
9815485a46SDave Young #include <scsi/sg.h>
9915485a46SDave Young #endif
100964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
101964c9dffSAlexander Popov #include <linux/stackleak.h>
102964c9dffSAlexander Popov #endif
10358687acbSDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR
104504d7cf1SDon Zickus #include <linux/nmi.h>
105504d7cf1SDon Zickus #endif
106504d7cf1SDon Zickus 
1071da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL)
1081da177e4SLinus Torvalds 
109c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and  maximum */
1102508ce18SDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR
111c4f3b63fSRavikiran G Thirumalai static int sixty = 60;
112c4f3b63fSRavikiran G Thirumalai #endif
113c4f3b63fSRavikiran G Thirumalai 
114270750dbSAaron Tomlin static int __maybe_unused neg_one = -1;
115cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2;
1165509a5d2SDave Hansen static int __maybe_unused four = 4;
1179002b214SWill Deacon static unsigned long zero_ul;
118fc3501d4SSven Wegener static unsigned long one_ul = 1;
11932a5ad9cSChristian Brauner static unsigned long long_max = LONG_MAX;
120c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100;
121c843966cSJohannes Weiner static int two_hundred = 200;
122795ae7a0SJohannes Weiner static int one_thousand = 1000;
123af91322eSDave Young #ifdef CONFIG_PRINTK
124af91322eSDave Young static int ten_thousand = 10000;
125af91322eSDave Young #endif
126c5dfd78eSArnaldo Carvalho de Melo #ifdef CONFIG_PERF_EVENTS
127c5dfd78eSArnaldo Carvalho de Melo static int six_hundred_forty_kb = 640 * 1024;
128c5dfd78eSArnaldo Carvalho de Melo #endif
129c4f3b63fSRavikiran G Thirumalai 
1309e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
1319e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1329e4a5bdaSAndrea Righi 
1331da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1341da177e4SLinus Torvalds static int maxolduid = 65535;
1351da177e4SLinus Torvalds static int minolduid;
1361da177e4SLinus Torvalds 
1371da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
13873efc039SDan Ballard static const int cap_last_cap = CAP_LAST_CAP;
1391da177e4SLinus Torvalds 
140a2e51445SDmitry Vyukov /*
141a2e51445SDmitry Vyukov  * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
142a2e51445SDmitry Vyukov  * and hung_task_check_interval_secs
143a2e51445SDmitry Vyukov  */
14480df2847SLiu Hua #ifdef CONFIG_DETECT_HUNG_TASK
14580df2847SLiu Hua static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
14680df2847SLiu Hua #endif
14780df2847SLiu Hua 
148d14f1729SDave Young #ifdef CONFIG_INOTIFY_USER
149d14f1729SDave Young #include <linux/inotify.h>
150d14f1729SDave Young #endif
151*5b8fea65SAmir Goldstein #ifdef CONFIG_FANOTIFY
152*5b8fea65SAmir Goldstein #include <linux/fanotify.h>
153*5b8fea65SAmir Goldstein #endif
154b6fca725SVineet Gupta 
155d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
156f4aacea2SKees Cook 
157a19ac337SLuis R. Rodriguez /**
158a19ac337SLuis R. Rodriguez  * enum sysctl_writes_mode - supported sysctl write modes
159a19ac337SLuis R. Rodriguez  *
160a19ac337SLuis R. Rodriguez  * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
161a19ac337SLuis R. Rodriguez  *	to be written, and multiple writes on the same sysctl file descriptor
162a19ac337SLuis R. Rodriguez  *	will rewrite the sysctl value, regardless of file position. No warning
163a19ac337SLuis R. Rodriguez  *	is issued when the initial position is not 0.
164a19ac337SLuis R. Rodriguez  * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
165a19ac337SLuis R. Rodriguez  *	not 0.
166a19ac337SLuis R. Rodriguez  * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
167a19ac337SLuis R. Rodriguez  *	file position 0 and the value must be fully contained in the buffer
168a19ac337SLuis R. Rodriguez  *	sent to the write syscall. If dealing with strings respect the file
169a19ac337SLuis R. Rodriguez  *	position, but restrict this to the max length of the buffer, anything
17065f50f25SWeitao Hou  *	passed the max length will be ignored. Multiple writes will append
171a19ac337SLuis R. Rodriguez  *	to the buffer.
172a19ac337SLuis R. Rodriguez  *
173a19ac337SLuis R. Rodriguez  * These write modes control how current file position affects the behavior of
174a19ac337SLuis R. Rodriguez  * updating sysctl values through the proc interface on each write.
175a19ac337SLuis R. Rodriguez  */
176a19ac337SLuis R. Rodriguez enum sysctl_writes_mode {
177a19ac337SLuis R. Rodriguez 	SYSCTL_WRITES_LEGACY		= -1,
178a19ac337SLuis R. Rodriguez 	SYSCTL_WRITES_WARN		= 0,
179a19ac337SLuis R. Rodriguez 	SYSCTL_WRITES_STRICT		= 1,
180a19ac337SLuis R. Rodriguez };
181f4aacea2SKees Cook 
182a19ac337SLuis R. Rodriguez static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
183f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */
184ceb18132SLuis R. Rodriguez 
18567f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
18667f3977fSAlexandre Ghiti     defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
1871da177e4SLinus Torvalds int sysctl_legacy_va_layout;
1881da177e4SLinus Torvalds #endif
1891da177e4SLinus Torvalds 
19077e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
19173c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000;		/* 100 usecs */
19273c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
19373c4efd2SEric Dumazet static int min_wakeup_granularity_ns;			/* 0 usecs */
19473c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
195cbee9f88SPeter Zijlstra #ifdef CONFIG_SMP
1961983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
1971983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
198cbee9f88SPeter Zijlstra #endif /* CONFIG_SMP */
199cbee9f88SPeter Zijlstra #endif /* CONFIG_SCHED_DEBUG */
20077e54a1fSIngo Molnar 
2015e771905SMel Gorman #ifdef CONFIG_COMPACTION
2025e771905SMel Gorman static int min_extfrag_threshold;
2035e771905SMel Gorman static int max_extfrag_threshold = 1000;
2045e771905SMel Gorman #endif
2055e771905SMel Gorman 
206f461d2dcSChristoph Hellwig #endif /* CONFIG_SYSCTL */
207f461d2dcSChristoph Hellwig 
2085447e8e0SArnd Bergmann #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
209d46edd67SSong Liu static int bpf_stats_handler(struct ctl_table *table, int write,
2107787b6fcSTobias Klauser 			     void *buffer, size_t *lenp, loff_t *ppos)
211d46edd67SSong Liu {
212d46edd67SSong Liu 	struct static_key *key = (struct static_key *)table->data;
213d46edd67SSong Liu 	static int saved_val;
214d46edd67SSong Liu 	int val, ret;
215d46edd67SSong Liu 	struct ctl_table tmp = {
216d46edd67SSong Liu 		.data   = &val,
217d46edd67SSong Liu 		.maxlen = sizeof(val),
218d46edd67SSong Liu 		.mode   = table->mode,
219d46edd67SSong Liu 		.extra1 = SYSCTL_ZERO,
220d46edd67SSong Liu 		.extra2 = SYSCTL_ONE,
221d46edd67SSong Liu 	};
222d46edd67SSong Liu 
223d46edd67SSong Liu 	if (write && !capable(CAP_SYS_ADMIN))
224d46edd67SSong Liu 		return -EPERM;
225d46edd67SSong Liu 
226d46edd67SSong Liu 	mutex_lock(&bpf_stats_enabled_mutex);
227d46edd67SSong Liu 	val = saved_val;
228d46edd67SSong Liu 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
229d46edd67SSong Liu 	if (write && !ret && val != saved_val) {
230d46edd67SSong Liu 		if (val)
231d46edd67SSong Liu 			static_key_slow_inc(key);
232d46edd67SSong Liu 		else
233d46edd67SSong Liu 			static_key_slow_dec(key);
234d46edd67SSong Liu 		saved_val = val;
235d46edd67SSong Liu 	}
236d46edd67SSong Liu 	mutex_unlock(&bpf_stats_enabled_mutex);
237d46edd67SSong Liu 	return ret;
238d46edd67SSong Liu }
239d46edd67SSong Liu #endif
240d46edd67SSong Liu 
241f461d2dcSChristoph Hellwig /*
242f461d2dcSChristoph Hellwig  * /proc/sys support
243f461d2dcSChristoph Hellwig  */
244f461d2dcSChristoph Hellwig 
245f461d2dcSChristoph Hellwig #ifdef CONFIG_PROC_SYSCTL
246f461d2dcSChristoph Hellwig 
247f461d2dcSChristoph Hellwig static int _proc_do_string(char *data, int maxlen, int write,
24832927393SChristoph Hellwig 		char *buffer, size_t *lenp, loff_t *ppos)
249f461d2dcSChristoph Hellwig {
250f461d2dcSChristoph Hellwig 	size_t len;
25132927393SChristoph Hellwig 	char c, *p;
252f461d2dcSChristoph Hellwig 
253f461d2dcSChristoph Hellwig 	if (!data || !maxlen || !*lenp) {
254f461d2dcSChristoph Hellwig 		*lenp = 0;
255f461d2dcSChristoph Hellwig 		return 0;
256f461d2dcSChristoph Hellwig 	}
257f461d2dcSChristoph Hellwig 
258f461d2dcSChristoph Hellwig 	if (write) {
259f461d2dcSChristoph Hellwig 		if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
260f461d2dcSChristoph Hellwig 			/* Only continue writes not past the end of buffer. */
261f461d2dcSChristoph Hellwig 			len = strlen(data);
262f461d2dcSChristoph Hellwig 			if (len > maxlen - 1)
263f461d2dcSChristoph Hellwig 				len = maxlen - 1;
264f461d2dcSChristoph Hellwig 
265f461d2dcSChristoph Hellwig 			if (*ppos > len)
266f461d2dcSChristoph Hellwig 				return 0;
267f461d2dcSChristoph Hellwig 			len = *ppos;
268f461d2dcSChristoph Hellwig 		} else {
269f461d2dcSChristoph Hellwig 			/* Start writing from beginning of buffer. */
270f461d2dcSChristoph Hellwig 			len = 0;
271f461d2dcSChristoph Hellwig 		}
272f461d2dcSChristoph Hellwig 
273f461d2dcSChristoph Hellwig 		*ppos += *lenp;
274f461d2dcSChristoph Hellwig 		p = buffer;
275f461d2dcSChristoph Hellwig 		while ((p - buffer) < *lenp && len < maxlen - 1) {
27632927393SChristoph Hellwig 			c = *(p++);
277f461d2dcSChristoph Hellwig 			if (c == 0 || c == '\n')
278f461d2dcSChristoph Hellwig 				break;
279f461d2dcSChristoph Hellwig 			data[len++] = c;
280f461d2dcSChristoph Hellwig 		}
281f461d2dcSChristoph Hellwig 		data[len] = 0;
282f461d2dcSChristoph Hellwig 	} else {
283f461d2dcSChristoph Hellwig 		len = strlen(data);
284f461d2dcSChristoph Hellwig 		if (len > maxlen)
285f461d2dcSChristoph Hellwig 			len = maxlen;
286f461d2dcSChristoph Hellwig 
287f461d2dcSChristoph Hellwig 		if (*ppos > len) {
288f461d2dcSChristoph Hellwig 			*lenp = 0;
289f461d2dcSChristoph Hellwig 			return 0;
290f461d2dcSChristoph Hellwig 		}
291f461d2dcSChristoph Hellwig 
292f461d2dcSChristoph Hellwig 		data += *ppos;
293f461d2dcSChristoph Hellwig 		len  -= *ppos;
294f461d2dcSChristoph Hellwig 
295f461d2dcSChristoph Hellwig 		if (len > *lenp)
296f461d2dcSChristoph Hellwig 			len = *lenp;
297f461d2dcSChristoph Hellwig 		if (len)
29832927393SChristoph Hellwig 			memcpy(buffer, data, len);
299f461d2dcSChristoph Hellwig 		if (len < *lenp) {
30032927393SChristoph Hellwig 			buffer[len] = '\n';
301f461d2dcSChristoph Hellwig 			len++;
302f461d2dcSChristoph Hellwig 		}
303f461d2dcSChristoph Hellwig 		*lenp = len;
304f461d2dcSChristoph Hellwig 		*ppos += len;
305f461d2dcSChristoph Hellwig 	}
306f461d2dcSChristoph Hellwig 	return 0;
307f461d2dcSChristoph Hellwig }
308f461d2dcSChristoph Hellwig 
309f461d2dcSChristoph Hellwig static void warn_sysctl_write(struct ctl_table *table)
310f461d2dcSChristoph Hellwig {
311f461d2dcSChristoph Hellwig 	pr_warn_once("%s wrote to %s when file position was not 0!\n"
312f461d2dcSChristoph Hellwig 		"This will not be supported in the future. To silence this\n"
313f461d2dcSChristoph Hellwig 		"warning, set kernel.sysctl_writes_strict = -1\n",
314f461d2dcSChristoph Hellwig 		current->comm, table->procname);
315f461d2dcSChristoph Hellwig }
316f461d2dcSChristoph Hellwig 
317f461d2dcSChristoph Hellwig /**
318f461d2dcSChristoph Hellwig  * proc_first_pos_non_zero_ignore - check if first position is allowed
319f461d2dcSChristoph Hellwig  * @ppos: file position
320f461d2dcSChristoph Hellwig  * @table: the sysctl table
321f461d2dcSChristoph Hellwig  *
322f461d2dcSChristoph Hellwig  * Returns true if the first position is non-zero and the sysctl_writes_strict
323f461d2dcSChristoph Hellwig  * mode indicates this is not allowed for numeric input types. String proc
324f461d2dcSChristoph Hellwig  * handlers can ignore the return value.
325f461d2dcSChristoph Hellwig  */
326f461d2dcSChristoph Hellwig static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
327f461d2dcSChristoph Hellwig 					   struct ctl_table *table)
328f461d2dcSChristoph Hellwig {
329f461d2dcSChristoph Hellwig 	if (!*ppos)
330f461d2dcSChristoph Hellwig 		return false;
331f461d2dcSChristoph Hellwig 
332f461d2dcSChristoph Hellwig 	switch (sysctl_writes_strict) {
333f461d2dcSChristoph Hellwig 	case SYSCTL_WRITES_STRICT:
334f461d2dcSChristoph Hellwig 		return true;
335f461d2dcSChristoph Hellwig 	case SYSCTL_WRITES_WARN:
336f461d2dcSChristoph Hellwig 		warn_sysctl_write(table);
337f461d2dcSChristoph Hellwig 		return false;
338f461d2dcSChristoph Hellwig 	default:
339f461d2dcSChristoph Hellwig 		return false;
340f461d2dcSChristoph Hellwig 	}
341f461d2dcSChristoph Hellwig }
342f461d2dcSChristoph Hellwig 
343f461d2dcSChristoph Hellwig /**
344f461d2dcSChristoph Hellwig  * proc_dostring - read a string sysctl
345f461d2dcSChristoph Hellwig  * @table: the sysctl table
346f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
347f461d2dcSChristoph Hellwig  * @buffer: the user buffer
348f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
349f461d2dcSChristoph Hellwig  * @ppos: file position
350f461d2dcSChristoph Hellwig  *
351f461d2dcSChristoph Hellwig  * Reads/writes a string from/to the user buffer. If the kernel
352f461d2dcSChristoph Hellwig  * buffer provided is not large enough to hold the string, the
353f461d2dcSChristoph Hellwig  * string is truncated. The copied string is %NULL-terminated.
354f461d2dcSChristoph Hellwig  * If the string is being read by the user process, it is copied
355f461d2dcSChristoph Hellwig  * and a newline '\n' is added. It is truncated if the buffer is
356f461d2dcSChristoph Hellwig  * not large enough.
357f461d2dcSChristoph Hellwig  *
358f461d2dcSChristoph Hellwig  * Returns 0 on success.
359f461d2dcSChristoph Hellwig  */
360f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write,
36132927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
362f461d2dcSChristoph Hellwig {
363f461d2dcSChristoph Hellwig 	if (write)
364f461d2dcSChristoph Hellwig 		proc_first_pos_non_zero_ignore(ppos, table);
365f461d2dcSChristoph Hellwig 
36632927393SChristoph Hellwig 	return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
36732927393SChristoph Hellwig 			ppos);
368f461d2dcSChristoph Hellwig }
369f461d2dcSChristoph Hellwig 
370f461d2dcSChristoph Hellwig static size_t proc_skip_spaces(char **buf)
371f461d2dcSChristoph Hellwig {
372f461d2dcSChristoph Hellwig 	size_t ret;
373f461d2dcSChristoph Hellwig 	char *tmp = skip_spaces(*buf);
374f461d2dcSChristoph Hellwig 	ret = tmp - *buf;
375f461d2dcSChristoph Hellwig 	*buf = tmp;
376f461d2dcSChristoph Hellwig 	return ret;
377f461d2dcSChristoph Hellwig }
378f461d2dcSChristoph Hellwig 
379f461d2dcSChristoph Hellwig static void proc_skip_char(char **buf, size_t *size, const char v)
380f461d2dcSChristoph Hellwig {
381f461d2dcSChristoph Hellwig 	while (*size) {
382f461d2dcSChristoph Hellwig 		if (**buf != v)
383f461d2dcSChristoph Hellwig 			break;
384f461d2dcSChristoph Hellwig 		(*size)--;
385f461d2dcSChristoph Hellwig 		(*buf)++;
386f461d2dcSChristoph Hellwig 	}
387f461d2dcSChristoph Hellwig }
388f461d2dcSChristoph Hellwig 
389f461d2dcSChristoph Hellwig /**
390f461d2dcSChristoph Hellwig  * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
391f461d2dcSChristoph Hellwig  *                   fail on overflow
392f461d2dcSChristoph Hellwig  *
393f461d2dcSChristoph Hellwig  * @cp: kernel buffer containing the string to parse
394f461d2dcSChristoph Hellwig  * @endp: pointer to store the trailing characters
395f461d2dcSChristoph Hellwig  * @base: the base to use
396f461d2dcSChristoph Hellwig  * @res: where the parsed integer will be stored
397f461d2dcSChristoph Hellwig  *
398f461d2dcSChristoph Hellwig  * In case of success 0 is returned and @res will contain the parsed integer,
399f461d2dcSChristoph Hellwig  * @endp will hold any trailing characters.
400f461d2dcSChristoph Hellwig  * This function will fail the parse on overflow. If there wasn't an overflow
401f461d2dcSChristoph Hellwig  * the function will defer the decision what characters count as invalid to the
402f461d2dcSChristoph Hellwig  * caller.
403f461d2dcSChristoph Hellwig  */
404f461d2dcSChristoph Hellwig static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
405f461d2dcSChristoph Hellwig 			   unsigned long *res)
406f461d2dcSChristoph Hellwig {
407f461d2dcSChristoph Hellwig 	unsigned long long result;
408f461d2dcSChristoph Hellwig 	unsigned int rv;
409f461d2dcSChristoph Hellwig 
410f461d2dcSChristoph Hellwig 	cp = _parse_integer_fixup_radix(cp, &base);
411f461d2dcSChristoph Hellwig 	rv = _parse_integer(cp, base, &result);
412f461d2dcSChristoph Hellwig 	if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
413f461d2dcSChristoph Hellwig 		return -ERANGE;
414f461d2dcSChristoph Hellwig 
415f461d2dcSChristoph Hellwig 	cp += rv;
416f461d2dcSChristoph Hellwig 
417f461d2dcSChristoph Hellwig 	if (endp)
418f461d2dcSChristoph Hellwig 		*endp = (char *)cp;
419f461d2dcSChristoph Hellwig 
420f461d2dcSChristoph Hellwig 	*res = (unsigned long)result;
421f461d2dcSChristoph Hellwig 	return 0;
422f461d2dcSChristoph Hellwig }
423f461d2dcSChristoph Hellwig 
424f461d2dcSChristoph Hellwig #define TMPBUFLEN 22
425f461d2dcSChristoph Hellwig /**
426f461d2dcSChristoph Hellwig  * proc_get_long - reads an ASCII formatted integer from a user buffer
427f461d2dcSChristoph Hellwig  *
428f461d2dcSChristoph Hellwig  * @buf: a kernel buffer
429f461d2dcSChristoph Hellwig  * @size: size of the kernel buffer
430f461d2dcSChristoph Hellwig  * @val: this is where the number will be stored
431f461d2dcSChristoph Hellwig  * @neg: set to %TRUE if number is negative
432f461d2dcSChristoph Hellwig  * @perm_tr: a vector which contains the allowed trailers
433f461d2dcSChristoph Hellwig  * @perm_tr_len: size of the perm_tr vector
434f461d2dcSChristoph Hellwig  * @tr: pointer to store the trailer character
435f461d2dcSChristoph Hellwig  *
436f461d2dcSChristoph Hellwig  * In case of success %0 is returned and @buf and @size are updated with
437f461d2dcSChristoph Hellwig  * the amount of bytes read. If @tr is non-NULL and a trailing
438f461d2dcSChristoph Hellwig  * character exists (size is non-zero after returning from this
439f461d2dcSChristoph Hellwig  * function), @tr is updated with the trailing character.
440f461d2dcSChristoph Hellwig  */
441f461d2dcSChristoph Hellwig static int proc_get_long(char **buf, size_t *size,
442f461d2dcSChristoph Hellwig 			  unsigned long *val, bool *neg,
443f461d2dcSChristoph Hellwig 			  const char *perm_tr, unsigned perm_tr_len, char *tr)
444f461d2dcSChristoph Hellwig {
445f461d2dcSChristoph Hellwig 	int len;
446f461d2dcSChristoph Hellwig 	char *p, tmp[TMPBUFLEN];
447f461d2dcSChristoph Hellwig 
448f461d2dcSChristoph Hellwig 	if (!*size)
449f461d2dcSChristoph Hellwig 		return -EINVAL;
450f461d2dcSChristoph Hellwig 
451f461d2dcSChristoph Hellwig 	len = *size;
452f461d2dcSChristoph Hellwig 	if (len > TMPBUFLEN - 1)
453f461d2dcSChristoph Hellwig 		len = TMPBUFLEN - 1;
454f461d2dcSChristoph Hellwig 
455f461d2dcSChristoph Hellwig 	memcpy(tmp, *buf, len);
456f461d2dcSChristoph Hellwig 
457f461d2dcSChristoph Hellwig 	tmp[len] = 0;
458f461d2dcSChristoph Hellwig 	p = tmp;
459f461d2dcSChristoph Hellwig 	if (*p == '-' && *size > 1) {
460f461d2dcSChristoph Hellwig 		*neg = true;
461f461d2dcSChristoph Hellwig 		p++;
462f461d2dcSChristoph Hellwig 	} else
463f461d2dcSChristoph Hellwig 		*neg = false;
464f461d2dcSChristoph Hellwig 	if (!isdigit(*p))
465f461d2dcSChristoph Hellwig 		return -EINVAL;
466f461d2dcSChristoph Hellwig 
467f461d2dcSChristoph Hellwig 	if (strtoul_lenient(p, &p, 0, val))
468f461d2dcSChristoph Hellwig 		return -EINVAL;
469f461d2dcSChristoph Hellwig 
470f461d2dcSChristoph Hellwig 	len = p - tmp;
471f461d2dcSChristoph Hellwig 
472f461d2dcSChristoph Hellwig 	/* We don't know if the next char is whitespace thus we may accept
473f461d2dcSChristoph Hellwig 	 * invalid integers (e.g. 1234...a) or two integers instead of one
474f461d2dcSChristoph Hellwig 	 * (e.g. 123...1). So lets not allow such large numbers. */
475f461d2dcSChristoph Hellwig 	if (len == TMPBUFLEN - 1)
476f461d2dcSChristoph Hellwig 		return -EINVAL;
477f461d2dcSChristoph Hellwig 
478f461d2dcSChristoph Hellwig 	if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
479f461d2dcSChristoph Hellwig 		return -EINVAL;
480f461d2dcSChristoph Hellwig 
481f461d2dcSChristoph Hellwig 	if (tr && (len < *size))
482f461d2dcSChristoph Hellwig 		*tr = *p;
483f461d2dcSChristoph Hellwig 
484f461d2dcSChristoph Hellwig 	*buf += len;
485f461d2dcSChristoph Hellwig 	*size -= len;
486f461d2dcSChristoph Hellwig 
487f461d2dcSChristoph Hellwig 	return 0;
488f461d2dcSChristoph Hellwig }
489f461d2dcSChristoph Hellwig 
490f461d2dcSChristoph Hellwig /**
491f461d2dcSChristoph Hellwig  * proc_put_long - converts an integer to a decimal ASCII formatted string
492f461d2dcSChristoph Hellwig  *
493f461d2dcSChristoph Hellwig  * @buf: the user buffer
494f461d2dcSChristoph Hellwig  * @size: the size of the user buffer
495f461d2dcSChristoph Hellwig  * @val: the integer to be converted
496f461d2dcSChristoph Hellwig  * @neg: sign of the number, %TRUE for negative
497f461d2dcSChristoph Hellwig  *
49832927393SChristoph Hellwig  * In case of success @buf and @size are updated with the amount of bytes
49932927393SChristoph Hellwig  * written.
500f461d2dcSChristoph Hellwig  */
50132927393SChristoph Hellwig static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
502f461d2dcSChristoph Hellwig {
503f461d2dcSChristoph Hellwig 	int len;
504f461d2dcSChristoph Hellwig 	char tmp[TMPBUFLEN], *p = tmp;
505f461d2dcSChristoph Hellwig 
506f461d2dcSChristoph Hellwig 	sprintf(p, "%s%lu", neg ? "-" : "", val);
507f461d2dcSChristoph Hellwig 	len = strlen(tmp);
508f461d2dcSChristoph Hellwig 	if (len > *size)
509f461d2dcSChristoph Hellwig 		len = *size;
51032927393SChristoph Hellwig 	memcpy(*buf, tmp, len);
511f461d2dcSChristoph Hellwig 	*size -= len;
512f461d2dcSChristoph Hellwig 	*buf += len;
513f461d2dcSChristoph Hellwig }
514f461d2dcSChristoph Hellwig #undef TMPBUFLEN
515f461d2dcSChristoph Hellwig 
51632927393SChristoph Hellwig static void proc_put_char(void **buf, size_t *size, char c)
517f461d2dcSChristoph Hellwig {
518f461d2dcSChristoph Hellwig 	if (*size) {
51932927393SChristoph Hellwig 		char **buffer = (char **)buf;
52032927393SChristoph Hellwig 		**buffer = c;
52132927393SChristoph Hellwig 
52232927393SChristoph Hellwig 		(*size)--;
52332927393SChristoph Hellwig 		(*buffer)++;
524f461d2dcSChristoph Hellwig 		*buf = *buffer;
525f461d2dcSChristoph Hellwig 	}
526f461d2dcSChristoph Hellwig }
527f461d2dcSChristoph Hellwig 
528f461d2dcSChristoph Hellwig static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
529f461d2dcSChristoph Hellwig 				 int *valp,
530f461d2dcSChristoph Hellwig 				 int write, void *data)
531f461d2dcSChristoph Hellwig {
532f461d2dcSChristoph Hellwig 	if (write) {
533f461d2dcSChristoph Hellwig 		if (*negp) {
534f461d2dcSChristoph Hellwig 			if (*lvalp > (unsigned long) INT_MAX + 1)
535f461d2dcSChristoph Hellwig 				return -EINVAL;
536f461d2dcSChristoph Hellwig 			*valp = -*lvalp;
537f461d2dcSChristoph Hellwig 		} else {
538f461d2dcSChristoph Hellwig 			if (*lvalp > (unsigned long) INT_MAX)
539f461d2dcSChristoph Hellwig 				return -EINVAL;
540f461d2dcSChristoph Hellwig 			*valp = *lvalp;
541f461d2dcSChristoph Hellwig 		}
542f461d2dcSChristoph Hellwig 	} else {
543f461d2dcSChristoph Hellwig 		int val = *valp;
544f461d2dcSChristoph Hellwig 		if (val < 0) {
545f461d2dcSChristoph Hellwig 			*negp = true;
546f461d2dcSChristoph Hellwig 			*lvalp = -(unsigned long)val;
547f461d2dcSChristoph Hellwig 		} else {
548f461d2dcSChristoph Hellwig 			*negp = false;
549f461d2dcSChristoph Hellwig 			*lvalp = (unsigned long)val;
550f461d2dcSChristoph Hellwig 		}
551f461d2dcSChristoph Hellwig 	}
552f461d2dcSChristoph Hellwig 	return 0;
553f461d2dcSChristoph Hellwig }
554f461d2dcSChristoph Hellwig 
555f461d2dcSChristoph Hellwig static int do_proc_douintvec_conv(unsigned long *lvalp,
556f461d2dcSChristoph Hellwig 				  unsigned int *valp,
557f461d2dcSChristoph Hellwig 				  int write, void *data)
558f461d2dcSChristoph Hellwig {
559f461d2dcSChristoph Hellwig 	if (write) {
560f461d2dcSChristoph Hellwig 		if (*lvalp > UINT_MAX)
561f461d2dcSChristoph Hellwig 			return -EINVAL;
562f461d2dcSChristoph Hellwig 		*valp = *lvalp;
563f461d2dcSChristoph Hellwig 	} else {
564f461d2dcSChristoph Hellwig 		unsigned int val = *valp;
565f461d2dcSChristoph Hellwig 		*lvalp = (unsigned long)val;
566f461d2dcSChristoph Hellwig 	}
567f461d2dcSChristoph Hellwig 	return 0;
568f461d2dcSChristoph Hellwig }
569f461d2dcSChristoph Hellwig 
570f461d2dcSChristoph Hellwig static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
571f461d2dcSChristoph Hellwig 
572f461d2dcSChristoph Hellwig static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
57332927393SChristoph Hellwig 		  int write, void *buffer,
574f461d2dcSChristoph Hellwig 		  size_t *lenp, loff_t *ppos,
575f461d2dcSChristoph Hellwig 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
576f461d2dcSChristoph Hellwig 			      int write, void *data),
577f461d2dcSChristoph Hellwig 		  void *data)
578f461d2dcSChristoph Hellwig {
579f461d2dcSChristoph Hellwig 	int *i, vleft, first = 1, err = 0;
580f461d2dcSChristoph Hellwig 	size_t left;
58132927393SChristoph Hellwig 	char *p;
582f461d2dcSChristoph Hellwig 
583f461d2dcSChristoph Hellwig 	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
584f461d2dcSChristoph Hellwig 		*lenp = 0;
585f461d2dcSChristoph Hellwig 		return 0;
586f461d2dcSChristoph Hellwig 	}
587f461d2dcSChristoph Hellwig 
588f461d2dcSChristoph Hellwig 	i = (int *) tbl_data;
589f461d2dcSChristoph Hellwig 	vleft = table->maxlen / sizeof(*i);
590f461d2dcSChristoph Hellwig 	left = *lenp;
591f461d2dcSChristoph Hellwig 
592f461d2dcSChristoph Hellwig 	if (!conv)
593f461d2dcSChristoph Hellwig 		conv = do_proc_dointvec_conv;
594f461d2dcSChristoph Hellwig 
595f461d2dcSChristoph Hellwig 	if (write) {
596f461d2dcSChristoph Hellwig 		if (proc_first_pos_non_zero_ignore(ppos, table))
597f461d2dcSChristoph Hellwig 			goto out;
598f461d2dcSChristoph Hellwig 
599f461d2dcSChristoph Hellwig 		if (left > PAGE_SIZE - 1)
600f461d2dcSChristoph Hellwig 			left = PAGE_SIZE - 1;
60132927393SChristoph Hellwig 		p = buffer;
602f461d2dcSChristoph Hellwig 	}
603f461d2dcSChristoph Hellwig 
604f461d2dcSChristoph Hellwig 	for (; left && vleft--; i++, first=0) {
605f461d2dcSChristoph Hellwig 		unsigned long lval;
606f461d2dcSChristoph Hellwig 		bool neg;
607f461d2dcSChristoph Hellwig 
608f461d2dcSChristoph Hellwig 		if (write) {
609f461d2dcSChristoph Hellwig 			left -= proc_skip_spaces(&p);
610f461d2dcSChristoph Hellwig 
611f461d2dcSChristoph Hellwig 			if (!left)
612f461d2dcSChristoph Hellwig 				break;
613f461d2dcSChristoph Hellwig 			err = proc_get_long(&p, &left, &lval, &neg,
614f461d2dcSChristoph Hellwig 					     proc_wspace_sep,
615f461d2dcSChristoph Hellwig 					     sizeof(proc_wspace_sep), NULL);
616f461d2dcSChristoph Hellwig 			if (err)
617f461d2dcSChristoph Hellwig 				break;
618f461d2dcSChristoph Hellwig 			if (conv(&neg, &lval, i, 1, data)) {
619f461d2dcSChristoph Hellwig 				err = -EINVAL;
620f461d2dcSChristoph Hellwig 				break;
621f461d2dcSChristoph Hellwig 			}
622f461d2dcSChristoph Hellwig 		} else {
623f461d2dcSChristoph Hellwig 			if (conv(&neg, &lval, i, 0, data)) {
624f461d2dcSChristoph Hellwig 				err = -EINVAL;
625f461d2dcSChristoph Hellwig 				break;
626f461d2dcSChristoph Hellwig 			}
627f461d2dcSChristoph Hellwig 			if (!first)
62832927393SChristoph Hellwig 				proc_put_char(&buffer, &left, '\t');
62932927393SChristoph Hellwig 			proc_put_long(&buffer, &left, lval, neg);
630f461d2dcSChristoph Hellwig 		}
631f461d2dcSChristoph Hellwig 	}
632f461d2dcSChristoph Hellwig 
633f461d2dcSChristoph Hellwig 	if (!write && !first && left && !err)
63432927393SChristoph Hellwig 		proc_put_char(&buffer, &left, '\n');
635f461d2dcSChristoph Hellwig 	if (write && !err && left)
636f461d2dcSChristoph Hellwig 		left -= proc_skip_spaces(&p);
63732927393SChristoph Hellwig 	if (write && first)
638f461d2dcSChristoph Hellwig 		return err ? : -EINVAL;
639f461d2dcSChristoph Hellwig 	*lenp -= left;
640f461d2dcSChristoph Hellwig out:
641f461d2dcSChristoph Hellwig 	*ppos += *lenp;
642f461d2dcSChristoph Hellwig 	return err;
643f461d2dcSChristoph Hellwig }
644f461d2dcSChristoph Hellwig 
645f461d2dcSChristoph Hellwig static int do_proc_dointvec(struct ctl_table *table, int write,
64632927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos,
647f461d2dcSChristoph Hellwig 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
648f461d2dcSChristoph Hellwig 			      int write, void *data),
649f461d2dcSChristoph Hellwig 		  void *data)
650f461d2dcSChristoph Hellwig {
651f461d2dcSChristoph Hellwig 	return __do_proc_dointvec(table->data, table, write,
652f461d2dcSChristoph Hellwig 			buffer, lenp, ppos, conv, data);
653f461d2dcSChristoph Hellwig }
654f461d2dcSChristoph Hellwig 
655f461d2dcSChristoph Hellwig static int do_proc_douintvec_w(unsigned int *tbl_data,
656f461d2dcSChristoph Hellwig 			       struct ctl_table *table,
65732927393SChristoph Hellwig 			       void *buffer,
658f461d2dcSChristoph Hellwig 			       size_t *lenp, loff_t *ppos,
659f461d2dcSChristoph Hellwig 			       int (*conv)(unsigned long *lvalp,
660f461d2dcSChristoph Hellwig 					   unsigned int *valp,
661f461d2dcSChristoph Hellwig 					   int write, void *data),
662f461d2dcSChristoph Hellwig 			       void *data)
663f461d2dcSChristoph Hellwig {
664f461d2dcSChristoph Hellwig 	unsigned long lval;
665f461d2dcSChristoph Hellwig 	int err = 0;
666f461d2dcSChristoph Hellwig 	size_t left;
667f461d2dcSChristoph Hellwig 	bool neg;
66832927393SChristoph Hellwig 	char *p = buffer;
669f461d2dcSChristoph Hellwig 
670f461d2dcSChristoph Hellwig 	left = *lenp;
671f461d2dcSChristoph Hellwig 
672f461d2dcSChristoph Hellwig 	if (proc_first_pos_non_zero_ignore(ppos, table))
673f461d2dcSChristoph Hellwig 		goto bail_early;
674f461d2dcSChristoph Hellwig 
675f461d2dcSChristoph Hellwig 	if (left > PAGE_SIZE - 1)
676f461d2dcSChristoph Hellwig 		left = PAGE_SIZE - 1;
677f461d2dcSChristoph Hellwig 
678f461d2dcSChristoph Hellwig 	left -= proc_skip_spaces(&p);
679f461d2dcSChristoph Hellwig 	if (!left) {
680f461d2dcSChristoph Hellwig 		err = -EINVAL;
681f461d2dcSChristoph Hellwig 		goto out_free;
682f461d2dcSChristoph Hellwig 	}
683f461d2dcSChristoph Hellwig 
684f461d2dcSChristoph Hellwig 	err = proc_get_long(&p, &left, &lval, &neg,
685f461d2dcSChristoph Hellwig 			     proc_wspace_sep,
686f461d2dcSChristoph Hellwig 			     sizeof(proc_wspace_sep), NULL);
687f461d2dcSChristoph Hellwig 	if (err || neg) {
688f461d2dcSChristoph Hellwig 		err = -EINVAL;
689f461d2dcSChristoph Hellwig 		goto out_free;
690f461d2dcSChristoph Hellwig 	}
691f461d2dcSChristoph Hellwig 
692f461d2dcSChristoph Hellwig 	if (conv(&lval, tbl_data, 1, data)) {
693f461d2dcSChristoph Hellwig 		err = -EINVAL;
694f461d2dcSChristoph Hellwig 		goto out_free;
695f461d2dcSChristoph Hellwig 	}
696f461d2dcSChristoph Hellwig 
697f461d2dcSChristoph Hellwig 	if (!err && left)
698f461d2dcSChristoph Hellwig 		left -= proc_skip_spaces(&p);
699f461d2dcSChristoph Hellwig 
700f461d2dcSChristoph Hellwig out_free:
701f461d2dcSChristoph Hellwig 	if (err)
702f461d2dcSChristoph Hellwig 		return -EINVAL;
703f461d2dcSChristoph Hellwig 
704f461d2dcSChristoph Hellwig 	return 0;
705f461d2dcSChristoph Hellwig 
706f461d2dcSChristoph Hellwig 	/* This is in keeping with old __do_proc_dointvec() */
707f461d2dcSChristoph Hellwig bail_early:
708f461d2dcSChristoph Hellwig 	*ppos += *lenp;
709f461d2dcSChristoph Hellwig 	return err;
710f461d2dcSChristoph Hellwig }
711f461d2dcSChristoph Hellwig 
71232927393SChristoph Hellwig static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
713f461d2dcSChristoph Hellwig 			       size_t *lenp, loff_t *ppos,
714f461d2dcSChristoph Hellwig 			       int (*conv)(unsigned long *lvalp,
715f461d2dcSChristoph Hellwig 					   unsigned int *valp,
716f461d2dcSChristoph Hellwig 					   int write, void *data),
717f461d2dcSChristoph Hellwig 			       void *data)
718f461d2dcSChristoph Hellwig {
719f461d2dcSChristoph Hellwig 	unsigned long lval;
720f461d2dcSChristoph Hellwig 	int err = 0;
721f461d2dcSChristoph Hellwig 	size_t left;
722f461d2dcSChristoph Hellwig 
723f461d2dcSChristoph Hellwig 	left = *lenp;
724f461d2dcSChristoph Hellwig 
725f461d2dcSChristoph Hellwig 	if (conv(&lval, tbl_data, 0, data)) {
726f461d2dcSChristoph Hellwig 		err = -EINVAL;
727f461d2dcSChristoph Hellwig 		goto out;
728f461d2dcSChristoph Hellwig 	}
729f461d2dcSChristoph Hellwig 
73032927393SChristoph Hellwig 	proc_put_long(&buffer, &left, lval, false);
73132927393SChristoph Hellwig 	if (!left)
732f461d2dcSChristoph Hellwig 		goto out;
733f461d2dcSChristoph Hellwig 
73432927393SChristoph Hellwig 	proc_put_char(&buffer, &left, '\n');
735f461d2dcSChristoph Hellwig 
736f461d2dcSChristoph Hellwig out:
737f461d2dcSChristoph Hellwig 	*lenp -= left;
738f461d2dcSChristoph Hellwig 	*ppos += *lenp;
739f461d2dcSChristoph Hellwig 
740f461d2dcSChristoph Hellwig 	return err;
741f461d2dcSChristoph Hellwig }
742f461d2dcSChristoph Hellwig 
743f461d2dcSChristoph Hellwig static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
74432927393SChristoph Hellwig 			       int write, void *buffer,
745f461d2dcSChristoph Hellwig 			       size_t *lenp, loff_t *ppos,
746f461d2dcSChristoph Hellwig 			       int (*conv)(unsigned long *lvalp,
747f461d2dcSChristoph Hellwig 					   unsigned int *valp,
748f461d2dcSChristoph Hellwig 					   int write, void *data),
749f461d2dcSChristoph Hellwig 			       void *data)
750f461d2dcSChristoph Hellwig {
751f461d2dcSChristoph Hellwig 	unsigned int *i, vleft;
752f461d2dcSChristoph Hellwig 
753f461d2dcSChristoph Hellwig 	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
754f461d2dcSChristoph Hellwig 		*lenp = 0;
755f461d2dcSChristoph Hellwig 		return 0;
756f461d2dcSChristoph Hellwig 	}
757f461d2dcSChristoph Hellwig 
758f461d2dcSChristoph Hellwig 	i = (unsigned int *) tbl_data;
759f461d2dcSChristoph Hellwig 	vleft = table->maxlen / sizeof(*i);
760f461d2dcSChristoph Hellwig 
761f461d2dcSChristoph Hellwig 	/*
762f461d2dcSChristoph Hellwig 	 * Arrays are not supported, keep this simple. *Do not* add
763f461d2dcSChristoph Hellwig 	 * support for them.
764f461d2dcSChristoph Hellwig 	 */
765f461d2dcSChristoph Hellwig 	if (vleft != 1) {
766f461d2dcSChristoph Hellwig 		*lenp = 0;
767f461d2dcSChristoph Hellwig 		return -EINVAL;
768f461d2dcSChristoph Hellwig 	}
769f461d2dcSChristoph Hellwig 
770f461d2dcSChristoph Hellwig 	if (!conv)
771f461d2dcSChristoph Hellwig 		conv = do_proc_douintvec_conv;
772f461d2dcSChristoph Hellwig 
773f461d2dcSChristoph Hellwig 	if (write)
774f461d2dcSChristoph Hellwig 		return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
775f461d2dcSChristoph Hellwig 					   conv, data);
776f461d2dcSChristoph Hellwig 	return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
777f461d2dcSChristoph Hellwig }
778f461d2dcSChristoph Hellwig 
779f461d2dcSChristoph Hellwig static int do_proc_douintvec(struct ctl_table *table, int write,
78032927393SChristoph Hellwig 			     void *buffer, size_t *lenp, loff_t *ppos,
781f461d2dcSChristoph Hellwig 			     int (*conv)(unsigned long *lvalp,
782f461d2dcSChristoph Hellwig 					 unsigned int *valp,
783f461d2dcSChristoph Hellwig 					 int write, void *data),
784f461d2dcSChristoph Hellwig 			     void *data)
785f461d2dcSChristoph Hellwig {
786f461d2dcSChristoph Hellwig 	return __do_proc_douintvec(table->data, table, write,
787f461d2dcSChristoph Hellwig 				   buffer, lenp, ppos, conv, data);
788f461d2dcSChristoph Hellwig }
789f461d2dcSChristoph Hellwig 
790f461d2dcSChristoph Hellwig /**
791f461d2dcSChristoph Hellwig  * proc_dointvec - read a vector of integers
792f461d2dcSChristoph Hellwig  * @table: the sysctl table
793f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
794f461d2dcSChristoph Hellwig  * @buffer: the user buffer
795f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
796f461d2dcSChristoph Hellwig  * @ppos: file position
797f461d2dcSChristoph Hellwig  *
798f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
799f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
800f461d2dcSChristoph Hellwig  *
801f461d2dcSChristoph Hellwig  * Returns 0 on success.
802f461d2dcSChristoph Hellwig  */
80332927393SChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, void *buffer,
80432927393SChristoph Hellwig 		  size_t *lenp, loff_t *ppos)
805f461d2dcSChristoph Hellwig {
806f461d2dcSChristoph Hellwig 	return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
807f461d2dcSChristoph Hellwig }
808f461d2dcSChristoph Hellwig 
809f461d2dcSChristoph Hellwig #ifdef CONFIG_COMPACTION
810f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
81132927393SChristoph Hellwig 		int write, void *buffer, size_t *lenp, loff_t *ppos)
812f461d2dcSChristoph Hellwig {
813f461d2dcSChristoph Hellwig 	int ret, old;
814f461d2dcSChristoph Hellwig 
815f461d2dcSChristoph Hellwig 	if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
816f461d2dcSChristoph Hellwig 		return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
817f461d2dcSChristoph Hellwig 
818f461d2dcSChristoph Hellwig 	old = *(int *)table->data;
819f461d2dcSChristoph Hellwig 	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
820f461d2dcSChristoph Hellwig 	if (ret)
821f461d2dcSChristoph Hellwig 		return ret;
822f461d2dcSChristoph Hellwig 	if (old != *(int *)table->data)
823f461d2dcSChristoph Hellwig 		pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
824f461d2dcSChristoph Hellwig 			     table->procname, current->comm,
825f461d2dcSChristoph Hellwig 			     task_pid_nr(current));
826f461d2dcSChristoph Hellwig 	return ret;
827f461d2dcSChristoph Hellwig }
828f461d2dcSChristoph Hellwig #endif
829f461d2dcSChristoph Hellwig 
830f461d2dcSChristoph Hellwig /**
831f461d2dcSChristoph Hellwig  * proc_douintvec - read a vector of unsigned integers
832f461d2dcSChristoph Hellwig  * @table: the sysctl table
833f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
834f461d2dcSChristoph Hellwig  * @buffer: the user buffer
835f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
836f461d2dcSChristoph Hellwig  * @ppos: file position
837f461d2dcSChristoph Hellwig  *
838f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
839f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
840f461d2dcSChristoph Hellwig  *
841f461d2dcSChristoph Hellwig  * Returns 0 on success.
842f461d2dcSChristoph Hellwig  */
84332927393SChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, void *buffer,
84432927393SChristoph Hellwig 		size_t *lenp, loff_t *ppos)
845f461d2dcSChristoph Hellwig {
846f461d2dcSChristoph Hellwig 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
847f461d2dcSChristoph Hellwig 				 do_proc_douintvec_conv, NULL);
848f461d2dcSChristoph Hellwig }
849f461d2dcSChristoph Hellwig 
850f461d2dcSChristoph Hellwig /*
851f461d2dcSChristoph Hellwig  * Taint values can only be increased
852f461d2dcSChristoph Hellwig  * This means we can safely use a temporary.
853f461d2dcSChristoph Hellwig  */
854f461d2dcSChristoph Hellwig static int proc_taint(struct ctl_table *table, int write,
85532927393SChristoph Hellwig 			       void *buffer, size_t *lenp, loff_t *ppos)
856f461d2dcSChristoph Hellwig {
857f461d2dcSChristoph Hellwig 	struct ctl_table t;
858f461d2dcSChristoph Hellwig 	unsigned long tmptaint = get_taint();
859f461d2dcSChristoph Hellwig 	int err;
860f461d2dcSChristoph Hellwig 
861f461d2dcSChristoph Hellwig 	if (write && !capable(CAP_SYS_ADMIN))
862f461d2dcSChristoph Hellwig 		return -EPERM;
863f461d2dcSChristoph Hellwig 
864f461d2dcSChristoph Hellwig 	t = *table;
865f461d2dcSChristoph Hellwig 	t.data = &tmptaint;
866f461d2dcSChristoph Hellwig 	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
867f461d2dcSChristoph Hellwig 	if (err < 0)
868f461d2dcSChristoph Hellwig 		return err;
869f461d2dcSChristoph Hellwig 
870f461d2dcSChristoph Hellwig 	if (write) {
871db38d5c1SRafael Aquini 		int i;
872db38d5c1SRafael Aquini 
873db38d5c1SRafael Aquini 		/*
874db38d5c1SRafael Aquini 		 * If we are relying on panic_on_taint not producing
875db38d5c1SRafael Aquini 		 * false positives due to userspace input, bail out
876db38d5c1SRafael Aquini 		 * before setting the requested taint flags.
877db38d5c1SRafael Aquini 		 */
878db38d5c1SRafael Aquini 		if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
879db38d5c1SRafael Aquini 			return -EINVAL;
880db38d5c1SRafael Aquini 
881f461d2dcSChristoph Hellwig 		/*
882f461d2dcSChristoph Hellwig 		 * Poor man's atomic or. Not worth adding a primitive
883f461d2dcSChristoph Hellwig 		 * to everyone's atomic.h for this
884f461d2dcSChristoph Hellwig 		 */
885e77132e7SRafael Aquini 		for (i = 0; i < TAINT_FLAGS_COUNT; i++)
886e77132e7SRafael Aquini 			if ((1UL << i) & tmptaint)
887f461d2dcSChristoph Hellwig 				add_taint(i, LOCKDEP_STILL_OK);
888f461d2dcSChristoph Hellwig 	}
889f461d2dcSChristoph Hellwig 
890f461d2dcSChristoph Hellwig 	return err;
891f461d2dcSChristoph Hellwig }
892f461d2dcSChristoph Hellwig 
893f461d2dcSChristoph Hellwig #ifdef CONFIG_PRINTK
894f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
89532927393SChristoph Hellwig 				void *buffer, size_t *lenp, loff_t *ppos)
896f461d2dcSChristoph Hellwig {
897f461d2dcSChristoph Hellwig 	if (write && !capable(CAP_SYS_ADMIN))
898f461d2dcSChristoph Hellwig 		return -EPERM;
899f461d2dcSChristoph Hellwig 
900f461d2dcSChristoph Hellwig 	return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
901f461d2dcSChristoph Hellwig }
902f461d2dcSChristoph Hellwig #endif
903f461d2dcSChristoph Hellwig 
904f461d2dcSChristoph Hellwig /**
905f461d2dcSChristoph Hellwig  * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
906f461d2dcSChristoph Hellwig  * @min: pointer to minimum allowable value
907f461d2dcSChristoph Hellwig  * @max: pointer to maximum allowable value
908f461d2dcSChristoph Hellwig  *
909f461d2dcSChristoph Hellwig  * The do_proc_dointvec_minmax_conv_param structure provides the
910f461d2dcSChristoph Hellwig  * minimum and maximum values for doing range checking for those sysctl
911f461d2dcSChristoph Hellwig  * parameters that use the proc_dointvec_minmax() handler.
912f461d2dcSChristoph Hellwig  */
913f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param {
914f461d2dcSChristoph Hellwig 	int *min;
915f461d2dcSChristoph Hellwig 	int *max;
916f461d2dcSChristoph Hellwig };
917f461d2dcSChristoph Hellwig 
918f461d2dcSChristoph Hellwig static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
919f461d2dcSChristoph Hellwig 					int *valp,
920f461d2dcSChristoph Hellwig 					int write, void *data)
921f461d2dcSChristoph Hellwig {
922f461d2dcSChristoph Hellwig 	int tmp, ret;
923f461d2dcSChristoph Hellwig 	struct do_proc_dointvec_minmax_conv_param *param = data;
924f461d2dcSChristoph Hellwig 	/*
925f461d2dcSChristoph Hellwig 	 * If writing, first do so via a temporary local int so we can
926f461d2dcSChristoph Hellwig 	 * bounds-check it before touching *valp.
927f461d2dcSChristoph Hellwig 	 */
928f461d2dcSChristoph Hellwig 	int *ip = write ? &tmp : valp;
929f461d2dcSChristoph Hellwig 
930f461d2dcSChristoph Hellwig 	ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
931f461d2dcSChristoph Hellwig 	if (ret)
932f461d2dcSChristoph Hellwig 		return ret;
933f461d2dcSChristoph Hellwig 
934f461d2dcSChristoph Hellwig 	if (write) {
935f461d2dcSChristoph Hellwig 		if ((param->min && *param->min > tmp) ||
936f461d2dcSChristoph Hellwig 		    (param->max && *param->max < tmp))
937f461d2dcSChristoph Hellwig 			return -EINVAL;
938f461d2dcSChristoph Hellwig 		*valp = tmp;
939f461d2dcSChristoph Hellwig 	}
940f461d2dcSChristoph Hellwig 
941f461d2dcSChristoph Hellwig 	return 0;
942f461d2dcSChristoph Hellwig }
943f461d2dcSChristoph Hellwig 
944f461d2dcSChristoph Hellwig /**
945f461d2dcSChristoph Hellwig  * proc_dointvec_minmax - read a vector of integers with min/max values
946f461d2dcSChristoph Hellwig  * @table: the sysctl table
947f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
948f461d2dcSChristoph Hellwig  * @buffer: the user buffer
949f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
950f461d2dcSChristoph Hellwig  * @ppos: file position
951f461d2dcSChristoph Hellwig  *
952f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
953f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
954f461d2dcSChristoph Hellwig  *
955f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
956f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max).
957f461d2dcSChristoph Hellwig  *
958f461d2dcSChristoph Hellwig  * Returns 0 on success or -EINVAL on write when the range check fails.
959f461d2dcSChristoph Hellwig  */
960f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write,
96132927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
962f461d2dcSChristoph Hellwig {
963f461d2dcSChristoph Hellwig 	struct do_proc_dointvec_minmax_conv_param param = {
964f461d2dcSChristoph Hellwig 		.min = (int *) table->extra1,
965f461d2dcSChristoph Hellwig 		.max = (int *) table->extra2,
966f461d2dcSChristoph Hellwig 	};
967f461d2dcSChristoph Hellwig 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
968f461d2dcSChristoph Hellwig 				do_proc_dointvec_minmax_conv, &param);
969f461d2dcSChristoph Hellwig }
970f461d2dcSChristoph Hellwig 
971f461d2dcSChristoph Hellwig /**
972f461d2dcSChristoph Hellwig  * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
973f461d2dcSChristoph Hellwig  * @min: pointer to minimum allowable value
974f461d2dcSChristoph Hellwig  * @max: pointer to maximum allowable value
975f461d2dcSChristoph Hellwig  *
976f461d2dcSChristoph Hellwig  * The do_proc_douintvec_minmax_conv_param structure provides the
977f461d2dcSChristoph Hellwig  * minimum and maximum values for doing range checking for those sysctl
978f461d2dcSChristoph Hellwig  * parameters that use the proc_douintvec_minmax() handler.
979f461d2dcSChristoph Hellwig  */
980f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param {
981f461d2dcSChristoph Hellwig 	unsigned int *min;
982f461d2dcSChristoph Hellwig 	unsigned int *max;
983f461d2dcSChristoph Hellwig };
984f461d2dcSChristoph Hellwig 
985f461d2dcSChristoph Hellwig static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
986f461d2dcSChristoph Hellwig 					 unsigned int *valp,
987f461d2dcSChristoph Hellwig 					 int write, void *data)
988f461d2dcSChristoph Hellwig {
989f461d2dcSChristoph Hellwig 	int ret;
990f461d2dcSChristoph Hellwig 	unsigned int tmp;
991f461d2dcSChristoph Hellwig 	struct do_proc_douintvec_minmax_conv_param *param = data;
992f461d2dcSChristoph Hellwig 	/* write via temporary local uint for bounds-checking */
993f461d2dcSChristoph Hellwig 	unsigned int *up = write ? &tmp : valp;
994f461d2dcSChristoph Hellwig 
995f461d2dcSChristoph Hellwig 	ret = do_proc_douintvec_conv(lvalp, up, write, data);
996f461d2dcSChristoph Hellwig 	if (ret)
997f461d2dcSChristoph Hellwig 		return ret;
998f461d2dcSChristoph Hellwig 
999f461d2dcSChristoph Hellwig 	if (write) {
1000f461d2dcSChristoph Hellwig 		if ((param->min && *param->min > tmp) ||
1001f461d2dcSChristoph Hellwig 		    (param->max && *param->max < tmp))
1002f461d2dcSChristoph Hellwig 			return -ERANGE;
1003f461d2dcSChristoph Hellwig 
1004f461d2dcSChristoph Hellwig 		*valp = tmp;
1005f461d2dcSChristoph Hellwig 	}
1006f461d2dcSChristoph Hellwig 
1007f461d2dcSChristoph Hellwig 	return 0;
1008f461d2dcSChristoph Hellwig }
1009f461d2dcSChristoph Hellwig 
1010f461d2dcSChristoph Hellwig /**
1011f461d2dcSChristoph Hellwig  * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1012f461d2dcSChristoph Hellwig  * @table: the sysctl table
1013f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1014f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1015f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1016f461d2dcSChristoph Hellwig  * @ppos: file position
1017f461d2dcSChristoph Hellwig  *
1018f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1019f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string. Negative
1020f461d2dcSChristoph Hellwig  * strings are not allowed.
1021f461d2dcSChristoph Hellwig  *
1022f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1023f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max). There is a final sanity
1024f461d2dcSChristoph Hellwig  * check for UINT_MAX to avoid having to support wrap around uses from
1025f461d2dcSChristoph Hellwig  * userspace.
1026f461d2dcSChristoph Hellwig  *
1027f461d2dcSChristoph Hellwig  * Returns 0 on success or -ERANGE on write when the range check fails.
1028f461d2dcSChristoph Hellwig  */
1029f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write,
103032927393SChristoph Hellwig 			  void *buffer, size_t *lenp, loff_t *ppos)
1031f461d2dcSChristoph Hellwig {
1032f461d2dcSChristoph Hellwig 	struct do_proc_douintvec_minmax_conv_param param = {
1033f461d2dcSChristoph Hellwig 		.min = (unsigned int *) table->extra1,
1034f461d2dcSChristoph Hellwig 		.max = (unsigned int *) table->extra2,
1035f461d2dcSChristoph Hellwig 	};
1036f461d2dcSChristoph Hellwig 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
1037f461d2dcSChristoph Hellwig 				 do_proc_douintvec_minmax_conv, &param);
1038f461d2dcSChristoph Hellwig }
1039f461d2dcSChristoph Hellwig 
1040f461d2dcSChristoph Hellwig static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1041f461d2dcSChristoph Hellwig 					unsigned int *valp,
1042f461d2dcSChristoph Hellwig 					int write, void *data)
1043f461d2dcSChristoph Hellwig {
1044f461d2dcSChristoph Hellwig 	if (write) {
1045f461d2dcSChristoph Hellwig 		unsigned int val;
1046f461d2dcSChristoph Hellwig 
1047f461d2dcSChristoph Hellwig 		val = round_pipe_size(*lvalp);
1048f461d2dcSChristoph Hellwig 		if (val == 0)
1049f461d2dcSChristoph Hellwig 			return -EINVAL;
1050f461d2dcSChristoph Hellwig 
1051f461d2dcSChristoph Hellwig 		*valp = val;
1052f461d2dcSChristoph Hellwig 	} else {
1053f461d2dcSChristoph Hellwig 		unsigned int val = *valp;
1054f461d2dcSChristoph Hellwig 		*lvalp = (unsigned long) val;
1055f461d2dcSChristoph Hellwig 	}
1056f461d2dcSChristoph Hellwig 
1057f461d2dcSChristoph Hellwig 	return 0;
1058f461d2dcSChristoph Hellwig }
1059f461d2dcSChristoph Hellwig 
1060f461d2dcSChristoph Hellwig static int proc_dopipe_max_size(struct ctl_table *table, int write,
106132927393SChristoph Hellwig 				void *buffer, size_t *lenp, loff_t *ppos)
1062f461d2dcSChristoph Hellwig {
1063f461d2dcSChristoph Hellwig 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
1064f461d2dcSChristoph Hellwig 				 do_proc_dopipe_max_size_conv, NULL);
1065f461d2dcSChristoph Hellwig }
1066f461d2dcSChristoph Hellwig 
1067f461d2dcSChristoph Hellwig static void validate_coredump_safety(void)
1068f461d2dcSChristoph Hellwig {
1069f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP
1070f461d2dcSChristoph Hellwig 	if (suid_dumpable == SUID_DUMP_ROOT &&
1071f461d2dcSChristoph Hellwig 	    core_pattern[0] != '/' && core_pattern[0] != '|') {
1072f461d2dcSChristoph Hellwig 		printk(KERN_WARNING
1073f461d2dcSChristoph Hellwig "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1074f461d2dcSChristoph Hellwig "Pipe handler or fully qualified core dump path required.\n"
1075f461d2dcSChristoph Hellwig "Set kernel.core_pattern before fs.suid_dumpable.\n"
1076f461d2dcSChristoph Hellwig 		);
1077f461d2dcSChristoph Hellwig 	}
1078f461d2dcSChristoph Hellwig #endif
1079f461d2dcSChristoph Hellwig }
1080f461d2dcSChristoph Hellwig 
1081f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
108232927393SChristoph Hellwig 		void *buffer, size_t *lenp, loff_t *ppos)
1083f461d2dcSChristoph Hellwig {
1084f461d2dcSChristoph Hellwig 	int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1085f461d2dcSChristoph Hellwig 	if (!error)
1086f461d2dcSChristoph Hellwig 		validate_coredump_safety();
1087f461d2dcSChristoph Hellwig 	return error;
1088f461d2dcSChristoph Hellwig }
1089f461d2dcSChristoph Hellwig 
1090f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP
1091f461d2dcSChristoph Hellwig static int proc_dostring_coredump(struct ctl_table *table, int write,
109232927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1093f461d2dcSChristoph Hellwig {
1094f461d2dcSChristoph Hellwig 	int error = proc_dostring(table, write, buffer, lenp, ppos);
1095f461d2dcSChristoph Hellwig 	if (!error)
1096f461d2dcSChristoph Hellwig 		validate_coredump_safety();
1097f461d2dcSChristoph Hellwig 	return error;
1098f461d2dcSChristoph Hellwig }
1099f461d2dcSChristoph Hellwig #endif
1100f461d2dcSChristoph Hellwig 
1101f461d2dcSChristoph Hellwig #ifdef CONFIG_MAGIC_SYSRQ
1102f461d2dcSChristoph Hellwig static int sysrq_sysctl_handler(struct ctl_table *table, int write,
110332927393SChristoph Hellwig 				void *buffer, size_t *lenp, loff_t *ppos)
1104f461d2dcSChristoph Hellwig {
1105f461d2dcSChristoph Hellwig 	int tmp, ret;
1106f461d2dcSChristoph Hellwig 
1107f461d2dcSChristoph Hellwig 	tmp = sysrq_mask();
1108f461d2dcSChristoph Hellwig 
1109f461d2dcSChristoph Hellwig 	ret = __do_proc_dointvec(&tmp, table, write, buffer,
1110f461d2dcSChristoph Hellwig 			       lenp, ppos, NULL, NULL);
1111f461d2dcSChristoph Hellwig 	if (ret || !write)
1112f461d2dcSChristoph Hellwig 		return ret;
1113f461d2dcSChristoph Hellwig 
1114f461d2dcSChristoph Hellwig 	if (write)
1115f461d2dcSChristoph Hellwig 		sysrq_toggle_support(tmp);
1116f461d2dcSChristoph Hellwig 
1117f461d2dcSChristoph Hellwig 	return 0;
1118f461d2dcSChristoph Hellwig }
1119f461d2dcSChristoph Hellwig #endif
1120f461d2dcSChristoph Hellwig 
112132927393SChristoph Hellwig static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
112232927393SChristoph Hellwig 		int write, void *buffer, size_t *lenp, loff_t *ppos,
112332927393SChristoph Hellwig 		unsigned long convmul, unsigned long convdiv)
1124f461d2dcSChristoph Hellwig {
1125f461d2dcSChristoph Hellwig 	unsigned long *i, *min, *max;
1126f461d2dcSChristoph Hellwig 	int vleft, first = 1, err = 0;
1127f461d2dcSChristoph Hellwig 	size_t left;
112832927393SChristoph Hellwig 	char *p;
1129f461d2dcSChristoph Hellwig 
1130f461d2dcSChristoph Hellwig 	if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1131f461d2dcSChristoph Hellwig 		*lenp = 0;
1132f461d2dcSChristoph Hellwig 		return 0;
1133f461d2dcSChristoph Hellwig 	}
1134f461d2dcSChristoph Hellwig 
1135f461d2dcSChristoph Hellwig 	i = (unsigned long *) data;
1136f461d2dcSChristoph Hellwig 	min = (unsigned long *) table->extra1;
1137f461d2dcSChristoph Hellwig 	max = (unsigned long *) table->extra2;
1138f461d2dcSChristoph Hellwig 	vleft = table->maxlen / sizeof(unsigned long);
1139f461d2dcSChristoph Hellwig 	left = *lenp;
1140f461d2dcSChristoph Hellwig 
1141f461d2dcSChristoph Hellwig 	if (write) {
1142f461d2dcSChristoph Hellwig 		if (proc_first_pos_non_zero_ignore(ppos, table))
1143f461d2dcSChristoph Hellwig 			goto out;
1144f461d2dcSChristoph Hellwig 
1145f461d2dcSChristoph Hellwig 		if (left > PAGE_SIZE - 1)
1146f461d2dcSChristoph Hellwig 			left = PAGE_SIZE - 1;
114732927393SChristoph Hellwig 		p = buffer;
1148f461d2dcSChristoph Hellwig 	}
1149f461d2dcSChristoph Hellwig 
1150f461d2dcSChristoph Hellwig 	for (; left && vleft--; i++, first = 0) {
1151f461d2dcSChristoph Hellwig 		unsigned long val;
1152f461d2dcSChristoph Hellwig 
1153f461d2dcSChristoph Hellwig 		if (write) {
1154f461d2dcSChristoph Hellwig 			bool neg;
1155f461d2dcSChristoph Hellwig 
1156f461d2dcSChristoph Hellwig 			left -= proc_skip_spaces(&p);
1157f461d2dcSChristoph Hellwig 			if (!left)
1158f461d2dcSChristoph Hellwig 				break;
1159f461d2dcSChristoph Hellwig 
1160f461d2dcSChristoph Hellwig 			err = proc_get_long(&p, &left, &val, &neg,
1161f461d2dcSChristoph Hellwig 					     proc_wspace_sep,
1162f461d2dcSChristoph Hellwig 					     sizeof(proc_wspace_sep), NULL);
1163f461d2dcSChristoph Hellwig 			if (err)
1164f461d2dcSChristoph Hellwig 				break;
1165f461d2dcSChristoph Hellwig 			if (neg)
1166f461d2dcSChristoph Hellwig 				continue;
1167f461d2dcSChristoph Hellwig 			val = convmul * val / convdiv;
1168f461d2dcSChristoph Hellwig 			if ((min && val < *min) || (max && val > *max)) {
1169f461d2dcSChristoph Hellwig 				err = -EINVAL;
1170f461d2dcSChristoph Hellwig 				break;
1171f461d2dcSChristoph Hellwig 			}
1172f461d2dcSChristoph Hellwig 			*i = val;
1173f461d2dcSChristoph Hellwig 		} else {
1174f461d2dcSChristoph Hellwig 			val = convdiv * (*i) / convmul;
117532927393SChristoph Hellwig 			if (!first)
117632927393SChristoph Hellwig 				proc_put_char(&buffer, &left, '\t');
117732927393SChristoph Hellwig 			proc_put_long(&buffer, &left, val, false);
1178f461d2dcSChristoph Hellwig 		}
1179f461d2dcSChristoph Hellwig 	}
1180f461d2dcSChristoph Hellwig 
1181f461d2dcSChristoph Hellwig 	if (!write && !first && left && !err)
118232927393SChristoph Hellwig 		proc_put_char(&buffer, &left, '\n');
1183f461d2dcSChristoph Hellwig 	if (write && !err)
1184f461d2dcSChristoph Hellwig 		left -= proc_skip_spaces(&p);
118532927393SChristoph Hellwig 	if (write && first)
1186f461d2dcSChristoph Hellwig 		return err ? : -EINVAL;
1187f461d2dcSChristoph Hellwig 	*lenp -= left;
1188f461d2dcSChristoph Hellwig out:
1189f461d2dcSChristoph Hellwig 	*ppos += *lenp;
1190f461d2dcSChristoph Hellwig 	return err;
1191f461d2dcSChristoph Hellwig }
1192f461d2dcSChristoph Hellwig 
1193f461d2dcSChristoph Hellwig static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
119432927393SChristoph Hellwig 		void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1195f461d2dcSChristoph Hellwig 		unsigned long convdiv)
1196f461d2dcSChristoph Hellwig {
1197f461d2dcSChristoph Hellwig 	return __do_proc_doulongvec_minmax(table->data, table, write,
1198f461d2dcSChristoph Hellwig 			buffer, lenp, ppos, convmul, convdiv);
1199f461d2dcSChristoph Hellwig }
1200f461d2dcSChristoph Hellwig 
1201f461d2dcSChristoph Hellwig /**
1202f461d2dcSChristoph Hellwig  * proc_doulongvec_minmax - read a vector of long integers with min/max values
1203f461d2dcSChristoph Hellwig  * @table: the sysctl table
1204f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1205f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1206f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1207f461d2dcSChristoph Hellwig  * @ppos: file position
1208f461d2dcSChristoph Hellwig  *
1209f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1210f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1211f461d2dcSChristoph Hellwig  *
1212f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1213f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max).
1214f461d2dcSChristoph Hellwig  *
1215f461d2dcSChristoph Hellwig  * Returns 0 on success.
1216f461d2dcSChristoph Hellwig  */
1217f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write,
121832927393SChristoph Hellwig 			   void *buffer, size_t *lenp, loff_t *ppos)
1219f461d2dcSChristoph Hellwig {
1220f461d2dcSChristoph Hellwig     return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1221f461d2dcSChristoph Hellwig }
1222f461d2dcSChristoph Hellwig 
1223f461d2dcSChristoph Hellwig /**
1224f461d2dcSChristoph Hellwig  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1225f461d2dcSChristoph Hellwig  * @table: the sysctl table
1226f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1227f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1228f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1229f461d2dcSChristoph Hellwig  * @ppos: file position
1230f461d2dcSChristoph Hellwig  *
1231f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1232f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string. The values
1233f461d2dcSChristoph Hellwig  * are treated as milliseconds, and converted to jiffies when they are stored.
1234f461d2dcSChristoph Hellwig  *
1235f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1236f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max).
1237f461d2dcSChristoph Hellwig  *
1238f461d2dcSChristoph Hellwig  * Returns 0 on success.
1239f461d2dcSChristoph Hellwig  */
1240f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
124132927393SChristoph Hellwig 				      void *buffer, size_t *lenp, loff_t *ppos)
1242f461d2dcSChristoph Hellwig {
1243f461d2dcSChristoph Hellwig     return do_proc_doulongvec_minmax(table, write, buffer,
1244f461d2dcSChristoph Hellwig 				     lenp, ppos, HZ, 1000l);
1245f461d2dcSChristoph Hellwig }
1246f461d2dcSChristoph Hellwig 
1247f461d2dcSChristoph Hellwig 
1248f461d2dcSChristoph Hellwig static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1249f461d2dcSChristoph Hellwig 					 int *valp,
1250f461d2dcSChristoph Hellwig 					 int write, void *data)
1251f461d2dcSChristoph Hellwig {
1252f461d2dcSChristoph Hellwig 	if (write) {
1253f461d2dcSChristoph Hellwig 		if (*lvalp > INT_MAX / HZ)
1254f461d2dcSChristoph Hellwig 			return 1;
1255f461d2dcSChristoph Hellwig 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1256f461d2dcSChristoph Hellwig 	} else {
1257f461d2dcSChristoph Hellwig 		int val = *valp;
1258f461d2dcSChristoph Hellwig 		unsigned long lval;
1259f461d2dcSChristoph Hellwig 		if (val < 0) {
1260f461d2dcSChristoph Hellwig 			*negp = true;
1261f461d2dcSChristoph Hellwig 			lval = -(unsigned long)val;
1262f461d2dcSChristoph Hellwig 		} else {
1263f461d2dcSChristoph Hellwig 			*negp = false;
1264f461d2dcSChristoph Hellwig 			lval = (unsigned long)val;
1265f461d2dcSChristoph Hellwig 		}
1266f461d2dcSChristoph Hellwig 		*lvalp = lval / HZ;
1267f461d2dcSChristoph Hellwig 	}
1268f461d2dcSChristoph Hellwig 	return 0;
1269f461d2dcSChristoph Hellwig }
1270f461d2dcSChristoph Hellwig 
1271f461d2dcSChristoph Hellwig static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1272f461d2dcSChristoph Hellwig 						int *valp,
1273f461d2dcSChristoph Hellwig 						int write, void *data)
1274f461d2dcSChristoph Hellwig {
1275f461d2dcSChristoph Hellwig 	if (write) {
1276f461d2dcSChristoph Hellwig 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1277f461d2dcSChristoph Hellwig 			return 1;
1278f461d2dcSChristoph Hellwig 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1279f461d2dcSChristoph Hellwig 	} else {
1280f461d2dcSChristoph Hellwig 		int val = *valp;
1281f461d2dcSChristoph Hellwig 		unsigned long lval;
1282f461d2dcSChristoph Hellwig 		if (val < 0) {
1283f461d2dcSChristoph Hellwig 			*negp = true;
1284f461d2dcSChristoph Hellwig 			lval = -(unsigned long)val;
1285f461d2dcSChristoph Hellwig 		} else {
1286f461d2dcSChristoph Hellwig 			*negp = false;
1287f461d2dcSChristoph Hellwig 			lval = (unsigned long)val;
1288f461d2dcSChristoph Hellwig 		}
1289f461d2dcSChristoph Hellwig 		*lvalp = jiffies_to_clock_t(lval);
1290f461d2dcSChristoph Hellwig 	}
1291f461d2dcSChristoph Hellwig 	return 0;
1292f461d2dcSChristoph Hellwig }
1293f461d2dcSChristoph Hellwig 
1294f461d2dcSChristoph Hellwig static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1295f461d2dcSChristoph Hellwig 					    int *valp,
1296f461d2dcSChristoph Hellwig 					    int write, void *data)
1297f461d2dcSChristoph Hellwig {
1298f461d2dcSChristoph Hellwig 	if (write) {
1299f461d2dcSChristoph Hellwig 		unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1300f461d2dcSChristoph Hellwig 
1301f461d2dcSChristoph Hellwig 		if (jif > INT_MAX)
1302f461d2dcSChristoph Hellwig 			return 1;
1303f461d2dcSChristoph Hellwig 		*valp = (int)jif;
1304f461d2dcSChristoph Hellwig 	} else {
1305f461d2dcSChristoph Hellwig 		int val = *valp;
1306f461d2dcSChristoph Hellwig 		unsigned long lval;
1307f461d2dcSChristoph Hellwig 		if (val < 0) {
1308f461d2dcSChristoph Hellwig 			*negp = true;
1309f461d2dcSChristoph Hellwig 			lval = -(unsigned long)val;
1310f461d2dcSChristoph Hellwig 		} else {
1311f461d2dcSChristoph Hellwig 			*negp = false;
1312f461d2dcSChristoph Hellwig 			lval = (unsigned long)val;
1313f461d2dcSChristoph Hellwig 		}
1314f461d2dcSChristoph Hellwig 		*lvalp = jiffies_to_msecs(lval);
1315f461d2dcSChristoph Hellwig 	}
1316f461d2dcSChristoph Hellwig 	return 0;
1317f461d2dcSChristoph Hellwig }
1318f461d2dcSChristoph Hellwig 
1319f461d2dcSChristoph Hellwig /**
1320f461d2dcSChristoph Hellwig  * proc_dointvec_jiffies - read a vector of integers as seconds
1321f461d2dcSChristoph Hellwig  * @table: the sysctl table
1322f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1323f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1324f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1325f461d2dcSChristoph Hellwig  * @ppos: file position
1326f461d2dcSChristoph Hellwig  *
1327f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1328f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1329f461d2dcSChristoph Hellwig  * The values read are assumed to be in seconds, and are converted into
1330f461d2dcSChristoph Hellwig  * jiffies.
1331f461d2dcSChristoph Hellwig  *
1332f461d2dcSChristoph Hellwig  * Returns 0 on success.
1333f461d2dcSChristoph Hellwig  */
1334f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write,
133532927393SChristoph Hellwig 			  void *buffer, size_t *lenp, loff_t *ppos)
1336f461d2dcSChristoph Hellwig {
1337f461d2dcSChristoph Hellwig     return do_proc_dointvec(table,write,buffer,lenp,ppos,
1338f461d2dcSChristoph Hellwig 		    	    do_proc_dointvec_jiffies_conv,NULL);
1339f461d2dcSChristoph Hellwig }
1340f461d2dcSChristoph Hellwig 
1341f461d2dcSChristoph Hellwig /**
1342f461d2dcSChristoph Hellwig  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1343f461d2dcSChristoph Hellwig  * @table: the sysctl table
1344f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1345f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1346f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1347f461d2dcSChristoph Hellwig  * @ppos: pointer to the file position
1348f461d2dcSChristoph Hellwig  *
1349f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1350f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1351f461d2dcSChristoph Hellwig  * The values read are assumed to be in 1/USER_HZ seconds, and
1352f461d2dcSChristoph Hellwig  * are converted into jiffies.
1353f461d2dcSChristoph Hellwig  *
1354f461d2dcSChristoph Hellwig  * Returns 0 on success.
1355f461d2dcSChristoph Hellwig  */
1356f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
135732927393SChristoph Hellwig 				 void *buffer, size_t *lenp, loff_t *ppos)
1358f461d2dcSChristoph Hellwig {
1359f461d2dcSChristoph Hellwig     return do_proc_dointvec(table,write,buffer,lenp,ppos,
1360f461d2dcSChristoph Hellwig 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
1361f461d2dcSChristoph Hellwig }
1362f461d2dcSChristoph Hellwig 
1363f461d2dcSChristoph Hellwig /**
1364f461d2dcSChristoph Hellwig  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1365f461d2dcSChristoph Hellwig  * @table: the sysctl table
1366f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1367f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1368f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1369f461d2dcSChristoph Hellwig  * @ppos: file position
1370f461d2dcSChristoph Hellwig  * @ppos: the current position in the file
1371f461d2dcSChristoph Hellwig  *
1372f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1373f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1374f461d2dcSChristoph Hellwig  * The values read are assumed to be in 1/1000 seconds, and
1375f461d2dcSChristoph Hellwig  * are converted into jiffies.
1376f461d2dcSChristoph Hellwig  *
1377f461d2dcSChristoph Hellwig  * Returns 0 on success.
1378f461d2dcSChristoph Hellwig  */
137932927393SChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
138032927393SChristoph Hellwig 		size_t *lenp, loff_t *ppos)
1381f461d2dcSChristoph Hellwig {
1382f461d2dcSChristoph Hellwig 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
1383f461d2dcSChristoph Hellwig 				do_proc_dointvec_ms_jiffies_conv, NULL);
1384f461d2dcSChristoph Hellwig }
1385f461d2dcSChristoph Hellwig 
138632927393SChristoph Hellwig static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
138732927393SChristoph Hellwig 		size_t *lenp, loff_t *ppos)
1388f461d2dcSChristoph Hellwig {
1389f461d2dcSChristoph Hellwig 	struct pid *new_pid;
1390f461d2dcSChristoph Hellwig 	pid_t tmp;
1391f461d2dcSChristoph Hellwig 	int r;
1392f461d2dcSChristoph Hellwig 
1393f461d2dcSChristoph Hellwig 	tmp = pid_vnr(cad_pid);
1394f461d2dcSChristoph Hellwig 
1395f461d2dcSChristoph Hellwig 	r = __do_proc_dointvec(&tmp, table, write, buffer,
1396f461d2dcSChristoph Hellwig 			       lenp, ppos, NULL, NULL);
1397f461d2dcSChristoph Hellwig 	if (r || !write)
1398f461d2dcSChristoph Hellwig 		return r;
1399f461d2dcSChristoph Hellwig 
1400f461d2dcSChristoph Hellwig 	new_pid = find_get_pid(tmp);
1401f461d2dcSChristoph Hellwig 	if (!new_pid)
1402f461d2dcSChristoph Hellwig 		return -ESRCH;
1403f461d2dcSChristoph Hellwig 
1404f461d2dcSChristoph Hellwig 	put_pid(xchg(&cad_pid, new_pid));
1405f461d2dcSChristoph Hellwig 	return 0;
1406f461d2dcSChristoph Hellwig }
1407f461d2dcSChristoph Hellwig 
1408f461d2dcSChristoph Hellwig /**
1409f461d2dcSChristoph Hellwig  * proc_do_large_bitmap - read/write from/to a large bitmap
1410f461d2dcSChristoph Hellwig  * @table: the sysctl table
1411f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1412f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1413f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1414f461d2dcSChristoph Hellwig  * @ppos: file position
1415f461d2dcSChristoph Hellwig  *
1416f461d2dcSChristoph Hellwig  * The bitmap is stored at table->data and the bitmap length (in bits)
1417f461d2dcSChristoph Hellwig  * in table->maxlen.
1418f461d2dcSChristoph Hellwig  *
1419f461d2dcSChristoph Hellwig  * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1420f461d2dcSChristoph Hellwig  * large bitmaps may be represented in a compact manner. Writing into
1421f461d2dcSChristoph Hellwig  * the file will clear the bitmap then update it with the given input.
1422f461d2dcSChristoph Hellwig  *
1423f461d2dcSChristoph Hellwig  * Returns 0 on success.
1424f461d2dcSChristoph Hellwig  */
1425f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write,
142632927393SChristoph Hellwig 			 void *buffer, size_t *lenp, loff_t *ppos)
1427f461d2dcSChristoph Hellwig {
1428f461d2dcSChristoph Hellwig 	int err = 0;
1429f461d2dcSChristoph Hellwig 	bool first = 1;
1430f461d2dcSChristoph Hellwig 	size_t left = *lenp;
1431f461d2dcSChristoph Hellwig 	unsigned long bitmap_len = table->maxlen;
1432f461d2dcSChristoph Hellwig 	unsigned long *bitmap = *(unsigned long **) table->data;
1433f461d2dcSChristoph Hellwig 	unsigned long *tmp_bitmap = NULL;
1434f461d2dcSChristoph Hellwig 	char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1435f461d2dcSChristoph Hellwig 
1436f461d2dcSChristoph Hellwig 	if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1437f461d2dcSChristoph Hellwig 		*lenp = 0;
1438f461d2dcSChristoph Hellwig 		return 0;
1439f461d2dcSChristoph Hellwig 	}
1440f461d2dcSChristoph Hellwig 
1441f461d2dcSChristoph Hellwig 	if (write) {
144232927393SChristoph Hellwig 		char *p = buffer;
1443f461d2dcSChristoph Hellwig 		size_t skipped = 0;
1444f461d2dcSChristoph Hellwig 
1445f461d2dcSChristoph Hellwig 		if (left > PAGE_SIZE - 1) {
1446f461d2dcSChristoph Hellwig 			left = PAGE_SIZE - 1;
1447f461d2dcSChristoph Hellwig 			/* How much of the buffer we'll skip this pass */
1448f461d2dcSChristoph Hellwig 			skipped = *lenp - left;
1449f461d2dcSChristoph Hellwig 		}
1450f461d2dcSChristoph Hellwig 
1451f461d2dcSChristoph Hellwig 		tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
145232927393SChristoph Hellwig 		if (!tmp_bitmap)
1453f461d2dcSChristoph Hellwig 			return -ENOMEM;
1454f461d2dcSChristoph Hellwig 		proc_skip_char(&p, &left, '\n');
1455f461d2dcSChristoph Hellwig 		while (!err && left) {
1456f461d2dcSChristoph Hellwig 			unsigned long val_a, val_b;
1457f461d2dcSChristoph Hellwig 			bool neg;
1458f461d2dcSChristoph Hellwig 			size_t saved_left;
1459f461d2dcSChristoph Hellwig 
1460f461d2dcSChristoph Hellwig 			/* In case we stop parsing mid-number, we can reset */
1461f461d2dcSChristoph Hellwig 			saved_left = left;
1462f461d2dcSChristoph Hellwig 			err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1463f461d2dcSChristoph Hellwig 					     sizeof(tr_a), &c);
1464f461d2dcSChristoph Hellwig 			/*
1465f461d2dcSChristoph Hellwig 			 * If we consumed the entirety of a truncated buffer or
1466f461d2dcSChristoph Hellwig 			 * only one char is left (may be a "-"), then stop here,
1467f461d2dcSChristoph Hellwig 			 * reset, & come back for more.
1468f461d2dcSChristoph Hellwig 			 */
1469f461d2dcSChristoph Hellwig 			if ((left <= 1) && skipped) {
1470f461d2dcSChristoph Hellwig 				left = saved_left;
1471f461d2dcSChristoph Hellwig 				break;
1472f461d2dcSChristoph Hellwig 			}
1473f461d2dcSChristoph Hellwig 
1474f461d2dcSChristoph Hellwig 			if (err)
1475f461d2dcSChristoph Hellwig 				break;
1476f461d2dcSChristoph Hellwig 			if (val_a >= bitmap_len || neg) {
1477f461d2dcSChristoph Hellwig 				err = -EINVAL;
1478f461d2dcSChristoph Hellwig 				break;
1479f461d2dcSChristoph Hellwig 			}
1480f461d2dcSChristoph Hellwig 
1481f461d2dcSChristoph Hellwig 			val_b = val_a;
1482f461d2dcSChristoph Hellwig 			if (left) {
1483f461d2dcSChristoph Hellwig 				p++;
1484f461d2dcSChristoph Hellwig 				left--;
1485f461d2dcSChristoph Hellwig 			}
1486f461d2dcSChristoph Hellwig 
1487f461d2dcSChristoph Hellwig 			if (c == '-') {
1488f461d2dcSChristoph Hellwig 				err = proc_get_long(&p, &left, &val_b,
1489f461d2dcSChristoph Hellwig 						     &neg, tr_b, sizeof(tr_b),
1490f461d2dcSChristoph Hellwig 						     &c);
1491f461d2dcSChristoph Hellwig 				/*
1492f461d2dcSChristoph Hellwig 				 * If we consumed all of a truncated buffer or
1493f461d2dcSChristoph Hellwig 				 * then stop here, reset, & come back for more.
1494f461d2dcSChristoph Hellwig 				 */
1495f461d2dcSChristoph Hellwig 				if (!left && skipped) {
1496f461d2dcSChristoph Hellwig 					left = saved_left;
1497f461d2dcSChristoph Hellwig 					break;
1498f461d2dcSChristoph Hellwig 				}
1499f461d2dcSChristoph Hellwig 
1500f461d2dcSChristoph Hellwig 				if (err)
1501f461d2dcSChristoph Hellwig 					break;
1502f461d2dcSChristoph Hellwig 				if (val_b >= bitmap_len || neg ||
1503f461d2dcSChristoph Hellwig 				    val_a > val_b) {
1504f461d2dcSChristoph Hellwig 					err = -EINVAL;
1505f461d2dcSChristoph Hellwig 					break;
1506f461d2dcSChristoph Hellwig 				}
1507f461d2dcSChristoph Hellwig 				if (left) {
1508f461d2dcSChristoph Hellwig 					p++;
1509f461d2dcSChristoph Hellwig 					left--;
1510f461d2dcSChristoph Hellwig 				}
1511f461d2dcSChristoph Hellwig 			}
1512f461d2dcSChristoph Hellwig 
1513f461d2dcSChristoph Hellwig 			bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1514f461d2dcSChristoph Hellwig 			first = 0;
1515f461d2dcSChristoph Hellwig 			proc_skip_char(&p, &left, '\n');
1516f461d2dcSChristoph Hellwig 		}
1517f461d2dcSChristoph Hellwig 		left += skipped;
1518f461d2dcSChristoph Hellwig 	} else {
1519f461d2dcSChristoph Hellwig 		unsigned long bit_a, bit_b = 0;
1520f461d2dcSChristoph Hellwig 
1521f461d2dcSChristoph Hellwig 		while (left) {
1522f461d2dcSChristoph Hellwig 			bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1523f461d2dcSChristoph Hellwig 			if (bit_a >= bitmap_len)
1524f461d2dcSChristoph Hellwig 				break;
1525f461d2dcSChristoph Hellwig 			bit_b = find_next_zero_bit(bitmap, bitmap_len,
1526f461d2dcSChristoph Hellwig 						   bit_a + 1) - 1;
1527f461d2dcSChristoph Hellwig 
152832927393SChristoph Hellwig 			if (!first)
152932927393SChristoph Hellwig 				proc_put_char(&buffer, &left, ',');
153032927393SChristoph Hellwig 			proc_put_long(&buffer, &left, bit_a, false);
1531f461d2dcSChristoph Hellwig 			if (bit_a != bit_b) {
153232927393SChristoph Hellwig 				proc_put_char(&buffer, &left, '-');
153332927393SChristoph Hellwig 				proc_put_long(&buffer, &left, bit_b, false);
1534f461d2dcSChristoph Hellwig 			}
1535f461d2dcSChristoph Hellwig 
1536f461d2dcSChristoph Hellwig 			first = 0; bit_b++;
1537f461d2dcSChristoph Hellwig 		}
153832927393SChristoph Hellwig 		proc_put_char(&buffer, &left, '\n');
1539f461d2dcSChristoph Hellwig 	}
1540f461d2dcSChristoph Hellwig 
1541f461d2dcSChristoph Hellwig 	if (!err) {
1542f461d2dcSChristoph Hellwig 		if (write) {
1543f461d2dcSChristoph Hellwig 			if (*ppos)
1544f461d2dcSChristoph Hellwig 				bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1545f461d2dcSChristoph Hellwig 			else
1546f461d2dcSChristoph Hellwig 				bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1547f461d2dcSChristoph Hellwig 		}
1548f461d2dcSChristoph Hellwig 		*lenp -= left;
1549f461d2dcSChristoph Hellwig 		*ppos += *lenp;
1550f461d2dcSChristoph Hellwig 	}
1551f461d2dcSChristoph Hellwig 
1552f461d2dcSChristoph Hellwig 	bitmap_free(tmp_bitmap);
1553f461d2dcSChristoph Hellwig 	return err;
1554f461d2dcSChristoph Hellwig }
1555f461d2dcSChristoph Hellwig 
1556f461d2dcSChristoph Hellwig #else /* CONFIG_PROC_SYSCTL */
1557f461d2dcSChristoph Hellwig 
1558f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write,
155932927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1560f461d2dcSChristoph Hellwig {
1561f461d2dcSChristoph Hellwig 	return -ENOSYS;
1562f461d2dcSChristoph Hellwig }
1563f461d2dcSChristoph Hellwig 
1564f461d2dcSChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write,
156532927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1566f461d2dcSChristoph Hellwig {
1567f461d2dcSChristoph Hellwig 	return -ENOSYS;
1568f461d2dcSChristoph Hellwig }
1569f461d2dcSChristoph Hellwig 
1570f461d2dcSChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write,
157132927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1572f461d2dcSChristoph Hellwig {
1573f461d2dcSChristoph Hellwig 	return -ENOSYS;
1574f461d2dcSChristoph Hellwig }
1575f461d2dcSChristoph Hellwig 
1576f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write,
157732927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1578f461d2dcSChristoph Hellwig {
1579f461d2dcSChristoph Hellwig 	return -ENOSYS;
1580f461d2dcSChristoph Hellwig }
1581f461d2dcSChristoph Hellwig 
1582f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write,
158332927393SChristoph Hellwig 			  void *buffer, size_t *lenp, loff_t *ppos)
1584f461d2dcSChristoph Hellwig {
1585f461d2dcSChristoph Hellwig 	return -ENOSYS;
1586f461d2dcSChristoph Hellwig }
1587f461d2dcSChristoph Hellwig 
1588f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write,
158932927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1590f461d2dcSChristoph Hellwig {
1591f461d2dcSChristoph Hellwig 	return -ENOSYS;
1592f461d2dcSChristoph Hellwig }
1593f461d2dcSChristoph Hellwig 
1594f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
159532927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1596f461d2dcSChristoph Hellwig {
1597f461d2dcSChristoph Hellwig 	return -ENOSYS;
1598f461d2dcSChristoph Hellwig }
1599f461d2dcSChristoph Hellwig 
1600f461d2dcSChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
160132927393SChristoph Hellwig 			     void *buffer, size_t *lenp, loff_t *ppos)
1602f461d2dcSChristoph Hellwig {
1603f461d2dcSChristoph Hellwig 	return -ENOSYS;
1604f461d2dcSChristoph Hellwig }
1605f461d2dcSChristoph Hellwig 
1606f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write,
160732927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1608f461d2dcSChristoph Hellwig {
1609f461d2dcSChristoph Hellwig 	return -ENOSYS;
1610f461d2dcSChristoph Hellwig }
1611f461d2dcSChristoph Hellwig 
1612f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
161332927393SChristoph Hellwig 				      void *buffer, size_t *lenp, loff_t *ppos)
1614f461d2dcSChristoph Hellwig {
1615f461d2dcSChristoph Hellwig 	return -ENOSYS;
1616f461d2dcSChristoph Hellwig }
1617f461d2dcSChristoph Hellwig 
1618f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write,
161932927393SChristoph Hellwig 			 void *buffer, size_t *lenp, loff_t *ppos)
1620f461d2dcSChristoph Hellwig {
1621f461d2dcSChristoph Hellwig 	return -ENOSYS;
1622f461d2dcSChristoph Hellwig }
1623f461d2dcSChristoph Hellwig 
1624f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */
1625f461d2dcSChristoph Hellwig 
1626f461d2dcSChristoph Hellwig #if defined(CONFIG_SYSCTL)
1627f461d2dcSChristoph Hellwig int proc_do_static_key(struct ctl_table *table, int write,
162832927393SChristoph Hellwig 		       void *buffer, size_t *lenp, loff_t *ppos)
1629f461d2dcSChristoph Hellwig {
1630f461d2dcSChristoph Hellwig 	struct static_key *key = (struct static_key *)table->data;
1631f461d2dcSChristoph Hellwig 	static DEFINE_MUTEX(static_key_mutex);
1632f461d2dcSChristoph Hellwig 	int val, ret;
1633f461d2dcSChristoph Hellwig 	struct ctl_table tmp = {
1634f461d2dcSChristoph Hellwig 		.data   = &val,
1635f461d2dcSChristoph Hellwig 		.maxlen = sizeof(val),
1636f461d2dcSChristoph Hellwig 		.mode   = table->mode,
1637f461d2dcSChristoph Hellwig 		.extra1 = SYSCTL_ZERO,
1638f461d2dcSChristoph Hellwig 		.extra2 = SYSCTL_ONE,
1639f461d2dcSChristoph Hellwig 	};
1640f461d2dcSChristoph Hellwig 
1641f461d2dcSChristoph Hellwig 	if (write && !capable(CAP_SYS_ADMIN))
1642f461d2dcSChristoph Hellwig 		return -EPERM;
1643f461d2dcSChristoph Hellwig 
1644f461d2dcSChristoph Hellwig 	mutex_lock(&static_key_mutex);
1645f461d2dcSChristoph Hellwig 	val = static_key_enabled(key);
1646f461d2dcSChristoph Hellwig 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1647f461d2dcSChristoph Hellwig 	if (write && !ret) {
1648f461d2dcSChristoph Hellwig 		if (val)
1649f461d2dcSChristoph Hellwig 			static_key_enable(key);
1650f461d2dcSChristoph Hellwig 		else
1651f461d2dcSChristoph Hellwig 			static_key_disable(key);
1652f461d2dcSChristoph Hellwig 	}
1653f461d2dcSChristoph Hellwig 	mutex_unlock(&static_key_mutex);
1654f461d2dcSChristoph Hellwig 	return ret;
1655f461d2dcSChristoph Hellwig }
1656f461d2dcSChristoph Hellwig 
1657d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
16582bba22c5SMike Galbraith 	{
16592bba22c5SMike Galbraith 		.procname	= "sched_child_runs_first",
16602bba22c5SMike Galbraith 		.data		= &sysctl_sched_child_runs_first,
16612bba22c5SMike Galbraith 		.maxlen		= sizeof(unsigned int),
16622bba22c5SMike Galbraith 		.mode		= 0644,
16636d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
16642bba22c5SMike Galbraith 	},
166577e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
166677e54a1fSIngo Molnar 	{
1667b2be5e96SPeter Zijlstra 		.procname	= "sched_min_granularity_ns",
1668b2be5e96SPeter Zijlstra 		.data		= &sysctl_sched_min_granularity,
166977e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
167077e54a1fSIngo Molnar 		.mode		= 0644,
1671702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
1672b2be5e96SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
1673b2be5e96SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
167477e54a1fSIngo Molnar 	},
167577e54a1fSIngo Molnar 	{
167621805085SPeter Zijlstra 		.procname	= "sched_latency_ns",
167721805085SPeter Zijlstra 		.data		= &sysctl_sched_latency,
167821805085SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
167921805085SPeter Zijlstra 		.mode		= 0644,
1680702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
168121805085SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
168221805085SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
168321805085SPeter Zijlstra 	},
168421805085SPeter Zijlstra 	{
168577e54a1fSIngo Molnar 		.procname	= "sched_wakeup_granularity_ns",
168677e54a1fSIngo Molnar 		.data		= &sysctl_sched_wakeup_granularity,
168777e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
168877e54a1fSIngo Molnar 		.mode		= 0644,
1689702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
169077e54a1fSIngo Molnar 		.extra1		= &min_wakeup_granularity_ns,
169177e54a1fSIngo Molnar 		.extra2		= &max_wakeup_granularity_ns,
169277e54a1fSIngo Molnar 	},
1693cbee9f88SPeter Zijlstra #ifdef CONFIG_SMP
169477e54a1fSIngo Molnar 	{
16951983a922SChristian Ehrhardt 		.procname	= "sched_tunable_scaling",
16961983a922SChristian Ehrhardt 		.data		= &sysctl_sched_tunable_scaling,
16971983a922SChristian Ehrhardt 		.maxlen		= sizeof(enum sched_tunable_scaling),
16981983a922SChristian Ehrhardt 		.mode		= 0644,
1699702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
17001983a922SChristian Ehrhardt 		.extra1		= &min_sched_tunable_scaling,
17011983a922SChristian Ehrhardt 		.extra2		= &max_sched_tunable_scaling,
17022398f2c6SPeter Zijlstra 	},
17032398f2c6SPeter Zijlstra 	{
1704d00535dbSNamhyung Kim 		.procname	= "sched_migration_cost_ns",
1705da84d961SIngo Molnar 		.data		= &sysctl_sched_migration_cost,
1706da84d961SIngo Molnar 		.maxlen		= sizeof(unsigned int),
1707da84d961SIngo Molnar 		.mode		= 0644,
17086d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1709da84d961SIngo Molnar 	},
1710b82d9fddSPeter Zijlstra 	{
1711b82d9fddSPeter Zijlstra 		.procname	= "sched_nr_migrate",
1712b82d9fddSPeter Zijlstra 		.data		= &sysctl_sched_nr_migrate,
1713b82d9fddSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
1714fa85ae24SPeter Zijlstra 		.mode		= 0644,
17156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1716fa85ae24SPeter Zijlstra 	},
1717cb251765SMel Gorman #ifdef CONFIG_SCHEDSTATS
1718cb251765SMel Gorman 	{
1719cb251765SMel Gorman 		.procname	= "sched_schedstats",
1720cb251765SMel Gorman 		.data		= NULL,
1721cb251765SMel Gorman 		.maxlen		= sizeof(unsigned int),
1722cb251765SMel Gorman 		.mode		= 0644,
1723cb251765SMel Gorman 		.proc_handler	= sysctl_schedstats,
1724eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1725eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
1726cb251765SMel Gorman 	},
1727cb251765SMel Gorman #endif /* CONFIG_SCHEDSTATS */
1728cbee9f88SPeter Zijlstra #endif /* CONFIG_SMP */
1729cbee9f88SPeter Zijlstra #ifdef CONFIG_NUMA_BALANCING
1730cbee9f88SPeter Zijlstra 	{
17314b96a29bSPeter Zijlstra 		.procname	= "numa_balancing_scan_delay_ms",
17324b96a29bSPeter Zijlstra 		.data		= &sysctl_numa_balancing_scan_delay,
17334b96a29bSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
17344b96a29bSPeter Zijlstra 		.mode		= 0644,
17354b96a29bSPeter Zijlstra 		.proc_handler	= proc_dointvec,
17364b96a29bSPeter Zijlstra 	},
17374b96a29bSPeter Zijlstra 	{
1738cbee9f88SPeter Zijlstra 		.procname	= "numa_balancing_scan_period_min_ms",
1739cbee9f88SPeter Zijlstra 		.data		= &sysctl_numa_balancing_scan_period_min,
1740cbee9f88SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
1741cbee9f88SPeter Zijlstra 		.mode		= 0644,
1742cbee9f88SPeter Zijlstra 		.proc_handler	= proc_dointvec,
1743cbee9f88SPeter Zijlstra 	},
1744cbee9f88SPeter Zijlstra 	{
1745cbee9f88SPeter Zijlstra 		.procname	= "numa_balancing_scan_period_max_ms",
1746cbee9f88SPeter Zijlstra 		.data		= &sysctl_numa_balancing_scan_period_max,
1747cbee9f88SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
1748cbee9f88SPeter Zijlstra 		.mode		= 0644,
1749cbee9f88SPeter Zijlstra 		.proc_handler	= proc_dointvec,
1750cbee9f88SPeter Zijlstra 	},
17516e5fb223SPeter Zijlstra 	{
17526e5fb223SPeter Zijlstra 		.procname	= "numa_balancing_scan_size_mb",
17536e5fb223SPeter Zijlstra 		.data		= &sysctl_numa_balancing_scan_size,
17546e5fb223SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
17556e5fb223SPeter Zijlstra 		.mode		= 0644,
175664192658SKirill Tkhai 		.proc_handler	= proc_dointvec_minmax,
1757eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
17586e5fb223SPeter Zijlstra 	},
17593a7053b3SMel Gorman 	{
176054a43d54SAndi Kleen 		.procname	= "numa_balancing",
176154a43d54SAndi Kleen 		.data		= NULL, /* filled in by handler */
176254a43d54SAndi Kleen 		.maxlen		= sizeof(unsigned int),
176354a43d54SAndi Kleen 		.mode		= 0644,
176454a43d54SAndi Kleen 		.proc_handler	= sysctl_numa_balancing,
1765eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1766eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
176754a43d54SAndi Kleen 	},
1768cbee9f88SPeter Zijlstra #endif /* CONFIG_NUMA_BALANCING */
1769cbee9f88SPeter Zijlstra #endif /* CONFIG_SCHED_DEBUG */
17701799e35dSIngo Molnar 	{
17719f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
17729f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
17739f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
17749f0c1e56SPeter Zijlstra 		.mode		= 0644,
17756d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
17769f0c1e56SPeter Zijlstra 	},
17779f0c1e56SPeter Zijlstra 	{
17789f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
17799f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
17809f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
17819f0c1e56SPeter Zijlstra 		.mode		= 0644,
17826d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
17839f0c1e56SPeter Zijlstra 	},
1784ce0dbbbbSClark Williams 	{
1785b4098bfcSPeter Zijlstra 		.procname	= "sched_deadline_period_max_us",
1786b4098bfcSPeter Zijlstra 		.data		= &sysctl_sched_dl_period_max,
1787b4098bfcSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
1788b4098bfcSPeter Zijlstra 		.mode		= 0644,
1789b4098bfcSPeter Zijlstra 		.proc_handler	= proc_dointvec,
1790b4098bfcSPeter Zijlstra 	},
1791b4098bfcSPeter Zijlstra 	{
1792b4098bfcSPeter Zijlstra 		.procname	= "sched_deadline_period_min_us",
1793b4098bfcSPeter Zijlstra 		.data		= &sysctl_sched_dl_period_min,
1794b4098bfcSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
1795b4098bfcSPeter Zijlstra 		.mode		= 0644,
1796b4098bfcSPeter Zijlstra 		.proc_handler	= proc_dointvec,
1797b4098bfcSPeter Zijlstra 	},
1798b4098bfcSPeter Zijlstra 	{
1799ce0dbbbbSClark Williams 		.procname	= "sched_rr_timeslice_ms",
1800975e155eSShile Zhang 		.data		= &sysctl_sched_rr_timeslice,
1801ce0dbbbbSClark Williams 		.maxlen		= sizeof(int),
1802ce0dbbbbSClark Williams 		.mode		= 0644,
1803ce0dbbbbSClark Williams 		.proc_handler	= sched_rr_handler,
1804ce0dbbbbSClark Williams 	},
1805e8f14172SPatrick Bellasi #ifdef CONFIG_UCLAMP_TASK
1806e8f14172SPatrick Bellasi 	{
1807e8f14172SPatrick Bellasi 		.procname	= "sched_util_clamp_min",
1808e8f14172SPatrick Bellasi 		.data		= &sysctl_sched_uclamp_util_min,
1809e8f14172SPatrick Bellasi 		.maxlen		= sizeof(unsigned int),
1810e8f14172SPatrick Bellasi 		.mode		= 0644,
1811e8f14172SPatrick Bellasi 		.proc_handler	= sysctl_sched_uclamp_handler,
1812e8f14172SPatrick Bellasi 	},
1813e8f14172SPatrick Bellasi 	{
1814e8f14172SPatrick Bellasi 		.procname	= "sched_util_clamp_max",
1815e8f14172SPatrick Bellasi 		.data		= &sysctl_sched_uclamp_util_max,
1816e8f14172SPatrick Bellasi 		.maxlen		= sizeof(unsigned int),
1817e8f14172SPatrick Bellasi 		.mode		= 0644,
1818e8f14172SPatrick Bellasi 		.proc_handler	= sysctl_sched_uclamp_handler,
1819e8f14172SPatrick Bellasi 	},
182013685c4aSQais Yousef 	{
182113685c4aSQais Yousef 		.procname	= "sched_util_clamp_min_rt_default",
182213685c4aSQais Yousef 		.data		= &sysctl_sched_uclamp_util_min_rt_default,
182313685c4aSQais Yousef 		.maxlen		= sizeof(unsigned int),
182413685c4aSQais Yousef 		.mode		= 0644,
182513685c4aSQais Yousef 		.proc_handler	= sysctl_sched_uclamp_handler,
182613685c4aSQais Yousef 	},
1827e8f14172SPatrick Bellasi #endif
18285091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP
18295091faa4SMike Galbraith 	{
18305091faa4SMike Galbraith 		.procname	= "sched_autogroup_enabled",
18315091faa4SMike Galbraith 		.data		= &sysctl_sched_autogroup_enabled,
18325091faa4SMike Galbraith 		.maxlen		= sizeof(unsigned int),
18335091faa4SMike Galbraith 		.mode		= 0644,
18341747b21fSYong Zhang 		.proc_handler	= proc_dointvec_minmax,
1835eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1836eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
18375091faa4SMike Galbraith 	},
18385091faa4SMike Galbraith #endif
1839ec12cb7fSPaul Turner #ifdef CONFIG_CFS_BANDWIDTH
1840ec12cb7fSPaul Turner 	{
1841ec12cb7fSPaul Turner 		.procname	= "sched_cfs_bandwidth_slice_us",
1842ec12cb7fSPaul Turner 		.data		= &sysctl_sched_cfs_bandwidth_slice,
1843ec12cb7fSPaul Turner 		.maxlen		= sizeof(unsigned int),
1844ec12cb7fSPaul Turner 		.mode		= 0644,
1845ec12cb7fSPaul Turner 		.proc_handler	= proc_dointvec_minmax,
1846eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
1847ec12cb7fSPaul Turner 	},
1848ec12cb7fSPaul Turner #endif
18498d5d0cfbSQuentin Perret #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
18508d5d0cfbSQuentin Perret 	{
18518d5d0cfbSQuentin Perret 		.procname	= "sched_energy_aware",
18528d5d0cfbSQuentin Perret 		.data		= &sysctl_sched_energy_aware,
18538d5d0cfbSQuentin Perret 		.maxlen		= sizeof(unsigned int),
18548d5d0cfbSQuentin Perret 		.mode		= 0644,
18558d5d0cfbSQuentin Perret 		.proc_handler	= sched_energy_aware_handler,
1856eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1857eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
18588d5d0cfbSQuentin Perret 	},
18598d5d0cfbSQuentin Perret #endif
1860f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
1861f20786ffSPeter Zijlstra 	{
1862f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
1863f20786ffSPeter Zijlstra 		.data		= &prove_locking,
1864f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
1865f20786ffSPeter Zijlstra 		.mode		= 0644,
18666d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1867f20786ffSPeter Zijlstra 	},
1868f20786ffSPeter Zijlstra #endif
1869f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
1870f20786ffSPeter Zijlstra 	{
1871f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
1872f20786ffSPeter Zijlstra 		.data		= &lock_stat,
1873f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
1874f20786ffSPeter Zijlstra 		.mode		= 0644,
18756d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1876f20786ffSPeter Zijlstra 	},
1877f20786ffSPeter Zijlstra #endif
187877e54a1fSIngo Molnar 	{
18791da177e4SLinus Torvalds 		.procname	= "panic",
18801da177e4SLinus Torvalds 		.data		= &panic_timeout,
18811da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
18821da177e4SLinus Torvalds 		.mode		= 0644,
18836d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
18841da177e4SLinus Torvalds 	},
1885046d662fSAlex Kelly #ifdef CONFIG_COREDUMP
18861da177e4SLinus Torvalds 	{
18871da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
18881da177e4SLinus Torvalds 		.data		= &core_uses_pid,
18891da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
18901da177e4SLinus Torvalds 		.mode		= 0644,
18916d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
18921da177e4SLinus Torvalds 	},
18931da177e4SLinus Torvalds 	{
18941da177e4SLinus Torvalds 		.procname	= "core_pattern",
18951da177e4SLinus Torvalds 		.data		= core_pattern,
189671ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
18971da177e4SLinus Torvalds 		.mode		= 0644,
189854b50199SKees Cook 		.proc_handler	= proc_dostring_coredump,
18991da177e4SLinus Torvalds 	},
1900a293980cSNeil Horman 	{
1901a293980cSNeil Horman 		.procname	= "core_pipe_limit",
1902a293980cSNeil Horman 		.data		= &core_pipe_limit,
1903a293980cSNeil Horman 		.maxlen		= sizeof(unsigned int),
1904a293980cSNeil Horman 		.mode		= 0644,
19056d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1906a293980cSNeil Horman 	},
1907046d662fSAlex Kelly #endif
190834f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
19091da177e4SLinus Torvalds 	{
19101da177e4SLinus Torvalds 		.procname	= "tainted",
191125ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
191234f5a398STheodore Ts'o 		.mode		= 0644,
19136d456111SEric W. Biederman 		.proc_handler	= proc_taint,
19141da177e4SLinus Torvalds 	},
1915f4aacea2SKees Cook 	{
1916f4aacea2SKees Cook 		.procname	= "sysctl_writes_strict",
1917f4aacea2SKees Cook 		.data		= &sysctl_writes_strict,
1918f4aacea2SKees Cook 		.maxlen		= sizeof(int),
1919f4aacea2SKees Cook 		.mode		= 0644,
1920f4aacea2SKees Cook 		.proc_handler	= proc_dointvec_minmax,
1921f4aacea2SKees Cook 		.extra1		= &neg_one,
1922eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
1923f4aacea2SKees Cook 	},
192434f5a398STheodore Ts'o #endif
19259745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
19269745512cSArjan van de Ven 	{
19279745512cSArjan van de Ven 		.procname	= "latencytop",
19289745512cSArjan van de Ven 		.data		= &latencytop_enabled,
19299745512cSArjan van de Ven 		.maxlen		= sizeof(int),
19309745512cSArjan van de Ven 		.mode		= 0644,
1931cb251765SMel Gorman 		.proc_handler	= sysctl_latencytop,
19329745512cSArjan van de Ven 	},
19339745512cSArjan van de Ven #endif
19341da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
19351da177e4SLinus Torvalds 	{
19361da177e4SLinus Torvalds 		.procname	= "real-root-dev",
19371da177e4SLinus Torvalds 		.data		= &real_root_dev,
19381da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
19391da177e4SLinus Torvalds 		.mode		= 0644,
19406d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19411da177e4SLinus Torvalds 	},
19421da177e4SLinus Torvalds #endif
194345807a1dSIngo Molnar 	{
194445807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
194545807a1dSIngo Molnar 		.data		= &print_fatal_signals,
194645807a1dSIngo Molnar 		.maxlen		= sizeof(int),
194745807a1dSIngo Molnar 		.mode		= 0644,
19486d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
194945807a1dSIngo Molnar 	},
195072c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
19511da177e4SLinus Torvalds 	{
19521da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
19531da177e4SLinus Torvalds 		.data		= reboot_command,
19541da177e4SLinus Torvalds 		.maxlen		= 256,
19551da177e4SLinus Torvalds 		.mode		= 0644,
19566d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
19571da177e4SLinus Torvalds 	},
19581da177e4SLinus Torvalds 	{
19591da177e4SLinus Torvalds 		.procname	= "stop-a",
19601da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
19611da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19621da177e4SLinus Torvalds 		.mode		= 0644,
19636d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19641da177e4SLinus Torvalds 	},
19651da177e4SLinus Torvalds 	{
19661da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
19671da177e4SLinus Torvalds 		.data		= &scons_pwroff,
19681da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19691da177e4SLinus Torvalds 		.mode		= 0644,
19706d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19711da177e4SLinus Torvalds 	},
19721da177e4SLinus Torvalds #endif
19730871420fSDavid S. Miller #ifdef CONFIG_SPARC64
19740871420fSDavid S. Miller 	{
19750871420fSDavid S. Miller 		.procname	= "tsb-ratio",
19760871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
19770871420fSDavid S. Miller 		.maxlen		= sizeof (int),
19780871420fSDavid S. Miller 		.mode		= 0644,
19796d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19800871420fSDavid S. Miller 	},
19810871420fSDavid S. Miller #endif
1982b67114dbSHelge Deller #ifdef CONFIG_PARISC
19831da177e4SLinus Torvalds 	{
19841da177e4SLinus Torvalds 		.procname	= "soft-power",
19851da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
19861da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19871da177e4SLinus Torvalds 		.mode		= 0644,
19886d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19891da177e4SLinus Torvalds 	},
1990bf14e3b9SVineet Gupta #endif
1991bf14e3b9SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
19921da177e4SLinus Torvalds 	{
19931da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
19941da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
19951da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19961da177e4SLinus Torvalds 		.mode		= 0644,
19976d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19981da177e4SLinus Torvalds 	},
19991da177e4SLinus Torvalds #endif
20001da177e4SLinus Torvalds 	{
20011da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
20021da177e4SLinus Torvalds 		.data		= &C_A_D,
20031da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
20041da177e4SLinus Torvalds 		.mode		= 0644,
20056d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
20061da177e4SLinus Torvalds 	},
2007606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
2008b0fc494fSSteven Rostedt 	{
2009b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
2010b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
2011b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
2012b0fc494fSSteven Rostedt 		.mode		= 0644,
20136d456111SEric W. Biederman 		.proc_handler	= ftrace_enable_sysctl,
2014b0fc494fSSteven Rostedt 	},
2015b0fc494fSSteven Rostedt #endif
2016f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
2017f38f1d2aSSteven Rostedt 	{
2018f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
2019f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
2020f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
2021f38f1d2aSSteven Rostedt 		.mode		= 0644,
20226d456111SEric W. Biederman 		.proc_handler	= stack_trace_sysctl,
2023f38f1d2aSSteven Rostedt 	},
2024f38f1d2aSSteven Rostedt #endif
2025944ac425SSteven Rostedt #ifdef CONFIG_TRACING
2026944ac425SSteven Rostedt 	{
20273299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
2028944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
2029944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
2030944ac425SSteven Rostedt 		.mode		= 0644,
20316d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2032944ac425SSteven Rostedt 	},
2033de7edd31SSteven Rostedt (Red Hat) 	{
2034de7edd31SSteven Rostedt (Red Hat) 		.procname	= "traceoff_on_warning",
2035de7edd31SSteven Rostedt (Red Hat) 		.data		= &__disable_trace_on_warning,
2036de7edd31SSteven Rostedt (Red Hat) 		.maxlen		= sizeof(__disable_trace_on_warning),
2037de7edd31SSteven Rostedt (Red Hat) 		.mode		= 0644,
2038de7edd31SSteven Rostedt (Red Hat) 		.proc_handler	= proc_dointvec,
2039de7edd31SSteven Rostedt (Red Hat) 	},
20400daa2302SSteven Rostedt (Red Hat) 	{
20410daa2302SSteven Rostedt (Red Hat) 		.procname	= "tracepoint_printk",
20420daa2302SSteven Rostedt (Red Hat) 		.data		= &tracepoint_printk,
20430daa2302SSteven Rostedt (Red Hat) 		.maxlen		= sizeof(tracepoint_printk),
20440daa2302SSteven Rostedt (Red Hat) 		.mode		= 0644,
204542391745SSteven Rostedt (Red Hat) 		.proc_handler	= tracepoint_printk_sysctl,
20460daa2302SSteven Rostedt (Red Hat) 	},
2047944ac425SSteven Rostedt #endif
20482965faa5SDave Young #ifdef CONFIG_KEXEC_CORE
20497984754bSKees Cook 	{
20507984754bSKees Cook 		.procname	= "kexec_load_disabled",
20517984754bSKees Cook 		.data		= &kexec_load_disabled,
20527984754bSKees Cook 		.maxlen		= sizeof(int),
20537984754bSKees Cook 		.mode		= 0644,
20547984754bSKees Cook 		/* only handle a transition from default "0" to "1" */
20557984754bSKees Cook 		.proc_handler	= proc_dointvec_minmax,
2056eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2057eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
20587984754bSKees Cook 	},
20597984754bSKees Cook #endif
2060a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
20611da177e4SLinus Torvalds 	{
20621da177e4SLinus Torvalds 		.procname	= "modprobe",
20631da177e4SLinus Torvalds 		.data		= &modprobe_path,
20641da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
20651da177e4SLinus Torvalds 		.mode		= 0644,
20666d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
20671da177e4SLinus Torvalds 	},
20683d43321bSKees Cook 	{
20693d43321bSKees Cook 		.procname	= "modules_disabled",
20703d43321bSKees Cook 		.data		= &modules_disabled,
20713d43321bSKees Cook 		.maxlen		= sizeof(int),
20723d43321bSKees Cook 		.mode		= 0644,
20733d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
20746d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2075eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2076eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
20773d43321bSKees Cook 	},
20781da177e4SLinus Torvalds #endif
207986d56134SMichael Marineau #ifdef CONFIG_UEVENT_HELPER
20801da177e4SLinus Torvalds 	{
20811da177e4SLinus Torvalds 		.procname	= "hotplug",
2082312c004dSKay Sievers 		.data		= &uevent_helper,
2083312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
20841da177e4SLinus Torvalds 		.mode		= 0644,
20856d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
20861da177e4SLinus Torvalds 	},
208786d56134SMichael Marineau #endif
20881da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
20891da177e4SLinus Torvalds 	{
20901da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
20911da177e4SLinus Torvalds 		.data		= &sg_big_buff,
20921da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
20931da177e4SLinus Torvalds 		.mode		= 0444,
20946d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
20951da177e4SLinus Torvalds 	},
20961da177e4SLinus Torvalds #endif
20971da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
20981da177e4SLinus Torvalds 	{
20991da177e4SLinus Torvalds 		.procname	= "acct",
21001da177e4SLinus Torvalds 		.data		= &acct_parm,
21011da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
21021da177e4SLinus Torvalds 		.mode		= 0644,
21036d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
21041da177e4SLinus Torvalds 	},
21051da177e4SLinus Torvalds #endif
21061da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
21071da177e4SLinus Torvalds 	{
21081da177e4SLinus Torvalds 		.procname	= "sysrq",
2109eaee4172SDmitry Safonov 		.data		= NULL,
21101da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
21111da177e4SLinus Torvalds 		.mode		= 0644,
211297f5f0cdSDmitry Torokhov 		.proc_handler	= sysrq_sysctl_handler,
21131da177e4SLinus Torvalds 	},
21141da177e4SLinus Torvalds #endif
2115d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
21161da177e4SLinus Torvalds 	{
21171da177e4SLinus Torvalds 		.procname	= "cad_pid",
21189ec52099SCedric Le Goater 		.data		= NULL,
21191da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
21201da177e4SLinus Torvalds 		.mode		= 0600,
21216d456111SEric W. Biederman 		.proc_handler	= proc_do_cad_pid,
21221da177e4SLinus Torvalds 	},
2123d6f8ff73SRandy Dunlap #endif
21241da177e4SLinus Torvalds 	{
21251da177e4SLinus Torvalds 		.procname	= "threads-max",
212616db3d3fSHeinrich Schuchardt 		.data		= NULL,
21271da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21281da177e4SLinus Torvalds 		.mode		= 0644,
212916db3d3fSHeinrich Schuchardt 		.proc_handler	= sysctl_max_threads,
21301da177e4SLinus Torvalds 	},
21311da177e4SLinus Torvalds 	{
21321da177e4SLinus Torvalds 		.procname	= "random",
21331da177e4SLinus Torvalds 		.mode		= 0555,
21341da177e4SLinus Torvalds 		.child		= random_table,
21351da177e4SLinus Torvalds 	},
21361da177e4SLinus Torvalds 	{
213717f60a7dSEric Paris 		.procname	= "usermodehelper",
213817f60a7dSEric Paris 		.mode		= 0555,
213917f60a7dSEric Paris 		.child		= usermodehelper_table,
214017f60a7dSEric Paris 	},
2141ceb18132SLuis R. Rodriguez #ifdef CONFIG_FW_LOADER_USER_HELPER
2142ceb18132SLuis R. Rodriguez 	{
2143ceb18132SLuis R. Rodriguez 		.procname	= "firmware_config",
2144ceb18132SLuis R. Rodriguez 		.mode		= 0555,
2145ceb18132SLuis R. Rodriguez 		.child		= firmware_config_table,
2146ceb18132SLuis R. Rodriguez 	},
2147ceb18132SLuis R. Rodriguez #endif
214817f60a7dSEric Paris 	{
21491da177e4SLinus Torvalds 		.procname	= "overflowuid",
21501da177e4SLinus Torvalds 		.data		= &overflowuid,
21511da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21521da177e4SLinus Torvalds 		.mode		= 0644,
21536d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
21541da177e4SLinus Torvalds 		.extra1		= &minolduid,
21551da177e4SLinus Torvalds 		.extra2		= &maxolduid,
21561da177e4SLinus Torvalds 	},
21571da177e4SLinus Torvalds 	{
21581da177e4SLinus Torvalds 		.procname	= "overflowgid",
21591da177e4SLinus Torvalds 		.data		= &overflowgid,
21601da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21611da177e4SLinus Torvalds 		.mode		= 0644,
21626d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
21631da177e4SLinus Torvalds 		.extra1		= &minolduid,
21641da177e4SLinus Torvalds 		.extra2		= &maxolduid,
21651da177e4SLinus Torvalds 	},
2166347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
21671da177e4SLinus Torvalds 	{
21681da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
2169ab3c68eeSHeiko Carstens 		.data		= &show_unhandled_signals,
21701da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21711da177e4SLinus Torvalds 		.mode		= 0644,
21726d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
21731da177e4SLinus Torvalds 	},
21741da177e4SLinus Torvalds #endif
217560c958d8SGuilherme G. Piccoli #ifdef CONFIG_SMP
217660c958d8SGuilherme G. Piccoli 	{
217760c958d8SGuilherme G. Piccoli 		.procname	= "oops_all_cpu_backtrace",
217860c958d8SGuilherme G. Piccoli 		.data		= &sysctl_oops_all_cpu_backtrace,
217960c958d8SGuilherme G. Piccoli 		.maxlen		= sizeof(int),
218060c958d8SGuilherme G. Piccoli 		.mode		= 0644,
218160c958d8SGuilherme G. Piccoli 		.proc_handler	= proc_dointvec_minmax,
218260c958d8SGuilherme G. Piccoli 		.extra1		= SYSCTL_ZERO,
218360c958d8SGuilherme G. Piccoli 		.extra2		= SYSCTL_ONE,
218460c958d8SGuilherme G. Piccoli 	},
218560c958d8SGuilherme G. Piccoli #endif /* CONFIG_SMP */
21861da177e4SLinus Torvalds 	{
21871da177e4SLinus Torvalds 		.procname	= "pid_max",
21881da177e4SLinus Torvalds 		.data		= &pid_max,
21891da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
21901da177e4SLinus Torvalds 		.mode		= 0644,
21916d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
21921da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
21931da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
21941da177e4SLinus Torvalds 	},
21951da177e4SLinus Torvalds 	{
21961da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
21971da177e4SLinus Torvalds 		.data		= &panic_on_oops,
21981da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21991da177e4SLinus Torvalds 		.mode		= 0644,
22006d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22011da177e4SLinus Torvalds 	},
220281c9d43fSFeng Tang 	{
220381c9d43fSFeng Tang 		.procname	= "panic_print",
220481c9d43fSFeng Tang 		.data		= &panic_print,
220581c9d43fSFeng Tang 		.maxlen		= sizeof(unsigned long),
220681c9d43fSFeng Tang 		.mode		= 0644,
220781c9d43fSFeng Tang 		.proc_handler	= proc_doulongvec_minmax,
220881c9d43fSFeng Tang 	},
22097ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
22107ef3d2fdSJoe Perches 	{
22117ef3d2fdSJoe Perches 		.procname	= "printk",
22127ef3d2fdSJoe Perches 		.data		= &console_loglevel,
22137ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
22147ef3d2fdSJoe Perches 		.mode		= 0644,
22156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22167ef3d2fdSJoe Perches 	},
22171da177e4SLinus Torvalds 	{
22181da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
2219717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
22201da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
22211da177e4SLinus Torvalds 		.mode		= 0644,
22226d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
22231da177e4SLinus Torvalds 	},
22241da177e4SLinus Torvalds 	{
22251da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
2226717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
22271da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
22281da177e4SLinus Torvalds 		.mode		= 0644,
22296d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22301da177e4SLinus Torvalds 	},
2231af91322eSDave Young 	{
2232af91322eSDave Young 		.procname	= "printk_delay",
2233af91322eSDave Young 		.data		= &printk_delay_msec,
2234af91322eSDave Young 		.maxlen		= sizeof(int),
2235af91322eSDave Young 		.mode		= 0644,
22366d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2237eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2238af91322eSDave Young 		.extra2		= &ten_thousand,
2239af91322eSDave Young 	},
22401da177e4SLinus Torvalds 	{
2241750afe7bSBorislav Petkov 		.procname	= "printk_devkmsg",
2242750afe7bSBorislav Petkov 		.data		= devkmsg_log_str,
2243750afe7bSBorislav Petkov 		.maxlen		= DEVKMSG_STR_MAX_SIZE,
2244750afe7bSBorislav Petkov 		.mode		= 0644,
2245750afe7bSBorislav Petkov 		.proc_handler	= devkmsg_sysctl_set_loglvl,
2246750afe7bSBorislav Petkov 	},
2247750afe7bSBorislav Petkov 	{
2248eaf06b24SDan Rosenberg 		.procname	= "dmesg_restrict",
2249eaf06b24SDan Rosenberg 		.data		= &dmesg_restrict,
2250eaf06b24SDan Rosenberg 		.maxlen		= sizeof(int),
2251eaf06b24SDan Rosenberg 		.mode		= 0644,
2252620f6e8eSKees Cook 		.proc_handler	= proc_dointvec_minmax_sysadmin,
2253eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2254eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2255eaf06b24SDan Rosenberg 	},
2256455cd5abSDan Rosenberg 	{
2257455cd5abSDan Rosenberg 		.procname	= "kptr_restrict",
2258455cd5abSDan Rosenberg 		.data		= &kptr_restrict,
2259455cd5abSDan Rosenberg 		.maxlen		= sizeof(int),
2260455cd5abSDan Rosenberg 		.mode		= 0644,
2261620f6e8eSKees Cook 		.proc_handler	= proc_dointvec_minmax_sysadmin,
2262eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2263455cd5abSDan Rosenberg 		.extra2		= &two,
2264455cd5abSDan Rosenberg 	},
2265df6e61d4SJoe Perches #endif
2266eaf06b24SDan Rosenberg 	{
22671da177e4SLinus Torvalds 		.procname	= "ngroups_max",
22681da177e4SLinus Torvalds 		.data		= &ngroups_max,
22691da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
22701da177e4SLinus Torvalds 		.mode		= 0444,
22716d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22721da177e4SLinus Torvalds 	},
227373efc039SDan Ballard 	{
227473efc039SDan Ballard 		.procname	= "cap_last_cap",
227573efc039SDan Ballard 		.data		= (void *)&cap_last_cap,
227673efc039SDan Ballard 		.maxlen		= sizeof(int),
227773efc039SDan Ballard 		.mode		= 0444,
227873efc039SDan Ballard 		.proc_handler	= proc_dointvec,
227973efc039SDan Ballard 	},
228058687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR)
2281504d7cf1SDon Zickus 	{
228258687acbSDon Zickus 		.procname       = "watchdog",
22833c00ea82SFrederic Weisbecker 		.data		= &watchdog_user_enabled,
2284504d7cf1SDon Zickus 		.maxlen		= sizeof(int),
2285504d7cf1SDon Zickus 		.mode		= 0644,
2286195daf66SUlrich Obergfell 		.proc_handler   = proc_watchdog,
2287eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2288eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
228958687acbSDon Zickus 	},
229058687acbSDon Zickus 	{
229158687acbSDon Zickus 		.procname	= "watchdog_thresh",
2292586692a5SMandeep Singh Baines 		.data		= &watchdog_thresh,
229358687acbSDon Zickus 		.maxlen		= sizeof(int),
229458687acbSDon Zickus 		.mode		= 0644,
2295195daf66SUlrich Obergfell 		.proc_handler	= proc_watchdog_thresh,
2296eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
229758687acbSDon Zickus 		.extra2		= &sixty,
2298504d7cf1SDon Zickus 	},
22992508ce18SDon Zickus 	{
2300195daf66SUlrich Obergfell 		.procname       = "nmi_watchdog",
23017feeb9cdSThomas Gleixner 		.data		= &nmi_watchdog_user_enabled,
2302195daf66SUlrich Obergfell 		.maxlen		= sizeof(int),
230351d4052bSThomas Gleixner 		.mode		= NMI_WATCHDOG_SYSCTL_PERM,
2304195daf66SUlrich Obergfell 		.proc_handler   = proc_nmi_watchdog,
2305eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2306eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2307195daf66SUlrich Obergfell 	},
2308195daf66SUlrich Obergfell 	{
230905a4a952SNicholas Piggin 		.procname	= "watchdog_cpumask",
231005a4a952SNicholas Piggin 		.data		= &watchdog_cpumask_bits,
231105a4a952SNicholas Piggin 		.maxlen		= NR_CPUS,
231205a4a952SNicholas Piggin 		.mode		= 0644,
231305a4a952SNicholas Piggin 		.proc_handler	= proc_watchdog_cpumask,
231405a4a952SNicholas Piggin 	},
231505a4a952SNicholas Piggin #ifdef CONFIG_SOFTLOCKUP_DETECTOR
231605a4a952SNicholas Piggin 	{
2317195daf66SUlrich Obergfell 		.procname       = "soft_watchdog",
23187feeb9cdSThomas Gleixner 		.data		= &soft_watchdog_user_enabled,
2319195daf66SUlrich Obergfell 		.maxlen		= sizeof(int),
2320195daf66SUlrich Obergfell 		.mode		= 0644,
2321195daf66SUlrich Obergfell 		.proc_handler   = proc_soft_watchdog,
2322eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2323eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2324195daf66SUlrich Obergfell 	},
2325195daf66SUlrich Obergfell 	{
23262508ce18SDon Zickus 		.procname	= "softlockup_panic",
23272508ce18SDon Zickus 		.data		= &softlockup_panic,
23282508ce18SDon Zickus 		.maxlen		= sizeof(int),
23292508ce18SDon Zickus 		.mode		= 0644,
23302508ce18SDon Zickus 		.proc_handler	= proc_dointvec_minmax,
2331eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2332eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
23332508ce18SDon Zickus 	},
2334ed235875SAaron Tomlin #ifdef CONFIG_SMP
2335ed235875SAaron Tomlin 	{
2336ed235875SAaron Tomlin 		.procname	= "softlockup_all_cpu_backtrace",
2337ed235875SAaron Tomlin 		.data		= &sysctl_softlockup_all_cpu_backtrace,
2338ed235875SAaron Tomlin 		.maxlen		= sizeof(int),
2339ed235875SAaron Tomlin 		.mode		= 0644,
2340ed235875SAaron Tomlin 		.proc_handler	= proc_dointvec_minmax,
2341eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2342eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2343ed235875SAaron Tomlin 	},
234405a4a952SNicholas Piggin #endif /* CONFIG_SMP */
234505a4a952SNicholas Piggin #endif
234605a4a952SNicholas Piggin #ifdef CONFIG_HARDLOCKUP_DETECTOR
234705a4a952SNicholas Piggin 	{
234805a4a952SNicholas Piggin 		.procname	= "hardlockup_panic",
234905a4a952SNicholas Piggin 		.data		= &hardlockup_panic,
235005a4a952SNicholas Piggin 		.maxlen		= sizeof(int),
235105a4a952SNicholas Piggin 		.mode		= 0644,
235205a4a952SNicholas Piggin 		.proc_handler	= proc_dointvec_minmax,
2353eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2354eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
235505a4a952SNicholas Piggin 	},
235605a4a952SNicholas Piggin #ifdef CONFIG_SMP
235755537871SJiri Kosina 	{
235855537871SJiri Kosina 		.procname	= "hardlockup_all_cpu_backtrace",
235955537871SJiri Kosina 		.data		= &sysctl_hardlockup_all_cpu_backtrace,
236055537871SJiri Kosina 		.maxlen		= sizeof(int),
236155537871SJiri Kosina 		.mode		= 0644,
236255537871SJiri Kosina 		.proc_handler	= proc_dointvec_minmax,
2363eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2364eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
236555537871SJiri Kosina 	},
2366ed235875SAaron Tomlin #endif /* CONFIG_SMP */
23675dc30558SDon Zickus #endif
236805a4a952SNicholas Piggin #endif
236905a4a952SNicholas Piggin 
23705dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
23715dc30558SDon Zickus 	{
23725dc30558SDon Zickus 		.procname       = "unknown_nmi_panic",
23735dc30558SDon Zickus 		.data           = &unknown_nmi_panic,
23745dc30558SDon Zickus 		.maxlen         = sizeof (int),
23755dc30558SDon Zickus 		.mode           = 0644,
23765dc30558SDon Zickus 		.proc_handler   = proc_dointvec,
23775dc30558SDon Zickus 	},
2378504d7cf1SDon Zickus #endif
2379b6522fa4SXiaoming Ni 
2380b6522fa4SXiaoming Ni #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2381b6522fa4SXiaoming Ni 	defined(CONFIG_DEBUG_STACKOVERFLOW)
2382b6522fa4SXiaoming Ni 	{
2383b6522fa4SXiaoming Ni 		.procname	= "panic_on_stackoverflow",
2384b6522fa4SXiaoming Ni 		.data		= &sysctl_panic_on_stackoverflow,
2385b6522fa4SXiaoming Ni 		.maxlen		= sizeof(int),
2386b6522fa4SXiaoming Ni 		.mode		= 0644,
2387b6522fa4SXiaoming Ni 		.proc_handler	= proc_dointvec,
2388b6522fa4SXiaoming Ni 	},
2389b6522fa4SXiaoming Ni #endif
23901da177e4SLinus Torvalds #if defined(CONFIG_X86)
23911da177e4SLinus Torvalds 	{
23928da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
23938da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
23948da5addaSDon Zickus 		.maxlen		= sizeof(int),
23958da5addaSDon Zickus 		.mode		= 0644,
23966d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
23978da5addaSDon Zickus 	},
23988da5addaSDon Zickus 	{
23995211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
24005211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
24015211a242SKurt Garloff 		.maxlen		= sizeof(int),
24025211a242SKurt Garloff 		.mode		= 0644,
24036d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24045211a242SKurt Garloff 	},
24055211a242SKurt Garloff 	{
24061da177e4SLinus Torvalds 		.procname	= "bootloader_type",
24071da177e4SLinus Torvalds 		.data		= &bootloader_type,
24081da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
24091da177e4SLinus Torvalds 		.mode		= 0444,
24106d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24111da177e4SLinus Torvalds 	},
24120741f4d2SChuck Ebbert 	{
24135031296cSH. Peter Anvin 		.procname	= "bootloader_version",
24145031296cSH. Peter Anvin 		.data		= &bootloader_version,
24155031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
24165031296cSH. Peter Anvin 		.mode		= 0444,
24176d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24185031296cSH. Peter Anvin 	},
24195031296cSH. Peter Anvin 	{
24206e7c4025SIngo Molnar 		.procname	= "io_delay_type",
24216e7c4025SIngo Molnar 		.data		= &io_delay_type,
24226e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
24236e7c4025SIngo Molnar 		.mode		= 0644,
24246d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24256e7c4025SIngo Molnar 	},
24261da177e4SLinus Torvalds #endif
24277a9166e3SLuke Yang #if defined(CONFIG_MMU)
24281da177e4SLinus Torvalds 	{
24291da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
24301da177e4SLinus Torvalds 		.data		= &randomize_va_space,
24311da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
24321da177e4SLinus Torvalds 		.mode		= 0644,
24336d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24341da177e4SLinus Torvalds 	},
24357a9166e3SLuke Yang #endif
24360152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2437951f22d5SMartin Schwidefsky 	{
2438951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
2439951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
2440951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
2441951f22d5SMartin Schwidefsky 		.mode		= 0644,
24426d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2443951f22d5SMartin Schwidefsky 	},
2444951f22d5SMartin Schwidefsky #endif
2445673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2446c255d844SPavel Machek 	{
2447c255d844SPavel Machek 		.procname	= "acpi_video_flags",
244877afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
2449c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
2450c255d844SPavel Machek 		.mode		= 0644,
24516d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
2452c255d844SPavel Machek 	},
2453c255d844SPavel Machek #endif
2454b6fca725SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2455d2b176edSJes Sorensen 	{
2456d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
2457d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
2458d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
2459d2b176edSJes Sorensen 		.mode		= 0644,
24606d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2461d2b176edSJes Sorensen 	},
2462b6fca725SVineet Gupta #endif
2463b6fca725SVineet Gupta #ifdef CONFIG_IA64
246488fc241fSDoug Chapman 	{
246588fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
246688fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
246788fc241fSDoug Chapman 		.maxlen		= sizeof (int),
246888fc241fSDoug Chapman 		.mode		= 0644,
24696d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
247088fc241fSDoug Chapman 	},
2471d2b176edSJes Sorensen #endif
2472e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
24730ec9dc9bSGuilherme G. Piccoli #ifdef CONFIG_SMP
24740ec9dc9bSGuilherme G. Piccoli 	{
24750ec9dc9bSGuilherme G. Piccoli 		.procname	= "hung_task_all_cpu_backtrace",
24760ec9dc9bSGuilherme G. Piccoli 		.data		= &sysctl_hung_task_all_cpu_backtrace,
24770ec9dc9bSGuilherme G. Piccoli 		.maxlen		= sizeof(int),
24780ec9dc9bSGuilherme G. Piccoli 		.mode		= 0644,
24790ec9dc9bSGuilherme G. Piccoli 		.proc_handler	= proc_dointvec_minmax,
24800ec9dc9bSGuilherme G. Piccoli 		.extra1		= SYSCTL_ZERO,
24810ec9dc9bSGuilherme G. Piccoli 		.extra2		= SYSCTL_ONE,
24820ec9dc9bSGuilherme G. Piccoli 	},
24830ec9dc9bSGuilherme G. Piccoli #endif /* CONFIG_SMP */
2484e162b39aSMandeep Singh Baines 	{
2485e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
2486e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
2487e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
2488e162b39aSMandeep Singh Baines 		.mode		= 0644,
24896d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2490eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2491eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2492e162b39aSMandeep Singh Baines 	},
249382a1fcb9SIngo Molnar 	{
249482a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
249582a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
2496cd64647fSLi Zefan 		.maxlen		= sizeof(int),
249782a1fcb9SIngo Molnar 		.mode		= 0644,
2498cd64647fSLi Zefan 		.proc_handler	= proc_dointvec_minmax,
2499eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
250082a1fcb9SIngo Molnar 	},
250182a1fcb9SIngo Molnar 	{
250282a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
250382a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
250490739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
250582a1fcb9SIngo Molnar 		.mode		= 0644,
25066d456111SEric W. Biederman 		.proc_handler	= proc_dohung_task_timeout_secs,
250780df2847SLiu Hua 		.extra2		= &hung_task_timeout_max,
250882a1fcb9SIngo Molnar 	},
250982a1fcb9SIngo Molnar 	{
2510a2e51445SDmitry Vyukov 		.procname	= "hung_task_check_interval_secs",
2511a2e51445SDmitry Vyukov 		.data		= &sysctl_hung_task_check_interval_secs,
2512a2e51445SDmitry Vyukov 		.maxlen		= sizeof(unsigned long),
2513a2e51445SDmitry Vyukov 		.mode		= 0644,
2514a2e51445SDmitry Vyukov 		.proc_handler	= proc_dohung_task_timeout_secs,
2515a2e51445SDmitry Vyukov 		.extra2		= &hung_task_timeout_max,
2516a2e51445SDmitry Vyukov 	},
2517a2e51445SDmitry Vyukov 	{
251882a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
251982a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
2520270750dbSAaron Tomlin 		.maxlen		= sizeof(int),
252182a1fcb9SIngo Molnar 		.mode		= 0644,
2522270750dbSAaron Tomlin 		.proc_handler	= proc_dointvec_minmax,
2523270750dbSAaron Tomlin 		.extra1		= &neg_one,
252482a1fcb9SIngo Molnar 	},
2525c4f3b63fSRavikiran G Thirumalai #endif
252623f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
252723f78d4aSIngo Molnar 	{
252823f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
252923f78d4aSIngo Molnar 		.data		= &max_lock_depth,
253023f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
253123f78d4aSIngo Molnar 		.mode		= 0644,
25326d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
253323f78d4aSIngo Molnar 	},
253423f78d4aSIngo Molnar #endif
253510a0a8d4SJeremy Fitzhardinge 	{
253610a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
253710a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
253810a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
253910a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
25406d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
254110a0a8d4SJeremy Fitzhardinge 	},
25420b77f5bfSDavid Howells #ifdef CONFIG_KEYS
25430b77f5bfSDavid Howells 	{
25440b77f5bfSDavid Howells 		.procname	= "keys",
25450b77f5bfSDavid Howells 		.mode		= 0555,
25460b77f5bfSDavid Howells 		.child		= key_sysctls,
25470b77f5bfSDavid Howells 	},
25480b77f5bfSDavid Howells #endif
2549cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS
2550aa4a2218SVince Weaver 	/*
2551aa4a2218SVince Weaver 	 * User-space scripts rely on the existence of this file
2552aa4a2218SVince Weaver 	 * as a feature check for perf_events being enabled.
2553aa4a2218SVince Weaver 	 *
2554aa4a2218SVince Weaver 	 * So it's an ABI, do not remove!
2555aa4a2218SVince Weaver 	 */
25561ccd1549SPeter Zijlstra 	{
2557cdd6c482SIngo Molnar 		.procname	= "perf_event_paranoid",
2558cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_paranoid,
2559cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_paranoid),
25601ccd1549SPeter Zijlstra 		.mode		= 0644,
25616d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
25621ccd1549SPeter Zijlstra 	},
2563c5078f78SPeter Zijlstra 	{
2564cdd6c482SIngo Molnar 		.procname	= "perf_event_mlock_kb",
2565cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_mlock,
2566cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_mlock),
2567c5078f78SPeter Zijlstra 		.mode		= 0644,
25686d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2569c5078f78SPeter Zijlstra 	},
2570a78ac325SPeter Zijlstra 	{
2571cdd6c482SIngo Molnar 		.procname	= "perf_event_max_sample_rate",
2572cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_sample_rate,
2573cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
2574a78ac325SPeter Zijlstra 		.mode		= 0644,
2575163ec435SPeter Zijlstra 		.proc_handler	= perf_proc_update_handler,
2576eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2577a78ac325SPeter Zijlstra 	},
257814c63f17SDave Hansen 	{
257914c63f17SDave Hansen 		.procname	= "perf_cpu_time_max_percent",
258014c63f17SDave Hansen 		.data		= &sysctl_perf_cpu_time_max_percent,
258114c63f17SDave Hansen 		.maxlen		= sizeof(sysctl_perf_cpu_time_max_percent),
258214c63f17SDave Hansen 		.mode		= 0644,
258314c63f17SDave Hansen 		.proc_handler	= perf_cpu_time_max_percent_handler,
2584eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
258514c63f17SDave Hansen 		.extra2		= &one_hundred,
258614c63f17SDave Hansen 	},
2587c5dfd78eSArnaldo Carvalho de Melo 	{
2588c5dfd78eSArnaldo Carvalho de Melo 		.procname	= "perf_event_max_stack",
2589a831100aSArnaldo Carvalho de Melo 		.data		= &sysctl_perf_event_max_stack,
2590c5dfd78eSArnaldo Carvalho de Melo 		.maxlen		= sizeof(sysctl_perf_event_max_stack),
2591c5dfd78eSArnaldo Carvalho de Melo 		.mode		= 0644,
2592c5dfd78eSArnaldo Carvalho de Melo 		.proc_handler	= perf_event_max_stack_handler,
2593eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2594c5dfd78eSArnaldo Carvalho de Melo 		.extra2		= &six_hundred_forty_kb,
2595c5dfd78eSArnaldo Carvalho de Melo 	},
2596c85b0334SArnaldo Carvalho de Melo 	{
2597c85b0334SArnaldo Carvalho de Melo 		.procname	= "perf_event_max_contexts_per_stack",
2598c85b0334SArnaldo Carvalho de Melo 		.data		= &sysctl_perf_event_max_contexts_per_stack,
2599c85b0334SArnaldo Carvalho de Melo 		.maxlen		= sizeof(sysctl_perf_event_max_contexts_per_stack),
2600c85b0334SArnaldo Carvalho de Melo 		.mode		= 0644,
2601c85b0334SArnaldo Carvalho de Melo 		.proc_handler	= perf_event_max_stack_handler,
2602eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2603c85b0334SArnaldo Carvalho de Melo 		.extra2		= &one_thousand,
2604c85b0334SArnaldo Carvalho de Melo 	},
26051ccd1549SPeter Zijlstra #endif
26069e3961a0SPrarit Bhargava 	{
26079e3961a0SPrarit Bhargava 		.procname	= "panic_on_warn",
26089e3961a0SPrarit Bhargava 		.data		= &panic_on_warn,
26099e3961a0SPrarit Bhargava 		.maxlen		= sizeof(int),
26109e3961a0SPrarit Bhargava 		.mode		= 0644,
26119e3961a0SPrarit Bhargava 		.proc_handler	= proc_dointvec_minmax,
2612eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2613eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
26149e3961a0SPrarit Bhargava 	},
2615bc7a34b8SThomas Gleixner #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2616bc7a34b8SThomas Gleixner 	{
2617bc7a34b8SThomas Gleixner 		.procname	= "timer_migration",
2618bc7a34b8SThomas Gleixner 		.data		= &sysctl_timer_migration,
2619bc7a34b8SThomas Gleixner 		.maxlen		= sizeof(unsigned int),
2620bc7a34b8SThomas Gleixner 		.mode		= 0644,
2621bc7a34b8SThomas Gleixner 		.proc_handler	= timer_migration_handler,
2622eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2623eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2624bc7a34b8SThomas Gleixner 	},
2625bc7a34b8SThomas Gleixner #endif
26261be7f75dSAlexei Starovoitov #ifdef CONFIG_BPF_SYSCALL
26271be7f75dSAlexei Starovoitov 	{
26281be7f75dSAlexei Starovoitov 		.procname	= "unprivileged_bpf_disabled",
26291be7f75dSAlexei Starovoitov 		.data		= &sysctl_unprivileged_bpf_disabled,
26301be7f75dSAlexei Starovoitov 		.maxlen		= sizeof(sysctl_unprivileged_bpf_disabled),
26311be7f75dSAlexei Starovoitov 		.mode		= 0644,
26321be7f75dSAlexei Starovoitov 		/* only handle a transition from default "0" to "1" */
26331be7f75dSAlexei Starovoitov 		.proc_handler	= proc_dointvec_minmax,
2634eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2635eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
26361be7f75dSAlexei Starovoitov 	},
2637492ecee8SAlexei Starovoitov 	{
2638492ecee8SAlexei Starovoitov 		.procname	= "bpf_stats_enabled",
2639a8e11e5cSEric Dumazet 		.data		= &bpf_stats_enabled_key.key,
2640a8e11e5cSEric Dumazet 		.maxlen		= sizeof(bpf_stats_enabled_key),
2641492ecee8SAlexei Starovoitov 		.mode		= 0644,
2642d46edd67SSong Liu 		.proc_handler	= bpf_stats_handler,
2643492ecee8SAlexei Starovoitov 	},
26443fcc5530SAlexei Starovoitov #endif
2645b3e627d3SLai Jiangshan #if defined(CONFIG_TREE_RCU)
2646088e9d25SDaniel Bristot de Oliveira 	{
2647088e9d25SDaniel Bristot de Oliveira 		.procname	= "panic_on_rcu_stall",
2648088e9d25SDaniel Bristot de Oliveira 		.data		= &sysctl_panic_on_rcu_stall,
2649088e9d25SDaniel Bristot de Oliveira 		.maxlen		= sizeof(sysctl_panic_on_rcu_stall),
2650088e9d25SDaniel Bristot de Oliveira 		.mode		= 0644,
2651088e9d25SDaniel Bristot de Oliveira 		.proc_handler	= proc_dointvec_minmax,
2652eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2653eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2654088e9d25SDaniel Bristot de Oliveira 	},
2655088e9d25SDaniel Bristot de Oliveira #endif
2656dfe56404Schao #if defined(CONFIG_TREE_RCU)
2657dfe56404Schao 	{
2658dfe56404Schao 		.procname	= "max_rcu_stall_to_panic",
2659dfe56404Schao 		.data		= &sysctl_max_rcu_stall_to_panic,
2660dfe56404Schao 		.maxlen		= sizeof(sysctl_max_rcu_stall_to_panic),
2661dfe56404Schao 		.mode		= 0644,
2662dfe56404Schao 		.proc_handler	= proc_dointvec_minmax,
2663dfe56404Schao 		.extra1		= SYSCTL_ONE,
2664dfe56404Schao 		.extra2		= SYSCTL_INT_MAX,
2665dfe56404Schao 	},
2666dfe56404Schao #endif
2667964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2668964c9dffSAlexander Popov 	{
2669964c9dffSAlexander Popov 		.procname	= "stack_erasing",
2670964c9dffSAlexander Popov 		.data		= NULL,
2671964c9dffSAlexander Popov 		.maxlen		= sizeof(int),
2672964c9dffSAlexander Popov 		.mode		= 0600,
2673964c9dffSAlexander Popov 		.proc_handler	= stack_erasing_sysctl,
2674eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2675eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2676964c9dffSAlexander Popov 	},
2677964c9dffSAlexander Popov #endif
26786fce56ecSEric W. Biederman 	{ }
26791da177e4SLinus Torvalds };
26801da177e4SLinus Torvalds 
2681d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
26821da177e4SLinus Torvalds 	{
26831da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
26841da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
26851da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
26861da177e4SLinus Torvalds 		.mode		= 0644,
268756f3547bSFeng Tang 		.proc_handler	= overcommit_policy_handler,
2688eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2689cb16e95fSPetr Holasek 		.extra2		= &two,
26901da177e4SLinus Torvalds 	},
26911da177e4SLinus Torvalds 	{
2692fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
2693fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
2694fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
2695fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
2696cb16e95fSPetr Holasek 		.proc_handler	= proc_dointvec_minmax,
2697eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2698cb16e95fSPetr Holasek 		.extra2		= &two,
2699fadd8fbdSKAMEZAWA Hiroyuki 	},
2700fadd8fbdSKAMEZAWA Hiroyuki 	{
2701fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
2702fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
2703fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
2704fe071d7eSDavid Rientjes 		.mode		= 0644,
27056d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2706fe071d7eSDavid Rientjes 	},
2707fe071d7eSDavid Rientjes 	{
2708fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
2709fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
2710fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
2711fef1bdd6SDavid Rientjes 		.mode		= 0644,
27126d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2713fef1bdd6SDavid Rientjes 	},
2714fef1bdd6SDavid Rientjes 	{
27151da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
27161da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
27171da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
27181da177e4SLinus Torvalds 		.mode		= 0644,
271949f0ce5fSJerome Marchand 		.proc_handler	= overcommit_ratio_handler,
272049f0ce5fSJerome Marchand 	},
272149f0ce5fSJerome Marchand 	{
272249f0ce5fSJerome Marchand 		.procname	= "overcommit_kbytes",
272349f0ce5fSJerome Marchand 		.data		= &sysctl_overcommit_kbytes,
272449f0ce5fSJerome Marchand 		.maxlen		= sizeof(sysctl_overcommit_kbytes),
272549f0ce5fSJerome Marchand 		.mode		= 0644,
272649f0ce5fSJerome Marchand 		.proc_handler	= overcommit_kbytes_handler,
27271da177e4SLinus Torvalds 	},
27281da177e4SLinus Torvalds 	{
27291da177e4SLinus Torvalds 		.procname	= "page-cluster",
27301da177e4SLinus Torvalds 		.data		= &page_cluster,
27311da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
27321da177e4SLinus Torvalds 		.mode		= 0644,
2733cb16e95fSPetr Holasek 		.proc_handler	= proc_dointvec_minmax,
2734eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27351da177e4SLinus Torvalds 	},
27361da177e4SLinus Torvalds 	{
27371da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
27381da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
27391da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
27401da177e4SLinus Torvalds 		.mode		= 0644,
27416d456111SEric W. Biederman 		.proc_handler	= dirty_background_ratio_handler,
2742eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27431da177e4SLinus Torvalds 		.extra2		= &one_hundred,
27441da177e4SLinus Torvalds 	},
27451da177e4SLinus Torvalds 	{
27462da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
27472da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
27482da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
27492da02997SDavid Rientjes 		.mode		= 0644,
27506d456111SEric W. Biederman 		.proc_handler	= dirty_background_bytes_handler,
2751fc3501d4SSven Wegener 		.extra1		= &one_ul,
27522da02997SDavid Rientjes 	},
27532da02997SDavid Rientjes 	{
27541da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
27551da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
27561da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
27571da177e4SLinus Torvalds 		.mode		= 0644,
27586d456111SEric W. Biederman 		.proc_handler	= dirty_ratio_handler,
2759eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27601da177e4SLinus Torvalds 		.extra2		= &one_hundred,
27611da177e4SLinus Torvalds 	},
27621da177e4SLinus Torvalds 	{
27632da02997SDavid Rientjes 		.procname	= "dirty_bytes",
27642da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
27652da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
27662da02997SDavid Rientjes 		.mode		= 0644,
27676d456111SEric W. Biederman 		.proc_handler	= dirty_bytes_handler,
27689e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
27692da02997SDavid Rientjes 	},
27702da02997SDavid Rientjes 	{
27711da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
2772f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
2773f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
27741da177e4SLinus Torvalds 		.mode		= 0644,
27756d456111SEric W. Biederman 		.proc_handler	= dirty_writeback_centisecs_handler,
27761da177e4SLinus Torvalds 	},
27771da177e4SLinus Torvalds 	{
27781da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
2779f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
2780f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
27811da177e4SLinus Torvalds 		.mode		= 0644,
2782cb16e95fSPetr Holasek 		.proc_handler	= proc_dointvec_minmax,
2783eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27841da177e4SLinus Torvalds 	},
27851da177e4SLinus Torvalds 	{
27861efff914STheodore Ts'o 		.procname	= "dirtytime_expire_seconds",
27871efff914STheodore Ts'o 		.data		= &dirtytime_expire_interval,
27882d87b309SRandy Dunlap 		.maxlen		= sizeof(dirtytime_expire_interval),
27891efff914STheodore Ts'o 		.mode		= 0644,
27901efff914STheodore Ts'o 		.proc_handler	= dirtytime_interval_handler,
2791eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27921efff914STheodore Ts'o 	},
27931efff914STheodore Ts'o 	{
27941da177e4SLinus Torvalds 		.procname	= "swappiness",
27951da177e4SLinus Torvalds 		.data		= &vm_swappiness,
27961da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
27971da177e4SLinus Torvalds 		.mode		= 0644,
27986d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2799eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2800c843966cSJohannes Weiner 		.extra2		= &two_hundred,
28011da177e4SLinus Torvalds 	},
28021da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
28031da177e4SLinus Torvalds 	{
28041da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
2805e5ff2159SAndi Kleen 		.data		= NULL,
28061da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
28071da177e4SLinus Torvalds 		.mode		= 0644,
28086d456111SEric W. Biederman 		.proc_handler	= hugetlb_sysctl_handler,
28091da177e4SLinus Torvalds 	},
281006808b08SLee Schermerhorn #ifdef CONFIG_NUMA
281106808b08SLee Schermerhorn 	{
281206808b08SLee Schermerhorn 		.procname       = "nr_hugepages_mempolicy",
281306808b08SLee Schermerhorn 		.data           = NULL,
281406808b08SLee Schermerhorn 		.maxlen         = sizeof(unsigned long),
281506808b08SLee Schermerhorn 		.mode           = 0644,
281606808b08SLee Schermerhorn 		.proc_handler   = &hugetlb_mempolicy_sysctl_handler,
281706808b08SLee Schermerhorn 	},
28184518085eSKemi Wang 	{
28194518085eSKemi Wang 		.procname		= "numa_stat",
28204518085eSKemi Wang 		.data			= &sysctl_vm_numa_stat,
28214518085eSKemi Wang 		.maxlen			= sizeof(int),
28224518085eSKemi Wang 		.mode			= 0644,
28234518085eSKemi Wang 		.proc_handler	= sysctl_vm_numa_stat_handler,
2824eec4844fSMatteo Croce 		.extra1			= SYSCTL_ZERO,
2825eec4844fSMatteo Croce 		.extra2			= SYSCTL_ONE,
28264518085eSKemi Wang 	},
282706808b08SLee Schermerhorn #endif
28281da177e4SLinus Torvalds 	 {
28291da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
28301da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
28311da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
28321da177e4SLinus Torvalds 		.mode		= 0644,
28336d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
28341da177e4SLinus Torvalds 	 },
2835396faf03SMel Gorman 	{
2836d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
2837e5ff2159SAndi Kleen 		.data		= NULL,
2838e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
2839d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
28406d456111SEric W. Biederman 		.proc_handler	= hugetlb_overcommit_handler,
2841d1c3fb1fSNishanth Aravamudan 	},
28421da177e4SLinus Torvalds #endif
28431da177e4SLinus Torvalds 	{
28441da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
28451da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
28461da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
28471da177e4SLinus Torvalds 		.mode		= 0644,
28486d456111SEric W. Biederman 		.proc_handler	= lowmem_reserve_ratio_sysctl_handler,
28491da177e4SLinus Torvalds 	},
28501da177e4SLinus Torvalds 	{
28519d0243bcSAndrew Morton 		.procname	= "drop_caches",
28529d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
28539d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
2854204cb79aSJohannes Weiner 		.mode		= 0200,
28559d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
2856eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
28575509a5d2SDave Hansen 		.extra2		= &four,
28589d0243bcSAndrew Morton 	},
285976ab0f53SMel Gorman #ifdef CONFIG_COMPACTION
286076ab0f53SMel Gorman 	{
286176ab0f53SMel Gorman 		.procname	= "compact_memory",
286276ab0f53SMel Gorman 		.data		= &sysctl_compact_memory,
286376ab0f53SMel Gorman 		.maxlen		= sizeof(int),
286476ab0f53SMel Gorman 		.mode		= 0200,
286576ab0f53SMel Gorman 		.proc_handler	= sysctl_compaction_handler,
286676ab0f53SMel Gorman 	},
28675e771905SMel Gorman 	{
2868facdaa91SNitin Gupta 		.procname	= "compaction_proactiveness",
2869facdaa91SNitin Gupta 		.data		= &sysctl_compaction_proactiveness,
2870d34c0a75SNitin Gupta 		.maxlen		= sizeof(sysctl_compaction_proactiveness),
2871facdaa91SNitin Gupta 		.mode		= 0644,
2872facdaa91SNitin Gupta 		.proc_handler	= proc_dointvec_minmax,
2873facdaa91SNitin Gupta 		.extra1		= SYSCTL_ZERO,
2874facdaa91SNitin Gupta 		.extra2		= &one_hundred,
2875facdaa91SNitin Gupta 	},
2876facdaa91SNitin Gupta 	{
28775e771905SMel Gorman 		.procname	= "extfrag_threshold",
28785e771905SMel Gorman 		.data		= &sysctl_extfrag_threshold,
28795e771905SMel Gorman 		.maxlen		= sizeof(int),
28805e771905SMel Gorman 		.mode		= 0644,
28816b7e5cadSMatthew Wilcox 		.proc_handler	= proc_dointvec_minmax,
28825e771905SMel Gorman 		.extra1		= &min_extfrag_threshold,
28835e771905SMel Gorman 		.extra2		= &max_extfrag_threshold,
28845e771905SMel Gorman 	},
28855bbe3547SEric B Munson 	{
28865bbe3547SEric B Munson 		.procname	= "compact_unevictable_allowed",
28875bbe3547SEric B Munson 		.data		= &sysctl_compact_unevictable_allowed,
28885bbe3547SEric B Munson 		.maxlen		= sizeof(int),
28895bbe3547SEric B Munson 		.mode		= 0644,
28906923aa0dSSebastian Andrzej Siewior 		.proc_handler	= proc_dointvec_minmax_warn_RT_change,
2891eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2892eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
28935bbe3547SEric B Munson 	},
28945e771905SMel Gorman 
289576ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */
28969d0243bcSAndrew Morton 	{
28971da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
28981da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
28991da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
29001da177e4SLinus Torvalds 		.mode		= 0644,
29016d456111SEric W. Biederman 		.proc_handler	= min_free_kbytes_sysctl_handler,
2902eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29031da177e4SLinus Torvalds 	},
29048ad4b1fbSRohit Seth 	{
29051c30844dSMel Gorman 		.procname	= "watermark_boost_factor",
29061c30844dSMel Gorman 		.data		= &watermark_boost_factor,
29071c30844dSMel Gorman 		.maxlen		= sizeof(watermark_boost_factor),
29081c30844dSMel Gorman 		.mode		= 0644,
290926363af5SChristoph Hellwig 		.proc_handler	= proc_dointvec_minmax,
2910eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29111c30844dSMel Gorman 	},
29121c30844dSMel Gorman 	{
2913795ae7a0SJohannes Weiner 		.procname	= "watermark_scale_factor",
2914795ae7a0SJohannes Weiner 		.data		= &watermark_scale_factor,
2915795ae7a0SJohannes Weiner 		.maxlen		= sizeof(watermark_scale_factor),
2916795ae7a0SJohannes Weiner 		.mode		= 0644,
2917795ae7a0SJohannes Weiner 		.proc_handler	= watermark_scale_factor_sysctl_handler,
2918eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2919795ae7a0SJohannes Weiner 		.extra2		= &one_thousand,
2920795ae7a0SJohannes Weiner 	},
2921795ae7a0SJohannes Weiner 	{
29228ad4b1fbSRohit Seth 		.procname	= "percpu_pagelist_fraction",
29238ad4b1fbSRohit Seth 		.data		= &percpu_pagelist_fraction,
29248ad4b1fbSRohit Seth 		.maxlen		= sizeof(percpu_pagelist_fraction),
29258ad4b1fbSRohit Seth 		.mode		= 0644,
29266d456111SEric W. Biederman 		.proc_handler	= percpu_pagelist_fraction_sysctl_handler,
2927eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29288ad4b1fbSRohit Seth 	},
29295ef64cc8SLinus Torvalds 	{
29305ef64cc8SLinus Torvalds 		.procname	= "page_lock_unfairness",
29315ef64cc8SLinus Torvalds 		.data		= &sysctl_page_lock_unfairness,
29325ef64cc8SLinus Torvalds 		.maxlen		= sizeof(sysctl_page_lock_unfairness),
29335ef64cc8SLinus Torvalds 		.mode		= 0644,
29345ef64cc8SLinus Torvalds 		.proc_handler	= proc_dointvec_minmax,
29355ef64cc8SLinus Torvalds 		.extra1		= SYSCTL_ZERO,
29365ef64cc8SLinus Torvalds 	},
29371da177e4SLinus Torvalds #ifdef CONFIG_MMU
29381da177e4SLinus Torvalds 	{
29391da177e4SLinus Torvalds 		.procname	= "max_map_count",
29401da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
29411da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
29421da177e4SLinus Torvalds 		.mode		= 0644,
29433e26120cSWANG Cong 		.proc_handler	= proc_dointvec_minmax,
2944eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29451da177e4SLinus Torvalds 	},
2946dd8632a1SPaul Mundt #else
2947dd8632a1SPaul Mundt 	{
2948dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
2949dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
2950dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
2951dd8632a1SPaul Mundt 		.mode		= 0644,
29526d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2953eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2954dd8632a1SPaul Mundt 	},
29551da177e4SLinus Torvalds #endif
29561da177e4SLinus Torvalds 	{
29571da177e4SLinus Torvalds 		.procname	= "laptop_mode",
29581da177e4SLinus Torvalds 		.data		= &laptop_mode,
29591da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
29601da177e4SLinus Torvalds 		.mode		= 0644,
29616d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
29621da177e4SLinus Torvalds 	},
29631da177e4SLinus Torvalds 	{
29641da177e4SLinus Torvalds 		.procname	= "block_dump",
29651da177e4SLinus Torvalds 		.data		= &block_dump,
29661da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
29671da177e4SLinus Torvalds 		.mode		= 0644,
29683b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2969eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29701da177e4SLinus Torvalds 	},
29711da177e4SLinus Torvalds 	{
29721da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
29731da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
29741da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
29751da177e4SLinus Torvalds 		.mode		= 0644,
29763b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2977eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29781da177e4SLinus Torvalds 	},
297967f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
298067f3977fSAlexandre Ghiti     defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
29811da177e4SLinus Torvalds 	{
29821da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
29831da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
29841da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
29851da177e4SLinus Torvalds 		.mode		= 0644,
29863b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2987eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29881da177e4SLinus Torvalds 	},
29891da177e4SLinus Torvalds #endif
29901743660bSChristoph Lameter #ifdef CONFIG_NUMA
29911743660bSChristoph Lameter 	{
29921743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
2993a5f5f91dSMel Gorman 		.data		= &node_reclaim_mode,
2994a5f5f91dSMel Gorman 		.maxlen		= sizeof(node_reclaim_mode),
29951743660bSChristoph Lameter 		.mode		= 0644,
29963b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2997eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29981743660bSChristoph Lameter 	},
29999614634fSChristoph Lameter 	{
30009614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
30019614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
30029614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
30039614634fSChristoph Lameter 		.mode		= 0644,
30046d456111SEric W. Biederman 		.proc_handler	= sysctl_min_unmapped_ratio_sysctl_handler,
3005eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
30069614634fSChristoph Lameter 		.extra2		= &one_hundred,
30079614634fSChristoph Lameter 	},
30080ff38490SChristoph Lameter 	{
30090ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
30100ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
30110ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
30120ff38490SChristoph Lameter 		.mode		= 0644,
30136d456111SEric W. Biederman 		.proc_handler	= sysctl_min_slab_ratio_sysctl_handler,
3014eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
30150ff38490SChristoph Lameter 		.extra2		= &one_hundred,
30160ff38490SChristoph Lameter 	},
30171743660bSChristoph Lameter #endif
301877461ab3SChristoph Lameter #ifdef CONFIG_SMP
301977461ab3SChristoph Lameter 	{
302077461ab3SChristoph Lameter 		.procname	= "stat_interval",
302177461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
302277461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
302377461ab3SChristoph Lameter 		.mode		= 0644,
30246d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
302577461ab3SChristoph Lameter 	},
302652b6f46bSHugh Dickins 	{
302752b6f46bSHugh Dickins 		.procname	= "stat_refresh",
302852b6f46bSHugh Dickins 		.data		= NULL,
302952b6f46bSHugh Dickins 		.maxlen		= 0,
303052b6f46bSHugh Dickins 		.mode		= 0600,
303152b6f46bSHugh Dickins 		.proc_handler	= vmstat_refresh,
303252b6f46bSHugh Dickins 	},
303377461ab3SChristoph Lameter #endif
30346e141546SDavid Howells #ifdef CONFIG_MMU
3035ed032189SEric Paris 	{
3036ed032189SEric Paris 		.procname	= "mmap_min_addr",
3037788084abSEric Paris 		.data		= &dac_mmap_min_addr,
3038ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
3039ed032189SEric Paris 		.mode		= 0644,
30406d456111SEric W. Biederman 		.proc_handler	= mmap_min_addr_handler,
3041ed032189SEric Paris 	},
30426e141546SDavid Howells #endif
3043f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
3044f0c0b2b8SKAMEZAWA Hiroyuki 	{
3045f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
3046f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
3047f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
3048f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
30496d456111SEric W. Biederman 		.proc_handler	= numa_zonelist_order_handler,
3050f0c0b2b8SKAMEZAWA Hiroyuki 	},
3051f0c0b2b8SKAMEZAWA Hiroyuki #endif
30522b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
30535c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3054e6e5494cSIngo Molnar 	{
3055e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
30563d7ee969SAndy Lutomirski #ifdef CONFIG_X86_32
30573d7ee969SAndy Lutomirski 		.data		= &vdso32_enabled,
30583d7ee969SAndy Lutomirski 		.maxlen		= sizeof(vdso32_enabled),
30593d7ee969SAndy Lutomirski #else
3060e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
3061e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
30623d7ee969SAndy Lutomirski #endif
3063e6e5494cSIngo Molnar 		.mode		= 0644,
30646d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3065eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3066e6e5494cSIngo Molnar 	},
3067e6e5494cSIngo Molnar #endif
3068195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
3069195cf453SBron Gondwana 	{
3070195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
3071195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
3072195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
3073195cf453SBron Gondwana 		.mode		= 0644,
30746d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3075eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3076eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3077195cf453SBron Gondwana 	},
3078195cf453SBron Gondwana #endif
30796a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE
30806a46079cSAndi Kleen 	{
30816a46079cSAndi Kleen 		.procname	= "memory_failure_early_kill",
30826a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_early_kill,
30836a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_early_kill),
30846a46079cSAndi Kleen 		.mode		= 0644,
30856d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3086eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3087eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
30886a46079cSAndi Kleen 	},
30896a46079cSAndi Kleen 	{
30906a46079cSAndi Kleen 		.procname	= "memory_failure_recovery",
30916a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_recovery,
30926a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_recovery),
30936a46079cSAndi Kleen 		.mode		= 0644,
30946d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3095eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3096eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
30976a46079cSAndi Kleen 	},
30986a46079cSAndi Kleen #endif
3099c9b1d098SAndrew Shewmaker 	{
3100c9b1d098SAndrew Shewmaker 		.procname	= "user_reserve_kbytes",
3101c9b1d098SAndrew Shewmaker 		.data		= &sysctl_user_reserve_kbytes,
3102c9b1d098SAndrew Shewmaker 		.maxlen		= sizeof(sysctl_user_reserve_kbytes),
3103c9b1d098SAndrew Shewmaker 		.mode		= 0644,
3104c9b1d098SAndrew Shewmaker 		.proc_handler	= proc_doulongvec_minmax,
3105c9b1d098SAndrew Shewmaker 	},
31064eeab4f5SAndrew Shewmaker 	{
31074eeab4f5SAndrew Shewmaker 		.procname	= "admin_reserve_kbytes",
31084eeab4f5SAndrew Shewmaker 		.data		= &sysctl_admin_reserve_kbytes,
31094eeab4f5SAndrew Shewmaker 		.maxlen		= sizeof(sysctl_admin_reserve_kbytes),
31104eeab4f5SAndrew Shewmaker 		.mode		= 0644,
31114eeab4f5SAndrew Shewmaker 		.proc_handler	= proc_doulongvec_minmax,
31124eeab4f5SAndrew Shewmaker 	},
3113d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3114d07e2259SDaniel Cashman 	{
3115d07e2259SDaniel Cashman 		.procname	= "mmap_rnd_bits",
3116d07e2259SDaniel Cashman 		.data		= &mmap_rnd_bits,
3117d07e2259SDaniel Cashman 		.maxlen		= sizeof(mmap_rnd_bits),
3118d07e2259SDaniel Cashman 		.mode		= 0600,
3119d07e2259SDaniel Cashman 		.proc_handler	= proc_dointvec_minmax,
3120d07e2259SDaniel Cashman 		.extra1		= (void *)&mmap_rnd_bits_min,
3121d07e2259SDaniel Cashman 		.extra2		= (void *)&mmap_rnd_bits_max,
3122d07e2259SDaniel Cashman 	},
3123d07e2259SDaniel Cashman #endif
3124d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3125d07e2259SDaniel Cashman 	{
3126d07e2259SDaniel Cashman 		.procname	= "mmap_rnd_compat_bits",
3127d07e2259SDaniel Cashman 		.data		= &mmap_rnd_compat_bits,
3128d07e2259SDaniel Cashman 		.maxlen		= sizeof(mmap_rnd_compat_bits),
3129d07e2259SDaniel Cashman 		.mode		= 0600,
3130d07e2259SDaniel Cashman 		.proc_handler	= proc_dointvec_minmax,
3131d07e2259SDaniel Cashman 		.extra1		= (void *)&mmap_rnd_compat_bits_min,
3132d07e2259SDaniel Cashman 		.extra2		= (void *)&mmap_rnd_compat_bits_max,
3133d07e2259SDaniel Cashman 	},
3134d07e2259SDaniel Cashman #endif
3135cefdca0aSPeter Xu #ifdef CONFIG_USERFAULTFD
3136cefdca0aSPeter Xu 	{
3137cefdca0aSPeter Xu 		.procname	= "unprivileged_userfaultfd",
3138cefdca0aSPeter Xu 		.data		= &sysctl_unprivileged_userfaultfd,
3139cefdca0aSPeter Xu 		.maxlen		= sizeof(sysctl_unprivileged_userfaultfd),
3140cefdca0aSPeter Xu 		.mode		= 0644,
3141cefdca0aSPeter Xu 		.proc_handler	= proc_dointvec_minmax,
3142eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3143eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3144cefdca0aSPeter Xu 	},
3145cefdca0aSPeter Xu #endif
31466fce56ecSEric W. Biederman 	{ }
31471da177e4SLinus Torvalds };
31481da177e4SLinus Torvalds 
3149d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
31501da177e4SLinus Torvalds 	{
31511da177e4SLinus Torvalds 		.procname	= "inode-nr",
31521da177e4SLinus Torvalds 		.data		= &inodes_stat,
31533942c07cSGlauber Costa 		.maxlen		= 2*sizeof(long),
31541da177e4SLinus Torvalds 		.mode		= 0444,
3155cffbc8aaSDave Chinner 		.proc_handler	= proc_nr_inodes,
31561da177e4SLinus Torvalds 	},
31571da177e4SLinus Torvalds 	{
31581da177e4SLinus Torvalds 		.procname	= "inode-state",
31591da177e4SLinus Torvalds 		.data		= &inodes_stat,
31603942c07cSGlauber Costa 		.maxlen		= 7*sizeof(long),
31611da177e4SLinus Torvalds 		.mode		= 0444,
3162cffbc8aaSDave Chinner 		.proc_handler	= proc_nr_inodes,
31631da177e4SLinus Torvalds 	},
31641da177e4SLinus Torvalds 	{
31651da177e4SLinus Torvalds 		.procname	= "file-nr",
31661da177e4SLinus Torvalds 		.data		= &files_stat,
3167518de9b3SEric Dumazet 		.maxlen		= sizeof(files_stat),
31681da177e4SLinus Torvalds 		.mode		= 0444,
31696d456111SEric W. Biederman 		.proc_handler	= proc_nr_files,
31701da177e4SLinus Torvalds 	},
31711da177e4SLinus Torvalds 	{
31721da177e4SLinus Torvalds 		.procname	= "file-max",
31731da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
3174518de9b3SEric Dumazet 		.maxlen		= sizeof(files_stat.max_files),
31751da177e4SLinus Torvalds 		.mode		= 0644,
3176518de9b3SEric Dumazet 		.proc_handler	= proc_doulongvec_minmax,
31779002b214SWill Deacon 		.extra1		= &zero_ul,
317832a5ad9cSChristian Brauner 		.extra2		= &long_max,
31791da177e4SLinus Torvalds 	},
31801da177e4SLinus Torvalds 	{
31819cfe015aSEric Dumazet 		.procname	= "nr_open",
31829cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
31839b80a184SAlexey Dobriyan 		.maxlen		= sizeof(unsigned int),
31849cfe015aSEric Dumazet 		.mode		= 0644,
31856d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3186eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
3187eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
31889cfe015aSEric Dumazet 	},
31899cfe015aSEric Dumazet 	{
31901da177e4SLinus Torvalds 		.procname	= "dentry-state",
31911da177e4SLinus Torvalds 		.data		= &dentry_stat,
31923942c07cSGlauber Costa 		.maxlen		= 6*sizeof(long),
31931da177e4SLinus Torvalds 		.mode		= 0444,
3194312d3ca8SChristoph Hellwig 		.proc_handler	= proc_nr_dentry,
31951da177e4SLinus Torvalds 	},
31961da177e4SLinus Torvalds 	{
31971da177e4SLinus Torvalds 		.procname	= "overflowuid",
31981da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
31991da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32001da177e4SLinus Torvalds 		.mode		= 0644,
32016d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
32021da177e4SLinus Torvalds 		.extra1		= &minolduid,
32031da177e4SLinus Torvalds 		.extra2		= &maxolduid,
32041da177e4SLinus Torvalds 	},
32051da177e4SLinus Torvalds 	{
32061da177e4SLinus Torvalds 		.procname	= "overflowgid",
32071da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
32081da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32091da177e4SLinus Torvalds 		.mode		= 0644,
32106d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
32111da177e4SLinus Torvalds 		.extra1		= &minolduid,
32121da177e4SLinus Torvalds 		.extra2		= &maxolduid,
32131da177e4SLinus Torvalds 	},
3214bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
32151da177e4SLinus Torvalds 	{
32161da177e4SLinus Torvalds 		.procname	= "leases-enable",
32171da177e4SLinus Torvalds 		.data		= &leases_enable,
32181da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32191da177e4SLinus Torvalds 		.mode		= 0644,
32206d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
32211da177e4SLinus Torvalds 	},
3222bfcd17a6SThomas Petazzoni #endif
32231da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
32241da177e4SLinus Torvalds 	{
32251da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
32261da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
32271da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32281da177e4SLinus Torvalds 		.mode		= 0644,
32296d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
32301da177e4SLinus Torvalds 	},
32311da177e4SLinus Torvalds #endif
32321da177e4SLinus Torvalds #ifdef CONFIG_MMU
3233bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
32341da177e4SLinus Torvalds 	{
32351da177e4SLinus Torvalds 		.procname	= "lease-break-time",
32361da177e4SLinus Torvalds 		.data		= &lease_break_time,
32371da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32381da177e4SLinus Torvalds 		.mode		= 0644,
32396d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
32401da177e4SLinus Torvalds 	},
3241bfcd17a6SThomas Petazzoni #endif
3242ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
32431da177e4SLinus Torvalds 	{
32441da177e4SLinus Torvalds 		.procname	= "aio-nr",
32451da177e4SLinus Torvalds 		.data		= &aio_nr,
32461da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
32471da177e4SLinus Torvalds 		.mode		= 0444,
32486d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
32491da177e4SLinus Torvalds 	},
32501da177e4SLinus Torvalds 	{
32511da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
32521da177e4SLinus Torvalds 		.data		= &aio_max_nr,
32531da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
32541da177e4SLinus Torvalds 		.mode		= 0644,
32556d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
32561da177e4SLinus Torvalds 	},
3257ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
32582d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
32590399cb08SRobert Love 	{
32600399cb08SRobert Love 		.procname	= "inotify",
32610399cb08SRobert Love 		.mode		= 0555,
32620399cb08SRobert Love 		.child		= inotify_table,
32630399cb08SRobert Love 	},
32640399cb08SRobert Love #endif
3265*5b8fea65SAmir Goldstein #ifdef CONFIG_FANOTIFY
3266*5b8fea65SAmir Goldstein 	{
3267*5b8fea65SAmir Goldstein 		.procname	= "fanotify",
3268*5b8fea65SAmir Goldstein 		.mode		= 0555,
3269*5b8fea65SAmir Goldstein 		.child		= fanotify_table,
3270*5b8fea65SAmir Goldstein 	},
3271*5b8fea65SAmir Goldstein #endif
32727ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
32737ef9964eSDavide Libenzi 	{
32747ef9964eSDavide Libenzi 		.procname	= "epoll",
32757ef9964eSDavide Libenzi 		.mode		= 0555,
32767ef9964eSDavide Libenzi 		.child		= epoll_table,
32777ef9964eSDavide Libenzi 	},
32787ef9964eSDavide Libenzi #endif
32791da177e4SLinus Torvalds #endif
3280d6e71144SAlan Cox 	{
3281800179c9SKees Cook 		.procname	= "protected_symlinks",
3282800179c9SKees Cook 		.data		= &sysctl_protected_symlinks,
3283800179c9SKees Cook 		.maxlen		= sizeof(int),
3284800179c9SKees Cook 		.mode		= 0600,
3285800179c9SKees Cook 		.proc_handler	= proc_dointvec_minmax,
3286eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3287eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3288800179c9SKees Cook 	},
3289800179c9SKees Cook 	{
3290800179c9SKees Cook 		.procname	= "protected_hardlinks",
3291800179c9SKees Cook 		.data		= &sysctl_protected_hardlinks,
3292800179c9SKees Cook 		.maxlen		= sizeof(int),
3293800179c9SKees Cook 		.mode		= 0600,
3294800179c9SKees Cook 		.proc_handler	= proc_dointvec_minmax,
3295eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3296eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3297800179c9SKees Cook 	},
3298800179c9SKees Cook 	{
329930aba665SSalvatore Mesoraca 		.procname	= "protected_fifos",
330030aba665SSalvatore Mesoraca 		.data		= &sysctl_protected_fifos,
330130aba665SSalvatore Mesoraca 		.maxlen		= sizeof(int),
330230aba665SSalvatore Mesoraca 		.mode		= 0600,
330330aba665SSalvatore Mesoraca 		.proc_handler	= proc_dointvec_minmax,
3304eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
330530aba665SSalvatore Mesoraca 		.extra2		= &two,
330630aba665SSalvatore Mesoraca 	},
330730aba665SSalvatore Mesoraca 	{
330830aba665SSalvatore Mesoraca 		.procname	= "protected_regular",
330930aba665SSalvatore Mesoraca 		.data		= &sysctl_protected_regular,
331030aba665SSalvatore Mesoraca 		.maxlen		= sizeof(int),
331130aba665SSalvatore Mesoraca 		.mode		= 0600,
331230aba665SSalvatore Mesoraca 		.proc_handler	= proc_dointvec_minmax,
3313eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
331430aba665SSalvatore Mesoraca 		.extra2		= &two,
331530aba665SSalvatore Mesoraca 	},
331630aba665SSalvatore Mesoraca 	{
3317d6e71144SAlan Cox 		.procname	= "suid_dumpable",
3318d6e71144SAlan Cox 		.data		= &suid_dumpable,
3319d6e71144SAlan Cox 		.maxlen		= sizeof(int),
3320d6e71144SAlan Cox 		.mode		= 0644,
332154b50199SKees Cook 		.proc_handler	= proc_dointvec_minmax_coredump,
3322eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
33238e654fbaSMatthew Wilcox 		.extra2		= &two,
3324d6e71144SAlan Cox 	},
33252abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
33262abc26fcSEric W. Biederman 	{
33272abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
33282abc26fcSEric W. Biederman 		.mode		= 0555,
3329f9bd6733SEric W. Biederman 		.child		= sysctl_mount_point,
33302abc26fcSEric W. Biederman 	},
33312abc26fcSEric W. Biederman #endif
3332b492e95bSJens Axboe 	{
3333ff9da691SJens Axboe 		.procname	= "pipe-max-size",
3334ff9da691SJens Axboe 		.data		= &pipe_max_size,
333598159d97SJoe Lawrence 		.maxlen		= sizeof(pipe_max_size),
3336b492e95bSJens Axboe 		.mode		= 0644,
3337319e0a21SEric Biggers 		.proc_handler	= proc_dopipe_max_size,
3338b492e95bSJens Axboe 	},
3339759c0114SWilly Tarreau 	{
3340759c0114SWilly Tarreau 		.procname	= "pipe-user-pages-hard",
3341759c0114SWilly Tarreau 		.data		= &pipe_user_pages_hard,
3342759c0114SWilly Tarreau 		.maxlen		= sizeof(pipe_user_pages_hard),
3343759c0114SWilly Tarreau 		.mode		= 0644,
3344759c0114SWilly Tarreau 		.proc_handler	= proc_doulongvec_minmax,
3345759c0114SWilly Tarreau 	},
3346759c0114SWilly Tarreau 	{
3347759c0114SWilly Tarreau 		.procname	= "pipe-user-pages-soft",
3348759c0114SWilly Tarreau 		.data		= &pipe_user_pages_soft,
3349759c0114SWilly Tarreau 		.maxlen		= sizeof(pipe_user_pages_soft),
3350759c0114SWilly Tarreau 		.mode		= 0644,
3351759c0114SWilly Tarreau 		.proc_handler	= proc_doulongvec_minmax,
3352759c0114SWilly Tarreau 	},
3353d2921684SEric W. Biederman 	{
3354d2921684SEric W. Biederman 		.procname	= "mount-max",
3355d2921684SEric W. Biederman 		.data		= &sysctl_mount_max,
3356d2921684SEric W. Biederman 		.maxlen		= sizeof(unsigned int),
3357d2921684SEric W. Biederman 		.mode		= 0644,
3358d2921684SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3359eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
3360d2921684SEric W. Biederman 	},
33616fce56ecSEric W. Biederman 	{ }
33621da177e4SLinus Torvalds };
33631da177e4SLinus Torvalds 
3364d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
33657ac57a89SCatalin Marinas #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3366abd4f750SMasoud Asgharifard Sharbiani 	{
3367abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
3368abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
3369abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
3370abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
3371abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
3372abd4f750SMasoud Asgharifard Sharbiani 	},
3373abd4f750SMasoud Asgharifard Sharbiani #endif
3374b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES)
3375b2be84dfSMasami Hiramatsu 	{
3376b2be84dfSMasami Hiramatsu 		.procname	= "kprobes-optimization",
3377b2be84dfSMasami Hiramatsu 		.data		= &sysctl_kprobes_optimization,
3378b2be84dfSMasami Hiramatsu 		.maxlen		= sizeof(int),
3379b2be84dfSMasami Hiramatsu 		.mode		= 0644,
3380b2be84dfSMasami Hiramatsu 		.proc_handler	= proc_kprobes_optimization_handler,
3381eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3382eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3383b2be84dfSMasami Hiramatsu 	},
3384b2be84dfSMasami Hiramatsu #endif
33856fce56ecSEric W. Biederman 	{ }
33861da177e4SLinus Torvalds };
33871da177e4SLinus Torvalds 
3388d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
33896fce56ecSEric W. Biederman 	{ }
33901da177e4SLinus Torvalds };
33911da177e4SLinus Torvalds 
3392f461d2dcSChristoph Hellwig static struct ctl_table sysctl_base_table[] = {
3393f461d2dcSChristoph Hellwig 	{
3394f461d2dcSChristoph Hellwig 		.procname	= "kernel",
3395f461d2dcSChristoph Hellwig 		.mode		= 0555,
3396f461d2dcSChristoph Hellwig 		.child		= kern_table,
3397f461d2dcSChristoph Hellwig 	},
3398f461d2dcSChristoph Hellwig 	{
3399f461d2dcSChristoph Hellwig 		.procname	= "vm",
3400f461d2dcSChristoph Hellwig 		.mode		= 0555,
3401f461d2dcSChristoph Hellwig 		.child		= vm_table,
3402f461d2dcSChristoph Hellwig 	},
3403f461d2dcSChristoph Hellwig 	{
3404f461d2dcSChristoph Hellwig 		.procname	= "fs",
3405f461d2dcSChristoph Hellwig 		.mode		= 0555,
3406f461d2dcSChristoph Hellwig 		.child		= fs_table,
3407f461d2dcSChristoph Hellwig 	},
3408f461d2dcSChristoph Hellwig 	{
3409f461d2dcSChristoph Hellwig 		.procname	= "debug",
3410f461d2dcSChristoph Hellwig 		.mode		= 0555,
3411f461d2dcSChristoph Hellwig 		.child		= debug_table,
3412f461d2dcSChristoph Hellwig 	},
3413f461d2dcSChristoph Hellwig 	{
3414f461d2dcSChristoph Hellwig 		.procname	= "dev",
3415f461d2dcSChristoph Hellwig 		.mode		= 0555,
3416f461d2dcSChristoph Hellwig 		.child		= dev_table,
3417f461d2dcSChristoph Hellwig 	},
3418f461d2dcSChristoph Hellwig 	{ }
3419f461d2dcSChristoph Hellwig };
3420f461d2dcSChristoph Hellwig 
3421de4e83bdSEric W. Biederman int __init sysctl_init(void)
3422330d57fbSAl Viro {
3423fd4b616bSSteven Rostedt 	struct ctl_table_header *hdr;
3424fd4b616bSSteven Rostedt 
3425fd4b616bSSteven Rostedt 	hdr = register_sysctl_table(sysctl_base_table);
3426fd4b616bSSteven Rostedt 	kmemleak_not_leak(hdr);
3427330d57fbSAl Viro 	return 0;
3428f7e6ced4SAl Viro }
3429b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
34301da177e4SLinus Torvalds /*
34311da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
34321da177e4SLinus Torvalds  * exception granted :-)
34331da177e4SLinus Torvalds  */
34341da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
3435e7d316a0SSubash Abhinov Kasiviswanathan EXPORT_SYMBOL(proc_douintvec);
34361da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
34371da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
343861d9b56aSLuis R. Rodriguez EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
34391da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
34401da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
34411da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
34421da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
34431da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
34440bc19985SStephen Suryaputra EXPORT_SYMBOL(proc_do_large_bitmap);
3445