xref: /openbmc/linux/kernel/sysctl.c (revision 0cd7c741f01de13dc1eecf22557593b3514639bb)
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>
74*0cd7c741SPeter Zijlstra #include <linux/delayacct.h>
751da177e4SLinus Torvalds 
767f2923c4SChristian Brauner #include "../lib/kstrtox.h"
777f2923c4SChristian Brauner 
787c0f6ba6SLinus Torvalds #include <linux/uaccess.h>
791da177e4SLinus Torvalds #include <asm/processor.h>
801da177e4SLinus Torvalds 
8129cbc78bSAndi Kleen #ifdef CONFIG_X86
8229cbc78bSAndi Kleen #include <asm/nmi.h>
830741f4d2SChuck Ebbert #include <asm/stacktrace.h>
846e7c4025SIngo Molnar #include <asm/io.h>
8529cbc78bSAndi Kleen #endif
86d550bbd4SDavid Howells #ifdef CONFIG_SPARC
87d550bbd4SDavid Howells #include <asm/setup.h>
88d550bbd4SDavid Howells #endif
89c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT
90c55b7c3eSDave Young #include <linux/acct.h>
91c55b7c3eSDave Young #endif
924f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES
934f0e056fSDave Young #include <linux/rtmutex.h>
944f0e056fSDave Young #endif
952edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
962edf5e49SDave Young #include <linux/lockdep.h>
972edf5e49SDave Young #endif
9815485a46SDave Young #ifdef CONFIG_CHR_DEV_SG
9915485a46SDave Young #include <scsi/sg.h>
10015485a46SDave Young #endif
101964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
102964c9dffSAlexander Popov #include <linux/stackleak.h>
103964c9dffSAlexander Popov #endif
10458687acbSDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR
105504d7cf1SDon Zickus #include <linux/nmi.h>
106504d7cf1SDon Zickus #endif
107504d7cf1SDon Zickus 
1081da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL)
1091da177e4SLinus Torvalds 
110c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and  maximum */
1112508ce18SDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR
112c4f3b63fSRavikiran G Thirumalai static int sixty = 60;
113c4f3b63fSRavikiran G Thirumalai #endif
114c4f3b63fSRavikiran G Thirumalai 
115270750dbSAaron Tomlin static int __maybe_unused neg_one = -1;
116cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2;
1175509a5d2SDave Hansen static int __maybe_unused four = 4;
1189002b214SWill Deacon static unsigned long zero_ul;
119fc3501d4SSven Wegener static unsigned long one_ul = 1;
12032a5ad9cSChristian Brauner static unsigned long long_max = LONG_MAX;
121c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100;
122c843966cSJohannes Weiner static int two_hundred = 200;
123795ae7a0SJohannes Weiner static int one_thousand = 1000;
124af91322eSDave Young #ifdef CONFIG_PRINTK
125af91322eSDave Young static int ten_thousand = 10000;
126af91322eSDave Young #endif
127c5dfd78eSArnaldo Carvalho de Melo #ifdef CONFIG_PERF_EVENTS
128c5dfd78eSArnaldo Carvalho de Melo static int six_hundred_forty_kb = 640 * 1024;
129c5dfd78eSArnaldo Carvalho de Melo #endif
130c4f3b63fSRavikiran G Thirumalai 
1319e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
1329e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1339e4a5bdaSAndrea Righi 
1341da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1351da177e4SLinus Torvalds static int maxolduid = 65535;
1361da177e4SLinus Torvalds static int minolduid;
1371da177e4SLinus Torvalds 
1381da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
13973efc039SDan Ballard static const int cap_last_cap = CAP_LAST_CAP;
1401da177e4SLinus Torvalds 
141a2e51445SDmitry Vyukov /*
142a2e51445SDmitry Vyukov  * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
143a2e51445SDmitry Vyukov  * and hung_task_check_interval_secs
144a2e51445SDmitry Vyukov  */
14580df2847SLiu Hua #ifdef CONFIG_DETECT_HUNG_TASK
14680df2847SLiu Hua static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
14780df2847SLiu Hua #endif
14880df2847SLiu Hua 
149d14f1729SDave Young #ifdef CONFIG_INOTIFY_USER
150d14f1729SDave Young #include <linux/inotify.h>
151d14f1729SDave Young #endif
1525b8fea65SAmir Goldstein #ifdef CONFIG_FANOTIFY
1535b8fea65SAmir Goldstein #include <linux/fanotify.h>
1545b8fea65SAmir Goldstein #endif
155b6fca725SVineet Gupta 
156d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
157f4aacea2SKees Cook 
158a19ac337SLuis R. Rodriguez /**
159a19ac337SLuis R. Rodriguez  * enum sysctl_writes_mode - supported sysctl write modes
160a19ac337SLuis R. Rodriguez  *
161a19ac337SLuis R. Rodriguez  * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
162a19ac337SLuis R. Rodriguez  *	to be written, and multiple writes on the same sysctl file descriptor
163a19ac337SLuis R. Rodriguez  *	will rewrite the sysctl value, regardless of file position. No warning
164a19ac337SLuis R. Rodriguez  *	is issued when the initial position is not 0.
165a19ac337SLuis R. Rodriguez  * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
166a19ac337SLuis R. Rodriguez  *	not 0.
167a19ac337SLuis R. Rodriguez  * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
168a19ac337SLuis R. Rodriguez  *	file position 0 and the value must be fully contained in the buffer
169a19ac337SLuis R. Rodriguez  *	sent to the write syscall. If dealing with strings respect the file
170a19ac337SLuis R. Rodriguez  *	position, but restrict this to the max length of the buffer, anything
17165f50f25SWeitao Hou  *	passed the max length will be ignored. Multiple writes will append
172a19ac337SLuis R. Rodriguez  *	to the buffer.
173a19ac337SLuis R. Rodriguez  *
174a19ac337SLuis R. Rodriguez  * These write modes control how current file position affects the behavior of
175a19ac337SLuis R. Rodriguez  * updating sysctl values through the proc interface on each write.
176a19ac337SLuis R. Rodriguez  */
177a19ac337SLuis R. Rodriguez enum sysctl_writes_mode {
178a19ac337SLuis R. Rodriguez 	SYSCTL_WRITES_LEGACY		= -1,
179a19ac337SLuis R. Rodriguez 	SYSCTL_WRITES_WARN		= 0,
180a19ac337SLuis R. Rodriguez 	SYSCTL_WRITES_STRICT		= 1,
181a19ac337SLuis R. Rodriguez };
182f4aacea2SKees Cook 
183a19ac337SLuis R. Rodriguez static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
184f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */
185ceb18132SLuis R. Rodriguez 
18667f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
18767f3977fSAlexandre Ghiti     defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
1881da177e4SLinus Torvalds int sysctl_legacy_va_layout;
1891da177e4SLinus Torvalds #endif
1901da177e4SLinus Torvalds 
1915e771905SMel Gorman #ifdef CONFIG_COMPACTION
1925e771905SMel Gorman static int min_extfrag_threshold;
1935e771905SMel Gorman static int max_extfrag_threshold = 1000;
1945e771905SMel Gorman #endif
1955e771905SMel Gorman 
196f461d2dcSChristoph Hellwig #endif /* CONFIG_SYSCTL */
197f461d2dcSChristoph Hellwig 
1985447e8e0SArnd Bergmann #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
199d46edd67SSong Liu static int bpf_stats_handler(struct ctl_table *table, int write,
2007787b6fcSTobias Klauser 			     void *buffer, size_t *lenp, loff_t *ppos)
201d46edd67SSong Liu {
202d46edd67SSong Liu 	struct static_key *key = (struct static_key *)table->data;
203d46edd67SSong Liu 	static int saved_val;
204d46edd67SSong Liu 	int val, ret;
205d46edd67SSong Liu 	struct ctl_table tmp = {
206d46edd67SSong Liu 		.data   = &val,
207d46edd67SSong Liu 		.maxlen = sizeof(val),
208d46edd67SSong Liu 		.mode   = table->mode,
209d46edd67SSong Liu 		.extra1 = SYSCTL_ZERO,
210d46edd67SSong Liu 		.extra2 = SYSCTL_ONE,
211d46edd67SSong Liu 	};
212d46edd67SSong Liu 
213d46edd67SSong Liu 	if (write && !capable(CAP_SYS_ADMIN))
214d46edd67SSong Liu 		return -EPERM;
215d46edd67SSong Liu 
216d46edd67SSong Liu 	mutex_lock(&bpf_stats_enabled_mutex);
217d46edd67SSong Liu 	val = saved_val;
218d46edd67SSong Liu 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
219d46edd67SSong Liu 	if (write && !ret && val != saved_val) {
220d46edd67SSong Liu 		if (val)
221d46edd67SSong Liu 			static_key_slow_inc(key);
222d46edd67SSong Liu 		else
223d46edd67SSong Liu 			static_key_slow_dec(key);
224d46edd67SSong Liu 		saved_val = val;
225d46edd67SSong Liu 	}
226d46edd67SSong Liu 	mutex_unlock(&bpf_stats_enabled_mutex);
227d46edd67SSong Liu 	return ret;
228d46edd67SSong Liu }
229d46edd67SSong Liu #endif
230d46edd67SSong Liu 
231f461d2dcSChristoph Hellwig /*
232f461d2dcSChristoph Hellwig  * /proc/sys support
233f461d2dcSChristoph Hellwig  */
234f461d2dcSChristoph Hellwig 
235f461d2dcSChristoph Hellwig #ifdef CONFIG_PROC_SYSCTL
236f461d2dcSChristoph Hellwig 
237f461d2dcSChristoph Hellwig static int _proc_do_string(char *data, int maxlen, int write,
23832927393SChristoph Hellwig 		char *buffer, size_t *lenp, loff_t *ppos)
239f461d2dcSChristoph Hellwig {
240f461d2dcSChristoph Hellwig 	size_t len;
24132927393SChristoph Hellwig 	char c, *p;
242f461d2dcSChristoph Hellwig 
243f461d2dcSChristoph Hellwig 	if (!data || !maxlen || !*lenp) {
244f461d2dcSChristoph Hellwig 		*lenp = 0;
245f461d2dcSChristoph Hellwig 		return 0;
246f461d2dcSChristoph Hellwig 	}
247f461d2dcSChristoph Hellwig 
248f461d2dcSChristoph Hellwig 	if (write) {
249f461d2dcSChristoph Hellwig 		if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
250f461d2dcSChristoph Hellwig 			/* Only continue writes not past the end of buffer. */
251f461d2dcSChristoph Hellwig 			len = strlen(data);
252f461d2dcSChristoph Hellwig 			if (len > maxlen - 1)
253f461d2dcSChristoph Hellwig 				len = maxlen - 1;
254f461d2dcSChristoph Hellwig 
255f461d2dcSChristoph Hellwig 			if (*ppos > len)
256f461d2dcSChristoph Hellwig 				return 0;
257f461d2dcSChristoph Hellwig 			len = *ppos;
258f461d2dcSChristoph Hellwig 		} else {
259f461d2dcSChristoph Hellwig 			/* Start writing from beginning of buffer. */
260f461d2dcSChristoph Hellwig 			len = 0;
261f461d2dcSChristoph Hellwig 		}
262f461d2dcSChristoph Hellwig 
263f461d2dcSChristoph Hellwig 		*ppos += *lenp;
264f461d2dcSChristoph Hellwig 		p = buffer;
265f461d2dcSChristoph Hellwig 		while ((p - buffer) < *lenp && len < maxlen - 1) {
26632927393SChristoph Hellwig 			c = *(p++);
267f461d2dcSChristoph Hellwig 			if (c == 0 || c == '\n')
268f461d2dcSChristoph Hellwig 				break;
269f461d2dcSChristoph Hellwig 			data[len++] = c;
270f461d2dcSChristoph Hellwig 		}
271f461d2dcSChristoph Hellwig 		data[len] = 0;
272f461d2dcSChristoph Hellwig 	} else {
273f461d2dcSChristoph Hellwig 		len = strlen(data);
274f461d2dcSChristoph Hellwig 		if (len > maxlen)
275f461d2dcSChristoph Hellwig 			len = maxlen;
276f461d2dcSChristoph Hellwig 
277f461d2dcSChristoph Hellwig 		if (*ppos > len) {
278f461d2dcSChristoph Hellwig 			*lenp = 0;
279f461d2dcSChristoph Hellwig 			return 0;
280f461d2dcSChristoph Hellwig 		}
281f461d2dcSChristoph Hellwig 
282f461d2dcSChristoph Hellwig 		data += *ppos;
283f461d2dcSChristoph Hellwig 		len  -= *ppos;
284f461d2dcSChristoph Hellwig 
285f461d2dcSChristoph Hellwig 		if (len > *lenp)
286f461d2dcSChristoph Hellwig 			len = *lenp;
287f461d2dcSChristoph Hellwig 		if (len)
28832927393SChristoph Hellwig 			memcpy(buffer, data, len);
289f461d2dcSChristoph Hellwig 		if (len < *lenp) {
29032927393SChristoph Hellwig 			buffer[len] = '\n';
291f461d2dcSChristoph Hellwig 			len++;
292f461d2dcSChristoph Hellwig 		}
293f461d2dcSChristoph Hellwig 		*lenp = len;
294f461d2dcSChristoph Hellwig 		*ppos += len;
295f461d2dcSChristoph Hellwig 	}
296f461d2dcSChristoph Hellwig 	return 0;
297f461d2dcSChristoph Hellwig }
298f461d2dcSChristoph Hellwig 
299f461d2dcSChristoph Hellwig static void warn_sysctl_write(struct ctl_table *table)
300f461d2dcSChristoph Hellwig {
301f461d2dcSChristoph Hellwig 	pr_warn_once("%s wrote to %s when file position was not 0!\n"
302f461d2dcSChristoph Hellwig 		"This will not be supported in the future. To silence this\n"
303f461d2dcSChristoph Hellwig 		"warning, set kernel.sysctl_writes_strict = -1\n",
304f461d2dcSChristoph Hellwig 		current->comm, table->procname);
305f461d2dcSChristoph Hellwig }
306f461d2dcSChristoph Hellwig 
307f461d2dcSChristoph Hellwig /**
308f461d2dcSChristoph Hellwig  * proc_first_pos_non_zero_ignore - check if first position is allowed
309f461d2dcSChristoph Hellwig  * @ppos: file position
310f461d2dcSChristoph Hellwig  * @table: the sysctl table
311f461d2dcSChristoph Hellwig  *
312f461d2dcSChristoph Hellwig  * Returns true if the first position is non-zero and the sysctl_writes_strict
313f461d2dcSChristoph Hellwig  * mode indicates this is not allowed for numeric input types. String proc
314f461d2dcSChristoph Hellwig  * handlers can ignore the return value.
315f461d2dcSChristoph Hellwig  */
316f461d2dcSChristoph Hellwig static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
317f461d2dcSChristoph Hellwig 					   struct ctl_table *table)
318f461d2dcSChristoph Hellwig {
319f461d2dcSChristoph Hellwig 	if (!*ppos)
320f461d2dcSChristoph Hellwig 		return false;
321f461d2dcSChristoph Hellwig 
322f461d2dcSChristoph Hellwig 	switch (sysctl_writes_strict) {
323f461d2dcSChristoph Hellwig 	case SYSCTL_WRITES_STRICT:
324f461d2dcSChristoph Hellwig 		return true;
325f461d2dcSChristoph Hellwig 	case SYSCTL_WRITES_WARN:
326f461d2dcSChristoph Hellwig 		warn_sysctl_write(table);
327f461d2dcSChristoph Hellwig 		return false;
328f461d2dcSChristoph Hellwig 	default:
329f461d2dcSChristoph Hellwig 		return false;
330f461d2dcSChristoph Hellwig 	}
331f461d2dcSChristoph Hellwig }
332f461d2dcSChristoph Hellwig 
333f461d2dcSChristoph Hellwig /**
334f461d2dcSChristoph Hellwig  * proc_dostring - read a string sysctl
335f461d2dcSChristoph Hellwig  * @table: the sysctl table
336f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
337f461d2dcSChristoph Hellwig  * @buffer: the user buffer
338f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
339f461d2dcSChristoph Hellwig  * @ppos: file position
340f461d2dcSChristoph Hellwig  *
341f461d2dcSChristoph Hellwig  * Reads/writes a string from/to the user buffer. If the kernel
342f461d2dcSChristoph Hellwig  * buffer provided is not large enough to hold the string, the
343f461d2dcSChristoph Hellwig  * string is truncated. The copied string is %NULL-terminated.
344f461d2dcSChristoph Hellwig  * If the string is being read by the user process, it is copied
345f461d2dcSChristoph Hellwig  * and a newline '\n' is added. It is truncated if the buffer is
346f461d2dcSChristoph Hellwig  * not large enough.
347f461d2dcSChristoph Hellwig  *
348f461d2dcSChristoph Hellwig  * Returns 0 on success.
349f461d2dcSChristoph Hellwig  */
350f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write,
35132927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
352f461d2dcSChristoph Hellwig {
353f461d2dcSChristoph Hellwig 	if (write)
354f461d2dcSChristoph Hellwig 		proc_first_pos_non_zero_ignore(ppos, table);
355f461d2dcSChristoph Hellwig 
35632927393SChristoph Hellwig 	return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
35732927393SChristoph Hellwig 			ppos);
358f461d2dcSChristoph Hellwig }
359f461d2dcSChristoph Hellwig 
360f461d2dcSChristoph Hellwig static size_t proc_skip_spaces(char **buf)
361f461d2dcSChristoph Hellwig {
362f461d2dcSChristoph Hellwig 	size_t ret;
363f461d2dcSChristoph Hellwig 	char *tmp = skip_spaces(*buf);
364f461d2dcSChristoph Hellwig 	ret = tmp - *buf;
365f461d2dcSChristoph Hellwig 	*buf = tmp;
366f461d2dcSChristoph Hellwig 	return ret;
367f461d2dcSChristoph Hellwig }
368f461d2dcSChristoph Hellwig 
369f461d2dcSChristoph Hellwig static void proc_skip_char(char **buf, size_t *size, const char v)
370f461d2dcSChristoph Hellwig {
371f461d2dcSChristoph Hellwig 	while (*size) {
372f461d2dcSChristoph Hellwig 		if (**buf != v)
373f461d2dcSChristoph Hellwig 			break;
374f461d2dcSChristoph Hellwig 		(*size)--;
375f461d2dcSChristoph Hellwig 		(*buf)++;
376f461d2dcSChristoph Hellwig 	}
377f461d2dcSChristoph Hellwig }
378f461d2dcSChristoph Hellwig 
379f461d2dcSChristoph Hellwig /**
380f461d2dcSChristoph Hellwig  * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
381f461d2dcSChristoph Hellwig  *                   fail on overflow
382f461d2dcSChristoph Hellwig  *
383f461d2dcSChristoph Hellwig  * @cp: kernel buffer containing the string to parse
384f461d2dcSChristoph Hellwig  * @endp: pointer to store the trailing characters
385f461d2dcSChristoph Hellwig  * @base: the base to use
386f461d2dcSChristoph Hellwig  * @res: where the parsed integer will be stored
387f461d2dcSChristoph Hellwig  *
388f461d2dcSChristoph Hellwig  * In case of success 0 is returned and @res will contain the parsed integer,
389f461d2dcSChristoph Hellwig  * @endp will hold any trailing characters.
390f461d2dcSChristoph Hellwig  * This function will fail the parse on overflow. If there wasn't an overflow
391f461d2dcSChristoph Hellwig  * the function will defer the decision what characters count as invalid to the
392f461d2dcSChristoph Hellwig  * caller.
393f461d2dcSChristoph Hellwig  */
394f461d2dcSChristoph Hellwig static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
395f461d2dcSChristoph Hellwig 			   unsigned long *res)
396f461d2dcSChristoph Hellwig {
397f461d2dcSChristoph Hellwig 	unsigned long long result;
398f461d2dcSChristoph Hellwig 	unsigned int rv;
399f461d2dcSChristoph Hellwig 
400f461d2dcSChristoph Hellwig 	cp = _parse_integer_fixup_radix(cp, &base);
401f461d2dcSChristoph Hellwig 	rv = _parse_integer(cp, base, &result);
402f461d2dcSChristoph Hellwig 	if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
403f461d2dcSChristoph Hellwig 		return -ERANGE;
404f461d2dcSChristoph Hellwig 
405f461d2dcSChristoph Hellwig 	cp += rv;
406f461d2dcSChristoph Hellwig 
407f461d2dcSChristoph Hellwig 	if (endp)
408f461d2dcSChristoph Hellwig 		*endp = (char *)cp;
409f461d2dcSChristoph Hellwig 
410f461d2dcSChristoph Hellwig 	*res = (unsigned long)result;
411f461d2dcSChristoph Hellwig 	return 0;
412f461d2dcSChristoph Hellwig }
413f461d2dcSChristoph Hellwig 
414f461d2dcSChristoph Hellwig #define TMPBUFLEN 22
415f461d2dcSChristoph Hellwig /**
416f461d2dcSChristoph Hellwig  * proc_get_long - reads an ASCII formatted integer from a user buffer
417f461d2dcSChristoph Hellwig  *
418f461d2dcSChristoph Hellwig  * @buf: a kernel buffer
419f461d2dcSChristoph Hellwig  * @size: size of the kernel buffer
420f461d2dcSChristoph Hellwig  * @val: this is where the number will be stored
421f461d2dcSChristoph Hellwig  * @neg: set to %TRUE if number is negative
422f461d2dcSChristoph Hellwig  * @perm_tr: a vector which contains the allowed trailers
423f461d2dcSChristoph Hellwig  * @perm_tr_len: size of the perm_tr vector
424f461d2dcSChristoph Hellwig  * @tr: pointer to store the trailer character
425f461d2dcSChristoph Hellwig  *
426f461d2dcSChristoph Hellwig  * In case of success %0 is returned and @buf and @size are updated with
427f461d2dcSChristoph Hellwig  * the amount of bytes read. If @tr is non-NULL and a trailing
428f461d2dcSChristoph Hellwig  * character exists (size is non-zero after returning from this
429f461d2dcSChristoph Hellwig  * function), @tr is updated with the trailing character.
430f461d2dcSChristoph Hellwig  */
431f461d2dcSChristoph Hellwig static int proc_get_long(char **buf, size_t *size,
432f461d2dcSChristoph Hellwig 			  unsigned long *val, bool *neg,
433f461d2dcSChristoph Hellwig 			  const char *perm_tr, unsigned perm_tr_len, char *tr)
434f461d2dcSChristoph Hellwig {
435f461d2dcSChristoph Hellwig 	int len;
436f461d2dcSChristoph Hellwig 	char *p, tmp[TMPBUFLEN];
437f461d2dcSChristoph Hellwig 
438f461d2dcSChristoph Hellwig 	if (!*size)
439f461d2dcSChristoph Hellwig 		return -EINVAL;
440f461d2dcSChristoph Hellwig 
441f461d2dcSChristoph Hellwig 	len = *size;
442f461d2dcSChristoph Hellwig 	if (len > TMPBUFLEN - 1)
443f461d2dcSChristoph Hellwig 		len = TMPBUFLEN - 1;
444f461d2dcSChristoph Hellwig 
445f461d2dcSChristoph Hellwig 	memcpy(tmp, *buf, len);
446f461d2dcSChristoph Hellwig 
447f461d2dcSChristoph Hellwig 	tmp[len] = 0;
448f461d2dcSChristoph Hellwig 	p = tmp;
449f461d2dcSChristoph Hellwig 	if (*p == '-' && *size > 1) {
450f461d2dcSChristoph Hellwig 		*neg = true;
451f461d2dcSChristoph Hellwig 		p++;
452f461d2dcSChristoph Hellwig 	} else
453f461d2dcSChristoph Hellwig 		*neg = false;
454f461d2dcSChristoph Hellwig 	if (!isdigit(*p))
455f461d2dcSChristoph Hellwig 		return -EINVAL;
456f461d2dcSChristoph Hellwig 
457f461d2dcSChristoph Hellwig 	if (strtoul_lenient(p, &p, 0, val))
458f461d2dcSChristoph Hellwig 		return -EINVAL;
459f461d2dcSChristoph Hellwig 
460f461d2dcSChristoph Hellwig 	len = p - tmp;
461f461d2dcSChristoph Hellwig 
462f461d2dcSChristoph Hellwig 	/* We don't know if the next char is whitespace thus we may accept
463f461d2dcSChristoph Hellwig 	 * invalid integers (e.g. 1234...a) or two integers instead of one
464f461d2dcSChristoph Hellwig 	 * (e.g. 123...1). So lets not allow such large numbers. */
465f461d2dcSChristoph Hellwig 	if (len == TMPBUFLEN - 1)
466f461d2dcSChristoph Hellwig 		return -EINVAL;
467f461d2dcSChristoph Hellwig 
468f461d2dcSChristoph Hellwig 	if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
469f461d2dcSChristoph Hellwig 		return -EINVAL;
470f461d2dcSChristoph Hellwig 
471f461d2dcSChristoph Hellwig 	if (tr && (len < *size))
472f461d2dcSChristoph Hellwig 		*tr = *p;
473f461d2dcSChristoph Hellwig 
474f461d2dcSChristoph Hellwig 	*buf += len;
475f461d2dcSChristoph Hellwig 	*size -= len;
476f461d2dcSChristoph Hellwig 
477f461d2dcSChristoph Hellwig 	return 0;
478f461d2dcSChristoph Hellwig }
479f461d2dcSChristoph Hellwig 
480f461d2dcSChristoph Hellwig /**
481f461d2dcSChristoph Hellwig  * proc_put_long - converts an integer to a decimal ASCII formatted string
482f461d2dcSChristoph Hellwig  *
483f461d2dcSChristoph Hellwig  * @buf: the user buffer
484f461d2dcSChristoph Hellwig  * @size: the size of the user buffer
485f461d2dcSChristoph Hellwig  * @val: the integer to be converted
486f461d2dcSChristoph Hellwig  * @neg: sign of the number, %TRUE for negative
487f461d2dcSChristoph Hellwig  *
48832927393SChristoph Hellwig  * In case of success @buf and @size are updated with the amount of bytes
48932927393SChristoph Hellwig  * written.
490f461d2dcSChristoph Hellwig  */
49132927393SChristoph Hellwig static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
492f461d2dcSChristoph Hellwig {
493f461d2dcSChristoph Hellwig 	int len;
494f461d2dcSChristoph Hellwig 	char tmp[TMPBUFLEN], *p = tmp;
495f461d2dcSChristoph Hellwig 
496f461d2dcSChristoph Hellwig 	sprintf(p, "%s%lu", neg ? "-" : "", val);
497f461d2dcSChristoph Hellwig 	len = strlen(tmp);
498f461d2dcSChristoph Hellwig 	if (len > *size)
499f461d2dcSChristoph Hellwig 		len = *size;
50032927393SChristoph Hellwig 	memcpy(*buf, tmp, len);
501f461d2dcSChristoph Hellwig 	*size -= len;
502f461d2dcSChristoph Hellwig 	*buf += len;
503f461d2dcSChristoph Hellwig }
504f461d2dcSChristoph Hellwig #undef TMPBUFLEN
505f461d2dcSChristoph Hellwig 
50632927393SChristoph Hellwig static void proc_put_char(void **buf, size_t *size, char c)
507f461d2dcSChristoph Hellwig {
508f461d2dcSChristoph Hellwig 	if (*size) {
50932927393SChristoph Hellwig 		char **buffer = (char **)buf;
51032927393SChristoph Hellwig 		**buffer = c;
51132927393SChristoph Hellwig 
51232927393SChristoph Hellwig 		(*size)--;
51332927393SChristoph Hellwig 		(*buffer)++;
514f461d2dcSChristoph Hellwig 		*buf = *buffer;
515f461d2dcSChristoph Hellwig 	}
516f461d2dcSChristoph Hellwig }
517f461d2dcSChristoph Hellwig 
518f461d2dcSChristoph Hellwig static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
519f461d2dcSChristoph Hellwig 				 int *valp,
520f461d2dcSChristoph Hellwig 				 int write, void *data)
521f461d2dcSChristoph Hellwig {
522f461d2dcSChristoph Hellwig 	if (write) {
523f461d2dcSChristoph Hellwig 		if (*negp) {
524f461d2dcSChristoph Hellwig 			if (*lvalp > (unsigned long) INT_MAX + 1)
525f461d2dcSChristoph Hellwig 				return -EINVAL;
526f461d2dcSChristoph Hellwig 			*valp = -*lvalp;
527f461d2dcSChristoph Hellwig 		} else {
528f461d2dcSChristoph Hellwig 			if (*lvalp > (unsigned long) INT_MAX)
529f461d2dcSChristoph Hellwig 				return -EINVAL;
530f461d2dcSChristoph Hellwig 			*valp = *lvalp;
531f461d2dcSChristoph Hellwig 		}
532f461d2dcSChristoph Hellwig 	} else {
533f461d2dcSChristoph Hellwig 		int val = *valp;
534f461d2dcSChristoph Hellwig 		if (val < 0) {
535f461d2dcSChristoph Hellwig 			*negp = true;
536f461d2dcSChristoph Hellwig 			*lvalp = -(unsigned long)val;
537f461d2dcSChristoph Hellwig 		} else {
538f461d2dcSChristoph Hellwig 			*negp = false;
539f461d2dcSChristoph Hellwig 			*lvalp = (unsigned long)val;
540f461d2dcSChristoph Hellwig 		}
541f461d2dcSChristoph Hellwig 	}
542f461d2dcSChristoph Hellwig 	return 0;
543f461d2dcSChristoph Hellwig }
544f461d2dcSChristoph Hellwig 
545f461d2dcSChristoph Hellwig static int do_proc_douintvec_conv(unsigned long *lvalp,
546f461d2dcSChristoph Hellwig 				  unsigned int *valp,
547f461d2dcSChristoph Hellwig 				  int write, void *data)
548f461d2dcSChristoph Hellwig {
549f461d2dcSChristoph Hellwig 	if (write) {
550f461d2dcSChristoph Hellwig 		if (*lvalp > UINT_MAX)
551f461d2dcSChristoph Hellwig 			return -EINVAL;
552f461d2dcSChristoph Hellwig 		*valp = *lvalp;
553f461d2dcSChristoph Hellwig 	} else {
554f461d2dcSChristoph Hellwig 		unsigned int val = *valp;
555f461d2dcSChristoph Hellwig 		*lvalp = (unsigned long)val;
556f461d2dcSChristoph Hellwig 	}
557f461d2dcSChristoph Hellwig 	return 0;
558f461d2dcSChristoph Hellwig }
559f461d2dcSChristoph Hellwig 
560f461d2dcSChristoph Hellwig static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
561f461d2dcSChristoph Hellwig 
562f461d2dcSChristoph Hellwig static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
56332927393SChristoph Hellwig 		  int write, void *buffer,
564f461d2dcSChristoph Hellwig 		  size_t *lenp, loff_t *ppos,
565f461d2dcSChristoph Hellwig 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
566f461d2dcSChristoph Hellwig 			      int write, void *data),
567f461d2dcSChristoph Hellwig 		  void *data)
568f461d2dcSChristoph Hellwig {
569f461d2dcSChristoph Hellwig 	int *i, vleft, first = 1, err = 0;
570f461d2dcSChristoph Hellwig 	size_t left;
57132927393SChristoph Hellwig 	char *p;
572f461d2dcSChristoph Hellwig 
573f461d2dcSChristoph Hellwig 	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
574f461d2dcSChristoph Hellwig 		*lenp = 0;
575f461d2dcSChristoph Hellwig 		return 0;
576f461d2dcSChristoph Hellwig 	}
577f461d2dcSChristoph Hellwig 
578f461d2dcSChristoph Hellwig 	i = (int *) tbl_data;
579f461d2dcSChristoph Hellwig 	vleft = table->maxlen / sizeof(*i);
580f461d2dcSChristoph Hellwig 	left = *lenp;
581f461d2dcSChristoph Hellwig 
582f461d2dcSChristoph Hellwig 	if (!conv)
583f461d2dcSChristoph Hellwig 		conv = do_proc_dointvec_conv;
584f461d2dcSChristoph Hellwig 
585f461d2dcSChristoph Hellwig 	if (write) {
586f461d2dcSChristoph Hellwig 		if (proc_first_pos_non_zero_ignore(ppos, table))
587f461d2dcSChristoph Hellwig 			goto out;
588f461d2dcSChristoph Hellwig 
589f461d2dcSChristoph Hellwig 		if (left > PAGE_SIZE - 1)
590f461d2dcSChristoph Hellwig 			left = PAGE_SIZE - 1;
59132927393SChristoph Hellwig 		p = buffer;
592f461d2dcSChristoph Hellwig 	}
593f461d2dcSChristoph Hellwig 
594f461d2dcSChristoph Hellwig 	for (; left && vleft--; i++, first=0) {
595f461d2dcSChristoph Hellwig 		unsigned long lval;
596f461d2dcSChristoph Hellwig 		bool neg;
597f461d2dcSChristoph Hellwig 
598f461d2dcSChristoph Hellwig 		if (write) {
599f461d2dcSChristoph Hellwig 			left -= proc_skip_spaces(&p);
600f461d2dcSChristoph Hellwig 
601f461d2dcSChristoph Hellwig 			if (!left)
602f461d2dcSChristoph Hellwig 				break;
603f461d2dcSChristoph Hellwig 			err = proc_get_long(&p, &left, &lval, &neg,
604f461d2dcSChristoph Hellwig 					     proc_wspace_sep,
605f461d2dcSChristoph Hellwig 					     sizeof(proc_wspace_sep), NULL);
606f461d2dcSChristoph Hellwig 			if (err)
607f461d2dcSChristoph Hellwig 				break;
608f461d2dcSChristoph Hellwig 			if (conv(&neg, &lval, i, 1, data)) {
609f461d2dcSChristoph Hellwig 				err = -EINVAL;
610f461d2dcSChristoph Hellwig 				break;
611f461d2dcSChristoph Hellwig 			}
612f461d2dcSChristoph Hellwig 		} else {
613f461d2dcSChristoph Hellwig 			if (conv(&neg, &lval, i, 0, data)) {
614f461d2dcSChristoph Hellwig 				err = -EINVAL;
615f461d2dcSChristoph Hellwig 				break;
616f461d2dcSChristoph Hellwig 			}
617f461d2dcSChristoph Hellwig 			if (!first)
61832927393SChristoph Hellwig 				proc_put_char(&buffer, &left, '\t');
61932927393SChristoph Hellwig 			proc_put_long(&buffer, &left, lval, neg);
620f461d2dcSChristoph Hellwig 		}
621f461d2dcSChristoph Hellwig 	}
622f461d2dcSChristoph Hellwig 
623f461d2dcSChristoph Hellwig 	if (!write && !first && left && !err)
62432927393SChristoph Hellwig 		proc_put_char(&buffer, &left, '\n');
625f461d2dcSChristoph Hellwig 	if (write && !err && left)
626f461d2dcSChristoph Hellwig 		left -= proc_skip_spaces(&p);
62732927393SChristoph Hellwig 	if (write && first)
628f461d2dcSChristoph Hellwig 		return err ? : -EINVAL;
629f461d2dcSChristoph Hellwig 	*lenp -= left;
630f461d2dcSChristoph Hellwig out:
631f461d2dcSChristoph Hellwig 	*ppos += *lenp;
632f461d2dcSChristoph Hellwig 	return err;
633f461d2dcSChristoph Hellwig }
634f461d2dcSChristoph Hellwig 
635f461d2dcSChristoph Hellwig static int do_proc_dointvec(struct ctl_table *table, int write,
63632927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos,
637f461d2dcSChristoph Hellwig 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
638f461d2dcSChristoph Hellwig 			      int write, void *data),
639f461d2dcSChristoph Hellwig 		  void *data)
640f461d2dcSChristoph Hellwig {
641f461d2dcSChristoph Hellwig 	return __do_proc_dointvec(table->data, table, write,
642f461d2dcSChristoph Hellwig 			buffer, lenp, ppos, conv, data);
643f461d2dcSChristoph Hellwig }
644f461d2dcSChristoph Hellwig 
645f461d2dcSChristoph Hellwig static int do_proc_douintvec_w(unsigned int *tbl_data,
646f461d2dcSChristoph Hellwig 			       struct ctl_table *table,
64732927393SChristoph Hellwig 			       void *buffer,
648f461d2dcSChristoph Hellwig 			       size_t *lenp, loff_t *ppos,
649f461d2dcSChristoph Hellwig 			       int (*conv)(unsigned long *lvalp,
650f461d2dcSChristoph Hellwig 					   unsigned int *valp,
651f461d2dcSChristoph Hellwig 					   int write, void *data),
652f461d2dcSChristoph Hellwig 			       void *data)
653f461d2dcSChristoph Hellwig {
654f461d2dcSChristoph Hellwig 	unsigned long lval;
655f461d2dcSChristoph Hellwig 	int err = 0;
656f461d2dcSChristoph Hellwig 	size_t left;
657f461d2dcSChristoph Hellwig 	bool neg;
65832927393SChristoph Hellwig 	char *p = buffer;
659f461d2dcSChristoph Hellwig 
660f461d2dcSChristoph Hellwig 	left = *lenp;
661f461d2dcSChristoph Hellwig 
662f461d2dcSChristoph Hellwig 	if (proc_first_pos_non_zero_ignore(ppos, table))
663f461d2dcSChristoph Hellwig 		goto bail_early;
664f461d2dcSChristoph Hellwig 
665f461d2dcSChristoph Hellwig 	if (left > PAGE_SIZE - 1)
666f461d2dcSChristoph Hellwig 		left = PAGE_SIZE - 1;
667f461d2dcSChristoph Hellwig 
668f461d2dcSChristoph Hellwig 	left -= proc_skip_spaces(&p);
669f461d2dcSChristoph Hellwig 	if (!left) {
670f461d2dcSChristoph Hellwig 		err = -EINVAL;
671f461d2dcSChristoph Hellwig 		goto out_free;
672f461d2dcSChristoph Hellwig 	}
673f461d2dcSChristoph Hellwig 
674f461d2dcSChristoph Hellwig 	err = proc_get_long(&p, &left, &lval, &neg,
675f461d2dcSChristoph Hellwig 			     proc_wspace_sep,
676f461d2dcSChristoph Hellwig 			     sizeof(proc_wspace_sep), NULL);
677f461d2dcSChristoph Hellwig 	if (err || neg) {
678f461d2dcSChristoph Hellwig 		err = -EINVAL;
679f461d2dcSChristoph Hellwig 		goto out_free;
680f461d2dcSChristoph Hellwig 	}
681f461d2dcSChristoph Hellwig 
682f461d2dcSChristoph Hellwig 	if (conv(&lval, tbl_data, 1, data)) {
683f461d2dcSChristoph Hellwig 		err = -EINVAL;
684f461d2dcSChristoph Hellwig 		goto out_free;
685f461d2dcSChristoph Hellwig 	}
686f461d2dcSChristoph Hellwig 
687f461d2dcSChristoph Hellwig 	if (!err && left)
688f461d2dcSChristoph Hellwig 		left -= proc_skip_spaces(&p);
689f461d2dcSChristoph Hellwig 
690f461d2dcSChristoph Hellwig out_free:
691f461d2dcSChristoph Hellwig 	if (err)
692f461d2dcSChristoph Hellwig 		return -EINVAL;
693f461d2dcSChristoph Hellwig 
694f461d2dcSChristoph Hellwig 	return 0;
695f461d2dcSChristoph Hellwig 
696f461d2dcSChristoph Hellwig 	/* This is in keeping with old __do_proc_dointvec() */
697f461d2dcSChristoph Hellwig bail_early:
698f461d2dcSChristoph Hellwig 	*ppos += *lenp;
699f461d2dcSChristoph Hellwig 	return err;
700f461d2dcSChristoph Hellwig }
701f461d2dcSChristoph Hellwig 
70232927393SChristoph Hellwig static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
703f461d2dcSChristoph Hellwig 			       size_t *lenp, loff_t *ppos,
704f461d2dcSChristoph Hellwig 			       int (*conv)(unsigned long *lvalp,
705f461d2dcSChristoph Hellwig 					   unsigned int *valp,
706f461d2dcSChristoph Hellwig 					   int write, void *data),
707f461d2dcSChristoph Hellwig 			       void *data)
708f461d2dcSChristoph Hellwig {
709f461d2dcSChristoph Hellwig 	unsigned long lval;
710f461d2dcSChristoph Hellwig 	int err = 0;
711f461d2dcSChristoph Hellwig 	size_t left;
712f461d2dcSChristoph Hellwig 
713f461d2dcSChristoph Hellwig 	left = *lenp;
714f461d2dcSChristoph Hellwig 
715f461d2dcSChristoph Hellwig 	if (conv(&lval, tbl_data, 0, data)) {
716f461d2dcSChristoph Hellwig 		err = -EINVAL;
717f461d2dcSChristoph Hellwig 		goto out;
718f461d2dcSChristoph Hellwig 	}
719f461d2dcSChristoph Hellwig 
72032927393SChristoph Hellwig 	proc_put_long(&buffer, &left, lval, false);
72132927393SChristoph Hellwig 	if (!left)
722f461d2dcSChristoph Hellwig 		goto out;
723f461d2dcSChristoph Hellwig 
72432927393SChristoph Hellwig 	proc_put_char(&buffer, &left, '\n');
725f461d2dcSChristoph Hellwig 
726f461d2dcSChristoph Hellwig out:
727f461d2dcSChristoph Hellwig 	*lenp -= left;
728f461d2dcSChristoph Hellwig 	*ppos += *lenp;
729f461d2dcSChristoph Hellwig 
730f461d2dcSChristoph Hellwig 	return err;
731f461d2dcSChristoph Hellwig }
732f461d2dcSChristoph Hellwig 
733f461d2dcSChristoph Hellwig static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
73432927393SChristoph Hellwig 			       int write, void *buffer,
735f461d2dcSChristoph Hellwig 			       size_t *lenp, loff_t *ppos,
736f461d2dcSChristoph Hellwig 			       int (*conv)(unsigned long *lvalp,
737f461d2dcSChristoph Hellwig 					   unsigned int *valp,
738f461d2dcSChristoph Hellwig 					   int write, void *data),
739f461d2dcSChristoph Hellwig 			       void *data)
740f461d2dcSChristoph Hellwig {
741f461d2dcSChristoph Hellwig 	unsigned int *i, vleft;
742f461d2dcSChristoph Hellwig 
743f461d2dcSChristoph Hellwig 	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
744f461d2dcSChristoph Hellwig 		*lenp = 0;
745f461d2dcSChristoph Hellwig 		return 0;
746f461d2dcSChristoph Hellwig 	}
747f461d2dcSChristoph Hellwig 
748f461d2dcSChristoph Hellwig 	i = (unsigned int *) tbl_data;
749f461d2dcSChristoph Hellwig 	vleft = table->maxlen / sizeof(*i);
750f461d2dcSChristoph Hellwig 
751f461d2dcSChristoph Hellwig 	/*
752f461d2dcSChristoph Hellwig 	 * Arrays are not supported, keep this simple. *Do not* add
753f461d2dcSChristoph Hellwig 	 * support for them.
754f461d2dcSChristoph Hellwig 	 */
755f461d2dcSChristoph Hellwig 	if (vleft != 1) {
756f461d2dcSChristoph Hellwig 		*lenp = 0;
757f461d2dcSChristoph Hellwig 		return -EINVAL;
758f461d2dcSChristoph Hellwig 	}
759f461d2dcSChristoph Hellwig 
760f461d2dcSChristoph Hellwig 	if (!conv)
761f461d2dcSChristoph Hellwig 		conv = do_proc_douintvec_conv;
762f461d2dcSChristoph Hellwig 
763f461d2dcSChristoph Hellwig 	if (write)
764f461d2dcSChristoph Hellwig 		return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
765f461d2dcSChristoph Hellwig 					   conv, data);
766f461d2dcSChristoph Hellwig 	return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
767f461d2dcSChristoph Hellwig }
768f461d2dcSChristoph Hellwig 
769f461d2dcSChristoph Hellwig static int do_proc_douintvec(struct ctl_table *table, int write,
77032927393SChristoph Hellwig 			     void *buffer, size_t *lenp, loff_t *ppos,
771f461d2dcSChristoph Hellwig 			     int (*conv)(unsigned long *lvalp,
772f461d2dcSChristoph Hellwig 					 unsigned int *valp,
773f461d2dcSChristoph Hellwig 					 int write, void *data),
774f461d2dcSChristoph Hellwig 			     void *data)
775f461d2dcSChristoph Hellwig {
776f461d2dcSChristoph Hellwig 	return __do_proc_douintvec(table->data, table, write,
777f461d2dcSChristoph Hellwig 				   buffer, lenp, ppos, conv, data);
778f461d2dcSChristoph Hellwig }
779f461d2dcSChristoph Hellwig 
780f461d2dcSChristoph Hellwig /**
781f461d2dcSChristoph Hellwig  * proc_dointvec - read a vector of integers
782f461d2dcSChristoph Hellwig  * @table: the sysctl table
783f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
784f461d2dcSChristoph Hellwig  * @buffer: the user buffer
785f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
786f461d2dcSChristoph Hellwig  * @ppos: file position
787f461d2dcSChristoph Hellwig  *
788f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
789f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
790f461d2dcSChristoph Hellwig  *
791f461d2dcSChristoph Hellwig  * Returns 0 on success.
792f461d2dcSChristoph Hellwig  */
79332927393SChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, void *buffer,
79432927393SChristoph Hellwig 		  size_t *lenp, loff_t *ppos)
795f461d2dcSChristoph Hellwig {
796f461d2dcSChristoph Hellwig 	return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
797f461d2dcSChristoph Hellwig }
798f461d2dcSChristoph Hellwig 
799f461d2dcSChristoph Hellwig #ifdef CONFIG_COMPACTION
800f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
80132927393SChristoph Hellwig 		int write, void *buffer, size_t *lenp, loff_t *ppos)
802f461d2dcSChristoph Hellwig {
803f461d2dcSChristoph Hellwig 	int ret, old;
804f461d2dcSChristoph Hellwig 
805f461d2dcSChristoph Hellwig 	if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
806f461d2dcSChristoph Hellwig 		return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
807f461d2dcSChristoph Hellwig 
808f461d2dcSChristoph Hellwig 	old = *(int *)table->data;
809f461d2dcSChristoph Hellwig 	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
810f461d2dcSChristoph Hellwig 	if (ret)
811f461d2dcSChristoph Hellwig 		return ret;
812f461d2dcSChristoph Hellwig 	if (old != *(int *)table->data)
813f461d2dcSChristoph Hellwig 		pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
814f461d2dcSChristoph Hellwig 			     table->procname, current->comm,
815f461d2dcSChristoph Hellwig 			     task_pid_nr(current));
816f461d2dcSChristoph Hellwig 	return ret;
817f461d2dcSChristoph Hellwig }
818f461d2dcSChristoph Hellwig #endif
819f461d2dcSChristoph Hellwig 
820f461d2dcSChristoph Hellwig /**
821f461d2dcSChristoph Hellwig  * proc_douintvec - read a vector of unsigned integers
822f461d2dcSChristoph Hellwig  * @table: the sysctl table
823f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
824f461d2dcSChristoph Hellwig  * @buffer: the user buffer
825f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
826f461d2dcSChristoph Hellwig  * @ppos: file position
827f461d2dcSChristoph Hellwig  *
828f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
829f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
830f461d2dcSChristoph Hellwig  *
831f461d2dcSChristoph Hellwig  * Returns 0 on success.
832f461d2dcSChristoph Hellwig  */
83332927393SChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, void *buffer,
83432927393SChristoph Hellwig 		size_t *lenp, loff_t *ppos)
835f461d2dcSChristoph Hellwig {
836f461d2dcSChristoph Hellwig 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
837f461d2dcSChristoph Hellwig 				 do_proc_douintvec_conv, NULL);
838f461d2dcSChristoph Hellwig }
839f461d2dcSChristoph Hellwig 
840f461d2dcSChristoph Hellwig /*
841f461d2dcSChristoph Hellwig  * Taint values can only be increased
842f461d2dcSChristoph Hellwig  * This means we can safely use a temporary.
843f461d2dcSChristoph Hellwig  */
844f461d2dcSChristoph Hellwig static int proc_taint(struct ctl_table *table, int write,
84532927393SChristoph Hellwig 			       void *buffer, size_t *lenp, loff_t *ppos)
846f461d2dcSChristoph Hellwig {
847f461d2dcSChristoph Hellwig 	struct ctl_table t;
848f461d2dcSChristoph Hellwig 	unsigned long tmptaint = get_taint();
849f461d2dcSChristoph Hellwig 	int err;
850f461d2dcSChristoph Hellwig 
851f461d2dcSChristoph Hellwig 	if (write && !capable(CAP_SYS_ADMIN))
852f461d2dcSChristoph Hellwig 		return -EPERM;
853f461d2dcSChristoph Hellwig 
854f461d2dcSChristoph Hellwig 	t = *table;
855f461d2dcSChristoph Hellwig 	t.data = &tmptaint;
856f461d2dcSChristoph Hellwig 	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
857f461d2dcSChristoph Hellwig 	if (err < 0)
858f461d2dcSChristoph Hellwig 		return err;
859f461d2dcSChristoph Hellwig 
860f461d2dcSChristoph Hellwig 	if (write) {
861db38d5c1SRafael Aquini 		int i;
862db38d5c1SRafael Aquini 
863db38d5c1SRafael Aquini 		/*
864db38d5c1SRafael Aquini 		 * If we are relying on panic_on_taint not producing
865db38d5c1SRafael Aquini 		 * false positives due to userspace input, bail out
866db38d5c1SRafael Aquini 		 * before setting the requested taint flags.
867db38d5c1SRafael Aquini 		 */
868db38d5c1SRafael Aquini 		if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
869db38d5c1SRafael Aquini 			return -EINVAL;
870db38d5c1SRafael Aquini 
871f461d2dcSChristoph Hellwig 		/*
872f461d2dcSChristoph Hellwig 		 * Poor man's atomic or. Not worth adding a primitive
873f461d2dcSChristoph Hellwig 		 * to everyone's atomic.h for this
874f461d2dcSChristoph Hellwig 		 */
875e77132e7SRafael Aquini 		for (i = 0; i < TAINT_FLAGS_COUNT; i++)
876e77132e7SRafael Aquini 			if ((1UL << i) & tmptaint)
877f461d2dcSChristoph Hellwig 				add_taint(i, LOCKDEP_STILL_OK);
878f461d2dcSChristoph Hellwig 	}
879f461d2dcSChristoph Hellwig 
880f461d2dcSChristoph Hellwig 	return err;
881f461d2dcSChristoph Hellwig }
882f461d2dcSChristoph Hellwig 
883f461d2dcSChristoph Hellwig #ifdef CONFIG_PRINTK
884f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
88532927393SChristoph Hellwig 				void *buffer, size_t *lenp, loff_t *ppos)
886f461d2dcSChristoph Hellwig {
887f461d2dcSChristoph Hellwig 	if (write && !capable(CAP_SYS_ADMIN))
888f461d2dcSChristoph Hellwig 		return -EPERM;
889f461d2dcSChristoph Hellwig 
890f461d2dcSChristoph Hellwig 	return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
891f461d2dcSChristoph Hellwig }
892f461d2dcSChristoph Hellwig #endif
893f461d2dcSChristoph Hellwig 
894f461d2dcSChristoph Hellwig /**
895f461d2dcSChristoph Hellwig  * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
896f461d2dcSChristoph Hellwig  * @min: pointer to minimum allowable value
897f461d2dcSChristoph Hellwig  * @max: pointer to maximum allowable value
898f461d2dcSChristoph Hellwig  *
899f461d2dcSChristoph Hellwig  * The do_proc_dointvec_minmax_conv_param structure provides the
900f461d2dcSChristoph Hellwig  * minimum and maximum values for doing range checking for those sysctl
901f461d2dcSChristoph Hellwig  * parameters that use the proc_dointvec_minmax() handler.
902f461d2dcSChristoph Hellwig  */
903f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param {
904f461d2dcSChristoph Hellwig 	int *min;
905f461d2dcSChristoph Hellwig 	int *max;
906f461d2dcSChristoph Hellwig };
907f461d2dcSChristoph Hellwig 
908f461d2dcSChristoph Hellwig static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
909f461d2dcSChristoph Hellwig 					int *valp,
910f461d2dcSChristoph Hellwig 					int write, void *data)
911f461d2dcSChristoph Hellwig {
912f461d2dcSChristoph Hellwig 	int tmp, ret;
913f461d2dcSChristoph Hellwig 	struct do_proc_dointvec_minmax_conv_param *param = data;
914f461d2dcSChristoph Hellwig 	/*
915f461d2dcSChristoph Hellwig 	 * If writing, first do so via a temporary local int so we can
916f461d2dcSChristoph Hellwig 	 * bounds-check it before touching *valp.
917f461d2dcSChristoph Hellwig 	 */
918f461d2dcSChristoph Hellwig 	int *ip = write ? &tmp : valp;
919f461d2dcSChristoph Hellwig 
920f461d2dcSChristoph Hellwig 	ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
921f461d2dcSChristoph Hellwig 	if (ret)
922f461d2dcSChristoph Hellwig 		return ret;
923f461d2dcSChristoph Hellwig 
924f461d2dcSChristoph Hellwig 	if (write) {
925f461d2dcSChristoph Hellwig 		if ((param->min && *param->min > tmp) ||
926f461d2dcSChristoph Hellwig 		    (param->max && *param->max < tmp))
927f461d2dcSChristoph Hellwig 			return -EINVAL;
928f461d2dcSChristoph Hellwig 		*valp = tmp;
929f461d2dcSChristoph Hellwig 	}
930f461d2dcSChristoph Hellwig 
931f461d2dcSChristoph Hellwig 	return 0;
932f461d2dcSChristoph Hellwig }
933f461d2dcSChristoph Hellwig 
934f461d2dcSChristoph Hellwig /**
935f461d2dcSChristoph Hellwig  * proc_dointvec_minmax - read a vector of integers with min/max values
936f461d2dcSChristoph Hellwig  * @table: the sysctl table
937f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
938f461d2dcSChristoph Hellwig  * @buffer: the user buffer
939f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
940f461d2dcSChristoph Hellwig  * @ppos: file position
941f461d2dcSChristoph Hellwig  *
942f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
943f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
944f461d2dcSChristoph Hellwig  *
945f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
946f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max).
947f461d2dcSChristoph Hellwig  *
948f461d2dcSChristoph Hellwig  * Returns 0 on success or -EINVAL on write when the range check fails.
949f461d2dcSChristoph Hellwig  */
950f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write,
95132927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
952f461d2dcSChristoph Hellwig {
953f461d2dcSChristoph Hellwig 	struct do_proc_dointvec_minmax_conv_param param = {
954f461d2dcSChristoph Hellwig 		.min = (int *) table->extra1,
955f461d2dcSChristoph Hellwig 		.max = (int *) table->extra2,
956f461d2dcSChristoph Hellwig 	};
957f461d2dcSChristoph Hellwig 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
958f461d2dcSChristoph Hellwig 				do_proc_dointvec_minmax_conv, &param);
959f461d2dcSChristoph Hellwig }
960f461d2dcSChristoph Hellwig 
961f461d2dcSChristoph Hellwig /**
962f461d2dcSChristoph Hellwig  * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
963f461d2dcSChristoph Hellwig  * @min: pointer to minimum allowable value
964f461d2dcSChristoph Hellwig  * @max: pointer to maximum allowable value
965f461d2dcSChristoph Hellwig  *
966f461d2dcSChristoph Hellwig  * The do_proc_douintvec_minmax_conv_param structure provides the
967f461d2dcSChristoph Hellwig  * minimum and maximum values for doing range checking for those sysctl
968f461d2dcSChristoph Hellwig  * parameters that use the proc_douintvec_minmax() handler.
969f461d2dcSChristoph Hellwig  */
970f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param {
971f461d2dcSChristoph Hellwig 	unsigned int *min;
972f461d2dcSChristoph Hellwig 	unsigned int *max;
973f461d2dcSChristoph Hellwig };
974f461d2dcSChristoph Hellwig 
975f461d2dcSChristoph Hellwig static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
976f461d2dcSChristoph Hellwig 					 unsigned int *valp,
977f461d2dcSChristoph Hellwig 					 int write, void *data)
978f461d2dcSChristoph Hellwig {
979f461d2dcSChristoph Hellwig 	int ret;
980f461d2dcSChristoph Hellwig 	unsigned int tmp;
981f461d2dcSChristoph Hellwig 	struct do_proc_douintvec_minmax_conv_param *param = data;
982f461d2dcSChristoph Hellwig 	/* write via temporary local uint for bounds-checking */
983f461d2dcSChristoph Hellwig 	unsigned int *up = write ? &tmp : valp;
984f461d2dcSChristoph Hellwig 
985f461d2dcSChristoph Hellwig 	ret = do_proc_douintvec_conv(lvalp, up, write, data);
986f461d2dcSChristoph Hellwig 	if (ret)
987f461d2dcSChristoph Hellwig 		return ret;
988f461d2dcSChristoph Hellwig 
989f461d2dcSChristoph Hellwig 	if (write) {
990f461d2dcSChristoph Hellwig 		if ((param->min && *param->min > tmp) ||
991f461d2dcSChristoph Hellwig 		    (param->max && *param->max < tmp))
992f461d2dcSChristoph Hellwig 			return -ERANGE;
993f461d2dcSChristoph Hellwig 
994f461d2dcSChristoph Hellwig 		*valp = tmp;
995f461d2dcSChristoph Hellwig 	}
996f461d2dcSChristoph Hellwig 
997f461d2dcSChristoph Hellwig 	return 0;
998f461d2dcSChristoph Hellwig }
999f461d2dcSChristoph Hellwig 
1000f461d2dcSChristoph Hellwig /**
1001f461d2dcSChristoph Hellwig  * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1002f461d2dcSChristoph Hellwig  * @table: the sysctl table
1003f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1004f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1005f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1006f461d2dcSChristoph Hellwig  * @ppos: file position
1007f461d2dcSChristoph Hellwig  *
1008f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1009f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string. Negative
1010f461d2dcSChristoph Hellwig  * strings are not allowed.
1011f461d2dcSChristoph Hellwig  *
1012f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1013f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max). There is a final sanity
1014f461d2dcSChristoph Hellwig  * check for UINT_MAX to avoid having to support wrap around uses from
1015f461d2dcSChristoph Hellwig  * userspace.
1016f461d2dcSChristoph Hellwig  *
1017f461d2dcSChristoph Hellwig  * Returns 0 on success or -ERANGE on write when the range check fails.
1018f461d2dcSChristoph Hellwig  */
1019f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write,
102032927393SChristoph Hellwig 			  void *buffer, size_t *lenp, loff_t *ppos)
1021f461d2dcSChristoph Hellwig {
1022f461d2dcSChristoph Hellwig 	struct do_proc_douintvec_minmax_conv_param param = {
1023f461d2dcSChristoph Hellwig 		.min = (unsigned int *) table->extra1,
1024f461d2dcSChristoph Hellwig 		.max = (unsigned int *) table->extra2,
1025f461d2dcSChristoph Hellwig 	};
1026f461d2dcSChristoph Hellwig 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
1027f461d2dcSChristoph Hellwig 				 do_proc_douintvec_minmax_conv, &param);
1028f461d2dcSChristoph Hellwig }
1029f461d2dcSChristoph Hellwig 
1030cb944413SEric Dumazet /**
1031cb944413SEric Dumazet  * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1032cb944413SEric Dumazet  * @table: the sysctl table
1033cb944413SEric Dumazet  * @write: %TRUE if this is a write to the sysctl file
1034cb944413SEric Dumazet  * @buffer: the user buffer
1035cb944413SEric Dumazet  * @lenp: the size of the user buffer
1036cb944413SEric Dumazet  * @ppos: file position
1037cb944413SEric Dumazet  *
1038cb944413SEric Dumazet  * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1039cb944413SEric Dumazet  * values from/to the user buffer, treated as an ASCII string. Negative
1040cb944413SEric Dumazet  * strings are not allowed.
1041cb944413SEric Dumazet  *
1042cb944413SEric Dumazet  * This routine will ensure the values are within the range specified by
1043cb944413SEric Dumazet  * table->extra1 (min) and table->extra2 (max).
1044cb944413SEric Dumazet  *
1045cb944413SEric Dumazet  * Returns 0 on success or an error on write when the range check fails.
1046cb944413SEric Dumazet  */
1047cb944413SEric Dumazet int proc_dou8vec_minmax(struct ctl_table *table, int write,
1048cb944413SEric Dumazet 			void *buffer, size_t *lenp, loff_t *ppos)
1049cb944413SEric Dumazet {
1050cb944413SEric Dumazet 	struct ctl_table tmp;
1051cb944413SEric Dumazet 	unsigned int min = 0, max = 255U, val;
1052cb944413SEric Dumazet 	u8 *data = table->data;
1053cb944413SEric Dumazet 	struct do_proc_douintvec_minmax_conv_param param = {
1054cb944413SEric Dumazet 		.min = &min,
1055cb944413SEric Dumazet 		.max = &max,
1056cb944413SEric Dumazet 	};
1057cb944413SEric Dumazet 	int res;
1058cb944413SEric Dumazet 
1059cb944413SEric Dumazet 	/* Do not support arrays yet. */
1060cb944413SEric Dumazet 	if (table->maxlen != sizeof(u8))
1061cb944413SEric Dumazet 		return -EINVAL;
1062cb944413SEric Dumazet 
1063cb944413SEric Dumazet 	if (table->extra1) {
1064cb944413SEric Dumazet 		min = *(unsigned int *) table->extra1;
1065cb944413SEric Dumazet 		if (min > 255U)
1066cb944413SEric Dumazet 			return -EINVAL;
1067cb944413SEric Dumazet 	}
1068cb944413SEric Dumazet 	if (table->extra2) {
1069cb944413SEric Dumazet 		max = *(unsigned int *) table->extra2;
1070cb944413SEric Dumazet 		if (max > 255U)
1071cb944413SEric Dumazet 			return -EINVAL;
1072cb944413SEric Dumazet 	}
1073cb944413SEric Dumazet 
1074cb944413SEric Dumazet 	tmp = *table;
1075cb944413SEric Dumazet 
1076cb944413SEric Dumazet 	tmp.maxlen = sizeof(val);
1077cb944413SEric Dumazet 	tmp.data = &val;
1078cb944413SEric Dumazet 	val = *data;
1079cb944413SEric Dumazet 	res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1080cb944413SEric Dumazet 				do_proc_douintvec_minmax_conv, &param);
1081cb944413SEric Dumazet 	if (res)
1082cb944413SEric Dumazet 		return res;
1083cb944413SEric Dumazet 	if (write)
1084cb944413SEric Dumazet 		*data = val;
1085cb944413SEric Dumazet 	return 0;
1086cb944413SEric Dumazet }
1087cb944413SEric Dumazet EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1088cb944413SEric Dumazet 
1089f461d2dcSChristoph Hellwig static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1090f461d2dcSChristoph Hellwig 					unsigned int *valp,
1091f461d2dcSChristoph Hellwig 					int write, void *data)
1092f461d2dcSChristoph Hellwig {
1093f461d2dcSChristoph Hellwig 	if (write) {
1094f461d2dcSChristoph Hellwig 		unsigned int val;
1095f461d2dcSChristoph Hellwig 
1096f461d2dcSChristoph Hellwig 		val = round_pipe_size(*lvalp);
1097f461d2dcSChristoph Hellwig 		if (val == 0)
1098f461d2dcSChristoph Hellwig 			return -EINVAL;
1099f461d2dcSChristoph Hellwig 
1100f461d2dcSChristoph Hellwig 		*valp = val;
1101f461d2dcSChristoph Hellwig 	} else {
1102f461d2dcSChristoph Hellwig 		unsigned int val = *valp;
1103f461d2dcSChristoph Hellwig 		*lvalp = (unsigned long) val;
1104f461d2dcSChristoph Hellwig 	}
1105f461d2dcSChristoph Hellwig 
1106f461d2dcSChristoph Hellwig 	return 0;
1107f461d2dcSChristoph Hellwig }
1108f461d2dcSChristoph Hellwig 
1109f461d2dcSChristoph Hellwig static int proc_dopipe_max_size(struct ctl_table *table, int write,
111032927393SChristoph Hellwig 				void *buffer, size_t *lenp, loff_t *ppos)
1111f461d2dcSChristoph Hellwig {
1112f461d2dcSChristoph Hellwig 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
1113f461d2dcSChristoph Hellwig 				 do_proc_dopipe_max_size_conv, NULL);
1114f461d2dcSChristoph Hellwig }
1115f461d2dcSChristoph Hellwig 
1116f461d2dcSChristoph Hellwig static void validate_coredump_safety(void)
1117f461d2dcSChristoph Hellwig {
1118f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP
1119f461d2dcSChristoph Hellwig 	if (suid_dumpable == SUID_DUMP_ROOT &&
1120f461d2dcSChristoph Hellwig 	    core_pattern[0] != '/' && core_pattern[0] != '|') {
1121f461d2dcSChristoph Hellwig 		printk(KERN_WARNING
1122f461d2dcSChristoph Hellwig "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1123f461d2dcSChristoph Hellwig "Pipe handler or fully qualified core dump path required.\n"
1124f461d2dcSChristoph Hellwig "Set kernel.core_pattern before fs.suid_dumpable.\n"
1125f461d2dcSChristoph Hellwig 		);
1126f461d2dcSChristoph Hellwig 	}
1127f461d2dcSChristoph Hellwig #endif
1128f461d2dcSChristoph Hellwig }
1129f461d2dcSChristoph Hellwig 
1130f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
113132927393SChristoph Hellwig 		void *buffer, size_t *lenp, loff_t *ppos)
1132f461d2dcSChristoph Hellwig {
1133f461d2dcSChristoph Hellwig 	int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1134f461d2dcSChristoph Hellwig 	if (!error)
1135f461d2dcSChristoph Hellwig 		validate_coredump_safety();
1136f461d2dcSChristoph Hellwig 	return error;
1137f461d2dcSChristoph Hellwig }
1138f461d2dcSChristoph Hellwig 
1139f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP
1140f461d2dcSChristoph Hellwig static int proc_dostring_coredump(struct ctl_table *table, int write,
114132927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1142f461d2dcSChristoph Hellwig {
1143f461d2dcSChristoph Hellwig 	int error = proc_dostring(table, write, buffer, lenp, ppos);
1144f461d2dcSChristoph Hellwig 	if (!error)
1145f461d2dcSChristoph Hellwig 		validate_coredump_safety();
1146f461d2dcSChristoph Hellwig 	return error;
1147f461d2dcSChristoph Hellwig }
1148f461d2dcSChristoph Hellwig #endif
1149f461d2dcSChristoph Hellwig 
1150f461d2dcSChristoph Hellwig #ifdef CONFIG_MAGIC_SYSRQ
1151f461d2dcSChristoph Hellwig static int sysrq_sysctl_handler(struct ctl_table *table, int write,
115232927393SChristoph Hellwig 				void *buffer, size_t *lenp, loff_t *ppos)
1153f461d2dcSChristoph Hellwig {
1154f461d2dcSChristoph Hellwig 	int tmp, ret;
1155f461d2dcSChristoph Hellwig 
1156f461d2dcSChristoph Hellwig 	tmp = sysrq_mask();
1157f461d2dcSChristoph Hellwig 
1158f461d2dcSChristoph Hellwig 	ret = __do_proc_dointvec(&tmp, table, write, buffer,
1159f461d2dcSChristoph Hellwig 			       lenp, ppos, NULL, NULL);
1160f461d2dcSChristoph Hellwig 	if (ret || !write)
1161f461d2dcSChristoph Hellwig 		return ret;
1162f461d2dcSChristoph Hellwig 
1163f461d2dcSChristoph Hellwig 	if (write)
1164f461d2dcSChristoph Hellwig 		sysrq_toggle_support(tmp);
1165f461d2dcSChristoph Hellwig 
1166f461d2dcSChristoph Hellwig 	return 0;
1167f461d2dcSChristoph Hellwig }
1168f461d2dcSChristoph Hellwig #endif
1169f461d2dcSChristoph Hellwig 
117032927393SChristoph Hellwig static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
117132927393SChristoph Hellwig 		int write, void *buffer, size_t *lenp, loff_t *ppos,
117232927393SChristoph Hellwig 		unsigned long convmul, unsigned long convdiv)
1173f461d2dcSChristoph Hellwig {
1174f461d2dcSChristoph Hellwig 	unsigned long *i, *min, *max;
1175f461d2dcSChristoph Hellwig 	int vleft, first = 1, err = 0;
1176f461d2dcSChristoph Hellwig 	size_t left;
117732927393SChristoph Hellwig 	char *p;
1178f461d2dcSChristoph Hellwig 
1179f461d2dcSChristoph Hellwig 	if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1180f461d2dcSChristoph Hellwig 		*lenp = 0;
1181f461d2dcSChristoph Hellwig 		return 0;
1182f461d2dcSChristoph Hellwig 	}
1183f461d2dcSChristoph Hellwig 
1184f461d2dcSChristoph Hellwig 	i = (unsigned long *) data;
1185f461d2dcSChristoph Hellwig 	min = (unsigned long *) table->extra1;
1186f461d2dcSChristoph Hellwig 	max = (unsigned long *) table->extra2;
1187f461d2dcSChristoph Hellwig 	vleft = table->maxlen / sizeof(unsigned long);
1188f461d2dcSChristoph Hellwig 	left = *lenp;
1189f461d2dcSChristoph Hellwig 
1190f461d2dcSChristoph Hellwig 	if (write) {
1191f461d2dcSChristoph Hellwig 		if (proc_first_pos_non_zero_ignore(ppos, table))
1192f461d2dcSChristoph Hellwig 			goto out;
1193f461d2dcSChristoph Hellwig 
1194f461d2dcSChristoph Hellwig 		if (left > PAGE_SIZE - 1)
1195f461d2dcSChristoph Hellwig 			left = PAGE_SIZE - 1;
119632927393SChristoph Hellwig 		p = buffer;
1197f461d2dcSChristoph Hellwig 	}
1198f461d2dcSChristoph Hellwig 
1199f461d2dcSChristoph Hellwig 	for (; left && vleft--; i++, first = 0) {
1200f461d2dcSChristoph Hellwig 		unsigned long val;
1201f461d2dcSChristoph Hellwig 
1202f461d2dcSChristoph Hellwig 		if (write) {
1203f461d2dcSChristoph Hellwig 			bool neg;
1204f461d2dcSChristoph Hellwig 
1205f461d2dcSChristoph Hellwig 			left -= proc_skip_spaces(&p);
1206f461d2dcSChristoph Hellwig 			if (!left)
1207f461d2dcSChristoph Hellwig 				break;
1208f461d2dcSChristoph Hellwig 
1209f461d2dcSChristoph Hellwig 			err = proc_get_long(&p, &left, &val, &neg,
1210f461d2dcSChristoph Hellwig 					     proc_wspace_sep,
1211f461d2dcSChristoph Hellwig 					     sizeof(proc_wspace_sep), NULL);
1212f461d2dcSChristoph Hellwig 			if (err)
1213f461d2dcSChristoph Hellwig 				break;
1214f461d2dcSChristoph Hellwig 			if (neg)
1215f461d2dcSChristoph Hellwig 				continue;
1216f461d2dcSChristoph Hellwig 			val = convmul * val / convdiv;
1217f461d2dcSChristoph Hellwig 			if ((min && val < *min) || (max && val > *max)) {
1218f461d2dcSChristoph Hellwig 				err = -EINVAL;
1219f461d2dcSChristoph Hellwig 				break;
1220f461d2dcSChristoph Hellwig 			}
1221f461d2dcSChristoph Hellwig 			*i = val;
1222f461d2dcSChristoph Hellwig 		} else {
1223f461d2dcSChristoph Hellwig 			val = convdiv * (*i) / convmul;
122432927393SChristoph Hellwig 			if (!first)
122532927393SChristoph Hellwig 				proc_put_char(&buffer, &left, '\t');
122632927393SChristoph Hellwig 			proc_put_long(&buffer, &left, val, false);
1227f461d2dcSChristoph Hellwig 		}
1228f461d2dcSChristoph Hellwig 	}
1229f461d2dcSChristoph Hellwig 
1230f461d2dcSChristoph Hellwig 	if (!write && !first && left && !err)
123132927393SChristoph Hellwig 		proc_put_char(&buffer, &left, '\n');
1232f461d2dcSChristoph Hellwig 	if (write && !err)
1233f461d2dcSChristoph Hellwig 		left -= proc_skip_spaces(&p);
123432927393SChristoph Hellwig 	if (write && first)
1235f461d2dcSChristoph Hellwig 		return err ? : -EINVAL;
1236f461d2dcSChristoph Hellwig 	*lenp -= left;
1237f461d2dcSChristoph Hellwig out:
1238f461d2dcSChristoph Hellwig 	*ppos += *lenp;
1239f461d2dcSChristoph Hellwig 	return err;
1240f461d2dcSChristoph Hellwig }
1241f461d2dcSChristoph Hellwig 
1242f461d2dcSChristoph Hellwig static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
124332927393SChristoph Hellwig 		void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1244f461d2dcSChristoph Hellwig 		unsigned long convdiv)
1245f461d2dcSChristoph Hellwig {
1246f461d2dcSChristoph Hellwig 	return __do_proc_doulongvec_minmax(table->data, table, write,
1247f461d2dcSChristoph Hellwig 			buffer, lenp, ppos, convmul, convdiv);
1248f461d2dcSChristoph Hellwig }
1249f461d2dcSChristoph Hellwig 
1250f461d2dcSChristoph Hellwig /**
1251f461d2dcSChristoph Hellwig  * proc_doulongvec_minmax - read a vector of long integers with min/max values
1252f461d2dcSChristoph Hellwig  * @table: the sysctl table
1253f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1254f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1255f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1256f461d2dcSChristoph Hellwig  * @ppos: file position
1257f461d2dcSChristoph Hellwig  *
1258f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1259f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1260f461d2dcSChristoph Hellwig  *
1261f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1262f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max).
1263f461d2dcSChristoph Hellwig  *
1264f461d2dcSChristoph Hellwig  * Returns 0 on success.
1265f461d2dcSChristoph Hellwig  */
1266f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write,
126732927393SChristoph Hellwig 			   void *buffer, size_t *lenp, loff_t *ppos)
1268f461d2dcSChristoph Hellwig {
1269f461d2dcSChristoph Hellwig     return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1270f461d2dcSChristoph Hellwig }
1271f461d2dcSChristoph Hellwig 
1272f461d2dcSChristoph Hellwig /**
1273f461d2dcSChristoph Hellwig  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1274f461d2dcSChristoph Hellwig  * @table: the sysctl table
1275f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1276f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1277f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1278f461d2dcSChristoph Hellwig  * @ppos: file position
1279f461d2dcSChristoph Hellwig  *
1280f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1281f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string. The values
1282f461d2dcSChristoph Hellwig  * are treated as milliseconds, and converted to jiffies when they are stored.
1283f461d2dcSChristoph Hellwig  *
1284f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1285f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max).
1286f461d2dcSChristoph Hellwig  *
1287f461d2dcSChristoph Hellwig  * Returns 0 on success.
1288f461d2dcSChristoph Hellwig  */
1289f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
129032927393SChristoph Hellwig 				      void *buffer, size_t *lenp, loff_t *ppos)
1291f461d2dcSChristoph Hellwig {
1292f461d2dcSChristoph Hellwig     return do_proc_doulongvec_minmax(table, write, buffer,
1293f461d2dcSChristoph Hellwig 				     lenp, ppos, HZ, 1000l);
1294f461d2dcSChristoph Hellwig }
1295f461d2dcSChristoph Hellwig 
1296f461d2dcSChristoph Hellwig 
1297f461d2dcSChristoph Hellwig static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1298f461d2dcSChristoph Hellwig 					 int *valp,
1299f461d2dcSChristoph Hellwig 					 int write, void *data)
1300f461d2dcSChristoph Hellwig {
1301f461d2dcSChristoph Hellwig 	if (write) {
1302f461d2dcSChristoph Hellwig 		if (*lvalp > INT_MAX / HZ)
1303f461d2dcSChristoph Hellwig 			return 1;
1304f461d2dcSChristoph Hellwig 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1305f461d2dcSChristoph Hellwig 	} else {
1306f461d2dcSChristoph Hellwig 		int val = *valp;
1307f461d2dcSChristoph Hellwig 		unsigned long lval;
1308f461d2dcSChristoph Hellwig 		if (val < 0) {
1309f461d2dcSChristoph Hellwig 			*negp = true;
1310f461d2dcSChristoph Hellwig 			lval = -(unsigned long)val;
1311f461d2dcSChristoph Hellwig 		} else {
1312f461d2dcSChristoph Hellwig 			*negp = false;
1313f461d2dcSChristoph Hellwig 			lval = (unsigned long)val;
1314f461d2dcSChristoph Hellwig 		}
1315f461d2dcSChristoph Hellwig 		*lvalp = lval / HZ;
1316f461d2dcSChristoph Hellwig 	}
1317f461d2dcSChristoph Hellwig 	return 0;
1318f461d2dcSChristoph Hellwig }
1319f461d2dcSChristoph Hellwig 
1320f461d2dcSChristoph Hellwig static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1321f461d2dcSChristoph Hellwig 						int *valp,
1322f461d2dcSChristoph Hellwig 						int write, void *data)
1323f461d2dcSChristoph Hellwig {
1324f461d2dcSChristoph Hellwig 	if (write) {
1325f461d2dcSChristoph Hellwig 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1326f461d2dcSChristoph Hellwig 			return 1;
1327f461d2dcSChristoph Hellwig 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1328f461d2dcSChristoph Hellwig 	} else {
1329f461d2dcSChristoph Hellwig 		int val = *valp;
1330f461d2dcSChristoph Hellwig 		unsigned long lval;
1331f461d2dcSChristoph Hellwig 		if (val < 0) {
1332f461d2dcSChristoph Hellwig 			*negp = true;
1333f461d2dcSChristoph Hellwig 			lval = -(unsigned long)val;
1334f461d2dcSChristoph Hellwig 		} else {
1335f461d2dcSChristoph Hellwig 			*negp = false;
1336f461d2dcSChristoph Hellwig 			lval = (unsigned long)val;
1337f461d2dcSChristoph Hellwig 		}
1338f461d2dcSChristoph Hellwig 		*lvalp = jiffies_to_clock_t(lval);
1339f461d2dcSChristoph Hellwig 	}
1340f461d2dcSChristoph Hellwig 	return 0;
1341f461d2dcSChristoph Hellwig }
1342f461d2dcSChristoph Hellwig 
1343f461d2dcSChristoph Hellwig static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1344f461d2dcSChristoph Hellwig 					    int *valp,
1345f461d2dcSChristoph Hellwig 					    int write, void *data)
1346f461d2dcSChristoph Hellwig {
1347f461d2dcSChristoph Hellwig 	if (write) {
1348f461d2dcSChristoph Hellwig 		unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1349f461d2dcSChristoph Hellwig 
1350f461d2dcSChristoph Hellwig 		if (jif > INT_MAX)
1351f461d2dcSChristoph Hellwig 			return 1;
1352f461d2dcSChristoph Hellwig 		*valp = (int)jif;
1353f461d2dcSChristoph Hellwig 	} else {
1354f461d2dcSChristoph Hellwig 		int val = *valp;
1355f461d2dcSChristoph Hellwig 		unsigned long lval;
1356f461d2dcSChristoph Hellwig 		if (val < 0) {
1357f461d2dcSChristoph Hellwig 			*negp = true;
1358f461d2dcSChristoph Hellwig 			lval = -(unsigned long)val;
1359f461d2dcSChristoph Hellwig 		} else {
1360f461d2dcSChristoph Hellwig 			*negp = false;
1361f461d2dcSChristoph Hellwig 			lval = (unsigned long)val;
1362f461d2dcSChristoph Hellwig 		}
1363f461d2dcSChristoph Hellwig 		*lvalp = jiffies_to_msecs(lval);
1364f461d2dcSChristoph Hellwig 	}
1365f461d2dcSChristoph Hellwig 	return 0;
1366f461d2dcSChristoph Hellwig }
1367f461d2dcSChristoph Hellwig 
1368f461d2dcSChristoph Hellwig /**
1369f461d2dcSChristoph Hellwig  * proc_dointvec_jiffies - read a vector of integers as seconds
1370f461d2dcSChristoph Hellwig  * @table: the sysctl table
1371f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1372f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1373f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1374f461d2dcSChristoph Hellwig  * @ppos: file position
1375f461d2dcSChristoph Hellwig  *
1376f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1377f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1378f461d2dcSChristoph Hellwig  * The values read are assumed to be in seconds, and are converted into
1379f461d2dcSChristoph Hellwig  * jiffies.
1380f461d2dcSChristoph Hellwig  *
1381f461d2dcSChristoph Hellwig  * Returns 0 on success.
1382f461d2dcSChristoph Hellwig  */
1383f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write,
138432927393SChristoph Hellwig 			  void *buffer, size_t *lenp, loff_t *ppos)
1385f461d2dcSChristoph Hellwig {
1386f461d2dcSChristoph Hellwig     return do_proc_dointvec(table,write,buffer,lenp,ppos,
1387f461d2dcSChristoph Hellwig 		    	    do_proc_dointvec_jiffies_conv,NULL);
1388f461d2dcSChristoph Hellwig }
1389f461d2dcSChristoph Hellwig 
1390f461d2dcSChristoph Hellwig /**
1391f461d2dcSChristoph Hellwig  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1392f461d2dcSChristoph Hellwig  * @table: the sysctl table
1393f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1394f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1395f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1396f461d2dcSChristoph Hellwig  * @ppos: pointer to the file position
1397f461d2dcSChristoph Hellwig  *
1398f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1399f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1400f461d2dcSChristoph Hellwig  * The values read are assumed to be in 1/USER_HZ seconds, and
1401f461d2dcSChristoph Hellwig  * are converted into jiffies.
1402f461d2dcSChristoph Hellwig  *
1403f461d2dcSChristoph Hellwig  * Returns 0 on success.
1404f461d2dcSChristoph Hellwig  */
1405f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
140632927393SChristoph Hellwig 				 void *buffer, size_t *lenp, loff_t *ppos)
1407f461d2dcSChristoph Hellwig {
1408f461d2dcSChristoph Hellwig     return do_proc_dointvec(table,write,buffer,lenp,ppos,
1409f461d2dcSChristoph Hellwig 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
1410f461d2dcSChristoph Hellwig }
1411f461d2dcSChristoph Hellwig 
1412f461d2dcSChristoph Hellwig /**
1413f461d2dcSChristoph Hellwig  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1414f461d2dcSChristoph Hellwig  * @table: the sysctl table
1415f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1416f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1417f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1418f461d2dcSChristoph Hellwig  * @ppos: file position
1419f461d2dcSChristoph Hellwig  * @ppos: the current position in the file
1420f461d2dcSChristoph Hellwig  *
1421f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1422f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1423f461d2dcSChristoph Hellwig  * The values read are assumed to be in 1/1000 seconds, and
1424f461d2dcSChristoph Hellwig  * are converted into jiffies.
1425f461d2dcSChristoph Hellwig  *
1426f461d2dcSChristoph Hellwig  * Returns 0 on success.
1427f461d2dcSChristoph Hellwig  */
142832927393SChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
142932927393SChristoph Hellwig 		size_t *lenp, loff_t *ppos)
1430f461d2dcSChristoph Hellwig {
1431f461d2dcSChristoph Hellwig 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
1432f461d2dcSChristoph Hellwig 				do_proc_dointvec_ms_jiffies_conv, NULL);
1433f461d2dcSChristoph Hellwig }
1434f461d2dcSChristoph Hellwig 
143532927393SChristoph Hellwig static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
143632927393SChristoph Hellwig 		size_t *lenp, loff_t *ppos)
1437f461d2dcSChristoph Hellwig {
1438f461d2dcSChristoph Hellwig 	struct pid *new_pid;
1439f461d2dcSChristoph Hellwig 	pid_t tmp;
1440f461d2dcSChristoph Hellwig 	int r;
1441f461d2dcSChristoph Hellwig 
1442f461d2dcSChristoph Hellwig 	tmp = pid_vnr(cad_pid);
1443f461d2dcSChristoph Hellwig 
1444f461d2dcSChristoph Hellwig 	r = __do_proc_dointvec(&tmp, table, write, buffer,
1445f461d2dcSChristoph Hellwig 			       lenp, ppos, NULL, NULL);
1446f461d2dcSChristoph Hellwig 	if (r || !write)
1447f461d2dcSChristoph Hellwig 		return r;
1448f461d2dcSChristoph Hellwig 
1449f461d2dcSChristoph Hellwig 	new_pid = find_get_pid(tmp);
1450f461d2dcSChristoph Hellwig 	if (!new_pid)
1451f461d2dcSChristoph Hellwig 		return -ESRCH;
1452f461d2dcSChristoph Hellwig 
1453f461d2dcSChristoph Hellwig 	put_pid(xchg(&cad_pid, new_pid));
1454f461d2dcSChristoph Hellwig 	return 0;
1455f461d2dcSChristoph Hellwig }
1456f461d2dcSChristoph Hellwig 
1457f461d2dcSChristoph Hellwig /**
1458f461d2dcSChristoph Hellwig  * proc_do_large_bitmap - read/write from/to a large bitmap
1459f461d2dcSChristoph Hellwig  * @table: the sysctl table
1460f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1461f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1462f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1463f461d2dcSChristoph Hellwig  * @ppos: file position
1464f461d2dcSChristoph Hellwig  *
1465f461d2dcSChristoph Hellwig  * The bitmap is stored at table->data and the bitmap length (in bits)
1466f461d2dcSChristoph Hellwig  * in table->maxlen.
1467f461d2dcSChristoph Hellwig  *
1468f461d2dcSChristoph Hellwig  * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1469f461d2dcSChristoph Hellwig  * large bitmaps may be represented in a compact manner. Writing into
1470f461d2dcSChristoph Hellwig  * the file will clear the bitmap then update it with the given input.
1471f461d2dcSChristoph Hellwig  *
1472f461d2dcSChristoph Hellwig  * Returns 0 on success.
1473f461d2dcSChristoph Hellwig  */
1474f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write,
147532927393SChristoph Hellwig 			 void *buffer, size_t *lenp, loff_t *ppos)
1476f461d2dcSChristoph Hellwig {
1477f461d2dcSChristoph Hellwig 	int err = 0;
1478f461d2dcSChristoph Hellwig 	bool first = 1;
1479f461d2dcSChristoph Hellwig 	size_t left = *lenp;
1480f461d2dcSChristoph Hellwig 	unsigned long bitmap_len = table->maxlen;
1481f461d2dcSChristoph Hellwig 	unsigned long *bitmap = *(unsigned long **) table->data;
1482f461d2dcSChristoph Hellwig 	unsigned long *tmp_bitmap = NULL;
1483f461d2dcSChristoph Hellwig 	char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1484f461d2dcSChristoph Hellwig 
1485f461d2dcSChristoph Hellwig 	if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1486f461d2dcSChristoph Hellwig 		*lenp = 0;
1487f461d2dcSChristoph Hellwig 		return 0;
1488f461d2dcSChristoph Hellwig 	}
1489f461d2dcSChristoph Hellwig 
1490f461d2dcSChristoph Hellwig 	if (write) {
149132927393SChristoph Hellwig 		char *p = buffer;
1492f461d2dcSChristoph Hellwig 		size_t skipped = 0;
1493f461d2dcSChristoph Hellwig 
1494f461d2dcSChristoph Hellwig 		if (left > PAGE_SIZE - 1) {
1495f461d2dcSChristoph Hellwig 			left = PAGE_SIZE - 1;
1496f461d2dcSChristoph Hellwig 			/* How much of the buffer we'll skip this pass */
1497f461d2dcSChristoph Hellwig 			skipped = *lenp - left;
1498f461d2dcSChristoph Hellwig 		}
1499f461d2dcSChristoph Hellwig 
1500f461d2dcSChristoph Hellwig 		tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
150132927393SChristoph Hellwig 		if (!tmp_bitmap)
1502f461d2dcSChristoph Hellwig 			return -ENOMEM;
1503f461d2dcSChristoph Hellwig 		proc_skip_char(&p, &left, '\n');
1504f461d2dcSChristoph Hellwig 		while (!err && left) {
1505f461d2dcSChristoph Hellwig 			unsigned long val_a, val_b;
1506f461d2dcSChristoph Hellwig 			bool neg;
1507f461d2dcSChristoph Hellwig 			size_t saved_left;
1508f461d2dcSChristoph Hellwig 
1509f461d2dcSChristoph Hellwig 			/* In case we stop parsing mid-number, we can reset */
1510f461d2dcSChristoph Hellwig 			saved_left = left;
1511f461d2dcSChristoph Hellwig 			err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1512f461d2dcSChristoph Hellwig 					     sizeof(tr_a), &c);
1513f461d2dcSChristoph Hellwig 			/*
1514f461d2dcSChristoph Hellwig 			 * If we consumed the entirety of a truncated buffer or
1515f461d2dcSChristoph Hellwig 			 * only one char is left (may be a "-"), then stop here,
1516f461d2dcSChristoph Hellwig 			 * reset, & come back for more.
1517f461d2dcSChristoph Hellwig 			 */
1518f461d2dcSChristoph Hellwig 			if ((left <= 1) && skipped) {
1519f461d2dcSChristoph Hellwig 				left = saved_left;
1520f461d2dcSChristoph Hellwig 				break;
1521f461d2dcSChristoph Hellwig 			}
1522f461d2dcSChristoph Hellwig 
1523f461d2dcSChristoph Hellwig 			if (err)
1524f461d2dcSChristoph Hellwig 				break;
1525f461d2dcSChristoph Hellwig 			if (val_a >= bitmap_len || neg) {
1526f461d2dcSChristoph Hellwig 				err = -EINVAL;
1527f461d2dcSChristoph Hellwig 				break;
1528f461d2dcSChristoph Hellwig 			}
1529f461d2dcSChristoph Hellwig 
1530f461d2dcSChristoph Hellwig 			val_b = val_a;
1531f461d2dcSChristoph Hellwig 			if (left) {
1532f461d2dcSChristoph Hellwig 				p++;
1533f461d2dcSChristoph Hellwig 				left--;
1534f461d2dcSChristoph Hellwig 			}
1535f461d2dcSChristoph Hellwig 
1536f461d2dcSChristoph Hellwig 			if (c == '-') {
1537f461d2dcSChristoph Hellwig 				err = proc_get_long(&p, &left, &val_b,
1538f461d2dcSChristoph Hellwig 						     &neg, tr_b, sizeof(tr_b),
1539f461d2dcSChristoph Hellwig 						     &c);
1540f461d2dcSChristoph Hellwig 				/*
1541f461d2dcSChristoph Hellwig 				 * If we consumed all of a truncated buffer or
1542f461d2dcSChristoph Hellwig 				 * then stop here, reset, & come back for more.
1543f461d2dcSChristoph Hellwig 				 */
1544f461d2dcSChristoph Hellwig 				if (!left && skipped) {
1545f461d2dcSChristoph Hellwig 					left = saved_left;
1546f461d2dcSChristoph Hellwig 					break;
1547f461d2dcSChristoph Hellwig 				}
1548f461d2dcSChristoph Hellwig 
1549f461d2dcSChristoph Hellwig 				if (err)
1550f461d2dcSChristoph Hellwig 					break;
1551f461d2dcSChristoph Hellwig 				if (val_b >= bitmap_len || neg ||
1552f461d2dcSChristoph Hellwig 				    val_a > val_b) {
1553f461d2dcSChristoph Hellwig 					err = -EINVAL;
1554f461d2dcSChristoph Hellwig 					break;
1555f461d2dcSChristoph Hellwig 				}
1556f461d2dcSChristoph Hellwig 				if (left) {
1557f461d2dcSChristoph Hellwig 					p++;
1558f461d2dcSChristoph Hellwig 					left--;
1559f461d2dcSChristoph Hellwig 				}
1560f461d2dcSChristoph Hellwig 			}
1561f461d2dcSChristoph Hellwig 
1562f461d2dcSChristoph Hellwig 			bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1563f461d2dcSChristoph Hellwig 			first = 0;
1564f461d2dcSChristoph Hellwig 			proc_skip_char(&p, &left, '\n');
1565f461d2dcSChristoph Hellwig 		}
1566f461d2dcSChristoph Hellwig 		left += skipped;
1567f461d2dcSChristoph Hellwig 	} else {
1568f461d2dcSChristoph Hellwig 		unsigned long bit_a, bit_b = 0;
1569f461d2dcSChristoph Hellwig 
1570f461d2dcSChristoph Hellwig 		while (left) {
1571f461d2dcSChristoph Hellwig 			bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1572f461d2dcSChristoph Hellwig 			if (bit_a >= bitmap_len)
1573f461d2dcSChristoph Hellwig 				break;
1574f461d2dcSChristoph Hellwig 			bit_b = find_next_zero_bit(bitmap, bitmap_len,
1575f461d2dcSChristoph Hellwig 						   bit_a + 1) - 1;
1576f461d2dcSChristoph Hellwig 
157732927393SChristoph Hellwig 			if (!first)
157832927393SChristoph Hellwig 				proc_put_char(&buffer, &left, ',');
157932927393SChristoph Hellwig 			proc_put_long(&buffer, &left, bit_a, false);
1580f461d2dcSChristoph Hellwig 			if (bit_a != bit_b) {
158132927393SChristoph Hellwig 				proc_put_char(&buffer, &left, '-');
158232927393SChristoph Hellwig 				proc_put_long(&buffer, &left, bit_b, false);
1583f461d2dcSChristoph Hellwig 			}
1584f461d2dcSChristoph Hellwig 
1585f461d2dcSChristoph Hellwig 			first = 0; bit_b++;
1586f461d2dcSChristoph Hellwig 		}
158732927393SChristoph Hellwig 		proc_put_char(&buffer, &left, '\n');
1588f461d2dcSChristoph Hellwig 	}
1589f461d2dcSChristoph Hellwig 
1590f461d2dcSChristoph Hellwig 	if (!err) {
1591f461d2dcSChristoph Hellwig 		if (write) {
1592f461d2dcSChristoph Hellwig 			if (*ppos)
1593f461d2dcSChristoph Hellwig 				bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1594f461d2dcSChristoph Hellwig 			else
1595f461d2dcSChristoph Hellwig 				bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1596f461d2dcSChristoph Hellwig 		}
1597f461d2dcSChristoph Hellwig 		*lenp -= left;
1598f461d2dcSChristoph Hellwig 		*ppos += *lenp;
1599f461d2dcSChristoph Hellwig 	}
1600f461d2dcSChristoph Hellwig 
1601f461d2dcSChristoph Hellwig 	bitmap_free(tmp_bitmap);
1602f461d2dcSChristoph Hellwig 	return err;
1603f461d2dcSChristoph Hellwig }
1604f461d2dcSChristoph Hellwig 
1605f461d2dcSChristoph Hellwig #else /* CONFIG_PROC_SYSCTL */
1606f461d2dcSChristoph Hellwig 
1607f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write,
160832927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1609f461d2dcSChristoph Hellwig {
1610f461d2dcSChristoph Hellwig 	return -ENOSYS;
1611f461d2dcSChristoph Hellwig }
1612f461d2dcSChristoph Hellwig 
1613f461d2dcSChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write,
161432927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1615f461d2dcSChristoph Hellwig {
1616f461d2dcSChristoph Hellwig 	return -ENOSYS;
1617f461d2dcSChristoph Hellwig }
1618f461d2dcSChristoph Hellwig 
1619f461d2dcSChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write,
162032927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1621f461d2dcSChristoph Hellwig {
1622f461d2dcSChristoph Hellwig 	return -ENOSYS;
1623f461d2dcSChristoph Hellwig }
1624f461d2dcSChristoph Hellwig 
1625f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write,
162632927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1627f461d2dcSChristoph Hellwig {
1628f461d2dcSChristoph Hellwig 	return -ENOSYS;
1629f461d2dcSChristoph Hellwig }
1630f461d2dcSChristoph Hellwig 
1631f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write,
163232927393SChristoph Hellwig 			  void *buffer, size_t *lenp, loff_t *ppos)
1633f461d2dcSChristoph Hellwig {
1634f461d2dcSChristoph Hellwig 	return -ENOSYS;
1635f461d2dcSChristoph Hellwig }
1636f461d2dcSChristoph Hellwig 
1637cb944413SEric Dumazet int proc_dou8vec_minmax(struct ctl_table *table, int write,
1638cb944413SEric Dumazet 			void *buffer, size_t *lenp, loff_t *ppos)
1639cb944413SEric Dumazet {
1640cb944413SEric Dumazet 	return -ENOSYS;
1641cb944413SEric Dumazet }
1642cb944413SEric Dumazet 
1643f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write,
164432927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1645f461d2dcSChristoph Hellwig {
1646f461d2dcSChristoph Hellwig 	return -ENOSYS;
1647f461d2dcSChristoph Hellwig }
1648f461d2dcSChristoph Hellwig 
1649f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
165032927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1651f461d2dcSChristoph Hellwig {
1652f461d2dcSChristoph Hellwig 	return -ENOSYS;
1653f461d2dcSChristoph Hellwig }
1654f461d2dcSChristoph Hellwig 
1655f461d2dcSChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
165632927393SChristoph Hellwig 			     void *buffer, size_t *lenp, loff_t *ppos)
1657f461d2dcSChristoph Hellwig {
1658f461d2dcSChristoph Hellwig 	return -ENOSYS;
1659f461d2dcSChristoph Hellwig }
1660f461d2dcSChristoph Hellwig 
1661f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write,
166232927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1663f461d2dcSChristoph Hellwig {
1664f461d2dcSChristoph Hellwig 	return -ENOSYS;
1665f461d2dcSChristoph Hellwig }
1666f461d2dcSChristoph Hellwig 
1667f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
166832927393SChristoph Hellwig 				      void *buffer, size_t *lenp, loff_t *ppos)
1669f461d2dcSChristoph Hellwig {
1670f461d2dcSChristoph Hellwig 	return -ENOSYS;
1671f461d2dcSChristoph Hellwig }
1672f461d2dcSChristoph Hellwig 
1673f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write,
167432927393SChristoph Hellwig 			 void *buffer, size_t *lenp, loff_t *ppos)
1675f461d2dcSChristoph Hellwig {
1676f461d2dcSChristoph Hellwig 	return -ENOSYS;
1677f461d2dcSChristoph Hellwig }
1678f461d2dcSChristoph Hellwig 
1679f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */
1680f461d2dcSChristoph Hellwig 
1681f461d2dcSChristoph Hellwig #if defined(CONFIG_SYSCTL)
1682f461d2dcSChristoph Hellwig int proc_do_static_key(struct ctl_table *table, int write,
168332927393SChristoph Hellwig 		       void *buffer, size_t *lenp, loff_t *ppos)
1684f461d2dcSChristoph Hellwig {
1685f461d2dcSChristoph Hellwig 	struct static_key *key = (struct static_key *)table->data;
1686f461d2dcSChristoph Hellwig 	static DEFINE_MUTEX(static_key_mutex);
1687f461d2dcSChristoph Hellwig 	int val, ret;
1688f461d2dcSChristoph Hellwig 	struct ctl_table tmp = {
1689f461d2dcSChristoph Hellwig 		.data   = &val,
1690f461d2dcSChristoph Hellwig 		.maxlen = sizeof(val),
1691f461d2dcSChristoph Hellwig 		.mode   = table->mode,
1692f461d2dcSChristoph Hellwig 		.extra1 = SYSCTL_ZERO,
1693f461d2dcSChristoph Hellwig 		.extra2 = SYSCTL_ONE,
1694f461d2dcSChristoph Hellwig 	};
1695f461d2dcSChristoph Hellwig 
1696f461d2dcSChristoph Hellwig 	if (write && !capable(CAP_SYS_ADMIN))
1697f461d2dcSChristoph Hellwig 		return -EPERM;
1698f461d2dcSChristoph Hellwig 
1699f461d2dcSChristoph Hellwig 	mutex_lock(&static_key_mutex);
1700f461d2dcSChristoph Hellwig 	val = static_key_enabled(key);
1701f461d2dcSChristoph Hellwig 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1702f461d2dcSChristoph Hellwig 	if (write && !ret) {
1703f461d2dcSChristoph Hellwig 		if (val)
1704f461d2dcSChristoph Hellwig 			static_key_enable(key);
1705f461d2dcSChristoph Hellwig 		else
1706f461d2dcSChristoph Hellwig 			static_key_disable(key);
1707f461d2dcSChristoph Hellwig 	}
1708f461d2dcSChristoph Hellwig 	mutex_unlock(&static_key_mutex);
1709f461d2dcSChristoph Hellwig 	return ret;
1710f461d2dcSChristoph Hellwig }
1711f461d2dcSChristoph Hellwig 
1712d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
17132bba22c5SMike Galbraith 	{
17142bba22c5SMike Galbraith 		.procname	= "sched_child_runs_first",
17152bba22c5SMike Galbraith 		.data		= &sysctl_sched_child_runs_first,
17162bba22c5SMike Galbraith 		.maxlen		= sizeof(unsigned int),
17172bba22c5SMike Galbraith 		.mode		= 0644,
17186d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
17192bba22c5SMike Galbraith 	},
17201d1c2509SPeter Zijlstra #ifdef CONFIG_SCHEDSTATS
17211d1c2509SPeter Zijlstra 	{
17221d1c2509SPeter Zijlstra 		.procname	= "sched_schedstats",
17231d1c2509SPeter Zijlstra 		.data		= NULL,
17241d1c2509SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
17251d1c2509SPeter Zijlstra 		.mode		= 0644,
17261d1c2509SPeter Zijlstra 		.proc_handler	= sysctl_schedstats,
17271d1c2509SPeter Zijlstra 		.extra1		= SYSCTL_ZERO,
17281d1c2509SPeter Zijlstra 		.extra2		= SYSCTL_ONE,
17291d1c2509SPeter Zijlstra 	},
17301d1c2509SPeter Zijlstra #endif /* CONFIG_SCHEDSTATS */
1731*0cd7c741SPeter Zijlstra #ifdef CONFIG_TASK_DELAY_ACCT
1732*0cd7c741SPeter Zijlstra 	{
1733*0cd7c741SPeter Zijlstra 		.procname	= "task_delayacct",
1734*0cd7c741SPeter Zijlstra 		.data		= NULL,
1735*0cd7c741SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
1736*0cd7c741SPeter Zijlstra 		.mode		= 0644,
1737*0cd7c741SPeter Zijlstra 		.proc_handler	= sysctl_delayacct,
1738*0cd7c741SPeter Zijlstra 		.extra1		= SYSCTL_ZERO,
1739*0cd7c741SPeter Zijlstra 		.extra2		= SYSCTL_ONE,
1740*0cd7c741SPeter Zijlstra 	},
1741*0cd7c741SPeter Zijlstra #endif /* CONFIG_TASK_DELAY_ACCT */
1742b7cc6ec7SMel Gorman #ifdef CONFIG_NUMA_BALANCING
17433a7053b3SMel Gorman 	{
174454a43d54SAndi Kleen 		.procname	= "numa_balancing",
174554a43d54SAndi Kleen 		.data		= NULL, /* filled in by handler */
174654a43d54SAndi Kleen 		.maxlen		= sizeof(unsigned int),
174754a43d54SAndi Kleen 		.mode		= 0644,
174854a43d54SAndi Kleen 		.proc_handler	= sysctl_numa_balancing,
1749eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1750eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
175154a43d54SAndi Kleen 	},
1752cbee9f88SPeter Zijlstra #endif /* CONFIG_NUMA_BALANCING */
17531799e35dSIngo Molnar 	{
17549f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
17559f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
17569f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
17579f0c1e56SPeter Zijlstra 		.mode		= 0644,
17586d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
17599f0c1e56SPeter Zijlstra 	},
17609f0c1e56SPeter Zijlstra 	{
17619f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
17629f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
17639f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
17649f0c1e56SPeter Zijlstra 		.mode		= 0644,
17656d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
17669f0c1e56SPeter Zijlstra 	},
1767ce0dbbbbSClark Williams 	{
1768b4098bfcSPeter Zijlstra 		.procname	= "sched_deadline_period_max_us",
1769b4098bfcSPeter Zijlstra 		.data		= &sysctl_sched_dl_period_max,
1770b4098bfcSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
1771b4098bfcSPeter Zijlstra 		.mode		= 0644,
1772b4098bfcSPeter Zijlstra 		.proc_handler	= proc_dointvec,
1773b4098bfcSPeter Zijlstra 	},
1774b4098bfcSPeter Zijlstra 	{
1775b4098bfcSPeter Zijlstra 		.procname	= "sched_deadline_period_min_us",
1776b4098bfcSPeter Zijlstra 		.data		= &sysctl_sched_dl_period_min,
1777b4098bfcSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
1778b4098bfcSPeter Zijlstra 		.mode		= 0644,
1779b4098bfcSPeter Zijlstra 		.proc_handler	= proc_dointvec,
1780b4098bfcSPeter Zijlstra 	},
1781b4098bfcSPeter Zijlstra 	{
1782ce0dbbbbSClark Williams 		.procname	= "sched_rr_timeslice_ms",
1783975e155eSShile Zhang 		.data		= &sysctl_sched_rr_timeslice,
1784ce0dbbbbSClark Williams 		.maxlen		= sizeof(int),
1785ce0dbbbbSClark Williams 		.mode		= 0644,
1786ce0dbbbbSClark Williams 		.proc_handler	= sched_rr_handler,
1787ce0dbbbbSClark Williams 	},
1788e8f14172SPatrick Bellasi #ifdef CONFIG_UCLAMP_TASK
1789e8f14172SPatrick Bellasi 	{
1790e8f14172SPatrick Bellasi 		.procname	= "sched_util_clamp_min",
1791e8f14172SPatrick Bellasi 		.data		= &sysctl_sched_uclamp_util_min,
1792e8f14172SPatrick Bellasi 		.maxlen		= sizeof(unsigned int),
1793e8f14172SPatrick Bellasi 		.mode		= 0644,
1794e8f14172SPatrick Bellasi 		.proc_handler	= sysctl_sched_uclamp_handler,
1795e8f14172SPatrick Bellasi 	},
1796e8f14172SPatrick Bellasi 	{
1797e8f14172SPatrick Bellasi 		.procname	= "sched_util_clamp_max",
1798e8f14172SPatrick Bellasi 		.data		= &sysctl_sched_uclamp_util_max,
1799e8f14172SPatrick Bellasi 		.maxlen		= sizeof(unsigned int),
1800e8f14172SPatrick Bellasi 		.mode		= 0644,
1801e8f14172SPatrick Bellasi 		.proc_handler	= sysctl_sched_uclamp_handler,
1802e8f14172SPatrick Bellasi 	},
180313685c4aSQais Yousef 	{
180413685c4aSQais Yousef 		.procname	= "sched_util_clamp_min_rt_default",
180513685c4aSQais Yousef 		.data		= &sysctl_sched_uclamp_util_min_rt_default,
180613685c4aSQais Yousef 		.maxlen		= sizeof(unsigned int),
180713685c4aSQais Yousef 		.mode		= 0644,
180813685c4aSQais Yousef 		.proc_handler	= sysctl_sched_uclamp_handler,
180913685c4aSQais Yousef 	},
1810e8f14172SPatrick Bellasi #endif
18115091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP
18125091faa4SMike Galbraith 	{
18135091faa4SMike Galbraith 		.procname	= "sched_autogroup_enabled",
18145091faa4SMike Galbraith 		.data		= &sysctl_sched_autogroup_enabled,
18155091faa4SMike Galbraith 		.maxlen		= sizeof(unsigned int),
18165091faa4SMike Galbraith 		.mode		= 0644,
18171747b21fSYong Zhang 		.proc_handler	= proc_dointvec_minmax,
1818eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1819eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
18205091faa4SMike Galbraith 	},
18215091faa4SMike Galbraith #endif
1822ec12cb7fSPaul Turner #ifdef CONFIG_CFS_BANDWIDTH
1823ec12cb7fSPaul Turner 	{
1824ec12cb7fSPaul Turner 		.procname	= "sched_cfs_bandwidth_slice_us",
1825ec12cb7fSPaul Turner 		.data		= &sysctl_sched_cfs_bandwidth_slice,
1826ec12cb7fSPaul Turner 		.maxlen		= sizeof(unsigned int),
1827ec12cb7fSPaul Turner 		.mode		= 0644,
1828ec12cb7fSPaul Turner 		.proc_handler	= proc_dointvec_minmax,
1829eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
1830ec12cb7fSPaul Turner 	},
1831ec12cb7fSPaul Turner #endif
18328d5d0cfbSQuentin Perret #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
18338d5d0cfbSQuentin Perret 	{
18348d5d0cfbSQuentin Perret 		.procname	= "sched_energy_aware",
18358d5d0cfbSQuentin Perret 		.data		= &sysctl_sched_energy_aware,
18368d5d0cfbSQuentin Perret 		.maxlen		= sizeof(unsigned int),
18378d5d0cfbSQuentin Perret 		.mode		= 0644,
18388d5d0cfbSQuentin Perret 		.proc_handler	= sched_energy_aware_handler,
1839eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1840eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
18418d5d0cfbSQuentin Perret 	},
18428d5d0cfbSQuentin Perret #endif
1843f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
1844f20786ffSPeter Zijlstra 	{
1845f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
1846f20786ffSPeter Zijlstra 		.data		= &prove_locking,
1847f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
1848f20786ffSPeter Zijlstra 		.mode		= 0644,
18496d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1850f20786ffSPeter Zijlstra 	},
1851f20786ffSPeter Zijlstra #endif
1852f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
1853f20786ffSPeter Zijlstra 	{
1854f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
1855f20786ffSPeter Zijlstra 		.data		= &lock_stat,
1856f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
1857f20786ffSPeter Zijlstra 		.mode		= 0644,
18586d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1859f20786ffSPeter Zijlstra 	},
1860f20786ffSPeter Zijlstra #endif
186177e54a1fSIngo Molnar 	{
18621da177e4SLinus Torvalds 		.procname	= "panic",
18631da177e4SLinus Torvalds 		.data		= &panic_timeout,
18641da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
18651da177e4SLinus Torvalds 		.mode		= 0644,
18666d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
18671da177e4SLinus Torvalds 	},
1868046d662fSAlex Kelly #ifdef CONFIG_COREDUMP
18691da177e4SLinus Torvalds 	{
18701da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
18711da177e4SLinus Torvalds 		.data		= &core_uses_pid,
18721da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
18731da177e4SLinus Torvalds 		.mode		= 0644,
18746d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
18751da177e4SLinus Torvalds 	},
18761da177e4SLinus Torvalds 	{
18771da177e4SLinus Torvalds 		.procname	= "core_pattern",
18781da177e4SLinus Torvalds 		.data		= core_pattern,
187971ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
18801da177e4SLinus Torvalds 		.mode		= 0644,
188154b50199SKees Cook 		.proc_handler	= proc_dostring_coredump,
18821da177e4SLinus Torvalds 	},
1883a293980cSNeil Horman 	{
1884a293980cSNeil Horman 		.procname	= "core_pipe_limit",
1885a293980cSNeil Horman 		.data		= &core_pipe_limit,
1886a293980cSNeil Horman 		.maxlen		= sizeof(unsigned int),
1887a293980cSNeil Horman 		.mode		= 0644,
18886d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1889a293980cSNeil Horman 	},
1890046d662fSAlex Kelly #endif
189134f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
18921da177e4SLinus Torvalds 	{
18931da177e4SLinus Torvalds 		.procname	= "tainted",
189425ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
189534f5a398STheodore Ts'o 		.mode		= 0644,
18966d456111SEric W. Biederman 		.proc_handler	= proc_taint,
18971da177e4SLinus Torvalds 	},
1898f4aacea2SKees Cook 	{
1899f4aacea2SKees Cook 		.procname	= "sysctl_writes_strict",
1900f4aacea2SKees Cook 		.data		= &sysctl_writes_strict,
1901f4aacea2SKees Cook 		.maxlen		= sizeof(int),
1902f4aacea2SKees Cook 		.mode		= 0644,
1903f4aacea2SKees Cook 		.proc_handler	= proc_dointvec_minmax,
1904f4aacea2SKees Cook 		.extra1		= &neg_one,
1905eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
1906f4aacea2SKees Cook 	},
190734f5a398STheodore Ts'o #endif
19089745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
19099745512cSArjan van de Ven 	{
19109745512cSArjan van de Ven 		.procname	= "latencytop",
19119745512cSArjan van de Ven 		.data		= &latencytop_enabled,
19129745512cSArjan van de Ven 		.maxlen		= sizeof(int),
19139745512cSArjan van de Ven 		.mode		= 0644,
1914cb251765SMel Gorman 		.proc_handler	= sysctl_latencytop,
19159745512cSArjan van de Ven 	},
19169745512cSArjan van de Ven #endif
19171da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
19181da177e4SLinus Torvalds 	{
19191da177e4SLinus Torvalds 		.procname	= "real-root-dev",
19201da177e4SLinus Torvalds 		.data		= &real_root_dev,
19211da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
19221da177e4SLinus Torvalds 		.mode		= 0644,
19236d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19241da177e4SLinus Torvalds 	},
19251da177e4SLinus Torvalds #endif
192645807a1dSIngo Molnar 	{
192745807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
192845807a1dSIngo Molnar 		.data		= &print_fatal_signals,
192945807a1dSIngo Molnar 		.maxlen		= sizeof(int),
193045807a1dSIngo Molnar 		.mode		= 0644,
19316d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
193245807a1dSIngo Molnar 	},
193372c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
19341da177e4SLinus Torvalds 	{
19351da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
19361da177e4SLinus Torvalds 		.data		= reboot_command,
19371da177e4SLinus Torvalds 		.maxlen		= 256,
19381da177e4SLinus Torvalds 		.mode		= 0644,
19396d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
19401da177e4SLinus Torvalds 	},
19411da177e4SLinus Torvalds 	{
19421da177e4SLinus Torvalds 		.procname	= "stop-a",
19431da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
19441da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19451da177e4SLinus Torvalds 		.mode		= 0644,
19466d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19471da177e4SLinus Torvalds 	},
19481da177e4SLinus Torvalds 	{
19491da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
19501da177e4SLinus Torvalds 		.data		= &scons_pwroff,
19511da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19521da177e4SLinus Torvalds 		.mode		= 0644,
19536d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19541da177e4SLinus Torvalds 	},
19551da177e4SLinus Torvalds #endif
19560871420fSDavid S. Miller #ifdef CONFIG_SPARC64
19570871420fSDavid S. Miller 	{
19580871420fSDavid S. Miller 		.procname	= "tsb-ratio",
19590871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
19600871420fSDavid S. Miller 		.maxlen		= sizeof (int),
19610871420fSDavid S. Miller 		.mode		= 0644,
19626d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19630871420fSDavid S. Miller 	},
19640871420fSDavid S. Miller #endif
1965b67114dbSHelge Deller #ifdef CONFIG_PARISC
19661da177e4SLinus Torvalds 	{
19671da177e4SLinus Torvalds 		.procname	= "soft-power",
19681da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
19691da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19701da177e4SLinus Torvalds 		.mode		= 0644,
19716d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19721da177e4SLinus Torvalds 	},
1973bf14e3b9SVineet Gupta #endif
1974bf14e3b9SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
19751da177e4SLinus Torvalds 	{
19761da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
19771da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
19781da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19791da177e4SLinus Torvalds 		.mode		= 0644,
19806d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19811da177e4SLinus Torvalds 	},
19821da177e4SLinus Torvalds #endif
19831da177e4SLinus Torvalds 	{
19841da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
19851da177e4SLinus Torvalds 		.data		= &C_A_D,
19861da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
19871da177e4SLinus Torvalds 		.mode		= 0644,
19886d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19891da177e4SLinus Torvalds 	},
1990606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
1991b0fc494fSSteven Rostedt 	{
1992b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
1993b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
1994b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
1995b0fc494fSSteven Rostedt 		.mode		= 0644,
19966d456111SEric W. Biederman 		.proc_handler	= ftrace_enable_sysctl,
1997b0fc494fSSteven Rostedt 	},
1998b0fc494fSSteven Rostedt #endif
1999f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
2000f38f1d2aSSteven Rostedt 	{
2001f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
2002f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
2003f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
2004f38f1d2aSSteven Rostedt 		.mode		= 0644,
20056d456111SEric W. Biederman 		.proc_handler	= stack_trace_sysctl,
2006f38f1d2aSSteven Rostedt 	},
2007f38f1d2aSSteven Rostedt #endif
2008944ac425SSteven Rostedt #ifdef CONFIG_TRACING
2009944ac425SSteven Rostedt 	{
20103299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
2011944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
2012944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
2013944ac425SSteven Rostedt 		.mode		= 0644,
20146d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2015944ac425SSteven Rostedt 	},
2016de7edd31SSteven Rostedt (Red Hat) 	{
2017de7edd31SSteven Rostedt (Red Hat) 		.procname	= "traceoff_on_warning",
2018de7edd31SSteven Rostedt (Red Hat) 		.data		= &__disable_trace_on_warning,
2019de7edd31SSteven Rostedt (Red Hat) 		.maxlen		= sizeof(__disable_trace_on_warning),
2020de7edd31SSteven Rostedt (Red Hat) 		.mode		= 0644,
2021de7edd31SSteven Rostedt (Red Hat) 		.proc_handler	= proc_dointvec,
2022de7edd31SSteven Rostedt (Red Hat) 	},
20230daa2302SSteven Rostedt (Red Hat) 	{
20240daa2302SSteven Rostedt (Red Hat) 		.procname	= "tracepoint_printk",
20250daa2302SSteven Rostedt (Red Hat) 		.data		= &tracepoint_printk,
20260daa2302SSteven Rostedt (Red Hat) 		.maxlen		= sizeof(tracepoint_printk),
20270daa2302SSteven Rostedt (Red Hat) 		.mode		= 0644,
202842391745SSteven Rostedt (Red Hat) 		.proc_handler	= tracepoint_printk_sysctl,
20290daa2302SSteven Rostedt (Red Hat) 	},
2030944ac425SSteven Rostedt #endif
20312965faa5SDave Young #ifdef CONFIG_KEXEC_CORE
20327984754bSKees Cook 	{
20337984754bSKees Cook 		.procname	= "kexec_load_disabled",
20347984754bSKees Cook 		.data		= &kexec_load_disabled,
20357984754bSKees Cook 		.maxlen		= sizeof(int),
20367984754bSKees Cook 		.mode		= 0644,
20377984754bSKees Cook 		/* only handle a transition from default "0" to "1" */
20387984754bSKees Cook 		.proc_handler	= proc_dointvec_minmax,
2039eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2040eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
20417984754bSKees Cook 	},
20427984754bSKees Cook #endif
2043a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
20441da177e4SLinus Torvalds 	{
20451da177e4SLinus Torvalds 		.procname	= "modprobe",
20461da177e4SLinus Torvalds 		.data		= &modprobe_path,
20471da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
20481da177e4SLinus Torvalds 		.mode		= 0644,
20496d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
20501da177e4SLinus Torvalds 	},
20513d43321bSKees Cook 	{
20523d43321bSKees Cook 		.procname	= "modules_disabled",
20533d43321bSKees Cook 		.data		= &modules_disabled,
20543d43321bSKees Cook 		.maxlen		= sizeof(int),
20553d43321bSKees Cook 		.mode		= 0644,
20563d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
20576d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2058eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2059eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
20603d43321bSKees Cook 	},
20611da177e4SLinus Torvalds #endif
206286d56134SMichael Marineau #ifdef CONFIG_UEVENT_HELPER
20631da177e4SLinus Torvalds 	{
20641da177e4SLinus Torvalds 		.procname	= "hotplug",
2065312c004dSKay Sievers 		.data		= &uevent_helper,
2066312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
20671da177e4SLinus Torvalds 		.mode		= 0644,
20686d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
20691da177e4SLinus Torvalds 	},
207086d56134SMichael Marineau #endif
20711da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
20721da177e4SLinus Torvalds 	{
20731da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
20741da177e4SLinus Torvalds 		.data		= &sg_big_buff,
20751da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
20761da177e4SLinus Torvalds 		.mode		= 0444,
20776d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
20781da177e4SLinus Torvalds 	},
20791da177e4SLinus Torvalds #endif
20801da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
20811da177e4SLinus Torvalds 	{
20821da177e4SLinus Torvalds 		.procname	= "acct",
20831da177e4SLinus Torvalds 		.data		= &acct_parm,
20841da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
20851da177e4SLinus Torvalds 		.mode		= 0644,
20866d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
20871da177e4SLinus Torvalds 	},
20881da177e4SLinus Torvalds #endif
20891da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
20901da177e4SLinus Torvalds 	{
20911da177e4SLinus Torvalds 		.procname	= "sysrq",
2092eaee4172SDmitry Safonov 		.data		= NULL,
20931da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
20941da177e4SLinus Torvalds 		.mode		= 0644,
209597f5f0cdSDmitry Torokhov 		.proc_handler	= sysrq_sysctl_handler,
20961da177e4SLinus Torvalds 	},
20971da177e4SLinus Torvalds #endif
2098d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
20991da177e4SLinus Torvalds 	{
21001da177e4SLinus Torvalds 		.procname	= "cad_pid",
21019ec52099SCedric Le Goater 		.data		= NULL,
21021da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
21031da177e4SLinus Torvalds 		.mode		= 0600,
21046d456111SEric W. Biederman 		.proc_handler	= proc_do_cad_pid,
21051da177e4SLinus Torvalds 	},
2106d6f8ff73SRandy Dunlap #endif
21071da177e4SLinus Torvalds 	{
21081da177e4SLinus Torvalds 		.procname	= "threads-max",
210916db3d3fSHeinrich Schuchardt 		.data		= NULL,
21101da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21111da177e4SLinus Torvalds 		.mode		= 0644,
211216db3d3fSHeinrich Schuchardt 		.proc_handler	= sysctl_max_threads,
21131da177e4SLinus Torvalds 	},
21141da177e4SLinus Torvalds 	{
21151da177e4SLinus Torvalds 		.procname	= "random",
21161da177e4SLinus Torvalds 		.mode		= 0555,
21171da177e4SLinus Torvalds 		.child		= random_table,
21181da177e4SLinus Torvalds 	},
21191da177e4SLinus Torvalds 	{
212017f60a7dSEric Paris 		.procname	= "usermodehelper",
212117f60a7dSEric Paris 		.mode		= 0555,
212217f60a7dSEric Paris 		.child		= usermodehelper_table,
212317f60a7dSEric Paris 	},
2124ceb18132SLuis R. Rodriguez #ifdef CONFIG_FW_LOADER_USER_HELPER
2125ceb18132SLuis R. Rodriguez 	{
2126ceb18132SLuis R. Rodriguez 		.procname	= "firmware_config",
2127ceb18132SLuis R. Rodriguez 		.mode		= 0555,
2128ceb18132SLuis R. Rodriguez 		.child		= firmware_config_table,
2129ceb18132SLuis R. Rodriguez 	},
2130ceb18132SLuis R. Rodriguez #endif
213117f60a7dSEric Paris 	{
21321da177e4SLinus Torvalds 		.procname	= "overflowuid",
21331da177e4SLinus Torvalds 		.data		= &overflowuid,
21341da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21351da177e4SLinus Torvalds 		.mode		= 0644,
21366d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
21371da177e4SLinus Torvalds 		.extra1		= &minolduid,
21381da177e4SLinus Torvalds 		.extra2		= &maxolduid,
21391da177e4SLinus Torvalds 	},
21401da177e4SLinus Torvalds 	{
21411da177e4SLinus Torvalds 		.procname	= "overflowgid",
21421da177e4SLinus Torvalds 		.data		= &overflowgid,
21431da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21441da177e4SLinus Torvalds 		.mode		= 0644,
21456d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
21461da177e4SLinus Torvalds 		.extra1		= &minolduid,
21471da177e4SLinus Torvalds 		.extra2		= &maxolduid,
21481da177e4SLinus Torvalds 	},
2149347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
21501da177e4SLinus Torvalds 	{
21511da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
2152ab3c68eeSHeiko Carstens 		.data		= &show_unhandled_signals,
21531da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21541da177e4SLinus Torvalds 		.mode		= 0644,
21556d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
21561da177e4SLinus Torvalds 	},
21571da177e4SLinus Torvalds #endif
215860c958d8SGuilherme G. Piccoli #ifdef CONFIG_SMP
215960c958d8SGuilherme G. Piccoli 	{
216060c958d8SGuilherme G. Piccoli 		.procname	= "oops_all_cpu_backtrace",
216160c958d8SGuilherme G. Piccoli 		.data		= &sysctl_oops_all_cpu_backtrace,
216260c958d8SGuilherme G. Piccoli 		.maxlen		= sizeof(int),
216360c958d8SGuilherme G. Piccoli 		.mode		= 0644,
216460c958d8SGuilherme G. Piccoli 		.proc_handler	= proc_dointvec_minmax,
216560c958d8SGuilherme G. Piccoli 		.extra1		= SYSCTL_ZERO,
216660c958d8SGuilherme G. Piccoli 		.extra2		= SYSCTL_ONE,
216760c958d8SGuilherme G. Piccoli 	},
216860c958d8SGuilherme G. Piccoli #endif /* CONFIG_SMP */
21691da177e4SLinus Torvalds 	{
21701da177e4SLinus Torvalds 		.procname	= "pid_max",
21711da177e4SLinus Torvalds 		.data		= &pid_max,
21721da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
21731da177e4SLinus Torvalds 		.mode		= 0644,
21746d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
21751da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
21761da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
21771da177e4SLinus Torvalds 	},
21781da177e4SLinus Torvalds 	{
21791da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
21801da177e4SLinus Torvalds 		.data		= &panic_on_oops,
21811da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21821da177e4SLinus Torvalds 		.mode		= 0644,
21836d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
21841da177e4SLinus Torvalds 	},
218581c9d43fSFeng Tang 	{
218681c9d43fSFeng Tang 		.procname	= "panic_print",
218781c9d43fSFeng Tang 		.data		= &panic_print,
218881c9d43fSFeng Tang 		.maxlen		= sizeof(unsigned long),
218981c9d43fSFeng Tang 		.mode		= 0644,
219081c9d43fSFeng Tang 		.proc_handler	= proc_doulongvec_minmax,
219181c9d43fSFeng Tang 	},
21927ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
21937ef3d2fdSJoe Perches 	{
21947ef3d2fdSJoe Perches 		.procname	= "printk",
21957ef3d2fdSJoe Perches 		.data		= &console_loglevel,
21967ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
21977ef3d2fdSJoe Perches 		.mode		= 0644,
21986d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
21997ef3d2fdSJoe Perches 	},
22001da177e4SLinus Torvalds 	{
22011da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
2202717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
22031da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
22041da177e4SLinus Torvalds 		.mode		= 0644,
22056d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
22061da177e4SLinus Torvalds 	},
22071da177e4SLinus Torvalds 	{
22081da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
2209717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
22101da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
22111da177e4SLinus Torvalds 		.mode		= 0644,
22126d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22131da177e4SLinus Torvalds 	},
2214af91322eSDave Young 	{
2215af91322eSDave Young 		.procname	= "printk_delay",
2216af91322eSDave Young 		.data		= &printk_delay_msec,
2217af91322eSDave Young 		.maxlen		= sizeof(int),
2218af91322eSDave Young 		.mode		= 0644,
22196d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2220eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2221af91322eSDave Young 		.extra2		= &ten_thousand,
2222af91322eSDave Young 	},
22231da177e4SLinus Torvalds 	{
2224750afe7bSBorislav Petkov 		.procname	= "printk_devkmsg",
2225750afe7bSBorislav Petkov 		.data		= devkmsg_log_str,
2226750afe7bSBorislav Petkov 		.maxlen		= DEVKMSG_STR_MAX_SIZE,
2227750afe7bSBorislav Petkov 		.mode		= 0644,
2228750afe7bSBorislav Petkov 		.proc_handler	= devkmsg_sysctl_set_loglvl,
2229750afe7bSBorislav Petkov 	},
2230750afe7bSBorislav Petkov 	{
2231eaf06b24SDan Rosenberg 		.procname	= "dmesg_restrict",
2232eaf06b24SDan Rosenberg 		.data		= &dmesg_restrict,
2233eaf06b24SDan Rosenberg 		.maxlen		= sizeof(int),
2234eaf06b24SDan Rosenberg 		.mode		= 0644,
2235620f6e8eSKees Cook 		.proc_handler	= proc_dointvec_minmax_sysadmin,
2236eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2237eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2238eaf06b24SDan Rosenberg 	},
2239455cd5abSDan Rosenberg 	{
2240455cd5abSDan Rosenberg 		.procname	= "kptr_restrict",
2241455cd5abSDan Rosenberg 		.data		= &kptr_restrict,
2242455cd5abSDan Rosenberg 		.maxlen		= sizeof(int),
2243455cd5abSDan Rosenberg 		.mode		= 0644,
2244620f6e8eSKees Cook 		.proc_handler	= proc_dointvec_minmax_sysadmin,
2245eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2246455cd5abSDan Rosenberg 		.extra2		= &two,
2247455cd5abSDan Rosenberg 	},
2248df6e61d4SJoe Perches #endif
2249eaf06b24SDan Rosenberg 	{
22501da177e4SLinus Torvalds 		.procname	= "ngroups_max",
22511da177e4SLinus Torvalds 		.data		= &ngroups_max,
22521da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
22531da177e4SLinus Torvalds 		.mode		= 0444,
22546d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22551da177e4SLinus Torvalds 	},
225673efc039SDan Ballard 	{
225773efc039SDan Ballard 		.procname	= "cap_last_cap",
225873efc039SDan Ballard 		.data		= (void *)&cap_last_cap,
225973efc039SDan Ballard 		.maxlen		= sizeof(int),
226073efc039SDan Ballard 		.mode		= 0444,
226173efc039SDan Ballard 		.proc_handler	= proc_dointvec,
226273efc039SDan Ballard 	},
226358687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR)
2264504d7cf1SDon Zickus 	{
226558687acbSDon Zickus 		.procname       = "watchdog",
22663c00ea82SFrederic Weisbecker 		.data		= &watchdog_user_enabled,
2267504d7cf1SDon Zickus 		.maxlen		= sizeof(int),
2268504d7cf1SDon Zickus 		.mode		= 0644,
2269195daf66SUlrich Obergfell 		.proc_handler   = proc_watchdog,
2270eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2271eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
227258687acbSDon Zickus 	},
227358687acbSDon Zickus 	{
227458687acbSDon Zickus 		.procname	= "watchdog_thresh",
2275586692a5SMandeep Singh Baines 		.data		= &watchdog_thresh,
227658687acbSDon Zickus 		.maxlen		= sizeof(int),
227758687acbSDon Zickus 		.mode		= 0644,
2278195daf66SUlrich Obergfell 		.proc_handler	= proc_watchdog_thresh,
2279eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
228058687acbSDon Zickus 		.extra2		= &sixty,
2281504d7cf1SDon Zickus 	},
22822508ce18SDon Zickus 	{
2283195daf66SUlrich Obergfell 		.procname       = "nmi_watchdog",
22847feeb9cdSThomas Gleixner 		.data		= &nmi_watchdog_user_enabled,
2285195daf66SUlrich Obergfell 		.maxlen		= sizeof(int),
228651d4052bSThomas Gleixner 		.mode		= NMI_WATCHDOG_SYSCTL_PERM,
2287195daf66SUlrich Obergfell 		.proc_handler   = proc_nmi_watchdog,
2288eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2289eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2290195daf66SUlrich Obergfell 	},
2291195daf66SUlrich Obergfell 	{
229205a4a952SNicholas Piggin 		.procname	= "watchdog_cpumask",
229305a4a952SNicholas Piggin 		.data		= &watchdog_cpumask_bits,
229405a4a952SNicholas Piggin 		.maxlen		= NR_CPUS,
229505a4a952SNicholas Piggin 		.mode		= 0644,
229605a4a952SNicholas Piggin 		.proc_handler	= proc_watchdog_cpumask,
229705a4a952SNicholas Piggin 	},
229805a4a952SNicholas Piggin #ifdef CONFIG_SOFTLOCKUP_DETECTOR
229905a4a952SNicholas Piggin 	{
2300195daf66SUlrich Obergfell 		.procname       = "soft_watchdog",
23017feeb9cdSThomas Gleixner 		.data		= &soft_watchdog_user_enabled,
2302195daf66SUlrich Obergfell 		.maxlen		= sizeof(int),
2303195daf66SUlrich Obergfell 		.mode		= 0644,
2304195daf66SUlrich Obergfell 		.proc_handler   = proc_soft_watchdog,
2305eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2306eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2307195daf66SUlrich Obergfell 	},
2308195daf66SUlrich Obergfell 	{
23092508ce18SDon Zickus 		.procname	= "softlockup_panic",
23102508ce18SDon Zickus 		.data		= &softlockup_panic,
23112508ce18SDon Zickus 		.maxlen		= sizeof(int),
23122508ce18SDon Zickus 		.mode		= 0644,
23132508ce18SDon Zickus 		.proc_handler	= proc_dointvec_minmax,
2314eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2315eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
23162508ce18SDon Zickus 	},
2317ed235875SAaron Tomlin #ifdef CONFIG_SMP
2318ed235875SAaron Tomlin 	{
2319ed235875SAaron Tomlin 		.procname	= "softlockup_all_cpu_backtrace",
2320ed235875SAaron Tomlin 		.data		= &sysctl_softlockup_all_cpu_backtrace,
2321ed235875SAaron Tomlin 		.maxlen		= sizeof(int),
2322ed235875SAaron Tomlin 		.mode		= 0644,
2323ed235875SAaron Tomlin 		.proc_handler	= proc_dointvec_minmax,
2324eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2325eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2326ed235875SAaron Tomlin 	},
232705a4a952SNicholas Piggin #endif /* CONFIG_SMP */
232805a4a952SNicholas Piggin #endif
232905a4a952SNicholas Piggin #ifdef CONFIG_HARDLOCKUP_DETECTOR
233005a4a952SNicholas Piggin 	{
233105a4a952SNicholas Piggin 		.procname	= "hardlockup_panic",
233205a4a952SNicholas Piggin 		.data		= &hardlockup_panic,
233305a4a952SNicholas Piggin 		.maxlen		= sizeof(int),
233405a4a952SNicholas Piggin 		.mode		= 0644,
233505a4a952SNicholas Piggin 		.proc_handler	= proc_dointvec_minmax,
2336eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2337eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
233805a4a952SNicholas Piggin 	},
233905a4a952SNicholas Piggin #ifdef CONFIG_SMP
234055537871SJiri Kosina 	{
234155537871SJiri Kosina 		.procname	= "hardlockup_all_cpu_backtrace",
234255537871SJiri Kosina 		.data		= &sysctl_hardlockup_all_cpu_backtrace,
234355537871SJiri Kosina 		.maxlen		= sizeof(int),
234455537871SJiri Kosina 		.mode		= 0644,
234555537871SJiri Kosina 		.proc_handler	= proc_dointvec_minmax,
2346eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2347eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
234855537871SJiri Kosina 	},
2349ed235875SAaron Tomlin #endif /* CONFIG_SMP */
23505dc30558SDon Zickus #endif
235105a4a952SNicholas Piggin #endif
235205a4a952SNicholas Piggin 
23535dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
23545dc30558SDon Zickus 	{
23555dc30558SDon Zickus 		.procname       = "unknown_nmi_panic",
23565dc30558SDon Zickus 		.data           = &unknown_nmi_panic,
23575dc30558SDon Zickus 		.maxlen         = sizeof (int),
23585dc30558SDon Zickus 		.mode           = 0644,
23595dc30558SDon Zickus 		.proc_handler   = proc_dointvec,
23605dc30558SDon Zickus 	},
2361504d7cf1SDon Zickus #endif
2362b6522fa4SXiaoming Ni 
2363b6522fa4SXiaoming Ni #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2364b6522fa4SXiaoming Ni 	defined(CONFIG_DEBUG_STACKOVERFLOW)
2365b6522fa4SXiaoming Ni 	{
2366b6522fa4SXiaoming Ni 		.procname	= "panic_on_stackoverflow",
2367b6522fa4SXiaoming Ni 		.data		= &sysctl_panic_on_stackoverflow,
2368b6522fa4SXiaoming Ni 		.maxlen		= sizeof(int),
2369b6522fa4SXiaoming Ni 		.mode		= 0644,
2370b6522fa4SXiaoming Ni 		.proc_handler	= proc_dointvec,
2371b6522fa4SXiaoming Ni 	},
2372b6522fa4SXiaoming Ni #endif
23731da177e4SLinus Torvalds #if defined(CONFIG_X86)
23741da177e4SLinus Torvalds 	{
23758da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
23768da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
23778da5addaSDon Zickus 		.maxlen		= sizeof(int),
23788da5addaSDon Zickus 		.mode		= 0644,
23796d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
23808da5addaSDon Zickus 	},
23818da5addaSDon Zickus 	{
23825211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
23835211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
23845211a242SKurt Garloff 		.maxlen		= sizeof(int),
23855211a242SKurt Garloff 		.mode		= 0644,
23866d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
23875211a242SKurt Garloff 	},
23885211a242SKurt Garloff 	{
23891da177e4SLinus Torvalds 		.procname	= "bootloader_type",
23901da177e4SLinus Torvalds 		.data		= &bootloader_type,
23911da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
23921da177e4SLinus Torvalds 		.mode		= 0444,
23936d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
23941da177e4SLinus Torvalds 	},
23950741f4d2SChuck Ebbert 	{
23965031296cSH. Peter Anvin 		.procname	= "bootloader_version",
23975031296cSH. Peter Anvin 		.data		= &bootloader_version,
23985031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
23995031296cSH. Peter Anvin 		.mode		= 0444,
24006d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24015031296cSH. Peter Anvin 	},
24025031296cSH. Peter Anvin 	{
24036e7c4025SIngo Molnar 		.procname	= "io_delay_type",
24046e7c4025SIngo Molnar 		.data		= &io_delay_type,
24056e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
24066e7c4025SIngo Molnar 		.mode		= 0644,
24076d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24086e7c4025SIngo Molnar 	},
24091da177e4SLinus Torvalds #endif
24107a9166e3SLuke Yang #if defined(CONFIG_MMU)
24111da177e4SLinus Torvalds 	{
24121da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
24131da177e4SLinus Torvalds 		.data		= &randomize_va_space,
24141da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
24151da177e4SLinus Torvalds 		.mode		= 0644,
24166d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24171da177e4SLinus Torvalds 	},
24187a9166e3SLuke Yang #endif
24190152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2420951f22d5SMartin Schwidefsky 	{
2421951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
2422951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
2423951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
2424951f22d5SMartin Schwidefsky 		.mode		= 0644,
24256d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2426951f22d5SMartin Schwidefsky 	},
2427951f22d5SMartin Schwidefsky #endif
2428673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2429c255d844SPavel Machek 	{
2430c255d844SPavel Machek 		.procname	= "acpi_video_flags",
243177afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
2432c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
2433c255d844SPavel Machek 		.mode		= 0644,
24346d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
2435c255d844SPavel Machek 	},
2436c255d844SPavel Machek #endif
2437b6fca725SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2438d2b176edSJes Sorensen 	{
2439d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
2440d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
2441d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
2442d2b176edSJes Sorensen 		.mode		= 0644,
24436d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2444d2b176edSJes Sorensen 	},
2445b6fca725SVineet Gupta #endif
2446b6fca725SVineet Gupta #ifdef CONFIG_IA64
244788fc241fSDoug Chapman 	{
244888fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
244988fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
245088fc241fSDoug Chapman 		.maxlen		= sizeof (int),
245188fc241fSDoug Chapman 		.mode		= 0644,
24526d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
245388fc241fSDoug Chapman 	},
2454d2b176edSJes Sorensen #endif
2455e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
24560ec9dc9bSGuilherme G. Piccoli #ifdef CONFIG_SMP
24570ec9dc9bSGuilherme G. Piccoli 	{
24580ec9dc9bSGuilherme G. Piccoli 		.procname	= "hung_task_all_cpu_backtrace",
24590ec9dc9bSGuilherme G. Piccoli 		.data		= &sysctl_hung_task_all_cpu_backtrace,
24600ec9dc9bSGuilherme G. Piccoli 		.maxlen		= sizeof(int),
24610ec9dc9bSGuilherme G. Piccoli 		.mode		= 0644,
24620ec9dc9bSGuilherme G. Piccoli 		.proc_handler	= proc_dointvec_minmax,
24630ec9dc9bSGuilherme G. Piccoli 		.extra1		= SYSCTL_ZERO,
24640ec9dc9bSGuilherme G. Piccoli 		.extra2		= SYSCTL_ONE,
24650ec9dc9bSGuilherme G. Piccoli 	},
24660ec9dc9bSGuilherme G. Piccoli #endif /* CONFIG_SMP */
2467e162b39aSMandeep Singh Baines 	{
2468e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
2469e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
2470e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
2471e162b39aSMandeep Singh Baines 		.mode		= 0644,
24726d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2473eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2474eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2475e162b39aSMandeep Singh Baines 	},
247682a1fcb9SIngo Molnar 	{
247782a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
247882a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
2479cd64647fSLi Zefan 		.maxlen		= sizeof(int),
248082a1fcb9SIngo Molnar 		.mode		= 0644,
2481cd64647fSLi Zefan 		.proc_handler	= proc_dointvec_minmax,
2482eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
248382a1fcb9SIngo Molnar 	},
248482a1fcb9SIngo Molnar 	{
248582a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
248682a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
248790739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
248882a1fcb9SIngo Molnar 		.mode		= 0644,
24896d456111SEric W. Biederman 		.proc_handler	= proc_dohung_task_timeout_secs,
249080df2847SLiu Hua 		.extra2		= &hung_task_timeout_max,
249182a1fcb9SIngo Molnar 	},
249282a1fcb9SIngo Molnar 	{
2493a2e51445SDmitry Vyukov 		.procname	= "hung_task_check_interval_secs",
2494a2e51445SDmitry Vyukov 		.data		= &sysctl_hung_task_check_interval_secs,
2495a2e51445SDmitry Vyukov 		.maxlen		= sizeof(unsigned long),
2496a2e51445SDmitry Vyukov 		.mode		= 0644,
2497a2e51445SDmitry Vyukov 		.proc_handler	= proc_dohung_task_timeout_secs,
2498a2e51445SDmitry Vyukov 		.extra2		= &hung_task_timeout_max,
2499a2e51445SDmitry Vyukov 	},
2500a2e51445SDmitry Vyukov 	{
250182a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
250282a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
2503270750dbSAaron Tomlin 		.maxlen		= sizeof(int),
250482a1fcb9SIngo Molnar 		.mode		= 0644,
2505270750dbSAaron Tomlin 		.proc_handler	= proc_dointvec_minmax,
2506270750dbSAaron Tomlin 		.extra1		= &neg_one,
250782a1fcb9SIngo Molnar 	},
2508c4f3b63fSRavikiran G Thirumalai #endif
250923f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
251023f78d4aSIngo Molnar 	{
251123f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
251223f78d4aSIngo Molnar 		.data		= &max_lock_depth,
251323f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
251423f78d4aSIngo Molnar 		.mode		= 0644,
25156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
251623f78d4aSIngo Molnar 	},
251723f78d4aSIngo Molnar #endif
251810a0a8d4SJeremy Fitzhardinge 	{
251910a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
252010a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
252110a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
252210a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
25236d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
252410a0a8d4SJeremy Fitzhardinge 	},
25250b77f5bfSDavid Howells #ifdef CONFIG_KEYS
25260b77f5bfSDavid Howells 	{
25270b77f5bfSDavid Howells 		.procname	= "keys",
25280b77f5bfSDavid Howells 		.mode		= 0555,
25290b77f5bfSDavid Howells 		.child		= key_sysctls,
25300b77f5bfSDavid Howells 	},
25310b77f5bfSDavid Howells #endif
2532cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS
2533aa4a2218SVince Weaver 	/*
2534aa4a2218SVince Weaver 	 * User-space scripts rely on the existence of this file
2535aa4a2218SVince Weaver 	 * as a feature check for perf_events being enabled.
2536aa4a2218SVince Weaver 	 *
2537aa4a2218SVince Weaver 	 * So it's an ABI, do not remove!
2538aa4a2218SVince Weaver 	 */
25391ccd1549SPeter Zijlstra 	{
2540cdd6c482SIngo Molnar 		.procname	= "perf_event_paranoid",
2541cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_paranoid,
2542cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_paranoid),
25431ccd1549SPeter Zijlstra 		.mode		= 0644,
25446d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
25451ccd1549SPeter Zijlstra 	},
2546c5078f78SPeter Zijlstra 	{
2547cdd6c482SIngo Molnar 		.procname	= "perf_event_mlock_kb",
2548cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_mlock,
2549cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_mlock),
2550c5078f78SPeter Zijlstra 		.mode		= 0644,
25516d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2552c5078f78SPeter Zijlstra 	},
2553a78ac325SPeter Zijlstra 	{
2554cdd6c482SIngo Molnar 		.procname	= "perf_event_max_sample_rate",
2555cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_sample_rate,
2556cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
2557a78ac325SPeter Zijlstra 		.mode		= 0644,
2558163ec435SPeter Zijlstra 		.proc_handler	= perf_proc_update_handler,
2559eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2560a78ac325SPeter Zijlstra 	},
256114c63f17SDave Hansen 	{
256214c63f17SDave Hansen 		.procname	= "perf_cpu_time_max_percent",
256314c63f17SDave Hansen 		.data		= &sysctl_perf_cpu_time_max_percent,
256414c63f17SDave Hansen 		.maxlen		= sizeof(sysctl_perf_cpu_time_max_percent),
256514c63f17SDave Hansen 		.mode		= 0644,
256614c63f17SDave Hansen 		.proc_handler	= perf_cpu_time_max_percent_handler,
2567eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
256814c63f17SDave Hansen 		.extra2		= &one_hundred,
256914c63f17SDave Hansen 	},
2570c5dfd78eSArnaldo Carvalho de Melo 	{
2571c5dfd78eSArnaldo Carvalho de Melo 		.procname	= "perf_event_max_stack",
2572a831100aSArnaldo Carvalho de Melo 		.data		= &sysctl_perf_event_max_stack,
2573c5dfd78eSArnaldo Carvalho de Melo 		.maxlen		= sizeof(sysctl_perf_event_max_stack),
2574c5dfd78eSArnaldo Carvalho de Melo 		.mode		= 0644,
2575c5dfd78eSArnaldo Carvalho de Melo 		.proc_handler	= perf_event_max_stack_handler,
2576eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2577c5dfd78eSArnaldo Carvalho de Melo 		.extra2		= &six_hundred_forty_kb,
2578c5dfd78eSArnaldo Carvalho de Melo 	},
2579c85b0334SArnaldo Carvalho de Melo 	{
2580c85b0334SArnaldo Carvalho de Melo 		.procname	= "perf_event_max_contexts_per_stack",
2581c85b0334SArnaldo Carvalho de Melo 		.data		= &sysctl_perf_event_max_contexts_per_stack,
2582c85b0334SArnaldo Carvalho de Melo 		.maxlen		= sizeof(sysctl_perf_event_max_contexts_per_stack),
2583c85b0334SArnaldo Carvalho de Melo 		.mode		= 0644,
2584c85b0334SArnaldo Carvalho de Melo 		.proc_handler	= perf_event_max_stack_handler,
2585eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2586c85b0334SArnaldo Carvalho de Melo 		.extra2		= &one_thousand,
2587c85b0334SArnaldo Carvalho de Melo 	},
25881ccd1549SPeter Zijlstra #endif
25899e3961a0SPrarit Bhargava 	{
25909e3961a0SPrarit Bhargava 		.procname	= "panic_on_warn",
25919e3961a0SPrarit Bhargava 		.data		= &panic_on_warn,
25929e3961a0SPrarit Bhargava 		.maxlen		= sizeof(int),
25939e3961a0SPrarit Bhargava 		.mode		= 0644,
25949e3961a0SPrarit Bhargava 		.proc_handler	= proc_dointvec_minmax,
2595eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2596eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
25979e3961a0SPrarit Bhargava 	},
2598bc7a34b8SThomas Gleixner #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2599bc7a34b8SThomas Gleixner 	{
2600bc7a34b8SThomas Gleixner 		.procname	= "timer_migration",
2601bc7a34b8SThomas Gleixner 		.data		= &sysctl_timer_migration,
2602bc7a34b8SThomas Gleixner 		.maxlen		= sizeof(unsigned int),
2603bc7a34b8SThomas Gleixner 		.mode		= 0644,
2604bc7a34b8SThomas Gleixner 		.proc_handler	= timer_migration_handler,
2605eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2606eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2607bc7a34b8SThomas Gleixner 	},
2608bc7a34b8SThomas Gleixner #endif
26091be7f75dSAlexei Starovoitov #ifdef CONFIG_BPF_SYSCALL
26101be7f75dSAlexei Starovoitov 	{
26111be7f75dSAlexei Starovoitov 		.procname	= "unprivileged_bpf_disabled",
26121be7f75dSAlexei Starovoitov 		.data		= &sysctl_unprivileged_bpf_disabled,
26131be7f75dSAlexei Starovoitov 		.maxlen		= sizeof(sysctl_unprivileged_bpf_disabled),
26141be7f75dSAlexei Starovoitov 		.mode		= 0644,
26151be7f75dSAlexei Starovoitov 		/* only handle a transition from default "0" to "1" */
26161be7f75dSAlexei Starovoitov 		.proc_handler	= proc_dointvec_minmax,
2617eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2618eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
26191be7f75dSAlexei Starovoitov 	},
2620492ecee8SAlexei Starovoitov 	{
2621492ecee8SAlexei Starovoitov 		.procname	= "bpf_stats_enabled",
2622a8e11e5cSEric Dumazet 		.data		= &bpf_stats_enabled_key.key,
2623a8e11e5cSEric Dumazet 		.maxlen		= sizeof(bpf_stats_enabled_key),
2624492ecee8SAlexei Starovoitov 		.mode		= 0644,
2625d46edd67SSong Liu 		.proc_handler	= bpf_stats_handler,
2626492ecee8SAlexei Starovoitov 	},
26273fcc5530SAlexei Starovoitov #endif
2628b3e627d3SLai Jiangshan #if defined(CONFIG_TREE_RCU)
2629088e9d25SDaniel Bristot de Oliveira 	{
2630088e9d25SDaniel Bristot de Oliveira 		.procname	= "panic_on_rcu_stall",
2631088e9d25SDaniel Bristot de Oliveira 		.data		= &sysctl_panic_on_rcu_stall,
2632088e9d25SDaniel Bristot de Oliveira 		.maxlen		= sizeof(sysctl_panic_on_rcu_stall),
2633088e9d25SDaniel Bristot de Oliveira 		.mode		= 0644,
2634088e9d25SDaniel Bristot de Oliveira 		.proc_handler	= proc_dointvec_minmax,
2635eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2636eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2637088e9d25SDaniel Bristot de Oliveira 	},
2638088e9d25SDaniel Bristot de Oliveira #endif
2639dfe56404Schao #if defined(CONFIG_TREE_RCU)
2640dfe56404Schao 	{
2641dfe56404Schao 		.procname	= "max_rcu_stall_to_panic",
2642dfe56404Schao 		.data		= &sysctl_max_rcu_stall_to_panic,
2643dfe56404Schao 		.maxlen		= sizeof(sysctl_max_rcu_stall_to_panic),
2644dfe56404Schao 		.mode		= 0644,
2645dfe56404Schao 		.proc_handler	= proc_dointvec_minmax,
2646dfe56404Schao 		.extra1		= SYSCTL_ONE,
2647dfe56404Schao 		.extra2		= SYSCTL_INT_MAX,
2648dfe56404Schao 	},
2649dfe56404Schao #endif
2650964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2651964c9dffSAlexander Popov 	{
2652964c9dffSAlexander Popov 		.procname	= "stack_erasing",
2653964c9dffSAlexander Popov 		.data		= NULL,
2654964c9dffSAlexander Popov 		.maxlen		= sizeof(int),
2655964c9dffSAlexander Popov 		.mode		= 0600,
2656964c9dffSAlexander Popov 		.proc_handler	= stack_erasing_sysctl,
2657eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2658eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2659964c9dffSAlexander Popov 	},
2660964c9dffSAlexander Popov #endif
26616fce56ecSEric W. Biederman 	{ }
26621da177e4SLinus Torvalds };
26631da177e4SLinus Torvalds 
2664d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
26651da177e4SLinus Torvalds 	{
26661da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
26671da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
26681da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
26691da177e4SLinus Torvalds 		.mode		= 0644,
267056f3547bSFeng Tang 		.proc_handler	= overcommit_policy_handler,
2671eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2672cb16e95fSPetr Holasek 		.extra2		= &two,
26731da177e4SLinus Torvalds 	},
26741da177e4SLinus Torvalds 	{
2675fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
2676fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
2677fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
2678fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
2679cb16e95fSPetr Holasek 		.proc_handler	= proc_dointvec_minmax,
2680eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2681cb16e95fSPetr Holasek 		.extra2		= &two,
2682fadd8fbdSKAMEZAWA Hiroyuki 	},
2683fadd8fbdSKAMEZAWA Hiroyuki 	{
2684fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
2685fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
2686fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
2687fe071d7eSDavid Rientjes 		.mode		= 0644,
26886d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2689fe071d7eSDavid Rientjes 	},
2690fe071d7eSDavid Rientjes 	{
2691fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
2692fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
2693fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
2694fef1bdd6SDavid Rientjes 		.mode		= 0644,
26956d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2696fef1bdd6SDavid Rientjes 	},
2697fef1bdd6SDavid Rientjes 	{
26981da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
26991da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
27001da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
27011da177e4SLinus Torvalds 		.mode		= 0644,
270249f0ce5fSJerome Marchand 		.proc_handler	= overcommit_ratio_handler,
270349f0ce5fSJerome Marchand 	},
270449f0ce5fSJerome Marchand 	{
270549f0ce5fSJerome Marchand 		.procname	= "overcommit_kbytes",
270649f0ce5fSJerome Marchand 		.data		= &sysctl_overcommit_kbytes,
270749f0ce5fSJerome Marchand 		.maxlen		= sizeof(sysctl_overcommit_kbytes),
270849f0ce5fSJerome Marchand 		.mode		= 0644,
270949f0ce5fSJerome Marchand 		.proc_handler	= overcommit_kbytes_handler,
27101da177e4SLinus Torvalds 	},
27111da177e4SLinus Torvalds 	{
27121da177e4SLinus Torvalds 		.procname	= "page-cluster",
27131da177e4SLinus Torvalds 		.data		= &page_cluster,
27141da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
27151da177e4SLinus Torvalds 		.mode		= 0644,
2716cb16e95fSPetr Holasek 		.proc_handler	= proc_dointvec_minmax,
2717eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27181da177e4SLinus Torvalds 	},
27191da177e4SLinus Torvalds 	{
27201da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
27211da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
27221da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
27231da177e4SLinus Torvalds 		.mode		= 0644,
27246d456111SEric W. Biederman 		.proc_handler	= dirty_background_ratio_handler,
2725eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27261da177e4SLinus Torvalds 		.extra2		= &one_hundred,
27271da177e4SLinus Torvalds 	},
27281da177e4SLinus Torvalds 	{
27292da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
27302da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
27312da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
27322da02997SDavid Rientjes 		.mode		= 0644,
27336d456111SEric W. Biederman 		.proc_handler	= dirty_background_bytes_handler,
2734fc3501d4SSven Wegener 		.extra1		= &one_ul,
27352da02997SDavid Rientjes 	},
27362da02997SDavid Rientjes 	{
27371da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
27381da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
27391da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
27401da177e4SLinus Torvalds 		.mode		= 0644,
27416d456111SEric W. Biederman 		.proc_handler	= dirty_ratio_handler,
2742eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27431da177e4SLinus Torvalds 		.extra2		= &one_hundred,
27441da177e4SLinus Torvalds 	},
27451da177e4SLinus Torvalds 	{
27462da02997SDavid Rientjes 		.procname	= "dirty_bytes",
27472da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
27482da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
27492da02997SDavid Rientjes 		.mode		= 0644,
27506d456111SEric W. Biederman 		.proc_handler	= dirty_bytes_handler,
27519e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
27522da02997SDavid Rientjes 	},
27532da02997SDavid Rientjes 	{
27541da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
2755f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
2756f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
27571da177e4SLinus Torvalds 		.mode		= 0644,
27586d456111SEric W. Biederman 		.proc_handler	= dirty_writeback_centisecs_handler,
27591da177e4SLinus Torvalds 	},
27601da177e4SLinus Torvalds 	{
27611da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
2762f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
2763f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
27641da177e4SLinus Torvalds 		.mode		= 0644,
2765cb16e95fSPetr Holasek 		.proc_handler	= proc_dointvec_minmax,
2766eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27671da177e4SLinus Torvalds 	},
27681da177e4SLinus Torvalds 	{
27691efff914STheodore Ts'o 		.procname	= "dirtytime_expire_seconds",
27701efff914STheodore Ts'o 		.data		= &dirtytime_expire_interval,
27712d87b309SRandy Dunlap 		.maxlen		= sizeof(dirtytime_expire_interval),
27721efff914STheodore Ts'o 		.mode		= 0644,
27731efff914STheodore Ts'o 		.proc_handler	= dirtytime_interval_handler,
2774eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27751efff914STheodore Ts'o 	},
27761efff914STheodore Ts'o 	{
27771da177e4SLinus Torvalds 		.procname	= "swappiness",
27781da177e4SLinus Torvalds 		.data		= &vm_swappiness,
27791da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
27801da177e4SLinus Torvalds 		.mode		= 0644,
27816d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2782eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2783c843966cSJohannes Weiner 		.extra2		= &two_hundred,
27841da177e4SLinus Torvalds 	},
27851da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
27861da177e4SLinus Torvalds 	{
27871da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
2788e5ff2159SAndi Kleen 		.data		= NULL,
27891da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
27901da177e4SLinus Torvalds 		.mode		= 0644,
27916d456111SEric W. Biederman 		.proc_handler	= hugetlb_sysctl_handler,
27921da177e4SLinus Torvalds 	},
279306808b08SLee Schermerhorn #ifdef CONFIG_NUMA
279406808b08SLee Schermerhorn 	{
279506808b08SLee Schermerhorn 		.procname       = "nr_hugepages_mempolicy",
279606808b08SLee Schermerhorn 		.data           = NULL,
279706808b08SLee Schermerhorn 		.maxlen         = sizeof(unsigned long),
279806808b08SLee Schermerhorn 		.mode           = 0644,
279906808b08SLee Schermerhorn 		.proc_handler   = &hugetlb_mempolicy_sysctl_handler,
280006808b08SLee Schermerhorn 	},
28014518085eSKemi Wang 	{
28024518085eSKemi Wang 		.procname		= "numa_stat",
28034518085eSKemi Wang 		.data			= &sysctl_vm_numa_stat,
28044518085eSKemi Wang 		.maxlen			= sizeof(int),
28054518085eSKemi Wang 		.mode			= 0644,
28064518085eSKemi Wang 		.proc_handler	= sysctl_vm_numa_stat_handler,
2807eec4844fSMatteo Croce 		.extra1			= SYSCTL_ZERO,
2808eec4844fSMatteo Croce 		.extra2			= SYSCTL_ONE,
28094518085eSKemi Wang 	},
281006808b08SLee Schermerhorn #endif
28111da177e4SLinus Torvalds 	 {
28121da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
28131da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
28141da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
28151da177e4SLinus Torvalds 		.mode		= 0644,
28166d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
28171da177e4SLinus Torvalds 	 },
2818396faf03SMel Gorman 	{
2819d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
2820e5ff2159SAndi Kleen 		.data		= NULL,
2821e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
2822d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
28236d456111SEric W. Biederman 		.proc_handler	= hugetlb_overcommit_handler,
2824d1c3fb1fSNishanth Aravamudan 	},
28251da177e4SLinus Torvalds #endif
28261da177e4SLinus Torvalds 	{
28271da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
28281da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
28291da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
28301da177e4SLinus Torvalds 		.mode		= 0644,
28316d456111SEric W. Biederman 		.proc_handler	= lowmem_reserve_ratio_sysctl_handler,
28321da177e4SLinus Torvalds 	},
28331da177e4SLinus Torvalds 	{
28349d0243bcSAndrew Morton 		.procname	= "drop_caches",
28359d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
28369d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
2837204cb79aSJohannes Weiner 		.mode		= 0200,
28389d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
2839eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
28405509a5d2SDave Hansen 		.extra2		= &four,
28419d0243bcSAndrew Morton 	},
284276ab0f53SMel Gorman #ifdef CONFIG_COMPACTION
284376ab0f53SMel Gorman 	{
284476ab0f53SMel Gorman 		.procname	= "compact_memory",
2845ef498438SPintu Kumar 		.data		= NULL,
284676ab0f53SMel Gorman 		.maxlen		= sizeof(int),
284776ab0f53SMel Gorman 		.mode		= 0200,
284876ab0f53SMel Gorman 		.proc_handler	= sysctl_compaction_handler,
284976ab0f53SMel Gorman 	},
28505e771905SMel Gorman 	{
2851facdaa91SNitin Gupta 		.procname	= "compaction_proactiveness",
2852facdaa91SNitin Gupta 		.data		= &sysctl_compaction_proactiveness,
2853d34c0a75SNitin Gupta 		.maxlen		= sizeof(sysctl_compaction_proactiveness),
2854facdaa91SNitin Gupta 		.mode		= 0644,
2855facdaa91SNitin Gupta 		.proc_handler	= proc_dointvec_minmax,
2856facdaa91SNitin Gupta 		.extra1		= SYSCTL_ZERO,
2857facdaa91SNitin Gupta 		.extra2		= &one_hundred,
2858facdaa91SNitin Gupta 	},
2859facdaa91SNitin Gupta 	{
28605e771905SMel Gorman 		.procname	= "extfrag_threshold",
28615e771905SMel Gorman 		.data		= &sysctl_extfrag_threshold,
28625e771905SMel Gorman 		.maxlen		= sizeof(int),
28635e771905SMel Gorman 		.mode		= 0644,
28646b7e5cadSMatthew Wilcox 		.proc_handler	= proc_dointvec_minmax,
28655e771905SMel Gorman 		.extra1		= &min_extfrag_threshold,
28665e771905SMel Gorman 		.extra2		= &max_extfrag_threshold,
28675e771905SMel Gorman 	},
28685bbe3547SEric B Munson 	{
28695bbe3547SEric B Munson 		.procname	= "compact_unevictable_allowed",
28705bbe3547SEric B Munson 		.data		= &sysctl_compact_unevictable_allowed,
28715bbe3547SEric B Munson 		.maxlen		= sizeof(int),
28725bbe3547SEric B Munson 		.mode		= 0644,
28736923aa0dSSebastian Andrzej Siewior 		.proc_handler	= proc_dointvec_minmax_warn_RT_change,
2874eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2875eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
28765bbe3547SEric B Munson 	},
28775e771905SMel Gorman 
287876ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */
28799d0243bcSAndrew Morton 	{
28801da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
28811da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
28821da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
28831da177e4SLinus Torvalds 		.mode		= 0644,
28846d456111SEric W. Biederman 		.proc_handler	= min_free_kbytes_sysctl_handler,
2885eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
28861da177e4SLinus Torvalds 	},
28878ad4b1fbSRohit Seth 	{
28881c30844dSMel Gorman 		.procname	= "watermark_boost_factor",
28891c30844dSMel Gorman 		.data		= &watermark_boost_factor,
28901c30844dSMel Gorman 		.maxlen		= sizeof(watermark_boost_factor),
28911c30844dSMel Gorman 		.mode		= 0644,
289226363af5SChristoph Hellwig 		.proc_handler	= proc_dointvec_minmax,
2893eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
28941c30844dSMel Gorman 	},
28951c30844dSMel Gorman 	{
2896795ae7a0SJohannes Weiner 		.procname	= "watermark_scale_factor",
2897795ae7a0SJohannes Weiner 		.data		= &watermark_scale_factor,
2898795ae7a0SJohannes Weiner 		.maxlen		= sizeof(watermark_scale_factor),
2899795ae7a0SJohannes Weiner 		.mode		= 0644,
2900795ae7a0SJohannes Weiner 		.proc_handler	= watermark_scale_factor_sysctl_handler,
2901eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2902795ae7a0SJohannes Weiner 		.extra2		= &one_thousand,
2903795ae7a0SJohannes Weiner 	},
2904795ae7a0SJohannes Weiner 	{
29058ad4b1fbSRohit Seth 		.procname	= "percpu_pagelist_fraction",
29068ad4b1fbSRohit Seth 		.data		= &percpu_pagelist_fraction,
29078ad4b1fbSRohit Seth 		.maxlen		= sizeof(percpu_pagelist_fraction),
29088ad4b1fbSRohit Seth 		.mode		= 0644,
29096d456111SEric W. Biederman 		.proc_handler	= percpu_pagelist_fraction_sysctl_handler,
2910eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29118ad4b1fbSRohit Seth 	},
29125ef64cc8SLinus Torvalds 	{
29135ef64cc8SLinus Torvalds 		.procname	= "page_lock_unfairness",
29145ef64cc8SLinus Torvalds 		.data		= &sysctl_page_lock_unfairness,
29155ef64cc8SLinus Torvalds 		.maxlen		= sizeof(sysctl_page_lock_unfairness),
29165ef64cc8SLinus Torvalds 		.mode		= 0644,
29175ef64cc8SLinus Torvalds 		.proc_handler	= proc_dointvec_minmax,
29185ef64cc8SLinus Torvalds 		.extra1		= SYSCTL_ZERO,
29195ef64cc8SLinus Torvalds 	},
29201da177e4SLinus Torvalds #ifdef CONFIG_MMU
29211da177e4SLinus Torvalds 	{
29221da177e4SLinus Torvalds 		.procname	= "max_map_count",
29231da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
29241da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
29251da177e4SLinus Torvalds 		.mode		= 0644,
29263e26120cSWANG Cong 		.proc_handler	= proc_dointvec_minmax,
2927eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29281da177e4SLinus Torvalds 	},
2929dd8632a1SPaul Mundt #else
2930dd8632a1SPaul Mundt 	{
2931dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
2932dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
2933dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
2934dd8632a1SPaul Mundt 		.mode		= 0644,
29356d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2936eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2937dd8632a1SPaul Mundt 	},
29381da177e4SLinus Torvalds #endif
29391da177e4SLinus Torvalds 	{
29401da177e4SLinus Torvalds 		.procname	= "laptop_mode",
29411da177e4SLinus Torvalds 		.data		= &laptop_mode,
29421da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
29431da177e4SLinus Torvalds 		.mode		= 0644,
29446d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
29451da177e4SLinus Torvalds 	},
29461da177e4SLinus Torvalds 	{
29471da177e4SLinus Torvalds 		.procname	= "block_dump",
29481da177e4SLinus Torvalds 		.data		= &block_dump,
29491da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
29501da177e4SLinus Torvalds 		.mode		= 0644,
29513b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2952eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29531da177e4SLinus Torvalds 	},
29541da177e4SLinus Torvalds 	{
29551da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
29561da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
29571da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
29581da177e4SLinus Torvalds 		.mode		= 0644,
29593b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2960eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29611da177e4SLinus Torvalds 	},
296267f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
296367f3977fSAlexandre Ghiti     defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
29641da177e4SLinus Torvalds 	{
29651da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
29661da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
29671da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
29681da177e4SLinus Torvalds 		.mode		= 0644,
29693b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2970eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29711da177e4SLinus Torvalds 	},
29721da177e4SLinus Torvalds #endif
29731743660bSChristoph Lameter #ifdef CONFIG_NUMA
29741743660bSChristoph Lameter 	{
29751743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
2976a5f5f91dSMel Gorman 		.data		= &node_reclaim_mode,
2977a5f5f91dSMel Gorman 		.maxlen		= sizeof(node_reclaim_mode),
29781743660bSChristoph Lameter 		.mode		= 0644,
29793b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2980eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29811743660bSChristoph Lameter 	},
29829614634fSChristoph Lameter 	{
29839614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
29849614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
29859614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
29869614634fSChristoph Lameter 		.mode		= 0644,
29876d456111SEric W. Biederman 		.proc_handler	= sysctl_min_unmapped_ratio_sysctl_handler,
2988eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29899614634fSChristoph Lameter 		.extra2		= &one_hundred,
29909614634fSChristoph Lameter 	},
29910ff38490SChristoph Lameter 	{
29920ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
29930ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
29940ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
29950ff38490SChristoph Lameter 		.mode		= 0644,
29966d456111SEric W. Biederman 		.proc_handler	= sysctl_min_slab_ratio_sysctl_handler,
2997eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29980ff38490SChristoph Lameter 		.extra2		= &one_hundred,
29990ff38490SChristoph Lameter 	},
30001743660bSChristoph Lameter #endif
300177461ab3SChristoph Lameter #ifdef CONFIG_SMP
300277461ab3SChristoph Lameter 	{
300377461ab3SChristoph Lameter 		.procname	= "stat_interval",
300477461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
300577461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
300677461ab3SChristoph Lameter 		.mode		= 0644,
30076d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
300877461ab3SChristoph Lameter 	},
300952b6f46bSHugh Dickins 	{
301052b6f46bSHugh Dickins 		.procname	= "stat_refresh",
301152b6f46bSHugh Dickins 		.data		= NULL,
301252b6f46bSHugh Dickins 		.maxlen		= 0,
301352b6f46bSHugh Dickins 		.mode		= 0600,
301452b6f46bSHugh Dickins 		.proc_handler	= vmstat_refresh,
301552b6f46bSHugh Dickins 	},
301677461ab3SChristoph Lameter #endif
30176e141546SDavid Howells #ifdef CONFIG_MMU
3018ed032189SEric Paris 	{
3019ed032189SEric Paris 		.procname	= "mmap_min_addr",
3020788084abSEric Paris 		.data		= &dac_mmap_min_addr,
3021ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
3022ed032189SEric Paris 		.mode		= 0644,
30236d456111SEric W. Biederman 		.proc_handler	= mmap_min_addr_handler,
3024ed032189SEric Paris 	},
30256e141546SDavid Howells #endif
3026f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
3027f0c0b2b8SKAMEZAWA Hiroyuki 	{
3028f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
3029f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
3030f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
3031f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
30326d456111SEric W. Biederman 		.proc_handler	= numa_zonelist_order_handler,
3033f0c0b2b8SKAMEZAWA Hiroyuki 	},
3034f0c0b2b8SKAMEZAWA Hiroyuki #endif
30352b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
30365c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3037e6e5494cSIngo Molnar 	{
3038e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
30393d7ee969SAndy Lutomirski #ifdef CONFIG_X86_32
30403d7ee969SAndy Lutomirski 		.data		= &vdso32_enabled,
30413d7ee969SAndy Lutomirski 		.maxlen		= sizeof(vdso32_enabled),
30423d7ee969SAndy Lutomirski #else
3043e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
3044e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
30453d7ee969SAndy Lutomirski #endif
3046e6e5494cSIngo Molnar 		.mode		= 0644,
30476d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3048eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3049e6e5494cSIngo Molnar 	},
3050e6e5494cSIngo Molnar #endif
3051195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
3052195cf453SBron Gondwana 	{
3053195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
3054195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
3055195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
3056195cf453SBron Gondwana 		.mode		= 0644,
30576d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3058eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3059eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3060195cf453SBron Gondwana 	},
3061195cf453SBron Gondwana #endif
30626a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE
30636a46079cSAndi Kleen 	{
30646a46079cSAndi Kleen 		.procname	= "memory_failure_early_kill",
30656a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_early_kill,
30666a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_early_kill),
30676a46079cSAndi Kleen 		.mode		= 0644,
30686d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3069eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3070eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
30716a46079cSAndi Kleen 	},
30726a46079cSAndi Kleen 	{
30736a46079cSAndi Kleen 		.procname	= "memory_failure_recovery",
30746a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_recovery,
30756a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_recovery),
30766a46079cSAndi Kleen 		.mode		= 0644,
30776d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3078eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3079eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
30806a46079cSAndi Kleen 	},
30816a46079cSAndi Kleen #endif
3082c9b1d098SAndrew Shewmaker 	{
3083c9b1d098SAndrew Shewmaker 		.procname	= "user_reserve_kbytes",
3084c9b1d098SAndrew Shewmaker 		.data		= &sysctl_user_reserve_kbytes,
3085c9b1d098SAndrew Shewmaker 		.maxlen		= sizeof(sysctl_user_reserve_kbytes),
3086c9b1d098SAndrew Shewmaker 		.mode		= 0644,
3087c9b1d098SAndrew Shewmaker 		.proc_handler	= proc_doulongvec_minmax,
3088c9b1d098SAndrew Shewmaker 	},
30894eeab4f5SAndrew Shewmaker 	{
30904eeab4f5SAndrew Shewmaker 		.procname	= "admin_reserve_kbytes",
30914eeab4f5SAndrew Shewmaker 		.data		= &sysctl_admin_reserve_kbytes,
30924eeab4f5SAndrew Shewmaker 		.maxlen		= sizeof(sysctl_admin_reserve_kbytes),
30934eeab4f5SAndrew Shewmaker 		.mode		= 0644,
30944eeab4f5SAndrew Shewmaker 		.proc_handler	= proc_doulongvec_minmax,
30954eeab4f5SAndrew Shewmaker 	},
3096d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3097d07e2259SDaniel Cashman 	{
3098d07e2259SDaniel Cashman 		.procname	= "mmap_rnd_bits",
3099d07e2259SDaniel Cashman 		.data		= &mmap_rnd_bits,
3100d07e2259SDaniel Cashman 		.maxlen		= sizeof(mmap_rnd_bits),
3101d07e2259SDaniel Cashman 		.mode		= 0600,
3102d07e2259SDaniel Cashman 		.proc_handler	= proc_dointvec_minmax,
3103d07e2259SDaniel Cashman 		.extra1		= (void *)&mmap_rnd_bits_min,
3104d07e2259SDaniel Cashman 		.extra2		= (void *)&mmap_rnd_bits_max,
3105d07e2259SDaniel Cashman 	},
3106d07e2259SDaniel Cashman #endif
3107d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3108d07e2259SDaniel Cashman 	{
3109d07e2259SDaniel Cashman 		.procname	= "mmap_rnd_compat_bits",
3110d07e2259SDaniel Cashman 		.data		= &mmap_rnd_compat_bits,
3111d07e2259SDaniel Cashman 		.maxlen		= sizeof(mmap_rnd_compat_bits),
3112d07e2259SDaniel Cashman 		.mode		= 0600,
3113d07e2259SDaniel Cashman 		.proc_handler	= proc_dointvec_minmax,
3114d07e2259SDaniel Cashman 		.extra1		= (void *)&mmap_rnd_compat_bits_min,
3115d07e2259SDaniel Cashman 		.extra2		= (void *)&mmap_rnd_compat_bits_max,
3116d07e2259SDaniel Cashman 	},
3117d07e2259SDaniel Cashman #endif
3118cefdca0aSPeter Xu #ifdef CONFIG_USERFAULTFD
3119cefdca0aSPeter Xu 	{
3120cefdca0aSPeter Xu 		.procname	= "unprivileged_userfaultfd",
3121cefdca0aSPeter Xu 		.data		= &sysctl_unprivileged_userfaultfd,
3122cefdca0aSPeter Xu 		.maxlen		= sizeof(sysctl_unprivileged_userfaultfd),
3123cefdca0aSPeter Xu 		.mode		= 0644,
3124cefdca0aSPeter Xu 		.proc_handler	= proc_dointvec_minmax,
3125eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3126eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3127cefdca0aSPeter Xu 	},
3128cefdca0aSPeter Xu #endif
31296fce56ecSEric W. Biederman 	{ }
31301da177e4SLinus Torvalds };
31311da177e4SLinus Torvalds 
3132d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
31331da177e4SLinus Torvalds 	{
31341da177e4SLinus Torvalds 		.procname	= "inode-nr",
31351da177e4SLinus Torvalds 		.data		= &inodes_stat,
31363942c07cSGlauber Costa 		.maxlen		= 2*sizeof(long),
31371da177e4SLinus Torvalds 		.mode		= 0444,
3138cffbc8aaSDave Chinner 		.proc_handler	= proc_nr_inodes,
31391da177e4SLinus Torvalds 	},
31401da177e4SLinus Torvalds 	{
31411da177e4SLinus Torvalds 		.procname	= "inode-state",
31421da177e4SLinus Torvalds 		.data		= &inodes_stat,
31433942c07cSGlauber Costa 		.maxlen		= 7*sizeof(long),
31441da177e4SLinus Torvalds 		.mode		= 0444,
3145cffbc8aaSDave Chinner 		.proc_handler	= proc_nr_inodes,
31461da177e4SLinus Torvalds 	},
31471da177e4SLinus Torvalds 	{
31481da177e4SLinus Torvalds 		.procname	= "file-nr",
31491da177e4SLinus Torvalds 		.data		= &files_stat,
3150518de9b3SEric Dumazet 		.maxlen		= sizeof(files_stat),
31511da177e4SLinus Torvalds 		.mode		= 0444,
31526d456111SEric W. Biederman 		.proc_handler	= proc_nr_files,
31531da177e4SLinus Torvalds 	},
31541da177e4SLinus Torvalds 	{
31551da177e4SLinus Torvalds 		.procname	= "file-max",
31561da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
3157518de9b3SEric Dumazet 		.maxlen		= sizeof(files_stat.max_files),
31581da177e4SLinus Torvalds 		.mode		= 0644,
3159518de9b3SEric Dumazet 		.proc_handler	= proc_doulongvec_minmax,
31609002b214SWill Deacon 		.extra1		= &zero_ul,
316132a5ad9cSChristian Brauner 		.extra2		= &long_max,
31621da177e4SLinus Torvalds 	},
31631da177e4SLinus Torvalds 	{
31649cfe015aSEric Dumazet 		.procname	= "nr_open",
31659cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
31669b80a184SAlexey Dobriyan 		.maxlen		= sizeof(unsigned int),
31679cfe015aSEric Dumazet 		.mode		= 0644,
31686d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3169eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
3170eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
31719cfe015aSEric Dumazet 	},
31729cfe015aSEric Dumazet 	{
31731da177e4SLinus Torvalds 		.procname	= "dentry-state",
31741da177e4SLinus Torvalds 		.data		= &dentry_stat,
31753942c07cSGlauber Costa 		.maxlen		= 6*sizeof(long),
31761da177e4SLinus Torvalds 		.mode		= 0444,
3177312d3ca8SChristoph Hellwig 		.proc_handler	= proc_nr_dentry,
31781da177e4SLinus Torvalds 	},
31791da177e4SLinus Torvalds 	{
31801da177e4SLinus Torvalds 		.procname	= "overflowuid",
31811da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
31821da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
31831da177e4SLinus Torvalds 		.mode		= 0644,
31846d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
31851da177e4SLinus Torvalds 		.extra1		= &minolduid,
31861da177e4SLinus Torvalds 		.extra2		= &maxolduid,
31871da177e4SLinus Torvalds 	},
31881da177e4SLinus Torvalds 	{
31891da177e4SLinus Torvalds 		.procname	= "overflowgid",
31901da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
31911da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
31921da177e4SLinus Torvalds 		.mode		= 0644,
31936d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
31941da177e4SLinus Torvalds 		.extra1		= &minolduid,
31951da177e4SLinus Torvalds 		.extra2		= &maxolduid,
31961da177e4SLinus Torvalds 	},
3197bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
31981da177e4SLinus Torvalds 	{
31991da177e4SLinus Torvalds 		.procname	= "leases-enable",
32001da177e4SLinus Torvalds 		.data		= &leases_enable,
32011da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32021da177e4SLinus Torvalds 		.mode		= 0644,
32036d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
32041da177e4SLinus Torvalds 	},
3205bfcd17a6SThomas Petazzoni #endif
32061da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
32071da177e4SLinus Torvalds 	{
32081da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
32091da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
32101da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32111da177e4SLinus Torvalds 		.mode		= 0644,
32126d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
32131da177e4SLinus Torvalds 	},
32141da177e4SLinus Torvalds #endif
32151da177e4SLinus Torvalds #ifdef CONFIG_MMU
3216bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
32171da177e4SLinus Torvalds 	{
32181da177e4SLinus Torvalds 		.procname	= "lease-break-time",
32191da177e4SLinus Torvalds 		.data		= &lease_break_time,
32201da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32211da177e4SLinus Torvalds 		.mode		= 0644,
32226d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
32231da177e4SLinus Torvalds 	},
3224bfcd17a6SThomas Petazzoni #endif
3225ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
32261da177e4SLinus Torvalds 	{
32271da177e4SLinus Torvalds 		.procname	= "aio-nr",
32281da177e4SLinus Torvalds 		.data		= &aio_nr,
32291da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
32301da177e4SLinus Torvalds 		.mode		= 0444,
32316d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
32321da177e4SLinus Torvalds 	},
32331da177e4SLinus Torvalds 	{
32341da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
32351da177e4SLinus Torvalds 		.data		= &aio_max_nr,
32361da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
32371da177e4SLinus Torvalds 		.mode		= 0644,
32386d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
32391da177e4SLinus Torvalds 	},
3240ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
32412d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
32420399cb08SRobert Love 	{
32430399cb08SRobert Love 		.procname	= "inotify",
32440399cb08SRobert Love 		.mode		= 0555,
32450399cb08SRobert Love 		.child		= inotify_table,
32460399cb08SRobert Love 	},
32470399cb08SRobert Love #endif
32485b8fea65SAmir Goldstein #ifdef CONFIG_FANOTIFY
32495b8fea65SAmir Goldstein 	{
32505b8fea65SAmir Goldstein 		.procname	= "fanotify",
32515b8fea65SAmir Goldstein 		.mode		= 0555,
32525b8fea65SAmir Goldstein 		.child		= fanotify_table,
32535b8fea65SAmir Goldstein 	},
32545b8fea65SAmir Goldstein #endif
32557ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
32567ef9964eSDavide Libenzi 	{
32577ef9964eSDavide Libenzi 		.procname	= "epoll",
32587ef9964eSDavide Libenzi 		.mode		= 0555,
32597ef9964eSDavide Libenzi 		.child		= epoll_table,
32607ef9964eSDavide Libenzi 	},
32617ef9964eSDavide Libenzi #endif
32621da177e4SLinus Torvalds #endif
3263d6e71144SAlan Cox 	{
3264800179c9SKees Cook 		.procname	= "protected_symlinks",
3265800179c9SKees Cook 		.data		= &sysctl_protected_symlinks,
3266800179c9SKees Cook 		.maxlen		= sizeof(int),
3267800179c9SKees Cook 		.mode		= 0600,
3268800179c9SKees Cook 		.proc_handler	= proc_dointvec_minmax,
3269eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3270eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3271800179c9SKees Cook 	},
3272800179c9SKees Cook 	{
3273800179c9SKees Cook 		.procname	= "protected_hardlinks",
3274800179c9SKees Cook 		.data		= &sysctl_protected_hardlinks,
3275800179c9SKees Cook 		.maxlen		= sizeof(int),
3276800179c9SKees Cook 		.mode		= 0600,
3277800179c9SKees Cook 		.proc_handler	= proc_dointvec_minmax,
3278eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3279eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3280800179c9SKees Cook 	},
3281800179c9SKees Cook 	{
328230aba665SSalvatore Mesoraca 		.procname	= "protected_fifos",
328330aba665SSalvatore Mesoraca 		.data		= &sysctl_protected_fifos,
328430aba665SSalvatore Mesoraca 		.maxlen		= sizeof(int),
328530aba665SSalvatore Mesoraca 		.mode		= 0600,
328630aba665SSalvatore Mesoraca 		.proc_handler	= proc_dointvec_minmax,
3287eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
328830aba665SSalvatore Mesoraca 		.extra2		= &two,
328930aba665SSalvatore Mesoraca 	},
329030aba665SSalvatore Mesoraca 	{
329130aba665SSalvatore Mesoraca 		.procname	= "protected_regular",
329230aba665SSalvatore Mesoraca 		.data		= &sysctl_protected_regular,
329330aba665SSalvatore Mesoraca 		.maxlen		= sizeof(int),
329430aba665SSalvatore Mesoraca 		.mode		= 0600,
329530aba665SSalvatore Mesoraca 		.proc_handler	= proc_dointvec_minmax,
3296eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
329730aba665SSalvatore Mesoraca 		.extra2		= &two,
329830aba665SSalvatore Mesoraca 	},
329930aba665SSalvatore Mesoraca 	{
3300d6e71144SAlan Cox 		.procname	= "suid_dumpable",
3301d6e71144SAlan Cox 		.data		= &suid_dumpable,
3302d6e71144SAlan Cox 		.maxlen		= sizeof(int),
3303d6e71144SAlan Cox 		.mode		= 0644,
330454b50199SKees Cook 		.proc_handler	= proc_dointvec_minmax_coredump,
3305eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
33068e654fbaSMatthew Wilcox 		.extra2		= &two,
3307d6e71144SAlan Cox 	},
33082abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
33092abc26fcSEric W. Biederman 	{
33102abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
33112abc26fcSEric W. Biederman 		.mode		= 0555,
3312f9bd6733SEric W. Biederman 		.child		= sysctl_mount_point,
33132abc26fcSEric W. Biederman 	},
33142abc26fcSEric W. Biederman #endif
3315b492e95bSJens Axboe 	{
3316ff9da691SJens Axboe 		.procname	= "pipe-max-size",
3317ff9da691SJens Axboe 		.data		= &pipe_max_size,
331898159d97SJoe Lawrence 		.maxlen		= sizeof(pipe_max_size),
3319b492e95bSJens Axboe 		.mode		= 0644,
3320319e0a21SEric Biggers 		.proc_handler	= proc_dopipe_max_size,
3321b492e95bSJens Axboe 	},
3322759c0114SWilly Tarreau 	{
3323759c0114SWilly Tarreau 		.procname	= "pipe-user-pages-hard",
3324759c0114SWilly Tarreau 		.data		= &pipe_user_pages_hard,
3325759c0114SWilly Tarreau 		.maxlen		= sizeof(pipe_user_pages_hard),
3326759c0114SWilly Tarreau 		.mode		= 0644,
3327759c0114SWilly Tarreau 		.proc_handler	= proc_doulongvec_minmax,
3328759c0114SWilly Tarreau 	},
3329759c0114SWilly Tarreau 	{
3330759c0114SWilly Tarreau 		.procname	= "pipe-user-pages-soft",
3331759c0114SWilly Tarreau 		.data		= &pipe_user_pages_soft,
3332759c0114SWilly Tarreau 		.maxlen		= sizeof(pipe_user_pages_soft),
3333759c0114SWilly Tarreau 		.mode		= 0644,
3334759c0114SWilly Tarreau 		.proc_handler	= proc_doulongvec_minmax,
3335759c0114SWilly Tarreau 	},
3336d2921684SEric W. Biederman 	{
3337d2921684SEric W. Biederman 		.procname	= "mount-max",
3338d2921684SEric W. Biederman 		.data		= &sysctl_mount_max,
3339d2921684SEric W. Biederman 		.maxlen		= sizeof(unsigned int),
3340d2921684SEric W. Biederman 		.mode		= 0644,
3341d2921684SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3342eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
3343d2921684SEric W. Biederman 	},
33446fce56ecSEric W. Biederman 	{ }
33451da177e4SLinus Torvalds };
33461da177e4SLinus Torvalds 
3347d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
33487ac57a89SCatalin Marinas #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3349abd4f750SMasoud Asgharifard Sharbiani 	{
3350abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
3351abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
3352abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
3353abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
3354abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
3355abd4f750SMasoud Asgharifard Sharbiani 	},
3356abd4f750SMasoud Asgharifard Sharbiani #endif
3357b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES)
3358b2be84dfSMasami Hiramatsu 	{
3359b2be84dfSMasami Hiramatsu 		.procname	= "kprobes-optimization",
3360b2be84dfSMasami Hiramatsu 		.data		= &sysctl_kprobes_optimization,
3361b2be84dfSMasami Hiramatsu 		.maxlen		= sizeof(int),
3362b2be84dfSMasami Hiramatsu 		.mode		= 0644,
3363b2be84dfSMasami Hiramatsu 		.proc_handler	= proc_kprobes_optimization_handler,
3364eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3365eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3366b2be84dfSMasami Hiramatsu 	},
3367b2be84dfSMasami Hiramatsu #endif
33686fce56ecSEric W. Biederman 	{ }
33691da177e4SLinus Torvalds };
33701da177e4SLinus Torvalds 
3371d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
33726fce56ecSEric W. Biederman 	{ }
33731da177e4SLinus Torvalds };
33741da177e4SLinus Torvalds 
3375f461d2dcSChristoph Hellwig static struct ctl_table sysctl_base_table[] = {
3376f461d2dcSChristoph Hellwig 	{
3377f461d2dcSChristoph Hellwig 		.procname	= "kernel",
3378f461d2dcSChristoph Hellwig 		.mode		= 0555,
3379f461d2dcSChristoph Hellwig 		.child		= kern_table,
3380f461d2dcSChristoph Hellwig 	},
3381f461d2dcSChristoph Hellwig 	{
3382f461d2dcSChristoph Hellwig 		.procname	= "vm",
3383f461d2dcSChristoph Hellwig 		.mode		= 0555,
3384f461d2dcSChristoph Hellwig 		.child		= vm_table,
3385f461d2dcSChristoph Hellwig 	},
3386f461d2dcSChristoph Hellwig 	{
3387f461d2dcSChristoph Hellwig 		.procname	= "fs",
3388f461d2dcSChristoph Hellwig 		.mode		= 0555,
3389f461d2dcSChristoph Hellwig 		.child		= fs_table,
3390f461d2dcSChristoph Hellwig 	},
3391f461d2dcSChristoph Hellwig 	{
3392f461d2dcSChristoph Hellwig 		.procname	= "debug",
3393f461d2dcSChristoph Hellwig 		.mode		= 0555,
3394f461d2dcSChristoph Hellwig 		.child		= debug_table,
3395f461d2dcSChristoph Hellwig 	},
3396f461d2dcSChristoph Hellwig 	{
3397f461d2dcSChristoph Hellwig 		.procname	= "dev",
3398f461d2dcSChristoph Hellwig 		.mode		= 0555,
3399f461d2dcSChristoph Hellwig 		.child		= dev_table,
3400f461d2dcSChristoph Hellwig 	},
3401f461d2dcSChristoph Hellwig 	{ }
3402f461d2dcSChristoph Hellwig };
3403f461d2dcSChristoph Hellwig 
3404de4e83bdSEric W. Biederman int __init sysctl_init(void)
3405330d57fbSAl Viro {
3406fd4b616bSSteven Rostedt 	struct ctl_table_header *hdr;
3407fd4b616bSSteven Rostedt 
3408fd4b616bSSteven Rostedt 	hdr = register_sysctl_table(sysctl_base_table);
3409fd4b616bSSteven Rostedt 	kmemleak_not_leak(hdr);
3410330d57fbSAl Viro 	return 0;
3411f7e6ced4SAl Viro }
3412b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
34131da177e4SLinus Torvalds /*
34141da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
34151da177e4SLinus Torvalds  * exception granted :-)
34161da177e4SLinus Torvalds  */
34171da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
3418e7d316a0SSubash Abhinov Kasiviswanathan EXPORT_SYMBOL(proc_douintvec);
34191da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
34201da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
342161d9b56aSLuis R. Rodriguez EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
34221da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
34231da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
34241da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
34251da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
34261da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
34270bc19985SStephen Suryaputra EXPORT_SYMBOL(proc_do_large_bitmap);
3428