xref: /openbmc/linux/kernel/sysctl.c (revision 9a52c5f3c8957872b2750314b56c64d9600542a9)
1457c8996SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * sysctl.c: General linux system control interface
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  * Begun 24 March 1995, Stephen Tweedie
61da177e4SLinus Torvalds  * Added /proc support, Dec 1995
71da177e4SLinus Torvalds  * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
81da177e4SLinus Torvalds  * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
91da177e4SLinus Torvalds  * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
101da177e4SLinus Torvalds  * Dynamic registration fixes, Stephen Tweedie.
111da177e4SLinus Torvalds  * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
121da177e4SLinus Torvalds  * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
131da177e4SLinus Torvalds  *  Horn.
141da177e4SLinus Torvalds  * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
151da177e4SLinus Torvalds  * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
161da177e4SLinus Torvalds  * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
171da177e4SLinus Torvalds  *  Wendling.
181da177e4SLinus Torvalds  * The list_for_each() macro wasn't appropriate for the sysctl loop.
191da177e4SLinus Torvalds  *  Removed it and replaced it with older style, 03/23/00, Bill Wendling
201da177e4SLinus Torvalds  */
211da177e4SLinus Torvalds 
221da177e4SLinus Torvalds #include <linux/module.h>
23e2e40f2cSChristoph Hellwig #include <linux/aio.h>
241da177e4SLinus Torvalds #include <linux/mm.h>
251da177e4SLinus Torvalds #include <linux/swap.h>
261da177e4SLinus Torvalds #include <linux/slab.h>
271da177e4SLinus Torvalds #include <linux/sysctl.h>
285a04cca6SAkinobu Mita #include <linux/bitmap.h>
29d33ed52dSDave Young #include <linux/signal.h>
30455cd5abSDan Rosenberg #include <linux/printk.h>
311da177e4SLinus Torvalds #include <linux/proc_fs.h>
3272c2d582SAndrew Morgan #include <linux/security.h>
331da177e4SLinus Torvalds #include <linux/ctype.h>
34fd4b616bSSteven Rostedt #include <linux/kmemleak.h>
3562239ac2SAdrian Bunk #include <linux/fs.h>
361da177e4SLinus Torvalds #include <linux/init.h>
371da177e4SLinus Torvalds #include <linux/kernel.h>
380296b228SKay Sievers #include <linux/kobject.h>
3920380731SArnaldo Carvalho de Melo #include <linux/net.h>
401da177e4SLinus Torvalds #include <linux/sysrq.h>
411da177e4SLinus Torvalds #include <linux/highuid.h>
421da177e4SLinus Torvalds #include <linux/writeback.h>
433fff4c42SIngo Molnar #include <linux/ratelimit.h>
4476ab0f53SMel Gorman #include <linux/compaction.h>
451da177e4SLinus Torvalds #include <linux/hugetlb.h>
461da177e4SLinus Torvalds #include <linux/initrd.h>
470b77f5bfSDavid Howells #include <linux/key.h>
481da177e4SLinus Torvalds #include <linux/times.h>
491da177e4SLinus Torvalds #include <linux/limits.h>
501da177e4SLinus Torvalds #include <linux/dcache.h>
516e006701SAlexey Dobriyan #include <linux/dnotify.h>
521da177e4SLinus Torvalds #include <linux/syscalls.h>
53c748e134SAdrian Bunk #include <linux/vmstat.h>
54c255d844SPavel Machek #include <linux/nfs_fs.h>
55c255d844SPavel Machek #include <linux/acpi.h>
5610a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h>
57b0fc494fSSteven Rostedt #include <linux/ftrace.h>
58cdd6c482SIngo Molnar #include <linux/perf_event.h>
59b2be84dfSMasami Hiramatsu #include <linux/kprobes.h>
60b492e95bSJens Axboe #include <linux/pipe_fs_i.h>
618e4228e1SDavid Rientjes #include <linux/oom.h>
6217f60a7dSEric Paris #include <linux/kmod.h>
6373efc039SDan Ballard #include <linux/capability.h>
6440401530SAl Viro #include <linux/binfmts.h>
65cf4aebc2SClark Williams #include <linux/sched/sysctl.h>
66f7ccbae4SIngo Molnar #include <linux/sched/coredump.h>
677984754bSKees Cook #include <linux/kexec.h>
681be7f75dSAlexei Starovoitov #include <linux/bpf.h>
69d2921684SEric W. Biederman #include <linux/mount.h>
70cefdca0aSPeter Xu #include <linux/userfaultfd_k.h>
712374c09bSChristoph Hellwig #include <linux/coredump.h>
722374c09bSChristoph Hellwig #include <linux/latencytop.h>
732374c09bSChristoph Hellwig #include <linux/pid.h>
741da177e4SLinus Torvalds 
757f2923c4SChristian Brauner #include "../lib/kstrtox.h"
767f2923c4SChristian Brauner 
777c0f6ba6SLinus Torvalds #include <linux/uaccess.h>
781da177e4SLinus Torvalds #include <asm/processor.h>
791da177e4SLinus Torvalds 
8029cbc78bSAndi Kleen #ifdef CONFIG_X86
8129cbc78bSAndi Kleen #include <asm/nmi.h>
820741f4d2SChuck Ebbert #include <asm/stacktrace.h>
836e7c4025SIngo Molnar #include <asm/io.h>
8429cbc78bSAndi Kleen #endif
85d550bbd4SDavid Howells #ifdef CONFIG_SPARC
86d550bbd4SDavid Howells #include <asm/setup.h>
87d550bbd4SDavid Howells #endif
88c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT
89c55b7c3eSDave Young #include <linux/acct.h>
90c55b7c3eSDave Young #endif
914f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES
924f0e056fSDave Young #include <linux/rtmutex.h>
934f0e056fSDave Young #endif
942edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
952edf5e49SDave Young #include <linux/lockdep.h>
962edf5e49SDave Young #endif
9715485a46SDave Young #ifdef CONFIG_CHR_DEV_SG
9815485a46SDave Young #include <scsi/sg.h>
9915485a46SDave Young #endif
100964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
101964c9dffSAlexander Popov #include <linux/stackleak.h>
102964c9dffSAlexander Popov #endif
10358687acbSDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR
104504d7cf1SDon Zickus #include <linux/nmi.h>
105504d7cf1SDon Zickus #endif
106504d7cf1SDon Zickus 
1071da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL)
1081da177e4SLinus Torvalds 
109c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and  maximum */
1102508ce18SDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR
111c4f3b63fSRavikiran G Thirumalai static int sixty = 60;
112c4f3b63fSRavikiran G Thirumalai #endif
113c4f3b63fSRavikiran G Thirumalai 
114270750dbSAaron Tomlin static int __maybe_unused neg_one = -1;
115cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2;
1165509a5d2SDave Hansen static int __maybe_unused four = 4;
1179002b214SWill Deacon static unsigned long zero_ul;
118fc3501d4SSven Wegener static unsigned long one_ul = 1;
11932a5ad9cSChristian Brauner static unsigned long long_max = LONG_MAX;
120c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100;
121c843966cSJohannes Weiner static int two_hundred = 200;
122795ae7a0SJohannes Weiner static int one_thousand = 1000;
123af91322eSDave Young #ifdef CONFIG_PRINTK
124af91322eSDave Young static int ten_thousand = 10000;
125af91322eSDave Young #endif
126c5dfd78eSArnaldo Carvalho de Melo #ifdef CONFIG_PERF_EVENTS
127c5dfd78eSArnaldo Carvalho de Melo static int six_hundred_forty_kb = 640 * 1024;
128c5dfd78eSArnaldo Carvalho de Melo #endif
129c4f3b63fSRavikiran G Thirumalai 
1309e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
1319e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1329e4a5bdaSAndrea Righi 
1331da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1341da177e4SLinus Torvalds static int maxolduid = 65535;
1351da177e4SLinus Torvalds static int minolduid;
1361da177e4SLinus Torvalds 
1371da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
13873efc039SDan Ballard static const int cap_last_cap = CAP_LAST_CAP;
1391da177e4SLinus Torvalds 
140a2e51445SDmitry Vyukov /*
141a2e51445SDmitry Vyukov  * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
142a2e51445SDmitry Vyukov  * and hung_task_check_interval_secs
143a2e51445SDmitry Vyukov  */
14480df2847SLiu Hua #ifdef CONFIG_DETECT_HUNG_TASK
14580df2847SLiu Hua static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
14680df2847SLiu Hua #endif
14780df2847SLiu Hua 
148d14f1729SDave Young #ifdef CONFIG_INOTIFY_USER
149d14f1729SDave Young #include <linux/inotify.h>
150d14f1729SDave Young #endif
1515b8fea65SAmir Goldstein #ifdef CONFIG_FANOTIFY
1525b8fea65SAmir Goldstein #include <linux/fanotify.h>
1535b8fea65SAmir Goldstein #endif
154b6fca725SVineet Gupta 
155d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
156f4aacea2SKees Cook 
157a19ac337SLuis R. Rodriguez /**
158a19ac337SLuis R. Rodriguez  * enum sysctl_writes_mode - supported sysctl write modes
159a19ac337SLuis R. Rodriguez  *
160a19ac337SLuis R. Rodriguez  * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
161a19ac337SLuis R. Rodriguez  *	to be written, and multiple writes on the same sysctl file descriptor
162a19ac337SLuis R. Rodriguez  *	will rewrite the sysctl value, regardless of file position. No warning
163a19ac337SLuis R. Rodriguez  *	is issued when the initial position is not 0.
164a19ac337SLuis R. Rodriguez  * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
165a19ac337SLuis R. Rodriguez  *	not 0.
166a19ac337SLuis R. Rodriguez  * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
167a19ac337SLuis R. Rodriguez  *	file position 0 and the value must be fully contained in the buffer
168a19ac337SLuis R. Rodriguez  *	sent to the write syscall. If dealing with strings respect the file
169a19ac337SLuis R. Rodriguez  *	position, but restrict this to the max length of the buffer, anything
17065f50f25SWeitao Hou  *	passed the max length will be ignored. Multiple writes will append
171a19ac337SLuis R. Rodriguez  *	to the buffer.
172a19ac337SLuis R. Rodriguez  *
173a19ac337SLuis R. Rodriguez  * These write modes control how current file position affects the behavior of
174a19ac337SLuis R. Rodriguez  * updating sysctl values through the proc interface on each write.
175a19ac337SLuis R. Rodriguez  */
176a19ac337SLuis R. Rodriguez enum sysctl_writes_mode {
177a19ac337SLuis R. Rodriguez 	SYSCTL_WRITES_LEGACY		= -1,
178a19ac337SLuis R. Rodriguez 	SYSCTL_WRITES_WARN		= 0,
179a19ac337SLuis R. Rodriguez 	SYSCTL_WRITES_STRICT		= 1,
180a19ac337SLuis R. Rodriguez };
181f4aacea2SKees Cook 
182a19ac337SLuis R. Rodriguez static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
183f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */
184ceb18132SLuis R. Rodriguez 
18567f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
18667f3977fSAlexandre Ghiti     defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
1871da177e4SLinus Torvalds int sysctl_legacy_va_layout;
1881da177e4SLinus Torvalds #endif
1891da177e4SLinus Torvalds 
1905e771905SMel Gorman #ifdef CONFIG_COMPACTION
1915e771905SMel Gorman static int min_extfrag_threshold;
1925e771905SMel Gorman static int max_extfrag_threshold = 1000;
1935e771905SMel Gorman #endif
1945e771905SMel Gorman 
195f461d2dcSChristoph Hellwig #endif /* CONFIG_SYSCTL */
196f461d2dcSChristoph Hellwig 
1975447e8e0SArnd Bergmann #if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
198d46edd67SSong Liu static int bpf_stats_handler(struct ctl_table *table, int write,
1997787b6fcSTobias Klauser 			     void *buffer, size_t *lenp, loff_t *ppos)
200d46edd67SSong Liu {
201d46edd67SSong Liu 	struct static_key *key = (struct static_key *)table->data;
202d46edd67SSong Liu 	static int saved_val;
203d46edd67SSong Liu 	int val, ret;
204d46edd67SSong Liu 	struct ctl_table tmp = {
205d46edd67SSong Liu 		.data   = &val,
206d46edd67SSong Liu 		.maxlen = sizeof(val),
207d46edd67SSong Liu 		.mode   = table->mode,
208d46edd67SSong Liu 		.extra1 = SYSCTL_ZERO,
209d46edd67SSong Liu 		.extra2 = SYSCTL_ONE,
210d46edd67SSong Liu 	};
211d46edd67SSong Liu 
212d46edd67SSong Liu 	if (write && !capable(CAP_SYS_ADMIN))
213d46edd67SSong Liu 		return -EPERM;
214d46edd67SSong Liu 
215d46edd67SSong Liu 	mutex_lock(&bpf_stats_enabled_mutex);
216d46edd67SSong Liu 	val = saved_val;
217d46edd67SSong Liu 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
218d46edd67SSong Liu 	if (write && !ret && val != saved_val) {
219d46edd67SSong Liu 		if (val)
220d46edd67SSong Liu 			static_key_slow_inc(key);
221d46edd67SSong Liu 		else
222d46edd67SSong Liu 			static_key_slow_dec(key);
223d46edd67SSong Liu 		saved_val = val;
224d46edd67SSong Liu 	}
225d46edd67SSong Liu 	mutex_unlock(&bpf_stats_enabled_mutex);
226d46edd67SSong Liu 	return ret;
227d46edd67SSong Liu }
22808389d88SDaniel Borkmann 
22908389d88SDaniel Borkmann static int bpf_unpriv_handler(struct ctl_table *table, int write,
23008389d88SDaniel Borkmann 			      void *buffer, size_t *lenp, loff_t *ppos)
23108389d88SDaniel Borkmann {
23208389d88SDaniel Borkmann 	int ret, unpriv_enable = *(int *)table->data;
23308389d88SDaniel Borkmann 	bool locked_state = unpriv_enable == 1;
23408389d88SDaniel Borkmann 	struct ctl_table tmp = *table;
23508389d88SDaniel Borkmann 
23608389d88SDaniel Borkmann 	if (write && !capable(CAP_SYS_ADMIN))
23708389d88SDaniel Borkmann 		return -EPERM;
23808389d88SDaniel Borkmann 
23908389d88SDaniel Borkmann 	tmp.data = &unpriv_enable;
24008389d88SDaniel Borkmann 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
24108389d88SDaniel Borkmann 	if (write && !ret) {
24208389d88SDaniel Borkmann 		if (locked_state && unpriv_enable != 1)
24308389d88SDaniel Borkmann 			return -EPERM;
24408389d88SDaniel Borkmann 		*(int *)table->data = unpriv_enable;
24508389d88SDaniel Borkmann 	}
24608389d88SDaniel Borkmann 	return ret;
24708389d88SDaniel Borkmann }
24808389d88SDaniel Borkmann #endif /* CONFIG_BPF_SYSCALL && CONFIG_SYSCTL */
249d46edd67SSong Liu 
250f461d2dcSChristoph Hellwig /*
251f461d2dcSChristoph Hellwig  * /proc/sys support
252f461d2dcSChristoph Hellwig  */
253f461d2dcSChristoph Hellwig 
254f461d2dcSChristoph Hellwig #ifdef CONFIG_PROC_SYSCTL
255f461d2dcSChristoph Hellwig 
256f461d2dcSChristoph Hellwig static int _proc_do_string(char *data, int maxlen, int write,
25732927393SChristoph Hellwig 		char *buffer, size_t *lenp, loff_t *ppos)
258f461d2dcSChristoph Hellwig {
259f461d2dcSChristoph Hellwig 	size_t len;
26032927393SChristoph Hellwig 	char c, *p;
261f461d2dcSChristoph Hellwig 
262f461d2dcSChristoph Hellwig 	if (!data || !maxlen || !*lenp) {
263f461d2dcSChristoph Hellwig 		*lenp = 0;
264f461d2dcSChristoph Hellwig 		return 0;
265f461d2dcSChristoph Hellwig 	}
266f461d2dcSChristoph Hellwig 
267f461d2dcSChristoph Hellwig 	if (write) {
268f461d2dcSChristoph Hellwig 		if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
269f461d2dcSChristoph Hellwig 			/* Only continue writes not past the end of buffer. */
270f461d2dcSChristoph Hellwig 			len = strlen(data);
271f461d2dcSChristoph Hellwig 			if (len > maxlen - 1)
272f461d2dcSChristoph Hellwig 				len = maxlen - 1;
273f461d2dcSChristoph Hellwig 
274f461d2dcSChristoph Hellwig 			if (*ppos > len)
275f461d2dcSChristoph Hellwig 				return 0;
276f461d2dcSChristoph Hellwig 			len = *ppos;
277f461d2dcSChristoph Hellwig 		} else {
278f461d2dcSChristoph Hellwig 			/* Start writing from beginning of buffer. */
279f461d2dcSChristoph Hellwig 			len = 0;
280f461d2dcSChristoph Hellwig 		}
281f461d2dcSChristoph Hellwig 
282f461d2dcSChristoph Hellwig 		*ppos += *lenp;
283f461d2dcSChristoph Hellwig 		p = buffer;
284f461d2dcSChristoph Hellwig 		while ((p - buffer) < *lenp && len < maxlen - 1) {
28532927393SChristoph Hellwig 			c = *(p++);
286f461d2dcSChristoph Hellwig 			if (c == 0 || c == '\n')
287f461d2dcSChristoph Hellwig 				break;
288f461d2dcSChristoph Hellwig 			data[len++] = c;
289f461d2dcSChristoph Hellwig 		}
290f461d2dcSChristoph Hellwig 		data[len] = 0;
291f461d2dcSChristoph Hellwig 	} else {
292f461d2dcSChristoph Hellwig 		len = strlen(data);
293f461d2dcSChristoph Hellwig 		if (len > maxlen)
294f461d2dcSChristoph Hellwig 			len = maxlen;
295f461d2dcSChristoph Hellwig 
296f461d2dcSChristoph Hellwig 		if (*ppos > len) {
297f461d2dcSChristoph Hellwig 			*lenp = 0;
298f461d2dcSChristoph Hellwig 			return 0;
299f461d2dcSChristoph Hellwig 		}
300f461d2dcSChristoph Hellwig 
301f461d2dcSChristoph Hellwig 		data += *ppos;
302f461d2dcSChristoph Hellwig 		len  -= *ppos;
303f461d2dcSChristoph Hellwig 
304f461d2dcSChristoph Hellwig 		if (len > *lenp)
305f461d2dcSChristoph Hellwig 			len = *lenp;
306f461d2dcSChristoph Hellwig 		if (len)
30732927393SChristoph Hellwig 			memcpy(buffer, data, len);
308f461d2dcSChristoph Hellwig 		if (len < *lenp) {
30932927393SChristoph Hellwig 			buffer[len] = '\n';
310f461d2dcSChristoph Hellwig 			len++;
311f461d2dcSChristoph Hellwig 		}
312f461d2dcSChristoph Hellwig 		*lenp = len;
313f461d2dcSChristoph Hellwig 		*ppos += len;
314f461d2dcSChristoph Hellwig 	}
315f461d2dcSChristoph Hellwig 	return 0;
316f461d2dcSChristoph Hellwig }
317f461d2dcSChristoph Hellwig 
318f461d2dcSChristoph Hellwig static void warn_sysctl_write(struct ctl_table *table)
319f461d2dcSChristoph Hellwig {
320f461d2dcSChristoph Hellwig 	pr_warn_once("%s wrote to %s when file position was not 0!\n"
321f461d2dcSChristoph Hellwig 		"This will not be supported in the future. To silence this\n"
322f461d2dcSChristoph Hellwig 		"warning, set kernel.sysctl_writes_strict = -1\n",
323f461d2dcSChristoph Hellwig 		current->comm, table->procname);
324f461d2dcSChristoph Hellwig }
325f461d2dcSChristoph Hellwig 
326f461d2dcSChristoph Hellwig /**
327f461d2dcSChristoph Hellwig  * proc_first_pos_non_zero_ignore - check if first position is allowed
328f461d2dcSChristoph Hellwig  * @ppos: file position
329f461d2dcSChristoph Hellwig  * @table: the sysctl table
330f461d2dcSChristoph Hellwig  *
331f461d2dcSChristoph Hellwig  * Returns true if the first position is non-zero and the sysctl_writes_strict
332f461d2dcSChristoph Hellwig  * mode indicates this is not allowed for numeric input types. String proc
333f461d2dcSChristoph Hellwig  * handlers can ignore the return value.
334f461d2dcSChristoph Hellwig  */
335f461d2dcSChristoph Hellwig static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
336f461d2dcSChristoph Hellwig 					   struct ctl_table *table)
337f461d2dcSChristoph Hellwig {
338f461d2dcSChristoph Hellwig 	if (!*ppos)
339f461d2dcSChristoph Hellwig 		return false;
340f461d2dcSChristoph Hellwig 
341f461d2dcSChristoph Hellwig 	switch (sysctl_writes_strict) {
342f461d2dcSChristoph Hellwig 	case SYSCTL_WRITES_STRICT:
343f461d2dcSChristoph Hellwig 		return true;
344f461d2dcSChristoph Hellwig 	case SYSCTL_WRITES_WARN:
345f461d2dcSChristoph Hellwig 		warn_sysctl_write(table);
346f461d2dcSChristoph Hellwig 		return false;
347f461d2dcSChristoph Hellwig 	default:
348f461d2dcSChristoph Hellwig 		return false;
349f461d2dcSChristoph Hellwig 	}
350f461d2dcSChristoph Hellwig }
351f461d2dcSChristoph Hellwig 
352f461d2dcSChristoph Hellwig /**
353f461d2dcSChristoph Hellwig  * proc_dostring - read a string sysctl
354f461d2dcSChristoph Hellwig  * @table: the sysctl table
355f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
356f461d2dcSChristoph Hellwig  * @buffer: the user buffer
357f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
358f461d2dcSChristoph Hellwig  * @ppos: file position
359f461d2dcSChristoph Hellwig  *
360f461d2dcSChristoph Hellwig  * Reads/writes a string from/to the user buffer. If the kernel
361f461d2dcSChristoph Hellwig  * buffer provided is not large enough to hold the string, the
362f461d2dcSChristoph Hellwig  * string is truncated. The copied string is %NULL-terminated.
363f461d2dcSChristoph Hellwig  * If the string is being read by the user process, it is copied
364f461d2dcSChristoph Hellwig  * and a newline '\n' is added. It is truncated if the buffer is
365f461d2dcSChristoph Hellwig  * not large enough.
366f461d2dcSChristoph Hellwig  *
367f461d2dcSChristoph Hellwig  * Returns 0 on success.
368f461d2dcSChristoph Hellwig  */
369f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write,
37032927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
371f461d2dcSChristoph Hellwig {
372f461d2dcSChristoph Hellwig 	if (write)
373f461d2dcSChristoph Hellwig 		proc_first_pos_non_zero_ignore(ppos, table);
374f461d2dcSChristoph Hellwig 
37532927393SChristoph Hellwig 	return _proc_do_string(table->data, table->maxlen, write, buffer, lenp,
37632927393SChristoph Hellwig 			ppos);
377f461d2dcSChristoph Hellwig }
378f461d2dcSChristoph Hellwig 
379f461d2dcSChristoph Hellwig static size_t proc_skip_spaces(char **buf)
380f461d2dcSChristoph Hellwig {
381f461d2dcSChristoph Hellwig 	size_t ret;
382f461d2dcSChristoph Hellwig 	char *tmp = skip_spaces(*buf);
383f461d2dcSChristoph Hellwig 	ret = tmp - *buf;
384f461d2dcSChristoph Hellwig 	*buf = tmp;
385f461d2dcSChristoph Hellwig 	return ret;
386f461d2dcSChristoph Hellwig }
387f461d2dcSChristoph Hellwig 
388f461d2dcSChristoph Hellwig static void proc_skip_char(char **buf, size_t *size, const char v)
389f461d2dcSChristoph Hellwig {
390f461d2dcSChristoph Hellwig 	while (*size) {
391f461d2dcSChristoph Hellwig 		if (**buf != v)
392f461d2dcSChristoph Hellwig 			break;
393f461d2dcSChristoph Hellwig 		(*size)--;
394f461d2dcSChristoph Hellwig 		(*buf)++;
395f461d2dcSChristoph Hellwig 	}
396f461d2dcSChristoph Hellwig }
397f461d2dcSChristoph Hellwig 
398f461d2dcSChristoph Hellwig /**
399f461d2dcSChristoph Hellwig  * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
400f461d2dcSChristoph Hellwig  *                   fail on overflow
401f461d2dcSChristoph Hellwig  *
402f461d2dcSChristoph Hellwig  * @cp: kernel buffer containing the string to parse
403f461d2dcSChristoph Hellwig  * @endp: pointer to store the trailing characters
404f461d2dcSChristoph Hellwig  * @base: the base to use
405f461d2dcSChristoph Hellwig  * @res: where the parsed integer will be stored
406f461d2dcSChristoph Hellwig  *
407f461d2dcSChristoph Hellwig  * In case of success 0 is returned and @res will contain the parsed integer,
408f461d2dcSChristoph Hellwig  * @endp will hold any trailing characters.
409f461d2dcSChristoph Hellwig  * This function will fail the parse on overflow. If there wasn't an overflow
410f461d2dcSChristoph Hellwig  * the function will defer the decision what characters count as invalid to the
411f461d2dcSChristoph Hellwig  * caller.
412f461d2dcSChristoph Hellwig  */
413f461d2dcSChristoph Hellwig static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
414f461d2dcSChristoph Hellwig 			   unsigned long *res)
415f461d2dcSChristoph Hellwig {
416f461d2dcSChristoph Hellwig 	unsigned long long result;
417f461d2dcSChristoph Hellwig 	unsigned int rv;
418f461d2dcSChristoph Hellwig 
419f461d2dcSChristoph Hellwig 	cp = _parse_integer_fixup_radix(cp, &base);
420f461d2dcSChristoph Hellwig 	rv = _parse_integer(cp, base, &result);
421f461d2dcSChristoph Hellwig 	if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
422f461d2dcSChristoph Hellwig 		return -ERANGE;
423f461d2dcSChristoph Hellwig 
424f461d2dcSChristoph Hellwig 	cp += rv;
425f461d2dcSChristoph Hellwig 
426f461d2dcSChristoph Hellwig 	if (endp)
427f461d2dcSChristoph Hellwig 		*endp = (char *)cp;
428f461d2dcSChristoph Hellwig 
429f461d2dcSChristoph Hellwig 	*res = (unsigned long)result;
430f461d2dcSChristoph Hellwig 	return 0;
431f461d2dcSChristoph Hellwig }
432f461d2dcSChristoph Hellwig 
433f461d2dcSChristoph Hellwig #define TMPBUFLEN 22
434f461d2dcSChristoph Hellwig /**
435f461d2dcSChristoph Hellwig  * proc_get_long - reads an ASCII formatted integer from a user buffer
436f461d2dcSChristoph Hellwig  *
437f461d2dcSChristoph Hellwig  * @buf: a kernel buffer
438f461d2dcSChristoph Hellwig  * @size: size of the kernel buffer
439f461d2dcSChristoph Hellwig  * @val: this is where the number will be stored
440f461d2dcSChristoph Hellwig  * @neg: set to %TRUE if number is negative
441f461d2dcSChristoph Hellwig  * @perm_tr: a vector which contains the allowed trailers
442f461d2dcSChristoph Hellwig  * @perm_tr_len: size of the perm_tr vector
443f461d2dcSChristoph Hellwig  * @tr: pointer to store the trailer character
444f461d2dcSChristoph Hellwig  *
445f461d2dcSChristoph Hellwig  * In case of success %0 is returned and @buf and @size are updated with
446f461d2dcSChristoph Hellwig  * the amount of bytes read. If @tr is non-NULL and a trailing
447f461d2dcSChristoph Hellwig  * character exists (size is non-zero after returning from this
448f461d2dcSChristoph Hellwig  * function), @tr is updated with the trailing character.
449f461d2dcSChristoph Hellwig  */
450f461d2dcSChristoph Hellwig static int proc_get_long(char **buf, size_t *size,
451f461d2dcSChristoph Hellwig 			  unsigned long *val, bool *neg,
452f461d2dcSChristoph Hellwig 			  const char *perm_tr, unsigned perm_tr_len, char *tr)
453f461d2dcSChristoph Hellwig {
454f461d2dcSChristoph Hellwig 	int len;
455f461d2dcSChristoph Hellwig 	char *p, tmp[TMPBUFLEN];
456f461d2dcSChristoph Hellwig 
457f461d2dcSChristoph Hellwig 	if (!*size)
458f461d2dcSChristoph Hellwig 		return -EINVAL;
459f461d2dcSChristoph Hellwig 
460f461d2dcSChristoph Hellwig 	len = *size;
461f461d2dcSChristoph Hellwig 	if (len > TMPBUFLEN - 1)
462f461d2dcSChristoph Hellwig 		len = TMPBUFLEN - 1;
463f461d2dcSChristoph Hellwig 
464f461d2dcSChristoph Hellwig 	memcpy(tmp, *buf, len);
465f461d2dcSChristoph Hellwig 
466f461d2dcSChristoph Hellwig 	tmp[len] = 0;
467f461d2dcSChristoph Hellwig 	p = tmp;
468f461d2dcSChristoph Hellwig 	if (*p == '-' && *size > 1) {
469f461d2dcSChristoph Hellwig 		*neg = true;
470f461d2dcSChristoph Hellwig 		p++;
471f461d2dcSChristoph Hellwig 	} else
472f461d2dcSChristoph Hellwig 		*neg = false;
473f461d2dcSChristoph Hellwig 	if (!isdigit(*p))
474f461d2dcSChristoph Hellwig 		return -EINVAL;
475f461d2dcSChristoph Hellwig 
476f461d2dcSChristoph Hellwig 	if (strtoul_lenient(p, &p, 0, val))
477f461d2dcSChristoph Hellwig 		return -EINVAL;
478f461d2dcSChristoph Hellwig 
479f461d2dcSChristoph Hellwig 	len = p - tmp;
480f461d2dcSChristoph Hellwig 
481f461d2dcSChristoph Hellwig 	/* We don't know if the next char is whitespace thus we may accept
482f461d2dcSChristoph Hellwig 	 * invalid integers (e.g. 1234...a) or two integers instead of one
483f461d2dcSChristoph Hellwig 	 * (e.g. 123...1). So lets not allow such large numbers. */
484f461d2dcSChristoph Hellwig 	if (len == TMPBUFLEN - 1)
485f461d2dcSChristoph Hellwig 		return -EINVAL;
486f461d2dcSChristoph Hellwig 
487f461d2dcSChristoph Hellwig 	if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
488f461d2dcSChristoph Hellwig 		return -EINVAL;
489f461d2dcSChristoph Hellwig 
490f461d2dcSChristoph Hellwig 	if (tr && (len < *size))
491f461d2dcSChristoph Hellwig 		*tr = *p;
492f461d2dcSChristoph Hellwig 
493f461d2dcSChristoph Hellwig 	*buf += len;
494f461d2dcSChristoph Hellwig 	*size -= len;
495f461d2dcSChristoph Hellwig 
496f461d2dcSChristoph Hellwig 	return 0;
497f461d2dcSChristoph Hellwig }
498f461d2dcSChristoph Hellwig 
499f461d2dcSChristoph Hellwig /**
500f461d2dcSChristoph Hellwig  * proc_put_long - converts an integer to a decimal ASCII formatted string
501f461d2dcSChristoph Hellwig  *
502f461d2dcSChristoph Hellwig  * @buf: the user buffer
503f461d2dcSChristoph Hellwig  * @size: the size of the user buffer
504f461d2dcSChristoph Hellwig  * @val: the integer to be converted
505f461d2dcSChristoph Hellwig  * @neg: sign of the number, %TRUE for negative
506f461d2dcSChristoph Hellwig  *
50732927393SChristoph Hellwig  * In case of success @buf and @size are updated with the amount of bytes
50832927393SChristoph Hellwig  * written.
509f461d2dcSChristoph Hellwig  */
51032927393SChristoph Hellwig static void proc_put_long(void **buf, size_t *size, unsigned long val, bool neg)
511f461d2dcSChristoph Hellwig {
512f461d2dcSChristoph Hellwig 	int len;
513f461d2dcSChristoph Hellwig 	char tmp[TMPBUFLEN], *p = tmp;
514f461d2dcSChristoph Hellwig 
515f461d2dcSChristoph Hellwig 	sprintf(p, "%s%lu", neg ? "-" : "", val);
516f461d2dcSChristoph Hellwig 	len = strlen(tmp);
517f461d2dcSChristoph Hellwig 	if (len > *size)
518f461d2dcSChristoph Hellwig 		len = *size;
51932927393SChristoph Hellwig 	memcpy(*buf, tmp, len);
520f461d2dcSChristoph Hellwig 	*size -= len;
521f461d2dcSChristoph Hellwig 	*buf += len;
522f461d2dcSChristoph Hellwig }
523f461d2dcSChristoph Hellwig #undef TMPBUFLEN
524f461d2dcSChristoph Hellwig 
52532927393SChristoph Hellwig static void proc_put_char(void **buf, size_t *size, char c)
526f461d2dcSChristoph Hellwig {
527f461d2dcSChristoph Hellwig 	if (*size) {
52832927393SChristoph Hellwig 		char **buffer = (char **)buf;
52932927393SChristoph Hellwig 		**buffer = c;
53032927393SChristoph Hellwig 
53132927393SChristoph Hellwig 		(*size)--;
53232927393SChristoph Hellwig 		(*buffer)++;
533f461d2dcSChristoph Hellwig 		*buf = *buffer;
534f461d2dcSChristoph Hellwig 	}
535f461d2dcSChristoph Hellwig }
536f461d2dcSChristoph Hellwig 
537f461d2dcSChristoph Hellwig static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
538f461d2dcSChristoph Hellwig 				 int *valp,
539f461d2dcSChristoph Hellwig 				 int write, void *data)
540f461d2dcSChristoph Hellwig {
541f461d2dcSChristoph Hellwig 	if (write) {
542f461d2dcSChristoph Hellwig 		if (*negp) {
543f461d2dcSChristoph Hellwig 			if (*lvalp > (unsigned long) INT_MAX + 1)
544f461d2dcSChristoph Hellwig 				return -EINVAL;
545f461d2dcSChristoph Hellwig 			*valp = -*lvalp;
546f461d2dcSChristoph Hellwig 		} else {
547f461d2dcSChristoph Hellwig 			if (*lvalp > (unsigned long) INT_MAX)
548f461d2dcSChristoph Hellwig 				return -EINVAL;
549f461d2dcSChristoph Hellwig 			*valp = *lvalp;
550f461d2dcSChristoph Hellwig 		}
551f461d2dcSChristoph Hellwig 	} else {
552f461d2dcSChristoph Hellwig 		int val = *valp;
553f461d2dcSChristoph Hellwig 		if (val < 0) {
554f461d2dcSChristoph Hellwig 			*negp = true;
555f461d2dcSChristoph Hellwig 			*lvalp = -(unsigned long)val;
556f461d2dcSChristoph Hellwig 		} else {
557f461d2dcSChristoph Hellwig 			*negp = false;
558f461d2dcSChristoph Hellwig 			*lvalp = (unsigned long)val;
559f461d2dcSChristoph Hellwig 		}
560f461d2dcSChristoph Hellwig 	}
561f461d2dcSChristoph Hellwig 	return 0;
562f461d2dcSChristoph Hellwig }
563f461d2dcSChristoph Hellwig 
564f461d2dcSChristoph Hellwig static int do_proc_douintvec_conv(unsigned long *lvalp,
565f461d2dcSChristoph Hellwig 				  unsigned int *valp,
566f461d2dcSChristoph Hellwig 				  int write, void *data)
567f461d2dcSChristoph Hellwig {
568f461d2dcSChristoph Hellwig 	if (write) {
569f461d2dcSChristoph Hellwig 		if (*lvalp > UINT_MAX)
570f461d2dcSChristoph Hellwig 			return -EINVAL;
571f461d2dcSChristoph Hellwig 		*valp = *lvalp;
572f461d2dcSChristoph Hellwig 	} else {
573f461d2dcSChristoph Hellwig 		unsigned int val = *valp;
574f461d2dcSChristoph Hellwig 		*lvalp = (unsigned long)val;
575f461d2dcSChristoph Hellwig 	}
576f461d2dcSChristoph Hellwig 	return 0;
577f461d2dcSChristoph Hellwig }
578f461d2dcSChristoph Hellwig 
579f461d2dcSChristoph Hellwig static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
580f461d2dcSChristoph Hellwig 
581f461d2dcSChristoph Hellwig static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
58232927393SChristoph Hellwig 		  int write, void *buffer,
583f461d2dcSChristoph Hellwig 		  size_t *lenp, loff_t *ppos,
584f461d2dcSChristoph Hellwig 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
585f461d2dcSChristoph Hellwig 			      int write, void *data),
586f461d2dcSChristoph Hellwig 		  void *data)
587f461d2dcSChristoph Hellwig {
588f461d2dcSChristoph Hellwig 	int *i, vleft, first = 1, err = 0;
589f461d2dcSChristoph Hellwig 	size_t left;
59032927393SChristoph Hellwig 	char *p;
591f461d2dcSChristoph Hellwig 
592f461d2dcSChristoph Hellwig 	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
593f461d2dcSChristoph Hellwig 		*lenp = 0;
594f461d2dcSChristoph Hellwig 		return 0;
595f461d2dcSChristoph Hellwig 	}
596f461d2dcSChristoph Hellwig 
597f461d2dcSChristoph Hellwig 	i = (int *) tbl_data;
598f461d2dcSChristoph Hellwig 	vleft = table->maxlen / sizeof(*i);
599f461d2dcSChristoph Hellwig 	left = *lenp;
600f461d2dcSChristoph Hellwig 
601f461d2dcSChristoph Hellwig 	if (!conv)
602f461d2dcSChristoph Hellwig 		conv = do_proc_dointvec_conv;
603f461d2dcSChristoph Hellwig 
604f461d2dcSChristoph Hellwig 	if (write) {
605f461d2dcSChristoph Hellwig 		if (proc_first_pos_non_zero_ignore(ppos, table))
606f461d2dcSChristoph Hellwig 			goto out;
607f461d2dcSChristoph Hellwig 
608f461d2dcSChristoph Hellwig 		if (left > PAGE_SIZE - 1)
609f461d2dcSChristoph Hellwig 			left = PAGE_SIZE - 1;
61032927393SChristoph Hellwig 		p = buffer;
611f461d2dcSChristoph Hellwig 	}
612f461d2dcSChristoph Hellwig 
613f461d2dcSChristoph Hellwig 	for (; left && vleft--; i++, first=0) {
614f461d2dcSChristoph Hellwig 		unsigned long lval;
615f461d2dcSChristoph Hellwig 		bool neg;
616f461d2dcSChristoph Hellwig 
617f461d2dcSChristoph Hellwig 		if (write) {
618f461d2dcSChristoph Hellwig 			left -= proc_skip_spaces(&p);
619f461d2dcSChristoph Hellwig 
620f461d2dcSChristoph Hellwig 			if (!left)
621f461d2dcSChristoph Hellwig 				break;
622f461d2dcSChristoph Hellwig 			err = proc_get_long(&p, &left, &lval, &neg,
623f461d2dcSChristoph Hellwig 					     proc_wspace_sep,
624f461d2dcSChristoph Hellwig 					     sizeof(proc_wspace_sep), NULL);
625f461d2dcSChristoph Hellwig 			if (err)
626f461d2dcSChristoph Hellwig 				break;
627f461d2dcSChristoph Hellwig 			if (conv(&neg, &lval, i, 1, data)) {
628f461d2dcSChristoph Hellwig 				err = -EINVAL;
629f461d2dcSChristoph Hellwig 				break;
630f461d2dcSChristoph Hellwig 			}
631f461d2dcSChristoph Hellwig 		} else {
632f461d2dcSChristoph Hellwig 			if (conv(&neg, &lval, i, 0, data)) {
633f461d2dcSChristoph Hellwig 				err = -EINVAL;
634f461d2dcSChristoph Hellwig 				break;
635f461d2dcSChristoph Hellwig 			}
636f461d2dcSChristoph Hellwig 			if (!first)
63732927393SChristoph Hellwig 				proc_put_char(&buffer, &left, '\t');
63832927393SChristoph Hellwig 			proc_put_long(&buffer, &left, lval, neg);
639f461d2dcSChristoph Hellwig 		}
640f461d2dcSChristoph Hellwig 	}
641f461d2dcSChristoph Hellwig 
642f461d2dcSChristoph Hellwig 	if (!write && !first && left && !err)
64332927393SChristoph Hellwig 		proc_put_char(&buffer, &left, '\n');
644f461d2dcSChristoph Hellwig 	if (write && !err && left)
645f461d2dcSChristoph Hellwig 		left -= proc_skip_spaces(&p);
64632927393SChristoph Hellwig 	if (write && first)
647f461d2dcSChristoph Hellwig 		return err ? : -EINVAL;
648f461d2dcSChristoph Hellwig 	*lenp -= left;
649f461d2dcSChristoph Hellwig out:
650f461d2dcSChristoph Hellwig 	*ppos += *lenp;
651f461d2dcSChristoph Hellwig 	return err;
652f461d2dcSChristoph Hellwig }
653f461d2dcSChristoph Hellwig 
654f461d2dcSChristoph Hellwig static int do_proc_dointvec(struct ctl_table *table, int write,
65532927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos,
656f461d2dcSChristoph Hellwig 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
657f461d2dcSChristoph Hellwig 			      int write, void *data),
658f461d2dcSChristoph Hellwig 		  void *data)
659f461d2dcSChristoph Hellwig {
660f461d2dcSChristoph Hellwig 	return __do_proc_dointvec(table->data, table, write,
661f461d2dcSChristoph Hellwig 			buffer, lenp, ppos, conv, data);
662f461d2dcSChristoph Hellwig }
663f461d2dcSChristoph Hellwig 
664f461d2dcSChristoph Hellwig static int do_proc_douintvec_w(unsigned int *tbl_data,
665f461d2dcSChristoph Hellwig 			       struct ctl_table *table,
66632927393SChristoph Hellwig 			       void *buffer,
667f461d2dcSChristoph Hellwig 			       size_t *lenp, loff_t *ppos,
668f461d2dcSChristoph Hellwig 			       int (*conv)(unsigned long *lvalp,
669f461d2dcSChristoph Hellwig 					   unsigned int *valp,
670f461d2dcSChristoph Hellwig 					   int write, void *data),
671f461d2dcSChristoph Hellwig 			       void *data)
672f461d2dcSChristoph Hellwig {
673f461d2dcSChristoph Hellwig 	unsigned long lval;
674f461d2dcSChristoph Hellwig 	int err = 0;
675f461d2dcSChristoph Hellwig 	size_t left;
676f461d2dcSChristoph Hellwig 	bool neg;
67732927393SChristoph Hellwig 	char *p = buffer;
678f461d2dcSChristoph Hellwig 
679f461d2dcSChristoph Hellwig 	left = *lenp;
680f461d2dcSChristoph Hellwig 
681f461d2dcSChristoph Hellwig 	if (proc_first_pos_non_zero_ignore(ppos, table))
682f461d2dcSChristoph Hellwig 		goto bail_early;
683f461d2dcSChristoph Hellwig 
684f461d2dcSChristoph Hellwig 	if (left > PAGE_SIZE - 1)
685f461d2dcSChristoph Hellwig 		left = PAGE_SIZE - 1;
686f461d2dcSChristoph Hellwig 
687f461d2dcSChristoph Hellwig 	left -= proc_skip_spaces(&p);
688f461d2dcSChristoph Hellwig 	if (!left) {
689f461d2dcSChristoph Hellwig 		err = -EINVAL;
690f461d2dcSChristoph Hellwig 		goto out_free;
691f461d2dcSChristoph Hellwig 	}
692f461d2dcSChristoph Hellwig 
693f461d2dcSChristoph Hellwig 	err = proc_get_long(&p, &left, &lval, &neg,
694f461d2dcSChristoph Hellwig 			     proc_wspace_sep,
695f461d2dcSChristoph Hellwig 			     sizeof(proc_wspace_sep), NULL);
696f461d2dcSChristoph Hellwig 	if (err || neg) {
697f461d2dcSChristoph Hellwig 		err = -EINVAL;
698f461d2dcSChristoph Hellwig 		goto out_free;
699f461d2dcSChristoph Hellwig 	}
700f461d2dcSChristoph Hellwig 
701f461d2dcSChristoph Hellwig 	if (conv(&lval, tbl_data, 1, data)) {
702f461d2dcSChristoph Hellwig 		err = -EINVAL;
703f461d2dcSChristoph Hellwig 		goto out_free;
704f461d2dcSChristoph Hellwig 	}
705f461d2dcSChristoph Hellwig 
706f461d2dcSChristoph Hellwig 	if (!err && left)
707f461d2dcSChristoph Hellwig 		left -= proc_skip_spaces(&p);
708f461d2dcSChristoph Hellwig 
709f461d2dcSChristoph Hellwig out_free:
710f461d2dcSChristoph Hellwig 	if (err)
711f461d2dcSChristoph Hellwig 		return -EINVAL;
712f461d2dcSChristoph Hellwig 
713f461d2dcSChristoph Hellwig 	return 0;
714f461d2dcSChristoph Hellwig 
715f461d2dcSChristoph Hellwig 	/* This is in keeping with old __do_proc_dointvec() */
716f461d2dcSChristoph Hellwig bail_early:
717f461d2dcSChristoph Hellwig 	*ppos += *lenp;
718f461d2dcSChristoph Hellwig 	return err;
719f461d2dcSChristoph Hellwig }
720f461d2dcSChristoph Hellwig 
72132927393SChristoph Hellwig static int do_proc_douintvec_r(unsigned int *tbl_data, void *buffer,
722f461d2dcSChristoph Hellwig 			       size_t *lenp, loff_t *ppos,
723f461d2dcSChristoph Hellwig 			       int (*conv)(unsigned long *lvalp,
724f461d2dcSChristoph Hellwig 					   unsigned int *valp,
725f461d2dcSChristoph Hellwig 					   int write, void *data),
726f461d2dcSChristoph Hellwig 			       void *data)
727f461d2dcSChristoph Hellwig {
728f461d2dcSChristoph Hellwig 	unsigned long lval;
729f461d2dcSChristoph Hellwig 	int err = 0;
730f461d2dcSChristoph Hellwig 	size_t left;
731f461d2dcSChristoph Hellwig 
732f461d2dcSChristoph Hellwig 	left = *lenp;
733f461d2dcSChristoph Hellwig 
734f461d2dcSChristoph Hellwig 	if (conv(&lval, tbl_data, 0, data)) {
735f461d2dcSChristoph Hellwig 		err = -EINVAL;
736f461d2dcSChristoph Hellwig 		goto out;
737f461d2dcSChristoph Hellwig 	}
738f461d2dcSChristoph Hellwig 
73932927393SChristoph Hellwig 	proc_put_long(&buffer, &left, lval, false);
74032927393SChristoph Hellwig 	if (!left)
741f461d2dcSChristoph Hellwig 		goto out;
742f461d2dcSChristoph Hellwig 
74332927393SChristoph Hellwig 	proc_put_char(&buffer, &left, '\n');
744f461d2dcSChristoph Hellwig 
745f461d2dcSChristoph Hellwig out:
746f461d2dcSChristoph Hellwig 	*lenp -= left;
747f461d2dcSChristoph Hellwig 	*ppos += *lenp;
748f461d2dcSChristoph Hellwig 
749f461d2dcSChristoph Hellwig 	return err;
750f461d2dcSChristoph Hellwig }
751f461d2dcSChristoph Hellwig 
752f461d2dcSChristoph Hellwig static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
75332927393SChristoph Hellwig 			       int write, void *buffer,
754f461d2dcSChristoph Hellwig 			       size_t *lenp, loff_t *ppos,
755f461d2dcSChristoph Hellwig 			       int (*conv)(unsigned long *lvalp,
756f461d2dcSChristoph Hellwig 					   unsigned int *valp,
757f461d2dcSChristoph Hellwig 					   int write, void *data),
758f461d2dcSChristoph Hellwig 			       void *data)
759f461d2dcSChristoph Hellwig {
760f461d2dcSChristoph Hellwig 	unsigned int *i, vleft;
761f461d2dcSChristoph Hellwig 
762f461d2dcSChristoph Hellwig 	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
763f461d2dcSChristoph Hellwig 		*lenp = 0;
764f461d2dcSChristoph Hellwig 		return 0;
765f461d2dcSChristoph Hellwig 	}
766f461d2dcSChristoph Hellwig 
767f461d2dcSChristoph Hellwig 	i = (unsigned int *) tbl_data;
768f461d2dcSChristoph Hellwig 	vleft = table->maxlen / sizeof(*i);
769f461d2dcSChristoph Hellwig 
770f461d2dcSChristoph Hellwig 	/*
771f461d2dcSChristoph Hellwig 	 * Arrays are not supported, keep this simple. *Do not* add
772f461d2dcSChristoph Hellwig 	 * support for them.
773f461d2dcSChristoph Hellwig 	 */
774f461d2dcSChristoph Hellwig 	if (vleft != 1) {
775f461d2dcSChristoph Hellwig 		*lenp = 0;
776f461d2dcSChristoph Hellwig 		return -EINVAL;
777f461d2dcSChristoph Hellwig 	}
778f461d2dcSChristoph Hellwig 
779f461d2dcSChristoph Hellwig 	if (!conv)
780f461d2dcSChristoph Hellwig 		conv = do_proc_douintvec_conv;
781f461d2dcSChristoph Hellwig 
782f461d2dcSChristoph Hellwig 	if (write)
783f461d2dcSChristoph Hellwig 		return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
784f461d2dcSChristoph Hellwig 					   conv, data);
785f461d2dcSChristoph Hellwig 	return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
786f461d2dcSChristoph Hellwig }
787f461d2dcSChristoph Hellwig 
788f461d2dcSChristoph Hellwig static int do_proc_douintvec(struct ctl_table *table, int write,
78932927393SChristoph Hellwig 			     void *buffer, size_t *lenp, loff_t *ppos,
790f461d2dcSChristoph Hellwig 			     int (*conv)(unsigned long *lvalp,
791f461d2dcSChristoph Hellwig 					 unsigned int *valp,
792f461d2dcSChristoph Hellwig 					 int write, void *data),
793f461d2dcSChristoph Hellwig 			     void *data)
794f461d2dcSChristoph Hellwig {
795f461d2dcSChristoph Hellwig 	return __do_proc_douintvec(table->data, table, write,
796f461d2dcSChristoph Hellwig 				   buffer, lenp, ppos, conv, data);
797f461d2dcSChristoph Hellwig }
798f461d2dcSChristoph Hellwig 
799f461d2dcSChristoph Hellwig /**
800f461d2dcSChristoph Hellwig  * proc_dointvec - read a vector of integers
801f461d2dcSChristoph Hellwig  * @table: the sysctl table
802f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
803f461d2dcSChristoph Hellwig  * @buffer: the user buffer
804f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
805f461d2dcSChristoph Hellwig  * @ppos: file position
806f461d2dcSChristoph Hellwig  *
807f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
808f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
809f461d2dcSChristoph Hellwig  *
810f461d2dcSChristoph Hellwig  * Returns 0 on success.
811f461d2dcSChristoph Hellwig  */
81232927393SChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write, void *buffer,
81332927393SChristoph Hellwig 		  size_t *lenp, loff_t *ppos)
814f461d2dcSChristoph Hellwig {
815f461d2dcSChristoph Hellwig 	return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
816f461d2dcSChristoph Hellwig }
817f461d2dcSChristoph Hellwig 
818f461d2dcSChristoph Hellwig #ifdef CONFIG_COMPACTION
819f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_warn_RT_change(struct ctl_table *table,
82032927393SChristoph Hellwig 		int write, void *buffer, size_t *lenp, loff_t *ppos)
821f461d2dcSChristoph Hellwig {
822f461d2dcSChristoph Hellwig 	int ret, old;
823f461d2dcSChristoph Hellwig 
824f461d2dcSChristoph Hellwig 	if (!IS_ENABLED(CONFIG_PREEMPT_RT) || !write)
825f461d2dcSChristoph Hellwig 		return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
826f461d2dcSChristoph Hellwig 
827f461d2dcSChristoph Hellwig 	old = *(int *)table->data;
828f461d2dcSChristoph Hellwig 	ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
829f461d2dcSChristoph Hellwig 	if (ret)
830f461d2dcSChristoph Hellwig 		return ret;
831f461d2dcSChristoph Hellwig 	if (old != *(int *)table->data)
832f461d2dcSChristoph Hellwig 		pr_warn_once("sysctl attribute %s changed by %s[%d]\n",
833f461d2dcSChristoph Hellwig 			     table->procname, current->comm,
834f461d2dcSChristoph Hellwig 			     task_pid_nr(current));
835f461d2dcSChristoph Hellwig 	return ret;
836f461d2dcSChristoph Hellwig }
837f461d2dcSChristoph Hellwig #endif
838f461d2dcSChristoph Hellwig 
839f461d2dcSChristoph Hellwig /**
840f461d2dcSChristoph Hellwig  * proc_douintvec - read a vector of unsigned integers
841f461d2dcSChristoph Hellwig  * @table: the sysctl table
842f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
843f461d2dcSChristoph Hellwig  * @buffer: the user buffer
844f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
845f461d2dcSChristoph Hellwig  * @ppos: file position
846f461d2dcSChristoph Hellwig  *
847f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
848f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
849f461d2dcSChristoph Hellwig  *
850f461d2dcSChristoph Hellwig  * Returns 0 on success.
851f461d2dcSChristoph Hellwig  */
85232927393SChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write, void *buffer,
85332927393SChristoph Hellwig 		size_t *lenp, loff_t *ppos)
854f461d2dcSChristoph Hellwig {
855f461d2dcSChristoph Hellwig 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
856f461d2dcSChristoph Hellwig 				 do_proc_douintvec_conv, NULL);
857f461d2dcSChristoph Hellwig }
858f461d2dcSChristoph Hellwig 
859f461d2dcSChristoph Hellwig /*
860f461d2dcSChristoph Hellwig  * Taint values can only be increased
861f461d2dcSChristoph Hellwig  * This means we can safely use a temporary.
862f461d2dcSChristoph Hellwig  */
863f461d2dcSChristoph Hellwig static int proc_taint(struct ctl_table *table, int write,
86432927393SChristoph Hellwig 			       void *buffer, size_t *lenp, loff_t *ppos)
865f461d2dcSChristoph Hellwig {
866f461d2dcSChristoph Hellwig 	struct ctl_table t;
867f461d2dcSChristoph Hellwig 	unsigned long tmptaint = get_taint();
868f461d2dcSChristoph Hellwig 	int err;
869f461d2dcSChristoph Hellwig 
870f461d2dcSChristoph Hellwig 	if (write && !capable(CAP_SYS_ADMIN))
871f461d2dcSChristoph Hellwig 		return -EPERM;
872f461d2dcSChristoph Hellwig 
873f461d2dcSChristoph Hellwig 	t = *table;
874f461d2dcSChristoph Hellwig 	t.data = &tmptaint;
875f461d2dcSChristoph Hellwig 	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
876f461d2dcSChristoph Hellwig 	if (err < 0)
877f461d2dcSChristoph Hellwig 		return err;
878f461d2dcSChristoph Hellwig 
879f461d2dcSChristoph Hellwig 	if (write) {
880db38d5c1SRafael Aquini 		int i;
881db38d5c1SRafael Aquini 
882db38d5c1SRafael Aquini 		/*
883db38d5c1SRafael Aquini 		 * If we are relying on panic_on_taint not producing
884db38d5c1SRafael Aquini 		 * false positives due to userspace input, bail out
885db38d5c1SRafael Aquini 		 * before setting the requested taint flags.
886db38d5c1SRafael Aquini 		 */
887db38d5c1SRafael Aquini 		if (panic_on_taint_nousertaint && (tmptaint & panic_on_taint))
888db38d5c1SRafael Aquini 			return -EINVAL;
889db38d5c1SRafael Aquini 
890f461d2dcSChristoph Hellwig 		/*
891f461d2dcSChristoph Hellwig 		 * Poor man's atomic or. Not worth adding a primitive
892f461d2dcSChristoph Hellwig 		 * to everyone's atomic.h for this
893f461d2dcSChristoph Hellwig 		 */
894e77132e7SRafael Aquini 		for (i = 0; i < TAINT_FLAGS_COUNT; i++)
895e77132e7SRafael Aquini 			if ((1UL << i) & tmptaint)
896f461d2dcSChristoph Hellwig 				add_taint(i, LOCKDEP_STILL_OK);
897f461d2dcSChristoph Hellwig 	}
898f461d2dcSChristoph Hellwig 
899f461d2dcSChristoph Hellwig 	return err;
900f461d2dcSChristoph Hellwig }
901f461d2dcSChristoph Hellwig 
902f461d2dcSChristoph Hellwig #ifdef CONFIG_PRINTK
903f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
90432927393SChristoph Hellwig 				void *buffer, size_t *lenp, loff_t *ppos)
905f461d2dcSChristoph Hellwig {
906f461d2dcSChristoph Hellwig 	if (write && !capable(CAP_SYS_ADMIN))
907f461d2dcSChristoph Hellwig 		return -EPERM;
908f461d2dcSChristoph Hellwig 
909f461d2dcSChristoph Hellwig 	return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
910f461d2dcSChristoph Hellwig }
911f461d2dcSChristoph Hellwig #endif
912f461d2dcSChristoph Hellwig 
913f461d2dcSChristoph Hellwig /**
914f461d2dcSChristoph Hellwig  * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
915f461d2dcSChristoph Hellwig  * @min: pointer to minimum allowable value
916f461d2dcSChristoph Hellwig  * @max: pointer to maximum allowable value
917f461d2dcSChristoph Hellwig  *
918f461d2dcSChristoph Hellwig  * The do_proc_dointvec_minmax_conv_param structure provides the
919f461d2dcSChristoph Hellwig  * minimum and maximum values for doing range checking for those sysctl
920f461d2dcSChristoph Hellwig  * parameters that use the proc_dointvec_minmax() handler.
921f461d2dcSChristoph Hellwig  */
922f461d2dcSChristoph Hellwig struct do_proc_dointvec_minmax_conv_param {
923f461d2dcSChristoph Hellwig 	int *min;
924f461d2dcSChristoph Hellwig 	int *max;
925f461d2dcSChristoph Hellwig };
926f461d2dcSChristoph Hellwig 
927f461d2dcSChristoph Hellwig static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
928f461d2dcSChristoph Hellwig 					int *valp,
929f461d2dcSChristoph Hellwig 					int write, void *data)
930f461d2dcSChristoph Hellwig {
931f461d2dcSChristoph Hellwig 	int tmp, ret;
932f461d2dcSChristoph Hellwig 	struct do_proc_dointvec_minmax_conv_param *param = data;
933f461d2dcSChristoph Hellwig 	/*
934f461d2dcSChristoph Hellwig 	 * If writing, first do so via a temporary local int so we can
935f461d2dcSChristoph Hellwig 	 * bounds-check it before touching *valp.
936f461d2dcSChristoph Hellwig 	 */
937f461d2dcSChristoph Hellwig 	int *ip = write ? &tmp : valp;
938f461d2dcSChristoph Hellwig 
939f461d2dcSChristoph Hellwig 	ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
940f461d2dcSChristoph Hellwig 	if (ret)
941f461d2dcSChristoph Hellwig 		return ret;
942f461d2dcSChristoph Hellwig 
943f461d2dcSChristoph Hellwig 	if (write) {
944f461d2dcSChristoph Hellwig 		if ((param->min && *param->min > tmp) ||
945f461d2dcSChristoph Hellwig 		    (param->max && *param->max < tmp))
946f461d2dcSChristoph Hellwig 			return -EINVAL;
947f461d2dcSChristoph Hellwig 		*valp = tmp;
948f461d2dcSChristoph Hellwig 	}
949f461d2dcSChristoph Hellwig 
950f461d2dcSChristoph Hellwig 	return 0;
951f461d2dcSChristoph Hellwig }
952f461d2dcSChristoph Hellwig 
953f461d2dcSChristoph Hellwig /**
954f461d2dcSChristoph Hellwig  * proc_dointvec_minmax - read a vector of integers with min/max values
955f461d2dcSChristoph Hellwig  * @table: the sysctl table
956f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
957f461d2dcSChristoph Hellwig  * @buffer: the user buffer
958f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
959f461d2dcSChristoph Hellwig  * @ppos: file position
960f461d2dcSChristoph Hellwig  *
961f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
962f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
963f461d2dcSChristoph Hellwig  *
964f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
965f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max).
966f461d2dcSChristoph Hellwig  *
967f461d2dcSChristoph Hellwig  * Returns 0 on success or -EINVAL on write when the range check fails.
968f461d2dcSChristoph Hellwig  */
969f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write,
97032927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
971f461d2dcSChristoph Hellwig {
972f461d2dcSChristoph Hellwig 	struct do_proc_dointvec_minmax_conv_param param = {
973f461d2dcSChristoph Hellwig 		.min = (int *) table->extra1,
974f461d2dcSChristoph Hellwig 		.max = (int *) table->extra2,
975f461d2dcSChristoph Hellwig 	};
976f461d2dcSChristoph Hellwig 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
977f461d2dcSChristoph Hellwig 				do_proc_dointvec_minmax_conv, &param);
978f461d2dcSChristoph Hellwig }
979f461d2dcSChristoph Hellwig 
980f461d2dcSChristoph Hellwig /**
981f461d2dcSChristoph Hellwig  * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
982f461d2dcSChristoph Hellwig  * @min: pointer to minimum allowable value
983f461d2dcSChristoph Hellwig  * @max: pointer to maximum allowable value
984f461d2dcSChristoph Hellwig  *
985f461d2dcSChristoph Hellwig  * The do_proc_douintvec_minmax_conv_param structure provides the
986f461d2dcSChristoph Hellwig  * minimum and maximum values for doing range checking for those sysctl
987f461d2dcSChristoph Hellwig  * parameters that use the proc_douintvec_minmax() handler.
988f461d2dcSChristoph Hellwig  */
989f461d2dcSChristoph Hellwig struct do_proc_douintvec_minmax_conv_param {
990f461d2dcSChristoph Hellwig 	unsigned int *min;
991f461d2dcSChristoph Hellwig 	unsigned int *max;
992f461d2dcSChristoph Hellwig };
993f461d2dcSChristoph Hellwig 
994f461d2dcSChristoph Hellwig static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
995f461d2dcSChristoph Hellwig 					 unsigned int *valp,
996f461d2dcSChristoph Hellwig 					 int write, void *data)
997f461d2dcSChristoph Hellwig {
998f461d2dcSChristoph Hellwig 	int ret;
999f461d2dcSChristoph Hellwig 	unsigned int tmp;
1000f461d2dcSChristoph Hellwig 	struct do_proc_douintvec_minmax_conv_param *param = data;
1001f461d2dcSChristoph Hellwig 	/* write via temporary local uint for bounds-checking */
1002f461d2dcSChristoph Hellwig 	unsigned int *up = write ? &tmp : valp;
1003f461d2dcSChristoph Hellwig 
1004f461d2dcSChristoph Hellwig 	ret = do_proc_douintvec_conv(lvalp, up, write, data);
1005f461d2dcSChristoph Hellwig 	if (ret)
1006f461d2dcSChristoph Hellwig 		return ret;
1007f461d2dcSChristoph Hellwig 
1008f461d2dcSChristoph Hellwig 	if (write) {
1009f461d2dcSChristoph Hellwig 		if ((param->min && *param->min > tmp) ||
1010f461d2dcSChristoph Hellwig 		    (param->max && *param->max < tmp))
1011f461d2dcSChristoph Hellwig 			return -ERANGE;
1012f461d2dcSChristoph Hellwig 
1013f461d2dcSChristoph Hellwig 		*valp = tmp;
1014f461d2dcSChristoph Hellwig 	}
1015f461d2dcSChristoph Hellwig 
1016f461d2dcSChristoph Hellwig 	return 0;
1017f461d2dcSChristoph Hellwig }
1018f461d2dcSChristoph Hellwig 
1019f461d2dcSChristoph Hellwig /**
1020f461d2dcSChristoph Hellwig  * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
1021f461d2dcSChristoph Hellwig  * @table: the sysctl table
1022f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1023f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1024f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1025f461d2dcSChristoph Hellwig  * @ppos: file position
1026f461d2dcSChristoph Hellwig  *
1027f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
1028f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string. Negative
1029f461d2dcSChristoph Hellwig  * strings are not allowed.
1030f461d2dcSChristoph Hellwig  *
1031f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1032f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max). There is a final sanity
1033f461d2dcSChristoph Hellwig  * check for UINT_MAX to avoid having to support wrap around uses from
1034f461d2dcSChristoph Hellwig  * userspace.
1035f461d2dcSChristoph Hellwig  *
1036f461d2dcSChristoph Hellwig  * Returns 0 on success or -ERANGE on write when the range check fails.
1037f461d2dcSChristoph Hellwig  */
1038f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write,
103932927393SChristoph Hellwig 			  void *buffer, size_t *lenp, loff_t *ppos)
1040f461d2dcSChristoph Hellwig {
1041f461d2dcSChristoph Hellwig 	struct do_proc_douintvec_minmax_conv_param param = {
1042f461d2dcSChristoph Hellwig 		.min = (unsigned int *) table->extra1,
1043f461d2dcSChristoph Hellwig 		.max = (unsigned int *) table->extra2,
1044f461d2dcSChristoph Hellwig 	};
1045f461d2dcSChristoph Hellwig 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
1046f461d2dcSChristoph Hellwig 				 do_proc_douintvec_minmax_conv, &param);
1047f461d2dcSChristoph Hellwig }
1048f461d2dcSChristoph Hellwig 
1049cb944413SEric Dumazet /**
1050cb944413SEric Dumazet  * proc_dou8vec_minmax - read a vector of unsigned chars with min/max values
1051cb944413SEric Dumazet  * @table: the sysctl table
1052cb944413SEric Dumazet  * @write: %TRUE if this is a write to the sysctl file
1053cb944413SEric Dumazet  * @buffer: the user buffer
1054cb944413SEric Dumazet  * @lenp: the size of the user buffer
1055cb944413SEric Dumazet  * @ppos: file position
1056cb944413SEric Dumazet  *
1057cb944413SEric Dumazet  * Reads/writes up to table->maxlen/sizeof(u8) unsigned chars
1058cb944413SEric Dumazet  * values from/to the user buffer, treated as an ASCII string. Negative
1059cb944413SEric Dumazet  * strings are not allowed.
1060cb944413SEric Dumazet  *
1061cb944413SEric Dumazet  * This routine will ensure the values are within the range specified by
1062cb944413SEric Dumazet  * table->extra1 (min) and table->extra2 (max).
1063cb944413SEric Dumazet  *
1064cb944413SEric Dumazet  * Returns 0 on success or an error on write when the range check fails.
1065cb944413SEric Dumazet  */
1066cb944413SEric Dumazet int proc_dou8vec_minmax(struct ctl_table *table, int write,
1067cb944413SEric Dumazet 			void *buffer, size_t *lenp, loff_t *ppos)
1068cb944413SEric Dumazet {
1069cb944413SEric Dumazet 	struct ctl_table tmp;
1070cb944413SEric Dumazet 	unsigned int min = 0, max = 255U, val;
1071cb944413SEric Dumazet 	u8 *data = table->data;
1072cb944413SEric Dumazet 	struct do_proc_douintvec_minmax_conv_param param = {
1073cb944413SEric Dumazet 		.min = &min,
1074cb944413SEric Dumazet 		.max = &max,
1075cb944413SEric Dumazet 	};
1076cb944413SEric Dumazet 	int res;
1077cb944413SEric Dumazet 
1078cb944413SEric Dumazet 	/* Do not support arrays yet. */
1079cb944413SEric Dumazet 	if (table->maxlen != sizeof(u8))
1080cb944413SEric Dumazet 		return -EINVAL;
1081cb944413SEric Dumazet 
1082cb944413SEric Dumazet 	if (table->extra1) {
1083cb944413SEric Dumazet 		min = *(unsigned int *) table->extra1;
1084cb944413SEric Dumazet 		if (min > 255U)
1085cb944413SEric Dumazet 			return -EINVAL;
1086cb944413SEric Dumazet 	}
1087cb944413SEric Dumazet 	if (table->extra2) {
1088cb944413SEric Dumazet 		max = *(unsigned int *) table->extra2;
1089cb944413SEric Dumazet 		if (max > 255U)
1090cb944413SEric Dumazet 			return -EINVAL;
1091cb944413SEric Dumazet 	}
1092cb944413SEric Dumazet 
1093cb944413SEric Dumazet 	tmp = *table;
1094cb944413SEric Dumazet 
1095cb944413SEric Dumazet 	tmp.maxlen = sizeof(val);
1096cb944413SEric Dumazet 	tmp.data = &val;
1097cb944413SEric Dumazet 	val = *data;
1098cb944413SEric Dumazet 	res = do_proc_douintvec(&tmp, write, buffer, lenp, ppos,
1099cb944413SEric Dumazet 				do_proc_douintvec_minmax_conv, &param);
1100cb944413SEric Dumazet 	if (res)
1101cb944413SEric Dumazet 		return res;
1102cb944413SEric Dumazet 	if (write)
1103cb944413SEric Dumazet 		*data = val;
1104cb944413SEric Dumazet 	return 0;
1105cb944413SEric Dumazet }
1106cb944413SEric Dumazet EXPORT_SYMBOL_GPL(proc_dou8vec_minmax);
1107cb944413SEric Dumazet 
1108f461d2dcSChristoph Hellwig static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
1109f461d2dcSChristoph Hellwig 					unsigned int *valp,
1110f461d2dcSChristoph Hellwig 					int write, void *data)
1111f461d2dcSChristoph Hellwig {
1112f461d2dcSChristoph Hellwig 	if (write) {
1113f461d2dcSChristoph Hellwig 		unsigned int val;
1114f461d2dcSChristoph Hellwig 
1115f461d2dcSChristoph Hellwig 		val = round_pipe_size(*lvalp);
1116f461d2dcSChristoph Hellwig 		if (val == 0)
1117f461d2dcSChristoph Hellwig 			return -EINVAL;
1118f461d2dcSChristoph Hellwig 
1119f461d2dcSChristoph Hellwig 		*valp = val;
1120f461d2dcSChristoph Hellwig 	} else {
1121f461d2dcSChristoph Hellwig 		unsigned int val = *valp;
1122f461d2dcSChristoph Hellwig 		*lvalp = (unsigned long) val;
1123f461d2dcSChristoph Hellwig 	}
1124f461d2dcSChristoph Hellwig 
1125f461d2dcSChristoph Hellwig 	return 0;
1126f461d2dcSChristoph Hellwig }
1127f461d2dcSChristoph Hellwig 
1128f461d2dcSChristoph Hellwig static int proc_dopipe_max_size(struct ctl_table *table, int write,
112932927393SChristoph Hellwig 				void *buffer, size_t *lenp, loff_t *ppos)
1130f461d2dcSChristoph Hellwig {
1131f461d2dcSChristoph Hellwig 	return do_proc_douintvec(table, write, buffer, lenp, ppos,
1132f461d2dcSChristoph Hellwig 				 do_proc_dopipe_max_size_conv, NULL);
1133f461d2dcSChristoph Hellwig }
1134f461d2dcSChristoph Hellwig 
1135f461d2dcSChristoph Hellwig static void validate_coredump_safety(void)
1136f461d2dcSChristoph Hellwig {
1137f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP
1138f461d2dcSChristoph Hellwig 	if (suid_dumpable == SUID_DUMP_ROOT &&
1139f461d2dcSChristoph Hellwig 	    core_pattern[0] != '/' && core_pattern[0] != '|') {
1140f461d2dcSChristoph Hellwig 		printk(KERN_WARNING
1141f461d2dcSChristoph Hellwig "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
1142f461d2dcSChristoph Hellwig "Pipe handler or fully qualified core dump path required.\n"
1143f461d2dcSChristoph Hellwig "Set kernel.core_pattern before fs.suid_dumpable.\n"
1144f461d2dcSChristoph Hellwig 		);
1145f461d2dcSChristoph Hellwig 	}
1146f461d2dcSChristoph Hellwig #endif
1147f461d2dcSChristoph Hellwig }
1148f461d2dcSChristoph Hellwig 
1149f461d2dcSChristoph Hellwig static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
115032927393SChristoph Hellwig 		void *buffer, size_t *lenp, loff_t *ppos)
1151f461d2dcSChristoph Hellwig {
1152f461d2dcSChristoph Hellwig 	int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
1153f461d2dcSChristoph Hellwig 	if (!error)
1154f461d2dcSChristoph Hellwig 		validate_coredump_safety();
1155f461d2dcSChristoph Hellwig 	return error;
1156f461d2dcSChristoph Hellwig }
1157f461d2dcSChristoph Hellwig 
1158f461d2dcSChristoph Hellwig #ifdef CONFIG_COREDUMP
1159f461d2dcSChristoph Hellwig static int proc_dostring_coredump(struct ctl_table *table, int write,
116032927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1161f461d2dcSChristoph Hellwig {
1162f461d2dcSChristoph Hellwig 	int error = proc_dostring(table, write, buffer, lenp, ppos);
1163f461d2dcSChristoph Hellwig 	if (!error)
1164f461d2dcSChristoph Hellwig 		validate_coredump_safety();
1165f461d2dcSChristoph Hellwig 	return error;
1166f461d2dcSChristoph Hellwig }
1167f461d2dcSChristoph Hellwig #endif
1168f461d2dcSChristoph Hellwig 
1169f461d2dcSChristoph Hellwig #ifdef CONFIG_MAGIC_SYSRQ
1170f461d2dcSChristoph Hellwig static int sysrq_sysctl_handler(struct ctl_table *table, int write,
117132927393SChristoph Hellwig 				void *buffer, size_t *lenp, loff_t *ppos)
1172f461d2dcSChristoph Hellwig {
1173f461d2dcSChristoph Hellwig 	int tmp, ret;
1174f461d2dcSChristoph Hellwig 
1175f461d2dcSChristoph Hellwig 	tmp = sysrq_mask();
1176f461d2dcSChristoph Hellwig 
1177f461d2dcSChristoph Hellwig 	ret = __do_proc_dointvec(&tmp, table, write, buffer,
1178f461d2dcSChristoph Hellwig 			       lenp, ppos, NULL, NULL);
1179f461d2dcSChristoph Hellwig 	if (ret || !write)
1180f461d2dcSChristoph Hellwig 		return ret;
1181f461d2dcSChristoph Hellwig 
1182f461d2dcSChristoph Hellwig 	if (write)
1183f461d2dcSChristoph Hellwig 		sysrq_toggle_support(tmp);
1184f461d2dcSChristoph Hellwig 
1185f461d2dcSChristoph Hellwig 	return 0;
1186f461d2dcSChristoph Hellwig }
1187f461d2dcSChristoph Hellwig #endif
1188f461d2dcSChristoph Hellwig 
118932927393SChristoph Hellwig static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table,
119032927393SChristoph Hellwig 		int write, void *buffer, size_t *lenp, loff_t *ppos,
119132927393SChristoph Hellwig 		unsigned long convmul, unsigned long convdiv)
1192f461d2dcSChristoph Hellwig {
1193f461d2dcSChristoph Hellwig 	unsigned long *i, *min, *max;
1194f461d2dcSChristoph Hellwig 	int vleft, first = 1, err = 0;
1195f461d2dcSChristoph Hellwig 	size_t left;
119632927393SChristoph Hellwig 	char *p;
1197f461d2dcSChristoph Hellwig 
1198f461d2dcSChristoph Hellwig 	if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
1199f461d2dcSChristoph Hellwig 		*lenp = 0;
1200f461d2dcSChristoph Hellwig 		return 0;
1201f461d2dcSChristoph Hellwig 	}
1202f461d2dcSChristoph Hellwig 
1203f461d2dcSChristoph Hellwig 	i = (unsigned long *) data;
1204f461d2dcSChristoph Hellwig 	min = (unsigned long *) table->extra1;
1205f461d2dcSChristoph Hellwig 	max = (unsigned long *) table->extra2;
1206f461d2dcSChristoph Hellwig 	vleft = table->maxlen / sizeof(unsigned long);
1207f461d2dcSChristoph Hellwig 	left = *lenp;
1208f461d2dcSChristoph Hellwig 
1209f461d2dcSChristoph Hellwig 	if (write) {
1210f461d2dcSChristoph Hellwig 		if (proc_first_pos_non_zero_ignore(ppos, table))
1211f461d2dcSChristoph Hellwig 			goto out;
1212f461d2dcSChristoph Hellwig 
1213f461d2dcSChristoph Hellwig 		if (left > PAGE_SIZE - 1)
1214f461d2dcSChristoph Hellwig 			left = PAGE_SIZE - 1;
121532927393SChristoph Hellwig 		p = buffer;
1216f461d2dcSChristoph Hellwig 	}
1217f461d2dcSChristoph Hellwig 
1218f461d2dcSChristoph Hellwig 	for (; left && vleft--; i++, first = 0) {
1219f461d2dcSChristoph Hellwig 		unsigned long val;
1220f461d2dcSChristoph Hellwig 
1221f461d2dcSChristoph Hellwig 		if (write) {
1222f461d2dcSChristoph Hellwig 			bool neg;
1223f461d2dcSChristoph Hellwig 
1224f461d2dcSChristoph Hellwig 			left -= proc_skip_spaces(&p);
1225f461d2dcSChristoph Hellwig 			if (!left)
1226f461d2dcSChristoph Hellwig 				break;
1227f461d2dcSChristoph Hellwig 
1228f461d2dcSChristoph Hellwig 			err = proc_get_long(&p, &left, &val, &neg,
1229f461d2dcSChristoph Hellwig 					     proc_wspace_sep,
1230f461d2dcSChristoph Hellwig 					     sizeof(proc_wspace_sep), NULL);
1231f461d2dcSChristoph Hellwig 			if (err)
1232f461d2dcSChristoph Hellwig 				break;
1233f461d2dcSChristoph Hellwig 			if (neg)
1234f461d2dcSChristoph Hellwig 				continue;
1235f461d2dcSChristoph Hellwig 			val = convmul * val / convdiv;
1236f461d2dcSChristoph Hellwig 			if ((min && val < *min) || (max && val > *max)) {
1237f461d2dcSChristoph Hellwig 				err = -EINVAL;
1238f461d2dcSChristoph Hellwig 				break;
1239f461d2dcSChristoph Hellwig 			}
1240f461d2dcSChristoph Hellwig 			*i = val;
1241f461d2dcSChristoph Hellwig 		} else {
1242f461d2dcSChristoph Hellwig 			val = convdiv * (*i) / convmul;
124332927393SChristoph Hellwig 			if (!first)
124432927393SChristoph Hellwig 				proc_put_char(&buffer, &left, '\t');
124532927393SChristoph Hellwig 			proc_put_long(&buffer, &left, val, false);
1246f461d2dcSChristoph Hellwig 		}
1247f461d2dcSChristoph Hellwig 	}
1248f461d2dcSChristoph Hellwig 
1249f461d2dcSChristoph Hellwig 	if (!write && !first && left && !err)
125032927393SChristoph Hellwig 		proc_put_char(&buffer, &left, '\n');
1251f461d2dcSChristoph Hellwig 	if (write && !err)
1252f461d2dcSChristoph Hellwig 		left -= proc_skip_spaces(&p);
125332927393SChristoph Hellwig 	if (write && first)
1254f461d2dcSChristoph Hellwig 		return err ? : -EINVAL;
1255f461d2dcSChristoph Hellwig 	*lenp -= left;
1256f461d2dcSChristoph Hellwig out:
1257f461d2dcSChristoph Hellwig 	*ppos += *lenp;
1258f461d2dcSChristoph Hellwig 	return err;
1259f461d2dcSChristoph Hellwig }
1260f461d2dcSChristoph Hellwig 
1261f461d2dcSChristoph Hellwig static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
126232927393SChristoph Hellwig 		void *buffer, size_t *lenp, loff_t *ppos, unsigned long convmul,
1263f461d2dcSChristoph Hellwig 		unsigned long convdiv)
1264f461d2dcSChristoph Hellwig {
1265f461d2dcSChristoph Hellwig 	return __do_proc_doulongvec_minmax(table->data, table, write,
1266f461d2dcSChristoph Hellwig 			buffer, lenp, ppos, convmul, convdiv);
1267f461d2dcSChristoph Hellwig }
1268f461d2dcSChristoph Hellwig 
1269f461d2dcSChristoph Hellwig /**
1270f461d2dcSChristoph Hellwig  * proc_doulongvec_minmax - read a vector of long integers with min/max values
1271f461d2dcSChristoph Hellwig  * @table: the sysctl table
1272f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1273f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1274f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1275f461d2dcSChristoph Hellwig  * @ppos: file position
1276f461d2dcSChristoph Hellwig  *
1277f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1278f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1279f461d2dcSChristoph Hellwig  *
1280f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1281f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max).
1282f461d2dcSChristoph Hellwig  *
1283f461d2dcSChristoph Hellwig  * Returns 0 on success.
1284f461d2dcSChristoph Hellwig  */
1285f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write,
128632927393SChristoph Hellwig 			   void *buffer, size_t *lenp, loff_t *ppos)
1287f461d2dcSChristoph Hellwig {
1288f461d2dcSChristoph Hellwig     return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
1289f461d2dcSChristoph Hellwig }
1290f461d2dcSChristoph Hellwig 
1291f461d2dcSChristoph Hellwig /**
1292f461d2dcSChristoph Hellwig  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
1293f461d2dcSChristoph Hellwig  * @table: the sysctl table
1294f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1295f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1296f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1297f461d2dcSChristoph Hellwig  * @ppos: file position
1298f461d2dcSChristoph Hellwig  *
1299f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
1300f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string. The values
1301f461d2dcSChristoph Hellwig  * are treated as milliseconds, and converted to jiffies when they are stored.
1302f461d2dcSChristoph Hellwig  *
1303f461d2dcSChristoph Hellwig  * This routine will ensure the values are within the range specified by
1304f461d2dcSChristoph Hellwig  * table->extra1 (min) and table->extra2 (max).
1305f461d2dcSChristoph Hellwig  *
1306f461d2dcSChristoph Hellwig  * Returns 0 on success.
1307f461d2dcSChristoph Hellwig  */
1308f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
130932927393SChristoph Hellwig 				      void *buffer, size_t *lenp, loff_t *ppos)
1310f461d2dcSChristoph Hellwig {
1311f461d2dcSChristoph Hellwig     return do_proc_doulongvec_minmax(table, write, buffer,
1312f461d2dcSChristoph Hellwig 				     lenp, ppos, HZ, 1000l);
1313f461d2dcSChristoph Hellwig }
1314f461d2dcSChristoph Hellwig 
1315f461d2dcSChristoph Hellwig 
1316f461d2dcSChristoph Hellwig static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
1317f461d2dcSChristoph Hellwig 					 int *valp,
1318f461d2dcSChristoph Hellwig 					 int write, void *data)
1319f461d2dcSChristoph Hellwig {
1320f461d2dcSChristoph Hellwig 	if (write) {
1321f461d2dcSChristoph Hellwig 		if (*lvalp > INT_MAX / HZ)
1322f461d2dcSChristoph Hellwig 			return 1;
1323f461d2dcSChristoph Hellwig 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
1324f461d2dcSChristoph Hellwig 	} else {
1325f461d2dcSChristoph Hellwig 		int val = *valp;
1326f461d2dcSChristoph Hellwig 		unsigned long lval;
1327f461d2dcSChristoph Hellwig 		if (val < 0) {
1328f461d2dcSChristoph Hellwig 			*negp = true;
1329f461d2dcSChristoph Hellwig 			lval = -(unsigned long)val;
1330f461d2dcSChristoph Hellwig 		} else {
1331f461d2dcSChristoph Hellwig 			*negp = false;
1332f461d2dcSChristoph Hellwig 			lval = (unsigned long)val;
1333f461d2dcSChristoph Hellwig 		}
1334f461d2dcSChristoph Hellwig 		*lvalp = lval / HZ;
1335f461d2dcSChristoph Hellwig 	}
1336f461d2dcSChristoph Hellwig 	return 0;
1337f461d2dcSChristoph Hellwig }
1338f461d2dcSChristoph Hellwig 
1339f461d2dcSChristoph Hellwig static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
1340f461d2dcSChristoph Hellwig 						int *valp,
1341f461d2dcSChristoph Hellwig 						int write, void *data)
1342f461d2dcSChristoph Hellwig {
1343f461d2dcSChristoph Hellwig 	if (write) {
1344f461d2dcSChristoph Hellwig 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
1345f461d2dcSChristoph Hellwig 			return 1;
1346f461d2dcSChristoph Hellwig 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
1347f461d2dcSChristoph Hellwig 	} else {
1348f461d2dcSChristoph Hellwig 		int val = *valp;
1349f461d2dcSChristoph Hellwig 		unsigned long lval;
1350f461d2dcSChristoph Hellwig 		if (val < 0) {
1351f461d2dcSChristoph Hellwig 			*negp = true;
1352f461d2dcSChristoph Hellwig 			lval = -(unsigned long)val;
1353f461d2dcSChristoph Hellwig 		} else {
1354f461d2dcSChristoph Hellwig 			*negp = false;
1355f461d2dcSChristoph Hellwig 			lval = (unsigned long)val;
1356f461d2dcSChristoph Hellwig 		}
1357f461d2dcSChristoph Hellwig 		*lvalp = jiffies_to_clock_t(lval);
1358f461d2dcSChristoph Hellwig 	}
1359f461d2dcSChristoph Hellwig 	return 0;
1360f461d2dcSChristoph Hellwig }
1361f461d2dcSChristoph Hellwig 
1362f461d2dcSChristoph Hellwig static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
1363f461d2dcSChristoph Hellwig 					    int *valp,
1364f461d2dcSChristoph Hellwig 					    int write, void *data)
1365f461d2dcSChristoph Hellwig {
1366f461d2dcSChristoph Hellwig 	if (write) {
1367f461d2dcSChristoph Hellwig 		unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
1368f461d2dcSChristoph Hellwig 
1369f461d2dcSChristoph Hellwig 		if (jif > INT_MAX)
1370f461d2dcSChristoph Hellwig 			return 1;
1371f461d2dcSChristoph Hellwig 		*valp = (int)jif;
1372f461d2dcSChristoph Hellwig 	} else {
1373f461d2dcSChristoph Hellwig 		int val = *valp;
1374f461d2dcSChristoph Hellwig 		unsigned long lval;
1375f461d2dcSChristoph Hellwig 		if (val < 0) {
1376f461d2dcSChristoph Hellwig 			*negp = true;
1377f461d2dcSChristoph Hellwig 			lval = -(unsigned long)val;
1378f461d2dcSChristoph Hellwig 		} else {
1379f461d2dcSChristoph Hellwig 			*negp = false;
1380f461d2dcSChristoph Hellwig 			lval = (unsigned long)val;
1381f461d2dcSChristoph Hellwig 		}
1382f461d2dcSChristoph Hellwig 		*lvalp = jiffies_to_msecs(lval);
1383f461d2dcSChristoph Hellwig 	}
1384f461d2dcSChristoph Hellwig 	return 0;
1385f461d2dcSChristoph Hellwig }
1386f461d2dcSChristoph Hellwig 
1387f461d2dcSChristoph Hellwig /**
1388f461d2dcSChristoph Hellwig  * proc_dointvec_jiffies - read a vector of integers as seconds
1389f461d2dcSChristoph Hellwig  * @table: the sysctl table
1390f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1391f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1392f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1393f461d2dcSChristoph Hellwig  * @ppos: file position
1394f461d2dcSChristoph Hellwig  *
1395f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1396f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1397f461d2dcSChristoph Hellwig  * The values read are assumed to be in seconds, and are converted into
1398f461d2dcSChristoph Hellwig  * jiffies.
1399f461d2dcSChristoph Hellwig  *
1400f461d2dcSChristoph Hellwig  * Returns 0 on success.
1401f461d2dcSChristoph Hellwig  */
1402f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write,
140332927393SChristoph Hellwig 			  void *buffer, size_t *lenp, loff_t *ppos)
1404f461d2dcSChristoph Hellwig {
1405f461d2dcSChristoph Hellwig     return do_proc_dointvec(table,write,buffer,lenp,ppos,
1406f461d2dcSChristoph Hellwig 		    	    do_proc_dointvec_jiffies_conv,NULL);
1407f461d2dcSChristoph Hellwig }
1408f461d2dcSChristoph Hellwig 
1409f461d2dcSChristoph Hellwig /**
1410f461d2dcSChristoph Hellwig  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
1411f461d2dcSChristoph Hellwig  * @table: the sysctl table
1412f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1413f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1414f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1415f461d2dcSChristoph Hellwig  * @ppos: pointer to the file position
1416f461d2dcSChristoph Hellwig  *
1417f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1418f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1419f461d2dcSChristoph Hellwig  * The values read are assumed to be in 1/USER_HZ seconds, and
1420f461d2dcSChristoph Hellwig  * are converted into jiffies.
1421f461d2dcSChristoph Hellwig  *
1422f461d2dcSChristoph Hellwig  * Returns 0 on success.
1423f461d2dcSChristoph Hellwig  */
1424f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
142532927393SChristoph Hellwig 				 void *buffer, size_t *lenp, loff_t *ppos)
1426f461d2dcSChristoph Hellwig {
1427f461d2dcSChristoph Hellwig     return do_proc_dointvec(table,write,buffer,lenp,ppos,
1428f461d2dcSChristoph Hellwig 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
1429f461d2dcSChristoph Hellwig }
1430f461d2dcSChristoph Hellwig 
1431f461d2dcSChristoph Hellwig /**
1432f461d2dcSChristoph Hellwig  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
1433f461d2dcSChristoph Hellwig  * @table: the sysctl table
1434f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1435f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1436f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1437f461d2dcSChristoph Hellwig  * @ppos: file position
1438f461d2dcSChristoph Hellwig  * @ppos: the current position in the file
1439f461d2dcSChristoph Hellwig  *
1440f461d2dcSChristoph Hellwig  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1441f461d2dcSChristoph Hellwig  * values from/to the user buffer, treated as an ASCII string.
1442f461d2dcSChristoph Hellwig  * The values read are assumed to be in 1/1000 seconds, and
1443f461d2dcSChristoph Hellwig  * are converted into jiffies.
1444f461d2dcSChristoph Hellwig  *
1445f461d2dcSChristoph Hellwig  * Returns 0 on success.
1446f461d2dcSChristoph Hellwig  */
144732927393SChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, void *buffer,
144832927393SChristoph Hellwig 		size_t *lenp, loff_t *ppos)
1449f461d2dcSChristoph Hellwig {
1450f461d2dcSChristoph Hellwig 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
1451f461d2dcSChristoph Hellwig 				do_proc_dointvec_ms_jiffies_conv, NULL);
1452f461d2dcSChristoph Hellwig }
1453f461d2dcSChristoph Hellwig 
145432927393SChristoph Hellwig static int proc_do_cad_pid(struct ctl_table *table, int write, void *buffer,
145532927393SChristoph Hellwig 		size_t *lenp, loff_t *ppos)
1456f461d2dcSChristoph Hellwig {
1457f461d2dcSChristoph Hellwig 	struct pid *new_pid;
1458f461d2dcSChristoph Hellwig 	pid_t tmp;
1459f461d2dcSChristoph Hellwig 	int r;
1460f461d2dcSChristoph Hellwig 
1461f461d2dcSChristoph Hellwig 	tmp = pid_vnr(cad_pid);
1462f461d2dcSChristoph Hellwig 
1463f461d2dcSChristoph Hellwig 	r = __do_proc_dointvec(&tmp, table, write, buffer,
1464f461d2dcSChristoph Hellwig 			       lenp, ppos, NULL, NULL);
1465f461d2dcSChristoph Hellwig 	if (r || !write)
1466f461d2dcSChristoph Hellwig 		return r;
1467f461d2dcSChristoph Hellwig 
1468f461d2dcSChristoph Hellwig 	new_pid = find_get_pid(tmp);
1469f461d2dcSChristoph Hellwig 	if (!new_pid)
1470f461d2dcSChristoph Hellwig 		return -ESRCH;
1471f461d2dcSChristoph Hellwig 
1472f461d2dcSChristoph Hellwig 	put_pid(xchg(&cad_pid, new_pid));
1473f461d2dcSChristoph Hellwig 	return 0;
1474f461d2dcSChristoph Hellwig }
1475f461d2dcSChristoph Hellwig 
1476f461d2dcSChristoph Hellwig /**
1477f461d2dcSChristoph Hellwig  * proc_do_large_bitmap - read/write from/to a large bitmap
1478f461d2dcSChristoph Hellwig  * @table: the sysctl table
1479f461d2dcSChristoph Hellwig  * @write: %TRUE if this is a write to the sysctl file
1480f461d2dcSChristoph Hellwig  * @buffer: the user buffer
1481f461d2dcSChristoph Hellwig  * @lenp: the size of the user buffer
1482f461d2dcSChristoph Hellwig  * @ppos: file position
1483f461d2dcSChristoph Hellwig  *
1484f461d2dcSChristoph Hellwig  * The bitmap is stored at table->data and the bitmap length (in bits)
1485f461d2dcSChristoph Hellwig  * in table->maxlen.
1486f461d2dcSChristoph Hellwig  *
1487f461d2dcSChristoph Hellwig  * We use a range comma separated format (e.g. 1,3-4,10-10) so that
1488f461d2dcSChristoph Hellwig  * large bitmaps may be represented in a compact manner. Writing into
1489f461d2dcSChristoph Hellwig  * the file will clear the bitmap then update it with the given input.
1490f461d2dcSChristoph Hellwig  *
1491f461d2dcSChristoph Hellwig  * Returns 0 on success.
1492f461d2dcSChristoph Hellwig  */
1493f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write,
149432927393SChristoph Hellwig 			 void *buffer, size_t *lenp, loff_t *ppos)
1495f461d2dcSChristoph Hellwig {
1496f461d2dcSChristoph Hellwig 	int err = 0;
1497f461d2dcSChristoph Hellwig 	size_t left = *lenp;
1498f461d2dcSChristoph Hellwig 	unsigned long bitmap_len = table->maxlen;
1499f461d2dcSChristoph Hellwig 	unsigned long *bitmap = *(unsigned long **) table->data;
1500f461d2dcSChristoph Hellwig 	unsigned long *tmp_bitmap = NULL;
1501f461d2dcSChristoph Hellwig 	char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
1502f461d2dcSChristoph Hellwig 
1503f461d2dcSChristoph Hellwig 	if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
1504f461d2dcSChristoph Hellwig 		*lenp = 0;
1505f461d2dcSChristoph Hellwig 		return 0;
1506f461d2dcSChristoph Hellwig 	}
1507f461d2dcSChristoph Hellwig 
1508f461d2dcSChristoph Hellwig 	if (write) {
150932927393SChristoph Hellwig 		char *p = buffer;
1510f461d2dcSChristoph Hellwig 		size_t skipped = 0;
1511f461d2dcSChristoph Hellwig 
1512f461d2dcSChristoph Hellwig 		if (left > PAGE_SIZE - 1) {
1513f461d2dcSChristoph Hellwig 			left = PAGE_SIZE - 1;
1514f461d2dcSChristoph Hellwig 			/* How much of the buffer we'll skip this pass */
1515f461d2dcSChristoph Hellwig 			skipped = *lenp - left;
1516f461d2dcSChristoph Hellwig 		}
1517f461d2dcSChristoph Hellwig 
1518f461d2dcSChristoph Hellwig 		tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
151932927393SChristoph Hellwig 		if (!tmp_bitmap)
1520f461d2dcSChristoph Hellwig 			return -ENOMEM;
1521f461d2dcSChristoph Hellwig 		proc_skip_char(&p, &left, '\n');
1522f461d2dcSChristoph Hellwig 		while (!err && left) {
1523f461d2dcSChristoph Hellwig 			unsigned long val_a, val_b;
1524f461d2dcSChristoph Hellwig 			bool neg;
1525f461d2dcSChristoph Hellwig 			size_t saved_left;
1526f461d2dcSChristoph Hellwig 
1527f461d2dcSChristoph Hellwig 			/* In case we stop parsing mid-number, we can reset */
1528f461d2dcSChristoph Hellwig 			saved_left = left;
1529f461d2dcSChristoph Hellwig 			err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
1530f461d2dcSChristoph Hellwig 					     sizeof(tr_a), &c);
1531f461d2dcSChristoph Hellwig 			/*
1532f461d2dcSChristoph Hellwig 			 * If we consumed the entirety of a truncated buffer or
1533f461d2dcSChristoph Hellwig 			 * only one char is left (may be a "-"), then stop here,
1534f461d2dcSChristoph Hellwig 			 * reset, & come back for more.
1535f461d2dcSChristoph Hellwig 			 */
1536f461d2dcSChristoph Hellwig 			if ((left <= 1) && skipped) {
1537f461d2dcSChristoph Hellwig 				left = saved_left;
1538f461d2dcSChristoph Hellwig 				break;
1539f461d2dcSChristoph Hellwig 			}
1540f461d2dcSChristoph Hellwig 
1541f461d2dcSChristoph Hellwig 			if (err)
1542f461d2dcSChristoph Hellwig 				break;
1543f461d2dcSChristoph Hellwig 			if (val_a >= bitmap_len || neg) {
1544f461d2dcSChristoph Hellwig 				err = -EINVAL;
1545f461d2dcSChristoph Hellwig 				break;
1546f461d2dcSChristoph Hellwig 			}
1547f461d2dcSChristoph Hellwig 
1548f461d2dcSChristoph Hellwig 			val_b = val_a;
1549f461d2dcSChristoph Hellwig 			if (left) {
1550f461d2dcSChristoph Hellwig 				p++;
1551f461d2dcSChristoph Hellwig 				left--;
1552f461d2dcSChristoph Hellwig 			}
1553f461d2dcSChristoph Hellwig 
1554f461d2dcSChristoph Hellwig 			if (c == '-') {
1555f461d2dcSChristoph Hellwig 				err = proc_get_long(&p, &left, &val_b,
1556f461d2dcSChristoph Hellwig 						     &neg, tr_b, sizeof(tr_b),
1557f461d2dcSChristoph Hellwig 						     &c);
1558f461d2dcSChristoph Hellwig 				/*
1559f461d2dcSChristoph Hellwig 				 * If we consumed all of a truncated buffer or
1560f461d2dcSChristoph Hellwig 				 * then stop here, reset, & come back for more.
1561f461d2dcSChristoph Hellwig 				 */
1562f461d2dcSChristoph Hellwig 				if (!left && skipped) {
1563f461d2dcSChristoph Hellwig 					left = saved_left;
1564f461d2dcSChristoph Hellwig 					break;
1565f461d2dcSChristoph Hellwig 				}
1566f461d2dcSChristoph Hellwig 
1567f461d2dcSChristoph Hellwig 				if (err)
1568f461d2dcSChristoph Hellwig 					break;
1569f461d2dcSChristoph Hellwig 				if (val_b >= bitmap_len || neg ||
1570f461d2dcSChristoph Hellwig 				    val_a > val_b) {
1571f461d2dcSChristoph Hellwig 					err = -EINVAL;
1572f461d2dcSChristoph Hellwig 					break;
1573f461d2dcSChristoph Hellwig 				}
1574f461d2dcSChristoph Hellwig 				if (left) {
1575f461d2dcSChristoph Hellwig 					p++;
1576f461d2dcSChristoph Hellwig 					left--;
1577f461d2dcSChristoph Hellwig 				}
1578f461d2dcSChristoph Hellwig 			}
1579f461d2dcSChristoph Hellwig 
1580f461d2dcSChristoph Hellwig 			bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
1581f461d2dcSChristoph Hellwig 			proc_skip_char(&p, &left, '\n');
1582f461d2dcSChristoph Hellwig 		}
1583f461d2dcSChristoph Hellwig 		left += skipped;
1584f461d2dcSChristoph Hellwig 	} else {
1585f461d2dcSChristoph Hellwig 		unsigned long bit_a, bit_b = 0;
1586*9a52c5f3SJiapeng Chong 		bool first = 1;
1587f461d2dcSChristoph Hellwig 
1588f461d2dcSChristoph Hellwig 		while (left) {
1589f461d2dcSChristoph Hellwig 			bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
1590f461d2dcSChristoph Hellwig 			if (bit_a >= bitmap_len)
1591f461d2dcSChristoph Hellwig 				break;
1592f461d2dcSChristoph Hellwig 			bit_b = find_next_zero_bit(bitmap, bitmap_len,
1593f461d2dcSChristoph Hellwig 						   bit_a + 1) - 1;
1594f461d2dcSChristoph Hellwig 
159532927393SChristoph Hellwig 			if (!first)
159632927393SChristoph Hellwig 				proc_put_char(&buffer, &left, ',');
159732927393SChristoph Hellwig 			proc_put_long(&buffer, &left, bit_a, false);
1598f461d2dcSChristoph Hellwig 			if (bit_a != bit_b) {
159932927393SChristoph Hellwig 				proc_put_char(&buffer, &left, '-');
160032927393SChristoph Hellwig 				proc_put_long(&buffer, &left, bit_b, false);
1601f461d2dcSChristoph Hellwig 			}
1602f461d2dcSChristoph Hellwig 
1603f461d2dcSChristoph Hellwig 			first = 0; bit_b++;
1604f461d2dcSChristoph Hellwig 		}
160532927393SChristoph Hellwig 		proc_put_char(&buffer, &left, '\n');
1606f461d2dcSChristoph Hellwig 	}
1607f461d2dcSChristoph Hellwig 
1608f461d2dcSChristoph Hellwig 	if (!err) {
1609f461d2dcSChristoph Hellwig 		if (write) {
1610f461d2dcSChristoph Hellwig 			if (*ppos)
1611f461d2dcSChristoph Hellwig 				bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
1612f461d2dcSChristoph Hellwig 			else
1613f461d2dcSChristoph Hellwig 				bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
1614f461d2dcSChristoph Hellwig 		}
1615f461d2dcSChristoph Hellwig 		*lenp -= left;
1616f461d2dcSChristoph Hellwig 		*ppos += *lenp;
1617f461d2dcSChristoph Hellwig 	}
1618f461d2dcSChristoph Hellwig 
1619f461d2dcSChristoph Hellwig 	bitmap_free(tmp_bitmap);
1620f461d2dcSChristoph Hellwig 	return err;
1621f461d2dcSChristoph Hellwig }
1622f461d2dcSChristoph Hellwig 
1623f461d2dcSChristoph Hellwig #else /* CONFIG_PROC_SYSCTL */
1624f461d2dcSChristoph Hellwig 
1625f461d2dcSChristoph Hellwig int proc_dostring(struct ctl_table *table, int write,
162632927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1627f461d2dcSChristoph Hellwig {
1628f461d2dcSChristoph Hellwig 	return -ENOSYS;
1629f461d2dcSChristoph Hellwig }
1630f461d2dcSChristoph Hellwig 
1631f461d2dcSChristoph Hellwig int proc_dointvec(struct ctl_table *table, int write,
163232927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1633f461d2dcSChristoph Hellwig {
1634f461d2dcSChristoph Hellwig 	return -ENOSYS;
1635f461d2dcSChristoph Hellwig }
1636f461d2dcSChristoph Hellwig 
1637f461d2dcSChristoph Hellwig int proc_douintvec(struct ctl_table *table, int write,
163832927393SChristoph Hellwig 		  void *buffer, size_t *lenp, loff_t *ppos)
1639f461d2dcSChristoph Hellwig {
1640f461d2dcSChristoph Hellwig 	return -ENOSYS;
1641f461d2dcSChristoph Hellwig }
1642f461d2dcSChristoph Hellwig 
1643f461d2dcSChristoph Hellwig int proc_dointvec_minmax(struct ctl_table *table, int write,
164432927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1645f461d2dcSChristoph Hellwig {
1646f461d2dcSChristoph Hellwig 	return -ENOSYS;
1647f461d2dcSChristoph Hellwig }
1648f461d2dcSChristoph Hellwig 
1649f461d2dcSChristoph Hellwig int proc_douintvec_minmax(struct ctl_table *table, int write,
165032927393SChristoph Hellwig 			  void *buffer, size_t *lenp, loff_t *ppos)
1651f461d2dcSChristoph Hellwig {
1652f461d2dcSChristoph Hellwig 	return -ENOSYS;
1653f461d2dcSChristoph Hellwig }
1654f461d2dcSChristoph Hellwig 
1655cb944413SEric Dumazet int proc_dou8vec_minmax(struct ctl_table *table, int write,
1656cb944413SEric Dumazet 			void *buffer, size_t *lenp, loff_t *ppos)
1657cb944413SEric Dumazet {
1658cb944413SEric Dumazet 	return -ENOSYS;
1659cb944413SEric Dumazet }
1660cb944413SEric Dumazet 
1661f461d2dcSChristoph Hellwig int proc_dointvec_jiffies(struct ctl_table *table, int write,
166232927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1663f461d2dcSChristoph Hellwig {
1664f461d2dcSChristoph Hellwig 	return -ENOSYS;
1665f461d2dcSChristoph Hellwig }
1666f461d2dcSChristoph Hellwig 
1667f461d2dcSChristoph Hellwig int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
166832927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1669f461d2dcSChristoph Hellwig {
1670f461d2dcSChristoph Hellwig 	return -ENOSYS;
1671f461d2dcSChristoph Hellwig }
1672f461d2dcSChristoph Hellwig 
1673f461d2dcSChristoph Hellwig int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
167432927393SChristoph Hellwig 			     void *buffer, size_t *lenp, loff_t *ppos)
1675f461d2dcSChristoph Hellwig {
1676f461d2dcSChristoph Hellwig 	return -ENOSYS;
1677f461d2dcSChristoph Hellwig }
1678f461d2dcSChristoph Hellwig 
1679f461d2dcSChristoph Hellwig int proc_doulongvec_minmax(struct ctl_table *table, int write,
168032927393SChristoph Hellwig 		    void *buffer, size_t *lenp, loff_t *ppos)
1681f461d2dcSChristoph Hellwig {
1682f461d2dcSChristoph Hellwig 	return -ENOSYS;
1683f461d2dcSChristoph Hellwig }
1684f461d2dcSChristoph Hellwig 
1685f461d2dcSChristoph Hellwig int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
168632927393SChristoph Hellwig 				      void *buffer, size_t *lenp, loff_t *ppos)
1687f461d2dcSChristoph Hellwig {
1688f461d2dcSChristoph Hellwig 	return -ENOSYS;
1689f461d2dcSChristoph Hellwig }
1690f461d2dcSChristoph Hellwig 
1691f461d2dcSChristoph Hellwig int proc_do_large_bitmap(struct ctl_table *table, int write,
169232927393SChristoph Hellwig 			 void *buffer, size_t *lenp, loff_t *ppos)
1693f461d2dcSChristoph Hellwig {
1694f461d2dcSChristoph Hellwig 	return -ENOSYS;
1695f461d2dcSChristoph Hellwig }
1696f461d2dcSChristoph Hellwig 
1697f461d2dcSChristoph Hellwig #endif /* CONFIG_PROC_SYSCTL */
1698f461d2dcSChristoph Hellwig 
1699f461d2dcSChristoph Hellwig #if defined(CONFIG_SYSCTL)
1700f461d2dcSChristoph Hellwig int proc_do_static_key(struct ctl_table *table, int write,
170132927393SChristoph Hellwig 		       void *buffer, size_t *lenp, loff_t *ppos)
1702f461d2dcSChristoph Hellwig {
1703f461d2dcSChristoph Hellwig 	struct static_key *key = (struct static_key *)table->data;
1704f461d2dcSChristoph Hellwig 	static DEFINE_MUTEX(static_key_mutex);
1705f461d2dcSChristoph Hellwig 	int val, ret;
1706f461d2dcSChristoph Hellwig 	struct ctl_table tmp = {
1707f461d2dcSChristoph Hellwig 		.data   = &val,
1708f461d2dcSChristoph Hellwig 		.maxlen = sizeof(val),
1709f461d2dcSChristoph Hellwig 		.mode   = table->mode,
1710f461d2dcSChristoph Hellwig 		.extra1 = SYSCTL_ZERO,
1711f461d2dcSChristoph Hellwig 		.extra2 = SYSCTL_ONE,
1712f461d2dcSChristoph Hellwig 	};
1713f461d2dcSChristoph Hellwig 
1714f461d2dcSChristoph Hellwig 	if (write && !capable(CAP_SYS_ADMIN))
1715f461d2dcSChristoph Hellwig 		return -EPERM;
1716f461d2dcSChristoph Hellwig 
1717f461d2dcSChristoph Hellwig 	mutex_lock(&static_key_mutex);
1718f461d2dcSChristoph Hellwig 	val = static_key_enabled(key);
1719f461d2dcSChristoph Hellwig 	ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
1720f461d2dcSChristoph Hellwig 	if (write && !ret) {
1721f461d2dcSChristoph Hellwig 		if (val)
1722f461d2dcSChristoph Hellwig 			static_key_enable(key);
1723f461d2dcSChristoph Hellwig 		else
1724f461d2dcSChristoph Hellwig 			static_key_disable(key);
1725f461d2dcSChristoph Hellwig 	}
1726f461d2dcSChristoph Hellwig 	mutex_unlock(&static_key_mutex);
1727f461d2dcSChristoph Hellwig 	return ret;
1728f461d2dcSChristoph Hellwig }
1729f461d2dcSChristoph Hellwig 
1730d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
17312bba22c5SMike Galbraith 	{
17322bba22c5SMike Galbraith 		.procname	= "sched_child_runs_first",
17332bba22c5SMike Galbraith 		.data		= &sysctl_sched_child_runs_first,
17342bba22c5SMike Galbraith 		.maxlen		= sizeof(unsigned int),
17352bba22c5SMike Galbraith 		.mode		= 0644,
17366d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
17372bba22c5SMike Galbraith 	},
17381d1c2509SPeter Zijlstra #ifdef CONFIG_SCHEDSTATS
17391d1c2509SPeter Zijlstra 	{
17401d1c2509SPeter Zijlstra 		.procname	= "sched_schedstats",
17411d1c2509SPeter Zijlstra 		.data		= NULL,
17421d1c2509SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
17431d1c2509SPeter Zijlstra 		.mode		= 0644,
17441d1c2509SPeter Zijlstra 		.proc_handler	= sysctl_schedstats,
17451d1c2509SPeter Zijlstra 		.extra1		= SYSCTL_ZERO,
17461d1c2509SPeter Zijlstra 		.extra2		= SYSCTL_ONE,
17471d1c2509SPeter Zijlstra 	},
17481d1c2509SPeter Zijlstra #endif /* CONFIG_SCHEDSTATS */
1749b7cc6ec7SMel Gorman #ifdef CONFIG_NUMA_BALANCING
17503a7053b3SMel Gorman 	{
175154a43d54SAndi Kleen 		.procname	= "numa_balancing",
175254a43d54SAndi Kleen 		.data		= NULL, /* filled in by handler */
175354a43d54SAndi Kleen 		.maxlen		= sizeof(unsigned int),
175454a43d54SAndi Kleen 		.mode		= 0644,
175554a43d54SAndi Kleen 		.proc_handler	= sysctl_numa_balancing,
1756eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1757eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
175854a43d54SAndi Kleen 	},
1759cbee9f88SPeter Zijlstra #endif /* CONFIG_NUMA_BALANCING */
17601799e35dSIngo Molnar 	{
17619f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
17629f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
17639f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
17649f0c1e56SPeter Zijlstra 		.mode		= 0644,
17656d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
17669f0c1e56SPeter Zijlstra 	},
17679f0c1e56SPeter Zijlstra 	{
17689f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
17699f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
17709f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
17719f0c1e56SPeter Zijlstra 		.mode		= 0644,
17726d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
17739f0c1e56SPeter Zijlstra 	},
1774ce0dbbbbSClark Williams 	{
1775b4098bfcSPeter Zijlstra 		.procname	= "sched_deadline_period_max_us",
1776b4098bfcSPeter Zijlstra 		.data		= &sysctl_sched_dl_period_max,
1777b4098bfcSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
1778b4098bfcSPeter Zijlstra 		.mode		= 0644,
1779b4098bfcSPeter Zijlstra 		.proc_handler	= proc_dointvec,
1780b4098bfcSPeter Zijlstra 	},
1781b4098bfcSPeter Zijlstra 	{
1782b4098bfcSPeter Zijlstra 		.procname	= "sched_deadline_period_min_us",
1783b4098bfcSPeter Zijlstra 		.data		= &sysctl_sched_dl_period_min,
1784b4098bfcSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
1785b4098bfcSPeter Zijlstra 		.mode		= 0644,
1786b4098bfcSPeter Zijlstra 		.proc_handler	= proc_dointvec,
1787b4098bfcSPeter Zijlstra 	},
1788b4098bfcSPeter Zijlstra 	{
1789ce0dbbbbSClark Williams 		.procname	= "sched_rr_timeslice_ms",
1790975e155eSShile Zhang 		.data		= &sysctl_sched_rr_timeslice,
1791ce0dbbbbSClark Williams 		.maxlen		= sizeof(int),
1792ce0dbbbbSClark Williams 		.mode		= 0644,
1793ce0dbbbbSClark Williams 		.proc_handler	= sched_rr_handler,
1794ce0dbbbbSClark Williams 	},
1795e8f14172SPatrick Bellasi #ifdef CONFIG_UCLAMP_TASK
1796e8f14172SPatrick Bellasi 	{
1797e8f14172SPatrick Bellasi 		.procname	= "sched_util_clamp_min",
1798e8f14172SPatrick Bellasi 		.data		= &sysctl_sched_uclamp_util_min,
1799e8f14172SPatrick Bellasi 		.maxlen		= sizeof(unsigned int),
1800e8f14172SPatrick Bellasi 		.mode		= 0644,
1801e8f14172SPatrick Bellasi 		.proc_handler	= sysctl_sched_uclamp_handler,
1802e8f14172SPatrick Bellasi 	},
1803e8f14172SPatrick Bellasi 	{
1804e8f14172SPatrick Bellasi 		.procname	= "sched_util_clamp_max",
1805e8f14172SPatrick Bellasi 		.data		= &sysctl_sched_uclamp_util_max,
1806e8f14172SPatrick Bellasi 		.maxlen		= sizeof(unsigned int),
1807e8f14172SPatrick Bellasi 		.mode		= 0644,
1808e8f14172SPatrick Bellasi 		.proc_handler	= sysctl_sched_uclamp_handler,
1809e8f14172SPatrick Bellasi 	},
181013685c4aSQais Yousef 	{
181113685c4aSQais Yousef 		.procname	= "sched_util_clamp_min_rt_default",
181213685c4aSQais Yousef 		.data		= &sysctl_sched_uclamp_util_min_rt_default,
181313685c4aSQais Yousef 		.maxlen		= sizeof(unsigned int),
181413685c4aSQais Yousef 		.mode		= 0644,
181513685c4aSQais Yousef 		.proc_handler	= sysctl_sched_uclamp_handler,
181613685c4aSQais Yousef 	},
1817e8f14172SPatrick Bellasi #endif
18185091faa4SMike Galbraith #ifdef CONFIG_SCHED_AUTOGROUP
18195091faa4SMike Galbraith 	{
18205091faa4SMike Galbraith 		.procname	= "sched_autogroup_enabled",
18215091faa4SMike Galbraith 		.data		= &sysctl_sched_autogroup_enabled,
18225091faa4SMike Galbraith 		.maxlen		= sizeof(unsigned int),
18235091faa4SMike Galbraith 		.mode		= 0644,
18241747b21fSYong Zhang 		.proc_handler	= proc_dointvec_minmax,
1825eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1826eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
18275091faa4SMike Galbraith 	},
18285091faa4SMike Galbraith #endif
1829ec12cb7fSPaul Turner #ifdef CONFIG_CFS_BANDWIDTH
1830ec12cb7fSPaul Turner 	{
1831ec12cb7fSPaul Turner 		.procname	= "sched_cfs_bandwidth_slice_us",
1832ec12cb7fSPaul Turner 		.data		= &sysctl_sched_cfs_bandwidth_slice,
1833ec12cb7fSPaul Turner 		.maxlen		= sizeof(unsigned int),
1834ec12cb7fSPaul Turner 		.mode		= 0644,
1835ec12cb7fSPaul Turner 		.proc_handler	= proc_dointvec_minmax,
1836eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
1837ec12cb7fSPaul Turner 	},
1838ec12cb7fSPaul Turner #endif
18398d5d0cfbSQuentin Perret #if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
18408d5d0cfbSQuentin Perret 	{
18418d5d0cfbSQuentin Perret 		.procname	= "sched_energy_aware",
18428d5d0cfbSQuentin Perret 		.data		= &sysctl_sched_energy_aware,
18438d5d0cfbSQuentin Perret 		.maxlen		= sizeof(unsigned int),
18448d5d0cfbSQuentin Perret 		.mode		= 0644,
18458d5d0cfbSQuentin Perret 		.proc_handler	= sched_energy_aware_handler,
1846eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
1847eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
18488d5d0cfbSQuentin Perret 	},
18498d5d0cfbSQuentin Perret #endif
1850f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
1851f20786ffSPeter Zijlstra 	{
1852f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
1853f20786ffSPeter Zijlstra 		.data		= &prove_locking,
1854f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
1855f20786ffSPeter Zijlstra 		.mode		= 0644,
18566d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1857f20786ffSPeter Zijlstra 	},
1858f20786ffSPeter Zijlstra #endif
1859f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
1860f20786ffSPeter Zijlstra 	{
1861f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
1862f20786ffSPeter Zijlstra 		.data		= &lock_stat,
1863f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
1864f20786ffSPeter Zijlstra 		.mode		= 0644,
18656d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1866f20786ffSPeter Zijlstra 	},
1867f20786ffSPeter Zijlstra #endif
186877e54a1fSIngo Molnar 	{
18691da177e4SLinus Torvalds 		.procname	= "panic",
18701da177e4SLinus Torvalds 		.data		= &panic_timeout,
18711da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
18721da177e4SLinus Torvalds 		.mode		= 0644,
18736d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
18741da177e4SLinus Torvalds 	},
1875046d662fSAlex Kelly #ifdef CONFIG_COREDUMP
18761da177e4SLinus Torvalds 	{
18771da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
18781da177e4SLinus Torvalds 		.data		= &core_uses_pid,
18791da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
18801da177e4SLinus Torvalds 		.mode		= 0644,
18816d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
18821da177e4SLinus Torvalds 	},
18831da177e4SLinus Torvalds 	{
18841da177e4SLinus Torvalds 		.procname	= "core_pattern",
18851da177e4SLinus Torvalds 		.data		= core_pattern,
188671ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
18871da177e4SLinus Torvalds 		.mode		= 0644,
188854b50199SKees Cook 		.proc_handler	= proc_dostring_coredump,
18891da177e4SLinus Torvalds 	},
1890a293980cSNeil Horman 	{
1891a293980cSNeil Horman 		.procname	= "core_pipe_limit",
1892a293980cSNeil Horman 		.data		= &core_pipe_limit,
1893a293980cSNeil Horman 		.maxlen		= sizeof(unsigned int),
1894a293980cSNeil Horman 		.mode		= 0644,
18956d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1896a293980cSNeil Horman 	},
1897046d662fSAlex Kelly #endif
189834f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
18991da177e4SLinus Torvalds 	{
19001da177e4SLinus Torvalds 		.procname	= "tainted",
190125ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
190234f5a398STheodore Ts'o 		.mode		= 0644,
19036d456111SEric W. Biederman 		.proc_handler	= proc_taint,
19041da177e4SLinus Torvalds 	},
1905f4aacea2SKees Cook 	{
1906f4aacea2SKees Cook 		.procname	= "sysctl_writes_strict",
1907f4aacea2SKees Cook 		.data		= &sysctl_writes_strict,
1908f4aacea2SKees Cook 		.maxlen		= sizeof(int),
1909f4aacea2SKees Cook 		.mode		= 0644,
1910f4aacea2SKees Cook 		.proc_handler	= proc_dointvec_minmax,
1911f4aacea2SKees Cook 		.extra1		= &neg_one,
1912eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
1913f4aacea2SKees Cook 	},
191434f5a398STheodore Ts'o #endif
19159745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
19169745512cSArjan van de Ven 	{
19179745512cSArjan van de Ven 		.procname	= "latencytop",
19189745512cSArjan van de Ven 		.data		= &latencytop_enabled,
19199745512cSArjan van de Ven 		.maxlen		= sizeof(int),
19209745512cSArjan van de Ven 		.mode		= 0644,
1921cb251765SMel Gorman 		.proc_handler	= sysctl_latencytop,
19229745512cSArjan van de Ven 	},
19239745512cSArjan van de Ven #endif
19241da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
19251da177e4SLinus Torvalds 	{
19261da177e4SLinus Torvalds 		.procname	= "real-root-dev",
19271da177e4SLinus Torvalds 		.data		= &real_root_dev,
19281da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
19291da177e4SLinus Torvalds 		.mode		= 0644,
19306d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19311da177e4SLinus Torvalds 	},
19321da177e4SLinus Torvalds #endif
193345807a1dSIngo Molnar 	{
193445807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
193545807a1dSIngo Molnar 		.data		= &print_fatal_signals,
193645807a1dSIngo Molnar 		.maxlen		= sizeof(int),
193745807a1dSIngo Molnar 		.mode		= 0644,
19386d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
193945807a1dSIngo Molnar 	},
194072c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
19411da177e4SLinus Torvalds 	{
19421da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
19431da177e4SLinus Torvalds 		.data		= reboot_command,
19441da177e4SLinus Torvalds 		.maxlen		= 256,
19451da177e4SLinus Torvalds 		.mode		= 0644,
19466d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
19471da177e4SLinus Torvalds 	},
19481da177e4SLinus Torvalds 	{
19491da177e4SLinus Torvalds 		.procname	= "stop-a",
19501da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
19511da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19521da177e4SLinus Torvalds 		.mode		= 0644,
19536d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19541da177e4SLinus Torvalds 	},
19551da177e4SLinus Torvalds 	{
19561da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
19571da177e4SLinus Torvalds 		.data		= &scons_pwroff,
19581da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19591da177e4SLinus Torvalds 		.mode		= 0644,
19606d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19611da177e4SLinus Torvalds 	},
19621da177e4SLinus Torvalds #endif
19630871420fSDavid S. Miller #ifdef CONFIG_SPARC64
19640871420fSDavid S. Miller 	{
19650871420fSDavid S. Miller 		.procname	= "tsb-ratio",
19660871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
19670871420fSDavid S. Miller 		.maxlen		= sizeof (int),
19680871420fSDavid S. Miller 		.mode		= 0644,
19696d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19700871420fSDavid S. Miller 	},
19710871420fSDavid S. Miller #endif
1972b67114dbSHelge Deller #ifdef CONFIG_PARISC
19731da177e4SLinus Torvalds 	{
19741da177e4SLinus Torvalds 		.procname	= "soft-power",
19751da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
19761da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19771da177e4SLinus Torvalds 		.mode		= 0644,
19786d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19791da177e4SLinus Torvalds 	},
1980bf14e3b9SVineet Gupta #endif
1981bf14e3b9SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
19821da177e4SLinus Torvalds 	{
19831da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
19841da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
19851da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
19861da177e4SLinus Torvalds 		.mode		= 0644,
19876d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19881da177e4SLinus Torvalds 	},
19891da177e4SLinus Torvalds #endif
19901da177e4SLinus Torvalds 	{
19911da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
19921da177e4SLinus Torvalds 		.data		= &C_A_D,
19931da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
19941da177e4SLinus Torvalds 		.mode		= 0644,
19956d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
19961da177e4SLinus Torvalds 	},
1997606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
1998b0fc494fSSteven Rostedt 	{
1999b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
2000b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
2001b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
2002b0fc494fSSteven Rostedt 		.mode		= 0644,
20036d456111SEric W. Biederman 		.proc_handler	= ftrace_enable_sysctl,
2004b0fc494fSSteven Rostedt 	},
2005b0fc494fSSteven Rostedt #endif
2006f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
2007f38f1d2aSSteven Rostedt 	{
2008f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
2009f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
2010f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
2011f38f1d2aSSteven Rostedt 		.mode		= 0644,
20126d456111SEric W. Biederman 		.proc_handler	= stack_trace_sysctl,
2013f38f1d2aSSteven Rostedt 	},
2014f38f1d2aSSteven Rostedt #endif
2015944ac425SSteven Rostedt #ifdef CONFIG_TRACING
2016944ac425SSteven Rostedt 	{
20173299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
2018944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
2019944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
2020944ac425SSteven Rostedt 		.mode		= 0644,
20216d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2022944ac425SSteven Rostedt 	},
2023de7edd31SSteven Rostedt (Red Hat) 	{
2024de7edd31SSteven Rostedt (Red Hat) 		.procname	= "traceoff_on_warning",
2025de7edd31SSteven Rostedt (Red Hat) 		.data		= &__disable_trace_on_warning,
2026de7edd31SSteven Rostedt (Red Hat) 		.maxlen		= sizeof(__disable_trace_on_warning),
2027de7edd31SSteven Rostedt (Red Hat) 		.mode		= 0644,
2028de7edd31SSteven Rostedt (Red Hat) 		.proc_handler	= proc_dointvec,
2029de7edd31SSteven Rostedt (Red Hat) 	},
20300daa2302SSteven Rostedt (Red Hat) 	{
20310daa2302SSteven Rostedt (Red Hat) 		.procname	= "tracepoint_printk",
20320daa2302SSteven Rostedt (Red Hat) 		.data		= &tracepoint_printk,
20330daa2302SSteven Rostedt (Red Hat) 		.maxlen		= sizeof(tracepoint_printk),
20340daa2302SSteven Rostedt (Red Hat) 		.mode		= 0644,
203542391745SSteven Rostedt (Red Hat) 		.proc_handler	= tracepoint_printk_sysctl,
20360daa2302SSteven Rostedt (Red Hat) 	},
2037944ac425SSteven Rostedt #endif
20382965faa5SDave Young #ifdef CONFIG_KEXEC_CORE
20397984754bSKees Cook 	{
20407984754bSKees Cook 		.procname	= "kexec_load_disabled",
20417984754bSKees Cook 		.data		= &kexec_load_disabled,
20427984754bSKees Cook 		.maxlen		= sizeof(int),
20437984754bSKees Cook 		.mode		= 0644,
20447984754bSKees Cook 		/* only handle a transition from default "0" to "1" */
20457984754bSKees Cook 		.proc_handler	= proc_dointvec_minmax,
2046eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2047eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
20487984754bSKees Cook 	},
20497984754bSKees Cook #endif
2050a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
20511da177e4SLinus Torvalds 	{
20521da177e4SLinus Torvalds 		.procname	= "modprobe",
20531da177e4SLinus Torvalds 		.data		= &modprobe_path,
20541da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
20551da177e4SLinus Torvalds 		.mode		= 0644,
20566d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
20571da177e4SLinus Torvalds 	},
20583d43321bSKees Cook 	{
20593d43321bSKees Cook 		.procname	= "modules_disabled",
20603d43321bSKees Cook 		.data		= &modules_disabled,
20613d43321bSKees Cook 		.maxlen		= sizeof(int),
20623d43321bSKees Cook 		.mode		= 0644,
20633d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
20646d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2065eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2066eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
20673d43321bSKees Cook 	},
20681da177e4SLinus Torvalds #endif
206986d56134SMichael Marineau #ifdef CONFIG_UEVENT_HELPER
20701da177e4SLinus Torvalds 	{
20711da177e4SLinus Torvalds 		.procname	= "hotplug",
2072312c004dSKay Sievers 		.data		= &uevent_helper,
2073312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
20741da177e4SLinus Torvalds 		.mode		= 0644,
20756d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
20761da177e4SLinus Torvalds 	},
207786d56134SMichael Marineau #endif
20781da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
20791da177e4SLinus Torvalds 	{
20801da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
20811da177e4SLinus Torvalds 		.data		= &sg_big_buff,
20821da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
20831da177e4SLinus Torvalds 		.mode		= 0444,
20846d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
20851da177e4SLinus Torvalds 	},
20861da177e4SLinus Torvalds #endif
20871da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
20881da177e4SLinus Torvalds 	{
20891da177e4SLinus Torvalds 		.procname	= "acct",
20901da177e4SLinus Torvalds 		.data		= &acct_parm,
20911da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
20921da177e4SLinus Torvalds 		.mode		= 0644,
20936d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
20941da177e4SLinus Torvalds 	},
20951da177e4SLinus Torvalds #endif
20961da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
20971da177e4SLinus Torvalds 	{
20981da177e4SLinus Torvalds 		.procname	= "sysrq",
2099eaee4172SDmitry Safonov 		.data		= NULL,
21001da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
21011da177e4SLinus Torvalds 		.mode		= 0644,
210297f5f0cdSDmitry Torokhov 		.proc_handler	= sysrq_sysctl_handler,
21031da177e4SLinus Torvalds 	},
21041da177e4SLinus Torvalds #endif
2105d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
21061da177e4SLinus Torvalds 	{
21071da177e4SLinus Torvalds 		.procname	= "cad_pid",
21089ec52099SCedric Le Goater 		.data		= NULL,
21091da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
21101da177e4SLinus Torvalds 		.mode		= 0600,
21116d456111SEric W. Biederman 		.proc_handler	= proc_do_cad_pid,
21121da177e4SLinus Torvalds 	},
2113d6f8ff73SRandy Dunlap #endif
21141da177e4SLinus Torvalds 	{
21151da177e4SLinus Torvalds 		.procname	= "threads-max",
211616db3d3fSHeinrich Schuchardt 		.data		= NULL,
21171da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21181da177e4SLinus Torvalds 		.mode		= 0644,
211916db3d3fSHeinrich Schuchardt 		.proc_handler	= sysctl_max_threads,
21201da177e4SLinus Torvalds 	},
21211da177e4SLinus Torvalds 	{
21221da177e4SLinus Torvalds 		.procname	= "random",
21231da177e4SLinus Torvalds 		.mode		= 0555,
21241da177e4SLinus Torvalds 		.child		= random_table,
21251da177e4SLinus Torvalds 	},
21261da177e4SLinus Torvalds 	{
212717f60a7dSEric Paris 		.procname	= "usermodehelper",
212817f60a7dSEric Paris 		.mode		= 0555,
212917f60a7dSEric Paris 		.child		= usermodehelper_table,
213017f60a7dSEric Paris 	},
2131ceb18132SLuis R. Rodriguez #ifdef CONFIG_FW_LOADER_USER_HELPER
2132ceb18132SLuis R. Rodriguez 	{
2133ceb18132SLuis R. Rodriguez 		.procname	= "firmware_config",
2134ceb18132SLuis R. Rodriguez 		.mode		= 0555,
2135ceb18132SLuis R. Rodriguez 		.child		= firmware_config_table,
2136ceb18132SLuis R. Rodriguez 	},
2137ceb18132SLuis R. Rodriguez #endif
213817f60a7dSEric Paris 	{
21391da177e4SLinus Torvalds 		.procname	= "overflowuid",
21401da177e4SLinus Torvalds 		.data		= &overflowuid,
21411da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21421da177e4SLinus Torvalds 		.mode		= 0644,
21436d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
21441da177e4SLinus Torvalds 		.extra1		= &minolduid,
21451da177e4SLinus Torvalds 		.extra2		= &maxolduid,
21461da177e4SLinus Torvalds 	},
21471da177e4SLinus Torvalds 	{
21481da177e4SLinus Torvalds 		.procname	= "overflowgid",
21491da177e4SLinus Torvalds 		.data		= &overflowgid,
21501da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21511da177e4SLinus Torvalds 		.mode		= 0644,
21526d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
21531da177e4SLinus Torvalds 		.extra1		= &minolduid,
21541da177e4SLinus Torvalds 		.extra2		= &maxolduid,
21551da177e4SLinus Torvalds 	},
2156347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
21571da177e4SLinus Torvalds 	{
21581da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
2159ab3c68eeSHeiko Carstens 		.data		= &show_unhandled_signals,
21601da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21611da177e4SLinus Torvalds 		.mode		= 0644,
21626d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
21631da177e4SLinus Torvalds 	},
21641da177e4SLinus Torvalds #endif
216560c958d8SGuilherme G. Piccoli #ifdef CONFIG_SMP
216660c958d8SGuilherme G. Piccoli 	{
216760c958d8SGuilherme G. Piccoli 		.procname	= "oops_all_cpu_backtrace",
216860c958d8SGuilherme G. Piccoli 		.data		= &sysctl_oops_all_cpu_backtrace,
216960c958d8SGuilherme G. Piccoli 		.maxlen		= sizeof(int),
217060c958d8SGuilherme G. Piccoli 		.mode		= 0644,
217160c958d8SGuilherme G. Piccoli 		.proc_handler	= proc_dointvec_minmax,
217260c958d8SGuilherme G. Piccoli 		.extra1		= SYSCTL_ZERO,
217360c958d8SGuilherme G. Piccoli 		.extra2		= SYSCTL_ONE,
217460c958d8SGuilherme G. Piccoli 	},
217560c958d8SGuilherme G. Piccoli #endif /* CONFIG_SMP */
21761da177e4SLinus Torvalds 	{
21771da177e4SLinus Torvalds 		.procname	= "pid_max",
21781da177e4SLinus Torvalds 		.data		= &pid_max,
21791da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
21801da177e4SLinus Torvalds 		.mode		= 0644,
21816d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
21821da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
21831da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
21841da177e4SLinus Torvalds 	},
21851da177e4SLinus Torvalds 	{
21861da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
21871da177e4SLinus Torvalds 		.data		= &panic_on_oops,
21881da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
21891da177e4SLinus Torvalds 		.mode		= 0644,
21906d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
21911da177e4SLinus Torvalds 	},
219281c9d43fSFeng Tang 	{
219381c9d43fSFeng Tang 		.procname	= "panic_print",
219481c9d43fSFeng Tang 		.data		= &panic_print,
219581c9d43fSFeng Tang 		.maxlen		= sizeof(unsigned long),
219681c9d43fSFeng Tang 		.mode		= 0644,
219781c9d43fSFeng Tang 		.proc_handler	= proc_doulongvec_minmax,
219881c9d43fSFeng Tang 	},
21997ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
22007ef3d2fdSJoe Perches 	{
22017ef3d2fdSJoe Perches 		.procname	= "printk",
22027ef3d2fdSJoe Perches 		.data		= &console_loglevel,
22037ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
22047ef3d2fdSJoe Perches 		.mode		= 0644,
22056d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22067ef3d2fdSJoe Perches 	},
22071da177e4SLinus Torvalds 	{
22081da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
2209717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
22101da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
22111da177e4SLinus Torvalds 		.mode		= 0644,
22126d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
22131da177e4SLinus Torvalds 	},
22141da177e4SLinus Torvalds 	{
22151da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
2216717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
22171da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
22181da177e4SLinus Torvalds 		.mode		= 0644,
22196d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22201da177e4SLinus Torvalds 	},
2221af91322eSDave Young 	{
2222af91322eSDave Young 		.procname	= "printk_delay",
2223af91322eSDave Young 		.data		= &printk_delay_msec,
2224af91322eSDave Young 		.maxlen		= sizeof(int),
2225af91322eSDave Young 		.mode		= 0644,
22266d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2227eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2228af91322eSDave Young 		.extra2		= &ten_thousand,
2229af91322eSDave Young 	},
22301da177e4SLinus Torvalds 	{
2231750afe7bSBorislav Petkov 		.procname	= "printk_devkmsg",
2232750afe7bSBorislav Petkov 		.data		= devkmsg_log_str,
2233750afe7bSBorislav Petkov 		.maxlen		= DEVKMSG_STR_MAX_SIZE,
2234750afe7bSBorislav Petkov 		.mode		= 0644,
2235750afe7bSBorislav Petkov 		.proc_handler	= devkmsg_sysctl_set_loglvl,
2236750afe7bSBorislav Petkov 	},
2237750afe7bSBorislav Petkov 	{
2238eaf06b24SDan Rosenberg 		.procname	= "dmesg_restrict",
2239eaf06b24SDan Rosenberg 		.data		= &dmesg_restrict,
2240eaf06b24SDan Rosenberg 		.maxlen		= sizeof(int),
2241eaf06b24SDan Rosenberg 		.mode		= 0644,
2242620f6e8eSKees Cook 		.proc_handler	= proc_dointvec_minmax_sysadmin,
2243eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2244eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2245eaf06b24SDan Rosenberg 	},
2246455cd5abSDan Rosenberg 	{
2247455cd5abSDan Rosenberg 		.procname	= "kptr_restrict",
2248455cd5abSDan Rosenberg 		.data		= &kptr_restrict,
2249455cd5abSDan Rosenberg 		.maxlen		= sizeof(int),
2250455cd5abSDan Rosenberg 		.mode		= 0644,
2251620f6e8eSKees Cook 		.proc_handler	= proc_dointvec_minmax_sysadmin,
2252eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2253455cd5abSDan Rosenberg 		.extra2		= &two,
2254455cd5abSDan Rosenberg 	},
2255df6e61d4SJoe Perches #endif
2256eaf06b24SDan Rosenberg 	{
22571da177e4SLinus Torvalds 		.procname	= "ngroups_max",
22581da177e4SLinus Torvalds 		.data		= &ngroups_max,
22591da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
22601da177e4SLinus Torvalds 		.mode		= 0444,
22616d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
22621da177e4SLinus Torvalds 	},
226373efc039SDan Ballard 	{
226473efc039SDan Ballard 		.procname	= "cap_last_cap",
226573efc039SDan Ballard 		.data		= (void *)&cap_last_cap,
226673efc039SDan Ballard 		.maxlen		= sizeof(int),
226773efc039SDan Ballard 		.mode		= 0444,
226873efc039SDan Ballard 		.proc_handler	= proc_dointvec,
226973efc039SDan Ballard 	},
227058687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR)
2271504d7cf1SDon Zickus 	{
227258687acbSDon Zickus 		.procname       = "watchdog",
22733c00ea82SFrederic Weisbecker 		.data		= &watchdog_user_enabled,
2274504d7cf1SDon Zickus 		.maxlen		= sizeof(int),
2275504d7cf1SDon Zickus 		.mode		= 0644,
2276195daf66SUlrich Obergfell 		.proc_handler   = proc_watchdog,
2277eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2278eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
227958687acbSDon Zickus 	},
228058687acbSDon Zickus 	{
228158687acbSDon Zickus 		.procname	= "watchdog_thresh",
2282586692a5SMandeep Singh Baines 		.data		= &watchdog_thresh,
228358687acbSDon Zickus 		.maxlen		= sizeof(int),
228458687acbSDon Zickus 		.mode		= 0644,
2285195daf66SUlrich Obergfell 		.proc_handler	= proc_watchdog_thresh,
2286eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
228758687acbSDon Zickus 		.extra2		= &sixty,
2288504d7cf1SDon Zickus 	},
22892508ce18SDon Zickus 	{
2290195daf66SUlrich Obergfell 		.procname       = "nmi_watchdog",
22917feeb9cdSThomas Gleixner 		.data		= &nmi_watchdog_user_enabled,
2292195daf66SUlrich Obergfell 		.maxlen		= sizeof(int),
229351d4052bSThomas Gleixner 		.mode		= NMI_WATCHDOG_SYSCTL_PERM,
2294195daf66SUlrich Obergfell 		.proc_handler   = proc_nmi_watchdog,
2295eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2296eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2297195daf66SUlrich Obergfell 	},
2298195daf66SUlrich Obergfell 	{
229905a4a952SNicholas Piggin 		.procname	= "watchdog_cpumask",
230005a4a952SNicholas Piggin 		.data		= &watchdog_cpumask_bits,
230105a4a952SNicholas Piggin 		.maxlen		= NR_CPUS,
230205a4a952SNicholas Piggin 		.mode		= 0644,
230305a4a952SNicholas Piggin 		.proc_handler	= proc_watchdog_cpumask,
230405a4a952SNicholas Piggin 	},
230505a4a952SNicholas Piggin #ifdef CONFIG_SOFTLOCKUP_DETECTOR
230605a4a952SNicholas Piggin 	{
2307195daf66SUlrich Obergfell 		.procname       = "soft_watchdog",
23087feeb9cdSThomas Gleixner 		.data		= &soft_watchdog_user_enabled,
2309195daf66SUlrich Obergfell 		.maxlen		= sizeof(int),
2310195daf66SUlrich Obergfell 		.mode		= 0644,
2311195daf66SUlrich Obergfell 		.proc_handler   = proc_soft_watchdog,
2312eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2313eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2314195daf66SUlrich Obergfell 	},
2315195daf66SUlrich Obergfell 	{
23162508ce18SDon Zickus 		.procname	= "softlockup_panic",
23172508ce18SDon Zickus 		.data		= &softlockup_panic,
23182508ce18SDon Zickus 		.maxlen		= sizeof(int),
23192508ce18SDon Zickus 		.mode		= 0644,
23202508ce18SDon Zickus 		.proc_handler	= proc_dointvec_minmax,
2321eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2322eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
23232508ce18SDon Zickus 	},
2324ed235875SAaron Tomlin #ifdef CONFIG_SMP
2325ed235875SAaron Tomlin 	{
2326ed235875SAaron Tomlin 		.procname	= "softlockup_all_cpu_backtrace",
2327ed235875SAaron Tomlin 		.data		= &sysctl_softlockup_all_cpu_backtrace,
2328ed235875SAaron Tomlin 		.maxlen		= sizeof(int),
2329ed235875SAaron Tomlin 		.mode		= 0644,
2330ed235875SAaron Tomlin 		.proc_handler	= proc_dointvec_minmax,
2331eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2332eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2333ed235875SAaron Tomlin 	},
233405a4a952SNicholas Piggin #endif /* CONFIG_SMP */
233505a4a952SNicholas Piggin #endif
233605a4a952SNicholas Piggin #ifdef CONFIG_HARDLOCKUP_DETECTOR
233705a4a952SNicholas Piggin 	{
233805a4a952SNicholas Piggin 		.procname	= "hardlockup_panic",
233905a4a952SNicholas Piggin 		.data		= &hardlockup_panic,
234005a4a952SNicholas Piggin 		.maxlen		= sizeof(int),
234105a4a952SNicholas Piggin 		.mode		= 0644,
234205a4a952SNicholas Piggin 		.proc_handler	= proc_dointvec_minmax,
2343eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2344eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
234505a4a952SNicholas Piggin 	},
234605a4a952SNicholas Piggin #ifdef CONFIG_SMP
234755537871SJiri Kosina 	{
234855537871SJiri Kosina 		.procname	= "hardlockup_all_cpu_backtrace",
234955537871SJiri Kosina 		.data		= &sysctl_hardlockup_all_cpu_backtrace,
235055537871SJiri Kosina 		.maxlen		= sizeof(int),
235155537871SJiri Kosina 		.mode		= 0644,
235255537871SJiri Kosina 		.proc_handler	= proc_dointvec_minmax,
2353eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2354eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
235555537871SJiri Kosina 	},
2356ed235875SAaron Tomlin #endif /* CONFIG_SMP */
23575dc30558SDon Zickus #endif
235805a4a952SNicholas Piggin #endif
235905a4a952SNicholas Piggin 
23605dc30558SDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
23615dc30558SDon Zickus 	{
23625dc30558SDon Zickus 		.procname       = "unknown_nmi_panic",
23635dc30558SDon Zickus 		.data           = &unknown_nmi_panic,
23645dc30558SDon Zickus 		.maxlen         = sizeof (int),
23655dc30558SDon Zickus 		.mode           = 0644,
23665dc30558SDon Zickus 		.proc_handler   = proc_dointvec,
23675dc30558SDon Zickus 	},
2368504d7cf1SDon Zickus #endif
2369b6522fa4SXiaoming Ni 
2370b6522fa4SXiaoming Ni #if (defined(CONFIG_X86_32) || defined(CONFIG_PARISC)) && \
2371b6522fa4SXiaoming Ni 	defined(CONFIG_DEBUG_STACKOVERFLOW)
2372b6522fa4SXiaoming Ni 	{
2373b6522fa4SXiaoming Ni 		.procname	= "panic_on_stackoverflow",
2374b6522fa4SXiaoming Ni 		.data		= &sysctl_panic_on_stackoverflow,
2375b6522fa4SXiaoming Ni 		.maxlen		= sizeof(int),
2376b6522fa4SXiaoming Ni 		.mode		= 0644,
2377b6522fa4SXiaoming Ni 		.proc_handler	= proc_dointvec,
2378b6522fa4SXiaoming Ni 	},
2379b6522fa4SXiaoming Ni #endif
23801da177e4SLinus Torvalds #if defined(CONFIG_X86)
23811da177e4SLinus Torvalds 	{
23828da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
23838da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
23848da5addaSDon Zickus 		.maxlen		= sizeof(int),
23858da5addaSDon Zickus 		.mode		= 0644,
23866d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
23878da5addaSDon Zickus 	},
23888da5addaSDon Zickus 	{
23895211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
23905211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
23915211a242SKurt Garloff 		.maxlen		= sizeof(int),
23925211a242SKurt Garloff 		.mode		= 0644,
23936d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
23945211a242SKurt Garloff 	},
23955211a242SKurt Garloff 	{
23961da177e4SLinus Torvalds 		.procname	= "bootloader_type",
23971da177e4SLinus Torvalds 		.data		= &bootloader_type,
23981da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
23991da177e4SLinus Torvalds 		.mode		= 0444,
24006d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24011da177e4SLinus Torvalds 	},
24020741f4d2SChuck Ebbert 	{
24035031296cSH. Peter Anvin 		.procname	= "bootloader_version",
24045031296cSH. Peter Anvin 		.data		= &bootloader_version,
24055031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
24065031296cSH. Peter Anvin 		.mode		= 0444,
24076d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24085031296cSH. Peter Anvin 	},
24095031296cSH. Peter Anvin 	{
24106e7c4025SIngo Molnar 		.procname	= "io_delay_type",
24116e7c4025SIngo Molnar 		.data		= &io_delay_type,
24126e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
24136e7c4025SIngo Molnar 		.mode		= 0644,
24146d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24156e7c4025SIngo Molnar 	},
24161da177e4SLinus Torvalds #endif
24177a9166e3SLuke Yang #if defined(CONFIG_MMU)
24181da177e4SLinus Torvalds 	{
24191da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
24201da177e4SLinus Torvalds 		.data		= &randomize_va_space,
24211da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
24221da177e4SLinus Torvalds 		.mode		= 0644,
24236d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
24241da177e4SLinus Torvalds 	},
24257a9166e3SLuke Yang #endif
24260152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
2427951f22d5SMartin Schwidefsky 	{
2428951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
2429951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
2430951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
2431951f22d5SMartin Schwidefsky 		.mode		= 0644,
24326d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2433951f22d5SMartin Schwidefsky 	},
2434951f22d5SMartin Schwidefsky #endif
2435673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
2436c255d844SPavel Machek 	{
2437c255d844SPavel Machek 		.procname	= "acpi_video_flags",
243877afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
2439c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
2440c255d844SPavel Machek 		.mode		= 0644,
24416d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
2442c255d844SPavel Machek 	},
2443c255d844SPavel Machek #endif
2444b6fca725SVineet Gupta #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
2445d2b176edSJes Sorensen 	{
2446d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
2447d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
2448d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
2449d2b176edSJes Sorensen 		.mode		= 0644,
24506d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2451d2b176edSJes Sorensen 	},
2452b6fca725SVineet Gupta #endif
2453b6fca725SVineet Gupta #ifdef CONFIG_IA64
245488fc241fSDoug Chapman 	{
245588fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
245688fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
245788fc241fSDoug Chapman 		.maxlen		= sizeof (int),
245888fc241fSDoug Chapman 		.mode		= 0644,
24596d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
246088fc241fSDoug Chapman 	},
2461d2b176edSJes Sorensen #endif
2462e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
24630ec9dc9bSGuilherme G. Piccoli #ifdef CONFIG_SMP
24640ec9dc9bSGuilherme G. Piccoli 	{
24650ec9dc9bSGuilherme G. Piccoli 		.procname	= "hung_task_all_cpu_backtrace",
24660ec9dc9bSGuilherme G. Piccoli 		.data		= &sysctl_hung_task_all_cpu_backtrace,
24670ec9dc9bSGuilherme G. Piccoli 		.maxlen		= sizeof(int),
24680ec9dc9bSGuilherme G. Piccoli 		.mode		= 0644,
24690ec9dc9bSGuilherme G. Piccoli 		.proc_handler	= proc_dointvec_minmax,
24700ec9dc9bSGuilherme G. Piccoli 		.extra1		= SYSCTL_ZERO,
24710ec9dc9bSGuilherme G. Piccoli 		.extra2		= SYSCTL_ONE,
24720ec9dc9bSGuilherme G. Piccoli 	},
24730ec9dc9bSGuilherme G. Piccoli #endif /* CONFIG_SMP */
2474e162b39aSMandeep Singh Baines 	{
2475e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
2476e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
2477e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
2478e162b39aSMandeep Singh Baines 		.mode		= 0644,
24796d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2480eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2481eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2482e162b39aSMandeep Singh Baines 	},
248382a1fcb9SIngo Molnar 	{
248482a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
248582a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
2486cd64647fSLi Zefan 		.maxlen		= sizeof(int),
248782a1fcb9SIngo Molnar 		.mode		= 0644,
2488cd64647fSLi Zefan 		.proc_handler	= proc_dointvec_minmax,
2489eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
249082a1fcb9SIngo Molnar 	},
249182a1fcb9SIngo Molnar 	{
249282a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
249382a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
249490739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
249582a1fcb9SIngo Molnar 		.mode		= 0644,
24966d456111SEric W. Biederman 		.proc_handler	= proc_dohung_task_timeout_secs,
249780df2847SLiu Hua 		.extra2		= &hung_task_timeout_max,
249882a1fcb9SIngo Molnar 	},
249982a1fcb9SIngo Molnar 	{
2500a2e51445SDmitry Vyukov 		.procname	= "hung_task_check_interval_secs",
2501a2e51445SDmitry Vyukov 		.data		= &sysctl_hung_task_check_interval_secs,
2502a2e51445SDmitry Vyukov 		.maxlen		= sizeof(unsigned long),
2503a2e51445SDmitry Vyukov 		.mode		= 0644,
2504a2e51445SDmitry Vyukov 		.proc_handler	= proc_dohung_task_timeout_secs,
2505a2e51445SDmitry Vyukov 		.extra2		= &hung_task_timeout_max,
2506a2e51445SDmitry Vyukov 	},
2507a2e51445SDmitry Vyukov 	{
250882a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
250982a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
2510270750dbSAaron Tomlin 		.maxlen		= sizeof(int),
251182a1fcb9SIngo Molnar 		.mode		= 0644,
2512270750dbSAaron Tomlin 		.proc_handler	= proc_dointvec_minmax,
2513270750dbSAaron Tomlin 		.extra1		= &neg_one,
251482a1fcb9SIngo Molnar 	},
2515c4f3b63fSRavikiran G Thirumalai #endif
251623f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
251723f78d4aSIngo Molnar 	{
251823f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
251923f78d4aSIngo Molnar 		.data		= &max_lock_depth,
252023f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
252123f78d4aSIngo Molnar 		.mode		= 0644,
25226d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
252323f78d4aSIngo Molnar 	},
252423f78d4aSIngo Molnar #endif
252510a0a8d4SJeremy Fitzhardinge 	{
252610a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
252710a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
252810a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
252910a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
25306d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
253110a0a8d4SJeremy Fitzhardinge 	},
25320b77f5bfSDavid Howells #ifdef CONFIG_KEYS
25330b77f5bfSDavid Howells 	{
25340b77f5bfSDavid Howells 		.procname	= "keys",
25350b77f5bfSDavid Howells 		.mode		= 0555,
25360b77f5bfSDavid Howells 		.child		= key_sysctls,
25370b77f5bfSDavid Howells 	},
25380b77f5bfSDavid Howells #endif
2539cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS
2540aa4a2218SVince Weaver 	/*
2541aa4a2218SVince Weaver 	 * User-space scripts rely on the existence of this file
2542aa4a2218SVince Weaver 	 * as a feature check for perf_events being enabled.
2543aa4a2218SVince Weaver 	 *
2544aa4a2218SVince Weaver 	 * So it's an ABI, do not remove!
2545aa4a2218SVince Weaver 	 */
25461ccd1549SPeter Zijlstra 	{
2547cdd6c482SIngo Molnar 		.procname	= "perf_event_paranoid",
2548cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_paranoid,
2549cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_paranoid),
25501ccd1549SPeter Zijlstra 		.mode		= 0644,
25516d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
25521ccd1549SPeter Zijlstra 	},
2553c5078f78SPeter Zijlstra 	{
2554cdd6c482SIngo Molnar 		.procname	= "perf_event_mlock_kb",
2555cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_mlock,
2556cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_mlock),
2557c5078f78SPeter Zijlstra 		.mode		= 0644,
25586d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2559c5078f78SPeter Zijlstra 	},
2560a78ac325SPeter Zijlstra 	{
2561cdd6c482SIngo Molnar 		.procname	= "perf_event_max_sample_rate",
2562cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_sample_rate,
2563cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
2564a78ac325SPeter Zijlstra 		.mode		= 0644,
2565163ec435SPeter Zijlstra 		.proc_handler	= perf_proc_update_handler,
2566eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2567a78ac325SPeter Zijlstra 	},
256814c63f17SDave Hansen 	{
256914c63f17SDave Hansen 		.procname	= "perf_cpu_time_max_percent",
257014c63f17SDave Hansen 		.data		= &sysctl_perf_cpu_time_max_percent,
257114c63f17SDave Hansen 		.maxlen		= sizeof(sysctl_perf_cpu_time_max_percent),
257214c63f17SDave Hansen 		.mode		= 0644,
257314c63f17SDave Hansen 		.proc_handler	= perf_cpu_time_max_percent_handler,
2574eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
257514c63f17SDave Hansen 		.extra2		= &one_hundred,
257614c63f17SDave Hansen 	},
2577c5dfd78eSArnaldo Carvalho de Melo 	{
2578c5dfd78eSArnaldo Carvalho de Melo 		.procname	= "perf_event_max_stack",
2579a831100aSArnaldo Carvalho de Melo 		.data		= &sysctl_perf_event_max_stack,
2580c5dfd78eSArnaldo Carvalho de Melo 		.maxlen		= sizeof(sysctl_perf_event_max_stack),
2581c5dfd78eSArnaldo Carvalho de Melo 		.mode		= 0644,
2582c5dfd78eSArnaldo Carvalho de Melo 		.proc_handler	= perf_event_max_stack_handler,
2583eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2584c5dfd78eSArnaldo Carvalho de Melo 		.extra2		= &six_hundred_forty_kb,
2585c5dfd78eSArnaldo Carvalho de Melo 	},
2586c85b0334SArnaldo Carvalho de Melo 	{
2587c85b0334SArnaldo Carvalho de Melo 		.procname	= "perf_event_max_contexts_per_stack",
2588c85b0334SArnaldo Carvalho de Melo 		.data		= &sysctl_perf_event_max_contexts_per_stack,
2589c85b0334SArnaldo Carvalho de Melo 		.maxlen		= sizeof(sysctl_perf_event_max_contexts_per_stack),
2590c85b0334SArnaldo Carvalho de Melo 		.mode		= 0644,
2591c85b0334SArnaldo Carvalho de Melo 		.proc_handler	= perf_event_max_stack_handler,
2592eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2593c85b0334SArnaldo Carvalho de Melo 		.extra2		= &one_thousand,
2594c85b0334SArnaldo Carvalho de Melo 	},
25951ccd1549SPeter Zijlstra #endif
25969e3961a0SPrarit Bhargava 	{
25979e3961a0SPrarit Bhargava 		.procname	= "panic_on_warn",
25989e3961a0SPrarit Bhargava 		.data		= &panic_on_warn,
25999e3961a0SPrarit Bhargava 		.maxlen		= sizeof(int),
26009e3961a0SPrarit Bhargava 		.mode		= 0644,
26019e3961a0SPrarit Bhargava 		.proc_handler	= proc_dointvec_minmax,
2602eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2603eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
26049e3961a0SPrarit Bhargava 	},
2605bc7a34b8SThomas Gleixner #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
2606bc7a34b8SThomas Gleixner 	{
2607bc7a34b8SThomas Gleixner 		.procname	= "timer_migration",
2608bc7a34b8SThomas Gleixner 		.data		= &sysctl_timer_migration,
2609bc7a34b8SThomas Gleixner 		.maxlen		= sizeof(unsigned int),
2610bc7a34b8SThomas Gleixner 		.mode		= 0644,
2611bc7a34b8SThomas Gleixner 		.proc_handler	= timer_migration_handler,
2612eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2613eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2614bc7a34b8SThomas Gleixner 	},
2615bc7a34b8SThomas Gleixner #endif
26161be7f75dSAlexei Starovoitov #ifdef CONFIG_BPF_SYSCALL
26171be7f75dSAlexei Starovoitov 	{
26181be7f75dSAlexei Starovoitov 		.procname	= "unprivileged_bpf_disabled",
26191be7f75dSAlexei Starovoitov 		.data		= &sysctl_unprivileged_bpf_disabled,
26201be7f75dSAlexei Starovoitov 		.maxlen		= sizeof(sysctl_unprivileged_bpf_disabled),
26211be7f75dSAlexei Starovoitov 		.mode		= 0644,
262208389d88SDaniel Borkmann 		.proc_handler	= bpf_unpriv_handler,
262308389d88SDaniel Borkmann 		.extra1		= SYSCTL_ZERO,
262408389d88SDaniel Borkmann 		.extra2		= &two,
26251be7f75dSAlexei Starovoitov 	},
2626492ecee8SAlexei Starovoitov 	{
2627492ecee8SAlexei Starovoitov 		.procname	= "bpf_stats_enabled",
2628a8e11e5cSEric Dumazet 		.data		= &bpf_stats_enabled_key.key,
2629a8e11e5cSEric Dumazet 		.maxlen		= sizeof(bpf_stats_enabled_key),
2630492ecee8SAlexei Starovoitov 		.mode		= 0644,
2631d46edd67SSong Liu 		.proc_handler	= bpf_stats_handler,
2632492ecee8SAlexei Starovoitov 	},
26333fcc5530SAlexei Starovoitov #endif
2634b3e627d3SLai Jiangshan #if defined(CONFIG_TREE_RCU)
2635088e9d25SDaniel Bristot de Oliveira 	{
2636088e9d25SDaniel Bristot de Oliveira 		.procname	= "panic_on_rcu_stall",
2637088e9d25SDaniel Bristot de Oliveira 		.data		= &sysctl_panic_on_rcu_stall,
2638088e9d25SDaniel Bristot de Oliveira 		.maxlen		= sizeof(sysctl_panic_on_rcu_stall),
2639088e9d25SDaniel Bristot de Oliveira 		.mode		= 0644,
2640088e9d25SDaniel Bristot de Oliveira 		.proc_handler	= proc_dointvec_minmax,
2641eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2642eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2643088e9d25SDaniel Bristot de Oliveira 	},
2644088e9d25SDaniel Bristot de Oliveira #endif
2645dfe56404Schao #if defined(CONFIG_TREE_RCU)
2646dfe56404Schao 	{
2647dfe56404Schao 		.procname	= "max_rcu_stall_to_panic",
2648dfe56404Schao 		.data		= &sysctl_max_rcu_stall_to_panic,
2649dfe56404Schao 		.maxlen		= sizeof(sysctl_max_rcu_stall_to_panic),
2650dfe56404Schao 		.mode		= 0644,
2651dfe56404Schao 		.proc_handler	= proc_dointvec_minmax,
2652dfe56404Schao 		.extra1		= SYSCTL_ONE,
2653dfe56404Schao 		.extra2		= SYSCTL_INT_MAX,
2654dfe56404Schao 	},
2655dfe56404Schao #endif
2656964c9dffSAlexander Popov #ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
2657964c9dffSAlexander Popov 	{
2658964c9dffSAlexander Popov 		.procname	= "stack_erasing",
2659964c9dffSAlexander Popov 		.data		= NULL,
2660964c9dffSAlexander Popov 		.maxlen		= sizeof(int),
2661964c9dffSAlexander Popov 		.mode		= 0600,
2662964c9dffSAlexander Popov 		.proc_handler	= stack_erasing_sysctl,
2663eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2664eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
2665964c9dffSAlexander Popov 	},
2666964c9dffSAlexander Popov #endif
26676fce56ecSEric W. Biederman 	{ }
26681da177e4SLinus Torvalds };
26691da177e4SLinus Torvalds 
2670d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
26711da177e4SLinus Torvalds 	{
26721da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
26731da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
26741da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
26751da177e4SLinus Torvalds 		.mode		= 0644,
267656f3547bSFeng Tang 		.proc_handler	= overcommit_policy_handler,
2677eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2678cb16e95fSPetr Holasek 		.extra2		= &two,
26791da177e4SLinus Torvalds 	},
26801da177e4SLinus Torvalds 	{
2681fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
2682fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
2683fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
2684fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
2685cb16e95fSPetr Holasek 		.proc_handler	= proc_dointvec_minmax,
2686eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2687cb16e95fSPetr Holasek 		.extra2		= &two,
2688fadd8fbdSKAMEZAWA Hiroyuki 	},
2689fadd8fbdSKAMEZAWA Hiroyuki 	{
2690fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
2691fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
2692fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
2693fe071d7eSDavid Rientjes 		.mode		= 0644,
26946d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2695fe071d7eSDavid Rientjes 	},
2696fe071d7eSDavid Rientjes 	{
2697fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
2698fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
2699fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
2700fef1bdd6SDavid Rientjes 		.mode		= 0644,
27016d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2702fef1bdd6SDavid Rientjes 	},
2703fef1bdd6SDavid Rientjes 	{
27041da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
27051da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
27061da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
27071da177e4SLinus Torvalds 		.mode		= 0644,
270849f0ce5fSJerome Marchand 		.proc_handler	= overcommit_ratio_handler,
270949f0ce5fSJerome Marchand 	},
271049f0ce5fSJerome Marchand 	{
271149f0ce5fSJerome Marchand 		.procname	= "overcommit_kbytes",
271249f0ce5fSJerome Marchand 		.data		= &sysctl_overcommit_kbytes,
271349f0ce5fSJerome Marchand 		.maxlen		= sizeof(sysctl_overcommit_kbytes),
271449f0ce5fSJerome Marchand 		.mode		= 0644,
271549f0ce5fSJerome Marchand 		.proc_handler	= overcommit_kbytes_handler,
27161da177e4SLinus Torvalds 	},
27171da177e4SLinus Torvalds 	{
27181da177e4SLinus Torvalds 		.procname	= "page-cluster",
27191da177e4SLinus Torvalds 		.data		= &page_cluster,
27201da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
27211da177e4SLinus Torvalds 		.mode		= 0644,
2722cb16e95fSPetr Holasek 		.proc_handler	= proc_dointvec_minmax,
2723eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27241da177e4SLinus Torvalds 	},
27251da177e4SLinus Torvalds 	{
27261da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
27271da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
27281da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
27291da177e4SLinus Torvalds 		.mode		= 0644,
27306d456111SEric W. Biederman 		.proc_handler	= dirty_background_ratio_handler,
2731eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27321da177e4SLinus Torvalds 		.extra2		= &one_hundred,
27331da177e4SLinus Torvalds 	},
27341da177e4SLinus Torvalds 	{
27352da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
27362da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
27372da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
27382da02997SDavid Rientjes 		.mode		= 0644,
27396d456111SEric W. Biederman 		.proc_handler	= dirty_background_bytes_handler,
2740fc3501d4SSven Wegener 		.extra1		= &one_ul,
27412da02997SDavid Rientjes 	},
27422da02997SDavid Rientjes 	{
27431da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
27441da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
27451da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
27461da177e4SLinus Torvalds 		.mode		= 0644,
27476d456111SEric W. Biederman 		.proc_handler	= dirty_ratio_handler,
2748eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27491da177e4SLinus Torvalds 		.extra2		= &one_hundred,
27501da177e4SLinus Torvalds 	},
27511da177e4SLinus Torvalds 	{
27522da02997SDavid Rientjes 		.procname	= "dirty_bytes",
27532da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
27542da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
27552da02997SDavid Rientjes 		.mode		= 0644,
27566d456111SEric W. Biederman 		.proc_handler	= dirty_bytes_handler,
27579e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
27582da02997SDavid Rientjes 	},
27592da02997SDavid Rientjes 	{
27601da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
2761f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
2762f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
27631da177e4SLinus Torvalds 		.mode		= 0644,
27646d456111SEric W. Biederman 		.proc_handler	= dirty_writeback_centisecs_handler,
27651da177e4SLinus Torvalds 	},
27661da177e4SLinus Torvalds 	{
27671da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
2768f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
2769f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
27701da177e4SLinus Torvalds 		.mode		= 0644,
2771cb16e95fSPetr Holasek 		.proc_handler	= proc_dointvec_minmax,
2772eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27731da177e4SLinus Torvalds 	},
27741da177e4SLinus Torvalds 	{
27751efff914STheodore Ts'o 		.procname	= "dirtytime_expire_seconds",
27761efff914STheodore Ts'o 		.data		= &dirtytime_expire_interval,
27772d87b309SRandy Dunlap 		.maxlen		= sizeof(dirtytime_expire_interval),
27781efff914STheodore Ts'o 		.mode		= 0644,
27791efff914STheodore Ts'o 		.proc_handler	= dirtytime_interval_handler,
2780eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
27811efff914STheodore Ts'o 	},
27821efff914STheodore Ts'o 	{
27831da177e4SLinus Torvalds 		.procname	= "swappiness",
27841da177e4SLinus Torvalds 		.data		= &vm_swappiness,
27851da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
27861da177e4SLinus Torvalds 		.mode		= 0644,
27876d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2788eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2789c843966cSJohannes Weiner 		.extra2		= &two_hundred,
27901da177e4SLinus Torvalds 	},
27911da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
27921da177e4SLinus Torvalds 	{
27931da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
2794e5ff2159SAndi Kleen 		.data		= NULL,
27951da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
27961da177e4SLinus Torvalds 		.mode		= 0644,
27976d456111SEric W. Biederman 		.proc_handler	= hugetlb_sysctl_handler,
27981da177e4SLinus Torvalds 	},
279906808b08SLee Schermerhorn #ifdef CONFIG_NUMA
280006808b08SLee Schermerhorn 	{
280106808b08SLee Schermerhorn 		.procname       = "nr_hugepages_mempolicy",
280206808b08SLee Schermerhorn 		.data           = NULL,
280306808b08SLee Schermerhorn 		.maxlen         = sizeof(unsigned long),
280406808b08SLee Schermerhorn 		.mode           = 0644,
280506808b08SLee Schermerhorn 		.proc_handler   = &hugetlb_mempolicy_sysctl_handler,
280606808b08SLee Schermerhorn 	},
28074518085eSKemi Wang 	{
28084518085eSKemi Wang 		.procname		= "numa_stat",
28094518085eSKemi Wang 		.data			= &sysctl_vm_numa_stat,
28104518085eSKemi Wang 		.maxlen			= sizeof(int),
28114518085eSKemi Wang 		.mode			= 0644,
28124518085eSKemi Wang 		.proc_handler	= sysctl_vm_numa_stat_handler,
2813eec4844fSMatteo Croce 		.extra1			= SYSCTL_ZERO,
2814eec4844fSMatteo Croce 		.extra2			= SYSCTL_ONE,
28154518085eSKemi Wang 	},
281606808b08SLee Schermerhorn #endif
28171da177e4SLinus Torvalds 	 {
28181da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
28191da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
28201da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
28211da177e4SLinus Torvalds 		.mode		= 0644,
28226d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
28231da177e4SLinus Torvalds 	 },
2824396faf03SMel Gorman 	{
2825d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
2826e5ff2159SAndi Kleen 		.data		= NULL,
2827e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
2828d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
28296d456111SEric W. Biederman 		.proc_handler	= hugetlb_overcommit_handler,
2830d1c3fb1fSNishanth Aravamudan 	},
28311da177e4SLinus Torvalds #endif
28321da177e4SLinus Torvalds 	{
28331da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
28341da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
28351da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
28361da177e4SLinus Torvalds 		.mode		= 0644,
28376d456111SEric W. Biederman 		.proc_handler	= lowmem_reserve_ratio_sysctl_handler,
28381da177e4SLinus Torvalds 	},
28391da177e4SLinus Torvalds 	{
28409d0243bcSAndrew Morton 		.procname	= "drop_caches",
28419d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
28429d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
2843204cb79aSJohannes Weiner 		.mode		= 0200,
28449d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
2845eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
28465509a5d2SDave Hansen 		.extra2		= &four,
28479d0243bcSAndrew Morton 	},
284876ab0f53SMel Gorman #ifdef CONFIG_COMPACTION
284976ab0f53SMel Gorman 	{
285076ab0f53SMel Gorman 		.procname	= "compact_memory",
2851ef498438SPintu Kumar 		.data		= NULL,
285276ab0f53SMel Gorman 		.maxlen		= sizeof(int),
285376ab0f53SMel Gorman 		.mode		= 0200,
285476ab0f53SMel Gorman 		.proc_handler	= sysctl_compaction_handler,
285576ab0f53SMel Gorman 	},
28565e771905SMel Gorman 	{
2857facdaa91SNitin Gupta 		.procname	= "compaction_proactiveness",
2858facdaa91SNitin Gupta 		.data		= &sysctl_compaction_proactiveness,
2859d34c0a75SNitin Gupta 		.maxlen		= sizeof(sysctl_compaction_proactiveness),
2860facdaa91SNitin Gupta 		.mode		= 0644,
2861facdaa91SNitin Gupta 		.proc_handler	= proc_dointvec_minmax,
2862facdaa91SNitin Gupta 		.extra1		= SYSCTL_ZERO,
2863facdaa91SNitin Gupta 		.extra2		= &one_hundred,
2864facdaa91SNitin Gupta 	},
2865facdaa91SNitin Gupta 	{
28665e771905SMel Gorman 		.procname	= "extfrag_threshold",
28675e771905SMel Gorman 		.data		= &sysctl_extfrag_threshold,
28685e771905SMel Gorman 		.maxlen		= sizeof(int),
28695e771905SMel Gorman 		.mode		= 0644,
28706b7e5cadSMatthew Wilcox 		.proc_handler	= proc_dointvec_minmax,
28715e771905SMel Gorman 		.extra1		= &min_extfrag_threshold,
28725e771905SMel Gorman 		.extra2		= &max_extfrag_threshold,
28735e771905SMel Gorman 	},
28745bbe3547SEric B Munson 	{
28755bbe3547SEric B Munson 		.procname	= "compact_unevictable_allowed",
28765bbe3547SEric B Munson 		.data		= &sysctl_compact_unevictable_allowed,
28775bbe3547SEric B Munson 		.maxlen		= sizeof(int),
28785bbe3547SEric B Munson 		.mode		= 0644,
28796923aa0dSSebastian Andrzej Siewior 		.proc_handler	= proc_dointvec_minmax_warn_RT_change,
2880eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2881eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
28825bbe3547SEric B Munson 	},
28835e771905SMel Gorman 
288476ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */
28859d0243bcSAndrew Morton 	{
28861da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
28871da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
28881da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
28891da177e4SLinus Torvalds 		.mode		= 0644,
28906d456111SEric W. Biederman 		.proc_handler	= min_free_kbytes_sysctl_handler,
2891eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
28921da177e4SLinus Torvalds 	},
28938ad4b1fbSRohit Seth 	{
28941c30844dSMel Gorman 		.procname	= "watermark_boost_factor",
28951c30844dSMel Gorman 		.data		= &watermark_boost_factor,
28961c30844dSMel Gorman 		.maxlen		= sizeof(watermark_boost_factor),
28971c30844dSMel Gorman 		.mode		= 0644,
289826363af5SChristoph Hellwig 		.proc_handler	= proc_dointvec_minmax,
2899eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29001c30844dSMel Gorman 	},
29011c30844dSMel Gorman 	{
2902795ae7a0SJohannes Weiner 		.procname	= "watermark_scale_factor",
2903795ae7a0SJohannes Weiner 		.data		= &watermark_scale_factor,
2904795ae7a0SJohannes Weiner 		.maxlen		= sizeof(watermark_scale_factor),
2905795ae7a0SJohannes Weiner 		.mode		= 0644,
2906795ae7a0SJohannes Weiner 		.proc_handler	= watermark_scale_factor_sysctl_handler,
2907eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
2908795ae7a0SJohannes Weiner 		.extra2		= &one_thousand,
2909795ae7a0SJohannes Weiner 	},
2910795ae7a0SJohannes Weiner 	{
291174f44822SMel Gorman 		.procname	= "percpu_pagelist_high_fraction",
291274f44822SMel Gorman 		.data		= &percpu_pagelist_high_fraction,
291374f44822SMel Gorman 		.maxlen		= sizeof(percpu_pagelist_high_fraction),
291474f44822SMel Gorman 		.mode		= 0644,
291574f44822SMel Gorman 		.proc_handler	= percpu_pagelist_high_fraction_sysctl_handler,
291674f44822SMel Gorman 		.extra1		= SYSCTL_ZERO,
291774f44822SMel Gorman 	},
291874f44822SMel Gorman 	{
29195ef64cc8SLinus Torvalds 		.procname	= "page_lock_unfairness",
29205ef64cc8SLinus Torvalds 		.data		= &sysctl_page_lock_unfairness,
29215ef64cc8SLinus Torvalds 		.maxlen		= sizeof(sysctl_page_lock_unfairness),
29225ef64cc8SLinus Torvalds 		.mode		= 0644,
29235ef64cc8SLinus Torvalds 		.proc_handler	= proc_dointvec_minmax,
29245ef64cc8SLinus Torvalds 		.extra1		= SYSCTL_ZERO,
29255ef64cc8SLinus Torvalds 	},
29261da177e4SLinus Torvalds #ifdef CONFIG_MMU
29271da177e4SLinus Torvalds 	{
29281da177e4SLinus Torvalds 		.procname	= "max_map_count",
29291da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
29301da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
29311da177e4SLinus Torvalds 		.mode		= 0644,
29323e26120cSWANG Cong 		.proc_handler	= proc_dointvec_minmax,
2933eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29341da177e4SLinus Torvalds 	},
2935dd8632a1SPaul Mundt #else
2936dd8632a1SPaul Mundt 	{
2937dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
2938dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
2939dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
2940dd8632a1SPaul Mundt 		.mode		= 0644,
29416d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
2942eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
2943dd8632a1SPaul Mundt 	},
29441da177e4SLinus Torvalds #endif
29451da177e4SLinus Torvalds 	{
29461da177e4SLinus Torvalds 		.procname	= "laptop_mode",
29471da177e4SLinus Torvalds 		.data		= &laptop_mode,
29481da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
29491da177e4SLinus Torvalds 		.mode		= 0644,
29506d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
29511da177e4SLinus Torvalds 	},
29521da177e4SLinus Torvalds 	{
29531da177e4SLinus Torvalds 		.procname	= "block_dump",
29541da177e4SLinus Torvalds 		.data		= &block_dump,
29551da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
29561da177e4SLinus Torvalds 		.mode		= 0644,
29573b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2958eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29591da177e4SLinus Torvalds 	},
29601da177e4SLinus Torvalds 	{
29611da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
29621da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
29631da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
29641da177e4SLinus Torvalds 		.mode		= 0644,
29653b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2966eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29671da177e4SLinus Torvalds 	},
296867f3977fSAlexandre Ghiti #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \
296967f3977fSAlexandre Ghiti     defined(CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT)
29701da177e4SLinus Torvalds 	{
29711da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
29721da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
29731da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
29741da177e4SLinus Torvalds 		.mode		= 0644,
29753b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2976eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29771da177e4SLinus Torvalds 	},
29781da177e4SLinus Torvalds #endif
29791743660bSChristoph Lameter #ifdef CONFIG_NUMA
29801743660bSChristoph Lameter 	{
29811743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
2982a5f5f91dSMel Gorman 		.data		= &node_reclaim_mode,
2983a5f5f91dSMel Gorman 		.maxlen		= sizeof(node_reclaim_mode),
29841743660bSChristoph Lameter 		.mode		= 0644,
29853b3376f2SLin Feng 		.proc_handler	= proc_dointvec_minmax,
2986eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29871743660bSChristoph Lameter 	},
29889614634fSChristoph Lameter 	{
29899614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
29909614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
29919614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
29929614634fSChristoph Lameter 		.mode		= 0644,
29936d456111SEric W. Biederman 		.proc_handler	= sysctl_min_unmapped_ratio_sysctl_handler,
2994eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
29959614634fSChristoph Lameter 		.extra2		= &one_hundred,
29969614634fSChristoph Lameter 	},
29970ff38490SChristoph Lameter 	{
29980ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
29990ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
30000ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
30010ff38490SChristoph Lameter 		.mode		= 0644,
30026d456111SEric W. Biederman 		.proc_handler	= sysctl_min_slab_ratio_sysctl_handler,
3003eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
30040ff38490SChristoph Lameter 		.extra2		= &one_hundred,
30050ff38490SChristoph Lameter 	},
30061743660bSChristoph Lameter #endif
300777461ab3SChristoph Lameter #ifdef CONFIG_SMP
300877461ab3SChristoph Lameter 	{
300977461ab3SChristoph Lameter 		.procname	= "stat_interval",
301077461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
301177461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
301277461ab3SChristoph Lameter 		.mode		= 0644,
30136d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
301477461ab3SChristoph Lameter 	},
301552b6f46bSHugh Dickins 	{
301652b6f46bSHugh Dickins 		.procname	= "stat_refresh",
301752b6f46bSHugh Dickins 		.data		= NULL,
301852b6f46bSHugh Dickins 		.maxlen		= 0,
301952b6f46bSHugh Dickins 		.mode		= 0600,
302052b6f46bSHugh Dickins 		.proc_handler	= vmstat_refresh,
302152b6f46bSHugh Dickins 	},
302277461ab3SChristoph Lameter #endif
30236e141546SDavid Howells #ifdef CONFIG_MMU
3024ed032189SEric Paris 	{
3025ed032189SEric Paris 		.procname	= "mmap_min_addr",
3026788084abSEric Paris 		.data		= &dac_mmap_min_addr,
3027ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
3028ed032189SEric Paris 		.mode		= 0644,
30296d456111SEric W. Biederman 		.proc_handler	= mmap_min_addr_handler,
3030ed032189SEric Paris 	},
30316e141546SDavid Howells #endif
3032f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
3033f0c0b2b8SKAMEZAWA Hiroyuki 	{
3034f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
3035f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
3036f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
3037f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
30386d456111SEric W. Biederman 		.proc_handler	= numa_zonelist_order_handler,
3039f0c0b2b8SKAMEZAWA Hiroyuki 	},
3040f0c0b2b8SKAMEZAWA Hiroyuki #endif
30412b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
30425c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
3043e6e5494cSIngo Molnar 	{
3044e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
30453d7ee969SAndy Lutomirski #ifdef CONFIG_X86_32
30463d7ee969SAndy Lutomirski 		.data		= &vdso32_enabled,
30473d7ee969SAndy Lutomirski 		.maxlen		= sizeof(vdso32_enabled),
30483d7ee969SAndy Lutomirski #else
3049e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
3050e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
30513d7ee969SAndy Lutomirski #endif
3052e6e5494cSIngo Molnar 		.mode		= 0644,
30536d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3054eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3055e6e5494cSIngo Molnar 	},
3056e6e5494cSIngo Molnar #endif
3057195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
3058195cf453SBron Gondwana 	{
3059195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
3060195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
3061195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
3062195cf453SBron Gondwana 		.mode		= 0644,
30636d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3064eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3065eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3066195cf453SBron Gondwana 	},
3067195cf453SBron Gondwana #endif
30686a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE
30696a46079cSAndi Kleen 	{
30706a46079cSAndi Kleen 		.procname	= "memory_failure_early_kill",
30716a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_early_kill,
30726a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_early_kill),
30736a46079cSAndi Kleen 		.mode		= 0644,
30746d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3075eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3076eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
30776a46079cSAndi Kleen 	},
30786a46079cSAndi Kleen 	{
30796a46079cSAndi Kleen 		.procname	= "memory_failure_recovery",
30806a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_recovery,
30816a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_recovery),
30826a46079cSAndi Kleen 		.mode		= 0644,
30836d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3084eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3085eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
30866a46079cSAndi Kleen 	},
30876a46079cSAndi Kleen #endif
3088c9b1d098SAndrew Shewmaker 	{
3089c9b1d098SAndrew Shewmaker 		.procname	= "user_reserve_kbytes",
3090c9b1d098SAndrew Shewmaker 		.data		= &sysctl_user_reserve_kbytes,
3091c9b1d098SAndrew Shewmaker 		.maxlen		= sizeof(sysctl_user_reserve_kbytes),
3092c9b1d098SAndrew Shewmaker 		.mode		= 0644,
3093c9b1d098SAndrew Shewmaker 		.proc_handler	= proc_doulongvec_minmax,
3094c9b1d098SAndrew Shewmaker 	},
30954eeab4f5SAndrew Shewmaker 	{
30964eeab4f5SAndrew Shewmaker 		.procname	= "admin_reserve_kbytes",
30974eeab4f5SAndrew Shewmaker 		.data		= &sysctl_admin_reserve_kbytes,
30984eeab4f5SAndrew Shewmaker 		.maxlen		= sizeof(sysctl_admin_reserve_kbytes),
30994eeab4f5SAndrew Shewmaker 		.mode		= 0644,
31004eeab4f5SAndrew Shewmaker 		.proc_handler	= proc_doulongvec_minmax,
31014eeab4f5SAndrew Shewmaker 	},
3102d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
3103d07e2259SDaniel Cashman 	{
3104d07e2259SDaniel Cashman 		.procname	= "mmap_rnd_bits",
3105d07e2259SDaniel Cashman 		.data		= &mmap_rnd_bits,
3106d07e2259SDaniel Cashman 		.maxlen		= sizeof(mmap_rnd_bits),
3107d07e2259SDaniel Cashman 		.mode		= 0600,
3108d07e2259SDaniel Cashman 		.proc_handler	= proc_dointvec_minmax,
3109d07e2259SDaniel Cashman 		.extra1		= (void *)&mmap_rnd_bits_min,
3110d07e2259SDaniel Cashman 		.extra2		= (void *)&mmap_rnd_bits_max,
3111d07e2259SDaniel Cashman 	},
3112d07e2259SDaniel Cashman #endif
3113d07e2259SDaniel Cashman #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
3114d07e2259SDaniel Cashman 	{
3115d07e2259SDaniel Cashman 		.procname	= "mmap_rnd_compat_bits",
3116d07e2259SDaniel Cashman 		.data		= &mmap_rnd_compat_bits,
3117d07e2259SDaniel Cashman 		.maxlen		= sizeof(mmap_rnd_compat_bits),
3118d07e2259SDaniel Cashman 		.mode		= 0600,
3119d07e2259SDaniel Cashman 		.proc_handler	= proc_dointvec_minmax,
3120d07e2259SDaniel Cashman 		.extra1		= (void *)&mmap_rnd_compat_bits_min,
3121d07e2259SDaniel Cashman 		.extra2		= (void *)&mmap_rnd_compat_bits_max,
3122d07e2259SDaniel Cashman 	},
3123d07e2259SDaniel Cashman #endif
3124cefdca0aSPeter Xu #ifdef CONFIG_USERFAULTFD
3125cefdca0aSPeter Xu 	{
3126cefdca0aSPeter Xu 		.procname	= "unprivileged_userfaultfd",
3127cefdca0aSPeter Xu 		.data		= &sysctl_unprivileged_userfaultfd,
3128cefdca0aSPeter Xu 		.maxlen		= sizeof(sysctl_unprivileged_userfaultfd),
3129cefdca0aSPeter Xu 		.mode		= 0644,
3130cefdca0aSPeter Xu 		.proc_handler	= proc_dointvec_minmax,
3131eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3132eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3133cefdca0aSPeter Xu 	},
3134cefdca0aSPeter Xu #endif
31356fce56ecSEric W. Biederman 	{ }
31361da177e4SLinus Torvalds };
31371da177e4SLinus Torvalds 
3138d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
31391da177e4SLinus Torvalds 	{
31401da177e4SLinus Torvalds 		.procname	= "inode-nr",
31411da177e4SLinus Torvalds 		.data		= &inodes_stat,
31423942c07cSGlauber Costa 		.maxlen		= 2*sizeof(long),
31431da177e4SLinus Torvalds 		.mode		= 0444,
3144cffbc8aaSDave Chinner 		.proc_handler	= proc_nr_inodes,
31451da177e4SLinus Torvalds 	},
31461da177e4SLinus Torvalds 	{
31471da177e4SLinus Torvalds 		.procname	= "inode-state",
31481da177e4SLinus Torvalds 		.data		= &inodes_stat,
31493942c07cSGlauber Costa 		.maxlen		= 7*sizeof(long),
31501da177e4SLinus Torvalds 		.mode		= 0444,
3151cffbc8aaSDave Chinner 		.proc_handler	= proc_nr_inodes,
31521da177e4SLinus Torvalds 	},
31531da177e4SLinus Torvalds 	{
31541da177e4SLinus Torvalds 		.procname	= "file-nr",
31551da177e4SLinus Torvalds 		.data		= &files_stat,
3156518de9b3SEric Dumazet 		.maxlen		= sizeof(files_stat),
31571da177e4SLinus Torvalds 		.mode		= 0444,
31586d456111SEric W. Biederman 		.proc_handler	= proc_nr_files,
31591da177e4SLinus Torvalds 	},
31601da177e4SLinus Torvalds 	{
31611da177e4SLinus Torvalds 		.procname	= "file-max",
31621da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
3163518de9b3SEric Dumazet 		.maxlen		= sizeof(files_stat.max_files),
31641da177e4SLinus Torvalds 		.mode		= 0644,
3165518de9b3SEric Dumazet 		.proc_handler	= proc_doulongvec_minmax,
31669002b214SWill Deacon 		.extra1		= &zero_ul,
316732a5ad9cSChristian Brauner 		.extra2		= &long_max,
31681da177e4SLinus Torvalds 	},
31691da177e4SLinus Torvalds 	{
31709cfe015aSEric Dumazet 		.procname	= "nr_open",
31719cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
31729b80a184SAlexey Dobriyan 		.maxlen		= sizeof(unsigned int),
31739cfe015aSEric Dumazet 		.mode		= 0644,
31746d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3175eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
3176eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
31779cfe015aSEric Dumazet 	},
31789cfe015aSEric Dumazet 	{
31791da177e4SLinus Torvalds 		.procname	= "dentry-state",
31801da177e4SLinus Torvalds 		.data		= &dentry_stat,
31813942c07cSGlauber Costa 		.maxlen		= 6*sizeof(long),
31821da177e4SLinus Torvalds 		.mode		= 0444,
3183312d3ca8SChristoph Hellwig 		.proc_handler	= proc_nr_dentry,
31841da177e4SLinus Torvalds 	},
31851da177e4SLinus Torvalds 	{
31861da177e4SLinus Torvalds 		.procname	= "overflowuid",
31871da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
31881da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
31891da177e4SLinus Torvalds 		.mode		= 0644,
31906d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
31911da177e4SLinus Torvalds 		.extra1		= &minolduid,
31921da177e4SLinus Torvalds 		.extra2		= &maxolduid,
31931da177e4SLinus Torvalds 	},
31941da177e4SLinus Torvalds 	{
31951da177e4SLinus Torvalds 		.procname	= "overflowgid",
31961da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
31971da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
31981da177e4SLinus Torvalds 		.mode		= 0644,
31996d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
32001da177e4SLinus Torvalds 		.extra1		= &minolduid,
32011da177e4SLinus Torvalds 		.extra2		= &maxolduid,
32021da177e4SLinus Torvalds 	},
3203bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
32041da177e4SLinus Torvalds 	{
32051da177e4SLinus Torvalds 		.procname	= "leases-enable",
32061da177e4SLinus Torvalds 		.data		= &leases_enable,
32071da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32081da177e4SLinus Torvalds 		.mode		= 0644,
32096d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
32101da177e4SLinus Torvalds 	},
3211bfcd17a6SThomas Petazzoni #endif
32121da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
32131da177e4SLinus Torvalds 	{
32141da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
32151da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
32161da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32171da177e4SLinus Torvalds 		.mode		= 0644,
32186d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
32191da177e4SLinus Torvalds 	},
32201da177e4SLinus Torvalds #endif
32211da177e4SLinus Torvalds #ifdef CONFIG_MMU
3222bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
32231da177e4SLinus Torvalds 	{
32241da177e4SLinus Torvalds 		.procname	= "lease-break-time",
32251da177e4SLinus Torvalds 		.data		= &lease_break_time,
32261da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
32271da177e4SLinus Torvalds 		.mode		= 0644,
32286d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
32291da177e4SLinus Torvalds 	},
3230bfcd17a6SThomas Petazzoni #endif
3231ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
32321da177e4SLinus Torvalds 	{
32331da177e4SLinus Torvalds 		.procname	= "aio-nr",
32341da177e4SLinus Torvalds 		.data		= &aio_nr,
32351da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
32361da177e4SLinus Torvalds 		.mode		= 0444,
32376d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
32381da177e4SLinus Torvalds 	},
32391da177e4SLinus Torvalds 	{
32401da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
32411da177e4SLinus Torvalds 		.data		= &aio_max_nr,
32421da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
32431da177e4SLinus Torvalds 		.mode		= 0644,
32446d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
32451da177e4SLinus Torvalds 	},
3246ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
32472d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
32480399cb08SRobert Love 	{
32490399cb08SRobert Love 		.procname	= "inotify",
32500399cb08SRobert Love 		.mode		= 0555,
32510399cb08SRobert Love 		.child		= inotify_table,
32520399cb08SRobert Love 	},
32530399cb08SRobert Love #endif
32545b8fea65SAmir Goldstein #ifdef CONFIG_FANOTIFY
32555b8fea65SAmir Goldstein 	{
32565b8fea65SAmir Goldstein 		.procname	= "fanotify",
32575b8fea65SAmir Goldstein 		.mode		= 0555,
32585b8fea65SAmir Goldstein 		.child		= fanotify_table,
32595b8fea65SAmir Goldstein 	},
32605b8fea65SAmir Goldstein #endif
32617ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
32627ef9964eSDavide Libenzi 	{
32637ef9964eSDavide Libenzi 		.procname	= "epoll",
32647ef9964eSDavide Libenzi 		.mode		= 0555,
32657ef9964eSDavide Libenzi 		.child		= epoll_table,
32667ef9964eSDavide Libenzi 	},
32677ef9964eSDavide Libenzi #endif
32681da177e4SLinus Torvalds #endif
3269d6e71144SAlan Cox 	{
3270800179c9SKees Cook 		.procname	= "protected_symlinks",
3271800179c9SKees Cook 		.data		= &sysctl_protected_symlinks,
3272800179c9SKees Cook 		.maxlen		= sizeof(int),
3273800179c9SKees Cook 		.mode		= 0600,
3274800179c9SKees Cook 		.proc_handler	= proc_dointvec_minmax,
3275eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3276eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3277800179c9SKees Cook 	},
3278800179c9SKees Cook 	{
3279800179c9SKees Cook 		.procname	= "protected_hardlinks",
3280800179c9SKees Cook 		.data		= &sysctl_protected_hardlinks,
3281800179c9SKees Cook 		.maxlen		= sizeof(int),
3282800179c9SKees Cook 		.mode		= 0600,
3283800179c9SKees Cook 		.proc_handler	= proc_dointvec_minmax,
3284eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3285eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3286800179c9SKees Cook 	},
3287800179c9SKees Cook 	{
328830aba665SSalvatore Mesoraca 		.procname	= "protected_fifos",
328930aba665SSalvatore Mesoraca 		.data		= &sysctl_protected_fifos,
329030aba665SSalvatore Mesoraca 		.maxlen		= sizeof(int),
329130aba665SSalvatore Mesoraca 		.mode		= 0600,
329230aba665SSalvatore Mesoraca 		.proc_handler	= proc_dointvec_minmax,
3293eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
329430aba665SSalvatore Mesoraca 		.extra2		= &two,
329530aba665SSalvatore Mesoraca 	},
329630aba665SSalvatore Mesoraca 	{
329730aba665SSalvatore Mesoraca 		.procname	= "protected_regular",
329830aba665SSalvatore Mesoraca 		.data		= &sysctl_protected_regular,
329930aba665SSalvatore Mesoraca 		.maxlen		= sizeof(int),
330030aba665SSalvatore Mesoraca 		.mode		= 0600,
330130aba665SSalvatore Mesoraca 		.proc_handler	= proc_dointvec_minmax,
3302eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
330330aba665SSalvatore Mesoraca 		.extra2		= &two,
330430aba665SSalvatore Mesoraca 	},
330530aba665SSalvatore Mesoraca 	{
3306d6e71144SAlan Cox 		.procname	= "suid_dumpable",
3307d6e71144SAlan Cox 		.data		= &suid_dumpable,
3308d6e71144SAlan Cox 		.maxlen		= sizeof(int),
3309d6e71144SAlan Cox 		.mode		= 0644,
331054b50199SKees Cook 		.proc_handler	= proc_dointvec_minmax_coredump,
3311eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
33128e654fbaSMatthew Wilcox 		.extra2		= &two,
3313d6e71144SAlan Cox 	},
33142abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
33152abc26fcSEric W. Biederman 	{
33162abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
33172abc26fcSEric W. Biederman 		.mode		= 0555,
3318f9bd6733SEric W. Biederman 		.child		= sysctl_mount_point,
33192abc26fcSEric W. Biederman 	},
33202abc26fcSEric W. Biederman #endif
3321b492e95bSJens Axboe 	{
3322ff9da691SJens Axboe 		.procname	= "pipe-max-size",
3323ff9da691SJens Axboe 		.data		= &pipe_max_size,
332498159d97SJoe Lawrence 		.maxlen		= sizeof(pipe_max_size),
3325b492e95bSJens Axboe 		.mode		= 0644,
3326319e0a21SEric Biggers 		.proc_handler	= proc_dopipe_max_size,
3327b492e95bSJens Axboe 	},
3328759c0114SWilly Tarreau 	{
3329759c0114SWilly Tarreau 		.procname	= "pipe-user-pages-hard",
3330759c0114SWilly Tarreau 		.data		= &pipe_user_pages_hard,
3331759c0114SWilly Tarreau 		.maxlen		= sizeof(pipe_user_pages_hard),
3332759c0114SWilly Tarreau 		.mode		= 0644,
3333759c0114SWilly Tarreau 		.proc_handler	= proc_doulongvec_minmax,
3334759c0114SWilly Tarreau 	},
3335759c0114SWilly Tarreau 	{
3336759c0114SWilly Tarreau 		.procname	= "pipe-user-pages-soft",
3337759c0114SWilly Tarreau 		.data		= &pipe_user_pages_soft,
3338759c0114SWilly Tarreau 		.maxlen		= sizeof(pipe_user_pages_soft),
3339759c0114SWilly Tarreau 		.mode		= 0644,
3340759c0114SWilly Tarreau 		.proc_handler	= proc_doulongvec_minmax,
3341759c0114SWilly Tarreau 	},
3342d2921684SEric W. Biederman 	{
3343d2921684SEric W. Biederman 		.procname	= "mount-max",
3344d2921684SEric W. Biederman 		.data		= &sysctl_mount_max,
3345d2921684SEric W. Biederman 		.maxlen		= sizeof(unsigned int),
3346d2921684SEric W. Biederman 		.mode		= 0644,
3347d2921684SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
3348eec4844fSMatteo Croce 		.extra1		= SYSCTL_ONE,
3349d2921684SEric W. Biederman 	},
33506fce56ecSEric W. Biederman 	{ }
33511da177e4SLinus Torvalds };
33521da177e4SLinus Torvalds 
3353d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
33547ac57a89SCatalin Marinas #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
3355abd4f750SMasoud Asgharifard Sharbiani 	{
3356abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
3357abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
3358abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
3359abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
3360abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
3361abd4f750SMasoud Asgharifard Sharbiani 	},
3362abd4f750SMasoud Asgharifard Sharbiani #endif
3363b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES)
3364b2be84dfSMasami Hiramatsu 	{
3365b2be84dfSMasami Hiramatsu 		.procname	= "kprobes-optimization",
3366b2be84dfSMasami Hiramatsu 		.data		= &sysctl_kprobes_optimization,
3367b2be84dfSMasami Hiramatsu 		.maxlen		= sizeof(int),
3368b2be84dfSMasami Hiramatsu 		.mode		= 0644,
3369b2be84dfSMasami Hiramatsu 		.proc_handler	= proc_kprobes_optimization_handler,
3370eec4844fSMatteo Croce 		.extra1		= SYSCTL_ZERO,
3371eec4844fSMatteo Croce 		.extra2		= SYSCTL_ONE,
3372b2be84dfSMasami Hiramatsu 	},
3373b2be84dfSMasami Hiramatsu #endif
33746fce56ecSEric W. Biederman 	{ }
33751da177e4SLinus Torvalds };
33761da177e4SLinus Torvalds 
3377d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
33786fce56ecSEric W. Biederman 	{ }
33791da177e4SLinus Torvalds };
33801da177e4SLinus Torvalds 
3381f461d2dcSChristoph Hellwig static struct ctl_table sysctl_base_table[] = {
3382f461d2dcSChristoph Hellwig 	{
3383f461d2dcSChristoph Hellwig 		.procname	= "kernel",
3384f461d2dcSChristoph Hellwig 		.mode		= 0555,
3385f461d2dcSChristoph Hellwig 		.child		= kern_table,
3386f461d2dcSChristoph Hellwig 	},
3387f461d2dcSChristoph Hellwig 	{
3388f461d2dcSChristoph Hellwig 		.procname	= "vm",
3389f461d2dcSChristoph Hellwig 		.mode		= 0555,
3390f461d2dcSChristoph Hellwig 		.child		= vm_table,
3391f461d2dcSChristoph Hellwig 	},
3392f461d2dcSChristoph Hellwig 	{
3393f461d2dcSChristoph Hellwig 		.procname	= "fs",
3394f461d2dcSChristoph Hellwig 		.mode		= 0555,
3395f461d2dcSChristoph Hellwig 		.child		= fs_table,
3396f461d2dcSChristoph Hellwig 	},
3397f461d2dcSChristoph Hellwig 	{
3398f461d2dcSChristoph Hellwig 		.procname	= "debug",
3399f461d2dcSChristoph Hellwig 		.mode		= 0555,
3400f461d2dcSChristoph Hellwig 		.child		= debug_table,
3401f461d2dcSChristoph Hellwig 	},
3402f461d2dcSChristoph Hellwig 	{
3403f461d2dcSChristoph Hellwig 		.procname	= "dev",
3404f461d2dcSChristoph Hellwig 		.mode		= 0555,
3405f461d2dcSChristoph Hellwig 		.child		= dev_table,
3406f461d2dcSChristoph Hellwig 	},
3407f461d2dcSChristoph Hellwig 	{ }
3408f461d2dcSChristoph Hellwig };
3409f461d2dcSChristoph Hellwig 
3410de4e83bdSEric W. Biederman int __init sysctl_init(void)
3411330d57fbSAl Viro {
3412fd4b616bSSteven Rostedt 	struct ctl_table_header *hdr;
3413fd4b616bSSteven Rostedt 
3414fd4b616bSSteven Rostedt 	hdr = register_sysctl_table(sysctl_base_table);
3415fd4b616bSSteven Rostedt 	kmemleak_not_leak(hdr);
3416330d57fbSAl Viro 	return 0;
3417f7e6ced4SAl Viro }
3418b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
34191da177e4SLinus Torvalds /*
34201da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
34211da177e4SLinus Torvalds  * exception granted :-)
34221da177e4SLinus Torvalds  */
34231da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
3424e7d316a0SSubash Abhinov Kasiviswanathan EXPORT_SYMBOL(proc_douintvec);
34251da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
34261da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
342761d9b56aSLuis R. Rodriguez EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
34281da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
34291da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
34301da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
34311da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
34321da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
34330bc19985SStephen Suryaputra EXPORT_SYMBOL(proc_do_large_bitmap);
3434