xref: /openbmc/linux/kernel/sysctl.c (revision 788084aba2ab7348257597496befcbccabdc98a3)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * sysctl.c: General linux system control interface
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  * Begun 24 March 1995, Stephen Tweedie
51da177e4SLinus Torvalds  * Added /proc support, Dec 1995
61da177e4SLinus Torvalds  * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
71da177e4SLinus Torvalds  * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
81da177e4SLinus Torvalds  * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
91da177e4SLinus Torvalds  * Dynamic registration fixes, Stephen Tweedie.
101da177e4SLinus Torvalds  * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
111da177e4SLinus Torvalds  * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
121da177e4SLinus Torvalds  *  Horn.
131da177e4SLinus Torvalds  * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
141da177e4SLinus Torvalds  * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
151da177e4SLinus Torvalds  * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
161da177e4SLinus Torvalds  *  Wendling.
171da177e4SLinus Torvalds  * The list_for_each() macro wasn't appropriate for the sysctl loop.
181da177e4SLinus Torvalds  *  Removed it and replaced it with older style, 03/23/00, Bill Wendling
191da177e4SLinus Torvalds  */
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds #include <linux/module.h>
221da177e4SLinus Torvalds #include <linux/mm.h>
231da177e4SLinus Torvalds #include <linux/swap.h>
241da177e4SLinus Torvalds #include <linux/slab.h>
251da177e4SLinus Torvalds #include <linux/sysctl.h>
261da177e4SLinus Torvalds #include <linux/proc_fs.h>
2772c2d582SAndrew Morgan #include <linux/security.h>
281da177e4SLinus Torvalds #include <linux/ctype.h>
291da177e4SLinus Torvalds #include <linux/utsname.h>
30dfec072eSVegard Nossum #include <linux/kmemcheck.h>
311da177e4SLinus Torvalds #include <linux/smp_lock.h>
3262239ac2SAdrian Bunk #include <linux/fs.h>
331da177e4SLinus Torvalds #include <linux/init.h>
341da177e4SLinus Torvalds #include <linux/kernel.h>
350296b228SKay Sievers #include <linux/kobject.h>
3620380731SArnaldo Carvalho de Melo #include <linux/net.h>
371da177e4SLinus Torvalds #include <linux/sysrq.h>
381da177e4SLinus Torvalds #include <linux/highuid.h>
391da177e4SLinus Torvalds #include <linux/writeback.h>
401da177e4SLinus Torvalds #include <linux/hugetlb.h>
411da177e4SLinus Torvalds #include <linux/initrd.h>
420b77f5bfSDavid Howells #include <linux/key.h>
431da177e4SLinus Torvalds #include <linux/times.h>
441da177e4SLinus Torvalds #include <linux/limits.h>
451da177e4SLinus Torvalds #include <linux/dcache.h>
461da177e4SLinus Torvalds #include <linux/syscalls.h>
47c748e134SAdrian Bunk #include <linux/vmstat.h>
48c255d844SPavel Machek #include <linux/nfs_fs.h>
49c255d844SPavel Machek #include <linux/acpi.h>
5010a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h>
51b0fc494fSSteven Rostedt #include <linux/ftrace.h>
52*788084abSEric Paris #include <linux/security.h>
5312e22c5eSDavid Howells #include <linux/slow-work.h>
541ccd1549SPeter Zijlstra #include <linux/perf_counter.h>
551da177e4SLinus Torvalds 
561da177e4SLinus Torvalds #include <asm/uaccess.h>
571da177e4SLinus Torvalds #include <asm/processor.h>
581da177e4SLinus Torvalds 
5929cbc78bSAndi Kleen #ifdef CONFIG_X86
6029cbc78bSAndi Kleen #include <asm/nmi.h>
610741f4d2SChuck Ebbert #include <asm/stacktrace.h>
626e7c4025SIngo Molnar #include <asm/io.h>
6329cbc78bSAndi Kleen #endif
6429cbc78bSAndi Kleen 
657058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args);
667058cb02SEric W. Biederman 
671da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL)
681da177e4SLinus Torvalds 
691da177e4SLinus Torvalds /* External variables not in a header file. */
701da177e4SLinus Torvalds extern int C_A_D;
7145807a1dSIngo Molnar extern int print_fatal_signals;
721da177e4SLinus Torvalds extern int sysctl_overcommit_memory;
731da177e4SLinus Torvalds extern int sysctl_overcommit_ratio;
74fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom;
75fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task;
76fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks;
771da177e4SLinus Torvalds extern int max_threads;
781da177e4SLinus Torvalds extern int core_uses_pid;
79d6e71144SAlan Cox extern int suid_dumpable;
801da177e4SLinus Torvalds extern char core_pattern[];
811da177e4SLinus Torvalds extern int pid_max;
821da177e4SLinus Torvalds extern int min_free_kbytes;
831da177e4SLinus Torvalds extern int pid_max_min, pid_max_max;
849d0243bcSAndrew Morton extern int sysctl_drop_caches;
858ad4b1fbSRohit Seth extern int percpu_pagelist_fraction;
86bebfa101SAndi Kleen extern int compat_log;
879745512cSArjan van de Ven extern int latencytop_enabled;
88eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max;
89dd8632a1SPaul Mundt #ifndef CONFIG_MMU
90dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages;
91dd8632a1SPaul Mundt #endif
9231a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
9331a72bceSPaul E. McKenney extern int rcutorture_runnable;
9431a72bceSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
951da177e4SLinus Torvalds 
96c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and  maximum */
97195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP
98c4f3b63fSRavikiran G Thirumalai static int sixty = 60;
999383d967SDimitri Sivanich static int neg_one = -1;
100c4f3b63fSRavikiran G Thirumalai #endif
101c4f3b63fSRavikiran G Thirumalai 
102c4f3b63fSRavikiran G Thirumalai static int zero;
103cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1;
104cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2;
105fc3501d4SSven Wegener static unsigned long one_ul = 1;
106c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100;
107c4f3b63fSRavikiran G Thirumalai 
1089e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
1099e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1109e4a5bdaSAndrea Righi 
1111da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1121da177e4SLinus Torvalds static int maxolduid = 65535;
1131da177e4SLinus Torvalds static int minolduid;
1148ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8;
1151da177e4SLinus Torvalds 
1161da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
1171da177e4SLinus Torvalds 
118a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
1191da177e4SLinus Torvalds extern char modprobe_path[];
1203d43321bSKees Cook extern int modules_disabled;
1211da177e4SLinus Torvalds #endif
1221da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
1231da177e4SLinus Torvalds extern int sg_big_buff;
1241da177e4SLinus Torvalds #endif
1251da177e4SLinus Torvalds 
12672c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
12717f04fbbSDavid S. Miller #include <asm/system.h>
1281da177e4SLinus Torvalds #endif
1291da177e4SLinus Torvalds 
1300871420fSDavid S. Miller #ifdef CONFIG_SPARC64
1310871420fSDavid S. Miller extern int sysctl_tsb_ratio;
1320871420fSDavid S. Miller #endif
1330871420fSDavid S. Miller 
1341da177e4SLinus Torvalds #ifdef __hppa__
1351da177e4SLinus Torvalds extern int pwrsw_enabled;
1361da177e4SLinus Torvalds extern int unaligned_enabled;
1371da177e4SLinus Torvalds #endif
1381da177e4SLinus Torvalds 
139347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
1401da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
1411da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings;
1421da177e4SLinus Torvalds #endif
1431da177e4SLinus Torvalds extern int sysctl_userprocess_debug;
144951f22d5SMartin Schwidefsky extern int spin_retry;
1451da177e4SLinus Torvalds #endif
1461da177e4SLinus Torvalds 
1471da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
1481da177e4SLinus Torvalds extern int acct_parm[];
1491da177e4SLinus Torvalds #endif
1501da177e4SLinus Torvalds 
151d2b176edSJes Sorensen #ifdef CONFIG_IA64
152d2b176edSJes Sorensen extern int no_unaligned_warning;
15388fc241fSDoug Chapman extern int unaligned_dump_stack;
154d2b176edSJes Sorensen #endif
155d2b176edSJes Sorensen 
15623f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
15723f78d4aSIngo Molnar extern int max_lock_depth;
15823f78d4aSIngo Molnar #endif
15923f78d4aSIngo Molnar 
160d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
161d8217f07SEric W. Biederman static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
1629ec52099SCedric Le Goater 		  void __user *buffer, size_t *lenp, loff_t *ppos);
16325ddbb18SAndi Kleen static int proc_taint(struct ctl_table *table, int write, struct file *filp,
16434f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos);
165d6f8ff73SRandy Dunlap #endif
1669ec52099SCedric Le Goater 
167d8217f07SEric W. Biederman static struct ctl_table root_table[];
168e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root;
169e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = {
170b380b0d4SAl Viro 	.count = 1,
171e51b6ba0SEric W. Biederman 	.ctl_table = root_table,
17273455092SAl Viro 	.ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
173e51b6ba0SEric W. Biederman 	.root = &sysctl_table_root,
17473455092SAl Viro 	.set = &sysctl_table_root.default_set,
175e51b6ba0SEric W. Biederman };
176e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = {
177e51b6ba0SEric W. Biederman 	.root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
17873455092SAl Viro 	.default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
179e51b6ba0SEric W. Biederman };
1801da177e4SLinus Torvalds 
181d8217f07SEric W. Biederman static struct ctl_table kern_table[];
182d8217f07SEric W. Biederman static struct ctl_table vm_table[];
183d8217f07SEric W. Biederman static struct ctl_table fs_table[];
184d8217f07SEric W. Biederman static struct ctl_table debug_table[];
185d8217f07SEric W. Biederman static struct ctl_table dev_table[];
186d8217f07SEric W. Biederman extern struct ctl_table random_table[];
1872d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
188d8217f07SEric W. Biederman extern struct ctl_table inotify_table[];
1890399cb08SRobert Love #endif
1907ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
1917ef9964eSDavide Libenzi extern struct ctl_table epoll_table[];
1927ef9964eSDavide Libenzi #endif
1931da177e4SLinus Torvalds 
1941da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1951da177e4SLinus Torvalds int sysctl_legacy_va_layout;
1961da177e4SLinus Torvalds #endif
1971da177e4SLinus Torvalds 
198f20786ffSPeter Zijlstra extern int prove_locking;
199f20786ffSPeter Zijlstra extern int lock_stat;
2009bc9a6bdSEric W. Biederman 
2011da177e4SLinus Torvalds /* The default sysctl tables: */
2021da177e4SLinus Torvalds 
203d8217f07SEric W. Biederman static struct ctl_table root_table[] = {
2041da177e4SLinus Torvalds 	{
2051da177e4SLinus Torvalds 		.ctl_name	= CTL_KERN,
2061da177e4SLinus Torvalds 		.procname	= "kernel",
2071da177e4SLinus Torvalds 		.mode		= 0555,
2081da177e4SLinus Torvalds 		.child		= kern_table,
2091da177e4SLinus Torvalds 	},
2101da177e4SLinus Torvalds 	{
2111da177e4SLinus Torvalds 		.ctl_name	= CTL_VM,
2121da177e4SLinus Torvalds 		.procname	= "vm",
2131da177e4SLinus Torvalds 		.mode		= 0555,
2141da177e4SLinus Torvalds 		.child		= vm_table,
2151da177e4SLinus Torvalds 	},
2161da177e4SLinus Torvalds 	{
2171da177e4SLinus Torvalds 		.ctl_name	= CTL_FS,
2181da177e4SLinus Torvalds 		.procname	= "fs",
2191da177e4SLinus Torvalds 		.mode		= 0555,
2201da177e4SLinus Torvalds 		.child		= fs_table,
2211da177e4SLinus Torvalds 	},
2221da177e4SLinus Torvalds 	{
2231da177e4SLinus Torvalds 		.ctl_name	= CTL_DEBUG,
2241da177e4SLinus Torvalds 		.procname	= "debug",
2251da177e4SLinus Torvalds 		.mode		= 0555,
2261da177e4SLinus Torvalds 		.child		= debug_table,
2271da177e4SLinus Torvalds 	},
2281da177e4SLinus Torvalds 	{
2291da177e4SLinus Torvalds 		.ctl_name	= CTL_DEV,
2301da177e4SLinus Torvalds 		.procname	= "dev",
2311da177e4SLinus Torvalds 		.mode		= 0555,
2321da177e4SLinus Torvalds 		.child		= dev_table,
2331da177e4SLinus Torvalds 	},
2342be7fe07SAndrew Morton /*
2352be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
2362be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
2372be7fe07SAndrew Morton  */
2381da177e4SLinus Torvalds 	{ .ctl_name = 0 }
2391da177e4SLinus Torvalds };
2401da177e4SLinus Torvalds 
24177e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
24273c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000;		/* 100 usecs */
24373c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
24473c4efd2SEric Dumazet static int min_wakeup_granularity_ns;			/* 0 usecs */
24573c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
24677e54a1fSIngo Molnar #endif
24777e54a1fSIngo Molnar 
248d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
24977e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
25077e54a1fSIngo Molnar 	{
25177e54a1fSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
252b2be5e96SPeter Zijlstra 		.procname	= "sched_min_granularity_ns",
253b2be5e96SPeter Zijlstra 		.data		= &sysctl_sched_min_granularity,
25477e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
25577e54a1fSIngo Molnar 		.mode		= 0644,
256b2be5e96SPeter Zijlstra 		.proc_handler	= &sched_nr_latency_handler,
257b2be5e96SPeter Zijlstra 		.strategy	= &sysctl_intvec,
258b2be5e96SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
259b2be5e96SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
26077e54a1fSIngo Molnar 	},
26177e54a1fSIngo Molnar 	{
26277e54a1fSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
26321805085SPeter Zijlstra 		.procname	= "sched_latency_ns",
26421805085SPeter Zijlstra 		.data		= &sysctl_sched_latency,
26521805085SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
26621805085SPeter Zijlstra 		.mode		= 0644,
267b2be5e96SPeter Zijlstra 		.proc_handler	= &sched_nr_latency_handler,
26821805085SPeter Zijlstra 		.strategy	= &sysctl_intvec,
26921805085SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
27021805085SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
27121805085SPeter Zijlstra 	},
27221805085SPeter Zijlstra 	{
27321805085SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
27477e54a1fSIngo Molnar 		.procname	= "sched_wakeup_granularity_ns",
27577e54a1fSIngo Molnar 		.data		= &sysctl_sched_wakeup_granularity,
27677e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
27777e54a1fSIngo Molnar 		.mode		= 0644,
27877e54a1fSIngo Molnar 		.proc_handler	= &proc_dointvec_minmax,
27977e54a1fSIngo Molnar 		.strategy	= &sysctl_intvec,
28077e54a1fSIngo Molnar 		.extra1		= &min_wakeup_granularity_ns,
28177e54a1fSIngo Molnar 		.extra2		= &max_wakeup_granularity_ns,
28277e54a1fSIngo Molnar 	},
28377e54a1fSIngo Molnar 	{
28477e54a1fSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
2852398f2c6SPeter Zijlstra 		.procname	= "sched_shares_ratelimit",
2862398f2c6SPeter Zijlstra 		.data		= &sysctl_sched_shares_ratelimit,
2872398f2c6SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
2882398f2c6SPeter Zijlstra 		.mode		= 0644,
2892398f2c6SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
2902398f2c6SPeter Zijlstra 	},
2912398f2c6SPeter Zijlstra 	{
2922398f2c6SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
293ffda12a1SPeter Zijlstra 		.procname	= "sched_shares_thresh",
294ffda12a1SPeter Zijlstra 		.data		= &sysctl_sched_shares_thresh,
295ffda12a1SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
296ffda12a1SPeter Zijlstra 		.mode		= 0644,
297ffda12a1SPeter Zijlstra 		.proc_handler	= &proc_dointvec_minmax,
298ffda12a1SPeter Zijlstra 		.strategy	= &sysctl_intvec,
299ffda12a1SPeter Zijlstra 		.extra1		= &zero,
300ffda12a1SPeter Zijlstra 	},
301ffda12a1SPeter Zijlstra 	{
302ffda12a1SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
30377e54a1fSIngo Molnar 		.procname	= "sched_child_runs_first",
30477e54a1fSIngo Molnar 		.data		= &sysctl_sched_child_runs_first,
30577e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
30677e54a1fSIngo Molnar 		.mode		= 0644,
30777e54a1fSIngo Molnar 		.proc_handler	= &proc_dointvec,
30877e54a1fSIngo Molnar 	},
3091fc84aaaSPeter Zijlstra 	{
3101fc84aaaSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
3111fc84aaaSPeter Zijlstra 		.procname	= "sched_features",
3121fc84aaaSPeter Zijlstra 		.data		= &sysctl_sched_features,
3131fc84aaaSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3141fc84aaaSPeter Zijlstra 		.mode		= 0644,
3151fc84aaaSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
3161fc84aaaSPeter Zijlstra 	},
317da84d961SIngo Molnar 	{
318da84d961SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
319da84d961SIngo Molnar 		.procname	= "sched_migration_cost",
320da84d961SIngo Molnar 		.data		= &sysctl_sched_migration_cost,
321da84d961SIngo Molnar 		.maxlen		= sizeof(unsigned int),
322da84d961SIngo Molnar 		.mode		= 0644,
323da84d961SIngo Molnar 		.proc_handler	= &proc_dointvec,
324da84d961SIngo Molnar 	},
325b82d9fddSPeter Zijlstra 	{
326b82d9fddSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
327b82d9fddSPeter Zijlstra 		.procname	= "sched_nr_migrate",
328b82d9fddSPeter Zijlstra 		.data		= &sysctl_sched_nr_migrate,
329b82d9fddSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
330fa85ae24SPeter Zijlstra 		.mode		= 0644,
331fa85ae24SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
332fa85ae24SPeter Zijlstra 	},
333cd1bb94bSArun R Bharadwaj 	{
334cd1bb94bSArun R Bharadwaj 		.ctl_name	= CTL_UNNUMBERED,
335cd1bb94bSArun R Bharadwaj 		.procname	= "timer_migration",
336cd1bb94bSArun R Bharadwaj 		.data		= &sysctl_timer_migration,
337cd1bb94bSArun R Bharadwaj 		.maxlen		= sizeof(unsigned int),
338cd1bb94bSArun R Bharadwaj 		.mode		= 0644,
339bfdb4d9fSArun R Bharadwaj 		.proc_handler	= &proc_dointvec_minmax,
340bfdb4d9fSArun R Bharadwaj 		.strategy	= &sysctl_intvec,
341bfdb4d9fSArun R Bharadwaj 		.extra1		= &zero,
342bfdb4d9fSArun R Bharadwaj 		.extra2		= &one,
343cd1bb94bSArun R Bharadwaj 	},
3441fc84aaaSPeter Zijlstra #endif
3451799e35dSIngo Molnar 	{
3461799e35dSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
3479f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
3489f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
3499f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3509f0c1e56SPeter Zijlstra 		.mode		= 0644,
351d0b27fa7SPeter Zijlstra 		.proc_handler	= &sched_rt_handler,
3529f0c1e56SPeter Zijlstra 	},
3539f0c1e56SPeter Zijlstra 	{
3549f0c1e56SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
3559f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
3569f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
3579f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
3589f0c1e56SPeter Zijlstra 		.mode		= 0644,
359d0b27fa7SPeter Zijlstra 		.proc_handler	= &sched_rt_handler,
3609f0c1e56SPeter Zijlstra 	},
3619f0c1e56SPeter Zijlstra 	{
3629f0c1e56SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
3631799e35dSIngo Molnar 		.procname	= "sched_compat_yield",
3641799e35dSIngo Molnar 		.data		= &sysctl_sched_compat_yield,
3651799e35dSIngo Molnar 		.maxlen		= sizeof(unsigned int),
3661799e35dSIngo Molnar 		.mode		= 0644,
3671799e35dSIngo Molnar 		.proc_handler	= &proc_dointvec,
3681799e35dSIngo Molnar 	},
369f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
370f20786ffSPeter Zijlstra 	{
371f20786ffSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
372f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
373f20786ffSPeter Zijlstra 		.data		= &prove_locking,
374f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
375f20786ffSPeter Zijlstra 		.mode		= 0644,
376f20786ffSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
377f20786ffSPeter Zijlstra 	},
378f20786ffSPeter Zijlstra #endif
379f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
380f20786ffSPeter Zijlstra 	{
381f20786ffSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
382f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
383f20786ffSPeter Zijlstra 		.data		= &lock_stat,
384f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
385f20786ffSPeter Zijlstra 		.mode		= 0644,
386f20786ffSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
387f20786ffSPeter Zijlstra 	},
388f20786ffSPeter Zijlstra #endif
38977e54a1fSIngo Molnar 	{
3901da177e4SLinus Torvalds 		.ctl_name	= KERN_PANIC,
3911da177e4SLinus Torvalds 		.procname	= "panic",
3921da177e4SLinus Torvalds 		.data		= &panic_timeout,
3931da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
3941da177e4SLinus Torvalds 		.mode		= 0644,
3951da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
3961da177e4SLinus Torvalds 	},
3971da177e4SLinus Torvalds 	{
3981da177e4SLinus Torvalds 		.ctl_name	= KERN_CORE_USES_PID,
3991da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
4001da177e4SLinus Torvalds 		.data		= &core_uses_pid,
4011da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4021da177e4SLinus Torvalds 		.mode		= 0644,
4031da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4041da177e4SLinus Torvalds 	},
4051da177e4SLinus Torvalds 	{
4061da177e4SLinus Torvalds 		.ctl_name	= KERN_CORE_PATTERN,
4071da177e4SLinus Torvalds 		.procname	= "core_pattern",
4081da177e4SLinus Torvalds 		.data		= core_pattern,
40971ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
4101da177e4SLinus Torvalds 		.mode		= 0644,
4111da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
4121da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
4131da177e4SLinus Torvalds 	},
41434f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
4151da177e4SLinus Torvalds 	{
4161da177e4SLinus Torvalds 		.procname	= "tainted",
41725ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
41834f5a398STheodore Ts'o 		.mode		= 0644,
41925ddbb18SAndi Kleen 		.proc_handler	= &proc_taint,
4201da177e4SLinus Torvalds 	},
42134f5a398STheodore Ts'o #endif
4229745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
4239745512cSArjan van de Ven 	{
4249745512cSArjan van de Ven 		.procname	= "latencytop",
4259745512cSArjan van de Ven 		.data		= &latencytop_enabled,
4269745512cSArjan van de Ven 		.maxlen		= sizeof(int),
4279745512cSArjan van de Ven 		.mode		= 0644,
4289745512cSArjan van de Ven 		.proc_handler	= &proc_dointvec,
4299745512cSArjan van de Ven 	},
4309745512cSArjan van de Ven #endif
4311da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
4321da177e4SLinus Torvalds 	{
4331da177e4SLinus Torvalds 		.ctl_name	= KERN_REALROOTDEV,
4341da177e4SLinus Torvalds 		.procname	= "real-root-dev",
4351da177e4SLinus Torvalds 		.data		= &real_root_dev,
4361da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4371da177e4SLinus Torvalds 		.mode		= 0644,
4381da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4391da177e4SLinus Torvalds 	},
4401da177e4SLinus Torvalds #endif
44145807a1dSIngo Molnar 	{
44245807a1dSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
44345807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
44445807a1dSIngo Molnar 		.data		= &print_fatal_signals,
44545807a1dSIngo Molnar 		.maxlen		= sizeof(int),
44645807a1dSIngo Molnar 		.mode		= 0644,
44745807a1dSIngo Molnar 		.proc_handler	= &proc_dointvec,
44845807a1dSIngo Molnar 	},
44972c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
4501da177e4SLinus Torvalds 	{
4511da177e4SLinus Torvalds 		.ctl_name	= KERN_SPARC_REBOOT,
4521da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
4531da177e4SLinus Torvalds 		.data		= reboot_command,
4541da177e4SLinus Torvalds 		.maxlen		= 256,
4551da177e4SLinus Torvalds 		.mode		= 0644,
4561da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
4571da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
4581da177e4SLinus Torvalds 	},
4591da177e4SLinus Torvalds 	{
4601da177e4SLinus Torvalds 		.ctl_name	= KERN_SPARC_STOP_A,
4611da177e4SLinus Torvalds 		.procname	= "stop-a",
4621da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
4631da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4641da177e4SLinus Torvalds 		.mode		= 0644,
4651da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4661da177e4SLinus Torvalds 	},
4671da177e4SLinus Torvalds 	{
4681da177e4SLinus Torvalds 		.ctl_name	= KERN_SPARC_SCONS_PWROFF,
4691da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
4701da177e4SLinus Torvalds 		.data		= &scons_pwroff,
4711da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4721da177e4SLinus Torvalds 		.mode		= 0644,
4731da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4741da177e4SLinus Torvalds 	},
4751da177e4SLinus Torvalds #endif
4760871420fSDavid S. Miller #ifdef CONFIG_SPARC64
4770871420fSDavid S. Miller 	{
4780871420fSDavid S. Miller 		.ctl_name	= CTL_UNNUMBERED,
4790871420fSDavid S. Miller 		.procname	= "tsb-ratio",
4800871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
4810871420fSDavid S. Miller 		.maxlen		= sizeof (int),
4820871420fSDavid S. Miller 		.mode		= 0644,
4830871420fSDavid S. Miller 		.proc_handler	= &proc_dointvec,
4840871420fSDavid S. Miller 	},
4850871420fSDavid S. Miller #endif
4861da177e4SLinus Torvalds #ifdef __hppa__
4871da177e4SLinus Torvalds 	{
4881da177e4SLinus Torvalds 		.ctl_name	= KERN_HPPA_PWRSW,
4891da177e4SLinus Torvalds 		.procname	= "soft-power",
4901da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
4911da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4921da177e4SLinus Torvalds 	 	.mode		= 0644,
4931da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4941da177e4SLinus Torvalds 	},
4951da177e4SLinus Torvalds 	{
4961da177e4SLinus Torvalds 		.ctl_name	= KERN_HPPA_UNALIGNED,
4971da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
4981da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
4991da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5001da177e4SLinus Torvalds 		.mode		= 0644,
5011da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5021da177e4SLinus Torvalds 	},
5031da177e4SLinus Torvalds #endif
5041da177e4SLinus Torvalds 	{
5051da177e4SLinus Torvalds 		.ctl_name	= KERN_CTLALTDEL,
5061da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
5071da177e4SLinus Torvalds 		.data		= &C_A_D,
5081da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5091da177e4SLinus Torvalds 		.mode		= 0644,
5101da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5111da177e4SLinus Torvalds 	},
512606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
513b0fc494fSSteven Rostedt 	{
514b0fc494fSSteven Rostedt 		.ctl_name	= CTL_UNNUMBERED,
515b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
516b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
517b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
518b0fc494fSSteven Rostedt 		.mode		= 0644,
519b0fc494fSSteven Rostedt 		.proc_handler	= &ftrace_enable_sysctl,
520b0fc494fSSteven Rostedt 	},
521b0fc494fSSteven Rostedt #endif
522f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
523f38f1d2aSSteven Rostedt 	{
524f38f1d2aSSteven Rostedt 		.ctl_name	= CTL_UNNUMBERED,
525f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
526f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
527f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
528f38f1d2aSSteven Rostedt 		.mode		= 0644,
529f38f1d2aSSteven Rostedt 		.proc_handler	= &stack_trace_sysctl,
530f38f1d2aSSteven Rostedt 	},
531f38f1d2aSSteven Rostedt #endif
532944ac425SSteven Rostedt #ifdef CONFIG_TRACING
533944ac425SSteven Rostedt 	{
534944ac425SSteven Rostedt 		.ctl_name	= CTL_UNNUMBERED,
5353299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
536944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
537944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
538944ac425SSteven Rostedt 		.mode		= 0644,
539944ac425SSteven Rostedt 		.proc_handler	= &proc_dointvec,
540944ac425SSteven Rostedt 	},
541944ac425SSteven Rostedt #endif
542a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
5431da177e4SLinus Torvalds 	{
5441da177e4SLinus Torvalds 		.ctl_name	= KERN_MODPROBE,
5451da177e4SLinus Torvalds 		.procname	= "modprobe",
5461da177e4SLinus Torvalds 		.data		= &modprobe_path,
5471da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
5481da177e4SLinus Torvalds 		.mode		= 0644,
5491da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
5501da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
5511da177e4SLinus Torvalds 	},
5523d43321bSKees Cook 	{
5533d43321bSKees Cook 		.ctl_name	= CTL_UNNUMBERED,
5543d43321bSKees Cook 		.procname	= "modules_disabled",
5553d43321bSKees Cook 		.data		= &modules_disabled,
5563d43321bSKees Cook 		.maxlen		= sizeof(int),
5573d43321bSKees Cook 		.mode		= 0644,
5583d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
5593d43321bSKees Cook 		.proc_handler	= &proc_dointvec_minmax,
5603d43321bSKees Cook 		.extra1		= &one,
5613d43321bSKees Cook 		.extra2		= &one,
5623d43321bSKees Cook 	},
5631da177e4SLinus Torvalds #endif
56457ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
5651da177e4SLinus Torvalds 	{
5661da177e4SLinus Torvalds 		.ctl_name	= KERN_HOTPLUG,
5671da177e4SLinus Torvalds 		.procname	= "hotplug",
568312c004dSKay Sievers 		.data		= &uevent_helper,
569312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
5701da177e4SLinus Torvalds 		.mode		= 0644,
5711da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
5721da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
5731da177e4SLinus Torvalds 	},
5741da177e4SLinus Torvalds #endif
5751da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
5761da177e4SLinus Torvalds 	{
5771da177e4SLinus Torvalds 		.ctl_name	= KERN_SG_BIG_BUFF,
5781da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
5791da177e4SLinus Torvalds 		.data		= &sg_big_buff,
5801da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5811da177e4SLinus Torvalds 		.mode		= 0444,
5821da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5831da177e4SLinus Torvalds 	},
5841da177e4SLinus Torvalds #endif
5851da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
5861da177e4SLinus Torvalds 	{
5871da177e4SLinus Torvalds 		.ctl_name	= KERN_ACCT,
5881da177e4SLinus Torvalds 		.procname	= "acct",
5891da177e4SLinus Torvalds 		.data		= &acct_parm,
5901da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
5911da177e4SLinus Torvalds 		.mode		= 0644,
5921da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5931da177e4SLinus Torvalds 	},
5941da177e4SLinus Torvalds #endif
5951da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
5961da177e4SLinus Torvalds 	{
5971da177e4SLinus Torvalds 		.ctl_name	= KERN_SYSRQ,
5981da177e4SLinus Torvalds 		.procname	= "sysrq",
5995d6f647fSIngo Molnar 		.data		= &__sysrq_enabled,
6001da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6011da177e4SLinus Torvalds 		.mode		= 0644,
6021da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6031da177e4SLinus Torvalds 	},
6041da177e4SLinus Torvalds #endif
605d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
6061da177e4SLinus Torvalds 	{
6071da177e4SLinus Torvalds 		.procname	= "cad_pid",
6089ec52099SCedric Le Goater 		.data		= NULL,
6091da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6101da177e4SLinus Torvalds 		.mode		= 0600,
6119ec52099SCedric Le Goater 		.proc_handler	= &proc_do_cad_pid,
6121da177e4SLinus Torvalds 	},
613d6f8ff73SRandy Dunlap #endif
6141da177e4SLinus Torvalds 	{
6151da177e4SLinus Torvalds 		.ctl_name	= KERN_MAX_THREADS,
6161da177e4SLinus Torvalds 		.procname	= "threads-max",
6171da177e4SLinus Torvalds 		.data		= &max_threads,
6181da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6191da177e4SLinus Torvalds 		.mode		= 0644,
6201da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6211da177e4SLinus Torvalds 	},
6221da177e4SLinus Torvalds 	{
6231da177e4SLinus Torvalds 		.ctl_name	= KERN_RANDOM,
6241da177e4SLinus Torvalds 		.procname	= "random",
6251da177e4SLinus Torvalds 		.mode		= 0555,
6261da177e4SLinus Torvalds 		.child		= random_table,
6271da177e4SLinus Torvalds 	},
6281da177e4SLinus Torvalds 	{
6291da177e4SLinus Torvalds 		.ctl_name	= KERN_OVERFLOWUID,
6301da177e4SLinus Torvalds 		.procname	= "overflowuid",
6311da177e4SLinus Torvalds 		.data		= &overflowuid,
6321da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6331da177e4SLinus Torvalds 		.mode		= 0644,
6341da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
6351da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
6361da177e4SLinus Torvalds 		.extra1		= &minolduid,
6371da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6381da177e4SLinus Torvalds 	},
6391da177e4SLinus Torvalds 	{
6401da177e4SLinus Torvalds 		.ctl_name	= KERN_OVERFLOWGID,
6411da177e4SLinus Torvalds 		.procname	= "overflowgid",
6421da177e4SLinus Torvalds 		.data		= &overflowgid,
6431da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6441da177e4SLinus Torvalds 		.mode		= 0644,
6451da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
6461da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
6471da177e4SLinus Torvalds 		.extra1		= &minolduid,
6481da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6491da177e4SLinus Torvalds 	},
650347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
6511da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
6521da177e4SLinus Torvalds 	{
6531da177e4SLinus Torvalds 		.ctl_name	= KERN_IEEE_EMULATION_WARNINGS,
6541da177e4SLinus Torvalds 		.procname	= "ieee_emulation_warnings",
6551da177e4SLinus Torvalds 		.data		= &sysctl_ieee_emulation_warnings,
6561da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6571da177e4SLinus Torvalds 		.mode		= 0644,
6581da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6591da177e4SLinus Torvalds 	},
6601da177e4SLinus Torvalds #endif
6611da177e4SLinus Torvalds 	{
6621da177e4SLinus Torvalds 		.ctl_name	= KERN_S390_USER_DEBUG_LOGGING,
6631da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
6641da177e4SLinus Torvalds 		.data		= &sysctl_userprocess_debug,
6651da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6661da177e4SLinus Torvalds 		.mode		= 0644,
6671da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6681da177e4SLinus Torvalds 	},
6691da177e4SLinus Torvalds #endif
6701da177e4SLinus Torvalds 	{
6711da177e4SLinus Torvalds 		.ctl_name	= KERN_PIDMAX,
6721da177e4SLinus Torvalds 		.procname	= "pid_max",
6731da177e4SLinus Torvalds 		.data		= &pid_max,
6741da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6751da177e4SLinus Torvalds 		.mode		= 0644,
6761da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
6771da177e4SLinus Torvalds 		.strategy	= sysctl_intvec,
6781da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
6791da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
6801da177e4SLinus Torvalds 	},
6811da177e4SLinus Torvalds 	{
6821da177e4SLinus Torvalds 		.ctl_name	= KERN_PANIC_ON_OOPS,
6831da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
6841da177e4SLinus Torvalds 		.data		= &panic_on_oops,
6851da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6861da177e4SLinus Torvalds 		.mode		= 0644,
6871da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6881da177e4SLinus Torvalds 	},
6897ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
6907ef3d2fdSJoe Perches 	{
6917ef3d2fdSJoe Perches 		.ctl_name	= KERN_PRINTK,
6927ef3d2fdSJoe Perches 		.procname	= "printk",
6937ef3d2fdSJoe Perches 		.data		= &console_loglevel,
6947ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
6957ef3d2fdSJoe Perches 		.mode		= 0644,
6967ef3d2fdSJoe Perches 		.proc_handler	= &proc_dointvec,
6977ef3d2fdSJoe Perches 	},
6981da177e4SLinus Torvalds 	{
6991da177e4SLinus Torvalds 		.ctl_name	= KERN_PRINTK_RATELIMIT,
7001da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
701717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
7021da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7031da177e4SLinus Torvalds 		.mode		= 0644,
7041da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_jiffies,
7051da177e4SLinus Torvalds 		.strategy	= &sysctl_jiffies,
7061da177e4SLinus Torvalds 	},
7071da177e4SLinus Torvalds 	{
7081da177e4SLinus Torvalds 		.ctl_name	= KERN_PRINTK_RATELIMIT_BURST,
7091da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
710717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
7111da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7121da177e4SLinus Torvalds 		.mode		= 0644,
7131da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7141da177e4SLinus Torvalds 	},
7157ef3d2fdSJoe Perches #endif
7161da177e4SLinus Torvalds 	{
7171da177e4SLinus Torvalds 		.ctl_name	= KERN_NGROUPS_MAX,
7181da177e4SLinus Torvalds 		.procname	= "ngroups_max",
7191da177e4SLinus Torvalds 		.data		= &ngroups_max,
7201da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7211da177e4SLinus Torvalds 		.mode		= 0444,
7221da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7231da177e4SLinus Torvalds 	},
7241da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
7251da177e4SLinus Torvalds 	{
7261da177e4SLinus Torvalds 		.ctl_name       = KERN_UNKNOWN_NMI_PANIC,
7271da177e4SLinus Torvalds 		.procname       = "unknown_nmi_panic",
7281da177e4SLinus Torvalds 		.data           = &unknown_nmi_panic,
7291da177e4SLinus Torvalds 		.maxlen         = sizeof (int),
7301da177e4SLinus Torvalds 		.mode           = 0644,
7312fbe7b25SDon Zickus 		.proc_handler   = &proc_dointvec,
7321da177e4SLinus Torvalds 	},
733407984f1SDon Zickus 	{
734407984f1SDon Zickus 		.procname       = "nmi_watchdog",
735407984f1SDon Zickus 		.data           = &nmi_watchdog_enabled,
736407984f1SDon Zickus 		.maxlen         = sizeof (int),
737407984f1SDon Zickus 		.mode           = 0644,
738407984f1SDon Zickus 		.proc_handler   = &proc_nmi_enabled,
7391da177e4SLinus Torvalds 	},
7401da177e4SLinus Torvalds #endif
7411da177e4SLinus Torvalds #if defined(CONFIG_X86)
7421da177e4SLinus Torvalds 	{
7438da5addaSDon Zickus 		.ctl_name	= KERN_PANIC_ON_NMI,
7448da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
7458da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
7468da5addaSDon Zickus 		.maxlen		= sizeof(int),
7478da5addaSDon Zickus 		.mode		= 0644,
7488da5addaSDon Zickus 		.proc_handler	= &proc_dointvec,
7498da5addaSDon Zickus 	},
7508da5addaSDon Zickus 	{
7515211a242SKurt Garloff 		.ctl_name	= CTL_UNNUMBERED,
7525211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
7535211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
7545211a242SKurt Garloff 		.maxlen		= sizeof(int),
7555211a242SKurt Garloff 		.mode		= 0644,
7565211a242SKurt Garloff 		.proc_handler	= &proc_dointvec,
7575211a242SKurt Garloff 	},
7585211a242SKurt Garloff 	{
7591da177e4SLinus Torvalds 		.ctl_name	= KERN_BOOTLOADER_TYPE,
7601da177e4SLinus Torvalds 		.procname	= "bootloader_type",
7611da177e4SLinus Torvalds 		.data		= &bootloader_type,
7621da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7631da177e4SLinus Torvalds 		.mode		= 0444,
7641da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7651da177e4SLinus Torvalds 	},
7660741f4d2SChuck Ebbert 	{
7670741f4d2SChuck Ebbert 		.ctl_name	= CTL_UNNUMBERED,
7685031296cSH. Peter Anvin 		.procname	= "bootloader_version",
7695031296cSH. Peter Anvin 		.data		= &bootloader_version,
7705031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
7715031296cSH. Peter Anvin 		.mode		= 0444,
7725031296cSH. Peter Anvin 		.proc_handler	= &proc_dointvec,
7735031296cSH. Peter Anvin 	},
7745031296cSH. Peter Anvin 	{
7755031296cSH. Peter Anvin 		.ctl_name	= CTL_UNNUMBERED,
7760741f4d2SChuck Ebbert 		.procname	= "kstack_depth_to_print",
7770741f4d2SChuck Ebbert 		.data		= &kstack_depth_to_print,
7780741f4d2SChuck Ebbert 		.maxlen		= sizeof(int),
7790741f4d2SChuck Ebbert 		.mode		= 0644,
7800741f4d2SChuck Ebbert 		.proc_handler	= &proc_dointvec,
7810741f4d2SChuck Ebbert 	},
7826e7c4025SIngo Molnar 	{
7836e7c4025SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
7846e7c4025SIngo Molnar 		.procname	= "io_delay_type",
7856e7c4025SIngo Molnar 		.data		= &io_delay_type,
7866e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
7876e7c4025SIngo Molnar 		.mode		= 0644,
7886e7c4025SIngo Molnar 		.proc_handler	= &proc_dointvec,
7896e7c4025SIngo Molnar 	},
7901da177e4SLinus Torvalds #endif
7917a9166e3SLuke Yang #if defined(CONFIG_MMU)
7921da177e4SLinus Torvalds 	{
7931da177e4SLinus Torvalds 		.ctl_name	= KERN_RANDOMIZE,
7941da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
7951da177e4SLinus Torvalds 		.data		= &randomize_va_space,
7961da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7971da177e4SLinus Torvalds 		.mode		= 0644,
7981da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7991da177e4SLinus Torvalds 	},
8007a9166e3SLuke Yang #endif
8010152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
802951f22d5SMartin Schwidefsky 	{
803951f22d5SMartin Schwidefsky 		.ctl_name	= KERN_SPIN_RETRY,
804951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
805951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
806951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
807951f22d5SMartin Schwidefsky 		.mode		= 0644,
808951f22d5SMartin Schwidefsky 		.proc_handler	= &proc_dointvec,
809951f22d5SMartin Schwidefsky 	},
810951f22d5SMartin Schwidefsky #endif
811673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
812c255d844SPavel Machek 	{
813c255d844SPavel Machek 		.procname	= "acpi_video_flags",
81477afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
815c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
816c255d844SPavel Machek 		.mode		= 0644,
8177f99f06fSStefan Seyfried 		.proc_handler	= &proc_doulongvec_minmax,
818c255d844SPavel Machek 	},
819c255d844SPavel Machek #endif
820d2b176edSJes Sorensen #ifdef CONFIG_IA64
821d2b176edSJes Sorensen 	{
822d2b176edSJes Sorensen 		.ctl_name	= KERN_IA64_UNALIGNED,
823d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
824d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
825d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
826d2b176edSJes Sorensen 	 	.mode		= 0644,
827d2b176edSJes Sorensen 		.proc_handler	= &proc_dointvec,
828d2b176edSJes Sorensen 	},
82988fc241fSDoug Chapman 	{
83088fc241fSDoug Chapman 		.ctl_name	= CTL_UNNUMBERED,
83188fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
83288fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
83388fc241fSDoug Chapman 		.maxlen		= sizeof (int),
83488fc241fSDoug Chapman 		.mode		= 0644,
83588fc241fSDoug Chapman 		.proc_handler	= &proc_dointvec,
83688fc241fSDoug Chapman 	},
837d2b176edSJes Sorensen #endif
838c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP
839c4f3b63fSRavikiran G Thirumalai 	{
840c4f3b63fSRavikiran G Thirumalai 		.ctl_name	= CTL_UNNUMBERED,
8419c44bc03SIngo Molnar 		.procname	= "softlockup_panic",
8429c44bc03SIngo Molnar 		.data		= &softlockup_panic,
8439c44bc03SIngo Molnar 		.maxlen		= sizeof(int),
8449c44bc03SIngo Molnar 		.mode		= 0644,
8454dca10a9SHiroshi Shimamoto 		.proc_handler	= &proc_dointvec_minmax,
8469c44bc03SIngo Molnar 		.strategy	= &sysctl_intvec,
8479c44bc03SIngo Molnar 		.extra1		= &zero,
8489c44bc03SIngo Molnar 		.extra2		= &one,
8499c44bc03SIngo Molnar 	},
8509c44bc03SIngo Molnar 	{
8519c44bc03SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
852c4f3b63fSRavikiran G Thirumalai 		.procname	= "softlockup_thresh",
853c4f3b63fSRavikiran G Thirumalai 		.data		= &softlockup_thresh,
8549383d967SDimitri Sivanich 		.maxlen		= sizeof(int),
855c4f3b63fSRavikiran G Thirumalai 		.mode		= 0644,
856baf48f65SMandeep Singh Baines 		.proc_handler	= &proc_dosoftlockup_thresh,
857c4f3b63fSRavikiran G Thirumalai 		.strategy	= &sysctl_intvec,
8589383d967SDimitri Sivanich 		.extra1		= &neg_one,
859c4f3b63fSRavikiran G Thirumalai 		.extra2		= &sixty,
860c4f3b63fSRavikiran G Thirumalai 	},
861e162b39aSMandeep Singh Baines #endif
862e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
863e162b39aSMandeep Singh Baines 	{
864e162b39aSMandeep Singh Baines 		.ctl_name	= CTL_UNNUMBERED,
865e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
866e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
867e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
868e162b39aSMandeep Singh Baines 		.mode		= 0644,
869e162b39aSMandeep Singh Baines 		.proc_handler	= &proc_dointvec_minmax,
870e162b39aSMandeep Singh Baines 		.strategy	= &sysctl_intvec,
871e162b39aSMandeep Singh Baines 		.extra1		= &zero,
872e162b39aSMandeep Singh Baines 		.extra2		= &one,
873e162b39aSMandeep Singh Baines 	},
87482a1fcb9SIngo Molnar 	{
87582a1fcb9SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
87682a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
87782a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
87890739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
87982a1fcb9SIngo Molnar 		.mode		= 0644,
88090739081SIngo Molnar 		.proc_handler	= &proc_doulongvec_minmax,
88182a1fcb9SIngo Molnar 		.strategy	= &sysctl_intvec,
88282a1fcb9SIngo Molnar 	},
88382a1fcb9SIngo Molnar 	{
88482a1fcb9SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
88582a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
88682a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
88790739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
88882a1fcb9SIngo Molnar 		.mode		= 0644,
889e162b39aSMandeep Singh Baines 		.proc_handler	= &proc_dohung_task_timeout_secs,
89082a1fcb9SIngo Molnar 		.strategy	= &sysctl_intvec,
89182a1fcb9SIngo Molnar 	},
89282a1fcb9SIngo Molnar 	{
89382a1fcb9SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
89482a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
89582a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
89690739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
89782a1fcb9SIngo Molnar 		.mode		= 0644,
89890739081SIngo Molnar 		.proc_handler	= &proc_doulongvec_minmax,
89982a1fcb9SIngo Molnar 		.strategy	= &sysctl_intvec,
90082a1fcb9SIngo Molnar 	},
901c4f3b63fSRavikiran G Thirumalai #endif
902bebfa101SAndi Kleen #ifdef CONFIG_COMPAT
903bebfa101SAndi Kleen 	{
904bebfa101SAndi Kleen 		.ctl_name	= KERN_COMPAT_LOG,
905bebfa101SAndi Kleen 		.procname	= "compat-log",
906bebfa101SAndi Kleen 		.data		= &compat_log,
907bebfa101SAndi Kleen 		.maxlen		= sizeof (int),
908bebfa101SAndi Kleen 	 	.mode		= 0644,
909bebfa101SAndi Kleen 		.proc_handler	= &proc_dointvec,
910bebfa101SAndi Kleen 	},
911bebfa101SAndi Kleen #endif
91223f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
91323f78d4aSIngo Molnar 	{
91423f78d4aSIngo Molnar 		.ctl_name	= KERN_MAX_LOCK_DEPTH,
91523f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
91623f78d4aSIngo Molnar 		.data		= &max_lock_depth,
91723f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
91823f78d4aSIngo Molnar 		.mode		= 0644,
91923f78d4aSIngo Molnar 		.proc_handler	= &proc_dointvec,
92023f78d4aSIngo Molnar 	},
92123f78d4aSIngo Molnar #endif
92210a0a8d4SJeremy Fitzhardinge 	{
92310a0a8d4SJeremy Fitzhardinge 		.ctl_name	= CTL_UNNUMBERED,
92410a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
92510a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
92610a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
92710a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
92810a0a8d4SJeremy Fitzhardinge 		.proc_handler	= &proc_dostring,
92910a0a8d4SJeremy Fitzhardinge 		.strategy	= &sysctl_string,
93010a0a8d4SJeremy Fitzhardinge 	},
9310b77f5bfSDavid Howells #ifdef CONFIG_KEYS
9320b77f5bfSDavid Howells 	{
9330b77f5bfSDavid Howells 		.ctl_name	= CTL_UNNUMBERED,
9340b77f5bfSDavid Howells 		.procname	= "keys",
9350b77f5bfSDavid Howells 		.mode		= 0555,
9360b77f5bfSDavid Howells 		.child		= key_sysctls,
9370b77f5bfSDavid Howells 	},
9380b77f5bfSDavid Howells #endif
93931a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
94031a72bceSPaul E. McKenney 	{
94131a72bceSPaul E. McKenney 		.ctl_name       = CTL_UNNUMBERED,
94231a72bceSPaul E. McKenney 		.procname       = "rcutorture_runnable",
94331a72bceSPaul E. McKenney 		.data           = &rcutorture_runnable,
94431a72bceSPaul E. McKenney 		.maxlen         = sizeof(int),
94531a72bceSPaul E. McKenney 		.mode           = 0644,
94631a72bceSPaul E. McKenney 		.proc_handler   = &proc_dointvec,
94731a72bceSPaul E. McKenney 	},
94831a72bceSPaul E. McKenney #endif
94912e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK
95012e22c5eSDavid Howells 	{
95112e22c5eSDavid Howells 		.ctl_name	= CTL_UNNUMBERED,
95212e22c5eSDavid Howells 		.procname	= "slow-work",
95312e22c5eSDavid Howells 		.mode		= 0555,
95412e22c5eSDavid Howells 		.child		= slow_work_sysctls,
95512e22c5eSDavid Howells 	},
95612e22c5eSDavid Howells #endif
9571ccd1549SPeter Zijlstra #ifdef CONFIG_PERF_COUNTERS
9581ccd1549SPeter Zijlstra 	{
9591ccd1549SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
9600764771dSPeter Zijlstra 		.procname	= "perf_counter_paranoid",
9610764771dSPeter Zijlstra 		.data		= &sysctl_perf_counter_paranoid,
9620764771dSPeter Zijlstra 		.maxlen		= sizeof(sysctl_perf_counter_paranoid),
9631ccd1549SPeter Zijlstra 		.mode		= 0644,
9641ccd1549SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
9651ccd1549SPeter Zijlstra 	},
966c5078f78SPeter Zijlstra 	{
967c5078f78SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
968c5078f78SPeter Zijlstra 		.procname	= "perf_counter_mlock_kb",
969c5078f78SPeter Zijlstra 		.data		= &sysctl_perf_counter_mlock,
970c5078f78SPeter Zijlstra 		.maxlen		= sizeof(sysctl_perf_counter_mlock),
971c5078f78SPeter Zijlstra 		.mode		= 0644,
972c5078f78SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
973c5078f78SPeter Zijlstra 	},
974a78ac325SPeter Zijlstra 	{
975a78ac325SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
976df58ab24SPeter Zijlstra 		.procname	= "perf_counter_max_sample_rate",
977df58ab24SPeter Zijlstra 		.data		= &sysctl_perf_counter_sample_rate,
978df58ab24SPeter Zijlstra 		.maxlen		= sizeof(sysctl_perf_counter_sample_rate),
979a78ac325SPeter Zijlstra 		.mode		= 0644,
980a78ac325SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
981a78ac325SPeter Zijlstra 	},
9821ccd1549SPeter Zijlstra #endif
983dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK
984dfec072eSVegard Nossum 	{
985dfec072eSVegard Nossum 		.ctl_name	= CTL_UNNUMBERED,
986dfec072eSVegard Nossum 		.procname	= "kmemcheck",
987dfec072eSVegard Nossum 		.data		= &kmemcheck_enabled,
988dfec072eSVegard Nossum 		.maxlen		= sizeof(int),
989dfec072eSVegard Nossum 		.mode		= 0644,
990dfec072eSVegard Nossum 		.proc_handler	= &proc_dointvec,
991dfec072eSVegard Nossum 	},
992dfec072eSVegard Nossum #endif
993dfec072eSVegard Nossum 
994ed2c12f3SAndrew Morton /*
995ed2c12f3SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
996ed2c12f3SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
997ed2c12f3SAndrew Morton  */
9981da177e4SLinus Torvalds 	{ .ctl_name = 0 }
9991da177e4SLinus Torvalds };
10001da177e4SLinus Torvalds 
1001d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
10021da177e4SLinus Torvalds 	{
10031da177e4SLinus Torvalds 		.ctl_name	= VM_OVERCOMMIT_MEMORY,
10041da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
10051da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
10061da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
10071da177e4SLinus Torvalds 		.mode		= 0644,
10081da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10091da177e4SLinus Torvalds 	},
10101da177e4SLinus Torvalds 	{
1011fadd8fbdSKAMEZAWA Hiroyuki 		.ctl_name	= VM_PANIC_ON_OOM,
1012fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
1013fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
1014fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
1015fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
1016fadd8fbdSKAMEZAWA Hiroyuki 		.proc_handler	= &proc_dointvec,
1017fadd8fbdSKAMEZAWA Hiroyuki 	},
1018fadd8fbdSKAMEZAWA Hiroyuki 	{
1019fe071d7eSDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
1020fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
1021fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
1022fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
1023fe071d7eSDavid Rientjes 		.mode		= 0644,
1024fe071d7eSDavid Rientjes 		.proc_handler	= &proc_dointvec,
1025fe071d7eSDavid Rientjes 	},
1026fe071d7eSDavid Rientjes 	{
1027fef1bdd6SDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
1028fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
1029fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
1030fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
1031fef1bdd6SDavid Rientjes 		.mode		= 0644,
1032fef1bdd6SDavid Rientjes 		.proc_handler	= &proc_dointvec,
1033fef1bdd6SDavid Rientjes 	},
1034fef1bdd6SDavid Rientjes 	{
10351da177e4SLinus Torvalds 		.ctl_name	= VM_OVERCOMMIT_RATIO,
10361da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
10371da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
10381da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
10391da177e4SLinus Torvalds 		.mode		= 0644,
10401da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10411da177e4SLinus Torvalds 	},
10421da177e4SLinus Torvalds 	{
10431da177e4SLinus Torvalds 		.ctl_name	= VM_PAGE_CLUSTER,
10441da177e4SLinus Torvalds 		.procname	= "page-cluster",
10451da177e4SLinus Torvalds 		.data		= &page_cluster,
10461da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
10471da177e4SLinus Torvalds 		.mode		= 0644,
10481da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10491da177e4SLinus Torvalds 	},
10501da177e4SLinus Torvalds 	{
10511da177e4SLinus Torvalds 		.ctl_name	= VM_DIRTY_BACKGROUND,
10521da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
10531da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
10541da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
10551da177e4SLinus Torvalds 		.mode		= 0644,
10562da02997SDavid Rientjes 		.proc_handler	= &dirty_background_ratio_handler,
10571da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
10581da177e4SLinus Torvalds 		.extra1		= &zero,
10591da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10601da177e4SLinus Torvalds 	},
10611da177e4SLinus Torvalds 	{
10622da02997SDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
10632da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
10642da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
10652da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
10662da02997SDavid Rientjes 		.mode		= 0644,
10672da02997SDavid Rientjes 		.proc_handler	= &dirty_background_bytes_handler,
10682da02997SDavid Rientjes 		.strategy	= &sysctl_intvec,
1069fc3501d4SSven Wegener 		.extra1		= &one_ul,
10702da02997SDavid Rientjes 	},
10712da02997SDavid Rientjes 	{
10721da177e4SLinus Torvalds 		.ctl_name	= VM_DIRTY_RATIO,
10731da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
10741da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
10751da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
10761da177e4SLinus Torvalds 		.mode		= 0644,
107704fbfdc1SPeter Zijlstra 		.proc_handler	= &dirty_ratio_handler,
10781da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
10791da177e4SLinus Torvalds 		.extra1		= &zero,
10801da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10811da177e4SLinus Torvalds 	},
10821da177e4SLinus Torvalds 	{
10832da02997SDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
10842da02997SDavid Rientjes 		.procname	= "dirty_bytes",
10852da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
10862da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
10872da02997SDavid Rientjes 		.mode		= 0644,
10882da02997SDavid Rientjes 		.proc_handler	= &dirty_bytes_handler,
10892da02997SDavid Rientjes 		.strategy	= &sysctl_intvec,
10909e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
10912da02997SDavid Rientjes 	},
10922da02997SDavid Rientjes 	{
10931da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
1094f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
1095f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
10961da177e4SLinus Torvalds 		.mode		= 0644,
10971da177e4SLinus Torvalds 		.proc_handler	= &dirty_writeback_centisecs_handler,
10981da177e4SLinus Torvalds 	},
10991da177e4SLinus Torvalds 	{
11001da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
1101f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
1102f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
11031da177e4SLinus Torvalds 		.mode		= 0644,
1104704503d8SAlexey Dobriyan 		.proc_handler	= &proc_dointvec,
11051da177e4SLinus Torvalds 	},
11061da177e4SLinus Torvalds 	{
11071da177e4SLinus Torvalds 		.ctl_name	= VM_NR_PDFLUSH_THREADS,
11081da177e4SLinus Torvalds 		.procname	= "nr_pdflush_threads",
11091da177e4SLinus Torvalds 		.data		= &nr_pdflush_threads,
11101da177e4SLinus Torvalds 		.maxlen		= sizeof nr_pdflush_threads,
11111da177e4SLinus Torvalds 		.mode		= 0444 /* read-only*/,
11121da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
11131da177e4SLinus Torvalds 	},
11141da177e4SLinus Torvalds 	{
11151da177e4SLinus Torvalds 		.ctl_name	= VM_SWAPPINESS,
11161da177e4SLinus Torvalds 		.procname	= "swappiness",
11171da177e4SLinus Torvalds 		.data		= &vm_swappiness,
11181da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
11191da177e4SLinus Torvalds 		.mode		= 0644,
11201da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
11211da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
11221da177e4SLinus Torvalds 		.extra1		= &zero,
11231da177e4SLinus Torvalds 		.extra2		= &one_hundred,
11241da177e4SLinus Torvalds 	},
11251da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
11261da177e4SLinus Torvalds 	 {
11271da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
1128e5ff2159SAndi Kleen 		.data		= NULL,
11291da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
11301da177e4SLinus Torvalds 		.mode		= 0644,
11311da177e4SLinus Torvalds 		.proc_handler	= &hugetlb_sysctl_handler,
11321da177e4SLinus Torvalds 		.extra1		= (void *)&hugetlb_zero,
11331da177e4SLinus Torvalds 		.extra2		= (void *)&hugetlb_infinity,
11341da177e4SLinus Torvalds 	 },
11351da177e4SLinus Torvalds 	 {
11361da177e4SLinus Torvalds 		.ctl_name	= VM_HUGETLB_GROUP,
11371da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
11381da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
11391da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
11401da177e4SLinus Torvalds 		.mode		= 0644,
11411da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
11421da177e4SLinus Torvalds 	 },
1143396faf03SMel Gorman 	 {
1144396faf03SMel Gorman 		.ctl_name	= CTL_UNNUMBERED,
1145396faf03SMel Gorman 		.procname	= "hugepages_treat_as_movable",
1146396faf03SMel Gorman 		.data		= &hugepages_treat_as_movable,
1147396faf03SMel Gorman 		.maxlen		= sizeof(int),
1148396faf03SMel Gorman 		.mode		= 0644,
1149396faf03SMel Gorman 		.proc_handler	= &hugetlb_treat_movable_handler,
1150396faf03SMel Gorman 	},
115154f9f80dSAdam Litke 	{
115254f9f80dSAdam Litke 		.ctl_name	= CTL_UNNUMBERED,
1153d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
1154e5ff2159SAndi Kleen 		.data		= NULL,
1155e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
1156d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
1157a3d0c6aaSNishanth Aravamudan 		.proc_handler	= &hugetlb_overcommit_handler,
1158e5ff2159SAndi Kleen 		.extra1		= (void *)&hugetlb_zero,
1159e5ff2159SAndi Kleen 		.extra2		= (void *)&hugetlb_infinity,
1160d1c3fb1fSNishanth Aravamudan 	},
11611da177e4SLinus Torvalds #endif
11621da177e4SLinus Torvalds 	{
11631da177e4SLinus Torvalds 		.ctl_name	= VM_LOWMEM_RESERVE_RATIO,
11641da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
11651da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
11661da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
11671da177e4SLinus Torvalds 		.mode		= 0644,
11681da177e4SLinus Torvalds 		.proc_handler	= &lowmem_reserve_ratio_sysctl_handler,
11691da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
11701da177e4SLinus Torvalds 	},
11711da177e4SLinus Torvalds 	{
11729d0243bcSAndrew Morton 		.ctl_name	= VM_DROP_PAGECACHE,
11739d0243bcSAndrew Morton 		.procname	= "drop_caches",
11749d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
11759d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
11769d0243bcSAndrew Morton 		.mode		= 0644,
11779d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
11789d0243bcSAndrew Morton 		.strategy	= &sysctl_intvec,
11799d0243bcSAndrew Morton 	},
11809d0243bcSAndrew Morton 	{
11811da177e4SLinus Torvalds 		.ctl_name	= VM_MIN_FREE_KBYTES,
11821da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
11831da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
11841da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
11851da177e4SLinus Torvalds 		.mode		= 0644,
11861da177e4SLinus Torvalds 		.proc_handler	= &min_free_kbytes_sysctl_handler,
11871da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
11881da177e4SLinus Torvalds 		.extra1		= &zero,
11891da177e4SLinus Torvalds 	},
11908ad4b1fbSRohit Seth 	{
11918ad4b1fbSRohit Seth 		.ctl_name	= VM_PERCPU_PAGELIST_FRACTION,
11928ad4b1fbSRohit Seth 		.procname	= "percpu_pagelist_fraction",
11938ad4b1fbSRohit Seth 		.data		= &percpu_pagelist_fraction,
11948ad4b1fbSRohit Seth 		.maxlen		= sizeof(percpu_pagelist_fraction),
11958ad4b1fbSRohit Seth 		.mode		= 0644,
11968ad4b1fbSRohit Seth 		.proc_handler	= &percpu_pagelist_fraction_sysctl_handler,
11978ad4b1fbSRohit Seth 		.strategy	= &sysctl_intvec,
11988ad4b1fbSRohit Seth 		.extra1		= &min_percpu_pagelist_fract,
11998ad4b1fbSRohit Seth 	},
12001da177e4SLinus Torvalds #ifdef CONFIG_MMU
12011da177e4SLinus Torvalds 	{
12021da177e4SLinus Torvalds 		.ctl_name	= VM_MAX_MAP_COUNT,
12031da177e4SLinus Torvalds 		.procname	= "max_map_count",
12041da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
12051da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
12061da177e4SLinus Torvalds 		.mode		= 0644,
12071da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec
12081da177e4SLinus Torvalds 	},
1209dd8632a1SPaul Mundt #else
1210dd8632a1SPaul Mundt 	{
1211dd8632a1SPaul Mundt 		.ctl_name	= CTL_UNNUMBERED,
1212dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
1213dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
1214dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
1215dd8632a1SPaul Mundt 		.mode		= 0644,
1216dd8632a1SPaul Mundt 		.proc_handler	= &proc_dointvec_minmax,
1217dd8632a1SPaul Mundt 		.strategy	= &sysctl_intvec,
1218dd8632a1SPaul Mundt 		.extra1		= &zero,
1219dd8632a1SPaul Mundt 	},
12201da177e4SLinus Torvalds #endif
12211da177e4SLinus Torvalds 	{
12221da177e4SLinus Torvalds 		.ctl_name	= VM_LAPTOP_MODE,
12231da177e4SLinus Torvalds 		.procname	= "laptop_mode",
12241da177e4SLinus Torvalds 		.data		= &laptop_mode,
12251da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
12261da177e4SLinus Torvalds 		.mode		= 0644,
1227ed5b43f1SBart Samwel 		.proc_handler	= &proc_dointvec_jiffies,
1228ed5b43f1SBart Samwel 		.strategy	= &sysctl_jiffies,
12291da177e4SLinus Torvalds 	},
12301da177e4SLinus Torvalds 	{
12311da177e4SLinus Torvalds 		.ctl_name	= VM_BLOCK_DUMP,
12321da177e4SLinus Torvalds 		.procname	= "block_dump",
12331da177e4SLinus Torvalds 		.data		= &block_dump,
12341da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
12351da177e4SLinus Torvalds 		.mode		= 0644,
12361da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
12371da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
12381da177e4SLinus Torvalds 		.extra1		= &zero,
12391da177e4SLinus Torvalds 	},
12401da177e4SLinus Torvalds 	{
12411da177e4SLinus Torvalds 		.ctl_name	= VM_VFS_CACHE_PRESSURE,
12421da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
12431da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
12441da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
12451da177e4SLinus Torvalds 		.mode		= 0644,
12461da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
12471da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
12481da177e4SLinus Torvalds 		.extra1		= &zero,
12491da177e4SLinus Torvalds 	},
12501da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
12511da177e4SLinus Torvalds 	{
12521da177e4SLinus Torvalds 		.ctl_name	= VM_LEGACY_VA_LAYOUT,
12531da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
12541da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
12551da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
12561da177e4SLinus Torvalds 		.mode		= 0644,
12571da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
12581da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
12591da177e4SLinus Torvalds 		.extra1		= &zero,
12601da177e4SLinus Torvalds 	},
12611da177e4SLinus Torvalds #endif
12621743660bSChristoph Lameter #ifdef CONFIG_NUMA
12631743660bSChristoph Lameter 	{
12641743660bSChristoph Lameter 		.ctl_name	= VM_ZONE_RECLAIM_MODE,
12651743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
12661743660bSChristoph Lameter 		.data		= &zone_reclaim_mode,
12671743660bSChristoph Lameter 		.maxlen		= sizeof(zone_reclaim_mode),
12681743660bSChristoph Lameter 		.mode		= 0644,
12691743660bSChristoph Lameter 		.proc_handler	= &proc_dointvec,
1270c84db23cSChristoph Lameter 		.strategy	= &sysctl_intvec,
1271c84db23cSChristoph Lameter 		.extra1		= &zero,
12721743660bSChristoph Lameter 	},
12739614634fSChristoph Lameter 	{
12749614634fSChristoph Lameter 		.ctl_name	= VM_MIN_UNMAPPED,
12759614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
12769614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
12779614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
12789614634fSChristoph Lameter 		.mode		= 0644,
12799614634fSChristoph Lameter 		.proc_handler	= &sysctl_min_unmapped_ratio_sysctl_handler,
12809614634fSChristoph Lameter 		.strategy	= &sysctl_intvec,
12819614634fSChristoph Lameter 		.extra1		= &zero,
12829614634fSChristoph Lameter 		.extra2		= &one_hundred,
12839614634fSChristoph Lameter 	},
12840ff38490SChristoph Lameter 	{
12850ff38490SChristoph Lameter 		.ctl_name	= VM_MIN_SLAB,
12860ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
12870ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
12880ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
12890ff38490SChristoph Lameter 		.mode		= 0644,
12900ff38490SChristoph Lameter 		.proc_handler	= &sysctl_min_slab_ratio_sysctl_handler,
12910ff38490SChristoph Lameter 		.strategy	= &sysctl_intvec,
12920ff38490SChristoph Lameter 		.extra1		= &zero,
12930ff38490SChristoph Lameter 		.extra2		= &one_hundred,
12940ff38490SChristoph Lameter 	},
12951743660bSChristoph Lameter #endif
129677461ab3SChristoph Lameter #ifdef CONFIG_SMP
129777461ab3SChristoph Lameter 	{
129877461ab3SChristoph Lameter 		.ctl_name	= CTL_UNNUMBERED,
129977461ab3SChristoph Lameter 		.procname	= "stat_interval",
130077461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
130177461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
130277461ab3SChristoph Lameter 		.mode		= 0644,
130377461ab3SChristoph Lameter 		.proc_handler	= &proc_dointvec_jiffies,
130477461ab3SChristoph Lameter 		.strategy	= &sysctl_jiffies,
130577461ab3SChristoph Lameter 	},
130677461ab3SChristoph Lameter #endif
1307ed032189SEric Paris 	{
1308ed032189SEric Paris 		.ctl_name	= CTL_UNNUMBERED,
1309ed032189SEric Paris 		.procname	= "mmap_min_addr",
1310*788084abSEric Paris 		.data		= &dac_mmap_min_addr,
1311ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
1312ed032189SEric Paris 		.mode		= 0644,
1313*788084abSEric Paris 		.proc_handler	= &mmap_min_addr_handler,
1314ed032189SEric Paris 	},
1315f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
1316f0c0b2b8SKAMEZAWA Hiroyuki 	{
1317f0c0b2b8SKAMEZAWA Hiroyuki 		.ctl_name	= CTL_UNNUMBERED,
1318f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
1319f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
1320f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
1321f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
1322f0c0b2b8SKAMEZAWA Hiroyuki 		.proc_handler	= &numa_zonelist_order_handler,
1323f0c0b2b8SKAMEZAWA Hiroyuki 		.strategy	= &sysctl_string,
1324f0c0b2b8SKAMEZAWA Hiroyuki 	},
1325f0c0b2b8SKAMEZAWA Hiroyuki #endif
13262b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
13275c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1328e6e5494cSIngo Molnar 	{
1329e6e5494cSIngo Molnar 		.ctl_name	= VM_VDSO_ENABLED,
1330e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
1331e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
1332e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
1333e6e5494cSIngo Molnar 		.mode		= 0644,
1334e6e5494cSIngo Molnar 		.proc_handler	= &proc_dointvec,
1335e6e5494cSIngo Molnar 		.strategy	= &sysctl_intvec,
1336e6e5494cSIngo Molnar 		.extra1		= &zero,
1337e6e5494cSIngo Molnar 	},
1338e6e5494cSIngo Molnar #endif
1339195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
1340195cf453SBron Gondwana 	{
1341195cf453SBron Gondwana 		.ctl_name	= CTL_UNNUMBERED,
1342195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
1343195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
1344195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
1345195cf453SBron Gondwana 		.mode		= 0644,
1346195cf453SBron Gondwana 		.proc_handler	= &proc_dointvec_minmax,
1347195cf453SBron Gondwana 		.strategy	= &sysctl_intvec,
1348195cf453SBron Gondwana 		.extra1		= &zero,
1349195cf453SBron Gondwana 		.extra2		= &one,
1350195cf453SBron Gondwana 	},
1351195cf453SBron Gondwana #endif
13524be6f6bbSPeter Zijlstra 	{
13534be6f6bbSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
13544be6f6bbSPeter Zijlstra 		.procname	= "scan_unevictable_pages",
13554be6f6bbSPeter Zijlstra 		.data		= &scan_unevictable_pages,
13564be6f6bbSPeter Zijlstra 		.maxlen		= sizeof(scan_unevictable_pages),
13574be6f6bbSPeter Zijlstra 		.mode		= 0644,
13584be6f6bbSPeter Zijlstra 		.proc_handler	= &scan_unevictable_handler,
13594be6f6bbSPeter Zijlstra 	},
13602be7fe07SAndrew Morton /*
13612be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
13622be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
13632be7fe07SAndrew Morton  */
13641da177e4SLinus Torvalds 	{ .ctl_name = 0 }
13651da177e4SLinus Torvalds };
13661da177e4SLinus Torvalds 
13672abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1368d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = {
13692abc26fcSEric W. Biederman 	{ .ctl_name = 0 }
13702abc26fcSEric W. Biederman };
13712abc26fcSEric W. Biederman #endif
13722abc26fcSEric W. Biederman 
1373d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
13741da177e4SLinus Torvalds 	{
13751da177e4SLinus Torvalds 		.ctl_name	= FS_NRINODE,
13761da177e4SLinus Torvalds 		.procname	= "inode-nr",
13771da177e4SLinus Torvalds 		.data		= &inodes_stat,
13781da177e4SLinus Torvalds 		.maxlen		= 2*sizeof(int),
13791da177e4SLinus Torvalds 		.mode		= 0444,
13801da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
13811da177e4SLinus Torvalds 	},
13821da177e4SLinus Torvalds 	{
13831da177e4SLinus Torvalds 		.ctl_name	= FS_STATINODE,
13841da177e4SLinus Torvalds 		.procname	= "inode-state",
13851da177e4SLinus Torvalds 		.data		= &inodes_stat,
13861da177e4SLinus Torvalds 		.maxlen		= 7*sizeof(int),
13871da177e4SLinus Torvalds 		.mode		= 0444,
13881da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
13891da177e4SLinus Torvalds 	},
13901da177e4SLinus Torvalds 	{
13911da177e4SLinus Torvalds 		.procname	= "file-nr",
13921da177e4SLinus Torvalds 		.data		= &files_stat,
13931da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
13941da177e4SLinus Torvalds 		.mode		= 0444,
1395529bf6beSDipankar Sarma 		.proc_handler	= &proc_nr_files,
13961da177e4SLinus Torvalds 	},
13971da177e4SLinus Torvalds 	{
13981da177e4SLinus Torvalds 		.ctl_name	= FS_MAXFILE,
13991da177e4SLinus Torvalds 		.procname	= "file-max",
14001da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
14011da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14021da177e4SLinus Torvalds 		.mode		= 0644,
14031da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14041da177e4SLinus Torvalds 	},
14051da177e4SLinus Torvalds 	{
14069cfe015aSEric Dumazet 		.ctl_name	= CTL_UNNUMBERED,
14079cfe015aSEric Dumazet 		.procname	= "nr_open",
14089cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
14099cfe015aSEric Dumazet 		.maxlen		= sizeof(int),
14109cfe015aSEric Dumazet 		.mode		= 0644,
1411eceea0b3SAl Viro 		.proc_handler	= &proc_dointvec_minmax,
1412eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
1413eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
14149cfe015aSEric Dumazet 	},
14159cfe015aSEric Dumazet 	{
14161da177e4SLinus Torvalds 		.ctl_name	= FS_DENTRY,
14171da177e4SLinus Torvalds 		.procname	= "dentry-state",
14181da177e4SLinus Torvalds 		.data		= &dentry_stat,
14191da177e4SLinus Torvalds 		.maxlen		= 6*sizeof(int),
14201da177e4SLinus Torvalds 		.mode		= 0444,
14211da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14221da177e4SLinus Torvalds 	},
14231da177e4SLinus Torvalds 	{
14241da177e4SLinus Torvalds 		.ctl_name	= FS_OVERFLOWUID,
14251da177e4SLinus Torvalds 		.procname	= "overflowuid",
14261da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
14271da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14281da177e4SLinus Torvalds 		.mode		= 0644,
14291da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
14301da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
14311da177e4SLinus Torvalds 		.extra1		= &minolduid,
14321da177e4SLinus Torvalds 		.extra2		= &maxolduid,
14331da177e4SLinus Torvalds 	},
14341da177e4SLinus Torvalds 	{
14351da177e4SLinus Torvalds 		.ctl_name	= FS_OVERFLOWGID,
14361da177e4SLinus Torvalds 		.procname	= "overflowgid",
14371da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
14381da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14391da177e4SLinus Torvalds 		.mode		= 0644,
14401da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
14411da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
14421da177e4SLinus Torvalds 		.extra1		= &minolduid,
14431da177e4SLinus Torvalds 		.extra2		= &maxolduid,
14441da177e4SLinus Torvalds 	},
1445bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
14461da177e4SLinus Torvalds 	{
14471da177e4SLinus Torvalds 		.ctl_name	= FS_LEASES,
14481da177e4SLinus Torvalds 		.procname	= "leases-enable",
14491da177e4SLinus Torvalds 		.data		= &leases_enable,
14501da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14511da177e4SLinus Torvalds 		.mode		= 0644,
14521da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14531da177e4SLinus Torvalds 	},
1454bfcd17a6SThomas Petazzoni #endif
14551da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
14561da177e4SLinus Torvalds 	{
14571da177e4SLinus Torvalds 		.ctl_name	= FS_DIR_NOTIFY,
14581da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
14591da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
14601da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14611da177e4SLinus Torvalds 		.mode		= 0644,
14621da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14631da177e4SLinus Torvalds 	},
14641da177e4SLinus Torvalds #endif
14651da177e4SLinus Torvalds #ifdef CONFIG_MMU
1466bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
14671da177e4SLinus Torvalds 	{
14681da177e4SLinus Torvalds 		.ctl_name	= FS_LEASE_TIME,
14691da177e4SLinus Torvalds 		.procname	= "lease-break-time",
14701da177e4SLinus Torvalds 		.data		= &lease_break_time,
14711da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14721da177e4SLinus Torvalds 		.mode		= 0644,
14738e654fbaSMatthew Wilcox 		.proc_handler	= &proc_dointvec,
14741da177e4SLinus Torvalds 	},
1475bfcd17a6SThomas Petazzoni #endif
1476ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
14771da177e4SLinus Torvalds 	{
14781da177e4SLinus Torvalds 		.procname	= "aio-nr",
14791da177e4SLinus Torvalds 		.data		= &aio_nr,
14801da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
14811da177e4SLinus Torvalds 		.mode		= 0444,
1482d55b5fdaSZach Brown 		.proc_handler	= &proc_doulongvec_minmax,
14831da177e4SLinus Torvalds 	},
14841da177e4SLinus Torvalds 	{
14851da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
14861da177e4SLinus Torvalds 		.data		= &aio_max_nr,
14871da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
14881da177e4SLinus Torvalds 		.mode		= 0644,
1489d55b5fdaSZach Brown 		.proc_handler	= &proc_doulongvec_minmax,
14901da177e4SLinus Torvalds 	},
1491ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
14922d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
14930399cb08SRobert Love 	{
14940399cb08SRobert Love 		.ctl_name	= FS_INOTIFY,
14950399cb08SRobert Love 		.procname	= "inotify",
14960399cb08SRobert Love 		.mode		= 0555,
14970399cb08SRobert Love 		.child		= inotify_table,
14980399cb08SRobert Love 	},
14990399cb08SRobert Love #endif
15007ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
15017ef9964eSDavide Libenzi 	{
15027ef9964eSDavide Libenzi 		.procname	= "epoll",
15037ef9964eSDavide Libenzi 		.mode		= 0555,
15047ef9964eSDavide Libenzi 		.child		= epoll_table,
15057ef9964eSDavide Libenzi 	},
15067ef9964eSDavide Libenzi #endif
15071da177e4SLinus Torvalds #endif
1508d6e71144SAlan Cox 	{
1509d6e71144SAlan Cox 		.ctl_name	= KERN_SETUID_DUMPABLE,
1510d6e71144SAlan Cox 		.procname	= "suid_dumpable",
1511d6e71144SAlan Cox 		.data		= &suid_dumpable,
1512d6e71144SAlan Cox 		.maxlen		= sizeof(int),
1513d6e71144SAlan Cox 		.mode		= 0644,
15148e654fbaSMatthew Wilcox 		.proc_handler	= &proc_dointvec_minmax,
15158e654fbaSMatthew Wilcox 		.strategy	= &sysctl_intvec,
15168e654fbaSMatthew Wilcox 		.extra1		= &zero,
15178e654fbaSMatthew Wilcox 		.extra2		= &two,
1518d6e71144SAlan Cox 	},
15192abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
15202abc26fcSEric W. Biederman 	{
15212abc26fcSEric W. Biederman 		.ctl_name	= CTL_UNNUMBERED,
15222abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
15232abc26fcSEric W. Biederman 		.mode		= 0555,
15242abc26fcSEric W. Biederman 		.child		= binfmt_misc_table,
15252abc26fcSEric W. Biederman 	},
15262abc26fcSEric W. Biederman #endif
15272be7fe07SAndrew Morton /*
15282be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
15292be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
15302be7fe07SAndrew Morton  */
15311da177e4SLinus Torvalds 	{ .ctl_name = 0 }
15321da177e4SLinus Torvalds };
15331da177e4SLinus Torvalds 
1534d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
1535d0c3d534SOlof Johansson #if defined(CONFIG_X86) || defined(CONFIG_PPC)
1536abd4f750SMasoud Asgharifard Sharbiani 	{
1537abd4f750SMasoud Asgharifard Sharbiani 		.ctl_name	= CTL_UNNUMBERED,
1538abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
1539abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
1540abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
1541abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
1542abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
1543abd4f750SMasoud Asgharifard Sharbiani 	},
1544abd4f750SMasoud Asgharifard Sharbiani #endif
15451da177e4SLinus Torvalds 	{ .ctl_name = 0 }
15461da177e4SLinus Torvalds };
15471da177e4SLinus Torvalds 
1548d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
15491da177e4SLinus Torvalds 	{ .ctl_name = 0 }
15501da177e4SLinus Torvalds };
15511da177e4SLinus Torvalds 
1552330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock);
1553330d57fbSAl Viro 
1554330d57fbSAl Viro /* called under sysctl_lock */
1555330d57fbSAl Viro static int use_table(struct ctl_table_header *p)
1556330d57fbSAl Viro {
1557330d57fbSAl Viro 	if (unlikely(p->unregistering))
1558330d57fbSAl Viro 		return 0;
1559330d57fbSAl Viro 	p->used++;
1560330d57fbSAl Viro 	return 1;
1561330d57fbSAl Viro }
1562330d57fbSAl Viro 
1563330d57fbSAl Viro /* called under sysctl_lock */
1564330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p)
1565330d57fbSAl Viro {
1566330d57fbSAl Viro 	if (!--p->used)
1567330d57fbSAl Viro 		if (unlikely(p->unregistering))
1568330d57fbSAl Viro 			complete(p->unregistering);
1569330d57fbSAl Viro }
1570330d57fbSAl Viro 
1571330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */
1572330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p)
1573330d57fbSAl Viro {
1574330d57fbSAl Viro 	/*
1575330d57fbSAl Viro 	 * if p->used is 0, nobody will ever touch that entry again;
1576330d57fbSAl Viro 	 * we'll eliminate all paths to it before dropping sysctl_lock
1577330d57fbSAl Viro 	 */
1578330d57fbSAl Viro 	if (unlikely(p->used)) {
1579330d57fbSAl Viro 		struct completion wait;
1580330d57fbSAl Viro 		init_completion(&wait);
1581330d57fbSAl Viro 		p->unregistering = &wait;
1582330d57fbSAl Viro 		spin_unlock(&sysctl_lock);
1583330d57fbSAl Viro 		wait_for_completion(&wait);
1584330d57fbSAl Viro 		spin_lock(&sysctl_lock);
1585f7e6ced4SAl Viro 	} else {
1586f7e6ced4SAl Viro 		/* anything non-NULL; we'll never dereference it */
1587f7e6ced4SAl Viro 		p->unregistering = ERR_PTR(-EINVAL);
1588330d57fbSAl Viro 	}
1589330d57fbSAl Viro 	/*
1590330d57fbSAl Viro 	 * do not remove from the list until nobody holds it; walking the
1591330d57fbSAl Viro 	 * list in do_sysctl() relies on that.
1592330d57fbSAl Viro 	 */
1593330d57fbSAl Viro 	list_del_init(&p->ctl_entry);
1594330d57fbSAl Viro }
1595330d57fbSAl Viro 
1596f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head)
1597f7e6ced4SAl Viro {
1598f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1599f7e6ced4SAl Viro 	head->count++;
1600f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1601f7e6ced4SAl Viro }
1602f7e6ced4SAl Viro 
1603f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
1604f7e6ced4SAl Viro {
1605f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1606f7e6ced4SAl Viro 	if (!--head->count)
1607f7e6ced4SAl Viro 		kfree(head);
1608f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1609f7e6ced4SAl Viro }
1610f7e6ced4SAl Viro 
1611f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1612f7e6ced4SAl Viro {
1613f7e6ced4SAl Viro 	if (!head)
1614f7e6ced4SAl Viro 		BUG();
1615f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1616f7e6ced4SAl Viro 	if (!use_table(head))
1617f7e6ced4SAl Viro 		head = ERR_PTR(-ENOENT);
1618f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1619f7e6ced4SAl Viro 	return head;
1620f7e6ced4SAl Viro }
1621f7e6ced4SAl Viro 
1622805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head)
1623805b5d5eSEric W. Biederman {
1624805b5d5eSEric W. Biederman 	if (!head)
1625805b5d5eSEric W. Biederman 		return;
1626805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1627805b5d5eSEric W. Biederman 	unuse_table(head);
1628805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1629805b5d5eSEric W. Biederman }
1630805b5d5eSEric W. Biederman 
163173455092SAl Viro static struct ctl_table_set *
163273455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
163373455092SAl Viro {
163473455092SAl Viro 	struct ctl_table_set *set = &root->default_set;
163573455092SAl Viro 	if (root->lookup)
163673455092SAl Viro 		set = root->lookup(root, namespaces);
163773455092SAl Viro 	return set;
163873455092SAl Viro }
163973455092SAl Viro 
1640e51b6ba0SEric W. Biederman static struct list_head *
1641e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1642805b5d5eSEric W. Biederman {
164373455092SAl Viro 	struct ctl_table_set *set = lookup_header_set(root, namespaces);
164473455092SAl Viro 	return &set->list;
1645e51b6ba0SEric W. Biederman }
1646e51b6ba0SEric W. Biederman 
1647e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1648e51b6ba0SEric W. Biederman 					    struct ctl_table_header *prev)
1649e51b6ba0SEric W. Biederman {
1650e51b6ba0SEric W. Biederman 	struct ctl_table_root *root;
1651e51b6ba0SEric W. Biederman 	struct list_head *header_list;
1652805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1653805b5d5eSEric W. Biederman 	struct list_head *tmp;
1654e51b6ba0SEric W. Biederman 
1655805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1656805b5d5eSEric W. Biederman 	if (prev) {
1657e51b6ba0SEric W. Biederman 		head = prev;
1658805b5d5eSEric W. Biederman 		tmp = &prev->ctl_entry;
1659805b5d5eSEric W. Biederman 		unuse_table(prev);
1660805b5d5eSEric W. Biederman 		goto next;
1661805b5d5eSEric W. Biederman 	}
1662805b5d5eSEric W. Biederman 	tmp = &root_table_header.ctl_entry;
1663805b5d5eSEric W. Biederman 	for (;;) {
1664805b5d5eSEric W. Biederman 		head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1665805b5d5eSEric W. Biederman 
1666805b5d5eSEric W. Biederman 		if (!use_table(head))
1667805b5d5eSEric W. Biederman 			goto next;
1668805b5d5eSEric W. Biederman 		spin_unlock(&sysctl_lock);
1669805b5d5eSEric W. Biederman 		return head;
1670805b5d5eSEric W. Biederman 	next:
1671e51b6ba0SEric W. Biederman 		root = head->root;
1672805b5d5eSEric W. Biederman 		tmp = tmp->next;
1673e51b6ba0SEric W. Biederman 		header_list = lookup_header_list(root, namespaces);
1674e51b6ba0SEric W. Biederman 		if (tmp != header_list)
1675e51b6ba0SEric W. Biederman 			continue;
1676e51b6ba0SEric W. Biederman 
1677e51b6ba0SEric W. Biederman 		do {
1678e51b6ba0SEric W. Biederman 			root = list_entry(root->root_list.next,
1679e51b6ba0SEric W. Biederman 					struct ctl_table_root, root_list);
1680e51b6ba0SEric W. Biederman 			if (root == &sysctl_table_root)
1681e51b6ba0SEric W. Biederman 				goto out;
1682e51b6ba0SEric W. Biederman 			header_list = lookup_header_list(root, namespaces);
1683e51b6ba0SEric W. Biederman 		} while (list_empty(header_list));
1684e51b6ba0SEric W. Biederman 		tmp = header_list->next;
1685805b5d5eSEric W. Biederman 	}
1686e51b6ba0SEric W. Biederman out:
1687805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1688805b5d5eSEric W. Biederman 	return NULL;
1689805b5d5eSEric W. Biederman }
1690805b5d5eSEric W. Biederman 
1691e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1692e51b6ba0SEric W. Biederman {
1693e51b6ba0SEric W. Biederman 	return __sysctl_head_next(current->nsproxy, prev);
1694e51b6ba0SEric W. Biederman }
1695e51b6ba0SEric W. Biederman 
1696e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root)
1697e51b6ba0SEric W. Biederman {
1698e51b6ba0SEric W. Biederman 	spin_lock(&sysctl_lock);
1699e51b6ba0SEric W. Biederman 	list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1700e51b6ba0SEric W. Biederman 	spin_unlock(&sysctl_lock);
1701e51b6ba0SEric W. Biederman }
1702e51b6ba0SEric W. Biederman 
1703b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL
17042c4c7155SPavel Emelyanov /* Perform the actual read/write of a sysctl table entry. */
1705d7321cd6SPavel Emelyanov static int do_sysctl_strategy(struct ctl_table_root *root,
1706d7321cd6SPavel Emelyanov 			struct ctl_table *table,
17072c4c7155SPavel Emelyanov 			void __user *oldval, size_t __user *oldlenp,
17082c4c7155SPavel Emelyanov 			void __user *newval, size_t newlen)
17092c4c7155SPavel Emelyanov {
17102c4c7155SPavel Emelyanov 	int op = 0, rc;
17112c4c7155SPavel Emelyanov 
17122c4c7155SPavel Emelyanov 	if (oldval)
1713e6305c43SAl Viro 		op |= MAY_READ;
17142c4c7155SPavel Emelyanov 	if (newval)
1715e6305c43SAl Viro 		op |= MAY_WRITE;
1716d7321cd6SPavel Emelyanov 	if (sysctl_perm(root, table, op))
17172c4c7155SPavel Emelyanov 		return -EPERM;
17182c4c7155SPavel Emelyanov 
17192c4c7155SPavel Emelyanov 	if (table->strategy) {
1720f221e726SAlexey Dobriyan 		rc = table->strategy(table, oldval, oldlenp, newval, newlen);
17212c4c7155SPavel Emelyanov 		if (rc < 0)
17222c4c7155SPavel Emelyanov 			return rc;
17232c4c7155SPavel Emelyanov 		if (rc > 0)
17242c4c7155SPavel Emelyanov 			return 0;
17252c4c7155SPavel Emelyanov 	}
17262c4c7155SPavel Emelyanov 
17272c4c7155SPavel Emelyanov 	/* If there is no strategy routine, or if the strategy returns
17282c4c7155SPavel Emelyanov 	 * zero, proceed with automatic r/w */
17292c4c7155SPavel Emelyanov 	if (table->data && table->maxlen) {
1730f221e726SAlexey Dobriyan 		rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
17312c4c7155SPavel Emelyanov 		if (rc < 0)
17322c4c7155SPavel Emelyanov 			return rc;
17332c4c7155SPavel Emelyanov 	}
17342c4c7155SPavel Emelyanov 	return 0;
17352c4c7155SPavel Emelyanov }
17362c4c7155SPavel Emelyanov 
17372c4c7155SPavel Emelyanov static int parse_table(int __user *name, int nlen,
17382c4c7155SPavel Emelyanov 		       void __user *oldval, size_t __user *oldlenp,
17392c4c7155SPavel Emelyanov 		       void __user *newval, size_t newlen,
1740d7321cd6SPavel Emelyanov 		       struct ctl_table_root *root,
17412c4c7155SPavel Emelyanov 		       struct ctl_table *table)
17422c4c7155SPavel Emelyanov {
17432c4c7155SPavel Emelyanov 	int n;
17442c4c7155SPavel Emelyanov repeat:
17452c4c7155SPavel Emelyanov 	if (!nlen)
17462c4c7155SPavel Emelyanov 		return -ENOTDIR;
17472c4c7155SPavel Emelyanov 	if (get_user(n, name))
17482c4c7155SPavel Emelyanov 		return -EFAULT;
17492c4c7155SPavel Emelyanov 	for ( ; table->ctl_name || table->procname; table++) {
17502c4c7155SPavel Emelyanov 		if (!table->ctl_name)
17512c4c7155SPavel Emelyanov 			continue;
17522c4c7155SPavel Emelyanov 		if (n == table->ctl_name) {
17532c4c7155SPavel Emelyanov 			int error;
17542c4c7155SPavel Emelyanov 			if (table->child) {
1755e6305c43SAl Viro 				if (sysctl_perm(root, table, MAY_EXEC))
17562c4c7155SPavel Emelyanov 					return -EPERM;
17572c4c7155SPavel Emelyanov 				name++;
17582c4c7155SPavel Emelyanov 				nlen--;
17592c4c7155SPavel Emelyanov 				table = table->child;
17602c4c7155SPavel Emelyanov 				goto repeat;
17612c4c7155SPavel Emelyanov 			}
1762f221e726SAlexey Dobriyan 			error = do_sysctl_strategy(root, table,
17632c4c7155SPavel Emelyanov 						   oldval, oldlenp,
17642c4c7155SPavel Emelyanov 						   newval, newlen);
17652c4c7155SPavel Emelyanov 			return error;
17662c4c7155SPavel Emelyanov 		}
17672c4c7155SPavel Emelyanov 	}
17682c4c7155SPavel Emelyanov 	return -ENOTDIR;
17692c4c7155SPavel Emelyanov }
17702c4c7155SPavel Emelyanov 
17711da177e4SLinus Torvalds int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
17721da177e4SLinus Torvalds 	       void __user *newval, size_t newlen)
17731da177e4SLinus Torvalds {
1774805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1775330d57fbSAl Viro 	int error = -ENOTDIR;
17761da177e4SLinus Torvalds 
17771da177e4SLinus Torvalds 	if (nlen <= 0 || nlen >= CTL_MAXNAME)
17781da177e4SLinus Torvalds 		return -ENOTDIR;
17791da177e4SLinus Torvalds 	if (oldval) {
17801da177e4SLinus Torvalds 		int old_len;
17811da177e4SLinus Torvalds 		if (!oldlenp || get_user(old_len, oldlenp))
17821da177e4SLinus Torvalds 			return -EFAULT;
17831da177e4SLinus Torvalds 	}
1784330d57fbSAl Viro 
1785805b5d5eSEric W. Biederman 	for (head = sysctl_head_next(NULL); head;
1786805b5d5eSEric W. Biederman 			head = sysctl_head_next(head)) {
1787330d57fbSAl Viro 		error = parse_table(name, nlen, oldval, oldlenp,
1788d7321cd6SPavel Emelyanov 					newval, newlen,
1789d7321cd6SPavel Emelyanov 					head->root, head->ctl_table);
1790805b5d5eSEric W. Biederman 		if (error != -ENOTDIR) {
1791805b5d5eSEric W. Biederman 			sysctl_head_finish(head);
1792330d57fbSAl Viro 			break;
1793805b5d5eSEric W. Biederman 		}
1794805b5d5eSEric W. Biederman 	}
17951da177e4SLinus Torvalds 	return error;
17961da177e4SLinus Torvalds }
17971da177e4SLinus Torvalds 
17981e7bfb21SHeiko Carstens SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
17991da177e4SLinus Torvalds {
18001da177e4SLinus Torvalds 	struct __sysctl_args tmp;
18011da177e4SLinus Torvalds 	int error;
18021da177e4SLinus Torvalds 
18031da177e4SLinus Torvalds 	if (copy_from_user(&tmp, args, sizeof(tmp)))
18041da177e4SLinus Torvalds 		return -EFAULT;
18051da177e4SLinus Torvalds 
18067058cb02SEric W. Biederman 	error = deprecated_sysctl_warning(&tmp);
18077058cb02SEric W. Biederman 	if (error)
18087058cb02SEric W. Biederman 		goto out;
18097058cb02SEric W. Biederman 
18101da177e4SLinus Torvalds 	lock_kernel();
18111da177e4SLinus Torvalds 	error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
18121da177e4SLinus Torvalds 			  tmp.newval, tmp.newlen);
18131da177e4SLinus Torvalds 	unlock_kernel();
18147058cb02SEric W. Biederman out:
18151da177e4SLinus Torvalds 	return error;
18161da177e4SLinus Torvalds }
1817b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */
18181da177e4SLinus Torvalds 
18191da177e4SLinus Torvalds /*
18201ff007ebSEric W. Biederman  * sysctl_perm does NOT grant the superuser all rights automatically, because
18211da177e4SLinus Torvalds  * some sysctl variables are readonly even to root.
18221da177e4SLinus Torvalds  */
18231da177e4SLinus Torvalds 
18241da177e4SLinus Torvalds static int test_perm(int mode, int op)
18251da177e4SLinus Torvalds {
182676aac0e9SDavid Howells 	if (!current_euid())
18271da177e4SLinus Torvalds 		mode >>= 6;
18281da177e4SLinus Torvalds 	else if (in_egroup_p(0))
18291da177e4SLinus Torvalds 		mode >>= 3;
1830e6305c43SAl Viro 	if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
18311da177e4SLinus Torvalds 		return 0;
18321da177e4SLinus Torvalds 	return -EACCES;
18331da177e4SLinus Torvalds }
18341da177e4SLinus Torvalds 
1835d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
18361da177e4SLinus Torvalds {
18371da177e4SLinus Torvalds 	int error;
1838d7321cd6SPavel Emelyanov 	int mode;
1839d7321cd6SPavel Emelyanov 
1840e6305c43SAl Viro 	error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
18411da177e4SLinus Torvalds 	if (error)
18421da177e4SLinus Torvalds 		return error;
1843d7321cd6SPavel Emelyanov 
1844d7321cd6SPavel Emelyanov 	if (root->permissions)
1845d7321cd6SPavel Emelyanov 		mode = root->permissions(root, current->nsproxy, table);
1846d7321cd6SPavel Emelyanov 	else
1847d7321cd6SPavel Emelyanov 		mode = table->mode;
1848d7321cd6SPavel Emelyanov 
1849d7321cd6SPavel Emelyanov 	return test_perm(mode, op);
18501da177e4SLinus Torvalds }
18511da177e4SLinus Torvalds 
1852d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1853d912b0ccSEric W. Biederman {
1854d912b0ccSEric W. Biederman 	for (; table->ctl_name || table->procname; table++) {
1855d912b0ccSEric W. Biederman 		table->parent = parent;
1856d912b0ccSEric W. Biederman 		if (table->child)
1857d912b0ccSEric W. Biederman 			sysctl_set_parent(table, table->child);
1858d912b0ccSEric W. Biederman 	}
1859d912b0ccSEric W. Biederman }
1860d912b0ccSEric W. Biederman 
1861d912b0ccSEric W. Biederman static __init int sysctl_init(void)
1862d912b0ccSEric W. Biederman {
1863d912b0ccSEric W. Biederman 	sysctl_set_parent(NULL, root_table);
186488f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
186588f458e4SHolger Schurig 	{
186688f458e4SHolger Schurig 		int err;
1867e51b6ba0SEric W. Biederman 		err = sysctl_check_table(current->nsproxy, root_table);
186888f458e4SHolger Schurig 	}
186988f458e4SHolger Schurig #endif
1870d912b0ccSEric W. Biederman 	return 0;
1871d912b0ccSEric W. Biederman }
1872d912b0ccSEric W. Biederman 
1873d912b0ccSEric W. Biederman core_initcall(sysctl_init);
1874d912b0ccSEric W. Biederman 
1875bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch,
1876bfbcf034SAl Viro 				      struct ctl_table *table)
1877ae7edeccSAl Viro {
1878ae7edeccSAl Viro 	struct ctl_table *p;
1879ae7edeccSAl Viro 	const char *s = branch->procname;
1880ae7edeccSAl Viro 
1881ae7edeccSAl Viro 	/* branch should have named subdirectory as its first element */
1882ae7edeccSAl Viro 	if (!s || !branch->child)
1883bfbcf034SAl Viro 		return NULL;
1884ae7edeccSAl Viro 
1885ae7edeccSAl Viro 	/* ... and nothing else */
1886ae7edeccSAl Viro 	if (branch[1].procname || branch[1].ctl_name)
1887bfbcf034SAl Viro 		return NULL;
1888ae7edeccSAl Viro 
1889ae7edeccSAl Viro 	/* table should contain subdirectory with the same name */
1890ae7edeccSAl Viro 	for (p = table; p->procname || p->ctl_name; p++) {
1891ae7edeccSAl Viro 		if (!p->child)
1892ae7edeccSAl Viro 			continue;
1893ae7edeccSAl Viro 		if (p->procname && strcmp(p->procname, s) == 0)
1894bfbcf034SAl Viro 			return p;
1895ae7edeccSAl Viro 	}
1896bfbcf034SAl Viro 	return NULL;
1897ae7edeccSAl Viro }
1898ae7edeccSAl Viro 
1899ae7edeccSAl Viro /* see if attaching q to p would be an improvement */
1900ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1901ae7edeccSAl Viro {
1902ae7edeccSAl Viro 	struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1903bfbcf034SAl Viro 	struct ctl_table *next;
1904ae7edeccSAl Viro 	int is_better = 0;
1905ae7edeccSAl Viro 	int not_in_parent = !p->attached_by;
1906ae7edeccSAl Viro 
1907bfbcf034SAl Viro 	while ((next = is_branch_in(by, to)) != NULL) {
1908ae7edeccSAl Viro 		if (by == q->attached_by)
1909ae7edeccSAl Viro 			is_better = 1;
1910ae7edeccSAl Viro 		if (to == p->attached_by)
1911ae7edeccSAl Viro 			not_in_parent = 1;
1912ae7edeccSAl Viro 		by = by->child;
1913bfbcf034SAl Viro 		to = next->child;
1914ae7edeccSAl Viro 	}
1915ae7edeccSAl Viro 
1916ae7edeccSAl Viro 	if (is_better && not_in_parent) {
1917ae7edeccSAl Viro 		q->attached_by = by;
1918ae7edeccSAl Viro 		q->attached_to = to;
1919ae7edeccSAl Viro 		q->parent = p;
1920ae7edeccSAl Viro 	}
1921ae7edeccSAl Viro }
1922ae7edeccSAl Viro 
19231da177e4SLinus Torvalds /**
1924e51b6ba0SEric W. Biederman  * __register_sysctl_paths - register a sysctl hierarchy
1925e51b6ba0SEric W. Biederman  * @root: List of sysctl headers to register on
1926e51b6ba0SEric W. Biederman  * @namespaces: Data to compute which lists of sysctl entries are visible
192729e796fdSEric W. Biederman  * @path: The path to the directory the sysctl table is in.
19281da177e4SLinus Torvalds  * @table: the top-level table structure
19291da177e4SLinus Torvalds  *
19301da177e4SLinus Torvalds  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
193129e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
19321da177e4SLinus Torvalds  *
1933d8217f07SEric W. Biederman  * The members of the &struct ctl_table structure are used as follows:
19341da177e4SLinus Torvalds  *
19351da177e4SLinus Torvalds  * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
19361da177e4SLinus Torvalds  *            must be unique within that level of sysctl
19371da177e4SLinus Torvalds  *
19381da177e4SLinus Torvalds  * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
19391da177e4SLinus Torvalds  *            enter a sysctl file
19401da177e4SLinus Torvalds  *
19411da177e4SLinus Torvalds  * data - a pointer to data for use by proc_handler
19421da177e4SLinus Torvalds  *
19431da177e4SLinus Torvalds  * maxlen - the maximum size in bytes of the data
19441da177e4SLinus Torvalds  *
19451da177e4SLinus Torvalds  * mode - the file permissions for the /proc/sys file, and for sysctl(2)
19461da177e4SLinus Torvalds  *
19471da177e4SLinus Torvalds  * child - a pointer to the child sysctl table if this entry is a directory, or
19481da177e4SLinus Torvalds  *         %NULL.
19491da177e4SLinus Torvalds  *
19501da177e4SLinus Torvalds  * proc_handler - the text handler routine (described below)
19511da177e4SLinus Torvalds  *
19521da177e4SLinus Torvalds  * strategy - the strategy routine (described below)
19531da177e4SLinus Torvalds  *
19541da177e4SLinus Torvalds  * de - for internal use by the sysctl routines
19551da177e4SLinus Torvalds  *
19561da177e4SLinus Torvalds  * extra1, extra2 - extra pointers usable by the proc handler routines
19571da177e4SLinus Torvalds  *
19581da177e4SLinus Torvalds  * Leaf nodes in the sysctl tree will be represented by a single file
19591da177e4SLinus Torvalds  * under /proc; non-leaf nodes will be represented by directories.
19601da177e4SLinus Torvalds  *
19611da177e4SLinus Torvalds  * sysctl(2) can automatically manage read and write requests through
19621da177e4SLinus Torvalds  * the sysctl table.  The data and maxlen fields of the ctl_table
19631da177e4SLinus Torvalds  * struct enable minimal validation of the values being written to be
19641da177e4SLinus Torvalds  * performed, and the mode field allows minimal authentication.
19651da177e4SLinus Torvalds  *
19661da177e4SLinus Torvalds  * More sophisticated management can be enabled by the provision of a
19671da177e4SLinus Torvalds  * strategy routine with the table entry.  This will be called before
19681da177e4SLinus Torvalds  * any automatic read or write of the data is performed.
19691da177e4SLinus Torvalds  *
19701da177e4SLinus Torvalds  * The strategy routine may return
19711da177e4SLinus Torvalds  *
19721da177e4SLinus Torvalds  * < 0 - Error occurred (error is passed to user process)
19731da177e4SLinus Torvalds  *
19741da177e4SLinus Torvalds  * 0   - OK - proceed with automatic read or write.
19751da177e4SLinus Torvalds  *
19761da177e4SLinus Torvalds  * > 0 - OK - read or write has been done by the strategy routine, so
19771da177e4SLinus Torvalds  *       return immediately.
19781da177e4SLinus Torvalds  *
19791da177e4SLinus Torvalds  * There must be a proc_handler routine for any terminal nodes
19801da177e4SLinus Torvalds  * mirrored under /proc/sys (non-terminals are handled by a built-in
19811da177e4SLinus Torvalds  * directory handler).  Several default handlers are available to
19821da177e4SLinus Torvalds  * cover common cases -
19831da177e4SLinus Torvalds  *
19841da177e4SLinus Torvalds  * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
19851da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
19861da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
19871da177e4SLinus Torvalds  *
19881da177e4SLinus Torvalds  * It is the handler's job to read the input buffer from user memory
19891da177e4SLinus Torvalds  * and process it. The handler should return 0 on success.
19901da177e4SLinus Torvalds  *
19911da177e4SLinus Torvalds  * This routine returns %NULL on a failure to register, and a pointer
19921da177e4SLinus Torvalds  * to the table header on success.
19931da177e4SLinus Torvalds  */
1994e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths(
1995e51b6ba0SEric W. Biederman 	struct ctl_table_root *root,
1996e51b6ba0SEric W. Biederman 	struct nsproxy *namespaces,
1997e51b6ba0SEric W. Biederman 	const struct ctl_path *path, struct ctl_table *table)
19981da177e4SLinus Torvalds {
199929e796fdSEric W. Biederman 	struct ctl_table_header *header;
200029e796fdSEric W. Biederman 	struct ctl_table *new, **prevp;
200129e796fdSEric W. Biederman 	unsigned int n, npath;
2002ae7edeccSAl Viro 	struct ctl_table_set *set;
200329e796fdSEric W. Biederman 
200429e796fdSEric W. Biederman 	/* Count the path components */
200529e796fdSEric W. Biederman 	for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
200629e796fdSEric W. Biederman 		;
200729e796fdSEric W. Biederman 
200829e796fdSEric W. Biederman 	/*
200929e796fdSEric W. Biederman 	 * For each path component, allocate a 2-element ctl_table array.
201029e796fdSEric W. Biederman 	 * The first array element will be filled with the sysctl entry
201129e796fdSEric W. Biederman 	 * for this, the second will be the sentinel (ctl_name == 0).
201229e796fdSEric W. Biederman 	 *
201329e796fdSEric W. Biederman 	 * We allocate everything in one go so that we don't have to
201429e796fdSEric W. Biederman 	 * worry about freeing additional memory in unregister_sysctl_table.
201529e796fdSEric W. Biederman 	 */
201629e796fdSEric W. Biederman 	header = kzalloc(sizeof(struct ctl_table_header) +
201729e796fdSEric W. Biederman 			 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
201829e796fdSEric W. Biederman 	if (!header)
20191da177e4SLinus Torvalds 		return NULL;
202029e796fdSEric W. Biederman 
202129e796fdSEric W. Biederman 	new = (struct ctl_table *) (header + 1);
202229e796fdSEric W. Biederman 
202329e796fdSEric W. Biederman 	/* Now connect the dots */
202429e796fdSEric W. Biederman 	prevp = &header->ctl_table;
202529e796fdSEric W. Biederman 	for (n = 0; n < npath; ++n, ++path) {
202629e796fdSEric W. Biederman 		/* Copy the procname */
202729e796fdSEric W. Biederman 		new->procname = path->procname;
202829e796fdSEric W. Biederman 		new->ctl_name = path->ctl_name;
202929e796fdSEric W. Biederman 		new->mode     = 0555;
203029e796fdSEric W. Biederman 
203129e796fdSEric W. Biederman 		*prevp = new;
203229e796fdSEric W. Biederman 		prevp = &new->child;
203329e796fdSEric W. Biederman 
203429e796fdSEric W. Biederman 		new += 2;
203529e796fdSEric W. Biederman 	}
203629e796fdSEric W. Biederman 	*prevp = table;
203723eb06deSEric W. Biederman 	header->ctl_table_arg = table;
203829e796fdSEric W. Biederman 
203929e796fdSEric W. Biederman 	INIT_LIST_HEAD(&header->ctl_entry);
204029e796fdSEric W. Biederman 	header->used = 0;
204129e796fdSEric W. Biederman 	header->unregistering = NULL;
2042e51b6ba0SEric W. Biederman 	header->root = root;
204329e796fdSEric W. Biederman 	sysctl_set_parent(NULL, header->ctl_table);
2044f7e6ced4SAl Viro 	header->count = 1;
204588f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
2046e51b6ba0SEric W. Biederman 	if (sysctl_check_table(namespaces, header->ctl_table)) {
204729e796fdSEric W. Biederman 		kfree(header);
2048fc6cd25bSEric W. Biederman 		return NULL;
2049fc6cd25bSEric W. Biederman 	}
205088f458e4SHolger Schurig #endif
2051330d57fbSAl Viro 	spin_lock(&sysctl_lock);
205273455092SAl Viro 	header->set = lookup_header_set(root, namespaces);
2053ae7edeccSAl Viro 	header->attached_by = header->ctl_table;
2054ae7edeccSAl Viro 	header->attached_to = root_table;
2055ae7edeccSAl Viro 	header->parent = &root_table_header;
2056ae7edeccSAl Viro 	for (set = header->set; set; set = set->parent) {
2057ae7edeccSAl Viro 		struct ctl_table_header *p;
2058ae7edeccSAl Viro 		list_for_each_entry(p, &set->list, ctl_entry) {
2059ae7edeccSAl Viro 			if (p->unregistering)
2060ae7edeccSAl Viro 				continue;
2061ae7edeccSAl Viro 			try_attach(p, header);
2062ae7edeccSAl Viro 		}
2063ae7edeccSAl Viro 	}
2064ae7edeccSAl Viro 	header->parent->count++;
206573455092SAl Viro 	list_add_tail(&header->ctl_entry, &header->set->list);
2066330d57fbSAl Viro 	spin_unlock(&sysctl_lock);
206729e796fdSEric W. Biederman 
206829e796fdSEric W. Biederman 	return header;
206929e796fdSEric W. Biederman }
207029e796fdSEric W. Biederman 
207129e796fdSEric W. Biederman /**
2072e51b6ba0SEric W. Biederman  * register_sysctl_table_path - register a sysctl table hierarchy
2073e51b6ba0SEric W. Biederman  * @path: The path to the directory the sysctl table is in.
2074e51b6ba0SEric W. Biederman  * @table: the top-level table structure
2075e51b6ba0SEric W. Biederman  *
2076e51b6ba0SEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2077e51b6ba0SEric W. Biederman  * array. A completely 0 filled entry terminates the table.
2078e51b6ba0SEric W. Biederman  *
2079e51b6ba0SEric W. Biederman  * See __register_sysctl_paths for more details.
2080e51b6ba0SEric W. Biederman  */
2081e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2082e51b6ba0SEric W. Biederman 						struct ctl_table *table)
2083e51b6ba0SEric W. Biederman {
2084e51b6ba0SEric W. Biederman 	return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
2085e51b6ba0SEric W. Biederman 					path, table);
2086e51b6ba0SEric W. Biederman }
2087e51b6ba0SEric W. Biederman 
2088e51b6ba0SEric W. Biederman /**
208929e796fdSEric W. Biederman  * register_sysctl_table - register a sysctl table hierarchy
209029e796fdSEric W. Biederman  * @table: the top-level table structure
209129e796fdSEric W. Biederman  *
209229e796fdSEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
209329e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
209429e796fdSEric W. Biederman  *
209529e796fdSEric W. Biederman  * See register_sysctl_paths for more details.
209629e796fdSEric W. Biederman  */
209729e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
209829e796fdSEric W. Biederman {
209929e796fdSEric W. Biederman 	static const struct ctl_path null_path[] = { {} };
210029e796fdSEric W. Biederman 
210129e796fdSEric W. Biederman 	return register_sysctl_paths(null_path, table);
21021da177e4SLinus Torvalds }
21031da177e4SLinus Torvalds 
21041da177e4SLinus Torvalds /**
21051da177e4SLinus Torvalds  * unregister_sysctl_table - unregister a sysctl table hierarchy
21061da177e4SLinus Torvalds  * @header: the header returned from register_sysctl_table
21071da177e4SLinus Torvalds  *
21081da177e4SLinus Torvalds  * Unregisters the sysctl table and all children. proc entries may not
21091da177e4SLinus Torvalds  * actually be removed until they are no longer used by anyone.
21101da177e4SLinus Torvalds  */
21111da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header)
21121da177e4SLinus Torvalds {
2113330d57fbSAl Viro 	might_sleep();
2114f1dad166SPavel Emelyanov 
2115f1dad166SPavel Emelyanov 	if (header == NULL)
2116f1dad166SPavel Emelyanov 		return;
2117f1dad166SPavel Emelyanov 
2118330d57fbSAl Viro 	spin_lock(&sysctl_lock);
2119330d57fbSAl Viro 	start_unregistering(header);
2120ae7edeccSAl Viro 	if (!--header->parent->count) {
2121ae7edeccSAl Viro 		WARN_ON(1);
2122ae7edeccSAl Viro 		kfree(header->parent);
2123ae7edeccSAl Viro 	}
2124f7e6ced4SAl Viro 	if (!--header->count)
21251da177e4SLinus Torvalds 		kfree(header);
2126f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
21271da177e4SLinus Torvalds }
21281da177e4SLinus Torvalds 
21299043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p)
21309043476fSAl Viro {
21319043476fSAl Viro 	struct ctl_table_set *set = p->set;
21329043476fSAl Viro 	int res;
21339043476fSAl Viro 	spin_lock(&sysctl_lock);
21349043476fSAl Viro 	if (p->unregistering)
21359043476fSAl Viro 		res = 0;
21369043476fSAl Viro 	else if (!set->is_seen)
21379043476fSAl Viro 		res = 1;
21389043476fSAl Viro 	else
21399043476fSAl Viro 		res = set->is_seen(set);
21409043476fSAl Viro 	spin_unlock(&sysctl_lock);
21419043476fSAl Viro 	return res;
21429043476fSAl Viro }
21439043476fSAl Viro 
214473455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
214573455092SAl Viro 	struct ctl_table_set *parent,
214673455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
214773455092SAl Viro {
214873455092SAl Viro 	INIT_LIST_HEAD(&p->list);
214973455092SAl Viro 	p->parent = parent ? parent : &sysctl_table_root.default_set;
215073455092SAl Viro 	p->is_seen = is_seen;
215173455092SAl Viro }
215273455092SAl Viro 
2153b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */
2154d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
2155b89a8171SEric W. Biederman {
2156b89a8171SEric W. Biederman 	return NULL;
2157b89a8171SEric W. Biederman }
2158b89a8171SEric W. Biederman 
215929e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
216029e796fdSEric W. Biederman 						    struct ctl_table *table)
216129e796fdSEric W. Biederman {
216229e796fdSEric W. Biederman 	return NULL;
216329e796fdSEric W. Biederman }
216429e796fdSEric W. Biederman 
2165b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table)
2166b89a8171SEric W. Biederman {
2167b89a8171SEric W. Biederman }
2168b89a8171SEric W. Biederman 
216973455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
217073455092SAl Viro 	struct ctl_table_set *parent,
217173455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
217273455092SAl Viro {
217373455092SAl Viro }
217473455092SAl Viro 
2175f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
2176f7e6ced4SAl Viro {
2177f7e6ced4SAl Viro }
2178f7e6ced4SAl Viro 
2179b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
2180b89a8171SEric W. Biederman 
21811da177e4SLinus Torvalds /*
21821da177e4SLinus Torvalds  * /proc/sys support
21831da177e4SLinus Torvalds  */
21841da177e4SLinus Torvalds 
2185b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL
21861da177e4SLinus Torvalds 
2187b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write,
2188b1ba4dddSAdrian Bunk 			   struct file *filp, void __user *buffer,
2189b1ba4dddSAdrian Bunk 			   size_t *lenp, loff_t *ppos)
2190f5dd3d6fSSam Vilain {
2191f5dd3d6fSSam Vilain 	size_t len;
2192f5dd3d6fSSam Vilain 	char __user *p;
2193f5dd3d6fSSam Vilain 	char c;
2194f5dd3d6fSSam Vilain 
21958d060877SOleg Nesterov 	if (!data || !maxlen || !*lenp) {
2196f5dd3d6fSSam Vilain 		*lenp = 0;
2197f5dd3d6fSSam Vilain 		return 0;
2198f5dd3d6fSSam Vilain 	}
2199f5dd3d6fSSam Vilain 
2200f5dd3d6fSSam Vilain 	if (write) {
2201f5dd3d6fSSam Vilain 		len = 0;
2202f5dd3d6fSSam Vilain 		p = buffer;
2203f5dd3d6fSSam Vilain 		while (len < *lenp) {
2204f5dd3d6fSSam Vilain 			if (get_user(c, p++))
2205f5dd3d6fSSam Vilain 				return -EFAULT;
2206f5dd3d6fSSam Vilain 			if (c == 0 || c == '\n')
2207f5dd3d6fSSam Vilain 				break;
2208f5dd3d6fSSam Vilain 			len++;
2209f5dd3d6fSSam Vilain 		}
2210f5dd3d6fSSam Vilain 		if (len >= maxlen)
2211f5dd3d6fSSam Vilain 			len = maxlen-1;
2212f5dd3d6fSSam Vilain 		if(copy_from_user(data, buffer, len))
2213f5dd3d6fSSam Vilain 			return -EFAULT;
2214f5dd3d6fSSam Vilain 		((char *) data)[len] = 0;
2215f5dd3d6fSSam Vilain 		*ppos += *lenp;
2216f5dd3d6fSSam Vilain 	} else {
2217f5dd3d6fSSam Vilain 		len = strlen(data);
2218f5dd3d6fSSam Vilain 		if (len > maxlen)
2219f5dd3d6fSSam Vilain 			len = maxlen;
22208d060877SOleg Nesterov 
22218d060877SOleg Nesterov 		if (*ppos > len) {
22228d060877SOleg Nesterov 			*lenp = 0;
22238d060877SOleg Nesterov 			return 0;
22248d060877SOleg Nesterov 		}
22258d060877SOleg Nesterov 
22268d060877SOleg Nesterov 		data += *ppos;
22278d060877SOleg Nesterov 		len  -= *ppos;
22288d060877SOleg Nesterov 
2229f5dd3d6fSSam Vilain 		if (len > *lenp)
2230f5dd3d6fSSam Vilain 			len = *lenp;
2231f5dd3d6fSSam Vilain 		if (len)
2232f5dd3d6fSSam Vilain 			if(copy_to_user(buffer, data, len))
2233f5dd3d6fSSam Vilain 				return -EFAULT;
2234f5dd3d6fSSam Vilain 		if (len < *lenp) {
2235f5dd3d6fSSam Vilain 			if(put_user('\n', ((char __user *) buffer) + len))
2236f5dd3d6fSSam Vilain 				return -EFAULT;
2237f5dd3d6fSSam Vilain 			len++;
2238f5dd3d6fSSam Vilain 		}
2239f5dd3d6fSSam Vilain 		*lenp = len;
2240f5dd3d6fSSam Vilain 		*ppos += len;
2241f5dd3d6fSSam Vilain 	}
2242f5dd3d6fSSam Vilain 	return 0;
2243f5dd3d6fSSam Vilain }
2244f5dd3d6fSSam Vilain 
22451da177e4SLinus Torvalds /**
22461da177e4SLinus Torvalds  * proc_dostring - read a string sysctl
22471da177e4SLinus Torvalds  * @table: the sysctl table
22481da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
22491da177e4SLinus Torvalds  * @filp: the file structure
22501da177e4SLinus Torvalds  * @buffer: the user buffer
22511da177e4SLinus Torvalds  * @lenp: the size of the user buffer
22521da177e4SLinus Torvalds  * @ppos: file position
22531da177e4SLinus Torvalds  *
22541da177e4SLinus Torvalds  * Reads/writes a string from/to the user buffer. If the kernel
22551da177e4SLinus Torvalds  * buffer provided is not large enough to hold the string, the
22561da177e4SLinus Torvalds  * string is truncated. The copied string is %NULL-terminated.
22571da177e4SLinus Torvalds  * If the string is being read by the user process, it is copied
22581da177e4SLinus Torvalds  * and a newline '\n' is added. It is truncated if the buffer is
22591da177e4SLinus Torvalds  * not large enough.
22601da177e4SLinus Torvalds  *
22611da177e4SLinus Torvalds  * Returns 0 on success.
22621da177e4SLinus Torvalds  */
2263d8217f07SEric W. Biederman int proc_dostring(struct ctl_table *table, int write, struct file *filp,
22641da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
22651da177e4SLinus Torvalds {
2266f5dd3d6fSSam Vilain 	return _proc_do_string(table->data, table->maxlen, write, filp,
2267f5dd3d6fSSam Vilain 			       buffer, lenp, ppos);
22681da177e4SLinus Torvalds }
22691da177e4SLinus Torvalds 
22701da177e4SLinus Torvalds 
22711da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
22721da177e4SLinus Torvalds 				 int *valp,
22731da177e4SLinus Torvalds 				 int write, void *data)
22741da177e4SLinus Torvalds {
22751da177e4SLinus Torvalds 	if (write) {
22761da177e4SLinus Torvalds 		*valp = *negp ? -*lvalp : *lvalp;
22771da177e4SLinus Torvalds 	} else {
22781da177e4SLinus Torvalds 		int val = *valp;
22791da177e4SLinus Torvalds 		if (val < 0) {
22801da177e4SLinus Torvalds 			*negp = -1;
22811da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
22821da177e4SLinus Torvalds 		} else {
22831da177e4SLinus Torvalds 			*negp = 0;
22841da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
22851da177e4SLinus Torvalds 		}
22861da177e4SLinus Torvalds 	}
22871da177e4SLinus Torvalds 	return 0;
22881da177e4SLinus Torvalds }
22891da177e4SLinus Torvalds 
2290d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
2291fcfbd547SKirill Korotaev 		  int write, struct file *filp, void __user *buffer,
2292fcfbd547SKirill Korotaev 		  size_t *lenp, loff_t *ppos,
22931da177e4SLinus Torvalds 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
22941da177e4SLinus Torvalds 			      int write, void *data),
22951da177e4SLinus Torvalds 		  void *data)
22961da177e4SLinus Torvalds {
22971da177e4SLinus Torvalds #define TMPBUFLEN 21
22987338f299SSukanto Ghosh 	int *i, vleft, first = 1, neg;
22991da177e4SLinus Torvalds 	unsigned long lval;
23001da177e4SLinus Torvalds 	size_t left, len;
23011da177e4SLinus Torvalds 
23021da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
23031da177e4SLinus Torvalds 	char __user *s = buffer;
23041da177e4SLinus Torvalds 
2305fcfbd547SKirill Korotaev 	if (!tbl_data || !table->maxlen || !*lenp ||
23061da177e4SLinus Torvalds 	    (*ppos && !write)) {
23071da177e4SLinus Torvalds 		*lenp = 0;
23081da177e4SLinus Torvalds 		return 0;
23091da177e4SLinus Torvalds 	}
23101da177e4SLinus Torvalds 
2311fcfbd547SKirill Korotaev 	i = (int *) tbl_data;
23121da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(*i);
23131da177e4SLinus Torvalds 	left = *lenp;
23141da177e4SLinus Torvalds 
23151da177e4SLinus Torvalds 	if (!conv)
23161da177e4SLinus Torvalds 		conv = do_proc_dointvec_conv;
23171da177e4SLinus Torvalds 
23181da177e4SLinus Torvalds 	for (; left && vleft--; i++, first=0) {
23191da177e4SLinus Torvalds 		if (write) {
23201da177e4SLinus Torvalds 			while (left) {
23211da177e4SLinus Torvalds 				char c;
23221da177e4SLinus Torvalds 				if (get_user(c, s))
23231da177e4SLinus Torvalds 					return -EFAULT;
23241da177e4SLinus Torvalds 				if (!isspace(c))
23251da177e4SLinus Torvalds 					break;
23261da177e4SLinus Torvalds 				left--;
23271da177e4SLinus Torvalds 				s++;
23281da177e4SLinus Torvalds 			}
23291da177e4SLinus Torvalds 			if (!left)
23301da177e4SLinus Torvalds 				break;
23311da177e4SLinus Torvalds 			neg = 0;
23321da177e4SLinus Torvalds 			len = left;
23331da177e4SLinus Torvalds 			if (len > sizeof(buf) - 1)
23341da177e4SLinus Torvalds 				len = sizeof(buf) - 1;
23351da177e4SLinus Torvalds 			if (copy_from_user(buf, s, len))
23361da177e4SLinus Torvalds 				return -EFAULT;
23371da177e4SLinus Torvalds 			buf[len] = 0;
23381da177e4SLinus Torvalds 			p = buf;
23391da177e4SLinus Torvalds 			if (*p == '-' && left > 1) {
23401da177e4SLinus Torvalds 				neg = 1;
2341bd9b0bacSBP, Praveen 				p++;
23421da177e4SLinus Torvalds 			}
23431da177e4SLinus Torvalds 			if (*p < '0' || *p > '9')
23441da177e4SLinus Torvalds 				break;
23451da177e4SLinus Torvalds 
23461da177e4SLinus Torvalds 			lval = simple_strtoul(p, &p, 0);
23471da177e4SLinus Torvalds 
23481da177e4SLinus Torvalds 			len = p-buf;
23491da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
23501da177e4SLinus Torvalds 				break;
23511da177e4SLinus Torvalds 			s += len;
23521da177e4SLinus Torvalds 			left -= len;
23531da177e4SLinus Torvalds 
23541da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 1, data))
23551da177e4SLinus Torvalds 				break;
23561da177e4SLinus Torvalds 		} else {
23571da177e4SLinus Torvalds 			p = buf;
23581da177e4SLinus Torvalds 			if (!first)
23591da177e4SLinus Torvalds 				*p++ = '\t';
23601da177e4SLinus Torvalds 
23611da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 0, data))
23621da177e4SLinus Torvalds 				break;
23631da177e4SLinus Torvalds 
23641da177e4SLinus Torvalds 			sprintf(p, "%s%lu", neg ? "-" : "", lval);
23651da177e4SLinus Torvalds 			len = strlen(buf);
23661da177e4SLinus Torvalds 			if (len > left)
23671da177e4SLinus Torvalds 				len = left;
23681da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
23691da177e4SLinus Torvalds 				return -EFAULT;
23701da177e4SLinus Torvalds 			left -= len;
23711da177e4SLinus Torvalds 			s += len;
23721da177e4SLinus Torvalds 		}
23731da177e4SLinus Torvalds 	}
23741da177e4SLinus Torvalds 
23751da177e4SLinus Torvalds 	if (!write && !first && left) {
23761da177e4SLinus Torvalds 		if(put_user('\n', s))
23771da177e4SLinus Torvalds 			return -EFAULT;
23781da177e4SLinus Torvalds 		left--, s++;
23791da177e4SLinus Torvalds 	}
23801da177e4SLinus Torvalds 	if (write) {
23811da177e4SLinus Torvalds 		while (left) {
23821da177e4SLinus Torvalds 			char c;
23831da177e4SLinus Torvalds 			if (get_user(c, s++))
23841da177e4SLinus Torvalds 				return -EFAULT;
23851da177e4SLinus Torvalds 			if (!isspace(c))
23861da177e4SLinus Torvalds 				break;
23871da177e4SLinus Torvalds 			left--;
23881da177e4SLinus Torvalds 		}
23891da177e4SLinus Torvalds 	}
23901da177e4SLinus Torvalds 	if (write && first)
23911da177e4SLinus Torvalds 		return -EINVAL;
23921da177e4SLinus Torvalds 	*lenp -= left;
23931da177e4SLinus Torvalds 	*ppos += *lenp;
23941da177e4SLinus Torvalds 	return 0;
23951da177e4SLinus Torvalds #undef TMPBUFLEN
23961da177e4SLinus Torvalds }
23971da177e4SLinus Torvalds 
2398d8217f07SEric W. Biederman static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2399fcfbd547SKirill Korotaev 		  void __user *buffer, size_t *lenp, loff_t *ppos,
2400fcfbd547SKirill Korotaev 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2401fcfbd547SKirill Korotaev 			      int write, void *data),
2402fcfbd547SKirill Korotaev 		  void *data)
2403fcfbd547SKirill Korotaev {
2404fcfbd547SKirill Korotaev 	return __do_proc_dointvec(table->data, table, write, filp,
2405fcfbd547SKirill Korotaev 			buffer, lenp, ppos, conv, data);
2406fcfbd547SKirill Korotaev }
2407fcfbd547SKirill Korotaev 
24081da177e4SLinus Torvalds /**
24091da177e4SLinus Torvalds  * proc_dointvec - read a vector of integers
24101da177e4SLinus Torvalds  * @table: the sysctl table
24111da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24121da177e4SLinus Torvalds  * @filp: the file structure
24131da177e4SLinus Torvalds  * @buffer: the user buffer
24141da177e4SLinus Torvalds  * @lenp: the size of the user buffer
24151da177e4SLinus Torvalds  * @ppos: file position
24161da177e4SLinus Torvalds  *
24171da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
24181da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
24191da177e4SLinus Torvalds  *
24201da177e4SLinus Torvalds  * Returns 0 on success.
24211da177e4SLinus Torvalds  */
2422d8217f07SEric W. Biederman int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
24231da177e4SLinus Torvalds 		     void __user *buffer, size_t *lenp, loff_t *ppos)
24241da177e4SLinus Torvalds {
24251da177e4SLinus Torvalds     return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
24261da177e4SLinus Torvalds 		    	    NULL,NULL);
24271da177e4SLinus Torvalds }
24281da177e4SLinus Torvalds 
242934f5a398STheodore Ts'o /*
243034f5a398STheodore Ts'o  * Taint values can only be increased
243125ddbb18SAndi Kleen  * This means we can safely use a temporary.
243234f5a398STheodore Ts'o  */
243325ddbb18SAndi Kleen static int proc_taint(struct ctl_table *table, int write, struct file *filp,
243434f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos)
243534f5a398STheodore Ts'o {
243625ddbb18SAndi Kleen 	struct ctl_table t;
243725ddbb18SAndi Kleen 	unsigned long tmptaint = get_taint();
243825ddbb18SAndi Kleen 	int err;
243934f5a398STheodore Ts'o 
244091fcd412SBastian Blank 	if (write && !capable(CAP_SYS_ADMIN))
244134f5a398STheodore Ts'o 		return -EPERM;
244234f5a398STheodore Ts'o 
244325ddbb18SAndi Kleen 	t = *table;
244425ddbb18SAndi Kleen 	t.data = &tmptaint;
244525ddbb18SAndi Kleen 	err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos);
244625ddbb18SAndi Kleen 	if (err < 0)
244725ddbb18SAndi Kleen 		return err;
244825ddbb18SAndi Kleen 
244925ddbb18SAndi Kleen 	if (write) {
245025ddbb18SAndi Kleen 		/*
245125ddbb18SAndi Kleen 		 * Poor man's atomic or. Not worth adding a primitive
245225ddbb18SAndi Kleen 		 * to everyone's atomic.h for this
245325ddbb18SAndi Kleen 		 */
245425ddbb18SAndi Kleen 		int i;
245525ddbb18SAndi Kleen 		for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
245625ddbb18SAndi Kleen 			if ((tmptaint >> i) & 1)
245725ddbb18SAndi Kleen 				add_taint(i);
245825ddbb18SAndi Kleen 		}
245925ddbb18SAndi Kleen 	}
246025ddbb18SAndi Kleen 
246125ddbb18SAndi Kleen 	return err;
246234f5a398STheodore Ts'o }
246334f5a398STheodore Ts'o 
24641da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param {
24651da177e4SLinus Torvalds 	int *min;
24661da177e4SLinus Torvalds 	int *max;
24671da177e4SLinus Torvalds };
24681da177e4SLinus Torvalds 
24691da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
24701da177e4SLinus Torvalds 					int *valp,
24711da177e4SLinus Torvalds 					int write, void *data)
24721da177e4SLinus Torvalds {
24731da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param *param = data;
24741da177e4SLinus Torvalds 	if (write) {
24751da177e4SLinus Torvalds 		int val = *negp ? -*lvalp : *lvalp;
24761da177e4SLinus Torvalds 		if ((param->min && *param->min > val) ||
24771da177e4SLinus Torvalds 		    (param->max && *param->max < val))
24781da177e4SLinus Torvalds 			return -EINVAL;
24791da177e4SLinus Torvalds 		*valp = val;
24801da177e4SLinus Torvalds 	} else {
24811da177e4SLinus Torvalds 		int val = *valp;
24821da177e4SLinus Torvalds 		if (val < 0) {
24831da177e4SLinus Torvalds 			*negp = -1;
24841da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
24851da177e4SLinus Torvalds 		} else {
24861da177e4SLinus Torvalds 			*negp = 0;
24871da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
24881da177e4SLinus Torvalds 		}
24891da177e4SLinus Torvalds 	}
24901da177e4SLinus Torvalds 	return 0;
24911da177e4SLinus Torvalds }
24921da177e4SLinus Torvalds 
24931da177e4SLinus Torvalds /**
24941da177e4SLinus Torvalds  * proc_dointvec_minmax - read a vector of integers with min/max values
24951da177e4SLinus Torvalds  * @table: the sysctl table
24961da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24971da177e4SLinus Torvalds  * @filp: the file structure
24981da177e4SLinus Torvalds  * @buffer: the user buffer
24991da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25001da177e4SLinus Torvalds  * @ppos: file position
25011da177e4SLinus Torvalds  *
25021da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
25031da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25041da177e4SLinus Torvalds  *
25051da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
25061da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
25071da177e4SLinus Torvalds  *
25081da177e4SLinus Torvalds  * Returns 0 on success.
25091da177e4SLinus Torvalds  */
2510d8217f07SEric W. Biederman int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
25111da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
25121da177e4SLinus Torvalds {
25131da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param param = {
25141da177e4SLinus Torvalds 		.min = (int *) table->extra1,
25151da177e4SLinus Torvalds 		.max = (int *) table->extra2,
25161da177e4SLinus Torvalds 	};
25171da177e4SLinus Torvalds 	return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
25181da177e4SLinus Torvalds 				do_proc_dointvec_minmax_conv, &param);
25191da177e4SLinus Torvalds }
25201da177e4SLinus Torvalds 
2521d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
25221da177e4SLinus Torvalds 				     struct file *filp,
25231da177e4SLinus Torvalds 				     void __user *buffer,
25241da177e4SLinus Torvalds 				     size_t *lenp, loff_t *ppos,
25251da177e4SLinus Torvalds 				     unsigned long convmul,
25261da177e4SLinus Torvalds 				     unsigned long convdiv)
25271da177e4SLinus Torvalds {
25281da177e4SLinus Torvalds #define TMPBUFLEN 21
25291da177e4SLinus Torvalds 	unsigned long *i, *min, *max, val;
25301da177e4SLinus Torvalds 	int vleft, first=1, neg;
25311da177e4SLinus Torvalds 	size_t len, left;
25321da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
25331da177e4SLinus Torvalds 	char __user *s = buffer;
25341da177e4SLinus Torvalds 
2535fcfbd547SKirill Korotaev 	if (!data || !table->maxlen || !*lenp ||
25361da177e4SLinus Torvalds 	    (*ppos && !write)) {
25371da177e4SLinus Torvalds 		*lenp = 0;
25381da177e4SLinus Torvalds 		return 0;
25391da177e4SLinus Torvalds 	}
25401da177e4SLinus Torvalds 
2541fcfbd547SKirill Korotaev 	i = (unsigned long *) data;
25421da177e4SLinus Torvalds 	min = (unsigned long *) table->extra1;
25431da177e4SLinus Torvalds 	max = (unsigned long *) table->extra2;
25441da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(unsigned long);
25451da177e4SLinus Torvalds 	left = *lenp;
25461da177e4SLinus Torvalds 
25471da177e4SLinus Torvalds 	for (; left && vleft--; i++, min++, max++, first=0) {
25481da177e4SLinus Torvalds 		if (write) {
25491da177e4SLinus Torvalds 			while (left) {
25501da177e4SLinus Torvalds 				char c;
25511da177e4SLinus Torvalds 				if (get_user(c, s))
25521da177e4SLinus Torvalds 					return -EFAULT;
25531da177e4SLinus Torvalds 				if (!isspace(c))
25541da177e4SLinus Torvalds 					break;
25551da177e4SLinus Torvalds 				left--;
25561da177e4SLinus Torvalds 				s++;
25571da177e4SLinus Torvalds 			}
25581da177e4SLinus Torvalds 			if (!left)
25591da177e4SLinus Torvalds 				break;
25601da177e4SLinus Torvalds 			neg = 0;
25611da177e4SLinus Torvalds 			len = left;
25621da177e4SLinus Torvalds 			if (len > TMPBUFLEN-1)
25631da177e4SLinus Torvalds 				len = TMPBUFLEN-1;
25641da177e4SLinus Torvalds 			if (copy_from_user(buf, s, len))
25651da177e4SLinus Torvalds 				return -EFAULT;
25661da177e4SLinus Torvalds 			buf[len] = 0;
25671da177e4SLinus Torvalds 			p = buf;
25681da177e4SLinus Torvalds 			if (*p == '-' && left > 1) {
25691da177e4SLinus Torvalds 				neg = 1;
2570bd9b0bacSBP, Praveen 				p++;
25711da177e4SLinus Torvalds 			}
25721da177e4SLinus Torvalds 			if (*p < '0' || *p > '9')
25731da177e4SLinus Torvalds 				break;
25741da177e4SLinus Torvalds 			val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
25751da177e4SLinus Torvalds 			len = p-buf;
25761da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
25771da177e4SLinus Torvalds 				break;
25781da177e4SLinus Torvalds 			if (neg)
25791da177e4SLinus Torvalds 				val = -val;
25801da177e4SLinus Torvalds 			s += len;
25811da177e4SLinus Torvalds 			left -= len;
25821da177e4SLinus Torvalds 
25831da177e4SLinus Torvalds 			if(neg)
25841da177e4SLinus Torvalds 				continue;
25851da177e4SLinus Torvalds 			if ((min && val < *min) || (max && val > *max))
25861da177e4SLinus Torvalds 				continue;
25871da177e4SLinus Torvalds 			*i = val;
25881da177e4SLinus Torvalds 		} else {
25891da177e4SLinus Torvalds 			p = buf;
25901da177e4SLinus Torvalds 			if (!first)
25911da177e4SLinus Torvalds 				*p++ = '\t';
25921da177e4SLinus Torvalds 			sprintf(p, "%lu", convdiv * (*i) / convmul);
25931da177e4SLinus Torvalds 			len = strlen(buf);
25941da177e4SLinus Torvalds 			if (len > left)
25951da177e4SLinus Torvalds 				len = left;
25961da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
25971da177e4SLinus Torvalds 				return -EFAULT;
25981da177e4SLinus Torvalds 			left -= len;
25991da177e4SLinus Torvalds 			s += len;
26001da177e4SLinus Torvalds 		}
26011da177e4SLinus Torvalds 	}
26021da177e4SLinus Torvalds 
26031da177e4SLinus Torvalds 	if (!write && !first && left) {
26041da177e4SLinus Torvalds 		if(put_user('\n', s))
26051da177e4SLinus Torvalds 			return -EFAULT;
26061da177e4SLinus Torvalds 		left--, s++;
26071da177e4SLinus Torvalds 	}
26081da177e4SLinus Torvalds 	if (write) {
26091da177e4SLinus Torvalds 		while (left) {
26101da177e4SLinus Torvalds 			char c;
26111da177e4SLinus Torvalds 			if (get_user(c, s++))
26121da177e4SLinus Torvalds 				return -EFAULT;
26131da177e4SLinus Torvalds 			if (!isspace(c))
26141da177e4SLinus Torvalds 				break;
26151da177e4SLinus Torvalds 			left--;
26161da177e4SLinus Torvalds 		}
26171da177e4SLinus Torvalds 	}
26181da177e4SLinus Torvalds 	if (write && first)
26191da177e4SLinus Torvalds 		return -EINVAL;
26201da177e4SLinus Torvalds 	*lenp -= left;
26211da177e4SLinus Torvalds 	*ppos += *lenp;
26221da177e4SLinus Torvalds 	return 0;
26231da177e4SLinus Torvalds #undef TMPBUFLEN
26241da177e4SLinus Torvalds }
26251da177e4SLinus Torvalds 
2626d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2627fcfbd547SKirill Korotaev 				     struct file *filp,
2628fcfbd547SKirill Korotaev 				     void __user *buffer,
2629fcfbd547SKirill Korotaev 				     size_t *lenp, loff_t *ppos,
2630fcfbd547SKirill Korotaev 				     unsigned long convmul,
2631fcfbd547SKirill Korotaev 				     unsigned long convdiv)
2632fcfbd547SKirill Korotaev {
2633fcfbd547SKirill Korotaev 	return __do_proc_doulongvec_minmax(table->data, table, write,
2634fcfbd547SKirill Korotaev 			filp, buffer, lenp, ppos, convmul, convdiv);
2635fcfbd547SKirill Korotaev }
2636fcfbd547SKirill Korotaev 
26371da177e4SLinus Torvalds /**
26381da177e4SLinus Torvalds  * proc_doulongvec_minmax - read a vector of long integers with min/max values
26391da177e4SLinus Torvalds  * @table: the sysctl table
26401da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
26411da177e4SLinus Torvalds  * @filp: the file structure
26421da177e4SLinus Torvalds  * @buffer: the user buffer
26431da177e4SLinus Torvalds  * @lenp: the size of the user buffer
26441da177e4SLinus Torvalds  * @ppos: file position
26451da177e4SLinus Torvalds  *
26461da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
26471da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
26481da177e4SLinus Torvalds  *
26491da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
26501da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
26511da177e4SLinus Torvalds  *
26521da177e4SLinus Torvalds  * Returns 0 on success.
26531da177e4SLinus Torvalds  */
2654d8217f07SEric W. Biederman int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
26551da177e4SLinus Torvalds 			   void __user *buffer, size_t *lenp, loff_t *ppos)
26561da177e4SLinus Torvalds {
26571da177e4SLinus Torvalds     return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
26581da177e4SLinus Torvalds }
26591da177e4SLinus Torvalds 
26601da177e4SLinus Torvalds /**
26611da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
26621da177e4SLinus Torvalds  * @table: the sysctl table
26631da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
26641da177e4SLinus Torvalds  * @filp: the file structure
26651da177e4SLinus Torvalds  * @buffer: the user buffer
26661da177e4SLinus Torvalds  * @lenp: the size of the user buffer
26671da177e4SLinus Torvalds  * @ppos: file position
26681da177e4SLinus Torvalds  *
26691da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
26701da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string. The values
26711da177e4SLinus Torvalds  * are treated as milliseconds, and converted to jiffies when they are stored.
26721da177e4SLinus Torvalds  *
26731da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
26741da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
26751da177e4SLinus Torvalds  *
26761da177e4SLinus Torvalds  * Returns 0 on success.
26771da177e4SLinus Torvalds  */
2678d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
26791da177e4SLinus Torvalds 				      struct file *filp,
26801da177e4SLinus Torvalds 				      void __user *buffer,
26811da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
26821da177e4SLinus Torvalds {
26831da177e4SLinus Torvalds     return do_proc_doulongvec_minmax(table, write, filp, buffer,
26841da177e4SLinus Torvalds 				     lenp, ppos, HZ, 1000l);
26851da177e4SLinus Torvalds }
26861da177e4SLinus Torvalds 
26871da177e4SLinus Torvalds 
26881da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
26891da177e4SLinus Torvalds 					 int *valp,
26901da177e4SLinus Torvalds 					 int write, void *data)
26911da177e4SLinus Torvalds {
26921da177e4SLinus Torvalds 	if (write) {
2693cba9f33dSBart Samwel 		if (*lvalp > LONG_MAX / HZ)
2694cba9f33dSBart Samwel 			return 1;
26951da177e4SLinus Torvalds 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
26961da177e4SLinus Torvalds 	} else {
26971da177e4SLinus Torvalds 		int val = *valp;
26981da177e4SLinus Torvalds 		unsigned long lval;
26991da177e4SLinus Torvalds 		if (val < 0) {
27001da177e4SLinus Torvalds 			*negp = -1;
27011da177e4SLinus Torvalds 			lval = (unsigned long)-val;
27021da177e4SLinus Torvalds 		} else {
27031da177e4SLinus Torvalds 			*negp = 0;
27041da177e4SLinus Torvalds 			lval = (unsigned long)val;
27051da177e4SLinus Torvalds 		}
27061da177e4SLinus Torvalds 		*lvalp = lval / HZ;
27071da177e4SLinus Torvalds 	}
27081da177e4SLinus Torvalds 	return 0;
27091da177e4SLinus Torvalds }
27101da177e4SLinus Torvalds 
27111da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
27121da177e4SLinus Torvalds 						int *valp,
27131da177e4SLinus Torvalds 						int write, void *data)
27141da177e4SLinus Torvalds {
27151da177e4SLinus Torvalds 	if (write) {
2716cba9f33dSBart Samwel 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2717cba9f33dSBart Samwel 			return 1;
27181da177e4SLinus Torvalds 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
27191da177e4SLinus Torvalds 	} else {
27201da177e4SLinus Torvalds 		int val = *valp;
27211da177e4SLinus Torvalds 		unsigned long lval;
27221da177e4SLinus Torvalds 		if (val < 0) {
27231da177e4SLinus Torvalds 			*negp = -1;
27241da177e4SLinus Torvalds 			lval = (unsigned long)-val;
27251da177e4SLinus Torvalds 		} else {
27261da177e4SLinus Torvalds 			*negp = 0;
27271da177e4SLinus Torvalds 			lval = (unsigned long)val;
27281da177e4SLinus Torvalds 		}
27291da177e4SLinus Torvalds 		*lvalp = jiffies_to_clock_t(lval);
27301da177e4SLinus Torvalds 	}
27311da177e4SLinus Torvalds 	return 0;
27321da177e4SLinus Torvalds }
27331da177e4SLinus Torvalds 
27341da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
27351da177e4SLinus Torvalds 					    int *valp,
27361da177e4SLinus Torvalds 					    int write, void *data)
27371da177e4SLinus Torvalds {
27381da177e4SLinus Torvalds 	if (write) {
27391da177e4SLinus Torvalds 		*valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
27401da177e4SLinus Torvalds 	} else {
27411da177e4SLinus Torvalds 		int val = *valp;
27421da177e4SLinus Torvalds 		unsigned long lval;
27431da177e4SLinus Torvalds 		if (val < 0) {
27441da177e4SLinus Torvalds 			*negp = -1;
27451da177e4SLinus Torvalds 			lval = (unsigned long)-val;
27461da177e4SLinus Torvalds 		} else {
27471da177e4SLinus Torvalds 			*negp = 0;
27481da177e4SLinus Torvalds 			lval = (unsigned long)val;
27491da177e4SLinus Torvalds 		}
27501da177e4SLinus Torvalds 		*lvalp = jiffies_to_msecs(lval);
27511da177e4SLinus Torvalds 	}
27521da177e4SLinus Torvalds 	return 0;
27531da177e4SLinus Torvalds }
27541da177e4SLinus Torvalds 
27551da177e4SLinus Torvalds /**
27561da177e4SLinus Torvalds  * proc_dointvec_jiffies - read a vector of integers as seconds
27571da177e4SLinus Torvalds  * @table: the sysctl table
27581da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
27591da177e4SLinus Torvalds  * @filp: the file structure
27601da177e4SLinus Torvalds  * @buffer: the user buffer
27611da177e4SLinus Torvalds  * @lenp: the size of the user buffer
27621da177e4SLinus Torvalds  * @ppos: file position
27631da177e4SLinus Torvalds  *
27641da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
27651da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
27661da177e4SLinus Torvalds  * The values read are assumed to be in seconds, and are converted into
27671da177e4SLinus Torvalds  * jiffies.
27681da177e4SLinus Torvalds  *
27691da177e4SLinus Torvalds  * Returns 0 on success.
27701da177e4SLinus Torvalds  */
2771d8217f07SEric W. Biederman int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
27721da177e4SLinus Torvalds 			  void __user *buffer, size_t *lenp, loff_t *ppos)
27731da177e4SLinus Torvalds {
27741da177e4SLinus Torvalds     return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
27751da177e4SLinus Torvalds 		    	    do_proc_dointvec_jiffies_conv,NULL);
27761da177e4SLinus Torvalds }
27771da177e4SLinus Torvalds 
27781da177e4SLinus Torvalds /**
27791da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
27801da177e4SLinus Torvalds  * @table: the sysctl table
27811da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
27821da177e4SLinus Torvalds  * @filp: the file structure
27831da177e4SLinus Torvalds  * @buffer: the user buffer
27841da177e4SLinus Torvalds  * @lenp: the size of the user buffer
27851e5d5331SRandy Dunlap  * @ppos: pointer to the file position
27861da177e4SLinus Torvalds  *
27871da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
27881da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
27891da177e4SLinus Torvalds  * The values read are assumed to be in 1/USER_HZ seconds, and
27901da177e4SLinus Torvalds  * are converted into jiffies.
27911da177e4SLinus Torvalds  *
27921da177e4SLinus Torvalds  * Returns 0 on success.
27931da177e4SLinus Torvalds  */
2794d8217f07SEric W. Biederman int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
27951da177e4SLinus Torvalds 				 void __user *buffer, size_t *lenp, loff_t *ppos)
27961da177e4SLinus Torvalds {
27971da177e4SLinus Torvalds     return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
27981da177e4SLinus Torvalds 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
27991da177e4SLinus Torvalds }
28001da177e4SLinus Torvalds 
28011da177e4SLinus Torvalds /**
28021da177e4SLinus Torvalds  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
28031da177e4SLinus Torvalds  * @table: the sysctl table
28041da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
28051da177e4SLinus Torvalds  * @filp: the file structure
28061da177e4SLinus Torvalds  * @buffer: the user buffer
28071da177e4SLinus Torvalds  * @lenp: the size of the user buffer
280867be2dd1SMartin Waitz  * @ppos: file position
280967be2dd1SMartin Waitz  * @ppos: the current position in the file
28101da177e4SLinus Torvalds  *
28111da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
28121da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
28131da177e4SLinus Torvalds  * The values read are assumed to be in 1/1000 seconds, and
28141da177e4SLinus Torvalds  * are converted into jiffies.
28151da177e4SLinus Torvalds  *
28161da177e4SLinus Torvalds  * Returns 0 on success.
28171da177e4SLinus Torvalds  */
2818d8217f07SEric W. Biederman int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
28191da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
28201da177e4SLinus Torvalds {
28211da177e4SLinus Torvalds 	return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
28221da177e4SLinus Torvalds 				do_proc_dointvec_ms_jiffies_conv, NULL);
28231da177e4SLinus Torvalds }
28241da177e4SLinus Torvalds 
2825d8217f07SEric W. Biederman static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
28269ec52099SCedric Le Goater 			   void __user *buffer, size_t *lenp, loff_t *ppos)
28279ec52099SCedric Le Goater {
28289ec52099SCedric Le Goater 	struct pid *new_pid;
28299ec52099SCedric Le Goater 	pid_t tmp;
28309ec52099SCedric Le Goater 	int r;
28319ec52099SCedric Le Goater 
28326c5f3e7bSPavel Emelyanov 	tmp = pid_vnr(cad_pid);
28339ec52099SCedric Le Goater 
28349ec52099SCedric Le Goater 	r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
28359ec52099SCedric Le Goater 			       lenp, ppos, NULL, NULL);
28369ec52099SCedric Le Goater 	if (r || !write)
28379ec52099SCedric Le Goater 		return r;
28389ec52099SCedric Le Goater 
28399ec52099SCedric Le Goater 	new_pid = find_get_pid(tmp);
28409ec52099SCedric Le Goater 	if (!new_pid)
28419ec52099SCedric Le Goater 		return -ESRCH;
28429ec52099SCedric Le Goater 
28439ec52099SCedric Le Goater 	put_pid(xchg(&cad_pid, new_pid));
28449ec52099SCedric Le Goater 	return 0;
28459ec52099SCedric Le Goater }
28469ec52099SCedric Le Goater 
28471da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */
28481da177e4SLinus Torvalds 
2849d8217f07SEric W. Biederman int proc_dostring(struct ctl_table *table, int write, struct file *filp,
28501da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
28511da177e4SLinus Torvalds {
28521da177e4SLinus Torvalds 	return -ENOSYS;
28531da177e4SLinus Torvalds }
28541da177e4SLinus Torvalds 
2855d8217f07SEric W. Biederman int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
28561da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
28571da177e4SLinus Torvalds {
28581da177e4SLinus Torvalds 	return -ENOSYS;
28591da177e4SLinus Torvalds }
28601da177e4SLinus Torvalds 
2861d8217f07SEric W. Biederman int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
28621da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
28631da177e4SLinus Torvalds {
28641da177e4SLinus Torvalds 	return -ENOSYS;
28651da177e4SLinus Torvalds }
28661da177e4SLinus Torvalds 
2867d8217f07SEric W. Biederman int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
28681da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
28691da177e4SLinus Torvalds {
28701da177e4SLinus Torvalds 	return -ENOSYS;
28711da177e4SLinus Torvalds }
28721da177e4SLinus Torvalds 
2873d8217f07SEric W. Biederman int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
28741da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
28751da177e4SLinus Torvalds {
28761da177e4SLinus Torvalds 	return -ENOSYS;
28771da177e4SLinus Torvalds }
28781da177e4SLinus Torvalds 
2879d8217f07SEric W. Biederman int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
28801da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
28811da177e4SLinus Torvalds {
28821da177e4SLinus Torvalds 	return -ENOSYS;
28831da177e4SLinus Torvalds }
28841da177e4SLinus Torvalds 
2885d8217f07SEric W. Biederman int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
28861da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
28871da177e4SLinus Torvalds {
28881da177e4SLinus Torvalds 	return -ENOSYS;
28891da177e4SLinus Torvalds }
28901da177e4SLinus Torvalds 
2891d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
28921da177e4SLinus Torvalds 				      struct file *filp,
28931da177e4SLinus Torvalds 				      void __user *buffer,
28941da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
28951da177e4SLinus Torvalds {
28961da177e4SLinus Torvalds     return -ENOSYS;
28971da177e4SLinus Torvalds }
28981da177e4SLinus Torvalds 
28991da177e4SLinus Torvalds 
29001da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */
29011da177e4SLinus Torvalds 
29021da177e4SLinus Torvalds 
2903b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL
29041da177e4SLinus Torvalds /*
29051da177e4SLinus Torvalds  * General sysctl support routines
29061da177e4SLinus Torvalds  */
29071da177e4SLinus Torvalds 
290849a0c458SEric W. Biederman /* The generic sysctl data routine (used if no strategy routine supplied) */
2909f221e726SAlexey Dobriyan int sysctl_data(struct ctl_table *table,
291049a0c458SEric W. Biederman 		void __user *oldval, size_t __user *oldlenp,
291149a0c458SEric W. Biederman 		void __user *newval, size_t newlen)
291249a0c458SEric W. Biederman {
291349a0c458SEric W. Biederman 	size_t len;
291449a0c458SEric W. Biederman 
291549a0c458SEric W. Biederman 	/* Get out of I don't have a variable */
291649a0c458SEric W. Biederman 	if (!table->data || !table->maxlen)
291749a0c458SEric W. Biederman 		return -ENOTDIR;
291849a0c458SEric W. Biederman 
291949a0c458SEric W. Biederman 	if (oldval && oldlenp) {
292049a0c458SEric W. Biederman 		if (get_user(len, oldlenp))
292149a0c458SEric W. Biederman 			return -EFAULT;
292249a0c458SEric W. Biederman 		if (len) {
292349a0c458SEric W. Biederman 			if (len > table->maxlen)
292449a0c458SEric W. Biederman 				len = table->maxlen;
292549a0c458SEric W. Biederman 			if (copy_to_user(oldval, table->data, len))
292649a0c458SEric W. Biederman 				return -EFAULT;
292749a0c458SEric W. Biederman 			if (put_user(len, oldlenp))
292849a0c458SEric W. Biederman 				return -EFAULT;
292949a0c458SEric W. Biederman 		}
293049a0c458SEric W. Biederman 	}
293149a0c458SEric W. Biederman 
293249a0c458SEric W. Biederman 	if (newval && newlen) {
293349a0c458SEric W. Biederman 		if (newlen > table->maxlen)
293449a0c458SEric W. Biederman 			newlen = table->maxlen;
293549a0c458SEric W. Biederman 
293649a0c458SEric W. Biederman 		if (copy_from_user(table->data, newval, newlen))
293749a0c458SEric W. Biederman 			return -EFAULT;
293849a0c458SEric W. Biederman 	}
293949a0c458SEric W. Biederman 	return 1;
294049a0c458SEric W. Biederman }
294149a0c458SEric W. Biederman 
29421da177e4SLinus Torvalds /* The generic string strategy routine: */
2943f221e726SAlexey Dobriyan int sysctl_string(struct ctl_table *table,
29441da177e4SLinus Torvalds 		  void __user *oldval, size_t __user *oldlenp,
29451f29bcd7SAlexey Dobriyan 		  void __user *newval, size_t newlen)
29461da177e4SLinus Torvalds {
29471da177e4SLinus Torvalds 	if (!table->data || !table->maxlen)
29481da177e4SLinus Torvalds 		return -ENOTDIR;
29491da177e4SLinus Torvalds 
29501da177e4SLinus Torvalds 	if (oldval && oldlenp) {
2951de9e007dSLinus Torvalds 		size_t bufsize;
2952de9e007dSLinus Torvalds 		if (get_user(bufsize, oldlenp))
29531da177e4SLinus Torvalds 			return -EFAULT;
2954de9e007dSLinus Torvalds 		if (bufsize) {
2955de9e007dSLinus Torvalds 			size_t len = strlen(table->data), copied;
2956de9e007dSLinus Torvalds 
2957de9e007dSLinus Torvalds 			/* This shouldn't trigger for a well-formed sysctl */
2958de9e007dSLinus Torvalds 			if (len > table->maxlen)
29591da177e4SLinus Torvalds 				len = table->maxlen;
2960de9e007dSLinus Torvalds 
2961de9e007dSLinus Torvalds 			/* Copy up to a max of bufsize-1 bytes of the string */
2962de9e007dSLinus Torvalds 			copied = (len >= bufsize) ? bufsize - 1 : len;
2963de9e007dSLinus Torvalds 
2964de9e007dSLinus Torvalds 			if (copy_to_user(oldval, table->data, copied) ||
2965de9e007dSLinus Torvalds 			    put_user(0, (char __user *)(oldval + copied)))
29661da177e4SLinus Torvalds 				return -EFAULT;
29671da177e4SLinus Torvalds 			if (put_user(len, oldlenp))
29681da177e4SLinus Torvalds 				return -EFAULT;
29691da177e4SLinus Torvalds 		}
29701da177e4SLinus Torvalds 	}
29711da177e4SLinus Torvalds 	if (newval && newlen) {
2972de9e007dSLinus Torvalds 		size_t len = newlen;
29731da177e4SLinus Torvalds 		if (len > table->maxlen)
29741da177e4SLinus Torvalds 			len = table->maxlen;
29751da177e4SLinus Torvalds 		if(copy_from_user(table->data, newval, len))
29761da177e4SLinus Torvalds 			return -EFAULT;
29771da177e4SLinus Torvalds 		if (len == table->maxlen)
29781da177e4SLinus Torvalds 			len--;
29791da177e4SLinus Torvalds 		((char *) table->data)[len] = 0;
29801da177e4SLinus Torvalds 	}
298182c9df82SYi Yang 	return 1;
29821da177e4SLinus Torvalds }
29831da177e4SLinus Torvalds 
29841da177e4SLinus Torvalds /*
29851da177e4SLinus Torvalds  * This function makes sure that all of the integers in the vector
29861da177e4SLinus Torvalds  * are between the minimum and maximum values given in the arrays
29871da177e4SLinus Torvalds  * table->extra1 and table->extra2, respectively.
29881da177e4SLinus Torvalds  */
2989f221e726SAlexey Dobriyan int sysctl_intvec(struct ctl_table *table,
29901da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
29911f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
29921da177e4SLinus Torvalds {
29931da177e4SLinus Torvalds 
29941da177e4SLinus Torvalds 	if (newval && newlen) {
29951da177e4SLinus Torvalds 		int __user *vec = (int __user *) newval;
29961da177e4SLinus Torvalds 		int *min = (int *) table->extra1;
29971da177e4SLinus Torvalds 		int *max = (int *) table->extra2;
29981da177e4SLinus Torvalds 		size_t length;
29991da177e4SLinus Torvalds 		int i;
30001da177e4SLinus Torvalds 
30011da177e4SLinus Torvalds 		if (newlen % sizeof(int) != 0)
30021da177e4SLinus Torvalds 			return -EINVAL;
30031da177e4SLinus Torvalds 
30041da177e4SLinus Torvalds 		if (!table->extra1 && !table->extra2)
30051da177e4SLinus Torvalds 			return 0;
30061da177e4SLinus Torvalds 
30071da177e4SLinus Torvalds 		if (newlen > table->maxlen)
30081da177e4SLinus Torvalds 			newlen = table->maxlen;
30091da177e4SLinus Torvalds 		length = newlen / sizeof(int);
30101da177e4SLinus Torvalds 
30111da177e4SLinus Torvalds 		for (i = 0; i < length; i++) {
30121da177e4SLinus Torvalds 			int value;
30131da177e4SLinus Torvalds 			if (get_user(value, vec + i))
30141da177e4SLinus Torvalds 				return -EFAULT;
30151da177e4SLinus Torvalds 			if (min && value < min[i])
30161da177e4SLinus Torvalds 				return -EINVAL;
30171da177e4SLinus Torvalds 			if (max && value > max[i])
30181da177e4SLinus Torvalds 				return -EINVAL;
30191da177e4SLinus Torvalds 		}
30201da177e4SLinus Torvalds 	}
30211da177e4SLinus Torvalds 	return 0;
30221da177e4SLinus Torvalds }
30231da177e4SLinus Torvalds 
30241da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */
3025f221e726SAlexey Dobriyan int sysctl_jiffies(struct ctl_table *table,
30261da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
30271f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
30281da177e4SLinus Torvalds {
30293ee75ac3SAlexey Dobriyan 	if (oldval && oldlenp) {
30301da177e4SLinus Torvalds 		size_t olen;
30313ee75ac3SAlexey Dobriyan 
30321da177e4SLinus Torvalds 		if (get_user(olen, oldlenp))
30331da177e4SLinus Torvalds 			return -EFAULT;
30343ee75ac3SAlexey Dobriyan 		if (olen) {
30353ee75ac3SAlexey Dobriyan 			int val;
30363ee75ac3SAlexey Dobriyan 
30373ee75ac3SAlexey Dobriyan 			if (olen < sizeof(int))
30381da177e4SLinus Torvalds 				return -EINVAL;
30393ee75ac3SAlexey Dobriyan 
30403ee75ac3SAlexey Dobriyan 			val = *(int *)(table->data) / HZ;
30413ee75ac3SAlexey Dobriyan 			if (put_user(val, (int __user *)oldval))
30421da177e4SLinus Torvalds 				return -EFAULT;
30433ee75ac3SAlexey Dobriyan 			if (put_user(sizeof(int), oldlenp))
30443ee75ac3SAlexey Dobriyan 				return -EFAULT;
30453ee75ac3SAlexey Dobriyan 		}
30461da177e4SLinus Torvalds 	}
30471da177e4SLinus Torvalds 	if (newval && newlen) {
30481da177e4SLinus Torvalds 		int new;
30491da177e4SLinus Torvalds 		if (newlen != sizeof(int))
30501da177e4SLinus Torvalds 			return -EINVAL;
30511da177e4SLinus Torvalds 		if (get_user(new, (int __user *)newval))
30521da177e4SLinus Torvalds 			return -EFAULT;
30531da177e4SLinus Torvalds 		*(int *)(table->data) = new*HZ;
30541da177e4SLinus Torvalds 	}
30551da177e4SLinus Torvalds 	return 1;
30561da177e4SLinus Torvalds }
30571da177e4SLinus Torvalds 
30581da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */
3059f221e726SAlexey Dobriyan int sysctl_ms_jiffies(struct ctl_table *table,
30601da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
30611f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
30621da177e4SLinus Torvalds {
30633ee75ac3SAlexey Dobriyan 	if (oldval && oldlenp) {
30641da177e4SLinus Torvalds 		size_t olen;
30653ee75ac3SAlexey Dobriyan 
30661da177e4SLinus Torvalds 		if (get_user(olen, oldlenp))
30671da177e4SLinus Torvalds 			return -EFAULT;
30683ee75ac3SAlexey Dobriyan 		if (olen) {
30693ee75ac3SAlexey Dobriyan 			int val;
30703ee75ac3SAlexey Dobriyan 
30713ee75ac3SAlexey Dobriyan 			if (olen < sizeof(int))
30721da177e4SLinus Torvalds 				return -EINVAL;
30733ee75ac3SAlexey Dobriyan 
30743ee75ac3SAlexey Dobriyan 			val = jiffies_to_msecs(*(int *)(table->data));
30753ee75ac3SAlexey Dobriyan 			if (put_user(val, (int __user *)oldval))
30761da177e4SLinus Torvalds 				return -EFAULT;
30773ee75ac3SAlexey Dobriyan 			if (put_user(sizeof(int), oldlenp))
30783ee75ac3SAlexey Dobriyan 				return -EFAULT;
30793ee75ac3SAlexey Dobriyan 		}
30801da177e4SLinus Torvalds 	}
30811da177e4SLinus Torvalds 	if (newval && newlen) {
30821da177e4SLinus Torvalds 		int new;
30831da177e4SLinus Torvalds 		if (newlen != sizeof(int))
30841da177e4SLinus Torvalds 			return -EINVAL;
30851da177e4SLinus Torvalds 		if (get_user(new, (int __user *)newval))
30861da177e4SLinus Torvalds 			return -EFAULT;
30871da177e4SLinus Torvalds 		*(int *)(table->data) = msecs_to_jiffies(new);
30881da177e4SLinus Torvalds 	}
30891da177e4SLinus Torvalds 	return 1;
30901da177e4SLinus Torvalds }
30911da177e4SLinus Torvalds 
3092c4b8b769SEric W. Biederman 
3093c4b8b769SEric W. Biederman 
3094b89a8171SEric W. Biederman #else /* CONFIG_SYSCTL_SYSCALL */
30951da177e4SLinus Torvalds 
30961da177e4SLinus Torvalds 
30971e7bfb21SHeiko Carstens SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
30981da177e4SLinus Torvalds {
30990e009be8SEric W. Biederman 	struct __sysctl_args tmp;
31007058cb02SEric W. Biederman 	int error;
31010e009be8SEric W. Biederman 
31020e009be8SEric W. Biederman 	if (copy_from_user(&tmp, args, sizeof(tmp)))
31030e009be8SEric W. Biederman 		return -EFAULT;
31040e009be8SEric W. Biederman 
31057058cb02SEric W. Biederman 	error = deprecated_sysctl_warning(&tmp);
3106b89a8171SEric W. Biederman 
31077058cb02SEric W. Biederman 	/* If no error reading the parameters then just -ENOSYS ... */
31087058cb02SEric W. Biederman 	if (!error)
31097058cb02SEric W. Biederman 		error = -ENOSYS;
31107058cb02SEric W. Biederman 
31117058cb02SEric W. Biederman 	return error;
31121da177e4SLinus Torvalds }
31131da177e4SLinus Torvalds 
3114f221e726SAlexey Dobriyan int sysctl_data(struct ctl_table *table,
311549a0c458SEric W. Biederman 		  void __user *oldval, size_t __user *oldlenp,
311649a0c458SEric W. Biederman 		  void __user *newval, size_t newlen)
311749a0c458SEric W. Biederman {
311849a0c458SEric W. Biederman 	return -ENOSYS;
311949a0c458SEric W. Biederman }
312049a0c458SEric W. Biederman 
3121f221e726SAlexey Dobriyan int sysctl_string(struct ctl_table *table,
31221da177e4SLinus Torvalds 		  void __user *oldval, size_t __user *oldlenp,
31231f29bcd7SAlexey Dobriyan 		  void __user *newval, size_t newlen)
31241da177e4SLinus Torvalds {
31251da177e4SLinus Torvalds 	return -ENOSYS;
31261da177e4SLinus Torvalds }
31271da177e4SLinus Torvalds 
3128f221e726SAlexey Dobriyan int sysctl_intvec(struct ctl_table *table,
31291da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
31301f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
31311da177e4SLinus Torvalds {
31321da177e4SLinus Torvalds 	return -ENOSYS;
31331da177e4SLinus Torvalds }
31341da177e4SLinus Torvalds 
3135f221e726SAlexey Dobriyan int sysctl_jiffies(struct ctl_table *table,
31361da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
31371f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
31381da177e4SLinus Torvalds {
31391da177e4SLinus Torvalds 	return -ENOSYS;
31401da177e4SLinus Torvalds }
31411da177e4SLinus Torvalds 
3142f221e726SAlexey Dobriyan int sysctl_ms_jiffies(struct ctl_table *table,
31431da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
31441f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
31451da177e4SLinus Torvalds {
31461da177e4SLinus Torvalds 	return -ENOSYS;
31471da177e4SLinus Torvalds }
31481da177e4SLinus Torvalds 
3149b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */
31501da177e4SLinus Torvalds 
31517058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args)
31527058cb02SEric W. Biederman {
31537058cb02SEric W. Biederman 	static int msg_count;
31547058cb02SEric W. Biederman 	int name[CTL_MAXNAME];
31557058cb02SEric W. Biederman 	int i;
31567058cb02SEric W. Biederman 
31576fc48af8STetsuo Handa 	/* Check args->nlen. */
31586fc48af8STetsuo Handa 	if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
31596fc48af8STetsuo Handa 		return -ENOTDIR;
31606fc48af8STetsuo Handa 
31617058cb02SEric W. Biederman 	/* Read in the sysctl name for better debug message logging */
31627058cb02SEric W. Biederman 	for (i = 0; i < args->nlen; i++)
31637058cb02SEric W. Biederman 		if (get_user(name[i], args->name + i))
31647058cb02SEric W. Biederman 			return -EFAULT;
31657058cb02SEric W. Biederman 
31667058cb02SEric W. Biederman 	/* Ignore accesses to kernel.version */
31677058cb02SEric W. Biederman 	if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
31687058cb02SEric W. Biederman 		return 0;
31697058cb02SEric W. Biederman 
31707058cb02SEric W. Biederman 	if (msg_count < 5) {
31717058cb02SEric W. Biederman 		msg_count++;
31727058cb02SEric W. Biederman 		printk(KERN_INFO
31737058cb02SEric W. Biederman 			"warning: process `%s' used the deprecated sysctl "
31747058cb02SEric W. Biederman 			"system call with ", current->comm);
31757058cb02SEric W. Biederman 		for (i = 0; i < args->nlen; i++)
31767058cb02SEric W. Biederman 			printk("%d.", name[i]);
31777058cb02SEric W. Biederman 		printk("\n");
31787058cb02SEric W. Biederman 	}
31797058cb02SEric W. Biederman 	return 0;
31807058cb02SEric W. Biederman }
31817058cb02SEric W. Biederman 
31821da177e4SLinus Torvalds /*
31831da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
31841da177e4SLinus Torvalds  * exception granted :-)
31851da177e4SLinus Torvalds  */
31861da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
31871da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
31881da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
31891da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
31901da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
31911da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
31921da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
31931da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
31941da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table);
319529e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths);
31961da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_intvec);
31971da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_jiffies);
31981da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_ms_jiffies);
31991da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_string);
320049a0c458SEric W. Biederman EXPORT_SYMBOL(sysctl_data);
32011da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table);
3202