xref: /openbmc/linux/kernel/sysctl.c (revision 3fff4c42bd0a89869a0eb1e7874cc06ffa4aa0f5)
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>
40*3fff4c42SIngo Molnar #include <linux/ratelimit.h>
411da177e4SLinus Torvalds #include <linux/hugetlb.h>
421da177e4SLinus Torvalds #include <linux/initrd.h>
430b77f5bfSDavid Howells #include <linux/key.h>
441da177e4SLinus Torvalds #include <linux/times.h>
451da177e4SLinus Torvalds #include <linux/limits.h>
461da177e4SLinus Torvalds #include <linux/dcache.h>
471da177e4SLinus Torvalds #include <linux/syscalls.h>
48c748e134SAdrian Bunk #include <linux/vmstat.h>
49c255d844SPavel Machek #include <linux/nfs_fs.h>
50c255d844SPavel Machek #include <linux/acpi.h>
5110a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h>
52b0fc494fSSteven Rostedt #include <linux/ftrace.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 */
95cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
965e605b64SJens Axboe extern int blk_iopoll_enabled;
97cb684b5bSJens Axboe #endif
981da177e4SLinus Torvalds 
99c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and  maximum */
100195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP
101c4f3b63fSRavikiran G Thirumalai static int sixty = 60;
1029383d967SDimitri Sivanich static int neg_one = -1;
103c4f3b63fSRavikiran G Thirumalai #endif
104c4f3b63fSRavikiran G Thirumalai 
105c4f3b63fSRavikiran G Thirumalai static int zero;
106cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1;
107cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2;
108fc3501d4SSven Wegener static unsigned long one_ul = 1;
109c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100;
110c4f3b63fSRavikiran G Thirumalai 
1119e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
1129e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1139e4a5bdaSAndrea Righi 
1141da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1151da177e4SLinus Torvalds static int maxolduid = 65535;
1161da177e4SLinus Torvalds static int minolduid;
1178ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8;
1181da177e4SLinus Torvalds 
1191da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
1201da177e4SLinus Torvalds 
121a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
1221da177e4SLinus Torvalds extern char modprobe_path[];
1233d43321bSKees Cook extern int modules_disabled;
1241da177e4SLinus Torvalds #endif
1251da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
1261da177e4SLinus Torvalds extern int sg_big_buff;
1271da177e4SLinus Torvalds #endif
1281da177e4SLinus Torvalds 
12972c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
13017f04fbbSDavid S. Miller #include <asm/system.h>
1311da177e4SLinus Torvalds #endif
1321da177e4SLinus Torvalds 
1330871420fSDavid S. Miller #ifdef CONFIG_SPARC64
1340871420fSDavid S. Miller extern int sysctl_tsb_ratio;
1350871420fSDavid S. Miller #endif
1360871420fSDavid S. Miller 
1371da177e4SLinus Torvalds #ifdef __hppa__
1381da177e4SLinus Torvalds extern int pwrsw_enabled;
1391da177e4SLinus Torvalds extern int unaligned_enabled;
1401da177e4SLinus Torvalds #endif
1411da177e4SLinus Torvalds 
142347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
1431da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
1441da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings;
1451da177e4SLinus Torvalds #endif
1461da177e4SLinus Torvalds extern int sysctl_userprocess_debug;
147951f22d5SMartin Schwidefsky extern int spin_retry;
1481da177e4SLinus Torvalds #endif
1491da177e4SLinus Torvalds 
1501da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
1511da177e4SLinus Torvalds extern int acct_parm[];
1521da177e4SLinus Torvalds #endif
1531da177e4SLinus Torvalds 
154d2b176edSJes Sorensen #ifdef CONFIG_IA64
155d2b176edSJes Sorensen extern int no_unaligned_warning;
15688fc241fSDoug Chapman extern int unaligned_dump_stack;
157d2b176edSJes Sorensen #endif
158d2b176edSJes Sorensen 
159*3fff4c42SIngo Molnar extern struct ratelimit_state printk_ratelimit_state;
160*3fff4c42SIngo Molnar 
16123f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
16223f78d4aSIngo Molnar extern int max_lock_depth;
16323f78d4aSIngo Molnar #endif
16423f78d4aSIngo Molnar 
165d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
166d8217f07SEric W. Biederman static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
1679ec52099SCedric Le Goater 		  void __user *buffer, size_t *lenp, loff_t *ppos);
16825ddbb18SAndi Kleen static int proc_taint(struct ctl_table *table, int write, struct file *filp,
16934f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos);
170d6f8ff73SRandy Dunlap #endif
1719ec52099SCedric Le Goater 
172d8217f07SEric W. Biederman static struct ctl_table root_table[];
173e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root;
174e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = {
175b380b0d4SAl Viro 	.count = 1,
176e51b6ba0SEric W. Biederman 	.ctl_table = root_table,
17773455092SAl Viro 	.ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
178e51b6ba0SEric W. Biederman 	.root = &sysctl_table_root,
17973455092SAl Viro 	.set = &sysctl_table_root.default_set,
180e51b6ba0SEric W. Biederman };
181e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = {
182e51b6ba0SEric W. Biederman 	.root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
18373455092SAl Viro 	.default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
184e51b6ba0SEric W. Biederman };
1851da177e4SLinus Torvalds 
186d8217f07SEric W. Biederman static struct ctl_table kern_table[];
187d8217f07SEric W. Biederman static struct ctl_table vm_table[];
188d8217f07SEric W. Biederman static struct ctl_table fs_table[];
189d8217f07SEric W. Biederman static struct ctl_table debug_table[];
190d8217f07SEric W. Biederman static struct ctl_table dev_table[];
191d8217f07SEric W. Biederman extern struct ctl_table random_table[];
1922d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
193d8217f07SEric W. Biederman extern struct ctl_table inotify_table[];
1940399cb08SRobert Love #endif
1957ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
1967ef9964eSDavide Libenzi extern struct ctl_table epoll_table[];
1977ef9964eSDavide Libenzi #endif
1981da177e4SLinus Torvalds 
1991da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
2001da177e4SLinus Torvalds int sysctl_legacy_va_layout;
2011da177e4SLinus Torvalds #endif
2021da177e4SLinus Torvalds 
203f20786ffSPeter Zijlstra extern int prove_locking;
204f20786ffSPeter Zijlstra extern int lock_stat;
2059bc9a6bdSEric W. Biederman 
2061da177e4SLinus Torvalds /* The default sysctl tables: */
2071da177e4SLinus Torvalds 
208d8217f07SEric W. Biederman static struct ctl_table root_table[] = {
2091da177e4SLinus Torvalds 	{
2101da177e4SLinus Torvalds 		.ctl_name	= CTL_KERN,
2111da177e4SLinus Torvalds 		.procname	= "kernel",
2121da177e4SLinus Torvalds 		.mode		= 0555,
2131da177e4SLinus Torvalds 		.child		= kern_table,
2141da177e4SLinus Torvalds 	},
2151da177e4SLinus Torvalds 	{
2161da177e4SLinus Torvalds 		.ctl_name	= CTL_VM,
2171da177e4SLinus Torvalds 		.procname	= "vm",
2181da177e4SLinus Torvalds 		.mode		= 0555,
2191da177e4SLinus Torvalds 		.child		= vm_table,
2201da177e4SLinus Torvalds 	},
2211da177e4SLinus Torvalds 	{
2221da177e4SLinus Torvalds 		.ctl_name	= CTL_FS,
2231da177e4SLinus Torvalds 		.procname	= "fs",
2241da177e4SLinus Torvalds 		.mode		= 0555,
2251da177e4SLinus Torvalds 		.child		= fs_table,
2261da177e4SLinus Torvalds 	},
2271da177e4SLinus Torvalds 	{
2281da177e4SLinus Torvalds 		.ctl_name	= CTL_DEBUG,
2291da177e4SLinus Torvalds 		.procname	= "debug",
2301da177e4SLinus Torvalds 		.mode		= 0555,
2311da177e4SLinus Torvalds 		.child		= debug_table,
2321da177e4SLinus Torvalds 	},
2331da177e4SLinus Torvalds 	{
2341da177e4SLinus Torvalds 		.ctl_name	= CTL_DEV,
2351da177e4SLinus Torvalds 		.procname	= "dev",
2361da177e4SLinus Torvalds 		.mode		= 0555,
2371da177e4SLinus Torvalds 		.child		= dev_table,
2381da177e4SLinus Torvalds 	},
2392be7fe07SAndrew Morton /*
2402be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
2412be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
2422be7fe07SAndrew Morton  */
2431da177e4SLinus Torvalds 	{ .ctl_name = 0 }
2441da177e4SLinus Torvalds };
2451da177e4SLinus Torvalds 
24677e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
24773c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000;		/* 100 usecs */
24873c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
24973c4efd2SEric Dumazet static int min_wakeup_granularity_ns;			/* 0 usecs */
25073c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
25177e54a1fSIngo Molnar #endif
25277e54a1fSIngo Molnar 
253d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
2542bba22c5SMike Galbraith 	{
2552bba22c5SMike Galbraith 		.ctl_name	= CTL_UNNUMBERED,
2562bba22c5SMike Galbraith 		.procname	= "sched_child_runs_first",
2572bba22c5SMike Galbraith 		.data		= &sysctl_sched_child_runs_first,
2582bba22c5SMike Galbraith 		.maxlen		= sizeof(unsigned int),
2592bba22c5SMike Galbraith 		.mode		= 0644,
2602bba22c5SMike Galbraith 		.proc_handler	= &proc_dointvec,
2612bba22c5SMike Galbraith 	},
26277e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
26377e54a1fSIngo Molnar 	{
26477e54a1fSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
265b2be5e96SPeter Zijlstra 		.procname	= "sched_min_granularity_ns",
266b2be5e96SPeter Zijlstra 		.data		= &sysctl_sched_min_granularity,
26777e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
26877e54a1fSIngo Molnar 		.mode		= 0644,
269b2be5e96SPeter Zijlstra 		.proc_handler	= &sched_nr_latency_handler,
270b2be5e96SPeter Zijlstra 		.strategy	= &sysctl_intvec,
271b2be5e96SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
272b2be5e96SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
27377e54a1fSIngo Molnar 	},
27477e54a1fSIngo Molnar 	{
27577e54a1fSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
27621805085SPeter Zijlstra 		.procname	= "sched_latency_ns",
27721805085SPeter Zijlstra 		.data		= &sysctl_sched_latency,
27821805085SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
27921805085SPeter Zijlstra 		.mode		= 0644,
280b2be5e96SPeter Zijlstra 		.proc_handler	= &sched_nr_latency_handler,
28121805085SPeter Zijlstra 		.strategy	= &sysctl_intvec,
28221805085SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
28321805085SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
28421805085SPeter Zijlstra 	},
28521805085SPeter Zijlstra 	{
28621805085SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
28777e54a1fSIngo Molnar 		.procname	= "sched_wakeup_granularity_ns",
28877e54a1fSIngo Molnar 		.data		= &sysctl_sched_wakeup_granularity,
28977e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
29077e54a1fSIngo Molnar 		.mode		= 0644,
29177e54a1fSIngo Molnar 		.proc_handler	= &proc_dointvec_minmax,
29277e54a1fSIngo Molnar 		.strategy	= &sysctl_intvec,
29377e54a1fSIngo Molnar 		.extra1		= &min_wakeup_granularity_ns,
29477e54a1fSIngo Molnar 		.extra2		= &max_wakeup_granularity_ns,
29577e54a1fSIngo Molnar 	},
29677e54a1fSIngo Molnar 	{
29777e54a1fSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
2982398f2c6SPeter Zijlstra 		.procname	= "sched_shares_ratelimit",
2992398f2c6SPeter Zijlstra 		.data		= &sysctl_sched_shares_ratelimit,
3002398f2c6SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3012398f2c6SPeter Zijlstra 		.mode		= 0644,
3022398f2c6SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
3032398f2c6SPeter Zijlstra 	},
3042398f2c6SPeter Zijlstra 	{
3052398f2c6SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
306ffda12a1SPeter Zijlstra 		.procname	= "sched_shares_thresh",
307ffda12a1SPeter Zijlstra 		.data		= &sysctl_sched_shares_thresh,
308ffda12a1SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
309ffda12a1SPeter Zijlstra 		.mode		= 0644,
310ffda12a1SPeter Zijlstra 		.proc_handler	= &proc_dointvec_minmax,
311ffda12a1SPeter Zijlstra 		.strategy	= &sysctl_intvec,
312ffda12a1SPeter Zijlstra 		.extra1		= &zero,
313ffda12a1SPeter Zijlstra 	},
314ffda12a1SPeter Zijlstra 	{
315ffda12a1SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
3161fc84aaaSPeter Zijlstra 		.procname	= "sched_features",
3171fc84aaaSPeter Zijlstra 		.data		= &sysctl_sched_features,
3181fc84aaaSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3191fc84aaaSPeter Zijlstra 		.mode		= 0644,
3201fc84aaaSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
3211fc84aaaSPeter Zijlstra 	},
322da84d961SIngo Molnar 	{
323da84d961SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
324da84d961SIngo Molnar 		.procname	= "sched_migration_cost",
325da84d961SIngo Molnar 		.data		= &sysctl_sched_migration_cost,
326da84d961SIngo Molnar 		.maxlen		= sizeof(unsigned int),
327da84d961SIngo Molnar 		.mode		= 0644,
328da84d961SIngo Molnar 		.proc_handler	= &proc_dointvec,
329da84d961SIngo Molnar 	},
330b82d9fddSPeter Zijlstra 	{
331b82d9fddSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
332b82d9fddSPeter Zijlstra 		.procname	= "sched_nr_migrate",
333b82d9fddSPeter Zijlstra 		.data		= &sysctl_sched_nr_migrate,
334b82d9fddSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
335fa85ae24SPeter Zijlstra 		.mode		= 0644,
336fa85ae24SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
337fa85ae24SPeter Zijlstra 	},
338cd1bb94bSArun R Bharadwaj 	{
339cd1bb94bSArun R Bharadwaj 		.ctl_name	= CTL_UNNUMBERED,
340e9e9250bSPeter Zijlstra 		.procname	= "sched_time_avg",
341e9e9250bSPeter Zijlstra 		.data		= &sysctl_sched_time_avg,
342e9e9250bSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
343e9e9250bSPeter Zijlstra 		.mode		= 0644,
344e9e9250bSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
345e9e9250bSPeter Zijlstra 	},
346e9e9250bSPeter Zijlstra 	{
347e9e9250bSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
348cd1bb94bSArun R Bharadwaj 		.procname	= "timer_migration",
349cd1bb94bSArun R Bharadwaj 		.data		= &sysctl_timer_migration,
350cd1bb94bSArun R Bharadwaj 		.maxlen		= sizeof(unsigned int),
351cd1bb94bSArun R Bharadwaj 		.mode		= 0644,
352bfdb4d9fSArun R Bharadwaj 		.proc_handler	= &proc_dointvec_minmax,
353bfdb4d9fSArun R Bharadwaj 		.strategy	= &sysctl_intvec,
354bfdb4d9fSArun R Bharadwaj 		.extra1		= &zero,
355bfdb4d9fSArun R Bharadwaj 		.extra2		= &one,
356cd1bb94bSArun R Bharadwaj 	},
3571fc84aaaSPeter Zijlstra #endif
3581799e35dSIngo Molnar 	{
3591799e35dSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
3609f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
3619f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
3629f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3639f0c1e56SPeter Zijlstra 		.mode		= 0644,
364d0b27fa7SPeter Zijlstra 		.proc_handler	= &sched_rt_handler,
3659f0c1e56SPeter Zijlstra 	},
3669f0c1e56SPeter Zijlstra 	{
3679f0c1e56SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
3689f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
3699f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
3709f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
3719f0c1e56SPeter Zijlstra 		.mode		= 0644,
372d0b27fa7SPeter Zijlstra 		.proc_handler	= &sched_rt_handler,
3739f0c1e56SPeter Zijlstra 	},
3749f0c1e56SPeter Zijlstra 	{
3759f0c1e56SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
3761799e35dSIngo Molnar 		.procname	= "sched_compat_yield",
3771799e35dSIngo Molnar 		.data		= &sysctl_sched_compat_yield,
3781799e35dSIngo Molnar 		.maxlen		= sizeof(unsigned int),
3791799e35dSIngo Molnar 		.mode		= 0644,
3801799e35dSIngo Molnar 		.proc_handler	= &proc_dointvec,
3811799e35dSIngo Molnar 	},
382f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
383f20786ffSPeter Zijlstra 	{
384f20786ffSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
385f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
386f20786ffSPeter Zijlstra 		.data		= &prove_locking,
387f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
388f20786ffSPeter Zijlstra 		.mode		= 0644,
389f20786ffSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
390f20786ffSPeter Zijlstra 	},
391f20786ffSPeter Zijlstra #endif
392f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
393f20786ffSPeter Zijlstra 	{
394f20786ffSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
395f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
396f20786ffSPeter Zijlstra 		.data		= &lock_stat,
397f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
398f20786ffSPeter Zijlstra 		.mode		= 0644,
399f20786ffSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
400f20786ffSPeter Zijlstra 	},
401f20786ffSPeter Zijlstra #endif
40277e54a1fSIngo Molnar 	{
4031da177e4SLinus Torvalds 		.ctl_name	= KERN_PANIC,
4041da177e4SLinus Torvalds 		.procname	= "panic",
4051da177e4SLinus Torvalds 		.data		= &panic_timeout,
4061da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4071da177e4SLinus Torvalds 		.mode		= 0644,
4081da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4091da177e4SLinus Torvalds 	},
4101da177e4SLinus Torvalds 	{
4111da177e4SLinus Torvalds 		.ctl_name	= KERN_CORE_USES_PID,
4121da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
4131da177e4SLinus Torvalds 		.data		= &core_uses_pid,
4141da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4151da177e4SLinus Torvalds 		.mode		= 0644,
4161da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4171da177e4SLinus Torvalds 	},
4181da177e4SLinus Torvalds 	{
4191da177e4SLinus Torvalds 		.ctl_name	= KERN_CORE_PATTERN,
4201da177e4SLinus Torvalds 		.procname	= "core_pattern",
4211da177e4SLinus Torvalds 		.data		= core_pattern,
42271ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
4231da177e4SLinus Torvalds 		.mode		= 0644,
4241da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
4251da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
4261da177e4SLinus Torvalds 	},
42734f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
4281da177e4SLinus Torvalds 	{
4291da177e4SLinus Torvalds 		.procname	= "tainted",
43025ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
43134f5a398STheodore Ts'o 		.mode		= 0644,
43225ddbb18SAndi Kleen 		.proc_handler	= &proc_taint,
4331da177e4SLinus Torvalds 	},
43434f5a398STheodore Ts'o #endif
4359745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
4369745512cSArjan van de Ven 	{
4379745512cSArjan van de Ven 		.procname	= "latencytop",
4389745512cSArjan van de Ven 		.data		= &latencytop_enabled,
4399745512cSArjan van de Ven 		.maxlen		= sizeof(int),
4409745512cSArjan van de Ven 		.mode		= 0644,
4419745512cSArjan van de Ven 		.proc_handler	= &proc_dointvec,
4429745512cSArjan van de Ven 	},
4439745512cSArjan van de Ven #endif
4441da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
4451da177e4SLinus Torvalds 	{
4461da177e4SLinus Torvalds 		.ctl_name	= KERN_REALROOTDEV,
4471da177e4SLinus Torvalds 		.procname	= "real-root-dev",
4481da177e4SLinus Torvalds 		.data		= &real_root_dev,
4491da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4501da177e4SLinus Torvalds 		.mode		= 0644,
4511da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4521da177e4SLinus Torvalds 	},
4531da177e4SLinus Torvalds #endif
45445807a1dSIngo Molnar 	{
45545807a1dSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
45645807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
45745807a1dSIngo Molnar 		.data		= &print_fatal_signals,
45845807a1dSIngo Molnar 		.maxlen		= sizeof(int),
45945807a1dSIngo Molnar 		.mode		= 0644,
46045807a1dSIngo Molnar 		.proc_handler	= &proc_dointvec,
46145807a1dSIngo Molnar 	},
46272c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
4631da177e4SLinus Torvalds 	{
4641da177e4SLinus Torvalds 		.ctl_name	= KERN_SPARC_REBOOT,
4651da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
4661da177e4SLinus Torvalds 		.data		= reboot_command,
4671da177e4SLinus Torvalds 		.maxlen		= 256,
4681da177e4SLinus Torvalds 		.mode		= 0644,
4691da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
4701da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
4711da177e4SLinus Torvalds 	},
4721da177e4SLinus Torvalds 	{
4731da177e4SLinus Torvalds 		.ctl_name	= KERN_SPARC_STOP_A,
4741da177e4SLinus Torvalds 		.procname	= "stop-a",
4751da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
4761da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4771da177e4SLinus Torvalds 		.mode		= 0644,
4781da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4791da177e4SLinus Torvalds 	},
4801da177e4SLinus Torvalds 	{
4811da177e4SLinus Torvalds 		.ctl_name	= KERN_SPARC_SCONS_PWROFF,
4821da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
4831da177e4SLinus Torvalds 		.data		= &scons_pwroff,
4841da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4851da177e4SLinus Torvalds 		.mode		= 0644,
4861da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4871da177e4SLinus Torvalds 	},
4881da177e4SLinus Torvalds #endif
4890871420fSDavid S. Miller #ifdef CONFIG_SPARC64
4900871420fSDavid S. Miller 	{
4910871420fSDavid S. Miller 		.ctl_name	= CTL_UNNUMBERED,
4920871420fSDavid S. Miller 		.procname	= "tsb-ratio",
4930871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
4940871420fSDavid S. Miller 		.maxlen		= sizeof (int),
4950871420fSDavid S. Miller 		.mode		= 0644,
4960871420fSDavid S. Miller 		.proc_handler	= &proc_dointvec,
4970871420fSDavid S. Miller 	},
4980871420fSDavid S. Miller #endif
4991da177e4SLinus Torvalds #ifdef __hppa__
5001da177e4SLinus Torvalds 	{
5011da177e4SLinus Torvalds 		.ctl_name	= KERN_HPPA_PWRSW,
5021da177e4SLinus Torvalds 		.procname	= "soft-power",
5031da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
5041da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5051da177e4SLinus Torvalds 	 	.mode		= 0644,
5061da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5071da177e4SLinus Torvalds 	},
5081da177e4SLinus Torvalds 	{
5091da177e4SLinus Torvalds 		.ctl_name	= KERN_HPPA_UNALIGNED,
5101da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
5111da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
5121da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5131da177e4SLinus Torvalds 		.mode		= 0644,
5141da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5151da177e4SLinus Torvalds 	},
5161da177e4SLinus Torvalds #endif
5171da177e4SLinus Torvalds 	{
5181da177e4SLinus Torvalds 		.ctl_name	= KERN_CTLALTDEL,
5191da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
5201da177e4SLinus Torvalds 		.data		= &C_A_D,
5211da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5221da177e4SLinus Torvalds 		.mode		= 0644,
5231da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5241da177e4SLinus Torvalds 	},
525606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
526b0fc494fSSteven Rostedt 	{
527b0fc494fSSteven Rostedt 		.ctl_name	= CTL_UNNUMBERED,
528b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
529b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
530b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
531b0fc494fSSteven Rostedt 		.mode		= 0644,
532b0fc494fSSteven Rostedt 		.proc_handler	= &ftrace_enable_sysctl,
533b0fc494fSSteven Rostedt 	},
534b0fc494fSSteven Rostedt #endif
535f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
536f38f1d2aSSteven Rostedt 	{
537f38f1d2aSSteven Rostedt 		.ctl_name	= CTL_UNNUMBERED,
538f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
539f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
540f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
541f38f1d2aSSteven Rostedt 		.mode		= 0644,
542f38f1d2aSSteven Rostedt 		.proc_handler	= &stack_trace_sysctl,
543f38f1d2aSSteven Rostedt 	},
544f38f1d2aSSteven Rostedt #endif
545944ac425SSteven Rostedt #ifdef CONFIG_TRACING
546944ac425SSteven Rostedt 	{
547944ac425SSteven Rostedt 		.ctl_name	= CTL_UNNUMBERED,
5483299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
549944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
550944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
551944ac425SSteven Rostedt 		.mode		= 0644,
552944ac425SSteven Rostedt 		.proc_handler	= &proc_dointvec,
553944ac425SSteven Rostedt 	},
554944ac425SSteven Rostedt #endif
555a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
5561da177e4SLinus Torvalds 	{
5571da177e4SLinus Torvalds 		.ctl_name	= KERN_MODPROBE,
5581da177e4SLinus Torvalds 		.procname	= "modprobe",
5591da177e4SLinus Torvalds 		.data		= &modprobe_path,
5601da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
5611da177e4SLinus Torvalds 		.mode		= 0644,
5621da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
5631da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
5641da177e4SLinus Torvalds 	},
5653d43321bSKees Cook 	{
5663d43321bSKees Cook 		.ctl_name	= CTL_UNNUMBERED,
5673d43321bSKees Cook 		.procname	= "modules_disabled",
5683d43321bSKees Cook 		.data		= &modules_disabled,
5693d43321bSKees Cook 		.maxlen		= sizeof(int),
5703d43321bSKees Cook 		.mode		= 0644,
5713d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
5723d43321bSKees Cook 		.proc_handler	= &proc_dointvec_minmax,
5733d43321bSKees Cook 		.extra1		= &one,
5743d43321bSKees Cook 		.extra2		= &one,
5753d43321bSKees Cook 	},
5761da177e4SLinus Torvalds #endif
57757ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
5781da177e4SLinus Torvalds 	{
5791da177e4SLinus Torvalds 		.ctl_name	= KERN_HOTPLUG,
5801da177e4SLinus Torvalds 		.procname	= "hotplug",
581312c004dSKay Sievers 		.data		= &uevent_helper,
582312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
5831da177e4SLinus Torvalds 		.mode		= 0644,
5841da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
5851da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
5861da177e4SLinus Torvalds 	},
5871da177e4SLinus Torvalds #endif
5881da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
5891da177e4SLinus Torvalds 	{
5901da177e4SLinus Torvalds 		.ctl_name	= KERN_SG_BIG_BUFF,
5911da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
5921da177e4SLinus Torvalds 		.data		= &sg_big_buff,
5931da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5941da177e4SLinus Torvalds 		.mode		= 0444,
5951da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5961da177e4SLinus Torvalds 	},
5971da177e4SLinus Torvalds #endif
5981da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
5991da177e4SLinus Torvalds 	{
6001da177e4SLinus Torvalds 		.ctl_name	= KERN_ACCT,
6011da177e4SLinus Torvalds 		.procname	= "acct",
6021da177e4SLinus Torvalds 		.data		= &acct_parm,
6031da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
6041da177e4SLinus Torvalds 		.mode		= 0644,
6051da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6061da177e4SLinus Torvalds 	},
6071da177e4SLinus Torvalds #endif
6081da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
6091da177e4SLinus Torvalds 	{
6101da177e4SLinus Torvalds 		.ctl_name	= KERN_SYSRQ,
6111da177e4SLinus Torvalds 		.procname	= "sysrq",
6125d6f647fSIngo Molnar 		.data		= &__sysrq_enabled,
6131da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6141da177e4SLinus Torvalds 		.mode		= 0644,
6151da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6161da177e4SLinus Torvalds 	},
6171da177e4SLinus Torvalds #endif
618d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
6191da177e4SLinus Torvalds 	{
6201da177e4SLinus Torvalds 		.procname	= "cad_pid",
6219ec52099SCedric Le Goater 		.data		= NULL,
6221da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6231da177e4SLinus Torvalds 		.mode		= 0600,
6249ec52099SCedric Le Goater 		.proc_handler	= &proc_do_cad_pid,
6251da177e4SLinus Torvalds 	},
626d6f8ff73SRandy Dunlap #endif
6271da177e4SLinus Torvalds 	{
6281da177e4SLinus Torvalds 		.ctl_name	= KERN_MAX_THREADS,
6291da177e4SLinus Torvalds 		.procname	= "threads-max",
6301da177e4SLinus Torvalds 		.data		= &max_threads,
6311da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6321da177e4SLinus Torvalds 		.mode		= 0644,
6331da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6341da177e4SLinus Torvalds 	},
6351da177e4SLinus Torvalds 	{
6361da177e4SLinus Torvalds 		.ctl_name	= KERN_RANDOM,
6371da177e4SLinus Torvalds 		.procname	= "random",
6381da177e4SLinus Torvalds 		.mode		= 0555,
6391da177e4SLinus Torvalds 		.child		= random_table,
6401da177e4SLinus Torvalds 	},
6411da177e4SLinus Torvalds 	{
6421da177e4SLinus Torvalds 		.ctl_name	= KERN_OVERFLOWUID,
6431da177e4SLinus Torvalds 		.procname	= "overflowuid",
6441da177e4SLinus Torvalds 		.data		= &overflowuid,
6451da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6461da177e4SLinus Torvalds 		.mode		= 0644,
6471da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
6481da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
6491da177e4SLinus Torvalds 		.extra1		= &minolduid,
6501da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6511da177e4SLinus Torvalds 	},
6521da177e4SLinus Torvalds 	{
6531da177e4SLinus Torvalds 		.ctl_name	= KERN_OVERFLOWGID,
6541da177e4SLinus Torvalds 		.procname	= "overflowgid",
6551da177e4SLinus Torvalds 		.data		= &overflowgid,
6561da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6571da177e4SLinus Torvalds 		.mode		= 0644,
6581da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
6591da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
6601da177e4SLinus Torvalds 		.extra1		= &minolduid,
6611da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6621da177e4SLinus Torvalds 	},
663347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
6641da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
6651da177e4SLinus Torvalds 	{
6661da177e4SLinus Torvalds 		.ctl_name	= KERN_IEEE_EMULATION_WARNINGS,
6671da177e4SLinus Torvalds 		.procname	= "ieee_emulation_warnings",
6681da177e4SLinus Torvalds 		.data		= &sysctl_ieee_emulation_warnings,
6691da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6701da177e4SLinus Torvalds 		.mode		= 0644,
6711da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6721da177e4SLinus Torvalds 	},
6731da177e4SLinus Torvalds #endif
6741da177e4SLinus Torvalds 	{
6751da177e4SLinus Torvalds 		.ctl_name	= KERN_S390_USER_DEBUG_LOGGING,
6761da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
6771da177e4SLinus Torvalds 		.data		= &sysctl_userprocess_debug,
6781da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6791da177e4SLinus Torvalds 		.mode		= 0644,
6801da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6811da177e4SLinus Torvalds 	},
6821da177e4SLinus Torvalds #endif
6831da177e4SLinus Torvalds 	{
6841da177e4SLinus Torvalds 		.ctl_name	= KERN_PIDMAX,
6851da177e4SLinus Torvalds 		.procname	= "pid_max",
6861da177e4SLinus Torvalds 		.data		= &pid_max,
6871da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6881da177e4SLinus Torvalds 		.mode		= 0644,
6891da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
6901da177e4SLinus Torvalds 		.strategy	= sysctl_intvec,
6911da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
6921da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
6931da177e4SLinus Torvalds 	},
6941da177e4SLinus Torvalds 	{
6951da177e4SLinus Torvalds 		.ctl_name	= KERN_PANIC_ON_OOPS,
6961da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
6971da177e4SLinus Torvalds 		.data		= &panic_on_oops,
6981da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6991da177e4SLinus Torvalds 		.mode		= 0644,
7001da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7011da177e4SLinus Torvalds 	},
7027ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
7037ef3d2fdSJoe Perches 	{
7047ef3d2fdSJoe Perches 		.ctl_name	= KERN_PRINTK,
7057ef3d2fdSJoe Perches 		.procname	= "printk",
7067ef3d2fdSJoe Perches 		.data		= &console_loglevel,
7077ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
7087ef3d2fdSJoe Perches 		.mode		= 0644,
7097ef3d2fdSJoe Perches 		.proc_handler	= &proc_dointvec,
7107ef3d2fdSJoe Perches 	},
7111da177e4SLinus Torvalds 	{
7121da177e4SLinus Torvalds 		.ctl_name	= KERN_PRINTK_RATELIMIT,
7131da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
714717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
7151da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7161da177e4SLinus Torvalds 		.mode		= 0644,
7171da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_jiffies,
7181da177e4SLinus Torvalds 		.strategy	= &sysctl_jiffies,
7191da177e4SLinus Torvalds 	},
7201da177e4SLinus Torvalds 	{
7211da177e4SLinus Torvalds 		.ctl_name	= KERN_PRINTK_RATELIMIT_BURST,
7221da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
723717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
7241da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7251da177e4SLinus Torvalds 		.mode		= 0644,
7261da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7271da177e4SLinus Torvalds 	},
7287ef3d2fdSJoe Perches #endif
7291da177e4SLinus Torvalds 	{
7301da177e4SLinus Torvalds 		.ctl_name	= KERN_NGROUPS_MAX,
7311da177e4SLinus Torvalds 		.procname	= "ngroups_max",
7321da177e4SLinus Torvalds 		.data		= &ngroups_max,
7331da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7341da177e4SLinus Torvalds 		.mode		= 0444,
7351da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7361da177e4SLinus Torvalds 	},
7371da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
7381da177e4SLinus Torvalds 	{
7391da177e4SLinus Torvalds 		.ctl_name       = KERN_UNKNOWN_NMI_PANIC,
7401da177e4SLinus Torvalds 		.procname       = "unknown_nmi_panic",
7411da177e4SLinus Torvalds 		.data           = &unknown_nmi_panic,
7421da177e4SLinus Torvalds 		.maxlen         = sizeof (int),
7431da177e4SLinus Torvalds 		.mode           = 0644,
7442fbe7b25SDon Zickus 		.proc_handler   = &proc_dointvec,
7451da177e4SLinus Torvalds 	},
746407984f1SDon Zickus 	{
747407984f1SDon Zickus 		.procname       = "nmi_watchdog",
748407984f1SDon Zickus 		.data           = &nmi_watchdog_enabled,
749407984f1SDon Zickus 		.maxlen         = sizeof (int),
750407984f1SDon Zickus 		.mode           = 0644,
751407984f1SDon Zickus 		.proc_handler   = &proc_nmi_enabled,
7521da177e4SLinus Torvalds 	},
7531da177e4SLinus Torvalds #endif
7541da177e4SLinus Torvalds #if defined(CONFIG_X86)
7551da177e4SLinus Torvalds 	{
7568da5addaSDon Zickus 		.ctl_name	= KERN_PANIC_ON_NMI,
7578da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
7588da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
7598da5addaSDon Zickus 		.maxlen		= sizeof(int),
7608da5addaSDon Zickus 		.mode		= 0644,
7618da5addaSDon Zickus 		.proc_handler	= &proc_dointvec,
7628da5addaSDon Zickus 	},
7638da5addaSDon Zickus 	{
7645211a242SKurt Garloff 		.ctl_name	= CTL_UNNUMBERED,
7655211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
7665211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
7675211a242SKurt Garloff 		.maxlen		= sizeof(int),
7685211a242SKurt Garloff 		.mode		= 0644,
7695211a242SKurt Garloff 		.proc_handler	= &proc_dointvec,
7705211a242SKurt Garloff 	},
7715211a242SKurt Garloff 	{
7721da177e4SLinus Torvalds 		.ctl_name	= KERN_BOOTLOADER_TYPE,
7731da177e4SLinus Torvalds 		.procname	= "bootloader_type",
7741da177e4SLinus Torvalds 		.data		= &bootloader_type,
7751da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7761da177e4SLinus Torvalds 		.mode		= 0444,
7771da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7781da177e4SLinus Torvalds 	},
7790741f4d2SChuck Ebbert 	{
7800741f4d2SChuck Ebbert 		.ctl_name	= CTL_UNNUMBERED,
7815031296cSH. Peter Anvin 		.procname	= "bootloader_version",
7825031296cSH. Peter Anvin 		.data		= &bootloader_version,
7835031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
7845031296cSH. Peter Anvin 		.mode		= 0444,
7855031296cSH. Peter Anvin 		.proc_handler	= &proc_dointvec,
7865031296cSH. Peter Anvin 	},
7875031296cSH. Peter Anvin 	{
7885031296cSH. Peter Anvin 		.ctl_name	= CTL_UNNUMBERED,
7890741f4d2SChuck Ebbert 		.procname	= "kstack_depth_to_print",
7900741f4d2SChuck Ebbert 		.data		= &kstack_depth_to_print,
7910741f4d2SChuck Ebbert 		.maxlen		= sizeof(int),
7920741f4d2SChuck Ebbert 		.mode		= 0644,
7930741f4d2SChuck Ebbert 		.proc_handler	= &proc_dointvec,
7940741f4d2SChuck Ebbert 	},
7956e7c4025SIngo Molnar 	{
7966e7c4025SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
7976e7c4025SIngo Molnar 		.procname	= "io_delay_type",
7986e7c4025SIngo Molnar 		.data		= &io_delay_type,
7996e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
8006e7c4025SIngo Molnar 		.mode		= 0644,
8016e7c4025SIngo Molnar 		.proc_handler	= &proc_dointvec,
8026e7c4025SIngo Molnar 	},
8031da177e4SLinus Torvalds #endif
8047a9166e3SLuke Yang #if defined(CONFIG_MMU)
8051da177e4SLinus Torvalds 	{
8061da177e4SLinus Torvalds 		.ctl_name	= KERN_RANDOMIZE,
8071da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
8081da177e4SLinus Torvalds 		.data		= &randomize_va_space,
8091da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
8101da177e4SLinus Torvalds 		.mode		= 0644,
8111da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
8121da177e4SLinus Torvalds 	},
8137a9166e3SLuke Yang #endif
8140152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
815951f22d5SMartin Schwidefsky 	{
816951f22d5SMartin Schwidefsky 		.ctl_name	= KERN_SPIN_RETRY,
817951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
818951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
819951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
820951f22d5SMartin Schwidefsky 		.mode		= 0644,
821951f22d5SMartin Schwidefsky 		.proc_handler	= &proc_dointvec,
822951f22d5SMartin Schwidefsky 	},
823951f22d5SMartin Schwidefsky #endif
824673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
825c255d844SPavel Machek 	{
826c255d844SPavel Machek 		.procname	= "acpi_video_flags",
82777afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
828c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
829c255d844SPavel Machek 		.mode		= 0644,
8307f99f06fSStefan Seyfried 		.proc_handler	= &proc_doulongvec_minmax,
831c255d844SPavel Machek 	},
832c255d844SPavel Machek #endif
833d2b176edSJes Sorensen #ifdef CONFIG_IA64
834d2b176edSJes Sorensen 	{
835d2b176edSJes Sorensen 		.ctl_name	= KERN_IA64_UNALIGNED,
836d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
837d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
838d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
839d2b176edSJes Sorensen 	 	.mode		= 0644,
840d2b176edSJes Sorensen 		.proc_handler	= &proc_dointvec,
841d2b176edSJes Sorensen 	},
84288fc241fSDoug Chapman 	{
84388fc241fSDoug Chapman 		.ctl_name	= CTL_UNNUMBERED,
84488fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
84588fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
84688fc241fSDoug Chapman 		.maxlen		= sizeof (int),
84788fc241fSDoug Chapman 		.mode		= 0644,
84888fc241fSDoug Chapman 		.proc_handler	= &proc_dointvec,
84988fc241fSDoug Chapman 	},
850d2b176edSJes Sorensen #endif
851c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP
852c4f3b63fSRavikiran G Thirumalai 	{
853c4f3b63fSRavikiran G Thirumalai 		.ctl_name	= CTL_UNNUMBERED,
8549c44bc03SIngo Molnar 		.procname	= "softlockup_panic",
8559c44bc03SIngo Molnar 		.data		= &softlockup_panic,
8569c44bc03SIngo Molnar 		.maxlen		= sizeof(int),
8579c44bc03SIngo Molnar 		.mode		= 0644,
8584dca10a9SHiroshi Shimamoto 		.proc_handler	= &proc_dointvec_minmax,
8599c44bc03SIngo Molnar 		.strategy	= &sysctl_intvec,
8609c44bc03SIngo Molnar 		.extra1		= &zero,
8619c44bc03SIngo Molnar 		.extra2		= &one,
8629c44bc03SIngo Molnar 	},
8639c44bc03SIngo Molnar 	{
8649c44bc03SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
865c4f3b63fSRavikiran G Thirumalai 		.procname	= "softlockup_thresh",
866c4f3b63fSRavikiran G Thirumalai 		.data		= &softlockup_thresh,
8679383d967SDimitri Sivanich 		.maxlen		= sizeof(int),
868c4f3b63fSRavikiran G Thirumalai 		.mode		= 0644,
869baf48f65SMandeep Singh Baines 		.proc_handler	= &proc_dosoftlockup_thresh,
870c4f3b63fSRavikiran G Thirumalai 		.strategy	= &sysctl_intvec,
8719383d967SDimitri Sivanich 		.extra1		= &neg_one,
872c4f3b63fSRavikiran G Thirumalai 		.extra2		= &sixty,
873c4f3b63fSRavikiran G Thirumalai 	},
874e162b39aSMandeep Singh Baines #endif
875e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
876e162b39aSMandeep Singh Baines 	{
877e162b39aSMandeep Singh Baines 		.ctl_name	= CTL_UNNUMBERED,
878e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
879e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
880e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
881e162b39aSMandeep Singh Baines 		.mode		= 0644,
882e162b39aSMandeep Singh Baines 		.proc_handler	= &proc_dointvec_minmax,
883e162b39aSMandeep Singh Baines 		.strategy	= &sysctl_intvec,
884e162b39aSMandeep Singh Baines 		.extra1		= &zero,
885e162b39aSMandeep Singh Baines 		.extra2		= &one,
886e162b39aSMandeep Singh Baines 	},
88782a1fcb9SIngo Molnar 	{
88882a1fcb9SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
88982a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
89082a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
89190739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
89282a1fcb9SIngo Molnar 		.mode		= 0644,
89390739081SIngo Molnar 		.proc_handler	= &proc_doulongvec_minmax,
89482a1fcb9SIngo Molnar 		.strategy	= &sysctl_intvec,
89582a1fcb9SIngo Molnar 	},
89682a1fcb9SIngo Molnar 	{
89782a1fcb9SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
89882a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
89982a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
90090739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
90182a1fcb9SIngo Molnar 		.mode		= 0644,
902e162b39aSMandeep Singh Baines 		.proc_handler	= &proc_dohung_task_timeout_secs,
90382a1fcb9SIngo Molnar 		.strategy	= &sysctl_intvec,
90482a1fcb9SIngo Molnar 	},
90582a1fcb9SIngo Molnar 	{
90682a1fcb9SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
90782a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
90882a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
90990739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
91082a1fcb9SIngo Molnar 		.mode		= 0644,
91190739081SIngo Molnar 		.proc_handler	= &proc_doulongvec_minmax,
91282a1fcb9SIngo Molnar 		.strategy	= &sysctl_intvec,
91382a1fcb9SIngo Molnar 	},
914c4f3b63fSRavikiran G Thirumalai #endif
915bebfa101SAndi Kleen #ifdef CONFIG_COMPAT
916bebfa101SAndi Kleen 	{
917bebfa101SAndi Kleen 		.ctl_name	= KERN_COMPAT_LOG,
918bebfa101SAndi Kleen 		.procname	= "compat-log",
919bebfa101SAndi Kleen 		.data		= &compat_log,
920bebfa101SAndi Kleen 		.maxlen		= sizeof (int),
921bebfa101SAndi Kleen 	 	.mode		= 0644,
922bebfa101SAndi Kleen 		.proc_handler	= &proc_dointvec,
923bebfa101SAndi Kleen 	},
924bebfa101SAndi Kleen #endif
92523f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
92623f78d4aSIngo Molnar 	{
92723f78d4aSIngo Molnar 		.ctl_name	= KERN_MAX_LOCK_DEPTH,
92823f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
92923f78d4aSIngo Molnar 		.data		= &max_lock_depth,
93023f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
93123f78d4aSIngo Molnar 		.mode		= 0644,
93223f78d4aSIngo Molnar 		.proc_handler	= &proc_dointvec,
93323f78d4aSIngo Molnar 	},
93423f78d4aSIngo Molnar #endif
93510a0a8d4SJeremy Fitzhardinge 	{
93610a0a8d4SJeremy Fitzhardinge 		.ctl_name	= CTL_UNNUMBERED,
93710a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
93810a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
93910a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
94010a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
94110a0a8d4SJeremy Fitzhardinge 		.proc_handler	= &proc_dostring,
94210a0a8d4SJeremy Fitzhardinge 		.strategy	= &sysctl_string,
94310a0a8d4SJeremy Fitzhardinge 	},
9440b77f5bfSDavid Howells #ifdef CONFIG_KEYS
9450b77f5bfSDavid Howells 	{
9460b77f5bfSDavid Howells 		.ctl_name	= CTL_UNNUMBERED,
9470b77f5bfSDavid Howells 		.procname	= "keys",
9480b77f5bfSDavid Howells 		.mode		= 0555,
9490b77f5bfSDavid Howells 		.child		= key_sysctls,
9500b77f5bfSDavid Howells 	},
9510b77f5bfSDavid Howells #endif
95231a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
95331a72bceSPaul E. McKenney 	{
95431a72bceSPaul E. McKenney 		.ctl_name       = CTL_UNNUMBERED,
95531a72bceSPaul E. McKenney 		.procname       = "rcutorture_runnable",
95631a72bceSPaul E. McKenney 		.data           = &rcutorture_runnable,
95731a72bceSPaul E. McKenney 		.maxlen         = sizeof(int),
95831a72bceSPaul E. McKenney 		.mode           = 0644,
95931a72bceSPaul E. McKenney 		.proc_handler   = &proc_dointvec,
96031a72bceSPaul E. McKenney 	},
96131a72bceSPaul E. McKenney #endif
96212e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK
96312e22c5eSDavid Howells 	{
96412e22c5eSDavid Howells 		.ctl_name	= CTL_UNNUMBERED,
96512e22c5eSDavid Howells 		.procname	= "slow-work",
96612e22c5eSDavid Howells 		.mode		= 0555,
96712e22c5eSDavid Howells 		.child		= slow_work_sysctls,
96812e22c5eSDavid Howells 	},
96912e22c5eSDavid Howells #endif
9701ccd1549SPeter Zijlstra #ifdef CONFIG_PERF_COUNTERS
9711ccd1549SPeter Zijlstra 	{
9721ccd1549SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
9730764771dSPeter Zijlstra 		.procname	= "perf_counter_paranoid",
9740764771dSPeter Zijlstra 		.data		= &sysctl_perf_counter_paranoid,
9750764771dSPeter Zijlstra 		.maxlen		= sizeof(sysctl_perf_counter_paranoid),
9761ccd1549SPeter Zijlstra 		.mode		= 0644,
9771ccd1549SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
9781ccd1549SPeter Zijlstra 	},
979c5078f78SPeter Zijlstra 	{
980c5078f78SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
981c5078f78SPeter Zijlstra 		.procname	= "perf_counter_mlock_kb",
982c5078f78SPeter Zijlstra 		.data		= &sysctl_perf_counter_mlock,
983c5078f78SPeter Zijlstra 		.maxlen		= sizeof(sysctl_perf_counter_mlock),
984c5078f78SPeter Zijlstra 		.mode		= 0644,
985c5078f78SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
986c5078f78SPeter Zijlstra 	},
987a78ac325SPeter Zijlstra 	{
988a78ac325SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
989df58ab24SPeter Zijlstra 		.procname	= "perf_counter_max_sample_rate",
990df58ab24SPeter Zijlstra 		.data		= &sysctl_perf_counter_sample_rate,
991df58ab24SPeter Zijlstra 		.maxlen		= sizeof(sysctl_perf_counter_sample_rate),
992a78ac325SPeter Zijlstra 		.mode		= 0644,
993a78ac325SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
994a78ac325SPeter Zijlstra 	},
9951ccd1549SPeter Zijlstra #endif
996dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK
997dfec072eSVegard Nossum 	{
998dfec072eSVegard Nossum 		.ctl_name	= CTL_UNNUMBERED,
999dfec072eSVegard Nossum 		.procname	= "kmemcheck",
1000dfec072eSVegard Nossum 		.data		= &kmemcheck_enabled,
1001dfec072eSVegard Nossum 		.maxlen		= sizeof(int),
1002dfec072eSVegard Nossum 		.mode		= 0644,
1003dfec072eSVegard Nossum 		.proc_handler	= &proc_dointvec,
1004dfec072eSVegard Nossum 	},
1005dfec072eSVegard Nossum #endif
1006cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
10075e605b64SJens Axboe 	{
10085e605b64SJens Axboe 		.ctl_name	= CTL_UNNUMBERED,
10095e605b64SJens Axboe 		.procname	= "blk_iopoll",
10105e605b64SJens Axboe 		.data		= &blk_iopoll_enabled,
10115e605b64SJens Axboe 		.maxlen		= sizeof(int),
10125e605b64SJens Axboe 		.mode		= 0644,
10135e605b64SJens Axboe 		.proc_handler	= &proc_dointvec,
10145e605b64SJens Axboe 	},
1015cb684b5bSJens Axboe #endif
1016ed2c12f3SAndrew Morton /*
1017ed2c12f3SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
1018ed2c12f3SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
1019ed2c12f3SAndrew Morton  */
10201da177e4SLinus Torvalds 	{ .ctl_name = 0 }
10211da177e4SLinus Torvalds };
10221da177e4SLinus Torvalds 
1023d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
10241da177e4SLinus Torvalds 	{
10251da177e4SLinus Torvalds 		.ctl_name	= VM_OVERCOMMIT_MEMORY,
10261da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
10271da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
10281da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
10291da177e4SLinus Torvalds 		.mode		= 0644,
10301da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10311da177e4SLinus Torvalds 	},
10321da177e4SLinus Torvalds 	{
1033fadd8fbdSKAMEZAWA Hiroyuki 		.ctl_name	= VM_PANIC_ON_OOM,
1034fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
1035fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
1036fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
1037fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
1038fadd8fbdSKAMEZAWA Hiroyuki 		.proc_handler	= &proc_dointvec,
1039fadd8fbdSKAMEZAWA Hiroyuki 	},
1040fadd8fbdSKAMEZAWA Hiroyuki 	{
1041fe071d7eSDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
1042fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
1043fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
1044fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
1045fe071d7eSDavid Rientjes 		.mode		= 0644,
1046fe071d7eSDavid Rientjes 		.proc_handler	= &proc_dointvec,
1047fe071d7eSDavid Rientjes 	},
1048fe071d7eSDavid Rientjes 	{
1049fef1bdd6SDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
1050fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
1051fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
1052fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
1053fef1bdd6SDavid Rientjes 		.mode		= 0644,
1054fef1bdd6SDavid Rientjes 		.proc_handler	= &proc_dointvec,
1055fef1bdd6SDavid Rientjes 	},
1056fef1bdd6SDavid Rientjes 	{
10571da177e4SLinus Torvalds 		.ctl_name	= VM_OVERCOMMIT_RATIO,
10581da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
10591da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
10601da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
10611da177e4SLinus Torvalds 		.mode		= 0644,
10621da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10631da177e4SLinus Torvalds 	},
10641da177e4SLinus Torvalds 	{
10651da177e4SLinus Torvalds 		.ctl_name	= VM_PAGE_CLUSTER,
10661da177e4SLinus Torvalds 		.procname	= "page-cluster",
10671da177e4SLinus Torvalds 		.data		= &page_cluster,
10681da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
10691da177e4SLinus Torvalds 		.mode		= 0644,
10701da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10711da177e4SLinus Torvalds 	},
10721da177e4SLinus Torvalds 	{
10731da177e4SLinus Torvalds 		.ctl_name	= VM_DIRTY_BACKGROUND,
10741da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
10751da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
10761da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
10771da177e4SLinus Torvalds 		.mode		= 0644,
10782da02997SDavid Rientjes 		.proc_handler	= &dirty_background_ratio_handler,
10791da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
10801da177e4SLinus Torvalds 		.extra1		= &zero,
10811da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10821da177e4SLinus Torvalds 	},
10831da177e4SLinus Torvalds 	{
10842da02997SDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
10852da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
10862da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
10872da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
10882da02997SDavid Rientjes 		.mode		= 0644,
10892da02997SDavid Rientjes 		.proc_handler	= &dirty_background_bytes_handler,
10902da02997SDavid Rientjes 		.strategy	= &sysctl_intvec,
1091fc3501d4SSven Wegener 		.extra1		= &one_ul,
10922da02997SDavid Rientjes 	},
10932da02997SDavid Rientjes 	{
10941da177e4SLinus Torvalds 		.ctl_name	= VM_DIRTY_RATIO,
10951da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
10961da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
10971da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
10981da177e4SLinus Torvalds 		.mode		= 0644,
109904fbfdc1SPeter Zijlstra 		.proc_handler	= &dirty_ratio_handler,
11001da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
11011da177e4SLinus Torvalds 		.extra1		= &zero,
11021da177e4SLinus Torvalds 		.extra2		= &one_hundred,
11031da177e4SLinus Torvalds 	},
11041da177e4SLinus Torvalds 	{
11052da02997SDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
11062da02997SDavid Rientjes 		.procname	= "dirty_bytes",
11072da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
11082da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
11092da02997SDavid Rientjes 		.mode		= 0644,
11102da02997SDavid Rientjes 		.proc_handler	= &dirty_bytes_handler,
11112da02997SDavid Rientjes 		.strategy	= &sysctl_intvec,
11129e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
11132da02997SDavid Rientjes 	},
11142da02997SDavid Rientjes 	{
11151da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
1116f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
1117f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
11181da177e4SLinus Torvalds 		.mode		= 0644,
11191da177e4SLinus Torvalds 		.proc_handler	= &dirty_writeback_centisecs_handler,
11201da177e4SLinus Torvalds 	},
11211da177e4SLinus Torvalds 	{
11221da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
1123f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
1124f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
11251da177e4SLinus Torvalds 		.mode		= 0644,
1126704503d8SAlexey Dobriyan 		.proc_handler	= &proc_dointvec,
11271da177e4SLinus Torvalds 	},
11281da177e4SLinus Torvalds 	{
11291da177e4SLinus Torvalds 		.ctl_name	= VM_NR_PDFLUSH_THREADS,
11301da177e4SLinus Torvalds 		.procname	= "nr_pdflush_threads",
11311da177e4SLinus Torvalds 		.data		= &nr_pdflush_threads,
11321da177e4SLinus Torvalds 		.maxlen		= sizeof nr_pdflush_threads,
11331da177e4SLinus Torvalds 		.mode		= 0444 /* read-only*/,
11341da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
11351da177e4SLinus Torvalds 	},
11361da177e4SLinus Torvalds 	{
11371da177e4SLinus Torvalds 		.ctl_name	= VM_SWAPPINESS,
11381da177e4SLinus Torvalds 		.procname	= "swappiness",
11391da177e4SLinus Torvalds 		.data		= &vm_swappiness,
11401da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
11411da177e4SLinus Torvalds 		.mode		= 0644,
11421da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
11431da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
11441da177e4SLinus Torvalds 		.extra1		= &zero,
11451da177e4SLinus Torvalds 		.extra2		= &one_hundred,
11461da177e4SLinus Torvalds 	},
11471da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
11481da177e4SLinus Torvalds 	 {
11491da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
1150e5ff2159SAndi Kleen 		.data		= NULL,
11511da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
11521da177e4SLinus Torvalds 		.mode		= 0644,
11531da177e4SLinus Torvalds 		.proc_handler	= &hugetlb_sysctl_handler,
11541da177e4SLinus Torvalds 		.extra1		= (void *)&hugetlb_zero,
11551da177e4SLinus Torvalds 		.extra2		= (void *)&hugetlb_infinity,
11561da177e4SLinus Torvalds 	 },
11571da177e4SLinus Torvalds 	 {
11581da177e4SLinus Torvalds 		.ctl_name	= VM_HUGETLB_GROUP,
11591da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
11601da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
11611da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
11621da177e4SLinus Torvalds 		.mode		= 0644,
11631da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
11641da177e4SLinus Torvalds 	 },
1165396faf03SMel Gorman 	 {
1166396faf03SMel Gorman 		.ctl_name	= CTL_UNNUMBERED,
1167396faf03SMel Gorman 		.procname	= "hugepages_treat_as_movable",
1168396faf03SMel Gorman 		.data		= &hugepages_treat_as_movable,
1169396faf03SMel Gorman 		.maxlen		= sizeof(int),
1170396faf03SMel Gorman 		.mode		= 0644,
1171396faf03SMel Gorman 		.proc_handler	= &hugetlb_treat_movable_handler,
1172396faf03SMel Gorman 	},
117354f9f80dSAdam Litke 	{
117454f9f80dSAdam Litke 		.ctl_name	= CTL_UNNUMBERED,
1175d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
1176e5ff2159SAndi Kleen 		.data		= NULL,
1177e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
1178d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
1179a3d0c6aaSNishanth Aravamudan 		.proc_handler	= &hugetlb_overcommit_handler,
1180e5ff2159SAndi Kleen 		.extra1		= (void *)&hugetlb_zero,
1181e5ff2159SAndi Kleen 		.extra2		= (void *)&hugetlb_infinity,
1182d1c3fb1fSNishanth Aravamudan 	},
11831da177e4SLinus Torvalds #endif
11841da177e4SLinus Torvalds 	{
11851da177e4SLinus Torvalds 		.ctl_name	= VM_LOWMEM_RESERVE_RATIO,
11861da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
11871da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
11881da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
11891da177e4SLinus Torvalds 		.mode		= 0644,
11901da177e4SLinus Torvalds 		.proc_handler	= &lowmem_reserve_ratio_sysctl_handler,
11911da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
11921da177e4SLinus Torvalds 	},
11931da177e4SLinus Torvalds 	{
11949d0243bcSAndrew Morton 		.ctl_name	= VM_DROP_PAGECACHE,
11959d0243bcSAndrew Morton 		.procname	= "drop_caches",
11969d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
11979d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
11989d0243bcSAndrew Morton 		.mode		= 0644,
11999d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
12009d0243bcSAndrew Morton 		.strategy	= &sysctl_intvec,
12019d0243bcSAndrew Morton 	},
12029d0243bcSAndrew Morton 	{
12031da177e4SLinus Torvalds 		.ctl_name	= VM_MIN_FREE_KBYTES,
12041da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
12051da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
12061da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
12071da177e4SLinus Torvalds 		.mode		= 0644,
12081da177e4SLinus Torvalds 		.proc_handler	= &min_free_kbytes_sysctl_handler,
12091da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
12101da177e4SLinus Torvalds 		.extra1		= &zero,
12111da177e4SLinus Torvalds 	},
12128ad4b1fbSRohit Seth 	{
12138ad4b1fbSRohit Seth 		.ctl_name	= VM_PERCPU_PAGELIST_FRACTION,
12148ad4b1fbSRohit Seth 		.procname	= "percpu_pagelist_fraction",
12158ad4b1fbSRohit Seth 		.data		= &percpu_pagelist_fraction,
12168ad4b1fbSRohit Seth 		.maxlen		= sizeof(percpu_pagelist_fraction),
12178ad4b1fbSRohit Seth 		.mode		= 0644,
12188ad4b1fbSRohit Seth 		.proc_handler	= &percpu_pagelist_fraction_sysctl_handler,
12198ad4b1fbSRohit Seth 		.strategy	= &sysctl_intvec,
12208ad4b1fbSRohit Seth 		.extra1		= &min_percpu_pagelist_fract,
12218ad4b1fbSRohit Seth 	},
12221da177e4SLinus Torvalds #ifdef CONFIG_MMU
12231da177e4SLinus Torvalds 	{
12241da177e4SLinus Torvalds 		.ctl_name	= VM_MAX_MAP_COUNT,
12251da177e4SLinus Torvalds 		.procname	= "max_map_count",
12261da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
12271da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
12281da177e4SLinus Torvalds 		.mode		= 0644,
12291da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec
12301da177e4SLinus Torvalds 	},
1231dd8632a1SPaul Mundt #else
1232dd8632a1SPaul Mundt 	{
1233dd8632a1SPaul Mundt 		.ctl_name	= CTL_UNNUMBERED,
1234dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
1235dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
1236dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
1237dd8632a1SPaul Mundt 		.mode		= 0644,
1238dd8632a1SPaul Mundt 		.proc_handler	= &proc_dointvec_minmax,
1239dd8632a1SPaul Mundt 		.strategy	= &sysctl_intvec,
1240dd8632a1SPaul Mundt 		.extra1		= &zero,
1241dd8632a1SPaul Mundt 	},
12421da177e4SLinus Torvalds #endif
12431da177e4SLinus Torvalds 	{
12441da177e4SLinus Torvalds 		.ctl_name	= VM_LAPTOP_MODE,
12451da177e4SLinus Torvalds 		.procname	= "laptop_mode",
12461da177e4SLinus Torvalds 		.data		= &laptop_mode,
12471da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
12481da177e4SLinus Torvalds 		.mode		= 0644,
1249ed5b43f1SBart Samwel 		.proc_handler	= &proc_dointvec_jiffies,
1250ed5b43f1SBart Samwel 		.strategy	= &sysctl_jiffies,
12511da177e4SLinus Torvalds 	},
12521da177e4SLinus Torvalds 	{
12531da177e4SLinus Torvalds 		.ctl_name	= VM_BLOCK_DUMP,
12541da177e4SLinus Torvalds 		.procname	= "block_dump",
12551da177e4SLinus Torvalds 		.data		= &block_dump,
12561da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
12571da177e4SLinus Torvalds 		.mode		= 0644,
12581da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
12591da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
12601da177e4SLinus Torvalds 		.extra1		= &zero,
12611da177e4SLinus Torvalds 	},
12621da177e4SLinus Torvalds 	{
12631da177e4SLinus Torvalds 		.ctl_name	= VM_VFS_CACHE_PRESSURE,
12641da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
12651da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
12661da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
12671da177e4SLinus Torvalds 		.mode		= 0644,
12681da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
12691da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
12701da177e4SLinus Torvalds 		.extra1		= &zero,
12711da177e4SLinus Torvalds 	},
12721da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
12731da177e4SLinus Torvalds 	{
12741da177e4SLinus Torvalds 		.ctl_name	= VM_LEGACY_VA_LAYOUT,
12751da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
12761da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
12771da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
12781da177e4SLinus Torvalds 		.mode		= 0644,
12791da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
12801da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
12811da177e4SLinus Torvalds 		.extra1		= &zero,
12821da177e4SLinus Torvalds 	},
12831da177e4SLinus Torvalds #endif
12841743660bSChristoph Lameter #ifdef CONFIG_NUMA
12851743660bSChristoph Lameter 	{
12861743660bSChristoph Lameter 		.ctl_name	= VM_ZONE_RECLAIM_MODE,
12871743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
12881743660bSChristoph Lameter 		.data		= &zone_reclaim_mode,
12891743660bSChristoph Lameter 		.maxlen		= sizeof(zone_reclaim_mode),
12901743660bSChristoph Lameter 		.mode		= 0644,
12911743660bSChristoph Lameter 		.proc_handler	= &proc_dointvec,
1292c84db23cSChristoph Lameter 		.strategy	= &sysctl_intvec,
1293c84db23cSChristoph Lameter 		.extra1		= &zero,
12941743660bSChristoph Lameter 	},
12959614634fSChristoph Lameter 	{
12969614634fSChristoph Lameter 		.ctl_name	= VM_MIN_UNMAPPED,
12979614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
12989614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
12999614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
13009614634fSChristoph Lameter 		.mode		= 0644,
13019614634fSChristoph Lameter 		.proc_handler	= &sysctl_min_unmapped_ratio_sysctl_handler,
13029614634fSChristoph Lameter 		.strategy	= &sysctl_intvec,
13039614634fSChristoph Lameter 		.extra1		= &zero,
13049614634fSChristoph Lameter 		.extra2		= &one_hundred,
13059614634fSChristoph Lameter 	},
13060ff38490SChristoph Lameter 	{
13070ff38490SChristoph Lameter 		.ctl_name	= VM_MIN_SLAB,
13080ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
13090ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
13100ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
13110ff38490SChristoph Lameter 		.mode		= 0644,
13120ff38490SChristoph Lameter 		.proc_handler	= &sysctl_min_slab_ratio_sysctl_handler,
13130ff38490SChristoph Lameter 		.strategy	= &sysctl_intvec,
13140ff38490SChristoph Lameter 		.extra1		= &zero,
13150ff38490SChristoph Lameter 		.extra2		= &one_hundred,
13160ff38490SChristoph Lameter 	},
13171743660bSChristoph Lameter #endif
131877461ab3SChristoph Lameter #ifdef CONFIG_SMP
131977461ab3SChristoph Lameter 	{
132077461ab3SChristoph Lameter 		.ctl_name	= CTL_UNNUMBERED,
132177461ab3SChristoph Lameter 		.procname	= "stat_interval",
132277461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
132377461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
132477461ab3SChristoph Lameter 		.mode		= 0644,
132577461ab3SChristoph Lameter 		.proc_handler	= &proc_dointvec_jiffies,
132677461ab3SChristoph Lameter 		.strategy	= &sysctl_jiffies,
132777461ab3SChristoph Lameter 	},
132877461ab3SChristoph Lameter #endif
1329ed032189SEric Paris 	{
1330ed032189SEric Paris 		.ctl_name	= CTL_UNNUMBERED,
1331ed032189SEric Paris 		.procname	= "mmap_min_addr",
1332788084abSEric Paris 		.data		= &dac_mmap_min_addr,
1333ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
1334ed032189SEric Paris 		.mode		= 0644,
1335788084abSEric Paris 		.proc_handler	= &mmap_min_addr_handler,
1336ed032189SEric Paris 	},
1337f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
1338f0c0b2b8SKAMEZAWA Hiroyuki 	{
1339f0c0b2b8SKAMEZAWA Hiroyuki 		.ctl_name	= CTL_UNNUMBERED,
1340f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
1341f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
1342f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
1343f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
1344f0c0b2b8SKAMEZAWA Hiroyuki 		.proc_handler	= &numa_zonelist_order_handler,
1345f0c0b2b8SKAMEZAWA Hiroyuki 		.strategy	= &sysctl_string,
1346f0c0b2b8SKAMEZAWA Hiroyuki 	},
1347f0c0b2b8SKAMEZAWA Hiroyuki #endif
13482b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
13495c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1350e6e5494cSIngo Molnar 	{
1351e6e5494cSIngo Molnar 		.ctl_name	= VM_VDSO_ENABLED,
1352e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
1353e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
1354e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
1355e6e5494cSIngo Molnar 		.mode		= 0644,
1356e6e5494cSIngo Molnar 		.proc_handler	= &proc_dointvec,
1357e6e5494cSIngo Molnar 		.strategy	= &sysctl_intvec,
1358e6e5494cSIngo Molnar 		.extra1		= &zero,
1359e6e5494cSIngo Molnar 	},
1360e6e5494cSIngo Molnar #endif
1361195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
1362195cf453SBron Gondwana 	{
1363195cf453SBron Gondwana 		.ctl_name	= CTL_UNNUMBERED,
1364195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
1365195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
1366195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
1367195cf453SBron Gondwana 		.mode		= 0644,
1368195cf453SBron Gondwana 		.proc_handler	= &proc_dointvec_minmax,
1369195cf453SBron Gondwana 		.strategy	= &sysctl_intvec,
1370195cf453SBron Gondwana 		.extra1		= &zero,
1371195cf453SBron Gondwana 		.extra2		= &one,
1372195cf453SBron Gondwana 	},
1373195cf453SBron Gondwana #endif
13744be6f6bbSPeter Zijlstra 	{
13754be6f6bbSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
13764be6f6bbSPeter Zijlstra 		.procname	= "scan_unevictable_pages",
13774be6f6bbSPeter Zijlstra 		.data		= &scan_unevictable_pages,
13784be6f6bbSPeter Zijlstra 		.maxlen		= sizeof(scan_unevictable_pages),
13794be6f6bbSPeter Zijlstra 		.mode		= 0644,
13804be6f6bbSPeter Zijlstra 		.proc_handler	= &scan_unevictable_handler,
13814be6f6bbSPeter Zijlstra 	},
13822be7fe07SAndrew Morton /*
13832be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
13842be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
13852be7fe07SAndrew Morton  */
13861da177e4SLinus Torvalds 	{ .ctl_name = 0 }
13871da177e4SLinus Torvalds };
13881da177e4SLinus Torvalds 
13892abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1390d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = {
13912abc26fcSEric W. Biederman 	{ .ctl_name = 0 }
13922abc26fcSEric W. Biederman };
13932abc26fcSEric W. Biederman #endif
13942abc26fcSEric W. Biederman 
1395d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
13961da177e4SLinus Torvalds 	{
13971da177e4SLinus Torvalds 		.ctl_name	= FS_NRINODE,
13981da177e4SLinus Torvalds 		.procname	= "inode-nr",
13991da177e4SLinus Torvalds 		.data		= &inodes_stat,
14001da177e4SLinus Torvalds 		.maxlen		= 2*sizeof(int),
14011da177e4SLinus Torvalds 		.mode		= 0444,
14021da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14031da177e4SLinus Torvalds 	},
14041da177e4SLinus Torvalds 	{
14051da177e4SLinus Torvalds 		.ctl_name	= FS_STATINODE,
14061da177e4SLinus Torvalds 		.procname	= "inode-state",
14071da177e4SLinus Torvalds 		.data		= &inodes_stat,
14081da177e4SLinus Torvalds 		.maxlen		= 7*sizeof(int),
14091da177e4SLinus Torvalds 		.mode		= 0444,
14101da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14111da177e4SLinus Torvalds 	},
14121da177e4SLinus Torvalds 	{
14131da177e4SLinus Torvalds 		.procname	= "file-nr",
14141da177e4SLinus Torvalds 		.data		= &files_stat,
14151da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
14161da177e4SLinus Torvalds 		.mode		= 0444,
1417529bf6beSDipankar Sarma 		.proc_handler	= &proc_nr_files,
14181da177e4SLinus Torvalds 	},
14191da177e4SLinus Torvalds 	{
14201da177e4SLinus Torvalds 		.ctl_name	= FS_MAXFILE,
14211da177e4SLinus Torvalds 		.procname	= "file-max",
14221da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
14231da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14241da177e4SLinus Torvalds 		.mode		= 0644,
14251da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14261da177e4SLinus Torvalds 	},
14271da177e4SLinus Torvalds 	{
14289cfe015aSEric Dumazet 		.ctl_name	= CTL_UNNUMBERED,
14299cfe015aSEric Dumazet 		.procname	= "nr_open",
14309cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
14319cfe015aSEric Dumazet 		.maxlen		= sizeof(int),
14329cfe015aSEric Dumazet 		.mode		= 0644,
1433eceea0b3SAl Viro 		.proc_handler	= &proc_dointvec_minmax,
1434eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
1435eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
14369cfe015aSEric Dumazet 	},
14379cfe015aSEric Dumazet 	{
14381da177e4SLinus Torvalds 		.ctl_name	= FS_DENTRY,
14391da177e4SLinus Torvalds 		.procname	= "dentry-state",
14401da177e4SLinus Torvalds 		.data		= &dentry_stat,
14411da177e4SLinus Torvalds 		.maxlen		= 6*sizeof(int),
14421da177e4SLinus Torvalds 		.mode		= 0444,
14431da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14441da177e4SLinus Torvalds 	},
14451da177e4SLinus Torvalds 	{
14461da177e4SLinus Torvalds 		.ctl_name	= FS_OVERFLOWUID,
14471da177e4SLinus Torvalds 		.procname	= "overflowuid",
14481da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
14491da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14501da177e4SLinus Torvalds 		.mode		= 0644,
14511da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
14521da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
14531da177e4SLinus Torvalds 		.extra1		= &minolduid,
14541da177e4SLinus Torvalds 		.extra2		= &maxolduid,
14551da177e4SLinus Torvalds 	},
14561da177e4SLinus Torvalds 	{
14571da177e4SLinus Torvalds 		.ctl_name	= FS_OVERFLOWGID,
14581da177e4SLinus Torvalds 		.procname	= "overflowgid",
14591da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
14601da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14611da177e4SLinus Torvalds 		.mode		= 0644,
14621da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
14631da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
14641da177e4SLinus Torvalds 		.extra1		= &minolduid,
14651da177e4SLinus Torvalds 		.extra2		= &maxolduid,
14661da177e4SLinus Torvalds 	},
1467bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
14681da177e4SLinus Torvalds 	{
14691da177e4SLinus Torvalds 		.ctl_name	= FS_LEASES,
14701da177e4SLinus Torvalds 		.procname	= "leases-enable",
14711da177e4SLinus Torvalds 		.data		= &leases_enable,
14721da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14731da177e4SLinus Torvalds 		.mode		= 0644,
14741da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14751da177e4SLinus Torvalds 	},
1476bfcd17a6SThomas Petazzoni #endif
14771da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
14781da177e4SLinus Torvalds 	{
14791da177e4SLinus Torvalds 		.ctl_name	= FS_DIR_NOTIFY,
14801da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
14811da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
14821da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14831da177e4SLinus Torvalds 		.mode		= 0644,
14841da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14851da177e4SLinus Torvalds 	},
14861da177e4SLinus Torvalds #endif
14871da177e4SLinus Torvalds #ifdef CONFIG_MMU
1488bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
14891da177e4SLinus Torvalds 	{
14901da177e4SLinus Torvalds 		.ctl_name	= FS_LEASE_TIME,
14911da177e4SLinus Torvalds 		.procname	= "lease-break-time",
14921da177e4SLinus Torvalds 		.data		= &lease_break_time,
14931da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14941da177e4SLinus Torvalds 		.mode		= 0644,
14958e654fbaSMatthew Wilcox 		.proc_handler	= &proc_dointvec,
14961da177e4SLinus Torvalds 	},
1497bfcd17a6SThomas Petazzoni #endif
1498ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
14991da177e4SLinus Torvalds 	{
15001da177e4SLinus Torvalds 		.procname	= "aio-nr",
15011da177e4SLinus Torvalds 		.data		= &aio_nr,
15021da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
15031da177e4SLinus Torvalds 		.mode		= 0444,
1504d55b5fdaSZach Brown 		.proc_handler	= &proc_doulongvec_minmax,
15051da177e4SLinus Torvalds 	},
15061da177e4SLinus Torvalds 	{
15071da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
15081da177e4SLinus Torvalds 		.data		= &aio_max_nr,
15091da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
15101da177e4SLinus Torvalds 		.mode		= 0644,
1511d55b5fdaSZach Brown 		.proc_handler	= &proc_doulongvec_minmax,
15121da177e4SLinus Torvalds 	},
1513ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
15142d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
15150399cb08SRobert Love 	{
15160399cb08SRobert Love 		.ctl_name	= FS_INOTIFY,
15170399cb08SRobert Love 		.procname	= "inotify",
15180399cb08SRobert Love 		.mode		= 0555,
15190399cb08SRobert Love 		.child		= inotify_table,
15200399cb08SRobert Love 	},
15210399cb08SRobert Love #endif
15227ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
15237ef9964eSDavide Libenzi 	{
15247ef9964eSDavide Libenzi 		.procname	= "epoll",
15257ef9964eSDavide Libenzi 		.mode		= 0555,
15267ef9964eSDavide Libenzi 		.child		= epoll_table,
15277ef9964eSDavide Libenzi 	},
15287ef9964eSDavide Libenzi #endif
15291da177e4SLinus Torvalds #endif
1530d6e71144SAlan Cox 	{
1531d6e71144SAlan Cox 		.ctl_name	= KERN_SETUID_DUMPABLE,
1532d6e71144SAlan Cox 		.procname	= "suid_dumpable",
1533d6e71144SAlan Cox 		.data		= &suid_dumpable,
1534d6e71144SAlan Cox 		.maxlen		= sizeof(int),
1535d6e71144SAlan Cox 		.mode		= 0644,
15368e654fbaSMatthew Wilcox 		.proc_handler	= &proc_dointvec_minmax,
15378e654fbaSMatthew Wilcox 		.strategy	= &sysctl_intvec,
15388e654fbaSMatthew Wilcox 		.extra1		= &zero,
15398e654fbaSMatthew Wilcox 		.extra2		= &two,
1540d6e71144SAlan Cox 	},
15412abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
15422abc26fcSEric W. Biederman 	{
15432abc26fcSEric W. Biederman 		.ctl_name	= CTL_UNNUMBERED,
15442abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
15452abc26fcSEric W. Biederman 		.mode		= 0555,
15462abc26fcSEric W. Biederman 		.child		= binfmt_misc_table,
15472abc26fcSEric W. Biederman 	},
15482abc26fcSEric W. Biederman #endif
15492be7fe07SAndrew Morton /*
15502be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
15512be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
15522be7fe07SAndrew Morton  */
15531da177e4SLinus Torvalds 	{ .ctl_name = 0 }
15541da177e4SLinus Torvalds };
15551da177e4SLinus Torvalds 
1556d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
1557d0c3d534SOlof Johansson #if defined(CONFIG_X86) || defined(CONFIG_PPC)
1558abd4f750SMasoud Asgharifard Sharbiani 	{
1559abd4f750SMasoud Asgharifard Sharbiani 		.ctl_name	= CTL_UNNUMBERED,
1560abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
1561abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
1562abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
1563abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
1564abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
1565abd4f750SMasoud Asgharifard Sharbiani 	},
1566abd4f750SMasoud Asgharifard Sharbiani #endif
15671da177e4SLinus Torvalds 	{ .ctl_name = 0 }
15681da177e4SLinus Torvalds };
15691da177e4SLinus Torvalds 
1570d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
15711da177e4SLinus Torvalds 	{ .ctl_name = 0 }
15721da177e4SLinus Torvalds };
15731da177e4SLinus Torvalds 
1574330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock);
1575330d57fbSAl Viro 
1576330d57fbSAl Viro /* called under sysctl_lock */
1577330d57fbSAl Viro static int use_table(struct ctl_table_header *p)
1578330d57fbSAl Viro {
1579330d57fbSAl Viro 	if (unlikely(p->unregistering))
1580330d57fbSAl Viro 		return 0;
1581330d57fbSAl Viro 	p->used++;
1582330d57fbSAl Viro 	return 1;
1583330d57fbSAl Viro }
1584330d57fbSAl Viro 
1585330d57fbSAl Viro /* called under sysctl_lock */
1586330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p)
1587330d57fbSAl Viro {
1588330d57fbSAl Viro 	if (!--p->used)
1589330d57fbSAl Viro 		if (unlikely(p->unregistering))
1590330d57fbSAl Viro 			complete(p->unregistering);
1591330d57fbSAl Viro }
1592330d57fbSAl Viro 
1593330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */
1594330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p)
1595330d57fbSAl Viro {
1596330d57fbSAl Viro 	/*
1597330d57fbSAl Viro 	 * if p->used is 0, nobody will ever touch that entry again;
1598330d57fbSAl Viro 	 * we'll eliminate all paths to it before dropping sysctl_lock
1599330d57fbSAl Viro 	 */
1600330d57fbSAl Viro 	if (unlikely(p->used)) {
1601330d57fbSAl Viro 		struct completion wait;
1602330d57fbSAl Viro 		init_completion(&wait);
1603330d57fbSAl Viro 		p->unregistering = &wait;
1604330d57fbSAl Viro 		spin_unlock(&sysctl_lock);
1605330d57fbSAl Viro 		wait_for_completion(&wait);
1606330d57fbSAl Viro 		spin_lock(&sysctl_lock);
1607f7e6ced4SAl Viro 	} else {
1608f7e6ced4SAl Viro 		/* anything non-NULL; we'll never dereference it */
1609f7e6ced4SAl Viro 		p->unregistering = ERR_PTR(-EINVAL);
1610330d57fbSAl Viro 	}
1611330d57fbSAl Viro 	/*
1612330d57fbSAl Viro 	 * do not remove from the list until nobody holds it; walking the
1613330d57fbSAl Viro 	 * list in do_sysctl() relies on that.
1614330d57fbSAl Viro 	 */
1615330d57fbSAl Viro 	list_del_init(&p->ctl_entry);
1616330d57fbSAl Viro }
1617330d57fbSAl Viro 
1618f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head)
1619f7e6ced4SAl Viro {
1620f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1621f7e6ced4SAl Viro 	head->count++;
1622f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1623f7e6ced4SAl Viro }
1624f7e6ced4SAl Viro 
1625f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
1626f7e6ced4SAl Viro {
1627f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1628f7e6ced4SAl Viro 	if (!--head->count)
1629f7e6ced4SAl Viro 		kfree(head);
1630f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1631f7e6ced4SAl Viro }
1632f7e6ced4SAl Viro 
1633f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1634f7e6ced4SAl Viro {
1635f7e6ced4SAl Viro 	if (!head)
1636f7e6ced4SAl Viro 		BUG();
1637f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1638f7e6ced4SAl Viro 	if (!use_table(head))
1639f7e6ced4SAl Viro 		head = ERR_PTR(-ENOENT);
1640f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1641f7e6ced4SAl Viro 	return head;
1642f7e6ced4SAl Viro }
1643f7e6ced4SAl Viro 
1644805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head)
1645805b5d5eSEric W. Biederman {
1646805b5d5eSEric W. Biederman 	if (!head)
1647805b5d5eSEric W. Biederman 		return;
1648805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1649805b5d5eSEric W. Biederman 	unuse_table(head);
1650805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1651805b5d5eSEric W. Biederman }
1652805b5d5eSEric W. Biederman 
165373455092SAl Viro static struct ctl_table_set *
165473455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
165573455092SAl Viro {
165673455092SAl Viro 	struct ctl_table_set *set = &root->default_set;
165773455092SAl Viro 	if (root->lookup)
165873455092SAl Viro 		set = root->lookup(root, namespaces);
165973455092SAl Viro 	return set;
166073455092SAl Viro }
166173455092SAl Viro 
1662e51b6ba0SEric W. Biederman static struct list_head *
1663e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1664805b5d5eSEric W. Biederman {
166573455092SAl Viro 	struct ctl_table_set *set = lookup_header_set(root, namespaces);
166673455092SAl Viro 	return &set->list;
1667e51b6ba0SEric W. Biederman }
1668e51b6ba0SEric W. Biederman 
1669e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1670e51b6ba0SEric W. Biederman 					    struct ctl_table_header *prev)
1671e51b6ba0SEric W. Biederman {
1672e51b6ba0SEric W. Biederman 	struct ctl_table_root *root;
1673e51b6ba0SEric W. Biederman 	struct list_head *header_list;
1674805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1675805b5d5eSEric W. Biederman 	struct list_head *tmp;
1676e51b6ba0SEric W. Biederman 
1677805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1678805b5d5eSEric W. Biederman 	if (prev) {
1679e51b6ba0SEric W. Biederman 		head = prev;
1680805b5d5eSEric W. Biederman 		tmp = &prev->ctl_entry;
1681805b5d5eSEric W. Biederman 		unuse_table(prev);
1682805b5d5eSEric W. Biederman 		goto next;
1683805b5d5eSEric W. Biederman 	}
1684805b5d5eSEric W. Biederman 	tmp = &root_table_header.ctl_entry;
1685805b5d5eSEric W. Biederman 	for (;;) {
1686805b5d5eSEric W. Biederman 		head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1687805b5d5eSEric W. Biederman 
1688805b5d5eSEric W. Biederman 		if (!use_table(head))
1689805b5d5eSEric W. Biederman 			goto next;
1690805b5d5eSEric W. Biederman 		spin_unlock(&sysctl_lock);
1691805b5d5eSEric W. Biederman 		return head;
1692805b5d5eSEric W. Biederman 	next:
1693e51b6ba0SEric W. Biederman 		root = head->root;
1694805b5d5eSEric W. Biederman 		tmp = tmp->next;
1695e51b6ba0SEric W. Biederman 		header_list = lookup_header_list(root, namespaces);
1696e51b6ba0SEric W. Biederman 		if (tmp != header_list)
1697e51b6ba0SEric W. Biederman 			continue;
1698e51b6ba0SEric W. Biederman 
1699e51b6ba0SEric W. Biederman 		do {
1700e51b6ba0SEric W. Biederman 			root = list_entry(root->root_list.next,
1701e51b6ba0SEric W. Biederman 					struct ctl_table_root, root_list);
1702e51b6ba0SEric W. Biederman 			if (root == &sysctl_table_root)
1703e51b6ba0SEric W. Biederman 				goto out;
1704e51b6ba0SEric W. Biederman 			header_list = lookup_header_list(root, namespaces);
1705e51b6ba0SEric W. Biederman 		} while (list_empty(header_list));
1706e51b6ba0SEric W. Biederman 		tmp = header_list->next;
1707805b5d5eSEric W. Biederman 	}
1708e51b6ba0SEric W. Biederman out:
1709805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1710805b5d5eSEric W. Biederman 	return NULL;
1711805b5d5eSEric W. Biederman }
1712805b5d5eSEric W. Biederman 
1713e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1714e51b6ba0SEric W. Biederman {
1715e51b6ba0SEric W. Biederman 	return __sysctl_head_next(current->nsproxy, prev);
1716e51b6ba0SEric W. Biederman }
1717e51b6ba0SEric W. Biederman 
1718e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root)
1719e51b6ba0SEric W. Biederman {
1720e51b6ba0SEric W. Biederman 	spin_lock(&sysctl_lock);
1721e51b6ba0SEric W. Biederman 	list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1722e51b6ba0SEric W. Biederman 	spin_unlock(&sysctl_lock);
1723e51b6ba0SEric W. Biederman }
1724e51b6ba0SEric W. Biederman 
1725b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL
17262c4c7155SPavel Emelyanov /* Perform the actual read/write of a sysctl table entry. */
1727d7321cd6SPavel Emelyanov static int do_sysctl_strategy(struct ctl_table_root *root,
1728d7321cd6SPavel Emelyanov 			struct ctl_table *table,
17292c4c7155SPavel Emelyanov 			void __user *oldval, size_t __user *oldlenp,
17302c4c7155SPavel Emelyanov 			void __user *newval, size_t newlen)
17312c4c7155SPavel Emelyanov {
17322c4c7155SPavel Emelyanov 	int op = 0, rc;
17332c4c7155SPavel Emelyanov 
17342c4c7155SPavel Emelyanov 	if (oldval)
1735e6305c43SAl Viro 		op |= MAY_READ;
17362c4c7155SPavel Emelyanov 	if (newval)
1737e6305c43SAl Viro 		op |= MAY_WRITE;
1738d7321cd6SPavel Emelyanov 	if (sysctl_perm(root, table, op))
17392c4c7155SPavel Emelyanov 		return -EPERM;
17402c4c7155SPavel Emelyanov 
17412c4c7155SPavel Emelyanov 	if (table->strategy) {
1742f221e726SAlexey Dobriyan 		rc = table->strategy(table, oldval, oldlenp, newval, newlen);
17432c4c7155SPavel Emelyanov 		if (rc < 0)
17442c4c7155SPavel Emelyanov 			return rc;
17452c4c7155SPavel Emelyanov 		if (rc > 0)
17462c4c7155SPavel Emelyanov 			return 0;
17472c4c7155SPavel Emelyanov 	}
17482c4c7155SPavel Emelyanov 
17492c4c7155SPavel Emelyanov 	/* If there is no strategy routine, or if the strategy returns
17502c4c7155SPavel Emelyanov 	 * zero, proceed with automatic r/w */
17512c4c7155SPavel Emelyanov 	if (table->data && table->maxlen) {
1752f221e726SAlexey Dobriyan 		rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
17532c4c7155SPavel Emelyanov 		if (rc < 0)
17542c4c7155SPavel Emelyanov 			return rc;
17552c4c7155SPavel Emelyanov 	}
17562c4c7155SPavel Emelyanov 	return 0;
17572c4c7155SPavel Emelyanov }
17582c4c7155SPavel Emelyanov 
17592c4c7155SPavel Emelyanov static int parse_table(int __user *name, int nlen,
17602c4c7155SPavel Emelyanov 		       void __user *oldval, size_t __user *oldlenp,
17612c4c7155SPavel Emelyanov 		       void __user *newval, size_t newlen,
1762d7321cd6SPavel Emelyanov 		       struct ctl_table_root *root,
17632c4c7155SPavel Emelyanov 		       struct ctl_table *table)
17642c4c7155SPavel Emelyanov {
17652c4c7155SPavel Emelyanov 	int n;
17662c4c7155SPavel Emelyanov repeat:
17672c4c7155SPavel Emelyanov 	if (!nlen)
17682c4c7155SPavel Emelyanov 		return -ENOTDIR;
17692c4c7155SPavel Emelyanov 	if (get_user(n, name))
17702c4c7155SPavel Emelyanov 		return -EFAULT;
17712c4c7155SPavel Emelyanov 	for ( ; table->ctl_name || table->procname; table++) {
17722c4c7155SPavel Emelyanov 		if (!table->ctl_name)
17732c4c7155SPavel Emelyanov 			continue;
17742c4c7155SPavel Emelyanov 		if (n == table->ctl_name) {
17752c4c7155SPavel Emelyanov 			int error;
17762c4c7155SPavel Emelyanov 			if (table->child) {
1777e6305c43SAl Viro 				if (sysctl_perm(root, table, MAY_EXEC))
17782c4c7155SPavel Emelyanov 					return -EPERM;
17792c4c7155SPavel Emelyanov 				name++;
17802c4c7155SPavel Emelyanov 				nlen--;
17812c4c7155SPavel Emelyanov 				table = table->child;
17822c4c7155SPavel Emelyanov 				goto repeat;
17832c4c7155SPavel Emelyanov 			}
1784f221e726SAlexey Dobriyan 			error = do_sysctl_strategy(root, table,
17852c4c7155SPavel Emelyanov 						   oldval, oldlenp,
17862c4c7155SPavel Emelyanov 						   newval, newlen);
17872c4c7155SPavel Emelyanov 			return error;
17882c4c7155SPavel Emelyanov 		}
17892c4c7155SPavel Emelyanov 	}
17902c4c7155SPavel Emelyanov 	return -ENOTDIR;
17912c4c7155SPavel Emelyanov }
17922c4c7155SPavel Emelyanov 
17931da177e4SLinus Torvalds int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
17941da177e4SLinus Torvalds 	       void __user *newval, size_t newlen)
17951da177e4SLinus Torvalds {
1796805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1797330d57fbSAl Viro 	int error = -ENOTDIR;
17981da177e4SLinus Torvalds 
17991da177e4SLinus Torvalds 	if (nlen <= 0 || nlen >= CTL_MAXNAME)
18001da177e4SLinus Torvalds 		return -ENOTDIR;
18011da177e4SLinus Torvalds 	if (oldval) {
18021da177e4SLinus Torvalds 		int old_len;
18031da177e4SLinus Torvalds 		if (!oldlenp || get_user(old_len, oldlenp))
18041da177e4SLinus Torvalds 			return -EFAULT;
18051da177e4SLinus Torvalds 	}
1806330d57fbSAl Viro 
1807805b5d5eSEric W. Biederman 	for (head = sysctl_head_next(NULL); head;
1808805b5d5eSEric W. Biederman 			head = sysctl_head_next(head)) {
1809330d57fbSAl Viro 		error = parse_table(name, nlen, oldval, oldlenp,
1810d7321cd6SPavel Emelyanov 					newval, newlen,
1811d7321cd6SPavel Emelyanov 					head->root, head->ctl_table);
1812805b5d5eSEric W. Biederman 		if (error != -ENOTDIR) {
1813805b5d5eSEric W. Biederman 			sysctl_head_finish(head);
1814330d57fbSAl Viro 			break;
1815805b5d5eSEric W. Biederman 		}
1816805b5d5eSEric W. Biederman 	}
18171da177e4SLinus Torvalds 	return error;
18181da177e4SLinus Torvalds }
18191da177e4SLinus Torvalds 
18201e7bfb21SHeiko Carstens SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
18211da177e4SLinus Torvalds {
18221da177e4SLinus Torvalds 	struct __sysctl_args tmp;
18231da177e4SLinus Torvalds 	int error;
18241da177e4SLinus Torvalds 
18251da177e4SLinus Torvalds 	if (copy_from_user(&tmp, args, sizeof(tmp)))
18261da177e4SLinus Torvalds 		return -EFAULT;
18271da177e4SLinus Torvalds 
18287058cb02SEric W. Biederman 	error = deprecated_sysctl_warning(&tmp);
18297058cb02SEric W. Biederman 	if (error)
18307058cb02SEric W. Biederman 		goto out;
18317058cb02SEric W. Biederman 
18321da177e4SLinus Torvalds 	lock_kernel();
18331da177e4SLinus Torvalds 	error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
18341da177e4SLinus Torvalds 			  tmp.newval, tmp.newlen);
18351da177e4SLinus Torvalds 	unlock_kernel();
18367058cb02SEric W. Biederman out:
18371da177e4SLinus Torvalds 	return error;
18381da177e4SLinus Torvalds }
1839b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */
18401da177e4SLinus Torvalds 
18411da177e4SLinus Torvalds /*
18421ff007ebSEric W. Biederman  * sysctl_perm does NOT grant the superuser all rights automatically, because
18431da177e4SLinus Torvalds  * some sysctl variables are readonly even to root.
18441da177e4SLinus Torvalds  */
18451da177e4SLinus Torvalds 
18461da177e4SLinus Torvalds static int test_perm(int mode, int op)
18471da177e4SLinus Torvalds {
184876aac0e9SDavid Howells 	if (!current_euid())
18491da177e4SLinus Torvalds 		mode >>= 6;
18501da177e4SLinus Torvalds 	else if (in_egroup_p(0))
18511da177e4SLinus Torvalds 		mode >>= 3;
1852e6305c43SAl Viro 	if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
18531da177e4SLinus Torvalds 		return 0;
18541da177e4SLinus Torvalds 	return -EACCES;
18551da177e4SLinus Torvalds }
18561da177e4SLinus Torvalds 
1857d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
18581da177e4SLinus Torvalds {
18591da177e4SLinus Torvalds 	int error;
1860d7321cd6SPavel Emelyanov 	int mode;
1861d7321cd6SPavel Emelyanov 
1862e6305c43SAl Viro 	error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
18631da177e4SLinus Torvalds 	if (error)
18641da177e4SLinus Torvalds 		return error;
1865d7321cd6SPavel Emelyanov 
1866d7321cd6SPavel Emelyanov 	if (root->permissions)
1867d7321cd6SPavel Emelyanov 		mode = root->permissions(root, current->nsproxy, table);
1868d7321cd6SPavel Emelyanov 	else
1869d7321cd6SPavel Emelyanov 		mode = table->mode;
1870d7321cd6SPavel Emelyanov 
1871d7321cd6SPavel Emelyanov 	return test_perm(mode, op);
18721da177e4SLinus Torvalds }
18731da177e4SLinus Torvalds 
1874d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1875d912b0ccSEric W. Biederman {
1876d912b0ccSEric W. Biederman 	for (; table->ctl_name || table->procname; table++) {
1877d912b0ccSEric W. Biederman 		table->parent = parent;
1878d912b0ccSEric W. Biederman 		if (table->child)
1879d912b0ccSEric W. Biederman 			sysctl_set_parent(table, table->child);
1880d912b0ccSEric W. Biederman 	}
1881d912b0ccSEric W. Biederman }
1882d912b0ccSEric W. Biederman 
1883d912b0ccSEric W. Biederman static __init int sysctl_init(void)
1884d912b0ccSEric W. Biederman {
1885d912b0ccSEric W. Biederman 	sysctl_set_parent(NULL, root_table);
188688f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
188788f458e4SHolger Schurig 	{
188888f458e4SHolger Schurig 		int err;
1889e51b6ba0SEric W. Biederman 		err = sysctl_check_table(current->nsproxy, root_table);
189088f458e4SHolger Schurig 	}
189188f458e4SHolger Schurig #endif
1892d912b0ccSEric W. Biederman 	return 0;
1893d912b0ccSEric W. Biederman }
1894d912b0ccSEric W. Biederman 
1895d912b0ccSEric W. Biederman core_initcall(sysctl_init);
1896d912b0ccSEric W. Biederman 
1897bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch,
1898bfbcf034SAl Viro 				      struct ctl_table *table)
1899ae7edeccSAl Viro {
1900ae7edeccSAl Viro 	struct ctl_table *p;
1901ae7edeccSAl Viro 	const char *s = branch->procname;
1902ae7edeccSAl Viro 
1903ae7edeccSAl Viro 	/* branch should have named subdirectory as its first element */
1904ae7edeccSAl Viro 	if (!s || !branch->child)
1905bfbcf034SAl Viro 		return NULL;
1906ae7edeccSAl Viro 
1907ae7edeccSAl Viro 	/* ... and nothing else */
1908ae7edeccSAl Viro 	if (branch[1].procname || branch[1].ctl_name)
1909bfbcf034SAl Viro 		return NULL;
1910ae7edeccSAl Viro 
1911ae7edeccSAl Viro 	/* table should contain subdirectory with the same name */
1912ae7edeccSAl Viro 	for (p = table; p->procname || p->ctl_name; p++) {
1913ae7edeccSAl Viro 		if (!p->child)
1914ae7edeccSAl Viro 			continue;
1915ae7edeccSAl Viro 		if (p->procname && strcmp(p->procname, s) == 0)
1916bfbcf034SAl Viro 			return p;
1917ae7edeccSAl Viro 	}
1918bfbcf034SAl Viro 	return NULL;
1919ae7edeccSAl Viro }
1920ae7edeccSAl Viro 
1921ae7edeccSAl Viro /* see if attaching q to p would be an improvement */
1922ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1923ae7edeccSAl Viro {
1924ae7edeccSAl Viro 	struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1925bfbcf034SAl Viro 	struct ctl_table *next;
1926ae7edeccSAl Viro 	int is_better = 0;
1927ae7edeccSAl Viro 	int not_in_parent = !p->attached_by;
1928ae7edeccSAl Viro 
1929bfbcf034SAl Viro 	while ((next = is_branch_in(by, to)) != NULL) {
1930ae7edeccSAl Viro 		if (by == q->attached_by)
1931ae7edeccSAl Viro 			is_better = 1;
1932ae7edeccSAl Viro 		if (to == p->attached_by)
1933ae7edeccSAl Viro 			not_in_parent = 1;
1934ae7edeccSAl Viro 		by = by->child;
1935bfbcf034SAl Viro 		to = next->child;
1936ae7edeccSAl Viro 	}
1937ae7edeccSAl Viro 
1938ae7edeccSAl Viro 	if (is_better && not_in_parent) {
1939ae7edeccSAl Viro 		q->attached_by = by;
1940ae7edeccSAl Viro 		q->attached_to = to;
1941ae7edeccSAl Viro 		q->parent = p;
1942ae7edeccSAl Viro 	}
1943ae7edeccSAl Viro }
1944ae7edeccSAl Viro 
19451da177e4SLinus Torvalds /**
1946e51b6ba0SEric W. Biederman  * __register_sysctl_paths - register a sysctl hierarchy
1947e51b6ba0SEric W. Biederman  * @root: List of sysctl headers to register on
1948e51b6ba0SEric W. Biederman  * @namespaces: Data to compute which lists of sysctl entries are visible
194929e796fdSEric W. Biederman  * @path: The path to the directory the sysctl table is in.
19501da177e4SLinus Torvalds  * @table: the top-level table structure
19511da177e4SLinus Torvalds  *
19521da177e4SLinus Torvalds  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
195329e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
19541da177e4SLinus Torvalds  *
1955d8217f07SEric W. Biederman  * The members of the &struct ctl_table structure are used as follows:
19561da177e4SLinus Torvalds  *
19571da177e4SLinus Torvalds  * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
19581da177e4SLinus Torvalds  *            must be unique within that level of sysctl
19591da177e4SLinus Torvalds  *
19601da177e4SLinus Torvalds  * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
19611da177e4SLinus Torvalds  *            enter a sysctl file
19621da177e4SLinus Torvalds  *
19631da177e4SLinus Torvalds  * data - a pointer to data for use by proc_handler
19641da177e4SLinus Torvalds  *
19651da177e4SLinus Torvalds  * maxlen - the maximum size in bytes of the data
19661da177e4SLinus Torvalds  *
19671da177e4SLinus Torvalds  * mode - the file permissions for the /proc/sys file, and for sysctl(2)
19681da177e4SLinus Torvalds  *
19691da177e4SLinus Torvalds  * child - a pointer to the child sysctl table if this entry is a directory, or
19701da177e4SLinus Torvalds  *         %NULL.
19711da177e4SLinus Torvalds  *
19721da177e4SLinus Torvalds  * proc_handler - the text handler routine (described below)
19731da177e4SLinus Torvalds  *
19741da177e4SLinus Torvalds  * strategy - the strategy routine (described below)
19751da177e4SLinus Torvalds  *
19761da177e4SLinus Torvalds  * de - for internal use by the sysctl routines
19771da177e4SLinus Torvalds  *
19781da177e4SLinus Torvalds  * extra1, extra2 - extra pointers usable by the proc handler routines
19791da177e4SLinus Torvalds  *
19801da177e4SLinus Torvalds  * Leaf nodes in the sysctl tree will be represented by a single file
19811da177e4SLinus Torvalds  * under /proc; non-leaf nodes will be represented by directories.
19821da177e4SLinus Torvalds  *
19831da177e4SLinus Torvalds  * sysctl(2) can automatically manage read and write requests through
19841da177e4SLinus Torvalds  * the sysctl table.  The data and maxlen fields of the ctl_table
19851da177e4SLinus Torvalds  * struct enable minimal validation of the values being written to be
19861da177e4SLinus Torvalds  * performed, and the mode field allows minimal authentication.
19871da177e4SLinus Torvalds  *
19881da177e4SLinus Torvalds  * More sophisticated management can be enabled by the provision of a
19891da177e4SLinus Torvalds  * strategy routine with the table entry.  This will be called before
19901da177e4SLinus Torvalds  * any automatic read or write of the data is performed.
19911da177e4SLinus Torvalds  *
19921da177e4SLinus Torvalds  * The strategy routine may return
19931da177e4SLinus Torvalds  *
19941da177e4SLinus Torvalds  * < 0 - Error occurred (error is passed to user process)
19951da177e4SLinus Torvalds  *
19961da177e4SLinus Torvalds  * 0   - OK - proceed with automatic read or write.
19971da177e4SLinus Torvalds  *
19981da177e4SLinus Torvalds  * > 0 - OK - read or write has been done by the strategy routine, so
19991da177e4SLinus Torvalds  *       return immediately.
20001da177e4SLinus Torvalds  *
20011da177e4SLinus Torvalds  * There must be a proc_handler routine for any terminal nodes
20021da177e4SLinus Torvalds  * mirrored under /proc/sys (non-terminals are handled by a built-in
20031da177e4SLinus Torvalds  * directory handler).  Several default handlers are available to
20041da177e4SLinus Torvalds  * cover common cases -
20051da177e4SLinus Torvalds  *
20061da177e4SLinus Torvalds  * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
20071da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
20081da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
20091da177e4SLinus Torvalds  *
20101da177e4SLinus Torvalds  * It is the handler's job to read the input buffer from user memory
20111da177e4SLinus Torvalds  * and process it. The handler should return 0 on success.
20121da177e4SLinus Torvalds  *
20131da177e4SLinus Torvalds  * This routine returns %NULL on a failure to register, and a pointer
20141da177e4SLinus Torvalds  * to the table header on success.
20151da177e4SLinus Torvalds  */
2016e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths(
2017e51b6ba0SEric W. Biederman 	struct ctl_table_root *root,
2018e51b6ba0SEric W. Biederman 	struct nsproxy *namespaces,
2019e51b6ba0SEric W. Biederman 	const struct ctl_path *path, struct ctl_table *table)
20201da177e4SLinus Torvalds {
202129e796fdSEric W. Biederman 	struct ctl_table_header *header;
202229e796fdSEric W. Biederman 	struct ctl_table *new, **prevp;
202329e796fdSEric W. Biederman 	unsigned int n, npath;
2024ae7edeccSAl Viro 	struct ctl_table_set *set;
202529e796fdSEric W. Biederman 
202629e796fdSEric W. Biederman 	/* Count the path components */
202729e796fdSEric W. Biederman 	for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
202829e796fdSEric W. Biederman 		;
202929e796fdSEric W. Biederman 
203029e796fdSEric W. Biederman 	/*
203129e796fdSEric W. Biederman 	 * For each path component, allocate a 2-element ctl_table array.
203229e796fdSEric W. Biederman 	 * The first array element will be filled with the sysctl entry
203329e796fdSEric W. Biederman 	 * for this, the second will be the sentinel (ctl_name == 0).
203429e796fdSEric W. Biederman 	 *
203529e796fdSEric W. Biederman 	 * We allocate everything in one go so that we don't have to
203629e796fdSEric W. Biederman 	 * worry about freeing additional memory in unregister_sysctl_table.
203729e796fdSEric W. Biederman 	 */
203829e796fdSEric W. Biederman 	header = kzalloc(sizeof(struct ctl_table_header) +
203929e796fdSEric W. Biederman 			 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
204029e796fdSEric W. Biederman 	if (!header)
20411da177e4SLinus Torvalds 		return NULL;
204229e796fdSEric W. Biederman 
204329e796fdSEric W. Biederman 	new = (struct ctl_table *) (header + 1);
204429e796fdSEric W. Biederman 
204529e796fdSEric W. Biederman 	/* Now connect the dots */
204629e796fdSEric W. Biederman 	prevp = &header->ctl_table;
204729e796fdSEric W. Biederman 	for (n = 0; n < npath; ++n, ++path) {
204829e796fdSEric W. Biederman 		/* Copy the procname */
204929e796fdSEric W. Biederman 		new->procname = path->procname;
205029e796fdSEric W. Biederman 		new->ctl_name = path->ctl_name;
205129e796fdSEric W. Biederman 		new->mode     = 0555;
205229e796fdSEric W. Biederman 
205329e796fdSEric W. Biederman 		*prevp = new;
205429e796fdSEric W. Biederman 		prevp = &new->child;
205529e796fdSEric W. Biederman 
205629e796fdSEric W. Biederman 		new += 2;
205729e796fdSEric W. Biederman 	}
205829e796fdSEric W. Biederman 	*prevp = table;
205923eb06deSEric W. Biederman 	header->ctl_table_arg = table;
206029e796fdSEric W. Biederman 
206129e796fdSEric W. Biederman 	INIT_LIST_HEAD(&header->ctl_entry);
206229e796fdSEric W. Biederman 	header->used = 0;
206329e796fdSEric W. Biederman 	header->unregistering = NULL;
2064e51b6ba0SEric W. Biederman 	header->root = root;
206529e796fdSEric W. Biederman 	sysctl_set_parent(NULL, header->ctl_table);
2066f7e6ced4SAl Viro 	header->count = 1;
206788f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
2068e51b6ba0SEric W. Biederman 	if (sysctl_check_table(namespaces, header->ctl_table)) {
206929e796fdSEric W. Biederman 		kfree(header);
2070fc6cd25bSEric W. Biederman 		return NULL;
2071fc6cd25bSEric W. Biederman 	}
207288f458e4SHolger Schurig #endif
2073330d57fbSAl Viro 	spin_lock(&sysctl_lock);
207473455092SAl Viro 	header->set = lookup_header_set(root, namespaces);
2075ae7edeccSAl Viro 	header->attached_by = header->ctl_table;
2076ae7edeccSAl Viro 	header->attached_to = root_table;
2077ae7edeccSAl Viro 	header->parent = &root_table_header;
2078ae7edeccSAl Viro 	for (set = header->set; set; set = set->parent) {
2079ae7edeccSAl Viro 		struct ctl_table_header *p;
2080ae7edeccSAl Viro 		list_for_each_entry(p, &set->list, ctl_entry) {
2081ae7edeccSAl Viro 			if (p->unregistering)
2082ae7edeccSAl Viro 				continue;
2083ae7edeccSAl Viro 			try_attach(p, header);
2084ae7edeccSAl Viro 		}
2085ae7edeccSAl Viro 	}
2086ae7edeccSAl Viro 	header->parent->count++;
208773455092SAl Viro 	list_add_tail(&header->ctl_entry, &header->set->list);
2088330d57fbSAl Viro 	spin_unlock(&sysctl_lock);
208929e796fdSEric W. Biederman 
209029e796fdSEric W. Biederman 	return header;
209129e796fdSEric W. Biederman }
209229e796fdSEric W. Biederman 
209329e796fdSEric W. Biederman /**
2094e51b6ba0SEric W. Biederman  * register_sysctl_table_path - register a sysctl table hierarchy
2095e51b6ba0SEric W. Biederman  * @path: The path to the directory the sysctl table is in.
2096e51b6ba0SEric W. Biederman  * @table: the top-level table structure
2097e51b6ba0SEric W. Biederman  *
2098e51b6ba0SEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2099e51b6ba0SEric W. Biederman  * array. A completely 0 filled entry terminates the table.
2100e51b6ba0SEric W. Biederman  *
2101e51b6ba0SEric W. Biederman  * See __register_sysctl_paths for more details.
2102e51b6ba0SEric W. Biederman  */
2103e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2104e51b6ba0SEric W. Biederman 						struct ctl_table *table)
2105e51b6ba0SEric W. Biederman {
2106e51b6ba0SEric W. Biederman 	return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
2107e51b6ba0SEric W. Biederman 					path, table);
2108e51b6ba0SEric W. Biederman }
2109e51b6ba0SEric W. Biederman 
2110e51b6ba0SEric W. Biederman /**
211129e796fdSEric W. Biederman  * register_sysctl_table - register a sysctl table hierarchy
211229e796fdSEric W. Biederman  * @table: the top-level table structure
211329e796fdSEric W. Biederman  *
211429e796fdSEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
211529e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
211629e796fdSEric W. Biederman  *
211729e796fdSEric W. Biederman  * See register_sysctl_paths for more details.
211829e796fdSEric W. Biederman  */
211929e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
212029e796fdSEric W. Biederman {
212129e796fdSEric W. Biederman 	static const struct ctl_path null_path[] = { {} };
212229e796fdSEric W. Biederman 
212329e796fdSEric W. Biederman 	return register_sysctl_paths(null_path, table);
21241da177e4SLinus Torvalds }
21251da177e4SLinus Torvalds 
21261da177e4SLinus Torvalds /**
21271da177e4SLinus Torvalds  * unregister_sysctl_table - unregister a sysctl table hierarchy
21281da177e4SLinus Torvalds  * @header: the header returned from register_sysctl_table
21291da177e4SLinus Torvalds  *
21301da177e4SLinus Torvalds  * Unregisters the sysctl table and all children. proc entries may not
21311da177e4SLinus Torvalds  * actually be removed until they are no longer used by anyone.
21321da177e4SLinus Torvalds  */
21331da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header)
21341da177e4SLinus Torvalds {
2135330d57fbSAl Viro 	might_sleep();
2136f1dad166SPavel Emelyanov 
2137f1dad166SPavel Emelyanov 	if (header == NULL)
2138f1dad166SPavel Emelyanov 		return;
2139f1dad166SPavel Emelyanov 
2140330d57fbSAl Viro 	spin_lock(&sysctl_lock);
2141330d57fbSAl Viro 	start_unregistering(header);
2142ae7edeccSAl Viro 	if (!--header->parent->count) {
2143ae7edeccSAl Viro 		WARN_ON(1);
2144ae7edeccSAl Viro 		kfree(header->parent);
2145ae7edeccSAl Viro 	}
2146f7e6ced4SAl Viro 	if (!--header->count)
21471da177e4SLinus Torvalds 		kfree(header);
2148f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
21491da177e4SLinus Torvalds }
21501da177e4SLinus Torvalds 
21519043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p)
21529043476fSAl Viro {
21539043476fSAl Viro 	struct ctl_table_set *set = p->set;
21549043476fSAl Viro 	int res;
21559043476fSAl Viro 	spin_lock(&sysctl_lock);
21569043476fSAl Viro 	if (p->unregistering)
21579043476fSAl Viro 		res = 0;
21589043476fSAl Viro 	else if (!set->is_seen)
21599043476fSAl Viro 		res = 1;
21609043476fSAl Viro 	else
21619043476fSAl Viro 		res = set->is_seen(set);
21629043476fSAl Viro 	spin_unlock(&sysctl_lock);
21639043476fSAl Viro 	return res;
21649043476fSAl Viro }
21659043476fSAl Viro 
216673455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
216773455092SAl Viro 	struct ctl_table_set *parent,
216873455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
216973455092SAl Viro {
217073455092SAl Viro 	INIT_LIST_HEAD(&p->list);
217173455092SAl Viro 	p->parent = parent ? parent : &sysctl_table_root.default_set;
217273455092SAl Viro 	p->is_seen = is_seen;
217373455092SAl Viro }
217473455092SAl Viro 
2175b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */
2176d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
2177b89a8171SEric W. Biederman {
2178b89a8171SEric W. Biederman 	return NULL;
2179b89a8171SEric W. Biederman }
2180b89a8171SEric W. Biederman 
218129e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
218229e796fdSEric W. Biederman 						    struct ctl_table *table)
218329e796fdSEric W. Biederman {
218429e796fdSEric W. Biederman 	return NULL;
218529e796fdSEric W. Biederman }
218629e796fdSEric W. Biederman 
2187b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table)
2188b89a8171SEric W. Biederman {
2189b89a8171SEric W. Biederman }
2190b89a8171SEric W. Biederman 
219173455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
219273455092SAl Viro 	struct ctl_table_set *parent,
219373455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
219473455092SAl Viro {
219573455092SAl Viro }
219673455092SAl Viro 
2197f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
2198f7e6ced4SAl Viro {
2199f7e6ced4SAl Viro }
2200f7e6ced4SAl Viro 
2201b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
2202b89a8171SEric W. Biederman 
22031da177e4SLinus Torvalds /*
22041da177e4SLinus Torvalds  * /proc/sys support
22051da177e4SLinus Torvalds  */
22061da177e4SLinus Torvalds 
2207b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL
22081da177e4SLinus Torvalds 
2209b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write,
2210b1ba4dddSAdrian Bunk 			   struct file *filp, void __user *buffer,
2211b1ba4dddSAdrian Bunk 			   size_t *lenp, loff_t *ppos)
2212f5dd3d6fSSam Vilain {
2213f5dd3d6fSSam Vilain 	size_t len;
2214f5dd3d6fSSam Vilain 	char __user *p;
2215f5dd3d6fSSam Vilain 	char c;
2216f5dd3d6fSSam Vilain 
22178d060877SOleg Nesterov 	if (!data || !maxlen || !*lenp) {
2218f5dd3d6fSSam Vilain 		*lenp = 0;
2219f5dd3d6fSSam Vilain 		return 0;
2220f5dd3d6fSSam Vilain 	}
2221f5dd3d6fSSam Vilain 
2222f5dd3d6fSSam Vilain 	if (write) {
2223f5dd3d6fSSam Vilain 		len = 0;
2224f5dd3d6fSSam Vilain 		p = buffer;
2225f5dd3d6fSSam Vilain 		while (len < *lenp) {
2226f5dd3d6fSSam Vilain 			if (get_user(c, p++))
2227f5dd3d6fSSam Vilain 				return -EFAULT;
2228f5dd3d6fSSam Vilain 			if (c == 0 || c == '\n')
2229f5dd3d6fSSam Vilain 				break;
2230f5dd3d6fSSam Vilain 			len++;
2231f5dd3d6fSSam Vilain 		}
2232f5dd3d6fSSam Vilain 		if (len >= maxlen)
2233f5dd3d6fSSam Vilain 			len = maxlen-1;
2234f5dd3d6fSSam Vilain 		if(copy_from_user(data, buffer, len))
2235f5dd3d6fSSam Vilain 			return -EFAULT;
2236f5dd3d6fSSam Vilain 		((char *) data)[len] = 0;
2237f5dd3d6fSSam Vilain 		*ppos += *lenp;
2238f5dd3d6fSSam Vilain 	} else {
2239f5dd3d6fSSam Vilain 		len = strlen(data);
2240f5dd3d6fSSam Vilain 		if (len > maxlen)
2241f5dd3d6fSSam Vilain 			len = maxlen;
22428d060877SOleg Nesterov 
22438d060877SOleg Nesterov 		if (*ppos > len) {
22448d060877SOleg Nesterov 			*lenp = 0;
22458d060877SOleg Nesterov 			return 0;
22468d060877SOleg Nesterov 		}
22478d060877SOleg Nesterov 
22488d060877SOleg Nesterov 		data += *ppos;
22498d060877SOleg Nesterov 		len  -= *ppos;
22508d060877SOleg Nesterov 
2251f5dd3d6fSSam Vilain 		if (len > *lenp)
2252f5dd3d6fSSam Vilain 			len = *lenp;
2253f5dd3d6fSSam Vilain 		if (len)
2254f5dd3d6fSSam Vilain 			if(copy_to_user(buffer, data, len))
2255f5dd3d6fSSam Vilain 				return -EFAULT;
2256f5dd3d6fSSam Vilain 		if (len < *lenp) {
2257f5dd3d6fSSam Vilain 			if(put_user('\n', ((char __user *) buffer) + len))
2258f5dd3d6fSSam Vilain 				return -EFAULT;
2259f5dd3d6fSSam Vilain 			len++;
2260f5dd3d6fSSam Vilain 		}
2261f5dd3d6fSSam Vilain 		*lenp = len;
2262f5dd3d6fSSam Vilain 		*ppos += len;
2263f5dd3d6fSSam Vilain 	}
2264f5dd3d6fSSam Vilain 	return 0;
2265f5dd3d6fSSam Vilain }
2266f5dd3d6fSSam Vilain 
22671da177e4SLinus Torvalds /**
22681da177e4SLinus Torvalds  * proc_dostring - read a string sysctl
22691da177e4SLinus Torvalds  * @table: the sysctl table
22701da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
22711da177e4SLinus Torvalds  * @filp: the file structure
22721da177e4SLinus Torvalds  * @buffer: the user buffer
22731da177e4SLinus Torvalds  * @lenp: the size of the user buffer
22741da177e4SLinus Torvalds  * @ppos: file position
22751da177e4SLinus Torvalds  *
22761da177e4SLinus Torvalds  * Reads/writes a string from/to the user buffer. If the kernel
22771da177e4SLinus Torvalds  * buffer provided is not large enough to hold the string, the
22781da177e4SLinus Torvalds  * string is truncated. The copied string is %NULL-terminated.
22791da177e4SLinus Torvalds  * If the string is being read by the user process, it is copied
22801da177e4SLinus Torvalds  * and a newline '\n' is added. It is truncated if the buffer is
22811da177e4SLinus Torvalds  * not large enough.
22821da177e4SLinus Torvalds  *
22831da177e4SLinus Torvalds  * Returns 0 on success.
22841da177e4SLinus Torvalds  */
2285d8217f07SEric W. Biederman int proc_dostring(struct ctl_table *table, int write, struct file *filp,
22861da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
22871da177e4SLinus Torvalds {
2288f5dd3d6fSSam Vilain 	return _proc_do_string(table->data, table->maxlen, write, filp,
2289f5dd3d6fSSam Vilain 			       buffer, lenp, ppos);
22901da177e4SLinus Torvalds }
22911da177e4SLinus Torvalds 
22921da177e4SLinus Torvalds 
22931da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
22941da177e4SLinus Torvalds 				 int *valp,
22951da177e4SLinus Torvalds 				 int write, void *data)
22961da177e4SLinus Torvalds {
22971da177e4SLinus Torvalds 	if (write) {
22981da177e4SLinus Torvalds 		*valp = *negp ? -*lvalp : *lvalp;
22991da177e4SLinus Torvalds 	} else {
23001da177e4SLinus Torvalds 		int val = *valp;
23011da177e4SLinus Torvalds 		if (val < 0) {
23021da177e4SLinus Torvalds 			*negp = -1;
23031da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
23041da177e4SLinus Torvalds 		} else {
23051da177e4SLinus Torvalds 			*negp = 0;
23061da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
23071da177e4SLinus Torvalds 		}
23081da177e4SLinus Torvalds 	}
23091da177e4SLinus Torvalds 	return 0;
23101da177e4SLinus Torvalds }
23111da177e4SLinus Torvalds 
2312d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
2313fcfbd547SKirill Korotaev 		  int write, struct file *filp, void __user *buffer,
2314fcfbd547SKirill Korotaev 		  size_t *lenp, loff_t *ppos,
23151da177e4SLinus Torvalds 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
23161da177e4SLinus Torvalds 			      int write, void *data),
23171da177e4SLinus Torvalds 		  void *data)
23181da177e4SLinus Torvalds {
23191da177e4SLinus Torvalds #define TMPBUFLEN 21
23207338f299SSukanto Ghosh 	int *i, vleft, first = 1, neg;
23211da177e4SLinus Torvalds 	unsigned long lval;
23221da177e4SLinus Torvalds 	size_t left, len;
23231da177e4SLinus Torvalds 
23241da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
23251da177e4SLinus Torvalds 	char __user *s = buffer;
23261da177e4SLinus Torvalds 
2327fcfbd547SKirill Korotaev 	if (!tbl_data || !table->maxlen || !*lenp ||
23281da177e4SLinus Torvalds 	    (*ppos && !write)) {
23291da177e4SLinus Torvalds 		*lenp = 0;
23301da177e4SLinus Torvalds 		return 0;
23311da177e4SLinus Torvalds 	}
23321da177e4SLinus Torvalds 
2333fcfbd547SKirill Korotaev 	i = (int *) tbl_data;
23341da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(*i);
23351da177e4SLinus Torvalds 	left = *lenp;
23361da177e4SLinus Torvalds 
23371da177e4SLinus Torvalds 	if (!conv)
23381da177e4SLinus Torvalds 		conv = do_proc_dointvec_conv;
23391da177e4SLinus Torvalds 
23401da177e4SLinus Torvalds 	for (; left && vleft--; i++, first=0) {
23411da177e4SLinus Torvalds 		if (write) {
23421da177e4SLinus Torvalds 			while (left) {
23431da177e4SLinus Torvalds 				char c;
23441da177e4SLinus Torvalds 				if (get_user(c, s))
23451da177e4SLinus Torvalds 					return -EFAULT;
23461da177e4SLinus Torvalds 				if (!isspace(c))
23471da177e4SLinus Torvalds 					break;
23481da177e4SLinus Torvalds 				left--;
23491da177e4SLinus Torvalds 				s++;
23501da177e4SLinus Torvalds 			}
23511da177e4SLinus Torvalds 			if (!left)
23521da177e4SLinus Torvalds 				break;
23531da177e4SLinus Torvalds 			neg = 0;
23541da177e4SLinus Torvalds 			len = left;
23551da177e4SLinus Torvalds 			if (len > sizeof(buf) - 1)
23561da177e4SLinus Torvalds 				len = sizeof(buf) - 1;
23571da177e4SLinus Torvalds 			if (copy_from_user(buf, s, len))
23581da177e4SLinus Torvalds 				return -EFAULT;
23591da177e4SLinus Torvalds 			buf[len] = 0;
23601da177e4SLinus Torvalds 			p = buf;
23611da177e4SLinus Torvalds 			if (*p == '-' && left > 1) {
23621da177e4SLinus Torvalds 				neg = 1;
2363bd9b0bacSBP, Praveen 				p++;
23641da177e4SLinus Torvalds 			}
23651da177e4SLinus Torvalds 			if (*p < '0' || *p > '9')
23661da177e4SLinus Torvalds 				break;
23671da177e4SLinus Torvalds 
23681da177e4SLinus Torvalds 			lval = simple_strtoul(p, &p, 0);
23691da177e4SLinus Torvalds 
23701da177e4SLinus Torvalds 			len = p-buf;
23711da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
23721da177e4SLinus Torvalds 				break;
23731da177e4SLinus Torvalds 			s += len;
23741da177e4SLinus Torvalds 			left -= len;
23751da177e4SLinus Torvalds 
23761da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 1, data))
23771da177e4SLinus Torvalds 				break;
23781da177e4SLinus Torvalds 		} else {
23791da177e4SLinus Torvalds 			p = buf;
23801da177e4SLinus Torvalds 			if (!first)
23811da177e4SLinus Torvalds 				*p++ = '\t';
23821da177e4SLinus Torvalds 
23831da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 0, data))
23841da177e4SLinus Torvalds 				break;
23851da177e4SLinus Torvalds 
23861da177e4SLinus Torvalds 			sprintf(p, "%s%lu", neg ? "-" : "", lval);
23871da177e4SLinus Torvalds 			len = strlen(buf);
23881da177e4SLinus Torvalds 			if (len > left)
23891da177e4SLinus Torvalds 				len = left;
23901da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
23911da177e4SLinus Torvalds 				return -EFAULT;
23921da177e4SLinus Torvalds 			left -= len;
23931da177e4SLinus Torvalds 			s += len;
23941da177e4SLinus Torvalds 		}
23951da177e4SLinus Torvalds 	}
23961da177e4SLinus Torvalds 
23971da177e4SLinus Torvalds 	if (!write && !first && left) {
23981da177e4SLinus Torvalds 		if(put_user('\n', s))
23991da177e4SLinus Torvalds 			return -EFAULT;
24001da177e4SLinus Torvalds 		left--, s++;
24011da177e4SLinus Torvalds 	}
24021da177e4SLinus Torvalds 	if (write) {
24031da177e4SLinus Torvalds 		while (left) {
24041da177e4SLinus Torvalds 			char c;
24051da177e4SLinus Torvalds 			if (get_user(c, s++))
24061da177e4SLinus Torvalds 				return -EFAULT;
24071da177e4SLinus Torvalds 			if (!isspace(c))
24081da177e4SLinus Torvalds 				break;
24091da177e4SLinus Torvalds 			left--;
24101da177e4SLinus Torvalds 		}
24111da177e4SLinus Torvalds 	}
24121da177e4SLinus Torvalds 	if (write && first)
24131da177e4SLinus Torvalds 		return -EINVAL;
24141da177e4SLinus Torvalds 	*lenp -= left;
24151da177e4SLinus Torvalds 	*ppos += *lenp;
24161da177e4SLinus Torvalds 	return 0;
24171da177e4SLinus Torvalds #undef TMPBUFLEN
24181da177e4SLinus Torvalds }
24191da177e4SLinus Torvalds 
2420d8217f07SEric W. Biederman static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2421fcfbd547SKirill Korotaev 		  void __user *buffer, size_t *lenp, loff_t *ppos,
2422fcfbd547SKirill Korotaev 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2423fcfbd547SKirill Korotaev 			      int write, void *data),
2424fcfbd547SKirill Korotaev 		  void *data)
2425fcfbd547SKirill Korotaev {
2426fcfbd547SKirill Korotaev 	return __do_proc_dointvec(table->data, table, write, filp,
2427fcfbd547SKirill Korotaev 			buffer, lenp, ppos, conv, data);
2428fcfbd547SKirill Korotaev }
2429fcfbd547SKirill Korotaev 
24301da177e4SLinus Torvalds /**
24311da177e4SLinus Torvalds  * proc_dointvec - read a vector of integers
24321da177e4SLinus Torvalds  * @table: the sysctl table
24331da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24341da177e4SLinus Torvalds  * @filp: the file structure
24351da177e4SLinus Torvalds  * @buffer: the user buffer
24361da177e4SLinus Torvalds  * @lenp: the size of the user buffer
24371da177e4SLinus Torvalds  * @ppos: file position
24381da177e4SLinus Torvalds  *
24391da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
24401da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
24411da177e4SLinus Torvalds  *
24421da177e4SLinus Torvalds  * Returns 0 on success.
24431da177e4SLinus Torvalds  */
2444d8217f07SEric W. Biederman int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
24451da177e4SLinus Torvalds 		     void __user *buffer, size_t *lenp, loff_t *ppos)
24461da177e4SLinus Torvalds {
24471da177e4SLinus Torvalds     return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
24481da177e4SLinus Torvalds 		    	    NULL,NULL);
24491da177e4SLinus Torvalds }
24501da177e4SLinus Torvalds 
245134f5a398STheodore Ts'o /*
245234f5a398STheodore Ts'o  * Taint values can only be increased
245325ddbb18SAndi Kleen  * This means we can safely use a temporary.
245434f5a398STheodore Ts'o  */
245525ddbb18SAndi Kleen static int proc_taint(struct ctl_table *table, int write, struct file *filp,
245634f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos)
245734f5a398STheodore Ts'o {
245825ddbb18SAndi Kleen 	struct ctl_table t;
245925ddbb18SAndi Kleen 	unsigned long tmptaint = get_taint();
246025ddbb18SAndi Kleen 	int err;
246134f5a398STheodore Ts'o 
246291fcd412SBastian Blank 	if (write && !capable(CAP_SYS_ADMIN))
246334f5a398STheodore Ts'o 		return -EPERM;
246434f5a398STheodore Ts'o 
246525ddbb18SAndi Kleen 	t = *table;
246625ddbb18SAndi Kleen 	t.data = &tmptaint;
246725ddbb18SAndi Kleen 	err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos);
246825ddbb18SAndi Kleen 	if (err < 0)
246925ddbb18SAndi Kleen 		return err;
247025ddbb18SAndi Kleen 
247125ddbb18SAndi Kleen 	if (write) {
247225ddbb18SAndi Kleen 		/*
247325ddbb18SAndi Kleen 		 * Poor man's atomic or. Not worth adding a primitive
247425ddbb18SAndi Kleen 		 * to everyone's atomic.h for this
247525ddbb18SAndi Kleen 		 */
247625ddbb18SAndi Kleen 		int i;
247725ddbb18SAndi Kleen 		for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
247825ddbb18SAndi Kleen 			if ((tmptaint >> i) & 1)
247925ddbb18SAndi Kleen 				add_taint(i);
248025ddbb18SAndi Kleen 		}
248125ddbb18SAndi Kleen 	}
248225ddbb18SAndi Kleen 
248325ddbb18SAndi Kleen 	return err;
248434f5a398STheodore Ts'o }
248534f5a398STheodore Ts'o 
24861da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param {
24871da177e4SLinus Torvalds 	int *min;
24881da177e4SLinus Torvalds 	int *max;
24891da177e4SLinus Torvalds };
24901da177e4SLinus Torvalds 
24911da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
24921da177e4SLinus Torvalds 					int *valp,
24931da177e4SLinus Torvalds 					int write, void *data)
24941da177e4SLinus Torvalds {
24951da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param *param = data;
24961da177e4SLinus Torvalds 	if (write) {
24971da177e4SLinus Torvalds 		int val = *negp ? -*lvalp : *lvalp;
24981da177e4SLinus Torvalds 		if ((param->min && *param->min > val) ||
24991da177e4SLinus Torvalds 		    (param->max && *param->max < val))
25001da177e4SLinus Torvalds 			return -EINVAL;
25011da177e4SLinus Torvalds 		*valp = val;
25021da177e4SLinus Torvalds 	} else {
25031da177e4SLinus Torvalds 		int val = *valp;
25041da177e4SLinus Torvalds 		if (val < 0) {
25051da177e4SLinus Torvalds 			*negp = -1;
25061da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
25071da177e4SLinus Torvalds 		} else {
25081da177e4SLinus Torvalds 			*negp = 0;
25091da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
25101da177e4SLinus Torvalds 		}
25111da177e4SLinus Torvalds 	}
25121da177e4SLinus Torvalds 	return 0;
25131da177e4SLinus Torvalds }
25141da177e4SLinus Torvalds 
25151da177e4SLinus Torvalds /**
25161da177e4SLinus Torvalds  * proc_dointvec_minmax - read a vector of integers with min/max values
25171da177e4SLinus Torvalds  * @table: the sysctl table
25181da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25191da177e4SLinus Torvalds  * @filp: the file structure
25201da177e4SLinus Torvalds  * @buffer: the user buffer
25211da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25221da177e4SLinus Torvalds  * @ppos: file position
25231da177e4SLinus Torvalds  *
25241da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
25251da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25261da177e4SLinus Torvalds  *
25271da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
25281da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
25291da177e4SLinus Torvalds  *
25301da177e4SLinus Torvalds  * Returns 0 on success.
25311da177e4SLinus Torvalds  */
2532d8217f07SEric W. Biederman int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
25331da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
25341da177e4SLinus Torvalds {
25351da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param param = {
25361da177e4SLinus Torvalds 		.min = (int *) table->extra1,
25371da177e4SLinus Torvalds 		.max = (int *) table->extra2,
25381da177e4SLinus Torvalds 	};
25391da177e4SLinus Torvalds 	return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
25401da177e4SLinus Torvalds 				do_proc_dointvec_minmax_conv, &param);
25411da177e4SLinus Torvalds }
25421da177e4SLinus Torvalds 
2543d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
25441da177e4SLinus Torvalds 				     struct file *filp,
25451da177e4SLinus Torvalds 				     void __user *buffer,
25461da177e4SLinus Torvalds 				     size_t *lenp, loff_t *ppos,
25471da177e4SLinus Torvalds 				     unsigned long convmul,
25481da177e4SLinus Torvalds 				     unsigned long convdiv)
25491da177e4SLinus Torvalds {
25501da177e4SLinus Torvalds #define TMPBUFLEN 21
25511da177e4SLinus Torvalds 	unsigned long *i, *min, *max, val;
25521da177e4SLinus Torvalds 	int vleft, first=1, neg;
25531da177e4SLinus Torvalds 	size_t len, left;
25541da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
25551da177e4SLinus Torvalds 	char __user *s = buffer;
25561da177e4SLinus Torvalds 
2557fcfbd547SKirill Korotaev 	if (!data || !table->maxlen || !*lenp ||
25581da177e4SLinus Torvalds 	    (*ppos && !write)) {
25591da177e4SLinus Torvalds 		*lenp = 0;
25601da177e4SLinus Torvalds 		return 0;
25611da177e4SLinus Torvalds 	}
25621da177e4SLinus Torvalds 
2563fcfbd547SKirill Korotaev 	i = (unsigned long *) data;
25641da177e4SLinus Torvalds 	min = (unsigned long *) table->extra1;
25651da177e4SLinus Torvalds 	max = (unsigned long *) table->extra2;
25661da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(unsigned long);
25671da177e4SLinus Torvalds 	left = *lenp;
25681da177e4SLinus Torvalds 
25691da177e4SLinus Torvalds 	for (; left && vleft--; i++, min++, max++, first=0) {
25701da177e4SLinus Torvalds 		if (write) {
25711da177e4SLinus Torvalds 			while (left) {
25721da177e4SLinus Torvalds 				char c;
25731da177e4SLinus Torvalds 				if (get_user(c, s))
25741da177e4SLinus Torvalds 					return -EFAULT;
25751da177e4SLinus Torvalds 				if (!isspace(c))
25761da177e4SLinus Torvalds 					break;
25771da177e4SLinus Torvalds 				left--;
25781da177e4SLinus Torvalds 				s++;
25791da177e4SLinus Torvalds 			}
25801da177e4SLinus Torvalds 			if (!left)
25811da177e4SLinus Torvalds 				break;
25821da177e4SLinus Torvalds 			neg = 0;
25831da177e4SLinus Torvalds 			len = left;
25841da177e4SLinus Torvalds 			if (len > TMPBUFLEN-1)
25851da177e4SLinus Torvalds 				len = TMPBUFLEN-1;
25861da177e4SLinus Torvalds 			if (copy_from_user(buf, s, len))
25871da177e4SLinus Torvalds 				return -EFAULT;
25881da177e4SLinus Torvalds 			buf[len] = 0;
25891da177e4SLinus Torvalds 			p = buf;
25901da177e4SLinus Torvalds 			if (*p == '-' && left > 1) {
25911da177e4SLinus Torvalds 				neg = 1;
2592bd9b0bacSBP, Praveen 				p++;
25931da177e4SLinus Torvalds 			}
25941da177e4SLinus Torvalds 			if (*p < '0' || *p > '9')
25951da177e4SLinus Torvalds 				break;
25961da177e4SLinus Torvalds 			val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
25971da177e4SLinus Torvalds 			len = p-buf;
25981da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
25991da177e4SLinus Torvalds 				break;
26001da177e4SLinus Torvalds 			if (neg)
26011da177e4SLinus Torvalds 				val = -val;
26021da177e4SLinus Torvalds 			s += len;
26031da177e4SLinus Torvalds 			left -= len;
26041da177e4SLinus Torvalds 
26051da177e4SLinus Torvalds 			if(neg)
26061da177e4SLinus Torvalds 				continue;
26071da177e4SLinus Torvalds 			if ((min && val < *min) || (max && val > *max))
26081da177e4SLinus Torvalds 				continue;
26091da177e4SLinus Torvalds 			*i = val;
26101da177e4SLinus Torvalds 		} else {
26111da177e4SLinus Torvalds 			p = buf;
26121da177e4SLinus Torvalds 			if (!first)
26131da177e4SLinus Torvalds 				*p++ = '\t';
26141da177e4SLinus Torvalds 			sprintf(p, "%lu", convdiv * (*i) / convmul);
26151da177e4SLinus Torvalds 			len = strlen(buf);
26161da177e4SLinus Torvalds 			if (len > left)
26171da177e4SLinus Torvalds 				len = left;
26181da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
26191da177e4SLinus Torvalds 				return -EFAULT;
26201da177e4SLinus Torvalds 			left -= len;
26211da177e4SLinus Torvalds 			s += len;
26221da177e4SLinus Torvalds 		}
26231da177e4SLinus Torvalds 	}
26241da177e4SLinus Torvalds 
26251da177e4SLinus Torvalds 	if (!write && !first && left) {
26261da177e4SLinus Torvalds 		if(put_user('\n', s))
26271da177e4SLinus Torvalds 			return -EFAULT;
26281da177e4SLinus Torvalds 		left--, s++;
26291da177e4SLinus Torvalds 	}
26301da177e4SLinus Torvalds 	if (write) {
26311da177e4SLinus Torvalds 		while (left) {
26321da177e4SLinus Torvalds 			char c;
26331da177e4SLinus Torvalds 			if (get_user(c, s++))
26341da177e4SLinus Torvalds 				return -EFAULT;
26351da177e4SLinus Torvalds 			if (!isspace(c))
26361da177e4SLinus Torvalds 				break;
26371da177e4SLinus Torvalds 			left--;
26381da177e4SLinus Torvalds 		}
26391da177e4SLinus Torvalds 	}
26401da177e4SLinus Torvalds 	if (write && first)
26411da177e4SLinus Torvalds 		return -EINVAL;
26421da177e4SLinus Torvalds 	*lenp -= left;
26431da177e4SLinus Torvalds 	*ppos += *lenp;
26441da177e4SLinus Torvalds 	return 0;
26451da177e4SLinus Torvalds #undef TMPBUFLEN
26461da177e4SLinus Torvalds }
26471da177e4SLinus Torvalds 
2648d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2649fcfbd547SKirill Korotaev 				     struct file *filp,
2650fcfbd547SKirill Korotaev 				     void __user *buffer,
2651fcfbd547SKirill Korotaev 				     size_t *lenp, loff_t *ppos,
2652fcfbd547SKirill Korotaev 				     unsigned long convmul,
2653fcfbd547SKirill Korotaev 				     unsigned long convdiv)
2654fcfbd547SKirill Korotaev {
2655fcfbd547SKirill Korotaev 	return __do_proc_doulongvec_minmax(table->data, table, write,
2656fcfbd547SKirill Korotaev 			filp, buffer, lenp, ppos, convmul, convdiv);
2657fcfbd547SKirill Korotaev }
2658fcfbd547SKirill Korotaev 
26591da177e4SLinus Torvalds /**
26601da177e4SLinus Torvalds  * proc_doulongvec_minmax - read a vector of long integers with min/max values
26611da177e4SLinus Torvalds  * @table: the sysctl table
26621da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
26631da177e4SLinus Torvalds  * @filp: the file structure
26641da177e4SLinus Torvalds  * @buffer: the user buffer
26651da177e4SLinus Torvalds  * @lenp: the size of the user buffer
26661da177e4SLinus Torvalds  * @ppos: file position
26671da177e4SLinus Torvalds  *
26681da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
26691da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
26701da177e4SLinus Torvalds  *
26711da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
26721da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
26731da177e4SLinus Torvalds  *
26741da177e4SLinus Torvalds  * Returns 0 on success.
26751da177e4SLinus Torvalds  */
2676d8217f07SEric W. Biederman int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
26771da177e4SLinus Torvalds 			   void __user *buffer, size_t *lenp, loff_t *ppos)
26781da177e4SLinus Torvalds {
26791da177e4SLinus Torvalds     return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
26801da177e4SLinus Torvalds }
26811da177e4SLinus Torvalds 
26821da177e4SLinus Torvalds /**
26831da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
26841da177e4SLinus Torvalds  * @table: the sysctl table
26851da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
26861da177e4SLinus Torvalds  * @filp: the file structure
26871da177e4SLinus Torvalds  * @buffer: the user buffer
26881da177e4SLinus Torvalds  * @lenp: the size of the user buffer
26891da177e4SLinus Torvalds  * @ppos: file position
26901da177e4SLinus Torvalds  *
26911da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
26921da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string. The values
26931da177e4SLinus Torvalds  * are treated as milliseconds, and converted to jiffies when they are stored.
26941da177e4SLinus Torvalds  *
26951da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
26961da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
26971da177e4SLinus Torvalds  *
26981da177e4SLinus Torvalds  * Returns 0 on success.
26991da177e4SLinus Torvalds  */
2700d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
27011da177e4SLinus Torvalds 				      struct file *filp,
27021da177e4SLinus Torvalds 				      void __user *buffer,
27031da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
27041da177e4SLinus Torvalds {
27051da177e4SLinus Torvalds     return do_proc_doulongvec_minmax(table, write, filp, buffer,
27061da177e4SLinus Torvalds 				     lenp, ppos, HZ, 1000l);
27071da177e4SLinus Torvalds }
27081da177e4SLinus Torvalds 
27091da177e4SLinus Torvalds 
27101da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
27111da177e4SLinus Torvalds 					 int *valp,
27121da177e4SLinus Torvalds 					 int write, void *data)
27131da177e4SLinus Torvalds {
27141da177e4SLinus Torvalds 	if (write) {
2715cba9f33dSBart Samwel 		if (*lvalp > LONG_MAX / HZ)
2716cba9f33dSBart Samwel 			return 1;
27171da177e4SLinus Torvalds 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
27181da177e4SLinus Torvalds 	} else {
27191da177e4SLinus Torvalds 		int val = *valp;
27201da177e4SLinus Torvalds 		unsigned long lval;
27211da177e4SLinus Torvalds 		if (val < 0) {
27221da177e4SLinus Torvalds 			*negp = -1;
27231da177e4SLinus Torvalds 			lval = (unsigned long)-val;
27241da177e4SLinus Torvalds 		} else {
27251da177e4SLinus Torvalds 			*negp = 0;
27261da177e4SLinus Torvalds 			lval = (unsigned long)val;
27271da177e4SLinus Torvalds 		}
27281da177e4SLinus Torvalds 		*lvalp = lval / HZ;
27291da177e4SLinus Torvalds 	}
27301da177e4SLinus Torvalds 	return 0;
27311da177e4SLinus Torvalds }
27321da177e4SLinus Torvalds 
27331da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
27341da177e4SLinus Torvalds 						int *valp,
27351da177e4SLinus Torvalds 						int write, void *data)
27361da177e4SLinus Torvalds {
27371da177e4SLinus Torvalds 	if (write) {
2738cba9f33dSBart Samwel 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2739cba9f33dSBart Samwel 			return 1;
27401da177e4SLinus Torvalds 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
27411da177e4SLinus Torvalds 	} else {
27421da177e4SLinus Torvalds 		int val = *valp;
27431da177e4SLinus Torvalds 		unsigned long lval;
27441da177e4SLinus Torvalds 		if (val < 0) {
27451da177e4SLinus Torvalds 			*negp = -1;
27461da177e4SLinus Torvalds 			lval = (unsigned long)-val;
27471da177e4SLinus Torvalds 		} else {
27481da177e4SLinus Torvalds 			*negp = 0;
27491da177e4SLinus Torvalds 			lval = (unsigned long)val;
27501da177e4SLinus Torvalds 		}
27511da177e4SLinus Torvalds 		*lvalp = jiffies_to_clock_t(lval);
27521da177e4SLinus Torvalds 	}
27531da177e4SLinus Torvalds 	return 0;
27541da177e4SLinus Torvalds }
27551da177e4SLinus Torvalds 
27561da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
27571da177e4SLinus Torvalds 					    int *valp,
27581da177e4SLinus Torvalds 					    int write, void *data)
27591da177e4SLinus Torvalds {
27601da177e4SLinus Torvalds 	if (write) {
27611da177e4SLinus Torvalds 		*valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
27621da177e4SLinus Torvalds 	} else {
27631da177e4SLinus Torvalds 		int val = *valp;
27641da177e4SLinus Torvalds 		unsigned long lval;
27651da177e4SLinus Torvalds 		if (val < 0) {
27661da177e4SLinus Torvalds 			*negp = -1;
27671da177e4SLinus Torvalds 			lval = (unsigned long)-val;
27681da177e4SLinus Torvalds 		} else {
27691da177e4SLinus Torvalds 			*negp = 0;
27701da177e4SLinus Torvalds 			lval = (unsigned long)val;
27711da177e4SLinus Torvalds 		}
27721da177e4SLinus Torvalds 		*lvalp = jiffies_to_msecs(lval);
27731da177e4SLinus Torvalds 	}
27741da177e4SLinus Torvalds 	return 0;
27751da177e4SLinus Torvalds }
27761da177e4SLinus Torvalds 
27771da177e4SLinus Torvalds /**
27781da177e4SLinus Torvalds  * proc_dointvec_jiffies - read a vector of integers as seconds
27791da177e4SLinus Torvalds  * @table: the sysctl table
27801da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
27811da177e4SLinus Torvalds  * @filp: the file structure
27821da177e4SLinus Torvalds  * @buffer: the user buffer
27831da177e4SLinus Torvalds  * @lenp: the size of the user buffer
27841da177e4SLinus Torvalds  * @ppos: file position
27851da177e4SLinus Torvalds  *
27861da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
27871da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
27881da177e4SLinus Torvalds  * The values read are assumed to be in seconds, and are converted into
27891da177e4SLinus Torvalds  * jiffies.
27901da177e4SLinus Torvalds  *
27911da177e4SLinus Torvalds  * Returns 0 on success.
27921da177e4SLinus Torvalds  */
2793d8217f07SEric W. Biederman int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
27941da177e4SLinus Torvalds 			  void __user *buffer, size_t *lenp, loff_t *ppos)
27951da177e4SLinus Torvalds {
27961da177e4SLinus Torvalds     return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
27971da177e4SLinus Torvalds 		    	    do_proc_dointvec_jiffies_conv,NULL);
27981da177e4SLinus Torvalds }
27991da177e4SLinus Torvalds 
28001da177e4SLinus Torvalds /**
28011da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
28021da177e4SLinus Torvalds  * @table: the sysctl table
28031da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
28041da177e4SLinus Torvalds  * @filp: the file structure
28051da177e4SLinus Torvalds  * @buffer: the user buffer
28061da177e4SLinus Torvalds  * @lenp: the size of the user buffer
28071e5d5331SRandy Dunlap  * @ppos: pointer to the file position
28081da177e4SLinus Torvalds  *
28091da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
28101da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
28111da177e4SLinus Torvalds  * The values read are assumed to be in 1/USER_HZ seconds, and
28121da177e4SLinus Torvalds  * are converted into jiffies.
28131da177e4SLinus Torvalds  *
28141da177e4SLinus Torvalds  * Returns 0 on success.
28151da177e4SLinus Torvalds  */
2816d8217f07SEric W. Biederman int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
28171da177e4SLinus Torvalds 				 void __user *buffer, size_t *lenp, loff_t *ppos)
28181da177e4SLinus Torvalds {
28191da177e4SLinus Torvalds     return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
28201da177e4SLinus Torvalds 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
28211da177e4SLinus Torvalds }
28221da177e4SLinus Torvalds 
28231da177e4SLinus Torvalds /**
28241da177e4SLinus Torvalds  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
28251da177e4SLinus Torvalds  * @table: the sysctl table
28261da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
28271da177e4SLinus Torvalds  * @filp: the file structure
28281da177e4SLinus Torvalds  * @buffer: the user buffer
28291da177e4SLinus Torvalds  * @lenp: the size of the user buffer
283067be2dd1SMartin Waitz  * @ppos: file position
283167be2dd1SMartin Waitz  * @ppos: the current position in the file
28321da177e4SLinus Torvalds  *
28331da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
28341da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
28351da177e4SLinus Torvalds  * The values read are assumed to be in 1/1000 seconds, and
28361da177e4SLinus Torvalds  * are converted into jiffies.
28371da177e4SLinus Torvalds  *
28381da177e4SLinus Torvalds  * Returns 0 on success.
28391da177e4SLinus Torvalds  */
2840d8217f07SEric W. Biederman int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
28411da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
28421da177e4SLinus Torvalds {
28431da177e4SLinus Torvalds 	return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
28441da177e4SLinus Torvalds 				do_proc_dointvec_ms_jiffies_conv, NULL);
28451da177e4SLinus Torvalds }
28461da177e4SLinus Torvalds 
2847d8217f07SEric W. Biederman static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
28489ec52099SCedric Le Goater 			   void __user *buffer, size_t *lenp, loff_t *ppos)
28499ec52099SCedric Le Goater {
28509ec52099SCedric Le Goater 	struct pid *new_pid;
28519ec52099SCedric Le Goater 	pid_t tmp;
28529ec52099SCedric Le Goater 	int r;
28539ec52099SCedric Le Goater 
28546c5f3e7bSPavel Emelyanov 	tmp = pid_vnr(cad_pid);
28559ec52099SCedric Le Goater 
28569ec52099SCedric Le Goater 	r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
28579ec52099SCedric Le Goater 			       lenp, ppos, NULL, NULL);
28589ec52099SCedric Le Goater 	if (r || !write)
28599ec52099SCedric Le Goater 		return r;
28609ec52099SCedric Le Goater 
28619ec52099SCedric Le Goater 	new_pid = find_get_pid(tmp);
28629ec52099SCedric Le Goater 	if (!new_pid)
28639ec52099SCedric Le Goater 		return -ESRCH;
28649ec52099SCedric Le Goater 
28659ec52099SCedric Le Goater 	put_pid(xchg(&cad_pid, new_pid));
28669ec52099SCedric Le Goater 	return 0;
28679ec52099SCedric Le Goater }
28689ec52099SCedric Le Goater 
28691da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */
28701da177e4SLinus Torvalds 
2871d8217f07SEric W. Biederman int proc_dostring(struct ctl_table *table, int write, struct file *filp,
28721da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
28731da177e4SLinus Torvalds {
28741da177e4SLinus Torvalds 	return -ENOSYS;
28751da177e4SLinus Torvalds }
28761da177e4SLinus Torvalds 
2877d8217f07SEric W. Biederman int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
28781da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
28791da177e4SLinus Torvalds {
28801da177e4SLinus Torvalds 	return -ENOSYS;
28811da177e4SLinus Torvalds }
28821da177e4SLinus Torvalds 
2883d8217f07SEric W. Biederman int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
28841da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
28851da177e4SLinus Torvalds {
28861da177e4SLinus Torvalds 	return -ENOSYS;
28871da177e4SLinus Torvalds }
28881da177e4SLinus Torvalds 
2889d8217f07SEric W. Biederman int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
28901da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
28911da177e4SLinus Torvalds {
28921da177e4SLinus Torvalds 	return -ENOSYS;
28931da177e4SLinus Torvalds }
28941da177e4SLinus Torvalds 
2895d8217f07SEric W. Biederman int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
28961da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
28971da177e4SLinus Torvalds {
28981da177e4SLinus Torvalds 	return -ENOSYS;
28991da177e4SLinus Torvalds }
29001da177e4SLinus Torvalds 
2901d8217f07SEric W. Biederman int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
29021da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
29031da177e4SLinus Torvalds {
29041da177e4SLinus Torvalds 	return -ENOSYS;
29051da177e4SLinus Torvalds }
29061da177e4SLinus Torvalds 
2907d8217f07SEric W. Biederman int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
29081da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
29091da177e4SLinus Torvalds {
29101da177e4SLinus Torvalds 	return -ENOSYS;
29111da177e4SLinus Torvalds }
29121da177e4SLinus Torvalds 
2913d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
29141da177e4SLinus Torvalds 				      struct file *filp,
29151da177e4SLinus Torvalds 				      void __user *buffer,
29161da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
29171da177e4SLinus Torvalds {
29181da177e4SLinus Torvalds     return -ENOSYS;
29191da177e4SLinus Torvalds }
29201da177e4SLinus Torvalds 
29211da177e4SLinus Torvalds 
29221da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */
29231da177e4SLinus Torvalds 
29241da177e4SLinus Torvalds 
2925b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL
29261da177e4SLinus Torvalds /*
29271da177e4SLinus Torvalds  * General sysctl support routines
29281da177e4SLinus Torvalds  */
29291da177e4SLinus Torvalds 
293049a0c458SEric W. Biederman /* The generic sysctl data routine (used if no strategy routine supplied) */
2931f221e726SAlexey Dobriyan int sysctl_data(struct ctl_table *table,
293249a0c458SEric W. Biederman 		void __user *oldval, size_t __user *oldlenp,
293349a0c458SEric W. Biederman 		void __user *newval, size_t newlen)
293449a0c458SEric W. Biederman {
293549a0c458SEric W. Biederman 	size_t len;
293649a0c458SEric W. Biederman 
293749a0c458SEric W. Biederman 	/* Get out of I don't have a variable */
293849a0c458SEric W. Biederman 	if (!table->data || !table->maxlen)
293949a0c458SEric W. Biederman 		return -ENOTDIR;
294049a0c458SEric W. Biederman 
294149a0c458SEric W. Biederman 	if (oldval && oldlenp) {
294249a0c458SEric W. Biederman 		if (get_user(len, oldlenp))
294349a0c458SEric W. Biederman 			return -EFAULT;
294449a0c458SEric W. Biederman 		if (len) {
294549a0c458SEric W. Biederman 			if (len > table->maxlen)
294649a0c458SEric W. Biederman 				len = table->maxlen;
294749a0c458SEric W. Biederman 			if (copy_to_user(oldval, table->data, len))
294849a0c458SEric W. Biederman 				return -EFAULT;
294949a0c458SEric W. Biederman 			if (put_user(len, oldlenp))
295049a0c458SEric W. Biederman 				return -EFAULT;
295149a0c458SEric W. Biederman 		}
295249a0c458SEric W. Biederman 	}
295349a0c458SEric W. Biederman 
295449a0c458SEric W. Biederman 	if (newval && newlen) {
295549a0c458SEric W. Biederman 		if (newlen > table->maxlen)
295649a0c458SEric W. Biederman 			newlen = table->maxlen;
295749a0c458SEric W. Biederman 
295849a0c458SEric W. Biederman 		if (copy_from_user(table->data, newval, newlen))
295949a0c458SEric W. Biederman 			return -EFAULT;
296049a0c458SEric W. Biederman 	}
296149a0c458SEric W. Biederman 	return 1;
296249a0c458SEric W. Biederman }
296349a0c458SEric W. Biederman 
29641da177e4SLinus Torvalds /* The generic string strategy routine: */
2965f221e726SAlexey Dobriyan int sysctl_string(struct ctl_table *table,
29661da177e4SLinus Torvalds 		  void __user *oldval, size_t __user *oldlenp,
29671f29bcd7SAlexey Dobriyan 		  void __user *newval, size_t newlen)
29681da177e4SLinus Torvalds {
29691da177e4SLinus Torvalds 	if (!table->data || !table->maxlen)
29701da177e4SLinus Torvalds 		return -ENOTDIR;
29711da177e4SLinus Torvalds 
29721da177e4SLinus Torvalds 	if (oldval && oldlenp) {
2973de9e007dSLinus Torvalds 		size_t bufsize;
2974de9e007dSLinus Torvalds 		if (get_user(bufsize, oldlenp))
29751da177e4SLinus Torvalds 			return -EFAULT;
2976de9e007dSLinus Torvalds 		if (bufsize) {
2977de9e007dSLinus Torvalds 			size_t len = strlen(table->data), copied;
2978de9e007dSLinus Torvalds 
2979de9e007dSLinus Torvalds 			/* This shouldn't trigger for a well-formed sysctl */
2980de9e007dSLinus Torvalds 			if (len > table->maxlen)
29811da177e4SLinus Torvalds 				len = table->maxlen;
2982de9e007dSLinus Torvalds 
2983de9e007dSLinus Torvalds 			/* Copy up to a max of bufsize-1 bytes of the string */
2984de9e007dSLinus Torvalds 			copied = (len >= bufsize) ? bufsize - 1 : len;
2985de9e007dSLinus Torvalds 
2986de9e007dSLinus Torvalds 			if (copy_to_user(oldval, table->data, copied) ||
2987de9e007dSLinus Torvalds 			    put_user(0, (char __user *)(oldval + copied)))
29881da177e4SLinus Torvalds 				return -EFAULT;
29891da177e4SLinus Torvalds 			if (put_user(len, oldlenp))
29901da177e4SLinus Torvalds 				return -EFAULT;
29911da177e4SLinus Torvalds 		}
29921da177e4SLinus Torvalds 	}
29931da177e4SLinus Torvalds 	if (newval && newlen) {
2994de9e007dSLinus Torvalds 		size_t len = newlen;
29951da177e4SLinus Torvalds 		if (len > table->maxlen)
29961da177e4SLinus Torvalds 			len = table->maxlen;
29971da177e4SLinus Torvalds 		if(copy_from_user(table->data, newval, len))
29981da177e4SLinus Torvalds 			return -EFAULT;
29991da177e4SLinus Torvalds 		if (len == table->maxlen)
30001da177e4SLinus Torvalds 			len--;
30011da177e4SLinus Torvalds 		((char *) table->data)[len] = 0;
30021da177e4SLinus Torvalds 	}
300382c9df82SYi Yang 	return 1;
30041da177e4SLinus Torvalds }
30051da177e4SLinus Torvalds 
30061da177e4SLinus Torvalds /*
30071da177e4SLinus Torvalds  * This function makes sure that all of the integers in the vector
30081da177e4SLinus Torvalds  * are between the minimum and maximum values given in the arrays
30091da177e4SLinus Torvalds  * table->extra1 and table->extra2, respectively.
30101da177e4SLinus Torvalds  */
3011f221e726SAlexey Dobriyan int sysctl_intvec(struct ctl_table *table,
30121da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
30131f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
30141da177e4SLinus Torvalds {
30151da177e4SLinus Torvalds 
30161da177e4SLinus Torvalds 	if (newval && newlen) {
30171da177e4SLinus Torvalds 		int __user *vec = (int __user *) newval;
30181da177e4SLinus Torvalds 		int *min = (int *) table->extra1;
30191da177e4SLinus Torvalds 		int *max = (int *) table->extra2;
30201da177e4SLinus Torvalds 		size_t length;
30211da177e4SLinus Torvalds 		int i;
30221da177e4SLinus Torvalds 
30231da177e4SLinus Torvalds 		if (newlen % sizeof(int) != 0)
30241da177e4SLinus Torvalds 			return -EINVAL;
30251da177e4SLinus Torvalds 
30261da177e4SLinus Torvalds 		if (!table->extra1 && !table->extra2)
30271da177e4SLinus Torvalds 			return 0;
30281da177e4SLinus Torvalds 
30291da177e4SLinus Torvalds 		if (newlen > table->maxlen)
30301da177e4SLinus Torvalds 			newlen = table->maxlen;
30311da177e4SLinus Torvalds 		length = newlen / sizeof(int);
30321da177e4SLinus Torvalds 
30331da177e4SLinus Torvalds 		for (i = 0; i < length; i++) {
30341da177e4SLinus Torvalds 			int value;
30351da177e4SLinus Torvalds 			if (get_user(value, vec + i))
30361da177e4SLinus Torvalds 				return -EFAULT;
30371da177e4SLinus Torvalds 			if (min && value < min[i])
30381da177e4SLinus Torvalds 				return -EINVAL;
30391da177e4SLinus Torvalds 			if (max && value > max[i])
30401da177e4SLinus Torvalds 				return -EINVAL;
30411da177e4SLinus Torvalds 		}
30421da177e4SLinus Torvalds 	}
30431da177e4SLinus Torvalds 	return 0;
30441da177e4SLinus Torvalds }
30451da177e4SLinus Torvalds 
30461da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */
3047f221e726SAlexey Dobriyan int sysctl_jiffies(struct ctl_table *table,
30481da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
30491f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
30501da177e4SLinus Torvalds {
30513ee75ac3SAlexey Dobriyan 	if (oldval && oldlenp) {
30521da177e4SLinus Torvalds 		size_t olen;
30533ee75ac3SAlexey Dobriyan 
30541da177e4SLinus Torvalds 		if (get_user(olen, oldlenp))
30551da177e4SLinus Torvalds 			return -EFAULT;
30563ee75ac3SAlexey Dobriyan 		if (olen) {
30573ee75ac3SAlexey Dobriyan 			int val;
30583ee75ac3SAlexey Dobriyan 
30593ee75ac3SAlexey Dobriyan 			if (olen < sizeof(int))
30601da177e4SLinus Torvalds 				return -EINVAL;
30613ee75ac3SAlexey Dobriyan 
30623ee75ac3SAlexey Dobriyan 			val = *(int *)(table->data) / HZ;
30633ee75ac3SAlexey Dobriyan 			if (put_user(val, (int __user *)oldval))
30641da177e4SLinus Torvalds 				return -EFAULT;
30653ee75ac3SAlexey Dobriyan 			if (put_user(sizeof(int), oldlenp))
30663ee75ac3SAlexey Dobriyan 				return -EFAULT;
30673ee75ac3SAlexey Dobriyan 		}
30681da177e4SLinus Torvalds 	}
30691da177e4SLinus Torvalds 	if (newval && newlen) {
30701da177e4SLinus Torvalds 		int new;
30711da177e4SLinus Torvalds 		if (newlen != sizeof(int))
30721da177e4SLinus Torvalds 			return -EINVAL;
30731da177e4SLinus Torvalds 		if (get_user(new, (int __user *)newval))
30741da177e4SLinus Torvalds 			return -EFAULT;
30751da177e4SLinus Torvalds 		*(int *)(table->data) = new*HZ;
30761da177e4SLinus Torvalds 	}
30771da177e4SLinus Torvalds 	return 1;
30781da177e4SLinus Torvalds }
30791da177e4SLinus Torvalds 
30801da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */
3081f221e726SAlexey Dobriyan int sysctl_ms_jiffies(struct ctl_table *table,
30821da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
30831f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
30841da177e4SLinus Torvalds {
30853ee75ac3SAlexey Dobriyan 	if (oldval && oldlenp) {
30861da177e4SLinus Torvalds 		size_t olen;
30873ee75ac3SAlexey Dobriyan 
30881da177e4SLinus Torvalds 		if (get_user(olen, oldlenp))
30891da177e4SLinus Torvalds 			return -EFAULT;
30903ee75ac3SAlexey Dobriyan 		if (olen) {
30913ee75ac3SAlexey Dobriyan 			int val;
30923ee75ac3SAlexey Dobriyan 
30933ee75ac3SAlexey Dobriyan 			if (olen < sizeof(int))
30941da177e4SLinus Torvalds 				return -EINVAL;
30953ee75ac3SAlexey Dobriyan 
30963ee75ac3SAlexey Dobriyan 			val = jiffies_to_msecs(*(int *)(table->data));
30973ee75ac3SAlexey Dobriyan 			if (put_user(val, (int __user *)oldval))
30981da177e4SLinus Torvalds 				return -EFAULT;
30993ee75ac3SAlexey Dobriyan 			if (put_user(sizeof(int), oldlenp))
31003ee75ac3SAlexey Dobriyan 				return -EFAULT;
31013ee75ac3SAlexey Dobriyan 		}
31021da177e4SLinus Torvalds 	}
31031da177e4SLinus Torvalds 	if (newval && newlen) {
31041da177e4SLinus Torvalds 		int new;
31051da177e4SLinus Torvalds 		if (newlen != sizeof(int))
31061da177e4SLinus Torvalds 			return -EINVAL;
31071da177e4SLinus Torvalds 		if (get_user(new, (int __user *)newval))
31081da177e4SLinus Torvalds 			return -EFAULT;
31091da177e4SLinus Torvalds 		*(int *)(table->data) = msecs_to_jiffies(new);
31101da177e4SLinus Torvalds 	}
31111da177e4SLinus Torvalds 	return 1;
31121da177e4SLinus Torvalds }
31131da177e4SLinus Torvalds 
3114c4b8b769SEric W. Biederman 
3115c4b8b769SEric W. Biederman 
3116b89a8171SEric W. Biederman #else /* CONFIG_SYSCTL_SYSCALL */
31171da177e4SLinus Torvalds 
31181da177e4SLinus Torvalds 
31191e7bfb21SHeiko Carstens SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
31201da177e4SLinus Torvalds {
31210e009be8SEric W. Biederman 	struct __sysctl_args tmp;
31227058cb02SEric W. Biederman 	int error;
31230e009be8SEric W. Biederman 
31240e009be8SEric W. Biederman 	if (copy_from_user(&tmp, args, sizeof(tmp)))
31250e009be8SEric W. Biederman 		return -EFAULT;
31260e009be8SEric W. Biederman 
31277058cb02SEric W. Biederman 	error = deprecated_sysctl_warning(&tmp);
3128b89a8171SEric W. Biederman 
31297058cb02SEric W. Biederman 	/* If no error reading the parameters then just -ENOSYS ... */
31307058cb02SEric W. Biederman 	if (!error)
31317058cb02SEric W. Biederman 		error = -ENOSYS;
31327058cb02SEric W. Biederman 
31337058cb02SEric W. Biederman 	return error;
31341da177e4SLinus Torvalds }
31351da177e4SLinus Torvalds 
3136f221e726SAlexey Dobriyan int sysctl_data(struct ctl_table *table,
313749a0c458SEric W. Biederman 		  void __user *oldval, size_t __user *oldlenp,
313849a0c458SEric W. Biederman 		  void __user *newval, size_t newlen)
313949a0c458SEric W. Biederman {
314049a0c458SEric W. Biederman 	return -ENOSYS;
314149a0c458SEric W. Biederman }
314249a0c458SEric W. Biederman 
3143f221e726SAlexey Dobriyan int sysctl_string(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_intvec(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 
3157f221e726SAlexey Dobriyan int sysctl_jiffies(struct ctl_table *table,
31581da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
31591f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
31601da177e4SLinus Torvalds {
31611da177e4SLinus Torvalds 	return -ENOSYS;
31621da177e4SLinus Torvalds }
31631da177e4SLinus Torvalds 
3164f221e726SAlexey Dobriyan int sysctl_ms_jiffies(struct ctl_table *table,
31651da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
31661f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
31671da177e4SLinus Torvalds {
31681da177e4SLinus Torvalds 	return -ENOSYS;
31691da177e4SLinus Torvalds }
31701da177e4SLinus Torvalds 
3171b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */
31721da177e4SLinus Torvalds 
31737058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args)
31747058cb02SEric W. Biederman {
31757058cb02SEric W. Biederman 	static int msg_count;
31767058cb02SEric W. Biederman 	int name[CTL_MAXNAME];
31777058cb02SEric W. Biederman 	int i;
31787058cb02SEric W. Biederman 
31796fc48af8STetsuo Handa 	/* Check args->nlen. */
31806fc48af8STetsuo Handa 	if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
31816fc48af8STetsuo Handa 		return -ENOTDIR;
31826fc48af8STetsuo Handa 
31837058cb02SEric W. Biederman 	/* Read in the sysctl name for better debug message logging */
31847058cb02SEric W. Biederman 	for (i = 0; i < args->nlen; i++)
31857058cb02SEric W. Biederman 		if (get_user(name[i], args->name + i))
31867058cb02SEric W. Biederman 			return -EFAULT;
31877058cb02SEric W. Biederman 
31887058cb02SEric W. Biederman 	/* Ignore accesses to kernel.version */
31897058cb02SEric W. Biederman 	if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
31907058cb02SEric W. Biederman 		return 0;
31917058cb02SEric W. Biederman 
31927058cb02SEric W. Biederman 	if (msg_count < 5) {
31937058cb02SEric W. Biederman 		msg_count++;
31947058cb02SEric W. Biederman 		printk(KERN_INFO
31957058cb02SEric W. Biederman 			"warning: process `%s' used the deprecated sysctl "
31967058cb02SEric W. Biederman 			"system call with ", current->comm);
31977058cb02SEric W. Biederman 		for (i = 0; i < args->nlen; i++)
31987058cb02SEric W. Biederman 			printk("%d.", name[i]);
31997058cb02SEric W. Biederman 		printk("\n");
32007058cb02SEric W. Biederman 	}
32017058cb02SEric W. Biederman 	return 0;
32027058cb02SEric W. Biederman }
32037058cb02SEric W. Biederman 
32041da177e4SLinus Torvalds /*
32051da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
32061da177e4SLinus Torvalds  * exception granted :-)
32071da177e4SLinus Torvalds  */
32081da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
32091da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
32101da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
32111da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
32121da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
32131da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
32141da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
32151da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
32161da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table);
321729e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths);
32181da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_intvec);
32191da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_jiffies);
32201da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_ms_jiffies);
32211da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_string);
322249a0c458SEric W. Biederman EXPORT_SYMBOL(sysctl_data);
32231da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table);
3224