xref: /openbmc/linux/kernel/sysctl.c (revision ab3c68ee5fd329ba48094d3417fd60e30ea14a87)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * sysctl.c: General linux system control interface
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  * Begun 24 March 1995, Stephen Tweedie
51da177e4SLinus Torvalds  * Added /proc support, Dec 1995
61da177e4SLinus Torvalds  * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
71da177e4SLinus Torvalds  * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
81da177e4SLinus Torvalds  * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
91da177e4SLinus Torvalds  * Dynamic registration fixes, Stephen Tweedie.
101da177e4SLinus Torvalds  * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
111da177e4SLinus Torvalds  * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
121da177e4SLinus Torvalds  *  Horn.
131da177e4SLinus Torvalds  * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
141da177e4SLinus Torvalds  * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
151da177e4SLinus Torvalds  * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
161da177e4SLinus Torvalds  *  Wendling.
171da177e4SLinus Torvalds  * The list_for_each() macro wasn't appropriate for the sysctl loop.
181da177e4SLinus Torvalds  *  Removed it and replaced it with older style, 03/23/00, Bill Wendling
191da177e4SLinus Torvalds  */
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds #include <linux/module.h>
221da177e4SLinus Torvalds #include <linux/mm.h>
231da177e4SLinus Torvalds #include <linux/swap.h>
241da177e4SLinus Torvalds #include <linux/slab.h>
251da177e4SLinus Torvalds #include <linux/sysctl.h>
26d33ed52dSDave Young #include <linux/signal.h>
271da177e4SLinus Torvalds #include <linux/proc_fs.h>
2872c2d582SAndrew Morgan #include <linux/security.h>
291da177e4SLinus Torvalds #include <linux/ctype.h>
30dfec072eSVegard Nossum #include <linux/kmemcheck.h>
3162239ac2SAdrian Bunk #include <linux/fs.h>
321da177e4SLinus Torvalds #include <linux/init.h>
331da177e4SLinus Torvalds #include <linux/kernel.h>
340296b228SKay Sievers #include <linux/kobject.h>
3520380731SArnaldo Carvalho de Melo #include <linux/net.h>
361da177e4SLinus Torvalds #include <linux/sysrq.h>
371da177e4SLinus Torvalds #include <linux/highuid.h>
381da177e4SLinus Torvalds #include <linux/writeback.h>
393fff4c42SIngo Molnar #include <linux/ratelimit.h>
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>
5212e22c5eSDavid Howells #include <linux/slow-work.h>
53cdd6c482SIngo Molnar #include <linux/perf_event.h>
54b2be84dfSMasami Hiramatsu #include <linux/kprobes.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
64c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT
65c55b7c3eSDave Young #include <linux/acct.h>
66c55b7c3eSDave Young #endif
674f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES
684f0e056fSDave Young #include <linux/rtmutex.h>
694f0e056fSDave Young #endif
702edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
712edf5e49SDave Young #include <linux/lockdep.h>
722edf5e49SDave Young #endif
7315485a46SDave Young #ifdef CONFIG_CHR_DEV_SG
7415485a46SDave Young #include <scsi/sg.h>
7515485a46SDave Young #endif
7629cbc78bSAndi Kleen 
777058cb02SEric W. Biederman 
781da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL)
791da177e4SLinus Torvalds 
801da177e4SLinus Torvalds /* External variables not in a header file. */
811da177e4SLinus Torvalds extern int sysctl_overcommit_memory;
821da177e4SLinus Torvalds extern int sysctl_overcommit_ratio;
83fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom;
84fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task;
85fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks;
861da177e4SLinus Torvalds extern int max_threads;
871da177e4SLinus Torvalds extern int core_uses_pid;
88d6e71144SAlan Cox extern int suid_dumpable;
891da177e4SLinus Torvalds extern char core_pattern[];
90a293980cSNeil Horman extern unsigned int core_pipe_limit;
911da177e4SLinus Torvalds extern int pid_max;
921da177e4SLinus Torvalds extern int min_free_kbytes;
931da177e4SLinus Torvalds extern int pid_max_min, pid_max_max;
949d0243bcSAndrew Morton extern int sysctl_drop_caches;
958ad4b1fbSRohit Seth extern int percpu_pagelist_fraction;
96bebfa101SAndi Kleen extern int compat_log;
979745512cSArjan van de Ven extern int latencytop_enabled;
98eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max;
99dd8632a1SPaul Mundt #ifndef CONFIG_MMU
100dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages;
101dd8632a1SPaul Mundt #endif
102cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
1035e605b64SJens Axboe extern int blk_iopoll_enabled;
104cb684b5bSJens Axboe #endif
1051da177e4SLinus Torvalds 
106c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and  maximum */
107195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP
108c4f3b63fSRavikiran G Thirumalai static int sixty = 60;
1099383d967SDimitri Sivanich static int neg_one = -1;
110c4f3b63fSRavikiran G Thirumalai #endif
111c4f3b63fSRavikiran G Thirumalai 
112c4f3b63fSRavikiran G Thirumalai static int zero;
113cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1;
114cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2;
115fc3501d4SSven Wegener static unsigned long one_ul = 1;
116c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100;
117af91322eSDave Young #ifdef CONFIG_PRINTK
118af91322eSDave Young static int ten_thousand = 10000;
119af91322eSDave Young #endif
120c4f3b63fSRavikiran G Thirumalai 
1219e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
1229e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1239e4a5bdaSAndrea Righi 
1241da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1251da177e4SLinus Torvalds static int maxolduid = 65535;
1261da177e4SLinus Torvalds static int minolduid;
1278ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8;
1281da177e4SLinus Torvalds 
1291da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
1301da177e4SLinus Torvalds 
13172c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
13217f04fbbSDavid S. Miller #include <asm/system.h>
1331da177e4SLinus Torvalds #endif
1341da177e4SLinus Torvalds 
1350871420fSDavid S. Miller #ifdef CONFIG_SPARC64
1360871420fSDavid S. Miller extern int sysctl_tsb_ratio;
1370871420fSDavid S. Miller #endif
1380871420fSDavid S. Miller 
1391da177e4SLinus Torvalds #ifdef __hppa__
1401da177e4SLinus Torvalds extern int pwrsw_enabled;
1411da177e4SLinus Torvalds extern int unaligned_enabled;
1421da177e4SLinus Torvalds #endif
1431da177e4SLinus Torvalds 
144347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
1451da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
1461da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings;
1471da177e4SLinus Torvalds #endif
1481da177e4SLinus Torvalds extern int sysctl_userprocess_debug;
149951f22d5SMartin Schwidefsky extern int spin_retry;
1501da177e4SLinus Torvalds #endif
1511da177e4SLinus Torvalds 
152d2b176edSJes Sorensen #ifdef CONFIG_IA64
153d2b176edSJes Sorensen extern int no_unaligned_warning;
15488fc241fSDoug Chapman extern int unaligned_dump_stack;
155d2b176edSJes Sorensen #endif
156d2b176edSJes Sorensen 
1573fff4c42SIngo Molnar extern struct ratelimit_state printk_ratelimit_state;
1583fff4c42SIngo Molnar 
159d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
1608d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write,
1619ec52099SCedric Le Goater 		  void __user *buffer, size_t *lenp, loff_t *ppos);
1628d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write,
16334f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos);
164d6f8ff73SRandy Dunlap #endif
1659ec52099SCedric Le Goater 
166d8217f07SEric W. Biederman static struct ctl_table root_table[];
167e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root;
168e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = {
169b380b0d4SAl Viro 	.count = 1,
170e51b6ba0SEric W. Biederman 	.ctl_table = root_table,
17173455092SAl Viro 	.ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
172e51b6ba0SEric W. Biederman 	.root = &sysctl_table_root,
17373455092SAl Viro 	.set = &sysctl_table_root.default_set,
174e51b6ba0SEric W. Biederman };
175e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = {
176e51b6ba0SEric W. Biederman 	.root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
17773455092SAl Viro 	.default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
178e51b6ba0SEric W. Biederman };
1791da177e4SLinus Torvalds 
180d8217f07SEric W. Biederman static struct ctl_table kern_table[];
181d8217f07SEric W. Biederman static struct ctl_table vm_table[];
182d8217f07SEric W. Biederman static struct ctl_table fs_table[];
183d8217f07SEric W. Biederman static struct ctl_table debug_table[];
184d8217f07SEric W. Biederman static struct ctl_table dev_table[];
185d8217f07SEric W. Biederman extern struct ctl_table random_table[];
1862d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
187d8217f07SEric W. Biederman extern struct ctl_table inotify_table[];
1880399cb08SRobert Love #endif
1897ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
1907ef9964eSDavide Libenzi extern struct ctl_table epoll_table[];
1917ef9964eSDavide Libenzi #endif
1921da177e4SLinus Torvalds 
1931da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1941da177e4SLinus Torvalds int sysctl_legacy_va_layout;
1951da177e4SLinus Torvalds #endif
1961da177e4SLinus Torvalds 
1971da177e4SLinus Torvalds /* The default sysctl tables: */
1981da177e4SLinus Torvalds 
199d8217f07SEric W. Biederman static struct ctl_table root_table[] = {
2001da177e4SLinus Torvalds 	{
2011da177e4SLinus Torvalds 		.procname	= "kernel",
2021da177e4SLinus Torvalds 		.mode		= 0555,
2031da177e4SLinus Torvalds 		.child		= kern_table,
2041da177e4SLinus Torvalds 	},
2051da177e4SLinus Torvalds 	{
2061da177e4SLinus Torvalds 		.procname	= "vm",
2071da177e4SLinus Torvalds 		.mode		= 0555,
2081da177e4SLinus Torvalds 		.child		= vm_table,
2091da177e4SLinus Torvalds 	},
2101da177e4SLinus Torvalds 	{
2111da177e4SLinus Torvalds 		.procname	= "fs",
2121da177e4SLinus Torvalds 		.mode		= 0555,
2131da177e4SLinus Torvalds 		.child		= fs_table,
2141da177e4SLinus Torvalds 	},
2151da177e4SLinus Torvalds 	{
2161da177e4SLinus Torvalds 		.procname	= "debug",
2171da177e4SLinus Torvalds 		.mode		= 0555,
2181da177e4SLinus Torvalds 		.child		= debug_table,
2191da177e4SLinus Torvalds 	},
2201da177e4SLinus Torvalds 	{
2211da177e4SLinus Torvalds 		.procname	= "dev",
2221da177e4SLinus Torvalds 		.mode		= 0555,
2231da177e4SLinus Torvalds 		.child		= dev_table,
2241da177e4SLinus Torvalds 	},
2252be7fe07SAndrew Morton /*
2262be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
2272be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
2282be7fe07SAndrew Morton  */
2296fce56ecSEric W. Biederman 	{ }
2301da177e4SLinus Torvalds };
2311da177e4SLinus Torvalds 
23277e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
23373c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000;		/* 100 usecs */
23473c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
23573c4efd2SEric Dumazet static int min_wakeup_granularity_ns;			/* 0 usecs */
23673c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
2371983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
2381983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
239acb4a848SChristian Ehrhardt static int min_sched_shares_ratelimit = 100000; /* 100 usec */
240acb4a848SChristian Ehrhardt static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
24177e54a1fSIngo Molnar #endif
24277e54a1fSIngo Molnar 
243d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
2442bba22c5SMike Galbraith 	{
2452bba22c5SMike Galbraith 		.procname	= "sched_child_runs_first",
2462bba22c5SMike Galbraith 		.data		= &sysctl_sched_child_runs_first,
2472bba22c5SMike Galbraith 		.maxlen		= sizeof(unsigned int),
2482bba22c5SMike Galbraith 		.mode		= 0644,
2496d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2502bba22c5SMike Galbraith 	},
25177e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
25277e54a1fSIngo Molnar 	{
253b2be5e96SPeter Zijlstra 		.procname	= "sched_min_granularity_ns",
254b2be5e96SPeter Zijlstra 		.data		= &sysctl_sched_min_granularity,
25577e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
25677e54a1fSIngo Molnar 		.mode		= 0644,
257702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
258b2be5e96SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
259b2be5e96SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
26077e54a1fSIngo Molnar 	},
26177e54a1fSIngo Molnar 	{
26221805085SPeter Zijlstra 		.procname	= "sched_latency_ns",
26321805085SPeter Zijlstra 		.data		= &sysctl_sched_latency,
26421805085SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
26521805085SPeter Zijlstra 		.mode		= 0644,
266702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
26721805085SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
26821805085SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
26921805085SPeter Zijlstra 	},
27021805085SPeter Zijlstra 	{
27177e54a1fSIngo Molnar 		.procname	= "sched_wakeup_granularity_ns",
27277e54a1fSIngo Molnar 		.data		= &sysctl_sched_wakeup_granularity,
27377e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
27477e54a1fSIngo Molnar 		.mode		= 0644,
275702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
27677e54a1fSIngo Molnar 		.extra1		= &min_wakeup_granularity_ns,
27777e54a1fSIngo Molnar 		.extra2		= &max_wakeup_granularity_ns,
27877e54a1fSIngo Molnar 	},
27977e54a1fSIngo Molnar 	{
2802398f2c6SPeter Zijlstra 		.procname	= "sched_shares_ratelimit",
2812398f2c6SPeter Zijlstra 		.data		= &sysctl_sched_shares_ratelimit,
2822398f2c6SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
2832398f2c6SPeter Zijlstra 		.mode		= 0644,
284702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
285acb4a848SChristian Ehrhardt 		.extra1		= &min_sched_shares_ratelimit,
286acb4a848SChristian Ehrhardt 		.extra2		= &max_sched_shares_ratelimit,
2872398f2c6SPeter Zijlstra 	},
2882398f2c6SPeter Zijlstra 	{
2891983a922SChristian Ehrhardt 		.procname	= "sched_tunable_scaling",
2901983a922SChristian Ehrhardt 		.data		= &sysctl_sched_tunable_scaling,
2911983a922SChristian Ehrhardt 		.maxlen		= sizeof(enum sched_tunable_scaling),
2921983a922SChristian Ehrhardt 		.mode		= 0644,
293702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
2941983a922SChristian Ehrhardt 		.extra1		= &min_sched_tunable_scaling,
2951983a922SChristian Ehrhardt 		.extra2		= &max_sched_tunable_scaling,
2962398f2c6SPeter Zijlstra 	},
2972398f2c6SPeter Zijlstra 	{
298ffda12a1SPeter Zijlstra 		.procname	= "sched_shares_thresh",
299ffda12a1SPeter Zijlstra 		.data		= &sysctl_sched_shares_thresh,
300ffda12a1SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
301ffda12a1SPeter Zijlstra 		.mode		= 0644,
3026d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
303ffda12a1SPeter Zijlstra 		.extra1		= &zero,
304ffda12a1SPeter Zijlstra 	},
305ffda12a1SPeter Zijlstra 	{
306da84d961SIngo Molnar 		.procname	= "sched_migration_cost",
307da84d961SIngo Molnar 		.data		= &sysctl_sched_migration_cost,
308da84d961SIngo Molnar 		.maxlen		= sizeof(unsigned int),
309da84d961SIngo Molnar 		.mode		= 0644,
3106d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
311da84d961SIngo Molnar 	},
312b82d9fddSPeter Zijlstra 	{
313b82d9fddSPeter Zijlstra 		.procname	= "sched_nr_migrate",
314b82d9fddSPeter Zijlstra 		.data		= &sysctl_sched_nr_migrate,
315b82d9fddSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
316fa85ae24SPeter Zijlstra 		.mode		= 0644,
3176d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
318fa85ae24SPeter Zijlstra 	},
319cd1bb94bSArun R Bharadwaj 	{
320e9e9250bSPeter Zijlstra 		.procname	= "sched_time_avg",
321e9e9250bSPeter Zijlstra 		.data		= &sysctl_sched_time_avg,
322e9e9250bSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
323e9e9250bSPeter Zijlstra 		.mode		= 0644,
3246d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
325e9e9250bSPeter Zijlstra 	},
326e9e9250bSPeter Zijlstra 	{
327cd1bb94bSArun R Bharadwaj 		.procname	= "timer_migration",
328cd1bb94bSArun R Bharadwaj 		.data		= &sysctl_timer_migration,
329cd1bb94bSArun R Bharadwaj 		.maxlen		= sizeof(unsigned int),
330cd1bb94bSArun R Bharadwaj 		.mode		= 0644,
3316d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
332bfdb4d9fSArun R Bharadwaj 		.extra1		= &zero,
333bfdb4d9fSArun R Bharadwaj 		.extra2		= &one,
334cd1bb94bSArun R Bharadwaj 	},
3351fc84aaaSPeter Zijlstra #endif
3361799e35dSIngo Molnar 	{
3379f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
3389f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
3399f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3409f0c1e56SPeter Zijlstra 		.mode		= 0644,
3416d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
3429f0c1e56SPeter Zijlstra 	},
3439f0c1e56SPeter Zijlstra 	{
3449f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
3459f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
3469f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
3479f0c1e56SPeter Zijlstra 		.mode		= 0644,
3486d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
3499f0c1e56SPeter Zijlstra 	},
3509f0c1e56SPeter Zijlstra 	{
3511799e35dSIngo Molnar 		.procname	= "sched_compat_yield",
3521799e35dSIngo Molnar 		.data		= &sysctl_sched_compat_yield,
3531799e35dSIngo Molnar 		.maxlen		= sizeof(unsigned int),
3541799e35dSIngo Molnar 		.mode		= 0644,
3556d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3561799e35dSIngo Molnar 	},
357f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
358f20786ffSPeter Zijlstra 	{
359f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
360f20786ffSPeter Zijlstra 		.data		= &prove_locking,
361f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
362f20786ffSPeter Zijlstra 		.mode		= 0644,
3636d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
364f20786ffSPeter Zijlstra 	},
365f20786ffSPeter Zijlstra #endif
366f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
367f20786ffSPeter Zijlstra 	{
368f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
369f20786ffSPeter Zijlstra 		.data		= &lock_stat,
370f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
371f20786ffSPeter Zijlstra 		.mode		= 0644,
3726d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
373f20786ffSPeter Zijlstra 	},
374f20786ffSPeter Zijlstra #endif
37577e54a1fSIngo Molnar 	{
3761da177e4SLinus Torvalds 		.procname	= "panic",
3771da177e4SLinus Torvalds 		.data		= &panic_timeout,
3781da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
3791da177e4SLinus Torvalds 		.mode		= 0644,
3806d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3811da177e4SLinus Torvalds 	},
3821da177e4SLinus Torvalds 	{
3831da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
3841da177e4SLinus Torvalds 		.data		= &core_uses_pid,
3851da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
3861da177e4SLinus Torvalds 		.mode		= 0644,
3876d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3881da177e4SLinus Torvalds 	},
3891da177e4SLinus Torvalds 	{
3901da177e4SLinus Torvalds 		.procname	= "core_pattern",
3911da177e4SLinus Torvalds 		.data		= core_pattern,
39271ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
3931da177e4SLinus Torvalds 		.mode		= 0644,
3946d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
3951da177e4SLinus Torvalds 	},
396a293980cSNeil Horman 	{
397a293980cSNeil Horman 		.procname	= "core_pipe_limit",
398a293980cSNeil Horman 		.data		= &core_pipe_limit,
399a293980cSNeil Horman 		.maxlen		= sizeof(unsigned int),
400a293980cSNeil Horman 		.mode		= 0644,
4016d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
402a293980cSNeil Horman 	},
40334f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
4041da177e4SLinus Torvalds 	{
4051da177e4SLinus Torvalds 		.procname	= "tainted",
40625ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
40734f5a398STheodore Ts'o 		.mode		= 0644,
4086d456111SEric W. Biederman 		.proc_handler	= proc_taint,
4091da177e4SLinus Torvalds 	},
41034f5a398STheodore Ts'o #endif
4119745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
4129745512cSArjan van de Ven 	{
4139745512cSArjan van de Ven 		.procname	= "latencytop",
4149745512cSArjan van de Ven 		.data		= &latencytop_enabled,
4159745512cSArjan van de Ven 		.maxlen		= sizeof(int),
4169745512cSArjan van de Ven 		.mode		= 0644,
4176d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4189745512cSArjan van de Ven 	},
4199745512cSArjan van de Ven #endif
4201da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
4211da177e4SLinus Torvalds 	{
4221da177e4SLinus Torvalds 		.procname	= "real-root-dev",
4231da177e4SLinus Torvalds 		.data		= &real_root_dev,
4241da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4251da177e4SLinus Torvalds 		.mode		= 0644,
4266d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4271da177e4SLinus Torvalds 	},
4281da177e4SLinus Torvalds #endif
42945807a1dSIngo Molnar 	{
43045807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
43145807a1dSIngo Molnar 		.data		= &print_fatal_signals,
43245807a1dSIngo Molnar 		.maxlen		= sizeof(int),
43345807a1dSIngo Molnar 		.mode		= 0644,
4346d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
43545807a1dSIngo Molnar 	},
43672c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
4371da177e4SLinus Torvalds 	{
4381da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
4391da177e4SLinus Torvalds 		.data		= reboot_command,
4401da177e4SLinus Torvalds 		.maxlen		= 256,
4411da177e4SLinus Torvalds 		.mode		= 0644,
4426d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
4431da177e4SLinus Torvalds 	},
4441da177e4SLinus Torvalds 	{
4451da177e4SLinus Torvalds 		.procname	= "stop-a",
4461da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
4471da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4481da177e4SLinus Torvalds 		.mode		= 0644,
4496d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4501da177e4SLinus Torvalds 	},
4511da177e4SLinus Torvalds 	{
4521da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
4531da177e4SLinus Torvalds 		.data		= &scons_pwroff,
4541da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4551da177e4SLinus Torvalds 		.mode		= 0644,
4566d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4571da177e4SLinus Torvalds 	},
4581da177e4SLinus Torvalds #endif
4590871420fSDavid S. Miller #ifdef CONFIG_SPARC64
4600871420fSDavid S. Miller 	{
4610871420fSDavid S. Miller 		.procname	= "tsb-ratio",
4620871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
4630871420fSDavid S. Miller 		.maxlen		= sizeof (int),
4640871420fSDavid S. Miller 		.mode		= 0644,
4656d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4660871420fSDavid S. Miller 	},
4670871420fSDavid S. Miller #endif
4681da177e4SLinus Torvalds #ifdef __hppa__
4691da177e4SLinus Torvalds 	{
4701da177e4SLinus Torvalds 		.procname	= "soft-power",
4711da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
4721da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4731da177e4SLinus Torvalds 	 	.mode		= 0644,
4746d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4751da177e4SLinus Torvalds 	},
4761da177e4SLinus Torvalds 	{
4771da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
4781da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
4791da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4801da177e4SLinus Torvalds 		.mode		= 0644,
4816d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4821da177e4SLinus Torvalds 	},
4831da177e4SLinus Torvalds #endif
4841da177e4SLinus Torvalds 	{
4851da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
4861da177e4SLinus Torvalds 		.data		= &C_A_D,
4871da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4881da177e4SLinus Torvalds 		.mode		= 0644,
4896d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4901da177e4SLinus Torvalds 	},
491606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
492b0fc494fSSteven Rostedt 	{
493b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
494b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
495b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
496b0fc494fSSteven Rostedt 		.mode		= 0644,
4976d456111SEric W. Biederman 		.proc_handler	= ftrace_enable_sysctl,
498b0fc494fSSteven Rostedt 	},
499b0fc494fSSteven Rostedt #endif
500f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
501f38f1d2aSSteven Rostedt 	{
502f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
503f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
504f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
505f38f1d2aSSteven Rostedt 		.mode		= 0644,
5066d456111SEric W. Biederman 		.proc_handler	= stack_trace_sysctl,
507f38f1d2aSSteven Rostedt 	},
508f38f1d2aSSteven Rostedt #endif
509944ac425SSteven Rostedt #ifdef CONFIG_TRACING
510944ac425SSteven Rostedt 	{
5113299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
512944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
513944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
514944ac425SSteven Rostedt 		.mode		= 0644,
5156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
516944ac425SSteven Rostedt 	},
517944ac425SSteven Rostedt #endif
518a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
5191da177e4SLinus Torvalds 	{
5201da177e4SLinus Torvalds 		.procname	= "modprobe",
5211da177e4SLinus Torvalds 		.data		= &modprobe_path,
5221da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
5231da177e4SLinus Torvalds 		.mode		= 0644,
5246d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
5251da177e4SLinus Torvalds 	},
5263d43321bSKees Cook 	{
5273d43321bSKees Cook 		.procname	= "modules_disabled",
5283d43321bSKees Cook 		.data		= &modules_disabled,
5293d43321bSKees Cook 		.maxlen		= sizeof(int),
5303d43321bSKees Cook 		.mode		= 0644,
5313d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
5326d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
5333d43321bSKees Cook 		.extra1		= &one,
5343d43321bSKees Cook 		.extra2		= &one,
5353d43321bSKees Cook 	},
5361da177e4SLinus Torvalds #endif
53757ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
5381da177e4SLinus Torvalds 	{
5391da177e4SLinus Torvalds 		.procname	= "hotplug",
540312c004dSKay Sievers 		.data		= &uevent_helper,
541312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
5421da177e4SLinus Torvalds 		.mode		= 0644,
5436d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
5441da177e4SLinus Torvalds 	},
5451da177e4SLinus Torvalds #endif
5461da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
5471da177e4SLinus Torvalds 	{
5481da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
5491da177e4SLinus Torvalds 		.data		= &sg_big_buff,
5501da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5511da177e4SLinus Torvalds 		.mode		= 0444,
5526d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5531da177e4SLinus Torvalds 	},
5541da177e4SLinus Torvalds #endif
5551da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
5561da177e4SLinus Torvalds 	{
5571da177e4SLinus Torvalds 		.procname	= "acct",
5581da177e4SLinus Torvalds 		.data		= &acct_parm,
5591da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
5601da177e4SLinus Torvalds 		.mode		= 0644,
5616d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5621da177e4SLinus Torvalds 	},
5631da177e4SLinus Torvalds #endif
5641da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
5651da177e4SLinus Torvalds 	{
5661da177e4SLinus Torvalds 		.procname	= "sysrq",
5675d6f647fSIngo Molnar 		.data		= &__sysrq_enabled,
5681da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5691da177e4SLinus Torvalds 		.mode		= 0644,
5706d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5711da177e4SLinus Torvalds 	},
5721da177e4SLinus Torvalds #endif
573d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
5741da177e4SLinus Torvalds 	{
5751da177e4SLinus Torvalds 		.procname	= "cad_pid",
5769ec52099SCedric Le Goater 		.data		= NULL,
5771da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5781da177e4SLinus Torvalds 		.mode		= 0600,
5796d456111SEric W. Biederman 		.proc_handler	= proc_do_cad_pid,
5801da177e4SLinus Torvalds 	},
581d6f8ff73SRandy Dunlap #endif
5821da177e4SLinus Torvalds 	{
5831da177e4SLinus Torvalds 		.procname	= "threads-max",
5841da177e4SLinus Torvalds 		.data		= &max_threads,
5851da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5861da177e4SLinus Torvalds 		.mode		= 0644,
5876d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5881da177e4SLinus Torvalds 	},
5891da177e4SLinus Torvalds 	{
5901da177e4SLinus Torvalds 		.procname	= "random",
5911da177e4SLinus Torvalds 		.mode		= 0555,
5921da177e4SLinus Torvalds 		.child		= random_table,
5931da177e4SLinus Torvalds 	},
5941da177e4SLinus Torvalds 	{
5951da177e4SLinus Torvalds 		.procname	= "overflowuid",
5961da177e4SLinus Torvalds 		.data		= &overflowuid,
5971da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5981da177e4SLinus Torvalds 		.mode		= 0644,
5996d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6001da177e4SLinus Torvalds 		.extra1		= &minolduid,
6011da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6021da177e4SLinus Torvalds 	},
6031da177e4SLinus Torvalds 	{
6041da177e4SLinus Torvalds 		.procname	= "overflowgid",
6051da177e4SLinus Torvalds 		.data		= &overflowgid,
6061da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6071da177e4SLinus Torvalds 		.mode		= 0644,
6086d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6091da177e4SLinus Torvalds 		.extra1		= &minolduid,
6101da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6111da177e4SLinus Torvalds 	},
612347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
6131da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
6141da177e4SLinus Torvalds 	{
6151da177e4SLinus Torvalds 		.procname	= "ieee_emulation_warnings",
6161da177e4SLinus Torvalds 		.data		= &sysctl_ieee_emulation_warnings,
6171da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6181da177e4SLinus Torvalds 		.mode		= 0644,
6196d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6201da177e4SLinus Torvalds 	},
6211da177e4SLinus Torvalds #endif
6221da177e4SLinus Torvalds 	{
6231da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
624*ab3c68eeSHeiko Carstens 		.data		= &show_unhandled_signals,
6251da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6261da177e4SLinus Torvalds 		.mode		= 0644,
6276d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6281da177e4SLinus Torvalds 	},
6291da177e4SLinus Torvalds #endif
6301da177e4SLinus Torvalds 	{
6311da177e4SLinus Torvalds 		.procname	= "pid_max",
6321da177e4SLinus Torvalds 		.data		= &pid_max,
6331da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6341da177e4SLinus Torvalds 		.mode		= 0644,
6356d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6361da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
6371da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
6381da177e4SLinus Torvalds 	},
6391da177e4SLinus Torvalds 	{
6401da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
6411da177e4SLinus Torvalds 		.data		= &panic_on_oops,
6421da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6431da177e4SLinus Torvalds 		.mode		= 0644,
6446d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6451da177e4SLinus Torvalds 	},
6467ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
6477ef3d2fdSJoe Perches 	{
6487ef3d2fdSJoe Perches 		.procname	= "printk",
6497ef3d2fdSJoe Perches 		.data		= &console_loglevel,
6507ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
6517ef3d2fdSJoe Perches 		.mode		= 0644,
6526d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6537ef3d2fdSJoe Perches 	},
6541da177e4SLinus Torvalds 	{
6551da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
656717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
6571da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6581da177e4SLinus Torvalds 		.mode		= 0644,
6596d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
6601da177e4SLinus Torvalds 	},
6611da177e4SLinus Torvalds 	{
6621da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
663717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
6641da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6651da177e4SLinus Torvalds 		.mode		= 0644,
6666d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6671da177e4SLinus Torvalds 	},
668af91322eSDave Young 	{
669af91322eSDave Young 		.procname	= "printk_delay",
670af91322eSDave Young 		.data		= &printk_delay_msec,
671af91322eSDave Young 		.maxlen		= sizeof(int),
672af91322eSDave Young 		.mode		= 0644,
6736d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
674af91322eSDave Young 		.extra1		= &zero,
675af91322eSDave Young 		.extra2		= &ten_thousand,
676af91322eSDave Young 	},
6777ef3d2fdSJoe Perches #endif
6781da177e4SLinus Torvalds 	{
6791da177e4SLinus Torvalds 		.procname	= "ngroups_max",
6801da177e4SLinus Torvalds 		.data		= &ngroups_max,
6811da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6821da177e4SLinus Torvalds 		.mode		= 0444,
6836d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6841da177e4SLinus Torvalds 	},
6851da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
6861da177e4SLinus Torvalds 	{
6871da177e4SLinus Torvalds 		.procname       = "unknown_nmi_panic",
6881da177e4SLinus Torvalds 		.data           = &unknown_nmi_panic,
6891da177e4SLinus Torvalds 		.maxlen         = sizeof (int),
6901da177e4SLinus Torvalds 		.mode           = 0644,
6916d456111SEric W. Biederman 		.proc_handler   = proc_dointvec,
6921da177e4SLinus Torvalds 	},
693407984f1SDon Zickus 	{
694407984f1SDon Zickus 		.procname       = "nmi_watchdog",
695407984f1SDon Zickus 		.data           = &nmi_watchdog_enabled,
696407984f1SDon Zickus 		.maxlen         = sizeof (int),
697407984f1SDon Zickus 		.mode           = 0644,
6986d456111SEric W. Biederman 		.proc_handler   = proc_nmi_enabled,
6991da177e4SLinus Torvalds 	},
7001da177e4SLinus Torvalds #endif
7011da177e4SLinus Torvalds #if defined(CONFIG_X86)
7021da177e4SLinus Torvalds 	{
7038da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
7048da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
7058da5addaSDon Zickus 		.maxlen		= sizeof(int),
7068da5addaSDon Zickus 		.mode		= 0644,
7076d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7088da5addaSDon Zickus 	},
7098da5addaSDon Zickus 	{
7105211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
7115211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
7125211a242SKurt Garloff 		.maxlen		= sizeof(int),
7135211a242SKurt Garloff 		.mode		= 0644,
7146d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7155211a242SKurt Garloff 	},
7165211a242SKurt Garloff 	{
7171da177e4SLinus Torvalds 		.procname	= "bootloader_type",
7181da177e4SLinus Torvalds 		.data		= &bootloader_type,
7191da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7201da177e4SLinus Torvalds 		.mode		= 0444,
7216d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7221da177e4SLinus Torvalds 	},
7230741f4d2SChuck Ebbert 	{
7245031296cSH. Peter Anvin 		.procname	= "bootloader_version",
7255031296cSH. Peter Anvin 		.data		= &bootloader_version,
7265031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
7275031296cSH. Peter Anvin 		.mode		= 0444,
7286d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7295031296cSH. Peter Anvin 	},
7305031296cSH. Peter Anvin 	{
7310741f4d2SChuck Ebbert 		.procname	= "kstack_depth_to_print",
7320741f4d2SChuck Ebbert 		.data		= &kstack_depth_to_print,
7330741f4d2SChuck Ebbert 		.maxlen		= sizeof(int),
7340741f4d2SChuck Ebbert 		.mode		= 0644,
7356d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7360741f4d2SChuck Ebbert 	},
7376e7c4025SIngo Molnar 	{
7386e7c4025SIngo Molnar 		.procname	= "io_delay_type",
7396e7c4025SIngo Molnar 		.data		= &io_delay_type,
7406e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
7416e7c4025SIngo Molnar 		.mode		= 0644,
7426d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7436e7c4025SIngo Molnar 	},
7441da177e4SLinus Torvalds #endif
7457a9166e3SLuke Yang #if defined(CONFIG_MMU)
7461da177e4SLinus Torvalds 	{
7471da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
7481da177e4SLinus Torvalds 		.data		= &randomize_va_space,
7491da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7501da177e4SLinus Torvalds 		.mode		= 0644,
7516d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7521da177e4SLinus Torvalds 	},
7537a9166e3SLuke Yang #endif
7540152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
755951f22d5SMartin Schwidefsky 	{
756951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
757951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
758951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
759951f22d5SMartin Schwidefsky 		.mode		= 0644,
7606d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
761951f22d5SMartin Schwidefsky 	},
762951f22d5SMartin Schwidefsky #endif
763673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
764c255d844SPavel Machek 	{
765c255d844SPavel Machek 		.procname	= "acpi_video_flags",
76677afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
767c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
768c255d844SPavel Machek 		.mode		= 0644,
7696d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
770c255d844SPavel Machek 	},
771c255d844SPavel Machek #endif
772d2b176edSJes Sorensen #ifdef CONFIG_IA64
773d2b176edSJes Sorensen 	{
774d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
775d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
776d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
777d2b176edSJes Sorensen 	 	.mode		= 0644,
7786d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
779d2b176edSJes Sorensen 	},
78088fc241fSDoug Chapman 	{
78188fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
78288fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
78388fc241fSDoug Chapman 		.maxlen		= sizeof (int),
78488fc241fSDoug Chapman 		.mode		= 0644,
7856d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
78688fc241fSDoug Chapman 	},
787d2b176edSJes Sorensen #endif
788c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP
789c4f3b63fSRavikiran G Thirumalai 	{
7909c44bc03SIngo Molnar 		.procname	= "softlockup_panic",
7919c44bc03SIngo Molnar 		.data		= &softlockup_panic,
7929c44bc03SIngo Molnar 		.maxlen		= sizeof(int),
7939c44bc03SIngo Molnar 		.mode		= 0644,
7946d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
7959c44bc03SIngo Molnar 		.extra1		= &zero,
7969c44bc03SIngo Molnar 		.extra2		= &one,
7979c44bc03SIngo Molnar 	},
7989c44bc03SIngo Molnar 	{
799c4f3b63fSRavikiran G Thirumalai 		.procname	= "softlockup_thresh",
800c4f3b63fSRavikiran G Thirumalai 		.data		= &softlockup_thresh,
8019383d967SDimitri Sivanich 		.maxlen		= sizeof(int),
802c4f3b63fSRavikiran G Thirumalai 		.mode		= 0644,
8036d456111SEric W. Biederman 		.proc_handler	= proc_dosoftlockup_thresh,
8049383d967SDimitri Sivanich 		.extra1		= &neg_one,
805c4f3b63fSRavikiran G Thirumalai 		.extra2		= &sixty,
806c4f3b63fSRavikiran G Thirumalai 	},
807e162b39aSMandeep Singh Baines #endif
808e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
809e162b39aSMandeep Singh Baines 	{
810e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
811e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
812e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
813e162b39aSMandeep Singh Baines 		.mode		= 0644,
8146d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
815e162b39aSMandeep Singh Baines 		.extra1		= &zero,
816e162b39aSMandeep Singh Baines 		.extra2		= &one,
817e162b39aSMandeep Singh Baines 	},
81882a1fcb9SIngo Molnar 	{
81982a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
82082a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
82190739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
82282a1fcb9SIngo Molnar 		.mode		= 0644,
8236d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
82482a1fcb9SIngo Molnar 	},
82582a1fcb9SIngo Molnar 	{
82682a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
82782a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
82890739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
82982a1fcb9SIngo Molnar 		.mode		= 0644,
8306d456111SEric W. Biederman 		.proc_handler	= proc_dohung_task_timeout_secs,
83182a1fcb9SIngo Molnar 	},
83282a1fcb9SIngo Molnar 	{
83382a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
83482a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
83590739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
83682a1fcb9SIngo Molnar 		.mode		= 0644,
8376d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
83882a1fcb9SIngo Molnar 	},
839c4f3b63fSRavikiran G Thirumalai #endif
840bebfa101SAndi Kleen #ifdef CONFIG_COMPAT
841bebfa101SAndi Kleen 	{
842bebfa101SAndi Kleen 		.procname	= "compat-log",
843bebfa101SAndi Kleen 		.data		= &compat_log,
844bebfa101SAndi Kleen 		.maxlen		= sizeof (int),
845bebfa101SAndi Kleen 	 	.mode		= 0644,
8466d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
847bebfa101SAndi Kleen 	},
848bebfa101SAndi Kleen #endif
84923f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
85023f78d4aSIngo Molnar 	{
85123f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
85223f78d4aSIngo Molnar 		.data		= &max_lock_depth,
85323f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
85423f78d4aSIngo Molnar 		.mode		= 0644,
8556d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
85623f78d4aSIngo Molnar 	},
85723f78d4aSIngo Molnar #endif
85810a0a8d4SJeremy Fitzhardinge 	{
85910a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
86010a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
86110a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
86210a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
8636d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
86410a0a8d4SJeremy Fitzhardinge 	},
8650b77f5bfSDavid Howells #ifdef CONFIG_KEYS
8660b77f5bfSDavid Howells 	{
8670b77f5bfSDavid Howells 		.procname	= "keys",
8680b77f5bfSDavid Howells 		.mode		= 0555,
8690b77f5bfSDavid Howells 		.child		= key_sysctls,
8700b77f5bfSDavid Howells 	},
8710b77f5bfSDavid Howells #endif
87231a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
87331a72bceSPaul E. McKenney 	{
87431a72bceSPaul E. McKenney 		.procname       = "rcutorture_runnable",
87531a72bceSPaul E. McKenney 		.data           = &rcutorture_runnable,
87631a72bceSPaul E. McKenney 		.maxlen         = sizeof(int),
87731a72bceSPaul E. McKenney 		.mode           = 0644,
8786d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
87931a72bceSPaul E. McKenney 	},
88031a72bceSPaul E. McKenney #endif
88112e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK
88212e22c5eSDavid Howells 	{
88312e22c5eSDavid Howells 		.procname	= "slow-work",
88412e22c5eSDavid Howells 		.mode		= 0555,
88512e22c5eSDavid Howells 		.child		= slow_work_sysctls,
88612e22c5eSDavid Howells 	},
88712e22c5eSDavid Howells #endif
888cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS
8891ccd1549SPeter Zijlstra 	{
890cdd6c482SIngo Molnar 		.procname	= "perf_event_paranoid",
891cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_paranoid,
892cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_paranoid),
8931ccd1549SPeter Zijlstra 		.mode		= 0644,
8946d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
8951ccd1549SPeter Zijlstra 	},
896c5078f78SPeter Zijlstra 	{
897cdd6c482SIngo Molnar 		.procname	= "perf_event_mlock_kb",
898cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_mlock,
899cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_mlock),
900c5078f78SPeter Zijlstra 		.mode		= 0644,
9016d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
902c5078f78SPeter Zijlstra 	},
903a78ac325SPeter Zijlstra 	{
904cdd6c482SIngo Molnar 		.procname	= "perf_event_max_sample_rate",
905cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_sample_rate,
906cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
907a78ac325SPeter Zijlstra 		.mode		= 0644,
9086d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
909a78ac325SPeter Zijlstra 	},
9101ccd1549SPeter Zijlstra #endif
911dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK
912dfec072eSVegard Nossum 	{
913dfec072eSVegard Nossum 		.procname	= "kmemcheck",
914dfec072eSVegard Nossum 		.data		= &kmemcheck_enabled,
915dfec072eSVegard Nossum 		.maxlen		= sizeof(int),
916dfec072eSVegard Nossum 		.mode		= 0644,
9176d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
918dfec072eSVegard Nossum 	},
919dfec072eSVegard Nossum #endif
920cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
9215e605b64SJens Axboe 	{
9225e605b64SJens Axboe 		.procname	= "blk_iopoll",
9235e605b64SJens Axboe 		.data		= &blk_iopoll_enabled,
9245e605b64SJens Axboe 		.maxlen		= sizeof(int),
9255e605b64SJens Axboe 		.mode		= 0644,
9266d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9275e605b64SJens Axboe 	},
928cb684b5bSJens Axboe #endif
929ed2c12f3SAndrew Morton /*
930ed2c12f3SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
931ed2c12f3SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
932ed2c12f3SAndrew Morton  */
9336fce56ecSEric W. Biederman 	{ }
9341da177e4SLinus Torvalds };
9351da177e4SLinus Torvalds 
936d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
9371da177e4SLinus Torvalds 	{
9381da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
9391da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
9401da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
9411da177e4SLinus Torvalds 		.mode		= 0644,
9426d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9431da177e4SLinus Torvalds 	},
9441da177e4SLinus Torvalds 	{
945fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
946fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
947fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
948fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
9496d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
950fadd8fbdSKAMEZAWA Hiroyuki 	},
951fadd8fbdSKAMEZAWA Hiroyuki 	{
952fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
953fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
954fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
955fe071d7eSDavid Rientjes 		.mode		= 0644,
9566d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
957fe071d7eSDavid Rientjes 	},
958fe071d7eSDavid Rientjes 	{
959fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
960fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
961fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
962fef1bdd6SDavid Rientjes 		.mode		= 0644,
9636d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
964fef1bdd6SDavid Rientjes 	},
965fef1bdd6SDavid Rientjes 	{
9661da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
9671da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
9681da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
9691da177e4SLinus Torvalds 		.mode		= 0644,
9706d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9711da177e4SLinus Torvalds 	},
9721da177e4SLinus Torvalds 	{
9731da177e4SLinus Torvalds 		.procname	= "page-cluster",
9741da177e4SLinus Torvalds 		.data		= &page_cluster,
9751da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
9761da177e4SLinus Torvalds 		.mode		= 0644,
9776d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9781da177e4SLinus Torvalds 	},
9791da177e4SLinus Torvalds 	{
9801da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
9811da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
9821da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
9831da177e4SLinus Torvalds 		.mode		= 0644,
9846d456111SEric W. Biederman 		.proc_handler	= dirty_background_ratio_handler,
9851da177e4SLinus Torvalds 		.extra1		= &zero,
9861da177e4SLinus Torvalds 		.extra2		= &one_hundred,
9871da177e4SLinus Torvalds 	},
9881da177e4SLinus Torvalds 	{
9892da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
9902da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
9912da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
9922da02997SDavid Rientjes 		.mode		= 0644,
9936d456111SEric W. Biederman 		.proc_handler	= dirty_background_bytes_handler,
994fc3501d4SSven Wegener 		.extra1		= &one_ul,
9952da02997SDavid Rientjes 	},
9962da02997SDavid Rientjes 	{
9971da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
9981da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
9991da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
10001da177e4SLinus Torvalds 		.mode		= 0644,
10016d456111SEric W. Biederman 		.proc_handler	= dirty_ratio_handler,
10021da177e4SLinus Torvalds 		.extra1		= &zero,
10031da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10041da177e4SLinus Torvalds 	},
10051da177e4SLinus Torvalds 	{
10062da02997SDavid Rientjes 		.procname	= "dirty_bytes",
10072da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
10082da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
10092da02997SDavid Rientjes 		.mode		= 0644,
10106d456111SEric W. Biederman 		.proc_handler	= dirty_bytes_handler,
10119e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
10122da02997SDavid Rientjes 	},
10132da02997SDavid Rientjes 	{
10141da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
1015f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
1016f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
10171da177e4SLinus Torvalds 		.mode		= 0644,
10186d456111SEric W. Biederman 		.proc_handler	= dirty_writeback_centisecs_handler,
10191da177e4SLinus Torvalds 	},
10201da177e4SLinus Torvalds 	{
10211da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
1022f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
1023f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
10241da177e4SLinus Torvalds 		.mode		= 0644,
10256d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10261da177e4SLinus Torvalds 	},
10271da177e4SLinus Torvalds 	{
10281da177e4SLinus Torvalds 		.procname	= "nr_pdflush_threads",
10291da177e4SLinus Torvalds 		.data		= &nr_pdflush_threads,
10301da177e4SLinus Torvalds 		.maxlen		= sizeof nr_pdflush_threads,
10311da177e4SLinus Torvalds 		.mode		= 0444 /* read-only*/,
10326d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10331da177e4SLinus Torvalds 	},
10341da177e4SLinus Torvalds 	{
10351da177e4SLinus Torvalds 		.procname	= "swappiness",
10361da177e4SLinus Torvalds 		.data		= &vm_swappiness,
10371da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
10381da177e4SLinus Torvalds 		.mode		= 0644,
10396d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
10401da177e4SLinus Torvalds 		.extra1		= &zero,
10411da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10421da177e4SLinus Torvalds 	},
10431da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
10441da177e4SLinus Torvalds 	{
10451da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
1046e5ff2159SAndi Kleen 		.data		= NULL,
10471da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
10481da177e4SLinus Torvalds 		.mode		= 0644,
10496d456111SEric W. Biederman 		.proc_handler	= hugetlb_sysctl_handler,
10501da177e4SLinus Torvalds 		.extra1		= (void *)&hugetlb_zero,
10511da177e4SLinus Torvalds 		.extra2		= (void *)&hugetlb_infinity,
10521da177e4SLinus Torvalds 	},
105306808b08SLee Schermerhorn #ifdef CONFIG_NUMA
105406808b08SLee Schermerhorn 	{
105506808b08SLee Schermerhorn 		.procname       = "nr_hugepages_mempolicy",
105606808b08SLee Schermerhorn 		.data           = NULL,
105706808b08SLee Schermerhorn 		.maxlen         = sizeof(unsigned long),
105806808b08SLee Schermerhorn 		.mode           = 0644,
105906808b08SLee Schermerhorn 		.proc_handler   = &hugetlb_mempolicy_sysctl_handler,
106006808b08SLee Schermerhorn 		.extra1		= (void *)&hugetlb_zero,
106106808b08SLee Schermerhorn 		.extra2		= (void *)&hugetlb_infinity,
106206808b08SLee Schermerhorn 	},
106306808b08SLee Schermerhorn #endif
10641da177e4SLinus Torvalds 	 {
10651da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
10661da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
10671da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
10681da177e4SLinus Torvalds 		.mode		= 0644,
10696d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10701da177e4SLinus Torvalds 	 },
1071396faf03SMel Gorman 	 {
1072396faf03SMel Gorman 		.procname	= "hugepages_treat_as_movable",
1073396faf03SMel Gorman 		.data		= &hugepages_treat_as_movable,
1074396faf03SMel Gorman 		.maxlen		= sizeof(int),
1075396faf03SMel Gorman 		.mode		= 0644,
10766d456111SEric W. Biederman 		.proc_handler	= hugetlb_treat_movable_handler,
1077396faf03SMel Gorman 	},
107854f9f80dSAdam Litke 	{
1079d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
1080e5ff2159SAndi Kleen 		.data		= NULL,
1081e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
1082d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
10836d456111SEric W. Biederman 		.proc_handler	= hugetlb_overcommit_handler,
1084e5ff2159SAndi Kleen 		.extra1		= (void *)&hugetlb_zero,
1085e5ff2159SAndi Kleen 		.extra2		= (void *)&hugetlb_infinity,
1086d1c3fb1fSNishanth Aravamudan 	},
10871da177e4SLinus Torvalds #endif
10881da177e4SLinus Torvalds 	{
10891da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
10901da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
10911da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
10921da177e4SLinus Torvalds 		.mode		= 0644,
10936d456111SEric W. Biederman 		.proc_handler	= lowmem_reserve_ratio_sysctl_handler,
10941da177e4SLinus Torvalds 	},
10951da177e4SLinus Torvalds 	{
10969d0243bcSAndrew Morton 		.procname	= "drop_caches",
10979d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
10989d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
10999d0243bcSAndrew Morton 		.mode		= 0644,
11009d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
11019d0243bcSAndrew Morton 	},
11029d0243bcSAndrew Morton 	{
11031da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
11041da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
11051da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
11061da177e4SLinus Torvalds 		.mode		= 0644,
11076d456111SEric W. Biederman 		.proc_handler	= min_free_kbytes_sysctl_handler,
11081da177e4SLinus Torvalds 		.extra1		= &zero,
11091da177e4SLinus Torvalds 	},
11108ad4b1fbSRohit Seth 	{
11118ad4b1fbSRohit Seth 		.procname	= "percpu_pagelist_fraction",
11128ad4b1fbSRohit Seth 		.data		= &percpu_pagelist_fraction,
11138ad4b1fbSRohit Seth 		.maxlen		= sizeof(percpu_pagelist_fraction),
11148ad4b1fbSRohit Seth 		.mode		= 0644,
11156d456111SEric W. Biederman 		.proc_handler	= percpu_pagelist_fraction_sysctl_handler,
11168ad4b1fbSRohit Seth 		.extra1		= &min_percpu_pagelist_fract,
11178ad4b1fbSRohit Seth 	},
11181da177e4SLinus Torvalds #ifdef CONFIG_MMU
11191da177e4SLinus Torvalds 	{
11201da177e4SLinus Torvalds 		.procname	= "max_map_count",
11211da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
11221da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
11231da177e4SLinus Torvalds 		.mode		= 0644,
11243e26120cSWANG Cong 		.proc_handler	= proc_dointvec_minmax,
112570da2340SAmerigo Wang 		.extra1		= &zero,
11261da177e4SLinus Torvalds 	},
1127dd8632a1SPaul Mundt #else
1128dd8632a1SPaul Mundt 	{
1129dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
1130dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
1131dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
1132dd8632a1SPaul Mundt 		.mode		= 0644,
11336d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1134dd8632a1SPaul Mundt 		.extra1		= &zero,
1135dd8632a1SPaul Mundt 	},
11361da177e4SLinus Torvalds #endif
11371da177e4SLinus Torvalds 	{
11381da177e4SLinus Torvalds 		.procname	= "laptop_mode",
11391da177e4SLinus Torvalds 		.data		= &laptop_mode,
11401da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
11411da177e4SLinus Torvalds 		.mode		= 0644,
11426d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
11431da177e4SLinus Torvalds 	},
11441da177e4SLinus Torvalds 	{
11451da177e4SLinus Torvalds 		.procname	= "block_dump",
11461da177e4SLinus Torvalds 		.data		= &block_dump,
11471da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
11481da177e4SLinus Torvalds 		.mode		= 0644,
11496d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
11501da177e4SLinus Torvalds 		.extra1		= &zero,
11511da177e4SLinus Torvalds 	},
11521da177e4SLinus Torvalds 	{
11531da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
11541da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
11551da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
11561da177e4SLinus Torvalds 		.mode		= 0644,
11576d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
11581da177e4SLinus Torvalds 		.extra1		= &zero,
11591da177e4SLinus Torvalds 	},
11601da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
11611da177e4SLinus Torvalds 	{
11621da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
11631da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
11641da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
11651da177e4SLinus Torvalds 		.mode		= 0644,
11666d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
11671da177e4SLinus Torvalds 		.extra1		= &zero,
11681da177e4SLinus Torvalds 	},
11691da177e4SLinus Torvalds #endif
11701743660bSChristoph Lameter #ifdef CONFIG_NUMA
11711743660bSChristoph Lameter 	{
11721743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
11731743660bSChristoph Lameter 		.data		= &zone_reclaim_mode,
11741743660bSChristoph Lameter 		.maxlen		= sizeof(zone_reclaim_mode),
11751743660bSChristoph Lameter 		.mode		= 0644,
11766d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1177c84db23cSChristoph Lameter 		.extra1		= &zero,
11781743660bSChristoph Lameter 	},
11799614634fSChristoph Lameter 	{
11809614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
11819614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
11829614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
11839614634fSChristoph Lameter 		.mode		= 0644,
11846d456111SEric W. Biederman 		.proc_handler	= sysctl_min_unmapped_ratio_sysctl_handler,
11859614634fSChristoph Lameter 		.extra1		= &zero,
11869614634fSChristoph Lameter 		.extra2		= &one_hundred,
11879614634fSChristoph Lameter 	},
11880ff38490SChristoph Lameter 	{
11890ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
11900ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
11910ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
11920ff38490SChristoph Lameter 		.mode		= 0644,
11936d456111SEric W. Biederman 		.proc_handler	= sysctl_min_slab_ratio_sysctl_handler,
11940ff38490SChristoph Lameter 		.extra1		= &zero,
11950ff38490SChristoph Lameter 		.extra2		= &one_hundred,
11960ff38490SChristoph Lameter 	},
11971743660bSChristoph Lameter #endif
119877461ab3SChristoph Lameter #ifdef CONFIG_SMP
119977461ab3SChristoph Lameter 	{
120077461ab3SChristoph Lameter 		.procname	= "stat_interval",
120177461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
120277461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
120377461ab3SChristoph Lameter 		.mode		= 0644,
12046d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
120577461ab3SChristoph Lameter 	},
120677461ab3SChristoph Lameter #endif
12076e141546SDavid Howells #ifdef CONFIG_MMU
1208ed032189SEric Paris 	{
1209ed032189SEric Paris 		.procname	= "mmap_min_addr",
1210788084abSEric Paris 		.data		= &dac_mmap_min_addr,
1211ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
1212ed032189SEric Paris 		.mode		= 0644,
12136d456111SEric W. Biederman 		.proc_handler	= mmap_min_addr_handler,
1214ed032189SEric Paris 	},
12156e141546SDavid Howells #endif
1216f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
1217f0c0b2b8SKAMEZAWA Hiroyuki 	{
1218f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
1219f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
1220f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
1221f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
12226d456111SEric W. Biederman 		.proc_handler	= numa_zonelist_order_handler,
1223f0c0b2b8SKAMEZAWA Hiroyuki 	},
1224f0c0b2b8SKAMEZAWA Hiroyuki #endif
12252b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
12265c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1227e6e5494cSIngo Molnar 	{
1228e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
1229e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
1230e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
1231e6e5494cSIngo Molnar 		.mode		= 0644,
12326d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1233e6e5494cSIngo Molnar 		.extra1		= &zero,
1234e6e5494cSIngo Molnar 	},
1235e6e5494cSIngo Molnar #endif
1236195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
1237195cf453SBron Gondwana 	{
1238195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
1239195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
1240195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
1241195cf453SBron Gondwana 		.mode		= 0644,
12426d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1243195cf453SBron Gondwana 		.extra1		= &zero,
1244195cf453SBron Gondwana 		.extra2		= &one,
1245195cf453SBron Gondwana 	},
1246195cf453SBron Gondwana #endif
12474be6f6bbSPeter Zijlstra 	{
12484be6f6bbSPeter Zijlstra 		.procname	= "scan_unevictable_pages",
12494be6f6bbSPeter Zijlstra 		.data		= &scan_unevictable_pages,
12504be6f6bbSPeter Zijlstra 		.maxlen		= sizeof(scan_unevictable_pages),
12514be6f6bbSPeter Zijlstra 		.mode		= 0644,
12526d456111SEric W. Biederman 		.proc_handler	= scan_unevictable_handler,
12534be6f6bbSPeter Zijlstra 	},
12546a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE
12556a46079cSAndi Kleen 	{
12566a46079cSAndi Kleen 		.procname	= "memory_failure_early_kill",
12576a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_early_kill,
12586a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_early_kill),
12596a46079cSAndi Kleen 		.mode		= 0644,
12606d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
12616a46079cSAndi Kleen 		.extra1		= &zero,
12626a46079cSAndi Kleen 		.extra2		= &one,
12636a46079cSAndi Kleen 	},
12646a46079cSAndi Kleen 	{
12656a46079cSAndi Kleen 		.procname	= "memory_failure_recovery",
12666a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_recovery,
12676a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_recovery),
12686a46079cSAndi Kleen 		.mode		= 0644,
12696d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
12706a46079cSAndi Kleen 		.extra1		= &zero,
12716a46079cSAndi Kleen 		.extra2		= &one,
12726a46079cSAndi Kleen 	},
12736a46079cSAndi Kleen #endif
12746a46079cSAndi Kleen 
12752be7fe07SAndrew Morton /*
12762be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
12772be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
12782be7fe07SAndrew Morton  */
12796fce56ecSEric W. Biederman 	{ }
12801da177e4SLinus Torvalds };
12811da177e4SLinus Torvalds 
12822abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1283d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = {
12846fce56ecSEric W. Biederman 	{ }
12852abc26fcSEric W. Biederman };
12862abc26fcSEric W. Biederman #endif
12872abc26fcSEric W. Biederman 
1288d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
12891da177e4SLinus Torvalds 	{
12901da177e4SLinus Torvalds 		.procname	= "inode-nr",
12911da177e4SLinus Torvalds 		.data		= &inodes_stat,
12921da177e4SLinus Torvalds 		.maxlen		= 2*sizeof(int),
12931da177e4SLinus Torvalds 		.mode		= 0444,
12946d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
12951da177e4SLinus Torvalds 	},
12961da177e4SLinus Torvalds 	{
12971da177e4SLinus Torvalds 		.procname	= "inode-state",
12981da177e4SLinus Torvalds 		.data		= &inodes_stat,
12991da177e4SLinus Torvalds 		.maxlen		= 7*sizeof(int),
13001da177e4SLinus Torvalds 		.mode		= 0444,
13016d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13021da177e4SLinus Torvalds 	},
13031da177e4SLinus Torvalds 	{
13041da177e4SLinus Torvalds 		.procname	= "file-nr",
13051da177e4SLinus Torvalds 		.data		= &files_stat,
13061da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
13071da177e4SLinus Torvalds 		.mode		= 0444,
13086d456111SEric W. Biederman 		.proc_handler	= proc_nr_files,
13091da177e4SLinus Torvalds 	},
13101da177e4SLinus Torvalds 	{
13111da177e4SLinus Torvalds 		.procname	= "file-max",
13121da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
13131da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13141da177e4SLinus Torvalds 		.mode		= 0644,
13156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13161da177e4SLinus Torvalds 	},
13171da177e4SLinus Torvalds 	{
13189cfe015aSEric Dumazet 		.procname	= "nr_open",
13199cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
13209cfe015aSEric Dumazet 		.maxlen		= sizeof(int),
13219cfe015aSEric Dumazet 		.mode		= 0644,
13226d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1323eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
1324eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
13259cfe015aSEric Dumazet 	},
13269cfe015aSEric Dumazet 	{
13271da177e4SLinus Torvalds 		.procname	= "dentry-state",
13281da177e4SLinus Torvalds 		.data		= &dentry_stat,
13291da177e4SLinus Torvalds 		.maxlen		= 6*sizeof(int),
13301da177e4SLinus Torvalds 		.mode		= 0444,
13316d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13321da177e4SLinus Torvalds 	},
13331da177e4SLinus Torvalds 	{
13341da177e4SLinus Torvalds 		.procname	= "overflowuid",
13351da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
13361da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13371da177e4SLinus Torvalds 		.mode		= 0644,
13386d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13391da177e4SLinus Torvalds 		.extra1		= &minolduid,
13401da177e4SLinus Torvalds 		.extra2		= &maxolduid,
13411da177e4SLinus Torvalds 	},
13421da177e4SLinus Torvalds 	{
13431da177e4SLinus Torvalds 		.procname	= "overflowgid",
13441da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
13451da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13461da177e4SLinus Torvalds 		.mode		= 0644,
13476d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13481da177e4SLinus Torvalds 		.extra1		= &minolduid,
13491da177e4SLinus Torvalds 		.extra2		= &maxolduid,
13501da177e4SLinus Torvalds 	},
1351bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
13521da177e4SLinus Torvalds 	{
13531da177e4SLinus Torvalds 		.procname	= "leases-enable",
13541da177e4SLinus Torvalds 		.data		= &leases_enable,
13551da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13561da177e4SLinus Torvalds 		.mode		= 0644,
13576d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13581da177e4SLinus Torvalds 	},
1359bfcd17a6SThomas Petazzoni #endif
13601da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
13611da177e4SLinus Torvalds 	{
13621da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
13631da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
13641da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13651da177e4SLinus Torvalds 		.mode		= 0644,
13666d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13671da177e4SLinus Torvalds 	},
13681da177e4SLinus Torvalds #endif
13691da177e4SLinus Torvalds #ifdef CONFIG_MMU
1370bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
13711da177e4SLinus Torvalds 	{
13721da177e4SLinus Torvalds 		.procname	= "lease-break-time",
13731da177e4SLinus Torvalds 		.data		= &lease_break_time,
13741da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13751da177e4SLinus Torvalds 		.mode		= 0644,
13766d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13771da177e4SLinus Torvalds 	},
1378bfcd17a6SThomas Petazzoni #endif
1379ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
13801da177e4SLinus Torvalds 	{
13811da177e4SLinus Torvalds 		.procname	= "aio-nr",
13821da177e4SLinus Torvalds 		.data		= &aio_nr,
13831da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
13841da177e4SLinus Torvalds 		.mode		= 0444,
13856d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
13861da177e4SLinus Torvalds 	},
13871da177e4SLinus Torvalds 	{
13881da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
13891da177e4SLinus Torvalds 		.data		= &aio_max_nr,
13901da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
13911da177e4SLinus Torvalds 		.mode		= 0644,
13926d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
13931da177e4SLinus Torvalds 	},
1394ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
13952d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
13960399cb08SRobert Love 	{
13970399cb08SRobert Love 		.procname	= "inotify",
13980399cb08SRobert Love 		.mode		= 0555,
13990399cb08SRobert Love 		.child		= inotify_table,
14000399cb08SRobert Love 	},
14010399cb08SRobert Love #endif
14027ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
14037ef9964eSDavide Libenzi 	{
14047ef9964eSDavide Libenzi 		.procname	= "epoll",
14057ef9964eSDavide Libenzi 		.mode		= 0555,
14067ef9964eSDavide Libenzi 		.child		= epoll_table,
14077ef9964eSDavide Libenzi 	},
14087ef9964eSDavide Libenzi #endif
14091da177e4SLinus Torvalds #endif
1410d6e71144SAlan Cox 	{
1411d6e71144SAlan Cox 		.procname	= "suid_dumpable",
1412d6e71144SAlan Cox 		.data		= &suid_dumpable,
1413d6e71144SAlan Cox 		.maxlen		= sizeof(int),
1414d6e71144SAlan Cox 		.mode		= 0644,
14156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
14168e654fbaSMatthew Wilcox 		.extra1		= &zero,
14178e654fbaSMatthew Wilcox 		.extra2		= &two,
1418d6e71144SAlan Cox 	},
14192abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
14202abc26fcSEric W. Biederman 	{
14212abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
14222abc26fcSEric W. Biederman 		.mode		= 0555,
14232abc26fcSEric W. Biederman 		.child		= binfmt_misc_table,
14242abc26fcSEric W. Biederman 	},
14252abc26fcSEric W. Biederman #endif
14262be7fe07SAndrew Morton /*
14272be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
14282be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
14292be7fe07SAndrew Morton  */
14306fce56ecSEric W. Biederman 	{ }
14311da177e4SLinus Torvalds };
14321da177e4SLinus Torvalds 
1433d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
1434*ab3c68eeSHeiko Carstens #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \
1435*ab3c68eeSHeiko Carstens     defined(CONFIG_S390)
1436abd4f750SMasoud Asgharifard Sharbiani 	{
1437abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
1438abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
1439abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
1440abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
1441abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
1442abd4f750SMasoud Asgharifard Sharbiani 	},
1443abd4f750SMasoud Asgharifard Sharbiani #endif
1444b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES)
1445b2be84dfSMasami Hiramatsu 	{
1446b2be84dfSMasami Hiramatsu 		.procname	= "kprobes-optimization",
1447b2be84dfSMasami Hiramatsu 		.data		= &sysctl_kprobes_optimization,
1448b2be84dfSMasami Hiramatsu 		.maxlen		= sizeof(int),
1449b2be84dfSMasami Hiramatsu 		.mode		= 0644,
1450b2be84dfSMasami Hiramatsu 		.proc_handler	= proc_kprobes_optimization_handler,
1451b2be84dfSMasami Hiramatsu 		.extra1		= &zero,
1452b2be84dfSMasami Hiramatsu 		.extra2		= &one,
1453b2be84dfSMasami Hiramatsu 	},
1454b2be84dfSMasami Hiramatsu #endif
14556fce56ecSEric W. Biederman 	{ }
14561da177e4SLinus Torvalds };
14571da177e4SLinus Torvalds 
1458d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
14596fce56ecSEric W. Biederman 	{ }
14601da177e4SLinus Torvalds };
14611da177e4SLinus Torvalds 
1462330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock);
1463330d57fbSAl Viro 
1464330d57fbSAl Viro /* called under sysctl_lock */
1465330d57fbSAl Viro static int use_table(struct ctl_table_header *p)
1466330d57fbSAl Viro {
1467330d57fbSAl Viro 	if (unlikely(p->unregistering))
1468330d57fbSAl Viro 		return 0;
1469330d57fbSAl Viro 	p->used++;
1470330d57fbSAl Viro 	return 1;
1471330d57fbSAl Viro }
1472330d57fbSAl Viro 
1473330d57fbSAl Viro /* called under sysctl_lock */
1474330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p)
1475330d57fbSAl Viro {
1476330d57fbSAl Viro 	if (!--p->used)
1477330d57fbSAl Viro 		if (unlikely(p->unregistering))
1478330d57fbSAl Viro 			complete(p->unregistering);
1479330d57fbSAl Viro }
1480330d57fbSAl Viro 
1481330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */
1482330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p)
1483330d57fbSAl Viro {
1484330d57fbSAl Viro 	/*
1485330d57fbSAl Viro 	 * if p->used is 0, nobody will ever touch that entry again;
1486330d57fbSAl Viro 	 * we'll eliminate all paths to it before dropping sysctl_lock
1487330d57fbSAl Viro 	 */
1488330d57fbSAl Viro 	if (unlikely(p->used)) {
1489330d57fbSAl Viro 		struct completion wait;
1490330d57fbSAl Viro 		init_completion(&wait);
1491330d57fbSAl Viro 		p->unregistering = &wait;
1492330d57fbSAl Viro 		spin_unlock(&sysctl_lock);
1493330d57fbSAl Viro 		wait_for_completion(&wait);
1494330d57fbSAl Viro 		spin_lock(&sysctl_lock);
1495f7e6ced4SAl Viro 	} else {
1496f7e6ced4SAl Viro 		/* anything non-NULL; we'll never dereference it */
1497f7e6ced4SAl Viro 		p->unregistering = ERR_PTR(-EINVAL);
1498330d57fbSAl Viro 	}
1499330d57fbSAl Viro 	/*
1500330d57fbSAl Viro 	 * do not remove from the list until nobody holds it; walking the
1501330d57fbSAl Viro 	 * list in do_sysctl() relies on that.
1502330d57fbSAl Viro 	 */
1503330d57fbSAl Viro 	list_del_init(&p->ctl_entry);
1504330d57fbSAl Viro }
1505330d57fbSAl Viro 
1506f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head)
1507f7e6ced4SAl Viro {
1508f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1509f7e6ced4SAl Viro 	head->count++;
1510f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1511f7e6ced4SAl Viro }
1512f7e6ced4SAl Viro 
1513f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
1514f7e6ced4SAl Viro {
1515f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1516f7e6ced4SAl Viro 	if (!--head->count)
1517f7e6ced4SAl Viro 		kfree(head);
1518f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1519f7e6ced4SAl Viro }
1520f7e6ced4SAl Viro 
1521f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1522f7e6ced4SAl Viro {
1523f7e6ced4SAl Viro 	if (!head)
1524f7e6ced4SAl Viro 		BUG();
1525f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1526f7e6ced4SAl Viro 	if (!use_table(head))
1527f7e6ced4SAl Viro 		head = ERR_PTR(-ENOENT);
1528f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1529f7e6ced4SAl Viro 	return head;
1530f7e6ced4SAl Viro }
1531f7e6ced4SAl Viro 
1532805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head)
1533805b5d5eSEric W. Biederman {
1534805b5d5eSEric W. Biederman 	if (!head)
1535805b5d5eSEric W. Biederman 		return;
1536805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1537805b5d5eSEric W. Biederman 	unuse_table(head);
1538805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1539805b5d5eSEric W. Biederman }
1540805b5d5eSEric W. Biederman 
154173455092SAl Viro static struct ctl_table_set *
154273455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
154373455092SAl Viro {
154473455092SAl Viro 	struct ctl_table_set *set = &root->default_set;
154573455092SAl Viro 	if (root->lookup)
154673455092SAl Viro 		set = root->lookup(root, namespaces);
154773455092SAl Viro 	return set;
154873455092SAl Viro }
154973455092SAl Viro 
1550e51b6ba0SEric W. Biederman static struct list_head *
1551e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1552805b5d5eSEric W. Biederman {
155373455092SAl Viro 	struct ctl_table_set *set = lookup_header_set(root, namespaces);
155473455092SAl Viro 	return &set->list;
1555e51b6ba0SEric W. Biederman }
1556e51b6ba0SEric W. Biederman 
1557e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1558e51b6ba0SEric W. Biederman 					    struct ctl_table_header *prev)
1559e51b6ba0SEric W. Biederman {
1560e51b6ba0SEric W. Biederman 	struct ctl_table_root *root;
1561e51b6ba0SEric W. Biederman 	struct list_head *header_list;
1562805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1563805b5d5eSEric W. Biederman 	struct list_head *tmp;
1564e51b6ba0SEric W. Biederman 
1565805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1566805b5d5eSEric W. Biederman 	if (prev) {
1567e51b6ba0SEric W. Biederman 		head = prev;
1568805b5d5eSEric W. Biederman 		tmp = &prev->ctl_entry;
1569805b5d5eSEric W. Biederman 		unuse_table(prev);
1570805b5d5eSEric W. Biederman 		goto next;
1571805b5d5eSEric W. Biederman 	}
1572805b5d5eSEric W. Biederman 	tmp = &root_table_header.ctl_entry;
1573805b5d5eSEric W. Biederman 	for (;;) {
1574805b5d5eSEric W. Biederman 		head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1575805b5d5eSEric W. Biederman 
1576805b5d5eSEric W. Biederman 		if (!use_table(head))
1577805b5d5eSEric W. Biederman 			goto next;
1578805b5d5eSEric W. Biederman 		spin_unlock(&sysctl_lock);
1579805b5d5eSEric W. Biederman 		return head;
1580805b5d5eSEric W. Biederman 	next:
1581e51b6ba0SEric W. Biederman 		root = head->root;
1582805b5d5eSEric W. Biederman 		tmp = tmp->next;
1583e51b6ba0SEric W. Biederman 		header_list = lookup_header_list(root, namespaces);
1584e51b6ba0SEric W. Biederman 		if (tmp != header_list)
1585e51b6ba0SEric W. Biederman 			continue;
1586e51b6ba0SEric W. Biederman 
1587e51b6ba0SEric W. Biederman 		do {
1588e51b6ba0SEric W. Biederman 			root = list_entry(root->root_list.next,
1589e51b6ba0SEric W. Biederman 					struct ctl_table_root, root_list);
1590e51b6ba0SEric W. Biederman 			if (root == &sysctl_table_root)
1591e51b6ba0SEric W. Biederman 				goto out;
1592e51b6ba0SEric W. Biederman 			header_list = lookup_header_list(root, namespaces);
1593e51b6ba0SEric W. Biederman 		} while (list_empty(header_list));
1594e51b6ba0SEric W. Biederman 		tmp = header_list->next;
1595805b5d5eSEric W. Biederman 	}
1596e51b6ba0SEric W. Biederman out:
1597805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1598805b5d5eSEric W. Biederman 	return NULL;
1599805b5d5eSEric W. Biederman }
1600805b5d5eSEric W. Biederman 
1601e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1602e51b6ba0SEric W. Biederman {
1603e51b6ba0SEric W. Biederman 	return __sysctl_head_next(current->nsproxy, prev);
1604e51b6ba0SEric W. Biederman }
1605e51b6ba0SEric W. Biederman 
1606e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root)
1607e51b6ba0SEric W. Biederman {
1608e51b6ba0SEric W. Biederman 	spin_lock(&sysctl_lock);
1609e51b6ba0SEric W. Biederman 	list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1610e51b6ba0SEric W. Biederman 	spin_unlock(&sysctl_lock);
1611e51b6ba0SEric W. Biederman }
1612e51b6ba0SEric W. Biederman 
16131da177e4SLinus Torvalds /*
16141ff007ebSEric W. Biederman  * sysctl_perm does NOT grant the superuser all rights automatically, because
16151da177e4SLinus Torvalds  * some sysctl variables are readonly even to root.
16161da177e4SLinus Torvalds  */
16171da177e4SLinus Torvalds 
16181da177e4SLinus Torvalds static int test_perm(int mode, int op)
16191da177e4SLinus Torvalds {
162076aac0e9SDavid Howells 	if (!current_euid())
16211da177e4SLinus Torvalds 		mode >>= 6;
16221da177e4SLinus Torvalds 	else if (in_egroup_p(0))
16231da177e4SLinus Torvalds 		mode >>= 3;
1624e6305c43SAl Viro 	if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
16251da177e4SLinus Torvalds 		return 0;
16261da177e4SLinus Torvalds 	return -EACCES;
16271da177e4SLinus Torvalds }
16281da177e4SLinus Torvalds 
1629d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
16301da177e4SLinus Torvalds {
16311da177e4SLinus Torvalds 	int error;
1632d7321cd6SPavel Emelyanov 	int mode;
1633d7321cd6SPavel Emelyanov 
1634e6305c43SAl Viro 	error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
16351da177e4SLinus Torvalds 	if (error)
16361da177e4SLinus Torvalds 		return error;
1637d7321cd6SPavel Emelyanov 
1638d7321cd6SPavel Emelyanov 	if (root->permissions)
1639d7321cd6SPavel Emelyanov 		mode = root->permissions(root, current->nsproxy, table);
1640d7321cd6SPavel Emelyanov 	else
1641d7321cd6SPavel Emelyanov 		mode = table->mode;
1642d7321cd6SPavel Emelyanov 
1643d7321cd6SPavel Emelyanov 	return test_perm(mode, op);
16441da177e4SLinus Torvalds }
16451da177e4SLinus Torvalds 
1646d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1647d912b0ccSEric W. Biederman {
16482315ffa0SEric W. Biederman 	for (; table->procname; table++) {
1649d912b0ccSEric W. Biederman 		table->parent = parent;
1650d912b0ccSEric W. Biederman 		if (table->child)
1651d912b0ccSEric W. Biederman 			sysctl_set_parent(table, table->child);
1652d912b0ccSEric W. Biederman 	}
1653d912b0ccSEric W. Biederman }
1654d912b0ccSEric W. Biederman 
1655d912b0ccSEric W. Biederman static __init int sysctl_init(void)
1656d912b0ccSEric W. Biederman {
1657d912b0ccSEric W. Biederman 	sysctl_set_parent(NULL, root_table);
165888f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
165988f458e4SHolger Schurig 	{
166088f458e4SHolger Schurig 		int err;
1661e51b6ba0SEric W. Biederman 		err = sysctl_check_table(current->nsproxy, root_table);
166288f458e4SHolger Schurig 	}
166388f458e4SHolger Schurig #endif
1664d912b0ccSEric W. Biederman 	return 0;
1665d912b0ccSEric W. Biederman }
1666d912b0ccSEric W. Biederman 
1667d912b0ccSEric W. Biederman core_initcall(sysctl_init);
1668d912b0ccSEric W. Biederman 
1669bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch,
1670bfbcf034SAl Viro 				      struct ctl_table *table)
1671ae7edeccSAl Viro {
1672ae7edeccSAl Viro 	struct ctl_table *p;
1673ae7edeccSAl Viro 	const char *s = branch->procname;
1674ae7edeccSAl Viro 
1675ae7edeccSAl Viro 	/* branch should have named subdirectory as its first element */
1676ae7edeccSAl Viro 	if (!s || !branch->child)
1677bfbcf034SAl Viro 		return NULL;
1678ae7edeccSAl Viro 
1679ae7edeccSAl Viro 	/* ... and nothing else */
16802315ffa0SEric W. Biederman 	if (branch[1].procname)
1681bfbcf034SAl Viro 		return NULL;
1682ae7edeccSAl Viro 
1683ae7edeccSAl Viro 	/* table should contain subdirectory with the same name */
16842315ffa0SEric W. Biederman 	for (p = table; p->procname; p++) {
1685ae7edeccSAl Viro 		if (!p->child)
1686ae7edeccSAl Viro 			continue;
1687ae7edeccSAl Viro 		if (p->procname && strcmp(p->procname, s) == 0)
1688bfbcf034SAl Viro 			return p;
1689ae7edeccSAl Viro 	}
1690bfbcf034SAl Viro 	return NULL;
1691ae7edeccSAl Viro }
1692ae7edeccSAl Viro 
1693ae7edeccSAl Viro /* see if attaching q to p would be an improvement */
1694ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1695ae7edeccSAl Viro {
1696ae7edeccSAl Viro 	struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1697bfbcf034SAl Viro 	struct ctl_table *next;
1698ae7edeccSAl Viro 	int is_better = 0;
1699ae7edeccSAl Viro 	int not_in_parent = !p->attached_by;
1700ae7edeccSAl Viro 
1701bfbcf034SAl Viro 	while ((next = is_branch_in(by, to)) != NULL) {
1702ae7edeccSAl Viro 		if (by == q->attached_by)
1703ae7edeccSAl Viro 			is_better = 1;
1704ae7edeccSAl Viro 		if (to == p->attached_by)
1705ae7edeccSAl Viro 			not_in_parent = 1;
1706ae7edeccSAl Viro 		by = by->child;
1707bfbcf034SAl Viro 		to = next->child;
1708ae7edeccSAl Viro 	}
1709ae7edeccSAl Viro 
1710ae7edeccSAl Viro 	if (is_better && not_in_parent) {
1711ae7edeccSAl Viro 		q->attached_by = by;
1712ae7edeccSAl Viro 		q->attached_to = to;
1713ae7edeccSAl Viro 		q->parent = p;
1714ae7edeccSAl Viro 	}
1715ae7edeccSAl Viro }
1716ae7edeccSAl Viro 
17171da177e4SLinus Torvalds /**
1718e51b6ba0SEric W. Biederman  * __register_sysctl_paths - register a sysctl hierarchy
1719e51b6ba0SEric W. Biederman  * @root: List of sysctl headers to register on
1720e51b6ba0SEric W. Biederman  * @namespaces: Data to compute which lists of sysctl entries are visible
172129e796fdSEric W. Biederman  * @path: The path to the directory the sysctl table is in.
17221da177e4SLinus Torvalds  * @table: the top-level table structure
17231da177e4SLinus Torvalds  *
17241da177e4SLinus Torvalds  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
172529e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
17261da177e4SLinus Torvalds  *
1727d8217f07SEric W. Biederman  * The members of the &struct ctl_table structure are used as follows:
17281da177e4SLinus Torvalds  *
17291da177e4SLinus Torvalds  * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
17301da177e4SLinus Torvalds  *            enter a sysctl file
17311da177e4SLinus Torvalds  *
17321da177e4SLinus Torvalds  * data - a pointer to data for use by proc_handler
17331da177e4SLinus Torvalds  *
17341da177e4SLinus Torvalds  * maxlen - the maximum size in bytes of the data
17351da177e4SLinus Torvalds  *
17361da177e4SLinus Torvalds  * mode - the file permissions for the /proc/sys file, and for sysctl(2)
17371da177e4SLinus Torvalds  *
17381da177e4SLinus Torvalds  * child - a pointer to the child sysctl table if this entry is a directory, or
17391da177e4SLinus Torvalds  *         %NULL.
17401da177e4SLinus Torvalds  *
17411da177e4SLinus Torvalds  * proc_handler - the text handler routine (described below)
17421da177e4SLinus Torvalds  *
17431da177e4SLinus Torvalds  * de - for internal use by the sysctl routines
17441da177e4SLinus Torvalds  *
17451da177e4SLinus Torvalds  * extra1, extra2 - extra pointers usable by the proc handler routines
17461da177e4SLinus Torvalds  *
17471da177e4SLinus Torvalds  * Leaf nodes in the sysctl tree will be represented by a single file
17481da177e4SLinus Torvalds  * under /proc; non-leaf nodes will be represented by directories.
17491da177e4SLinus Torvalds  *
17501da177e4SLinus Torvalds  * sysctl(2) can automatically manage read and write requests through
17511da177e4SLinus Torvalds  * the sysctl table.  The data and maxlen fields of the ctl_table
17521da177e4SLinus Torvalds  * struct enable minimal validation of the values being written to be
17531da177e4SLinus Torvalds  * performed, and the mode field allows minimal authentication.
17541da177e4SLinus Torvalds  *
17551da177e4SLinus Torvalds  * There must be a proc_handler routine for any terminal nodes
17561da177e4SLinus Torvalds  * mirrored under /proc/sys (non-terminals are handled by a built-in
17571da177e4SLinus Torvalds  * directory handler).  Several default handlers are available to
17581da177e4SLinus Torvalds  * cover common cases -
17591da177e4SLinus Torvalds  *
17601da177e4SLinus Torvalds  * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
17611da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
17621da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
17631da177e4SLinus Torvalds  *
17641da177e4SLinus Torvalds  * It is the handler's job to read the input buffer from user memory
17651da177e4SLinus Torvalds  * and process it. The handler should return 0 on success.
17661da177e4SLinus Torvalds  *
17671da177e4SLinus Torvalds  * This routine returns %NULL on a failure to register, and a pointer
17681da177e4SLinus Torvalds  * to the table header on success.
17691da177e4SLinus Torvalds  */
1770e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths(
1771e51b6ba0SEric W. Biederman 	struct ctl_table_root *root,
1772e51b6ba0SEric W. Biederman 	struct nsproxy *namespaces,
1773e51b6ba0SEric W. Biederman 	const struct ctl_path *path, struct ctl_table *table)
17741da177e4SLinus Torvalds {
177529e796fdSEric W. Biederman 	struct ctl_table_header *header;
177629e796fdSEric W. Biederman 	struct ctl_table *new, **prevp;
177729e796fdSEric W. Biederman 	unsigned int n, npath;
1778ae7edeccSAl Viro 	struct ctl_table_set *set;
177929e796fdSEric W. Biederman 
178029e796fdSEric W. Biederman 	/* Count the path components */
17812315ffa0SEric W. Biederman 	for (npath = 0; path[npath].procname; ++npath)
178229e796fdSEric W. Biederman 		;
178329e796fdSEric W. Biederman 
178429e796fdSEric W. Biederman 	/*
178529e796fdSEric W. Biederman 	 * For each path component, allocate a 2-element ctl_table array.
178629e796fdSEric W. Biederman 	 * The first array element will be filled with the sysctl entry
17872315ffa0SEric W. Biederman 	 * for this, the second will be the sentinel (procname == 0).
178829e796fdSEric W. Biederman 	 *
178929e796fdSEric W. Biederman 	 * We allocate everything in one go so that we don't have to
179029e796fdSEric W. Biederman 	 * worry about freeing additional memory in unregister_sysctl_table.
179129e796fdSEric W. Biederman 	 */
179229e796fdSEric W. Biederman 	header = kzalloc(sizeof(struct ctl_table_header) +
179329e796fdSEric W. Biederman 			 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
179429e796fdSEric W. Biederman 	if (!header)
17951da177e4SLinus Torvalds 		return NULL;
179629e796fdSEric W. Biederman 
179729e796fdSEric W. Biederman 	new = (struct ctl_table *) (header + 1);
179829e796fdSEric W. Biederman 
179929e796fdSEric W. Biederman 	/* Now connect the dots */
180029e796fdSEric W. Biederman 	prevp = &header->ctl_table;
180129e796fdSEric W. Biederman 	for (n = 0; n < npath; ++n, ++path) {
180229e796fdSEric W. Biederman 		/* Copy the procname */
180329e796fdSEric W. Biederman 		new->procname = path->procname;
180429e796fdSEric W. Biederman 		new->mode     = 0555;
180529e796fdSEric W. Biederman 
180629e796fdSEric W. Biederman 		*prevp = new;
180729e796fdSEric W. Biederman 		prevp = &new->child;
180829e796fdSEric W. Biederman 
180929e796fdSEric W. Biederman 		new += 2;
181029e796fdSEric W. Biederman 	}
181129e796fdSEric W. Biederman 	*prevp = table;
181223eb06deSEric W. Biederman 	header->ctl_table_arg = table;
181329e796fdSEric W. Biederman 
181429e796fdSEric W. Biederman 	INIT_LIST_HEAD(&header->ctl_entry);
181529e796fdSEric W. Biederman 	header->used = 0;
181629e796fdSEric W. Biederman 	header->unregistering = NULL;
1817e51b6ba0SEric W. Biederman 	header->root = root;
181829e796fdSEric W. Biederman 	sysctl_set_parent(NULL, header->ctl_table);
1819f7e6ced4SAl Viro 	header->count = 1;
182088f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1821e51b6ba0SEric W. Biederman 	if (sysctl_check_table(namespaces, header->ctl_table)) {
182229e796fdSEric W. Biederman 		kfree(header);
1823fc6cd25bSEric W. Biederman 		return NULL;
1824fc6cd25bSEric W. Biederman 	}
182588f458e4SHolger Schurig #endif
1826330d57fbSAl Viro 	spin_lock(&sysctl_lock);
182773455092SAl Viro 	header->set = lookup_header_set(root, namespaces);
1828ae7edeccSAl Viro 	header->attached_by = header->ctl_table;
1829ae7edeccSAl Viro 	header->attached_to = root_table;
1830ae7edeccSAl Viro 	header->parent = &root_table_header;
1831ae7edeccSAl Viro 	for (set = header->set; set; set = set->parent) {
1832ae7edeccSAl Viro 		struct ctl_table_header *p;
1833ae7edeccSAl Viro 		list_for_each_entry(p, &set->list, ctl_entry) {
1834ae7edeccSAl Viro 			if (p->unregistering)
1835ae7edeccSAl Viro 				continue;
1836ae7edeccSAl Viro 			try_attach(p, header);
1837ae7edeccSAl Viro 		}
1838ae7edeccSAl Viro 	}
1839ae7edeccSAl Viro 	header->parent->count++;
184073455092SAl Viro 	list_add_tail(&header->ctl_entry, &header->set->list);
1841330d57fbSAl Viro 	spin_unlock(&sysctl_lock);
184229e796fdSEric W. Biederman 
184329e796fdSEric W. Biederman 	return header;
184429e796fdSEric W. Biederman }
184529e796fdSEric W. Biederman 
184629e796fdSEric W. Biederman /**
1847e51b6ba0SEric W. Biederman  * register_sysctl_table_path - register a sysctl table hierarchy
1848e51b6ba0SEric W. Biederman  * @path: The path to the directory the sysctl table is in.
1849e51b6ba0SEric W. Biederman  * @table: the top-level table structure
1850e51b6ba0SEric W. Biederman  *
1851e51b6ba0SEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1852e51b6ba0SEric W. Biederman  * array. A completely 0 filled entry terminates the table.
1853e51b6ba0SEric W. Biederman  *
1854e51b6ba0SEric W. Biederman  * See __register_sysctl_paths for more details.
1855e51b6ba0SEric W. Biederman  */
1856e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1857e51b6ba0SEric W. Biederman 						struct ctl_table *table)
1858e51b6ba0SEric W. Biederman {
1859e51b6ba0SEric W. Biederman 	return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1860e51b6ba0SEric W. Biederman 					path, table);
1861e51b6ba0SEric W. Biederman }
1862e51b6ba0SEric W. Biederman 
1863e51b6ba0SEric W. Biederman /**
186429e796fdSEric W. Biederman  * register_sysctl_table - register a sysctl table hierarchy
186529e796fdSEric W. Biederman  * @table: the top-level table structure
186629e796fdSEric W. Biederman  *
186729e796fdSEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
186829e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
186929e796fdSEric W. Biederman  *
187029e796fdSEric W. Biederman  * See register_sysctl_paths for more details.
187129e796fdSEric W. Biederman  */
187229e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
187329e796fdSEric W. Biederman {
187429e796fdSEric W. Biederman 	static const struct ctl_path null_path[] = { {} };
187529e796fdSEric W. Biederman 
187629e796fdSEric W. Biederman 	return register_sysctl_paths(null_path, table);
18771da177e4SLinus Torvalds }
18781da177e4SLinus Torvalds 
18791da177e4SLinus Torvalds /**
18801da177e4SLinus Torvalds  * unregister_sysctl_table - unregister a sysctl table hierarchy
18811da177e4SLinus Torvalds  * @header: the header returned from register_sysctl_table
18821da177e4SLinus Torvalds  *
18831da177e4SLinus Torvalds  * Unregisters the sysctl table and all children. proc entries may not
18841da177e4SLinus Torvalds  * actually be removed until they are no longer used by anyone.
18851da177e4SLinus Torvalds  */
18861da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header)
18871da177e4SLinus Torvalds {
1888330d57fbSAl Viro 	might_sleep();
1889f1dad166SPavel Emelyanov 
1890f1dad166SPavel Emelyanov 	if (header == NULL)
1891f1dad166SPavel Emelyanov 		return;
1892f1dad166SPavel Emelyanov 
1893330d57fbSAl Viro 	spin_lock(&sysctl_lock);
1894330d57fbSAl Viro 	start_unregistering(header);
1895ae7edeccSAl Viro 	if (!--header->parent->count) {
1896ae7edeccSAl Viro 		WARN_ON(1);
1897ae7edeccSAl Viro 		kfree(header->parent);
1898ae7edeccSAl Viro 	}
1899f7e6ced4SAl Viro 	if (!--header->count)
19001da177e4SLinus Torvalds 		kfree(header);
1901f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
19021da177e4SLinus Torvalds }
19031da177e4SLinus Torvalds 
19049043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p)
19059043476fSAl Viro {
19069043476fSAl Viro 	struct ctl_table_set *set = p->set;
19079043476fSAl Viro 	int res;
19089043476fSAl Viro 	spin_lock(&sysctl_lock);
19099043476fSAl Viro 	if (p->unregistering)
19109043476fSAl Viro 		res = 0;
19119043476fSAl Viro 	else if (!set->is_seen)
19129043476fSAl Viro 		res = 1;
19139043476fSAl Viro 	else
19149043476fSAl Viro 		res = set->is_seen(set);
19159043476fSAl Viro 	spin_unlock(&sysctl_lock);
19169043476fSAl Viro 	return res;
19179043476fSAl Viro }
19189043476fSAl Viro 
191973455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
192073455092SAl Viro 	struct ctl_table_set *parent,
192173455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
192273455092SAl Viro {
192373455092SAl Viro 	INIT_LIST_HEAD(&p->list);
192473455092SAl Viro 	p->parent = parent ? parent : &sysctl_table_root.default_set;
192573455092SAl Viro 	p->is_seen = is_seen;
192673455092SAl Viro }
192773455092SAl Viro 
1928b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */
1929d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
1930b89a8171SEric W. Biederman {
1931b89a8171SEric W. Biederman 	return NULL;
1932b89a8171SEric W. Biederman }
1933b89a8171SEric W. Biederman 
193429e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
193529e796fdSEric W. Biederman 						    struct ctl_table *table)
193629e796fdSEric W. Biederman {
193729e796fdSEric W. Biederman 	return NULL;
193829e796fdSEric W. Biederman }
193929e796fdSEric W. Biederman 
1940b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table)
1941b89a8171SEric W. Biederman {
1942b89a8171SEric W. Biederman }
1943b89a8171SEric W. Biederman 
194473455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
194573455092SAl Viro 	struct ctl_table_set *parent,
194673455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
194773455092SAl Viro {
194873455092SAl Viro }
194973455092SAl Viro 
1950f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
1951f7e6ced4SAl Viro {
1952f7e6ced4SAl Viro }
1953f7e6ced4SAl Viro 
1954b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
1955b89a8171SEric W. Biederman 
19561da177e4SLinus Torvalds /*
19571da177e4SLinus Torvalds  * /proc/sys support
19581da177e4SLinus Torvalds  */
19591da177e4SLinus Torvalds 
1960b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL
19611da177e4SLinus Torvalds 
1962b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write,
19638d65af78SAlexey Dobriyan 			   void __user *buffer,
1964b1ba4dddSAdrian Bunk 			   size_t *lenp, loff_t *ppos)
1965f5dd3d6fSSam Vilain {
1966f5dd3d6fSSam Vilain 	size_t len;
1967f5dd3d6fSSam Vilain 	char __user *p;
1968f5dd3d6fSSam Vilain 	char c;
1969f5dd3d6fSSam Vilain 
19708d060877SOleg Nesterov 	if (!data || !maxlen || !*lenp) {
1971f5dd3d6fSSam Vilain 		*lenp = 0;
1972f5dd3d6fSSam Vilain 		return 0;
1973f5dd3d6fSSam Vilain 	}
1974f5dd3d6fSSam Vilain 
1975f5dd3d6fSSam Vilain 	if (write) {
1976f5dd3d6fSSam Vilain 		len = 0;
1977f5dd3d6fSSam Vilain 		p = buffer;
1978f5dd3d6fSSam Vilain 		while (len < *lenp) {
1979f5dd3d6fSSam Vilain 			if (get_user(c, p++))
1980f5dd3d6fSSam Vilain 				return -EFAULT;
1981f5dd3d6fSSam Vilain 			if (c == 0 || c == '\n')
1982f5dd3d6fSSam Vilain 				break;
1983f5dd3d6fSSam Vilain 			len++;
1984f5dd3d6fSSam Vilain 		}
1985f5dd3d6fSSam Vilain 		if (len >= maxlen)
1986f5dd3d6fSSam Vilain 			len = maxlen-1;
1987f5dd3d6fSSam Vilain 		if(copy_from_user(data, buffer, len))
1988f5dd3d6fSSam Vilain 			return -EFAULT;
1989f5dd3d6fSSam Vilain 		((char *) data)[len] = 0;
1990f5dd3d6fSSam Vilain 		*ppos += *lenp;
1991f5dd3d6fSSam Vilain 	} else {
1992f5dd3d6fSSam Vilain 		len = strlen(data);
1993f5dd3d6fSSam Vilain 		if (len > maxlen)
1994f5dd3d6fSSam Vilain 			len = maxlen;
19958d060877SOleg Nesterov 
19968d060877SOleg Nesterov 		if (*ppos > len) {
19978d060877SOleg Nesterov 			*lenp = 0;
19988d060877SOleg Nesterov 			return 0;
19998d060877SOleg Nesterov 		}
20008d060877SOleg Nesterov 
20018d060877SOleg Nesterov 		data += *ppos;
20028d060877SOleg Nesterov 		len  -= *ppos;
20038d060877SOleg Nesterov 
2004f5dd3d6fSSam Vilain 		if (len > *lenp)
2005f5dd3d6fSSam Vilain 			len = *lenp;
2006f5dd3d6fSSam Vilain 		if (len)
2007f5dd3d6fSSam Vilain 			if(copy_to_user(buffer, data, len))
2008f5dd3d6fSSam Vilain 				return -EFAULT;
2009f5dd3d6fSSam Vilain 		if (len < *lenp) {
2010f5dd3d6fSSam Vilain 			if(put_user('\n', ((char __user *) buffer) + len))
2011f5dd3d6fSSam Vilain 				return -EFAULT;
2012f5dd3d6fSSam Vilain 			len++;
2013f5dd3d6fSSam Vilain 		}
2014f5dd3d6fSSam Vilain 		*lenp = len;
2015f5dd3d6fSSam Vilain 		*ppos += len;
2016f5dd3d6fSSam Vilain 	}
2017f5dd3d6fSSam Vilain 	return 0;
2018f5dd3d6fSSam Vilain }
2019f5dd3d6fSSam Vilain 
20201da177e4SLinus Torvalds /**
20211da177e4SLinus Torvalds  * proc_dostring - read a string sysctl
20221da177e4SLinus Torvalds  * @table: the sysctl table
20231da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
20241da177e4SLinus Torvalds  * @buffer: the user buffer
20251da177e4SLinus Torvalds  * @lenp: the size of the user buffer
20261da177e4SLinus Torvalds  * @ppos: file position
20271da177e4SLinus Torvalds  *
20281da177e4SLinus Torvalds  * Reads/writes a string from/to the user buffer. If the kernel
20291da177e4SLinus Torvalds  * buffer provided is not large enough to hold the string, the
20301da177e4SLinus Torvalds  * string is truncated. The copied string is %NULL-terminated.
20311da177e4SLinus Torvalds  * If the string is being read by the user process, it is copied
20321da177e4SLinus Torvalds  * and a newline '\n' is added. It is truncated if the buffer is
20331da177e4SLinus Torvalds  * not large enough.
20341da177e4SLinus Torvalds  *
20351da177e4SLinus Torvalds  * Returns 0 on success.
20361da177e4SLinus Torvalds  */
20378d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write,
20381da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
20391da177e4SLinus Torvalds {
20408d65af78SAlexey Dobriyan 	return _proc_do_string(table->data, table->maxlen, write,
2041f5dd3d6fSSam Vilain 			       buffer, lenp, ppos);
20421da177e4SLinus Torvalds }
20431da177e4SLinus Torvalds 
20441da177e4SLinus Torvalds 
20451da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
20461da177e4SLinus Torvalds 				 int *valp,
20471da177e4SLinus Torvalds 				 int write, void *data)
20481da177e4SLinus Torvalds {
20491da177e4SLinus Torvalds 	if (write) {
20501da177e4SLinus Torvalds 		*valp = *negp ? -*lvalp : *lvalp;
20511da177e4SLinus Torvalds 	} else {
20521da177e4SLinus Torvalds 		int val = *valp;
20531da177e4SLinus Torvalds 		if (val < 0) {
20541da177e4SLinus Torvalds 			*negp = -1;
20551da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
20561da177e4SLinus Torvalds 		} else {
20571da177e4SLinus Torvalds 			*negp = 0;
20581da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
20591da177e4SLinus Torvalds 		}
20601da177e4SLinus Torvalds 	}
20611da177e4SLinus Torvalds 	return 0;
20621da177e4SLinus Torvalds }
20631da177e4SLinus Torvalds 
2064d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
20658d65af78SAlexey Dobriyan 		  int write, void __user *buffer,
2066fcfbd547SKirill Korotaev 		  size_t *lenp, loff_t *ppos,
20671da177e4SLinus Torvalds 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
20681da177e4SLinus Torvalds 			      int write, void *data),
20691da177e4SLinus Torvalds 		  void *data)
20701da177e4SLinus Torvalds {
20711da177e4SLinus Torvalds #define TMPBUFLEN 21
20727338f299SSukanto Ghosh 	int *i, vleft, first = 1, neg;
20731da177e4SLinus Torvalds 	unsigned long lval;
20741da177e4SLinus Torvalds 	size_t left, len;
20751da177e4SLinus Torvalds 
20761da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
20771da177e4SLinus Torvalds 	char __user *s = buffer;
20781da177e4SLinus Torvalds 
2079fcfbd547SKirill Korotaev 	if (!tbl_data || !table->maxlen || !*lenp ||
20801da177e4SLinus Torvalds 	    (*ppos && !write)) {
20811da177e4SLinus Torvalds 		*lenp = 0;
20821da177e4SLinus Torvalds 		return 0;
20831da177e4SLinus Torvalds 	}
20841da177e4SLinus Torvalds 
2085fcfbd547SKirill Korotaev 	i = (int *) tbl_data;
20861da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(*i);
20871da177e4SLinus Torvalds 	left = *lenp;
20881da177e4SLinus Torvalds 
20891da177e4SLinus Torvalds 	if (!conv)
20901da177e4SLinus Torvalds 		conv = do_proc_dointvec_conv;
20911da177e4SLinus Torvalds 
20921da177e4SLinus Torvalds 	for (; left && vleft--; i++, first=0) {
20931da177e4SLinus Torvalds 		if (write) {
20941da177e4SLinus Torvalds 			while (left) {
20951da177e4SLinus Torvalds 				char c;
20961da177e4SLinus Torvalds 				if (get_user(c, s))
20971da177e4SLinus Torvalds 					return -EFAULT;
20981da177e4SLinus Torvalds 				if (!isspace(c))
20991da177e4SLinus Torvalds 					break;
21001da177e4SLinus Torvalds 				left--;
21011da177e4SLinus Torvalds 				s++;
21021da177e4SLinus Torvalds 			}
21031da177e4SLinus Torvalds 			if (!left)
21041da177e4SLinus Torvalds 				break;
21051da177e4SLinus Torvalds 			neg = 0;
21061da177e4SLinus Torvalds 			len = left;
21071da177e4SLinus Torvalds 			if (len > sizeof(buf) - 1)
21081da177e4SLinus Torvalds 				len = sizeof(buf) - 1;
21091da177e4SLinus Torvalds 			if (copy_from_user(buf, s, len))
21101da177e4SLinus Torvalds 				return -EFAULT;
21111da177e4SLinus Torvalds 			buf[len] = 0;
21121da177e4SLinus Torvalds 			p = buf;
21131da177e4SLinus Torvalds 			if (*p == '-' && left > 1) {
21141da177e4SLinus Torvalds 				neg = 1;
2115bd9b0bacSBP, Praveen 				p++;
21161da177e4SLinus Torvalds 			}
21171da177e4SLinus Torvalds 			if (*p < '0' || *p > '9')
21181da177e4SLinus Torvalds 				break;
21191da177e4SLinus Torvalds 
21201da177e4SLinus Torvalds 			lval = simple_strtoul(p, &p, 0);
21211da177e4SLinus Torvalds 
21221da177e4SLinus Torvalds 			len = p-buf;
21231da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
21241da177e4SLinus Torvalds 				break;
21251da177e4SLinus Torvalds 			s += len;
21261da177e4SLinus Torvalds 			left -= len;
21271da177e4SLinus Torvalds 
21281da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 1, data))
21291da177e4SLinus Torvalds 				break;
21301da177e4SLinus Torvalds 		} else {
21311da177e4SLinus Torvalds 			p = buf;
21321da177e4SLinus Torvalds 			if (!first)
21331da177e4SLinus Torvalds 				*p++ = '\t';
21341da177e4SLinus Torvalds 
21351da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 0, data))
21361da177e4SLinus Torvalds 				break;
21371da177e4SLinus Torvalds 
21381da177e4SLinus Torvalds 			sprintf(p, "%s%lu", neg ? "-" : "", lval);
21391da177e4SLinus Torvalds 			len = strlen(buf);
21401da177e4SLinus Torvalds 			if (len > left)
21411da177e4SLinus Torvalds 				len = left;
21421da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
21431da177e4SLinus Torvalds 				return -EFAULT;
21441da177e4SLinus Torvalds 			left -= len;
21451da177e4SLinus Torvalds 			s += len;
21461da177e4SLinus Torvalds 		}
21471da177e4SLinus Torvalds 	}
21481da177e4SLinus Torvalds 
21491da177e4SLinus Torvalds 	if (!write && !first && left) {
21501da177e4SLinus Torvalds 		if(put_user('\n', s))
21511da177e4SLinus Torvalds 			return -EFAULT;
21521da177e4SLinus Torvalds 		left--, s++;
21531da177e4SLinus Torvalds 	}
21541da177e4SLinus Torvalds 	if (write) {
21551da177e4SLinus Torvalds 		while (left) {
21561da177e4SLinus Torvalds 			char c;
21571da177e4SLinus Torvalds 			if (get_user(c, s++))
21581da177e4SLinus Torvalds 				return -EFAULT;
21591da177e4SLinus Torvalds 			if (!isspace(c))
21601da177e4SLinus Torvalds 				break;
21611da177e4SLinus Torvalds 			left--;
21621da177e4SLinus Torvalds 		}
21631da177e4SLinus Torvalds 	}
21641da177e4SLinus Torvalds 	if (write && first)
21651da177e4SLinus Torvalds 		return -EINVAL;
21661da177e4SLinus Torvalds 	*lenp -= left;
21671da177e4SLinus Torvalds 	*ppos += *lenp;
21681da177e4SLinus Torvalds 	return 0;
21691da177e4SLinus Torvalds #undef TMPBUFLEN
21701da177e4SLinus Torvalds }
21711da177e4SLinus Torvalds 
21728d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write,
2173fcfbd547SKirill Korotaev 		  void __user *buffer, size_t *lenp, loff_t *ppos,
2174fcfbd547SKirill Korotaev 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2175fcfbd547SKirill Korotaev 			      int write, void *data),
2176fcfbd547SKirill Korotaev 		  void *data)
2177fcfbd547SKirill Korotaev {
21788d65af78SAlexey Dobriyan 	return __do_proc_dointvec(table->data, table, write,
2179fcfbd547SKirill Korotaev 			buffer, lenp, ppos, conv, data);
2180fcfbd547SKirill Korotaev }
2181fcfbd547SKirill Korotaev 
21821da177e4SLinus Torvalds /**
21831da177e4SLinus Torvalds  * proc_dointvec - read a vector of integers
21841da177e4SLinus Torvalds  * @table: the sysctl table
21851da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
21861da177e4SLinus Torvalds  * @buffer: the user buffer
21871da177e4SLinus Torvalds  * @lenp: the size of the user buffer
21881da177e4SLinus Torvalds  * @ppos: file position
21891da177e4SLinus Torvalds  *
21901da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
21911da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
21921da177e4SLinus Torvalds  *
21931da177e4SLinus Torvalds  * Returns 0 on success.
21941da177e4SLinus Torvalds  */
21958d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write,
21961da177e4SLinus Torvalds 		     void __user *buffer, size_t *lenp, loff_t *ppos)
21971da177e4SLinus Torvalds {
21988d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
21991da177e4SLinus Torvalds 		    	    NULL,NULL);
22001da177e4SLinus Torvalds }
22011da177e4SLinus Torvalds 
220234f5a398STheodore Ts'o /*
220334f5a398STheodore Ts'o  * Taint values can only be increased
220425ddbb18SAndi Kleen  * This means we can safely use a temporary.
220534f5a398STheodore Ts'o  */
22068d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write,
220734f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos)
220834f5a398STheodore Ts'o {
220925ddbb18SAndi Kleen 	struct ctl_table t;
221025ddbb18SAndi Kleen 	unsigned long tmptaint = get_taint();
221125ddbb18SAndi Kleen 	int err;
221234f5a398STheodore Ts'o 
221391fcd412SBastian Blank 	if (write && !capable(CAP_SYS_ADMIN))
221434f5a398STheodore Ts'o 		return -EPERM;
221534f5a398STheodore Ts'o 
221625ddbb18SAndi Kleen 	t = *table;
221725ddbb18SAndi Kleen 	t.data = &tmptaint;
22188d65af78SAlexey Dobriyan 	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
221925ddbb18SAndi Kleen 	if (err < 0)
222025ddbb18SAndi Kleen 		return err;
222125ddbb18SAndi Kleen 
222225ddbb18SAndi Kleen 	if (write) {
222325ddbb18SAndi Kleen 		/*
222425ddbb18SAndi Kleen 		 * Poor man's atomic or. Not worth adding a primitive
222525ddbb18SAndi Kleen 		 * to everyone's atomic.h for this
222625ddbb18SAndi Kleen 		 */
222725ddbb18SAndi Kleen 		int i;
222825ddbb18SAndi Kleen 		for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
222925ddbb18SAndi Kleen 			if ((tmptaint >> i) & 1)
223025ddbb18SAndi Kleen 				add_taint(i);
223125ddbb18SAndi Kleen 		}
223225ddbb18SAndi Kleen 	}
223325ddbb18SAndi Kleen 
223425ddbb18SAndi Kleen 	return err;
223534f5a398STheodore Ts'o }
223634f5a398STheodore Ts'o 
22371da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param {
22381da177e4SLinus Torvalds 	int *min;
22391da177e4SLinus Torvalds 	int *max;
22401da177e4SLinus Torvalds };
22411da177e4SLinus Torvalds 
22421da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
22431da177e4SLinus Torvalds 					int *valp,
22441da177e4SLinus Torvalds 					int write, void *data)
22451da177e4SLinus Torvalds {
22461da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param *param = data;
22471da177e4SLinus Torvalds 	if (write) {
22481da177e4SLinus Torvalds 		int val = *negp ? -*lvalp : *lvalp;
22491da177e4SLinus Torvalds 		if ((param->min && *param->min > val) ||
22501da177e4SLinus Torvalds 		    (param->max && *param->max < val))
22511da177e4SLinus Torvalds 			return -EINVAL;
22521da177e4SLinus Torvalds 		*valp = val;
22531da177e4SLinus Torvalds 	} else {
22541da177e4SLinus Torvalds 		int val = *valp;
22551da177e4SLinus Torvalds 		if (val < 0) {
22561da177e4SLinus Torvalds 			*negp = -1;
22571da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
22581da177e4SLinus Torvalds 		} else {
22591da177e4SLinus Torvalds 			*negp = 0;
22601da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
22611da177e4SLinus Torvalds 		}
22621da177e4SLinus Torvalds 	}
22631da177e4SLinus Torvalds 	return 0;
22641da177e4SLinus Torvalds }
22651da177e4SLinus Torvalds 
22661da177e4SLinus Torvalds /**
22671da177e4SLinus Torvalds  * proc_dointvec_minmax - read a vector of integers with min/max values
22681da177e4SLinus Torvalds  * @table: the sysctl table
22691da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
22701da177e4SLinus Torvalds  * @buffer: the user buffer
22711da177e4SLinus Torvalds  * @lenp: the size of the user buffer
22721da177e4SLinus Torvalds  * @ppos: file position
22731da177e4SLinus Torvalds  *
22741da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
22751da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
22761da177e4SLinus Torvalds  *
22771da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
22781da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
22791da177e4SLinus Torvalds  *
22801da177e4SLinus Torvalds  * Returns 0 on success.
22811da177e4SLinus Torvalds  */
22828d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write,
22831da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
22841da177e4SLinus Torvalds {
22851da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param param = {
22861da177e4SLinus Torvalds 		.min = (int *) table->extra1,
22871da177e4SLinus Torvalds 		.max = (int *) table->extra2,
22881da177e4SLinus Torvalds 	};
22898d65af78SAlexey Dobriyan 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
22901da177e4SLinus Torvalds 				do_proc_dointvec_minmax_conv, &param);
22911da177e4SLinus Torvalds }
22921da177e4SLinus Torvalds 
2293d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
22941da177e4SLinus Torvalds 				     void __user *buffer,
22951da177e4SLinus Torvalds 				     size_t *lenp, loff_t *ppos,
22961da177e4SLinus Torvalds 				     unsigned long convmul,
22971da177e4SLinus Torvalds 				     unsigned long convdiv)
22981da177e4SLinus Torvalds {
22991da177e4SLinus Torvalds #define TMPBUFLEN 21
23001da177e4SLinus Torvalds 	unsigned long *i, *min, *max, val;
23011da177e4SLinus Torvalds 	int vleft, first=1, neg;
23021da177e4SLinus Torvalds 	size_t len, left;
23031da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
23041da177e4SLinus Torvalds 	char __user *s = buffer;
23051da177e4SLinus Torvalds 
2306fcfbd547SKirill Korotaev 	if (!data || !table->maxlen || !*lenp ||
23071da177e4SLinus Torvalds 	    (*ppos && !write)) {
23081da177e4SLinus Torvalds 		*lenp = 0;
23091da177e4SLinus Torvalds 		return 0;
23101da177e4SLinus Torvalds 	}
23111da177e4SLinus Torvalds 
2312fcfbd547SKirill Korotaev 	i = (unsigned long *) data;
23131da177e4SLinus Torvalds 	min = (unsigned long *) table->extra1;
23141da177e4SLinus Torvalds 	max = (unsigned long *) table->extra2;
23151da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(unsigned long);
23161da177e4SLinus Torvalds 	left = *lenp;
23171da177e4SLinus Torvalds 
23181da177e4SLinus Torvalds 	for (; left && vleft--; i++, min++, max++, 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 > TMPBUFLEN-1)
23341da177e4SLinus Torvalds 				len = TMPBUFLEN-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 			val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
23461da177e4SLinus Torvalds 			len = p-buf;
23471da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
23481da177e4SLinus Torvalds 				break;
23491da177e4SLinus Torvalds 			if (neg)
23501da177e4SLinus Torvalds 				val = -val;
23511da177e4SLinus Torvalds 			s += len;
23521da177e4SLinus Torvalds 			left -= len;
23531da177e4SLinus Torvalds 
23541da177e4SLinus Torvalds 			if(neg)
23551da177e4SLinus Torvalds 				continue;
23561da177e4SLinus Torvalds 			if ((min && val < *min) || (max && val > *max))
23571da177e4SLinus Torvalds 				continue;
23581da177e4SLinus Torvalds 			*i = val;
23591da177e4SLinus Torvalds 		} else {
23601da177e4SLinus Torvalds 			p = buf;
23611da177e4SLinus Torvalds 			if (!first)
23621da177e4SLinus Torvalds 				*p++ = '\t';
23631da177e4SLinus Torvalds 			sprintf(p, "%lu", convdiv * (*i) / convmul);
23641da177e4SLinus Torvalds 			len = strlen(buf);
23651da177e4SLinus Torvalds 			if (len > left)
23661da177e4SLinus Torvalds 				len = left;
23671da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
23681da177e4SLinus Torvalds 				return -EFAULT;
23691da177e4SLinus Torvalds 			left -= len;
23701da177e4SLinus Torvalds 			s += len;
23711da177e4SLinus Torvalds 		}
23721da177e4SLinus Torvalds 	}
23731da177e4SLinus Torvalds 
23741da177e4SLinus Torvalds 	if (!write && !first && left) {
23751da177e4SLinus Torvalds 		if(put_user('\n', s))
23761da177e4SLinus Torvalds 			return -EFAULT;
23771da177e4SLinus Torvalds 		left--, s++;
23781da177e4SLinus Torvalds 	}
23791da177e4SLinus Torvalds 	if (write) {
23801da177e4SLinus Torvalds 		while (left) {
23811da177e4SLinus Torvalds 			char c;
23821da177e4SLinus Torvalds 			if (get_user(c, s++))
23831da177e4SLinus Torvalds 				return -EFAULT;
23841da177e4SLinus Torvalds 			if (!isspace(c))
23851da177e4SLinus Torvalds 				break;
23861da177e4SLinus Torvalds 			left--;
23871da177e4SLinus Torvalds 		}
23881da177e4SLinus Torvalds 	}
23891da177e4SLinus Torvalds 	if (write && first)
23901da177e4SLinus Torvalds 		return -EINVAL;
23911da177e4SLinus Torvalds 	*lenp -= left;
23921da177e4SLinus Torvalds 	*ppos += *lenp;
23931da177e4SLinus Torvalds 	return 0;
23941da177e4SLinus Torvalds #undef TMPBUFLEN
23951da177e4SLinus Torvalds }
23961da177e4SLinus Torvalds 
2397d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2398fcfbd547SKirill Korotaev 				     void __user *buffer,
2399fcfbd547SKirill Korotaev 				     size_t *lenp, loff_t *ppos,
2400fcfbd547SKirill Korotaev 				     unsigned long convmul,
2401fcfbd547SKirill Korotaev 				     unsigned long convdiv)
2402fcfbd547SKirill Korotaev {
2403fcfbd547SKirill Korotaev 	return __do_proc_doulongvec_minmax(table->data, table, write,
24048d65af78SAlexey Dobriyan 			buffer, lenp, ppos, convmul, convdiv);
2405fcfbd547SKirill Korotaev }
2406fcfbd547SKirill Korotaev 
24071da177e4SLinus Torvalds /**
24081da177e4SLinus Torvalds  * proc_doulongvec_minmax - read a vector of long integers with min/max values
24091da177e4SLinus Torvalds  * @table: the sysctl table
24101da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24111da177e4SLinus Torvalds  * @buffer: the user buffer
24121da177e4SLinus Torvalds  * @lenp: the size of the user buffer
24131da177e4SLinus Torvalds  * @ppos: file position
24141da177e4SLinus Torvalds  *
24151da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
24161da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
24171da177e4SLinus Torvalds  *
24181da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
24191da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
24201da177e4SLinus Torvalds  *
24211da177e4SLinus Torvalds  * Returns 0 on success.
24221da177e4SLinus Torvalds  */
24238d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write,
24241da177e4SLinus Torvalds 			   void __user *buffer, size_t *lenp, loff_t *ppos)
24251da177e4SLinus Torvalds {
24268d65af78SAlexey Dobriyan     return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
24271da177e4SLinus Torvalds }
24281da177e4SLinus Torvalds 
24291da177e4SLinus Torvalds /**
24301da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
24311da177e4SLinus Torvalds  * @table: the sysctl table
24321da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24331da177e4SLinus Torvalds  * @buffer: the user buffer
24341da177e4SLinus Torvalds  * @lenp: the size of the user buffer
24351da177e4SLinus Torvalds  * @ppos: file position
24361da177e4SLinus Torvalds  *
24371da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
24381da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string. The values
24391da177e4SLinus Torvalds  * are treated as milliseconds, and converted to jiffies when they are stored.
24401da177e4SLinus Torvalds  *
24411da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
24421da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
24431da177e4SLinus Torvalds  *
24441da177e4SLinus Torvalds  * Returns 0 on success.
24451da177e4SLinus Torvalds  */
2446d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
24471da177e4SLinus Torvalds 				      void __user *buffer,
24481da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
24491da177e4SLinus Torvalds {
24508d65af78SAlexey Dobriyan     return do_proc_doulongvec_minmax(table, write, buffer,
24511da177e4SLinus Torvalds 				     lenp, ppos, HZ, 1000l);
24521da177e4SLinus Torvalds }
24531da177e4SLinus Torvalds 
24541da177e4SLinus Torvalds 
24551da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
24561da177e4SLinus Torvalds 					 int *valp,
24571da177e4SLinus Torvalds 					 int write, void *data)
24581da177e4SLinus Torvalds {
24591da177e4SLinus Torvalds 	if (write) {
2460cba9f33dSBart Samwel 		if (*lvalp > LONG_MAX / HZ)
2461cba9f33dSBart Samwel 			return 1;
24621da177e4SLinus Torvalds 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
24631da177e4SLinus Torvalds 	} else {
24641da177e4SLinus Torvalds 		int val = *valp;
24651da177e4SLinus Torvalds 		unsigned long lval;
24661da177e4SLinus Torvalds 		if (val < 0) {
24671da177e4SLinus Torvalds 			*negp = -1;
24681da177e4SLinus Torvalds 			lval = (unsigned long)-val;
24691da177e4SLinus Torvalds 		} else {
24701da177e4SLinus Torvalds 			*negp = 0;
24711da177e4SLinus Torvalds 			lval = (unsigned long)val;
24721da177e4SLinus Torvalds 		}
24731da177e4SLinus Torvalds 		*lvalp = lval / HZ;
24741da177e4SLinus Torvalds 	}
24751da177e4SLinus Torvalds 	return 0;
24761da177e4SLinus Torvalds }
24771da177e4SLinus Torvalds 
24781da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
24791da177e4SLinus Torvalds 						int *valp,
24801da177e4SLinus Torvalds 						int write, void *data)
24811da177e4SLinus Torvalds {
24821da177e4SLinus Torvalds 	if (write) {
2483cba9f33dSBart Samwel 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2484cba9f33dSBart Samwel 			return 1;
24851da177e4SLinus Torvalds 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
24861da177e4SLinus Torvalds 	} else {
24871da177e4SLinus Torvalds 		int val = *valp;
24881da177e4SLinus Torvalds 		unsigned long lval;
24891da177e4SLinus Torvalds 		if (val < 0) {
24901da177e4SLinus Torvalds 			*negp = -1;
24911da177e4SLinus Torvalds 			lval = (unsigned long)-val;
24921da177e4SLinus Torvalds 		} else {
24931da177e4SLinus Torvalds 			*negp = 0;
24941da177e4SLinus Torvalds 			lval = (unsigned long)val;
24951da177e4SLinus Torvalds 		}
24961da177e4SLinus Torvalds 		*lvalp = jiffies_to_clock_t(lval);
24971da177e4SLinus Torvalds 	}
24981da177e4SLinus Torvalds 	return 0;
24991da177e4SLinus Torvalds }
25001da177e4SLinus Torvalds 
25011da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
25021da177e4SLinus Torvalds 					    int *valp,
25031da177e4SLinus Torvalds 					    int write, void *data)
25041da177e4SLinus Torvalds {
25051da177e4SLinus Torvalds 	if (write) {
25061da177e4SLinus Torvalds 		*valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
25071da177e4SLinus Torvalds 	} else {
25081da177e4SLinus Torvalds 		int val = *valp;
25091da177e4SLinus Torvalds 		unsigned long lval;
25101da177e4SLinus Torvalds 		if (val < 0) {
25111da177e4SLinus Torvalds 			*negp = -1;
25121da177e4SLinus Torvalds 			lval = (unsigned long)-val;
25131da177e4SLinus Torvalds 		} else {
25141da177e4SLinus Torvalds 			*negp = 0;
25151da177e4SLinus Torvalds 			lval = (unsigned long)val;
25161da177e4SLinus Torvalds 		}
25171da177e4SLinus Torvalds 		*lvalp = jiffies_to_msecs(lval);
25181da177e4SLinus Torvalds 	}
25191da177e4SLinus Torvalds 	return 0;
25201da177e4SLinus Torvalds }
25211da177e4SLinus Torvalds 
25221da177e4SLinus Torvalds /**
25231da177e4SLinus Torvalds  * proc_dointvec_jiffies - read a vector of integers as seconds
25241da177e4SLinus Torvalds  * @table: the sysctl table
25251da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25261da177e4SLinus Torvalds  * @buffer: the user buffer
25271da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25281da177e4SLinus Torvalds  * @ppos: file position
25291da177e4SLinus Torvalds  *
25301da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
25311da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25321da177e4SLinus Torvalds  * The values read are assumed to be in seconds, and are converted into
25331da177e4SLinus Torvalds  * jiffies.
25341da177e4SLinus Torvalds  *
25351da177e4SLinus Torvalds  * Returns 0 on success.
25361da177e4SLinus Torvalds  */
25378d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write,
25381da177e4SLinus Torvalds 			  void __user *buffer, size_t *lenp, loff_t *ppos)
25391da177e4SLinus Torvalds {
25408d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
25411da177e4SLinus Torvalds 		    	    do_proc_dointvec_jiffies_conv,NULL);
25421da177e4SLinus Torvalds }
25431da177e4SLinus Torvalds 
25441da177e4SLinus Torvalds /**
25451da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
25461da177e4SLinus Torvalds  * @table: the sysctl table
25471da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25481da177e4SLinus Torvalds  * @buffer: the user buffer
25491da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25501e5d5331SRandy Dunlap  * @ppos: pointer to the file position
25511da177e4SLinus Torvalds  *
25521da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
25531da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25541da177e4SLinus Torvalds  * The values read are assumed to be in 1/USER_HZ seconds, and
25551da177e4SLinus Torvalds  * are converted into jiffies.
25561da177e4SLinus Torvalds  *
25571da177e4SLinus Torvalds  * Returns 0 on success.
25581da177e4SLinus Torvalds  */
25598d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
25601da177e4SLinus Torvalds 				 void __user *buffer, size_t *lenp, loff_t *ppos)
25611da177e4SLinus Torvalds {
25628d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
25631da177e4SLinus Torvalds 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
25641da177e4SLinus Torvalds }
25651da177e4SLinus Torvalds 
25661da177e4SLinus Torvalds /**
25671da177e4SLinus Torvalds  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
25681da177e4SLinus Torvalds  * @table: the sysctl table
25691da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25701da177e4SLinus Torvalds  * @buffer: the user buffer
25711da177e4SLinus Torvalds  * @lenp: the size of the user buffer
257267be2dd1SMartin Waitz  * @ppos: file position
257367be2dd1SMartin Waitz  * @ppos: the current position in the file
25741da177e4SLinus Torvalds  *
25751da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
25761da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25771da177e4SLinus Torvalds  * The values read are assumed to be in 1/1000 seconds, and
25781da177e4SLinus Torvalds  * are converted into jiffies.
25791da177e4SLinus Torvalds  *
25801da177e4SLinus Torvalds  * Returns 0 on success.
25811da177e4SLinus Torvalds  */
25828d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
25831da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
25841da177e4SLinus Torvalds {
25858d65af78SAlexey Dobriyan 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
25861da177e4SLinus Torvalds 				do_proc_dointvec_ms_jiffies_conv, NULL);
25871da177e4SLinus Torvalds }
25881da177e4SLinus Torvalds 
25898d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write,
25909ec52099SCedric Le Goater 			   void __user *buffer, size_t *lenp, loff_t *ppos)
25919ec52099SCedric Le Goater {
25929ec52099SCedric Le Goater 	struct pid *new_pid;
25939ec52099SCedric Le Goater 	pid_t tmp;
25949ec52099SCedric Le Goater 	int r;
25959ec52099SCedric Le Goater 
25966c5f3e7bSPavel Emelyanov 	tmp = pid_vnr(cad_pid);
25979ec52099SCedric Le Goater 
25988d65af78SAlexey Dobriyan 	r = __do_proc_dointvec(&tmp, table, write, buffer,
25999ec52099SCedric Le Goater 			       lenp, ppos, NULL, NULL);
26009ec52099SCedric Le Goater 	if (r || !write)
26019ec52099SCedric Le Goater 		return r;
26029ec52099SCedric Le Goater 
26039ec52099SCedric Le Goater 	new_pid = find_get_pid(tmp);
26049ec52099SCedric Le Goater 	if (!new_pid)
26059ec52099SCedric Le Goater 		return -ESRCH;
26069ec52099SCedric Le Goater 
26079ec52099SCedric Le Goater 	put_pid(xchg(&cad_pid, new_pid));
26089ec52099SCedric Le Goater 	return 0;
26099ec52099SCedric Le Goater }
26109ec52099SCedric Le Goater 
26111da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */
26121da177e4SLinus Torvalds 
26138d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write,
26141da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
26151da177e4SLinus Torvalds {
26161da177e4SLinus Torvalds 	return -ENOSYS;
26171da177e4SLinus Torvalds }
26181da177e4SLinus Torvalds 
26198d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write,
26201da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
26211da177e4SLinus Torvalds {
26221da177e4SLinus Torvalds 	return -ENOSYS;
26231da177e4SLinus Torvalds }
26241da177e4SLinus Torvalds 
26258d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write,
26261da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
26271da177e4SLinus Torvalds {
26281da177e4SLinus Torvalds 	return -ENOSYS;
26291da177e4SLinus Torvalds }
26301da177e4SLinus Torvalds 
26318d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write,
26321da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
26331da177e4SLinus Torvalds {
26341da177e4SLinus Torvalds 	return -ENOSYS;
26351da177e4SLinus Torvalds }
26361da177e4SLinus Torvalds 
26378d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
26381da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
26391da177e4SLinus Torvalds {
26401da177e4SLinus Torvalds 	return -ENOSYS;
26411da177e4SLinus Torvalds }
26421da177e4SLinus Torvalds 
26438d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
26441da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
26451da177e4SLinus Torvalds {
26461da177e4SLinus Torvalds 	return -ENOSYS;
26471da177e4SLinus Torvalds }
26481da177e4SLinus Torvalds 
26498d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write,
26501da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
26511da177e4SLinus Torvalds {
26521da177e4SLinus Torvalds 	return -ENOSYS;
26531da177e4SLinus Torvalds }
26541da177e4SLinus Torvalds 
2655d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
26561da177e4SLinus Torvalds 				      void __user *buffer,
26571da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
26581da177e4SLinus Torvalds {
26591da177e4SLinus Torvalds     return -ENOSYS;
26601da177e4SLinus Torvalds }
26611da177e4SLinus Torvalds 
26621da177e4SLinus Torvalds 
26631da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */
26641da177e4SLinus Torvalds 
26651da177e4SLinus Torvalds /*
26661da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
26671da177e4SLinus Torvalds  * exception granted :-)
26681da177e4SLinus Torvalds  */
26691da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
26701da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
26711da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
26721da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
26731da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
26741da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
26751da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
26761da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
26771da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table);
267829e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths);
26791da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table);
2680