xref: /openbmc/linux/kernel/sysctl.c (revision f39650de687e35766572ac89dbcd16a5911e2f0a)
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>
30*f39650deSAndy Shevchenko #include <linux/panic.h>
31455cd5abSDan Rosenberg #include <linux/printk.h>
321da177e4SLinus Torvalds #include <linux/proc_fs.h>
3372c2d582SAndrew Morgan #include <linux/security.h>
341da177e4SLinus Torvalds #include <linux/ctype.h>
35fd4b616bSSteven Rostedt #include <linux/kmemleak.h>
3662239ac2SAdrian Bunk #include <linux/fs.h>
371da177e4SLinus Torvalds #include <linux/init.h>
381da177e4SLinus Torvalds #include <linux/kernel.h>
390296b228SKay Sievers #include <linux/kobject.h>
4020380731SArnaldo Carvalho de Melo #include <linux/net.h>
411da177e4SLinus Torvalds #include <linux/sysrq.h>
421da177e4SLinus Torvalds #include <linux/highuid.h>
431da177e4SLinus Torvalds #include <linux/writeback.h>
443fff4c42SIngo Molnar #include <linux/ratelimit.h>
4576ab0f53SMel Gorman #include <linux/compaction.h>
461da177e4SLinus Torvalds #include <linux/hugetlb.h>
471da177e4SLinus Torvalds #include <linux/initrd.h>
480b77f5bfSDavid Howells #include <linux/key.h>
491da177e4SLinus Torvalds #include <linux/times.h>
501da177e4SLinus Torvalds #include <linux/limits.h>
511da177e4SLinus Torvalds #include <linux/dcache.h>
526e006701SAlexey Dobriyan #include <linux/dnotify.h>
531da177e4SLinus Torvalds #include <linux/syscalls.h>
54c748e134SAdrian Bunk #include <linux/vmstat.h>
55c255d844SPavel Machek #include <linux/nfs_fs.h>
56c255d844SPavel Machek #include <linux/acpi.h>
5710a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h>
58b0fc494fSSteven Rostedt #include <linux/ftrace.h>
59cdd6c482SIngo Molnar #include <linux/perf_event.h>
60b2be84dfSMasami Hiramatsu #include <linux/kprobes.h>
61b492e95bSJens Axboe #include <linux/pipe_fs_i.h>
628e4228e1SDavid Rientjes #include <linux/oom.h>
6317f60a7dSEric Paris #include <linux/kmod.h>
6473efc039SDan Ballard #include <linux/capability.h>
6540401530SAl Viro #include <linux/binfmts.h>
66cf4aebc2SClark Williams #include <linux/sched/sysctl.h>
67f7ccbae4SIngo Molnar #include <linux/sched/coredump.h>
687984754bSKees Cook #include <linux/kexec.h>
691be7f75dSAlexei Starovoitov #include <linux/bpf.h>
70d2921684SEric W. Biederman #include <linux/mount.h>
71cefdca0aSPeter Xu #include <linux/userfaultfd_k.h>
722374c09bSChristoph Hellwig #include <linux/coredump.h>
732374c09bSChristoph Hellwig #include <linux/latencytop.h>
742374c09bSChristoph Hellwig #include <linux/pid.h>
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 }
22908389d88SDaniel Borkmann 
23008389d88SDaniel Borkmann static int bpf_unpriv_handler(struct ctl_table *table, int write,
23108389d88SDaniel Borkmann 			      void *buffer, size_t *lenp, loff_t *ppos)
23208389d88SDaniel Borkmann {
23308389d88SDaniel Borkmann 	int ret, unpriv_enable = *(int *)table->data;
23408389d88SDaniel Borkmann 	bool locked_state = unpriv_enable == 1;
23508389d88SDaniel Borkmann 	struct ctl_table tmp = *table;
23608389d88SDaniel Borkmann 
23708389d88SDaniel Borkmann 	if (write && !capable(CAP_SYS_ADMIN))
23808389d88SDaniel Borkmann 		return -EPERM;
23908389d88SDaniel Borkmann 
24008389d88SDaniel Borkmann 	tmp.data = &unpriv_enable;
24108389d88SDaniel Borkmann 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
24208389d88SDaniel Borkmann 	if (write && !ret) {
24308389d88SDaniel Borkmann 		if (locked_state && unpriv_enable != 1)
24408389d88SDaniel Borkmann 			return -EPERM;
24508389d88SDaniel Borkmann 		*(int *)table->data = unpriv_enable;
24608389d88SDaniel Borkmann 	}
24708389d88SDaniel Borkmann 	return ret;
24808389d88SDaniel Borkmann }
24908389d88SDaniel Borkmann #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */
250d46edd67SSong Liu 
251f461d2dcSChristoph Hellwig /*
252f461d2dcSChristoph Hellwig  * /proc/sys support
253f461d2dcSChristoph Hellwig  */
254f461d2dcSChristoph Hellwig 
255f461d2dcSChristoph Hellwig #ifdef CONFIG_PROC_SYSCTL
256f461d2dcSChristoph Hellwig 
257f461d2dcSChristoph Hellwig static int _proc_do_string(char *data, int maxlen, int write,
25832927393SChristoph Hellwig 		char *buffer, size_t *lenp, loff_t *ppos)
259f461d2dcSChristoph Hellwig {
260f461d2dcSChristoph Hellwig 	size_t len;
26132927393SChristoph Hellwig 	char c, *p;
262f461d2dcSChristoph Hellwig 
263f461d2dcSChristoph Hellwig 	if (!data || !maxlen || !*lenp) {
264f461d2dcSChristoph Hellwig 		*lenp = 0;
265f461d2dcSChristoph Hellwig 		return 0;
266f461d2dcSChristoph Hellwig 	}
267f461d2dcSChristoph Hellwig 
268f461d2dcSChristoph Hellwig 	if (write) {
269f461d2dcSChristoph Hellwig 		if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
270f461d2dcSChristoph Hellwig 			/* Only continue writes not past the end of buffer. */
271f461d2dcSChristoph Hellwig 			len = strlen(data);
272f461d2dcSChristoph Hellwig 			if (len > maxlen - 1)
273f461d2dcSChristoph Hellwig 				len = maxlen - 1;
274f461d2dcSChristoph Hellwig 
275f461d2dcSChristoph Hellwig 			if (*ppos > len)
276f461d2dcSChristoph Hellwig 				return 0;
277f461d2dcSChristoph Hellwig 			len = *ppos;
278f461d2dcSChristoph Hellwig 		} else {
279f461d2dcSChristoph Hellwig 			/* Start writing from beginning of buffer. */
280f461d2dcSChristoph Hellwig 			len = 0;
281f461d2dcSChristoph Hellwig 		}
282f461d2dcSChristoph Hellwig 
283f461d2dcSChristoph Hellwig 		*ppos += *lenp;
284f461d2dcSChristoph Hellwig 		p = buffer;
285f461d2dcSChristoph Hellwig 		while ((p - buffer) < *lenp && len < maxlen - 1) {
28632927393SChristoph Hellwig 			c = *(p++);
287f461d2dcSChristoph Hellwig 			if (c == 0 || c == '\n')
288f461d2dcSChristoph Hellwig 				break;
289f461d2dcSChristoph Hellwig 			data[len++] = c;
290f461d2dcSChristoph Hellwig 		}
291f461d2dcSChristoph Hellwig 		data[len] = 0;
292f461d2dcSChristoph Hellwig 	} else {
293f461d2dcSChristoph Hellwig 		len = strlen(data);
294f461d2dcSChristoph Hellwig 		if (len > maxlen)
295f461d2dcSChristoph Hellwig 			len = maxlen;
296f461d2dcSChristoph Hellwig 
297f461d2dcSChristoph Hellwig 		if (*ppos > len) {
298f461d2dcSChristoph Hellwig 			*lenp = 0;
299f461d2dcSChristoph Hellwig 			return 0;
300f461d2dcSChristoph Hellwig 		}
301f461d2dcSChristoph Hellwig 
302f461d2dcSChristoph Hellwig 		data += *ppos;
303f461d2dcSChristoph Hellwig 		len  -= *ppos;
304f461d2dcSChristoph Hellwig 
305f461d2dcSChristoph Hellwig 		if (len > *lenp)
306f461d2dcSChristoph Hellwig 			len = *lenp;
307f461d2dcSChristoph Hellwig 		if (len)
30832927393SChristoph Hellwig 			memcpy(buffer, data, len);
309f461d2dcSChristoph Hellwig 		if (len < *lenp) {
31032927393SChristoph Hellwig 			buffer[len] = '\n';
311f461d2dcSChristoph Hellwig 			len++;
312f461d2dcSChristoph Hellwig 		}
313f461d2dcSChristoph Hellwig 		*lenp = len;
314f461d2dcSChristoph Hellwig 		*ppos += len;
315f461d2dcSChristoph Hellwig 	}
316f461d2dcSChristoph Hellwig 	return 0;
317f461d2dcSChristoph Hellwig }
318f461d2dcSChristoph Hellwig 
319f461d2dcSChristoph Hellwig static void warn_sysctl_write(struct ctl_table *table)
320f461d2dcSChristoph Hellwig {
321f461d2dcSChristoph Hellwig 	pr_warn_once("%s wrote to %s when file position was not 0!\n"
322f461d2dcSChristoph Hellwig 		"This will not be supported in the future. To silence this\n"
323f461d2dcSChristoph Hellwig 		"warning, set kernel.sysctl_writes_strict = -1\n",
324f461d2dcSChristoph Hellwig 		current->comm, table->procname);
325f461d2dcSChristoph Hellwig }
326f461d2dcSChristoph Hellwig 
327f461d2dcSChristoph Hellwig /**
328f461d2dcSChristoph Hellwig  * proc_first_pos_non_zero_ignore - check if first position is allowed
329f461d2dcSChristoph Hellwig  * @ppos: file position
330f461d2dcSChristoph Hellwig  * @table: the sysctl table
331f461d2dcSChristoph Hellwig  *
332f461d2dcSChristoph Hellwig  * Returns true if the first position is non-zero and the sysctl_writes_strict
333f461d2dcSChristoph Hellwig  * mode indicates this is not allowed for numeric input types. String proc
334f461d2dcSChristoph Hellwig  * handlers can ignore the return value.
335f461d2dcSChristoph Hellwig  */
336f461d2dcSChristoph Hellwig static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
337f461d2dcSChristoph Hellwig 					   struct ctl_table *table)
338f461d2dcSChristoph Hellwig {
339f461d2dcSChristoph Hellwig 	if (!*ppos)
340f461d2dcSChristoph Hellwig 		return false;
341f461d2dcSChristoph Hellwig 
342f461d2dcSChristoph Hellwig 	switch (sysctl_writes_strict) {
343f461d2dcSChristoph Hellwig 	case SYSCTL_WRITES_STRICT:
344f461d2dcSChristoph Hellwig 		return true;
345f461d2dcSChristoph Hellwig 	case SYSCTL_WRITES_WARN:
346f461d2dcSChristoph Hellwig 		warn_sysctl_write(table);
347f461d2dcSChristoph Hellwig 		return false;
348f461d2dcSChristoph Hellwig 	default:
349f461d2dcSChristoph Hellwig 		return false;
350f461d2dcSChristoph Hellwig 	}
351f461d2dcSChristoph Hellwig }
352f461d2dcSChristoph Hellwig 
353f461d2dcSChristoph Hellwig /**
354f461d2dcSChristoph Hellwig  * proc_dostring - read a string sysctl
355f461d2dcSChristoph Hellwig  * @table: the sysctl table
356f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
357f461d2dcSChristoph Hellwig  * @buffer: the user buffer
358f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
359f461d2dcSChristoph Hellwig  * @ppos: file position
360f461d2dcSChristoph Hellwig  *
361f461d2dcSChristoph Hellwig  * Reads/writes a string from/to the user buffer. If the kernel
362f461d2dcSChristoph Hellwig  * buffer provided is not large enough to hold the string, the
363f461d2dcSChristoph Hellwig  * string is truncated. The copied string is %NULL-terminated.
364f461d2dcSChristoph Hellwig  * If the string is being read by the user process, it is copied
365f461d2dcSChristoph Hellwig  * and a newline '\n' is added. It is truncated if the buffer is
366f461d2dcSChristoph Hellwig  * not large enough.
367f461d2dcSChristoph Hellwig  *
368f461d2dcSChristoph Hellwig  * Returns 0 on success.
369f461d2dcSChristoph Hellwig  */
370f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write,
37132927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
372f461d2dcSChristoph Hellwig {
373f461d2dcSChristoph Hellwig 	if (write)
374f461d2dcSChristoph Hellwig 		proc_first_pos_non_zero_ignore(ppos, table);
375f461d2dcSChristoph Hellwig 
37632927393SChristoph Hellwig 	return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
37732927393SChristoph Hellwig 			ppos);
378f461d2dcSChristoph Hellwig }
379f461d2dcSChristoph Hellwig 
380f461d2dcSChristoph Hellwig static size_t proc_skip_spaces(char **buf)
381f461d2dcSChristoph Hellwig {
382f461d2dcSChristoph Hellwig 	size_t ret;
383f461d2dcSChristoph Hellwig 	char *tmp = skip_spaces(*buf);
384f461d2dcSChristoph Hellwig 	ret = tmp - *buf;
385f461d2dcSChristoph Hellwig 	*buf = tmp;
386f461d2dcSChristoph Hellwig 	return ret;
387f461d2dcSChristoph Hellwig }
388f461d2dcSChristoph Hellwig 
389f461d2dcSChristoph Hellwig static void proc_skip_char(char **buf, size_t *size, const char v)
390f461d2dcSChristoph Hellwig {
391f461d2dcSChristoph Hellwig 	while (*size) {
392f461d2dcSChristoph Hellwig 		if (**buf != v)
393f461d2dcSChristoph Hellwig 			break;
394f461d2dcSChristoph Hellwig 		(*size)--;
395f461d2dcSChristoph Hellwig 		(*buf)++;
396f461d2dcSChristoph Hellwig 	}
397f461d2dcSChristoph Hellwig }
398f461d2dcSChristoph Hellwig 
399f461d2dcSChristoph Hellwig /**
400f461d2dcSChristoph Hellwig  * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
401f461d2dcSChristoph Hellwig  *                   fail on overflow
402f461d2dcSChristoph Hellwig  *
403f461d2dcSChristoph Hellwig  * @cp: kernel buffer containing the string to parse
404f461d2dcSChristoph Hellwig  * @endp: pointer to store the trailing characters
405f461d2dcSChristoph Hellwig  * @base: the base to use
406f461d2dcSChristoph Hellwig  * @res: where the parsed integer will be stored
407f461d2dcSChristoph Hellwig  *
408f461d2dcSChristoph Hellwig  * In case of success 0 is returned and @res will contain the parsed integer,
409f461d2dcSChristoph Hellwig  * @endp will hold any trailing characters.
410f461d2dcSChristoph Hellwig  * This function will fail the parse on overflow. If there wasn't an overflow
411f461d2dcSChristoph Hellwig  * the function will defer the decision what characters count as invalid to the
412f461d2dcSChristoph Hellwig  * caller.
413f461d2dcSChristoph Hellwig  */
414f461d2dcSChristoph Hellwig static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
415f461d2dcSChristoph Hellwig 			   unsigned long *res)
416f461d2dcSChristoph Hellwig {
417f461d2dcSChristoph Hellwig 	unsigned long long result;
418f461d2dcSChristoph Hellwig 	unsigned int rv;
419f461d2dcSChristoph Hellwig 
420f461d2dcSChristoph Hellwig 	cp = _parse_integer_fixup_radix(cp, &base);
421f461d2dcSChristoph Hellwig 	rv = _parse_integer(cp, base, &result);
422f461d2dcSChristoph Hellwig 	if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
423f461d2dcSChristoph Hellwig 		return -ERANGE;
424f461d2dcSChristoph Hellwig 
425f461d2dcSChristoph Hellwig 	cp += rv;
426f461d2dcSChristoph Hellwig 
427f461d2dcSChristoph Hellwig 	if (endp)
428f461d2dcSChristoph Hellwig 		*endp = (char *)cp;
429f461d2dcSChristoph Hellwig 
430f461d2dcSChristoph Hellwig 	*res = (unsigned long)result;
431f461d2dcSChristoph Hellwig 	return 0;
432f461d2dcSChristoph Hellwig }
433f461d2dcSChristoph Hellwig 
434f461d2dcSChristoph Hellwig #define TMPBUFLEN 22
435f461d2dcSChristoph Hellwig /**
436f461d2dcSChristoph Hellwig  * proc_get_long - reads an ASCII formatted integer from a user buffer
437f461d2dcSChristoph Hellwig  *
438f461d2dcSChristoph Hellwig  * @buf: a kernel buffer
439f461d2dcSChristoph Hellwig  * @size: size of the kernel buffer
440f461d2dcSChristoph Hellwig  * @val: this is where the number will be stored
441f461d2dcSChristoph Hellwig  * @neg: set to %TRUE if number is negative
442f461d2dcSChristoph Hellwig  * @perm_tr: a vector which contains the allowed trailers
443f461d2dcSChristoph Hellwig  * @perm_tr_len: size of the perm_tr vector
444f461d2dcSChristoph Hellwig  * @tr: pointer to store the trailer character
445f461d2dcSChristoph Hellwig  *
446f461d2dcSChristoph Hellwig  * In case of success %0 is returned and @buf and @size are updated with
447f461d2dcSChristoph Hellwig  * the amount of bytes read. If @tr is non-NULL and a trailing
448f461d2dcSChristoph Hellwig  * character exists (size is non-zero after returning from this
449f461d2dcSChristoph Hellwig  * function), @tr is updated with the trailing character.
450f461d2dcSChristoph Hellwig  */
451f461d2dcSChristoph Hellwig static int proc_get_long(char **buf, size_t *size,
452f461d2dcSChristoph Hellwig 			  unsigned long *val, bool *neg,
453f461d2dcSChristoph Hellwig 			  const char *perm_tr, unsigned perm_tr_len, char *tr)
454f461d2dcSChristoph Hellwig {
455f461d2dcSChristoph Hellwig 	int len;
456f461d2dcSChristoph Hellwig 	char *p, tmp[TMPBUFLEN];
457f461d2dcSChristoph Hellwig 
458f461d2dcSChristoph Hellwig 	if (!*size)
459f461d2dcSChristoph Hellwig 		return -EINVAL;
460f461d2dcSChristoph Hellwig 
461f461d2dcSChristoph Hellwig 	len = *size;
462f461d2dcSChristoph Hellwig 	if (len > TMPBUFLEN - 1)
463f461d2dcSChristoph Hellwig 		len = TMPBUFLEN - 1;
464f461d2dcSChristoph Hellwig 
465f461d2dcSChristoph Hellwig 	memcpy(tmp, *buf, len);
466f461d2dcSChristoph Hellwig 
467f461d2dcSChristoph Hellwig 	tmp[len] = 0;
468f461d2dcSChristoph Hellwig 	p = tmp;
469f461d2dcSChristoph Hellwig 	if (*p == '-' && *size > 1) {
470f461d2dcSChristoph Hellwig 		*neg = true;
471f461d2dcSChristoph Hellwig 		p++;
472f461d2dcSChristoph Hellwig 	} else
473f461d2dcSChristoph Hellwig 		*neg = false;
474f461d2dcSChristoph Hellwig 	if (!isdigit(*p))
475f461d2dcSChristoph Hellwig 		return -EINVAL;
476f461d2dcSChristoph Hellwig 
477f461d2dcSChristoph Hellwig 	if (strtoul_lenient(p, &p, 0, val))
478f461d2dcSChristoph Hellwig 		return -EINVAL;
479f461d2dcSChristoph Hellwig 
480f461d2dcSChristoph Hellwig 	len = p - tmp;
481f461d2dcSChristoph Hellwig 
482f461d2dcSChristoph Hellwig 	/* We don't know if the next char is whitespace thus we may accept
483f461d2dcSChristoph Hellwig 	 * invalid integers (e.g. 1234...a) or two integers instead of one
484f461d2dcSChristoph Hellwig 	 * (e.g. 123...1). So lets not allow such large numbers. */
485f461d2dcSChristoph Hellwig 	if (len == TMPBUFLEN - 1)
486f461d2dcSChristoph Hellwig 		return -EINVAL;
487f461d2dcSChristoph Hellwig 
488f461d2dcSChristoph Hellwig 	if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
489f461d2dcSChristoph Hellwig 		return -EINVAL;
490f461d2dcSChristoph Hellwig 
491f461d2dcSChristoph Hellwig 	if (tr && (len < *size))
492f461d2dcSChristoph Hellwig 		*tr = *p;
493f461d2dcSChristoph Hellwig 
494f461d2dcSChristoph Hellwig 	*buf += len;
495f461d2dcSChristoph Hellwig 	*size -= len;
496f461d2dcSChristoph Hellwig 
497f461d2dcSChristoph Hellwig 	return 0;
498f461d2dcSChristoph Hellwig }
499f461d2dcSChristoph Hellwig 
500f461d2dcSChristoph Hellwig /**
501f461d2dcSChristoph Hellwig  * proc_put_long - converts an integer to a decimal ASCII formatted string
502f461d2dcSChristoph Hellwig  *
503f461d2dcSChristoph Hellwig  * @buf: the user buffer
504f461d2dcSChristoph Hellwig  * @size: the size of the user buffer
505f461d2dcSChristoph Hellwig  * @val: the integer to be converted
506f461d2dcSChristoph Hellwig  * @neg: sign of the number, %TRUE for negative
507f461d2dcSChristoph Hellwig  *
50832927393SChristoph Hellwig  * In case of success @buf and @size are updated with the amount of bytes
50932927393SChristoph Hellwig  * written.
510f461d2dcSChristoph Hellwig  */
51132927393SChristoph Hellwig static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
512f461d2dcSChristoph Hellwig {
513f461d2dcSChristoph Hellwig 	int len;
514f461d2dcSChristoph Hellwig 	char tmp[TMPBUFLEN], *p = tmp;
515f461d2dcSChristoph Hellwig 
516f461d2dcSChristoph Hellwig 	sprintf(p, "%s%lu", neg ? "-" : "", val);
517f461d2dcSChristoph Hellwig 	len = strlen(tmp);
518f461d2dcSChristoph Hellwig 	if (len > *size)
519f461d2dcSChristoph Hellwig 		len = *size;
52032927393SChristoph Hellwig 	memcpy(*buf, tmp, len);
521f461d2dcSChristoph Hellwig 	*size -= len;
522f461d2dcSChristoph Hellwig 	*buf += len;
523f461d2dcSChristoph Hellwig }
524f461d2dcSChristoph Hellwig #undef TMPBUFLEN
525f461d2dcSChristoph Hellwig 
52632927393SChristoph Hellwig static void proc_put_char(void **buf, size_t *size, char c)
527f461d2dcSChristoph Hellwig {
528f461d2dcSChristoph Hellwig 	if (*size) {
52932927393SChristoph Hellwig 		char **buffer = (char **)buf;
53032927393SChristoph Hellwig 		**buffer = c;
53132927393SChristoph Hellwig 
53232927393SChristoph Hellwig 		(*size)--;
53332927393SChristoph Hellwig 		(*buffer)++;
534f461d2dcSChristoph Hellwig 		*buf = *buffer;
535f461d2dcSChristoph Hellwig 	}
536f461d2dcSChristoph Hellwig }
537f461d2dcSChristoph Hellwig 
538f461d2dcSChristoph Hellwig static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
539f461d2dcSChristoph Hellwig 				 int *valp,
540f461d2dcSChristoph Hellwig 				 int write, void *data)
541f461d2dcSChristoph Hellwig {
542f461d2dcSChristoph Hellwig 	if (write) {
543f461d2dcSChristoph Hellwig 		if (*negp) {
544f461d2dcSChristoph Hellwig 			if (*lvalp > (unsigned long) INT_MAX + 1)
545f461d2dcSChristoph Hellwig 				return -EINVAL;
546f461d2dcSChristoph Hellwig 			*valp = -*lvalp;
547f461d2dcSChristoph Hellwig 		} else {
548f461d2dcSChristoph Hellwig 			if (*lvalp > (unsigned long) INT_MAX)
549f461d2dcSChristoph Hellwig 				return -EINVAL;
550f461d2dcSChristoph Hellwig 			*valp = *lvalp;
551f461d2dcSChristoph Hellwig 		}
552f461d2dcSChristoph Hellwig 	} else {
553f461d2dcSChristoph Hellwig 		int val = *valp;
554f461d2dcSChristoph Hellwig 		if (val < 0) {
555f461d2dcSChristoph Hellwig 			*negp = true;
556f461d2dcSChristoph Hellwig 			*lvalp = -(unsigned long)val;
557f461d2dcSChristoph Hellwig 		} else {
558f461d2dcSChristoph Hellwig 			*negp = false;
559f461d2dcSChristoph Hellwig 			*lvalp = (unsigned long)val;
560f461d2dcSChristoph Hellwig 		}
561f461d2dcSChristoph Hellwig 	}
562f461d2dcSChristoph Hellwig 	return 0;
563f461d2dcSChristoph Hellwig }
564f461d2dcSChristoph Hellwig 
565f461d2dcSChristoph Hellwig static int do_proc_douintvec_conv(unsigned long *lvalp,
566f461d2dcSChristoph Hellwig 				  unsigned int *valp,
567f461d2dcSChristoph Hellwig 				  int write, void *data)
568f461d2dcSChristoph Hellwig {
569f461d2dcSChristoph Hellwig 	if (write) {
570f461d2dcSChristoph Hellwig 		if (*lvalp > UINT_MAX)
571f461d2dcSChristoph Hellwig 			return -EINVAL;
572f461d2dcSChristoph Hellwig 		*valp = *lvalp;
573f461d2dcSChristoph Hellwig 	} else {
574f461d2dcSChristoph Hellwig 		unsigned int val = *valp;
575f461d2dcSChristoph Hellwig 		*lvalp = (unsigned long)val;
576f461d2dcSChristoph Hellwig 	}
577f461d2dcSChristoph Hellwig 	return 0;
578f461d2dcSChristoph Hellwig }
579f461d2dcSChristoph Hellwig 
580f461d2dcSChristoph Hellwig static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
581f461d2dcSChristoph Hellwig 
582f461d2dcSChristoph Hellwig static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
58332927393SChristoph Hellwig 		  int write, void *buffer,
584f461d2dcSChristoph Hellwig 		  size_t *lenp, loff_t *ppos,
585f461d2dcSChristoph Hellwig 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
586f461d2dcSChristoph Hellwig 			      int write, void *data),
587f461d2dcSChristoph Hellwig 		  void *data)
588f461d2dcSChristoph Hellwig {
589f461d2dcSChristoph Hellwig 	int *i, vleft, first = 1, err = 0;
590f461d2dcSChristoph Hellwig 	size_t left;
59132927393SChristoph Hellwig 	char *p;
592f461d2dcSChristoph Hellwig 
593f461d2dcSChristoph Hellwig 	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
594f461d2dcSChristoph Hellwig 		*lenp = 0;
595f461d2dcSChristoph Hellwig 		return 0;
596f461d2dcSChristoph Hellwig 	}
597f461d2dcSChristoph Hellwig 
598f461d2dcSChristoph Hellwig 	i = (int *) tbl_data;
599f461d2dcSChristoph Hellwig 	vleft = table->maxlen / sizeof(*i);
600f461d2dcSChristoph Hellwig 	left = *lenp;
601f461d2dcSChristoph Hellwig 
602f461d2dcSChristoph Hellwig 	if (!conv)
603f461d2dcSChristoph Hellwig 		conv = do_proc_dointvec_conv;
604f461d2dcSChristoph Hellwig 
605f461d2dcSChristoph Hellwig 	if (write) {
606f461d2dcSChristoph Hellwig 		if (proc_first_pos_non_zero_ignore(ppos, table))
607f461d2dcSChristoph Hellwig 			goto out;
608f461d2dcSChristoph Hellwig 
609f461d2dcSChristoph Hellwig 		if (left > PAGE_SIZE - 1)
610f461d2dcSChristoph Hellwig 			left = PAGE_SIZE - 1;
61132927393SChristoph Hellwig 		p = buffer;
612f461d2dcSChristoph Hellwig 	}
613f461d2dcSChristoph Hellwig 
614f461d2dcSChristoph Hellwig 	for (; left && vleft--; i++, first=0) {
615f461d2dcSChristoph Hellwig 		unsigned long lval;
616f461d2dcSChristoph Hellwig 		bool neg;
617f461d2dcSChristoph Hellwig 
618f461d2dcSChristoph Hellwig 		if (write) {
619f461d2dcSChristoph Hellwig 			left -= proc_skip_spaces(&p);
620f461d2dcSChristoph Hellwig 
621f461d2dcSChristoph Hellwig 			if (!left)
622f461d2dcSChristoph Hellwig 				break;
623f461d2dcSChristoph Hellwig 			err = proc_get_long(&p, &left, &lval, &neg,
624f461d2dcSChristoph Hellwig 					     proc_wspace_sep,
625f461d2dcSChristoph Hellwig 					     sizeof(proc_wspace_sep), NULL);
626f461d2dcSChristoph Hellwig 			if (err)
627f461d2dcSChristoph Hellwig 				break;
628f461d2dcSChristoph Hellwig 			if (conv(&neg, &lval, i, 1, data)) {
629f461d2dcSChristoph Hellwig 				err = -EINVAL;
630f461d2dcSChristoph Hellwig 				break;
631f461d2dcSChristoph Hellwig 			}
632f461d2dcSChristoph Hellwig 		} else {
633f461d2dcSChristoph Hellwig 			if (conv(&neg, &lval, i, 0, data)) {
634f461d2dcSChristoph Hellwig 				err = -EINVAL;
635f461d2dcSChristoph Hellwig 				break;
636f461d2dcSChristoph Hellwig 			}
637f461d2dcSChristoph Hellwig 			if (!first)
63832927393SChristoph Hellwig 				proc_put_char(&buffer, &left, '\t');
63932927393SChristoph Hellwig 			proc_put_long(&buffer, &left, lval, neg);
640f461d2dcSChristoph Hellwig 		}
641f461d2dcSChristoph Hellwig 	}
642f461d2dcSChristoph Hellwig 
643f461d2dcSChristoph Hellwig 	if (!write && !first && left && !err)
64432927393SChristoph Hellwig 		proc_put_char(&buffer, &left, '\n');
645f461d2dcSChristoph Hellwig 	if (write && !err && left)
646f461d2dcSChristoph Hellwig 		left -= proc_skip_spaces(&p);
64732927393SChristoph Hellwig 	if (write && first)
648f461d2dcSChristoph Hellwig 		return err ? : -EINVAL;
649f461d2dcSChristoph Hellwig 	*lenp -= left;
650f461d2dcSChristoph Hellwig out:
651f461d2dcSChristoph Hellwig 	*ppos += *lenp;
652f461d2dcSChristoph Hellwig 	return err;
653f461d2dcSChristoph Hellwig }
654f461d2dcSChristoph Hellwig 
655f461d2dcSChristoph Hellwig static int do_proc_dointvec(struct ctl_table *table, int write,
65632927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos,
657f461d2dcSChristoph Hellwig 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
658f461d2dcSChristoph Hellwig 			      int write, void *data),
659f461d2dcSChristoph Hellwig 		  void *data)
660f461d2dcSChristoph Hellwig {
661f461d2dcSChristoph Hellwig 	return __do_proc_dointvec(table->data, table, write,
662f461d2dcSChristoph Hellwig 			buffer, lenp, ppos, conv, data);
663f461d2dcSChristoph Hellwig }
664f461d2dcSChristoph Hellwig 
665f461d2dcSChristoph Hellwig static int do_proc_douintvec_w(unsigned int *tbl_data,
666f461d2dcSChristoph Hellwig 			       struct ctl_table *table,
66732927393SChristoph Hellwig 			       void *buffer,
668f461d2dcSChristoph Hellwig 			       size_t *lenp, loff_t *ppos,
669f461d2dcSChristoph Hellwig 			       int (*conv)(unsigned long *lvalp,
670f461d2dcSChristoph Hellwig 					   unsigned int *valp,
671f461d2dcSChristoph Hellwig 					   int write, void *data),
672f461d2dcSChristoph Hellwig 			       void *data)
673f461d2dcSChristoph Hellwig {
674f461d2dcSChristoph Hellwig 	unsigned long lval;
675f461d2dcSChristoph Hellwig 	int err = 0;
676f461d2dcSChristoph Hellwig 	size_t left;
677f461d2dcSChristoph Hellwig 	bool neg;
67832927393SChristoph Hellwig 	char *p = buffer;
679f461d2dcSChristoph Hellwig 
680f461d2dcSChristoph Hellwig 	left = *lenp;
681f461d2dcSChristoph Hellwig 
682f461d2dcSChristoph Hellwig 	if (proc_first_pos_non_zero_ignore(ppos, table))
683f461d2dcSChristoph Hellwig 		goto bail_early;
684f461d2dcSChristoph Hellwig 
685f461d2dcSChristoph Hellwig 	if (left > PAGE_SIZE - 1)
686f461d2dcSChristoph Hellwig 		left = PAGE_SIZE - 1;
687f461d2dcSChristoph Hellwig 
688f461d2dcSChristoph Hellwig 	left -= proc_skip_spaces(&p);
689f461d2dcSChristoph Hellwig 	if (!left) {
690f461d2dcSChristoph Hellwig 		err = -EINVAL;
691f461d2dcSChristoph Hellwig 		goto out_free;
692f461d2dcSChristoph Hellwig 	}
693f461d2dcSChristoph Hellwig 
694f461d2dcSChristoph Hellwig 	err = proc_get_long(&p, &left, &lval, &neg,
695f461d2dcSChristoph Hellwig 			     proc_wspace_sep,
696f461d2dcSChristoph Hellwig 			     sizeof(proc_wspace_sep), NULL);
697f461d2dcSChristoph Hellwig 	if (err || neg) {
698f461d2dcSChristoph Hellwig 		err = -EINVAL;
699f461d2dcSChristoph Hellwig 		goto out_free;
700f461d2dcSChristoph Hellwig 	}
701f461d2dcSChristoph Hellwig 
702f461d2dcSChristoph Hellwig 	if (conv(&lval, tbl_data, 1, data)) {
703f461d2dcSChristoph Hellwig 		err = -EINVAL;
704f461d2dcSChristoph Hellwig 		goto out_free;
705f461d2dcSChristoph Hellwig 	}
706f461d2dcSChristoph Hellwig 
707f461d2dcSChristoph Hellwig 	if (!err && left)
708f461d2dcSChristoph Hellwig 		left -= proc_skip_spaces(&p);
709f461d2dcSChristoph Hellwig 
710f461d2dcSChristoph Hellwig out_free:
711f461d2dcSChristoph Hellwig 	if (err)
712f461d2dcSChristoph Hellwig 		return -EINVAL;
713f461d2dcSChristoph Hellwig 
714f461d2dcSChristoph Hellwig 	return 0;
715f461d2dcSChristoph Hellwig 
716f461d2dcSChristoph Hellwig 	/* This is in keeping with old __do_proc_dointvec() */
717f461d2dcSChristoph Hellwig bail_early:
718f461d2dcSChristoph Hellwig 	*ppos += *lenp;
719f461d2dcSChristoph Hellwig 	return err;
720f461d2dcSChristoph Hellwig }
721f461d2dcSChristoph Hellwig 
72232927393SChristoph Hellwig static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
723f461d2dcSChristoph Hellwig 			       size_t *lenp, loff_t *ppos,
724f461d2dcSChristoph Hellwig 			       int (*conv)(unsigned long *lvalp,
725f461d2dcSChristoph Hellwig 					   unsigned int *valp,
726f461d2dcSChristoph Hellwig 					   int write, void *data),
727f461d2dcSChristoph Hellwig 			       void *data)
728f461d2dcSChristoph Hellwig {
729f461d2dcSChristoph Hellwig 	unsigned long lval;
730f461d2dcSChristoph Hellwig 	int err = 0;
731f461d2dcSChristoph Hellwig 	size_t left;
732f461d2dcSChristoph Hellwig 
733f461d2dcSChristoph Hellwig 	left = *lenp;
734f461d2dcSChristoph Hellwig 
735f461d2dcSChristoph Hellwig 	if (conv(&lval, tbl_data, 0, data)) {
736f461d2dcSChristoph Hellwig 		err = -EINVAL;
737f461d2dcSChristoph Hellwig 		goto out;
738f461d2dcSChristoph Hellwig 	}
739f461d2dcSChristoph Hellwig 
74032927393SChristoph Hellwig 	proc_put_long(&buffer, &left, lval, false);
74132927393SChristoph Hellwig 	if (!left)
742f461d2dcSChristoph Hellwig 		goto out;
743f461d2dcSChristoph Hellwig 
74432927393SChristoph Hellwig 	proc_put_char(&buffer, &left, '\n');
745f461d2dcSChristoph Hellwig 
746f461d2dcSChristoph Hellwig out:
747f461d2dcSChristoph Hellwig 	*lenp -= left;
748f461d2dcSChristoph Hellwig 	*ppos += *lenp;
749f461d2dcSChristoph Hellwig 
750f461d2dcSChristoph Hellwig 	return err;
751f461d2dcSChristoph Hellwig }
752f461d2dcSChristoph Hellwig 
753f461d2dcSChristoph Hellwig static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
75432927393SChristoph Hellwig 			       int write, void *buffer,
755f461d2dcSChristoph Hellwig 			       size_t *lenp, loff_t *ppos,
756f461d2dcSChristoph Hellwig 			       int (*conv)(unsigned long *lvalp,
757f461d2dcSChristoph Hellwig 					   unsigned int *valp,
758f461d2dcSChristoph Hellwig 					   int write, void *data),
759f461d2dcSChristoph Hellwig 			       void *data)
760f461d2dcSChristoph Hellwig {
761f461d2dcSChristoph Hellwig 	unsigned int *i, vleft;
762f461d2dcSChristoph Hellwig 
763f461d2dcSChristoph Hellwig 	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
764f461d2dcSChristoph Hellwig 		*lenp = 0;
765f461d2dcSChristoph Hellwig 		return 0;
766f461d2dcSChristoph Hellwig 	}
767f461d2dcSChristoph Hellwig 
768f461d2dcSChristoph Hellwig 	i = (unsigned int *) tbl_data;
769f461d2dcSChristoph Hellwig 	vleft = table->maxlen / sizeof(*i);
770f461d2dcSChristoph Hellwig 
771f461d2dcSChristoph Hellwig 	/*
772f461d2dcSChristoph Hellwig 	 * Arrays are not supported, keep this simple. *Do not* add
773f461d2dcSChristoph Hellwig 	 * support for them.
774f461d2dcSChristoph Hellwig 	 */
775f461d2dcSChristoph Hellwig 	if (vleft != 1) {
776f461d2dcSChristoph Hellwig 		*lenp = 0;
777f461d2dcSChristoph Hellwig 		return -EINVAL;
778f461d2dcSChristoph Hellwig 	}
779f461d2dcSChristoph Hellwig 
780f461d2dcSChristoph Hellwig 	if (!conv)
781f461d2dcSChristoph Hellwig 		conv = do_proc_douintvec_conv;
782f461d2dcSChristoph Hellwig 
783f461d2dcSChristoph Hellwig 	if (write)
784f461d2dcSChristoph Hellwig 		return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
785f461d2dcSChristoph Hellwig 					   conv, data);
786f461d2dcSChristoph Hellwig 	return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
787f461d2dcSChristoph Hellwig }
788f461d2dcSChristoph Hellwig 
789f461d2dcSChristoph Hellwig static int do_proc_douintvec(struct ctl_table *table, int write,
79032927393SChristoph Hellwig 			     void *buffer, size_t *lenp, loff_t *ppos,
791f461d2dcSChristoph Hellwig 			     int (*conv)(unsigned long *lvalp,
792f461d2dcSChristoph Hellwig 					 unsigned int *valp,
793f461d2dcSChristoph Hellwig 					 int write, void *data),
794f461d2dcSChristoph Hellwig 			     void *data)
795f461d2dcSChristoph Hellwig {
796f461d2dcSChristoph Hellwig 	return __do_proc_douintvec(table->data, table, write,
797f461d2dcSChristoph Hellwig 				   buffer, lenp, ppos, conv, data);
798f461d2dcSChristoph Hellwig }
799f461d2dcSChristoph Hellwig 
800f461d2dcSChristoph Hellwig /**
801f461d2dcSChristoph Hellwig  * proc_dointvec - read a vector of integers
802f461d2dcSChristoph Hellwig  * @table: the sysctl table
803f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
804f461d2dcSChristoph Hellwig  * @buffer: the user buffer
805f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
806f461d2dcSChristoph Hellwig  * @ppos: file position
807f461d2dcSChristoph Hellwig  *
808f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
809f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
810f461d2dcSChristoph Hellwig  *
811f461d2dcSChristoph Hellwig  * Returns 0 on success.
812f461d2dcSChristoph Hellwig  */
81332927393SChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, void *buffer,
81432927393SChristoph Hellwig 		  size_t *lenp, loff_t *ppos)
815f461d2dcSChristoph Hellwig {
816f461d2dcSChristoph Hellwig 	return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
817f461d2dcSChristoph Hellwig }
818f461d2dcSChristoph Hellwig 
819f461d2dcSChristoph Hellwig #ifdef CONFIG_COMPACTION
820f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
82132927393SChristoph Hellwig 		int write, void *buffer, size_t *lenp, loff_t *ppos)
822f461d2dcSChristoph Hellwig {
823f461d2dcSChristoph Hellwig 	int ret, old;
824f461d2dcSChristoph Hellwig 
825f461d2dcSChristoph Hellwig 	if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
826f461d2dcSChristoph Hellwig 		return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
827f461d2dcSChristoph Hellwig 
828f461d2dcSChristoph Hellwig 	old = *(int *)table->data;
829f461d2dcSChristoph Hellwig 	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
830f461d2dcSChristoph Hellwig 	if (ret)
831f461d2dcSChristoph Hellwig 		return ret;
832f461d2dcSChristoph Hellwig 	if (old != *(int *)table->data)
833f461d2dcSChristoph Hellwig 		pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
834f461d2dcSChristoph Hellwig 			     table->procname, current->comm,
835f461d2dcSChristoph Hellwig 			     task_pid_nr(current));
836f461d2dcSChristoph Hellwig 	return ret;
837f461d2dcSChristoph Hellwig }
838f461d2dcSChristoph Hellwig #endif
839f461d2dcSChristoph Hellwig 
840f461d2dcSChristoph Hellwig /**
841f461d2dcSChristoph Hellwig  * proc_douintvec - read a vector of unsigned integers
842f461d2dcSChristoph Hellwig  * @table: the sysctl table
843f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
844f461d2dcSChristoph Hellwig  * @buffer: the user buffer
845f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
846f461d2dcSChristoph Hellwig  * @ppos: file position
847f461d2dcSChristoph Hellwig  *
848f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
849f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
850f461d2dcSChristoph Hellwig  *
851f461d2dcSChristoph Hellwig  * Returns 0 on success.
852f461d2dcSChristoph Hellwig  */
85332927393SChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, void *buffer,
85432927393SChristoph Hellwig 		size_t *lenp, loff_t *ppos)
855f461d2dcSChristoph Hellwig {
856f461d2dcSChristoph Hellwig 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
857f461d2dcSChristoph Hellwig 				 do_proc_douintvec_conv, NULL);
858f461d2dcSChristoph Hellwig }
859f461d2dcSChristoph Hellwig 
860f461d2dcSChristoph Hellwig /*
861f461d2dcSChristoph Hellwig  * Taint values can only be increased
862f461d2dcSChristoph Hellwig  * This means we can safely use a temporary.
863f461d2dcSChristoph Hellwig  */
864f461d2dcSChristoph Hellwig static int proc_taint(struct ctl_table *table, int write,
86532927393SChristoph Hellwig 			       void *buffer, size_t *lenp, loff_t *ppos)
866f461d2dcSChristoph Hellwig {
867f461d2dcSChristoph Hellwig 	struct ctl_table t;
868f461d2dcSChristoph Hellwig 	unsigned long tmptaint = get_taint();
869f461d2dcSChristoph Hellwig 	int err;
870f461d2dcSChristoph Hellwig 
871f461d2dcSChristoph Hellwig 	if (write && !capable(CAP_SYS_ADMIN))
872f461d2dcSChristoph Hellwig 		return -EPERM;
873f461d2dcSChristoph Hellwig 
874f461d2dcSChristoph Hellwig 	t = *table;
875f461d2dcSChristoph Hellwig 	t.data = &tmptaint;
876f461d2dcSChristoph Hellwig 	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
877f461d2dcSChristoph Hellwig 	if (err < 0)
878f461d2dcSChristoph Hellwig 		return err;
879f461d2dcSChristoph Hellwig 
880f461d2dcSChristoph Hellwig 	if (write) {
881db38d5c1SRafael Aquini 		int i;
882db38d5c1SRafael Aquini 
883db38d5c1SRafael Aquini 		/*
884db38d5c1SRafael Aquini 		 * If we are relying on panic_on_taint not producing
885db38d5c1SRafael Aquini 		 * false positives due to userspace input, bail out
886db38d5c1SRafael Aquini 		 * before setting the requested taint flags.
887db38d5c1SRafael Aquini 		 */
888db38d5c1SRafael Aquini 		if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
889db38d5c1SRafael Aquini 			return -EINVAL;
890db38d5c1SRafael Aquini 
891f461d2dcSChristoph Hellwig 		/*
892f461d2dcSChristoph Hellwig 		 * Poor man's atomic or. Not worth adding a primitive
893f461d2dcSChristoph Hellwig 		 * to everyone's atomic.h for this
894f461d2dcSChristoph Hellwig 		 */
895e77132e7SRafael Aquini 		for (i = 0; i < TAINT_FLAGS_COUNT; i++)
896e77132e7SRafael Aquini 			if ((1UL << i) & tmptaint)
897f461d2dcSChristoph Hellwig 				add_taint(i, LOCKDEP_STILL_OK);
898f461d2dcSChristoph Hellwig 	}
899f461d2dcSChristoph Hellwig 
900f461d2dcSChristoph Hellwig 	return err;
901f461d2dcSChristoph Hellwig }
902f461d2dcSChristoph Hellwig 
903f461d2dcSChristoph Hellwig #ifdef CONFIG_PRINTK
904f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
90532927393SChristoph Hellwig 				void *buffer, size_t *lenp, loff_t *ppos)
906f461d2dcSChristoph Hellwig {
907f461d2dcSChristoph Hellwig 	if (write && !capable(CAP_SYS_ADMIN))
908f461d2dcSChristoph Hellwig 		return -EPERM;
909f461d2dcSChristoph Hellwig 
910f461d2dcSChristoph Hellwig 	return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
911f461d2dcSChristoph Hellwig }
912f461d2dcSChristoph Hellwig #endif
913f461d2dcSChristoph Hellwig 
914f461d2dcSChristoph Hellwig /**
915f461d2dcSChristoph Hellwig  * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
916f461d2dcSChristoph Hellwig  * @min: pointer to minimum allowable value
917f461d2dcSChristoph Hellwig  * @max: pointer to maximum allowable value
918f461d2dcSChristoph Hellwig  *
919f461d2dcSChristoph Hellwig  * The do_proc_dointvec_minmax_conv_param structure provides the
920f461d2dcSChristoph Hellwig  * minimum and maximum values for doing range checking for those sysctl
921f461d2dcSChristoph Hellwig  * parameters that use the proc_dointvec_minmax() handler.
922f461d2dcSChristoph Hellwig  */
923f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param {
924f461d2dcSChristoph Hellwig 	int *min;
925f461d2dcSChristoph Hellwig 	int *max;
926f461d2dcSChristoph Hellwig };
927f461d2dcSChristoph Hellwig 
928f461d2dcSChristoph Hellwig static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
929f461d2dcSChristoph Hellwig 					int *valp,
930f461d2dcSChristoph Hellwig 					int write, void *data)
931f461d2dcSChristoph Hellwig {
932f461d2dcSChristoph Hellwig 	int tmp, ret;
933f461d2dcSChristoph Hellwig 	struct do_proc_dointvec_minmax_conv_param *param = data;
934f461d2dcSChristoph Hellwig 	/*
935f461d2dcSChristoph Hellwig 	 * If writing, first do so via a temporary local int so we can
936f461d2dcSChristoph Hellwig 	 * bounds-check it before touching *valp.
937f461d2dcSChristoph Hellwig 	 */
938f461d2dcSChristoph Hellwig 	int *ip = write ? &tmp : valp;
939f461d2dcSChristoph Hellwig 
940f461d2dcSChristoph Hellwig 	ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
941f461d2dcSChristoph Hellwig 	if (ret)
942f461d2dcSChristoph Hellwig 		return ret;
943f461d2dcSChristoph Hellwig 
944f461d2dcSChristoph Hellwig 	if (write) {
945f461d2dcSChristoph Hellwig 		if ((param->min && *param->min > tmp) ||
946f461d2dcSChristoph Hellwig 		    (param->max && *param->max < tmp))
947f461d2dcSChristoph Hellwig 			return -EINVAL;
948f461d2dcSChristoph Hellwig 		*valp = tmp;
949f461d2dcSChristoph Hellwig 	}
950f461d2dcSChristoph Hellwig 
951f461d2dcSChristoph Hellwig 	return 0;
952f461d2dcSChristoph Hellwig }
953f461d2dcSChristoph Hellwig 
954f461d2dcSChristoph Hellwig /**
955f461d2dcSChristoph Hellwig  * proc_dointvec_minmax - read a vector of integers with min/max values
956f461d2dcSChristoph Hellwig  * @table: the sysctl table
957f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
958f461d2dcSChristoph Hellwig  * @buffer: the user buffer
959f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
960f461d2dcSChristoph Hellwig  * @ppos: file position
961f461d2dcSChristoph Hellwig  *
962f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
963f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
964f461d2dcSChristoph Hellwig  *
965f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
966f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max).
967f461d2dcSChristoph Hellwig  *
968f461d2dcSChristoph Hellwig  * Returns 0 on success or -EINVAL on write when the range check fails.
969f461d2dcSChristoph Hellwig  */
970f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write,
97132927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
972f461d2dcSChristoph Hellwig {
973f461d2dcSChristoph Hellwig 	struct do_proc_dointvec_minmax_conv_param param = {
974f461d2dcSChristoph Hellwig 		.min = (int *) table->extra1,
975f461d2dcSChristoph Hellwig 		.max = (int *) table->extra2,
976f461d2dcSChristoph Hellwig 	};
977f461d2dcSChristoph Hellwig 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
978f461d2dcSChristoph Hellwig 				do_proc_dointvec_minmax_conv, &param);
979f461d2dcSChristoph Hellwig }
980f461d2dcSChristoph Hellwig 
981f461d2dcSChristoph Hellwig /**
982f461d2dcSChristoph Hellwig  * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
983f461d2dcSChristoph Hellwig  * @min: pointer to minimum allowable value
984f461d2dcSChristoph Hellwig  * @max: pointer to maximum allowable value
985f461d2dcSChristoph Hellwig  *
986f461d2dcSChristoph Hellwig  * The do_proc_douintvec_minmax_conv_param structure provides the
987f461d2dcSChristoph Hellwig  * minimum and maximum values for doing range checking for those sysctl
988f461d2dcSChristoph Hellwig  * parameters that use the proc_douintvec_minmax() handler.
989f461d2dcSChristoph Hellwig  */
990f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param {
991f461d2dcSChristoph Hellwig 	unsigned int *min;
992f461d2dcSChristoph Hellwig 	unsigned int *max;
993f461d2dcSChristoph Hellwig };
994f461d2dcSChristoph Hellwig 
995f461d2dcSChristoph Hellwig static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
996f461d2dcSChristoph Hellwig 					 unsigned int *valp,
997f461d2dcSChristoph Hellwig 					 int write, void *data)
998f461d2dcSChristoph Hellwig {
999f461d2dcSChristoph Hellwig 	int ret;
1000f461d2dcSChristoph Hellwig 	unsigned int tmp;
1001f461d2dcSChristoph Hellwig 	struct do_proc_douintvec_minmax_conv_param *param = data;
1002f461d2dcSChristoph Hellwig 	/* write via temporary local uint for bounds-checking */
1003f461d2dcSChristoph Hellwig 	unsigned int *up = write ? &tmp : valp;
1004f461d2dcSChristoph Hellwig 
1005f461d2dcSChristoph Hellwig 	ret = do_proc_douintvec_conv(lvalp, up, write, data);
1006f461d2dcSChristoph Hellwig 	if (ret)
1007f461d2dcSChristoph Hellwig 		return ret;
1008f461d2dcSChristoph Hellwig 
1009f461d2dcSChristoph Hellwig 	if (write) {
1010f461d2dcSChristoph Hellwig 		if ((param->min && *param->min > tmp) ||
1011f461d2dcSChristoph Hellwig 		    (param->max && *param->max < tmp))
1012f461d2dcSChristoph Hellwig 			return -ERANGE;
1013f461d2dcSChristoph Hellwig 
1014f461d2dcSChristoph Hellwig 		*valp = tmp;
1015f461d2dcSChristoph Hellwig 	}
1016f461d2dcSChristoph Hellwig 
1017f461d2dcSChristoph Hellwig 	return 0;
1018f461d2dcSChristoph Hellwig }
1019f461d2dcSChristoph Hellwig 
1020f461d2dcSChristoph Hellwig /**
1021f461d2dcSChristoph Hellwig  * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1022f461d2dcSChristoph Hellwig  * @table: the sysctl table
1023f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1024f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1025f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1026f461d2dcSChristoph Hellwig  * @ppos: file position
1027f461d2dcSChristoph Hellwig  *
1028f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1029f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string. Negative
1030f461d2dcSChristoph Hellwig  * strings are not allowed.
1031f461d2dcSChristoph Hellwig  *
1032f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1033f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max). There is a final sanity
1034f461d2dcSChristoph Hellwig  * check for UINT_MAX to avoid having to support wrap around uses from
1035f461d2dcSChristoph Hellwig  * userspace.
1036f461d2dcSChristoph Hellwig  *
1037f461d2dcSChristoph Hellwig  * Returns 0 on success or -ERANGE on write when the range check fails.
1038f461d2dcSChristoph Hellwig  */
1039f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write,
104032927393SChristoph Hellwig 			  void *buffer, size_t *lenp, loff_t *ppos)
1041f461d2dcSChristoph Hellwig {
1042f461d2dcSChristoph Hellwig 	struct do_proc_douintvec_minmax_conv_param param = {
1043f461d2dcSChristoph Hellwig 		.min = (unsigned int *) table->extra1,
1044f461d2dcSChristoph Hellwig 		.max = (unsigned int *) table->extra2,
1045f461d2dcSChristoph Hellwig 	};
1046f461d2dcSChristoph Hellwig 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
1047f461d2dcSChristoph Hellwig 				 do_proc_douintvec_minmax_conv, &param);
1048f461d2dcSChristoph Hellwig }
1049f461d2dcSChristoph Hellwig 
1050cb944413SEric Dumazet /**
1051cb944413SEric Dumazet  * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1052cb944413SEric Dumazet  * @table: the sysctl table
1053cb944413SEric Dumazet  * @write: %TRUE if this is a write to the sysctl file
1054cb944413SEric Dumazet  * @buffer: the user buffer
1055cb944413SEric Dumazet  * @lenp: the size of the user buffer
1056cb944413SEric Dumazet  * @ppos: file position
1057cb944413SEric Dumazet  *
1058cb944413SEric Dumazet  * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1059cb944413SEric Dumazet  * values from/to the user buffer, treated as an ASCII string. Negative
1060cb944413SEric Dumazet  * strings are not allowed.
1061cb944413SEric Dumazet  *
1062cb944413SEric Dumazet  * This routine will ensure the values are within the range specified by
1063cb944413SEric Dumazet  * table->extra1 (min) and table->extra2 (max).
1064cb944413SEric Dumazet  *
1065cb944413SEric Dumazet  * Returns 0 on success or an error on write when the range check fails.
1066cb944413SEric Dumazet  */
1067cb944413SEric Dumazet int proc_dou8vec_minmax(struct ctl_table *table, int write,
1068cb944413SEric Dumazet 			void *buffer, size_t *lenp, loff_t *ppos)
1069cb944413SEric Dumazet {
1070cb944413SEric Dumazet 	struct ctl_table tmp;
1071cb944413SEric Dumazet 	unsigned int min = 0, max = 255U, val;
1072cb944413SEric Dumazet 	u8 *data = table->data;
1073cb944413SEric Dumazet 	struct do_proc_douintvec_minmax_conv_param param = {
1074cb944413SEric Dumazet 		.min = &min,
1075cb944413SEric Dumazet 		.max = &max,
1076cb944413SEric Dumazet 	};
1077cb944413SEric Dumazet 	int res;
1078cb944413SEric Dumazet 
1079cb944413SEric Dumazet 	/* Do not support arrays yet. */
1080cb944413SEric Dumazet 	if (table->maxlen != sizeof(u8))
1081cb944413SEric Dumazet 		return -EINVAL;
1082cb944413SEric Dumazet 
1083cb944413SEric Dumazet 	if (table->extra1) {
1084cb944413SEric Dumazet 		min = *(unsigned int *) table->extra1;
1085cb944413SEric Dumazet 		if (min > 255U)
1086cb944413SEric Dumazet 			return -EINVAL;
1087cb944413SEric Dumazet 	}
1088cb944413SEric Dumazet 	if (table->extra2) {
1089cb944413SEric Dumazet 		max = *(unsigned int *) table->extra2;
1090cb944413SEric Dumazet 		if (max > 255U)
1091cb944413SEric Dumazet 			return -EINVAL;
1092cb944413SEric Dumazet 	}
1093cb944413SEric Dumazet 
1094cb944413SEric Dumazet 	tmp = *table;
1095cb944413SEric Dumazet 
1096cb944413SEric Dumazet 	tmp.maxlen = sizeof(val);
1097cb944413SEric Dumazet 	tmp.data = &val;
1098cb944413SEric Dumazet 	val = *data;
1099cb944413SEric Dumazet 	res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1100cb944413SEric Dumazet 				do_proc_douintvec_minmax_conv, &param);
1101cb944413SEric Dumazet 	if (res)
1102cb944413SEric Dumazet 		return res;
1103cb944413SEric Dumazet 	if (write)
1104cb944413SEric Dumazet 		*data = val;
1105cb944413SEric Dumazet 	return 0;
1106cb944413SEric Dumazet }
1107cb944413SEric Dumazet EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1108cb944413SEric Dumazet 
1109f461d2dcSChristoph Hellwig static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1110f461d2dcSChristoph Hellwig 					unsigned int *valp,
1111f461d2dcSChristoph Hellwig 					int write, void *data)
1112f461d2dcSChristoph Hellwig {
1113f461d2dcSChristoph Hellwig 	if (write) {
1114f461d2dcSChristoph Hellwig 		unsigned int val;
1115f461d2dcSChristoph Hellwig 
1116f461d2dcSChristoph Hellwig 		val = round_pipe_size(*lvalp);
1117f461d2dcSChristoph Hellwig 		if (val == 0)
1118f461d2dcSChristoph Hellwig 			return -EINVAL;
1119f461d2dcSChristoph Hellwig 
1120f461d2dcSChristoph Hellwig 		*valp = val;
1121f461d2dcSChristoph Hellwig 	} else {
1122f461d2dcSChristoph Hellwig 		unsigned int val = *valp;
1123f461d2dcSChristoph Hellwig 		*lvalp = (unsigned long) val;
1124f461d2dcSChristoph Hellwig 	}
1125f461d2dcSChristoph Hellwig 
1126f461d2dcSChristoph Hellwig 	return 0;
1127f461d2dcSChristoph Hellwig }
1128f461d2dcSChristoph Hellwig 
1129f461d2dcSChristoph Hellwig static int proc_dopipe_max_size(struct ctl_table *table, int write,
113032927393SChristoph Hellwig 				void *buffer, size_t *lenp, loff_t *ppos)
1131f461d2dcSChristoph Hellwig {
1132f461d2dcSChristoph Hellwig 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
1133f461d2dcSChristoph Hellwig 				 do_proc_dopipe_max_size_conv, NULL);
1134f461d2dcSChristoph Hellwig }
1135f461d2dcSChristoph Hellwig 
1136f461d2dcSChristoph Hellwig static void validate_coredump_safety(void)
1137f461d2dcSChristoph Hellwig {
1138f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP
1139f461d2dcSChristoph Hellwig 	if (suid_dumpable == SUID_DUMP_ROOT &&
1140f461d2dcSChristoph Hellwig 	    core_pattern[0] != '/' && core_pattern[0] != '|') {
1141f461d2dcSChristoph Hellwig 		printk(KERN_WARNING
1142f461d2dcSChristoph Hellwig "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1143f461d2dcSChristoph Hellwig "Pipe handler or fully qualified core dump path required.\n"
1144f461d2dcSChristoph Hellwig "Set kernel.core_pattern before fs.suid_dumpable.\n"
1145f461d2dcSChristoph Hellwig 		);
1146f461d2dcSChristoph Hellwig 	}
1147f461d2dcSChristoph Hellwig #endif
1148f461d2dcSChristoph Hellwig }
1149f461d2dcSChristoph Hellwig 
1150f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
115132927393SChristoph Hellwig 		void *buffer, size_t *lenp, loff_t *ppos)
1152f461d2dcSChristoph Hellwig {
1153f461d2dcSChristoph Hellwig 	int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1154f461d2dcSChristoph Hellwig 	if (!error)
1155f461d2dcSChristoph Hellwig 		validate_coredump_safety();
1156f461d2dcSChristoph Hellwig 	return error;
1157f461d2dcSChristoph Hellwig }
1158f461d2dcSChristoph Hellwig 
1159f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP
1160f461d2dcSChristoph Hellwig static int proc_dostring_coredump(struct ctl_table *table, int write,
116132927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1162f461d2dcSChristoph Hellwig {
1163f461d2dcSChristoph Hellwig 	int error = proc_dostring(table, write, buffer, lenp, ppos);
1164f461d2dcSChristoph Hellwig 	if (!error)
1165f461d2dcSChristoph Hellwig 		validate_coredump_safety();
1166f461d2dcSChristoph Hellwig 	return error;
1167f461d2dcSChristoph Hellwig }
1168f461d2dcSChristoph Hellwig #endif
1169f461d2dcSChristoph Hellwig 
1170f461d2dcSChristoph Hellwig #ifdef CONFIG_MAGIC_SYSRQ
1171f461d2dcSChristoph Hellwig static int sysrq_sysctl_handler(struct ctl_table *table, int write,
117232927393SChristoph Hellwig 				void *buffer, size_t *lenp, loff_t *ppos)
1173f461d2dcSChristoph Hellwig {
1174f461d2dcSChristoph Hellwig 	int tmp, ret;
1175f461d2dcSChristoph Hellwig 
1176f461d2dcSChristoph Hellwig 	tmp = sysrq_mask();
1177f461d2dcSChristoph Hellwig 
1178f461d2dcSChristoph Hellwig 	ret = __do_proc_dointvec(&tmp, table, write, buffer,
1179f461d2dcSChristoph Hellwig 			       lenp, ppos, NULL, NULL);
1180f461d2dcSChristoph Hellwig 	if (ret || !write)
1181f461d2dcSChristoph Hellwig 		return ret;
1182f461d2dcSChristoph Hellwig 
1183f461d2dcSChristoph Hellwig 	if (write)
1184f461d2dcSChristoph Hellwig 		sysrq_toggle_support(tmp);
1185f461d2dcSChristoph Hellwig 
1186f461d2dcSChristoph Hellwig 	return 0;
1187f461d2dcSChristoph Hellwig }
1188f461d2dcSChristoph Hellwig #endif
1189f461d2dcSChristoph Hellwig 
119032927393SChristoph Hellwig static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
119132927393SChristoph Hellwig 		int write, void *buffer, size_t *lenp, loff_t *ppos,
119232927393SChristoph Hellwig 		unsigned long convmul, unsigned long convdiv)
1193f461d2dcSChristoph Hellwig {
1194f461d2dcSChristoph Hellwig 	unsigned long *i, *min, *max;
1195f461d2dcSChristoph Hellwig 	int vleft, first = 1, err = 0;
1196f461d2dcSChristoph Hellwig 	size_t left;
119732927393SChristoph Hellwig 	char *p;
1198f461d2dcSChristoph Hellwig 
1199f461d2dcSChristoph Hellwig 	if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1200f461d2dcSChristoph Hellwig 		*lenp = 0;
1201f461d2dcSChristoph Hellwig 		return 0;
1202f461d2dcSChristoph Hellwig 	}
1203f461d2dcSChristoph Hellwig 
1204f461d2dcSChristoph Hellwig 	i = (unsigned long *) data;
1205f461d2dcSChristoph Hellwig 	min = (unsigned long *) table->extra1;
1206f461d2dcSChristoph Hellwig 	max = (unsigned long *) table->extra2;
1207f461d2dcSChristoph Hellwig 	vleft = table->maxlen / sizeof(unsigned long);
1208f461d2dcSChristoph Hellwig 	left = *lenp;
1209f461d2dcSChristoph Hellwig 
1210f461d2dcSChristoph Hellwig 	if (write) {
1211f461d2dcSChristoph Hellwig 		if (proc_first_pos_non_zero_ignore(ppos, table))
1212f461d2dcSChristoph Hellwig 			goto out;
1213f461d2dcSChristoph Hellwig 
1214f461d2dcSChristoph Hellwig 		if (left > PAGE_SIZE - 1)
1215f461d2dcSChristoph Hellwig 			left = PAGE_SIZE - 1;
121632927393SChristoph Hellwig 		p = buffer;
1217f461d2dcSChristoph Hellwig 	}
1218f461d2dcSChristoph Hellwig 
1219f461d2dcSChristoph Hellwig 	for (; left && vleft--; i++, first = 0) {
1220f461d2dcSChristoph Hellwig 		unsigned long val;
1221f461d2dcSChristoph Hellwig 
1222f461d2dcSChristoph Hellwig 		if (write) {
1223f461d2dcSChristoph Hellwig 			bool neg;
1224f461d2dcSChristoph Hellwig 
1225f461d2dcSChristoph Hellwig 			left -= proc_skip_spaces(&p);
1226f461d2dcSChristoph Hellwig 			if (!left)
1227f461d2dcSChristoph Hellwig 				break;
1228f461d2dcSChristoph Hellwig 
1229f461d2dcSChristoph Hellwig 			err = proc_get_long(&p, &left, &val, &neg,
1230f461d2dcSChristoph Hellwig 					     proc_wspace_sep,
1231f461d2dcSChristoph Hellwig 					     sizeof(proc_wspace_sep), NULL);
1232f461d2dcSChristoph Hellwig 			if (err)
1233f461d2dcSChristoph Hellwig 				break;
1234f461d2dcSChristoph Hellwig 			if (neg)
1235f461d2dcSChristoph Hellwig 				continue;
1236f461d2dcSChristoph Hellwig 			val = convmul * val / convdiv;
1237f461d2dcSChristoph Hellwig 			if ((min && val < *min) || (max && val > *max)) {
1238f461d2dcSChristoph Hellwig 				err = -EINVAL;
1239f461d2dcSChristoph Hellwig 				break;
1240f461d2dcSChristoph Hellwig 			}
1241f461d2dcSChristoph Hellwig 			*i = val;
1242f461d2dcSChristoph Hellwig 		} else {
1243f461d2dcSChristoph Hellwig 			val = convdiv * (*i) / convmul;
124432927393SChristoph Hellwig 			if (!first)
124532927393SChristoph Hellwig 				proc_put_char(&buffer, &left, '\t');
124632927393SChristoph Hellwig 			proc_put_long(&buffer, &left, val, false);
1247f461d2dcSChristoph Hellwig 		}
1248f461d2dcSChristoph Hellwig 	}
1249f461d2dcSChristoph Hellwig 
1250f461d2dcSChristoph Hellwig 	if (!write && !first && left && !err)
125132927393SChristoph Hellwig 		proc_put_char(&buffer, &left, '\n');
1252f461d2dcSChristoph Hellwig 	if (write && !err)
1253f461d2dcSChristoph Hellwig 		left -= proc_skip_spaces(&p);
125432927393SChristoph Hellwig 	if (write && first)
1255f461d2dcSChristoph Hellwig 		return err ? : -EINVAL;
1256f461d2dcSChristoph Hellwig 	*lenp -= left;
1257f461d2dcSChristoph Hellwig out:
1258f461d2dcSChristoph Hellwig 	*ppos += *lenp;
1259f461d2dcSChristoph Hellwig 	return err;
1260f461d2dcSChristoph Hellwig }
1261f461d2dcSChristoph Hellwig 
1262f461d2dcSChristoph Hellwig static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
126332927393SChristoph Hellwig 		void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1264f461d2dcSChristoph Hellwig 		unsigned long convdiv)
1265f461d2dcSChristoph Hellwig {
1266f461d2dcSChristoph Hellwig 	return __do_proc_doulongvec_minmax(table->data, table, write,
1267f461d2dcSChristoph Hellwig 			buffer, lenp, ppos, convmul, convdiv);
1268f461d2dcSChristoph Hellwig }
1269f461d2dcSChristoph Hellwig 
1270f461d2dcSChristoph Hellwig /**
1271f461d2dcSChristoph Hellwig  * proc_doulongvec_minmax - read a vector of long integers with min/max values
1272f461d2dcSChristoph Hellwig  * @table: the sysctl table
1273f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1274f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1275f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1276f461d2dcSChristoph Hellwig  * @ppos: file position
1277f461d2dcSChristoph Hellwig  *
1278f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1279f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1280f461d2dcSChristoph Hellwig  *
1281f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1282f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max).
1283f461d2dcSChristoph Hellwig  *
1284f461d2dcSChristoph Hellwig  * Returns 0 on success.
1285f461d2dcSChristoph Hellwig  */
1286f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write,
128732927393SChristoph Hellwig 			   void *buffer, size_t *lenp, loff_t *ppos)
1288f461d2dcSChristoph Hellwig {
1289f461d2dcSChristoph Hellwig     return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1290f461d2dcSChristoph Hellwig }
1291f461d2dcSChristoph Hellwig 
1292f461d2dcSChristoph Hellwig /**
1293f461d2dcSChristoph Hellwig  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1294f461d2dcSChristoph Hellwig  * @table: the sysctl table
1295f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1296f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1297f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1298f461d2dcSChristoph Hellwig  * @ppos: file position
1299f461d2dcSChristoph Hellwig  *
1300f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1301f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string. The values
1302f461d2dcSChristoph Hellwig  * are treated as milliseconds, and converted to jiffies when they are stored.
1303f461d2dcSChristoph Hellwig  *
1304f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1305f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max).
1306f461d2dcSChristoph Hellwig  *
1307f461d2dcSChristoph Hellwig  * Returns 0 on success.
1308f461d2dcSChristoph Hellwig  */
1309f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
131032927393SChristoph Hellwig 				      void *buffer, size_t *lenp, loff_t *ppos)
1311f461d2dcSChristoph Hellwig {
1312f461d2dcSChristoph Hellwig     return do_proc_doulongvec_minmax(table, write, buffer,
1313f461d2dcSChristoph Hellwig 				     lenp, ppos, HZ, 1000l);
1314f461d2dcSChristoph Hellwig }
1315f461d2dcSChristoph Hellwig 
1316f461d2dcSChristoph Hellwig 
1317f461d2dcSChristoph Hellwig static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1318f461d2dcSChristoph Hellwig 					 int *valp,
1319f461d2dcSChristoph Hellwig 					 int write, void *data)
1320f461d2dcSChristoph Hellwig {
1321f461d2dcSChristoph Hellwig 	if (write) {
1322f461d2dcSChristoph Hellwig 		if (*lvalp > INT_MAX / HZ)
1323f461d2dcSChristoph Hellwig 			return 1;
1324f461d2dcSChristoph Hellwig 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1325f461d2dcSChristoph Hellwig 	} else {
1326f461d2dcSChristoph Hellwig 		int val = *valp;
1327f461d2dcSChristoph Hellwig 		unsigned long lval;
1328f461d2dcSChristoph Hellwig 		if (val < 0) {
1329f461d2dcSChristoph Hellwig 			*negp = true;
1330f461d2dcSChristoph Hellwig 			lval = -(unsigned long)val;
1331f461d2dcSChristoph Hellwig 		} else {
1332f461d2dcSChristoph Hellwig 			*negp = false;
1333f461d2dcSChristoph Hellwig 			lval = (unsigned long)val;
1334f461d2dcSChristoph Hellwig 		}
1335f461d2dcSChristoph Hellwig 		*lvalp = lval / HZ;
1336f461d2dcSChristoph Hellwig 	}
1337f461d2dcSChristoph Hellwig 	return 0;
1338f461d2dcSChristoph Hellwig }
1339f461d2dcSChristoph Hellwig 
1340f461d2dcSChristoph Hellwig static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1341f461d2dcSChristoph Hellwig 						int *valp,
1342f461d2dcSChristoph Hellwig 						int write, void *data)
1343f461d2dcSChristoph Hellwig {
1344f461d2dcSChristoph Hellwig 	if (write) {
1345f461d2dcSChristoph Hellwig 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1346f461d2dcSChristoph Hellwig 			return 1;
1347f461d2dcSChristoph Hellwig 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1348f461d2dcSChristoph Hellwig 	} else {
1349f461d2dcSChristoph Hellwig 		int val = *valp;
1350f461d2dcSChristoph Hellwig 		unsigned long lval;
1351f461d2dcSChristoph Hellwig 		if (val < 0) {
1352f461d2dcSChristoph Hellwig 			*negp = true;
1353f461d2dcSChristoph Hellwig 			lval = -(unsigned long)val;
1354f461d2dcSChristoph Hellwig 		} else {
1355f461d2dcSChristoph Hellwig 			*negp = false;
1356f461d2dcSChristoph Hellwig 			lval = (unsigned long)val;
1357f461d2dcSChristoph Hellwig 		}
1358f461d2dcSChristoph Hellwig 		*lvalp = jiffies_to_clock_t(lval);
1359f461d2dcSChristoph Hellwig 	}
1360f461d2dcSChristoph Hellwig 	return 0;
1361f461d2dcSChristoph Hellwig }
1362f461d2dcSChristoph Hellwig 
1363f461d2dcSChristoph Hellwig static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1364f461d2dcSChristoph Hellwig 					    int *valp,
1365f461d2dcSChristoph Hellwig 					    int write, void *data)
1366f461d2dcSChristoph Hellwig {
1367f461d2dcSChristoph Hellwig 	if (write) {
1368f461d2dcSChristoph Hellwig 		unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1369f461d2dcSChristoph Hellwig 
1370f461d2dcSChristoph Hellwig 		if (jif > INT_MAX)
1371f461d2dcSChristoph Hellwig 			return 1;
1372f461d2dcSChristoph Hellwig 		*valp = (int)jif;
1373f461d2dcSChristoph Hellwig 	} else {
1374f461d2dcSChristoph Hellwig 		int val = *valp;
1375f461d2dcSChristoph Hellwig 		unsigned long lval;
1376f461d2dcSChristoph Hellwig 		if (val < 0) {
1377f461d2dcSChristoph Hellwig 			*negp = true;
1378f461d2dcSChristoph Hellwig 			lval = -(unsigned long)val;
1379f461d2dcSChristoph Hellwig 		} else {
1380f461d2dcSChristoph Hellwig 			*negp = false;
1381f461d2dcSChristoph Hellwig 			lval = (unsigned long)val;
1382f461d2dcSChristoph Hellwig 		}
1383f461d2dcSChristoph Hellwig 		*lvalp = jiffies_to_msecs(lval);
1384f461d2dcSChristoph Hellwig 	}
1385f461d2dcSChristoph Hellwig 	return 0;
1386f461d2dcSChristoph Hellwig }
1387f461d2dcSChristoph Hellwig 
1388f461d2dcSChristoph Hellwig /**
1389f461d2dcSChristoph Hellwig  * proc_dointvec_jiffies - read a vector of integers as seconds
1390f461d2dcSChristoph Hellwig  * @table: the sysctl table
1391f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1392f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1393f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1394f461d2dcSChristoph Hellwig  * @ppos: file position
1395f461d2dcSChristoph Hellwig  *
1396f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1397f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1398f461d2dcSChristoph Hellwig  * The values read are assumed to be in seconds, and are converted into
1399f461d2dcSChristoph Hellwig  * jiffies.
1400f461d2dcSChristoph Hellwig  *
1401f461d2dcSChristoph Hellwig  * Returns 0 on success.
1402f461d2dcSChristoph Hellwig  */
1403f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write,
140432927393SChristoph Hellwig 			  void *buffer, size_t *lenp, loff_t *ppos)
1405f461d2dcSChristoph Hellwig {
1406f461d2dcSChristoph Hellwig     return do_proc_dointvec(table,write,buffer,lenp,ppos,
1407f461d2dcSChristoph Hellwig 		    	    do_proc_dointvec_jiffies_conv,NULL);
1408f461d2dcSChristoph Hellwig }
1409f461d2dcSChristoph Hellwig 
1410f461d2dcSChristoph Hellwig /**
1411f461d2dcSChristoph Hellwig  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1412f461d2dcSChristoph Hellwig  * @table: the sysctl table
1413f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1414f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1415f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1416f461d2dcSChristoph Hellwig  * @ppos: pointer to the file position
1417f461d2dcSChristoph Hellwig  *
1418f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1419f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1420f461d2dcSChristoph Hellwig  * The values read are assumed to be in 1/USER_HZ seconds, and
1421f461d2dcSChristoph Hellwig  * are converted into jiffies.
1422f461d2dcSChristoph Hellwig  *
1423f461d2dcSChristoph Hellwig  * Returns 0 on success.
1424f461d2dcSChristoph Hellwig  */
1425f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
142632927393SChristoph Hellwig 				 void *buffer, size_t *lenp, loff_t *ppos)
1427f461d2dcSChristoph Hellwig {
1428f461d2dcSChristoph Hellwig     return do_proc_dointvec(table,write,buffer,lenp,ppos,
1429f461d2dcSChristoph Hellwig 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
1430f461d2dcSChristoph Hellwig }
1431f461d2dcSChristoph Hellwig 
1432f461d2dcSChristoph Hellwig /**
1433f461d2dcSChristoph Hellwig  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1434f461d2dcSChristoph Hellwig  * @table: the sysctl table
1435f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1436f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1437f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1438f461d2dcSChristoph Hellwig  * @ppos: file position
1439f461d2dcSChristoph Hellwig  * @ppos: the current position in the file
1440f461d2dcSChristoph Hellwig  *
1441f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1442f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1443f461d2dcSChristoph Hellwig  * The values read are assumed to be in 1/1000 seconds, and
1444f461d2dcSChristoph Hellwig  * are converted into jiffies.
1445f461d2dcSChristoph Hellwig  *
1446f461d2dcSChristoph Hellwig  * Returns 0 on success.
1447f461d2dcSChristoph Hellwig  */
144832927393SChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
144932927393SChristoph Hellwig 		size_t *lenp, loff_t *ppos)
1450f461d2dcSChristoph Hellwig {
1451f461d2dcSChristoph Hellwig 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
1452f461d2dcSChristoph Hellwig 				do_proc_dointvec_ms_jiffies_conv, NULL);
1453f461d2dcSChristoph Hellwig }
1454f461d2dcSChristoph Hellwig 
145532927393SChristoph Hellwig static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
145632927393SChristoph Hellwig 		size_t *lenp, loff_t *ppos)
1457f461d2dcSChristoph Hellwig {
1458f461d2dcSChristoph Hellwig 	struct pid *new_pid;
1459f461d2dcSChristoph Hellwig 	pid_t tmp;
1460f461d2dcSChristoph Hellwig 	int r;
1461f461d2dcSChristoph Hellwig 
1462f461d2dcSChristoph Hellwig 	tmp = pid_vnr(cad_pid);
1463f461d2dcSChristoph Hellwig 
1464f461d2dcSChristoph Hellwig 	r = __do_proc_dointvec(&tmp, table, write, buffer,
1465f461d2dcSChristoph Hellwig 			       lenp, ppos, NULL, NULL);
1466f461d2dcSChristoph Hellwig 	if (r || !write)
1467f461d2dcSChristoph Hellwig 		return r;
1468f461d2dcSChristoph Hellwig 
1469f461d2dcSChristoph Hellwig 	new_pid = find_get_pid(tmp);
1470f461d2dcSChristoph Hellwig 	if (!new_pid)
1471f461d2dcSChristoph Hellwig 		return -ESRCH;
1472f461d2dcSChristoph Hellwig 
1473f461d2dcSChristoph Hellwig 	put_pid(xchg(&cad_pid, new_pid));
1474f461d2dcSChristoph Hellwig 	return 0;
1475f461d2dcSChristoph Hellwig }
1476f461d2dcSChristoph Hellwig 
1477f461d2dcSChristoph Hellwig /**
1478f461d2dcSChristoph Hellwig  * proc_do_large_bitmap - read/write from/to a large bitmap
1479f461d2dcSChristoph Hellwig  * @table: the sysctl table
1480f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1481f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1482f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1483f461d2dcSChristoph Hellwig  * @ppos: file position
1484f461d2dcSChristoph Hellwig  *
1485f461d2dcSChristoph Hellwig  * The bitmap is stored at table->data and the bitmap length (in bits)
1486f461d2dcSChristoph Hellwig  * in table->maxlen.
1487f461d2dcSChristoph Hellwig  *
1488f461d2dcSChristoph Hellwig  * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1489f461d2dcSChristoph Hellwig  * large bitmaps may be represented in a compact manner. Writing into
1490f461d2dcSChristoph Hellwig  * the file will clear the bitmap then update it with the given input.
1491f461d2dcSChristoph Hellwig  *
1492f461d2dcSChristoph Hellwig  * Returns 0 on success.
1493f461d2dcSChristoph Hellwig  */
1494f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write,
149532927393SChristoph Hellwig 			 void *buffer, size_t *lenp, loff_t *ppos)
1496f461d2dcSChristoph Hellwig {
1497f461d2dcSChristoph Hellwig 	int err = 0;
1498f461d2dcSChristoph Hellwig 	size_t left = *lenp;
1499f461d2dcSChristoph Hellwig 	unsigned long bitmap_len = table->maxlen;
1500f461d2dcSChristoph Hellwig 	unsigned long *bitmap = *(unsigned long **) table->data;
1501f461d2dcSChristoph Hellwig 	unsigned long *tmp_bitmap = NULL;
1502f461d2dcSChristoph Hellwig 	char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1503f461d2dcSChristoph Hellwig 
1504f461d2dcSChristoph Hellwig 	if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1505f461d2dcSChristoph Hellwig 		*lenp = 0;
1506f461d2dcSChristoph Hellwig 		return 0;
1507f461d2dcSChristoph Hellwig 	}
1508f461d2dcSChristoph Hellwig 
1509f461d2dcSChristoph Hellwig 	if (write) {
151032927393SChristoph Hellwig 		char *p = buffer;
1511f461d2dcSChristoph Hellwig 		size_t skipped = 0;
1512f461d2dcSChristoph Hellwig 
1513f461d2dcSChristoph Hellwig 		if (left > PAGE_SIZE - 1) {
1514f461d2dcSChristoph Hellwig 			left = PAGE_SIZE - 1;
1515f461d2dcSChristoph Hellwig 			/* How much of the buffer we'll skip this pass */
1516f461d2dcSChristoph Hellwig 			skipped = *lenp - left;
1517f461d2dcSChristoph Hellwig 		}
1518f461d2dcSChristoph Hellwig 
1519f461d2dcSChristoph Hellwig 		tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
152032927393SChristoph Hellwig 		if (!tmp_bitmap)
1521f461d2dcSChristoph Hellwig 			return -ENOMEM;
1522f461d2dcSChristoph Hellwig 		proc_skip_char(&p, &left, '\n');
1523f461d2dcSChristoph Hellwig 		while (!err && left) {
1524f461d2dcSChristoph Hellwig 			unsigned long val_a, val_b;
1525f461d2dcSChristoph Hellwig 			bool neg;
1526f461d2dcSChristoph Hellwig 			size_t saved_left;
1527f461d2dcSChristoph Hellwig 
1528f461d2dcSChristoph Hellwig 			/* In case we stop parsing mid-number, we can reset */
1529f461d2dcSChristoph Hellwig 			saved_left = left;
1530f461d2dcSChristoph Hellwig 			err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1531f461d2dcSChristoph Hellwig 					     sizeof(tr_a), &c);
1532f461d2dcSChristoph Hellwig 			/*
1533f461d2dcSChristoph Hellwig 			 * If we consumed the entirety of a truncated buffer or
1534f461d2dcSChristoph Hellwig 			 * only one char is left (may be a "-"), then stop here,
1535f461d2dcSChristoph Hellwig 			 * reset, & come back for more.
1536f461d2dcSChristoph Hellwig 			 */
1537f461d2dcSChristoph Hellwig 			if ((left <= 1) && skipped) {
1538f461d2dcSChristoph Hellwig 				left = saved_left;
1539f461d2dcSChristoph Hellwig 				break;
1540f461d2dcSChristoph Hellwig 			}
1541f461d2dcSChristoph Hellwig 
1542f461d2dcSChristoph Hellwig 			if (err)
1543f461d2dcSChristoph Hellwig 				break;
1544f461d2dcSChristoph Hellwig 			if (val_a >= bitmap_len || neg) {
1545f461d2dcSChristoph Hellwig 				err = -EINVAL;
1546f461d2dcSChristoph Hellwig 				break;
1547f461d2dcSChristoph Hellwig 			}
1548f461d2dcSChristoph Hellwig 
1549f461d2dcSChristoph Hellwig 			val_b = val_a;
1550f461d2dcSChristoph Hellwig 			if (left) {
1551f461d2dcSChristoph Hellwig 				p++;
1552f461d2dcSChristoph Hellwig 				left--;
1553f461d2dcSChristoph Hellwig 			}
1554f461d2dcSChristoph Hellwig 
1555f461d2dcSChristoph Hellwig 			if (c == '-') {
1556f461d2dcSChristoph Hellwig 				err = proc_get_long(&p, &left, &val_b,
1557f461d2dcSChristoph Hellwig 						     &neg, tr_b, sizeof(tr_b),
1558f461d2dcSChristoph Hellwig 						     &c);
1559f461d2dcSChristoph Hellwig 				/*
1560f461d2dcSChristoph Hellwig 				 * If we consumed all of a truncated buffer or
1561f461d2dcSChristoph Hellwig 				 * then stop here, reset, & come back for more.
1562f461d2dcSChristoph Hellwig 				 */
1563f461d2dcSChristoph Hellwig 				if (!left && skipped) {
1564f461d2dcSChristoph Hellwig 					left = saved_left;
1565f461d2dcSChristoph Hellwig 					break;
1566f461d2dcSChristoph Hellwig 				}
1567f461d2dcSChristoph Hellwig 
1568f461d2dcSChristoph Hellwig 				if (err)
1569f461d2dcSChristoph Hellwig 					break;
1570f461d2dcSChristoph Hellwig 				if (val_b >= bitmap_len || neg ||
1571f461d2dcSChristoph Hellwig 				    val_a > val_b) {
1572f461d2dcSChristoph Hellwig 					err = -EINVAL;
1573f461d2dcSChristoph Hellwig 					break;
1574f461d2dcSChristoph Hellwig 				}
1575f461d2dcSChristoph Hellwig 				if (left) {
1576f461d2dcSChristoph Hellwig 					p++;
1577f461d2dcSChristoph Hellwig 					left--;
1578f461d2dcSChristoph Hellwig 				}
1579f461d2dcSChristoph Hellwig 			}
1580f461d2dcSChristoph Hellwig 
1581f461d2dcSChristoph Hellwig 			bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1582f461d2dcSChristoph Hellwig 			proc_skip_char(&p, &left, '\n');
1583f461d2dcSChristoph Hellwig 		}
1584f461d2dcSChristoph Hellwig 		left += skipped;
1585f461d2dcSChristoph Hellwig 	} else {
1586f461d2dcSChristoph Hellwig 		unsigned long bit_a, bit_b = 0;
15879a52c5f3SJiapeng Chong 		bool first = 1;
1588f461d2dcSChristoph Hellwig 
1589f461d2dcSChristoph Hellwig 		while (left) {
1590f461d2dcSChristoph Hellwig 			bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1591f461d2dcSChristoph Hellwig 			if (bit_a >= bitmap_len)
1592f461d2dcSChristoph Hellwig 				break;
1593f461d2dcSChristoph Hellwig 			bit_b = find_next_zero_bit(bitmap, bitmap_len,
1594f461d2dcSChristoph Hellwig 						   bit_a + 1) - 1;
1595f461d2dcSChristoph Hellwig 
159632927393SChristoph Hellwig 			if (!first)
159732927393SChristoph Hellwig 				proc_put_char(&buffer, &left, ',');
159832927393SChristoph Hellwig 			proc_put_long(&buffer, &left, bit_a, false);
1599f461d2dcSChristoph Hellwig 			if (bit_a != bit_b) {
160032927393SChristoph Hellwig 				proc_put_char(&buffer, &left, '-');
160132927393SChristoph Hellwig 				proc_put_long(&buffer, &left, bit_b, false);
1602f461d2dcSChristoph Hellwig 			}
1603f461d2dcSChristoph Hellwig 
1604f461d2dcSChristoph Hellwig 			first = 0; bit_b++;
1605f461d2dcSChristoph Hellwig 		}
160632927393SChristoph Hellwig 		proc_put_char(&buffer, &left, '\n');
1607f461d2dcSChristoph Hellwig 	}
1608f461d2dcSChristoph Hellwig 
1609f461d2dcSChristoph Hellwig 	if (!err) {
1610f461d2dcSChristoph Hellwig 		if (write) {
1611f461d2dcSChristoph Hellwig 			if (*ppos)
1612f461d2dcSChristoph Hellwig 				bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1613f461d2dcSChristoph Hellwig 			else
1614f461d2dcSChristoph Hellwig 				bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1615f461d2dcSChristoph Hellwig 		}
1616f461d2dcSChristoph Hellwig 		*lenp -= left;
1617f461d2dcSChristoph Hellwig 		*ppos += *lenp;
1618f461d2dcSChristoph Hellwig 	}
1619f461d2dcSChristoph Hellwig 
1620f461d2dcSChristoph Hellwig 	bitmap_free(tmp_bitmap);
1621f461d2dcSChristoph Hellwig 	return err;
1622f461d2dcSChristoph Hellwig }
1623f461d2dcSChristoph Hellwig 
1624f461d2dcSChristoph Hellwig #else /* CONFIG_PROC_SYSCTL */
1625f461d2dcSChristoph Hellwig 
1626f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write,
162732927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1628f461d2dcSChristoph Hellwig {
1629f461d2dcSChristoph Hellwig 	return -ENOSYS;
1630f461d2dcSChristoph Hellwig }
1631f461d2dcSChristoph Hellwig 
1632f461d2dcSChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write,
163332927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1634f461d2dcSChristoph Hellwig {
1635f461d2dcSChristoph Hellwig 	return -ENOSYS;
1636f461d2dcSChristoph Hellwig }
1637f461d2dcSChristoph Hellwig 
1638f461d2dcSChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write,
163932927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1640f461d2dcSChristoph Hellwig {
1641f461d2dcSChristoph Hellwig 	return -ENOSYS;
1642f461d2dcSChristoph Hellwig }
1643f461d2dcSChristoph Hellwig 
1644f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write,
164532927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1646f461d2dcSChristoph Hellwig {
1647f461d2dcSChristoph Hellwig 	return -ENOSYS;
1648f461d2dcSChristoph Hellwig }
1649f461d2dcSChristoph Hellwig 
1650f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write,
165132927393SChristoph Hellwig 			  void *buffer, size_t *lenp, loff_t *ppos)
1652f461d2dcSChristoph Hellwig {
1653f461d2dcSChristoph Hellwig 	return -ENOSYS;
1654f461d2dcSChristoph Hellwig }
1655f461d2dcSChristoph Hellwig 
1656cb944413SEric Dumazet int proc_dou8vec_minmax(struct ctl_table *table, int write,
1657cb944413SEric Dumazet 			void *buffer, size_t *lenp, loff_t *ppos)
1658cb944413SEric Dumazet {
1659cb944413SEric Dumazet 	return -ENOSYS;
1660cb944413SEric Dumazet }
1661cb944413SEric Dumazet 
1662f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write,
166332927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1664f461d2dcSChristoph Hellwig {
1665f461d2dcSChristoph Hellwig 	return -ENOSYS;
1666f461d2dcSChristoph Hellwig }
1667f461d2dcSChristoph Hellwig 
1668f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
166932927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1670f461d2dcSChristoph Hellwig {
1671f461d2dcSChristoph Hellwig 	return -ENOSYS;
1672f461d2dcSChristoph Hellwig }
1673f461d2dcSChristoph Hellwig 
1674f461d2dcSChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
167532927393SChristoph Hellwig 			     void *buffer, size_t *lenp, loff_t *ppos)
1676f461d2dcSChristoph Hellwig {
1677f461d2dcSChristoph Hellwig 	return -ENOSYS;
1678f461d2dcSChristoph Hellwig }
1679f461d2dcSChristoph Hellwig 
1680f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write,
168132927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1682f461d2dcSChristoph Hellwig {
1683f461d2dcSChristoph Hellwig 	return -ENOSYS;
1684f461d2dcSChristoph Hellwig }
1685f461d2dcSChristoph Hellwig 
1686f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
168732927393SChristoph Hellwig 				      void *buffer, size_t *lenp, loff_t *ppos)
1688f461d2dcSChristoph Hellwig {
1689f461d2dcSChristoph Hellwig 	return -ENOSYS;
1690f461d2dcSChristoph Hellwig }
1691f461d2dcSChristoph Hellwig 
1692f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write,
169332927393SChristoph Hellwig 			 void *buffer, size_t *lenp, loff_t *ppos)
1694f461d2dcSChristoph Hellwig {
1695f461d2dcSChristoph Hellwig 	return -ENOSYS;
1696f461d2dcSChristoph Hellwig }
1697f461d2dcSChristoph Hellwig 
1698f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */
1699f461d2dcSChristoph Hellwig 
1700f461d2dcSChristoph Hellwig #if defined(CONFIG_SYSCTL)
1701f461d2dcSChristoph Hellwig int proc_do_static_key(struct ctl_table *table, int write,
170232927393SChristoph Hellwig 		       void *buffer, size_t *lenp, loff_t *ppos)
1703f461d2dcSChristoph Hellwig {
1704f461d2dcSChristoph Hellwig 	struct static_key *key = (struct static_key *)table->data;
1705f461d2dcSChristoph Hellwig 	static DEFINE_MUTEX(static_key_mutex);
1706f461d2dcSChristoph Hellwig 	int val, ret;
1707f461d2dcSChristoph Hellwig 	struct ctl_table tmp = {
1708f461d2dcSChristoph Hellwig 		.data   = &val,
1709f461d2dcSChristoph Hellwig 		.maxlen = sizeof(val),
1710f461d2dcSChristoph Hellwig 		.mode   = table->mode,
1711f461d2dcSChristoph Hellwig 		.extra1 = SYSCTL_ZERO,
1712f461d2dcSChristoph Hellwig 		.extra2 = SYSCTL_ONE,
1713f461d2dcSChristoph Hellwig 	};
1714f461d2dcSChristoph Hellwig 
1715f461d2dcSChristoph Hellwig 	if (write && !capable(CAP_SYS_ADMIN))
1716f461d2dcSChristoph Hellwig 		return -EPERM;
1717f461d2dcSChristoph Hellwig 
1718f461d2dcSChristoph Hellwig 	mutex_lock(&static_key_mutex);
1719f461d2dcSChristoph Hellwig 	val = static_key_enabled(key);
1720f461d2dcSChristoph Hellwig 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1721f461d2dcSChristoph Hellwig 	if (write && !ret) {
1722f461d2dcSChristoph Hellwig 		if (val)
1723f461d2dcSChristoph Hellwig 			static_key_enable(key);
1724f461d2dcSChristoph Hellwig 		else
1725f461d2dcSChristoph Hellwig 			static_key_disable(key);
1726f461d2dcSChristoph Hellwig 	}
1727f461d2dcSChristoph Hellwig 	mutex_unlock(&static_key_mutex);
1728f461d2dcSChristoph Hellwig 	return ret;
1729f461d2dcSChristoph Hellwig }
1730f461d2dcSChristoph Hellwig 
1731d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
17322bba22c5SMike Galbraith 	{
17332bba22c5SMike Galbraith 		.procname	= "sched_child_runs_first",
17342bba22c5SMike Galbraith 		.data		= &sysctl_sched_child_runs_first,
17352bba22c5SMike Galbraith 		.maxlen		= sizeof(unsigned int),
17362bba22c5SMike Galbraith 		.mode		= 0644,
17376d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
17382bba22c5SMike Galbraith 	},
17391d1c2509SPeter Zijlstra #ifdef CONFIG_SCHEDSTATS
17401d1c2509SPeter Zijlstra 	{
17411d1c2509SPeter Zijlstra 		.procname	= "sched_schedstats",
17421d1c2509SPeter Zijlstra 		.data		= NULL,
17431d1c2509SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
17441d1c2509SPeter Zijlstra 		.mode		= 0644,
17451d1c2509SPeter Zijlstra 		.proc_handler	= sysctl_schedstats,
17461d1c2509SPeter Zijlstra 		.extra1		= SYSCTL_ZERO,
17471d1c2509SPeter Zijlstra 		.extra2		= SYSCTL_ONE,
17481d1c2509SPeter Zijlstra 	},
17491d1c2509SPeter Zijlstra #endif /* CONFIG_SCHEDSTATS */
1750b7cc6ec7SMel Gorman #ifdef CONFIG_NUMA_BALANCING
17513a7053b3SMel Gorman 	{
175254a43d54SAndi Kleen 		.procname	= "numa_balancing",
175354a43d54SAndi Kleen 		.data		= NULL, /* filled in by handler */
175454a43d54SAndi Kleen 		.maxlen		= sizeof(unsigned int),
175554a43d54SAndi Kleen 		.mode		= 0644,
175654a43d54SAndi Kleen 		.proc_handler	= sysctl_numa_balancing,
1757eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1758eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
175954a43d54SAndi Kleen 	},
1760cbee9f88SPeter Zijlstra #endif /* CONFIG_NUMA_BALANCING */
17611799e35dSIngo Molnar 	{
17629f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
17639f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
17649f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
17659f0c1e56SPeter Zijlstra 		.mode		= 0644,
17666d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
17679f0c1e56SPeter Zijlstra 	},
17689f0c1e56SPeter Zijlstra 	{
17699f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
17709f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
17719f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
17729f0c1e56SPeter Zijlstra 		.mode		= 0644,
17736d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
17749f0c1e56SPeter Zijlstra 	},
1775ce0dbbbbSClark Williams 	{
1776b4098bfcSPeter Zijlstra 		.procname	= "sched_deadline_period_max_us",
1777b4098bfcSPeter Zijlstra 		.data		= &sysctl_sched_dl_period_max,
1778b4098bfcSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
1779b4098bfcSPeter Zijlstra 		.mode		= 0644,
1780b4098bfcSPeter Zijlstra 		.proc_handler	= proc_dointvec,
1781b4098bfcSPeter Zijlstra 	},
1782b4098bfcSPeter Zijlstra 	{
1783b4098bfcSPeter Zijlstra 		.procname	= "sched_deadline_period_min_us",
1784b4098bfcSPeter Zijlstra 		.data		= &sysctl_sched_dl_period_min,
1785b4098bfcSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
1786b4098bfcSPeter Zijlstra 		.mode		= 0644,
1787b4098bfcSPeter Zijlstra 		.proc_handler	= proc_dointvec,
1788b4098bfcSPeter Zijlstra 	},
1789b4098bfcSPeter Zijlstra 	{
1790ce0dbbbbSClark Williams 		.procname	= "sched_rr_timeslice_ms",
1791975e155eSShile Zhang 		.data		= &sysctl_sched_rr_timeslice,
1792ce0dbbbbSClark Williams 		.maxlen		= sizeof(int),
1793ce0dbbbbSClark Williams 		.mode		= 0644,
1794ce0dbbbbSClark Williams 		.proc_handler	= sched_rr_handler,
1795ce0dbbbbSClark Williams 	},
1796e8f14172SPatrick Bellasi #ifdef CONFIG_UCLAMP_TASK
1797e8f14172SPatrick Bellasi 	{
1798e8f14172SPatrick Bellasi 		.procname	= "sched_util_clamp_min",
1799e8f14172SPatrick Bellasi 		.data		= &sysctl_sched_uclamp_util_min,
1800e8f14172SPatrick Bellasi 		.maxlen		= sizeof(unsigned int),
1801e8f14172SPatrick Bellasi 		.mode		= 0644,
1802e8f14172SPatrick Bellasi 		.proc_handler	= sysctl_sched_uclamp_handler,
1803e8f14172SPatrick Bellasi 	},
1804e8f14172SPatrick Bellasi 	{
1805e8f14172SPatrick Bellasi 		.procname	= "sched_util_clamp_max",
1806e8f14172SPatrick Bellasi 		.data		= &sysctl_sched_uclamp_util_max,
1807e8f14172SPatrick Bellasi 		.maxlen		= sizeof(unsigned int),
1808e8f14172SPatrick Bellasi 		.mode		= 0644,
1809e8f14172SPatrick Bellasi 		.proc_handler	= sysctl_sched_uclamp_handler,
1810e8f14172SPatrick Bellasi 	},
181113685c4aSQais Yousef 	{
181213685c4aSQais Yousef 		.procname	= "sched_util_clamp_min_rt_default",
181313685c4aSQais Yousef 		.data		= &sysctl_sched_uclamp_util_min_rt_default,
181413685c4aSQais Yousef 		.maxlen		= sizeof(unsigned int),
181513685c4aSQais Yousef 		.mode		= 0644,
181613685c4aSQais Yousef 		.proc_handler	= sysctl_sched_uclamp_handler,
181713685c4aSQais Yousef 	},
1818e8f14172SPatrick Bellasi #endif
18195091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP
18205091faa4SMike Galbraith 	{
18215091faa4SMike Galbraith 		.procname	= "sched_autogroup_enabled",
18225091faa4SMike Galbraith 		.data		= &sysctl_sched_autogroup_enabled,
18235091faa4SMike Galbraith 		.maxlen		= sizeof(unsigned int),
18245091faa4SMike Galbraith 		.mode		= 0644,
18251747b21fSYong Zhang 		.proc_handler	= proc_dointvec_minmax,
1826eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1827eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
18285091faa4SMike Galbraith 	},
18295091faa4SMike Galbraith #endif
1830ec12cb7fSPaul Turner #ifdef CONFIG_CFS_BANDWIDTH
1831ec12cb7fSPaul Turner 	{
1832ec12cb7fSPaul Turner 		.procname	= "sched_cfs_bandwidth_slice_us",
1833ec12cb7fSPaul Turner 		.data		= &sysctl_sched_cfs_bandwidth_slice,
1834ec12cb7fSPaul Turner 		.maxlen		= sizeof(unsigned int),
1835ec12cb7fSPaul Turner 		.mode		= 0644,
1836ec12cb7fSPaul Turner 		.proc_handler	= proc_dointvec_minmax,
1837eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
1838ec12cb7fSPaul Turner 	},
1839ec12cb7fSPaul Turner #endif
18408d5d0cfbSQuentin Perret #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
18418d5d0cfbSQuentin Perret 	{
18428d5d0cfbSQuentin Perret 		.procname	= "sched_energy_aware",
18438d5d0cfbSQuentin Perret 		.data		= &sysctl_sched_energy_aware,
18448d5d0cfbSQuentin Perret 		.maxlen		= sizeof(unsigned int),
18458d5d0cfbSQuentin Perret 		.mode		= 0644,
18468d5d0cfbSQuentin Perret 		.proc_handler	= sched_energy_aware_handler,
1847eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1848eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
18498d5d0cfbSQuentin Perret 	},
18508d5d0cfbSQuentin Perret #endif
1851f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
1852f20786ffSPeter Zijlstra 	{
1853f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
1854f20786ffSPeter Zijlstra 		.data		= &prove_locking,
1855f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
1856f20786ffSPeter Zijlstra 		.mode		= 0644,
18576d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1858f20786ffSPeter Zijlstra 	},
1859f20786ffSPeter Zijlstra #endif
1860f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
1861f20786ffSPeter Zijlstra 	{
1862f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
1863f20786ffSPeter Zijlstra 		.data		= &lock_stat,
1864f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
1865f20786ffSPeter Zijlstra 		.mode		= 0644,
18666d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1867f20786ffSPeter Zijlstra 	},
1868f20786ffSPeter Zijlstra #endif
186977e54a1fSIngo Molnar 	{
18701da177e4SLinus Torvalds 		.procname	= "panic",
18711da177e4SLinus Torvalds 		.data		= &panic_timeout,
18721da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
18731da177e4SLinus Torvalds 		.mode		= 0644,
18746d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
18751da177e4SLinus Torvalds 	},
1876046d662fSAlex Kelly #ifdef CONFIG_COREDUMP
18771da177e4SLinus Torvalds 	{
18781da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
18791da177e4SLinus Torvalds 		.data		= &core_uses_pid,
18801da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
18811da177e4SLinus Torvalds 		.mode		= 0644,
18826d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
18831da177e4SLinus Torvalds 	},
18841da177e4SLinus Torvalds 	{
18851da177e4SLinus Torvalds 		.procname	= "core_pattern",
18861da177e4SLinus Torvalds 		.data		= core_pattern,
188771ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
18881da177e4SLinus Torvalds 		.mode		= 0644,
188954b50199SKees Cook 		.proc_handler	= proc_dostring_coredump,
18901da177e4SLinus Torvalds 	},
1891a293980cSNeil Horman 	{
1892a293980cSNeil Horman 		.procname	= "core_pipe_limit",
1893a293980cSNeil Horman 		.data		= &core_pipe_limit,
1894a293980cSNeil Horman 		.maxlen		= sizeof(unsigned int),
1895a293980cSNeil Horman 		.mode		= 0644,
18966d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1897a293980cSNeil Horman 	},
1898046d662fSAlex Kelly #endif
189934f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
19001da177e4SLinus Torvalds 	{
19011da177e4SLinus Torvalds 		.procname	= "tainted",
190225ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
190334f5a398STheodore Ts'o 		.mode		= 0644,
19046d456111SEric W. Biederman 		.proc_handler	= proc_taint,
19051da177e4SLinus Torvalds 	},
1906f4aacea2SKees Cook 	{
1907f4aacea2SKees Cook 		.procname	= "sysctl_writes_strict",
1908f4aacea2SKees Cook 		.data		= &sysctl_writes_strict,
1909f4aacea2SKees Cook 		.maxlen		= sizeof(int),
1910f4aacea2SKees Cook 		.mode		= 0644,
1911f4aacea2SKees Cook 		.proc_handler	= proc_dointvec_minmax,
1912f4aacea2SKees Cook 		.extra1		= &neg_one,
1913eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
1914f4aacea2SKees Cook 	},
191534f5a398STheodore Ts'o #endif
19169745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
19179745512cSArjan van de Ven 	{
19189745512cSArjan van de Ven 		.procname	= "latencytop",
19199745512cSArjan van de Ven 		.data		= &latencytop_enabled,
19209745512cSArjan van de Ven 		.maxlen		= sizeof(int),
19219745512cSArjan van de Ven 		.mode		= 0644,
1922cb251765SMel Gorman 		.proc_handler	= sysctl_latencytop,
19239745512cSArjan van de Ven 	},
19249745512cSArjan van de Ven #endif
19251da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
19261da177e4SLinus Torvalds 	{
19271da177e4SLinus Torvalds 		.procname	= "real-root-dev",
19281da177e4SLinus Torvalds 		.data		= &real_root_dev,
19291da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
19301da177e4SLinus Torvalds 		.mode		= 0644,
19316d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19321da177e4SLinus Torvalds 	},
19331da177e4SLinus Torvalds #endif
193445807a1dSIngo Molnar 	{
193545807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
193645807a1dSIngo Molnar 		.data		= &print_fatal_signals,
193745807a1dSIngo Molnar 		.maxlen		= sizeof(int),
193845807a1dSIngo Molnar 		.mode		= 0644,
19396d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
194045807a1dSIngo Molnar 	},
194172c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
19421da177e4SLinus Torvalds 	{
19431da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
19441da177e4SLinus Torvalds 		.data		= reboot_command,
19451da177e4SLinus Torvalds 		.maxlen		= 256,
19461da177e4SLinus Torvalds 		.mode		= 0644,
19476d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
19481da177e4SLinus Torvalds 	},
19491da177e4SLinus Torvalds 	{
19501da177e4SLinus Torvalds 		.procname	= "stop-a",
19511da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
19521da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19531da177e4SLinus Torvalds 		.mode		= 0644,
19546d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19551da177e4SLinus Torvalds 	},
19561da177e4SLinus Torvalds 	{
19571da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
19581da177e4SLinus Torvalds 		.data		= &scons_pwroff,
19591da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19601da177e4SLinus Torvalds 		.mode		= 0644,
19616d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19621da177e4SLinus Torvalds 	},
19631da177e4SLinus Torvalds #endif
19640871420fSDavid S. Miller #ifdef CONFIG_SPARC64
19650871420fSDavid S. Miller 	{
19660871420fSDavid S. Miller 		.procname	= "tsb-ratio",
19670871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
19680871420fSDavid S. Miller 		.maxlen		= sizeof (int),
19690871420fSDavid S. Miller 		.mode		= 0644,
19706d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19710871420fSDavid S. Miller 	},
19720871420fSDavid S. Miller #endif
1973b67114dbSHelge Deller #ifdef CONFIG_PARISC
19741da177e4SLinus Torvalds 	{
19751da177e4SLinus Torvalds 		.procname	= "soft-power",
19761da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
19771da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19781da177e4SLinus Torvalds 		.mode		= 0644,
19796d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19801da177e4SLinus Torvalds 	},
1981bf14e3b9SVineet Gupta #endif
1982bf14e3b9SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
19831da177e4SLinus Torvalds 	{
19841da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
19851da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
19861da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19871da177e4SLinus Torvalds 		.mode		= 0644,
19886d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19891da177e4SLinus Torvalds 	},
19901da177e4SLinus Torvalds #endif
19911da177e4SLinus Torvalds 	{
19921da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
19931da177e4SLinus Torvalds 		.data		= &C_A_D,
19941da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
19951da177e4SLinus Torvalds 		.mode		= 0644,
19966d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19971da177e4SLinus Torvalds 	},
1998606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
1999b0fc494fSSteven Rostedt 	{
2000b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
2001b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
2002b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
2003b0fc494fSSteven Rostedt 		.mode		= 0644,
20046d456111SEric W. Biederman 		.proc_handler	= ftrace_enable_sysctl,
2005b0fc494fSSteven Rostedt 	},
2006b0fc494fSSteven Rostedt #endif
2007f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
2008f38f1d2aSSteven Rostedt 	{
2009f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
2010f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
2011f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
2012f38f1d2aSSteven Rostedt 		.mode		= 0644,
20136d456111SEric W. Biederman 		.proc_handler	= stack_trace_sysctl,
2014f38f1d2aSSteven Rostedt 	},
2015f38f1d2aSSteven Rostedt #endif
2016944ac425SSteven Rostedt #ifdef CONFIG_TRACING
2017944ac425SSteven Rostedt 	{
20183299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
2019944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
2020944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
2021944ac425SSteven Rostedt 		.mode		= 0644,
20226d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2023944ac425SSteven Rostedt 	},
2024de7edd31SSteven Rostedt (Red Hat) 	{
2025de7edd31SSteven Rostedt (Red Hat) 		.procname	= "traceoff_on_warning",
2026de7edd31SSteven Rostedt (Red Hat) 		.data		= &__disable_trace_on_warning,
2027de7edd31SSteven Rostedt (Red Hat) 		.maxlen		= sizeof(__disable_trace_on_warning),
2028de7edd31SSteven Rostedt (Red Hat) 		.mode		= 0644,
2029de7edd31SSteven Rostedt (Red Hat) 		.proc_handler	= proc_dointvec,
2030de7edd31SSteven Rostedt (Red Hat) 	},
20310daa2302SSteven Rostedt (Red Hat) 	{
20320daa2302SSteven Rostedt (Red Hat) 		.procname	= "tracepoint_printk",
20330daa2302SSteven Rostedt (Red Hat) 		.data		= &tracepoint_printk,
20340daa2302SSteven Rostedt (Red Hat) 		.maxlen		= sizeof(tracepoint_printk),
20350daa2302SSteven Rostedt (Red Hat) 		.mode		= 0644,
203642391745SSteven Rostedt (Red Hat) 		.proc_handler	= tracepoint_printk_sysctl,
20370daa2302SSteven Rostedt (Red Hat) 	},
2038944ac425SSteven Rostedt #endif
20392965faa5SDave Young #ifdef CONFIG_KEXEC_CORE
20407984754bSKees Cook 	{
20417984754bSKees Cook 		.procname	= "kexec_load_disabled",
20427984754bSKees Cook 		.data		= &kexec_load_disabled,
20437984754bSKees Cook 		.maxlen		= sizeof(int),
20447984754bSKees Cook 		.mode		= 0644,
20457984754bSKees Cook 		/* only handle a transition from default "0" to "1" */
20467984754bSKees Cook 		.proc_handler	= proc_dointvec_minmax,
2047eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2048eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
20497984754bSKees Cook 	},
20507984754bSKees Cook #endif
2051a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
20521da177e4SLinus Torvalds 	{
20531da177e4SLinus Torvalds 		.procname	= "modprobe",
20541da177e4SLinus Torvalds 		.data		= &modprobe_path,
20551da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
20561da177e4SLinus Torvalds 		.mode		= 0644,
20576d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
20581da177e4SLinus Torvalds 	},
20593d43321bSKees Cook 	{
20603d43321bSKees Cook 		.procname	= "modules_disabled",
20613d43321bSKees Cook 		.data		= &modules_disabled,
20623d43321bSKees Cook 		.maxlen		= sizeof(int),
20633d43321bSKees Cook 		.mode		= 0644,
20643d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
20656d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2066eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2067eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
20683d43321bSKees Cook 	},
20691da177e4SLinus Torvalds #endif
207086d56134SMichael Marineau #ifdef CONFIG_UEVENT_HELPER
20711da177e4SLinus Torvalds 	{
20721da177e4SLinus Torvalds 		.procname	= "hotplug",
2073312c004dSKay Sievers 		.data		= &uevent_helper,
2074312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
20751da177e4SLinus Torvalds 		.mode		= 0644,
20766d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
20771da177e4SLinus Torvalds 	},
207886d56134SMichael Marineau #endif
20791da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
20801da177e4SLinus Torvalds 	{
20811da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
20821da177e4SLinus Torvalds 		.data		= &sg_big_buff,
20831da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
20841da177e4SLinus Torvalds 		.mode		= 0444,
20856d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
20861da177e4SLinus Torvalds 	},
20871da177e4SLinus Torvalds #endif
20881da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
20891da177e4SLinus Torvalds 	{
20901da177e4SLinus Torvalds 		.procname	= "acct",
20911da177e4SLinus Torvalds 		.data		= &acct_parm,
20921da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
20931da177e4SLinus Torvalds 		.mode		= 0644,
20946d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
20951da177e4SLinus Torvalds 	},
20961da177e4SLinus Torvalds #endif
20971da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
20981da177e4SLinus Torvalds 	{
20991da177e4SLinus Torvalds 		.procname	= "sysrq",
2100eaee4172SDmitry Safonov 		.data		= NULL,
21011da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
21021da177e4SLinus Torvalds 		.mode		= 0644,
210397f5f0cdSDmitry Torokhov 		.proc_handler	= sysrq_sysctl_handler,
21041da177e4SLinus Torvalds 	},
21051da177e4SLinus Torvalds #endif
2106d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
21071da177e4SLinus Torvalds 	{
21081da177e4SLinus Torvalds 		.procname	= "cad_pid",
21099ec52099SCedric Le Goater 		.data		= NULL,
21101da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
21111da177e4SLinus Torvalds 		.mode		= 0600,
21126d456111SEric W. Biederman 		.proc_handler	= proc_do_cad_pid,
21131da177e4SLinus Torvalds 	},
2114d6f8ff73SRandy Dunlap #endif
21151da177e4SLinus Torvalds 	{
21161da177e4SLinus Torvalds 		.procname	= "threads-max",
211716db3d3fSHeinrich Schuchardt 		.data		= NULL,
21181da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21191da177e4SLinus Torvalds 		.mode		= 0644,
212016db3d3fSHeinrich Schuchardt 		.proc_handler	= sysctl_max_threads,
21211da177e4SLinus Torvalds 	},
21221da177e4SLinus Torvalds 	{
21231da177e4SLinus Torvalds 		.procname	= "random",
21241da177e4SLinus Torvalds 		.mode		= 0555,
21251da177e4SLinus Torvalds 		.child		= random_table,
21261da177e4SLinus Torvalds 	},
21271da177e4SLinus Torvalds 	{
212817f60a7dSEric Paris 		.procname	= "usermodehelper",
212917f60a7dSEric Paris 		.mode		= 0555,
213017f60a7dSEric Paris 		.child		= usermodehelper_table,
213117f60a7dSEric Paris 	},
2132ceb18132SLuis R. Rodriguez #ifdef CONFIG_FW_LOADER_USER_HELPER
2133ceb18132SLuis R. Rodriguez 	{
2134ceb18132SLuis R. Rodriguez 		.procname	= "firmware_config",
2135ceb18132SLuis R. Rodriguez 		.mode		= 0555,
2136ceb18132SLuis R. Rodriguez 		.child		= firmware_config_table,
2137ceb18132SLuis R. Rodriguez 	},
2138ceb18132SLuis R. Rodriguez #endif
213917f60a7dSEric Paris 	{
21401da177e4SLinus Torvalds 		.procname	= "overflowuid",
21411da177e4SLinus Torvalds 		.data		= &overflowuid,
21421da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21431da177e4SLinus Torvalds 		.mode		= 0644,
21446d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
21451da177e4SLinus Torvalds 		.extra1		= &minolduid,
21461da177e4SLinus Torvalds 		.extra2		= &maxolduid,
21471da177e4SLinus Torvalds 	},
21481da177e4SLinus Torvalds 	{
21491da177e4SLinus Torvalds 		.procname	= "overflowgid",
21501da177e4SLinus Torvalds 		.data		= &overflowgid,
21511da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21521da177e4SLinus Torvalds 		.mode		= 0644,
21536d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
21541da177e4SLinus Torvalds 		.extra1		= &minolduid,
21551da177e4SLinus Torvalds 		.extra2		= &maxolduid,
21561da177e4SLinus Torvalds 	},
2157347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
21581da177e4SLinus Torvalds 	{
21591da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
2160ab3c68eeSHeiko Carstens 		.data		= &show_unhandled_signals,
21611da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21621da177e4SLinus Torvalds 		.mode		= 0644,
21636d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
21641da177e4SLinus Torvalds 	},
21651da177e4SLinus Torvalds #endif
216660c958d8SGuilherme G. Piccoli #ifdef CONFIG_SMP
216760c958d8SGuilherme G. Piccoli 	{
216860c958d8SGuilherme G. Piccoli 		.procname	= "oops_all_cpu_backtrace",
216960c958d8SGuilherme G. Piccoli 		.data		= &sysctl_oops_all_cpu_backtrace,
217060c958d8SGuilherme G. Piccoli 		.maxlen		= sizeof(int),
217160c958d8SGuilherme G. Piccoli 		.mode		= 0644,
217260c958d8SGuilherme G. Piccoli 		.proc_handler	= proc_dointvec_minmax,
217360c958d8SGuilherme G. Piccoli 		.extra1		= SYSCTL_ZERO,
217460c958d8SGuilherme G. Piccoli 		.extra2		= SYSCTL_ONE,
217560c958d8SGuilherme G. Piccoli 	},
217660c958d8SGuilherme G. Piccoli #endif /* CONFIG_SMP */
21771da177e4SLinus Torvalds 	{
21781da177e4SLinus Torvalds 		.procname	= "pid_max",
21791da177e4SLinus Torvalds 		.data		= &pid_max,
21801da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
21811da177e4SLinus Torvalds 		.mode		= 0644,
21826d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
21831da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
21841da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
21851da177e4SLinus Torvalds 	},
21861da177e4SLinus Torvalds 	{
21871da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
21881da177e4SLinus Torvalds 		.data		= &panic_on_oops,
21891da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21901da177e4SLinus Torvalds 		.mode		= 0644,
21916d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
21921da177e4SLinus Torvalds 	},
219381c9d43fSFeng Tang 	{
219481c9d43fSFeng Tang 		.procname	= "panic_print",
219581c9d43fSFeng Tang 		.data		= &panic_print,
219681c9d43fSFeng Tang 		.maxlen		= sizeof(unsigned long),
219781c9d43fSFeng Tang 		.mode		= 0644,
219881c9d43fSFeng Tang 		.proc_handler	= proc_doulongvec_minmax,
219981c9d43fSFeng Tang 	},
22007ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
22017ef3d2fdSJoe Perches 	{
22027ef3d2fdSJoe Perches 		.procname	= "printk",
22037ef3d2fdSJoe Perches 		.data		= &console_loglevel,
22047ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
22057ef3d2fdSJoe Perches 		.mode		= 0644,
22066d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22077ef3d2fdSJoe Perches 	},
22081da177e4SLinus Torvalds 	{
22091da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
2210717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
22111da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
22121da177e4SLinus Torvalds 		.mode		= 0644,
22136d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
22141da177e4SLinus Torvalds 	},
22151da177e4SLinus Torvalds 	{
22161da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
2217717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
22181da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
22191da177e4SLinus Torvalds 		.mode		= 0644,
22206d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22211da177e4SLinus Torvalds 	},
2222af91322eSDave Young 	{
2223af91322eSDave Young 		.procname	= "printk_delay",
2224af91322eSDave Young 		.data		= &printk_delay_msec,
2225af91322eSDave Young 		.maxlen		= sizeof(int),
2226af91322eSDave Young 		.mode		= 0644,
22276d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2228eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2229af91322eSDave Young 		.extra2		= &ten_thousand,
2230af91322eSDave Young 	},
22311da177e4SLinus Torvalds 	{
2232750afe7bSBorislav Petkov 		.procname	= "printk_devkmsg",
2233750afe7bSBorislav Petkov 		.data		= devkmsg_log_str,
2234750afe7bSBorislav Petkov 		.maxlen		= DEVKMSG_STR_MAX_SIZE,
2235750afe7bSBorislav Petkov 		.mode		= 0644,
2236750afe7bSBorislav Petkov 		.proc_handler	= devkmsg_sysctl_set_loglvl,
2237750afe7bSBorislav Petkov 	},
2238750afe7bSBorislav Petkov 	{
2239eaf06b24SDan Rosenberg 		.procname	= "dmesg_restrict",
2240eaf06b24SDan Rosenberg 		.data		= &dmesg_restrict,
2241eaf06b24SDan Rosenberg 		.maxlen		= sizeof(int),
2242eaf06b24SDan Rosenberg 		.mode		= 0644,
2243620f6e8eSKees Cook 		.proc_handler	= proc_dointvec_minmax_sysadmin,
2244eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2245eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2246eaf06b24SDan Rosenberg 	},
2247455cd5abSDan Rosenberg 	{
2248455cd5abSDan Rosenberg 		.procname	= "kptr_restrict",
2249455cd5abSDan Rosenberg 		.data		= &kptr_restrict,
2250455cd5abSDan Rosenberg 		.maxlen		= sizeof(int),
2251455cd5abSDan Rosenberg 		.mode		= 0644,
2252620f6e8eSKees Cook 		.proc_handler	= proc_dointvec_minmax_sysadmin,
2253eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2254455cd5abSDan Rosenberg 		.extra2		= &two,
2255455cd5abSDan Rosenberg 	},
2256df6e61d4SJoe Perches #endif
2257eaf06b24SDan Rosenberg 	{
22581da177e4SLinus Torvalds 		.procname	= "ngroups_max",
22591da177e4SLinus Torvalds 		.data		= &ngroups_max,
22601da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
22611da177e4SLinus Torvalds 		.mode		= 0444,
22626d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22631da177e4SLinus Torvalds 	},
226473efc039SDan Ballard 	{
226573efc039SDan Ballard 		.procname	= "cap_last_cap",
226673efc039SDan Ballard 		.data		= (void *)&cap_last_cap,
226773efc039SDan Ballard 		.maxlen		= sizeof(int),
226873efc039SDan Ballard 		.mode		= 0444,
226973efc039SDan Ballard 		.proc_handler	= proc_dointvec,
227073efc039SDan Ballard 	},
227158687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR)
2272504d7cf1SDon Zickus 	{
227358687acbSDon Zickus 		.procname       = "watchdog",
22743c00ea82SFrederic Weisbecker 		.data		= &watchdog_user_enabled,
2275504d7cf1SDon Zickus 		.maxlen		= sizeof(int),
2276504d7cf1SDon Zickus 		.mode		= 0644,
2277195daf66SUlrich Obergfell 		.proc_handler   = proc_watchdog,
2278eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2279eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
228058687acbSDon Zickus 	},
228158687acbSDon Zickus 	{
228258687acbSDon Zickus 		.procname	= "watchdog_thresh",
2283586692a5SMandeep Singh Baines 		.data		= &watchdog_thresh,
228458687acbSDon Zickus 		.maxlen		= sizeof(int),
228558687acbSDon Zickus 		.mode		= 0644,
2286195daf66SUlrich Obergfell 		.proc_handler	= proc_watchdog_thresh,
2287eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
228858687acbSDon Zickus 		.extra2		= &sixty,
2289504d7cf1SDon Zickus 	},
22902508ce18SDon Zickus 	{
2291195daf66SUlrich Obergfell 		.procname       = "nmi_watchdog",
22927feeb9cdSThomas Gleixner 		.data		= &nmi_watchdog_user_enabled,
2293195daf66SUlrich Obergfell 		.maxlen		= sizeof(int),
229451d4052bSThomas Gleixner 		.mode		= NMI_WATCHDOG_SYSCTL_PERM,
2295195daf66SUlrich Obergfell 		.proc_handler   = proc_nmi_watchdog,
2296eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2297eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2298195daf66SUlrich Obergfell 	},
2299195daf66SUlrich Obergfell 	{
230005a4a952SNicholas Piggin 		.procname	= "watchdog_cpumask",
230105a4a952SNicholas Piggin 		.data		= &watchdog_cpumask_bits,
230205a4a952SNicholas Piggin 		.maxlen		= NR_CPUS,
230305a4a952SNicholas Piggin 		.mode		= 0644,
230405a4a952SNicholas Piggin 		.proc_handler	= proc_watchdog_cpumask,
230505a4a952SNicholas Piggin 	},
230605a4a952SNicholas Piggin #ifdef CONFIG_SOFTLOCKUP_DETECTOR
230705a4a952SNicholas Piggin 	{
2308195daf66SUlrich Obergfell 		.procname       = "soft_watchdog",
23097feeb9cdSThomas Gleixner 		.data		= &soft_watchdog_user_enabled,
2310195daf66SUlrich Obergfell 		.maxlen		= sizeof(int),
2311195daf66SUlrich Obergfell 		.mode		= 0644,
2312195daf66SUlrich Obergfell 		.proc_handler   = proc_soft_watchdog,
2313eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2314eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2315195daf66SUlrich Obergfell 	},
2316195daf66SUlrich Obergfell 	{
23172508ce18SDon Zickus 		.procname	= "softlockup_panic",
23182508ce18SDon Zickus 		.data		= &softlockup_panic,
23192508ce18SDon Zickus 		.maxlen		= sizeof(int),
23202508ce18SDon Zickus 		.mode		= 0644,
23212508ce18SDon Zickus 		.proc_handler	= proc_dointvec_minmax,
2322eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2323eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
23242508ce18SDon Zickus 	},
2325ed235875SAaron Tomlin #ifdef CONFIG_SMP
2326ed235875SAaron Tomlin 	{
2327ed235875SAaron Tomlin 		.procname	= "softlockup_all_cpu_backtrace",
2328ed235875SAaron Tomlin 		.data		= &sysctl_softlockup_all_cpu_backtrace,
2329ed235875SAaron Tomlin 		.maxlen		= sizeof(int),
2330ed235875SAaron Tomlin 		.mode		= 0644,
2331ed235875SAaron Tomlin 		.proc_handler	= proc_dointvec_minmax,
2332eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2333eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2334ed235875SAaron Tomlin 	},
233505a4a952SNicholas Piggin #endif /* CONFIG_SMP */
233605a4a952SNicholas Piggin #endif
233705a4a952SNicholas Piggin #ifdef CONFIG_HARDLOCKUP_DETECTOR
233805a4a952SNicholas Piggin 	{
233905a4a952SNicholas Piggin 		.procname	= "hardlockup_panic",
234005a4a952SNicholas Piggin 		.data		= &hardlockup_panic,
234105a4a952SNicholas Piggin 		.maxlen		= sizeof(int),
234205a4a952SNicholas Piggin 		.mode		= 0644,
234305a4a952SNicholas Piggin 		.proc_handler	= proc_dointvec_minmax,
2344eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2345eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
234605a4a952SNicholas Piggin 	},
234705a4a952SNicholas Piggin #ifdef CONFIG_SMP
234855537871SJiri Kosina 	{
234955537871SJiri Kosina 		.procname	= "hardlockup_all_cpu_backtrace",
235055537871SJiri Kosina 		.data		= &sysctl_hardlockup_all_cpu_backtrace,
235155537871SJiri Kosina 		.maxlen		= sizeof(int),
235255537871SJiri Kosina 		.mode		= 0644,
235355537871SJiri Kosina 		.proc_handler	= proc_dointvec_minmax,
2354eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2355eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
235655537871SJiri Kosina 	},
2357ed235875SAaron Tomlin #endif /* CONFIG_SMP */
23585dc30558SDon Zickus #endif
235905a4a952SNicholas Piggin #endif
236005a4a952SNicholas Piggin 
23615dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
23625dc30558SDon Zickus 	{
23635dc30558SDon Zickus 		.procname       = "unknown_nmi_panic",
23645dc30558SDon Zickus 		.data           = &unknown_nmi_panic,
23655dc30558SDon Zickus 		.maxlen         = sizeof (int),
23665dc30558SDon Zickus 		.mode           = 0644,
23675dc30558SDon Zickus 		.proc_handler   = proc_dointvec,
23685dc30558SDon Zickus 	},
2369504d7cf1SDon Zickus #endif
2370b6522fa4SXiaoming Ni 
2371b6522fa4SXiaoming Ni #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2372b6522fa4SXiaoming Ni 	defined(CONFIG_DEBUG_STACKOVERFLOW)
2373b6522fa4SXiaoming Ni 	{
2374b6522fa4SXiaoming Ni 		.procname	= "panic_on_stackoverflow",
2375b6522fa4SXiaoming Ni 		.data		= &sysctl_panic_on_stackoverflow,
2376b6522fa4SXiaoming Ni 		.maxlen		= sizeof(int),
2377b6522fa4SXiaoming Ni 		.mode		= 0644,
2378b6522fa4SXiaoming Ni 		.proc_handler	= proc_dointvec,
2379b6522fa4SXiaoming Ni 	},
2380b6522fa4SXiaoming Ni #endif
23811da177e4SLinus Torvalds #if defined(CONFIG_X86)
23821da177e4SLinus Torvalds 	{
23838da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
23848da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
23858da5addaSDon Zickus 		.maxlen		= sizeof(int),
23868da5addaSDon Zickus 		.mode		= 0644,
23876d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
23888da5addaSDon Zickus 	},
23898da5addaSDon Zickus 	{
23905211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
23915211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
23925211a242SKurt Garloff 		.maxlen		= sizeof(int),
23935211a242SKurt Garloff 		.mode		= 0644,
23946d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
23955211a242SKurt Garloff 	},
23965211a242SKurt Garloff 	{
23971da177e4SLinus Torvalds 		.procname	= "bootloader_type",
23981da177e4SLinus Torvalds 		.data		= &bootloader_type,
23991da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
24001da177e4SLinus Torvalds 		.mode		= 0444,
24016d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24021da177e4SLinus Torvalds 	},
24030741f4d2SChuck Ebbert 	{
24045031296cSH. Peter Anvin 		.procname	= "bootloader_version",
24055031296cSH. Peter Anvin 		.data		= &bootloader_version,
24065031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
24075031296cSH. Peter Anvin 		.mode		= 0444,
24086d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24095031296cSH. Peter Anvin 	},
24105031296cSH. Peter Anvin 	{
24116e7c4025SIngo Molnar 		.procname	= "io_delay_type",
24126e7c4025SIngo Molnar 		.data		= &io_delay_type,
24136e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
24146e7c4025SIngo Molnar 		.mode		= 0644,
24156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24166e7c4025SIngo Molnar 	},
24171da177e4SLinus Torvalds #endif
24187a9166e3SLuke Yang #if defined(CONFIG_MMU)
24191da177e4SLinus Torvalds 	{
24201da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
24211da177e4SLinus Torvalds 		.data		= &randomize_va_space,
24221da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
24231da177e4SLinus Torvalds 		.mode		= 0644,
24246d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24251da177e4SLinus Torvalds 	},
24267a9166e3SLuke Yang #endif
24270152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2428951f22d5SMartin Schwidefsky 	{
2429951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
2430951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
2431951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
2432951f22d5SMartin Schwidefsky 		.mode		= 0644,
24336d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2434951f22d5SMartin Schwidefsky 	},
2435951f22d5SMartin Schwidefsky #endif
2436673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2437c255d844SPavel Machek 	{
2438c255d844SPavel Machek 		.procname	= "acpi_video_flags",
243977afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
2440c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
2441c255d844SPavel Machek 		.mode		= 0644,
24426d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
2443c255d844SPavel Machek 	},
2444c255d844SPavel Machek #endif
2445b6fca725SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2446d2b176edSJes Sorensen 	{
2447d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
2448d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
2449d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
2450d2b176edSJes Sorensen 		.mode		= 0644,
24516d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2452d2b176edSJes Sorensen 	},
2453b6fca725SVineet Gupta #endif
2454b6fca725SVineet Gupta #ifdef CONFIG_IA64
245588fc241fSDoug Chapman 	{
245688fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
245788fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
245888fc241fSDoug Chapman 		.maxlen		= sizeof (int),
245988fc241fSDoug Chapman 		.mode		= 0644,
24606d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
246188fc241fSDoug Chapman 	},
2462d2b176edSJes Sorensen #endif
2463e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
24640ec9dc9bSGuilherme G. Piccoli #ifdef CONFIG_SMP
24650ec9dc9bSGuilherme G. Piccoli 	{
24660ec9dc9bSGuilherme G. Piccoli 		.procname	= "hung_task_all_cpu_backtrace",
24670ec9dc9bSGuilherme G. Piccoli 		.data		= &sysctl_hung_task_all_cpu_backtrace,
24680ec9dc9bSGuilherme G. Piccoli 		.maxlen		= sizeof(int),
24690ec9dc9bSGuilherme G. Piccoli 		.mode		= 0644,
24700ec9dc9bSGuilherme G. Piccoli 		.proc_handler	= proc_dointvec_minmax,
24710ec9dc9bSGuilherme G. Piccoli 		.extra1		= SYSCTL_ZERO,
24720ec9dc9bSGuilherme G. Piccoli 		.extra2		= SYSCTL_ONE,
24730ec9dc9bSGuilherme G. Piccoli 	},
24740ec9dc9bSGuilherme G. Piccoli #endif /* CONFIG_SMP */
2475e162b39aSMandeep Singh Baines 	{
2476e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
2477e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
2478e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
2479e162b39aSMandeep Singh Baines 		.mode		= 0644,
24806d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2481eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2482eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2483e162b39aSMandeep Singh Baines 	},
248482a1fcb9SIngo Molnar 	{
248582a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
248682a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
2487cd64647fSLi Zefan 		.maxlen		= sizeof(int),
248882a1fcb9SIngo Molnar 		.mode		= 0644,
2489cd64647fSLi Zefan 		.proc_handler	= proc_dointvec_minmax,
2490eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
249182a1fcb9SIngo Molnar 	},
249282a1fcb9SIngo Molnar 	{
249382a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
249482a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
249590739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
249682a1fcb9SIngo Molnar 		.mode		= 0644,
24976d456111SEric W. Biederman 		.proc_handler	= proc_dohung_task_timeout_secs,
249880df2847SLiu Hua 		.extra2		= &hung_task_timeout_max,
249982a1fcb9SIngo Molnar 	},
250082a1fcb9SIngo Molnar 	{
2501a2e51445SDmitry Vyukov 		.procname	= "hung_task_check_interval_secs",
2502a2e51445SDmitry Vyukov 		.data		= &sysctl_hung_task_check_interval_secs,
2503a2e51445SDmitry Vyukov 		.maxlen		= sizeof(unsigned long),
2504a2e51445SDmitry Vyukov 		.mode		= 0644,
2505a2e51445SDmitry Vyukov 		.proc_handler	= proc_dohung_task_timeout_secs,
2506a2e51445SDmitry Vyukov 		.extra2		= &hung_task_timeout_max,
2507a2e51445SDmitry Vyukov 	},
2508a2e51445SDmitry Vyukov 	{
250982a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
251082a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
2511270750dbSAaron Tomlin 		.maxlen		= sizeof(int),
251282a1fcb9SIngo Molnar 		.mode		= 0644,
2513270750dbSAaron Tomlin 		.proc_handler	= proc_dointvec_minmax,
2514270750dbSAaron Tomlin 		.extra1		= &neg_one,
251582a1fcb9SIngo Molnar 	},
2516c4f3b63fSRavikiran G Thirumalai #endif
251723f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
251823f78d4aSIngo Molnar 	{
251923f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
252023f78d4aSIngo Molnar 		.data		= &max_lock_depth,
252123f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
252223f78d4aSIngo Molnar 		.mode		= 0644,
25236d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
252423f78d4aSIngo Molnar 	},
252523f78d4aSIngo Molnar #endif
252610a0a8d4SJeremy Fitzhardinge 	{
252710a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
252810a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
252910a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
253010a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
25316d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
253210a0a8d4SJeremy Fitzhardinge 	},
25330b77f5bfSDavid Howells #ifdef CONFIG_KEYS
25340b77f5bfSDavid Howells 	{
25350b77f5bfSDavid Howells 		.procname	= "keys",
25360b77f5bfSDavid Howells 		.mode		= 0555,
25370b77f5bfSDavid Howells 		.child		= key_sysctls,
25380b77f5bfSDavid Howells 	},
25390b77f5bfSDavid Howells #endif
2540cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS
2541aa4a2218SVince Weaver 	/*
2542aa4a2218SVince Weaver 	 * User-space scripts rely on the existence of this file
2543aa4a2218SVince Weaver 	 * as a feature check for perf_events being enabled.
2544aa4a2218SVince Weaver 	 *
2545aa4a2218SVince Weaver 	 * So it's an ABI, do not remove!
2546aa4a2218SVince Weaver 	 */
25471ccd1549SPeter Zijlstra 	{
2548cdd6c482SIngo Molnar 		.procname	= "perf_event_paranoid",
2549cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_paranoid,
2550cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_paranoid),
25511ccd1549SPeter Zijlstra 		.mode		= 0644,
25526d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
25531ccd1549SPeter Zijlstra 	},
2554c5078f78SPeter Zijlstra 	{
2555cdd6c482SIngo Molnar 		.procname	= "perf_event_mlock_kb",
2556cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_mlock,
2557cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_mlock),
2558c5078f78SPeter Zijlstra 		.mode		= 0644,
25596d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2560c5078f78SPeter Zijlstra 	},
2561a78ac325SPeter Zijlstra 	{
2562cdd6c482SIngo Molnar 		.procname	= "perf_event_max_sample_rate",
2563cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_sample_rate,
2564cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
2565a78ac325SPeter Zijlstra 		.mode		= 0644,
2566163ec435SPeter Zijlstra 		.proc_handler	= perf_proc_update_handler,
2567eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2568a78ac325SPeter Zijlstra 	},
256914c63f17SDave Hansen 	{
257014c63f17SDave Hansen 		.procname	= "perf_cpu_time_max_percent",
257114c63f17SDave Hansen 		.data		= &sysctl_perf_cpu_time_max_percent,
257214c63f17SDave Hansen 		.maxlen		= sizeof(sysctl_perf_cpu_time_max_percent),
257314c63f17SDave Hansen 		.mode		= 0644,
257414c63f17SDave Hansen 		.proc_handler	= perf_cpu_time_max_percent_handler,
2575eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
257614c63f17SDave Hansen 		.extra2		= &one_hundred,
257714c63f17SDave Hansen 	},
2578c5dfd78eSArnaldo Carvalho de Melo 	{
2579c5dfd78eSArnaldo Carvalho de Melo 		.procname	= "perf_event_max_stack",
2580a831100aSArnaldo Carvalho de Melo 		.data		= &sysctl_perf_event_max_stack,
2581c5dfd78eSArnaldo Carvalho de Melo 		.maxlen		= sizeof(sysctl_perf_event_max_stack),
2582c5dfd78eSArnaldo Carvalho de Melo 		.mode		= 0644,
2583c5dfd78eSArnaldo Carvalho de Melo 		.proc_handler	= perf_event_max_stack_handler,
2584eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2585c5dfd78eSArnaldo Carvalho de Melo 		.extra2		= &six_hundred_forty_kb,
2586c5dfd78eSArnaldo Carvalho de Melo 	},
2587c85b0334SArnaldo Carvalho de Melo 	{
2588c85b0334SArnaldo Carvalho de Melo 		.procname	= "perf_event_max_contexts_per_stack",
2589c85b0334SArnaldo Carvalho de Melo 		.data		= &sysctl_perf_event_max_contexts_per_stack,
2590c85b0334SArnaldo Carvalho de Melo 		.maxlen		= sizeof(sysctl_perf_event_max_contexts_per_stack),
2591c85b0334SArnaldo Carvalho de Melo 		.mode		= 0644,
2592c85b0334SArnaldo Carvalho de Melo 		.proc_handler	= perf_event_max_stack_handler,
2593eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2594c85b0334SArnaldo Carvalho de Melo 		.extra2		= &one_thousand,
2595c85b0334SArnaldo Carvalho de Melo 	},
25961ccd1549SPeter Zijlstra #endif
25979e3961a0SPrarit Bhargava 	{
25989e3961a0SPrarit Bhargava 		.procname	= "panic_on_warn",
25999e3961a0SPrarit Bhargava 		.data		= &panic_on_warn,
26009e3961a0SPrarit Bhargava 		.maxlen		= sizeof(int),
26019e3961a0SPrarit Bhargava 		.mode		= 0644,
26029e3961a0SPrarit Bhargava 		.proc_handler	= proc_dointvec_minmax,
2603eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2604eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
26059e3961a0SPrarit Bhargava 	},
2606bc7a34b8SThomas Gleixner #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2607bc7a34b8SThomas Gleixner 	{
2608bc7a34b8SThomas Gleixner 		.procname	= "timer_migration",
2609bc7a34b8SThomas Gleixner 		.data		= &sysctl_timer_migration,
2610bc7a34b8SThomas Gleixner 		.maxlen		= sizeof(unsigned int),
2611bc7a34b8SThomas Gleixner 		.mode		= 0644,
2612bc7a34b8SThomas Gleixner 		.proc_handler	= timer_migration_handler,
2613eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2614eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2615bc7a34b8SThomas Gleixner 	},
2616bc7a34b8SThomas Gleixner #endif
26171be7f75dSAlexei Starovoitov #ifdef CONFIG_BPF_SYSCALL
26181be7f75dSAlexei Starovoitov 	{
26191be7f75dSAlexei Starovoitov 		.procname	= "unprivileged_bpf_disabled",
26201be7f75dSAlexei Starovoitov 		.data		= &sysctl_unprivileged_bpf_disabled,
26211be7f75dSAlexei Starovoitov 		.maxlen		= sizeof(sysctl_unprivileged_bpf_disabled),
26221be7f75dSAlexei Starovoitov 		.mode		= 0644,
262308389d88SDaniel Borkmann 		.proc_handler	= bpf_unpriv_handler,
262408389d88SDaniel Borkmann 		.extra1		= SYSCTL_ZERO,
262508389d88SDaniel Borkmann 		.extra2		= &two,
26261be7f75dSAlexei Starovoitov 	},
2627492ecee8SAlexei Starovoitov 	{
2628492ecee8SAlexei Starovoitov 		.procname	= "bpf_stats_enabled",
2629a8e11e5cSEric Dumazet 		.data		= &bpf_stats_enabled_key.key,
2630a8e11e5cSEric Dumazet 		.maxlen		= sizeof(bpf_stats_enabled_key),
2631492ecee8SAlexei Starovoitov 		.mode		= 0644,
2632d46edd67SSong Liu 		.proc_handler	= bpf_stats_handler,
2633492ecee8SAlexei Starovoitov 	},
26343fcc5530SAlexei Starovoitov #endif
2635b3e627d3SLai Jiangshan #if defined(CONFIG_TREE_RCU)
2636088e9d25SDaniel Bristot de Oliveira 	{
2637088e9d25SDaniel Bristot de Oliveira 		.procname	= "panic_on_rcu_stall",
2638088e9d25SDaniel Bristot de Oliveira 		.data		= &sysctl_panic_on_rcu_stall,
2639088e9d25SDaniel Bristot de Oliveira 		.maxlen		= sizeof(sysctl_panic_on_rcu_stall),
2640088e9d25SDaniel Bristot de Oliveira 		.mode		= 0644,
2641088e9d25SDaniel Bristot de Oliveira 		.proc_handler	= proc_dointvec_minmax,
2642eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2643eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2644088e9d25SDaniel Bristot de Oliveira 	},
2645088e9d25SDaniel Bristot de Oliveira #endif
2646dfe56404Schao #if defined(CONFIG_TREE_RCU)
2647dfe56404Schao 	{
2648dfe56404Schao 		.procname	= "max_rcu_stall_to_panic",
2649dfe56404Schao 		.data		= &sysctl_max_rcu_stall_to_panic,
2650dfe56404Schao 		.maxlen		= sizeof(sysctl_max_rcu_stall_to_panic),
2651dfe56404Schao 		.mode		= 0644,
2652dfe56404Schao 		.proc_handler	= proc_dointvec_minmax,
2653dfe56404Schao 		.extra1		= SYSCTL_ONE,
2654dfe56404Schao 		.extra2		= SYSCTL_INT_MAX,
2655dfe56404Schao 	},
2656dfe56404Schao #endif
2657964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2658964c9dffSAlexander Popov 	{
2659964c9dffSAlexander Popov 		.procname	= "stack_erasing",
2660964c9dffSAlexander Popov 		.data		= NULL,
2661964c9dffSAlexander Popov 		.maxlen		= sizeof(int),
2662964c9dffSAlexander Popov 		.mode		= 0600,
2663964c9dffSAlexander Popov 		.proc_handler	= stack_erasing_sysctl,
2664eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2665eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2666964c9dffSAlexander Popov 	},
2667964c9dffSAlexander Popov #endif
26686fce56ecSEric W. Biederman 	{ }
26691da177e4SLinus Torvalds };
26701da177e4SLinus Torvalds 
2671d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
26721da177e4SLinus Torvalds 	{
26731da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
26741da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
26751da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
26761da177e4SLinus Torvalds 		.mode		= 0644,
267756f3547bSFeng Tang 		.proc_handler	= overcommit_policy_handler,
2678eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2679cb16e95fSPetr Holasek 		.extra2		= &two,
26801da177e4SLinus Torvalds 	},
26811da177e4SLinus Torvalds 	{
2682fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
2683fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
2684fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
2685fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
2686cb16e95fSPetr Holasek 		.proc_handler	= proc_dointvec_minmax,
2687eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2688cb16e95fSPetr Holasek 		.extra2		= &two,
2689fadd8fbdSKAMEZAWA Hiroyuki 	},
2690fadd8fbdSKAMEZAWA Hiroyuki 	{
2691fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
2692fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
2693fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
2694fe071d7eSDavid Rientjes 		.mode		= 0644,
26956d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2696fe071d7eSDavid Rientjes 	},
2697fe071d7eSDavid Rientjes 	{
2698fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
2699fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
2700fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
2701fef1bdd6SDavid Rientjes 		.mode		= 0644,
27026d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2703fef1bdd6SDavid Rientjes 	},
2704fef1bdd6SDavid Rientjes 	{
27051da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
27061da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
27071da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
27081da177e4SLinus Torvalds 		.mode		= 0644,
270949f0ce5fSJerome Marchand 		.proc_handler	= overcommit_ratio_handler,
271049f0ce5fSJerome Marchand 	},
271149f0ce5fSJerome Marchand 	{
271249f0ce5fSJerome Marchand 		.procname	= "overcommit_kbytes",
271349f0ce5fSJerome Marchand 		.data		= &sysctl_overcommit_kbytes,
271449f0ce5fSJerome Marchand 		.maxlen		= sizeof(sysctl_overcommit_kbytes),
271549f0ce5fSJerome Marchand 		.mode		= 0644,
271649f0ce5fSJerome Marchand 		.proc_handler	= overcommit_kbytes_handler,
27171da177e4SLinus Torvalds 	},
27181da177e4SLinus Torvalds 	{
27191da177e4SLinus Torvalds 		.procname	= "page-cluster",
27201da177e4SLinus Torvalds 		.data		= &page_cluster,
27211da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
27221da177e4SLinus Torvalds 		.mode		= 0644,
2723cb16e95fSPetr Holasek 		.proc_handler	= proc_dointvec_minmax,
2724eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27251da177e4SLinus Torvalds 	},
27261da177e4SLinus Torvalds 	{
27271da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
27281da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
27291da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
27301da177e4SLinus Torvalds 		.mode		= 0644,
27316d456111SEric W. Biederman 		.proc_handler	= dirty_background_ratio_handler,
2732eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27331da177e4SLinus Torvalds 		.extra2		= &one_hundred,
27341da177e4SLinus Torvalds 	},
27351da177e4SLinus Torvalds 	{
27362da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
27372da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
27382da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
27392da02997SDavid Rientjes 		.mode		= 0644,
27406d456111SEric W. Biederman 		.proc_handler	= dirty_background_bytes_handler,
2741fc3501d4SSven Wegener 		.extra1		= &one_ul,
27422da02997SDavid Rientjes 	},
27432da02997SDavid Rientjes 	{
27441da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
27451da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
27461da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
27471da177e4SLinus Torvalds 		.mode		= 0644,
27486d456111SEric W. Biederman 		.proc_handler	= dirty_ratio_handler,
2749eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27501da177e4SLinus Torvalds 		.extra2		= &one_hundred,
27511da177e4SLinus Torvalds 	},
27521da177e4SLinus Torvalds 	{
27532da02997SDavid Rientjes 		.procname	= "dirty_bytes",
27542da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
27552da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
27562da02997SDavid Rientjes 		.mode		= 0644,
27576d456111SEric W. Biederman 		.proc_handler	= dirty_bytes_handler,
27589e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
27592da02997SDavid Rientjes 	},
27602da02997SDavid Rientjes 	{
27611da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
2762f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
2763f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
27641da177e4SLinus Torvalds 		.mode		= 0644,
27656d456111SEric W. Biederman 		.proc_handler	= dirty_writeback_centisecs_handler,
27661da177e4SLinus Torvalds 	},
27671da177e4SLinus Torvalds 	{
27681da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
2769f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
2770f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
27711da177e4SLinus Torvalds 		.mode		= 0644,
2772cb16e95fSPetr Holasek 		.proc_handler	= proc_dointvec_minmax,
2773eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27741da177e4SLinus Torvalds 	},
27751da177e4SLinus Torvalds 	{
27761efff914STheodore Ts'o 		.procname	= "dirtytime_expire_seconds",
27771efff914STheodore Ts'o 		.data		= &dirtytime_expire_interval,
27782d87b309SRandy Dunlap 		.maxlen		= sizeof(dirtytime_expire_interval),
27791efff914STheodore Ts'o 		.mode		= 0644,
27801efff914STheodore Ts'o 		.proc_handler	= dirtytime_interval_handler,
2781eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27821efff914STheodore Ts'o 	},
27831efff914STheodore Ts'o 	{
27841da177e4SLinus Torvalds 		.procname	= "swappiness",
27851da177e4SLinus Torvalds 		.data		= &vm_swappiness,
27861da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
27871da177e4SLinus Torvalds 		.mode		= 0644,
27886d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2789eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2790c843966cSJohannes Weiner 		.extra2		= &two_hundred,
27911da177e4SLinus Torvalds 	},
27921da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
27931da177e4SLinus Torvalds 	{
27941da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
2795e5ff2159SAndi Kleen 		.data		= NULL,
27961da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
27971da177e4SLinus Torvalds 		.mode		= 0644,
27986d456111SEric W. Biederman 		.proc_handler	= hugetlb_sysctl_handler,
27991da177e4SLinus Torvalds 	},
280006808b08SLee Schermerhorn #ifdef CONFIG_NUMA
280106808b08SLee Schermerhorn 	{
280206808b08SLee Schermerhorn 		.procname       = "nr_hugepages_mempolicy",
280306808b08SLee Schermerhorn 		.data           = NULL,
280406808b08SLee Schermerhorn 		.maxlen         = sizeof(unsigned long),
280506808b08SLee Schermerhorn 		.mode           = 0644,
280606808b08SLee Schermerhorn 		.proc_handler   = &hugetlb_mempolicy_sysctl_handler,
280706808b08SLee Schermerhorn 	},
28084518085eSKemi Wang 	{
28094518085eSKemi Wang 		.procname		= "numa_stat",
28104518085eSKemi Wang 		.data			= &sysctl_vm_numa_stat,
28114518085eSKemi Wang 		.maxlen			= sizeof(int),
28124518085eSKemi Wang 		.mode			= 0644,
28134518085eSKemi Wang 		.proc_handler	= sysctl_vm_numa_stat_handler,
2814eec4844fSMatteo Croce 		.extra1			= SYSCTL_ZERO,
2815eec4844fSMatteo Croce 		.extra2			= SYSCTL_ONE,
28164518085eSKemi Wang 	},
281706808b08SLee Schermerhorn #endif
28181da177e4SLinus Torvalds 	 {
28191da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
28201da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
28211da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
28221da177e4SLinus Torvalds 		.mode		= 0644,
28236d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
28241da177e4SLinus Torvalds 	 },
2825396faf03SMel Gorman 	{
2826d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
2827e5ff2159SAndi Kleen 		.data		= NULL,
2828e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
2829d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
28306d456111SEric W. Biederman 		.proc_handler	= hugetlb_overcommit_handler,
2831d1c3fb1fSNishanth Aravamudan 	},
28321da177e4SLinus Torvalds #endif
28331da177e4SLinus Torvalds 	{
28341da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
28351da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
28361da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
28371da177e4SLinus Torvalds 		.mode		= 0644,
28386d456111SEric W. Biederman 		.proc_handler	= lowmem_reserve_ratio_sysctl_handler,
28391da177e4SLinus Torvalds 	},
28401da177e4SLinus Torvalds 	{
28419d0243bcSAndrew Morton 		.procname	= "drop_caches",
28429d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
28439d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
2844204cb79aSJohannes Weiner 		.mode		= 0200,
28459d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
2846eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
28475509a5d2SDave Hansen 		.extra2		= &four,
28489d0243bcSAndrew Morton 	},
284976ab0f53SMel Gorman #ifdef CONFIG_COMPACTION
285076ab0f53SMel Gorman 	{
285176ab0f53SMel Gorman 		.procname	= "compact_memory",
2852ef498438SPintu Kumar 		.data		= NULL,
285376ab0f53SMel Gorman 		.maxlen		= sizeof(int),
285476ab0f53SMel Gorman 		.mode		= 0200,
285576ab0f53SMel Gorman 		.proc_handler	= sysctl_compaction_handler,
285676ab0f53SMel Gorman 	},
28575e771905SMel Gorman 	{
2858facdaa91SNitin Gupta 		.procname	= "compaction_proactiveness",
2859facdaa91SNitin Gupta 		.data		= &sysctl_compaction_proactiveness,
2860d34c0a75SNitin Gupta 		.maxlen		= sizeof(sysctl_compaction_proactiveness),
2861facdaa91SNitin Gupta 		.mode		= 0644,
2862facdaa91SNitin Gupta 		.proc_handler	= proc_dointvec_minmax,
2863facdaa91SNitin Gupta 		.extra1		= SYSCTL_ZERO,
2864facdaa91SNitin Gupta 		.extra2		= &one_hundred,
2865facdaa91SNitin Gupta 	},
2866facdaa91SNitin Gupta 	{
28675e771905SMel Gorman 		.procname	= "extfrag_threshold",
28685e771905SMel Gorman 		.data		= &sysctl_extfrag_threshold,
28695e771905SMel Gorman 		.maxlen		= sizeof(int),
28705e771905SMel Gorman 		.mode		= 0644,
28716b7e5cadSMatthew Wilcox 		.proc_handler	= proc_dointvec_minmax,
28725e771905SMel Gorman 		.extra1		= &min_extfrag_threshold,
28735e771905SMel Gorman 		.extra2		= &max_extfrag_threshold,
28745e771905SMel Gorman 	},
28755bbe3547SEric B Munson 	{
28765bbe3547SEric B Munson 		.procname	= "compact_unevictable_allowed",
28775bbe3547SEric B Munson 		.data		= &sysctl_compact_unevictable_allowed,
28785bbe3547SEric B Munson 		.maxlen		= sizeof(int),
28795bbe3547SEric B Munson 		.mode		= 0644,
28806923aa0dSSebastian Andrzej Siewior 		.proc_handler	= proc_dointvec_minmax_warn_RT_change,
2881eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2882eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
28835bbe3547SEric B Munson 	},
28845e771905SMel Gorman 
288576ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */
28869d0243bcSAndrew Morton 	{
28871da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
28881da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
28891da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
28901da177e4SLinus Torvalds 		.mode		= 0644,
28916d456111SEric W. Biederman 		.proc_handler	= min_free_kbytes_sysctl_handler,
2892eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
28931da177e4SLinus Torvalds 	},
28948ad4b1fbSRohit Seth 	{
28951c30844dSMel Gorman 		.procname	= "watermark_boost_factor",
28961c30844dSMel Gorman 		.data		= &watermark_boost_factor,
28971c30844dSMel Gorman 		.maxlen		= sizeof(watermark_boost_factor),
28981c30844dSMel Gorman 		.mode		= 0644,
289926363af5SChristoph Hellwig 		.proc_handler	= proc_dointvec_minmax,
2900eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29011c30844dSMel Gorman 	},
29021c30844dSMel Gorman 	{
2903795ae7a0SJohannes Weiner 		.procname	= "watermark_scale_factor",
2904795ae7a0SJohannes Weiner 		.data		= &watermark_scale_factor,
2905795ae7a0SJohannes Weiner 		.maxlen		= sizeof(watermark_scale_factor),
2906795ae7a0SJohannes Weiner 		.mode		= 0644,
2907795ae7a0SJohannes Weiner 		.proc_handler	= watermark_scale_factor_sysctl_handler,
2908eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2909795ae7a0SJohannes Weiner 		.extra2		= &one_thousand,
2910795ae7a0SJohannes Weiner 	},
2911795ae7a0SJohannes Weiner 	{
291274f44822SMel Gorman 		.procname	= "percpu_pagelist_high_fraction",
291374f44822SMel Gorman 		.data		= &percpu_pagelist_high_fraction,
291474f44822SMel Gorman 		.maxlen		= sizeof(percpu_pagelist_high_fraction),
291574f44822SMel Gorman 		.mode		= 0644,
291674f44822SMel Gorman 		.proc_handler	= percpu_pagelist_high_fraction_sysctl_handler,
291774f44822SMel Gorman 		.extra1		= SYSCTL_ZERO,
291874f44822SMel Gorman 	},
291974f44822SMel Gorman 	{
29205ef64cc8SLinus Torvalds 		.procname	= "page_lock_unfairness",
29215ef64cc8SLinus Torvalds 		.data		= &sysctl_page_lock_unfairness,
29225ef64cc8SLinus Torvalds 		.maxlen		= sizeof(sysctl_page_lock_unfairness),
29235ef64cc8SLinus Torvalds 		.mode		= 0644,
29245ef64cc8SLinus Torvalds 		.proc_handler	= proc_dointvec_minmax,
29255ef64cc8SLinus Torvalds 		.extra1		= SYSCTL_ZERO,
29265ef64cc8SLinus Torvalds 	},
29271da177e4SLinus Torvalds #ifdef CONFIG_MMU
29281da177e4SLinus Torvalds 	{
29291da177e4SLinus Torvalds 		.procname	= "max_map_count",
29301da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
29311da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
29321da177e4SLinus Torvalds 		.mode		= 0644,
29333e26120cSWANG Cong 		.proc_handler	= proc_dointvec_minmax,
2934eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29351da177e4SLinus Torvalds 	},
2936dd8632a1SPaul Mundt #else
2937dd8632a1SPaul Mundt 	{
2938dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
2939dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
2940dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
2941dd8632a1SPaul Mundt 		.mode		= 0644,
29426d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2943eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2944dd8632a1SPaul Mundt 	},
29451da177e4SLinus Torvalds #endif
29461da177e4SLinus Torvalds 	{
29471da177e4SLinus Torvalds 		.procname	= "laptop_mode",
29481da177e4SLinus Torvalds 		.data		= &laptop_mode,
29491da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
29501da177e4SLinus Torvalds 		.mode		= 0644,
29516d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
29521da177e4SLinus Torvalds 	},
29531da177e4SLinus Torvalds 	{
29541da177e4SLinus Torvalds 		.procname	= "block_dump",
29551da177e4SLinus Torvalds 		.data		= &block_dump,
29561da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
29571da177e4SLinus Torvalds 		.mode		= 0644,
29583b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2959eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29601da177e4SLinus Torvalds 	},
29611da177e4SLinus Torvalds 	{
29621da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
29631da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
29641da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
29651da177e4SLinus Torvalds 		.mode		= 0644,
29663b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2967eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29681da177e4SLinus Torvalds 	},
296967f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
297067f3977fSAlexandre Ghiti     defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
29711da177e4SLinus Torvalds 	{
29721da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
29731da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
29741da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
29751da177e4SLinus Torvalds 		.mode		= 0644,
29763b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2977eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29781da177e4SLinus Torvalds 	},
29791da177e4SLinus Torvalds #endif
29801743660bSChristoph Lameter #ifdef CONFIG_NUMA
29811743660bSChristoph Lameter 	{
29821743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
2983a5f5f91dSMel Gorman 		.data		= &node_reclaim_mode,
2984a5f5f91dSMel Gorman 		.maxlen		= sizeof(node_reclaim_mode),
29851743660bSChristoph Lameter 		.mode		= 0644,
29863b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2987eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29881743660bSChristoph Lameter 	},
29899614634fSChristoph Lameter 	{
29909614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
29919614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
29929614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
29939614634fSChristoph Lameter 		.mode		= 0644,
29946d456111SEric W. Biederman 		.proc_handler	= sysctl_min_unmapped_ratio_sysctl_handler,
2995eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29969614634fSChristoph Lameter 		.extra2		= &one_hundred,
29979614634fSChristoph Lameter 	},
29980ff38490SChristoph Lameter 	{
29990ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
30000ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
30010ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
30020ff38490SChristoph Lameter 		.mode		= 0644,
30036d456111SEric W. Biederman 		.proc_handler	= sysctl_min_slab_ratio_sysctl_handler,
3004eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
30050ff38490SChristoph Lameter 		.extra2		= &one_hundred,
30060ff38490SChristoph Lameter 	},
30071743660bSChristoph Lameter #endif
300877461ab3SChristoph Lameter #ifdef CONFIG_SMP
300977461ab3SChristoph Lameter 	{
301077461ab3SChristoph Lameter 		.procname	= "stat_interval",
301177461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
301277461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
301377461ab3SChristoph Lameter 		.mode		= 0644,
30146d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
301577461ab3SChristoph Lameter 	},
301652b6f46bSHugh Dickins 	{
301752b6f46bSHugh Dickins 		.procname	= "stat_refresh",
301852b6f46bSHugh Dickins 		.data		= NULL,
301952b6f46bSHugh Dickins 		.maxlen		= 0,
302052b6f46bSHugh Dickins 		.mode		= 0600,
302152b6f46bSHugh Dickins 		.proc_handler	= vmstat_refresh,
302252b6f46bSHugh Dickins 	},
302377461ab3SChristoph Lameter #endif
30246e141546SDavid Howells #ifdef CONFIG_MMU
3025ed032189SEric Paris 	{
3026ed032189SEric Paris 		.procname	= "mmap_min_addr",
3027788084abSEric Paris 		.data		= &dac_mmap_min_addr,
3028ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
3029ed032189SEric Paris 		.mode		= 0644,
30306d456111SEric W. Biederman 		.proc_handler	= mmap_min_addr_handler,
3031ed032189SEric Paris 	},
30326e141546SDavid Howells #endif
3033f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
3034f0c0b2b8SKAMEZAWA Hiroyuki 	{
3035f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
3036f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
3037f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
3038f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
30396d456111SEric W. Biederman 		.proc_handler	= numa_zonelist_order_handler,
3040f0c0b2b8SKAMEZAWA Hiroyuki 	},
3041f0c0b2b8SKAMEZAWA Hiroyuki #endif
30422b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
30435c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3044e6e5494cSIngo Molnar 	{
3045e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
30463d7ee969SAndy Lutomirski #ifdef CONFIG_X86_32
30473d7ee969SAndy Lutomirski 		.data		= &vdso32_enabled,
30483d7ee969SAndy Lutomirski 		.maxlen		= sizeof(vdso32_enabled),
30493d7ee969SAndy Lutomirski #else
3050e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
3051e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
30523d7ee969SAndy Lutomirski #endif
3053e6e5494cSIngo Molnar 		.mode		= 0644,
30546d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3055eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3056e6e5494cSIngo Molnar 	},
3057e6e5494cSIngo Molnar #endif
3058195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
3059195cf453SBron Gondwana 	{
3060195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
3061195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
3062195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
3063195cf453SBron Gondwana 		.mode		= 0644,
30646d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3065eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3066eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3067195cf453SBron Gondwana 	},
3068195cf453SBron Gondwana #endif
30696a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE
30706a46079cSAndi Kleen 	{
30716a46079cSAndi Kleen 		.procname	= "memory_failure_early_kill",
30726a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_early_kill,
30736a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_early_kill),
30746a46079cSAndi Kleen 		.mode		= 0644,
30756d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3076eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3077eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
30786a46079cSAndi Kleen 	},
30796a46079cSAndi Kleen 	{
30806a46079cSAndi Kleen 		.procname	= "memory_failure_recovery",
30816a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_recovery,
30826a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_recovery),
30836a46079cSAndi Kleen 		.mode		= 0644,
30846d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3085eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3086eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
30876a46079cSAndi Kleen 	},
30886a46079cSAndi Kleen #endif
3089c9b1d098SAndrew Shewmaker 	{
3090c9b1d098SAndrew Shewmaker 		.procname	= "user_reserve_kbytes",
3091c9b1d098SAndrew Shewmaker 		.data		= &sysctl_user_reserve_kbytes,
3092c9b1d098SAndrew Shewmaker 		.maxlen		= sizeof(sysctl_user_reserve_kbytes),
3093c9b1d098SAndrew Shewmaker 		.mode		= 0644,
3094c9b1d098SAndrew Shewmaker 		.proc_handler	= proc_doulongvec_minmax,
3095c9b1d098SAndrew Shewmaker 	},
30964eeab4f5SAndrew Shewmaker 	{
30974eeab4f5SAndrew Shewmaker 		.procname	= "admin_reserve_kbytes",
30984eeab4f5SAndrew Shewmaker 		.data		= &sysctl_admin_reserve_kbytes,
30994eeab4f5SAndrew Shewmaker 		.maxlen		= sizeof(sysctl_admin_reserve_kbytes),
31004eeab4f5SAndrew Shewmaker 		.mode		= 0644,
31014eeab4f5SAndrew Shewmaker 		.proc_handler	= proc_doulongvec_minmax,
31024eeab4f5SAndrew Shewmaker 	},
3103d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3104d07e2259SDaniel Cashman 	{
3105d07e2259SDaniel Cashman 		.procname	= "mmap_rnd_bits",
3106d07e2259SDaniel Cashman 		.data		= &mmap_rnd_bits,
3107d07e2259SDaniel Cashman 		.maxlen		= sizeof(mmap_rnd_bits),
3108d07e2259SDaniel Cashman 		.mode		= 0600,
3109d07e2259SDaniel Cashman 		.proc_handler	= proc_dointvec_minmax,
3110d07e2259SDaniel Cashman 		.extra1		= (void *)&mmap_rnd_bits_min,
3111d07e2259SDaniel Cashman 		.extra2		= (void *)&mmap_rnd_bits_max,
3112d07e2259SDaniel Cashman 	},
3113d07e2259SDaniel Cashman #endif
3114d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3115d07e2259SDaniel Cashman 	{
3116d07e2259SDaniel Cashman 		.procname	= "mmap_rnd_compat_bits",
3117d07e2259SDaniel Cashman 		.data		= &mmap_rnd_compat_bits,
3118d07e2259SDaniel Cashman 		.maxlen		= sizeof(mmap_rnd_compat_bits),
3119d07e2259SDaniel Cashman 		.mode		= 0600,
3120d07e2259SDaniel Cashman 		.proc_handler	= proc_dointvec_minmax,
3121d07e2259SDaniel Cashman 		.extra1		= (void *)&mmap_rnd_compat_bits_min,
3122d07e2259SDaniel Cashman 		.extra2		= (void *)&mmap_rnd_compat_bits_max,
3123d07e2259SDaniel Cashman 	},
3124d07e2259SDaniel Cashman #endif
3125cefdca0aSPeter Xu #ifdef CONFIG_USERFAULTFD
3126cefdca0aSPeter Xu 	{
3127cefdca0aSPeter Xu 		.procname	= "unprivileged_userfaultfd",
3128cefdca0aSPeter Xu 		.data		= &sysctl_unprivileged_userfaultfd,
3129cefdca0aSPeter Xu 		.maxlen		= sizeof(sysctl_unprivileged_userfaultfd),
3130cefdca0aSPeter Xu 		.mode		= 0644,
3131cefdca0aSPeter Xu 		.proc_handler	= proc_dointvec_minmax,
3132eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3133eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3134cefdca0aSPeter Xu 	},
3135cefdca0aSPeter Xu #endif
31366fce56ecSEric W. Biederman 	{ }
31371da177e4SLinus Torvalds };
31381da177e4SLinus Torvalds 
3139d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
31401da177e4SLinus Torvalds 	{
31411da177e4SLinus Torvalds 		.procname	= "inode-nr",
31421da177e4SLinus Torvalds 		.data		= &inodes_stat,
31433942c07cSGlauber Costa 		.maxlen		= 2*sizeof(long),
31441da177e4SLinus Torvalds 		.mode		= 0444,
3145cffbc8aaSDave Chinner 		.proc_handler	= proc_nr_inodes,
31461da177e4SLinus Torvalds 	},
31471da177e4SLinus Torvalds 	{
31481da177e4SLinus Torvalds 		.procname	= "inode-state",
31491da177e4SLinus Torvalds 		.data		= &inodes_stat,
31503942c07cSGlauber Costa 		.maxlen		= 7*sizeof(long),
31511da177e4SLinus Torvalds 		.mode		= 0444,
3152cffbc8aaSDave Chinner 		.proc_handler	= proc_nr_inodes,
31531da177e4SLinus Torvalds 	},
31541da177e4SLinus Torvalds 	{
31551da177e4SLinus Torvalds 		.procname	= "file-nr",
31561da177e4SLinus Torvalds 		.data		= &files_stat,
3157518de9b3SEric Dumazet 		.maxlen		= sizeof(files_stat),
31581da177e4SLinus Torvalds 		.mode		= 0444,
31596d456111SEric W. Biederman 		.proc_handler	= proc_nr_files,
31601da177e4SLinus Torvalds 	},
31611da177e4SLinus Torvalds 	{
31621da177e4SLinus Torvalds 		.procname	= "file-max",
31631da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
3164518de9b3SEric Dumazet 		.maxlen		= sizeof(files_stat.max_files),
31651da177e4SLinus Torvalds 		.mode		= 0644,
3166518de9b3SEric Dumazet 		.proc_handler	= proc_doulongvec_minmax,
31679002b214SWill Deacon 		.extra1		= &zero_ul,
316832a5ad9cSChristian Brauner 		.extra2		= &long_max,
31691da177e4SLinus Torvalds 	},
31701da177e4SLinus Torvalds 	{
31719cfe015aSEric Dumazet 		.procname	= "nr_open",
31729cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
31739b80a184SAlexey Dobriyan 		.maxlen		= sizeof(unsigned int),
31749cfe015aSEric Dumazet 		.mode		= 0644,
31756d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3176eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
3177eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
31789cfe015aSEric Dumazet 	},
31799cfe015aSEric Dumazet 	{
31801da177e4SLinus Torvalds 		.procname	= "dentry-state",
31811da177e4SLinus Torvalds 		.data		= &dentry_stat,
31823942c07cSGlauber Costa 		.maxlen		= 6*sizeof(long),
31831da177e4SLinus Torvalds 		.mode		= 0444,
3184312d3ca8SChristoph Hellwig 		.proc_handler	= proc_nr_dentry,
31851da177e4SLinus Torvalds 	},
31861da177e4SLinus Torvalds 	{
31871da177e4SLinus Torvalds 		.procname	= "overflowuid",
31881da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
31891da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
31901da177e4SLinus Torvalds 		.mode		= 0644,
31916d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
31921da177e4SLinus Torvalds 		.extra1		= &minolduid,
31931da177e4SLinus Torvalds 		.extra2		= &maxolduid,
31941da177e4SLinus Torvalds 	},
31951da177e4SLinus Torvalds 	{
31961da177e4SLinus Torvalds 		.procname	= "overflowgid",
31971da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
31981da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
31991da177e4SLinus Torvalds 		.mode		= 0644,
32006d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
32011da177e4SLinus Torvalds 		.extra1		= &minolduid,
32021da177e4SLinus Torvalds 		.extra2		= &maxolduid,
32031da177e4SLinus Torvalds 	},
3204bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
32051da177e4SLinus Torvalds 	{
32061da177e4SLinus Torvalds 		.procname	= "leases-enable",
32071da177e4SLinus Torvalds 		.data		= &leases_enable,
32081da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32091da177e4SLinus Torvalds 		.mode		= 0644,
32106d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
32111da177e4SLinus Torvalds 	},
3212bfcd17a6SThomas Petazzoni #endif
32131da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
32141da177e4SLinus Torvalds 	{
32151da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
32161da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
32171da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32181da177e4SLinus Torvalds 		.mode		= 0644,
32196d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
32201da177e4SLinus Torvalds 	},
32211da177e4SLinus Torvalds #endif
32221da177e4SLinus Torvalds #ifdef CONFIG_MMU
3223bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
32241da177e4SLinus Torvalds 	{
32251da177e4SLinus Torvalds 		.procname	= "lease-break-time",
32261da177e4SLinus Torvalds 		.data		= &lease_break_time,
32271da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32281da177e4SLinus Torvalds 		.mode		= 0644,
32296d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
32301da177e4SLinus Torvalds 	},
3231bfcd17a6SThomas Petazzoni #endif
3232ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
32331da177e4SLinus Torvalds 	{
32341da177e4SLinus Torvalds 		.procname	= "aio-nr",
32351da177e4SLinus Torvalds 		.data		= &aio_nr,
32361da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
32371da177e4SLinus Torvalds 		.mode		= 0444,
32386d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
32391da177e4SLinus Torvalds 	},
32401da177e4SLinus Torvalds 	{
32411da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
32421da177e4SLinus Torvalds 		.data		= &aio_max_nr,
32431da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
32441da177e4SLinus Torvalds 		.mode		= 0644,
32456d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
32461da177e4SLinus Torvalds 	},
3247ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
32482d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
32490399cb08SRobert Love 	{
32500399cb08SRobert Love 		.procname	= "inotify",
32510399cb08SRobert Love 		.mode		= 0555,
32520399cb08SRobert Love 		.child		= inotify_table,
32530399cb08SRobert Love 	},
32540399cb08SRobert Love #endif
32555b8fea65SAmir Goldstein #ifdef CONFIG_FANOTIFY
32565b8fea65SAmir Goldstein 	{
32575b8fea65SAmir Goldstein 		.procname	= "fanotify",
32585b8fea65SAmir Goldstein 		.mode		= 0555,
32595b8fea65SAmir Goldstein 		.child		= fanotify_table,
32605b8fea65SAmir Goldstein 	},
32615b8fea65SAmir Goldstein #endif
32627ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
32637ef9964eSDavide Libenzi 	{
32647ef9964eSDavide Libenzi 		.procname	= "epoll",
32657ef9964eSDavide Libenzi 		.mode		= 0555,
32667ef9964eSDavide Libenzi 		.child		= epoll_table,
32677ef9964eSDavide Libenzi 	},
32687ef9964eSDavide Libenzi #endif
32691da177e4SLinus Torvalds #endif
3270d6e71144SAlan Cox 	{
3271800179c9SKees Cook 		.procname	= "protected_symlinks",
3272800179c9SKees Cook 		.data		= &sysctl_protected_symlinks,
3273800179c9SKees Cook 		.maxlen		= sizeof(int),
3274800179c9SKees Cook 		.mode		= 0600,
3275800179c9SKees Cook 		.proc_handler	= proc_dointvec_minmax,
3276eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3277eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3278800179c9SKees Cook 	},
3279800179c9SKees Cook 	{
3280800179c9SKees Cook 		.procname	= "protected_hardlinks",
3281800179c9SKees Cook 		.data		= &sysctl_protected_hardlinks,
3282800179c9SKees Cook 		.maxlen		= sizeof(int),
3283800179c9SKees Cook 		.mode		= 0600,
3284800179c9SKees Cook 		.proc_handler	= proc_dointvec_minmax,
3285eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3286eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3287800179c9SKees Cook 	},
3288800179c9SKees Cook 	{
328930aba665SSalvatore Mesoraca 		.procname	= "protected_fifos",
329030aba665SSalvatore Mesoraca 		.data		= &sysctl_protected_fifos,
329130aba665SSalvatore Mesoraca 		.maxlen		= sizeof(int),
329230aba665SSalvatore Mesoraca 		.mode		= 0600,
329330aba665SSalvatore Mesoraca 		.proc_handler	= proc_dointvec_minmax,
3294eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
329530aba665SSalvatore Mesoraca 		.extra2		= &two,
329630aba665SSalvatore Mesoraca 	},
329730aba665SSalvatore Mesoraca 	{
329830aba665SSalvatore Mesoraca 		.procname	= "protected_regular",
329930aba665SSalvatore Mesoraca 		.data		= &sysctl_protected_regular,
330030aba665SSalvatore Mesoraca 		.maxlen		= sizeof(int),
330130aba665SSalvatore Mesoraca 		.mode		= 0600,
330230aba665SSalvatore Mesoraca 		.proc_handler	= proc_dointvec_minmax,
3303eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
330430aba665SSalvatore Mesoraca 		.extra2		= &two,
330530aba665SSalvatore Mesoraca 	},
330630aba665SSalvatore Mesoraca 	{
3307d6e71144SAlan Cox 		.procname	= "suid_dumpable",
3308d6e71144SAlan Cox 		.data		= &suid_dumpable,
3309d6e71144SAlan Cox 		.maxlen		= sizeof(int),
3310d6e71144SAlan Cox 		.mode		= 0644,
331154b50199SKees Cook 		.proc_handler	= proc_dointvec_minmax_coredump,
3312eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
33138e654fbaSMatthew Wilcox 		.extra2		= &two,
3314d6e71144SAlan Cox 	},
33152abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
33162abc26fcSEric W. Biederman 	{
33172abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
33182abc26fcSEric W. Biederman 		.mode		= 0555,
3319f9bd6733SEric W. Biederman 		.child		= sysctl_mount_point,
33202abc26fcSEric W. Biederman 	},
33212abc26fcSEric W. Biederman #endif
3322b492e95bSJens Axboe 	{
3323ff9da691SJens Axboe 		.procname	= "pipe-max-size",
3324ff9da691SJens Axboe 		.data		= &pipe_max_size,
332598159d97SJoe Lawrence 		.maxlen		= sizeof(pipe_max_size),
3326b492e95bSJens Axboe 		.mode		= 0644,
3327319e0a21SEric Biggers 		.proc_handler	= proc_dopipe_max_size,
3328b492e95bSJens Axboe 	},
3329759c0114SWilly Tarreau 	{
3330759c0114SWilly Tarreau 		.procname	= "pipe-user-pages-hard",
3331759c0114SWilly Tarreau 		.data		= &pipe_user_pages_hard,
3332759c0114SWilly Tarreau 		.maxlen		= sizeof(pipe_user_pages_hard),
3333759c0114SWilly Tarreau 		.mode		= 0644,
3334759c0114SWilly Tarreau 		.proc_handler	= proc_doulongvec_minmax,
3335759c0114SWilly Tarreau 	},
3336759c0114SWilly Tarreau 	{
3337759c0114SWilly Tarreau 		.procname	= "pipe-user-pages-soft",
3338759c0114SWilly Tarreau 		.data		= &pipe_user_pages_soft,
3339759c0114SWilly Tarreau 		.maxlen		= sizeof(pipe_user_pages_soft),
3340759c0114SWilly Tarreau 		.mode		= 0644,
3341759c0114SWilly Tarreau 		.proc_handler	= proc_doulongvec_minmax,
3342759c0114SWilly Tarreau 	},
3343d2921684SEric W. Biederman 	{
3344d2921684SEric W. Biederman 		.procname	= "mount-max",
3345d2921684SEric W. Biederman 		.data		= &sysctl_mount_max,
3346d2921684SEric W. Biederman 		.maxlen		= sizeof(unsigned int),
3347d2921684SEric W. Biederman 		.mode		= 0644,
3348d2921684SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3349eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
3350d2921684SEric W. Biederman 	},
33516fce56ecSEric W. Biederman 	{ }
33521da177e4SLinus Torvalds };
33531da177e4SLinus Torvalds 
3354d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
33557ac57a89SCatalin Marinas #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3356abd4f750SMasoud Asgharifard Sharbiani 	{
3357abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
3358abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
3359abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
3360abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
3361abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
3362abd4f750SMasoud Asgharifard Sharbiani 	},
3363abd4f750SMasoud Asgharifard Sharbiani #endif
3364b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES)
3365b2be84dfSMasami Hiramatsu 	{
3366b2be84dfSMasami Hiramatsu 		.procname	= "kprobes-optimization",
3367b2be84dfSMasami Hiramatsu 		.data		= &sysctl_kprobes_optimization,
3368b2be84dfSMasami Hiramatsu 		.maxlen		= sizeof(int),
3369b2be84dfSMasami Hiramatsu 		.mode		= 0644,
3370b2be84dfSMasami Hiramatsu 		.proc_handler	= proc_kprobes_optimization_handler,
3371eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3372eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3373b2be84dfSMasami Hiramatsu 	},
3374b2be84dfSMasami Hiramatsu #endif
33756fce56ecSEric W. Biederman 	{ }
33761da177e4SLinus Torvalds };
33771da177e4SLinus Torvalds 
3378d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
33796fce56ecSEric W. Biederman 	{ }
33801da177e4SLinus Torvalds };
33811da177e4SLinus Torvalds 
3382f461d2dcSChristoph Hellwig static struct ctl_table sysctl_base_table[] = {
3383f461d2dcSChristoph Hellwig 	{
3384f461d2dcSChristoph Hellwig 		.procname	= "kernel",
3385f461d2dcSChristoph Hellwig 		.mode		= 0555,
3386f461d2dcSChristoph Hellwig 		.child		= kern_table,
3387f461d2dcSChristoph Hellwig 	},
3388f461d2dcSChristoph Hellwig 	{
3389f461d2dcSChristoph Hellwig 		.procname	= "vm",
3390f461d2dcSChristoph Hellwig 		.mode		= 0555,
3391f461d2dcSChristoph Hellwig 		.child		= vm_table,
3392f461d2dcSChristoph Hellwig 	},
3393f461d2dcSChristoph Hellwig 	{
3394f461d2dcSChristoph Hellwig 		.procname	= "fs",
3395f461d2dcSChristoph Hellwig 		.mode		= 0555,
3396f461d2dcSChristoph Hellwig 		.child		= fs_table,
3397f461d2dcSChristoph Hellwig 	},
3398f461d2dcSChristoph Hellwig 	{
3399f461d2dcSChristoph Hellwig 		.procname	= "debug",
3400f461d2dcSChristoph Hellwig 		.mode		= 0555,
3401f461d2dcSChristoph Hellwig 		.child		= debug_table,
3402f461d2dcSChristoph Hellwig 	},
3403f461d2dcSChristoph Hellwig 	{
3404f461d2dcSChristoph Hellwig 		.procname	= "dev",
3405f461d2dcSChristoph Hellwig 		.mode		= 0555,
3406f461d2dcSChristoph Hellwig 		.child		= dev_table,
3407f461d2dcSChristoph Hellwig 	},
3408f461d2dcSChristoph Hellwig 	{ }
3409f461d2dcSChristoph Hellwig };
3410f461d2dcSChristoph Hellwig 
3411de4e83bdSEric W. Biederman int __init sysctl_init(void)
3412330d57fbSAl Viro {
3413fd4b616bSSteven Rostedt 	struct ctl_table_header *hdr;
3414fd4b616bSSteven Rostedt 
3415fd4b616bSSteven Rostedt 	hdr = register_sysctl_table(sysctl_base_table);
3416fd4b616bSSteven Rostedt 	kmemleak_not_leak(hdr);
3417330d57fbSAl Viro 	return 0;
3418f7e6ced4SAl Viro }
3419b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
34201da177e4SLinus Torvalds /*
34211da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
34221da177e4SLinus Torvalds  * exception granted :-)
34231da177e4SLinus Torvalds  */
34241da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
3425e7d316a0SSubash Abhinov Kasiviswanathan EXPORT_SYMBOL(proc_douintvec);
34261da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
34271da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
342861d9b56aSLuis R. Rodriguez EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
34291da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
34301da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
34311da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
34321da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
34331da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
34340bc19985SStephen Suryaputra EXPORT_SYMBOL(proc_do_large_bitmap);
3435