xref: /openbmc/linux/kernel/sysctl.c (revision 6fce56ec91b502ba6fcbbc2a6d25a8c2c7f77934)
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>
261da177e4SLinus Torvalds #include <linux/proc_fs.h>
2772c2d582SAndrew Morgan #include <linux/security.h>
281da177e4SLinus Torvalds #include <linux/ctype.h>
29dfec072eSVegard Nossum #include <linux/kmemcheck.h>
3062239ac2SAdrian Bunk #include <linux/fs.h>
311da177e4SLinus Torvalds #include <linux/init.h>
321da177e4SLinus Torvalds #include <linux/kernel.h>
330296b228SKay Sievers #include <linux/kobject.h>
3420380731SArnaldo Carvalho de Melo #include <linux/net.h>
351da177e4SLinus Torvalds #include <linux/sysrq.h>
361da177e4SLinus Torvalds #include <linux/highuid.h>
371da177e4SLinus Torvalds #include <linux/writeback.h>
381da177e4SLinus Torvalds #include <linux/hugetlb.h>
391da177e4SLinus Torvalds #include <linux/initrd.h>
400b77f5bfSDavid Howells #include <linux/key.h>
411da177e4SLinus Torvalds #include <linux/times.h>
421da177e4SLinus Torvalds #include <linux/limits.h>
431da177e4SLinus Torvalds #include <linux/dcache.h>
441da177e4SLinus Torvalds #include <linux/syscalls.h>
45c748e134SAdrian Bunk #include <linux/vmstat.h>
46c255d844SPavel Machek #include <linux/nfs_fs.h>
47c255d844SPavel Machek #include <linux/acpi.h>
4810a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h>
49b0fc494fSSteven Rostedt #include <linux/ftrace.h>
5012e22c5eSDavid Howells #include <linux/slow-work.h>
51cdd6c482SIngo Molnar #include <linux/perf_event.h>
521da177e4SLinus Torvalds 
531da177e4SLinus Torvalds #include <asm/uaccess.h>
541da177e4SLinus Torvalds #include <asm/processor.h>
551da177e4SLinus Torvalds 
5629cbc78bSAndi Kleen #ifdef CONFIG_X86
5729cbc78bSAndi Kleen #include <asm/nmi.h>
580741f4d2SChuck Ebbert #include <asm/stacktrace.h>
596e7c4025SIngo Molnar #include <asm/io.h>
6029cbc78bSAndi Kleen #endif
6129cbc78bSAndi Kleen 
627058cb02SEric W. Biederman 
631da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL)
641da177e4SLinus Torvalds 
651da177e4SLinus Torvalds /* External variables not in a header file. */
661da177e4SLinus Torvalds extern int C_A_D;
6745807a1dSIngo Molnar extern int print_fatal_signals;
681da177e4SLinus Torvalds extern int sysctl_overcommit_memory;
691da177e4SLinus Torvalds extern int sysctl_overcommit_ratio;
70fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom;
71fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task;
72fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks;
731da177e4SLinus Torvalds extern int max_threads;
741da177e4SLinus Torvalds extern int core_uses_pid;
75d6e71144SAlan Cox extern int suid_dumpable;
761da177e4SLinus Torvalds extern char core_pattern[];
77a293980cSNeil Horman extern unsigned int core_pipe_limit;
781da177e4SLinus Torvalds extern int pid_max;
791da177e4SLinus Torvalds extern int min_free_kbytes;
801da177e4SLinus Torvalds extern int pid_max_min, pid_max_max;
819d0243bcSAndrew Morton extern int sysctl_drop_caches;
828ad4b1fbSRohit Seth extern int percpu_pagelist_fraction;
83bebfa101SAndi Kleen extern int compat_log;
849745512cSArjan van de Ven extern int latencytop_enabled;
85eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max;
86dd8632a1SPaul Mundt #ifndef CONFIG_MMU
87dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages;
88dd8632a1SPaul Mundt #endif
8931a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
9031a72bceSPaul E. McKenney extern int rcutorture_runnable;
9131a72bceSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
92cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
935e605b64SJens Axboe extern int blk_iopoll_enabled;
94cb684b5bSJens Axboe #endif
951da177e4SLinus Torvalds 
96c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and  maximum */
97195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP
98c4f3b63fSRavikiran G Thirumalai static int sixty = 60;
999383d967SDimitri Sivanich static int neg_one = -1;
100c4f3b63fSRavikiran G Thirumalai #endif
101c4f3b63fSRavikiran G Thirumalai 
102c4f3b63fSRavikiran G Thirumalai static int zero;
103cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1;
104cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2;
105fc3501d4SSven Wegener static unsigned long one_ul = 1;
106c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100;
107af91322eSDave Young #ifdef CONFIG_PRINTK
108af91322eSDave Young static int ten_thousand = 10000;
109af91322eSDave Young #endif
110c4f3b63fSRavikiran G Thirumalai 
1119e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
1129e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1139e4a5bdaSAndrea Righi 
1141da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1151da177e4SLinus Torvalds static int maxolduid = 65535;
1161da177e4SLinus Torvalds static int minolduid;
1178ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8;
1181da177e4SLinus Torvalds 
1191da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
1201da177e4SLinus Torvalds 
121a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
1221da177e4SLinus Torvalds extern char modprobe_path[];
1233d43321bSKees Cook extern int modules_disabled;
1241da177e4SLinus Torvalds #endif
1251da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
1261da177e4SLinus Torvalds extern int sg_big_buff;
1271da177e4SLinus Torvalds #endif
1281da177e4SLinus Torvalds 
12972c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
13017f04fbbSDavid S. Miller #include <asm/system.h>
1311da177e4SLinus Torvalds #endif
1321da177e4SLinus Torvalds 
1330871420fSDavid S. Miller #ifdef CONFIG_SPARC64
1340871420fSDavid S. Miller extern int sysctl_tsb_ratio;
1350871420fSDavid S. Miller #endif
1360871420fSDavid S. Miller 
1371da177e4SLinus Torvalds #ifdef __hppa__
1381da177e4SLinus Torvalds extern int pwrsw_enabled;
1391da177e4SLinus Torvalds extern int unaligned_enabled;
1401da177e4SLinus Torvalds #endif
1411da177e4SLinus Torvalds 
142347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
1431da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
1441da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings;
1451da177e4SLinus Torvalds #endif
1461da177e4SLinus Torvalds extern int sysctl_userprocess_debug;
147951f22d5SMartin Schwidefsky extern int spin_retry;
1481da177e4SLinus Torvalds #endif
1491da177e4SLinus Torvalds 
1501da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
1511da177e4SLinus Torvalds extern int acct_parm[];
1521da177e4SLinus Torvalds #endif
1531da177e4SLinus Torvalds 
154d2b176edSJes Sorensen #ifdef CONFIG_IA64
155d2b176edSJes Sorensen extern int no_unaligned_warning;
15688fc241fSDoug Chapman extern int unaligned_dump_stack;
157d2b176edSJes Sorensen #endif
158d2b176edSJes Sorensen 
15923f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
16023f78d4aSIngo Molnar extern int max_lock_depth;
16123f78d4aSIngo Molnar #endif
16223f78d4aSIngo Molnar 
163d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
1648d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write,
1659ec52099SCedric Le Goater 		  void __user *buffer, size_t *lenp, loff_t *ppos);
1668d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write,
16734f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos);
168d6f8ff73SRandy Dunlap #endif
1699ec52099SCedric Le Goater 
170d8217f07SEric W. Biederman static struct ctl_table root_table[];
171e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root;
172e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = {
173b380b0d4SAl Viro 	.count = 1,
174e51b6ba0SEric W. Biederman 	.ctl_table = root_table,
17573455092SAl Viro 	.ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
176e51b6ba0SEric W. Biederman 	.root = &sysctl_table_root,
17773455092SAl Viro 	.set = &sysctl_table_root.default_set,
178e51b6ba0SEric W. Biederman };
179e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = {
180e51b6ba0SEric W. Biederman 	.root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
18173455092SAl Viro 	.default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
182e51b6ba0SEric W. Biederman };
1831da177e4SLinus Torvalds 
184d8217f07SEric W. Biederman static struct ctl_table kern_table[];
185d8217f07SEric W. Biederman static struct ctl_table vm_table[];
186d8217f07SEric W. Biederman static struct ctl_table fs_table[];
187d8217f07SEric W. Biederman static struct ctl_table debug_table[];
188d8217f07SEric W. Biederman static struct ctl_table dev_table[];
189d8217f07SEric W. Biederman extern struct ctl_table random_table[];
1902d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
191d8217f07SEric W. Biederman extern struct ctl_table inotify_table[];
1920399cb08SRobert Love #endif
1937ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
1947ef9964eSDavide Libenzi extern struct ctl_table epoll_table[];
1957ef9964eSDavide Libenzi #endif
1961da177e4SLinus Torvalds 
1971da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1981da177e4SLinus Torvalds int sysctl_legacy_va_layout;
1991da177e4SLinus Torvalds #endif
2001da177e4SLinus Torvalds 
201f20786ffSPeter Zijlstra extern int prove_locking;
202f20786ffSPeter Zijlstra extern int lock_stat;
2039bc9a6bdSEric W. Biederman 
2041da177e4SLinus Torvalds /* The default sysctl tables: */
2051da177e4SLinus Torvalds 
206d8217f07SEric W. Biederman static struct ctl_table root_table[] = {
2071da177e4SLinus Torvalds 	{
2081da177e4SLinus Torvalds 		.procname	= "kernel",
2091da177e4SLinus Torvalds 		.mode		= 0555,
2101da177e4SLinus Torvalds 		.child		= kern_table,
2111da177e4SLinus Torvalds 	},
2121da177e4SLinus Torvalds 	{
2131da177e4SLinus Torvalds 		.procname	= "vm",
2141da177e4SLinus Torvalds 		.mode		= 0555,
2151da177e4SLinus Torvalds 		.child		= vm_table,
2161da177e4SLinus Torvalds 	},
2171da177e4SLinus Torvalds 	{
2181da177e4SLinus Torvalds 		.procname	= "fs",
2191da177e4SLinus Torvalds 		.mode		= 0555,
2201da177e4SLinus Torvalds 		.child		= fs_table,
2211da177e4SLinus Torvalds 	},
2221da177e4SLinus Torvalds 	{
2231da177e4SLinus Torvalds 		.procname	= "debug",
2241da177e4SLinus Torvalds 		.mode		= 0555,
2251da177e4SLinus Torvalds 		.child		= debug_table,
2261da177e4SLinus Torvalds 	},
2271da177e4SLinus Torvalds 	{
2281da177e4SLinus Torvalds 		.procname	= "dev",
2291da177e4SLinus Torvalds 		.mode		= 0555,
2301da177e4SLinus Torvalds 		.child		= dev_table,
2311da177e4SLinus Torvalds 	},
2322be7fe07SAndrew Morton /*
2332be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
2342be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
2352be7fe07SAndrew Morton  */
236*6fce56ecSEric W. Biederman 	{ }
2371da177e4SLinus Torvalds };
2381da177e4SLinus Torvalds 
23977e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
24073c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000;		/* 100 usecs */
24173c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
24273c4efd2SEric Dumazet static int min_wakeup_granularity_ns;			/* 0 usecs */
24373c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
24477e54a1fSIngo Molnar #endif
24577e54a1fSIngo Molnar 
246d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
2472bba22c5SMike Galbraith 	{
2482bba22c5SMike Galbraith 		.procname	= "sched_child_runs_first",
2492bba22c5SMike Galbraith 		.data		= &sysctl_sched_child_runs_first,
2502bba22c5SMike Galbraith 		.maxlen		= sizeof(unsigned int),
2512bba22c5SMike Galbraith 		.mode		= 0644,
2522bba22c5SMike Galbraith 		.proc_handler	= &proc_dointvec,
2532bba22c5SMike Galbraith 	},
25477e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
25577e54a1fSIngo Molnar 	{
256b2be5e96SPeter Zijlstra 		.procname	= "sched_min_granularity_ns",
257b2be5e96SPeter Zijlstra 		.data		= &sysctl_sched_min_granularity,
25877e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
25977e54a1fSIngo Molnar 		.mode		= 0644,
260b2be5e96SPeter Zijlstra 		.proc_handler	= &sched_nr_latency_handler,
261b2be5e96SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
262b2be5e96SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
26377e54a1fSIngo Molnar 	},
26477e54a1fSIngo Molnar 	{
26521805085SPeter Zijlstra 		.procname	= "sched_latency_ns",
26621805085SPeter Zijlstra 		.data		= &sysctl_sched_latency,
26721805085SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
26821805085SPeter Zijlstra 		.mode		= 0644,
269b2be5e96SPeter Zijlstra 		.proc_handler	= &sched_nr_latency_handler,
27021805085SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
27121805085SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
27221805085SPeter Zijlstra 	},
27321805085SPeter Zijlstra 	{
27477e54a1fSIngo Molnar 		.procname	= "sched_wakeup_granularity_ns",
27577e54a1fSIngo Molnar 		.data		= &sysctl_sched_wakeup_granularity,
27677e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
27777e54a1fSIngo Molnar 		.mode		= 0644,
27877e54a1fSIngo Molnar 		.proc_handler	= &proc_dointvec_minmax,
27977e54a1fSIngo Molnar 		.extra1		= &min_wakeup_granularity_ns,
28077e54a1fSIngo Molnar 		.extra2		= &max_wakeup_granularity_ns,
28177e54a1fSIngo Molnar 	},
28277e54a1fSIngo Molnar 	{
2832398f2c6SPeter Zijlstra 		.procname	= "sched_shares_ratelimit",
2842398f2c6SPeter Zijlstra 		.data		= &sysctl_sched_shares_ratelimit,
2852398f2c6SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
2862398f2c6SPeter Zijlstra 		.mode		= 0644,
2872398f2c6SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
2882398f2c6SPeter Zijlstra 	},
2892398f2c6SPeter Zijlstra 	{
290ffda12a1SPeter Zijlstra 		.procname	= "sched_shares_thresh",
291ffda12a1SPeter Zijlstra 		.data		= &sysctl_sched_shares_thresh,
292ffda12a1SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
293ffda12a1SPeter Zijlstra 		.mode		= 0644,
294ffda12a1SPeter Zijlstra 		.proc_handler	= &proc_dointvec_minmax,
295ffda12a1SPeter Zijlstra 		.extra1		= &zero,
296ffda12a1SPeter Zijlstra 	},
297ffda12a1SPeter Zijlstra 	{
2981fc84aaaSPeter Zijlstra 		.procname	= "sched_features",
2991fc84aaaSPeter Zijlstra 		.data		= &sysctl_sched_features,
3001fc84aaaSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3011fc84aaaSPeter Zijlstra 		.mode		= 0644,
3021fc84aaaSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
3031fc84aaaSPeter Zijlstra 	},
304da84d961SIngo Molnar 	{
305da84d961SIngo Molnar 		.procname	= "sched_migration_cost",
306da84d961SIngo Molnar 		.data		= &sysctl_sched_migration_cost,
307da84d961SIngo Molnar 		.maxlen		= sizeof(unsigned int),
308da84d961SIngo Molnar 		.mode		= 0644,
309da84d961SIngo Molnar 		.proc_handler	= &proc_dointvec,
310da84d961SIngo Molnar 	},
311b82d9fddSPeter Zijlstra 	{
312b82d9fddSPeter Zijlstra 		.procname	= "sched_nr_migrate",
313b82d9fddSPeter Zijlstra 		.data		= &sysctl_sched_nr_migrate,
314b82d9fddSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
315fa85ae24SPeter Zijlstra 		.mode		= 0644,
316fa85ae24SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
317fa85ae24SPeter Zijlstra 	},
318cd1bb94bSArun R Bharadwaj 	{
319e9e9250bSPeter Zijlstra 		.procname	= "sched_time_avg",
320e9e9250bSPeter Zijlstra 		.data		= &sysctl_sched_time_avg,
321e9e9250bSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
322e9e9250bSPeter Zijlstra 		.mode		= 0644,
323e9e9250bSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
324e9e9250bSPeter Zijlstra 	},
325e9e9250bSPeter Zijlstra 	{
326cd1bb94bSArun R Bharadwaj 		.procname	= "timer_migration",
327cd1bb94bSArun R Bharadwaj 		.data		= &sysctl_timer_migration,
328cd1bb94bSArun R Bharadwaj 		.maxlen		= sizeof(unsigned int),
329cd1bb94bSArun R Bharadwaj 		.mode		= 0644,
330bfdb4d9fSArun R Bharadwaj 		.proc_handler	= &proc_dointvec_minmax,
331bfdb4d9fSArun R Bharadwaj 		.extra1		= &zero,
332bfdb4d9fSArun R Bharadwaj 		.extra2		= &one,
333cd1bb94bSArun R Bharadwaj 	},
3341fc84aaaSPeter Zijlstra #endif
3351799e35dSIngo Molnar 	{
3369f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
3379f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
3389f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3399f0c1e56SPeter Zijlstra 		.mode		= 0644,
340d0b27fa7SPeter Zijlstra 		.proc_handler	= &sched_rt_handler,
3419f0c1e56SPeter Zijlstra 	},
3429f0c1e56SPeter Zijlstra 	{
3439f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
3449f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
3459f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
3469f0c1e56SPeter Zijlstra 		.mode		= 0644,
347d0b27fa7SPeter Zijlstra 		.proc_handler	= &sched_rt_handler,
3489f0c1e56SPeter Zijlstra 	},
3499f0c1e56SPeter Zijlstra 	{
3501799e35dSIngo Molnar 		.procname	= "sched_compat_yield",
3511799e35dSIngo Molnar 		.data		= &sysctl_sched_compat_yield,
3521799e35dSIngo Molnar 		.maxlen		= sizeof(unsigned int),
3531799e35dSIngo Molnar 		.mode		= 0644,
3541799e35dSIngo Molnar 		.proc_handler	= &proc_dointvec,
3551799e35dSIngo Molnar 	},
356f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
357f20786ffSPeter Zijlstra 	{
358f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
359f20786ffSPeter Zijlstra 		.data		= &prove_locking,
360f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
361f20786ffSPeter Zijlstra 		.mode		= 0644,
362f20786ffSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
363f20786ffSPeter Zijlstra 	},
364f20786ffSPeter Zijlstra #endif
365f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
366f20786ffSPeter Zijlstra 	{
367f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
368f20786ffSPeter Zijlstra 		.data		= &lock_stat,
369f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
370f20786ffSPeter Zijlstra 		.mode		= 0644,
371f20786ffSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
372f20786ffSPeter Zijlstra 	},
373f20786ffSPeter Zijlstra #endif
37477e54a1fSIngo Molnar 	{
3751da177e4SLinus Torvalds 		.procname	= "panic",
3761da177e4SLinus Torvalds 		.data		= &panic_timeout,
3771da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
3781da177e4SLinus Torvalds 		.mode		= 0644,
3791da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
3801da177e4SLinus Torvalds 	},
3811da177e4SLinus Torvalds 	{
3821da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
3831da177e4SLinus Torvalds 		.data		= &core_uses_pid,
3841da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
3851da177e4SLinus Torvalds 		.mode		= 0644,
3861da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
3871da177e4SLinus Torvalds 	},
3881da177e4SLinus Torvalds 	{
3891da177e4SLinus Torvalds 		.procname	= "core_pattern",
3901da177e4SLinus Torvalds 		.data		= core_pattern,
39171ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
3921da177e4SLinus Torvalds 		.mode		= 0644,
3931da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
3941da177e4SLinus Torvalds 	},
395a293980cSNeil Horman 	{
396a293980cSNeil Horman 		.procname	= "core_pipe_limit",
397a293980cSNeil Horman 		.data		= &core_pipe_limit,
398a293980cSNeil Horman 		.maxlen		= sizeof(unsigned int),
399a293980cSNeil Horman 		.mode		= 0644,
400a293980cSNeil Horman 		.proc_handler	= &proc_dointvec,
401a293980cSNeil Horman 	},
40234f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
4031da177e4SLinus Torvalds 	{
4041da177e4SLinus Torvalds 		.procname	= "tainted",
40525ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
40634f5a398STheodore Ts'o 		.mode		= 0644,
40725ddbb18SAndi Kleen 		.proc_handler	= &proc_taint,
4081da177e4SLinus Torvalds 	},
40934f5a398STheodore Ts'o #endif
4109745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
4119745512cSArjan van de Ven 	{
4129745512cSArjan van de Ven 		.procname	= "latencytop",
4139745512cSArjan van de Ven 		.data		= &latencytop_enabled,
4149745512cSArjan van de Ven 		.maxlen		= sizeof(int),
4159745512cSArjan van de Ven 		.mode		= 0644,
4169745512cSArjan van de Ven 		.proc_handler	= &proc_dointvec,
4179745512cSArjan van de Ven 	},
4189745512cSArjan van de Ven #endif
4191da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
4201da177e4SLinus Torvalds 	{
4211da177e4SLinus Torvalds 		.procname	= "real-root-dev",
4221da177e4SLinus Torvalds 		.data		= &real_root_dev,
4231da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4241da177e4SLinus Torvalds 		.mode		= 0644,
4251da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4261da177e4SLinus Torvalds 	},
4271da177e4SLinus Torvalds #endif
42845807a1dSIngo Molnar 	{
42945807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
43045807a1dSIngo Molnar 		.data		= &print_fatal_signals,
43145807a1dSIngo Molnar 		.maxlen		= sizeof(int),
43245807a1dSIngo Molnar 		.mode		= 0644,
43345807a1dSIngo Molnar 		.proc_handler	= &proc_dointvec,
43445807a1dSIngo Molnar 	},
43572c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
4361da177e4SLinus Torvalds 	{
4371da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
4381da177e4SLinus Torvalds 		.data		= reboot_command,
4391da177e4SLinus Torvalds 		.maxlen		= 256,
4401da177e4SLinus Torvalds 		.mode		= 0644,
4411da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
4421da177e4SLinus Torvalds 	},
4431da177e4SLinus Torvalds 	{
4441da177e4SLinus Torvalds 		.procname	= "stop-a",
4451da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
4461da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4471da177e4SLinus Torvalds 		.mode		= 0644,
4481da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4491da177e4SLinus Torvalds 	},
4501da177e4SLinus Torvalds 	{
4511da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
4521da177e4SLinus Torvalds 		.data		= &scons_pwroff,
4531da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4541da177e4SLinus Torvalds 		.mode		= 0644,
4551da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4561da177e4SLinus Torvalds 	},
4571da177e4SLinus Torvalds #endif
4580871420fSDavid S. Miller #ifdef CONFIG_SPARC64
4590871420fSDavid S. Miller 	{
4600871420fSDavid S. Miller 		.procname	= "tsb-ratio",
4610871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
4620871420fSDavid S. Miller 		.maxlen		= sizeof (int),
4630871420fSDavid S. Miller 		.mode		= 0644,
4640871420fSDavid S. Miller 		.proc_handler	= &proc_dointvec,
4650871420fSDavid S. Miller 	},
4660871420fSDavid S. Miller #endif
4671da177e4SLinus Torvalds #ifdef __hppa__
4681da177e4SLinus Torvalds 	{
4691da177e4SLinus Torvalds 		.procname	= "soft-power",
4701da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
4711da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4721da177e4SLinus Torvalds 	 	.mode		= 0644,
4731da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4741da177e4SLinus Torvalds 	},
4751da177e4SLinus Torvalds 	{
4761da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
4771da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
4781da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4791da177e4SLinus Torvalds 		.mode		= 0644,
4801da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4811da177e4SLinus Torvalds 	},
4821da177e4SLinus Torvalds #endif
4831da177e4SLinus Torvalds 	{
4841da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
4851da177e4SLinus Torvalds 		.data		= &C_A_D,
4861da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4871da177e4SLinus Torvalds 		.mode		= 0644,
4881da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4891da177e4SLinus Torvalds 	},
490606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
491b0fc494fSSteven Rostedt 	{
492b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
493b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
494b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
495b0fc494fSSteven Rostedt 		.mode		= 0644,
496b0fc494fSSteven Rostedt 		.proc_handler	= &ftrace_enable_sysctl,
497b0fc494fSSteven Rostedt 	},
498b0fc494fSSteven Rostedt #endif
499f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
500f38f1d2aSSteven Rostedt 	{
501f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
502f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
503f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
504f38f1d2aSSteven Rostedt 		.mode		= 0644,
505f38f1d2aSSteven Rostedt 		.proc_handler	= &stack_trace_sysctl,
506f38f1d2aSSteven Rostedt 	},
507f38f1d2aSSteven Rostedt #endif
508944ac425SSteven Rostedt #ifdef CONFIG_TRACING
509944ac425SSteven Rostedt 	{
5103299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
511944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
512944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
513944ac425SSteven Rostedt 		.mode		= 0644,
514944ac425SSteven Rostedt 		.proc_handler	= &proc_dointvec,
515944ac425SSteven Rostedt 	},
516944ac425SSteven Rostedt #endif
517a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
5181da177e4SLinus Torvalds 	{
5191da177e4SLinus Torvalds 		.procname	= "modprobe",
5201da177e4SLinus Torvalds 		.data		= &modprobe_path,
5211da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
5221da177e4SLinus Torvalds 		.mode		= 0644,
5231da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
5241da177e4SLinus Torvalds 	},
5253d43321bSKees Cook 	{
5263d43321bSKees Cook 		.procname	= "modules_disabled",
5273d43321bSKees Cook 		.data		= &modules_disabled,
5283d43321bSKees Cook 		.maxlen		= sizeof(int),
5293d43321bSKees Cook 		.mode		= 0644,
5303d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
5313d43321bSKees Cook 		.proc_handler	= &proc_dointvec_minmax,
5323d43321bSKees Cook 		.extra1		= &one,
5333d43321bSKees Cook 		.extra2		= &one,
5343d43321bSKees Cook 	},
5351da177e4SLinus Torvalds #endif
53657ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
5371da177e4SLinus Torvalds 	{
5381da177e4SLinus Torvalds 		.procname	= "hotplug",
539312c004dSKay Sievers 		.data		= &uevent_helper,
540312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
5411da177e4SLinus Torvalds 		.mode		= 0644,
5421da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
5431da177e4SLinus Torvalds 	},
5441da177e4SLinus Torvalds #endif
5451da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
5461da177e4SLinus Torvalds 	{
5471da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
5481da177e4SLinus Torvalds 		.data		= &sg_big_buff,
5491da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5501da177e4SLinus Torvalds 		.mode		= 0444,
5511da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5521da177e4SLinus Torvalds 	},
5531da177e4SLinus Torvalds #endif
5541da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
5551da177e4SLinus Torvalds 	{
5561da177e4SLinus Torvalds 		.procname	= "acct",
5571da177e4SLinus Torvalds 		.data		= &acct_parm,
5581da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
5591da177e4SLinus Torvalds 		.mode		= 0644,
5601da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5611da177e4SLinus Torvalds 	},
5621da177e4SLinus Torvalds #endif
5631da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
5641da177e4SLinus Torvalds 	{
5651da177e4SLinus Torvalds 		.procname	= "sysrq",
5665d6f647fSIngo Molnar 		.data		= &__sysrq_enabled,
5671da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5681da177e4SLinus Torvalds 		.mode		= 0644,
5691da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5701da177e4SLinus Torvalds 	},
5711da177e4SLinus Torvalds #endif
572d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
5731da177e4SLinus Torvalds 	{
5741da177e4SLinus Torvalds 		.procname	= "cad_pid",
5759ec52099SCedric Le Goater 		.data		= NULL,
5761da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5771da177e4SLinus Torvalds 		.mode		= 0600,
5789ec52099SCedric Le Goater 		.proc_handler	= &proc_do_cad_pid,
5791da177e4SLinus Torvalds 	},
580d6f8ff73SRandy Dunlap #endif
5811da177e4SLinus Torvalds 	{
5821da177e4SLinus Torvalds 		.procname	= "threads-max",
5831da177e4SLinus Torvalds 		.data		= &max_threads,
5841da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5851da177e4SLinus Torvalds 		.mode		= 0644,
5861da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5871da177e4SLinus Torvalds 	},
5881da177e4SLinus Torvalds 	{
5891da177e4SLinus Torvalds 		.procname	= "random",
5901da177e4SLinus Torvalds 		.mode		= 0555,
5911da177e4SLinus Torvalds 		.child		= random_table,
5921da177e4SLinus Torvalds 	},
5931da177e4SLinus Torvalds 	{
5941da177e4SLinus Torvalds 		.procname	= "overflowuid",
5951da177e4SLinus Torvalds 		.data		= &overflowuid,
5961da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5971da177e4SLinus Torvalds 		.mode		= 0644,
5981da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
5991da177e4SLinus Torvalds 		.extra1		= &minolduid,
6001da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6011da177e4SLinus Torvalds 	},
6021da177e4SLinus Torvalds 	{
6031da177e4SLinus Torvalds 		.procname	= "overflowgid",
6041da177e4SLinus Torvalds 		.data		= &overflowgid,
6051da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6061da177e4SLinus Torvalds 		.mode		= 0644,
6071da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
6081da177e4SLinus Torvalds 		.extra1		= &minolduid,
6091da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6101da177e4SLinus Torvalds 	},
611347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
6121da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
6131da177e4SLinus Torvalds 	{
6141da177e4SLinus Torvalds 		.procname	= "ieee_emulation_warnings",
6151da177e4SLinus Torvalds 		.data		= &sysctl_ieee_emulation_warnings,
6161da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6171da177e4SLinus Torvalds 		.mode		= 0644,
6181da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6191da177e4SLinus Torvalds 	},
6201da177e4SLinus Torvalds #endif
6211da177e4SLinus Torvalds 	{
6221da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
6231da177e4SLinus Torvalds 		.data		= &sysctl_userprocess_debug,
6241da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6251da177e4SLinus Torvalds 		.mode		= 0644,
6261da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6271da177e4SLinus Torvalds 	},
6281da177e4SLinus Torvalds #endif
6291da177e4SLinus Torvalds 	{
6301da177e4SLinus Torvalds 		.procname	= "pid_max",
6311da177e4SLinus Torvalds 		.data		= &pid_max,
6321da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6331da177e4SLinus Torvalds 		.mode		= 0644,
6341da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
6351da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
6361da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
6371da177e4SLinus Torvalds 	},
6381da177e4SLinus Torvalds 	{
6391da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
6401da177e4SLinus Torvalds 		.data		= &panic_on_oops,
6411da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6421da177e4SLinus Torvalds 		.mode		= 0644,
6431da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6441da177e4SLinus Torvalds 	},
6457ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
6467ef3d2fdSJoe Perches 	{
6477ef3d2fdSJoe Perches 		.procname	= "printk",
6487ef3d2fdSJoe Perches 		.data		= &console_loglevel,
6497ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
6507ef3d2fdSJoe Perches 		.mode		= 0644,
6517ef3d2fdSJoe Perches 		.proc_handler	= &proc_dointvec,
6527ef3d2fdSJoe Perches 	},
6531da177e4SLinus Torvalds 	{
6541da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
655717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
6561da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6571da177e4SLinus Torvalds 		.mode		= 0644,
6581da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_jiffies,
6591da177e4SLinus Torvalds 	},
6601da177e4SLinus Torvalds 	{
6611da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
662717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
6631da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6641da177e4SLinus Torvalds 		.mode		= 0644,
6651da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6661da177e4SLinus Torvalds 	},
667af91322eSDave Young 	{
668af91322eSDave Young 		.procname	= "printk_delay",
669af91322eSDave Young 		.data		= &printk_delay_msec,
670af91322eSDave Young 		.maxlen		= sizeof(int),
671af91322eSDave Young 		.mode		= 0644,
672af91322eSDave Young 		.proc_handler	= &proc_dointvec_minmax,
673af91322eSDave Young 		.extra1		= &zero,
674af91322eSDave Young 		.extra2		= &ten_thousand,
675af91322eSDave Young 	},
6767ef3d2fdSJoe Perches #endif
6771da177e4SLinus Torvalds 	{
6781da177e4SLinus Torvalds 		.procname	= "ngroups_max",
6791da177e4SLinus Torvalds 		.data		= &ngroups_max,
6801da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6811da177e4SLinus Torvalds 		.mode		= 0444,
6821da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6831da177e4SLinus Torvalds 	},
6841da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
6851da177e4SLinus Torvalds 	{
6861da177e4SLinus Torvalds 		.procname       = "unknown_nmi_panic",
6871da177e4SLinus Torvalds 		.data           = &unknown_nmi_panic,
6881da177e4SLinus Torvalds 		.maxlen         = sizeof (int),
6891da177e4SLinus Torvalds 		.mode           = 0644,
6902fbe7b25SDon Zickus 		.proc_handler   = &proc_dointvec,
6911da177e4SLinus Torvalds 	},
692407984f1SDon Zickus 	{
693407984f1SDon Zickus 		.procname       = "nmi_watchdog",
694407984f1SDon Zickus 		.data           = &nmi_watchdog_enabled,
695407984f1SDon Zickus 		.maxlen         = sizeof (int),
696407984f1SDon Zickus 		.mode           = 0644,
697407984f1SDon Zickus 		.proc_handler   = &proc_nmi_enabled,
6981da177e4SLinus Torvalds 	},
6991da177e4SLinus Torvalds #endif
7001da177e4SLinus Torvalds #if defined(CONFIG_X86)
7011da177e4SLinus Torvalds 	{
7028da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
7038da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
7048da5addaSDon Zickus 		.maxlen		= sizeof(int),
7058da5addaSDon Zickus 		.mode		= 0644,
7068da5addaSDon Zickus 		.proc_handler	= &proc_dointvec,
7078da5addaSDon Zickus 	},
7088da5addaSDon Zickus 	{
7095211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
7105211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
7115211a242SKurt Garloff 		.maxlen		= sizeof(int),
7125211a242SKurt Garloff 		.mode		= 0644,
7135211a242SKurt Garloff 		.proc_handler	= &proc_dointvec,
7145211a242SKurt Garloff 	},
7155211a242SKurt Garloff 	{
7161da177e4SLinus Torvalds 		.procname	= "bootloader_type",
7171da177e4SLinus Torvalds 		.data		= &bootloader_type,
7181da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7191da177e4SLinus Torvalds 		.mode		= 0444,
7201da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7211da177e4SLinus Torvalds 	},
7220741f4d2SChuck Ebbert 	{
7235031296cSH. Peter Anvin 		.procname	= "bootloader_version",
7245031296cSH. Peter Anvin 		.data		= &bootloader_version,
7255031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
7265031296cSH. Peter Anvin 		.mode		= 0444,
7275031296cSH. Peter Anvin 		.proc_handler	= &proc_dointvec,
7285031296cSH. Peter Anvin 	},
7295031296cSH. Peter Anvin 	{
7300741f4d2SChuck Ebbert 		.procname	= "kstack_depth_to_print",
7310741f4d2SChuck Ebbert 		.data		= &kstack_depth_to_print,
7320741f4d2SChuck Ebbert 		.maxlen		= sizeof(int),
7330741f4d2SChuck Ebbert 		.mode		= 0644,
7340741f4d2SChuck Ebbert 		.proc_handler	= &proc_dointvec,
7350741f4d2SChuck Ebbert 	},
7366e7c4025SIngo Molnar 	{
7376e7c4025SIngo Molnar 		.procname	= "io_delay_type",
7386e7c4025SIngo Molnar 		.data		= &io_delay_type,
7396e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
7406e7c4025SIngo Molnar 		.mode		= 0644,
7416e7c4025SIngo Molnar 		.proc_handler	= &proc_dointvec,
7426e7c4025SIngo Molnar 	},
7431da177e4SLinus Torvalds #endif
7447a9166e3SLuke Yang #if defined(CONFIG_MMU)
7451da177e4SLinus Torvalds 	{
7461da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
7471da177e4SLinus Torvalds 		.data		= &randomize_va_space,
7481da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7491da177e4SLinus Torvalds 		.mode		= 0644,
7501da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7511da177e4SLinus Torvalds 	},
7527a9166e3SLuke Yang #endif
7530152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
754951f22d5SMartin Schwidefsky 	{
755951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
756951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
757951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
758951f22d5SMartin Schwidefsky 		.mode		= 0644,
759951f22d5SMartin Schwidefsky 		.proc_handler	= &proc_dointvec,
760951f22d5SMartin Schwidefsky 	},
761951f22d5SMartin Schwidefsky #endif
762673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
763c255d844SPavel Machek 	{
764c255d844SPavel Machek 		.procname	= "acpi_video_flags",
76577afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
766c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
767c255d844SPavel Machek 		.mode		= 0644,
7687f99f06fSStefan Seyfried 		.proc_handler	= &proc_doulongvec_minmax,
769c255d844SPavel Machek 	},
770c255d844SPavel Machek #endif
771d2b176edSJes Sorensen #ifdef CONFIG_IA64
772d2b176edSJes Sorensen 	{
773d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
774d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
775d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
776d2b176edSJes Sorensen 	 	.mode		= 0644,
777d2b176edSJes Sorensen 		.proc_handler	= &proc_dointvec,
778d2b176edSJes Sorensen 	},
77988fc241fSDoug Chapman 	{
78088fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
78188fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
78288fc241fSDoug Chapman 		.maxlen		= sizeof (int),
78388fc241fSDoug Chapman 		.mode		= 0644,
78488fc241fSDoug Chapman 		.proc_handler	= &proc_dointvec,
78588fc241fSDoug Chapman 	},
786d2b176edSJes Sorensen #endif
787c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP
788c4f3b63fSRavikiran G Thirumalai 	{
7899c44bc03SIngo Molnar 		.procname	= "softlockup_panic",
7909c44bc03SIngo Molnar 		.data		= &softlockup_panic,
7919c44bc03SIngo Molnar 		.maxlen		= sizeof(int),
7929c44bc03SIngo Molnar 		.mode		= 0644,
7934dca10a9SHiroshi Shimamoto 		.proc_handler	= &proc_dointvec_minmax,
7949c44bc03SIngo Molnar 		.extra1		= &zero,
7959c44bc03SIngo Molnar 		.extra2		= &one,
7969c44bc03SIngo Molnar 	},
7979c44bc03SIngo Molnar 	{
798c4f3b63fSRavikiran G Thirumalai 		.procname	= "softlockup_thresh",
799c4f3b63fSRavikiran G Thirumalai 		.data		= &softlockup_thresh,
8009383d967SDimitri Sivanich 		.maxlen		= sizeof(int),
801c4f3b63fSRavikiran G Thirumalai 		.mode		= 0644,
802baf48f65SMandeep Singh Baines 		.proc_handler	= &proc_dosoftlockup_thresh,
8039383d967SDimitri Sivanich 		.extra1		= &neg_one,
804c4f3b63fSRavikiran G Thirumalai 		.extra2		= &sixty,
805c4f3b63fSRavikiran G Thirumalai 	},
806e162b39aSMandeep Singh Baines #endif
807e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
808e162b39aSMandeep Singh Baines 	{
809e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
810e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
811e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
812e162b39aSMandeep Singh Baines 		.mode		= 0644,
813e162b39aSMandeep Singh Baines 		.proc_handler	= &proc_dointvec_minmax,
814e162b39aSMandeep Singh Baines 		.extra1		= &zero,
815e162b39aSMandeep Singh Baines 		.extra2		= &one,
816e162b39aSMandeep Singh Baines 	},
81782a1fcb9SIngo Molnar 	{
81882a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
81982a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
82090739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
82182a1fcb9SIngo Molnar 		.mode		= 0644,
82290739081SIngo Molnar 		.proc_handler	= &proc_doulongvec_minmax,
82382a1fcb9SIngo Molnar 	},
82482a1fcb9SIngo Molnar 	{
82582a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
82682a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
82790739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
82882a1fcb9SIngo Molnar 		.mode		= 0644,
829e162b39aSMandeep Singh Baines 		.proc_handler	= &proc_dohung_task_timeout_secs,
83082a1fcb9SIngo Molnar 	},
83182a1fcb9SIngo Molnar 	{
83282a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
83382a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
83490739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
83582a1fcb9SIngo Molnar 		.mode		= 0644,
83690739081SIngo Molnar 		.proc_handler	= &proc_doulongvec_minmax,
83782a1fcb9SIngo Molnar 	},
838c4f3b63fSRavikiran G Thirumalai #endif
839bebfa101SAndi Kleen #ifdef CONFIG_COMPAT
840bebfa101SAndi Kleen 	{
841bebfa101SAndi Kleen 		.procname	= "compat-log",
842bebfa101SAndi Kleen 		.data		= &compat_log,
843bebfa101SAndi Kleen 		.maxlen		= sizeof (int),
844bebfa101SAndi Kleen 	 	.mode		= 0644,
845bebfa101SAndi Kleen 		.proc_handler	= &proc_dointvec,
846bebfa101SAndi Kleen 	},
847bebfa101SAndi Kleen #endif
84823f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
84923f78d4aSIngo Molnar 	{
85023f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
85123f78d4aSIngo Molnar 		.data		= &max_lock_depth,
85223f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
85323f78d4aSIngo Molnar 		.mode		= 0644,
85423f78d4aSIngo Molnar 		.proc_handler	= &proc_dointvec,
85523f78d4aSIngo Molnar 	},
85623f78d4aSIngo Molnar #endif
85710a0a8d4SJeremy Fitzhardinge 	{
85810a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
85910a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
86010a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
86110a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
86210a0a8d4SJeremy Fitzhardinge 		.proc_handler	= &proc_dostring,
86310a0a8d4SJeremy Fitzhardinge 	},
8640b77f5bfSDavid Howells #ifdef CONFIG_KEYS
8650b77f5bfSDavid Howells 	{
8660b77f5bfSDavid Howells 		.procname	= "keys",
8670b77f5bfSDavid Howells 		.mode		= 0555,
8680b77f5bfSDavid Howells 		.child		= key_sysctls,
8690b77f5bfSDavid Howells 	},
8700b77f5bfSDavid Howells #endif
87131a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
87231a72bceSPaul E. McKenney 	{
87331a72bceSPaul E. McKenney 		.procname       = "rcutorture_runnable",
87431a72bceSPaul E. McKenney 		.data           = &rcutorture_runnable,
87531a72bceSPaul E. McKenney 		.maxlen         = sizeof(int),
87631a72bceSPaul E. McKenney 		.mode           = 0644,
87731a72bceSPaul E. McKenney 		.proc_handler   = &proc_dointvec,
87831a72bceSPaul E. McKenney 	},
87931a72bceSPaul E. McKenney #endif
88012e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK
88112e22c5eSDavid Howells 	{
88212e22c5eSDavid Howells 		.procname	= "slow-work",
88312e22c5eSDavid Howells 		.mode		= 0555,
88412e22c5eSDavid Howells 		.child		= slow_work_sysctls,
88512e22c5eSDavid Howells 	},
88612e22c5eSDavid Howells #endif
887cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS
8881ccd1549SPeter Zijlstra 	{
889cdd6c482SIngo Molnar 		.procname	= "perf_event_paranoid",
890cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_paranoid,
891cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_paranoid),
8921ccd1549SPeter Zijlstra 		.mode		= 0644,
8931ccd1549SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
8941ccd1549SPeter Zijlstra 	},
895c5078f78SPeter Zijlstra 	{
896cdd6c482SIngo Molnar 		.procname	= "perf_event_mlock_kb",
897cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_mlock,
898cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_mlock),
899c5078f78SPeter Zijlstra 		.mode		= 0644,
900c5078f78SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
901c5078f78SPeter Zijlstra 	},
902a78ac325SPeter Zijlstra 	{
903cdd6c482SIngo Molnar 		.procname	= "perf_event_max_sample_rate",
904cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_sample_rate,
905cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
906a78ac325SPeter Zijlstra 		.mode		= 0644,
907a78ac325SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
908a78ac325SPeter Zijlstra 	},
9091ccd1549SPeter Zijlstra #endif
910dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK
911dfec072eSVegard Nossum 	{
912dfec072eSVegard Nossum 		.procname	= "kmemcheck",
913dfec072eSVegard Nossum 		.data		= &kmemcheck_enabled,
914dfec072eSVegard Nossum 		.maxlen		= sizeof(int),
915dfec072eSVegard Nossum 		.mode		= 0644,
916dfec072eSVegard Nossum 		.proc_handler	= &proc_dointvec,
917dfec072eSVegard Nossum 	},
918dfec072eSVegard Nossum #endif
919cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
9205e605b64SJens Axboe 	{
9215e605b64SJens Axboe 		.procname	= "blk_iopoll",
9225e605b64SJens Axboe 		.data		= &blk_iopoll_enabled,
9235e605b64SJens Axboe 		.maxlen		= sizeof(int),
9245e605b64SJens Axboe 		.mode		= 0644,
9255e605b64SJens Axboe 		.proc_handler	= &proc_dointvec,
9265e605b64SJens Axboe 	},
927cb684b5bSJens Axboe #endif
928ed2c12f3SAndrew Morton /*
929ed2c12f3SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
930ed2c12f3SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
931ed2c12f3SAndrew Morton  */
932*6fce56ecSEric W. Biederman 	{ }
9331da177e4SLinus Torvalds };
9341da177e4SLinus Torvalds 
935d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
9361da177e4SLinus Torvalds 	{
9371da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
9381da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
9391da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
9401da177e4SLinus Torvalds 		.mode		= 0644,
9411da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
9421da177e4SLinus Torvalds 	},
9431da177e4SLinus Torvalds 	{
944fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
945fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
946fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
947fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
948fadd8fbdSKAMEZAWA Hiroyuki 		.proc_handler	= &proc_dointvec,
949fadd8fbdSKAMEZAWA Hiroyuki 	},
950fadd8fbdSKAMEZAWA Hiroyuki 	{
951fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
952fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
953fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
954fe071d7eSDavid Rientjes 		.mode		= 0644,
955fe071d7eSDavid Rientjes 		.proc_handler	= &proc_dointvec,
956fe071d7eSDavid Rientjes 	},
957fe071d7eSDavid Rientjes 	{
958fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
959fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
960fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
961fef1bdd6SDavid Rientjes 		.mode		= 0644,
962fef1bdd6SDavid Rientjes 		.proc_handler	= &proc_dointvec,
963fef1bdd6SDavid Rientjes 	},
964fef1bdd6SDavid Rientjes 	{
9651da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
9661da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
9671da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
9681da177e4SLinus Torvalds 		.mode		= 0644,
9691da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
9701da177e4SLinus Torvalds 	},
9711da177e4SLinus Torvalds 	{
9721da177e4SLinus Torvalds 		.procname	= "page-cluster",
9731da177e4SLinus Torvalds 		.data		= &page_cluster,
9741da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
9751da177e4SLinus Torvalds 		.mode		= 0644,
9761da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
9771da177e4SLinus Torvalds 	},
9781da177e4SLinus Torvalds 	{
9791da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
9801da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
9811da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
9821da177e4SLinus Torvalds 		.mode		= 0644,
9832da02997SDavid Rientjes 		.proc_handler	= &dirty_background_ratio_handler,
9841da177e4SLinus Torvalds 		.extra1		= &zero,
9851da177e4SLinus Torvalds 		.extra2		= &one_hundred,
9861da177e4SLinus Torvalds 	},
9871da177e4SLinus Torvalds 	{
9882da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
9892da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
9902da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
9912da02997SDavid Rientjes 		.mode		= 0644,
9922da02997SDavid Rientjes 		.proc_handler	= &dirty_background_bytes_handler,
993fc3501d4SSven Wegener 		.extra1		= &one_ul,
9942da02997SDavid Rientjes 	},
9952da02997SDavid Rientjes 	{
9961da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
9971da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
9981da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
9991da177e4SLinus Torvalds 		.mode		= 0644,
100004fbfdc1SPeter Zijlstra 		.proc_handler	= &dirty_ratio_handler,
10011da177e4SLinus Torvalds 		.extra1		= &zero,
10021da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10031da177e4SLinus Torvalds 	},
10041da177e4SLinus Torvalds 	{
10052da02997SDavid Rientjes 		.procname	= "dirty_bytes",
10062da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
10072da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
10082da02997SDavid Rientjes 		.mode		= 0644,
10092da02997SDavid Rientjes 		.proc_handler	= &dirty_bytes_handler,
10109e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
10112da02997SDavid Rientjes 	},
10122da02997SDavid Rientjes 	{
10131da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
1014f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
1015f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
10161da177e4SLinus Torvalds 		.mode		= 0644,
10171da177e4SLinus Torvalds 		.proc_handler	= &dirty_writeback_centisecs_handler,
10181da177e4SLinus Torvalds 	},
10191da177e4SLinus Torvalds 	{
10201da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
1021f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
1022f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
10231da177e4SLinus Torvalds 		.mode		= 0644,
1024704503d8SAlexey Dobriyan 		.proc_handler	= &proc_dointvec,
10251da177e4SLinus Torvalds 	},
10261da177e4SLinus Torvalds 	{
10271da177e4SLinus Torvalds 		.procname	= "nr_pdflush_threads",
10281da177e4SLinus Torvalds 		.data		= &nr_pdflush_threads,
10291da177e4SLinus Torvalds 		.maxlen		= sizeof nr_pdflush_threads,
10301da177e4SLinus Torvalds 		.mode		= 0444 /* read-only*/,
10311da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10321da177e4SLinus Torvalds 	},
10331da177e4SLinus Torvalds 	{
10341da177e4SLinus Torvalds 		.procname	= "swappiness",
10351da177e4SLinus Torvalds 		.data		= &vm_swappiness,
10361da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
10371da177e4SLinus Torvalds 		.mode		= 0644,
10381da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
10391da177e4SLinus Torvalds 		.extra1		= &zero,
10401da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10411da177e4SLinus Torvalds 	},
10421da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
10431da177e4SLinus Torvalds 	 {
10441da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
1045e5ff2159SAndi Kleen 		.data		= NULL,
10461da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
10471da177e4SLinus Torvalds 		.mode		= 0644,
10481da177e4SLinus Torvalds 		.proc_handler	= &hugetlb_sysctl_handler,
10491da177e4SLinus Torvalds 		.extra1		= (void *)&hugetlb_zero,
10501da177e4SLinus Torvalds 		.extra2		= (void *)&hugetlb_infinity,
10511da177e4SLinus Torvalds 	 },
10521da177e4SLinus Torvalds 	 {
10531da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
10541da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
10551da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
10561da177e4SLinus Torvalds 		.mode		= 0644,
10571da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10581da177e4SLinus Torvalds 	 },
1059396faf03SMel Gorman 	 {
1060396faf03SMel Gorman 		.procname	= "hugepages_treat_as_movable",
1061396faf03SMel Gorman 		.data		= &hugepages_treat_as_movable,
1062396faf03SMel Gorman 		.maxlen		= sizeof(int),
1063396faf03SMel Gorman 		.mode		= 0644,
1064396faf03SMel Gorman 		.proc_handler	= &hugetlb_treat_movable_handler,
1065396faf03SMel Gorman 	},
106654f9f80dSAdam Litke 	{
1067d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
1068e5ff2159SAndi Kleen 		.data		= NULL,
1069e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
1070d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
1071a3d0c6aaSNishanth Aravamudan 		.proc_handler	= &hugetlb_overcommit_handler,
1072e5ff2159SAndi Kleen 		.extra1		= (void *)&hugetlb_zero,
1073e5ff2159SAndi Kleen 		.extra2		= (void *)&hugetlb_infinity,
1074d1c3fb1fSNishanth Aravamudan 	},
10751da177e4SLinus Torvalds #endif
10761da177e4SLinus Torvalds 	{
10771da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
10781da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
10791da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
10801da177e4SLinus Torvalds 		.mode		= 0644,
10811da177e4SLinus Torvalds 		.proc_handler	= &lowmem_reserve_ratio_sysctl_handler,
10821da177e4SLinus Torvalds 	},
10831da177e4SLinus Torvalds 	{
10849d0243bcSAndrew Morton 		.procname	= "drop_caches",
10859d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
10869d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
10879d0243bcSAndrew Morton 		.mode		= 0644,
10889d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
10899d0243bcSAndrew Morton 	},
10909d0243bcSAndrew Morton 	{
10911da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
10921da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
10931da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
10941da177e4SLinus Torvalds 		.mode		= 0644,
10951da177e4SLinus Torvalds 		.proc_handler	= &min_free_kbytes_sysctl_handler,
10961da177e4SLinus Torvalds 		.extra1		= &zero,
10971da177e4SLinus Torvalds 	},
10988ad4b1fbSRohit Seth 	{
10998ad4b1fbSRohit Seth 		.procname	= "percpu_pagelist_fraction",
11008ad4b1fbSRohit Seth 		.data		= &percpu_pagelist_fraction,
11018ad4b1fbSRohit Seth 		.maxlen		= sizeof(percpu_pagelist_fraction),
11028ad4b1fbSRohit Seth 		.mode		= 0644,
11038ad4b1fbSRohit Seth 		.proc_handler	= &percpu_pagelist_fraction_sysctl_handler,
11048ad4b1fbSRohit Seth 		.extra1		= &min_percpu_pagelist_fract,
11058ad4b1fbSRohit Seth 	},
11061da177e4SLinus Torvalds #ifdef CONFIG_MMU
11071da177e4SLinus Torvalds 	{
11081da177e4SLinus Torvalds 		.procname	= "max_map_count",
11091da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
11101da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
11111da177e4SLinus Torvalds 		.mode		= 0644,
11121da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec
11131da177e4SLinus Torvalds 	},
1114dd8632a1SPaul Mundt #else
1115dd8632a1SPaul Mundt 	{
1116dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
1117dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
1118dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
1119dd8632a1SPaul Mundt 		.mode		= 0644,
1120dd8632a1SPaul Mundt 		.proc_handler	= &proc_dointvec_minmax,
1121dd8632a1SPaul Mundt 		.extra1		= &zero,
1122dd8632a1SPaul Mundt 	},
11231da177e4SLinus Torvalds #endif
11241da177e4SLinus Torvalds 	{
11251da177e4SLinus Torvalds 		.procname	= "laptop_mode",
11261da177e4SLinus Torvalds 		.data		= &laptop_mode,
11271da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
11281da177e4SLinus Torvalds 		.mode		= 0644,
1129ed5b43f1SBart Samwel 		.proc_handler	= &proc_dointvec_jiffies,
11301da177e4SLinus Torvalds 	},
11311da177e4SLinus Torvalds 	{
11321da177e4SLinus Torvalds 		.procname	= "block_dump",
11331da177e4SLinus Torvalds 		.data		= &block_dump,
11341da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
11351da177e4SLinus Torvalds 		.mode		= 0644,
11361da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
11371da177e4SLinus Torvalds 		.extra1		= &zero,
11381da177e4SLinus Torvalds 	},
11391da177e4SLinus Torvalds 	{
11401da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
11411da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
11421da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
11431da177e4SLinus Torvalds 		.mode		= 0644,
11441da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
11451da177e4SLinus Torvalds 		.extra1		= &zero,
11461da177e4SLinus Torvalds 	},
11471da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
11481da177e4SLinus Torvalds 	{
11491da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
11501da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
11511da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
11521da177e4SLinus Torvalds 		.mode		= 0644,
11531da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
11541da177e4SLinus Torvalds 		.extra1		= &zero,
11551da177e4SLinus Torvalds 	},
11561da177e4SLinus Torvalds #endif
11571743660bSChristoph Lameter #ifdef CONFIG_NUMA
11581743660bSChristoph Lameter 	{
11591743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
11601743660bSChristoph Lameter 		.data		= &zone_reclaim_mode,
11611743660bSChristoph Lameter 		.maxlen		= sizeof(zone_reclaim_mode),
11621743660bSChristoph Lameter 		.mode		= 0644,
11631743660bSChristoph Lameter 		.proc_handler	= &proc_dointvec,
1164c84db23cSChristoph Lameter 		.extra1		= &zero,
11651743660bSChristoph Lameter 	},
11669614634fSChristoph Lameter 	{
11679614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
11689614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
11699614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
11709614634fSChristoph Lameter 		.mode		= 0644,
11719614634fSChristoph Lameter 		.proc_handler	= &sysctl_min_unmapped_ratio_sysctl_handler,
11729614634fSChristoph Lameter 		.extra1		= &zero,
11739614634fSChristoph Lameter 		.extra2		= &one_hundred,
11749614634fSChristoph Lameter 	},
11750ff38490SChristoph Lameter 	{
11760ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
11770ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
11780ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
11790ff38490SChristoph Lameter 		.mode		= 0644,
11800ff38490SChristoph Lameter 		.proc_handler	= &sysctl_min_slab_ratio_sysctl_handler,
11810ff38490SChristoph Lameter 		.extra1		= &zero,
11820ff38490SChristoph Lameter 		.extra2		= &one_hundred,
11830ff38490SChristoph Lameter 	},
11841743660bSChristoph Lameter #endif
118577461ab3SChristoph Lameter #ifdef CONFIG_SMP
118677461ab3SChristoph Lameter 	{
118777461ab3SChristoph Lameter 		.procname	= "stat_interval",
118877461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
118977461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
119077461ab3SChristoph Lameter 		.mode		= 0644,
119177461ab3SChristoph Lameter 		.proc_handler	= &proc_dointvec_jiffies,
119277461ab3SChristoph Lameter 	},
119377461ab3SChristoph Lameter #endif
1194ed032189SEric Paris 	{
1195ed032189SEric Paris 		.procname	= "mmap_min_addr",
1196788084abSEric Paris 		.data		= &dac_mmap_min_addr,
1197ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
1198ed032189SEric Paris 		.mode		= 0644,
1199788084abSEric Paris 		.proc_handler	= &mmap_min_addr_handler,
1200ed032189SEric Paris 	},
1201f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
1202f0c0b2b8SKAMEZAWA Hiroyuki 	{
1203f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
1204f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
1205f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
1206f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
1207f0c0b2b8SKAMEZAWA Hiroyuki 		.proc_handler	= &numa_zonelist_order_handler,
1208f0c0b2b8SKAMEZAWA Hiroyuki 	},
1209f0c0b2b8SKAMEZAWA Hiroyuki #endif
12102b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
12115c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1212e6e5494cSIngo Molnar 	{
1213e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
1214e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
1215e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
1216e6e5494cSIngo Molnar 		.mode		= 0644,
1217e6e5494cSIngo Molnar 		.proc_handler	= &proc_dointvec,
1218e6e5494cSIngo Molnar 		.extra1		= &zero,
1219e6e5494cSIngo Molnar 	},
1220e6e5494cSIngo Molnar #endif
1221195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
1222195cf453SBron Gondwana 	{
1223195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
1224195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
1225195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
1226195cf453SBron Gondwana 		.mode		= 0644,
1227195cf453SBron Gondwana 		.proc_handler	= &proc_dointvec_minmax,
1228195cf453SBron Gondwana 		.extra1		= &zero,
1229195cf453SBron Gondwana 		.extra2		= &one,
1230195cf453SBron Gondwana 	},
1231195cf453SBron Gondwana #endif
12324be6f6bbSPeter Zijlstra 	{
12334be6f6bbSPeter Zijlstra 		.procname	= "scan_unevictable_pages",
12344be6f6bbSPeter Zijlstra 		.data		= &scan_unevictable_pages,
12354be6f6bbSPeter Zijlstra 		.maxlen		= sizeof(scan_unevictable_pages),
12364be6f6bbSPeter Zijlstra 		.mode		= 0644,
12374be6f6bbSPeter Zijlstra 		.proc_handler	= &scan_unevictable_handler,
12384be6f6bbSPeter Zijlstra 	},
12396a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE
12406a46079cSAndi Kleen 	{
12416a46079cSAndi Kleen 		.procname	= "memory_failure_early_kill",
12426a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_early_kill,
12436a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_early_kill),
12446a46079cSAndi Kleen 		.mode		= 0644,
12456a46079cSAndi Kleen 		.proc_handler	= &proc_dointvec_minmax,
12466a46079cSAndi Kleen 		.extra1		= &zero,
12476a46079cSAndi Kleen 		.extra2		= &one,
12486a46079cSAndi Kleen 	},
12496a46079cSAndi Kleen 	{
12506a46079cSAndi Kleen 		.procname	= "memory_failure_recovery",
12516a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_recovery,
12526a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_recovery),
12536a46079cSAndi Kleen 		.mode		= 0644,
12546a46079cSAndi Kleen 		.proc_handler	= &proc_dointvec_minmax,
12556a46079cSAndi Kleen 		.extra1		= &zero,
12566a46079cSAndi Kleen 		.extra2		= &one,
12576a46079cSAndi Kleen 	},
12586a46079cSAndi Kleen #endif
12596a46079cSAndi Kleen 
12602be7fe07SAndrew Morton /*
12612be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
12622be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
12632be7fe07SAndrew Morton  */
1264*6fce56ecSEric W. Biederman 	{ }
12651da177e4SLinus Torvalds };
12661da177e4SLinus Torvalds 
12672abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1268d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = {
1269*6fce56ecSEric W. Biederman 	{ }
12702abc26fcSEric W. Biederman };
12712abc26fcSEric W. Biederman #endif
12722abc26fcSEric W. Biederman 
1273d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
12741da177e4SLinus Torvalds 	{
12751da177e4SLinus Torvalds 		.procname	= "inode-nr",
12761da177e4SLinus Torvalds 		.data		= &inodes_stat,
12771da177e4SLinus Torvalds 		.maxlen		= 2*sizeof(int),
12781da177e4SLinus Torvalds 		.mode		= 0444,
12791da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
12801da177e4SLinus Torvalds 	},
12811da177e4SLinus Torvalds 	{
12821da177e4SLinus Torvalds 		.procname	= "inode-state",
12831da177e4SLinus Torvalds 		.data		= &inodes_stat,
12841da177e4SLinus Torvalds 		.maxlen		= 7*sizeof(int),
12851da177e4SLinus Torvalds 		.mode		= 0444,
12861da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
12871da177e4SLinus Torvalds 	},
12881da177e4SLinus Torvalds 	{
12891da177e4SLinus Torvalds 		.procname	= "file-nr",
12901da177e4SLinus Torvalds 		.data		= &files_stat,
12911da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
12921da177e4SLinus Torvalds 		.mode		= 0444,
1293529bf6beSDipankar Sarma 		.proc_handler	= &proc_nr_files,
12941da177e4SLinus Torvalds 	},
12951da177e4SLinus Torvalds 	{
12961da177e4SLinus Torvalds 		.procname	= "file-max",
12971da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
12981da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
12991da177e4SLinus Torvalds 		.mode		= 0644,
13001da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
13011da177e4SLinus Torvalds 	},
13021da177e4SLinus Torvalds 	{
13039cfe015aSEric Dumazet 		.procname	= "nr_open",
13049cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
13059cfe015aSEric Dumazet 		.maxlen		= sizeof(int),
13069cfe015aSEric Dumazet 		.mode		= 0644,
1307eceea0b3SAl Viro 		.proc_handler	= &proc_dointvec_minmax,
1308eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
1309eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
13109cfe015aSEric Dumazet 	},
13119cfe015aSEric Dumazet 	{
13121da177e4SLinus Torvalds 		.procname	= "dentry-state",
13131da177e4SLinus Torvalds 		.data		= &dentry_stat,
13141da177e4SLinus Torvalds 		.maxlen		= 6*sizeof(int),
13151da177e4SLinus Torvalds 		.mode		= 0444,
13161da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
13171da177e4SLinus Torvalds 	},
13181da177e4SLinus Torvalds 	{
13191da177e4SLinus Torvalds 		.procname	= "overflowuid",
13201da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
13211da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13221da177e4SLinus Torvalds 		.mode		= 0644,
13231da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
13241da177e4SLinus Torvalds 		.extra1		= &minolduid,
13251da177e4SLinus Torvalds 		.extra2		= &maxolduid,
13261da177e4SLinus Torvalds 	},
13271da177e4SLinus Torvalds 	{
13281da177e4SLinus Torvalds 		.procname	= "overflowgid",
13291da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
13301da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13311da177e4SLinus Torvalds 		.mode		= 0644,
13321da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
13331da177e4SLinus Torvalds 		.extra1		= &minolduid,
13341da177e4SLinus Torvalds 		.extra2		= &maxolduid,
13351da177e4SLinus Torvalds 	},
1336bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
13371da177e4SLinus Torvalds 	{
13381da177e4SLinus Torvalds 		.procname	= "leases-enable",
13391da177e4SLinus Torvalds 		.data		= &leases_enable,
13401da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13411da177e4SLinus Torvalds 		.mode		= 0644,
13421da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
13431da177e4SLinus Torvalds 	},
1344bfcd17a6SThomas Petazzoni #endif
13451da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
13461da177e4SLinus Torvalds 	{
13471da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
13481da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
13491da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13501da177e4SLinus Torvalds 		.mode		= 0644,
13511da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
13521da177e4SLinus Torvalds 	},
13531da177e4SLinus Torvalds #endif
13541da177e4SLinus Torvalds #ifdef CONFIG_MMU
1355bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
13561da177e4SLinus Torvalds 	{
13571da177e4SLinus Torvalds 		.procname	= "lease-break-time",
13581da177e4SLinus Torvalds 		.data		= &lease_break_time,
13591da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13601da177e4SLinus Torvalds 		.mode		= 0644,
13618e654fbaSMatthew Wilcox 		.proc_handler	= &proc_dointvec,
13621da177e4SLinus Torvalds 	},
1363bfcd17a6SThomas Petazzoni #endif
1364ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
13651da177e4SLinus Torvalds 	{
13661da177e4SLinus Torvalds 		.procname	= "aio-nr",
13671da177e4SLinus Torvalds 		.data		= &aio_nr,
13681da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
13691da177e4SLinus Torvalds 		.mode		= 0444,
1370d55b5fdaSZach Brown 		.proc_handler	= &proc_doulongvec_minmax,
13711da177e4SLinus Torvalds 	},
13721da177e4SLinus Torvalds 	{
13731da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
13741da177e4SLinus Torvalds 		.data		= &aio_max_nr,
13751da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
13761da177e4SLinus Torvalds 		.mode		= 0644,
1377d55b5fdaSZach Brown 		.proc_handler	= &proc_doulongvec_minmax,
13781da177e4SLinus Torvalds 	},
1379ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
13802d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
13810399cb08SRobert Love 	{
13820399cb08SRobert Love 		.procname	= "inotify",
13830399cb08SRobert Love 		.mode		= 0555,
13840399cb08SRobert Love 		.child		= inotify_table,
13850399cb08SRobert Love 	},
13860399cb08SRobert Love #endif
13877ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
13887ef9964eSDavide Libenzi 	{
13897ef9964eSDavide Libenzi 		.procname	= "epoll",
13907ef9964eSDavide Libenzi 		.mode		= 0555,
13917ef9964eSDavide Libenzi 		.child		= epoll_table,
13927ef9964eSDavide Libenzi 	},
13937ef9964eSDavide Libenzi #endif
13941da177e4SLinus Torvalds #endif
1395d6e71144SAlan Cox 	{
1396d6e71144SAlan Cox 		.procname	= "suid_dumpable",
1397d6e71144SAlan Cox 		.data		= &suid_dumpable,
1398d6e71144SAlan Cox 		.maxlen		= sizeof(int),
1399d6e71144SAlan Cox 		.mode		= 0644,
14008e654fbaSMatthew Wilcox 		.proc_handler	= &proc_dointvec_minmax,
14018e654fbaSMatthew Wilcox 		.extra1		= &zero,
14028e654fbaSMatthew Wilcox 		.extra2		= &two,
1403d6e71144SAlan Cox 	},
14042abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
14052abc26fcSEric W. Biederman 	{
14062abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
14072abc26fcSEric W. Biederman 		.mode		= 0555,
14082abc26fcSEric W. Biederman 		.child		= binfmt_misc_table,
14092abc26fcSEric W. Biederman 	},
14102abc26fcSEric W. Biederman #endif
14112be7fe07SAndrew Morton /*
14122be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
14132be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
14142be7fe07SAndrew Morton  */
1415*6fce56ecSEric W. Biederman 	{ }
14161da177e4SLinus Torvalds };
14171da177e4SLinus Torvalds 
1418d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
1419d0c3d534SOlof Johansson #if defined(CONFIG_X86) || defined(CONFIG_PPC)
1420abd4f750SMasoud Asgharifard Sharbiani 	{
1421abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
1422abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
1423abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
1424abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
1425abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
1426abd4f750SMasoud Asgharifard Sharbiani 	},
1427abd4f750SMasoud Asgharifard Sharbiani #endif
1428*6fce56ecSEric W. Biederman 	{ }
14291da177e4SLinus Torvalds };
14301da177e4SLinus Torvalds 
1431d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
1432*6fce56ecSEric W. Biederman 	{ }
14331da177e4SLinus Torvalds };
14341da177e4SLinus Torvalds 
1435330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock);
1436330d57fbSAl Viro 
1437330d57fbSAl Viro /* called under sysctl_lock */
1438330d57fbSAl Viro static int use_table(struct ctl_table_header *p)
1439330d57fbSAl Viro {
1440330d57fbSAl Viro 	if (unlikely(p->unregistering))
1441330d57fbSAl Viro 		return 0;
1442330d57fbSAl Viro 	p->used++;
1443330d57fbSAl Viro 	return 1;
1444330d57fbSAl Viro }
1445330d57fbSAl Viro 
1446330d57fbSAl Viro /* called under sysctl_lock */
1447330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p)
1448330d57fbSAl Viro {
1449330d57fbSAl Viro 	if (!--p->used)
1450330d57fbSAl Viro 		if (unlikely(p->unregistering))
1451330d57fbSAl Viro 			complete(p->unregistering);
1452330d57fbSAl Viro }
1453330d57fbSAl Viro 
1454330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */
1455330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p)
1456330d57fbSAl Viro {
1457330d57fbSAl Viro 	/*
1458330d57fbSAl Viro 	 * if p->used is 0, nobody will ever touch that entry again;
1459330d57fbSAl Viro 	 * we'll eliminate all paths to it before dropping sysctl_lock
1460330d57fbSAl Viro 	 */
1461330d57fbSAl Viro 	if (unlikely(p->used)) {
1462330d57fbSAl Viro 		struct completion wait;
1463330d57fbSAl Viro 		init_completion(&wait);
1464330d57fbSAl Viro 		p->unregistering = &wait;
1465330d57fbSAl Viro 		spin_unlock(&sysctl_lock);
1466330d57fbSAl Viro 		wait_for_completion(&wait);
1467330d57fbSAl Viro 		spin_lock(&sysctl_lock);
1468f7e6ced4SAl Viro 	} else {
1469f7e6ced4SAl Viro 		/* anything non-NULL; we'll never dereference it */
1470f7e6ced4SAl Viro 		p->unregistering = ERR_PTR(-EINVAL);
1471330d57fbSAl Viro 	}
1472330d57fbSAl Viro 	/*
1473330d57fbSAl Viro 	 * do not remove from the list until nobody holds it; walking the
1474330d57fbSAl Viro 	 * list in do_sysctl() relies on that.
1475330d57fbSAl Viro 	 */
1476330d57fbSAl Viro 	list_del_init(&p->ctl_entry);
1477330d57fbSAl Viro }
1478330d57fbSAl Viro 
1479f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head)
1480f7e6ced4SAl Viro {
1481f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1482f7e6ced4SAl Viro 	head->count++;
1483f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1484f7e6ced4SAl Viro }
1485f7e6ced4SAl Viro 
1486f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
1487f7e6ced4SAl Viro {
1488f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1489f7e6ced4SAl Viro 	if (!--head->count)
1490f7e6ced4SAl Viro 		kfree(head);
1491f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1492f7e6ced4SAl Viro }
1493f7e6ced4SAl Viro 
1494f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1495f7e6ced4SAl Viro {
1496f7e6ced4SAl Viro 	if (!head)
1497f7e6ced4SAl Viro 		BUG();
1498f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1499f7e6ced4SAl Viro 	if (!use_table(head))
1500f7e6ced4SAl Viro 		head = ERR_PTR(-ENOENT);
1501f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1502f7e6ced4SAl Viro 	return head;
1503f7e6ced4SAl Viro }
1504f7e6ced4SAl Viro 
1505805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head)
1506805b5d5eSEric W. Biederman {
1507805b5d5eSEric W. Biederman 	if (!head)
1508805b5d5eSEric W. Biederman 		return;
1509805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1510805b5d5eSEric W. Biederman 	unuse_table(head);
1511805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1512805b5d5eSEric W. Biederman }
1513805b5d5eSEric W. Biederman 
151473455092SAl Viro static struct ctl_table_set *
151573455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
151673455092SAl Viro {
151773455092SAl Viro 	struct ctl_table_set *set = &root->default_set;
151873455092SAl Viro 	if (root->lookup)
151973455092SAl Viro 		set = root->lookup(root, namespaces);
152073455092SAl Viro 	return set;
152173455092SAl Viro }
152273455092SAl Viro 
1523e51b6ba0SEric W. Biederman static struct list_head *
1524e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1525805b5d5eSEric W. Biederman {
152673455092SAl Viro 	struct ctl_table_set *set = lookup_header_set(root, namespaces);
152773455092SAl Viro 	return &set->list;
1528e51b6ba0SEric W. Biederman }
1529e51b6ba0SEric W. Biederman 
1530e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1531e51b6ba0SEric W. Biederman 					    struct ctl_table_header *prev)
1532e51b6ba0SEric W. Biederman {
1533e51b6ba0SEric W. Biederman 	struct ctl_table_root *root;
1534e51b6ba0SEric W. Biederman 	struct list_head *header_list;
1535805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1536805b5d5eSEric W. Biederman 	struct list_head *tmp;
1537e51b6ba0SEric W. Biederman 
1538805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1539805b5d5eSEric W. Biederman 	if (prev) {
1540e51b6ba0SEric W. Biederman 		head = prev;
1541805b5d5eSEric W. Biederman 		tmp = &prev->ctl_entry;
1542805b5d5eSEric W. Biederman 		unuse_table(prev);
1543805b5d5eSEric W. Biederman 		goto next;
1544805b5d5eSEric W. Biederman 	}
1545805b5d5eSEric W. Biederman 	tmp = &root_table_header.ctl_entry;
1546805b5d5eSEric W. Biederman 	for (;;) {
1547805b5d5eSEric W. Biederman 		head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1548805b5d5eSEric W. Biederman 
1549805b5d5eSEric W. Biederman 		if (!use_table(head))
1550805b5d5eSEric W. Biederman 			goto next;
1551805b5d5eSEric W. Biederman 		spin_unlock(&sysctl_lock);
1552805b5d5eSEric W. Biederman 		return head;
1553805b5d5eSEric W. Biederman 	next:
1554e51b6ba0SEric W. Biederman 		root = head->root;
1555805b5d5eSEric W. Biederman 		tmp = tmp->next;
1556e51b6ba0SEric W. Biederman 		header_list = lookup_header_list(root, namespaces);
1557e51b6ba0SEric W. Biederman 		if (tmp != header_list)
1558e51b6ba0SEric W. Biederman 			continue;
1559e51b6ba0SEric W. Biederman 
1560e51b6ba0SEric W. Biederman 		do {
1561e51b6ba0SEric W. Biederman 			root = list_entry(root->root_list.next,
1562e51b6ba0SEric W. Biederman 					struct ctl_table_root, root_list);
1563e51b6ba0SEric W. Biederman 			if (root == &sysctl_table_root)
1564e51b6ba0SEric W. Biederman 				goto out;
1565e51b6ba0SEric W. Biederman 			header_list = lookup_header_list(root, namespaces);
1566e51b6ba0SEric W. Biederman 		} while (list_empty(header_list));
1567e51b6ba0SEric W. Biederman 		tmp = header_list->next;
1568805b5d5eSEric W. Biederman 	}
1569e51b6ba0SEric W. Biederman out:
1570805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1571805b5d5eSEric W. Biederman 	return NULL;
1572805b5d5eSEric W. Biederman }
1573805b5d5eSEric W. Biederman 
1574e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1575e51b6ba0SEric W. Biederman {
1576e51b6ba0SEric W. Biederman 	return __sysctl_head_next(current->nsproxy, prev);
1577e51b6ba0SEric W. Biederman }
1578e51b6ba0SEric W. Biederman 
1579e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root)
1580e51b6ba0SEric W. Biederman {
1581e51b6ba0SEric W. Biederman 	spin_lock(&sysctl_lock);
1582e51b6ba0SEric W. Biederman 	list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1583e51b6ba0SEric W. Biederman 	spin_unlock(&sysctl_lock);
1584e51b6ba0SEric W. Biederman }
1585e51b6ba0SEric W. Biederman 
15861da177e4SLinus Torvalds /*
15871ff007ebSEric W. Biederman  * sysctl_perm does NOT grant the superuser all rights automatically, because
15881da177e4SLinus Torvalds  * some sysctl variables are readonly even to root.
15891da177e4SLinus Torvalds  */
15901da177e4SLinus Torvalds 
15911da177e4SLinus Torvalds static int test_perm(int mode, int op)
15921da177e4SLinus Torvalds {
159376aac0e9SDavid Howells 	if (!current_euid())
15941da177e4SLinus Torvalds 		mode >>= 6;
15951da177e4SLinus Torvalds 	else if (in_egroup_p(0))
15961da177e4SLinus Torvalds 		mode >>= 3;
1597e6305c43SAl Viro 	if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
15981da177e4SLinus Torvalds 		return 0;
15991da177e4SLinus Torvalds 	return -EACCES;
16001da177e4SLinus Torvalds }
16011da177e4SLinus Torvalds 
1602d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
16031da177e4SLinus Torvalds {
16041da177e4SLinus Torvalds 	int error;
1605d7321cd6SPavel Emelyanov 	int mode;
1606d7321cd6SPavel Emelyanov 
1607e6305c43SAl Viro 	error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
16081da177e4SLinus Torvalds 	if (error)
16091da177e4SLinus Torvalds 		return error;
1610d7321cd6SPavel Emelyanov 
1611d7321cd6SPavel Emelyanov 	if (root->permissions)
1612d7321cd6SPavel Emelyanov 		mode = root->permissions(root, current->nsproxy, table);
1613d7321cd6SPavel Emelyanov 	else
1614d7321cd6SPavel Emelyanov 		mode = table->mode;
1615d7321cd6SPavel Emelyanov 
1616d7321cd6SPavel Emelyanov 	return test_perm(mode, op);
16171da177e4SLinus Torvalds }
16181da177e4SLinus Torvalds 
1619d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1620d912b0ccSEric W. Biederman {
1621d912b0ccSEric W. Biederman 	for (; table->ctl_name || table->procname; table++) {
1622d912b0ccSEric W. Biederman 		table->parent = parent;
1623d912b0ccSEric W. Biederman 		if (table->child)
1624d912b0ccSEric W. Biederman 			sysctl_set_parent(table, table->child);
1625d912b0ccSEric W. Biederman 	}
1626d912b0ccSEric W. Biederman }
1627d912b0ccSEric W. Biederman 
1628d912b0ccSEric W. Biederman static __init int sysctl_init(void)
1629d912b0ccSEric W. Biederman {
1630d912b0ccSEric W. Biederman 	sysctl_set_parent(NULL, root_table);
163188f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
163288f458e4SHolger Schurig 	{
163388f458e4SHolger Schurig 		int err;
1634e51b6ba0SEric W. Biederman 		err = sysctl_check_table(current->nsproxy, root_table);
163588f458e4SHolger Schurig 	}
163688f458e4SHolger Schurig #endif
1637d912b0ccSEric W. Biederman 	return 0;
1638d912b0ccSEric W. Biederman }
1639d912b0ccSEric W. Biederman 
1640d912b0ccSEric W. Biederman core_initcall(sysctl_init);
1641d912b0ccSEric W. Biederman 
1642bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch,
1643bfbcf034SAl Viro 				      struct ctl_table *table)
1644ae7edeccSAl Viro {
1645ae7edeccSAl Viro 	struct ctl_table *p;
1646ae7edeccSAl Viro 	const char *s = branch->procname;
1647ae7edeccSAl Viro 
1648ae7edeccSAl Viro 	/* branch should have named subdirectory as its first element */
1649ae7edeccSAl Viro 	if (!s || !branch->child)
1650bfbcf034SAl Viro 		return NULL;
1651ae7edeccSAl Viro 
1652ae7edeccSAl Viro 	/* ... and nothing else */
1653ae7edeccSAl Viro 	if (branch[1].procname || branch[1].ctl_name)
1654bfbcf034SAl Viro 		return NULL;
1655ae7edeccSAl Viro 
1656ae7edeccSAl Viro 	/* table should contain subdirectory with the same name */
1657ae7edeccSAl Viro 	for (p = table; p->procname || p->ctl_name; p++) {
1658ae7edeccSAl Viro 		if (!p->child)
1659ae7edeccSAl Viro 			continue;
1660ae7edeccSAl Viro 		if (p->procname && strcmp(p->procname, s) == 0)
1661bfbcf034SAl Viro 			return p;
1662ae7edeccSAl Viro 	}
1663bfbcf034SAl Viro 	return NULL;
1664ae7edeccSAl Viro }
1665ae7edeccSAl Viro 
1666ae7edeccSAl Viro /* see if attaching q to p would be an improvement */
1667ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1668ae7edeccSAl Viro {
1669ae7edeccSAl Viro 	struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1670bfbcf034SAl Viro 	struct ctl_table *next;
1671ae7edeccSAl Viro 	int is_better = 0;
1672ae7edeccSAl Viro 	int not_in_parent = !p->attached_by;
1673ae7edeccSAl Viro 
1674bfbcf034SAl Viro 	while ((next = is_branch_in(by, to)) != NULL) {
1675ae7edeccSAl Viro 		if (by == q->attached_by)
1676ae7edeccSAl Viro 			is_better = 1;
1677ae7edeccSAl Viro 		if (to == p->attached_by)
1678ae7edeccSAl Viro 			not_in_parent = 1;
1679ae7edeccSAl Viro 		by = by->child;
1680bfbcf034SAl Viro 		to = next->child;
1681ae7edeccSAl Viro 	}
1682ae7edeccSAl Viro 
1683ae7edeccSAl Viro 	if (is_better && not_in_parent) {
1684ae7edeccSAl Viro 		q->attached_by = by;
1685ae7edeccSAl Viro 		q->attached_to = to;
1686ae7edeccSAl Viro 		q->parent = p;
1687ae7edeccSAl Viro 	}
1688ae7edeccSAl Viro }
1689ae7edeccSAl Viro 
16901da177e4SLinus Torvalds /**
1691e51b6ba0SEric W. Biederman  * __register_sysctl_paths - register a sysctl hierarchy
1692e51b6ba0SEric W. Biederman  * @root: List of sysctl headers to register on
1693e51b6ba0SEric W. Biederman  * @namespaces: Data to compute which lists of sysctl entries are visible
169429e796fdSEric W. Biederman  * @path: The path to the directory the sysctl table is in.
16951da177e4SLinus Torvalds  * @table: the top-level table structure
16961da177e4SLinus Torvalds  *
16971da177e4SLinus Torvalds  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
169829e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
16991da177e4SLinus Torvalds  *
1700d8217f07SEric W. Biederman  * The members of the &struct ctl_table structure are used as follows:
17011da177e4SLinus Torvalds  *
17021da177e4SLinus Torvalds  * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
17031da177e4SLinus Torvalds  *            must be unique within that level of sysctl
17041da177e4SLinus Torvalds  *
17051da177e4SLinus Torvalds  * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
17061da177e4SLinus Torvalds  *            enter a sysctl file
17071da177e4SLinus Torvalds  *
17081da177e4SLinus Torvalds  * data - a pointer to data for use by proc_handler
17091da177e4SLinus Torvalds  *
17101da177e4SLinus Torvalds  * maxlen - the maximum size in bytes of the data
17111da177e4SLinus Torvalds  *
17121da177e4SLinus Torvalds  * mode - the file permissions for the /proc/sys file, and for sysctl(2)
17131da177e4SLinus Torvalds  *
17141da177e4SLinus Torvalds  * child - a pointer to the child sysctl table if this entry is a directory, or
17151da177e4SLinus Torvalds  *         %NULL.
17161da177e4SLinus Torvalds  *
17171da177e4SLinus Torvalds  * proc_handler - the text handler routine (described below)
17181da177e4SLinus Torvalds  *
17191da177e4SLinus Torvalds  * strategy - the strategy routine (described below)
17201da177e4SLinus Torvalds  *
17211da177e4SLinus Torvalds  * de - for internal use by the sysctl routines
17221da177e4SLinus Torvalds  *
17231da177e4SLinus Torvalds  * extra1, extra2 - extra pointers usable by the proc handler routines
17241da177e4SLinus Torvalds  *
17251da177e4SLinus Torvalds  * Leaf nodes in the sysctl tree will be represented by a single file
17261da177e4SLinus Torvalds  * under /proc; non-leaf nodes will be represented by directories.
17271da177e4SLinus Torvalds  *
17281da177e4SLinus Torvalds  * sysctl(2) can automatically manage read and write requests through
17291da177e4SLinus Torvalds  * the sysctl table.  The data and maxlen fields of the ctl_table
17301da177e4SLinus Torvalds  * struct enable minimal validation of the values being written to be
17311da177e4SLinus Torvalds  * performed, and the mode field allows minimal authentication.
17321da177e4SLinus Torvalds  *
17331da177e4SLinus Torvalds  * More sophisticated management can be enabled by the provision of a
17341da177e4SLinus Torvalds  * strategy routine with the table entry.  This will be called before
17351da177e4SLinus Torvalds  * any automatic read or write of the data is performed.
17361da177e4SLinus Torvalds  *
17371da177e4SLinus Torvalds  * The strategy routine may return
17381da177e4SLinus Torvalds  *
17391da177e4SLinus Torvalds  * < 0 - Error occurred (error is passed to user process)
17401da177e4SLinus Torvalds  *
17411da177e4SLinus Torvalds  * 0   - OK - proceed with automatic read or write.
17421da177e4SLinus Torvalds  *
17431da177e4SLinus Torvalds  * > 0 - OK - read or write has been done by the strategy routine, so
17441da177e4SLinus Torvalds  *       return immediately.
17451da177e4SLinus Torvalds  *
17461da177e4SLinus Torvalds  * There must be a proc_handler routine for any terminal nodes
17471da177e4SLinus Torvalds  * mirrored under /proc/sys (non-terminals are handled by a built-in
17481da177e4SLinus Torvalds  * directory handler).  Several default handlers are available to
17491da177e4SLinus Torvalds  * cover common cases -
17501da177e4SLinus Torvalds  *
17511da177e4SLinus Torvalds  * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
17521da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
17531da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
17541da177e4SLinus Torvalds  *
17551da177e4SLinus Torvalds  * It is the handler's job to read the input buffer from user memory
17561da177e4SLinus Torvalds  * and process it. The handler should return 0 on success.
17571da177e4SLinus Torvalds  *
17581da177e4SLinus Torvalds  * This routine returns %NULL on a failure to register, and a pointer
17591da177e4SLinus Torvalds  * to the table header on success.
17601da177e4SLinus Torvalds  */
1761e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths(
1762e51b6ba0SEric W. Biederman 	struct ctl_table_root *root,
1763e51b6ba0SEric W. Biederman 	struct nsproxy *namespaces,
1764e51b6ba0SEric W. Biederman 	const struct ctl_path *path, struct ctl_table *table)
17651da177e4SLinus Torvalds {
176629e796fdSEric W. Biederman 	struct ctl_table_header *header;
176729e796fdSEric W. Biederman 	struct ctl_table *new, **prevp;
176829e796fdSEric W. Biederman 	unsigned int n, npath;
1769ae7edeccSAl Viro 	struct ctl_table_set *set;
177029e796fdSEric W. Biederman 
177129e796fdSEric W. Biederman 	/* Count the path components */
177229e796fdSEric W. Biederman 	for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
177329e796fdSEric W. Biederman 		;
177429e796fdSEric W. Biederman 
177529e796fdSEric W. Biederman 	/*
177629e796fdSEric W. Biederman 	 * For each path component, allocate a 2-element ctl_table array.
177729e796fdSEric W. Biederman 	 * The first array element will be filled with the sysctl entry
177829e796fdSEric W. Biederman 	 * for this, the second will be the sentinel (ctl_name == 0).
177929e796fdSEric W. Biederman 	 *
178029e796fdSEric W. Biederman 	 * We allocate everything in one go so that we don't have to
178129e796fdSEric W. Biederman 	 * worry about freeing additional memory in unregister_sysctl_table.
178229e796fdSEric W. Biederman 	 */
178329e796fdSEric W. Biederman 	header = kzalloc(sizeof(struct ctl_table_header) +
178429e796fdSEric W. Biederman 			 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
178529e796fdSEric W. Biederman 	if (!header)
17861da177e4SLinus Torvalds 		return NULL;
178729e796fdSEric W. Biederman 
178829e796fdSEric W. Biederman 	new = (struct ctl_table *) (header + 1);
178929e796fdSEric W. Biederman 
179029e796fdSEric W. Biederman 	/* Now connect the dots */
179129e796fdSEric W. Biederman 	prevp = &header->ctl_table;
179229e796fdSEric W. Biederman 	for (n = 0; n < npath; ++n, ++path) {
179329e796fdSEric W. Biederman 		/* Copy the procname */
179429e796fdSEric W. Biederman 		new->procname = path->procname;
179529e796fdSEric W. Biederman 		new->ctl_name = path->ctl_name;
179629e796fdSEric W. Biederman 		new->mode     = 0555;
179729e796fdSEric W. Biederman 
179829e796fdSEric W. Biederman 		*prevp = new;
179929e796fdSEric W. Biederman 		prevp = &new->child;
180029e796fdSEric W. Biederman 
180129e796fdSEric W. Biederman 		new += 2;
180229e796fdSEric W. Biederman 	}
180329e796fdSEric W. Biederman 	*prevp = table;
180423eb06deSEric W. Biederman 	header->ctl_table_arg = table;
180529e796fdSEric W. Biederman 
180629e796fdSEric W. Biederman 	INIT_LIST_HEAD(&header->ctl_entry);
180729e796fdSEric W. Biederman 	header->used = 0;
180829e796fdSEric W. Biederman 	header->unregistering = NULL;
1809e51b6ba0SEric W. Biederman 	header->root = root;
181029e796fdSEric W. Biederman 	sysctl_set_parent(NULL, header->ctl_table);
1811f7e6ced4SAl Viro 	header->count = 1;
181288f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1813e51b6ba0SEric W. Biederman 	if (sysctl_check_table(namespaces, header->ctl_table)) {
181429e796fdSEric W. Biederman 		kfree(header);
1815fc6cd25bSEric W. Biederman 		return NULL;
1816fc6cd25bSEric W. Biederman 	}
181788f458e4SHolger Schurig #endif
1818330d57fbSAl Viro 	spin_lock(&sysctl_lock);
181973455092SAl Viro 	header->set = lookup_header_set(root, namespaces);
1820ae7edeccSAl Viro 	header->attached_by = header->ctl_table;
1821ae7edeccSAl Viro 	header->attached_to = root_table;
1822ae7edeccSAl Viro 	header->parent = &root_table_header;
1823ae7edeccSAl Viro 	for (set = header->set; set; set = set->parent) {
1824ae7edeccSAl Viro 		struct ctl_table_header *p;
1825ae7edeccSAl Viro 		list_for_each_entry(p, &set->list, ctl_entry) {
1826ae7edeccSAl Viro 			if (p->unregistering)
1827ae7edeccSAl Viro 				continue;
1828ae7edeccSAl Viro 			try_attach(p, header);
1829ae7edeccSAl Viro 		}
1830ae7edeccSAl Viro 	}
1831ae7edeccSAl Viro 	header->parent->count++;
183273455092SAl Viro 	list_add_tail(&header->ctl_entry, &header->set->list);
1833330d57fbSAl Viro 	spin_unlock(&sysctl_lock);
183429e796fdSEric W. Biederman 
183529e796fdSEric W. Biederman 	return header;
183629e796fdSEric W. Biederman }
183729e796fdSEric W. Biederman 
183829e796fdSEric W. Biederman /**
1839e51b6ba0SEric W. Biederman  * register_sysctl_table_path - register a sysctl table hierarchy
1840e51b6ba0SEric W. Biederman  * @path: The path to the directory the sysctl table is in.
1841e51b6ba0SEric W. Biederman  * @table: the top-level table structure
1842e51b6ba0SEric W. Biederman  *
1843e51b6ba0SEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1844e51b6ba0SEric W. Biederman  * array. A completely 0 filled entry terminates the table.
1845e51b6ba0SEric W. Biederman  *
1846e51b6ba0SEric W. Biederman  * See __register_sysctl_paths for more details.
1847e51b6ba0SEric W. Biederman  */
1848e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1849e51b6ba0SEric W. Biederman 						struct ctl_table *table)
1850e51b6ba0SEric W. Biederman {
1851e51b6ba0SEric W. Biederman 	return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1852e51b6ba0SEric W. Biederman 					path, table);
1853e51b6ba0SEric W. Biederman }
1854e51b6ba0SEric W. Biederman 
1855e51b6ba0SEric W. Biederman /**
185629e796fdSEric W. Biederman  * register_sysctl_table - register a sysctl table hierarchy
185729e796fdSEric W. Biederman  * @table: the top-level table structure
185829e796fdSEric W. Biederman  *
185929e796fdSEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
186029e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
186129e796fdSEric W. Biederman  *
186229e796fdSEric W. Biederman  * See register_sysctl_paths for more details.
186329e796fdSEric W. Biederman  */
186429e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
186529e796fdSEric W. Biederman {
186629e796fdSEric W. Biederman 	static const struct ctl_path null_path[] = { {} };
186729e796fdSEric W. Biederman 
186829e796fdSEric W. Biederman 	return register_sysctl_paths(null_path, table);
18691da177e4SLinus Torvalds }
18701da177e4SLinus Torvalds 
18711da177e4SLinus Torvalds /**
18721da177e4SLinus Torvalds  * unregister_sysctl_table - unregister a sysctl table hierarchy
18731da177e4SLinus Torvalds  * @header: the header returned from register_sysctl_table
18741da177e4SLinus Torvalds  *
18751da177e4SLinus Torvalds  * Unregisters the sysctl table and all children. proc entries may not
18761da177e4SLinus Torvalds  * actually be removed until they are no longer used by anyone.
18771da177e4SLinus Torvalds  */
18781da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header)
18791da177e4SLinus Torvalds {
1880330d57fbSAl Viro 	might_sleep();
1881f1dad166SPavel Emelyanov 
1882f1dad166SPavel Emelyanov 	if (header == NULL)
1883f1dad166SPavel Emelyanov 		return;
1884f1dad166SPavel Emelyanov 
1885330d57fbSAl Viro 	spin_lock(&sysctl_lock);
1886330d57fbSAl Viro 	start_unregistering(header);
1887ae7edeccSAl Viro 	if (!--header->parent->count) {
1888ae7edeccSAl Viro 		WARN_ON(1);
1889ae7edeccSAl Viro 		kfree(header->parent);
1890ae7edeccSAl Viro 	}
1891f7e6ced4SAl Viro 	if (!--header->count)
18921da177e4SLinus Torvalds 		kfree(header);
1893f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
18941da177e4SLinus Torvalds }
18951da177e4SLinus Torvalds 
18969043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p)
18979043476fSAl Viro {
18989043476fSAl Viro 	struct ctl_table_set *set = p->set;
18999043476fSAl Viro 	int res;
19009043476fSAl Viro 	spin_lock(&sysctl_lock);
19019043476fSAl Viro 	if (p->unregistering)
19029043476fSAl Viro 		res = 0;
19039043476fSAl Viro 	else if (!set->is_seen)
19049043476fSAl Viro 		res = 1;
19059043476fSAl Viro 	else
19069043476fSAl Viro 		res = set->is_seen(set);
19079043476fSAl Viro 	spin_unlock(&sysctl_lock);
19089043476fSAl Viro 	return res;
19099043476fSAl Viro }
19109043476fSAl Viro 
191173455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
191273455092SAl Viro 	struct ctl_table_set *parent,
191373455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
191473455092SAl Viro {
191573455092SAl Viro 	INIT_LIST_HEAD(&p->list);
191673455092SAl Viro 	p->parent = parent ? parent : &sysctl_table_root.default_set;
191773455092SAl Viro 	p->is_seen = is_seen;
191873455092SAl Viro }
191973455092SAl Viro 
1920b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */
1921d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
1922b89a8171SEric W. Biederman {
1923b89a8171SEric W. Biederman 	return NULL;
1924b89a8171SEric W. Biederman }
1925b89a8171SEric W. Biederman 
192629e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
192729e796fdSEric W. Biederman 						    struct ctl_table *table)
192829e796fdSEric W. Biederman {
192929e796fdSEric W. Biederman 	return NULL;
193029e796fdSEric W. Biederman }
193129e796fdSEric W. Biederman 
1932b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table)
1933b89a8171SEric W. Biederman {
1934b89a8171SEric W. Biederman }
1935b89a8171SEric W. Biederman 
193673455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
193773455092SAl Viro 	struct ctl_table_set *parent,
193873455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
193973455092SAl Viro {
194073455092SAl Viro }
194173455092SAl Viro 
1942f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
1943f7e6ced4SAl Viro {
1944f7e6ced4SAl Viro }
1945f7e6ced4SAl Viro 
1946b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
1947b89a8171SEric W. Biederman 
19481da177e4SLinus Torvalds /*
19491da177e4SLinus Torvalds  * /proc/sys support
19501da177e4SLinus Torvalds  */
19511da177e4SLinus Torvalds 
1952b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL
19531da177e4SLinus Torvalds 
1954b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write,
19558d65af78SAlexey Dobriyan 			   void __user *buffer,
1956b1ba4dddSAdrian Bunk 			   size_t *lenp, loff_t *ppos)
1957f5dd3d6fSSam Vilain {
1958f5dd3d6fSSam Vilain 	size_t len;
1959f5dd3d6fSSam Vilain 	char __user *p;
1960f5dd3d6fSSam Vilain 	char c;
1961f5dd3d6fSSam Vilain 
19628d060877SOleg Nesterov 	if (!data || !maxlen || !*lenp) {
1963f5dd3d6fSSam Vilain 		*lenp = 0;
1964f5dd3d6fSSam Vilain 		return 0;
1965f5dd3d6fSSam Vilain 	}
1966f5dd3d6fSSam Vilain 
1967f5dd3d6fSSam Vilain 	if (write) {
1968f5dd3d6fSSam Vilain 		len = 0;
1969f5dd3d6fSSam Vilain 		p = buffer;
1970f5dd3d6fSSam Vilain 		while (len < *lenp) {
1971f5dd3d6fSSam Vilain 			if (get_user(c, p++))
1972f5dd3d6fSSam Vilain 				return -EFAULT;
1973f5dd3d6fSSam Vilain 			if (c == 0 || c == '\n')
1974f5dd3d6fSSam Vilain 				break;
1975f5dd3d6fSSam Vilain 			len++;
1976f5dd3d6fSSam Vilain 		}
1977f5dd3d6fSSam Vilain 		if (len >= maxlen)
1978f5dd3d6fSSam Vilain 			len = maxlen-1;
1979f5dd3d6fSSam Vilain 		if(copy_from_user(data, buffer, len))
1980f5dd3d6fSSam Vilain 			return -EFAULT;
1981f5dd3d6fSSam Vilain 		((char *) data)[len] = 0;
1982f5dd3d6fSSam Vilain 		*ppos += *lenp;
1983f5dd3d6fSSam Vilain 	} else {
1984f5dd3d6fSSam Vilain 		len = strlen(data);
1985f5dd3d6fSSam Vilain 		if (len > maxlen)
1986f5dd3d6fSSam Vilain 			len = maxlen;
19878d060877SOleg Nesterov 
19888d060877SOleg Nesterov 		if (*ppos > len) {
19898d060877SOleg Nesterov 			*lenp = 0;
19908d060877SOleg Nesterov 			return 0;
19918d060877SOleg Nesterov 		}
19928d060877SOleg Nesterov 
19938d060877SOleg Nesterov 		data += *ppos;
19948d060877SOleg Nesterov 		len  -= *ppos;
19958d060877SOleg Nesterov 
1996f5dd3d6fSSam Vilain 		if (len > *lenp)
1997f5dd3d6fSSam Vilain 			len = *lenp;
1998f5dd3d6fSSam Vilain 		if (len)
1999f5dd3d6fSSam Vilain 			if(copy_to_user(buffer, data, len))
2000f5dd3d6fSSam Vilain 				return -EFAULT;
2001f5dd3d6fSSam Vilain 		if (len < *lenp) {
2002f5dd3d6fSSam Vilain 			if(put_user('\n', ((char __user *) buffer) + len))
2003f5dd3d6fSSam Vilain 				return -EFAULT;
2004f5dd3d6fSSam Vilain 			len++;
2005f5dd3d6fSSam Vilain 		}
2006f5dd3d6fSSam Vilain 		*lenp = len;
2007f5dd3d6fSSam Vilain 		*ppos += len;
2008f5dd3d6fSSam Vilain 	}
2009f5dd3d6fSSam Vilain 	return 0;
2010f5dd3d6fSSam Vilain }
2011f5dd3d6fSSam Vilain 
20121da177e4SLinus Torvalds /**
20131da177e4SLinus Torvalds  * proc_dostring - read a string sysctl
20141da177e4SLinus Torvalds  * @table: the sysctl table
20151da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
20161da177e4SLinus Torvalds  * @buffer: the user buffer
20171da177e4SLinus Torvalds  * @lenp: the size of the user buffer
20181da177e4SLinus Torvalds  * @ppos: file position
20191da177e4SLinus Torvalds  *
20201da177e4SLinus Torvalds  * Reads/writes a string from/to the user buffer. If the kernel
20211da177e4SLinus Torvalds  * buffer provided is not large enough to hold the string, the
20221da177e4SLinus Torvalds  * string is truncated. The copied string is %NULL-terminated.
20231da177e4SLinus Torvalds  * If the string is being read by the user process, it is copied
20241da177e4SLinus Torvalds  * and a newline '\n' is added. It is truncated if the buffer is
20251da177e4SLinus Torvalds  * not large enough.
20261da177e4SLinus Torvalds  *
20271da177e4SLinus Torvalds  * Returns 0 on success.
20281da177e4SLinus Torvalds  */
20298d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write,
20301da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
20311da177e4SLinus Torvalds {
20328d65af78SAlexey Dobriyan 	return _proc_do_string(table->data, table->maxlen, write,
2033f5dd3d6fSSam Vilain 			       buffer, lenp, ppos);
20341da177e4SLinus Torvalds }
20351da177e4SLinus Torvalds 
20361da177e4SLinus Torvalds 
20371da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
20381da177e4SLinus Torvalds 				 int *valp,
20391da177e4SLinus Torvalds 				 int write, void *data)
20401da177e4SLinus Torvalds {
20411da177e4SLinus Torvalds 	if (write) {
20421da177e4SLinus Torvalds 		*valp = *negp ? -*lvalp : *lvalp;
20431da177e4SLinus Torvalds 	} else {
20441da177e4SLinus Torvalds 		int val = *valp;
20451da177e4SLinus Torvalds 		if (val < 0) {
20461da177e4SLinus Torvalds 			*negp = -1;
20471da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
20481da177e4SLinus Torvalds 		} else {
20491da177e4SLinus Torvalds 			*negp = 0;
20501da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
20511da177e4SLinus Torvalds 		}
20521da177e4SLinus Torvalds 	}
20531da177e4SLinus Torvalds 	return 0;
20541da177e4SLinus Torvalds }
20551da177e4SLinus Torvalds 
2056d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
20578d65af78SAlexey Dobriyan 		  int write, void __user *buffer,
2058fcfbd547SKirill Korotaev 		  size_t *lenp, loff_t *ppos,
20591da177e4SLinus Torvalds 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
20601da177e4SLinus Torvalds 			      int write, void *data),
20611da177e4SLinus Torvalds 		  void *data)
20621da177e4SLinus Torvalds {
20631da177e4SLinus Torvalds #define TMPBUFLEN 21
20647338f299SSukanto Ghosh 	int *i, vleft, first = 1, neg;
20651da177e4SLinus Torvalds 	unsigned long lval;
20661da177e4SLinus Torvalds 	size_t left, len;
20671da177e4SLinus Torvalds 
20681da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
20691da177e4SLinus Torvalds 	char __user *s = buffer;
20701da177e4SLinus Torvalds 
2071fcfbd547SKirill Korotaev 	if (!tbl_data || !table->maxlen || !*lenp ||
20721da177e4SLinus Torvalds 	    (*ppos && !write)) {
20731da177e4SLinus Torvalds 		*lenp = 0;
20741da177e4SLinus Torvalds 		return 0;
20751da177e4SLinus Torvalds 	}
20761da177e4SLinus Torvalds 
2077fcfbd547SKirill Korotaev 	i = (int *) tbl_data;
20781da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(*i);
20791da177e4SLinus Torvalds 	left = *lenp;
20801da177e4SLinus Torvalds 
20811da177e4SLinus Torvalds 	if (!conv)
20821da177e4SLinus Torvalds 		conv = do_proc_dointvec_conv;
20831da177e4SLinus Torvalds 
20841da177e4SLinus Torvalds 	for (; left && vleft--; i++, first=0) {
20851da177e4SLinus Torvalds 		if (write) {
20861da177e4SLinus Torvalds 			while (left) {
20871da177e4SLinus Torvalds 				char c;
20881da177e4SLinus Torvalds 				if (get_user(c, s))
20891da177e4SLinus Torvalds 					return -EFAULT;
20901da177e4SLinus Torvalds 				if (!isspace(c))
20911da177e4SLinus Torvalds 					break;
20921da177e4SLinus Torvalds 				left--;
20931da177e4SLinus Torvalds 				s++;
20941da177e4SLinus Torvalds 			}
20951da177e4SLinus Torvalds 			if (!left)
20961da177e4SLinus Torvalds 				break;
20971da177e4SLinus Torvalds 			neg = 0;
20981da177e4SLinus Torvalds 			len = left;
20991da177e4SLinus Torvalds 			if (len > sizeof(buf) - 1)
21001da177e4SLinus Torvalds 				len = sizeof(buf) - 1;
21011da177e4SLinus Torvalds 			if (copy_from_user(buf, s, len))
21021da177e4SLinus Torvalds 				return -EFAULT;
21031da177e4SLinus Torvalds 			buf[len] = 0;
21041da177e4SLinus Torvalds 			p = buf;
21051da177e4SLinus Torvalds 			if (*p == '-' && left > 1) {
21061da177e4SLinus Torvalds 				neg = 1;
2107bd9b0bacSBP, Praveen 				p++;
21081da177e4SLinus Torvalds 			}
21091da177e4SLinus Torvalds 			if (*p < '0' || *p > '9')
21101da177e4SLinus Torvalds 				break;
21111da177e4SLinus Torvalds 
21121da177e4SLinus Torvalds 			lval = simple_strtoul(p, &p, 0);
21131da177e4SLinus Torvalds 
21141da177e4SLinus Torvalds 			len = p-buf;
21151da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
21161da177e4SLinus Torvalds 				break;
21171da177e4SLinus Torvalds 			s += len;
21181da177e4SLinus Torvalds 			left -= len;
21191da177e4SLinus Torvalds 
21201da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 1, data))
21211da177e4SLinus Torvalds 				break;
21221da177e4SLinus Torvalds 		} else {
21231da177e4SLinus Torvalds 			p = buf;
21241da177e4SLinus Torvalds 			if (!first)
21251da177e4SLinus Torvalds 				*p++ = '\t';
21261da177e4SLinus Torvalds 
21271da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 0, data))
21281da177e4SLinus Torvalds 				break;
21291da177e4SLinus Torvalds 
21301da177e4SLinus Torvalds 			sprintf(p, "%s%lu", neg ? "-" : "", lval);
21311da177e4SLinus Torvalds 			len = strlen(buf);
21321da177e4SLinus Torvalds 			if (len > left)
21331da177e4SLinus Torvalds 				len = left;
21341da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
21351da177e4SLinus Torvalds 				return -EFAULT;
21361da177e4SLinus Torvalds 			left -= len;
21371da177e4SLinus Torvalds 			s += len;
21381da177e4SLinus Torvalds 		}
21391da177e4SLinus Torvalds 	}
21401da177e4SLinus Torvalds 
21411da177e4SLinus Torvalds 	if (!write && !first && left) {
21421da177e4SLinus Torvalds 		if(put_user('\n', s))
21431da177e4SLinus Torvalds 			return -EFAULT;
21441da177e4SLinus Torvalds 		left--, s++;
21451da177e4SLinus Torvalds 	}
21461da177e4SLinus Torvalds 	if (write) {
21471da177e4SLinus Torvalds 		while (left) {
21481da177e4SLinus Torvalds 			char c;
21491da177e4SLinus Torvalds 			if (get_user(c, s++))
21501da177e4SLinus Torvalds 				return -EFAULT;
21511da177e4SLinus Torvalds 			if (!isspace(c))
21521da177e4SLinus Torvalds 				break;
21531da177e4SLinus Torvalds 			left--;
21541da177e4SLinus Torvalds 		}
21551da177e4SLinus Torvalds 	}
21561da177e4SLinus Torvalds 	if (write && first)
21571da177e4SLinus Torvalds 		return -EINVAL;
21581da177e4SLinus Torvalds 	*lenp -= left;
21591da177e4SLinus Torvalds 	*ppos += *lenp;
21601da177e4SLinus Torvalds 	return 0;
21611da177e4SLinus Torvalds #undef TMPBUFLEN
21621da177e4SLinus Torvalds }
21631da177e4SLinus Torvalds 
21648d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write,
2165fcfbd547SKirill Korotaev 		  void __user *buffer, size_t *lenp, loff_t *ppos,
2166fcfbd547SKirill Korotaev 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2167fcfbd547SKirill Korotaev 			      int write, void *data),
2168fcfbd547SKirill Korotaev 		  void *data)
2169fcfbd547SKirill Korotaev {
21708d65af78SAlexey Dobriyan 	return __do_proc_dointvec(table->data, table, write,
2171fcfbd547SKirill Korotaev 			buffer, lenp, ppos, conv, data);
2172fcfbd547SKirill Korotaev }
2173fcfbd547SKirill Korotaev 
21741da177e4SLinus Torvalds /**
21751da177e4SLinus Torvalds  * proc_dointvec - read a vector of integers
21761da177e4SLinus Torvalds  * @table: the sysctl table
21771da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
21781da177e4SLinus Torvalds  * @buffer: the user buffer
21791da177e4SLinus Torvalds  * @lenp: the size of the user buffer
21801da177e4SLinus Torvalds  * @ppos: file position
21811da177e4SLinus Torvalds  *
21821da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
21831da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
21841da177e4SLinus Torvalds  *
21851da177e4SLinus Torvalds  * Returns 0 on success.
21861da177e4SLinus Torvalds  */
21878d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write,
21881da177e4SLinus Torvalds 		     void __user *buffer, size_t *lenp, loff_t *ppos)
21891da177e4SLinus Torvalds {
21908d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
21911da177e4SLinus Torvalds 		    	    NULL,NULL);
21921da177e4SLinus Torvalds }
21931da177e4SLinus Torvalds 
219434f5a398STheodore Ts'o /*
219534f5a398STheodore Ts'o  * Taint values can only be increased
219625ddbb18SAndi Kleen  * This means we can safely use a temporary.
219734f5a398STheodore Ts'o  */
21988d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write,
219934f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos)
220034f5a398STheodore Ts'o {
220125ddbb18SAndi Kleen 	struct ctl_table t;
220225ddbb18SAndi Kleen 	unsigned long tmptaint = get_taint();
220325ddbb18SAndi Kleen 	int err;
220434f5a398STheodore Ts'o 
220591fcd412SBastian Blank 	if (write && !capable(CAP_SYS_ADMIN))
220634f5a398STheodore Ts'o 		return -EPERM;
220734f5a398STheodore Ts'o 
220825ddbb18SAndi Kleen 	t = *table;
220925ddbb18SAndi Kleen 	t.data = &tmptaint;
22108d65af78SAlexey Dobriyan 	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
221125ddbb18SAndi Kleen 	if (err < 0)
221225ddbb18SAndi Kleen 		return err;
221325ddbb18SAndi Kleen 
221425ddbb18SAndi Kleen 	if (write) {
221525ddbb18SAndi Kleen 		/*
221625ddbb18SAndi Kleen 		 * Poor man's atomic or. Not worth adding a primitive
221725ddbb18SAndi Kleen 		 * to everyone's atomic.h for this
221825ddbb18SAndi Kleen 		 */
221925ddbb18SAndi Kleen 		int i;
222025ddbb18SAndi Kleen 		for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
222125ddbb18SAndi Kleen 			if ((tmptaint >> i) & 1)
222225ddbb18SAndi Kleen 				add_taint(i);
222325ddbb18SAndi Kleen 		}
222425ddbb18SAndi Kleen 	}
222525ddbb18SAndi Kleen 
222625ddbb18SAndi Kleen 	return err;
222734f5a398STheodore Ts'o }
222834f5a398STheodore Ts'o 
22291da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param {
22301da177e4SLinus Torvalds 	int *min;
22311da177e4SLinus Torvalds 	int *max;
22321da177e4SLinus Torvalds };
22331da177e4SLinus Torvalds 
22341da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
22351da177e4SLinus Torvalds 					int *valp,
22361da177e4SLinus Torvalds 					int write, void *data)
22371da177e4SLinus Torvalds {
22381da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param *param = data;
22391da177e4SLinus Torvalds 	if (write) {
22401da177e4SLinus Torvalds 		int val = *negp ? -*lvalp : *lvalp;
22411da177e4SLinus Torvalds 		if ((param->min && *param->min > val) ||
22421da177e4SLinus Torvalds 		    (param->max && *param->max < val))
22431da177e4SLinus Torvalds 			return -EINVAL;
22441da177e4SLinus Torvalds 		*valp = val;
22451da177e4SLinus Torvalds 	} else {
22461da177e4SLinus Torvalds 		int val = *valp;
22471da177e4SLinus Torvalds 		if (val < 0) {
22481da177e4SLinus Torvalds 			*negp = -1;
22491da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
22501da177e4SLinus Torvalds 		} else {
22511da177e4SLinus Torvalds 			*negp = 0;
22521da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
22531da177e4SLinus Torvalds 		}
22541da177e4SLinus Torvalds 	}
22551da177e4SLinus Torvalds 	return 0;
22561da177e4SLinus Torvalds }
22571da177e4SLinus Torvalds 
22581da177e4SLinus Torvalds /**
22591da177e4SLinus Torvalds  * proc_dointvec_minmax - read a vector of integers with min/max values
22601da177e4SLinus Torvalds  * @table: the sysctl table
22611da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
22621da177e4SLinus Torvalds  * @buffer: the user buffer
22631da177e4SLinus Torvalds  * @lenp: the size of the user buffer
22641da177e4SLinus Torvalds  * @ppos: file position
22651da177e4SLinus Torvalds  *
22661da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
22671da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
22681da177e4SLinus Torvalds  *
22691da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
22701da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
22711da177e4SLinus Torvalds  *
22721da177e4SLinus Torvalds  * Returns 0 on success.
22731da177e4SLinus Torvalds  */
22748d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write,
22751da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
22761da177e4SLinus Torvalds {
22771da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param param = {
22781da177e4SLinus Torvalds 		.min = (int *) table->extra1,
22791da177e4SLinus Torvalds 		.max = (int *) table->extra2,
22801da177e4SLinus Torvalds 	};
22818d65af78SAlexey Dobriyan 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
22821da177e4SLinus Torvalds 				do_proc_dointvec_minmax_conv, &param);
22831da177e4SLinus Torvalds }
22841da177e4SLinus Torvalds 
2285d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
22861da177e4SLinus Torvalds 				     void __user *buffer,
22871da177e4SLinus Torvalds 				     size_t *lenp, loff_t *ppos,
22881da177e4SLinus Torvalds 				     unsigned long convmul,
22891da177e4SLinus Torvalds 				     unsigned long convdiv)
22901da177e4SLinus Torvalds {
22911da177e4SLinus Torvalds #define TMPBUFLEN 21
22921da177e4SLinus Torvalds 	unsigned long *i, *min, *max, val;
22931da177e4SLinus Torvalds 	int vleft, first=1, neg;
22941da177e4SLinus Torvalds 	size_t len, left;
22951da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
22961da177e4SLinus Torvalds 	char __user *s = buffer;
22971da177e4SLinus Torvalds 
2298fcfbd547SKirill Korotaev 	if (!data || !table->maxlen || !*lenp ||
22991da177e4SLinus Torvalds 	    (*ppos && !write)) {
23001da177e4SLinus Torvalds 		*lenp = 0;
23011da177e4SLinus Torvalds 		return 0;
23021da177e4SLinus Torvalds 	}
23031da177e4SLinus Torvalds 
2304fcfbd547SKirill Korotaev 	i = (unsigned long *) data;
23051da177e4SLinus Torvalds 	min = (unsigned long *) table->extra1;
23061da177e4SLinus Torvalds 	max = (unsigned long *) table->extra2;
23071da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(unsigned long);
23081da177e4SLinus Torvalds 	left = *lenp;
23091da177e4SLinus Torvalds 
23101da177e4SLinus Torvalds 	for (; left && vleft--; i++, min++, max++, first=0) {
23111da177e4SLinus Torvalds 		if (write) {
23121da177e4SLinus Torvalds 			while (left) {
23131da177e4SLinus Torvalds 				char c;
23141da177e4SLinus Torvalds 				if (get_user(c, s))
23151da177e4SLinus Torvalds 					return -EFAULT;
23161da177e4SLinus Torvalds 				if (!isspace(c))
23171da177e4SLinus Torvalds 					break;
23181da177e4SLinus Torvalds 				left--;
23191da177e4SLinus Torvalds 				s++;
23201da177e4SLinus Torvalds 			}
23211da177e4SLinus Torvalds 			if (!left)
23221da177e4SLinus Torvalds 				break;
23231da177e4SLinus Torvalds 			neg = 0;
23241da177e4SLinus Torvalds 			len = left;
23251da177e4SLinus Torvalds 			if (len > TMPBUFLEN-1)
23261da177e4SLinus Torvalds 				len = TMPBUFLEN-1;
23271da177e4SLinus Torvalds 			if (copy_from_user(buf, s, len))
23281da177e4SLinus Torvalds 				return -EFAULT;
23291da177e4SLinus Torvalds 			buf[len] = 0;
23301da177e4SLinus Torvalds 			p = buf;
23311da177e4SLinus Torvalds 			if (*p == '-' && left > 1) {
23321da177e4SLinus Torvalds 				neg = 1;
2333bd9b0bacSBP, Praveen 				p++;
23341da177e4SLinus Torvalds 			}
23351da177e4SLinus Torvalds 			if (*p < '0' || *p > '9')
23361da177e4SLinus Torvalds 				break;
23371da177e4SLinus Torvalds 			val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
23381da177e4SLinus Torvalds 			len = p-buf;
23391da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
23401da177e4SLinus Torvalds 				break;
23411da177e4SLinus Torvalds 			if (neg)
23421da177e4SLinus Torvalds 				val = -val;
23431da177e4SLinus Torvalds 			s += len;
23441da177e4SLinus Torvalds 			left -= len;
23451da177e4SLinus Torvalds 
23461da177e4SLinus Torvalds 			if(neg)
23471da177e4SLinus Torvalds 				continue;
23481da177e4SLinus Torvalds 			if ((min && val < *min) || (max && val > *max))
23491da177e4SLinus Torvalds 				continue;
23501da177e4SLinus Torvalds 			*i = val;
23511da177e4SLinus Torvalds 		} else {
23521da177e4SLinus Torvalds 			p = buf;
23531da177e4SLinus Torvalds 			if (!first)
23541da177e4SLinus Torvalds 				*p++ = '\t';
23551da177e4SLinus Torvalds 			sprintf(p, "%lu", convdiv * (*i) / convmul);
23561da177e4SLinus Torvalds 			len = strlen(buf);
23571da177e4SLinus Torvalds 			if (len > left)
23581da177e4SLinus Torvalds 				len = left;
23591da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
23601da177e4SLinus Torvalds 				return -EFAULT;
23611da177e4SLinus Torvalds 			left -= len;
23621da177e4SLinus Torvalds 			s += len;
23631da177e4SLinus Torvalds 		}
23641da177e4SLinus Torvalds 	}
23651da177e4SLinus Torvalds 
23661da177e4SLinus Torvalds 	if (!write && !first && left) {
23671da177e4SLinus Torvalds 		if(put_user('\n', s))
23681da177e4SLinus Torvalds 			return -EFAULT;
23691da177e4SLinus Torvalds 		left--, s++;
23701da177e4SLinus Torvalds 	}
23711da177e4SLinus Torvalds 	if (write) {
23721da177e4SLinus Torvalds 		while (left) {
23731da177e4SLinus Torvalds 			char c;
23741da177e4SLinus Torvalds 			if (get_user(c, s++))
23751da177e4SLinus Torvalds 				return -EFAULT;
23761da177e4SLinus Torvalds 			if (!isspace(c))
23771da177e4SLinus Torvalds 				break;
23781da177e4SLinus Torvalds 			left--;
23791da177e4SLinus Torvalds 		}
23801da177e4SLinus Torvalds 	}
23811da177e4SLinus Torvalds 	if (write && first)
23821da177e4SLinus Torvalds 		return -EINVAL;
23831da177e4SLinus Torvalds 	*lenp -= left;
23841da177e4SLinus Torvalds 	*ppos += *lenp;
23851da177e4SLinus Torvalds 	return 0;
23861da177e4SLinus Torvalds #undef TMPBUFLEN
23871da177e4SLinus Torvalds }
23881da177e4SLinus Torvalds 
2389d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2390fcfbd547SKirill Korotaev 				     void __user *buffer,
2391fcfbd547SKirill Korotaev 				     size_t *lenp, loff_t *ppos,
2392fcfbd547SKirill Korotaev 				     unsigned long convmul,
2393fcfbd547SKirill Korotaev 				     unsigned long convdiv)
2394fcfbd547SKirill Korotaev {
2395fcfbd547SKirill Korotaev 	return __do_proc_doulongvec_minmax(table->data, table, write,
23968d65af78SAlexey Dobriyan 			buffer, lenp, ppos, convmul, convdiv);
2397fcfbd547SKirill Korotaev }
2398fcfbd547SKirill Korotaev 
23991da177e4SLinus Torvalds /**
24001da177e4SLinus Torvalds  * proc_doulongvec_minmax - read a vector of long integers with min/max values
24011da177e4SLinus Torvalds  * @table: the sysctl table
24021da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24031da177e4SLinus Torvalds  * @buffer: the user buffer
24041da177e4SLinus Torvalds  * @lenp: the size of the user buffer
24051da177e4SLinus Torvalds  * @ppos: file position
24061da177e4SLinus Torvalds  *
24071da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
24081da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
24091da177e4SLinus Torvalds  *
24101da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
24111da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
24121da177e4SLinus Torvalds  *
24131da177e4SLinus Torvalds  * Returns 0 on success.
24141da177e4SLinus Torvalds  */
24158d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write,
24161da177e4SLinus Torvalds 			   void __user *buffer, size_t *lenp, loff_t *ppos)
24171da177e4SLinus Torvalds {
24188d65af78SAlexey Dobriyan     return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
24191da177e4SLinus Torvalds }
24201da177e4SLinus Torvalds 
24211da177e4SLinus Torvalds /**
24221da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
24231da177e4SLinus Torvalds  * @table: the sysctl table
24241da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24251da177e4SLinus Torvalds  * @buffer: the user buffer
24261da177e4SLinus Torvalds  * @lenp: the size of the user buffer
24271da177e4SLinus Torvalds  * @ppos: file position
24281da177e4SLinus Torvalds  *
24291da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
24301da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string. The values
24311da177e4SLinus Torvalds  * are treated as milliseconds, and converted to jiffies when they are stored.
24321da177e4SLinus Torvalds  *
24331da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
24341da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
24351da177e4SLinus Torvalds  *
24361da177e4SLinus Torvalds  * Returns 0 on success.
24371da177e4SLinus Torvalds  */
2438d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
24391da177e4SLinus Torvalds 				      void __user *buffer,
24401da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
24411da177e4SLinus Torvalds {
24428d65af78SAlexey Dobriyan     return do_proc_doulongvec_minmax(table, write, buffer,
24431da177e4SLinus Torvalds 				     lenp, ppos, HZ, 1000l);
24441da177e4SLinus Torvalds }
24451da177e4SLinus Torvalds 
24461da177e4SLinus Torvalds 
24471da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
24481da177e4SLinus Torvalds 					 int *valp,
24491da177e4SLinus Torvalds 					 int write, void *data)
24501da177e4SLinus Torvalds {
24511da177e4SLinus Torvalds 	if (write) {
2452cba9f33dSBart Samwel 		if (*lvalp > LONG_MAX / HZ)
2453cba9f33dSBart Samwel 			return 1;
24541da177e4SLinus Torvalds 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
24551da177e4SLinus Torvalds 	} else {
24561da177e4SLinus Torvalds 		int val = *valp;
24571da177e4SLinus Torvalds 		unsigned long lval;
24581da177e4SLinus Torvalds 		if (val < 0) {
24591da177e4SLinus Torvalds 			*negp = -1;
24601da177e4SLinus Torvalds 			lval = (unsigned long)-val;
24611da177e4SLinus Torvalds 		} else {
24621da177e4SLinus Torvalds 			*negp = 0;
24631da177e4SLinus Torvalds 			lval = (unsigned long)val;
24641da177e4SLinus Torvalds 		}
24651da177e4SLinus Torvalds 		*lvalp = lval / HZ;
24661da177e4SLinus Torvalds 	}
24671da177e4SLinus Torvalds 	return 0;
24681da177e4SLinus Torvalds }
24691da177e4SLinus Torvalds 
24701da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
24711da177e4SLinus Torvalds 						int *valp,
24721da177e4SLinus Torvalds 						int write, void *data)
24731da177e4SLinus Torvalds {
24741da177e4SLinus Torvalds 	if (write) {
2475cba9f33dSBart Samwel 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2476cba9f33dSBart Samwel 			return 1;
24771da177e4SLinus Torvalds 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
24781da177e4SLinus Torvalds 	} else {
24791da177e4SLinus Torvalds 		int val = *valp;
24801da177e4SLinus Torvalds 		unsigned long lval;
24811da177e4SLinus Torvalds 		if (val < 0) {
24821da177e4SLinus Torvalds 			*negp = -1;
24831da177e4SLinus Torvalds 			lval = (unsigned long)-val;
24841da177e4SLinus Torvalds 		} else {
24851da177e4SLinus Torvalds 			*negp = 0;
24861da177e4SLinus Torvalds 			lval = (unsigned long)val;
24871da177e4SLinus Torvalds 		}
24881da177e4SLinus Torvalds 		*lvalp = jiffies_to_clock_t(lval);
24891da177e4SLinus Torvalds 	}
24901da177e4SLinus Torvalds 	return 0;
24911da177e4SLinus Torvalds }
24921da177e4SLinus Torvalds 
24931da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
24941da177e4SLinus Torvalds 					    int *valp,
24951da177e4SLinus Torvalds 					    int write, void *data)
24961da177e4SLinus Torvalds {
24971da177e4SLinus Torvalds 	if (write) {
24981da177e4SLinus Torvalds 		*valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
24991da177e4SLinus Torvalds 	} else {
25001da177e4SLinus Torvalds 		int val = *valp;
25011da177e4SLinus Torvalds 		unsigned long lval;
25021da177e4SLinus Torvalds 		if (val < 0) {
25031da177e4SLinus Torvalds 			*negp = -1;
25041da177e4SLinus Torvalds 			lval = (unsigned long)-val;
25051da177e4SLinus Torvalds 		} else {
25061da177e4SLinus Torvalds 			*negp = 0;
25071da177e4SLinus Torvalds 			lval = (unsigned long)val;
25081da177e4SLinus Torvalds 		}
25091da177e4SLinus Torvalds 		*lvalp = jiffies_to_msecs(lval);
25101da177e4SLinus Torvalds 	}
25111da177e4SLinus Torvalds 	return 0;
25121da177e4SLinus Torvalds }
25131da177e4SLinus Torvalds 
25141da177e4SLinus Torvalds /**
25151da177e4SLinus Torvalds  * proc_dointvec_jiffies - read a vector of integers as seconds
25161da177e4SLinus Torvalds  * @table: the sysctl table
25171da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25181da177e4SLinus Torvalds  * @buffer: the user buffer
25191da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25201da177e4SLinus Torvalds  * @ppos: file position
25211da177e4SLinus Torvalds  *
25221da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
25231da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25241da177e4SLinus Torvalds  * The values read are assumed to be in seconds, and are converted into
25251da177e4SLinus Torvalds  * jiffies.
25261da177e4SLinus Torvalds  *
25271da177e4SLinus Torvalds  * Returns 0 on success.
25281da177e4SLinus Torvalds  */
25298d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write,
25301da177e4SLinus Torvalds 			  void __user *buffer, size_t *lenp, loff_t *ppos)
25311da177e4SLinus Torvalds {
25328d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
25331da177e4SLinus Torvalds 		    	    do_proc_dointvec_jiffies_conv,NULL);
25341da177e4SLinus Torvalds }
25351da177e4SLinus Torvalds 
25361da177e4SLinus Torvalds /**
25371da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
25381da177e4SLinus Torvalds  * @table: the sysctl table
25391da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25401da177e4SLinus Torvalds  * @buffer: the user buffer
25411da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25421e5d5331SRandy Dunlap  * @ppos: pointer to the file position
25431da177e4SLinus Torvalds  *
25441da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
25451da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25461da177e4SLinus Torvalds  * The values read are assumed to be in 1/USER_HZ seconds, and
25471da177e4SLinus Torvalds  * are converted into jiffies.
25481da177e4SLinus Torvalds  *
25491da177e4SLinus Torvalds  * Returns 0 on success.
25501da177e4SLinus Torvalds  */
25518d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
25521da177e4SLinus Torvalds 				 void __user *buffer, size_t *lenp, loff_t *ppos)
25531da177e4SLinus Torvalds {
25548d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
25551da177e4SLinus Torvalds 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
25561da177e4SLinus Torvalds }
25571da177e4SLinus Torvalds 
25581da177e4SLinus Torvalds /**
25591da177e4SLinus Torvalds  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
25601da177e4SLinus Torvalds  * @table: the sysctl table
25611da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25621da177e4SLinus Torvalds  * @buffer: the user buffer
25631da177e4SLinus Torvalds  * @lenp: the size of the user buffer
256467be2dd1SMartin Waitz  * @ppos: file position
256567be2dd1SMartin Waitz  * @ppos: the current position in the file
25661da177e4SLinus Torvalds  *
25671da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
25681da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25691da177e4SLinus Torvalds  * The values read are assumed to be in 1/1000 seconds, and
25701da177e4SLinus Torvalds  * are converted into jiffies.
25711da177e4SLinus Torvalds  *
25721da177e4SLinus Torvalds  * Returns 0 on success.
25731da177e4SLinus Torvalds  */
25748d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
25751da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
25761da177e4SLinus Torvalds {
25778d65af78SAlexey Dobriyan 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
25781da177e4SLinus Torvalds 				do_proc_dointvec_ms_jiffies_conv, NULL);
25791da177e4SLinus Torvalds }
25801da177e4SLinus Torvalds 
25818d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write,
25829ec52099SCedric Le Goater 			   void __user *buffer, size_t *lenp, loff_t *ppos)
25839ec52099SCedric Le Goater {
25849ec52099SCedric Le Goater 	struct pid *new_pid;
25859ec52099SCedric Le Goater 	pid_t tmp;
25869ec52099SCedric Le Goater 	int r;
25879ec52099SCedric Le Goater 
25886c5f3e7bSPavel Emelyanov 	tmp = pid_vnr(cad_pid);
25899ec52099SCedric Le Goater 
25908d65af78SAlexey Dobriyan 	r = __do_proc_dointvec(&tmp, table, write, buffer,
25919ec52099SCedric Le Goater 			       lenp, ppos, NULL, NULL);
25929ec52099SCedric Le Goater 	if (r || !write)
25939ec52099SCedric Le Goater 		return r;
25949ec52099SCedric Le Goater 
25959ec52099SCedric Le Goater 	new_pid = find_get_pid(tmp);
25969ec52099SCedric Le Goater 	if (!new_pid)
25979ec52099SCedric Le Goater 		return -ESRCH;
25989ec52099SCedric Le Goater 
25999ec52099SCedric Le Goater 	put_pid(xchg(&cad_pid, new_pid));
26009ec52099SCedric Le Goater 	return 0;
26019ec52099SCedric Le Goater }
26029ec52099SCedric Le Goater 
26031da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */
26041da177e4SLinus Torvalds 
26058d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write,
26061da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
26071da177e4SLinus Torvalds {
26081da177e4SLinus Torvalds 	return -ENOSYS;
26091da177e4SLinus Torvalds }
26101da177e4SLinus Torvalds 
26118d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write,
26121da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
26131da177e4SLinus Torvalds {
26141da177e4SLinus Torvalds 	return -ENOSYS;
26151da177e4SLinus Torvalds }
26161da177e4SLinus Torvalds 
26178d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write,
26181da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
26191da177e4SLinus Torvalds {
26201da177e4SLinus Torvalds 	return -ENOSYS;
26211da177e4SLinus Torvalds }
26221da177e4SLinus Torvalds 
26238d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write,
26241da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
26251da177e4SLinus Torvalds {
26261da177e4SLinus Torvalds 	return -ENOSYS;
26271da177e4SLinus Torvalds }
26281da177e4SLinus Torvalds 
26298d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
26301da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
26311da177e4SLinus Torvalds {
26321da177e4SLinus Torvalds 	return -ENOSYS;
26331da177e4SLinus Torvalds }
26341da177e4SLinus Torvalds 
26358d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
26361da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
26371da177e4SLinus Torvalds {
26381da177e4SLinus Torvalds 	return -ENOSYS;
26391da177e4SLinus Torvalds }
26401da177e4SLinus Torvalds 
26418d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write,
26421da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
26431da177e4SLinus Torvalds {
26441da177e4SLinus Torvalds 	return -ENOSYS;
26451da177e4SLinus Torvalds }
26461da177e4SLinus Torvalds 
2647d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
26481da177e4SLinus Torvalds 				      void __user *buffer,
26491da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
26501da177e4SLinus Torvalds {
26511da177e4SLinus Torvalds     return -ENOSYS;
26521da177e4SLinus Torvalds }
26531da177e4SLinus Torvalds 
26541da177e4SLinus Torvalds 
26551da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */
26561da177e4SLinus Torvalds 
2657f221e726SAlexey Dobriyan int sysctl_data(struct ctl_table *table,
265849a0c458SEric W. Biederman 		  void __user *oldval, size_t __user *oldlenp,
265949a0c458SEric W. Biederman 		  void __user *newval, size_t newlen)
266049a0c458SEric W. Biederman {
266149a0c458SEric W. Biederman 	return -ENOSYS;
266249a0c458SEric W. Biederman }
266349a0c458SEric W. Biederman 
2664f221e726SAlexey Dobriyan int sysctl_string(struct ctl_table *table,
26651da177e4SLinus Torvalds 		  void __user *oldval, size_t __user *oldlenp,
26661f29bcd7SAlexey Dobriyan 		  void __user *newval, size_t newlen)
26671da177e4SLinus Torvalds {
26681da177e4SLinus Torvalds 	return -ENOSYS;
26691da177e4SLinus Torvalds }
26701da177e4SLinus Torvalds 
2671f221e726SAlexey Dobriyan int sysctl_intvec(struct ctl_table *table,
26721da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
26731f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
26741da177e4SLinus Torvalds {
26751da177e4SLinus Torvalds 	return -ENOSYS;
26761da177e4SLinus Torvalds }
26771da177e4SLinus Torvalds 
2678f221e726SAlexey Dobriyan int sysctl_jiffies(struct ctl_table *table,
26791da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
26801f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
26811da177e4SLinus Torvalds {
26821da177e4SLinus Torvalds 	return -ENOSYS;
26831da177e4SLinus Torvalds }
26841da177e4SLinus Torvalds 
2685f221e726SAlexey Dobriyan int sysctl_ms_jiffies(struct ctl_table *table,
26861da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
26871f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
26881da177e4SLinus Torvalds {
26891da177e4SLinus Torvalds 	return -ENOSYS;
26901da177e4SLinus Torvalds }
26911da177e4SLinus Torvalds 
26921da177e4SLinus Torvalds /*
26931da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
26941da177e4SLinus Torvalds  * exception granted :-)
26951da177e4SLinus Torvalds  */
26961da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
26971da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
26981da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
26991da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
27001da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
27011da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
27021da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
27031da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
27041da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table);
270529e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths);
27061da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_intvec);
27071da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_jiffies);
27081da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_ms_jiffies);
27091da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_string);
271049a0c458SEric W. Biederman EXPORT_SYMBOL(sysctl_data);
27111da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table);
2712