xref: /openbmc/linux/kernel/sysctl.c (revision c55b7c3e82d0ad58f35a0785faaaf2f70b9b6cd3)
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
64*c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT
65*c55b7c3eSDave Young #include <linux/acct.h>
66*c55b7c3eSDave Young #endif
6715485a46SDave Young #ifdef CONFIG_CHR_DEV_SG
6815485a46SDave Young #include <scsi/sg.h>
6915485a46SDave Young #endif
7029cbc78bSAndi Kleen 
717058cb02SEric W. Biederman 
721da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL)
731da177e4SLinus Torvalds 
741da177e4SLinus Torvalds /* External variables not in a header file. */
751da177e4SLinus Torvalds extern int sysctl_overcommit_memory;
761da177e4SLinus Torvalds extern int sysctl_overcommit_ratio;
77fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom;
78fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task;
79fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks;
801da177e4SLinus Torvalds extern int max_threads;
811da177e4SLinus Torvalds extern int core_uses_pid;
82d6e71144SAlan Cox extern int suid_dumpable;
831da177e4SLinus Torvalds extern char core_pattern[];
84a293980cSNeil Horman extern unsigned int core_pipe_limit;
851da177e4SLinus Torvalds extern int pid_max;
861da177e4SLinus Torvalds extern int min_free_kbytes;
871da177e4SLinus Torvalds extern int pid_max_min, pid_max_max;
889d0243bcSAndrew Morton extern int sysctl_drop_caches;
898ad4b1fbSRohit Seth extern int percpu_pagelist_fraction;
90bebfa101SAndi Kleen extern int compat_log;
919745512cSArjan van de Ven extern int latencytop_enabled;
92eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max;
93dd8632a1SPaul Mundt #ifndef CONFIG_MMU
94dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages;
95dd8632a1SPaul Mundt #endif
96cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
975e605b64SJens Axboe extern int blk_iopoll_enabled;
98cb684b5bSJens Axboe #endif
991da177e4SLinus Torvalds 
100c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and  maximum */
101195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP
102c4f3b63fSRavikiran G Thirumalai static int sixty = 60;
1039383d967SDimitri Sivanich static int neg_one = -1;
104c4f3b63fSRavikiran G Thirumalai #endif
105c4f3b63fSRavikiran G Thirumalai 
106c4f3b63fSRavikiran G Thirumalai static int zero;
107cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1;
108cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2;
109fc3501d4SSven Wegener static unsigned long one_ul = 1;
110c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100;
111af91322eSDave Young #ifdef CONFIG_PRINTK
112af91322eSDave Young static int ten_thousand = 10000;
113af91322eSDave Young #endif
114c4f3b63fSRavikiran G Thirumalai 
1159e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
1169e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1179e4a5bdaSAndrea Righi 
1181da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1191da177e4SLinus Torvalds static int maxolduid = 65535;
1201da177e4SLinus Torvalds static int minolduid;
1218ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8;
1221da177e4SLinus Torvalds 
1231da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
1241da177e4SLinus Torvalds 
12572c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
12617f04fbbSDavid S. Miller #include <asm/system.h>
1271da177e4SLinus Torvalds #endif
1281da177e4SLinus Torvalds 
1290871420fSDavid S. Miller #ifdef CONFIG_SPARC64
1300871420fSDavid S. Miller extern int sysctl_tsb_ratio;
1310871420fSDavid S. Miller #endif
1320871420fSDavid S. Miller 
1331da177e4SLinus Torvalds #ifdef __hppa__
1341da177e4SLinus Torvalds extern int pwrsw_enabled;
1351da177e4SLinus Torvalds extern int unaligned_enabled;
1361da177e4SLinus Torvalds #endif
1371da177e4SLinus Torvalds 
138347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
1391da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
1401da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings;
1411da177e4SLinus Torvalds #endif
1421da177e4SLinus Torvalds extern int sysctl_userprocess_debug;
143951f22d5SMartin Schwidefsky extern int spin_retry;
1441da177e4SLinus Torvalds #endif
1451da177e4SLinus Torvalds 
146d2b176edSJes Sorensen #ifdef CONFIG_IA64
147d2b176edSJes Sorensen extern int no_unaligned_warning;
14888fc241fSDoug Chapman extern int unaligned_dump_stack;
149d2b176edSJes Sorensen #endif
150d2b176edSJes Sorensen 
1513fff4c42SIngo Molnar extern struct ratelimit_state printk_ratelimit_state;
1523fff4c42SIngo Molnar 
15323f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
15423f78d4aSIngo Molnar extern int max_lock_depth;
15523f78d4aSIngo Molnar #endif
15623f78d4aSIngo Molnar 
157d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
1588d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write,
1599ec52099SCedric Le Goater 		  void __user *buffer, size_t *lenp, loff_t *ppos);
1608d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write,
16134f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos);
162d6f8ff73SRandy Dunlap #endif
1639ec52099SCedric Le Goater 
164d8217f07SEric W. Biederman static struct ctl_table root_table[];
165e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root;
166e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = {
167b380b0d4SAl Viro 	.count = 1,
168e51b6ba0SEric W. Biederman 	.ctl_table = root_table,
16973455092SAl Viro 	.ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
170e51b6ba0SEric W. Biederman 	.root = &sysctl_table_root,
17173455092SAl Viro 	.set = &sysctl_table_root.default_set,
172e51b6ba0SEric W. Biederman };
173e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = {
174e51b6ba0SEric W. Biederman 	.root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
17573455092SAl Viro 	.default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
176e51b6ba0SEric W. Biederman };
1771da177e4SLinus Torvalds 
178d8217f07SEric W. Biederman static struct ctl_table kern_table[];
179d8217f07SEric W. Biederman static struct ctl_table vm_table[];
180d8217f07SEric W. Biederman static struct ctl_table fs_table[];
181d8217f07SEric W. Biederman static struct ctl_table debug_table[];
182d8217f07SEric W. Biederman static struct ctl_table dev_table[];
183d8217f07SEric W. Biederman extern struct ctl_table random_table[];
1842d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
185d8217f07SEric W. Biederman extern struct ctl_table inotify_table[];
1860399cb08SRobert Love #endif
1877ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
1887ef9964eSDavide Libenzi extern struct ctl_table epoll_table[];
1897ef9964eSDavide Libenzi #endif
1901da177e4SLinus Torvalds 
1911da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1921da177e4SLinus Torvalds int sysctl_legacy_va_layout;
1931da177e4SLinus Torvalds #endif
1941da177e4SLinus Torvalds 
195f20786ffSPeter Zijlstra extern int prove_locking;
196f20786ffSPeter Zijlstra extern int lock_stat;
1979bc9a6bdSEric W. Biederman 
1981da177e4SLinus Torvalds /* The default sysctl tables: */
1991da177e4SLinus Torvalds 
200d8217f07SEric W. Biederman static struct ctl_table root_table[] = {
2011da177e4SLinus Torvalds 	{
2021da177e4SLinus Torvalds 		.procname	= "kernel",
2031da177e4SLinus Torvalds 		.mode		= 0555,
2041da177e4SLinus Torvalds 		.child		= kern_table,
2051da177e4SLinus Torvalds 	},
2061da177e4SLinus Torvalds 	{
2071da177e4SLinus Torvalds 		.procname	= "vm",
2081da177e4SLinus Torvalds 		.mode		= 0555,
2091da177e4SLinus Torvalds 		.child		= vm_table,
2101da177e4SLinus Torvalds 	},
2111da177e4SLinus Torvalds 	{
2121da177e4SLinus Torvalds 		.procname	= "fs",
2131da177e4SLinus Torvalds 		.mode		= 0555,
2141da177e4SLinus Torvalds 		.child		= fs_table,
2151da177e4SLinus Torvalds 	},
2161da177e4SLinus Torvalds 	{
2171da177e4SLinus Torvalds 		.procname	= "debug",
2181da177e4SLinus Torvalds 		.mode		= 0555,
2191da177e4SLinus Torvalds 		.child		= debug_table,
2201da177e4SLinus Torvalds 	},
2211da177e4SLinus Torvalds 	{
2221da177e4SLinus Torvalds 		.procname	= "dev",
2231da177e4SLinus Torvalds 		.mode		= 0555,
2241da177e4SLinus Torvalds 		.child		= dev_table,
2251da177e4SLinus Torvalds 	},
2262be7fe07SAndrew Morton /*
2272be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
2282be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
2292be7fe07SAndrew Morton  */
2306fce56ecSEric W. Biederman 	{ }
2311da177e4SLinus Torvalds };
2321da177e4SLinus Torvalds 
23377e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
23473c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000;		/* 100 usecs */
23573c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
23673c4efd2SEric Dumazet static int min_wakeup_granularity_ns;			/* 0 usecs */
23773c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
2381983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
2391983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
240acb4a848SChristian Ehrhardt static int min_sched_shares_ratelimit = 100000; /* 100 usec */
241acb4a848SChristian Ehrhardt static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
24277e54a1fSIngo Molnar #endif
24377e54a1fSIngo Molnar 
244d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
2452bba22c5SMike Galbraith 	{
2462bba22c5SMike Galbraith 		.procname	= "sched_child_runs_first",
2472bba22c5SMike Galbraith 		.data		= &sysctl_sched_child_runs_first,
2482bba22c5SMike Galbraith 		.maxlen		= sizeof(unsigned int),
2492bba22c5SMike Galbraith 		.mode		= 0644,
2506d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2512bba22c5SMike Galbraith 	},
25277e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
25377e54a1fSIngo Molnar 	{
254b2be5e96SPeter Zijlstra 		.procname	= "sched_min_granularity_ns",
255b2be5e96SPeter Zijlstra 		.data		= &sysctl_sched_min_granularity,
25677e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
25777e54a1fSIngo Molnar 		.mode		= 0644,
258702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
259b2be5e96SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
260b2be5e96SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
26177e54a1fSIngo Molnar 	},
26277e54a1fSIngo Molnar 	{
26321805085SPeter Zijlstra 		.procname	= "sched_latency_ns",
26421805085SPeter Zijlstra 		.data		= &sysctl_sched_latency,
26521805085SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
26621805085SPeter Zijlstra 		.mode		= 0644,
267702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
26821805085SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
26921805085SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
27021805085SPeter Zijlstra 	},
27121805085SPeter Zijlstra 	{
27277e54a1fSIngo Molnar 		.procname	= "sched_wakeup_granularity_ns",
27377e54a1fSIngo Molnar 		.data		= &sysctl_sched_wakeup_granularity,
27477e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
27577e54a1fSIngo Molnar 		.mode		= 0644,
276702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
27777e54a1fSIngo Molnar 		.extra1		= &min_wakeup_granularity_ns,
27877e54a1fSIngo Molnar 		.extra2		= &max_wakeup_granularity_ns,
27977e54a1fSIngo Molnar 	},
28077e54a1fSIngo Molnar 	{
2812398f2c6SPeter Zijlstra 		.procname	= "sched_shares_ratelimit",
2822398f2c6SPeter Zijlstra 		.data		= &sysctl_sched_shares_ratelimit,
2832398f2c6SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
2842398f2c6SPeter Zijlstra 		.mode		= 0644,
285702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
286acb4a848SChristian Ehrhardt 		.extra1		= &min_sched_shares_ratelimit,
287acb4a848SChristian Ehrhardt 		.extra2		= &max_sched_shares_ratelimit,
2882398f2c6SPeter Zijlstra 	},
2892398f2c6SPeter Zijlstra 	{
2901983a922SChristian Ehrhardt 		.procname	= "sched_tunable_scaling",
2911983a922SChristian Ehrhardt 		.data		= &sysctl_sched_tunable_scaling,
2921983a922SChristian Ehrhardt 		.maxlen		= sizeof(enum sched_tunable_scaling),
2931983a922SChristian Ehrhardt 		.mode		= 0644,
294702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
2951983a922SChristian Ehrhardt 		.extra1		= &min_sched_tunable_scaling,
2961983a922SChristian Ehrhardt 		.extra2		= &max_sched_tunable_scaling,
2972398f2c6SPeter Zijlstra 	},
2982398f2c6SPeter Zijlstra 	{
299ffda12a1SPeter Zijlstra 		.procname	= "sched_shares_thresh",
300ffda12a1SPeter Zijlstra 		.data		= &sysctl_sched_shares_thresh,
301ffda12a1SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
302ffda12a1SPeter Zijlstra 		.mode		= 0644,
3036d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
304ffda12a1SPeter Zijlstra 		.extra1		= &zero,
305ffda12a1SPeter Zijlstra 	},
306ffda12a1SPeter Zijlstra 	{
307da84d961SIngo Molnar 		.procname	= "sched_migration_cost",
308da84d961SIngo Molnar 		.data		= &sysctl_sched_migration_cost,
309da84d961SIngo Molnar 		.maxlen		= sizeof(unsigned int),
310da84d961SIngo Molnar 		.mode		= 0644,
3116d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
312da84d961SIngo Molnar 	},
313b82d9fddSPeter Zijlstra 	{
314b82d9fddSPeter Zijlstra 		.procname	= "sched_nr_migrate",
315b82d9fddSPeter Zijlstra 		.data		= &sysctl_sched_nr_migrate,
316b82d9fddSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
317fa85ae24SPeter Zijlstra 		.mode		= 0644,
3186d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
319fa85ae24SPeter Zijlstra 	},
320cd1bb94bSArun R Bharadwaj 	{
321e9e9250bSPeter Zijlstra 		.procname	= "sched_time_avg",
322e9e9250bSPeter Zijlstra 		.data		= &sysctl_sched_time_avg,
323e9e9250bSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
324e9e9250bSPeter Zijlstra 		.mode		= 0644,
3256d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
326e9e9250bSPeter Zijlstra 	},
327e9e9250bSPeter Zijlstra 	{
328cd1bb94bSArun R Bharadwaj 		.procname	= "timer_migration",
329cd1bb94bSArun R Bharadwaj 		.data		= &sysctl_timer_migration,
330cd1bb94bSArun R Bharadwaj 		.maxlen		= sizeof(unsigned int),
331cd1bb94bSArun R Bharadwaj 		.mode		= 0644,
3326d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
333bfdb4d9fSArun R Bharadwaj 		.extra1		= &zero,
334bfdb4d9fSArun R Bharadwaj 		.extra2		= &one,
335cd1bb94bSArun R Bharadwaj 	},
3361fc84aaaSPeter Zijlstra #endif
3371799e35dSIngo Molnar 	{
3389f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
3399f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
3409f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3419f0c1e56SPeter Zijlstra 		.mode		= 0644,
3426d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
3439f0c1e56SPeter Zijlstra 	},
3449f0c1e56SPeter Zijlstra 	{
3459f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
3469f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
3479f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
3489f0c1e56SPeter Zijlstra 		.mode		= 0644,
3496d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
3509f0c1e56SPeter Zijlstra 	},
3519f0c1e56SPeter Zijlstra 	{
3521799e35dSIngo Molnar 		.procname	= "sched_compat_yield",
3531799e35dSIngo Molnar 		.data		= &sysctl_sched_compat_yield,
3541799e35dSIngo Molnar 		.maxlen		= sizeof(unsigned int),
3551799e35dSIngo Molnar 		.mode		= 0644,
3566d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3571799e35dSIngo Molnar 	},
358f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
359f20786ffSPeter Zijlstra 	{
360f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
361f20786ffSPeter Zijlstra 		.data		= &prove_locking,
362f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
363f20786ffSPeter Zijlstra 		.mode		= 0644,
3646d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
365f20786ffSPeter Zijlstra 	},
366f20786ffSPeter Zijlstra #endif
367f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
368f20786ffSPeter Zijlstra 	{
369f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
370f20786ffSPeter Zijlstra 		.data		= &lock_stat,
371f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
372f20786ffSPeter Zijlstra 		.mode		= 0644,
3736d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
374f20786ffSPeter Zijlstra 	},
375f20786ffSPeter Zijlstra #endif
37677e54a1fSIngo Molnar 	{
3771da177e4SLinus Torvalds 		.procname	= "panic",
3781da177e4SLinus Torvalds 		.data		= &panic_timeout,
3791da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
3801da177e4SLinus Torvalds 		.mode		= 0644,
3816d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3821da177e4SLinus Torvalds 	},
3831da177e4SLinus Torvalds 	{
3841da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
3851da177e4SLinus Torvalds 		.data		= &core_uses_pid,
3861da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
3871da177e4SLinus Torvalds 		.mode		= 0644,
3886d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3891da177e4SLinus Torvalds 	},
3901da177e4SLinus Torvalds 	{
3911da177e4SLinus Torvalds 		.procname	= "core_pattern",
3921da177e4SLinus Torvalds 		.data		= core_pattern,
39371ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
3941da177e4SLinus Torvalds 		.mode		= 0644,
3956d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
3961da177e4SLinus Torvalds 	},
397a293980cSNeil Horman 	{
398a293980cSNeil Horman 		.procname	= "core_pipe_limit",
399a293980cSNeil Horman 		.data		= &core_pipe_limit,
400a293980cSNeil Horman 		.maxlen		= sizeof(unsigned int),
401a293980cSNeil Horman 		.mode		= 0644,
4026d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
403a293980cSNeil Horman 	},
40434f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
4051da177e4SLinus Torvalds 	{
4061da177e4SLinus Torvalds 		.procname	= "tainted",
40725ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
40834f5a398STheodore Ts'o 		.mode		= 0644,
4096d456111SEric W. Biederman 		.proc_handler	= proc_taint,
4101da177e4SLinus Torvalds 	},
41134f5a398STheodore Ts'o #endif
4129745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
4139745512cSArjan van de Ven 	{
4149745512cSArjan van de Ven 		.procname	= "latencytop",
4159745512cSArjan van de Ven 		.data		= &latencytop_enabled,
4169745512cSArjan van de Ven 		.maxlen		= sizeof(int),
4179745512cSArjan van de Ven 		.mode		= 0644,
4186d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4199745512cSArjan van de Ven 	},
4209745512cSArjan van de Ven #endif
4211da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
4221da177e4SLinus Torvalds 	{
4231da177e4SLinus Torvalds 		.procname	= "real-root-dev",
4241da177e4SLinus Torvalds 		.data		= &real_root_dev,
4251da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4261da177e4SLinus Torvalds 		.mode		= 0644,
4276d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4281da177e4SLinus Torvalds 	},
4291da177e4SLinus Torvalds #endif
43045807a1dSIngo Molnar 	{
43145807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
43245807a1dSIngo Molnar 		.data		= &print_fatal_signals,
43345807a1dSIngo Molnar 		.maxlen		= sizeof(int),
43445807a1dSIngo Molnar 		.mode		= 0644,
4356d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
43645807a1dSIngo Molnar 	},
43772c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
4381da177e4SLinus Torvalds 	{
4391da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
4401da177e4SLinus Torvalds 		.data		= reboot_command,
4411da177e4SLinus Torvalds 		.maxlen		= 256,
4421da177e4SLinus Torvalds 		.mode		= 0644,
4436d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
4441da177e4SLinus Torvalds 	},
4451da177e4SLinus Torvalds 	{
4461da177e4SLinus Torvalds 		.procname	= "stop-a",
4471da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
4481da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4491da177e4SLinus Torvalds 		.mode		= 0644,
4506d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4511da177e4SLinus Torvalds 	},
4521da177e4SLinus Torvalds 	{
4531da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
4541da177e4SLinus Torvalds 		.data		= &scons_pwroff,
4551da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4561da177e4SLinus Torvalds 		.mode		= 0644,
4576d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4581da177e4SLinus Torvalds 	},
4591da177e4SLinus Torvalds #endif
4600871420fSDavid S. Miller #ifdef CONFIG_SPARC64
4610871420fSDavid S. Miller 	{
4620871420fSDavid S. Miller 		.procname	= "tsb-ratio",
4630871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
4640871420fSDavid S. Miller 		.maxlen		= sizeof (int),
4650871420fSDavid S. Miller 		.mode		= 0644,
4666d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4670871420fSDavid S. Miller 	},
4680871420fSDavid S. Miller #endif
4691da177e4SLinus Torvalds #ifdef __hppa__
4701da177e4SLinus Torvalds 	{
4711da177e4SLinus Torvalds 		.procname	= "soft-power",
4721da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
4731da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4741da177e4SLinus Torvalds 	 	.mode		= 0644,
4756d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4761da177e4SLinus Torvalds 	},
4771da177e4SLinus Torvalds 	{
4781da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
4791da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
4801da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4811da177e4SLinus Torvalds 		.mode		= 0644,
4826d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4831da177e4SLinus Torvalds 	},
4841da177e4SLinus Torvalds #endif
4851da177e4SLinus Torvalds 	{
4861da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
4871da177e4SLinus Torvalds 		.data		= &C_A_D,
4881da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4891da177e4SLinus Torvalds 		.mode		= 0644,
4906d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4911da177e4SLinus Torvalds 	},
492606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
493b0fc494fSSteven Rostedt 	{
494b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
495b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
496b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
497b0fc494fSSteven Rostedt 		.mode		= 0644,
4986d456111SEric W. Biederman 		.proc_handler	= ftrace_enable_sysctl,
499b0fc494fSSteven Rostedt 	},
500b0fc494fSSteven Rostedt #endif
501f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
502f38f1d2aSSteven Rostedt 	{
503f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
504f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
505f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
506f38f1d2aSSteven Rostedt 		.mode		= 0644,
5076d456111SEric W. Biederman 		.proc_handler	= stack_trace_sysctl,
508f38f1d2aSSteven Rostedt 	},
509f38f1d2aSSteven Rostedt #endif
510944ac425SSteven Rostedt #ifdef CONFIG_TRACING
511944ac425SSteven Rostedt 	{
5123299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
513944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
514944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
515944ac425SSteven Rostedt 		.mode		= 0644,
5166d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
517944ac425SSteven Rostedt 	},
518944ac425SSteven Rostedt #endif
519a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
5201da177e4SLinus Torvalds 	{
5211da177e4SLinus Torvalds 		.procname	= "modprobe",
5221da177e4SLinus Torvalds 		.data		= &modprobe_path,
5231da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
5241da177e4SLinus Torvalds 		.mode		= 0644,
5256d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
5261da177e4SLinus Torvalds 	},
5273d43321bSKees Cook 	{
5283d43321bSKees Cook 		.procname	= "modules_disabled",
5293d43321bSKees Cook 		.data		= &modules_disabled,
5303d43321bSKees Cook 		.maxlen		= sizeof(int),
5313d43321bSKees Cook 		.mode		= 0644,
5323d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
5336d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
5343d43321bSKees Cook 		.extra1		= &one,
5353d43321bSKees Cook 		.extra2		= &one,
5363d43321bSKees Cook 	},
5371da177e4SLinus Torvalds #endif
53857ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
5391da177e4SLinus Torvalds 	{
5401da177e4SLinus Torvalds 		.procname	= "hotplug",
541312c004dSKay Sievers 		.data		= &uevent_helper,
542312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
5431da177e4SLinus Torvalds 		.mode		= 0644,
5446d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
5451da177e4SLinus Torvalds 	},
5461da177e4SLinus Torvalds #endif
5471da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
5481da177e4SLinus Torvalds 	{
5491da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
5501da177e4SLinus Torvalds 		.data		= &sg_big_buff,
5511da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5521da177e4SLinus Torvalds 		.mode		= 0444,
5536d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5541da177e4SLinus Torvalds 	},
5551da177e4SLinus Torvalds #endif
5561da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
5571da177e4SLinus Torvalds 	{
5581da177e4SLinus Torvalds 		.procname	= "acct",
5591da177e4SLinus Torvalds 		.data		= &acct_parm,
5601da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
5611da177e4SLinus Torvalds 		.mode		= 0644,
5626d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5631da177e4SLinus Torvalds 	},
5641da177e4SLinus Torvalds #endif
5651da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
5661da177e4SLinus Torvalds 	{
5671da177e4SLinus Torvalds 		.procname	= "sysrq",
5685d6f647fSIngo Molnar 		.data		= &__sysrq_enabled,
5691da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5701da177e4SLinus Torvalds 		.mode		= 0644,
5716d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5721da177e4SLinus Torvalds 	},
5731da177e4SLinus Torvalds #endif
574d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
5751da177e4SLinus Torvalds 	{
5761da177e4SLinus Torvalds 		.procname	= "cad_pid",
5779ec52099SCedric Le Goater 		.data		= NULL,
5781da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5791da177e4SLinus Torvalds 		.mode		= 0600,
5806d456111SEric W. Biederman 		.proc_handler	= proc_do_cad_pid,
5811da177e4SLinus Torvalds 	},
582d6f8ff73SRandy Dunlap #endif
5831da177e4SLinus Torvalds 	{
5841da177e4SLinus Torvalds 		.procname	= "threads-max",
5851da177e4SLinus Torvalds 		.data		= &max_threads,
5861da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5871da177e4SLinus Torvalds 		.mode		= 0644,
5886d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5891da177e4SLinus Torvalds 	},
5901da177e4SLinus Torvalds 	{
5911da177e4SLinus Torvalds 		.procname	= "random",
5921da177e4SLinus Torvalds 		.mode		= 0555,
5931da177e4SLinus Torvalds 		.child		= random_table,
5941da177e4SLinus Torvalds 	},
5951da177e4SLinus Torvalds 	{
5961da177e4SLinus Torvalds 		.procname	= "overflowuid",
5971da177e4SLinus Torvalds 		.data		= &overflowuid,
5981da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5991da177e4SLinus Torvalds 		.mode		= 0644,
6006d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6011da177e4SLinus Torvalds 		.extra1		= &minolduid,
6021da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6031da177e4SLinus Torvalds 	},
6041da177e4SLinus Torvalds 	{
6051da177e4SLinus Torvalds 		.procname	= "overflowgid",
6061da177e4SLinus Torvalds 		.data		= &overflowgid,
6071da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6081da177e4SLinus Torvalds 		.mode		= 0644,
6096d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6101da177e4SLinus Torvalds 		.extra1		= &minolduid,
6111da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6121da177e4SLinus Torvalds 	},
613347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
6141da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
6151da177e4SLinus Torvalds 	{
6161da177e4SLinus Torvalds 		.procname	= "ieee_emulation_warnings",
6171da177e4SLinus Torvalds 		.data		= &sysctl_ieee_emulation_warnings,
6181da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6191da177e4SLinus Torvalds 		.mode		= 0644,
6206d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6211da177e4SLinus Torvalds 	},
6221da177e4SLinus Torvalds #endif
6231da177e4SLinus Torvalds 	{
6241da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
6251da177e4SLinus Torvalds 		.data		= &sysctl_userprocess_debug,
6261da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6271da177e4SLinus Torvalds 		.mode		= 0644,
6286d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6291da177e4SLinus Torvalds 	},
6301da177e4SLinus Torvalds #endif
6311da177e4SLinus Torvalds 	{
6321da177e4SLinus Torvalds 		.procname	= "pid_max",
6331da177e4SLinus Torvalds 		.data		= &pid_max,
6341da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6351da177e4SLinus Torvalds 		.mode		= 0644,
6366d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6371da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
6381da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
6391da177e4SLinus Torvalds 	},
6401da177e4SLinus Torvalds 	{
6411da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
6421da177e4SLinus Torvalds 		.data		= &panic_on_oops,
6431da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6441da177e4SLinus Torvalds 		.mode		= 0644,
6456d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6461da177e4SLinus Torvalds 	},
6477ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
6487ef3d2fdSJoe Perches 	{
6497ef3d2fdSJoe Perches 		.procname	= "printk",
6507ef3d2fdSJoe Perches 		.data		= &console_loglevel,
6517ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
6527ef3d2fdSJoe Perches 		.mode		= 0644,
6536d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6547ef3d2fdSJoe Perches 	},
6551da177e4SLinus Torvalds 	{
6561da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
657717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
6581da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6591da177e4SLinus Torvalds 		.mode		= 0644,
6606d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
6611da177e4SLinus Torvalds 	},
6621da177e4SLinus Torvalds 	{
6631da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
664717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
6651da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6661da177e4SLinus Torvalds 		.mode		= 0644,
6676d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6681da177e4SLinus Torvalds 	},
669af91322eSDave Young 	{
670af91322eSDave Young 		.procname	= "printk_delay",
671af91322eSDave Young 		.data		= &printk_delay_msec,
672af91322eSDave Young 		.maxlen		= sizeof(int),
673af91322eSDave Young 		.mode		= 0644,
6746d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
675af91322eSDave Young 		.extra1		= &zero,
676af91322eSDave Young 		.extra2		= &ten_thousand,
677af91322eSDave Young 	},
6787ef3d2fdSJoe Perches #endif
6791da177e4SLinus Torvalds 	{
6801da177e4SLinus Torvalds 		.procname	= "ngroups_max",
6811da177e4SLinus Torvalds 		.data		= &ngroups_max,
6821da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6831da177e4SLinus Torvalds 		.mode		= 0444,
6846d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6851da177e4SLinus Torvalds 	},
6861da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
6871da177e4SLinus Torvalds 	{
6881da177e4SLinus Torvalds 		.procname       = "unknown_nmi_panic",
6891da177e4SLinus Torvalds 		.data           = &unknown_nmi_panic,
6901da177e4SLinus Torvalds 		.maxlen         = sizeof (int),
6911da177e4SLinus Torvalds 		.mode           = 0644,
6926d456111SEric W. Biederman 		.proc_handler   = proc_dointvec,
6931da177e4SLinus Torvalds 	},
694407984f1SDon Zickus 	{
695407984f1SDon Zickus 		.procname       = "nmi_watchdog",
696407984f1SDon Zickus 		.data           = &nmi_watchdog_enabled,
697407984f1SDon Zickus 		.maxlen         = sizeof (int),
698407984f1SDon Zickus 		.mode           = 0644,
6996d456111SEric W. Biederman 		.proc_handler   = proc_nmi_enabled,
7001da177e4SLinus Torvalds 	},
7011da177e4SLinus Torvalds #endif
7021da177e4SLinus Torvalds #if defined(CONFIG_X86)
7031da177e4SLinus Torvalds 	{
7048da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
7058da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
7068da5addaSDon Zickus 		.maxlen		= sizeof(int),
7078da5addaSDon Zickus 		.mode		= 0644,
7086d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7098da5addaSDon Zickus 	},
7108da5addaSDon Zickus 	{
7115211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
7125211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
7135211a242SKurt Garloff 		.maxlen		= sizeof(int),
7145211a242SKurt Garloff 		.mode		= 0644,
7156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7165211a242SKurt Garloff 	},
7175211a242SKurt Garloff 	{
7181da177e4SLinus Torvalds 		.procname	= "bootloader_type",
7191da177e4SLinus Torvalds 		.data		= &bootloader_type,
7201da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7211da177e4SLinus Torvalds 		.mode		= 0444,
7226d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7231da177e4SLinus Torvalds 	},
7240741f4d2SChuck Ebbert 	{
7255031296cSH. Peter Anvin 		.procname	= "bootloader_version",
7265031296cSH. Peter Anvin 		.data		= &bootloader_version,
7275031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
7285031296cSH. Peter Anvin 		.mode		= 0444,
7296d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7305031296cSH. Peter Anvin 	},
7315031296cSH. Peter Anvin 	{
7320741f4d2SChuck Ebbert 		.procname	= "kstack_depth_to_print",
7330741f4d2SChuck Ebbert 		.data		= &kstack_depth_to_print,
7340741f4d2SChuck Ebbert 		.maxlen		= sizeof(int),
7350741f4d2SChuck Ebbert 		.mode		= 0644,
7366d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7370741f4d2SChuck Ebbert 	},
7386e7c4025SIngo Molnar 	{
7396e7c4025SIngo Molnar 		.procname	= "io_delay_type",
7406e7c4025SIngo Molnar 		.data		= &io_delay_type,
7416e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
7426e7c4025SIngo Molnar 		.mode		= 0644,
7436d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7446e7c4025SIngo Molnar 	},
7451da177e4SLinus Torvalds #endif
7467a9166e3SLuke Yang #if defined(CONFIG_MMU)
7471da177e4SLinus Torvalds 	{
7481da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
7491da177e4SLinus Torvalds 		.data		= &randomize_va_space,
7501da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7511da177e4SLinus Torvalds 		.mode		= 0644,
7526d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7531da177e4SLinus Torvalds 	},
7547a9166e3SLuke Yang #endif
7550152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
756951f22d5SMartin Schwidefsky 	{
757951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
758951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
759951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
760951f22d5SMartin Schwidefsky 		.mode		= 0644,
7616d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
762951f22d5SMartin Schwidefsky 	},
763951f22d5SMartin Schwidefsky #endif
764673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
765c255d844SPavel Machek 	{
766c255d844SPavel Machek 		.procname	= "acpi_video_flags",
76777afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
768c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
769c255d844SPavel Machek 		.mode		= 0644,
7706d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
771c255d844SPavel Machek 	},
772c255d844SPavel Machek #endif
773d2b176edSJes Sorensen #ifdef CONFIG_IA64
774d2b176edSJes Sorensen 	{
775d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
776d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
777d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
778d2b176edSJes Sorensen 	 	.mode		= 0644,
7796d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
780d2b176edSJes Sorensen 	},
78188fc241fSDoug Chapman 	{
78288fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
78388fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
78488fc241fSDoug Chapman 		.maxlen		= sizeof (int),
78588fc241fSDoug Chapman 		.mode		= 0644,
7866d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
78788fc241fSDoug Chapman 	},
788d2b176edSJes Sorensen #endif
789c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP
790c4f3b63fSRavikiran G Thirumalai 	{
7919c44bc03SIngo Molnar 		.procname	= "softlockup_panic",
7929c44bc03SIngo Molnar 		.data		= &softlockup_panic,
7939c44bc03SIngo Molnar 		.maxlen		= sizeof(int),
7949c44bc03SIngo Molnar 		.mode		= 0644,
7956d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
7969c44bc03SIngo Molnar 		.extra1		= &zero,
7979c44bc03SIngo Molnar 		.extra2		= &one,
7989c44bc03SIngo Molnar 	},
7999c44bc03SIngo Molnar 	{
800c4f3b63fSRavikiran G Thirumalai 		.procname	= "softlockup_thresh",
801c4f3b63fSRavikiran G Thirumalai 		.data		= &softlockup_thresh,
8029383d967SDimitri Sivanich 		.maxlen		= sizeof(int),
803c4f3b63fSRavikiran G Thirumalai 		.mode		= 0644,
8046d456111SEric W. Biederman 		.proc_handler	= proc_dosoftlockup_thresh,
8059383d967SDimitri Sivanich 		.extra1		= &neg_one,
806c4f3b63fSRavikiran G Thirumalai 		.extra2		= &sixty,
807c4f3b63fSRavikiran G Thirumalai 	},
808e162b39aSMandeep Singh Baines #endif
809e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
810e162b39aSMandeep Singh Baines 	{
811e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
812e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
813e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
814e162b39aSMandeep Singh Baines 		.mode		= 0644,
8156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
816e162b39aSMandeep Singh Baines 		.extra1		= &zero,
817e162b39aSMandeep Singh Baines 		.extra2		= &one,
818e162b39aSMandeep Singh Baines 	},
81982a1fcb9SIngo Molnar 	{
82082a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
82182a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
82290739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
82382a1fcb9SIngo Molnar 		.mode		= 0644,
8246d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
82582a1fcb9SIngo Molnar 	},
82682a1fcb9SIngo Molnar 	{
82782a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
82882a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
82990739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
83082a1fcb9SIngo Molnar 		.mode		= 0644,
8316d456111SEric W. Biederman 		.proc_handler	= proc_dohung_task_timeout_secs,
83282a1fcb9SIngo Molnar 	},
83382a1fcb9SIngo Molnar 	{
83482a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
83582a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
83690739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
83782a1fcb9SIngo Molnar 		.mode		= 0644,
8386d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
83982a1fcb9SIngo Molnar 	},
840c4f3b63fSRavikiran G Thirumalai #endif
841bebfa101SAndi Kleen #ifdef CONFIG_COMPAT
842bebfa101SAndi Kleen 	{
843bebfa101SAndi Kleen 		.procname	= "compat-log",
844bebfa101SAndi Kleen 		.data		= &compat_log,
845bebfa101SAndi Kleen 		.maxlen		= sizeof (int),
846bebfa101SAndi Kleen 	 	.mode		= 0644,
8476d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
848bebfa101SAndi Kleen 	},
849bebfa101SAndi Kleen #endif
85023f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
85123f78d4aSIngo Molnar 	{
85223f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
85323f78d4aSIngo Molnar 		.data		= &max_lock_depth,
85423f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
85523f78d4aSIngo Molnar 		.mode		= 0644,
8566d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
85723f78d4aSIngo Molnar 	},
85823f78d4aSIngo Molnar #endif
85910a0a8d4SJeremy Fitzhardinge 	{
86010a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
86110a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
86210a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
86310a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
8646d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
86510a0a8d4SJeremy Fitzhardinge 	},
8660b77f5bfSDavid Howells #ifdef CONFIG_KEYS
8670b77f5bfSDavid Howells 	{
8680b77f5bfSDavid Howells 		.procname	= "keys",
8690b77f5bfSDavid Howells 		.mode		= 0555,
8700b77f5bfSDavid Howells 		.child		= key_sysctls,
8710b77f5bfSDavid Howells 	},
8720b77f5bfSDavid Howells #endif
87331a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
87431a72bceSPaul E. McKenney 	{
87531a72bceSPaul E. McKenney 		.procname       = "rcutorture_runnable",
87631a72bceSPaul E. McKenney 		.data           = &rcutorture_runnable,
87731a72bceSPaul E. McKenney 		.maxlen         = sizeof(int),
87831a72bceSPaul E. McKenney 		.mode           = 0644,
8796d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
88031a72bceSPaul E. McKenney 	},
88131a72bceSPaul E. McKenney #endif
88212e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK
88312e22c5eSDavid Howells 	{
88412e22c5eSDavid Howells 		.procname	= "slow-work",
88512e22c5eSDavid Howells 		.mode		= 0555,
88612e22c5eSDavid Howells 		.child		= slow_work_sysctls,
88712e22c5eSDavid Howells 	},
88812e22c5eSDavid Howells #endif
889cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS
8901ccd1549SPeter Zijlstra 	{
891cdd6c482SIngo Molnar 		.procname	= "perf_event_paranoid",
892cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_paranoid,
893cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_paranoid),
8941ccd1549SPeter Zijlstra 		.mode		= 0644,
8956d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
8961ccd1549SPeter Zijlstra 	},
897c5078f78SPeter Zijlstra 	{
898cdd6c482SIngo Molnar 		.procname	= "perf_event_mlock_kb",
899cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_mlock,
900cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_mlock),
901c5078f78SPeter Zijlstra 		.mode		= 0644,
9026d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
903c5078f78SPeter Zijlstra 	},
904a78ac325SPeter Zijlstra 	{
905cdd6c482SIngo Molnar 		.procname	= "perf_event_max_sample_rate",
906cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_sample_rate,
907cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
908a78ac325SPeter Zijlstra 		.mode		= 0644,
9096d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
910a78ac325SPeter Zijlstra 	},
9111ccd1549SPeter Zijlstra #endif
912dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK
913dfec072eSVegard Nossum 	{
914dfec072eSVegard Nossum 		.procname	= "kmemcheck",
915dfec072eSVegard Nossum 		.data		= &kmemcheck_enabled,
916dfec072eSVegard Nossum 		.maxlen		= sizeof(int),
917dfec072eSVegard Nossum 		.mode		= 0644,
9186d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
919dfec072eSVegard Nossum 	},
920dfec072eSVegard Nossum #endif
921cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
9225e605b64SJens Axboe 	{
9235e605b64SJens Axboe 		.procname	= "blk_iopoll",
9245e605b64SJens Axboe 		.data		= &blk_iopoll_enabled,
9255e605b64SJens Axboe 		.maxlen		= sizeof(int),
9265e605b64SJens Axboe 		.mode		= 0644,
9276d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9285e605b64SJens Axboe 	},
929cb684b5bSJens Axboe #endif
930ed2c12f3SAndrew Morton /*
931ed2c12f3SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
932ed2c12f3SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
933ed2c12f3SAndrew Morton  */
9346fce56ecSEric W. Biederman 	{ }
9351da177e4SLinus Torvalds };
9361da177e4SLinus Torvalds 
937d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
9381da177e4SLinus Torvalds 	{
9391da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
9401da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
9411da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
9421da177e4SLinus Torvalds 		.mode		= 0644,
9436d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9441da177e4SLinus Torvalds 	},
9451da177e4SLinus Torvalds 	{
946fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
947fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
948fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
949fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
9506d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
951fadd8fbdSKAMEZAWA Hiroyuki 	},
952fadd8fbdSKAMEZAWA Hiroyuki 	{
953fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
954fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
955fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
956fe071d7eSDavid Rientjes 		.mode		= 0644,
9576d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
958fe071d7eSDavid Rientjes 	},
959fe071d7eSDavid Rientjes 	{
960fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
961fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
962fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
963fef1bdd6SDavid Rientjes 		.mode		= 0644,
9646d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
965fef1bdd6SDavid Rientjes 	},
966fef1bdd6SDavid Rientjes 	{
9671da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
9681da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
9691da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
9701da177e4SLinus Torvalds 		.mode		= 0644,
9716d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9721da177e4SLinus Torvalds 	},
9731da177e4SLinus Torvalds 	{
9741da177e4SLinus Torvalds 		.procname	= "page-cluster",
9751da177e4SLinus Torvalds 		.data		= &page_cluster,
9761da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
9771da177e4SLinus Torvalds 		.mode		= 0644,
9786d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9791da177e4SLinus Torvalds 	},
9801da177e4SLinus Torvalds 	{
9811da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
9821da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
9831da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
9841da177e4SLinus Torvalds 		.mode		= 0644,
9856d456111SEric W. Biederman 		.proc_handler	= dirty_background_ratio_handler,
9861da177e4SLinus Torvalds 		.extra1		= &zero,
9871da177e4SLinus Torvalds 		.extra2		= &one_hundred,
9881da177e4SLinus Torvalds 	},
9891da177e4SLinus Torvalds 	{
9902da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
9912da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
9922da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
9932da02997SDavid Rientjes 		.mode		= 0644,
9946d456111SEric W. Biederman 		.proc_handler	= dirty_background_bytes_handler,
995fc3501d4SSven Wegener 		.extra1		= &one_ul,
9962da02997SDavid Rientjes 	},
9972da02997SDavid Rientjes 	{
9981da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
9991da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
10001da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
10011da177e4SLinus Torvalds 		.mode		= 0644,
10026d456111SEric W. Biederman 		.proc_handler	= dirty_ratio_handler,
10031da177e4SLinus Torvalds 		.extra1		= &zero,
10041da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10051da177e4SLinus Torvalds 	},
10061da177e4SLinus Torvalds 	{
10072da02997SDavid Rientjes 		.procname	= "dirty_bytes",
10082da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
10092da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
10102da02997SDavid Rientjes 		.mode		= 0644,
10116d456111SEric W. Biederman 		.proc_handler	= dirty_bytes_handler,
10129e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
10132da02997SDavid Rientjes 	},
10142da02997SDavid Rientjes 	{
10151da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
1016f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
1017f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
10181da177e4SLinus Torvalds 		.mode		= 0644,
10196d456111SEric W. Biederman 		.proc_handler	= dirty_writeback_centisecs_handler,
10201da177e4SLinus Torvalds 	},
10211da177e4SLinus Torvalds 	{
10221da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
1023f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
1024f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
10251da177e4SLinus Torvalds 		.mode		= 0644,
10266d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10271da177e4SLinus Torvalds 	},
10281da177e4SLinus Torvalds 	{
10291da177e4SLinus Torvalds 		.procname	= "nr_pdflush_threads",
10301da177e4SLinus Torvalds 		.data		= &nr_pdflush_threads,
10311da177e4SLinus Torvalds 		.maxlen		= sizeof nr_pdflush_threads,
10321da177e4SLinus Torvalds 		.mode		= 0444 /* read-only*/,
10336d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10341da177e4SLinus Torvalds 	},
10351da177e4SLinus Torvalds 	{
10361da177e4SLinus Torvalds 		.procname	= "swappiness",
10371da177e4SLinus Torvalds 		.data		= &vm_swappiness,
10381da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
10391da177e4SLinus Torvalds 		.mode		= 0644,
10406d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
10411da177e4SLinus Torvalds 		.extra1		= &zero,
10421da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10431da177e4SLinus Torvalds 	},
10441da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
10451da177e4SLinus Torvalds 	{
10461da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
1047e5ff2159SAndi Kleen 		.data		= NULL,
10481da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
10491da177e4SLinus Torvalds 		.mode		= 0644,
10506d456111SEric W. Biederman 		.proc_handler	= hugetlb_sysctl_handler,
10511da177e4SLinus Torvalds 		.extra1		= (void *)&hugetlb_zero,
10521da177e4SLinus Torvalds 		.extra2		= (void *)&hugetlb_infinity,
10531da177e4SLinus Torvalds 	},
105406808b08SLee Schermerhorn #ifdef CONFIG_NUMA
105506808b08SLee Schermerhorn 	{
105606808b08SLee Schermerhorn 		.procname       = "nr_hugepages_mempolicy",
105706808b08SLee Schermerhorn 		.data           = NULL,
105806808b08SLee Schermerhorn 		.maxlen         = sizeof(unsigned long),
105906808b08SLee Schermerhorn 		.mode           = 0644,
106006808b08SLee Schermerhorn 		.proc_handler   = &hugetlb_mempolicy_sysctl_handler,
106106808b08SLee Schermerhorn 		.extra1		= (void *)&hugetlb_zero,
106206808b08SLee Schermerhorn 		.extra2		= (void *)&hugetlb_infinity,
106306808b08SLee Schermerhorn 	},
106406808b08SLee Schermerhorn #endif
10651da177e4SLinus Torvalds 	 {
10661da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
10671da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
10681da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
10691da177e4SLinus Torvalds 		.mode		= 0644,
10706d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10711da177e4SLinus Torvalds 	 },
1072396faf03SMel Gorman 	 {
1073396faf03SMel Gorman 		.procname	= "hugepages_treat_as_movable",
1074396faf03SMel Gorman 		.data		= &hugepages_treat_as_movable,
1075396faf03SMel Gorman 		.maxlen		= sizeof(int),
1076396faf03SMel Gorman 		.mode		= 0644,
10776d456111SEric W. Biederman 		.proc_handler	= hugetlb_treat_movable_handler,
1078396faf03SMel Gorman 	},
107954f9f80dSAdam Litke 	{
1080d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
1081e5ff2159SAndi Kleen 		.data		= NULL,
1082e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
1083d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
10846d456111SEric W. Biederman 		.proc_handler	= hugetlb_overcommit_handler,
1085e5ff2159SAndi Kleen 		.extra1		= (void *)&hugetlb_zero,
1086e5ff2159SAndi Kleen 		.extra2		= (void *)&hugetlb_infinity,
1087d1c3fb1fSNishanth Aravamudan 	},
10881da177e4SLinus Torvalds #endif
10891da177e4SLinus Torvalds 	{
10901da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
10911da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
10921da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
10931da177e4SLinus Torvalds 		.mode		= 0644,
10946d456111SEric W. Biederman 		.proc_handler	= lowmem_reserve_ratio_sysctl_handler,
10951da177e4SLinus Torvalds 	},
10961da177e4SLinus Torvalds 	{
10979d0243bcSAndrew Morton 		.procname	= "drop_caches",
10989d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
10999d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
11009d0243bcSAndrew Morton 		.mode		= 0644,
11019d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
11029d0243bcSAndrew Morton 	},
11039d0243bcSAndrew Morton 	{
11041da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
11051da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
11061da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
11071da177e4SLinus Torvalds 		.mode		= 0644,
11086d456111SEric W. Biederman 		.proc_handler	= min_free_kbytes_sysctl_handler,
11091da177e4SLinus Torvalds 		.extra1		= &zero,
11101da177e4SLinus Torvalds 	},
11118ad4b1fbSRohit Seth 	{
11128ad4b1fbSRohit Seth 		.procname	= "percpu_pagelist_fraction",
11138ad4b1fbSRohit Seth 		.data		= &percpu_pagelist_fraction,
11148ad4b1fbSRohit Seth 		.maxlen		= sizeof(percpu_pagelist_fraction),
11158ad4b1fbSRohit Seth 		.mode		= 0644,
11166d456111SEric W. Biederman 		.proc_handler	= percpu_pagelist_fraction_sysctl_handler,
11178ad4b1fbSRohit Seth 		.extra1		= &min_percpu_pagelist_fract,
11188ad4b1fbSRohit Seth 	},
11191da177e4SLinus Torvalds #ifdef CONFIG_MMU
11201da177e4SLinus Torvalds 	{
11211da177e4SLinus Torvalds 		.procname	= "max_map_count",
11221da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
11231da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
11241da177e4SLinus Torvalds 		.mode		= 0644,
11253e26120cSWANG Cong 		.proc_handler	= proc_dointvec_minmax,
112670da2340SAmerigo Wang 		.extra1		= &zero,
11271da177e4SLinus Torvalds 	},
1128dd8632a1SPaul Mundt #else
1129dd8632a1SPaul Mundt 	{
1130dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
1131dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
1132dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
1133dd8632a1SPaul Mundt 		.mode		= 0644,
11346d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1135dd8632a1SPaul Mundt 		.extra1		= &zero,
1136dd8632a1SPaul Mundt 	},
11371da177e4SLinus Torvalds #endif
11381da177e4SLinus Torvalds 	{
11391da177e4SLinus Torvalds 		.procname	= "laptop_mode",
11401da177e4SLinus Torvalds 		.data		= &laptop_mode,
11411da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
11421da177e4SLinus Torvalds 		.mode		= 0644,
11436d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
11441da177e4SLinus Torvalds 	},
11451da177e4SLinus Torvalds 	{
11461da177e4SLinus Torvalds 		.procname	= "block_dump",
11471da177e4SLinus Torvalds 		.data		= &block_dump,
11481da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
11491da177e4SLinus Torvalds 		.mode		= 0644,
11506d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
11511da177e4SLinus Torvalds 		.extra1		= &zero,
11521da177e4SLinus Torvalds 	},
11531da177e4SLinus Torvalds 	{
11541da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
11551da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
11561da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
11571da177e4SLinus Torvalds 		.mode		= 0644,
11586d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
11591da177e4SLinus Torvalds 		.extra1		= &zero,
11601da177e4SLinus Torvalds 	},
11611da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
11621da177e4SLinus Torvalds 	{
11631da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
11641da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
11651da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
11661da177e4SLinus Torvalds 		.mode		= 0644,
11676d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
11681da177e4SLinus Torvalds 		.extra1		= &zero,
11691da177e4SLinus Torvalds 	},
11701da177e4SLinus Torvalds #endif
11711743660bSChristoph Lameter #ifdef CONFIG_NUMA
11721743660bSChristoph Lameter 	{
11731743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
11741743660bSChristoph Lameter 		.data		= &zone_reclaim_mode,
11751743660bSChristoph Lameter 		.maxlen		= sizeof(zone_reclaim_mode),
11761743660bSChristoph Lameter 		.mode		= 0644,
11776d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1178c84db23cSChristoph Lameter 		.extra1		= &zero,
11791743660bSChristoph Lameter 	},
11809614634fSChristoph Lameter 	{
11819614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
11829614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
11839614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
11849614634fSChristoph Lameter 		.mode		= 0644,
11856d456111SEric W. Biederman 		.proc_handler	= sysctl_min_unmapped_ratio_sysctl_handler,
11869614634fSChristoph Lameter 		.extra1		= &zero,
11879614634fSChristoph Lameter 		.extra2		= &one_hundred,
11889614634fSChristoph Lameter 	},
11890ff38490SChristoph Lameter 	{
11900ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
11910ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
11920ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
11930ff38490SChristoph Lameter 		.mode		= 0644,
11946d456111SEric W. Biederman 		.proc_handler	= sysctl_min_slab_ratio_sysctl_handler,
11950ff38490SChristoph Lameter 		.extra1		= &zero,
11960ff38490SChristoph Lameter 		.extra2		= &one_hundred,
11970ff38490SChristoph Lameter 	},
11981743660bSChristoph Lameter #endif
119977461ab3SChristoph Lameter #ifdef CONFIG_SMP
120077461ab3SChristoph Lameter 	{
120177461ab3SChristoph Lameter 		.procname	= "stat_interval",
120277461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
120377461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
120477461ab3SChristoph Lameter 		.mode		= 0644,
12056d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
120677461ab3SChristoph Lameter 	},
120777461ab3SChristoph Lameter #endif
12086e141546SDavid Howells #ifdef CONFIG_MMU
1209ed032189SEric Paris 	{
1210ed032189SEric Paris 		.procname	= "mmap_min_addr",
1211788084abSEric Paris 		.data		= &dac_mmap_min_addr,
1212ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
1213ed032189SEric Paris 		.mode		= 0644,
12146d456111SEric W. Biederman 		.proc_handler	= mmap_min_addr_handler,
1215ed032189SEric Paris 	},
12166e141546SDavid Howells #endif
1217f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
1218f0c0b2b8SKAMEZAWA Hiroyuki 	{
1219f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
1220f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
1221f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
1222f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
12236d456111SEric W. Biederman 		.proc_handler	= numa_zonelist_order_handler,
1224f0c0b2b8SKAMEZAWA Hiroyuki 	},
1225f0c0b2b8SKAMEZAWA Hiroyuki #endif
12262b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
12275c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1228e6e5494cSIngo Molnar 	{
1229e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
1230e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
1231e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
1232e6e5494cSIngo Molnar 		.mode		= 0644,
12336d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1234e6e5494cSIngo Molnar 		.extra1		= &zero,
1235e6e5494cSIngo Molnar 	},
1236e6e5494cSIngo Molnar #endif
1237195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
1238195cf453SBron Gondwana 	{
1239195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
1240195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
1241195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
1242195cf453SBron Gondwana 		.mode		= 0644,
12436d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1244195cf453SBron Gondwana 		.extra1		= &zero,
1245195cf453SBron Gondwana 		.extra2		= &one,
1246195cf453SBron Gondwana 	},
1247195cf453SBron Gondwana #endif
12484be6f6bbSPeter Zijlstra 	{
12494be6f6bbSPeter Zijlstra 		.procname	= "scan_unevictable_pages",
12504be6f6bbSPeter Zijlstra 		.data		= &scan_unevictable_pages,
12514be6f6bbSPeter Zijlstra 		.maxlen		= sizeof(scan_unevictable_pages),
12524be6f6bbSPeter Zijlstra 		.mode		= 0644,
12536d456111SEric W. Biederman 		.proc_handler	= scan_unevictable_handler,
12544be6f6bbSPeter Zijlstra 	},
12556a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE
12566a46079cSAndi Kleen 	{
12576a46079cSAndi Kleen 		.procname	= "memory_failure_early_kill",
12586a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_early_kill,
12596a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_early_kill),
12606a46079cSAndi Kleen 		.mode		= 0644,
12616d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
12626a46079cSAndi Kleen 		.extra1		= &zero,
12636a46079cSAndi Kleen 		.extra2		= &one,
12646a46079cSAndi Kleen 	},
12656a46079cSAndi Kleen 	{
12666a46079cSAndi Kleen 		.procname	= "memory_failure_recovery",
12676a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_recovery,
12686a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_recovery),
12696a46079cSAndi Kleen 		.mode		= 0644,
12706d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
12716a46079cSAndi Kleen 		.extra1		= &zero,
12726a46079cSAndi Kleen 		.extra2		= &one,
12736a46079cSAndi Kleen 	},
12746a46079cSAndi Kleen #endif
12756a46079cSAndi Kleen 
12762be7fe07SAndrew Morton /*
12772be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
12782be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
12792be7fe07SAndrew Morton  */
12806fce56ecSEric W. Biederman 	{ }
12811da177e4SLinus Torvalds };
12821da177e4SLinus Torvalds 
12832abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1284d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = {
12856fce56ecSEric W. Biederman 	{ }
12862abc26fcSEric W. Biederman };
12872abc26fcSEric W. Biederman #endif
12882abc26fcSEric W. Biederman 
1289d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
12901da177e4SLinus Torvalds 	{
12911da177e4SLinus Torvalds 		.procname	= "inode-nr",
12921da177e4SLinus Torvalds 		.data		= &inodes_stat,
12931da177e4SLinus Torvalds 		.maxlen		= 2*sizeof(int),
12941da177e4SLinus Torvalds 		.mode		= 0444,
12956d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
12961da177e4SLinus Torvalds 	},
12971da177e4SLinus Torvalds 	{
12981da177e4SLinus Torvalds 		.procname	= "inode-state",
12991da177e4SLinus Torvalds 		.data		= &inodes_stat,
13001da177e4SLinus Torvalds 		.maxlen		= 7*sizeof(int),
13011da177e4SLinus Torvalds 		.mode		= 0444,
13026d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13031da177e4SLinus Torvalds 	},
13041da177e4SLinus Torvalds 	{
13051da177e4SLinus Torvalds 		.procname	= "file-nr",
13061da177e4SLinus Torvalds 		.data		= &files_stat,
13071da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
13081da177e4SLinus Torvalds 		.mode		= 0444,
13096d456111SEric W. Biederman 		.proc_handler	= proc_nr_files,
13101da177e4SLinus Torvalds 	},
13111da177e4SLinus Torvalds 	{
13121da177e4SLinus Torvalds 		.procname	= "file-max",
13131da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
13141da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13151da177e4SLinus Torvalds 		.mode		= 0644,
13166d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13171da177e4SLinus Torvalds 	},
13181da177e4SLinus Torvalds 	{
13199cfe015aSEric Dumazet 		.procname	= "nr_open",
13209cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
13219cfe015aSEric Dumazet 		.maxlen		= sizeof(int),
13229cfe015aSEric Dumazet 		.mode		= 0644,
13236d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1324eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
1325eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
13269cfe015aSEric Dumazet 	},
13279cfe015aSEric Dumazet 	{
13281da177e4SLinus Torvalds 		.procname	= "dentry-state",
13291da177e4SLinus Torvalds 		.data		= &dentry_stat,
13301da177e4SLinus Torvalds 		.maxlen		= 6*sizeof(int),
13311da177e4SLinus Torvalds 		.mode		= 0444,
13326d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13331da177e4SLinus Torvalds 	},
13341da177e4SLinus Torvalds 	{
13351da177e4SLinus Torvalds 		.procname	= "overflowuid",
13361da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
13371da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13381da177e4SLinus Torvalds 		.mode		= 0644,
13396d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13401da177e4SLinus Torvalds 		.extra1		= &minolduid,
13411da177e4SLinus Torvalds 		.extra2		= &maxolduid,
13421da177e4SLinus Torvalds 	},
13431da177e4SLinus Torvalds 	{
13441da177e4SLinus Torvalds 		.procname	= "overflowgid",
13451da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
13461da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13471da177e4SLinus Torvalds 		.mode		= 0644,
13486d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13491da177e4SLinus Torvalds 		.extra1		= &minolduid,
13501da177e4SLinus Torvalds 		.extra2		= &maxolduid,
13511da177e4SLinus Torvalds 	},
1352bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
13531da177e4SLinus Torvalds 	{
13541da177e4SLinus Torvalds 		.procname	= "leases-enable",
13551da177e4SLinus Torvalds 		.data		= &leases_enable,
13561da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13571da177e4SLinus Torvalds 		.mode		= 0644,
13586d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13591da177e4SLinus Torvalds 	},
1360bfcd17a6SThomas Petazzoni #endif
13611da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
13621da177e4SLinus Torvalds 	{
13631da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
13641da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
13651da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13661da177e4SLinus Torvalds 		.mode		= 0644,
13676d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13681da177e4SLinus Torvalds 	},
13691da177e4SLinus Torvalds #endif
13701da177e4SLinus Torvalds #ifdef CONFIG_MMU
1371bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
13721da177e4SLinus Torvalds 	{
13731da177e4SLinus Torvalds 		.procname	= "lease-break-time",
13741da177e4SLinus Torvalds 		.data		= &lease_break_time,
13751da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13761da177e4SLinus Torvalds 		.mode		= 0644,
13776d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13781da177e4SLinus Torvalds 	},
1379bfcd17a6SThomas Petazzoni #endif
1380ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
13811da177e4SLinus Torvalds 	{
13821da177e4SLinus Torvalds 		.procname	= "aio-nr",
13831da177e4SLinus Torvalds 		.data		= &aio_nr,
13841da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
13851da177e4SLinus Torvalds 		.mode		= 0444,
13866d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
13871da177e4SLinus Torvalds 	},
13881da177e4SLinus Torvalds 	{
13891da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
13901da177e4SLinus Torvalds 		.data		= &aio_max_nr,
13911da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
13921da177e4SLinus Torvalds 		.mode		= 0644,
13936d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
13941da177e4SLinus Torvalds 	},
1395ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
13962d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
13970399cb08SRobert Love 	{
13980399cb08SRobert Love 		.procname	= "inotify",
13990399cb08SRobert Love 		.mode		= 0555,
14000399cb08SRobert Love 		.child		= inotify_table,
14010399cb08SRobert Love 	},
14020399cb08SRobert Love #endif
14037ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
14047ef9964eSDavide Libenzi 	{
14057ef9964eSDavide Libenzi 		.procname	= "epoll",
14067ef9964eSDavide Libenzi 		.mode		= 0555,
14077ef9964eSDavide Libenzi 		.child		= epoll_table,
14087ef9964eSDavide Libenzi 	},
14097ef9964eSDavide Libenzi #endif
14101da177e4SLinus Torvalds #endif
1411d6e71144SAlan Cox 	{
1412d6e71144SAlan Cox 		.procname	= "suid_dumpable",
1413d6e71144SAlan Cox 		.data		= &suid_dumpable,
1414d6e71144SAlan Cox 		.maxlen		= sizeof(int),
1415d6e71144SAlan Cox 		.mode		= 0644,
14166d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
14178e654fbaSMatthew Wilcox 		.extra1		= &zero,
14188e654fbaSMatthew Wilcox 		.extra2		= &two,
1419d6e71144SAlan Cox 	},
14202abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
14212abc26fcSEric W. Biederman 	{
14222abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
14232abc26fcSEric W. Biederman 		.mode		= 0555,
14242abc26fcSEric W. Biederman 		.child		= binfmt_misc_table,
14252abc26fcSEric W. Biederman 	},
14262abc26fcSEric W. Biederman #endif
14272be7fe07SAndrew Morton /*
14282be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
14292be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
14302be7fe07SAndrew Morton  */
14316fce56ecSEric W. Biederman 	{ }
14321da177e4SLinus Torvalds };
14331da177e4SLinus Torvalds 
1434d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
14354b177647SDavid S. Miller #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC)
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