xref: /openbmc/linux/kernel/sysctl.c (revision 2bba22c50b06abe9fd0d23933b1e64d35b419262)
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>
291da177e4SLinus Torvalds #include <linux/utsname.h>
30dfec072eSVegard Nossum #include <linux/kmemcheck.h>
311da177e4SLinus Torvalds #include <linux/smp_lock.h>
3262239ac2SAdrian Bunk #include <linux/fs.h>
331da177e4SLinus Torvalds #include <linux/init.h>
341da177e4SLinus Torvalds #include <linux/kernel.h>
350296b228SKay Sievers #include <linux/kobject.h>
3620380731SArnaldo Carvalho de Melo #include <linux/net.h>
371da177e4SLinus Torvalds #include <linux/sysrq.h>
381da177e4SLinus Torvalds #include <linux/highuid.h>
391da177e4SLinus Torvalds #include <linux/writeback.h>
401da177e4SLinus Torvalds #include <linux/hugetlb.h>
411da177e4SLinus Torvalds #include <linux/initrd.h>
420b77f5bfSDavid Howells #include <linux/key.h>
431da177e4SLinus Torvalds #include <linux/times.h>
441da177e4SLinus Torvalds #include <linux/limits.h>
451da177e4SLinus Torvalds #include <linux/dcache.h>
461da177e4SLinus Torvalds #include <linux/syscalls.h>
47c748e134SAdrian Bunk #include <linux/vmstat.h>
48c255d844SPavel Machek #include <linux/nfs_fs.h>
49c255d844SPavel Machek #include <linux/acpi.h>
5010a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h>
51b0fc494fSSteven Rostedt #include <linux/ftrace.h>
52788084abSEric Paris #include <linux/security.h>
5312e22c5eSDavid Howells #include <linux/slow-work.h>
541ccd1549SPeter Zijlstra #include <linux/perf_counter.h>
551da177e4SLinus Torvalds 
561da177e4SLinus Torvalds #include <asm/uaccess.h>
571da177e4SLinus Torvalds #include <asm/processor.h>
581da177e4SLinus Torvalds 
5929cbc78bSAndi Kleen #ifdef CONFIG_X86
6029cbc78bSAndi Kleen #include <asm/nmi.h>
610741f4d2SChuck Ebbert #include <asm/stacktrace.h>
626e7c4025SIngo Molnar #include <asm/io.h>
6329cbc78bSAndi Kleen #endif
6429cbc78bSAndi Kleen 
657058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args);
667058cb02SEric W. Biederman 
671da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL)
681da177e4SLinus Torvalds 
691da177e4SLinus Torvalds /* External variables not in a header file. */
701da177e4SLinus Torvalds extern int C_A_D;
7145807a1dSIngo Molnar extern int print_fatal_signals;
721da177e4SLinus Torvalds extern int sysctl_overcommit_memory;
731da177e4SLinus Torvalds extern int sysctl_overcommit_ratio;
74fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom;
75fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task;
76fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks;
771da177e4SLinus Torvalds extern int max_threads;
781da177e4SLinus Torvalds extern int core_uses_pid;
79d6e71144SAlan Cox extern int suid_dumpable;
801da177e4SLinus Torvalds extern char core_pattern[];
811da177e4SLinus Torvalds extern int pid_max;
821da177e4SLinus Torvalds extern int min_free_kbytes;
831da177e4SLinus Torvalds extern int pid_max_min, pid_max_max;
849d0243bcSAndrew Morton extern int sysctl_drop_caches;
858ad4b1fbSRohit Seth extern int percpu_pagelist_fraction;
86bebfa101SAndi Kleen extern int compat_log;
879745512cSArjan van de Ven extern int latencytop_enabled;
88eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max;
89dd8632a1SPaul Mundt #ifndef CONFIG_MMU
90dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages;
91dd8632a1SPaul Mundt #endif
9231a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
9331a72bceSPaul E. McKenney extern int rcutorture_runnable;
9431a72bceSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
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;
107c4f3b63fSRavikiran G Thirumalai 
1089e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
1099e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1109e4a5bdaSAndrea Righi 
1111da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1121da177e4SLinus Torvalds static int maxolduid = 65535;
1131da177e4SLinus Torvalds static int minolduid;
1148ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8;
1151da177e4SLinus Torvalds 
1161da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
1171da177e4SLinus Torvalds 
118a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
1191da177e4SLinus Torvalds extern char modprobe_path[];
1203d43321bSKees Cook extern int modules_disabled;
1211da177e4SLinus Torvalds #endif
1221da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
1231da177e4SLinus Torvalds extern int sg_big_buff;
1241da177e4SLinus Torvalds #endif
1251da177e4SLinus Torvalds 
12672c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
12717f04fbbSDavid S. Miller #include <asm/system.h>
1281da177e4SLinus Torvalds #endif
1291da177e4SLinus Torvalds 
1300871420fSDavid S. Miller #ifdef CONFIG_SPARC64
1310871420fSDavid S. Miller extern int sysctl_tsb_ratio;
1320871420fSDavid S. Miller #endif
1330871420fSDavid S. Miller 
1341da177e4SLinus Torvalds #ifdef __hppa__
1351da177e4SLinus Torvalds extern int pwrsw_enabled;
1361da177e4SLinus Torvalds extern int unaligned_enabled;
1371da177e4SLinus Torvalds #endif
1381da177e4SLinus Torvalds 
139347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
1401da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
1411da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings;
1421da177e4SLinus Torvalds #endif
1431da177e4SLinus Torvalds extern int sysctl_userprocess_debug;
144951f22d5SMartin Schwidefsky extern int spin_retry;
1451da177e4SLinus Torvalds #endif
1461da177e4SLinus Torvalds 
1471da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
1481da177e4SLinus Torvalds extern int acct_parm[];
1491da177e4SLinus Torvalds #endif
1501da177e4SLinus Torvalds 
151d2b176edSJes Sorensen #ifdef CONFIG_IA64
152d2b176edSJes Sorensen extern int no_unaligned_warning;
15388fc241fSDoug Chapman extern int unaligned_dump_stack;
154d2b176edSJes Sorensen #endif
155d2b176edSJes Sorensen 
15623f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
15723f78d4aSIngo Molnar extern int max_lock_depth;
15823f78d4aSIngo Molnar #endif
15923f78d4aSIngo Molnar 
160d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
161d8217f07SEric W. Biederman static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
1629ec52099SCedric Le Goater 		  void __user *buffer, size_t *lenp, loff_t *ppos);
16325ddbb18SAndi Kleen static int proc_taint(struct ctl_table *table, int write, struct file *filp,
16434f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos);
165d6f8ff73SRandy Dunlap #endif
1669ec52099SCedric Le Goater 
167d8217f07SEric W. Biederman static struct ctl_table root_table[];
168e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root;
169e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = {
170b380b0d4SAl Viro 	.count = 1,
171e51b6ba0SEric W. Biederman 	.ctl_table = root_table,
17273455092SAl Viro 	.ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
173e51b6ba0SEric W. Biederman 	.root = &sysctl_table_root,
17473455092SAl Viro 	.set = &sysctl_table_root.default_set,
175e51b6ba0SEric W. Biederman };
176e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = {
177e51b6ba0SEric W. Biederman 	.root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
17873455092SAl Viro 	.default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
179e51b6ba0SEric W. Biederman };
1801da177e4SLinus Torvalds 
181d8217f07SEric W. Biederman static struct ctl_table kern_table[];
182d8217f07SEric W. Biederman static struct ctl_table vm_table[];
183d8217f07SEric W. Biederman static struct ctl_table fs_table[];
184d8217f07SEric W. Biederman static struct ctl_table debug_table[];
185d8217f07SEric W. Biederman static struct ctl_table dev_table[];
186d8217f07SEric W. Biederman extern struct ctl_table random_table[];
1872d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
188d8217f07SEric W. Biederman extern struct ctl_table inotify_table[];
1890399cb08SRobert Love #endif
1907ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
1917ef9964eSDavide Libenzi extern struct ctl_table epoll_table[];
1927ef9964eSDavide Libenzi #endif
1931da177e4SLinus Torvalds 
1941da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1951da177e4SLinus Torvalds int sysctl_legacy_va_layout;
1961da177e4SLinus Torvalds #endif
1971da177e4SLinus Torvalds 
198f20786ffSPeter Zijlstra extern int prove_locking;
199f20786ffSPeter Zijlstra extern int lock_stat;
2009bc9a6bdSEric W. Biederman 
2011da177e4SLinus Torvalds /* The default sysctl tables: */
2021da177e4SLinus Torvalds 
203d8217f07SEric W. Biederman static struct ctl_table root_table[] = {
2041da177e4SLinus Torvalds 	{
2051da177e4SLinus Torvalds 		.ctl_name	= CTL_KERN,
2061da177e4SLinus Torvalds 		.procname	= "kernel",
2071da177e4SLinus Torvalds 		.mode		= 0555,
2081da177e4SLinus Torvalds 		.child		= kern_table,
2091da177e4SLinus Torvalds 	},
2101da177e4SLinus Torvalds 	{
2111da177e4SLinus Torvalds 		.ctl_name	= CTL_VM,
2121da177e4SLinus Torvalds 		.procname	= "vm",
2131da177e4SLinus Torvalds 		.mode		= 0555,
2141da177e4SLinus Torvalds 		.child		= vm_table,
2151da177e4SLinus Torvalds 	},
2161da177e4SLinus Torvalds 	{
2171da177e4SLinus Torvalds 		.ctl_name	= CTL_FS,
2181da177e4SLinus Torvalds 		.procname	= "fs",
2191da177e4SLinus Torvalds 		.mode		= 0555,
2201da177e4SLinus Torvalds 		.child		= fs_table,
2211da177e4SLinus Torvalds 	},
2221da177e4SLinus Torvalds 	{
2231da177e4SLinus Torvalds 		.ctl_name	= CTL_DEBUG,
2241da177e4SLinus Torvalds 		.procname	= "debug",
2251da177e4SLinus Torvalds 		.mode		= 0555,
2261da177e4SLinus Torvalds 		.child		= debug_table,
2271da177e4SLinus Torvalds 	},
2281da177e4SLinus Torvalds 	{
2291da177e4SLinus Torvalds 		.ctl_name	= CTL_DEV,
2301da177e4SLinus Torvalds 		.procname	= "dev",
2311da177e4SLinus Torvalds 		.mode		= 0555,
2321da177e4SLinus Torvalds 		.child		= dev_table,
2331da177e4SLinus Torvalds 	},
2342be7fe07SAndrew Morton /*
2352be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
2362be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
2372be7fe07SAndrew Morton  */
2381da177e4SLinus Torvalds 	{ .ctl_name = 0 }
2391da177e4SLinus Torvalds };
2401da177e4SLinus Torvalds 
24177e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
24273c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000;		/* 100 usecs */
24373c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
24473c4efd2SEric Dumazet static int min_wakeup_granularity_ns;			/* 0 usecs */
24573c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
24677e54a1fSIngo Molnar #endif
24777e54a1fSIngo Molnar 
248d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
249*2bba22c5SMike Galbraith 	{
250*2bba22c5SMike Galbraith 		.ctl_name	= CTL_UNNUMBERED,
251*2bba22c5SMike Galbraith 		.procname	= "sched_child_runs_first",
252*2bba22c5SMike Galbraith 		.data		= &sysctl_sched_child_runs_first,
253*2bba22c5SMike Galbraith 		.maxlen		= sizeof(unsigned int),
254*2bba22c5SMike Galbraith 		.mode		= 0644,
255*2bba22c5SMike Galbraith 		.proc_handler	= &proc_dointvec,
256*2bba22c5SMike Galbraith 	},
25777e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
25877e54a1fSIngo Molnar 	{
25977e54a1fSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
260b2be5e96SPeter Zijlstra 		.procname	= "sched_min_granularity_ns",
261b2be5e96SPeter Zijlstra 		.data		= &sysctl_sched_min_granularity,
26277e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
26377e54a1fSIngo Molnar 		.mode		= 0644,
264b2be5e96SPeter Zijlstra 		.proc_handler	= &sched_nr_latency_handler,
265b2be5e96SPeter Zijlstra 		.strategy	= &sysctl_intvec,
266b2be5e96SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
267b2be5e96SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
26877e54a1fSIngo Molnar 	},
26977e54a1fSIngo Molnar 	{
27077e54a1fSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
27121805085SPeter Zijlstra 		.procname	= "sched_latency_ns",
27221805085SPeter Zijlstra 		.data		= &sysctl_sched_latency,
27321805085SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
27421805085SPeter Zijlstra 		.mode		= 0644,
275b2be5e96SPeter Zijlstra 		.proc_handler	= &sched_nr_latency_handler,
27621805085SPeter Zijlstra 		.strategy	= &sysctl_intvec,
27721805085SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
27821805085SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
27921805085SPeter Zijlstra 	},
28021805085SPeter Zijlstra 	{
28121805085SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
28277e54a1fSIngo Molnar 		.procname	= "sched_wakeup_granularity_ns",
28377e54a1fSIngo Molnar 		.data		= &sysctl_sched_wakeup_granularity,
28477e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
28577e54a1fSIngo Molnar 		.mode		= 0644,
28677e54a1fSIngo Molnar 		.proc_handler	= &proc_dointvec_minmax,
28777e54a1fSIngo Molnar 		.strategy	= &sysctl_intvec,
28877e54a1fSIngo Molnar 		.extra1		= &min_wakeup_granularity_ns,
28977e54a1fSIngo Molnar 		.extra2		= &max_wakeup_granularity_ns,
29077e54a1fSIngo Molnar 	},
29177e54a1fSIngo Molnar 	{
29277e54a1fSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
2932398f2c6SPeter Zijlstra 		.procname	= "sched_shares_ratelimit",
2942398f2c6SPeter Zijlstra 		.data		= &sysctl_sched_shares_ratelimit,
2952398f2c6SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
2962398f2c6SPeter Zijlstra 		.mode		= 0644,
2972398f2c6SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
2982398f2c6SPeter Zijlstra 	},
2992398f2c6SPeter Zijlstra 	{
3002398f2c6SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
301ffda12a1SPeter Zijlstra 		.procname	= "sched_shares_thresh",
302ffda12a1SPeter Zijlstra 		.data		= &sysctl_sched_shares_thresh,
303ffda12a1SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
304ffda12a1SPeter Zijlstra 		.mode		= 0644,
305ffda12a1SPeter Zijlstra 		.proc_handler	= &proc_dointvec_minmax,
306ffda12a1SPeter Zijlstra 		.strategy	= &sysctl_intvec,
307ffda12a1SPeter Zijlstra 		.extra1		= &zero,
308ffda12a1SPeter Zijlstra 	},
309ffda12a1SPeter Zijlstra 	{
310ffda12a1SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
3111fc84aaaSPeter Zijlstra 		.procname	= "sched_features",
3121fc84aaaSPeter Zijlstra 		.data		= &sysctl_sched_features,
3131fc84aaaSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3141fc84aaaSPeter Zijlstra 		.mode		= 0644,
3151fc84aaaSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
3161fc84aaaSPeter Zijlstra 	},
317da84d961SIngo Molnar 	{
318da84d961SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
319da84d961SIngo Molnar 		.procname	= "sched_migration_cost",
320da84d961SIngo Molnar 		.data		= &sysctl_sched_migration_cost,
321da84d961SIngo Molnar 		.maxlen		= sizeof(unsigned int),
322da84d961SIngo Molnar 		.mode		= 0644,
323da84d961SIngo Molnar 		.proc_handler	= &proc_dointvec,
324da84d961SIngo Molnar 	},
325b82d9fddSPeter Zijlstra 	{
326b82d9fddSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
327b82d9fddSPeter Zijlstra 		.procname	= "sched_nr_migrate",
328b82d9fddSPeter Zijlstra 		.data		= &sysctl_sched_nr_migrate,
329b82d9fddSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
330fa85ae24SPeter Zijlstra 		.mode		= 0644,
331fa85ae24SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
332fa85ae24SPeter Zijlstra 	},
333cd1bb94bSArun R Bharadwaj 	{
334cd1bb94bSArun R Bharadwaj 		.ctl_name	= CTL_UNNUMBERED,
335e9e9250bSPeter Zijlstra 		.procname	= "sched_time_avg",
336e9e9250bSPeter Zijlstra 		.data		= &sysctl_sched_time_avg,
337e9e9250bSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
338e9e9250bSPeter Zijlstra 		.mode		= 0644,
339e9e9250bSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
340e9e9250bSPeter Zijlstra 	},
341e9e9250bSPeter Zijlstra 	{
342e9e9250bSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
343cd1bb94bSArun R Bharadwaj 		.procname	= "timer_migration",
344cd1bb94bSArun R Bharadwaj 		.data		= &sysctl_timer_migration,
345cd1bb94bSArun R Bharadwaj 		.maxlen		= sizeof(unsigned int),
346cd1bb94bSArun R Bharadwaj 		.mode		= 0644,
347bfdb4d9fSArun R Bharadwaj 		.proc_handler	= &proc_dointvec_minmax,
348bfdb4d9fSArun R Bharadwaj 		.strategy	= &sysctl_intvec,
349bfdb4d9fSArun R Bharadwaj 		.extra1		= &zero,
350bfdb4d9fSArun R Bharadwaj 		.extra2		= &one,
351cd1bb94bSArun R Bharadwaj 	},
3521fc84aaaSPeter Zijlstra #endif
3531799e35dSIngo Molnar 	{
3541799e35dSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
3559f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
3569f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
3579f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3589f0c1e56SPeter Zijlstra 		.mode		= 0644,
359d0b27fa7SPeter Zijlstra 		.proc_handler	= &sched_rt_handler,
3609f0c1e56SPeter Zijlstra 	},
3619f0c1e56SPeter Zijlstra 	{
3629f0c1e56SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
3639f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
3649f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
3659f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
3669f0c1e56SPeter Zijlstra 		.mode		= 0644,
367d0b27fa7SPeter Zijlstra 		.proc_handler	= &sched_rt_handler,
3689f0c1e56SPeter Zijlstra 	},
3699f0c1e56SPeter Zijlstra 	{
3709f0c1e56SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
3711799e35dSIngo Molnar 		.procname	= "sched_compat_yield",
3721799e35dSIngo Molnar 		.data		= &sysctl_sched_compat_yield,
3731799e35dSIngo Molnar 		.maxlen		= sizeof(unsigned int),
3741799e35dSIngo Molnar 		.mode		= 0644,
3751799e35dSIngo Molnar 		.proc_handler	= &proc_dointvec,
3761799e35dSIngo Molnar 	},
377f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
378f20786ffSPeter Zijlstra 	{
379f20786ffSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
380f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
381f20786ffSPeter Zijlstra 		.data		= &prove_locking,
382f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
383f20786ffSPeter Zijlstra 		.mode		= 0644,
384f20786ffSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
385f20786ffSPeter Zijlstra 	},
386f20786ffSPeter Zijlstra #endif
387f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
388f20786ffSPeter Zijlstra 	{
389f20786ffSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
390f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
391f20786ffSPeter Zijlstra 		.data		= &lock_stat,
392f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
393f20786ffSPeter Zijlstra 		.mode		= 0644,
394f20786ffSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
395f20786ffSPeter Zijlstra 	},
396f20786ffSPeter Zijlstra #endif
39777e54a1fSIngo Molnar 	{
3981da177e4SLinus Torvalds 		.ctl_name	= KERN_PANIC,
3991da177e4SLinus Torvalds 		.procname	= "panic",
4001da177e4SLinus Torvalds 		.data		= &panic_timeout,
4011da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4021da177e4SLinus Torvalds 		.mode		= 0644,
4031da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4041da177e4SLinus Torvalds 	},
4051da177e4SLinus Torvalds 	{
4061da177e4SLinus Torvalds 		.ctl_name	= KERN_CORE_USES_PID,
4071da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
4081da177e4SLinus Torvalds 		.data		= &core_uses_pid,
4091da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4101da177e4SLinus Torvalds 		.mode		= 0644,
4111da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4121da177e4SLinus Torvalds 	},
4131da177e4SLinus Torvalds 	{
4141da177e4SLinus Torvalds 		.ctl_name	= KERN_CORE_PATTERN,
4151da177e4SLinus Torvalds 		.procname	= "core_pattern",
4161da177e4SLinus Torvalds 		.data		= core_pattern,
41771ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
4181da177e4SLinus Torvalds 		.mode		= 0644,
4191da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
4201da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
4211da177e4SLinus Torvalds 	},
42234f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
4231da177e4SLinus Torvalds 	{
4241da177e4SLinus Torvalds 		.procname	= "tainted",
42525ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
42634f5a398STheodore Ts'o 		.mode		= 0644,
42725ddbb18SAndi Kleen 		.proc_handler	= &proc_taint,
4281da177e4SLinus Torvalds 	},
42934f5a398STheodore Ts'o #endif
4309745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
4319745512cSArjan van de Ven 	{
4329745512cSArjan van de Ven 		.procname	= "latencytop",
4339745512cSArjan van de Ven 		.data		= &latencytop_enabled,
4349745512cSArjan van de Ven 		.maxlen		= sizeof(int),
4359745512cSArjan van de Ven 		.mode		= 0644,
4369745512cSArjan van de Ven 		.proc_handler	= &proc_dointvec,
4379745512cSArjan van de Ven 	},
4389745512cSArjan van de Ven #endif
4391da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
4401da177e4SLinus Torvalds 	{
4411da177e4SLinus Torvalds 		.ctl_name	= KERN_REALROOTDEV,
4421da177e4SLinus Torvalds 		.procname	= "real-root-dev",
4431da177e4SLinus Torvalds 		.data		= &real_root_dev,
4441da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4451da177e4SLinus Torvalds 		.mode		= 0644,
4461da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4471da177e4SLinus Torvalds 	},
4481da177e4SLinus Torvalds #endif
44945807a1dSIngo Molnar 	{
45045807a1dSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
45145807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
45245807a1dSIngo Molnar 		.data		= &print_fatal_signals,
45345807a1dSIngo Molnar 		.maxlen		= sizeof(int),
45445807a1dSIngo Molnar 		.mode		= 0644,
45545807a1dSIngo Molnar 		.proc_handler	= &proc_dointvec,
45645807a1dSIngo Molnar 	},
45772c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
4581da177e4SLinus Torvalds 	{
4591da177e4SLinus Torvalds 		.ctl_name	= KERN_SPARC_REBOOT,
4601da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
4611da177e4SLinus Torvalds 		.data		= reboot_command,
4621da177e4SLinus Torvalds 		.maxlen		= 256,
4631da177e4SLinus Torvalds 		.mode		= 0644,
4641da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
4651da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
4661da177e4SLinus Torvalds 	},
4671da177e4SLinus Torvalds 	{
4681da177e4SLinus Torvalds 		.ctl_name	= KERN_SPARC_STOP_A,
4691da177e4SLinus Torvalds 		.procname	= "stop-a",
4701da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
4711da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4721da177e4SLinus Torvalds 		.mode		= 0644,
4731da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4741da177e4SLinus Torvalds 	},
4751da177e4SLinus Torvalds 	{
4761da177e4SLinus Torvalds 		.ctl_name	= KERN_SPARC_SCONS_PWROFF,
4771da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
4781da177e4SLinus Torvalds 		.data		= &scons_pwroff,
4791da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4801da177e4SLinus Torvalds 		.mode		= 0644,
4811da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4821da177e4SLinus Torvalds 	},
4831da177e4SLinus Torvalds #endif
4840871420fSDavid S. Miller #ifdef CONFIG_SPARC64
4850871420fSDavid S. Miller 	{
4860871420fSDavid S. Miller 		.ctl_name	= CTL_UNNUMBERED,
4870871420fSDavid S. Miller 		.procname	= "tsb-ratio",
4880871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
4890871420fSDavid S. Miller 		.maxlen		= sizeof (int),
4900871420fSDavid S. Miller 		.mode		= 0644,
4910871420fSDavid S. Miller 		.proc_handler	= &proc_dointvec,
4920871420fSDavid S. Miller 	},
4930871420fSDavid S. Miller #endif
4941da177e4SLinus Torvalds #ifdef __hppa__
4951da177e4SLinus Torvalds 	{
4961da177e4SLinus Torvalds 		.ctl_name	= KERN_HPPA_PWRSW,
4971da177e4SLinus Torvalds 		.procname	= "soft-power",
4981da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
4991da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5001da177e4SLinus Torvalds 	 	.mode		= 0644,
5011da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5021da177e4SLinus Torvalds 	},
5031da177e4SLinus Torvalds 	{
5041da177e4SLinus Torvalds 		.ctl_name	= KERN_HPPA_UNALIGNED,
5051da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
5061da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
5071da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5081da177e4SLinus Torvalds 		.mode		= 0644,
5091da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5101da177e4SLinus Torvalds 	},
5111da177e4SLinus Torvalds #endif
5121da177e4SLinus Torvalds 	{
5131da177e4SLinus Torvalds 		.ctl_name	= KERN_CTLALTDEL,
5141da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
5151da177e4SLinus Torvalds 		.data		= &C_A_D,
5161da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5171da177e4SLinus Torvalds 		.mode		= 0644,
5181da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5191da177e4SLinus Torvalds 	},
520606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
521b0fc494fSSteven Rostedt 	{
522b0fc494fSSteven Rostedt 		.ctl_name	= CTL_UNNUMBERED,
523b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
524b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
525b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
526b0fc494fSSteven Rostedt 		.mode		= 0644,
527b0fc494fSSteven Rostedt 		.proc_handler	= &ftrace_enable_sysctl,
528b0fc494fSSteven Rostedt 	},
529b0fc494fSSteven Rostedt #endif
530f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
531f38f1d2aSSteven Rostedt 	{
532f38f1d2aSSteven Rostedt 		.ctl_name	= CTL_UNNUMBERED,
533f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
534f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
535f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
536f38f1d2aSSteven Rostedt 		.mode		= 0644,
537f38f1d2aSSteven Rostedt 		.proc_handler	= &stack_trace_sysctl,
538f38f1d2aSSteven Rostedt 	},
539f38f1d2aSSteven Rostedt #endif
540944ac425SSteven Rostedt #ifdef CONFIG_TRACING
541944ac425SSteven Rostedt 	{
542944ac425SSteven Rostedt 		.ctl_name	= CTL_UNNUMBERED,
5433299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
544944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
545944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
546944ac425SSteven Rostedt 		.mode		= 0644,
547944ac425SSteven Rostedt 		.proc_handler	= &proc_dointvec,
548944ac425SSteven Rostedt 	},
549944ac425SSteven Rostedt #endif
550a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
5511da177e4SLinus Torvalds 	{
5521da177e4SLinus Torvalds 		.ctl_name	= KERN_MODPROBE,
5531da177e4SLinus Torvalds 		.procname	= "modprobe",
5541da177e4SLinus Torvalds 		.data		= &modprobe_path,
5551da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
5561da177e4SLinus Torvalds 		.mode		= 0644,
5571da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
5581da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
5591da177e4SLinus Torvalds 	},
5603d43321bSKees Cook 	{
5613d43321bSKees Cook 		.ctl_name	= CTL_UNNUMBERED,
5623d43321bSKees Cook 		.procname	= "modules_disabled",
5633d43321bSKees Cook 		.data		= &modules_disabled,
5643d43321bSKees Cook 		.maxlen		= sizeof(int),
5653d43321bSKees Cook 		.mode		= 0644,
5663d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
5673d43321bSKees Cook 		.proc_handler	= &proc_dointvec_minmax,
5683d43321bSKees Cook 		.extra1		= &one,
5693d43321bSKees Cook 		.extra2		= &one,
5703d43321bSKees Cook 	},
5711da177e4SLinus Torvalds #endif
57257ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
5731da177e4SLinus Torvalds 	{
5741da177e4SLinus Torvalds 		.ctl_name	= KERN_HOTPLUG,
5751da177e4SLinus Torvalds 		.procname	= "hotplug",
576312c004dSKay Sievers 		.data		= &uevent_helper,
577312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
5781da177e4SLinus Torvalds 		.mode		= 0644,
5791da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
5801da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
5811da177e4SLinus Torvalds 	},
5821da177e4SLinus Torvalds #endif
5831da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
5841da177e4SLinus Torvalds 	{
5851da177e4SLinus Torvalds 		.ctl_name	= KERN_SG_BIG_BUFF,
5861da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
5871da177e4SLinus Torvalds 		.data		= &sg_big_buff,
5881da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5891da177e4SLinus Torvalds 		.mode		= 0444,
5901da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5911da177e4SLinus Torvalds 	},
5921da177e4SLinus Torvalds #endif
5931da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
5941da177e4SLinus Torvalds 	{
5951da177e4SLinus Torvalds 		.ctl_name	= KERN_ACCT,
5961da177e4SLinus Torvalds 		.procname	= "acct",
5971da177e4SLinus Torvalds 		.data		= &acct_parm,
5981da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
5991da177e4SLinus Torvalds 		.mode		= 0644,
6001da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6011da177e4SLinus Torvalds 	},
6021da177e4SLinus Torvalds #endif
6031da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
6041da177e4SLinus Torvalds 	{
6051da177e4SLinus Torvalds 		.ctl_name	= KERN_SYSRQ,
6061da177e4SLinus Torvalds 		.procname	= "sysrq",
6075d6f647fSIngo Molnar 		.data		= &__sysrq_enabled,
6081da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6091da177e4SLinus Torvalds 		.mode		= 0644,
6101da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6111da177e4SLinus Torvalds 	},
6121da177e4SLinus Torvalds #endif
613d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
6141da177e4SLinus Torvalds 	{
6151da177e4SLinus Torvalds 		.procname	= "cad_pid",
6169ec52099SCedric Le Goater 		.data		= NULL,
6171da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6181da177e4SLinus Torvalds 		.mode		= 0600,
6199ec52099SCedric Le Goater 		.proc_handler	= &proc_do_cad_pid,
6201da177e4SLinus Torvalds 	},
621d6f8ff73SRandy Dunlap #endif
6221da177e4SLinus Torvalds 	{
6231da177e4SLinus Torvalds 		.ctl_name	= KERN_MAX_THREADS,
6241da177e4SLinus Torvalds 		.procname	= "threads-max",
6251da177e4SLinus Torvalds 		.data		= &max_threads,
6261da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6271da177e4SLinus Torvalds 		.mode		= 0644,
6281da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6291da177e4SLinus Torvalds 	},
6301da177e4SLinus Torvalds 	{
6311da177e4SLinus Torvalds 		.ctl_name	= KERN_RANDOM,
6321da177e4SLinus Torvalds 		.procname	= "random",
6331da177e4SLinus Torvalds 		.mode		= 0555,
6341da177e4SLinus Torvalds 		.child		= random_table,
6351da177e4SLinus Torvalds 	},
6361da177e4SLinus Torvalds 	{
6371da177e4SLinus Torvalds 		.ctl_name	= KERN_OVERFLOWUID,
6381da177e4SLinus Torvalds 		.procname	= "overflowuid",
6391da177e4SLinus Torvalds 		.data		= &overflowuid,
6401da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6411da177e4SLinus Torvalds 		.mode		= 0644,
6421da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
6431da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
6441da177e4SLinus Torvalds 		.extra1		= &minolduid,
6451da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6461da177e4SLinus Torvalds 	},
6471da177e4SLinus Torvalds 	{
6481da177e4SLinus Torvalds 		.ctl_name	= KERN_OVERFLOWGID,
6491da177e4SLinus Torvalds 		.procname	= "overflowgid",
6501da177e4SLinus Torvalds 		.data		= &overflowgid,
6511da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6521da177e4SLinus Torvalds 		.mode		= 0644,
6531da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
6541da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
6551da177e4SLinus Torvalds 		.extra1		= &minolduid,
6561da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6571da177e4SLinus Torvalds 	},
658347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
6591da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
6601da177e4SLinus Torvalds 	{
6611da177e4SLinus Torvalds 		.ctl_name	= KERN_IEEE_EMULATION_WARNINGS,
6621da177e4SLinus Torvalds 		.procname	= "ieee_emulation_warnings",
6631da177e4SLinus Torvalds 		.data		= &sysctl_ieee_emulation_warnings,
6641da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6651da177e4SLinus Torvalds 		.mode		= 0644,
6661da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6671da177e4SLinus Torvalds 	},
6681da177e4SLinus Torvalds #endif
6691da177e4SLinus Torvalds 	{
6701da177e4SLinus Torvalds 		.ctl_name	= KERN_S390_USER_DEBUG_LOGGING,
6711da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
6721da177e4SLinus Torvalds 		.data		= &sysctl_userprocess_debug,
6731da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6741da177e4SLinus Torvalds 		.mode		= 0644,
6751da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6761da177e4SLinus Torvalds 	},
6771da177e4SLinus Torvalds #endif
6781da177e4SLinus Torvalds 	{
6791da177e4SLinus Torvalds 		.ctl_name	= KERN_PIDMAX,
6801da177e4SLinus Torvalds 		.procname	= "pid_max",
6811da177e4SLinus Torvalds 		.data		= &pid_max,
6821da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6831da177e4SLinus Torvalds 		.mode		= 0644,
6841da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
6851da177e4SLinus Torvalds 		.strategy	= sysctl_intvec,
6861da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
6871da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
6881da177e4SLinus Torvalds 	},
6891da177e4SLinus Torvalds 	{
6901da177e4SLinus Torvalds 		.ctl_name	= KERN_PANIC_ON_OOPS,
6911da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
6921da177e4SLinus Torvalds 		.data		= &panic_on_oops,
6931da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6941da177e4SLinus Torvalds 		.mode		= 0644,
6951da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6961da177e4SLinus Torvalds 	},
6977ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
6987ef3d2fdSJoe Perches 	{
6997ef3d2fdSJoe Perches 		.ctl_name	= KERN_PRINTK,
7007ef3d2fdSJoe Perches 		.procname	= "printk",
7017ef3d2fdSJoe Perches 		.data		= &console_loglevel,
7027ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
7037ef3d2fdSJoe Perches 		.mode		= 0644,
7047ef3d2fdSJoe Perches 		.proc_handler	= &proc_dointvec,
7057ef3d2fdSJoe Perches 	},
7061da177e4SLinus Torvalds 	{
7071da177e4SLinus Torvalds 		.ctl_name	= KERN_PRINTK_RATELIMIT,
7081da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
709717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
7101da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7111da177e4SLinus Torvalds 		.mode		= 0644,
7121da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_jiffies,
7131da177e4SLinus Torvalds 		.strategy	= &sysctl_jiffies,
7141da177e4SLinus Torvalds 	},
7151da177e4SLinus Torvalds 	{
7161da177e4SLinus Torvalds 		.ctl_name	= KERN_PRINTK_RATELIMIT_BURST,
7171da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
718717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
7191da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7201da177e4SLinus Torvalds 		.mode		= 0644,
7211da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7221da177e4SLinus Torvalds 	},
7237ef3d2fdSJoe Perches #endif
7241da177e4SLinus Torvalds 	{
7251da177e4SLinus Torvalds 		.ctl_name	= KERN_NGROUPS_MAX,
7261da177e4SLinus Torvalds 		.procname	= "ngroups_max",
7271da177e4SLinus Torvalds 		.data		= &ngroups_max,
7281da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7291da177e4SLinus Torvalds 		.mode		= 0444,
7301da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7311da177e4SLinus Torvalds 	},
7321da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
7331da177e4SLinus Torvalds 	{
7341da177e4SLinus Torvalds 		.ctl_name       = KERN_UNKNOWN_NMI_PANIC,
7351da177e4SLinus Torvalds 		.procname       = "unknown_nmi_panic",
7361da177e4SLinus Torvalds 		.data           = &unknown_nmi_panic,
7371da177e4SLinus Torvalds 		.maxlen         = sizeof (int),
7381da177e4SLinus Torvalds 		.mode           = 0644,
7392fbe7b25SDon Zickus 		.proc_handler   = &proc_dointvec,
7401da177e4SLinus Torvalds 	},
741407984f1SDon Zickus 	{
742407984f1SDon Zickus 		.procname       = "nmi_watchdog",
743407984f1SDon Zickus 		.data           = &nmi_watchdog_enabled,
744407984f1SDon Zickus 		.maxlen         = sizeof (int),
745407984f1SDon Zickus 		.mode           = 0644,
746407984f1SDon Zickus 		.proc_handler   = &proc_nmi_enabled,
7471da177e4SLinus Torvalds 	},
7481da177e4SLinus Torvalds #endif
7491da177e4SLinus Torvalds #if defined(CONFIG_X86)
7501da177e4SLinus Torvalds 	{
7518da5addaSDon Zickus 		.ctl_name	= KERN_PANIC_ON_NMI,
7528da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
7538da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
7548da5addaSDon Zickus 		.maxlen		= sizeof(int),
7558da5addaSDon Zickus 		.mode		= 0644,
7568da5addaSDon Zickus 		.proc_handler	= &proc_dointvec,
7578da5addaSDon Zickus 	},
7588da5addaSDon Zickus 	{
7595211a242SKurt Garloff 		.ctl_name	= CTL_UNNUMBERED,
7605211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
7615211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
7625211a242SKurt Garloff 		.maxlen		= sizeof(int),
7635211a242SKurt Garloff 		.mode		= 0644,
7645211a242SKurt Garloff 		.proc_handler	= &proc_dointvec,
7655211a242SKurt Garloff 	},
7665211a242SKurt Garloff 	{
7671da177e4SLinus Torvalds 		.ctl_name	= KERN_BOOTLOADER_TYPE,
7681da177e4SLinus Torvalds 		.procname	= "bootloader_type",
7691da177e4SLinus Torvalds 		.data		= &bootloader_type,
7701da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7711da177e4SLinus Torvalds 		.mode		= 0444,
7721da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7731da177e4SLinus Torvalds 	},
7740741f4d2SChuck Ebbert 	{
7750741f4d2SChuck Ebbert 		.ctl_name	= CTL_UNNUMBERED,
7765031296cSH. Peter Anvin 		.procname	= "bootloader_version",
7775031296cSH. Peter Anvin 		.data		= &bootloader_version,
7785031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
7795031296cSH. Peter Anvin 		.mode		= 0444,
7805031296cSH. Peter Anvin 		.proc_handler	= &proc_dointvec,
7815031296cSH. Peter Anvin 	},
7825031296cSH. Peter Anvin 	{
7835031296cSH. Peter Anvin 		.ctl_name	= CTL_UNNUMBERED,
7840741f4d2SChuck Ebbert 		.procname	= "kstack_depth_to_print",
7850741f4d2SChuck Ebbert 		.data		= &kstack_depth_to_print,
7860741f4d2SChuck Ebbert 		.maxlen		= sizeof(int),
7870741f4d2SChuck Ebbert 		.mode		= 0644,
7880741f4d2SChuck Ebbert 		.proc_handler	= &proc_dointvec,
7890741f4d2SChuck Ebbert 	},
7906e7c4025SIngo Molnar 	{
7916e7c4025SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
7926e7c4025SIngo Molnar 		.procname	= "io_delay_type",
7936e7c4025SIngo Molnar 		.data		= &io_delay_type,
7946e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
7956e7c4025SIngo Molnar 		.mode		= 0644,
7966e7c4025SIngo Molnar 		.proc_handler	= &proc_dointvec,
7976e7c4025SIngo Molnar 	},
7981da177e4SLinus Torvalds #endif
7997a9166e3SLuke Yang #if defined(CONFIG_MMU)
8001da177e4SLinus Torvalds 	{
8011da177e4SLinus Torvalds 		.ctl_name	= KERN_RANDOMIZE,
8021da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
8031da177e4SLinus Torvalds 		.data		= &randomize_va_space,
8041da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
8051da177e4SLinus Torvalds 		.mode		= 0644,
8061da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
8071da177e4SLinus Torvalds 	},
8087a9166e3SLuke Yang #endif
8090152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
810951f22d5SMartin Schwidefsky 	{
811951f22d5SMartin Schwidefsky 		.ctl_name	= KERN_SPIN_RETRY,
812951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
813951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
814951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
815951f22d5SMartin Schwidefsky 		.mode		= 0644,
816951f22d5SMartin Schwidefsky 		.proc_handler	= &proc_dointvec,
817951f22d5SMartin Schwidefsky 	},
818951f22d5SMartin Schwidefsky #endif
819673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
820c255d844SPavel Machek 	{
821c255d844SPavel Machek 		.procname	= "acpi_video_flags",
82277afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
823c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
824c255d844SPavel Machek 		.mode		= 0644,
8257f99f06fSStefan Seyfried 		.proc_handler	= &proc_doulongvec_minmax,
826c255d844SPavel Machek 	},
827c255d844SPavel Machek #endif
828d2b176edSJes Sorensen #ifdef CONFIG_IA64
829d2b176edSJes Sorensen 	{
830d2b176edSJes Sorensen 		.ctl_name	= KERN_IA64_UNALIGNED,
831d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
832d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
833d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
834d2b176edSJes Sorensen 	 	.mode		= 0644,
835d2b176edSJes Sorensen 		.proc_handler	= &proc_dointvec,
836d2b176edSJes Sorensen 	},
83788fc241fSDoug Chapman 	{
83888fc241fSDoug Chapman 		.ctl_name	= CTL_UNNUMBERED,
83988fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
84088fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
84188fc241fSDoug Chapman 		.maxlen		= sizeof (int),
84288fc241fSDoug Chapman 		.mode		= 0644,
84388fc241fSDoug Chapman 		.proc_handler	= &proc_dointvec,
84488fc241fSDoug Chapman 	},
845d2b176edSJes Sorensen #endif
846c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP
847c4f3b63fSRavikiran G Thirumalai 	{
848c4f3b63fSRavikiran G Thirumalai 		.ctl_name	= CTL_UNNUMBERED,
8499c44bc03SIngo Molnar 		.procname	= "softlockup_panic",
8509c44bc03SIngo Molnar 		.data		= &softlockup_panic,
8519c44bc03SIngo Molnar 		.maxlen		= sizeof(int),
8529c44bc03SIngo Molnar 		.mode		= 0644,
8534dca10a9SHiroshi Shimamoto 		.proc_handler	= &proc_dointvec_minmax,
8549c44bc03SIngo Molnar 		.strategy	= &sysctl_intvec,
8559c44bc03SIngo Molnar 		.extra1		= &zero,
8569c44bc03SIngo Molnar 		.extra2		= &one,
8579c44bc03SIngo Molnar 	},
8589c44bc03SIngo Molnar 	{
8599c44bc03SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
860c4f3b63fSRavikiran G Thirumalai 		.procname	= "softlockup_thresh",
861c4f3b63fSRavikiran G Thirumalai 		.data		= &softlockup_thresh,
8629383d967SDimitri Sivanich 		.maxlen		= sizeof(int),
863c4f3b63fSRavikiran G Thirumalai 		.mode		= 0644,
864baf48f65SMandeep Singh Baines 		.proc_handler	= &proc_dosoftlockup_thresh,
865c4f3b63fSRavikiran G Thirumalai 		.strategy	= &sysctl_intvec,
8669383d967SDimitri Sivanich 		.extra1		= &neg_one,
867c4f3b63fSRavikiran G Thirumalai 		.extra2		= &sixty,
868c4f3b63fSRavikiran G Thirumalai 	},
869e162b39aSMandeep Singh Baines #endif
870e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
871e162b39aSMandeep Singh Baines 	{
872e162b39aSMandeep Singh Baines 		.ctl_name	= CTL_UNNUMBERED,
873e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
874e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
875e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
876e162b39aSMandeep Singh Baines 		.mode		= 0644,
877e162b39aSMandeep Singh Baines 		.proc_handler	= &proc_dointvec_minmax,
878e162b39aSMandeep Singh Baines 		.strategy	= &sysctl_intvec,
879e162b39aSMandeep Singh Baines 		.extra1		= &zero,
880e162b39aSMandeep Singh Baines 		.extra2		= &one,
881e162b39aSMandeep Singh Baines 	},
88282a1fcb9SIngo Molnar 	{
88382a1fcb9SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
88482a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
88582a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
88690739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
88782a1fcb9SIngo Molnar 		.mode		= 0644,
88890739081SIngo Molnar 		.proc_handler	= &proc_doulongvec_minmax,
88982a1fcb9SIngo Molnar 		.strategy	= &sysctl_intvec,
89082a1fcb9SIngo Molnar 	},
89182a1fcb9SIngo Molnar 	{
89282a1fcb9SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
89382a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
89482a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
89590739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
89682a1fcb9SIngo Molnar 		.mode		= 0644,
897e162b39aSMandeep Singh Baines 		.proc_handler	= &proc_dohung_task_timeout_secs,
89882a1fcb9SIngo Molnar 		.strategy	= &sysctl_intvec,
89982a1fcb9SIngo Molnar 	},
90082a1fcb9SIngo Molnar 	{
90182a1fcb9SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
90282a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
90382a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
90490739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
90582a1fcb9SIngo Molnar 		.mode		= 0644,
90690739081SIngo Molnar 		.proc_handler	= &proc_doulongvec_minmax,
90782a1fcb9SIngo Molnar 		.strategy	= &sysctl_intvec,
90882a1fcb9SIngo Molnar 	},
909c4f3b63fSRavikiran G Thirumalai #endif
910bebfa101SAndi Kleen #ifdef CONFIG_COMPAT
911bebfa101SAndi Kleen 	{
912bebfa101SAndi Kleen 		.ctl_name	= KERN_COMPAT_LOG,
913bebfa101SAndi Kleen 		.procname	= "compat-log",
914bebfa101SAndi Kleen 		.data		= &compat_log,
915bebfa101SAndi Kleen 		.maxlen		= sizeof (int),
916bebfa101SAndi Kleen 	 	.mode		= 0644,
917bebfa101SAndi Kleen 		.proc_handler	= &proc_dointvec,
918bebfa101SAndi Kleen 	},
919bebfa101SAndi Kleen #endif
92023f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
92123f78d4aSIngo Molnar 	{
92223f78d4aSIngo Molnar 		.ctl_name	= KERN_MAX_LOCK_DEPTH,
92323f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
92423f78d4aSIngo Molnar 		.data		= &max_lock_depth,
92523f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
92623f78d4aSIngo Molnar 		.mode		= 0644,
92723f78d4aSIngo Molnar 		.proc_handler	= &proc_dointvec,
92823f78d4aSIngo Molnar 	},
92923f78d4aSIngo Molnar #endif
93010a0a8d4SJeremy Fitzhardinge 	{
93110a0a8d4SJeremy Fitzhardinge 		.ctl_name	= CTL_UNNUMBERED,
93210a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
93310a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
93410a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
93510a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
93610a0a8d4SJeremy Fitzhardinge 		.proc_handler	= &proc_dostring,
93710a0a8d4SJeremy Fitzhardinge 		.strategy	= &sysctl_string,
93810a0a8d4SJeremy Fitzhardinge 	},
9390b77f5bfSDavid Howells #ifdef CONFIG_KEYS
9400b77f5bfSDavid Howells 	{
9410b77f5bfSDavid Howells 		.ctl_name	= CTL_UNNUMBERED,
9420b77f5bfSDavid Howells 		.procname	= "keys",
9430b77f5bfSDavid Howells 		.mode		= 0555,
9440b77f5bfSDavid Howells 		.child		= key_sysctls,
9450b77f5bfSDavid Howells 	},
9460b77f5bfSDavid Howells #endif
94731a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
94831a72bceSPaul E. McKenney 	{
94931a72bceSPaul E. McKenney 		.ctl_name       = CTL_UNNUMBERED,
95031a72bceSPaul E. McKenney 		.procname       = "rcutorture_runnable",
95131a72bceSPaul E. McKenney 		.data           = &rcutorture_runnable,
95231a72bceSPaul E. McKenney 		.maxlen         = sizeof(int),
95331a72bceSPaul E. McKenney 		.mode           = 0644,
95431a72bceSPaul E. McKenney 		.proc_handler   = &proc_dointvec,
95531a72bceSPaul E. McKenney 	},
95631a72bceSPaul E. McKenney #endif
95712e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK
95812e22c5eSDavid Howells 	{
95912e22c5eSDavid Howells 		.ctl_name	= CTL_UNNUMBERED,
96012e22c5eSDavid Howells 		.procname	= "slow-work",
96112e22c5eSDavid Howells 		.mode		= 0555,
96212e22c5eSDavid Howells 		.child		= slow_work_sysctls,
96312e22c5eSDavid Howells 	},
96412e22c5eSDavid Howells #endif
9651ccd1549SPeter Zijlstra #ifdef CONFIG_PERF_COUNTERS
9661ccd1549SPeter Zijlstra 	{
9671ccd1549SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
9680764771dSPeter Zijlstra 		.procname	= "perf_counter_paranoid",
9690764771dSPeter Zijlstra 		.data		= &sysctl_perf_counter_paranoid,
9700764771dSPeter Zijlstra 		.maxlen		= sizeof(sysctl_perf_counter_paranoid),
9711ccd1549SPeter Zijlstra 		.mode		= 0644,
9721ccd1549SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
9731ccd1549SPeter Zijlstra 	},
974c5078f78SPeter Zijlstra 	{
975c5078f78SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
976c5078f78SPeter Zijlstra 		.procname	= "perf_counter_mlock_kb",
977c5078f78SPeter Zijlstra 		.data		= &sysctl_perf_counter_mlock,
978c5078f78SPeter Zijlstra 		.maxlen		= sizeof(sysctl_perf_counter_mlock),
979c5078f78SPeter Zijlstra 		.mode		= 0644,
980c5078f78SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
981c5078f78SPeter Zijlstra 	},
982a78ac325SPeter Zijlstra 	{
983a78ac325SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
984df58ab24SPeter Zijlstra 		.procname	= "perf_counter_max_sample_rate",
985df58ab24SPeter Zijlstra 		.data		= &sysctl_perf_counter_sample_rate,
986df58ab24SPeter Zijlstra 		.maxlen		= sizeof(sysctl_perf_counter_sample_rate),
987a78ac325SPeter Zijlstra 		.mode		= 0644,
988a78ac325SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
989a78ac325SPeter Zijlstra 	},
9901ccd1549SPeter Zijlstra #endif
991dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK
992dfec072eSVegard Nossum 	{
993dfec072eSVegard Nossum 		.ctl_name	= CTL_UNNUMBERED,
994dfec072eSVegard Nossum 		.procname	= "kmemcheck",
995dfec072eSVegard Nossum 		.data		= &kmemcheck_enabled,
996dfec072eSVegard Nossum 		.maxlen		= sizeof(int),
997dfec072eSVegard Nossum 		.mode		= 0644,
998dfec072eSVegard Nossum 		.proc_handler	= &proc_dointvec,
999dfec072eSVegard Nossum 	},
1000dfec072eSVegard Nossum #endif
1001dfec072eSVegard Nossum 
1002ed2c12f3SAndrew Morton /*
1003ed2c12f3SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
1004ed2c12f3SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
1005ed2c12f3SAndrew Morton  */
10061da177e4SLinus Torvalds 	{ .ctl_name = 0 }
10071da177e4SLinus Torvalds };
10081da177e4SLinus Torvalds 
1009d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
10101da177e4SLinus Torvalds 	{
10111da177e4SLinus Torvalds 		.ctl_name	= VM_OVERCOMMIT_MEMORY,
10121da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
10131da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
10141da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
10151da177e4SLinus Torvalds 		.mode		= 0644,
10161da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10171da177e4SLinus Torvalds 	},
10181da177e4SLinus Torvalds 	{
1019fadd8fbdSKAMEZAWA Hiroyuki 		.ctl_name	= VM_PANIC_ON_OOM,
1020fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
1021fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
1022fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
1023fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
1024fadd8fbdSKAMEZAWA Hiroyuki 		.proc_handler	= &proc_dointvec,
1025fadd8fbdSKAMEZAWA Hiroyuki 	},
1026fadd8fbdSKAMEZAWA Hiroyuki 	{
1027fe071d7eSDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
1028fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
1029fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
1030fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
1031fe071d7eSDavid Rientjes 		.mode		= 0644,
1032fe071d7eSDavid Rientjes 		.proc_handler	= &proc_dointvec,
1033fe071d7eSDavid Rientjes 	},
1034fe071d7eSDavid Rientjes 	{
1035fef1bdd6SDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
1036fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
1037fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
1038fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
1039fef1bdd6SDavid Rientjes 		.mode		= 0644,
1040fef1bdd6SDavid Rientjes 		.proc_handler	= &proc_dointvec,
1041fef1bdd6SDavid Rientjes 	},
1042fef1bdd6SDavid Rientjes 	{
10431da177e4SLinus Torvalds 		.ctl_name	= VM_OVERCOMMIT_RATIO,
10441da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
10451da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
10461da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
10471da177e4SLinus Torvalds 		.mode		= 0644,
10481da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10491da177e4SLinus Torvalds 	},
10501da177e4SLinus Torvalds 	{
10511da177e4SLinus Torvalds 		.ctl_name	= VM_PAGE_CLUSTER,
10521da177e4SLinus Torvalds 		.procname	= "page-cluster",
10531da177e4SLinus Torvalds 		.data		= &page_cluster,
10541da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
10551da177e4SLinus Torvalds 		.mode		= 0644,
10561da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10571da177e4SLinus Torvalds 	},
10581da177e4SLinus Torvalds 	{
10591da177e4SLinus Torvalds 		.ctl_name	= VM_DIRTY_BACKGROUND,
10601da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
10611da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
10621da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
10631da177e4SLinus Torvalds 		.mode		= 0644,
10642da02997SDavid Rientjes 		.proc_handler	= &dirty_background_ratio_handler,
10651da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
10661da177e4SLinus Torvalds 		.extra1		= &zero,
10671da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10681da177e4SLinus Torvalds 	},
10691da177e4SLinus Torvalds 	{
10702da02997SDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
10712da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
10722da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
10732da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
10742da02997SDavid Rientjes 		.mode		= 0644,
10752da02997SDavid Rientjes 		.proc_handler	= &dirty_background_bytes_handler,
10762da02997SDavid Rientjes 		.strategy	= &sysctl_intvec,
1077fc3501d4SSven Wegener 		.extra1		= &one_ul,
10782da02997SDavid Rientjes 	},
10792da02997SDavid Rientjes 	{
10801da177e4SLinus Torvalds 		.ctl_name	= VM_DIRTY_RATIO,
10811da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
10821da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
10831da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
10841da177e4SLinus Torvalds 		.mode		= 0644,
108504fbfdc1SPeter Zijlstra 		.proc_handler	= &dirty_ratio_handler,
10861da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
10871da177e4SLinus Torvalds 		.extra1		= &zero,
10881da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10891da177e4SLinus Torvalds 	},
10901da177e4SLinus Torvalds 	{
10912da02997SDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
10922da02997SDavid Rientjes 		.procname	= "dirty_bytes",
10932da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
10942da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
10952da02997SDavid Rientjes 		.mode		= 0644,
10962da02997SDavid Rientjes 		.proc_handler	= &dirty_bytes_handler,
10972da02997SDavid Rientjes 		.strategy	= &sysctl_intvec,
10989e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
10992da02997SDavid Rientjes 	},
11002da02997SDavid Rientjes 	{
11011da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
1102f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
1103f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
11041da177e4SLinus Torvalds 		.mode		= 0644,
11051da177e4SLinus Torvalds 		.proc_handler	= &dirty_writeback_centisecs_handler,
11061da177e4SLinus Torvalds 	},
11071da177e4SLinus Torvalds 	{
11081da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
1109f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
1110f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
11111da177e4SLinus Torvalds 		.mode		= 0644,
1112704503d8SAlexey Dobriyan 		.proc_handler	= &proc_dointvec,
11131da177e4SLinus Torvalds 	},
11141da177e4SLinus Torvalds 	{
11151da177e4SLinus Torvalds 		.ctl_name	= VM_NR_PDFLUSH_THREADS,
11161da177e4SLinus Torvalds 		.procname	= "nr_pdflush_threads",
11171da177e4SLinus Torvalds 		.data		= &nr_pdflush_threads,
11181da177e4SLinus Torvalds 		.maxlen		= sizeof nr_pdflush_threads,
11191da177e4SLinus Torvalds 		.mode		= 0444 /* read-only*/,
11201da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
11211da177e4SLinus Torvalds 	},
11221da177e4SLinus Torvalds 	{
11231da177e4SLinus Torvalds 		.ctl_name	= VM_SWAPPINESS,
11241da177e4SLinus Torvalds 		.procname	= "swappiness",
11251da177e4SLinus Torvalds 		.data		= &vm_swappiness,
11261da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
11271da177e4SLinus Torvalds 		.mode		= 0644,
11281da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
11291da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
11301da177e4SLinus Torvalds 		.extra1		= &zero,
11311da177e4SLinus Torvalds 		.extra2		= &one_hundred,
11321da177e4SLinus Torvalds 	},
11331da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
11341da177e4SLinus Torvalds 	 {
11351da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
1136e5ff2159SAndi Kleen 		.data		= NULL,
11371da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
11381da177e4SLinus Torvalds 		.mode		= 0644,
11391da177e4SLinus Torvalds 		.proc_handler	= &hugetlb_sysctl_handler,
11401da177e4SLinus Torvalds 		.extra1		= (void *)&hugetlb_zero,
11411da177e4SLinus Torvalds 		.extra2		= (void *)&hugetlb_infinity,
11421da177e4SLinus Torvalds 	 },
11431da177e4SLinus Torvalds 	 {
11441da177e4SLinus Torvalds 		.ctl_name	= VM_HUGETLB_GROUP,
11451da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
11461da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
11471da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
11481da177e4SLinus Torvalds 		.mode		= 0644,
11491da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
11501da177e4SLinus Torvalds 	 },
1151396faf03SMel Gorman 	 {
1152396faf03SMel Gorman 		.ctl_name	= CTL_UNNUMBERED,
1153396faf03SMel Gorman 		.procname	= "hugepages_treat_as_movable",
1154396faf03SMel Gorman 		.data		= &hugepages_treat_as_movable,
1155396faf03SMel Gorman 		.maxlen		= sizeof(int),
1156396faf03SMel Gorman 		.mode		= 0644,
1157396faf03SMel Gorman 		.proc_handler	= &hugetlb_treat_movable_handler,
1158396faf03SMel Gorman 	},
115954f9f80dSAdam Litke 	{
116054f9f80dSAdam Litke 		.ctl_name	= CTL_UNNUMBERED,
1161d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
1162e5ff2159SAndi Kleen 		.data		= NULL,
1163e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
1164d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
1165a3d0c6aaSNishanth Aravamudan 		.proc_handler	= &hugetlb_overcommit_handler,
1166e5ff2159SAndi Kleen 		.extra1		= (void *)&hugetlb_zero,
1167e5ff2159SAndi Kleen 		.extra2		= (void *)&hugetlb_infinity,
1168d1c3fb1fSNishanth Aravamudan 	},
11691da177e4SLinus Torvalds #endif
11701da177e4SLinus Torvalds 	{
11711da177e4SLinus Torvalds 		.ctl_name	= VM_LOWMEM_RESERVE_RATIO,
11721da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
11731da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
11741da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
11751da177e4SLinus Torvalds 		.mode		= 0644,
11761da177e4SLinus Torvalds 		.proc_handler	= &lowmem_reserve_ratio_sysctl_handler,
11771da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
11781da177e4SLinus Torvalds 	},
11791da177e4SLinus Torvalds 	{
11809d0243bcSAndrew Morton 		.ctl_name	= VM_DROP_PAGECACHE,
11819d0243bcSAndrew Morton 		.procname	= "drop_caches",
11829d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
11839d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
11849d0243bcSAndrew Morton 		.mode		= 0644,
11859d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
11869d0243bcSAndrew Morton 		.strategy	= &sysctl_intvec,
11879d0243bcSAndrew Morton 	},
11889d0243bcSAndrew Morton 	{
11891da177e4SLinus Torvalds 		.ctl_name	= VM_MIN_FREE_KBYTES,
11901da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
11911da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
11921da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
11931da177e4SLinus Torvalds 		.mode		= 0644,
11941da177e4SLinus Torvalds 		.proc_handler	= &min_free_kbytes_sysctl_handler,
11951da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
11961da177e4SLinus Torvalds 		.extra1		= &zero,
11971da177e4SLinus Torvalds 	},
11988ad4b1fbSRohit Seth 	{
11998ad4b1fbSRohit Seth 		.ctl_name	= VM_PERCPU_PAGELIST_FRACTION,
12008ad4b1fbSRohit Seth 		.procname	= "percpu_pagelist_fraction",
12018ad4b1fbSRohit Seth 		.data		= &percpu_pagelist_fraction,
12028ad4b1fbSRohit Seth 		.maxlen		= sizeof(percpu_pagelist_fraction),
12038ad4b1fbSRohit Seth 		.mode		= 0644,
12048ad4b1fbSRohit Seth 		.proc_handler	= &percpu_pagelist_fraction_sysctl_handler,
12058ad4b1fbSRohit Seth 		.strategy	= &sysctl_intvec,
12068ad4b1fbSRohit Seth 		.extra1		= &min_percpu_pagelist_fract,
12078ad4b1fbSRohit Seth 	},
12081da177e4SLinus Torvalds #ifdef CONFIG_MMU
12091da177e4SLinus Torvalds 	{
12101da177e4SLinus Torvalds 		.ctl_name	= VM_MAX_MAP_COUNT,
12111da177e4SLinus Torvalds 		.procname	= "max_map_count",
12121da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
12131da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
12141da177e4SLinus Torvalds 		.mode		= 0644,
12151da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec
12161da177e4SLinus Torvalds 	},
1217dd8632a1SPaul Mundt #else
1218dd8632a1SPaul Mundt 	{
1219dd8632a1SPaul Mundt 		.ctl_name	= CTL_UNNUMBERED,
1220dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
1221dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
1222dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
1223dd8632a1SPaul Mundt 		.mode		= 0644,
1224dd8632a1SPaul Mundt 		.proc_handler	= &proc_dointvec_minmax,
1225dd8632a1SPaul Mundt 		.strategy	= &sysctl_intvec,
1226dd8632a1SPaul Mundt 		.extra1		= &zero,
1227dd8632a1SPaul Mundt 	},
12281da177e4SLinus Torvalds #endif
12291da177e4SLinus Torvalds 	{
12301da177e4SLinus Torvalds 		.ctl_name	= VM_LAPTOP_MODE,
12311da177e4SLinus Torvalds 		.procname	= "laptop_mode",
12321da177e4SLinus Torvalds 		.data		= &laptop_mode,
12331da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
12341da177e4SLinus Torvalds 		.mode		= 0644,
1235ed5b43f1SBart Samwel 		.proc_handler	= &proc_dointvec_jiffies,
1236ed5b43f1SBart Samwel 		.strategy	= &sysctl_jiffies,
12371da177e4SLinus Torvalds 	},
12381da177e4SLinus Torvalds 	{
12391da177e4SLinus Torvalds 		.ctl_name	= VM_BLOCK_DUMP,
12401da177e4SLinus Torvalds 		.procname	= "block_dump",
12411da177e4SLinus Torvalds 		.data		= &block_dump,
12421da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
12431da177e4SLinus Torvalds 		.mode		= 0644,
12441da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
12451da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
12461da177e4SLinus Torvalds 		.extra1		= &zero,
12471da177e4SLinus Torvalds 	},
12481da177e4SLinus Torvalds 	{
12491da177e4SLinus Torvalds 		.ctl_name	= VM_VFS_CACHE_PRESSURE,
12501da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
12511da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
12521da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
12531da177e4SLinus Torvalds 		.mode		= 0644,
12541da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
12551da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
12561da177e4SLinus Torvalds 		.extra1		= &zero,
12571da177e4SLinus Torvalds 	},
12581da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
12591da177e4SLinus Torvalds 	{
12601da177e4SLinus Torvalds 		.ctl_name	= VM_LEGACY_VA_LAYOUT,
12611da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
12621da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
12631da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
12641da177e4SLinus Torvalds 		.mode		= 0644,
12651da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
12661da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
12671da177e4SLinus Torvalds 		.extra1		= &zero,
12681da177e4SLinus Torvalds 	},
12691da177e4SLinus Torvalds #endif
12701743660bSChristoph Lameter #ifdef CONFIG_NUMA
12711743660bSChristoph Lameter 	{
12721743660bSChristoph Lameter 		.ctl_name	= VM_ZONE_RECLAIM_MODE,
12731743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
12741743660bSChristoph Lameter 		.data		= &zone_reclaim_mode,
12751743660bSChristoph Lameter 		.maxlen		= sizeof(zone_reclaim_mode),
12761743660bSChristoph Lameter 		.mode		= 0644,
12771743660bSChristoph Lameter 		.proc_handler	= &proc_dointvec,
1278c84db23cSChristoph Lameter 		.strategy	= &sysctl_intvec,
1279c84db23cSChristoph Lameter 		.extra1		= &zero,
12801743660bSChristoph Lameter 	},
12819614634fSChristoph Lameter 	{
12829614634fSChristoph Lameter 		.ctl_name	= VM_MIN_UNMAPPED,
12839614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
12849614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
12859614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
12869614634fSChristoph Lameter 		.mode		= 0644,
12879614634fSChristoph Lameter 		.proc_handler	= &sysctl_min_unmapped_ratio_sysctl_handler,
12889614634fSChristoph Lameter 		.strategy	= &sysctl_intvec,
12899614634fSChristoph Lameter 		.extra1		= &zero,
12909614634fSChristoph Lameter 		.extra2		= &one_hundred,
12919614634fSChristoph Lameter 	},
12920ff38490SChristoph Lameter 	{
12930ff38490SChristoph Lameter 		.ctl_name	= VM_MIN_SLAB,
12940ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
12950ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
12960ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
12970ff38490SChristoph Lameter 		.mode		= 0644,
12980ff38490SChristoph Lameter 		.proc_handler	= &sysctl_min_slab_ratio_sysctl_handler,
12990ff38490SChristoph Lameter 		.strategy	= &sysctl_intvec,
13000ff38490SChristoph Lameter 		.extra1		= &zero,
13010ff38490SChristoph Lameter 		.extra2		= &one_hundred,
13020ff38490SChristoph Lameter 	},
13031743660bSChristoph Lameter #endif
130477461ab3SChristoph Lameter #ifdef CONFIG_SMP
130577461ab3SChristoph Lameter 	{
130677461ab3SChristoph Lameter 		.ctl_name	= CTL_UNNUMBERED,
130777461ab3SChristoph Lameter 		.procname	= "stat_interval",
130877461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
130977461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
131077461ab3SChristoph Lameter 		.mode		= 0644,
131177461ab3SChristoph Lameter 		.proc_handler	= &proc_dointvec_jiffies,
131277461ab3SChristoph Lameter 		.strategy	= &sysctl_jiffies,
131377461ab3SChristoph Lameter 	},
131477461ab3SChristoph Lameter #endif
1315ed032189SEric Paris 	{
1316ed032189SEric Paris 		.ctl_name	= CTL_UNNUMBERED,
1317ed032189SEric Paris 		.procname	= "mmap_min_addr",
1318788084abSEric Paris 		.data		= &dac_mmap_min_addr,
1319ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
1320ed032189SEric Paris 		.mode		= 0644,
1321788084abSEric Paris 		.proc_handler	= &mmap_min_addr_handler,
1322ed032189SEric Paris 	},
1323f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
1324f0c0b2b8SKAMEZAWA Hiroyuki 	{
1325f0c0b2b8SKAMEZAWA Hiroyuki 		.ctl_name	= CTL_UNNUMBERED,
1326f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
1327f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
1328f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
1329f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
1330f0c0b2b8SKAMEZAWA Hiroyuki 		.proc_handler	= &numa_zonelist_order_handler,
1331f0c0b2b8SKAMEZAWA Hiroyuki 		.strategy	= &sysctl_string,
1332f0c0b2b8SKAMEZAWA Hiroyuki 	},
1333f0c0b2b8SKAMEZAWA Hiroyuki #endif
13342b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
13355c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1336e6e5494cSIngo Molnar 	{
1337e6e5494cSIngo Molnar 		.ctl_name	= VM_VDSO_ENABLED,
1338e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
1339e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
1340e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
1341e6e5494cSIngo Molnar 		.mode		= 0644,
1342e6e5494cSIngo Molnar 		.proc_handler	= &proc_dointvec,
1343e6e5494cSIngo Molnar 		.strategy	= &sysctl_intvec,
1344e6e5494cSIngo Molnar 		.extra1		= &zero,
1345e6e5494cSIngo Molnar 	},
1346e6e5494cSIngo Molnar #endif
1347195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
1348195cf453SBron Gondwana 	{
1349195cf453SBron Gondwana 		.ctl_name	= CTL_UNNUMBERED,
1350195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
1351195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
1352195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
1353195cf453SBron Gondwana 		.mode		= 0644,
1354195cf453SBron Gondwana 		.proc_handler	= &proc_dointvec_minmax,
1355195cf453SBron Gondwana 		.strategy	= &sysctl_intvec,
1356195cf453SBron Gondwana 		.extra1		= &zero,
1357195cf453SBron Gondwana 		.extra2		= &one,
1358195cf453SBron Gondwana 	},
1359195cf453SBron Gondwana #endif
13604be6f6bbSPeter Zijlstra 	{
13614be6f6bbSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
13624be6f6bbSPeter Zijlstra 		.procname	= "scan_unevictable_pages",
13634be6f6bbSPeter Zijlstra 		.data		= &scan_unevictable_pages,
13644be6f6bbSPeter Zijlstra 		.maxlen		= sizeof(scan_unevictable_pages),
13654be6f6bbSPeter Zijlstra 		.mode		= 0644,
13664be6f6bbSPeter Zijlstra 		.proc_handler	= &scan_unevictable_handler,
13674be6f6bbSPeter Zijlstra 	},
13682be7fe07SAndrew Morton /*
13692be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
13702be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
13712be7fe07SAndrew Morton  */
13721da177e4SLinus Torvalds 	{ .ctl_name = 0 }
13731da177e4SLinus Torvalds };
13741da177e4SLinus Torvalds 
13752abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1376d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = {
13772abc26fcSEric W. Biederman 	{ .ctl_name = 0 }
13782abc26fcSEric W. Biederman };
13792abc26fcSEric W. Biederman #endif
13802abc26fcSEric W. Biederman 
1381d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
13821da177e4SLinus Torvalds 	{
13831da177e4SLinus Torvalds 		.ctl_name	= FS_NRINODE,
13841da177e4SLinus Torvalds 		.procname	= "inode-nr",
13851da177e4SLinus Torvalds 		.data		= &inodes_stat,
13861da177e4SLinus Torvalds 		.maxlen		= 2*sizeof(int),
13871da177e4SLinus Torvalds 		.mode		= 0444,
13881da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
13891da177e4SLinus Torvalds 	},
13901da177e4SLinus Torvalds 	{
13911da177e4SLinus Torvalds 		.ctl_name	= FS_STATINODE,
13921da177e4SLinus Torvalds 		.procname	= "inode-state",
13931da177e4SLinus Torvalds 		.data		= &inodes_stat,
13941da177e4SLinus Torvalds 		.maxlen		= 7*sizeof(int),
13951da177e4SLinus Torvalds 		.mode		= 0444,
13961da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
13971da177e4SLinus Torvalds 	},
13981da177e4SLinus Torvalds 	{
13991da177e4SLinus Torvalds 		.procname	= "file-nr",
14001da177e4SLinus Torvalds 		.data		= &files_stat,
14011da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
14021da177e4SLinus Torvalds 		.mode		= 0444,
1403529bf6beSDipankar Sarma 		.proc_handler	= &proc_nr_files,
14041da177e4SLinus Torvalds 	},
14051da177e4SLinus Torvalds 	{
14061da177e4SLinus Torvalds 		.ctl_name	= FS_MAXFILE,
14071da177e4SLinus Torvalds 		.procname	= "file-max",
14081da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
14091da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14101da177e4SLinus Torvalds 		.mode		= 0644,
14111da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14121da177e4SLinus Torvalds 	},
14131da177e4SLinus Torvalds 	{
14149cfe015aSEric Dumazet 		.ctl_name	= CTL_UNNUMBERED,
14159cfe015aSEric Dumazet 		.procname	= "nr_open",
14169cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
14179cfe015aSEric Dumazet 		.maxlen		= sizeof(int),
14189cfe015aSEric Dumazet 		.mode		= 0644,
1419eceea0b3SAl Viro 		.proc_handler	= &proc_dointvec_minmax,
1420eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
1421eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
14229cfe015aSEric Dumazet 	},
14239cfe015aSEric Dumazet 	{
14241da177e4SLinus Torvalds 		.ctl_name	= FS_DENTRY,
14251da177e4SLinus Torvalds 		.procname	= "dentry-state",
14261da177e4SLinus Torvalds 		.data		= &dentry_stat,
14271da177e4SLinus Torvalds 		.maxlen		= 6*sizeof(int),
14281da177e4SLinus Torvalds 		.mode		= 0444,
14291da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14301da177e4SLinus Torvalds 	},
14311da177e4SLinus Torvalds 	{
14321da177e4SLinus Torvalds 		.ctl_name	= FS_OVERFLOWUID,
14331da177e4SLinus Torvalds 		.procname	= "overflowuid",
14341da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
14351da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14361da177e4SLinus Torvalds 		.mode		= 0644,
14371da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
14381da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
14391da177e4SLinus Torvalds 		.extra1		= &minolduid,
14401da177e4SLinus Torvalds 		.extra2		= &maxolduid,
14411da177e4SLinus Torvalds 	},
14421da177e4SLinus Torvalds 	{
14431da177e4SLinus Torvalds 		.ctl_name	= FS_OVERFLOWGID,
14441da177e4SLinus Torvalds 		.procname	= "overflowgid",
14451da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
14461da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14471da177e4SLinus Torvalds 		.mode		= 0644,
14481da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
14491da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
14501da177e4SLinus Torvalds 		.extra1		= &minolduid,
14511da177e4SLinus Torvalds 		.extra2		= &maxolduid,
14521da177e4SLinus Torvalds 	},
1453bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
14541da177e4SLinus Torvalds 	{
14551da177e4SLinus Torvalds 		.ctl_name	= FS_LEASES,
14561da177e4SLinus Torvalds 		.procname	= "leases-enable",
14571da177e4SLinus Torvalds 		.data		= &leases_enable,
14581da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14591da177e4SLinus Torvalds 		.mode		= 0644,
14601da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14611da177e4SLinus Torvalds 	},
1462bfcd17a6SThomas Petazzoni #endif
14631da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
14641da177e4SLinus Torvalds 	{
14651da177e4SLinus Torvalds 		.ctl_name	= FS_DIR_NOTIFY,
14661da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
14671da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
14681da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14691da177e4SLinus Torvalds 		.mode		= 0644,
14701da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14711da177e4SLinus Torvalds 	},
14721da177e4SLinus Torvalds #endif
14731da177e4SLinus Torvalds #ifdef CONFIG_MMU
1474bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
14751da177e4SLinus Torvalds 	{
14761da177e4SLinus Torvalds 		.ctl_name	= FS_LEASE_TIME,
14771da177e4SLinus Torvalds 		.procname	= "lease-break-time",
14781da177e4SLinus Torvalds 		.data		= &lease_break_time,
14791da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14801da177e4SLinus Torvalds 		.mode		= 0644,
14818e654fbaSMatthew Wilcox 		.proc_handler	= &proc_dointvec,
14821da177e4SLinus Torvalds 	},
1483bfcd17a6SThomas Petazzoni #endif
1484ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
14851da177e4SLinus Torvalds 	{
14861da177e4SLinus Torvalds 		.procname	= "aio-nr",
14871da177e4SLinus Torvalds 		.data		= &aio_nr,
14881da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
14891da177e4SLinus Torvalds 		.mode		= 0444,
1490d55b5fdaSZach Brown 		.proc_handler	= &proc_doulongvec_minmax,
14911da177e4SLinus Torvalds 	},
14921da177e4SLinus Torvalds 	{
14931da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
14941da177e4SLinus Torvalds 		.data		= &aio_max_nr,
14951da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
14961da177e4SLinus Torvalds 		.mode		= 0644,
1497d55b5fdaSZach Brown 		.proc_handler	= &proc_doulongvec_minmax,
14981da177e4SLinus Torvalds 	},
1499ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
15002d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
15010399cb08SRobert Love 	{
15020399cb08SRobert Love 		.ctl_name	= FS_INOTIFY,
15030399cb08SRobert Love 		.procname	= "inotify",
15040399cb08SRobert Love 		.mode		= 0555,
15050399cb08SRobert Love 		.child		= inotify_table,
15060399cb08SRobert Love 	},
15070399cb08SRobert Love #endif
15087ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
15097ef9964eSDavide Libenzi 	{
15107ef9964eSDavide Libenzi 		.procname	= "epoll",
15117ef9964eSDavide Libenzi 		.mode		= 0555,
15127ef9964eSDavide Libenzi 		.child		= epoll_table,
15137ef9964eSDavide Libenzi 	},
15147ef9964eSDavide Libenzi #endif
15151da177e4SLinus Torvalds #endif
1516d6e71144SAlan Cox 	{
1517d6e71144SAlan Cox 		.ctl_name	= KERN_SETUID_DUMPABLE,
1518d6e71144SAlan Cox 		.procname	= "suid_dumpable",
1519d6e71144SAlan Cox 		.data		= &suid_dumpable,
1520d6e71144SAlan Cox 		.maxlen		= sizeof(int),
1521d6e71144SAlan Cox 		.mode		= 0644,
15228e654fbaSMatthew Wilcox 		.proc_handler	= &proc_dointvec_minmax,
15238e654fbaSMatthew Wilcox 		.strategy	= &sysctl_intvec,
15248e654fbaSMatthew Wilcox 		.extra1		= &zero,
15258e654fbaSMatthew Wilcox 		.extra2		= &two,
1526d6e71144SAlan Cox 	},
15272abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
15282abc26fcSEric W. Biederman 	{
15292abc26fcSEric W. Biederman 		.ctl_name	= CTL_UNNUMBERED,
15302abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
15312abc26fcSEric W. Biederman 		.mode		= 0555,
15322abc26fcSEric W. Biederman 		.child		= binfmt_misc_table,
15332abc26fcSEric W. Biederman 	},
15342abc26fcSEric W. Biederman #endif
15352be7fe07SAndrew Morton /*
15362be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
15372be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
15382be7fe07SAndrew Morton  */
15391da177e4SLinus Torvalds 	{ .ctl_name = 0 }
15401da177e4SLinus Torvalds };
15411da177e4SLinus Torvalds 
1542d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
1543d0c3d534SOlof Johansson #if defined(CONFIG_X86) || defined(CONFIG_PPC)
1544abd4f750SMasoud Asgharifard Sharbiani 	{
1545abd4f750SMasoud Asgharifard Sharbiani 		.ctl_name	= CTL_UNNUMBERED,
1546abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
1547abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
1548abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
1549abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
1550abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
1551abd4f750SMasoud Asgharifard Sharbiani 	},
1552abd4f750SMasoud Asgharifard Sharbiani #endif
15531da177e4SLinus Torvalds 	{ .ctl_name = 0 }
15541da177e4SLinus Torvalds };
15551da177e4SLinus Torvalds 
1556d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
15571da177e4SLinus Torvalds 	{ .ctl_name = 0 }
15581da177e4SLinus Torvalds };
15591da177e4SLinus Torvalds 
1560330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock);
1561330d57fbSAl Viro 
1562330d57fbSAl Viro /* called under sysctl_lock */
1563330d57fbSAl Viro static int use_table(struct ctl_table_header *p)
1564330d57fbSAl Viro {
1565330d57fbSAl Viro 	if (unlikely(p->unregistering))
1566330d57fbSAl Viro 		return 0;
1567330d57fbSAl Viro 	p->used++;
1568330d57fbSAl Viro 	return 1;
1569330d57fbSAl Viro }
1570330d57fbSAl Viro 
1571330d57fbSAl Viro /* called under sysctl_lock */
1572330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p)
1573330d57fbSAl Viro {
1574330d57fbSAl Viro 	if (!--p->used)
1575330d57fbSAl Viro 		if (unlikely(p->unregistering))
1576330d57fbSAl Viro 			complete(p->unregistering);
1577330d57fbSAl Viro }
1578330d57fbSAl Viro 
1579330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */
1580330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p)
1581330d57fbSAl Viro {
1582330d57fbSAl Viro 	/*
1583330d57fbSAl Viro 	 * if p->used is 0, nobody will ever touch that entry again;
1584330d57fbSAl Viro 	 * we'll eliminate all paths to it before dropping sysctl_lock
1585330d57fbSAl Viro 	 */
1586330d57fbSAl Viro 	if (unlikely(p->used)) {
1587330d57fbSAl Viro 		struct completion wait;
1588330d57fbSAl Viro 		init_completion(&wait);
1589330d57fbSAl Viro 		p->unregistering = &wait;
1590330d57fbSAl Viro 		spin_unlock(&sysctl_lock);
1591330d57fbSAl Viro 		wait_for_completion(&wait);
1592330d57fbSAl Viro 		spin_lock(&sysctl_lock);
1593f7e6ced4SAl Viro 	} else {
1594f7e6ced4SAl Viro 		/* anything non-NULL; we'll never dereference it */
1595f7e6ced4SAl Viro 		p->unregistering = ERR_PTR(-EINVAL);
1596330d57fbSAl Viro 	}
1597330d57fbSAl Viro 	/*
1598330d57fbSAl Viro 	 * do not remove from the list until nobody holds it; walking the
1599330d57fbSAl Viro 	 * list in do_sysctl() relies on that.
1600330d57fbSAl Viro 	 */
1601330d57fbSAl Viro 	list_del_init(&p->ctl_entry);
1602330d57fbSAl Viro }
1603330d57fbSAl Viro 
1604f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head)
1605f7e6ced4SAl Viro {
1606f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1607f7e6ced4SAl Viro 	head->count++;
1608f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1609f7e6ced4SAl Viro }
1610f7e6ced4SAl Viro 
1611f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
1612f7e6ced4SAl Viro {
1613f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1614f7e6ced4SAl Viro 	if (!--head->count)
1615f7e6ced4SAl Viro 		kfree(head);
1616f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1617f7e6ced4SAl Viro }
1618f7e6ced4SAl Viro 
1619f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1620f7e6ced4SAl Viro {
1621f7e6ced4SAl Viro 	if (!head)
1622f7e6ced4SAl Viro 		BUG();
1623f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1624f7e6ced4SAl Viro 	if (!use_table(head))
1625f7e6ced4SAl Viro 		head = ERR_PTR(-ENOENT);
1626f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1627f7e6ced4SAl Viro 	return head;
1628f7e6ced4SAl Viro }
1629f7e6ced4SAl Viro 
1630805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head)
1631805b5d5eSEric W. Biederman {
1632805b5d5eSEric W. Biederman 	if (!head)
1633805b5d5eSEric W. Biederman 		return;
1634805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1635805b5d5eSEric W. Biederman 	unuse_table(head);
1636805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1637805b5d5eSEric W. Biederman }
1638805b5d5eSEric W. Biederman 
163973455092SAl Viro static struct ctl_table_set *
164073455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
164173455092SAl Viro {
164273455092SAl Viro 	struct ctl_table_set *set = &root->default_set;
164373455092SAl Viro 	if (root->lookup)
164473455092SAl Viro 		set = root->lookup(root, namespaces);
164573455092SAl Viro 	return set;
164673455092SAl Viro }
164773455092SAl Viro 
1648e51b6ba0SEric W. Biederman static struct list_head *
1649e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1650805b5d5eSEric W. Biederman {
165173455092SAl Viro 	struct ctl_table_set *set = lookup_header_set(root, namespaces);
165273455092SAl Viro 	return &set->list;
1653e51b6ba0SEric W. Biederman }
1654e51b6ba0SEric W. Biederman 
1655e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1656e51b6ba0SEric W. Biederman 					    struct ctl_table_header *prev)
1657e51b6ba0SEric W. Biederman {
1658e51b6ba0SEric W. Biederman 	struct ctl_table_root *root;
1659e51b6ba0SEric W. Biederman 	struct list_head *header_list;
1660805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1661805b5d5eSEric W. Biederman 	struct list_head *tmp;
1662e51b6ba0SEric W. Biederman 
1663805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1664805b5d5eSEric W. Biederman 	if (prev) {
1665e51b6ba0SEric W. Biederman 		head = prev;
1666805b5d5eSEric W. Biederman 		tmp = &prev->ctl_entry;
1667805b5d5eSEric W. Biederman 		unuse_table(prev);
1668805b5d5eSEric W. Biederman 		goto next;
1669805b5d5eSEric W. Biederman 	}
1670805b5d5eSEric W. Biederman 	tmp = &root_table_header.ctl_entry;
1671805b5d5eSEric W. Biederman 	for (;;) {
1672805b5d5eSEric W. Biederman 		head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1673805b5d5eSEric W. Biederman 
1674805b5d5eSEric W. Biederman 		if (!use_table(head))
1675805b5d5eSEric W. Biederman 			goto next;
1676805b5d5eSEric W. Biederman 		spin_unlock(&sysctl_lock);
1677805b5d5eSEric W. Biederman 		return head;
1678805b5d5eSEric W. Biederman 	next:
1679e51b6ba0SEric W. Biederman 		root = head->root;
1680805b5d5eSEric W. Biederman 		tmp = tmp->next;
1681e51b6ba0SEric W. Biederman 		header_list = lookup_header_list(root, namespaces);
1682e51b6ba0SEric W. Biederman 		if (tmp != header_list)
1683e51b6ba0SEric W. Biederman 			continue;
1684e51b6ba0SEric W. Biederman 
1685e51b6ba0SEric W. Biederman 		do {
1686e51b6ba0SEric W. Biederman 			root = list_entry(root->root_list.next,
1687e51b6ba0SEric W. Biederman 					struct ctl_table_root, root_list);
1688e51b6ba0SEric W. Biederman 			if (root == &sysctl_table_root)
1689e51b6ba0SEric W. Biederman 				goto out;
1690e51b6ba0SEric W. Biederman 			header_list = lookup_header_list(root, namespaces);
1691e51b6ba0SEric W. Biederman 		} while (list_empty(header_list));
1692e51b6ba0SEric W. Biederman 		tmp = header_list->next;
1693805b5d5eSEric W. Biederman 	}
1694e51b6ba0SEric W. Biederman out:
1695805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1696805b5d5eSEric W. Biederman 	return NULL;
1697805b5d5eSEric W. Biederman }
1698805b5d5eSEric W. Biederman 
1699e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1700e51b6ba0SEric W. Biederman {
1701e51b6ba0SEric W. Biederman 	return __sysctl_head_next(current->nsproxy, prev);
1702e51b6ba0SEric W. Biederman }
1703e51b6ba0SEric W. Biederman 
1704e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root)
1705e51b6ba0SEric W. Biederman {
1706e51b6ba0SEric W. Biederman 	spin_lock(&sysctl_lock);
1707e51b6ba0SEric W. Biederman 	list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1708e51b6ba0SEric W. Biederman 	spin_unlock(&sysctl_lock);
1709e51b6ba0SEric W. Biederman }
1710e51b6ba0SEric W. Biederman 
1711b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL
17122c4c7155SPavel Emelyanov /* Perform the actual read/write of a sysctl table entry. */
1713d7321cd6SPavel Emelyanov static int do_sysctl_strategy(struct ctl_table_root *root,
1714d7321cd6SPavel Emelyanov 			struct ctl_table *table,
17152c4c7155SPavel Emelyanov 			void __user *oldval, size_t __user *oldlenp,
17162c4c7155SPavel Emelyanov 			void __user *newval, size_t newlen)
17172c4c7155SPavel Emelyanov {
17182c4c7155SPavel Emelyanov 	int op = 0, rc;
17192c4c7155SPavel Emelyanov 
17202c4c7155SPavel Emelyanov 	if (oldval)
1721e6305c43SAl Viro 		op |= MAY_READ;
17222c4c7155SPavel Emelyanov 	if (newval)
1723e6305c43SAl Viro 		op |= MAY_WRITE;
1724d7321cd6SPavel Emelyanov 	if (sysctl_perm(root, table, op))
17252c4c7155SPavel Emelyanov 		return -EPERM;
17262c4c7155SPavel Emelyanov 
17272c4c7155SPavel Emelyanov 	if (table->strategy) {
1728f221e726SAlexey Dobriyan 		rc = table->strategy(table, oldval, oldlenp, newval, newlen);
17292c4c7155SPavel Emelyanov 		if (rc < 0)
17302c4c7155SPavel Emelyanov 			return rc;
17312c4c7155SPavel Emelyanov 		if (rc > 0)
17322c4c7155SPavel Emelyanov 			return 0;
17332c4c7155SPavel Emelyanov 	}
17342c4c7155SPavel Emelyanov 
17352c4c7155SPavel Emelyanov 	/* If there is no strategy routine, or if the strategy returns
17362c4c7155SPavel Emelyanov 	 * zero, proceed with automatic r/w */
17372c4c7155SPavel Emelyanov 	if (table->data && table->maxlen) {
1738f221e726SAlexey Dobriyan 		rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
17392c4c7155SPavel Emelyanov 		if (rc < 0)
17402c4c7155SPavel Emelyanov 			return rc;
17412c4c7155SPavel Emelyanov 	}
17422c4c7155SPavel Emelyanov 	return 0;
17432c4c7155SPavel Emelyanov }
17442c4c7155SPavel Emelyanov 
17452c4c7155SPavel Emelyanov static int parse_table(int __user *name, int nlen,
17462c4c7155SPavel Emelyanov 		       void __user *oldval, size_t __user *oldlenp,
17472c4c7155SPavel Emelyanov 		       void __user *newval, size_t newlen,
1748d7321cd6SPavel Emelyanov 		       struct ctl_table_root *root,
17492c4c7155SPavel Emelyanov 		       struct ctl_table *table)
17502c4c7155SPavel Emelyanov {
17512c4c7155SPavel Emelyanov 	int n;
17522c4c7155SPavel Emelyanov repeat:
17532c4c7155SPavel Emelyanov 	if (!nlen)
17542c4c7155SPavel Emelyanov 		return -ENOTDIR;
17552c4c7155SPavel Emelyanov 	if (get_user(n, name))
17562c4c7155SPavel Emelyanov 		return -EFAULT;
17572c4c7155SPavel Emelyanov 	for ( ; table->ctl_name || table->procname; table++) {
17582c4c7155SPavel Emelyanov 		if (!table->ctl_name)
17592c4c7155SPavel Emelyanov 			continue;
17602c4c7155SPavel Emelyanov 		if (n == table->ctl_name) {
17612c4c7155SPavel Emelyanov 			int error;
17622c4c7155SPavel Emelyanov 			if (table->child) {
1763e6305c43SAl Viro 				if (sysctl_perm(root, table, MAY_EXEC))
17642c4c7155SPavel Emelyanov 					return -EPERM;
17652c4c7155SPavel Emelyanov 				name++;
17662c4c7155SPavel Emelyanov 				nlen--;
17672c4c7155SPavel Emelyanov 				table = table->child;
17682c4c7155SPavel Emelyanov 				goto repeat;
17692c4c7155SPavel Emelyanov 			}
1770f221e726SAlexey Dobriyan 			error = do_sysctl_strategy(root, table,
17712c4c7155SPavel Emelyanov 						   oldval, oldlenp,
17722c4c7155SPavel Emelyanov 						   newval, newlen);
17732c4c7155SPavel Emelyanov 			return error;
17742c4c7155SPavel Emelyanov 		}
17752c4c7155SPavel Emelyanov 	}
17762c4c7155SPavel Emelyanov 	return -ENOTDIR;
17772c4c7155SPavel Emelyanov }
17782c4c7155SPavel Emelyanov 
17791da177e4SLinus Torvalds int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
17801da177e4SLinus Torvalds 	       void __user *newval, size_t newlen)
17811da177e4SLinus Torvalds {
1782805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1783330d57fbSAl Viro 	int error = -ENOTDIR;
17841da177e4SLinus Torvalds 
17851da177e4SLinus Torvalds 	if (nlen <= 0 || nlen >= CTL_MAXNAME)
17861da177e4SLinus Torvalds 		return -ENOTDIR;
17871da177e4SLinus Torvalds 	if (oldval) {
17881da177e4SLinus Torvalds 		int old_len;
17891da177e4SLinus Torvalds 		if (!oldlenp || get_user(old_len, oldlenp))
17901da177e4SLinus Torvalds 			return -EFAULT;
17911da177e4SLinus Torvalds 	}
1792330d57fbSAl Viro 
1793805b5d5eSEric W. Biederman 	for (head = sysctl_head_next(NULL); head;
1794805b5d5eSEric W. Biederman 			head = sysctl_head_next(head)) {
1795330d57fbSAl Viro 		error = parse_table(name, nlen, oldval, oldlenp,
1796d7321cd6SPavel Emelyanov 					newval, newlen,
1797d7321cd6SPavel Emelyanov 					head->root, head->ctl_table);
1798805b5d5eSEric W. Biederman 		if (error != -ENOTDIR) {
1799805b5d5eSEric W. Biederman 			sysctl_head_finish(head);
1800330d57fbSAl Viro 			break;
1801805b5d5eSEric W. Biederman 		}
1802805b5d5eSEric W. Biederman 	}
18031da177e4SLinus Torvalds 	return error;
18041da177e4SLinus Torvalds }
18051da177e4SLinus Torvalds 
18061e7bfb21SHeiko Carstens SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
18071da177e4SLinus Torvalds {
18081da177e4SLinus Torvalds 	struct __sysctl_args tmp;
18091da177e4SLinus Torvalds 	int error;
18101da177e4SLinus Torvalds 
18111da177e4SLinus Torvalds 	if (copy_from_user(&tmp, args, sizeof(tmp)))
18121da177e4SLinus Torvalds 		return -EFAULT;
18131da177e4SLinus Torvalds 
18147058cb02SEric W. Biederman 	error = deprecated_sysctl_warning(&tmp);
18157058cb02SEric W. Biederman 	if (error)
18167058cb02SEric W. Biederman 		goto out;
18177058cb02SEric W. Biederman 
18181da177e4SLinus Torvalds 	lock_kernel();
18191da177e4SLinus Torvalds 	error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
18201da177e4SLinus Torvalds 			  tmp.newval, tmp.newlen);
18211da177e4SLinus Torvalds 	unlock_kernel();
18227058cb02SEric W. Biederman out:
18231da177e4SLinus Torvalds 	return error;
18241da177e4SLinus Torvalds }
1825b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */
18261da177e4SLinus Torvalds 
18271da177e4SLinus Torvalds /*
18281ff007ebSEric W. Biederman  * sysctl_perm does NOT grant the superuser all rights automatically, because
18291da177e4SLinus Torvalds  * some sysctl variables are readonly even to root.
18301da177e4SLinus Torvalds  */
18311da177e4SLinus Torvalds 
18321da177e4SLinus Torvalds static int test_perm(int mode, int op)
18331da177e4SLinus Torvalds {
183476aac0e9SDavid Howells 	if (!current_euid())
18351da177e4SLinus Torvalds 		mode >>= 6;
18361da177e4SLinus Torvalds 	else if (in_egroup_p(0))
18371da177e4SLinus Torvalds 		mode >>= 3;
1838e6305c43SAl Viro 	if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
18391da177e4SLinus Torvalds 		return 0;
18401da177e4SLinus Torvalds 	return -EACCES;
18411da177e4SLinus Torvalds }
18421da177e4SLinus Torvalds 
1843d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
18441da177e4SLinus Torvalds {
18451da177e4SLinus Torvalds 	int error;
1846d7321cd6SPavel Emelyanov 	int mode;
1847d7321cd6SPavel Emelyanov 
1848e6305c43SAl Viro 	error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
18491da177e4SLinus Torvalds 	if (error)
18501da177e4SLinus Torvalds 		return error;
1851d7321cd6SPavel Emelyanov 
1852d7321cd6SPavel Emelyanov 	if (root->permissions)
1853d7321cd6SPavel Emelyanov 		mode = root->permissions(root, current->nsproxy, table);
1854d7321cd6SPavel Emelyanov 	else
1855d7321cd6SPavel Emelyanov 		mode = table->mode;
1856d7321cd6SPavel Emelyanov 
1857d7321cd6SPavel Emelyanov 	return test_perm(mode, op);
18581da177e4SLinus Torvalds }
18591da177e4SLinus Torvalds 
1860d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1861d912b0ccSEric W. Biederman {
1862d912b0ccSEric W. Biederman 	for (; table->ctl_name || table->procname; table++) {
1863d912b0ccSEric W. Biederman 		table->parent = parent;
1864d912b0ccSEric W. Biederman 		if (table->child)
1865d912b0ccSEric W. Biederman 			sysctl_set_parent(table, table->child);
1866d912b0ccSEric W. Biederman 	}
1867d912b0ccSEric W. Biederman }
1868d912b0ccSEric W. Biederman 
1869d912b0ccSEric W. Biederman static __init int sysctl_init(void)
1870d912b0ccSEric W. Biederman {
1871d912b0ccSEric W. Biederman 	sysctl_set_parent(NULL, root_table);
187288f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
187388f458e4SHolger Schurig 	{
187488f458e4SHolger Schurig 		int err;
1875e51b6ba0SEric W. Biederman 		err = sysctl_check_table(current->nsproxy, root_table);
187688f458e4SHolger Schurig 	}
187788f458e4SHolger Schurig #endif
1878d912b0ccSEric W. Biederman 	return 0;
1879d912b0ccSEric W. Biederman }
1880d912b0ccSEric W. Biederman 
1881d912b0ccSEric W. Biederman core_initcall(sysctl_init);
1882d912b0ccSEric W. Biederman 
1883bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch,
1884bfbcf034SAl Viro 				      struct ctl_table *table)
1885ae7edeccSAl Viro {
1886ae7edeccSAl Viro 	struct ctl_table *p;
1887ae7edeccSAl Viro 	const char *s = branch->procname;
1888ae7edeccSAl Viro 
1889ae7edeccSAl Viro 	/* branch should have named subdirectory as its first element */
1890ae7edeccSAl Viro 	if (!s || !branch->child)
1891bfbcf034SAl Viro 		return NULL;
1892ae7edeccSAl Viro 
1893ae7edeccSAl Viro 	/* ... and nothing else */
1894ae7edeccSAl Viro 	if (branch[1].procname || branch[1].ctl_name)
1895bfbcf034SAl Viro 		return NULL;
1896ae7edeccSAl Viro 
1897ae7edeccSAl Viro 	/* table should contain subdirectory with the same name */
1898ae7edeccSAl Viro 	for (p = table; p->procname || p->ctl_name; p++) {
1899ae7edeccSAl Viro 		if (!p->child)
1900ae7edeccSAl Viro 			continue;
1901ae7edeccSAl Viro 		if (p->procname && strcmp(p->procname, s) == 0)
1902bfbcf034SAl Viro 			return p;
1903ae7edeccSAl Viro 	}
1904bfbcf034SAl Viro 	return NULL;
1905ae7edeccSAl Viro }
1906ae7edeccSAl Viro 
1907ae7edeccSAl Viro /* see if attaching q to p would be an improvement */
1908ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1909ae7edeccSAl Viro {
1910ae7edeccSAl Viro 	struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1911bfbcf034SAl Viro 	struct ctl_table *next;
1912ae7edeccSAl Viro 	int is_better = 0;
1913ae7edeccSAl Viro 	int not_in_parent = !p->attached_by;
1914ae7edeccSAl Viro 
1915bfbcf034SAl Viro 	while ((next = is_branch_in(by, to)) != NULL) {
1916ae7edeccSAl Viro 		if (by == q->attached_by)
1917ae7edeccSAl Viro 			is_better = 1;
1918ae7edeccSAl Viro 		if (to == p->attached_by)
1919ae7edeccSAl Viro 			not_in_parent = 1;
1920ae7edeccSAl Viro 		by = by->child;
1921bfbcf034SAl Viro 		to = next->child;
1922ae7edeccSAl Viro 	}
1923ae7edeccSAl Viro 
1924ae7edeccSAl Viro 	if (is_better && not_in_parent) {
1925ae7edeccSAl Viro 		q->attached_by = by;
1926ae7edeccSAl Viro 		q->attached_to = to;
1927ae7edeccSAl Viro 		q->parent = p;
1928ae7edeccSAl Viro 	}
1929ae7edeccSAl Viro }
1930ae7edeccSAl Viro 
19311da177e4SLinus Torvalds /**
1932e51b6ba0SEric W. Biederman  * __register_sysctl_paths - register a sysctl hierarchy
1933e51b6ba0SEric W. Biederman  * @root: List of sysctl headers to register on
1934e51b6ba0SEric W. Biederman  * @namespaces: Data to compute which lists of sysctl entries are visible
193529e796fdSEric W. Biederman  * @path: The path to the directory the sysctl table is in.
19361da177e4SLinus Torvalds  * @table: the top-level table structure
19371da177e4SLinus Torvalds  *
19381da177e4SLinus Torvalds  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
193929e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
19401da177e4SLinus Torvalds  *
1941d8217f07SEric W. Biederman  * The members of the &struct ctl_table structure are used as follows:
19421da177e4SLinus Torvalds  *
19431da177e4SLinus Torvalds  * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
19441da177e4SLinus Torvalds  *            must be unique within that level of sysctl
19451da177e4SLinus Torvalds  *
19461da177e4SLinus Torvalds  * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
19471da177e4SLinus Torvalds  *            enter a sysctl file
19481da177e4SLinus Torvalds  *
19491da177e4SLinus Torvalds  * data - a pointer to data for use by proc_handler
19501da177e4SLinus Torvalds  *
19511da177e4SLinus Torvalds  * maxlen - the maximum size in bytes of the data
19521da177e4SLinus Torvalds  *
19531da177e4SLinus Torvalds  * mode - the file permissions for the /proc/sys file, and for sysctl(2)
19541da177e4SLinus Torvalds  *
19551da177e4SLinus Torvalds  * child - a pointer to the child sysctl table if this entry is a directory, or
19561da177e4SLinus Torvalds  *         %NULL.
19571da177e4SLinus Torvalds  *
19581da177e4SLinus Torvalds  * proc_handler - the text handler routine (described below)
19591da177e4SLinus Torvalds  *
19601da177e4SLinus Torvalds  * strategy - the strategy routine (described below)
19611da177e4SLinus Torvalds  *
19621da177e4SLinus Torvalds  * de - for internal use by the sysctl routines
19631da177e4SLinus Torvalds  *
19641da177e4SLinus Torvalds  * extra1, extra2 - extra pointers usable by the proc handler routines
19651da177e4SLinus Torvalds  *
19661da177e4SLinus Torvalds  * Leaf nodes in the sysctl tree will be represented by a single file
19671da177e4SLinus Torvalds  * under /proc; non-leaf nodes will be represented by directories.
19681da177e4SLinus Torvalds  *
19691da177e4SLinus Torvalds  * sysctl(2) can automatically manage read and write requests through
19701da177e4SLinus Torvalds  * the sysctl table.  The data and maxlen fields of the ctl_table
19711da177e4SLinus Torvalds  * struct enable minimal validation of the values being written to be
19721da177e4SLinus Torvalds  * performed, and the mode field allows minimal authentication.
19731da177e4SLinus Torvalds  *
19741da177e4SLinus Torvalds  * More sophisticated management can be enabled by the provision of a
19751da177e4SLinus Torvalds  * strategy routine with the table entry.  This will be called before
19761da177e4SLinus Torvalds  * any automatic read or write of the data is performed.
19771da177e4SLinus Torvalds  *
19781da177e4SLinus Torvalds  * The strategy routine may return
19791da177e4SLinus Torvalds  *
19801da177e4SLinus Torvalds  * < 0 - Error occurred (error is passed to user process)
19811da177e4SLinus Torvalds  *
19821da177e4SLinus Torvalds  * 0   - OK - proceed with automatic read or write.
19831da177e4SLinus Torvalds  *
19841da177e4SLinus Torvalds  * > 0 - OK - read or write has been done by the strategy routine, so
19851da177e4SLinus Torvalds  *       return immediately.
19861da177e4SLinus Torvalds  *
19871da177e4SLinus Torvalds  * There must be a proc_handler routine for any terminal nodes
19881da177e4SLinus Torvalds  * mirrored under /proc/sys (non-terminals are handled by a built-in
19891da177e4SLinus Torvalds  * directory handler).  Several default handlers are available to
19901da177e4SLinus Torvalds  * cover common cases -
19911da177e4SLinus Torvalds  *
19921da177e4SLinus Torvalds  * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
19931da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
19941da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
19951da177e4SLinus Torvalds  *
19961da177e4SLinus Torvalds  * It is the handler's job to read the input buffer from user memory
19971da177e4SLinus Torvalds  * and process it. The handler should return 0 on success.
19981da177e4SLinus Torvalds  *
19991da177e4SLinus Torvalds  * This routine returns %NULL on a failure to register, and a pointer
20001da177e4SLinus Torvalds  * to the table header on success.
20011da177e4SLinus Torvalds  */
2002e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths(
2003e51b6ba0SEric W. Biederman 	struct ctl_table_root *root,
2004e51b6ba0SEric W. Biederman 	struct nsproxy *namespaces,
2005e51b6ba0SEric W. Biederman 	const struct ctl_path *path, struct ctl_table *table)
20061da177e4SLinus Torvalds {
200729e796fdSEric W. Biederman 	struct ctl_table_header *header;
200829e796fdSEric W. Biederman 	struct ctl_table *new, **prevp;
200929e796fdSEric W. Biederman 	unsigned int n, npath;
2010ae7edeccSAl Viro 	struct ctl_table_set *set;
201129e796fdSEric W. Biederman 
201229e796fdSEric W. Biederman 	/* Count the path components */
201329e796fdSEric W. Biederman 	for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
201429e796fdSEric W. Biederman 		;
201529e796fdSEric W. Biederman 
201629e796fdSEric W. Biederman 	/*
201729e796fdSEric W. Biederman 	 * For each path component, allocate a 2-element ctl_table array.
201829e796fdSEric W. Biederman 	 * The first array element will be filled with the sysctl entry
201929e796fdSEric W. Biederman 	 * for this, the second will be the sentinel (ctl_name == 0).
202029e796fdSEric W. Biederman 	 *
202129e796fdSEric W. Biederman 	 * We allocate everything in one go so that we don't have to
202229e796fdSEric W. Biederman 	 * worry about freeing additional memory in unregister_sysctl_table.
202329e796fdSEric W. Biederman 	 */
202429e796fdSEric W. Biederman 	header = kzalloc(sizeof(struct ctl_table_header) +
202529e796fdSEric W. Biederman 			 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
202629e796fdSEric W. Biederman 	if (!header)
20271da177e4SLinus Torvalds 		return NULL;
202829e796fdSEric W. Biederman 
202929e796fdSEric W. Biederman 	new = (struct ctl_table *) (header + 1);
203029e796fdSEric W. Biederman 
203129e796fdSEric W. Biederman 	/* Now connect the dots */
203229e796fdSEric W. Biederman 	prevp = &header->ctl_table;
203329e796fdSEric W. Biederman 	for (n = 0; n < npath; ++n, ++path) {
203429e796fdSEric W. Biederman 		/* Copy the procname */
203529e796fdSEric W. Biederman 		new->procname = path->procname;
203629e796fdSEric W. Biederman 		new->ctl_name = path->ctl_name;
203729e796fdSEric W. Biederman 		new->mode     = 0555;
203829e796fdSEric W. Biederman 
203929e796fdSEric W. Biederman 		*prevp = new;
204029e796fdSEric W. Biederman 		prevp = &new->child;
204129e796fdSEric W. Biederman 
204229e796fdSEric W. Biederman 		new += 2;
204329e796fdSEric W. Biederman 	}
204429e796fdSEric W. Biederman 	*prevp = table;
204523eb06deSEric W. Biederman 	header->ctl_table_arg = table;
204629e796fdSEric W. Biederman 
204729e796fdSEric W. Biederman 	INIT_LIST_HEAD(&header->ctl_entry);
204829e796fdSEric W. Biederman 	header->used = 0;
204929e796fdSEric W. Biederman 	header->unregistering = NULL;
2050e51b6ba0SEric W. Biederman 	header->root = root;
205129e796fdSEric W. Biederman 	sysctl_set_parent(NULL, header->ctl_table);
2052f7e6ced4SAl Viro 	header->count = 1;
205388f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
2054e51b6ba0SEric W. Biederman 	if (sysctl_check_table(namespaces, header->ctl_table)) {
205529e796fdSEric W. Biederman 		kfree(header);
2056fc6cd25bSEric W. Biederman 		return NULL;
2057fc6cd25bSEric W. Biederman 	}
205888f458e4SHolger Schurig #endif
2059330d57fbSAl Viro 	spin_lock(&sysctl_lock);
206073455092SAl Viro 	header->set = lookup_header_set(root, namespaces);
2061ae7edeccSAl Viro 	header->attached_by = header->ctl_table;
2062ae7edeccSAl Viro 	header->attached_to = root_table;
2063ae7edeccSAl Viro 	header->parent = &root_table_header;
2064ae7edeccSAl Viro 	for (set = header->set; set; set = set->parent) {
2065ae7edeccSAl Viro 		struct ctl_table_header *p;
2066ae7edeccSAl Viro 		list_for_each_entry(p, &set->list, ctl_entry) {
2067ae7edeccSAl Viro 			if (p->unregistering)
2068ae7edeccSAl Viro 				continue;
2069ae7edeccSAl Viro 			try_attach(p, header);
2070ae7edeccSAl Viro 		}
2071ae7edeccSAl Viro 	}
2072ae7edeccSAl Viro 	header->parent->count++;
207373455092SAl Viro 	list_add_tail(&header->ctl_entry, &header->set->list);
2074330d57fbSAl Viro 	spin_unlock(&sysctl_lock);
207529e796fdSEric W. Biederman 
207629e796fdSEric W. Biederman 	return header;
207729e796fdSEric W. Biederman }
207829e796fdSEric W. Biederman 
207929e796fdSEric W. Biederman /**
2080e51b6ba0SEric W. Biederman  * register_sysctl_table_path - register a sysctl table hierarchy
2081e51b6ba0SEric W. Biederman  * @path: The path to the directory the sysctl table is in.
2082e51b6ba0SEric W. Biederman  * @table: the top-level table structure
2083e51b6ba0SEric W. Biederman  *
2084e51b6ba0SEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2085e51b6ba0SEric W. Biederman  * array. A completely 0 filled entry terminates the table.
2086e51b6ba0SEric W. Biederman  *
2087e51b6ba0SEric W. Biederman  * See __register_sysctl_paths for more details.
2088e51b6ba0SEric W. Biederman  */
2089e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2090e51b6ba0SEric W. Biederman 						struct ctl_table *table)
2091e51b6ba0SEric W. Biederman {
2092e51b6ba0SEric W. Biederman 	return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
2093e51b6ba0SEric W. Biederman 					path, table);
2094e51b6ba0SEric W. Biederman }
2095e51b6ba0SEric W. Biederman 
2096e51b6ba0SEric W. Biederman /**
209729e796fdSEric W. Biederman  * register_sysctl_table - register a sysctl table hierarchy
209829e796fdSEric W. Biederman  * @table: the top-level table structure
209929e796fdSEric W. Biederman  *
210029e796fdSEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
210129e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
210229e796fdSEric W. Biederman  *
210329e796fdSEric W. Biederman  * See register_sysctl_paths for more details.
210429e796fdSEric W. Biederman  */
210529e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
210629e796fdSEric W. Biederman {
210729e796fdSEric W. Biederman 	static const struct ctl_path null_path[] = { {} };
210829e796fdSEric W. Biederman 
210929e796fdSEric W. Biederman 	return register_sysctl_paths(null_path, table);
21101da177e4SLinus Torvalds }
21111da177e4SLinus Torvalds 
21121da177e4SLinus Torvalds /**
21131da177e4SLinus Torvalds  * unregister_sysctl_table - unregister a sysctl table hierarchy
21141da177e4SLinus Torvalds  * @header: the header returned from register_sysctl_table
21151da177e4SLinus Torvalds  *
21161da177e4SLinus Torvalds  * Unregisters the sysctl table and all children. proc entries may not
21171da177e4SLinus Torvalds  * actually be removed until they are no longer used by anyone.
21181da177e4SLinus Torvalds  */
21191da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header)
21201da177e4SLinus Torvalds {
2121330d57fbSAl Viro 	might_sleep();
2122f1dad166SPavel Emelyanov 
2123f1dad166SPavel Emelyanov 	if (header == NULL)
2124f1dad166SPavel Emelyanov 		return;
2125f1dad166SPavel Emelyanov 
2126330d57fbSAl Viro 	spin_lock(&sysctl_lock);
2127330d57fbSAl Viro 	start_unregistering(header);
2128ae7edeccSAl Viro 	if (!--header->parent->count) {
2129ae7edeccSAl Viro 		WARN_ON(1);
2130ae7edeccSAl Viro 		kfree(header->parent);
2131ae7edeccSAl Viro 	}
2132f7e6ced4SAl Viro 	if (!--header->count)
21331da177e4SLinus Torvalds 		kfree(header);
2134f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
21351da177e4SLinus Torvalds }
21361da177e4SLinus Torvalds 
21379043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p)
21389043476fSAl Viro {
21399043476fSAl Viro 	struct ctl_table_set *set = p->set;
21409043476fSAl Viro 	int res;
21419043476fSAl Viro 	spin_lock(&sysctl_lock);
21429043476fSAl Viro 	if (p->unregistering)
21439043476fSAl Viro 		res = 0;
21449043476fSAl Viro 	else if (!set->is_seen)
21459043476fSAl Viro 		res = 1;
21469043476fSAl Viro 	else
21479043476fSAl Viro 		res = set->is_seen(set);
21489043476fSAl Viro 	spin_unlock(&sysctl_lock);
21499043476fSAl Viro 	return res;
21509043476fSAl Viro }
21519043476fSAl Viro 
215273455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
215373455092SAl Viro 	struct ctl_table_set *parent,
215473455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
215573455092SAl Viro {
215673455092SAl Viro 	INIT_LIST_HEAD(&p->list);
215773455092SAl Viro 	p->parent = parent ? parent : &sysctl_table_root.default_set;
215873455092SAl Viro 	p->is_seen = is_seen;
215973455092SAl Viro }
216073455092SAl Viro 
2161b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */
2162d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
2163b89a8171SEric W. Biederman {
2164b89a8171SEric W. Biederman 	return NULL;
2165b89a8171SEric W. Biederman }
2166b89a8171SEric W. Biederman 
216729e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
216829e796fdSEric W. Biederman 						    struct ctl_table *table)
216929e796fdSEric W. Biederman {
217029e796fdSEric W. Biederman 	return NULL;
217129e796fdSEric W. Biederman }
217229e796fdSEric W. Biederman 
2173b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table)
2174b89a8171SEric W. Biederman {
2175b89a8171SEric W. Biederman }
2176b89a8171SEric W. Biederman 
217773455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
217873455092SAl Viro 	struct ctl_table_set *parent,
217973455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
218073455092SAl Viro {
218173455092SAl Viro }
218273455092SAl Viro 
2183f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
2184f7e6ced4SAl Viro {
2185f7e6ced4SAl Viro }
2186f7e6ced4SAl Viro 
2187b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
2188b89a8171SEric W. Biederman 
21891da177e4SLinus Torvalds /*
21901da177e4SLinus Torvalds  * /proc/sys support
21911da177e4SLinus Torvalds  */
21921da177e4SLinus Torvalds 
2193b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL
21941da177e4SLinus Torvalds 
2195b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write,
2196b1ba4dddSAdrian Bunk 			   struct file *filp, void __user *buffer,
2197b1ba4dddSAdrian Bunk 			   size_t *lenp, loff_t *ppos)
2198f5dd3d6fSSam Vilain {
2199f5dd3d6fSSam Vilain 	size_t len;
2200f5dd3d6fSSam Vilain 	char __user *p;
2201f5dd3d6fSSam Vilain 	char c;
2202f5dd3d6fSSam Vilain 
22038d060877SOleg Nesterov 	if (!data || !maxlen || !*lenp) {
2204f5dd3d6fSSam Vilain 		*lenp = 0;
2205f5dd3d6fSSam Vilain 		return 0;
2206f5dd3d6fSSam Vilain 	}
2207f5dd3d6fSSam Vilain 
2208f5dd3d6fSSam Vilain 	if (write) {
2209f5dd3d6fSSam Vilain 		len = 0;
2210f5dd3d6fSSam Vilain 		p = buffer;
2211f5dd3d6fSSam Vilain 		while (len < *lenp) {
2212f5dd3d6fSSam Vilain 			if (get_user(c, p++))
2213f5dd3d6fSSam Vilain 				return -EFAULT;
2214f5dd3d6fSSam Vilain 			if (c == 0 || c == '\n')
2215f5dd3d6fSSam Vilain 				break;
2216f5dd3d6fSSam Vilain 			len++;
2217f5dd3d6fSSam Vilain 		}
2218f5dd3d6fSSam Vilain 		if (len >= maxlen)
2219f5dd3d6fSSam Vilain 			len = maxlen-1;
2220f5dd3d6fSSam Vilain 		if(copy_from_user(data, buffer, len))
2221f5dd3d6fSSam Vilain 			return -EFAULT;
2222f5dd3d6fSSam Vilain 		((char *) data)[len] = 0;
2223f5dd3d6fSSam Vilain 		*ppos += *lenp;
2224f5dd3d6fSSam Vilain 	} else {
2225f5dd3d6fSSam Vilain 		len = strlen(data);
2226f5dd3d6fSSam Vilain 		if (len > maxlen)
2227f5dd3d6fSSam Vilain 			len = maxlen;
22288d060877SOleg Nesterov 
22298d060877SOleg Nesterov 		if (*ppos > len) {
22308d060877SOleg Nesterov 			*lenp = 0;
22318d060877SOleg Nesterov 			return 0;
22328d060877SOleg Nesterov 		}
22338d060877SOleg Nesterov 
22348d060877SOleg Nesterov 		data += *ppos;
22358d060877SOleg Nesterov 		len  -= *ppos;
22368d060877SOleg Nesterov 
2237f5dd3d6fSSam Vilain 		if (len > *lenp)
2238f5dd3d6fSSam Vilain 			len = *lenp;
2239f5dd3d6fSSam Vilain 		if (len)
2240f5dd3d6fSSam Vilain 			if(copy_to_user(buffer, data, len))
2241f5dd3d6fSSam Vilain 				return -EFAULT;
2242f5dd3d6fSSam Vilain 		if (len < *lenp) {
2243f5dd3d6fSSam Vilain 			if(put_user('\n', ((char __user *) buffer) + len))
2244f5dd3d6fSSam Vilain 				return -EFAULT;
2245f5dd3d6fSSam Vilain 			len++;
2246f5dd3d6fSSam Vilain 		}
2247f5dd3d6fSSam Vilain 		*lenp = len;
2248f5dd3d6fSSam Vilain 		*ppos += len;
2249f5dd3d6fSSam Vilain 	}
2250f5dd3d6fSSam Vilain 	return 0;
2251f5dd3d6fSSam Vilain }
2252f5dd3d6fSSam Vilain 
22531da177e4SLinus Torvalds /**
22541da177e4SLinus Torvalds  * proc_dostring - read a string sysctl
22551da177e4SLinus Torvalds  * @table: the sysctl table
22561da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
22571da177e4SLinus Torvalds  * @filp: the file structure
22581da177e4SLinus Torvalds  * @buffer: the user buffer
22591da177e4SLinus Torvalds  * @lenp: the size of the user buffer
22601da177e4SLinus Torvalds  * @ppos: file position
22611da177e4SLinus Torvalds  *
22621da177e4SLinus Torvalds  * Reads/writes a string from/to the user buffer. If the kernel
22631da177e4SLinus Torvalds  * buffer provided is not large enough to hold the string, the
22641da177e4SLinus Torvalds  * string is truncated. The copied string is %NULL-terminated.
22651da177e4SLinus Torvalds  * If the string is being read by the user process, it is copied
22661da177e4SLinus Torvalds  * and a newline '\n' is added. It is truncated if the buffer is
22671da177e4SLinus Torvalds  * not large enough.
22681da177e4SLinus Torvalds  *
22691da177e4SLinus Torvalds  * Returns 0 on success.
22701da177e4SLinus Torvalds  */
2271d8217f07SEric W. Biederman int proc_dostring(struct ctl_table *table, int write, struct file *filp,
22721da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
22731da177e4SLinus Torvalds {
2274f5dd3d6fSSam Vilain 	return _proc_do_string(table->data, table->maxlen, write, filp,
2275f5dd3d6fSSam Vilain 			       buffer, lenp, ppos);
22761da177e4SLinus Torvalds }
22771da177e4SLinus Torvalds 
22781da177e4SLinus Torvalds 
22791da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
22801da177e4SLinus Torvalds 				 int *valp,
22811da177e4SLinus Torvalds 				 int write, void *data)
22821da177e4SLinus Torvalds {
22831da177e4SLinus Torvalds 	if (write) {
22841da177e4SLinus Torvalds 		*valp = *negp ? -*lvalp : *lvalp;
22851da177e4SLinus Torvalds 	} else {
22861da177e4SLinus Torvalds 		int val = *valp;
22871da177e4SLinus Torvalds 		if (val < 0) {
22881da177e4SLinus Torvalds 			*negp = -1;
22891da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
22901da177e4SLinus Torvalds 		} else {
22911da177e4SLinus Torvalds 			*negp = 0;
22921da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
22931da177e4SLinus Torvalds 		}
22941da177e4SLinus Torvalds 	}
22951da177e4SLinus Torvalds 	return 0;
22961da177e4SLinus Torvalds }
22971da177e4SLinus Torvalds 
2298d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
2299fcfbd547SKirill Korotaev 		  int write, struct file *filp, void __user *buffer,
2300fcfbd547SKirill Korotaev 		  size_t *lenp, loff_t *ppos,
23011da177e4SLinus Torvalds 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
23021da177e4SLinus Torvalds 			      int write, void *data),
23031da177e4SLinus Torvalds 		  void *data)
23041da177e4SLinus Torvalds {
23051da177e4SLinus Torvalds #define TMPBUFLEN 21
23067338f299SSukanto Ghosh 	int *i, vleft, first = 1, neg;
23071da177e4SLinus Torvalds 	unsigned long lval;
23081da177e4SLinus Torvalds 	size_t left, len;
23091da177e4SLinus Torvalds 
23101da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
23111da177e4SLinus Torvalds 	char __user *s = buffer;
23121da177e4SLinus Torvalds 
2313fcfbd547SKirill Korotaev 	if (!tbl_data || !table->maxlen || !*lenp ||
23141da177e4SLinus Torvalds 	    (*ppos && !write)) {
23151da177e4SLinus Torvalds 		*lenp = 0;
23161da177e4SLinus Torvalds 		return 0;
23171da177e4SLinus Torvalds 	}
23181da177e4SLinus Torvalds 
2319fcfbd547SKirill Korotaev 	i = (int *) tbl_data;
23201da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(*i);
23211da177e4SLinus Torvalds 	left = *lenp;
23221da177e4SLinus Torvalds 
23231da177e4SLinus Torvalds 	if (!conv)
23241da177e4SLinus Torvalds 		conv = do_proc_dointvec_conv;
23251da177e4SLinus Torvalds 
23261da177e4SLinus Torvalds 	for (; left && vleft--; i++, first=0) {
23271da177e4SLinus Torvalds 		if (write) {
23281da177e4SLinus Torvalds 			while (left) {
23291da177e4SLinus Torvalds 				char c;
23301da177e4SLinus Torvalds 				if (get_user(c, s))
23311da177e4SLinus Torvalds 					return -EFAULT;
23321da177e4SLinus Torvalds 				if (!isspace(c))
23331da177e4SLinus Torvalds 					break;
23341da177e4SLinus Torvalds 				left--;
23351da177e4SLinus Torvalds 				s++;
23361da177e4SLinus Torvalds 			}
23371da177e4SLinus Torvalds 			if (!left)
23381da177e4SLinus Torvalds 				break;
23391da177e4SLinus Torvalds 			neg = 0;
23401da177e4SLinus Torvalds 			len = left;
23411da177e4SLinus Torvalds 			if (len > sizeof(buf) - 1)
23421da177e4SLinus Torvalds 				len = sizeof(buf) - 1;
23431da177e4SLinus Torvalds 			if (copy_from_user(buf, s, len))
23441da177e4SLinus Torvalds 				return -EFAULT;
23451da177e4SLinus Torvalds 			buf[len] = 0;
23461da177e4SLinus Torvalds 			p = buf;
23471da177e4SLinus Torvalds 			if (*p == '-' && left > 1) {
23481da177e4SLinus Torvalds 				neg = 1;
2349bd9b0bacSBP, Praveen 				p++;
23501da177e4SLinus Torvalds 			}
23511da177e4SLinus Torvalds 			if (*p < '0' || *p > '9')
23521da177e4SLinus Torvalds 				break;
23531da177e4SLinus Torvalds 
23541da177e4SLinus Torvalds 			lval = simple_strtoul(p, &p, 0);
23551da177e4SLinus Torvalds 
23561da177e4SLinus Torvalds 			len = p-buf;
23571da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
23581da177e4SLinus Torvalds 				break;
23591da177e4SLinus Torvalds 			s += len;
23601da177e4SLinus Torvalds 			left -= len;
23611da177e4SLinus Torvalds 
23621da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 1, data))
23631da177e4SLinus Torvalds 				break;
23641da177e4SLinus Torvalds 		} else {
23651da177e4SLinus Torvalds 			p = buf;
23661da177e4SLinus Torvalds 			if (!first)
23671da177e4SLinus Torvalds 				*p++ = '\t';
23681da177e4SLinus Torvalds 
23691da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 0, data))
23701da177e4SLinus Torvalds 				break;
23711da177e4SLinus Torvalds 
23721da177e4SLinus Torvalds 			sprintf(p, "%s%lu", neg ? "-" : "", lval);
23731da177e4SLinus Torvalds 			len = strlen(buf);
23741da177e4SLinus Torvalds 			if (len > left)
23751da177e4SLinus Torvalds 				len = left;
23761da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
23771da177e4SLinus Torvalds 				return -EFAULT;
23781da177e4SLinus Torvalds 			left -= len;
23791da177e4SLinus Torvalds 			s += len;
23801da177e4SLinus Torvalds 		}
23811da177e4SLinus Torvalds 	}
23821da177e4SLinus Torvalds 
23831da177e4SLinus Torvalds 	if (!write && !first && left) {
23841da177e4SLinus Torvalds 		if(put_user('\n', s))
23851da177e4SLinus Torvalds 			return -EFAULT;
23861da177e4SLinus Torvalds 		left--, s++;
23871da177e4SLinus Torvalds 	}
23881da177e4SLinus Torvalds 	if (write) {
23891da177e4SLinus Torvalds 		while (left) {
23901da177e4SLinus Torvalds 			char c;
23911da177e4SLinus Torvalds 			if (get_user(c, s++))
23921da177e4SLinus Torvalds 				return -EFAULT;
23931da177e4SLinus Torvalds 			if (!isspace(c))
23941da177e4SLinus Torvalds 				break;
23951da177e4SLinus Torvalds 			left--;
23961da177e4SLinus Torvalds 		}
23971da177e4SLinus Torvalds 	}
23981da177e4SLinus Torvalds 	if (write && first)
23991da177e4SLinus Torvalds 		return -EINVAL;
24001da177e4SLinus Torvalds 	*lenp -= left;
24011da177e4SLinus Torvalds 	*ppos += *lenp;
24021da177e4SLinus Torvalds 	return 0;
24031da177e4SLinus Torvalds #undef TMPBUFLEN
24041da177e4SLinus Torvalds }
24051da177e4SLinus Torvalds 
2406d8217f07SEric W. Biederman static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2407fcfbd547SKirill Korotaev 		  void __user *buffer, size_t *lenp, loff_t *ppos,
2408fcfbd547SKirill Korotaev 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2409fcfbd547SKirill Korotaev 			      int write, void *data),
2410fcfbd547SKirill Korotaev 		  void *data)
2411fcfbd547SKirill Korotaev {
2412fcfbd547SKirill Korotaev 	return __do_proc_dointvec(table->data, table, write, filp,
2413fcfbd547SKirill Korotaev 			buffer, lenp, ppos, conv, data);
2414fcfbd547SKirill Korotaev }
2415fcfbd547SKirill Korotaev 
24161da177e4SLinus Torvalds /**
24171da177e4SLinus Torvalds  * proc_dointvec - read a vector of integers
24181da177e4SLinus Torvalds  * @table: the sysctl table
24191da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24201da177e4SLinus Torvalds  * @filp: the file structure
24211da177e4SLinus Torvalds  * @buffer: the user buffer
24221da177e4SLinus Torvalds  * @lenp: the size of the user buffer
24231da177e4SLinus Torvalds  * @ppos: file position
24241da177e4SLinus Torvalds  *
24251da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
24261da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
24271da177e4SLinus Torvalds  *
24281da177e4SLinus Torvalds  * Returns 0 on success.
24291da177e4SLinus Torvalds  */
2430d8217f07SEric W. Biederman int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
24311da177e4SLinus Torvalds 		     void __user *buffer, size_t *lenp, loff_t *ppos)
24321da177e4SLinus Torvalds {
24331da177e4SLinus Torvalds     return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
24341da177e4SLinus Torvalds 		    	    NULL,NULL);
24351da177e4SLinus Torvalds }
24361da177e4SLinus Torvalds 
243734f5a398STheodore Ts'o /*
243834f5a398STheodore Ts'o  * Taint values can only be increased
243925ddbb18SAndi Kleen  * This means we can safely use a temporary.
244034f5a398STheodore Ts'o  */
244125ddbb18SAndi Kleen static int proc_taint(struct ctl_table *table, int write, struct file *filp,
244234f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos)
244334f5a398STheodore Ts'o {
244425ddbb18SAndi Kleen 	struct ctl_table t;
244525ddbb18SAndi Kleen 	unsigned long tmptaint = get_taint();
244625ddbb18SAndi Kleen 	int err;
244734f5a398STheodore Ts'o 
244891fcd412SBastian Blank 	if (write && !capable(CAP_SYS_ADMIN))
244934f5a398STheodore Ts'o 		return -EPERM;
245034f5a398STheodore Ts'o 
245125ddbb18SAndi Kleen 	t = *table;
245225ddbb18SAndi Kleen 	t.data = &tmptaint;
245325ddbb18SAndi Kleen 	err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos);
245425ddbb18SAndi Kleen 	if (err < 0)
245525ddbb18SAndi Kleen 		return err;
245625ddbb18SAndi Kleen 
245725ddbb18SAndi Kleen 	if (write) {
245825ddbb18SAndi Kleen 		/*
245925ddbb18SAndi Kleen 		 * Poor man's atomic or. Not worth adding a primitive
246025ddbb18SAndi Kleen 		 * to everyone's atomic.h for this
246125ddbb18SAndi Kleen 		 */
246225ddbb18SAndi Kleen 		int i;
246325ddbb18SAndi Kleen 		for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
246425ddbb18SAndi Kleen 			if ((tmptaint >> i) & 1)
246525ddbb18SAndi Kleen 				add_taint(i);
246625ddbb18SAndi Kleen 		}
246725ddbb18SAndi Kleen 	}
246825ddbb18SAndi Kleen 
246925ddbb18SAndi Kleen 	return err;
247034f5a398STheodore Ts'o }
247134f5a398STheodore Ts'o 
24721da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param {
24731da177e4SLinus Torvalds 	int *min;
24741da177e4SLinus Torvalds 	int *max;
24751da177e4SLinus Torvalds };
24761da177e4SLinus Torvalds 
24771da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
24781da177e4SLinus Torvalds 					int *valp,
24791da177e4SLinus Torvalds 					int write, void *data)
24801da177e4SLinus Torvalds {
24811da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param *param = data;
24821da177e4SLinus Torvalds 	if (write) {
24831da177e4SLinus Torvalds 		int val = *negp ? -*lvalp : *lvalp;
24841da177e4SLinus Torvalds 		if ((param->min && *param->min > val) ||
24851da177e4SLinus Torvalds 		    (param->max && *param->max < val))
24861da177e4SLinus Torvalds 			return -EINVAL;
24871da177e4SLinus Torvalds 		*valp = val;
24881da177e4SLinus Torvalds 	} else {
24891da177e4SLinus Torvalds 		int val = *valp;
24901da177e4SLinus Torvalds 		if (val < 0) {
24911da177e4SLinus Torvalds 			*negp = -1;
24921da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
24931da177e4SLinus Torvalds 		} else {
24941da177e4SLinus Torvalds 			*negp = 0;
24951da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
24961da177e4SLinus Torvalds 		}
24971da177e4SLinus Torvalds 	}
24981da177e4SLinus Torvalds 	return 0;
24991da177e4SLinus Torvalds }
25001da177e4SLinus Torvalds 
25011da177e4SLinus Torvalds /**
25021da177e4SLinus Torvalds  * proc_dointvec_minmax - read a vector of integers with min/max values
25031da177e4SLinus Torvalds  * @table: the sysctl table
25041da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25051da177e4SLinus Torvalds  * @filp: the file structure
25061da177e4SLinus Torvalds  * @buffer: the user buffer
25071da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25081da177e4SLinus Torvalds  * @ppos: file position
25091da177e4SLinus Torvalds  *
25101da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
25111da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25121da177e4SLinus Torvalds  *
25131da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
25141da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
25151da177e4SLinus Torvalds  *
25161da177e4SLinus Torvalds  * Returns 0 on success.
25171da177e4SLinus Torvalds  */
2518d8217f07SEric W. Biederman int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
25191da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
25201da177e4SLinus Torvalds {
25211da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param param = {
25221da177e4SLinus Torvalds 		.min = (int *) table->extra1,
25231da177e4SLinus Torvalds 		.max = (int *) table->extra2,
25241da177e4SLinus Torvalds 	};
25251da177e4SLinus Torvalds 	return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
25261da177e4SLinus Torvalds 				do_proc_dointvec_minmax_conv, &param);
25271da177e4SLinus Torvalds }
25281da177e4SLinus Torvalds 
2529d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
25301da177e4SLinus Torvalds 				     struct file *filp,
25311da177e4SLinus Torvalds 				     void __user *buffer,
25321da177e4SLinus Torvalds 				     size_t *lenp, loff_t *ppos,
25331da177e4SLinus Torvalds 				     unsigned long convmul,
25341da177e4SLinus Torvalds 				     unsigned long convdiv)
25351da177e4SLinus Torvalds {
25361da177e4SLinus Torvalds #define TMPBUFLEN 21
25371da177e4SLinus Torvalds 	unsigned long *i, *min, *max, val;
25381da177e4SLinus Torvalds 	int vleft, first=1, neg;
25391da177e4SLinus Torvalds 	size_t len, left;
25401da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
25411da177e4SLinus Torvalds 	char __user *s = buffer;
25421da177e4SLinus Torvalds 
2543fcfbd547SKirill Korotaev 	if (!data || !table->maxlen || !*lenp ||
25441da177e4SLinus Torvalds 	    (*ppos && !write)) {
25451da177e4SLinus Torvalds 		*lenp = 0;
25461da177e4SLinus Torvalds 		return 0;
25471da177e4SLinus Torvalds 	}
25481da177e4SLinus Torvalds 
2549fcfbd547SKirill Korotaev 	i = (unsigned long *) data;
25501da177e4SLinus Torvalds 	min = (unsigned long *) table->extra1;
25511da177e4SLinus Torvalds 	max = (unsigned long *) table->extra2;
25521da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(unsigned long);
25531da177e4SLinus Torvalds 	left = *lenp;
25541da177e4SLinus Torvalds 
25551da177e4SLinus Torvalds 	for (; left && vleft--; i++, min++, max++, first=0) {
25561da177e4SLinus Torvalds 		if (write) {
25571da177e4SLinus Torvalds 			while (left) {
25581da177e4SLinus Torvalds 				char c;
25591da177e4SLinus Torvalds 				if (get_user(c, s))
25601da177e4SLinus Torvalds 					return -EFAULT;
25611da177e4SLinus Torvalds 				if (!isspace(c))
25621da177e4SLinus Torvalds 					break;
25631da177e4SLinus Torvalds 				left--;
25641da177e4SLinus Torvalds 				s++;
25651da177e4SLinus Torvalds 			}
25661da177e4SLinus Torvalds 			if (!left)
25671da177e4SLinus Torvalds 				break;
25681da177e4SLinus Torvalds 			neg = 0;
25691da177e4SLinus Torvalds 			len = left;
25701da177e4SLinus Torvalds 			if (len > TMPBUFLEN-1)
25711da177e4SLinus Torvalds 				len = TMPBUFLEN-1;
25721da177e4SLinus Torvalds 			if (copy_from_user(buf, s, len))
25731da177e4SLinus Torvalds 				return -EFAULT;
25741da177e4SLinus Torvalds 			buf[len] = 0;
25751da177e4SLinus Torvalds 			p = buf;
25761da177e4SLinus Torvalds 			if (*p == '-' && left > 1) {
25771da177e4SLinus Torvalds 				neg = 1;
2578bd9b0bacSBP, Praveen 				p++;
25791da177e4SLinus Torvalds 			}
25801da177e4SLinus Torvalds 			if (*p < '0' || *p > '9')
25811da177e4SLinus Torvalds 				break;
25821da177e4SLinus Torvalds 			val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
25831da177e4SLinus Torvalds 			len = p-buf;
25841da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
25851da177e4SLinus Torvalds 				break;
25861da177e4SLinus Torvalds 			if (neg)
25871da177e4SLinus Torvalds 				val = -val;
25881da177e4SLinus Torvalds 			s += len;
25891da177e4SLinus Torvalds 			left -= len;
25901da177e4SLinus Torvalds 
25911da177e4SLinus Torvalds 			if(neg)
25921da177e4SLinus Torvalds 				continue;
25931da177e4SLinus Torvalds 			if ((min && val < *min) || (max && val > *max))
25941da177e4SLinus Torvalds 				continue;
25951da177e4SLinus Torvalds 			*i = val;
25961da177e4SLinus Torvalds 		} else {
25971da177e4SLinus Torvalds 			p = buf;
25981da177e4SLinus Torvalds 			if (!first)
25991da177e4SLinus Torvalds 				*p++ = '\t';
26001da177e4SLinus Torvalds 			sprintf(p, "%lu", convdiv * (*i) / convmul);
26011da177e4SLinus Torvalds 			len = strlen(buf);
26021da177e4SLinus Torvalds 			if (len > left)
26031da177e4SLinus Torvalds 				len = left;
26041da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
26051da177e4SLinus Torvalds 				return -EFAULT;
26061da177e4SLinus Torvalds 			left -= len;
26071da177e4SLinus Torvalds 			s += len;
26081da177e4SLinus Torvalds 		}
26091da177e4SLinus Torvalds 	}
26101da177e4SLinus Torvalds 
26111da177e4SLinus Torvalds 	if (!write && !first && left) {
26121da177e4SLinus Torvalds 		if(put_user('\n', s))
26131da177e4SLinus Torvalds 			return -EFAULT;
26141da177e4SLinus Torvalds 		left--, s++;
26151da177e4SLinus Torvalds 	}
26161da177e4SLinus Torvalds 	if (write) {
26171da177e4SLinus Torvalds 		while (left) {
26181da177e4SLinus Torvalds 			char c;
26191da177e4SLinus Torvalds 			if (get_user(c, s++))
26201da177e4SLinus Torvalds 				return -EFAULT;
26211da177e4SLinus Torvalds 			if (!isspace(c))
26221da177e4SLinus Torvalds 				break;
26231da177e4SLinus Torvalds 			left--;
26241da177e4SLinus Torvalds 		}
26251da177e4SLinus Torvalds 	}
26261da177e4SLinus Torvalds 	if (write && first)
26271da177e4SLinus Torvalds 		return -EINVAL;
26281da177e4SLinus Torvalds 	*lenp -= left;
26291da177e4SLinus Torvalds 	*ppos += *lenp;
26301da177e4SLinus Torvalds 	return 0;
26311da177e4SLinus Torvalds #undef TMPBUFLEN
26321da177e4SLinus Torvalds }
26331da177e4SLinus Torvalds 
2634d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2635fcfbd547SKirill Korotaev 				     struct file *filp,
2636fcfbd547SKirill Korotaev 				     void __user *buffer,
2637fcfbd547SKirill Korotaev 				     size_t *lenp, loff_t *ppos,
2638fcfbd547SKirill Korotaev 				     unsigned long convmul,
2639fcfbd547SKirill Korotaev 				     unsigned long convdiv)
2640fcfbd547SKirill Korotaev {
2641fcfbd547SKirill Korotaev 	return __do_proc_doulongvec_minmax(table->data, table, write,
2642fcfbd547SKirill Korotaev 			filp, buffer, lenp, ppos, convmul, convdiv);
2643fcfbd547SKirill Korotaev }
2644fcfbd547SKirill Korotaev 
26451da177e4SLinus Torvalds /**
26461da177e4SLinus Torvalds  * proc_doulongvec_minmax - read a vector of long integers with min/max values
26471da177e4SLinus Torvalds  * @table: the sysctl table
26481da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
26491da177e4SLinus Torvalds  * @filp: the file structure
26501da177e4SLinus Torvalds  * @buffer: the user buffer
26511da177e4SLinus Torvalds  * @lenp: the size of the user buffer
26521da177e4SLinus Torvalds  * @ppos: file position
26531da177e4SLinus Torvalds  *
26541da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
26551da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
26561da177e4SLinus Torvalds  *
26571da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
26581da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
26591da177e4SLinus Torvalds  *
26601da177e4SLinus Torvalds  * Returns 0 on success.
26611da177e4SLinus Torvalds  */
2662d8217f07SEric W. Biederman int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
26631da177e4SLinus Torvalds 			   void __user *buffer, size_t *lenp, loff_t *ppos)
26641da177e4SLinus Torvalds {
26651da177e4SLinus Torvalds     return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
26661da177e4SLinus Torvalds }
26671da177e4SLinus Torvalds 
26681da177e4SLinus Torvalds /**
26691da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
26701da177e4SLinus Torvalds  * @table: the sysctl table
26711da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
26721da177e4SLinus Torvalds  * @filp: the file structure
26731da177e4SLinus Torvalds  * @buffer: the user buffer
26741da177e4SLinus Torvalds  * @lenp: the size of the user buffer
26751da177e4SLinus Torvalds  * @ppos: file position
26761da177e4SLinus Torvalds  *
26771da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
26781da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string. The values
26791da177e4SLinus Torvalds  * are treated as milliseconds, and converted to jiffies when they are stored.
26801da177e4SLinus Torvalds  *
26811da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
26821da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
26831da177e4SLinus Torvalds  *
26841da177e4SLinus Torvalds  * Returns 0 on success.
26851da177e4SLinus Torvalds  */
2686d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
26871da177e4SLinus Torvalds 				      struct file *filp,
26881da177e4SLinus Torvalds 				      void __user *buffer,
26891da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
26901da177e4SLinus Torvalds {
26911da177e4SLinus Torvalds     return do_proc_doulongvec_minmax(table, write, filp, buffer,
26921da177e4SLinus Torvalds 				     lenp, ppos, HZ, 1000l);
26931da177e4SLinus Torvalds }
26941da177e4SLinus Torvalds 
26951da177e4SLinus Torvalds 
26961da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
26971da177e4SLinus Torvalds 					 int *valp,
26981da177e4SLinus Torvalds 					 int write, void *data)
26991da177e4SLinus Torvalds {
27001da177e4SLinus Torvalds 	if (write) {
2701cba9f33dSBart Samwel 		if (*lvalp > LONG_MAX / HZ)
2702cba9f33dSBart Samwel 			return 1;
27031da177e4SLinus Torvalds 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
27041da177e4SLinus Torvalds 	} else {
27051da177e4SLinus Torvalds 		int val = *valp;
27061da177e4SLinus Torvalds 		unsigned long lval;
27071da177e4SLinus Torvalds 		if (val < 0) {
27081da177e4SLinus Torvalds 			*negp = -1;
27091da177e4SLinus Torvalds 			lval = (unsigned long)-val;
27101da177e4SLinus Torvalds 		} else {
27111da177e4SLinus Torvalds 			*negp = 0;
27121da177e4SLinus Torvalds 			lval = (unsigned long)val;
27131da177e4SLinus Torvalds 		}
27141da177e4SLinus Torvalds 		*lvalp = lval / HZ;
27151da177e4SLinus Torvalds 	}
27161da177e4SLinus Torvalds 	return 0;
27171da177e4SLinus Torvalds }
27181da177e4SLinus Torvalds 
27191da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
27201da177e4SLinus Torvalds 						int *valp,
27211da177e4SLinus Torvalds 						int write, void *data)
27221da177e4SLinus Torvalds {
27231da177e4SLinus Torvalds 	if (write) {
2724cba9f33dSBart Samwel 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2725cba9f33dSBart Samwel 			return 1;
27261da177e4SLinus Torvalds 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
27271da177e4SLinus Torvalds 	} else {
27281da177e4SLinus Torvalds 		int val = *valp;
27291da177e4SLinus Torvalds 		unsigned long lval;
27301da177e4SLinus Torvalds 		if (val < 0) {
27311da177e4SLinus Torvalds 			*negp = -1;
27321da177e4SLinus Torvalds 			lval = (unsigned long)-val;
27331da177e4SLinus Torvalds 		} else {
27341da177e4SLinus Torvalds 			*negp = 0;
27351da177e4SLinus Torvalds 			lval = (unsigned long)val;
27361da177e4SLinus Torvalds 		}
27371da177e4SLinus Torvalds 		*lvalp = jiffies_to_clock_t(lval);
27381da177e4SLinus Torvalds 	}
27391da177e4SLinus Torvalds 	return 0;
27401da177e4SLinus Torvalds }
27411da177e4SLinus Torvalds 
27421da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
27431da177e4SLinus Torvalds 					    int *valp,
27441da177e4SLinus Torvalds 					    int write, void *data)
27451da177e4SLinus Torvalds {
27461da177e4SLinus Torvalds 	if (write) {
27471da177e4SLinus Torvalds 		*valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
27481da177e4SLinus Torvalds 	} else {
27491da177e4SLinus Torvalds 		int val = *valp;
27501da177e4SLinus Torvalds 		unsigned long lval;
27511da177e4SLinus Torvalds 		if (val < 0) {
27521da177e4SLinus Torvalds 			*negp = -1;
27531da177e4SLinus Torvalds 			lval = (unsigned long)-val;
27541da177e4SLinus Torvalds 		} else {
27551da177e4SLinus Torvalds 			*negp = 0;
27561da177e4SLinus Torvalds 			lval = (unsigned long)val;
27571da177e4SLinus Torvalds 		}
27581da177e4SLinus Torvalds 		*lvalp = jiffies_to_msecs(lval);
27591da177e4SLinus Torvalds 	}
27601da177e4SLinus Torvalds 	return 0;
27611da177e4SLinus Torvalds }
27621da177e4SLinus Torvalds 
27631da177e4SLinus Torvalds /**
27641da177e4SLinus Torvalds  * proc_dointvec_jiffies - read a vector of integers as seconds
27651da177e4SLinus Torvalds  * @table: the sysctl table
27661da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
27671da177e4SLinus Torvalds  * @filp: the file structure
27681da177e4SLinus Torvalds  * @buffer: the user buffer
27691da177e4SLinus Torvalds  * @lenp: the size of the user buffer
27701da177e4SLinus Torvalds  * @ppos: file position
27711da177e4SLinus Torvalds  *
27721da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
27731da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
27741da177e4SLinus Torvalds  * The values read are assumed to be in seconds, and are converted into
27751da177e4SLinus Torvalds  * jiffies.
27761da177e4SLinus Torvalds  *
27771da177e4SLinus Torvalds  * Returns 0 on success.
27781da177e4SLinus Torvalds  */
2779d8217f07SEric W. Biederman int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
27801da177e4SLinus Torvalds 			  void __user *buffer, size_t *lenp, loff_t *ppos)
27811da177e4SLinus Torvalds {
27821da177e4SLinus Torvalds     return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
27831da177e4SLinus Torvalds 		    	    do_proc_dointvec_jiffies_conv,NULL);
27841da177e4SLinus Torvalds }
27851da177e4SLinus Torvalds 
27861da177e4SLinus Torvalds /**
27871da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
27881da177e4SLinus Torvalds  * @table: the sysctl table
27891da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
27901da177e4SLinus Torvalds  * @filp: the file structure
27911da177e4SLinus Torvalds  * @buffer: the user buffer
27921da177e4SLinus Torvalds  * @lenp: the size of the user buffer
27931e5d5331SRandy Dunlap  * @ppos: pointer to the file position
27941da177e4SLinus Torvalds  *
27951da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
27961da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
27971da177e4SLinus Torvalds  * The values read are assumed to be in 1/USER_HZ seconds, and
27981da177e4SLinus Torvalds  * are converted into jiffies.
27991da177e4SLinus Torvalds  *
28001da177e4SLinus Torvalds  * Returns 0 on success.
28011da177e4SLinus Torvalds  */
2802d8217f07SEric W. Biederman int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
28031da177e4SLinus Torvalds 				 void __user *buffer, size_t *lenp, loff_t *ppos)
28041da177e4SLinus Torvalds {
28051da177e4SLinus Torvalds     return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
28061da177e4SLinus Torvalds 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
28071da177e4SLinus Torvalds }
28081da177e4SLinus Torvalds 
28091da177e4SLinus Torvalds /**
28101da177e4SLinus Torvalds  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
28111da177e4SLinus Torvalds  * @table: the sysctl table
28121da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
28131da177e4SLinus Torvalds  * @filp: the file structure
28141da177e4SLinus Torvalds  * @buffer: the user buffer
28151da177e4SLinus Torvalds  * @lenp: the size of the user buffer
281667be2dd1SMartin Waitz  * @ppos: file position
281767be2dd1SMartin Waitz  * @ppos: the current position in the file
28181da177e4SLinus Torvalds  *
28191da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
28201da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
28211da177e4SLinus Torvalds  * The values read are assumed to be in 1/1000 seconds, and
28221da177e4SLinus Torvalds  * are converted into jiffies.
28231da177e4SLinus Torvalds  *
28241da177e4SLinus Torvalds  * Returns 0 on success.
28251da177e4SLinus Torvalds  */
2826d8217f07SEric W. Biederman int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
28271da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
28281da177e4SLinus Torvalds {
28291da177e4SLinus Torvalds 	return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
28301da177e4SLinus Torvalds 				do_proc_dointvec_ms_jiffies_conv, NULL);
28311da177e4SLinus Torvalds }
28321da177e4SLinus Torvalds 
2833d8217f07SEric W. Biederman static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
28349ec52099SCedric Le Goater 			   void __user *buffer, size_t *lenp, loff_t *ppos)
28359ec52099SCedric Le Goater {
28369ec52099SCedric Le Goater 	struct pid *new_pid;
28379ec52099SCedric Le Goater 	pid_t tmp;
28389ec52099SCedric Le Goater 	int r;
28399ec52099SCedric Le Goater 
28406c5f3e7bSPavel Emelyanov 	tmp = pid_vnr(cad_pid);
28419ec52099SCedric Le Goater 
28429ec52099SCedric Le Goater 	r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
28439ec52099SCedric Le Goater 			       lenp, ppos, NULL, NULL);
28449ec52099SCedric Le Goater 	if (r || !write)
28459ec52099SCedric Le Goater 		return r;
28469ec52099SCedric Le Goater 
28479ec52099SCedric Le Goater 	new_pid = find_get_pid(tmp);
28489ec52099SCedric Le Goater 	if (!new_pid)
28499ec52099SCedric Le Goater 		return -ESRCH;
28509ec52099SCedric Le Goater 
28519ec52099SCedric Le Goater 	put_pid(xchg(&cad_pid, new_pid));
28529ec52099SCedric Le Goater 	return 0;
28539ec52099SCedric Le Goater }
28549ec52099SCedric Le Goater 
28551da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */
28561da177e4SLinus Torvalds 
2857d8217f07SEric W. Biederman int proc_dostring(struct ctl_table *table, int write, struct file *filp,
28581da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
28591da177e4SLinus Torvalds {
28601da177e4SLinus Torvalds 	return -ENOSYS;
28611da177e4SLinus Torvalds }
28621da177e4SLinus Torvalds 
2863d8217f07SEric W. Biederman int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
28641da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
28651da177e4SLinus Torvalds {
28661da177e4SLinus Torvalds 	return -ENOSYS;
28671da177e4SLinus Torvalds }
28681da177e4SLinus Torvalds 
2869d8217f07SEric W. Biederman int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
28701da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
28711da177e4SLinus Torvalds {
28721da177e4SLinus Torvalds 	return -ENOSYS;
28731da177e4SLinus Torvalds }
28741da177e4SLinus Torvalds 
2875d8217f07SEric W. Biederman int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
28761da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
28771da177e4SLinus Torvalds {
28781da177e4SLinus Torvalds 	return -ENOSYS;
28791da177e4SLinus Torvalds }
28801da177e4SLinus Torvalds 
2881d8217f07SEric W. Biederman int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
28821da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
28831da177e4SLinus Torvalds {
28841da177e4SLinus Torvalds 	return -ENOSYS;
28851da177e4SLinus Torvalds }
28861da177e4SLinus Torvalds 
2887d8217f07SEric W. Biederman int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
28881da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
28891da177e4SLinus Torvalds {
28901da177e4SLinus Torvalds 	return -ENOSYS;
28911da177e4SLinus Torvalds }
28921da177e4SLinus Torvalds 
2893d8217f07SEric W. Biederman int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
28941da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
28951da177e4SLinus Torvalds {
28961da177e4SLinus Torvalds 	return -ENOSYS;
28971da177e4SLinus Torvalds }
28981da177e4SLinus Torvalds 
2899d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
29001da177e4SLinus Torvalds 				      struct file *filp,
29011da177e4SLinus Torvalds 				      void __user *buffer,
29021da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
29031da177e4SLinus Torvalds {
29041da177e4SLinus Torvalds     return -ENOSYS;
29051da177e4SLinus Torvalds }
29061da177e4SLinus Torvalds 
29071da177e4SLinus Torvalds 
29081da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */
29091da177e4SLinus Torvalds 
29101da177e4SLinus Torvalds 
2911b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL
29121da177e4SLinus Torvalds /*
29131da177e4SLinus Torvalds  * General sysctl support routines
29141da177e4SLinus Torvalds  */
29151da177e4SLinus Torvalds 
291649a0c458SEric W. Biederman /* The generic sysctl data routine (used if no strategy routine supplied) */
2917f221e726SAlexey Dobriyan int sysctl_data(struct ctl_table *table,
291849a0c458SEric W. Biederman 		void __user *oldval, size_t __user *oldlenp,
291949a0c458SEric W. Biederman 		void __user *newval, size_t newlen)
292049a0c458SEric W. Biederman {
292149a0c458SEric W. Biederman 	size_t len;
292249a0c458SEric W. Biederman 
292349a0c458SEric W. Biederman 	/* Get out of I don't have a variable */
292449a0c458SEric W. Biederman 	if (!table->data || !table->maxlen)
292549a0c458SEric W. Biederman 		return -ENOTDIR;
292649a0c458SEric W. Biederman 
292749a0c458SEric W. Biederman 	if (oldval && oldlenp) {
292849a0c458SEric W. Biederman 		if (get_user(len, oldlenp))
292949a0c458SEric W. Biederman 			return -EFAULT;
293049a0c458SEric W. Biederman 		if (len) {
293149a0c458SEric W. Biederman 			if (len > table->maxlen)
293249a0c458SEric W. Biederman 				len = table->maxlen;
293349a0c458SEric W. Biederman 			if (copy_to_user(oldval, table->data, len))
293449a0c458SEric W. Biederman 				return -EFAULT;
293549a0c458SEric W. Biederman 			if (put_user(len, oldlenp))
293649a0c458SEric W. Biederman 				return -EFAULT;
293749a0c458SEric W. Biederman 		}
293849a0c458SEric W. Biederman 	}
293949a0c458SEric W. Biederman 
294049a0c458SEric W. Biederman 	if (newval && newlen) {
294149a0c458SEric W. Biederman 		if (newlen > table->maxlen)
294249a0c458SEric W. Biederman 			newlen = table->maxlen;
294349a0c458SEric W. Biederman 
294449a0c458SEric W. Biederman 		if (copy_from_user(table->data, newval, newlen))
294549a0c458SEric W. Biederman 			return -EFAULT;
294649a0c458SEric W. Biederman 	}
294749a0c458SEric W. Biederman 	return 1;
294849a0c458SEric W. Biederman }
294949a0c458SEric W. Biederman 
29501da177e4SLinus Torvalds /* The generic string strategy routine: */
2951f221e726SAlexey Dobriyan int sysctl_string(struct ctl_table *table,
29521da177e4SLinus Torvalds 		  void __user *oldval, size_t __user *oldlenp,
29531f29bcd7SAlexey Dobriyan 		  void __user *newval, size_t newlen)
29541da177e4SLinus Torvalds {
29551da177e4SLinus Torvalds 	if (!table->data || !table->maxlen)
29561da177e4SLinus Torvalds 		return -ENOTDIR;
29571da177e4SLinus Torvalds 
29581da177e4SLinus Torvalds 	if (oldval && oldlenp) {
2959de9e007dSLinus Torvalds 		size_t bufsize;
2960de9e007dSLinus Torvalds 		if (get_user(bufsize, oldlenp))
29611da177e4SLinus Torvalds 			return -EFAULT;
2962de9e007dSLinus Torvalds 		if (bufsize) {
2963de9e007dSLinus Torvalds 			size_t len = strlen(table->data), copied;
2964de9e007dSLinus Torvalds 
2965de9e007dSLinus Torvalds 			/* This shouldn't trigger for a well-formed sysctl */
2966de9e007dSLinus Torvalds 			if (len > table->maxlen)
29671da177e4SLinus Torvalds 				len = table->maxlen;
2968de9e007dSLinus Torvalds 
2969de9e007dSLinus Torvalds 			/* Copy up to a max of bufsize-1 bytes of the string */
2970de9e007dSLinus Torvalds 			copied = (len >= bufsize) ? bufsize - 1 : len;
2971de9e007dSLinus Torvalds 
2972de9e007dSLinus Torvalds 			if (copy_to_user(oldval, table->data, copied) ||
2973de9e007dSLinus Torvalds 			    put_user(0, (char __user *)(oldval + copied)))
29741da177e4SLinus Torvalds 				return -EFAULT;
29751da177e4SLinus Torvalds 			if (put_user(len, oldlenp))
29761da177e4SLinus Torvalds 				return -EFAULT;
29771da177e4SLinus Torvalds 		}
29781da177e4SLinus Torvalds 	}
29791da177e4SLinus Torvalds 	if (newval && newlen) {
2980de9e007dSLinus Torvalds 		size_t len = newlen;
29811da177e4SLinus Torvalds 		if (len > table->maxlen)
29821da177e4SLinus Torvalds 			len = table->maxlen;
29831da177e4SLinus Torvalds 		if(copy_from_user(table->data, newval, len))
29841da177e4SLinus Torvalds 			return -EFAULT;
29851da177e4SLinus Torvalds 		if (len == table->maxlen)
29861da177e4SLinus Torvalds 			len--;
29871da177e4SLinus Torvalds 		((char *) table->data)[len] = 0;
29881da177e4SLinus Torvalds 	}
298982c9df82SYi Yang 	return 1;
29901da177e4SLinus Torvalds }
29911da177e4SLinus Torvalds 
29921da177e4SLinus Torvalds /*
29931da177e4SLinus Torvalds  * This function makes sure that all of the integers in the vector
29941da177e4SLinus Torvalds  * are between the minimum and maximum values given in the arrays
29951da177e4SLinus Torvalds  * table->extra1 and table->extra2, respectively.
29961da177e4SLinus Torvalds  */
2997f221e726SAlexey Dobriyan int sysctl_intvec(struct ctl_table *table,
29981da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
29991f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
30001da177e4SLinus Torvalds {
30011da177e4SLinus Torvalds 
30021da177e4SLinus Torvalds 	if (newval && newlen) {
30031da177e4SLinus Torvalds 		int __user *vec = (int __user *) newval;
30041da177e4SLinus Torvalds 		int *min = (int *) table->extra1;
30051da177e4SLinus Torvalds 		int *max = (int *) table->extra2;
30061da177e4SLinus Torvalds 		size_t length;
30071da177e4SLinus Torvalds 		int i;
30081da177e4SLinus Torvalds 
30091da177e4SLinus Torvalds 		if (newlen % sizeof(int) != 0)
30101da177e4SLinus Torvalds 			return -EINVAL;
30111da177e4SLinus Torvalds 
30121da177e4SLinus Torvalds 		if (!table->extra1 && !table->extra2)
30131da177e4SLinus Torvalds 			return 0;
30141da177e4SLinus Torvalds 
30151da177e4SLinus Torvalds 		if (newlen > table->maxlen)
30161da177e4SLinus Torvalds 			newlen = table->maxlen;
30171da177e4SLinus Torvalds 		length = newlen / sizeof(int);
30181da177e4SLinus Torvalds 
30191da177e4SLinus Torvalds 		for (i = 0; i < length; i++) {
30201da177e4SLinus Torvalds 			int value;
30211da177e4SLinus Torvalds 			if (get_user(value, vec + i))
30221da177e4SLinus Torvalds 				return -EFAULT;
30231da177e4SLinus Torvalds 			if (min && value < min[i])
30241da177e4SLinus Torvalds 				return -EINVAL;
30251da177e4SLinus Torvalds 			if (max && value > max[i])
30261da177e4SLinus Torvalds 				return -EINVAL;
30271da177e4SLinus Torvalds 		}
30281da177e4SLinus Torvalds 	}
30291da177e4SLinus Torvalds 	return 0;
30301da177e4SLinus Torvalds }
30311da177e4SLinus Torvalds 
30321da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */
3033f221e726SAlexey Dobriyan int sysctl_jiffies(struct ctl_table *table,
30341da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
30351f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
30361da177e4SLinus Torvalds {
30373ee75ac3SAlexey Dobriyan 	if (oldval && oldlenp) {
30381da177e4SLinus Torvalds 		size_t olen;
30393ee75ac3SAlexey Dobriyan 
30401da177e4SLinus Torvalds 		if (get_user(olen, oldlenp))
30411da177e4SLinus Torvalds 			return -EFAULT;
30423ee75ac3SAlexey Dobriyan 		if (olen) {
30433ee75ac3SAlexey Dobriyan 			int val;
30443ee75ac3SAlexey Dobriyan 
30453ee75ac3SAlexey Dobriyan 			if (olen < sizeof(int))
30461da177e4SLinus Torvalds 				return -EINVAL;
30473ee75ac3SAlexey Dobriyan 
30483ee75ac3SAlexey Dobriyan 			val = *(int *)(table->data) / HZ;
30493ee75ac3SAlexey Dobriyan 			if (put_user(val, (int __user *)oldval))
30501da177e4SLinus Torvalds 				return -EFAULT;
30513ee75ac3SAlexey Dobriyan 			if (put_user(sizeof(int), oldlenp))
30523ee75ac3SAlexey Dobriyan 				return -EFAULT;
30533ee75ac3SAlexey Dobriyan 		}
30541da177e4SLinus Torvalds 	}
30551da177e4SLinus Torvalds 	if (newval && newlen) {
30561da177e4SLinus Torvalds 		int new;
30571da177e4SLinus Torvalds 		if (newlen != sizeof(int))
30581da177e4SLinus Torvalds 			return -EINVAL;
30591da177e4SLinus Torvalds 		if (get_user(new, (int __user *)newval))
30601da177e4SLinus Torvalds 			return -EFAULT;
30611da177e4SLinus Torvalds 		*(int *)(table->data) = new*HZ;
30621da177e4SLinus Torvalds 	}
30631da177e4SLinus Torvalds 	return 1;
30641da177e4SLinus Torvalds }
30651da177e4SLinus Torvalds 
30661da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */
3067f221e726SAlexey Dobriyan int sysctl_ms_jiffies(struct ctl_table *table,
30681da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
30691f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
30701da177e4SLinus Torvalds {
30713ee75ac3SAlexey Dobriyan 	if (oldval && oldlenp) {
30721da177e4SLinus Torvalds 		size_t olen;
30733ee75ac3SAlexey Dobriyan 
30741da177e4SLinus Torvalds 		if (get_user(olen, oldlenp))
30751da177e4SLinus Torvalds 			return -EFAULT;
30763ee75ac3SAlexey Dobriyan 		if (olen) {
30773ee75ac3SAlexey Dobriyan 			int val;
30783ee75ac3SAlexey Dobriyan 
30793ee75ac3SAlexey Dobriyan 			if (olen < sizeof(int))
30801da177e4SLinus Torvalds 				return -EINVAL;
30813ee75ac3SAlexey Dobriyan 
30823ee75ac3SAlexey Dobriyan 			val = jiffies_to_msecs(*(int *)(table->data));
30833ee75ac3SAlexey Dobriyan 			if (put_user(val, (int __user *)oldval))
30841da177e4SLinus Torvalds 				return -EFAULT;
30853ee75ac3SAlexey Dobriyan 			if (put_user(sizeof(int), oldlenp))
30863ee75ac3SAlexey Dobriyan 				return -EFAULT;
30873ee75ac3SAlexey Dobriyan 		}
30881da177e4SLinus Torvalds 	}
30891da177e4SLinus Torvalds 	if (newval && newlen) {
30901da177e4SLinus Torvalds 		int new;
30911da177e4SLinus Torvalds 		if (newlen != sizeof(int))
30921da177e4SLinus Torvalds 			return -EINVAL;
30931da177e4SLinus Torvalds 		if (get_user(new, (int __user *)newval))
30941da177e4SLinus Torvalds 			return -EFAULT;
30951da177e4SLinus Torvalds 		*(int *)(table->data) = msecs_to_jiffies(new);
30961da177e4SLinus Torvalds 	}
30971da177e4SLinus Torvalds 	return 1;
30981da177e4SLinus Torvalds }
30991da177e4SLinus Torvalds 
3100c4b8b769SEric W. Biederman 
3101c4b8b769SEric W. Biederman 
3102b89a8171SEric W. Biederman #else /* CONFIG_SYSCTL_SYSCALL */
31031da177e4SLinus Torvalds 
31041da177e4SLinus Torvalds 
31051e7bfb21SHeiko Carstens SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
31061da177e4SLinus Torvalds {
31070e009be8SEric W. Biederman 	struct __sysctl_args tmp;
31087058cb02SEric W. Biederman 	int error;
31090e009be8SEric W. Biederman 
31100e009be8SEric W. Biederman 	if (copy_from_user(&tmp, args, sizeof(tmp)))
31110e009be8SEric W. Biederman 		return -EFAULT;
31120e009be8SEric W. Biederman 
31137058cb02SEric W. Biederman 	error = deprecated_sysctl_warning(&tmp);
3114b89a8171SEric W. Biederman 
31157058cb02SEric W. Biederman 	/* If no error reading the parameters then just -ENOSYS ... */
31167058cb02SEric W. Biederman 	if (!error)
31177058cb02SEric W. Biederman 		error = -ENOSYS;
31187058cb02SEric W. Biederman 
31197058cb02SEric W. Biederman 	return error;
31201da177e4SLinus Torvalds }
31211da177e4SLinus Torvalds 
3122f221e726SAlexey Dobriyan int sysctl_data(struct ctl_table *table,
312349a0c458SEric W. Biederman 		  void __user *oldval, size_t __user *oldlenp,
312449a0c458SEric W. Biederman 		  void __user *newval, size_t newlen)
312549a0c458SEric W. Biederman {
312649a0c458SEric W. Biederman 	return -ENOSYS;
312749a0c458SEric W. Biederman }
312849a0c458SEric W. Biederman 
3129f221e726SAlexey Dobriyan int sysctl_string(struct ctl_table *table,
31301da177e4SLinus Torvalds 		  void __user *oldval, size_t __user *oldlenp,
31311f29bcd7SAlexey Dobriyan 		  void __user *newval, size_t newlen)
31321da177e4SLinus Torvalds {
31331da177e4SLinus Torvalds 	return -ENOSYS;
31341da177e4SLinus Torvalds }
31351da177e4SLinus Torvalds 
3136f221e726SAlexey Dobriyan int sysctl_intvec(struct ctl_table *table,
31371da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
31381f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
31391da177e4SLinus Torvalds {
31401da177e4SLinus Torvalds 	return -ENOSYS;
31411da177e4SLinus Torvalds }
31421da177e4SLinus Torvalds 
3143f221e726SAlexey Dobriyan int sysctl_jiffies(struct ctl_table *table,
31441da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
31451f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
31461da177e4SLinus Torvalds {
31471da177e4SLinus Torvalds 	return -ENOSYS;
31481da177e4SLinus Torvalds }
31491da177e4SLinus Torvalds 
3150f221e726SAlexey Dobriyan int sysctl_ms_jiffies(struct ctl_table *table,
31511da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
31521f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
31531da177e4SLinus Torvalds {
31541da177e4SLinus Torvalds 	return -ENOSYS;
31551da177e4SLinus Torvalds }
31561da177e4SLinus Torvalds 
3157b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */
31581da177e4SLinus Torvalds 
31597058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args)
31607058cb02SEric W. Biederman {
31617058cb02SEric W. Biederman 	static int msg_count;
31627058cb02SEric W. Biederman 	int name[CTL_MAXNAME];
31637058cb02SEric W. Biederman 	int i;
31647058cb02SEric W. Biederman 
31656fc48af8STetsuo Handa 	/* Check args->nlen. */
31666fc48af8STetsuo Handa 	if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
31676fc48af8STetsuo Handa 		return -ENOTDIR;
31686fc48af8STetsuo Handa 
31697058cb02SEric W. Biederman 	/* Read in the sysctl name for better debug message logging */
31707058cb02SEric W. Biederman 	for (i = 0; i < args->nlen; i++)
31717058cb02SEric W. Biederman 		if (get_user(name[i], args->name + i))
31727058cb02SEric W. Biederman 			return -EFAULT;
31737058cb02SEric W. Biederman 
31747058cb02SEric W. Biederman 	/* Ignore accesses to kernel.version */
31757058cb02SEric W. Biederman 	if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
31767058cb02SEric W. Biederman 		return 0;
31777058cb02SEric W. Biederman 
31787058cb02SEric W. Biederman 	if (msg_count < 5) {
31797058cb02SEric W. Biederman 		msg_count++;
31807058cb02SEric W. Biederman 		printk(KERN_INFO
31817058cb02SEric W. Biederman 			"warning: process `%s' used the deprecated sysctl "
31827058cb02SEric W. Biederman 			"system call with ", current->comm);
31837058cb02SEric W. Biederman 		for (i = 0; i < args->nlen; i++)
31847058cb02SEric W. Biederman 			printk("%d.", name[i]);
31857058cb02SEric W. Biederman 		printk("\n");
31867058cb02SEric W. Biederman 	}
31877058cb02SEric W. Biederman 	return 0;
31887058cb02SEric W. Biederman }
31897058cb02SEric W. Biederman 
31901da177e4SLinus Torvalds /*
31911da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
31921da177e4SLinus Torvalds  * exception granted :-)
31931da177e4SLinus Torvalds  */
31941da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
31951da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
31961da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
31971da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
31981da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
31991da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
32001da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
32011da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
32021da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table);
320329e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths);
32041da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_intvec);
32051da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_jiffies);
32061da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_ms_jiffies);
32071da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_string);
320849a0c458SEric W. Biederman EXPORT_SYMBOL(sysctl_data);
32091da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table);
3210