xref: /openbmc/linux/kernel/sysctl.c (revision cffbc8aa334f55c9ed42d25202eb3ebf3a97c195)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * sysctl.c: General linux system control interface
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  * Begun 24 March 1995, Stephen Tweedie
51da177e4SLinus Torvalds  * Added /proc support, Dec 1995
61da177e4SLinus Torvalds  * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
71da177e4SLinus Torvalds  * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
81da177e4SLinus Torvalds  * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
91da177e4SLinus Torvalds  * Dynamic registration fixes, Stephen Tweedie.
101da177e4SLinus Torvalds  * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
111da177e4SLinus Torvalds  * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
121da177e4SLinus Torvalds  *  Horn.
131da177e4SLinus Torvalds  * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
141da177e4SLinus Torvalds  * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
151da177e4SLinus Torvalds  * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
161da177e4SLinus Torvalds  *  Wendling.
171da177e4SLinus Torvalds  * The list_for_each() macro wasn't appropriate for the sysctl loop.
181da177e4SLinus Torvalds  *  Removed it and replaced it with older style, 03/23/00, Bill Wendling
191da177e4SLinus Torvalds  */
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds #include <linux/module.h>
221da177e4SLinus Torvalds #include <linux/mm.h>
231da177e4SLinus Torvalds #include <linux/swap.h>
241da177e4SLinus Torvalds #include <linux/slab.h>
251da177e4SLinus Torvalds #include <linux/sysctl.h>
26d33ed52dSDave Young #include <linux/signal.h>
271da177e4SLinus Torvalds #include <linux/proc_fs.h>
2872c2d582SAndrew Morgan #include <linux/security.h>
291da177e4SLinus Torvalds #include <linux/ctype.h>
30dfec072eSVegard Nossum #include <linux/kmemcheck.h>
3162239ac2SAdrian Bunk #include <linux/fs.h>
321da177e4SLinus Torvalds #include <linux/init.h>
331da177e4SLinus Torvalds #include <linux/kernel.h>
340296b228SKay Sievers #include <linux/kobject.h>
3520380731SArnaldo Carvalho de Melo #include <linux/net.h>
361da177e4SLinus Torvalds #include <linux/sysrq.h>
371da177e4SLinus Torvalds #include <linux/highuid.h>
381da177e4SLinus Torvalds #include <linux/writeback.h>
393fff4c42SIngo Molnar #include <linux/ratelimit.h>
4076ab0f53SMel Gorman #include <linux/compaction.h>
411da177e4SLinus Torvalds #include <linux/hugetlb.h>
421da177e4SLinus Torvalds #include <linux/initrd.h>
430b77f5bfSDavid Howells #include <linux/key.h>
441da177e4SLinus Torvalds #include <linux/times.h>
451da177e4SLinus Torvalds #include <linux/limits.h>
461da177e4SLinus Torvalds #include <linux/dcache.h>
476e006701SAlexey Dobriyan #include <linux/dnotify.h>
481da177e4SLinus Torvalds #include <linux/syscalls.h>
49c748e134SAdrian Bunk #include <linux/vmstat.h>
50c255d844SPavel Machek #include <linux/nfs_fs.h>
51c255d844SPavel Machek #include <linux/acpi.h>
5210a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h>
53b0fc494fSSteven Rostedt #include <linux/ftrace.h>
54cdd6c482SIngo Molnar #include <linux/perf_event.h>
55b2be84dfSMasami Hiramatsu #include <linux/kprobes.h>
56b492e95bSJens Axboe #include <linux/pipe_fs_i.h>
578e4228e1SDavid Rientjes #include <linux/oom.h>
581da177e4SLinus Torvalds 
591da177e4SLinus Torvalds #include <asm/uaccess.h>
601da177e4SLinus Torvalds #include <asm/processor.h>
611da177e4SLinus Torvalds 
6229cbc78bSAndi Kleen #ifdef CONFIG_X86
6329cbc78bSAndi Kleen #include <asm/nmi.h>
640741f4d2SChuck Ebbert #include <asm/stacktrace.h>
656e7c4025SIngo Molnar #include <asm/io.h>
6629cbc78bSAndi Kleen #endif
67c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT
68c55b7c3eSDave Young #include <linux/acct.h>
69c55b7c3eSDave Young #endif
704f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES
714f0e056fSDave Young #include <linux/rtmutex.h>
724f0e056fSDave Young #endif
732edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
742edf5e49SDave Young #include <linux/lockdep.h>
752edf5e49SDave Young #endif
7615485a46SDave Young #ifdef CONFIG_CHR_DEV_SG
7715485a46SDave Young #include <scsi/sg.h>
7815485a46SDave Young #endif
7929cbc78bSAndi Kleen 
8058687acbSDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR
81504d7cf1SDon Zickus #include <linux/nmi.h>
82504d7cf1SDon Zickus #endif
83504d7cf1SDon Zickus 
847058cb02SEric W. Biederman 
851da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL)
861da177e4SLinus Torvalds 
871da177e4SLinus Torvalds /* External variables not in a header file. */
881da177e4SLinus Torvalds extern int sysctl_overcommit_memory;
891da177e4SLinus Torvalds extern int sysctl_overcommit_ratio;
901da177e4SLinus Torvalds extern int max_threads;
911da177e4SLinus Torvalds extern int core_uses_pid;
92d6e71144SAlan Cox extern int suid_dumpable;
931da177e4SLinus Torvalds extern char core_pattern[];
94a293980cSNeil Horman extern unsigned int core_pipe_limit;
951da177e4SLinus Torvalds extern int pid_max;
961da177e4SLinus Torvalds extern int min_free_kbytes;
971da177e4SLinus Torvalds extern int pid_max_min, pid_max_max;
989d0243bcSAndrew Morton extern int sysctl_drop_caches;
998ad4b1fbSRohit Seth extern int percpu_pagelist_fraction;
100bebfa101SAndi Kleen extern int compat_log;
1019745512cSArjan van de Ven extern int latencytop_enabled;
102eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max;
103dd8632a1SPaul Mundt #ifndef CONFIG_MMU
104dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages;
105dd8632a1SPaul Mundt #endif
106cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
1075e605b64SJens Axboe extern int blk_iopoll_enabled;
108cb684b5bSJens Axboe #endif
1091da177e4SLinus Torvalds 
110c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and  maximum */
1112508ce18SDon Zickus #ifdef CONFIG_LOCKUP_DETECTOR
112c4f3b63fSRavikiran G Thirumalai static int sixty = 60;
1139383d967SDimitri Sivanich static int neg_one = -1;
114c4f3b63fSRavikiran G Thirumalai #endif
115c4f3b63fSRavikiran G Thirumalai 
116c4f3b63fSRavikiran G Thirumalai static int zero;
117cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1;
118cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2;
119fc3501d4SSven Wegener static unsigned long one_ul = 1;
120c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100;
121af91322eSDave Young #ifdef CONFIG_PRINTK
122af91322eSDave Young static int ten_thousand = 10000;
123af91322eSDave Young #endif
124c4f3b63fSRavikiran G Thirumalai 
1259e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
1269e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1279e4a5bdaSAndrea Righi 
1281da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1291da177e4SLinus Torvalds static int maxolduid = 65535;
1301da177e4SLinus Torvalds static int minolduid;
1318ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8;
1321da177e4SLinus Torvalds 
1331da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
1341da177e4SLinus Torvalds 
135d14f1729SDave Young #ifdef CONFIG_INOTIFY_USER
136d14f1729SDave Young #include <linux/inotify.h>
137d14f1729SDave Young #endif
13872c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
13917f04fbbSDavid S. Miller #include <asm/system.h>
1401da177e4SLinus Torvalds #endif
1411da177e4SLinus Torvalds 
1420871420fSDavid S. Miller #ifdef CONFIG_SPARC64
1430871420fSDavid S. Miller extern int sysctl_tsb_ratio;
1440871420fSDavid S. Miller #endif
1450871420fSDavid S. Miller 
1461da177e4SLinus Torvalds #ifdef __hppa__
1471da177e4SLinus Torvalds extern int pwrsw_enabled;
1481da177e4SLinus Torvalds extern int unaligned_enabled;
1491da177e4SLinus Torvalds #endif
1501da177e4SLinus Torvalds 
151347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
1521da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
1531da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings;
1541da177e4SLinus Torvalds #endif
1551da177e4SLinus Torvalds extern int sysctl_userprocess_debug;
156951f22d5SMartin Schwidefsky extern int spin_retry;
1571da177e4SLinus Torvalds #endif
1581da177e4SLinus Torvalds 
159d2b176edSJes Sorensen #ifdef CONFIG_IA64
160d2b176edSJes Sorensen extern int no_unaligned_warning;
16188fc241fSDoug Chapman extern int unaligned_dump_stack;
162d2b176edSJes Sorensen #endif
163d2b176edSJes Sorensen 
1643fff4c42SIngo Molnar extern struct ratelimit_state printk_ratelimit_state;
1653fff4c42SIngo Molnar 
166d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
1678d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write,
1689ec52099SCedric Le Goater 		  void __user *buffer, size_t *lenp, loff_t *ppos);
1698d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write,
17034f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos);
171d6f8ff73SRandy Dunlap #endif
1729ec52099SCedric Le Goater 
17397f5f0cdSDmitry Torokhov #ifdef CONFIG_MAGIC_SYSRQ
17497f5f0cdSDmitry Torokhov static int __sysrq_enabled; /* Note: sysrq code ises it's own private copy */
17597f5f0cdSDmitry Torokhov 
17697f5f0cdSDmitry Torokhov static int sysrq_sysctl_handler(ctl_table *table, int write,
17797f5f0cdSDmitry Torokhov 				void __user *buffer, size_t *lenp,
17897f5f0cdSDmitry Torokhov 				loff_t *ppos)
17997f5f0cdSDmitry Torokhov {
18097f5f0cdSDmitry Torokhov 	int error;
18197f5f0cdSDmitry Torokhov 
18297f5f0cdSDmitry Torokhov 	error = proc_dointvec(table, write, buffer, lenp, ppos);
18397f5f0cdSDmitry Torokhov 	if (error)
18497f5f0cdSDmitry Torokhov 		return error;
18597f5f0cdSDmitry Torokhov 
18697f5f0cdSDmitry Torokhov 	if (write)
18797f5f0cdSDmitry Torokhov 		sysrq_toggle_support(__sysrq_enabled);
18897f5f0cdSDmitry Torokhov 
18997f5f0cdSDmitry Torokhov 	return 0;
19097f5f0cdSDmitry Torokhov }
19197f5f0cdSDmitry Torokhov 
19297f5f0cdSDmitry Torokhov #endif
19397f5f0cdSDmitry Torokhov 
194d8217f07SEric W. Biederman static struct ctl_table root_table[];
195e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root;
196e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = {
197b380b0d4SAl Viro 	.count = 1,
198e51b6ba0SEric W. Biederman 	.ctl_table = root_table,
19973455092SAl Viro 	.ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
200e51b6ba0SEric W. Biederman 	.root = &sysctl_table_root,
20173455092SAl Viro 	.set = &sysctl_table_root.default_set,
202e51b6ba0SEric W. Biederman };
203e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = {
204e51b6ba0SEric W. Biederman 	.root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
20573455092SAl Viro 	.default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
206e51b6ba0SEric W. Biederman };
2071da177e4SLinus Torvalds 
208d8217f07SEric W. Biederman static struct ctl_table kern_table[];
209d8217f07SEric W. Biederman static struct ctl_table vm_table[];
210d8217f07SEric W. Biederman static struct ctl_table fs_table[];
211d8217f07SEric W. Biederman static struct ctl_table debug_table[];
212d8217f07SEric W. Biederman static struct ctl_table dev_table[];
213d8217f07SEric W. Biederman extern struct ctl_table random_table[];
2147ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
2157ef9964eSDavide Libenzi extern struct ctl_table epoll_table[];
2167ef9964eSDavide Libenzi #endif
2171da177e4SLinus Torvalds 
2181da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
2191da177e4SLinus Torvalds int sysctl_legacy_va_layout;
2201da177e4SLinus Torvalds #endif
2211da177e4SLinus Torvalds 
2221da177e4SLinus Torvalds /* The default sysctl tables: */
2231da177e4SLinus Torvalds 
224d8217f07SEric W. Biederman static struct ctl_table root_table[] = {
2251da177e4SLinus Torvalds 	{
2261da177e4SLinus Torvalds 		.procname	= "kernel",
2271da177e4SLinus Torvalds 		.mode		= 0555,
2281da177e4SLinus Torvalds 		.child		= kern_table,
2291da177e4SLinus Torvalds 	},
2301da177e4SLinus Torvalds 	{
2311da177e4SLinus Torvalds 		.procname	= "vm",
2321da177e4SLinus Torvalds 		.mode		= 0555,
2331da177e4SLinus Torvalds 		.child		= vm_table,
2341da177e4SLinus Torvalds 	},
2351da177e4SLinus Torvalds 	{
2361da177e4SLinus Torvalds 		.procname	= "fs",
2371da177e4SLinus Torvalds 		.mode		= 0555,
2381da177e4SLinus Torvalds 		.child		= fs_table,
2391da177e4SLinus Torvalds 	},
2401da177e4SLinus Torvalds 	{
2411da177e4SLinus Torvalds 		.procname	= "debug",
2421da177e4SLinus Torvalds 		.mode		= 0555,
2431da177e4SLinus Torvalds 		.child		= debug_table,
2441da177e4SLinus Torvalds 	},
2451da177e4SLinus Torvalds 	{
2461da177e4SLinus Torvalds 		.procname	= "dev",
2471da177e4SLinus Torvalds 		.mode		= 0555,
2481da177e4SLinus Torvalds 		.child		= dev_table,
2491da177e4SLinus Torvalds 	},
2502be7fe07SAndrew Morton /*
2512be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
2522be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
2532be7fe07SAndrew Morton  */
2546fce56ecSEric W. Biederman 	{ }
2551da177e4SLinus Torvalds };
2561da177e4SLinus Torvalds 
25777e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
25873c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000;		/* 100 usecs */
25973c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
26073c4efd2SEric Dumazet static int min_wakeup_granularity_ns;			/* 0 usecs */
26173c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
2621983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
2631983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
264acb4a848SChristian Ehrhardt static int min_sched_shares_ratelimit = 100000; /* 100 usec */
265acb4a848SChristian Ehrhardt static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
26677e54a1fSIngo Molnar #endif
26777e54a1fSIngo Molnar 
2685e771905SMel Gorman #ifdef CONFIG_COMPACTION
2695e771905SMel Gorman static int min_extfrag_threshold;
2705e771905SMel Gorman static int max_extfrag_threshold = 1000;
2715e771905SMel Gorman #endif
2725e771905SMel Gorman 
273d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
2742bba22c5SMike Galbraith 	{
2752bba22c5SMike Galbraith 		.procname	= "sched_child_runs_first",
2762bba22c5SMike Galbraith 		.data		= &sysctl_sched_child_runs_first,
2772bba22c5SMike Galbraith 		.maxlen		= sizeof(unsigned int),
2782bba22c5SMike Galbraith 		.mode		= 0644,
2796d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2802bba22c5SMike Galbraith 	},
28177e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
28277e54a1fSIngo Molnar 	{
283b2be5e96SPeter Zijlstra 		.procname	= "sched_min_granularity_ns",
284b2be5e96SPeter Zijlstra 		.data		= &sysctl_sched_min_granularity,
28577e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
28677e54a1fSIngo Molnar 		.mode		= 0644,
287702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
288b2be5e96SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
289b2be5e96SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
29077e54a1fSIngo Molnar 	},
29177e54a1fSIngo Molnar 	{
29221805085SPeter Zijlstra 		.procname	= "sched_latency_ns",
29321805085SPeter Zijlstra 		.data		= &sysctl_sched_latency,
29421805085SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
29521805085SPeter Zijlstra 		.mode		= 0644,
296702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
29721805085SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
29821805085SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
29921805085SPeter Zijlstra 	},
30021805085SPeter Zijlstra 	{
30177e54a1fSIngo Molnar 		.procname	= "sched_wakeup_granularity_ns",
30277e54a1fSIngo Molnar 		.data		= &sysctl_sched_wakeup_granularity,
30377e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
30477e54a1fSIngo Molnar 		.mode		= 0644,
305702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
30677e54a1fSIngo Molnar 		.extra1		= &min_wakeup_granularity_ns,
30777e54a1fSIngo Molnar 		.extra2		= &max_wakeup_granularity_ns,
30877e54a1fSIngo Molnar 	},
30977e54a1fSIngo Molnar 	{
3102398f2c6SPeter Zijlstra 		.procname	= "sched_shares_ratelimit",
3112398f2c6SPeter Zijlstra 		.data		= &sysctl_sched_shares_ratelimit,
3122398f2c6SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3132398f2c6SPeter Zijlstra 		.mode		= 0644,
314702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
315acb4a848SChristian Ehrhardt 		.extra1		= &min_sched_shares_ratelimit,
316acb4a848SChristian Ehrhardt 		.extra2		= &max_sched_shares_ratelimit,
3172398f2c6SPeter Zijlstra 	},
3182398f2c6SPeter Zijlstra 	{
3191983a922SChristian Ehrhardt 		.procname	= "sched_tunable_scaling",
3201983a922SChristian Ehrhardt 		.data		= &sysctl_sched_tunable_scaling,
3211983a922SChristian Ehrhardt 		.maxlen		= sizeof(enum sched_tunable_scaling),
3221983a922SChristian Ehrhardt 		.mode		= 0644,
323702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
3241983a922SChristian Ehrhardt 		.extra1		= &min_sched_tunable_scaling,
3251983a922SChristian Ehrhardt 		.extra2		= &max_sched_tunable_scaling,
3262398f2c6SPeter Zijlstra 	},
3272398f2c6SPeter Zijlstra 	{
328ffda12a1SPeter Zijlstra 		.procname	= "sched_shares_thresh",
329ffda12a1SPeter Zijlstra 		.data		= &sysctl_sched_shares_thresh,
330ffda12a1SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
331ffda12a1SPeter Zijlstra 		.mode		= 0644,
3326d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
333ffda12a1SPeter Zijlstra 		.extra1		= &zero,
334ffda12a1SPeter Zijlstra 	},
335ffda12a1SPeter Zijlstra 	{
336da84d961SIngo Molnar 		.procname	= "sched_migration_cost",
337da84d961SIngo Molnar 		.data		= &sysctl_sched_migration_cost,
338da84d961SIngo Molnar 		.maxlen		= sizeof(unsigned int),
339da84d961SIngo Molnar 		.mode		= 0644,
3406d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
341da84d961SIngo Molnar 	},
342b82d9fddSPeter Zijlstra 	{
343b82d9fddSPeter Zijlstra 		.procname	= "sched_nr_migrate",
344b82d9fddSPeter Zijlstra 		.data		= &sysctl_sched_nr_migrate,
345b82d9fddSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
346fa85ae24SPeter Zijlstra 		.mode		= 0644,
3476d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
348fa85ae24SPeter Zijlstra 	},
349cd1bb94bSArun R Bharadwaj 	{
350e9e9250bSPeter Zijlstra 		.procname	= "sched_time_avg",
351e9e9250bSPeter Zijlstra 		.data		= &sysctl_sched_time_avg,
352e9e9250bSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
353e9e9250bSPeter Zijlstra 		.mode		= 0644,
3546d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
355e9e9250bSPeter Zijlstra 	},
356e9e9250bSPeter Zijlstra 	{
357cd1bb94bSArun R Bharadwaj 		.procname	= "timer_migration",
358cd1bb94bSArun R Bharadwaj 		.data		= &sysctl_timer_migration,
359cd1bb94bSArun R Bharadwaj 		.maxlen		= sizeof(unsigned int),
360cd1bb94bSArun R Bharadwaj 		.mode		= 0644,
3616d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
362bfdb4d9fSArun R Bharadwaj 		.extra1		= &zero,
363bfdb4d9fSArun R Bharadwaj 		.extra2		= &one,
364cd1bb94bSArun R Bharadwaj 	},
3651fc84aaaSPeter Zijlstra #endif
3661799e35dSIngo Molnar 	{
3679f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
3689f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
3699f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3709f0c1e56SPeter Zijlstra 		.mode		= 0644,
3716d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
3729f0c1e56SPeter Zijlstra 	},
3739f0c1e56SPeter Zijlstra 	{
3749f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
3759f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
3769f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
3779f0c1e56SPeter Zijlstra 		.mode		= 0644,
3786d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
3799f0c1e56SPeter Zijlstra 	},
3809f0c1e56SPeter Zijlstra 	{
3811799e35dSIngo Molnar 		.procname	= "sched_compat_yield",
3821799e35dSIngo Molnar 		.data		= &sysctl_sched_compat_yield,
3831799e35dSIngo Molnar 		.maxlen		= sizeof(unsigned int),
3841799e35dSIngo Molnar 		.mode		= 0644,
3856d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3861799e35dSIngo Molnar 	},
387f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
388f20786ffSPeter Zijlstra 	{
389f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
390f20786ffSPeter Zijlstra 		.data		= &prove_locking,
391f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
392f20786ffSPeter Zijlstra 		.mode		= 0644,
3936d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
394f20786ffSPeter Zijlstra 	},
395f20786ffSPeter Zijlstra #endif
396f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
397f20786ffSPeter Zijlstra 	{
398f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
399f20786ffSPeter Zijlstra 		.data		= &lock_stat,
400f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
401f20786ffSPeter Zijlstra 		.mode		= 0644,
4026d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
403f20786ffSPeter Zijlstra 	},
404f20786ffSPeter Zijlstra #endif
40577e54a1fSIngo Molnar 	{
4061da177e4SLinus Torvalds 		.procname	= "panic",
4071da177e4SLinus Torvalds 		.data		= &panic_timeout,
4081da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4091da177e4SLinus Torvalds 		.mode		= 0644,
4106d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4111da177e4SLinus Torvalds 	},
4121da177e4SLinus Torvalds 	{
4131da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
4141da177e4SLinus Torvalds 		.data		= &core_uses_pid,
4151da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4161da177e4SLinus Torvalds 		.mode		= 0644,
4176d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4181da177e4SLinus Torvalds 	},
4191da177e4SLinus Torvalds 	{
4201da177e4SLinus Torvalds 		.procname	= "core_pattern",
4211da177e4SLinus Torvalds 		.data		= core_pattern,
42271ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
4231da177e4SLinus Torvalds 		.mode		= 0644,
4246d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
4251da177e4SLinus Torvalds 	},
426a293980cSNeil Horman 	{
427a293980cSNeil Horman 		.procname	= "core_pipe_limit",
428a293980cSNeil Horman 		.data		= &core_pipe_limit,
429a293980cSNeil Horman 		.maxlen		= sizeof(unsigned int),
430a293980cSNeil Horman 		.mode		= 0644,
4316d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
432a293980cSNeil Horman 	},
43334f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
4341da177e4SLinus Torvalds 	{
4351da177e4SLinus Torvalds 		.procname	= "tainted",
43625ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
43734f5a398STheodore Ts'o 		.mode		= 0644,
4386d456111SEric W. Biederman 		.proc_handler	= proc_taint,
4391da177e4SLinus Torvalds 	},
44034f5a398STheodore Ts'o #endif
4419745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
4429745512cSArjan van de Ven 	{
4439745512cSArjan van de Ven 		.procname	= "latencytop",
4449745512cSArjan van de Ven 		.data		= &latencytop_enabled,
4459745512cSArjan van de Ven 		.maxlen		= sizeof(int),
4469745512cSArjan van de Ven 		.mode		= 0644,
4476d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4489745512cSArjan van de Ven 	},
4499745512cSArjan van de Ven #endif
4501da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
4511da177e4SLinus Torvalds 	{
4521da177e4SLinus Torvalds 		.procname	= "real-root-dev",
4531da177e4SLinus Torvalds 		.data		= &real_root_dev,
4541da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4551da177e4SLinus Torvalds 		.mode		= 0644,
4566d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4571da177e4SLinus Torvalds 	},
4581da177e4SLinus Torvalds #endif
45945807a1dSIngo Molnar 	{
46045807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
46145807a1dSIngo Molnar 		.data		= &print_fatal_signals,
46245807a1dSIngo Molnar 		.maxlen		= sizeof(int),
46345807a1dSIngo Molnar 		.mode		= 0644,
4646d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
46545807a1dSIngo Molnar 	},
46672c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
4671da177e4SLinus Torvalds 	{
4681da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
4691da177e4SLinus Torvalds 		.data		= reboot_command,
4701da177e4SLinus Torvalds 		.maxlen		= 256,
4711da177e4SLinus Torvalds 		.mode		= 0644,
4726d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
4731da177e4SLinus Torvalds 	},
4741da177e4SLinus Torvalds 	{
4751da177e4SLinus Torvalds 		.procname	= "stop-a",
4761da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
4771da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4781da177e4SLinus Torvalds 		.mode		= 0644,
4796d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4801da177e4SLinus Torvalds 	},
4811da177e4SLinus Torvalds 	{
4821da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
4831da177e4SLinus Torvalds 		.data		= &scons_pwroff,
4841da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4851da177e4SLinus Torvalds 		.mode		= 0644,
4866d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4871da177e4SLinus Torvalds 	},
4881da177e4SLinus Torvalds #endif
4890871420fSDavid S. Miller #ifdef CONFIG_SPARC64
4900871420fSDavid S. Miller 	{
4910871420fSDavid S. Miller 		.procname	= "tsb-ratio",
4920871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
4930871420fSDavid S. Miller 		.maxlen		= sizeof (int),
4940871420fSDavid S. Miller 		.mode		= 0644,
4956d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4960871420fSDavid S. Miller 	},
4970871420fSDavid S. Miller #endif
4981da177e4SLinus Torvalds #ifdef __hppa__
4991da177e4SLinus Torvalds 	{
5001da177e4SLinus Torvalds 		.procname	= "soft-power",
5011da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
5021da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5031da177e4SLinus Torvalds 	 	.mode		= 0644,
5046d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5051da177e4SLinus Torvalds 	},
5061da177e4SLinus Torvalds 	{
5071da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
5081da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
5091da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5101da177e4SLinus Torvalds 		.mode		= 0644,
5116d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5121da177e4SLinus Torvalds 	},
5131da177e4SLinus Torvalds #endif
5141da177e4SLinus Torvalds 	{
5151da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
5161da177e4SLinus Torvalds 		.data		= &C_A_D,
5171da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5181da177e4SLinus Torvalds 		.mode		= 0644,
5196d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5201da177e4SLinus Torvalds 	},
521606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
522b0fc494fSSteven Rostedt 	{
523b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
524b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
525b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
526b0fc494fSSteven Rostedt 		.mode		= 0644,
5276d456111SEric W. Biederman 		.proc_handler	= ftrace_enable_sysctl,
528b0fc494fSSteven Rostedt 	},
529b0fc494fSSteven Rostedt #endif
530f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
531f38f1d2aSSteven Rostedt 	{
532f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
533f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
534f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
535f38f1d2aSSteven Rostedt 		.mode		= 0644,
5366d456111SEric W. Biederman 		.proc_handler	= stack_trace_sysctl,
537f38f1d2aSSteven Rostedt 	},
538f38f1d2aSSteven Rostedt #endif
539944ac425SSteven Rostedt #ifdef CONFIG_TRACING
540944ac425SSteven Rostedt 	{
5413299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
542944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
543944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
544944ac425SSteven Rostedt 		.mode		= 0644,
5456d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
546944ac425SSteven Rostedt 	},
547944ac425SSteven Rostedt #endif
548a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
5491da177e4SLinus Torvalds 	{
5501da177e4SLinus Torvalds 		.procname	= "modprobe",
5511da177e4SLinus Torvalds 		.data		= &modprobe_path,
5521da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
5531da177e4SLinus Torvalds 		.mode		= 0644,
5546d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
5551da177e4SLinus Torvalds 	},
5563d43321bSKees Cook 	{
5573d43321bSKees Cook 		.procname	= "modules_disabled",
5583d43321bSKees Cook 		.data		= &modules_disabled,
5593d43321bSKees Cook 		.maxlen		= sizeof(int),
5603d43321bSKees Cook 		.mode		= 0644,
5613d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
5626d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
5633d43321bSKees Cook 		.extra1		= &one,
5643d43321bSKees Cook 		.extra2		= &one,
5653d43321bSKees Cook 	},
5661da177e4SLinus Torvalds #endif
56794f17cd7SIan Abbott #ifdef CONFIG_HOTPLUG
5681da177e4SLinus Torvalds 	{
5691da177e4SLinus Torvalds 		.procname	= "hotplug",
570312c004dSKay Sievers 		.data		= &uevent_helper,
571312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
5721da177e4SLinus Torvalds 		.mode		= 0644,
5736d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
5741da177e4SLinus Torvalds 	},
5751da177e4SLinus Torvalds #endif
5761da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
5771da177e4SLinus Torvalds 	{
5781da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
5791da177e4SLinus Torvalds 		.data		= &sg_big_buff,
5801da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5811da177e4SLinus Torvalds 		.mode		= 0444,
5826d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5831da177e4SLinus Torvalds 	},
5841da177e4SLinus Torvalds #endif
5851da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
5861da177e4SLinus Torvalds 	{
5871da177e4SLinus Torvalds 		.procname	= "acct",
5881da177e4SLinus Torvalds 		.data		= &acct_parm,
5891da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
5901da177e4SLinus Torvalds 		.mode		= 0644,
5916d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5921da177e4SLinus Torvalds 	},
5931da177e4SLinus Torvalds #endif
5941da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
5951da177e4SLinus Torvalds 	{
5961da177e4SLinus Torvalds 		.procname	= "sysrq",
5975d6f647fSIngo Molnar 		.data		= &__sysrq_enabled,
5981da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5991da177e4SLinus Torvalds 		.mode		= 0644,
60097f5f0cdSDmitry Torokhov 		.proc_handler	= sysrq_sysctl_handler,
6011da177e4SLinus Torvalds 	},
6021da177e4SLinus Torvalds #endif
603d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
6041da177e4SLinus Torvalds 	{
6051da177e4SLinus Torvalds 		.procname	= "cad_pid",
6069ec52099SCedric Le Goater 		.data		= NULL,
6071da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6081da177e4SLinus Torvalds 		.mode		= 0600,
6096d456111SEric W. Biederman 		.proc_handler	= proc_do_cad_pid,
6101da177e4SLinus Torvalds 	},
611d6f8ff73SRandy Dunlap #endif
6121da177e4SLinus Torvalds 	{
6131da177e4SLinus Torvalds 		.procname	= "threads-max",
6141da177e4SLinus Torvalds 		.data		= &max_threads,
6151da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6161da177e4SLinus Torvalds 		.mode		= 0644,
6176d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6181da177e4SLinus Torvalds 	},
6191da177e4SLinus Torvalds 	{
6201da177e4SLinus Torvalds 		.procname	= "random",
6211da177e4SLinus Torvalds 		.mode		= 0555,
6221da177e4SLinus Torvalds 		.child		= random_table,
6231da177e4SLinus Torvalds 	},
6241da177e4SLinus Torvalds 	{
6251da177e4SLinus Torvalds 		.procname	= "overflowuid",
6261da177e4SLinus Torvalds 		.data		= &overflowuid,
6271da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6281da177e4SLinus Torvalds 		.mode		= 0644,
6296d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6301da177e4SLinus Torvalds 		.extra1		= &minolduid,
6311da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6321da177e4SLinus Torvalds 	},
6331da177e4SLinus Torvalds 	{
6341da177e4SLinus Torvalds 		.procname	= "overflowgid",
6351da177e4SLinus Torvalds 		.data		= &overflowgid,
6361da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6371da177e4SLinus Torvalds 		.mode		= 0644,
6386d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6391da177e4SLinus Torvalds 		.extra1		= &minolduid,
6401da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6411da177e4SLinus Torvalds 	},
642347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
6431da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
6441da177e4SLinus Torvalds 	{
6451da177e4SLinus Torvalds 		.procname	= "ieee_emulation_warnings",
6461da177e4SLinus Torvalds 		.data		= &sysctl_ieee_emulation_warnings,
6471da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6481da177e4SLinus Torvalds 		.mode		= 0644,
6496d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6501da177e4SLinus Torvalds 	},
6511da177e4SLinus Torvalds #endif
6521da177e4SLinus Torvalds 	{
6531da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
654ab3c68eeSHeiko Carstens 		.data		= &show_unhandled_signals,
6551da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6561da177e4SLinus Torvalds 		.mode		= 0644,
6576d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6581da177e4SLinus Torvalds 	},
6591da177e4SLinus Torvalds #endif
6601da177e4SLinus Torvalds 	{
6611da177e4SLinus Torvalds 		.procname	= "pid_max",
6621da177e4SLinus Torvalds 		.data		= &pid_max,
6631da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6641da177e4SLinus Torvalds 		.mode		= 0644,
6656d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6661da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
6671da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
6681da177e4SLinus Torvalds 	},
6691da177e4SLinus Torvalds 	{
6701da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
6711da177e4SLinus Torvalds 		.data		= &panic_on_oops,
6721da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6731da177e4SLinus Torvalds 		.mode		= 0644,
6746d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6751da177e4SLinus Torvalds 	},
6767ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
6777ef3d2fdSJoe Perches 	{
6787ef3d2fdSJoe Perches 		.procname	= "printk",
6797ef3d2fdSJoe Perches 		.data		= &console_loglevel,
6807ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
6817ef3d2fdSJoe Perches 		.mode		= 0644,
6826d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6837ef3d2fdSJoe Perches 	},
6841da177e4SLinus Torvalds 	{
6851da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
686717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
6871da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6881da177e4SLinus Torvalds 		.mode		= 0644,
6896d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
6901da177e4SLinus Torvalds 	},
6911da177e4SLinus Torvalds 	{
6921da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
693717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
6941da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6951da177e4SLinus Torvalds 		.mode		= 0644,
6966d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6971da177e4SLinus Torvalds 	},
698af91322eSDave Young 	{
699af91322eSDave Young 		.procname	= "printk_delay",
700af91322eSDave Young 		.data		= &printk_delay_msec,
701af91322eSDave Young 		.maxlen		= sizeof(int),
702af91322eSDave Young 		.mode		= 0644,
7036d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
704af91322eSDave Young 		.extra1		= &zero,
705af91322eSDave Young 		.extra2		= &ten_thousand,
706af91322eSDave Young 	},
7077ef3d2fdSJoe Perches #endif
7081da177e4SLinus Torvalds 	{
7091da177e4SLinus Torvalds 		.procname	= "ngroups_max",
7101da177e4SLinus Torvalds 		.data		= &ngroups_max,
7111da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7121da177e4SLinus Torvalds 		.mode		= 0444,
7136d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7141da177e4SLinus Torvalds 	},
71558687acbSDon Zickus #if defined(CONFIG_LOCKUP_DETECTOR)
716504d7cf1SDon Zickus 	{
71758687acbSDon Zickus 		.procname       = "watchdog",
71858687acbSDon Zickus 		.data           = &watchdog_enabled,
719504d7cf1SDon Zickus 		.maxlen         = sizeof (int),
720504d7cf1SDon Zickus 		.mode           = 0644,
72158687acbSDon Zickus 		.proc_handler   = proc_dowatchdog_enabled,
72258687acbSDon Zickus 	},
72358687acbSDon Zickus 	{
72458687acbSDon Zickus 		.procname	= "watchdog_thresh",
72558687acbSDon Zickus 		.data		= &softlockup_thresh,
72658687acbSDon Zickus 		.maxlen		= sizeof(int),
72758687acbSDon Zickus 		.mode		= 0644,
72858687acbSDon Zickus 		.proc_handler	= proc_dowatchdog_thresh,
72958687acbSDon Zickus 		.extra1		= &neg_one,
73058687acbSDon Zickus 		.extra2		= &sixty,
731504d7cf1SDon Zickus 	},
7322508ce18SDon Zickus 	{
7332508ce18SDon Zickus 		.procname	= "softlockup_panic",
7342508ce18SDon Zickus 		.data		= &softlockup_panic,
7352508ce18SDon Zickus 		.maxlen		= sizeof(int),
7362508ce18SDon Zickus 		.mode		= 0644,
7372508ce18SDon Zickus 		.proc_handler	= proc_dointvec_minmax,
7382508ce18SDon Zickus 		.extra1		= &zero,
7392508ce18SDon Zickus 		.extra2		= &one,
7402508ce18SDon Zickus 	},
741504d7cf1SDon Zickus #endif
74258687acbSDon Zickus #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) && !defined(CONFIG_LOCKUP_DETECTOR)
7431da177e4SLinus Torvalds 	{
7441da177e4SLinus Torvalds 		.procname       = "unknown_nmi_panic",
7451da177e4SLinus Torvalds 		.data           = &unknown_nmi_panic,
7461da177e4SLinus Torvalds 		.maxlen         = sizeof (int),
7471da177e4SLinus Torvalds 		.mode           = 0644,
7486d456111SEric W. Biederman 		.proc_handler   = proc_dointvec,
7491da177e4SLinus Torvalds 	},
750407984f1SDon Zickus 	{
751407984f1SDon Zickus 		.procname       = "nmi_watchdog",
752407984f1SDon Zickus 		.data           = &nmi_watchdog_enabled,
753407984f1SDon Zickus 		.maxlen         = sizeof (int),
754407984f1SDon Zickus 		.mode           = 0644,
7556d456111SEric W. Biederman 		.proc_handler   = proc_nmi_enabled,
7561da177e4SLinus Torvalds 	},
7571da177e4SLinus Torvalds #endif
7581da177e4SLinus Torvalds #if defined(CONFIG_X86)
7591da177e4SLinus Torvalds 	{
7608da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
7618da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
7628da5addaSDon Zickus 		.maxlen		= sizeof(int),
7638da5addaSDon Zickus 		.mode		= 0644,
7646d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7658da5addaSDon Zickus 	},
7668da5addaSDon Zickus 	{
7675211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
7685211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
7695211a242SKurt Garloff 		.maxlen		= sizeof(int),
7705211a242SKurt Garloff 		.mode		= 0644,
7716d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7725211a242SKurt Garloff 	},
7735211a242SKurt Garloff 	{
7741da177e4SLinus Torvalds 		.procname	= "bootloader_type",
7751da177e4SLinus Torvalds 		.data		= &bootloader_type,
7761da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7771da177e4SLinus Torvalds 		.mode		= 0444,
7786d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7791da177e4SLinus Torvalds 	},
7800741f4d2SChuck Ebbert 	{
7815031296cSH. Peter Anvin 		.procname	= "bootloader_version",
7825031296cSH. Peter Anvin 		.data		= &bootloader_version,
7835031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
7845031296cSH. Peter Anvin 		.mode		= 0444,
7856d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7865031296cSH. Peter Anvin 	},
7875031296cSH. Peter Anvin 	{
7880741f4d2SChuck Ebbert 		.procname	= "kstack_depth_to_print",
7890741f4d2SChuck Ebbert 		.data		= &kstack_depth_to_print,
7900741f4d2SChuck Ebbert 		.maxlen		= sizeof(int),
7910741f4d2SChuck Ebbert 		.mode		= 0644,
7926d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7930741f4d2SChuck Ebbert 	},
7946e7c4025SIngo Molnar 	{
7956e7c4025SIngo Molnar 		.procname	= "io_delay_type",
7966e7c4025SIngo Molnar 		.data		= &io_delay_type,
7976e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
7986e7c4025SIngo Molnar 		.mode		= 0644,
7996d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
8006e7c4025SIngo Molnar 	},
8011da177e4SLinus Torvalds #endif
8027a9166e3SLuke Yang #if defined(CONFIG_MMU)
8031da177e4SLinus Torvalds 	{
8041da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
8051da177e4SLinus Torvalds 		.data		= &randomize_va_space,
8061da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
8071da177e4SLinus Torvalds 		.mode		= 0644,
8086d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
8091da177e4SLinus Torvalds 	},
8107a9166e3SLuke Yang #endif
8110152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
812951f22d5SMartin Schwidefsky 	{
813951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
814951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
815951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
816951f22d5SMartin Schwidefsky 		.mode		= 0644,
8176d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
818951f22d5SMartin Schwidefsky 	},
819951f22d5SMartin Schwidefsky #endif
820673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
821c255d844SPavel Machek 	{
822c255d844SPavel Machek 		.procname	= "acpi_video_flags",
82377afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
824c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
825c255d844SPavel Machek 		.mode		= 0644,
8266d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
827c255d844SPavel Machek 	},
828c255d844SPavel Machek #endif
829d2b176edSJes Sorensen #ifdef CONFIG_IA64
830d2b176edSJes Sorensen 	{
831d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
832d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
833d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
834d2b176edSJes Sorensen 	 	.mode		= 0644,
8356d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
836d2b176edSJes Sorensen 	},
83788fc241fSDoug Chapman 	{
83888fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
83988fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
84088fc241fSDoug Chapman 		.maxlen		= sizeof (int),
84188fc241fSDoug Chapman 		.mode		= 0644,
8426d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
84388fc241fSDoug Chapman 	},
844d2b176edSJes Sorensen #endif
845e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
846e162b39aSMandeep Singh Baines 	{
847e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
848e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
849e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
850e162b39aSMandeep Singh Baines 		.mode		= 0644,
8516d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
852e162b39aSMandeep Singh Baines 		.extra1		= &zero,
853e162b39aSMandeep Singh Baines 		.extra2		= &one,
854e162b39aSMandeep Singh Baines 	},
85582a1fcb9SIngo Molnar 	{
85682a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
85782a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
85890739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
85982a1fcb9SIngo Molnar 		.mode		= 0644,
8606d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
86182a1fcb9SIngo Molnar 	},
86282a1fcb9SIngo Molnar 	{
86382a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
86482a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
86590739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
86682a1fcb9SIngo Molnar 		.mode		= 0644,
8676d456111SEric W. Biederman 		.proc_handler	= proc_dohung_task_timeout_secs,
86882a1fcb9SIngo Molnar 	},
86982a1fcb9SIngo Molnar 	{
87082a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
87182a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
87290739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
87382a1fcb9SIngo Molnar 		.mode		= 0644,
8746d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
87582a1fcb9SIngo Molnar 	},
876c4f3b63fSRavikiran G Thirumalai #endif
877bebfa101SAndi Kleen #ifdef CONFIG_COMPAT
878bebfa101SAndi Kleen 	{
879bebfa101SAndi Kleen 		.procname	= "compat-log",
880bebfa101SAndi Kleen 		.data		= &compat_log,
881bebfa101SAndi Kleen 		.maxlen		= sizeof (int),
882bebfa101SAndi Kleen 	 	.mode		= 0644,
8836d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
884bebfa101SAndi Kleen 	},
885bebfa101SAndi Kleen #endif
88623f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
88723f78d4aSIngo Molnar 	{
88823f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
88923f78d4aSIngo Molnar 		.data		= &max_lock_depth,
89023f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
89123f78d4aSIngo Molnar 		.mode		= 0644,
8926d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
89323f78d4aSIngo Molnar 	},
89423f78d4aSIngo Molnar #endif
89510a0a8d4SJeremy Fitzhardinge 	{
89610a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
89710a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
89810a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
89910a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
9006d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
90110a0a8d4SJeremy Fitzhardinge 	},
9020b77f5bfSDavid Howells #ifdef CONFIG_KEYS
9030b77f5bfSDavid Howells 	{
9040b77f5bfSDavid Howells 		.procname	= "keys",
9050b77f5bfSDavid Howells 		.mode		= 0555,
9060b77f5bfSDavid Howells 		.child		= key_sysctls,
9070b77f5bfSDavid Howells 	},
9080b77f5bfSDavid Howells #endif
90931a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
91031a72bceSPaul E. McKenney 	{
91131a72bceSPaul E. McKenney 		.procname       = "rcutorture_runnable",
91231a72bceSPaul E. McKenney 		.data           = &rcutorture_runnable,
91331a72bceSPaul E. McKenney 		.maxlen         = sizeof(int),
91431a72bceSPaul E. McKenney 		.mode           = 0644,
9156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
91631a72bceSPaul E. McKenney 	},
91731a72bceSPaul E. McKenney #endif
918cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS
9191ccd1549SPeter Zijlstra 	{
920cdd6c482SIngo Molnar 		.procname	= "perf_event_paranoid",
921cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_paranoid,
922cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_paranoid),
9231ccd1549SPeter Zijlstra 		.mode		= 0644,
9246d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9251ccd1549SPeter Zijlstra 	},
926c5078f78SPeter Zijlstra 	{
927cdd6c482SIngo Molnar 		.procname	= "perf_event_mlock_kb",
928cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_mlock,
929cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_mlock),
930c5078f78SPeter Zijlstra 		.mode		= 0644,
9316d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
932c5078f78SPeter Zijlstra 	},
933a78ac325SPeter Zijlstra 	{
934cdd6c482SIngo Molnar 		.procname	= "perf_event_max_sample_rate",
935cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_sample_rate,
936cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
937a78ac325SPeter Zijlstra 		.mode		= 0644,
9386d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
939a78ac325SPeter Zijlstra 	},
9401ccd1549SPeter Zijlstra #endif
941dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK
942dfec072eSVegard Nossum 	{
943dfec072eSVegard Nossum 		.procname	= "kmemcheck",
944dfec072eSVegard Nossum 		.data		= &kmemcheck_enabled,
945dfec072eSVegard Nossum 		.maxlen		= sizeof(int),
946dfec072eSVegard Nossum 		.mode		= 0644,
9476d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
948dfec072eSVegard Nossum 	},
949dfec072eSVegard Nossum #endif
950cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
9515e605b64SJens Axboe 	{
9525e605b64SJens Axboe 		.procname	= "blk_iopoll",
9535e605b64SJens Axboe 		.data		= &blk_iopoll_enabled,
9545e605b64SJens Axboe 		.maxlen		= sizeof(int),
9555e605b64SJens Axboe 		.mode		= 0644,
9566d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9575e605b64SJens Axboe 	},
958cb684b5bSJens Axboe #endif
959ed2c12f3SAndrew Morton /*
960ed2c12f3SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
961ed2c12f3SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
962ed2c12f3SAndrew Morton  */
9636fce56ecSEric W. Biederman 	{ }
9641da177e4SLinus Torvalds };
9651da177e4SLinus Torvalds 
966d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
9671da177e4SLinus Torvalds 	{
9681da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
9691da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
9701da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
9711da177e4SLinus Torvalds 		.mode		= 0644,
9726d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9731da177e4SLinus Torvalds 	},
9741da177e4SLinus Torvalds 	{
975fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
976fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
977fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
978fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
9796d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
980fadd8fbdSKAMEZAWA Hiroyuki 	},
981fadd8fbdSKAMEZAWA Hiroyuki 	{
982fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
983fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
984fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
985fe071d7eSDavid Rientjes 		.mode		= 0644,
9866d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
987fe071d7eSDavid Rientjes 	},
988fe071d7eSDavid Rientjes 	{
989fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
990fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
991fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
992fef1bdd6SDavid Rientjes 		.mode		= 0644,
9936d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
994fef1bdd6SDavid Rientjes 	},
995fef1bdd6SDavid Rientjes 	{
9961da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
9971da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
9981da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
9991da177e4SLinus Torvalds 		.mode		= 0644,
10006d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10011da177e4SLinus Torvalds 	},
10021da177e4SLinus Torvalds 	{
10031da177e4SLinus Torvalds 		.procname	= "page-cluster",
10041da177e4SLinus Torvalds 		.data		= &page_cluster,
10051da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
10061da177e4SLinus Torvalds 		.mode		= 0644,
10076d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10081da177e4SLinus Torvalds 	},
10091da177e4SLinus Torvalds 	{
10101da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
10111da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
10121da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
10131da177e4SLinus Torvalds 		.mode		= 0644,
10146d456111SEric W. Biederman 		.proc_handler	= dirty_background_ratio_handler,
10151da177e4SLinus Torvalds 		.extra1		= &zero,
10161da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10171da177e4SLinus Torvalds 	},
10181da177e4SLinus Torvalds 	{
10192da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
10202da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
10212da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
10222da02997SDavid Rientjes 		.mode		= 0644,
10236d456111SEric W. Biederman 		.proc_handler	= dirty_background_bytes_handler,
1024fc3501d4SSven Wegener 		.extra1		= &one_ul,
10252da02997SDavid Rientjes 	},
10262da02997SDavid Rientjes 	{
10271da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
10281da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
10291da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
10301da177e4SLinus Torvalds 		.mode		= 0644,
10316d456111SEric W. Biederman 		.proc_handler	= dirty_ratio_handler,
10321da177e4SLinus Torvalds 		.extra1		= &zero,
10331da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10341da177e4SLinus Torvalds 	},
10351da177e4SLinus Torvalds 	{
10362da02997SDavid Rientjes 		.procname	= "dirty_bytes",
10372da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
10382da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
10392da02997SDavid Rientjes 		.mode		= 0644,
10406d456111SEric W. Biederman 		.proc_handler	= dirty_bytes_handler,
10419e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
10422da02997SDavid Rientjes 	},
10432da02997SDavid Rientjes 	{
10441da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
1045f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
1046f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
10471da177e4SLinus Torvalds 		.mode		= 0644,
10486d456111SEric W. Biederman 		.proc_handler	= dirty_writeback_centisecs_handler,
10491da177e4SLinus Torvalds 	},
10501da177e4SLinus Torvalds 	{
10511da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
1052f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
1053f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
10541da177e4SLinus Torvalds 		.mode		= 0644,
10556d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10561da177e4SLinus Torvalds 	},
10571da177e4SLinus Torvalds 	{
10581da177e4SLinus Torvalds 		.procname	= "nr_pdflush_threads",
10591da177e4SLinus Torvalds 		.data		= &nr_pdflush_threads,
10601da177e4SLinus Torvalds 		.maxlen		= sizeof nr_pdflush_threads,
10611da177e4SLinus Torvalds 		.mode		= 0444 /* read-only*/,
10626d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10631da177e4SLinus Torvalds 	},
10641da177e4SLinus Torvalds 	{
10651da177e4SLinus Torvalds 		.procname	= "swappiness",
10661da177e4SLinus Torvalds 		.data		= &vm_swappiness,
10671da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
10681da177e4SLinus Torvalds 		.mode		= 0644,
10696d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
10701da177e4SLinus Torvalds 		.extra1		= &zero,
10711da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10721da177e4SLinus Torvalds 	},
10731da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
10741da177e4SLinus Torvalds 	{
10751da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
1076e5ff2159SAndi Kleen 		.data		= NULL,
10771da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
10781da177e4SLinus Torvalds 		.mode		= 0644,
10796d456111SEric W. Biederman 		.proc_handler	= hugetlb_sysctl_handler,
10801da177e4SLinus Torvalds 		.extra1		= (void *)&hugetlb_zero,
10811da177e4SLinus Torvalds 		.extra2		= (void *)&hugetlb_infinity,
10821da177e4SLinus Torvalds 	},
108306808b08SLee Schermerhorn #ifdef CONFIG_NUMA
108406808b08SLee Schermerhorn 	{
108506808b08SLee Schermerhorn 		.procname       = "nr_hugepages_mempolicy",
108606808b08SLee Schermerhorn 		.data           = NULL,
108706808b08SLee Schermerhorn 		.maxlen         = sizeof(unsigned long),
108806808b08SLee Schermerhorn 		.mode           = 0644,
108906808b08SLee Schermerhorn 		.proc_handler   = &hugetlb_mempolicy_sysctl_handler,
109006808b08SLee Schermerhorn 		.extra1		= (void *)&hugetlb_zero,
109106808b08SLee Schermerhorn 		.extra2		= (void *)&hugetlb_infinity,
109206808b08SLee Schermerhorn 	},
109306808b08SLee Schermerhorn #endif
10941da177e4SLinus Torvalds 	 {
10951da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
10961da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
10971da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
10981da177e4SLinus Torvalds 		.mode		= 0644,
10996d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
11001da177e4SLinus Torvalds 	 },
1101396faf03SMel Gorman 	 {
1102396faf03SMel Gorman 		.procname	= "hugepages_treat_as_movable",
1103396faf03SMel Gorman 		.data		= &hugepages_treat_as_movable,
1104396faf03SMel Gorman 		.maxlen		= sizeof(int),
1105396faf03SMel Gorman 		.mode		= 0644,
11066d456111SEric W. Biederman 		.proc_handler	= hugetlb_treat_movable_handler,
1107396faf03SMel Gorman 	},
110854f9f80dSAdam Litke 	{
1109d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
1110e5ff2159SAndi Kleen 		.data		= NULL,
1111e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
1112d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
11136d456111SEric W. Biederman 		.proc_handler	= hugetlb_overcommit_handler,
1114e5ff2159SAndi Kleen 		.extra1		= (void *)&hugetlb_zero,
1115e5ff2159SAndi Kleen 		.extra2		= (void *)&hugetlb_infinity,
1116d1c3fb1fSNishanth Aravamudan 	},
11171da177e4SLinus Torvalds #endif
11181da177e4SLinus Torvalds 	{
11191da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
11201da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
11211da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
11221da177e4SLinus Torvalds 		.mode		= 0644,
11236d456111SEric W. Biederman 		.proc_handler	= lowmem_reserve_ratio_sysctl_handler,
11241da177e4SLinus Torvalds 	},
11251da177e4SLinus Torvalds 	{
11269d0243bcSAndrew Morton 		.procname	= "drop_caches",
11279d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
11289d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
11299d0243bcSAndrew Morton 		.mode		= 0644,
11309d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
11319d0243bcSAndrew Morton 	},
113276ab0f53SMel Gorman #ifdef CONFIG_COMPACTION
113376ab0f53SMel Gorman 	{
113476ab0f53SMel Gorman 		.procname	= "compact_memory",
113576ab0f53SMel Gorman 		.data		= &sysctl_compact_memory,
113676ab0f53SMel Gorman 		.maxlen		= sizeof(int),
113776ab0f53SMel Gorman 		.mode		= 0200,
113876ab0f53SMel Gorman 		.proc_handler	= sysctl_compaction_handler,
113976ab0f53SMel Gorman 	},
11405e771905SMel Gorman 	{
11415e771905SMel Gorman 		.procname	= "extfrag_threshold",
11425e771905SMel Gorman 		.data		= &sysctl_extfrag_threshold,
11435e771905SMel Gorman 		.maxlen		= sizeof(int),
11445e771905SMel Gorman 		.mode		= 0644,
11455e771905SMel Gorman 		.proc_handler	= sysctl_extfrag_handler,
11465e771905SMel Gorman 		.extra1		= &min_extfrag_threshold,
11475e771905SMel Gorman 		.extra2		= &max_extfrag_threshold,
11485e771905SMel Gorman 	},
11495e771905SMel Gorman 
115076ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */
11519d0243bcSAndrew Morton 	{
11521da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
11531da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
11541da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
11551da177e4SLinus Torvalds 		.mode		= 0644,
11566d456111SEric W. Biederman 		.proc_handler	= min_free_kbytes_sysctl_handler,
11571da177e4SLinus Torvalds 		.extra1		= &zero,
11581da177e4SLinus Torvalds 	},
11598ad4b1fbSRohit Seth 	{
11608ad4b1fbSRohit Seth 		.procname	= "percpu_pagelist_fraction",
11618ad4b1fbSRohit Seth 		.data		= &percpu_pagelist_fraction,
11628ad4b1fbSRohit Seth 		.maxlen		= sizeof(percpu_pagelist_fraction),
11638ad4b1fbSRohit Seth 		.mode		= 0644,
11646d456111SEric W. Biederman 		.proc_handler	= percpu_pagelist_fraction_sysctl_handler,
11658ad4b1fbSRohit Seth 		.extra1		= &min_percpu_pagelist_fract,
11668ad4b1fbSRohit Seth 	},
11671da177e4SLinus Torvalds #ifdef CONFIG_MMU
11681da177e4SLinus Torvalds 	{
11691da177e4SLinus Torvalds 		.procname	= "max_map_count",
11701da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
11711da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
11721da177e4SLinus Torvalds 		.mode		= 0644,
11733e26120cSWANG Cong 		.proc_handler	= proc_dointvec_minmax,
117470da2340SAmerigo Wang 		.extra1		= &zero,
11751da177e4SLinus Torvalds 	},
1176dd8632a1SPaul Mundt #else
1177dd8632a1SPaul Mundt 	{
1178dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
1179dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
1180dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
1181dd8632a1SPaul Mundt 		.mode		= 0644,
11826d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1183dd8632a1SPaul Mundt 		.extra1		= &zero,
1184dd8632a1SPaul Mundt 	},
11851da177e4SLinus Torvalds #endif
11861da177e4SLinus Torvalds 	{
11871da177e4SLinus Torvalds 		.procname	= "laptop_mode",
11881da177e4SLinus Torvalds 		.data		= &laptop_mode,
11891da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
11901da177e4SLinus Torvalds 		.mode		= 0644,
11916d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
11921da177e4SLinus Torvalds 	},
11931da177e4SLinus Torvalds 	{
11941da177e4SLinus Torvalds 		.procname	= "block_dump",
11951da177e4SLinus Torvalds 		.data		= &block_dump,
11961da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
11971da177e4SLinus Torvalds 		.mode		= 0644,
11986d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
11991da177e4SLinus Torvalds 		.extra1		= &zero,
12001da177e4SLinus Torvalds 	},
12011da177e4SLinus Torvalds 	{
12021da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
12031da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
12041da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
12051da177e4SLinus Torvalds 		.mode		= 0644,
12066d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
12071da177e4SLinus Torvalds 		.extra1		= &zero,
12081da177e4SLinus Torvalds 	},
12091da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
12101da177e4SLinus Torvalds 	{
12111da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
12121da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
12131da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
12141da177e4SLinus Torvalds 		.mode		= 0644,
12156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
12161da177e4SLinus Torvalds 		.extra1		= &zero,
12171da177e4SLinus Torvalds 	},
12181da177e4SLinus Torvalds #endif
12191743660bSChristoph Lameter #ifdef CONFIG_NUMA
12201743660bSChristoph Lameter 	{
12211743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
12221743660bSChristoph Lameter 		.data		= &zone_reclaim_mode,
12231743660bSChristoph Lameter 		.maxlen		= sizeof(zone_reclaim_mode),
12241743660bSChristoph Lameter 		.mode		= 0644,
12256d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1226c84db23cSChristoph Lameter 		.extra1		= &zero,
12271743660bSChristoph Lameter 	},
12289614634fSChristoph Lameter 	{
12299614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
12309614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
12319614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
12329614634fSChristoph Lameter 		.mode		= 0644,
12336d456111SEric W. Biederman 		.proc_handler	= sysctl_min_unmapped_ratio_sysctl_handler,
12349614634fSChristoph Lameter 		.extra1		= &zero,
12359614634fSChristoph Lameter 		.extra2		= &one_hundred,
12369614634fSChristoph Lameter 	},
12370ff38490SChristoph Lameter 	{
12380ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
12390ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
12400ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
12410ff38490SChristoph Lameter 		.mode		= 0644,
12426d456111SEric W. Biederman 		.proc_handler	= sysctl_min_slab_ratio_sysctl_handler,
12430ff38490SChristoph Lameter 		.extra1		= &zero,
12440ff38490SChristoph Lameter 		.extra2		= &one_hundred,
12450ff38490SChristoph Lameter 	},
12461743660bSChristoph Lameter #endif
124777461ab3SChristoph Lameter #ifdef CONFIG_SMP
124877461ab3SChristoph Lameter 	{
124977461ab3SChristoph Lameter 		.procname	= "stat_interval",
125077461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
125177461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
125277461ab3SChristoph Lameter 		.mode		= 0644,
12536d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
125477461ab3SChristoph Lameter 	},
125577461ab3SChristoph Lameter #endif
12566e141546SDavid Howells #ifdef CONFIG_MMU
1257ed032189SEric Paris 	{
1258ed032189SEric Paris 		.procname	= "mmap_min_addr",
1259788084abSEric Paris 		.data		= &dac_mmap_min_addr,
1260ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
1261ed032189SEric Paris 		.mode		= 0644,
12626d456111SEric W. Biederman 		.proc_handler	= mmap_min_addr_handler,
1263ed032189SEric Paris 	},
12646e141546SDavid Howells #endif
1265f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
1266f0c0b2b8SKAMEZAWA Hiroyuki 	{
1267f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
1268f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
1269f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
1270f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
12716d456111SEric W. Biederman 		.proc_handler	= numa_zonelist_order_handler,
1272f0c0b2b8SKAMEZAWA Hiroyuki 	},
1273f0c0b2b8SKAMEZAWA Hiroyuki #endif
12742b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
12755c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1276e6e5494cSIngo Molnar 	{
1277e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
1278e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
1279e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
1280e6e5494cSIngo Molnar 		.mode		= 0644,
12816d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1282e6e5494cSIngo Molnar 		.extra1		= &zero,
1283e6e5494cSIngo Molnar 	},
1284e6e5494cSIngo Molnar #endif
1285195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
1286195cf453SBron Gondwana 	{
1287195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
1288195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
1289195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
1290195cf453SBron Gondwana 		.mode		= 0644,
12916d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1292195cf453SBron Gondwana 		.extra1		= &zero,
1293195cf453SBron Gondwana 		.extra2		= &one,
1294195cf453SBron Gondwana 	},
1295195cf453SBron Gondwana #endif
12964be6f6bbSPeter Zijlstra 	{
12974be6f6bbSPeter Zijlstra 		.procname	= "scan_unevictable_pages",
12984be6f6bbSPeter Zijlstra 		.data		= &scan_unevictable_pages,
12994be6f6bbSPeter Zijlstra 		.maxlen		= sizeof(scan_unevictable_pages),
13004be6f6bbSPeter Zijlstra 		.mode		= 0644,
13016d456111SEric W. Biederman 		.proc_handler	= scan_unevictable_handler,
13024be6f6bbSPeter Zijlstra 	},
13036a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE
13046a46079cSAndi Kleen 	{
13056a46079cSAndi Kleen 		.procname	= "memory_failure_early_kill",
13066a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_early_kill,
13076a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_early_kill),
13086a46079cSAndi Kleen 		.mode		= 0644,
13096d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13106a46079cSAndi Kleen 		.extra1		= &zero,
13116a46079cSAndi Kleen 		.extra2		= &one,
13126a46079cSAndi Kleen 	},
13136a46079cSAndi Kleen 	{
13146a46079cSAndi Kleen 		.procname	= "memory_failure_recovery",
13156a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_recovery,
13166a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_recovery),
13176a46079cSAndi Kleen 		.mode		= 0644,
13186d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13196a46079cSAndi Kleen 		.extra1		= &zero,
13206a46079cSAndi Kleen 		.extra2		= &one,
13216a46079cSAndi Kleen 	},
13226a46079cSAndi Kleen #endif
13236a46079cSAndi Kleen 
13242be7fe07SAndrew Morton /*
13252be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
13262be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
13272be7fe07SAndrew Morton  */
13286fce56ecSEric W. Biederman 	{ }
13291da177e4SLinus Torvalds };
13301da177e4SLinus Torvalds 
13312abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1332d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = {
13336fce56ecSEric W. Biederman 	{ }
13342abc26fcSEric W. Biederman };
13352abc26fcSEric W. Biederman #endif
13362abc26fcSEric W. Biederman 
1337d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
13381da177e4SLinus Torvalds 	{
13391da177e4SLinus Torvalds 		.procname	= "inode-nr",
13401da177e4SLinus Torvalds 		.data		= &inodes_stat,
13411da177e4SLinus Torvalds 		.maxlen		= 2*sizeof(int),
13421da177e4SLinus Torvalds 		.mode		= 0444,
1343*cffbc8aaSDave Chinner 		.proc_handler	= proc_nr_inodes,
13441da177e4SLinus Torvalds 	},
13451da177e4SLinus Torvalds 	{
13461da177e4SLinus Torvalds 		.procname	= "inode-state",
13471da177e4SLinus Torvalds 		.data		= &inodes_stat,
13481da177e4SLinus Torvalds 		.maxlen		= 7*sizeof(int),
13491da177e4SLinus Torvalds 		.mode		= 0444,
1350*cffbc8aaSDave Chinner 		.proc_handler	= proc_nr_inodes,
13511da177e4SLinus Torvalds 	},
13521da177e4SLinus Torvalds 	{
13531da177e4SLinus Torvalds 		.procname	= "file-nr",
13541da177e4SLinus Torvalds 		.data		= &files_stat,
13557e360c38SEric Dumazet 		.maxlen		= sizeof(files_stat),
13561da177e4SLinus Torvalds 		.mode		= 0444,
13576d456111SEric W. Biederman 		.proc_handler	= proc_nr_files,
13581da177e4SLinus Torvalds 	},
13591da177e4SLinus Torvalds 	{
13601da177e4SLinus Torvalds 		.procname	= "file-max",
13611da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
13627e360c38SEric Dumazet 		.maxlen		= sizeof(files_stat.max_files),
13631da177e4SLinus Torvalds 		.mode		= 0644,
13647e360c38SEric Dumazet 		.proc_handler	= proc_doulongvec_minmax,
13651da177e4SLinus Torvalds 	},
13661da177e4SLinus Torvalds 	{
13679cfe015aSEric Dumazet 		.procname	= "nr_open",
13689cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
13699cfe015aSEric Dumazet 		.maxlen		= sizeof(int),
13709cfe015aSEric Dumazet 		.mode		= 0644,
13716d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1372eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
1373eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
13749cfe015aSEric Dumazet 	},
13759cfe015aSEric Dumazet 	{
13761da177e4SLinus Torvalds 		.procname	= "dentry-state",
13771da177e4SLinus Torvalds 		.data		= &dentry_stat,
13781da177e4SLinus Torvalds 		.maxlen		= 6*sizeof(int),
13791da177e4SLinus Torvalds 		.mode		= 0444,
13806d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13811da177e4SLinus Torvalds 	},
13821da177e4SLinus Torvalds 	{
13831da177e4SLinus Torvalds 		.procname	= "overflowuid",
13841da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
13851da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13861da177e4SLinus Torvalds 		.mode		= 0644,
13876d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13881da177e4SLinus Torvalds 		.extra1		= &minolduid,
13891da177e4SLinus Torvalds 		.extra2		= &maxolduid,
13901da177e4SLinus Torvalds 	},
13911da177e4SLinus Torvalds 	{
13921da177e4SLinus Torvalds 		.procname	= "overflowgid",
13931da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
13941da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13951da177e4SLinus Torvalds 		.mode		= 0644,
13966d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13971da177e4SLinus Torvalds 		.extra1		= &minolduid,
13981da177e4SLinus Torvalds 		.extra2		= &maxolduid,
13991da177e4SLinus Torvalds 	},
1400bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
14011da177e4SLinus Torvalds 	{
14021da177e4SLinus Torvalds 		.procname	= "leases-enable",
14031da177e4SLinus Torvalds 		.data		= &leases_enable,
14041da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14051da177e4SLinus Torvalds 		.mode		= 0644,
14066d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
14071da177e4SLinus Torvalds 	},
1408bfcd17a6SThomas Petazzoni #endif
14091da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
14101da177e4SLinus Torvalds 	{
14111da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
14121da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
14131da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14141da177e4SLinus Torvalds 		.mode		= 0644,
14156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
14161da177e4SLinus Torvalds 	},
14171da177e4SLinus Torvalds #endif
14181da177e4SLinus Torvalds #ifdef CONFIG_MMU
1419bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
14201da177e4SLinus Torvalds 	{
14211da177e4SLinus Torvalds 		.procname	= "lease-break-time",
14221da177e4SLinus Torvalds 		.data		= &lease_break_time,
14231da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14241da177e4SLinus Torvalds 		.mode		= 0644,
14256d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
14261da177e4SLinus Torvalds 	},
1427bfcd17a6SThomas Petazzoni #endif
1428ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
14291da177e4SLinus Torvalds 	{
14301da177e4SLinus Torvalds 		.procname	= "aio-nr",
14311da177e4SLinus Torvalds 		.data		= &aio_nr,
14321da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
14331da177e4SLinus Torvalds 		.mode		= 0444,
14346d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
14351da177e4SLinus Torvalds 	},
14361da177e4SLinus Torvalds 	{
14371da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
14381da177e4SLinus Torvalds 		.data		= &aio_max_nr,
14391da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
14401da177e4SLinus Torvalds 		.mode		= 0644,
14416d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
14421da177e4SLinus Torvalds 	},
1443ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
14442d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
14450399cb08SRobert Love 	{
14460399cb08SRobert Love 		.procname	= "inotify",
14470399cb08SRobert Love 		.mode		= 0555,
14480399cb08SRobert Love 		.child		= inotify_table,
14490399cb08SRobert Love 	},
14500399cb08SRobert Love #endif
14517ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
14527ef9964eSDavide Libenzi 	{
14537ef9964eSDavide Libenzi 		.procname	= "epoll",
14547ef9964eSDavide Libenzi 		.mode		= 0555,
14557ef9964eSDavide Libenzi 		.child		= epoll_table,
14567ef9964eSDavide Libenzi 	},
14577ef9964eSDavide Libenzi #endif
14581da177e4SLinus Torvalds #endif
1459d6e71144SAlan Cox 	{
1460d6e71144SAlan Cox 		.procname	= "suid_dumpable",
1461d6e71144SAlan Cox 		.data		= &suid_dumpable,
1462d6e71144SAlan Cox 		.maxlen		= sizeof(int),
1463d6e71144SAlan Cox 		.mode		= 0644,
14646d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
14658e654fbaSMatthew Wilcox 		.extra1		= &zero,
14668e654fbaSMatthew Wilcox 		.extra2		= &two,
1467d6e71144SAlan Cox 	},
14682abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
14692abc26fcSEric W. Biederman 	{
14702abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
14712abc26fcSEric W. Biederman 		.mode		= 0555,
14722abc26fcSEric W. Biederman 		.child		= binfmt_misc_table,
14732abc26fcSEric W. Biederman 	},
14742abc26fcSEric W. Biederman #endif
1475b492e95bSJens Axboe 	{
1476ff9da691SJens Axboe 		.procname	= "pipe-max-size",
1477ff9da691SJens Axboe 		.data		= &pipe_max_size,
1478b492e95bSJens Axboe 		.maxlen		= sizeof(int),
1479b492e95bSJens Axboe 		.mode		= 0644,
1480ff9da691SJens Axboe 		.proc_handler	= &pipe_proc_fn,
1481ff9da691SJens Axboe 		.extra1		= &pipe_min_size,
1482b492e95bSJens Axboe 	},
14832be7fe07SAndrew Morton /*
14842be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
14852be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
14862be7fe07SAndrew Morton  */
14876fce56ecSEric W. Biederman 	{ }
14881da177e4SLinus Torvalds };
14891da177e4SLinus Torvalds 
1490d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
1491ab3c68eeSHeiko Carstens #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \
1492ab3c68eeSHeiko Carstens     defined(CONFIG_S390)
1493abd4f750SMasoud Asgharifard Sharbiani 	{
1494abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
1495abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
1496abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
1497abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
1498abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
1499abd4f750SMasoud Asgharifard Sharbiani 	},
1500abd4f750SMasoud Asgharifard Sharbiani #endif
1501b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES)
1502b2be84dfSMasami Hiramatsu 	{
1503b2be84dfSMasami Hiramatsu 		.procname	= "kprobes-optimization",
1504b2be84dfSMasami Hiramatsu 		.data		= &sysctl_kprobes_optimization,
1505b2be84dfSMasami Hiramatsu 		.maxlen		= sizeof(int),
1506b2be84dfSMasami Hiramatsu 		.mode		= 0644,
1507b2be84dfSMasami Hiramatsu 		.proc_handler	= proc_kprobes_optimization_handler,
1508b2be84dfSMasami Hiramatsu 		.extra1		= &zero,
1509b2be84dfSMasami Hiramatsu 		.extra2		= &one,
1510b2be84dfSMasami Hiramatsu 	},
1511b2be84dfSMasami Hiramatsu #endif
15126fce56ecSEric W. Biederman 	{ }
15131da177e4SLinus Torvalds };
15141da177e4SLinus Torvalds 
1515d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
15166fce56ecSEric W. Biederman 	{ }
15171da177e4SLinus Torvalds };
15181da177e4SLinus Torvalds 
1519330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock);
1520330d57fbSAl Viro 
1521330d57fbSAl Viro /* called under sysctl_lock */
1522330d57fbSAl Viro static int use_table(struct ctl_table_header *p)
1523330d57fbSAl Viro {
1524330d57fbSAl Viro 	if (unlikely(p->unregistering))
1525330d57fbSAl Viro 		return 0;
1526330d57fbSAl Viro 	p->used++;
1527330d57fbSAl Viro 	return 1;
1528330d57fbSAl Viro }
1529330d57fbSAl Viro 
1530330d57fbSAl Viro /* called under sysctl_lock */
1531330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p)
1532330d57fbSAl Viro {
1533330d57fbSAl Viro 	if (!--p->used)
1534330d57fbSAl Viro 		if (unlikely(p->unregistering))
1535330d57fbSAl Viro 			complete(p->unregistering);
1536330d57fbSAl Viro }
1537330d57fbSAl Viro 
1538330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */
1539330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p)
1540330d57fbSAl Viro {
1541330d57fbSAl Viro 	/*
1542330d57fbSAl Viro 	 * if p->used is 0, nobody will ever touch that entry again;
1543330d57fbSAl Viro 	 * we'll eliminate all paths to it before dropping sysctl_lock
1544330d57fbSAl Viro 	 */
1545330d57fbSAl Viro 	if (unlikely(p->used)) {
1546330d57fbSAl Viro 		struct completion wait;
1547330d57fbSAl Viro 		init_completion(&wait);
1548330d57fbSAl Viro 		p->unregistering = &wait;
1549330d57fbSAl Viro 		spin_unlock(&sysctl_lock);
1550330d57fbSAl Viro 		wait_for_completion(&wait);
1551330d57fbSAl Viro 		spin_lock(&sysctl_lock);
1552f7e6ced4SAl Viro 	} else {
1553f7e6ced4SAl Viro 		/* anything non-NULL; we'll never dereference it */
1554f7e6ced4SAl Viro 		p->unregistering = ERR_PTR(-EINVAL);
1555330d57fbSAl Viro 	}
1556330d57fbSAl Viro 	/*
1557330d57fbSAl Viro 	 * do not remove from the list until nobody holds it; walking the
1558330d57fbSAl Viro 	 * list in do_sysctl() relies on that.
1559330d57fbSAl Viro 	 */
1560330d57fbSAl Viro 	list_del_init(&p->ctl_entry);
1561330d57fbSAl Viro }
1562330d57fbSAl Viro 
1563f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head)
1564f7e6ced4SAl Viro {
1565f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1566f7e6ced4SAl Viro 	head->count++;
1567f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1568f7e6ced4SAl Viro }
1569f7e6ced4SAl Viro 
1570f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
1571f7e6ced4SAl Viro {
1572f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1573f7e6ced4SAl Viro 	if (!--head->count)
1574f7e6ced4SAl Viro 		kfree(head);
1575f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1576f7e6ced4SAl Viro }
1577f7e6ced4SAl Viro 
1578f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1579f7e6ced4SAl Viro {
1580f7e6ced4SAl Viro 	if (!head)
1581f7e6ced4SAl Viro 		BUG();
1582f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1583f7e6ced4SAl Viro 	if (!use_table(head))
1584f7e6ced4SAl Viro 		head = ERR_PTR(-ENOENT);
1585f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1586f7e6ced4SAl Viro 	return head;
1587f7e6ced4SAl Viro }
1588f7e6ced4SAl Viro 
1589805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head)
1590805b5d5eSEric W. Biederman {
1591805b5d5eSEric W. Biederman 	if (!head)
1592805b5d5eSEric W. Biederman 		return;
1593805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1594805b5d5eSEric W. Biederman 	unuse_table(head);
1595805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1596805b5d5eSEric W. Biederman }
1597805b5d5eSEric W. Biederman 
159873455092SAl Viro static struct ctl_table_set *
159973455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
160073455092SAl Viro {
160173455092SAl Viro 	struct ctl_table_set *set = &root->default_set;
160273455092SAl Viro 	if (root->lookup)
160373455092SAl Viro 		set = root->lookup(root, namespaces);
160473455092SAl Viro 	return set;
160573455092SAl Viro }
160673455092SAl Viro 
1607e51b6ba0SEric W. Biederman static struct list_head *
1608e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1609805b5d5eSEric W. Biederman {
161073455092SAl Viro 	struct ctl_table_set *set = lookup_header_set(root, namespaces);
161173455092SAl Viro 	return &set->list;
1612e51b6ba0SEric W. Biederman }
1613e51b6ba0SEric W. Biederman 
1614e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1615e51b6ba0SEric W. Biederman 					    struct ctl_table_header *prev)
1616e51b6ba0SEric W. Biederman {
1617e51b6ba0SEric W. Biederman 	struct ctl_table_root *root;
1618e51b6ba0SEric W. Biederman 	struct list_head *header_list;
1619805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1620805b5d5eSEric W. Biederman 	struct list_head *tmp;
1621e51b6ba0SEric W. Biederman 
1622805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1623805b5d5eSEric W. Biederman 	if (prev) {
1624e51b6ba0SEric W. Biederman 		head = prev;
1625805b5d5eSEric W. Biederman 		tmp = &prev->ctl_entry;
1626805b5d5eSEric W. Biederman 		unuse_table(prev);
1627805b5d5eSEric W. Biederman 		goto next;
1628805b5d5eSEric W. Biederman 	}
1629805b5d5eSEric W. Biederman 	tmp = &root_table_header.ctl_entry;
1630805b5d5eSEric W. Biederman 	for (;;) {
1631805b5d5eSEric W. Biederman 		head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1632805b5d5eSEric W. Biederman 
1633805b5d5eSEric W. Biederman 		if (!use_table(head))
1634805b5d5eSEric W. Biederman 			goto next;
1635805b5d5eSEric W. Biederman 		spin_unlock(&sysctl_lock);
1636805b5d5eSEric W. Biederman 		return head;
1637805b5d5eSEric W. Biederman 	next:
1638e51b6ba0SEric W. Biederman 		root = head->root;
1639805b5d5eSEric W. Biederman 		tmp = tmp->next;
1640e51b6ba0SEric W. Biederman 		header_list = lookup_header_list(root, namespaces);
1641e51b6ba0SEric W. Biederman 		if (tmp != header_list)
1642e51b6ba0SEric W. Biederman 			continue;
1643e51b6ba0SEric W. Biederman 
1644e51b6ba0SEric W. Biederman 		do {
1645e51b6ba0SEric W. Biederman 			root = list_entry(root->root_list.next,
1646e51b6ba0SEric W. Biederman 					struct ctl_table_root, root_list);
1647e51b6ba0SEric W. Biederman 			if (root == &sysctl_table_root)
1648e51b6ba0SEric W. Biederman 				goto out;
1649e51b6ba0SEric W. Biederman 			header_list = lookup_header_list(root, namespaces);
1650e51b6ba0SEric W. Biederman 		} while (list_empty(header_list));
1651e51b6ba0SEric W. Biederman 		tmp = header_list->next;
1652805b5d5eSEric W. Biederman 	}
1653e51b6ba0SEric W. Biederman out:
1654805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1655805b5d5eSEric W. Biederman 	return NULL;
1656805b5d5eSEric W. Biederman }
1657805b5d5eSEric W. Biederman 
1658e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1659e51b6ba0SEric W. Biederman {
1660e51b6ba0SEric W. Biederman 	return __sysctl_head_next(current->nsproxy, prev);
1661e51b6ba0SEric W. Biederman }
1662e51b6ba0SEric W. Biederman 
1663e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root)
1664e51b6ba0SEric W. Biederman {
1665e51b6ba0SEric W. Biederman 	spin_lock(&sysctl_lock);
1666e51b6ba0SEric W. Biederman 	list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1667e51b6ba0SEric W. Biederman 	spin_unlock(&sysctl_lock);
1668e51b6ba0SEric W. Biederman }
1669e51b6ba0SEric W. Biederman 
16701da177e4SLinus Torvalds /*
16711ff007ebSEric W. Biederman  * sysctl_perm does NOT grant the superuser all rights automatically, because
16721da177e4SLinus Torvalds  * some sysctl variables are readonly even to root.
16731da177e4SLinus Torvalds  */
16741da177e4SLinus Torvalds 
16751da177e4SLinus Torvalds static int test_perm(int mode, int op)
16761da177e4SLinus Torvalds {
167776aac0e9SDavid Howells 	if (!current_euid())
16781da177e4SLinus Torvalds 		mode >>= 6;
16791da177e4SLinus Torvalds 	else if (in_egroup_p(0))
16801da177e4SLinus Torvalds 		mode >>= 3;
1681e6305c43SAl Viro 	if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
16821da177e4SLinus Torvalds 		return 0;
16831da177e4SLinus Torvalds 	return -EACCES;
16841da177e4SLinus Torvalds }
16851da177e4SLinus Torvalds 
1686d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
16871da177e4SLinus Torvalds {
16881da177e4SLinus Torvalds 	int error;
1689d7321cd6SPavel Emelyanov 	int mode;
1690d7321cd6SPavel Emelyanov 
1691e6305c43SAl Viro 	error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
16921da177e4SLinus Torvalds 	if (error)
16931da177e4SLinus Torvalds 		return error;
1694d7321cd6SPavel Emelyanov 
1695d7321cd6SPavel Emelyanov 	if (root->permissions)
1696d7321cd6SPavel Emelyanov 		mode = root->permissions(root, current->nsproxy, table);
1697d7321cd6SPavel Emelyanov 	else
1698d7321cd6SPavel Emelyanov 		mode = table->mode;
1699d7321cd6SPavel Emelyanov 
1700d7321cd6SPavel Emelyanov 	return test_perm(mode, op);
17011da177e4SLinus Torvalds }
17021da177e4SLinus Torvalds 
1703d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1704d912b0ccSEric W. Biederman {
17052315ffa0SEric W. Biederman 	for (; table->procname; table++) {
1706d912b0ccSEric W. Biederman 		table->parent = parent;
1707d912b0ccSEric W. Biederman 		if (table->child)
1708d912b0ccSEric W. Biederman 			sysctl_set_parent(table, table->child);
1709d912b0ccSEric W. Biederman 	}
1710d912b0ccSEric W. Biederman }
1711d912b0ccSEric W. Biederman 
1712d912b0ccSEric W. Biederman static __init int sysctl_init(void)
1713d912b0ccSEric W. Biederman {
1714d912b0ccSEric W. Biederman 	sysctl_set_parent(NULL, root_table);
171588f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1716b3bd3de6SAndi Kleen 	sysctl_check_table(current->nsproxy, root_table);
171788f458e4SHolger Schurig #endif
1718d912b0ccSEric W. Biederman 	return 0;
1719d912b0ccSEric W. Biederman }
1720d912b0ccSEric W. Biederman 
1721d912b0ccSEric W. Biederman core_initcall(sysctl_init);
1722d912b0ccSEric W. Biederman 
1723bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch,
1724bfbcf034SAl Viro 				      struct ctl_table *table)
1725ae7edeccSAl Viro {
1726ae7edeccSAl Viro 	struct ctl_table *p;
1727ae7edeccSAl Viro 	const char *s = branch->procname;
1728ae7edeccSAl Viro 
1729ae7edeccSAl Viro 	/* branch should have named subdirectory as its first element */
1730ae7edeccSAl Viro 	if (!s || !branch->child)
1731bfbcf034SAl Viro 		return NULL;
1732ae7edeccSAl Viro 
1733ae7edeccSAl Viro 	/* ... and nothing else */
17342315ffa0SEric W. Biederman 	if (branch[1].procname)
1735bfbcf034SAl Viro 		return NULL;
1736ae7edeccSAl Viro 
1737ae7edeccSAl Viro 	/* table should contain subdirectory with the same name */
17382315ffa0SEric W. Biederman 	for (p = table; p->procname; p++) {
1739ae7edeccSAl Viro 		if (!p->child)
1740ae7edeccSAl Viro 			continue;
1741ae7edeccSAl Viro 		if (p->procname && strcmp(p->procname, s) == 0)
1742bfbcf034SAl Viro 			return p;
1743ae7edeccSAl Viro 	}
1744bfbcf034SAl Viro 	return NULL;
1745ae7edeccSAl Viro }
1746ae7edeccSAl Viro 
1747ae7edeccSAl Viro /* see if attaching q to p would be an improvement */
1748ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1749ae7edeccSAl Viro {
1750ae7edeccSAl Viro 	struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1751bfbcf034SAl Viro 	struct ctl_table *next;
1752ae7edeccSAl Viro 	int is_better = 0;
1753ae7edeccSAl Viro 	int not_in_parent = !p->attached_by;
1754ae7edeccSAl Viro 
1755bfbcf034SAl Viro 	while ((next = is_branch_in(by, to)) != NULL) {
1756ae7edeccSAl Viro 		if (by == q->attached_by)
1757ae7edeccSAl Viro 			is_better = 1;
1758ae7edeccSAl Viro 		if (to == p->attached_by)
1759ae7edeccSAl Viro 			not_in_parent = 1;
1760ae7edeccSAl Viro 		by = by->child;
1761bfbcf034SAl Viro 		to = next->child;
1762ae7edeccSAl Viro 	}
1763ae7edeccSAl Viro 
1764ae7edeccSAl Viro 	if (is_better && not_in_parent) {
1765ae7edeccSAl Viro 		q->attached_by = by;
1766ae7edeccSAl Viro 		q->attached_to = to;
1767ae7edeccSAl Viro 		q->parent = p;
1768ae7edeccSAl Viro 	}
1769ae7edeccSAl Viro }
1770ae7edeccSAl Viro 
17711da177e4SLinus Torvalds /**
1772e51b6ba0SEric W. Biederman  * __register_sysctl_paths - register a sysctl hierarchy
1773e51b6ba0SEric W. Biederman  * @root: List of sysctl headers to register on
1774e51b6ba0SEric W. Biederman  * @namespaces: Data to compute which lists of sysctl entries are visible
177529e796fdSEric W. Biederman  * @path: The path to the directory the sysctl table is in.
17761da177e4SLinus Torvalds  * @table: the top-level table structure
17771da177e4SLinus Torvalds  *
17781da177e4SLinus Torvalds  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
177929e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
17801da177e4SLinus Torvalds  *
1781d8217f07SEric W. Biederman  * The members of the &struct ctl_table structure are used as follows:
17821da177e4SLinus Torvalds  *
17831da177e4SLinus Torvalds  * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
17841da177e4SLinus Torvalds  *            enter a sysctl file
17851da177e4SLinus Torvalds  *
17861da177e4SLinus Torvalds  * data - a pointer to data for use by proc_handler
17871da177e4SLinus Torvalds  *
17881da177e4SLinus Torvalds  * maxlen - the maximum size in bytes of the data
17891da177e4SLinus Torvalds  *
17901da177e4SLinus Torvalds  * mode - the file permissions for the /proc/sys file, and for sysctl(2)
17911da177e4SLinus Torvalds  *
17921da177e4SLinus Torvalds  * child - a pointer to the child sysctl table if this entry is a directory, or
17931da177e4SLinus Torvalds  *         %NULL.
17941da177e4SLinus Torvalds  *
17951da177e4SLinus Torvalds  * proc_handler - the text handler routine (described below)
17961da177e4SLinus Torvalds  *
17971da177e4SLinus Torvalds  * de - for internal use by the sysctl routines
17981da177e4SLinus Torvalds  *
17991da177e4SLinus Torvalds  * extra1, extra2 - extra pointers usable by the proc handler routines
18001da177e4SLinus Torvalds  *
18011da177e4SLinus Torvalds  * Leaf nodes in the sysctl tree will be represented by a single file
18021da177e4SLinus Torvalds  * under /proc; non-leaf nodes will be represented by directories.
18031da177e4SLinus Torvalds  *
18041da177e4SLinus Torvalds  * sysctl(2) can automatically manage read and write requests through
18051da177e4SLinus Torvalds  * the sysctl table.  The data and maxlen fields of the ctl_table
18061da177e4SLinus Torvalds  * struct enable minimal validation of the values being written to be
18071da177e4SLinus Torvalds  * performed, and the mode field allows minimal authentication.
18081da177e4SLinus Torvalds  *
18091da177e4SLinus Torvalds  * There must be a proc_handler routine for any terminal nodes
18101da177e4SLinus Torvalds  * mirrored under /proc/sys (non-terminals are handled by a built-in
18111da177e4SLinus Torvalds  * directory handler).  Several default handlers are available to
18121da177e4SLinus Torvalds  * cover common cases -
18131da177e4SLinus Torvalds  *
18141da177e4SLinus Torvalds  * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
18151da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
18161da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
18171da177e4SLinus Torvalds  *
18181da177e4SLinus Torvalds  * It is the handler's job to read the input buffer from user memory
18191da177e4SLinus Torvalds  * and process it. The handler should return 0 on success.
18201da177e4SLinus Torvalds  *
18211da177e4SLinus Torvalds  * This routine returns %NULL on a failure to register, and a pointer
18221da177e4SLinus Torvalds  * to the table header on success.
18231da177e4SLinus Torvalds  */
1824e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths(
1825e51b6ba0SEric W. Biederman 	struct ctl_table_root *root,
1826e51b6ba0SEric W. Biederman 	struct nsproxy *namespaces,
1827e51b6ba0SEric W. Biederman 	const struct ctl_path *path, struct ctl_table *table)
18281da177e4SLinus Torvalds {
182929e796fdSEric W. Biederman 	struct ctl_table_header *header;
183029e796fdSEric W. Biederman 	struct ctl_table *new, **prevp;
183129e796fdSEric W. Biederman 	unsigned int n, npath;
1832ae7edeccSAl Viro 	struct ctl_table_set *set;
183329e796fdSEric W. Biederman 
183429e796fdSEric W. Biederman 	/* Count the path components */
18352315ffa0SEric W. Biederman 	for (npath = 0; path[npath].procname; ++npath)
183629e796fdSEric W. Biederman 		;
183729e796fdSEric W. Biederman 
183829e796fdSEric W. Biederman 	/*
183929e796fdSEric W. Biederman 	 * For each path component, allocate a 2-element ctl_table array.
184029e796fdSEric W. Biederman 	 * The first array element will be filled with the sysctl entry
18412315ffa0SEric W. Biederman 	 * for this, the second will be the sentinel (procname == 0).
184229e796fdSEric W. Biederman 	 *
184329e796fdSEric W. Biederman 	 * We allocate everything in one go so that we don't have to
184429e796fdSEric W. Biederman 	 * worry about freeing additional memory in unregister_sysctl_table.
184529e796fdSEric W. Biederman 	 */
184629e796fdSEric W. Biederman 	header = kzalloc(sizeof(struct ctl_table_header) +
184729e796fdSEric W. Biederman 			 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
184829e796fdSEric W. Biederman 	if (!header)
18491da177e4SLinus Torvalds 		return NULL;
185029e796fdSEric W. Biederman 
185129e796fdSEric W. Biederman 	new = (struct ctl_table *) (header + 1);
185229e796fdSEric W. Biederman 
185329e796fdSEric W. Biederman 	/* Now connect the dots */
185429e796fdSEric W. Biederman 	prevp = &header->ctl_table;
185529e796fdSEric W. Biederman 	for (n = 0; n < npath; ++n, ++path) {
185629e796fdSEric W. Biederman 		/* Copy the procname */
185729e796fdSEric W. Biederman 		new->procname = path->procname;
185829e796fdSEric W. Biederman 		new->mode     = 0555;
185929e796fdSEric W. Biederman 
186029e796fdSEric W. Biederman 		*prevp = new;
186129e796fdSEric W. Biederman 		prevp = &new->child;
186229e796fdSEric W. Biederman 
186329e796fdSEric W. Biederman 		new += 2;
186429e796fdSEric W. Biederman 	}
186529e796fdSEric W. Biederman 	*prevp = table;
186623eb06deSEric W. Biederman 	header->ctl_table_arg = table;
186729e796fdSEric W. Biederman 
186829e796fdSEric W. Biederman 	INIT_LIST_HEAD(&header->ctl_entry);
186929e796fdSEric W. Biederman 	header->used = 0;
187029e796fdSEric W. Biederman 	header->unregistering = NULL;
1871e51b6ba0SEric W. Biederman 	header->root = root;
187229e796fdSEric W. Biederman 	sysctl_set_parent(NULL, header->ctl_table);
1873f7e6ced4SAl Viro 	header->count = 1;
187488f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1875e51b6ba0SEric W. Biederman 	if (sysctl_check_table(namespaces, header->ctl_table)) {
187629e796fdSEric W. Biederman 		kfree(header);
1877fc6cd25bSEric W. Biederman 		return NULL;
1878fc6cd25bSEric W. Biederman 	}
187988f458e4SHolger Schurig #endif
1880330d57fbSAl Viro 	spin_lock(&sysctl_lock);
188173455092SAl Viro 	header->set = lookup_header_set(root, namespaces);
1882ae7edeccSAl Viro 	header->attached_by = header->ctl_table;
1883ae7edeccSAl Viro 	header->attached_to = root_table;
1884ae7edeccSAl Viro 	header->parent = &root_table_header;
1885ae7edeccSAl Viro 	for (set = header->set; set; set = set->parent) {
1886ae7edeccSAl Viro 		struct ctl_table_header *p;
1887ae7edeccSAl Viro 		list_for_each_entry(p, &set->list, ctl_entry) {
1888ae7edeccSAl Viro 			if (p->unregistering)
1889ae7edeccSAl Viro 				continue;
1890ae7edeccSAl Viro 			try_attach(p, header);
1891ae7edeccSAl Viro 		}
1892ae7edeccSAl Viro 	}
1893ae7edeccSAl Viro 	header->parent->count++;
189473455092SAl Viro 	list_add_tail(&header->ctl_entry, &header->set->list);
1895330d57fbSAl Viro 	spin_unlock(&sysctl_lock);
189629e796fdSEric W. Biederman 
189729e796fdSEric W. Biederman 	return header;
189829e796fdSEric W. Biederman }
189929e796fdSEric W. Biederman 
190029e796fdSEric W. Biederman /**
1901e51b6ba0SEric W. Biederman  * register_sysctl_table_path - register a sysctl table hierarchy
1902e51b6ba0SEric W. Biederman  * @path: The path to the directory the sysctl table is in.
1903e51b6ba0SEric W. Biederman  * @table: the top-level table structure
1904e51b6ba0SEric W. Biederman  *
1905e51b6ba0SEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1906e51b6ba0SEric W. Biederman  * array. A completely 0 filled entry terminates the table.
1907e51b6ba0SEric W. Biederman  *
1908e51b6ba0SEric W. Biederman  * See __register_sysctl_paths for more details.
1909e51b6ba0SEric W. Biederman  */
1910e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1911e51b6ba0SEric W. Biederman 						struct ctl_table *table)
1912e51b6ba0SEric W. Biederman {
1913e51b6ba0SEric W. Biederman 	return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1914e51b6ba0SEric W. Biederman 					path, table);
1915e51b6ba0SEric W. Biederman }
1916e51b6ba0SEric W. Biederman 
1917e51b6ba0SEric W. Biederman /**
191829e796fdSEric W. Biederman  * register_sysctl_table - register a sysctl table hierarchy
191929e796fdSEric W. Biederman  * @table: the top-level table structure
192029e796fdSEric W. Biederman  *
192129e796fdSEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
192229e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
192329e796fdSEric W. Biederman  *
192429e796fdSEric W. Biederman  * See register_sysctl_paths for more details.
192529e796fdSEric W. Biederman  */
192629e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
192729e796fdSEric W. Biederman {
192829e796fdSEric W. Biederman 	static const struct ctl_path null_path[] = { {} };
192929e796fdSEric W. Biederman 
193029e796fdSEric W. Biederman 	return register_sysctl_paths(null_path, table);
19311da177e4SLinus Torvalds }
19321da177e4SLinus Torvalds 
19331da177e4SLinus Torvalds /**
19341da177e4SLinus Torvalds  * unregister_sysctl_table - unregister a sysctl table hierarchy
19351da177e4SLinus Torvalds  * @header: the header returned from register_sysctl_table
19361da177e4SLinus Torvalds  *
19371da177e4SLinus Torvalds  * Unregisters the sysctl table and all children. proc entries may not
19381da177e4SLinus Torvalds  * actually be removed until they are no longer used by anyone.
19391da177e4SLinus Torvalds  */
19401da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header)
19411da177e4SLinus Torvalds {
1942330d57fbSAl Viro 	might_sleep();
1943f1dad166SPavel Emelyanov 
1944f1dad166SPavel Emelyanov 	if (header == NULL)
1945f1dad166SPavel Emelyanov 		return;
1946f1dad166SPavel Emelyanov 
1947330d57fbSAl Viro 	spin_lock(&sysctl_lock);
1948330d57fbSAl Viro 	start_unregistering(header);
1949ae7edeccSAl Viro 	if (!--header->parent->count) {
1950ae7edeccSAl Viro 		WARN_ON(1);
1951ae7edeccSAl Viro 		kfree(header->parent);
1952ae7edeccSAl Viro 	}
1953f7e6ced4SAl Viro 	if (!--header->count)
19541da177e4SLinus Torvalds 		kfree(header);
1955f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
19561da177e4SLinus Torvalds }
19571da177e4SLinus Torvalds 
19589043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p)
19599043476fSAl Viro {
19609043476fSAl Viro 	struct ctl_table_set *set = p->set;
19619043476fSAl Viro 	int res;
19629043476fSAl Viro 	spin_lock(&sysctl_lock);
19639043476fSAl Viro 	if (p->unregistering)
19649043476fSAl Viro 		res = 0;
19659043476fSAl Viro 	else if (!set->is_seen)
19669043476fSAl Viro 		res = 1;
19679043476fSAl Viro 	else
19689043476fSAl Viro 		res = set->is_seen(set);
19699043476fSAl Viro 	spin_unlock(&sysctl_lock);
19709043476fSAl Viro 	return res;
19719043476fSAl Viro }
19729043476fSAl Viro 
197373455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
197473455092SAl Viro 	struct ctl_table_set *parent,
197573455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
197673455092SAl Viro {
197773455092SAl Viro 	INIT_LIST_HEAD(&p->list);
197873455092SAl Viro 	p->parent = parent ? parent : &sysctl_table_root.default_set;
197973455092SAl Viro 	p->is_seen = is_seen;
198073455092SAl Viro }
198173455092SAl Viro 
1982b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */
1983d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
1984b89a8171SEric W. Biederman {
1985b89a8171SEric W. Biederman 	return NULL;
1986b89a8171SEric W. Biederman }
1987b89a8171SEric W. Biederman 
198829e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
198929e796fdSEric W. Biederman 						    struct ctl_table *table)
199029e796fdSEric W. Biederman {
199129e796fdSEric W. Biederman 	return NULL;
199229e796fdSEric W. Biederman }
199329e796fdSEric W. Biederman 
1994b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table)
1995b89a8171SEric W. Biederman {
1996b89a8171SEric W. Biederman }
1997b89a8171SEric W. Biederman 
199873455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
199973455092SAl Viro 	struct ctl_table_set *parent,
200073455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
200173455092SAl Viro {
200273455092SAl Viro }
200373455092SAl Viro 
2004f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
2005f7e6ced4SAl Viro {
2006f7e6ced4SAl Viro }
2007f7e6ced4SAl Viro 
2008b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
2009b89a8171SEric W. Biederman 
20101da177e4SLinus Torvalds /*
20111da177e4SLinus Torvalds  * /proc/sys support
20121da177e4SLinus Torvalds  */
20131da177e4SLinus Torvalds 
2014b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL
20151da177e4SLinus Torvalds 
2016b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write,
20178d65af78SAlexey Dobriyan 			   void __user *buffer,
2018b1ba4dddSAdrian Bunk 			   size_t *lenp, loff_t *ppos)
2019f5dd3d6fSSam Vilain {
2020f5dd3d6fSSam Vilain 	size_t len;
2021f5dd3d6fSSam Vilain 	char __user *p;
2022f5dd3d6fSSam Vilain 	char c;
2023f5dd3d6fSSam Vilain 
20248d060877SOleg Nesterov 	if (!data || !maxlen || !*lenp) {
2025f5dd3d6fSSam Vilain 		*lenp = 0;
2026f5dd3d6fSSam Vilain 		return 0;
2027f5dd3d6fSSam Vilain 	}
2028f5dd3d6fSSam Vilain 
2029f5dd3d6fSSam Vilain 	if (write) {
2030f5dd3d6fSSam Vilain 		len = 0;
2031f5dd3d6fSSam Vilain 		p = buffer;
2032f5dd3d6fSSam Vilain 		while (len < *lenp) {
2033f5dd3d6fSSam Vilain 			if (get_user(c, p++))
2034f5dd3d6fSSam Vilain 				return -EFAULT;
2035f5dd3d6fSSam Vilain 			if (c == 0 || c == '\n')
2036f5dd3d6fSSam Vilain 				break;
2037f5dd3d6fSSam Vilain 			len++;
2038f5dd3d6fSSam Vilain 		}
2039f5dd3d6fSSam Vilain 		if (len >= maxlen)
2040f5dd3d6fSSam Vilain 			len = maxlen-1;
2041f5dd3d6fSSam Vilain 		if(copy_from_user(data, buffer, len))
2042f5dd3d6fSSam Vilain 			return -EFAULT;
2043f5dd3d6fSSam Vilain 		((char *) data)[len] = 0;
2044f5dd3d6fSSam Vilain 		*ppos += *lenp;
2045f5dd3d6fSSam Vilain 	} else {
2046f5dd3d6fSSam Vilain 		len = strlen(data);
2047f5dd3d6fSSam Vilain 		if (len > maxlen)
2048f5dd3d6fSSam Vilain 			len = maxlen;
20498d060877SOleg Nesterov 
20508d060877SOleg Nesterov 		if (*ppos > len) {
20518d060877SOleg Nesterov 			*lenp = 0;
20528d060877SOleg Nesterov 			return 0;
20538d060877SOleg Nesterov 		}
20548d060877SOleg Nesterov 
20558d060877SOleg Nesterov 		data += *ppos;
20568d060877SOleg Nesterov 		len  -= *ppos;
20578d060877SOleg Nesterov 
2058f5dd3d6fSSam Vilain 		if (len > *lenp)
2059f5dd3d6fSSam Vilain 			len = *lenp;
2060f5dd3d6fSSam Vilain 		if (len)
2061f5dd3d6fSSam Vilain 			if(copy_to_user(buffer, data, len))
2062f5dd3d6fSSam Vilain 				return -EFAULT;
2063f5dd3d6fSSam Vilain 		if (len < *lenp) {
2064f5dd3d6fSSam Vilain 			if(put_user('\n', ((char __user *) buffer) + len))
2065f5dd3d6fSSam Vilain 				return -EFAULT;
2066f5dd3d6fSSam Vilain 			len++;
2067f5dd3d6fSSam Vilain 		}
2068f5dd3d6fSSam Vilain 		*lenp = len;
2069f5dd3d6fSSam Vilain 		*ppos += len;
2070f5dd3d6fSSam Vilain 	}
2071f5dd3d6fSSam Vilain 	return 0;
2072f5dd3d6fSSam Vilain }
2073f5dd3d6fSSam Vilain 
20741da177e4SLinus Torvalds /**
20751da177e4SLinus Torvalds  * proc_dostring - read a string sysctl
20761da177e4SLinus Torvalds  * @table: the sysctl table
20771da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
20781da177e4SLinus Torvalds  * @buffer: the user buffer
20791da177e4SLinus Torvalds  * @lenp: the size of the user buffer
20801da177e4SLinus Torvalds  * @ppos: file position
20811da177e4SLinus Torvalds  *
20821da177e4SLinus Torvalds  * Reads/writes a string from/to the user buffer. If the kernel
20831da177e4SLinus Torvalds  * buffer provided is not large enough to hold the string, the
20841da177e4SLinus Torvalds  * string is truncated. The copied string is %NULL-terminated.
20851da177e4SLinus Torvalds  * If the string is being read by the user process, it is copied
20861da177e4SLinus Torvalds  * and a newline '\n' is added. It is truncated if the buffer is
20871da177e4SLinus Torvalds  * not large enough.
20881da177e4SLinus Torvalds  *
20891da177e4SLinus Torvalds  * Returns 0 on success.
20901da177e4SLinus Torvalds  */
20918d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write,
20921da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
20931da177e4SLinus Torvalds {
20948d65af78SAlexey Dobriyan 	return _proc_do_string(table->data, table->maxlen, write,
2095f5dd3d6fSSam Vilain 			       buffer, lenp, ppos);
20961da177e4SLinus Torvalds }
20971da177e4SLinus Torvalds 
209800b7c339SAmerigo Wang static size_t proc_skip_spaces(char **buf)
209900b7c339SAmerigo Wang {
210000b7c339SAmerigo Wang 	size_t ret;
210100b7c339SAmerigo Wang 	char *tmp = skip_spaces(*buf);
210200b7c339SAmerigo Wang 	ret = tmp - *buf;
210300b7c339SAmerigo Wang 	*buf = tmp;
210400b7c339SAmerigo Wang 	return ret;
210500b7c339SAmerigo Wang }
21061da177e4SLinus Torvalds 
21079f977fb7SOctavian Purdila static void proc_skip_char(char **buf, size_t *size, const char v)
21089f977fb7SOctavian Purdila {
21099f977fb7SOctavian Purdila 	while (*size) {
21109f977fb7SOctavian Purdila 		if (**buf != v)
21119f977fb7SOctavian Purdila 			break;
21129f977fb7SOctavian Purdila 		(*size)--;
21139f977fb7SOctavian Purdila 		(*buf)++;
21149f977fb7SOctavian Purdila 	}
21159f977fb7SOctavian Purdila }
21169f977fb7SOctavian Purdila 
211700b7c339SAmerigo Wang #define TMPBUFLEN 22
211800b7c339SAmerigo Wang /**
21190fc377bdSRandy Dunlap  * proc_get_long - reads an ASCII formatted integer from a user buffer
212000b7c339SAmerigo Wang  *
21210fc377bdSRandy Dunlap  * @buf: a kernel buffer
21220fc377bdSRandy Dunlap  * @size: size of the kernel buffer
21230fc377bdSRandy Dunlap  * @val: this is where the number will be stored
21240fc377bdSRandy Dunlap  * @neg: set to %TRUE if number is negative
21250fc377bdSRandy Dunlap  * @perm_tr: a vector which contains the allowed trailers
21260fc377bdSRandy Dunlap  * @perm_tr_len: size of the perm_tr vector
21270fc377bdSRandy Dunlap  * @tr: pointer to store the trailer character
212800b7c339SAmerigo Wang  *
21290fc377bdSRandy Dunlap  * In case of success %0 is returned and @buf and @size are updated with
21300fc377bdSRandy Dunlap  * the amount of bytes read. If @tr is non-NULL and a trailing
21310fc377bdSRandy Dunlap  * character exists (size is non-zero after returning from this
21320fc377bdSRandy Dunlap  * function), @tr is updated with the trailing character.
213300b7c339SAmerigo Wang  */
213400b7c339SAmerigo Wang static int proc_get_long(char **buf, size_t *size,
213500b7c339SAmerigo Wang 			  unsigned long *val, bool *neg,
213600b7c339SAmerigo Wang 			  const char *perm_tr, unsigned perm_tr_len, char *tr)
213700b7c339SAmerigo Wang {
213800b7c339SAmerigo Wang 	int len;
213900b7c339SAmerigo Wang 	char *p, tmp[TMPBUFLEN];
214000b7c339SAmerigo Wang 
214100b7c339SAmerigo Wang 	if (!*size)
214200b7c339SAmerigo Wang 		return -EINVAL;
214300b7c339SAmerigo Wang 
214400b7c339SAmerigo Wang 	len = *size;
214500b7c339SAmerigo Wang 	if (len > TMPBUFLEN - 1)
214600b7c339SAmerigo Wang 		len = TMPBUFLEN - 1;
214700b7c339SAmerigo Wang 
214800b7c339SAmerigo Wang 	memcpy(tmp, *buf, len);
214900b7c339SAmerigo Wang 
215000b7c339SAmerigo Wang 	tmp[len] = 0;
215100b7c339SAmerigo Wang 	p = tmp;
215200b7c339SAmerigo Wang 	if (*p == '-' && *size > 1) {
215300b7c339SAmerigo Wang 		*neg = true;
215400b7c339SAmerigo Wang 		p++;
215500b7c339SAmerigo Wang 	} else
215600b7c339SAmerigo Wang 		*neg = false;
215700b7c339SAmerigo Wang 	if (!isdigit(*p))
215800b7c339SAmerigo Wang 		return -EINVAL;
215900b7c339SAmerigo Wang 
216000b7c339SAmerigo Wang 	*val = simple_strtoul(p, &p, 0);
216100b7c339SAmerigo Wang 
216200b7c339SAmerigo Wang 	len = p - tmp;
216300b7c339SAmerigo Wang 
216400b7c339SAmerigo Wang 	/* We don't know if the next char is whitespace thus we may accept
216500b7c339SAmerigo Wang 	 * invalid integers (e.g. 1234...a) or two integers instead of one
216600b7c339SAmerigo Wang 	 * (e.g. 123...1). So lets not allow such large numbers. */
216700b7c339SAmerigo Wang 	if (len == TMPBUFLEN - 1)
216800b7c339SAmerigo Wang 		return -EINVAL;
216900b7c339SAmerigo Wang 
217000b7c339SAmerigo Wang 	if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
217100b7c339SAmerigo Wang 		return -EINVAL;
217200b7c339SAmerigo Wang 
217300b7c339SAmerigo Wang 	if (tr && (len < *size))
217400b7c339SAmerigo Wang 		*tr = *p;
217500b7c339SAmerigo Wang 
217600b7c339SAmerigo Wang 	*buf += len;
217700b7c339SAmerigo Wang 	*size -= len;
217800b7c339SAmerigo Wang 
217900b7c339SAmerigo Wang 	return 0;
218000b7c339SAmerigo Wang }
218100b7c339SAmerigo Wang 
218200b7c339SAmerigo Wang /**
21830fc377bdSRandy Dunlap  * proc_put_long - converts an integer to a decimal ASCII formatted string
218400b7c339SAmerigo Wang  *
21850fc377bdSRandy Dunlap  * @buf: the user buffer
21860fc377bdSRandy Dunlap  * @size: the size of the user buffer
21870fc377bdSRandy Dunlap  * @val: the integer to be converted
21880fc377bdSRandy Dunlap  * @neg: sign of the number, %TRUE for negative
218900b7c339SAmerigo Wang  *
21900fc377bdSRandy Dunlap  * In case of success %0 is returned and @buf and @size are updated with
21910fc377bdSRandy Dunlap  * the amount of bytes written.
219200b7c339SAmerigo Wang  */
219300b7c339SAmerigo Wang static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
219400b7c339SAmerigo Wang 			  bool neg)
219500b7c339SAmerigo Wang {
219600b7c339SAmerigo Wang 	int len;
219700b7c339SAmerigo Wang 	char tmp[TMPBUFLEN], *p = tmp;
219800b7c339SAmerigo Wang 
219900b7c339SAmerigo Wang 	sprintf(p, "%s%lu", neg ? "-" : "", val);
220000b7c339SAmerigo Wang 	len = strlen(tmp);
220100b7c339SAmerigo Wang 	if (len > *size)
220200b7c339SAmerigo Wang 		len = *size;
220300b7c339SAmerigo Wang 	if (copy_to_user(*buf, tmp, len))
220400b7c339SAmerigo Wang 		return -EFAULT;
220500b7c339SAmerigo Wang 	*size -= len;
220600b7c339SAmerigo Wang 	*buf += len;
220700b7c339SAmerigo Wang 	return 0;
220800b7c339SAmerigo Wang }
220900b7c339SAmerigo Wang #undef TMPBUFLEN
221000b7c339SAmerigo Wang 
221100b7c339SAmerigo Wang static int proc_put_char(void __user **buf, size_t *size, char c)
221200b7c339SAmerigo Wang {
221300b7c339SAmerigo Wang 	if (*size) {
221400b7c339SAmerigo Wang 		char __user **buffer = (char __user **)buf;
221500b7c339SAmerigo Wang 		if (put_user(c, *buffer))
221600b7c339SAmerigo Wang 			return -EFAULT;
221700b7c339SAmerigo Wang 		(*size)--, (*buffer)++;
221800b7c339SAmerigo Wang 		*buf = *buffer;
221900b7c339SAmerigo Wang 	}
222000b7c339SAmerigo Wang 	return 0;
222100b7c339SAmerigo Wang }
222200b7c339SAmerigo Wang 
222300b7c339SAmerigo Wang static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
22241da177e4SLinus Torvalds 				 int *valp,
22251da177e4SLinus Torvalds 				 int write, void *data)
22261da177e4SLinus Torvalds {
22271da177e4SLinus Torvalds 	if (write) {
22281da177e4SLinus Torvalds 		*valp = *negp ? -*lvalp : *lvalp;
22291da177e4SLinus Torvalds 	} else {
22301da177e4SLinus Torvalds 		int val = *valp;
22311da177e4SLinus Torvalds 		if (val < 0) {
223200b7c339SAmerigo Wang 			*negp = true;
22331da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
22341da177e4SLinus Torvalds 		} else {
223500b7c339SAmerigo Wang 			*negp = false;
22361da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
22371da177e4SLinus Torvalds 		}
22381da177e4SLinus Torvalds 	}
22391da177e4SLinus Torvalds 	return 0;
22401da177e4SLinus Torvalds }
22411da177e4SLinus Torvalds 
224200b7c339SAmerigo Wang static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
224300b7c339SAmerigo Wang 
2244d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
22458d65af78SAlexey Dobriyan 		  int write, void __user *buffer,
2246fcfbd547SKirill Korotaev 		  size_t *lenp, loff_t *ppos,
224700b7c339SAmerigo Wang 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
22481da177e4SLinus Torvalds 			      int write, void *data),
22491da177e4SLinus Torvalds 		  void *data)
22501da177e4SLinus Torvalds {
225100b7c339SAmerigo Wang 	int *i, vleft, first = 1, err = 0;
225200b7c339SAmerigo Wang 	unsigned long page = 0;
225300b7c339SAmerigo Wang 	size_t left;
225400b7c339SAmerigo Wang 	char *kbuf;
22551da177e4SLinus Torvalds 
225600b7c339SAmerigo Wang 	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
22571da177e4SLinus Torvalds 		*lenp = 0;
22581da177e4SLinus Torvalds 		return 0;
22591da177e4SLinus Torvalds 	}
22601da177e4SLinus Torvalds 
2261fcfbd547SKirill Korotaev 	i = (int *) tbl_data;
22621da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(*i);
22631da177e4SLinus Torvalds 	left = *lenp;
22641da177e4SLinus Torvalds 
22651da177e4SLinus Torvalds 	if (!conv)
22661da177e4SLinus Torvalds 		conv = do_proc_dointvec_conv;
22671da177e4SLinus Torvalds 
226800b7c339SAmerigo Wang 	if (write) {
226900b7c339SAmerigo Wang 		if (left > PAGE_SIZE - 1)
227000b7c339SAmerigo Wang 			left = PAGE_SIZE - 1;
227100b7c339SAmerigo Wang 		page = __get_free_page(GFP_TEMPORARY);
227200b7c339SAmerigo Wang 		kbuf = (char *) page;
227300b7c339SAmerigo Wang 		if (!kbuf)
227400b7c339SAmerigo Wang 			return -ENOMEM;
227500b7c339SAmerigo Wang 		if (copy_from_user(kbuf, buffer, left)) {
227600b7c339SAmerigo Wang 			err = -EFAULT;
227700b7c339SAmerigo Wang 			goto free;
227800b7c339SAmerigo Wang 		}
227900b7c339SAmerigo Wang 		kbuf[left] = 0;
228000b7c339SAmerigo Wang 	}
228100b7c339SAmerigo Wang 
22821da177e4SLinus Torvalds 	for (; left && vleft--; i++, first=0) {
228300b7c339SAmerigo Wang 		unsigned long lval;
228400b7c339SAmerigo Wang 		bool neg;
228500b7c339SAmerigo Wang 
22861da177e4SLinus Torvalds 		if (write) {
228700b7c339SAmerigo Wang 			left -= proc_skip_spaces(&kbuf);
228800b7c339SAmerigo Wang 
2289563b0467SJ. R. Okajima 			if (!left)
2290563b0467SJ. R. Okajima 				break;
229100b7c339SAmerigo Wang 			err = proc_get_long(&kbuf, &left, &lval, &neg,
229200b7c339SAmerigo Wang 					     proc_wspace_sep,
229300b7c339SAmerigo Wang 					     sizeof(proc_wspace_sep), NULL);
229400b7c339SAmerigo Wang 			if (err)
22951da177e4SLinus Torvalds 				break;
229600b7c339SAmerigo Wang 			if (conv(&neg, &lval, i, 1, data)) {
229700b7c339SAmerigo Wang 				err = -EINVAL;
229800b7c339SAmerigo Wang 				break;
22991da177e4SLinus Torvalds 			}
23001da177e4SLinus Torvalds 		} else {
230100b7c339SAmerigo Wang 			if (conv(&neg, &lval, i, 0, data)) {
230200b7c339SAmerigo Wang 				err = -EINVAL;
230300b7c339SAmerigo Wang 				break;
230400b7c339SAmerigo Wang 			}
23051da177e4SLinus Torvalds 			if (!first)
230600b7c339SAmerigo Wang 				err = proc_put_char(&buffer, &left, '\t');
230700b7c339SAmerigo Wang 			if (err)
23081da177e4SLinus Torvalds 				break;
230900b7c339SAmerigo Wang 			err = proc_put_long(&buffer, &left, lval, neg);
231000b7c339SAmerigo Wang 			if (err)
231100b7c339SAmerigo Wang 				break;
23121da177e4SLinus Torvalds 		}
23131da177e4SLinus Torvalds 	}
23141da177e4SLinus Torvalds 
231500b7c339SAmerigo Wang 	if (!write && !first && left && !err)
231600b7c339SAmerigo Wang 		err = proc_put_char(&buffer, &left, '\n');
2317563b0467SJ. R. Okajima 	if (write && !err && left)
231800b7c339SAmerigo Wang 		left -= proc_skip_spaces(&kbuf);
231900b7c339SAmerigo Wang free:
23201da177e4SLinus Torvalds 	if (write) {
232100b7c339SAmerigo Wang 		free_page(page);
232200b7c339SAmerigo Wang 		if (first)
232300b7c339SAmerigo Wang 			return err ? : -EINVAL;
23241da177e4SLinus Torvalds 	}
23251da177e4SLinus Torvalds 	*lenp -= left;
23261da177e4SLinus Torvalds 	*ppos += *lenp;
232700b7c339SAmerigo Wang 	return err;
23281da177e4SLinus Torvalds }
23291da177e4SLinus Torvalds 
23308d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write,
2331fcfbd547SKirill Korotaev 		  void __user *buffer, size_t *lenp, loff_t *ppos,
233200b7c339SAmerigo Wang 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2333fcfbd547SKirill Korotaev 			      int write, void *data),
2334fcfbd547SKirill Korotaev 		  void *data)
2335fcfbd547SKirill Korotaev {
23368d65af78SAlexey Dobriyan 	return __do_proc_dointvec(table->data, table, write,
2337fcfbd547SKirill Korotaev 			buffer, lenp, ppos, conv, data);
2338fcfbd547SKirill Korotaev }
2339fcfbd547SKirill Korotaev 
23401da177e4SLinus Torvalds /**
23411da177e4SLinus Torvalds  * proc_dointvec - read a vector of integers
23421da177e4SLinus Torvalds  * @table: the sysctl table
23431da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
23441da177e4SLinus Torvalds  * @buffer: the user buffer
23451da177e4SLinus Torvalds  * @lenp: the size of the user buffer
23461da177e4SLinus Torvalds  * @ppos: file position
23471da177e4SLinus Torvalds  *
23481da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
23491da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
23501da177e4SLinus Torvalds  *
23511da177e4SLinus Torvalds  * Returns 0 on success.
23521da177e4SLinus Torvalds  */
23538d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write,
23541da177e4SLinus Torvalds 		     void __user *buffer, size_t *lenp, loff_t *ppos)
23551da177e4SLinus Torvalds {
23568d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
23571da177e4SLinus Torvalds 		    	    NULL,NULL);
23581da177e4SLinus Torvalds }
23591da177e4SLinus Torvalds 
236034f5a398STheodore Ts'o /*
236134f5a398STheodore Ts'o  * Taint values can only be increased
236225ddbb18SAndi Kleen  * This means we can safely use a temporary.
236334f5a398STheodore Ts'o  */
23648d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write,
236534f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos)
236634f5a398STheodore Ts'o {
236725ddbb18SAndi Kleen 	struct ctl_table t;
236825ddbb18SAndi Kleen 	unsigned long tmptaint = get_taint();
236925ddbb18SAndi Kleen 	int err;
237034f5a398STheodore Ts'o 
237191fcd412SBastian Blank 	if (write && !capable(CAP_SYS_ADMIN))
237234f5a398STheodore Ts'o 		return -EPERM;
237334f5a398STheodore Ts'o 
237425ddbb18SAndi Kleen 	t = *table;
237525ddbb18SAndi Kleen 	t.data = &tmptaint;
23768d65af78SAlexey Dobriyan 	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
237725ddbb18SAndi Kleen 	if (err < 0)
237825ddbb18SAndi Kleen 		return err;
237925ddbb18SAndi Kleen 
238025ddbb18SAndi Kleen 	if (write) {
238125ddbb18SAndi Kleen 		/*
238225ddbb18SAndi Kleen 		 * Poor man's atomic or. Not worth adding a primitive
238325ddbb18SAndi Kleen 		 * to everyone's atomic.h for this
238425ddbb18SAndi Kleen 		 */
238525ddbb18SAndi Kleen 		int i;
238625ddbb18SAndi Kleen 		for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
238725ddbb18SAndi Kleen 			if ((tmptaint >> i) & 1)
238825ddbb18SAndi Kleen 				add_taint(i);
238925ddbb18SAndi Kleen 		}
239025ddbb18SAndi Kleen 	}
239125ddbb18SAndi Kleen 
239225ddbb18SAndi Kleen 	return err;
239334f5a398STheodore Ts'o }
239434f5a398STheodore Ts'o 
23951da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param {
23961da177e4SLinus Torvalds 	int *min;
23971da177e4SLinus Torvalds 	int *max;
23981da177e4SLinus Torvalds };
23991da177e4SLinus Torvalds 
240000b7c339SAmerigo Wang static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
24011da177e4SLinus Torvalds 					int *valp,
24021da177e4SLinus Torvalds 					int write, void *data)
24031da177e4SLinus Torvalds {
24041da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param *param = data;
24051da177e4SLinus Torvalds 	if (write) {
24061da177e4SLinus Torvalds 		int val = *negp ? -*lvalp : *lvalp;
24071da177e4SLinus Torvalds 		if ((param->min && *param->min > val) ||
24081da177e4SLinus Torvalds 		    (param->max && *param->max < val))
24091da177e4SLinus Torvalds 			return -EINVAL;
24101da177e4SLinus Torvalds 		*valp = val;
24111da177e4SLinus Torvalds 	} else {
24121da177e4SLinus Torvalds 		int val = *valp;
24131da177e4SLinus Torvalds 		if (val < 0) {
241400b7c339SAmerigo Wang 			*negp = true;
24151da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
24161da177e4SLinus Torvalds 		} else {
241700b7c339SAmerigo Wang 			*negp = false;
24181da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
24191da177e4SLinus Torvalds 		}
24201da177e4SLinus Torvalds 	}
24211da177e4SLinus Torvalds 	return 0;
24221da177e4SLinus Torvalds }
24231da177e4SLinus Torvalds 
24241da177e4SLinus Torvalds /**
24251da177e4SLinus Torvalds  * proc_dointvec_minmax - read a vector of integers with min/max values
24261da177e4SLinus Torvalds  * @table: the sysctl table
24271da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24281da177e4SLinus Torvalds  * @buffer: the user buffer
24291da177e4SLinus Torvalds  * @lenp: the size of the user buffer
24301da177e4SLinus Torvalds  * @ppos: file position
24311da177e4SLinus Torvalds  *
24321da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
24331da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
24341da177e4SLinus Torvalds  *
24351da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
24361da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
24371da177e4SLinus Torvalds  *
24381da177e4SLinus Torvalds  * Returns 0 on success.
24391da177e4SLinus Torvalds  */
24408d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write,
24411da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
24421da177e4SLinus Torvalds {
24431da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param param = {
24441da177e4SLinus Torvalds 		.min = (int *) table->extra1,
24451da177e4SLinus Torvalds 		.max = (int *) table->extra2,
24461da177e4SLinus Torvalds 	};
24478d65af78SAlexey Dobriyan 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
24481da177e4SLinus Torvalds 				do_proc_dointvec_minmax_conv, &param);
24491da177e4SLinus Torvalds }
24501da177e4SLinus Torvalds 
2451d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
24521da177e4SLinus Torvalds 				     void __user *buffer,
24531da177e4SLinus Torvalds 				     size_t *lenp, loff_t *ppos,
24541da177e4SLinus Torvalds 				     unsigned long convmul,
24551da177e4SLinus Torvalds 				     unsigned long convdiv)
24561da177e4SLinus Torvalds {
245700b7c339SAmerigo Wang 	unsigned long *i, *min, *max;
245800b7c339SAmerigo Wang 	int vleft, first = 1, err = 0;
245900b7c339SAmerigo Wang 	unsigned long page = 0;
246000b7c339SAmerigo Wang 	size_t left;
246100b7c339SAmerigo Wang 	char *kbuf;
24621da177e4SLinus Torvalds 
246300b7c339SAmerigo Wang 	if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
24641da177e4SLinus Torvalds 		*lenp = 0;
24651da177e4SLinus Torvalds 		return 0;
24661da177e4SLinus Torvalds 	}
24671da177e4SLinus Torvalds 
2468fcfbd547SKirill Korotaev 	i = (unsigned long *) data;
24691da177e4SLinus Torvalds 	min = (unsigned long *) table->extra1;
24701da177e4SLinus Torvalds 	max = (unsigned long *) table->extra2;
24711da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(unsigned long);
24721da177e4SLinus Torvalds 	left = *lenp;
24731da177e4SLinus Torvalds 
24741da177e4SLinus Torvalds 	if (write) {
247500b7c339SAmerigo Wang 		if (left > PAGE_SIZE - 1)
247600b7c339SAmerigo Wang 			left = PAGE_SIZE - 1;
247700b7c339SAmerigo Wang 		page = __get_free_page(GFP_TEMPORARY);
247800b7c339SAmerigo Wang 		kbuf = (char *) page;
247900b7c339SAmerigo Wang 		if (!kbuf)
248000b7c339SAmerigo Wang 			return -ENOMEM;
248100b7c339SAmerigo Wang 		if (copy_from_user(kbuf, buffer, left)) {
248200b7c339SAmerigo Wang 			err = -EFAULT;
248300b7c339SAmerigo Wang 			goto free;
24841da177e4SLinus Torvalds 		}
248500b7c339SAmerigo Wang 		kbuf[left] = 0;
24861da177e4SLinus Torvalds 	}
24871da177e4SLinus Torvalds 
248827b3d80aSEric Dumazet 	for (; left && vleft--; i++, first = 0) {
248900b7c339SAmerigo Wang 		unsigned long val;
249000b7c339SAmerigo Wang 
249100b7c339SAmerigo Wang 		if (write) {
249200b7c339SAmerigo Wang 			bool neg;
249300b7c339SAmerigo Wang 
249400b7c339SAmerigo Wang 			left -= proc_skip_spaces(&kbuf);
249500b7c339SAmerigo Wang 
249600b7c339SAmerigo Wang 			err = proc_get_long(&kbuf, &left, &val, &neg,
249700b7c339SAmerigo Wang 					     proc_wspace_sep,
249800b7c339SAmerigo Wang 					     sizeof(proc_wspace_sep), NULL);
249900b7c339SAmerigo Wang 			if (err)
250000b7c339SAmerigo Wang 				break;
25011da177e4SLinus Torvalds 			if (neg)
25021da177e4SLinus Torvalds 				continue;
25031da177e4SLinus Torvalds 			if ((min && val < *min) || (max && val > *max))
25041da177e4SLinus Torvalds 				continue;
25051da177e4SLinus Torvalds 			*i = val;
25061da177e4SLinus Torvalds 		} else {
250700b7c339SAmerigo Wang 			val = convdiv * (*i) / convmul;
25081da177e4SLinus Torvalds 			if (!first)
250900b7c339SAmerigo Wang 				err = proc_put_char(&buffer, &left, '\t');
251000b7c339SAmerigo Wang 			err = proc_put_long(&buffer, &left, val, false);
251100b7c339SAmerigo Wang 			if (err)
251200b7c339SAmerigo Wang 				break;
25131da177e4SLinus Torvalds 		}
25141da177e4SLinus Torvalds 	}
25151da177e4SLinus Torvalds 
251600b7c339SAmerigo Wang 	if (!write && !first && left && !err)
251700b7c339SAmerigo Wang 		err = proc_put_char(&buffer, &left, '\n');
251800b7c339SAmerigo Wang 	if (write && !err)
251900b7c339SAmerigo Wang 		left -= proc_skip_spaces(&kbuf);
252000b7c339SAmerigo Wang free:
25211da177e4SLinus Torvalds 	if (write) {
252200b7c339SAmerigo Wang 		free_page(page);
252300b7c339SAmerigo Wang 		if (first)
252400b7c339SAmerigo Wang 			return err ? : -EINVAL;
25251da177e4SLinus Torvalds 	}
25261da177e4SLinus Torvalds 	*lenp -= left;
25271da177e4SLinus Torvalds 	*ppos += *lenp;
252800b7c339SAmerigo Wang 	return err;
25291da177e4SLinus Torvalds }
25301da177e4SLinus Torvalds 
2531d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2532fcfbd547SKirill Korotaev 				     void __user *buffer,
2533fcfbd547SKirill Korotaev 				     size_t *lenp, loff_t *ppos,
2534fcfbd547SKirill Korotaev 				     unsigned long convmul,
2535fcfbd547SKirill Korotaev 				     unsigned long convdiv)
2536fcfbd547SKirill Korotaev {
2537fcfbd547SKirill Korotaev 	return __do_proc_doulongvec_minmax(table->data, table, write,
25388d65af78SAlexey Dobriyan 			buffer, lenp, ppos, convmul, convdiv);
2539fcfbd547SKirill Korotaev }
2540fcfbd547SKirill Korotaev 
25411da177e4SLinus Torvalds /**
25421da177e4SLinus Torvalds  * proc_doulongvec_minmax - read a vector of long integers with min/max values
25431da177e4SLinus Torvalds  * @table: the sysctl table
25441da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25451da177e4SLinus Torvalds  * @buffer: the user buffer
25461da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25471da177e4SLinus Torvalds  * @ppos: file position
25481da177e4SLinus Torvalds  *
25491da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
25501da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25511da177e4SLinus Torvalds  *
25521da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
25531da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
25541da177e4SLinus Torvalds  *
25551da177e4SLinus Torvalds  * Returns 0 on success.
25561da177e4SLinus Torvalds  */
25578d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write,
25581da177e4SLinus Torvalds 			   void __user *buffer, size_t *lenp, loff_t *ppos)
25591da177e4SLinus Torvalds {
25608d65af78SAlexey Dobriyan     return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
25611da177e4SLinus Torvalds }
25621da177e4SLinus Torvalds 
25631da177e4SLinus Torvalds /**
25641da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
25651da177e4SLinus Torvalds  * @table: the sysctl table
25661da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25671da177e4SLinus Torvalds  * @buffer: the user buffer
25681da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25691da177e4SLinus Torvalds  * @ppos: file position
25701da177e4SLinus Torvalds  *
25711da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
25721da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string. The values
25731da177e4SLinus Torvalds  * are treated as milliseconds, and converted to jiffies when they are stored.
25741da177e4SLinus Torvalds  *
25751da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
25761da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
25771da177e4SLinus Torvalds  *
25781da177e4SLinus Torvalds  * Returns 0 on success.
25791da177e4SLinus Torvalds  */
2580d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
25811da177e4SLinus Torvalds 				      void __user *buffer,
25821da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
25831da177e4SLinus Torvalds {
25848d65af78SAlexey Dobriyan     return do_proc_doulongvec_minmax(table, write, buffer,
25851da177e4SLinus Torvalds 				     lenp, ppos, HZ, 1000l);
25861da177e4SLinus Torvalds }
25871da177e4SLinus Torvalds 
25881da177e4SLinus Torvalds 
258900b7c339SAmerigo Wang static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
25901da177e4SLinus Torvalds 					 int *valp,
25911da177e4SLinus Torvalds 					 int write, void *data)
25921da177e4SLinus Torvalds {
25931da177e4SLinus Torvalds 	if (write) {
2594cba9f33dSBart Samwel 		if (*lvalp > LONG_MAX / HZ)
2595cba9f33dSBart Samwel 			return 1;
25961da177e4SLinus Torvalds 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
25971da177e4SLinus Torvalds 	} else {
25981da177e4SLinus Torvalds 		int val = *valp;
25991da177e4SLinus Torvalds 		unsigned long lval;
26001da177e4SLinus Torvalds 		if (val < 0) {
260100b7c339SAmerigo Wang 			*negp = true;
26021da177e4SLinus Torvalds 			lval = (unsigned long)-val;
26031da177e4SLinus Torvalds 		} else {
260400b7c339SAmerigo Wang 			*negp = false;
26051da177e4SLinus Torvalds 			lval = (unsigned long)val;
26061da177e4SLinus Torvalds 		}
26071da177e4SLinus Torvalds 		*lvalp = lval / HZ;
26081da177e4SLinus Torvalds 	}
26091da177e4SLinus Torvalds 	return 0;
26101da177e4SLinus Torvalds }
26111da177e4SLinus Torvalds 
261200b7c339SAmerigo Wang static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
26131da177e4SLinus Torvalds 						int *valp,
26141da177e4SLinus Torvalds 						int write, void *data)
26151da177e4SLinus Torvalds {
26161da177e4SLinus Torvalds 	if (write) {
2617cba9f33dSBart Samwel 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2618cba9f33dSBart Samwel 			return 1;
26191da177e4SLinus Torvalds 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
26201da177e4SLinus Torvalds 	} else {
26211da177e4SLinus Torvalds 		int val = *valp;
26221da177e4SLinus Torvalds 		unsigned long lval;
26231da177e4SLinus Torvalds 		if (val < 0) {
262400b7c339SAmerigo Wang 			*negp = true;
26251da177e4SLinus Torvalds 			lval = (unsigned long)-val;
26261da177e4SLinus Torvalds 		} else {
262700b7c339SAmerigo Wang 			*negp = false;
26281da177e4SLinus Torvalds 			lval = (unsigned long)val;
26291da177e4SLinus Torvalds 		}
26301da177e4SLinus Torvalds 		*lvalp = jiffies_to_clock_t(lval);
26311da177e4SLinus Torvalds 	}
26321da177e4SLinus Torvalds 	return 0;
26331da177e4SLinus Torvalds }
26341da177e4SLinus Torvalds 
263500b7c339SAmerigo Wang static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
26361da177e4SLinus Torvalds 					    int *valp,
26371da177e4SLinus Torvalds 					    int write, void *data)
26381da177e4SLinus Torvalds {
26391da177e4SLinus Torvalds 	if (write) {
26401da177e4SLinus Torvalds 		*valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
26411da177e4SLinus Torvalds 	} else {
26421da177e4SLinus Torvalds 		int val = *valp;
26431da177e4SLinus Torvalds 		unsigned long lval;
26441da177e4SLinus Torvalds 		if (val < 0) {
264500b7c339SAmerigo Wang 			*negp = true;
26461da177e4SLinus Torvalds 			lval = (unsigned long)-val;
26471da177e4SLinus Torvalds 		} else {
264800b7c339SAmerigo Wang 			*negp = false;
26491da177e4SLinus Torvalds 			lval = (unsigned long)val;
26501da177e4SLinus Torvalds 		}
26511da177e4SLinus Torvalds 		*lvalp = jiffies_to_msecs(lval);
26521da177e4SLinus Torvalds 	}
26531da177e4SLinus Torvalds 	return 0;
26541da177e4SLinus Torvalds }
26551da177e4SLinus Torvalds 
26561da177e4SLinus Torvalds /**
26571da177e4SLinus Torvalds  * proc_dointvec_jiffies - read a vector of integers as seconds
26581da177e4SLinus Torvalds  * @table: the sysctl table
26591da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
26601da177e4SLinus Torvalds  * @buffer: the user buffer
26611da177e4SLinus Torvalds  * @lenp: the size of the user buffer
26621da177e4SLinus Torvalds  * @ppos: file position
26631da177e4SLinus Torvalds  *
26641da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
26651da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
26661da177e4SLinus Torvalds  * The values read are assumed to be in seconds, and are converted into
26671da177e4SLinus Torvalds  * jiffies.
26681da177e4SLinus Torvalds  *
26691da177e4SLinus Torvalds  * Returns 0 on success.
26701da177e4SLinus Torvalds  */
26718d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write,
26721da177e4SLinus Torvalds 			  void __user *buffer, size_t *lenp, loff_t *ppos)
26731da177e4SLinus Torvalds {
26748d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
26751da177e4SLinus Torvalds 		    	    do_proc_dointvec_jiffies_conv,NULL);
26761da177e4SLinus Torvalds }
26771da177e4SLinus Torvalds 
26781da177e4SLinus Torvalds /**
26791da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
26801da177e4SLinus Torvalds  * @table: the sysctl table
26811da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
26821da177e4SLinus Torvalds  * @buffer: the user buffer
26831da177e4SLinus Torvalds  * @lenp: the size of the user buffer
26841e5d5331SRandy Dunlap  * @ppos: pointer to the file position
26851da177e4SLinus Torvalds  *
26861da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
26871da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
26881da177e4SLinus Torvalds  * The values read are assumed to be in 1/USER_HZ seconds, and
26891da177e4SLinus Torvalds  * are converted into jiffies.
26901da177e4SLinus Torvalds  *
26911da177e4SLinus Torvalds  * Returns 0 on success.
26921da177e4SLinus Torvalds  */
26938d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
26941da177e4SLinus Torvalds 				 void __user *buffer, size_t *lenp, loff_t *ppos)
26951da177e4SLinus Torvalds {
26968d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
26971da177e4SLinus Torvalds 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
26981da177e4SLinus Torvalds }
26991da177e4SLinus Torvalds 
27001da177e4SLinus Torvalds /**
27011da177e4SLinus Torvalds  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
27021da177e4SLinus Torvalds  * @table: the sysctl table
27031da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
27041da177e4SLinus Torvalds  * @buffer: the user buffer
27051da177e4SLinus Torvalds  * @lenp: the size of the user buffer
270667be2dd1SMartin Waitz  * @ppos: file position
270767be2dd1SMartin Waitz  * @ppos: the current position in the file
27081da177e4SLinus Torvalds  *
27091da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
27101da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
27111da177e4SLinus Torvalds  * The values read are assumed to be in 1/1000 seconds, and
27121da177e4SLinus Torvalds  * are converted into jiffies.
27131da177e4SLinus Torvalds  *
27141da177e4SLinus Torvalds  * Returns 0 on success.
27151da177e4SLinus Torvalds  */
27168d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
27171da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
27181da177e4SLinus Torvalds {
27198d65af78SAlexey Dobriyan 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
27201da177e4SLinus Torvalds 				do_proc_dointvec_ms_jiffies_conv, NULL);
27211da177e4SLinus Torvalds }
27221da177e4SLinus Torvalds 
27238d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write,
27249ec52099SCedric Le Goater 			   void __user *buffer, size_t *lenp, loff_t *ppos)
27259ec52099SCedric Le Goater {
27269ec52099SCedric Le Goater 	struct pid *new_pid;
27279ec52099SCedric Le Goater 	pid_t tmp;
27289ec52099SCedric Le Goater 	int r;
27299ec52099SCedric Le Goater 
27306c5f3e7bSPavel Emelyanov 	tmp = pid_vnr(cad_pid);
27319ec52099SCedric Le Goater 
27328d65af78SAlexey Dobriyan 	r = __do_proc_dointvec(&tmp, table, write, buffer,
27339ec52099SCedric Le Goater 			       lenp, ppos, NULL, NULL);
27349ec52099SCedric Le Goater 	if (r || !write)
27359ec52099SCedric Le Goater 		return r;
27369ec52099SCedric Le Goater 
27379ec52099SCedric Le Goater 	new_pid = find_get_pid(tmp);
27389ec52099SCedric Le Goater 	if (!new_pid)
27399ec52099SCedric Le Goater 		return -ESRCH;
27409ec52099SCedric Le Goater 
27419ec52099SCedric Le Goater 	put_pid(xchg(&cad_pid, new_pid));
27429ec52099SCedric Le Goater 	return 0;
27439ec52099SCedric Le Goater }
27449ec52099SCedric Le Goater 
27459f977fb7SOctavian Purdila /**
27469f977fb7SOctavian Purdila  * proc_do_large_bitmap - read/write from/to a large bitmap
27479f977fb7SOctavian Purdila  * @table: the sysctl table
27489f977fb7SOctavian Purdila  * @write: %TRUE if this is a write to the sysctl file
27499f977fb7SOctavian Purdila  * @buffer: the user buffer
27509f977fb7SOctavian Purdila  * @lenp: the size of the user buffer
27519f977fb7SOctavian Purdila  * @ppos: file position
27529f977fb7SOctavian Purdila  *
27539f977fb7SOctavian Purdila  * The bitmap is stored at table->data and the bitmap length (in bits)
27549f977fb7SOctavian Purdila  * in table->maxlen.
27559f977fb7SOctavian Purdila  *
27569f977fb7SOctavian Purdila  * We use a range comma separated format (e.g. 1,3-4,10-10) so that
27579f977fb7SOctavian Purdila  * large bitmaps may be represented in a compact manner. Writing into
27589f977fb7SOctavian Purdila  * the file will clear the bitmap then update it with the given input.
27599f977fb7SOctavian Purdila  *
27609f977fb7SOctavian Purdila  * Returns 0 on success.
27619f977fb7SOctavian Purdila  */
27629f977fb7SOctavian Purdila int proc_do_large_bitmap(struct ctl_table *table, int write,
27639f977fb7SOctavian Purdila 			 void __user *buffer, size_t *lenp, loff_t *ppos)
27649f977fb7SOctavian Purdila {
27659f977fb7SOctavian Purdila 	int err = 0;
27669f977fb7SOctavian Purdila 	bool first = 1;
27679f977fb7SOctavian Purdila 	size_t left = *lenp;
27689f977fb7SOctavian Purdila 	unsigned long bitmap_len = table->maxlen;
27699f977fb7SOctavian Purdila 	unsigned long *bitmap = (unsigned long *) table->data;
27709f977fb7SOctavian Purdila 	unsigned long *tmp_bitmap = NULL;
27719f977fb7SOctavian Purdila 	char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
27729f977fb7SOctavian Purdila 
27739f977fb7SOctavian Purdila 	if (!bitmap_len || !left || (*ppos && !write)) {
27749f977fb7SOctavian Purdila 		*lenp = 0;
27759f977fb7SOctavian Purdila 		return 0;
27769f977fb7SOctavian Purdila 	}
27779f977fb7SOctavian Purdila 
27789f977fb7SOctavian Purdila 	if (write) {
27799f977fb7SOctavian Purdila 		unsigned long page = 0;
27809f977fb7SOctavian Purdila 		char *kbuf;
27819f977fb7SOctavian Purdila 
27829f977fb7SOctavian Purdila 		if (left > PAGE_SIZE - 1)
27839f977fb7SOctavian Purdila 			left = PAGE_SIZE - 1;
27849f977fb7SOctavian Purdila 
27859f977fb7SOctavian Purdila 		page = __get_free_page(GFP_TEMPORARY);
27869f977fb7SOctavian Purdila 		kbuf = (char *) page;
27879f977fb7SOctavian Purdila 		if (!kbuf)
27889f977fb7SOctavian Purdila 			return -ENOMEM;
27899f977fb7SOctavian Purdila 		if (copy_from_user(kbuf, buffer, left)) {
27909f977fb7SOctavian Purdila 			free_page(page);
27919f977fb7SOctavian Purdila 			return -EFAULT;
27929f977fb7SOctavian Purdila                 }
27939f977fb7SOctavian Purdila 		kbuf[left] = 0;
27949f977fb7SOctavian Purdila 
27959f977fb7SOctavian Purdila 		tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
27969f977fb7SOctavian Purdila 				     GFP_KERNEL);
27979f977fb7SOctavian Purdila 		if (!tmp_bitmap) {
27989f977fb7SOctavian Purdila 			free_page(page);
27999f977fb7SOctavian Purdila 			return -ENOMEM;
28009f977fb7SOctavian Purdila 		}
28019f977fb7SOctavian Purdila 		proc_skip_char(&kbuf, &left, '\n');
28029f977fb7SOctavian Purdila 		while (!err && left) {
28039f977fb7SOctavian Purdila 			unsigned long val_a, val_b;
28049f977fb7SOctavian Purdila 			bool neg;
28059f977fb7SOctavian Purdila 
28069f977fb7SOctavian Purdila 			err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
28079f977fb7SOctavian Purdila 					     sizeof(tr_a), &c);
28089f977fb7SOctavian Purdila 			if (err)
28099f977fb7SOctavian Purdila 				break;
28109f977fb7SOctavian Purdila 			if (val_a >= bitmap_len || neg) {
28119f977fb7SOctavian Purdila 				err = -EINVAL;
28129f977fb7SOctavian Purdila 				break;
28139f977fb7SOctavian Purdila 			}
28149f977fb7SOctavian Purdila 
28159f977fb7SOctavian Purdila 			val_b = val_a;
28169f977fb7SOctavian Purdila 			if (left) {
28179f977fb7SOctavian Purdila 				kbuf++;
28189f977fb7SOctavian Purdila 				left--;
28199f977fb7SOctavian Purdila 			}
28209f977fb7SOctavian Purdila 
28219f977fb7SOctavian Purdila 			if (c == '-') {
28229f977fb7SOctavian Purdila 				err = proc_get_long(&kbuf, &left, &val_b,
28239f977fb7SOctavian Purdila 						     &neg, tr_b, sizeof(tr_b),
28249f977fb7SOctavian Purdila 						     &c);
28259f977fb7SOctavian Purdila 				if (err)
28269f977fb7SOctavian Purdila 					break;
28279f977fb7SOctavian Purdila 				if (val_b >= bitmap_len || neg ||
28289f977fb7SOctavian Purdila 				    val_a > val_b) {
28299f977fb7SOctavian Purdila 					err = -EINVAL;
28309f977fb7SOctavian Purdila 					break;
28319f977fb7SOctavian Purdila 				}
28329f977fb7SOctavian Purdila 				if (left) {
28339f977fb7SOctavian Purdila 					kbuf++;
28349f977fb7SOctavian Purdila 					left--;
28359f977fb7SOctavian Purdila 				}
28369f977fb7SOctavian Purdila 			}
28379f977fb7SOctavian Purdila 
28389f977fb7SOctavian Purdila 			while (val_a <= val_b)
28399f977fb7SOctavian Purdila 				set_bit(val_a++, tmp_bitmap);
28409f977fb7SOctavian Purdila 
28419f977fb7SOctavian Purdila 			first = 0;
28429f977fb7SOctavian Purdila 			proc_skip_char(&kbuf, &left, '\n');
28439f977fb7SOctavian Purdila 		}
28449f977fb7SOctavian Purdila 		free_page(page);
28459f977fb7SOctavian Purdila 	} else {
28469f977fb7SOctavian Purdila 		unsigned long bit_a, bit_b = 0;
28479f977fb7SOctavian Purdila 
28489f977fb7SOctavian Purdila 		while (left) {
28499f977fb7SOctavian Purdila 			bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
28509f977fb7SOctavian Purdila 			if (bit_a >= bitmap_len)
28519f977fb7SOctavian Purdila 				break;
28529f977fb7SOctavian Purdila 			bit_b = find_next_zero_bit(bitmap, bitmap_len,
28539f977fb7SOctavian Purdila 						   bit_a + 1) - 1;
28549f977fb7SOctavian Purdila 
28559f977fb7SOctavian Purdila 			if (!first) {
28569f977fb7SOctavian Purdila 				err = proc_put_char(&buffer, &left, ',');
28579f977fb7SOctavian Purdila 				if (err)
28589f977fb7SOctavian Purdila 					break;
28599f977fb7SOctavian Purdila 			}
28609f977fb7SOctavian Purdila 			err = proc_put_long(&buffer, &left, bit_a, false);
28619f977fb7SOctavian Purdila 			if (err)
28629f977fb7SOctavian Purdila 				break;
28639f977fb7SOctavian Purdila 			if (bit_a != bit_b) {
28649f977fb7SOctavian Purdila 				err = proc_put_char(&buffer, &left, '-');
28659f977fb7SOctavian Purdila 				if (err)
28669f977fb7SOctavian Purdila 					break;
28679f977fb7SOctavian Purdila 				err = proc_put_long(&buffer, &left, bit_b, false);
28689f977fb7SOctavian Purdila 				if (err)
28699f977fb7SOctavian Purdila 					break;
28709f977fb7SOctavian Purdila 			}
28719f977fb7SOctavian Purdila 
28729f977fb7SOctavian Purdila 			first = 0; bit_b++;
28739f977fb7SOctavian Purdila 		}
28749f977fb7SOctavian Purdila 		if (!err)
28759f977fb7SOctavian Purdila 			err = proc_put_char(&buffer, &left, '\n');
28769f977fb7SOctavian Purdila 	}
28779f977fb7SOctavian Purdila 
28789f977fb7SOctavian Purdila 	if (!err) {
28799f977fb7SOctavian Purdila 		if (write) {
28809f977fb7SOctavian Purdila 			if (*ppos)
28819f977fb7SOctavian Purdila 				bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
28829f977fb7SOctavian Purdila 			else
28839f977fb7SOctavian Purdila 				memcpy(bitmap, tmp_bitmap,
28849f977fb7SOctavian Purdila 					BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long));
28859f977fb7SOctavian Purdila 		}
28869f977fb7SOctavian Purdila 		kfree(tmp_bitmap);
28879f977fb7SOctavian Purdila 		*lenp -= left;
28889f977fb7SOctavian Purdila 		*ppos += *lenp;
28899f977fb7SOctavian Purdila 		return 0;
28909f977fb7SOctavian Purdila 	} else {
28919f977fb7SOctavian Purdila 		kfree(tmp_bitmap);
28929f977fb7SOctavian Purdila 		return err;
28939f977fb7SOctavian Purdila 	}
28949f977fb7SOctavian Purdila }
28959f977fb7SOctavian Purdila 
28961da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */
28971da177e4SLinus Torvalds 
28988d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write,
28991da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
29001da177e4SLinus Torvalds {
29011da177e4SLinus Torvalds 	return -ENOSYS;
29021da177e4SLinus Torvalds }
29031da177e4SLinus Torvalds 
29048d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write,
29051da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
29061da177e4SLinus Torvalds {
29071da177e4SLinus Torvalds 	return -ENOSYS;
29081da177e4SLinus Torvalds }
29091da177e4SLinus Torvalds 
29108d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write,
29111da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
29121da177e4SLinus Torvalds {
29131da177e4SLinus Torvalds 	return -ENOSYS;
29141da177e4SLinus Torvalds }
29151da177e4SLinus Torvalds 
29168d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write,
29171da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
29181da177e4SLinus Torvalds {
29191da177e4SLinus Torvalds 	return -ENOSYS;
29201da177e4SLinus Torvalds }
29211da177e4SLinus Torvalds 
29228d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
29231da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
29241da177e4SLinus Torvalds {
29251da177e4SLinus Torvalds 	return -ENOSYS;
29261da177e4SLinus Torvalds }
29271da177e4SLinus Torvalds 
29288d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
29291da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
29301da177e4SLinus Torvalds {
29311da177e4SLinus Torvalds 	return -ENOSYS;
29321da177e4SLinus Torvalds }
29331da177e4SLinus Torvalds 
29348d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write,
29351da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
29361da177e4SLinus Torvalds {
29371da177e4SLinus Torvalds 	return -ENOSYS;
29381da177e4SLinus Torvalds }
29391da177e4SLinus Torvalds 
2940d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
29411da177e4SLinus Torvalds 				      void __user *buffer,
29421da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
29431da177e4SLinus Torvalds {
29441da177e4SLinus Torvalds     return -ENOSYS;
29451da177e4SLinus Torvalds }
29461da177e4SLinus Torvalds 
29471da177e4SLinus Torvalds 
29481da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */
29491da177e4SLinus Torvalds 
29501da177e4SLinus Torvalds /*
29511da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
29521da177e4SLinus Torvalds  * exception granted :-)
29531da177e4SLinus Torvalds  */
29541da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
29551da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
29561da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
29571da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
29581da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
29591da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
29601da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
29611da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
29621da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table);
296329e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths);
29641da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table);
2965