xref: /openbmc/linux/kernel/sysctl.c (revision 6d4561110a3e9fa742aeec6717248a491dfb1878)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * sysctl.c: General linux system control interface
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  * Begun 24 March 1995, Stephen Tweedie
51da177e4SLinus Torvalds  * Added /proc support, Dec 1995
61da177e4SLinus Torvalds  * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
71da177e4SLinus Torvalds  * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
81da177e4SLinus Torvalds  * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
91da177e4SLinus Torvalds  * Dynamic registration fixes, Stephen Tweedie.
101da177e4SLinus Torvalds  * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
111da177e4SLinus Torvalds  * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
121da177e4SLinus Torvalds  *  Horn.
131da177e4SLinus Torvalds  * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
141da177e4SLinus Torvalds  * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
151da177e4SLinus Torvalds  * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
161da177e4SLinus Torvalds  *  Wendling.
171da177e4SLinus Torvalds  * The list_for_each() macro wasn't appropriate for the sysctl loop.
181da177e4SLinus Torvalds  *  Removed it and replaced it with older style, 03/23/00, Bill Wendling
191da177e4SLinus Torvalds  */
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds #include <linux/module.h>
221da177e4SLinus Torvalds #include <linux/mm.h>
231da177e4SLinus Torvalds #include <linux/swap.h>
241da177e4SLinus Torvalds #include <linux/slab.h>
251da177e4SLinus Torvalds #include <linux/sysctl.h>
261da177e4SLinus Torvalds #include <linux/proc_fs.h>
2772c2d582SAndrew Morgan #include <linux/security.h>
281da177e4SLinus Torvalds #include <linux/ctype.h>
29dfec072eSVegard Nossum #include <linux/kmemcheck.h>
3062239ac2SAdrian Bunk #include <linux/fs.h>
311da177e4SLinus Torvalds #include <linux/init.h>
321da177e4SLinus Torvalds #include <linux/kernel.h>
330296b228SKay Sievers #include <linux/kobject.h>
3420380731SArnaldo Carvalho de Melo #include <linux/net.h>
351da177e4SLinus Torvalds #include <linux/sysrq.h>
361da177e4SLinus Torvalds #include <linux/highuid.h>
371da177e4SLinus Torvalds #include <linux/writeback.h>
381da177e4SLinus Torvalds #include <linux/hugetlb.h>
391da177e4SLinus Torvalds #include <linux/initrd.h>
400b77f5bfSDavid Howells #include <linux/key.h>
411da177e4SLinus Torvalds #include <linux/times.h>
421da177e4SLinus Torvalds #include <linux/limits.h>
431da177e4SLinus Torvalds #include <linux/dcache.h>
441da177e4SLinus Torvalds #include <linux/syscalls.h>
45c748e134SAdrian Bunk #include <linux/vmstat.h>
46c255d844SPavel Machek #include <linux/nfs_fs.h>
47c255d844SPavel Machek #include <linux/acpi.h>
4810a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h>
49b0fc494fSSteven Rostedt #include <linux/ftrace.h>
5012e22c5eSDavid Howells #include <linux/slow-work.h>
51cdd6c482SIngo Molnar #include <linux/perf_event.h>
521da177e4SLinus Torvalds 
531da177e4SLinus Torvalds #include <asm/uaccess.h>
541da177e4SLinus Torvalds #include <asm/processor.h>
551da177e4SLinus Torvalds 
5629cbc78bSAndi Kleen #ifdef CONFIG_X86
5729cbc78bSAndi Kleen #include <asm/nmi.h>
580741f4d2SChuck Ebbert #include <asm/stacktrace.h>
596e7c4025SIngo Molnar #include <asm/io.h>
6029cbc78bSAndi Kleen #endif
6129cbc78bSAndi Kleen 
627058cb02SEric W. Biederman 
631da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL)
641da177e4SLinus Torvalds 
651da177e4SLinus Torvalds /* External variables not in a header file. */
661da177e4SLinus Torvalds extern int C_A_D;
6745807a1dSIngo Molnar extern int print_fatal_signals;
681da177e4SLinus Torvalds extern int sysctl_overcommit_memory;
691da177e4SLinus Torvalds extern int sysctl_overcommit_ratio;
70fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom;
71fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task;
72fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks;
731da177e4SLinus Torvalds extern int max_threads;
741da177e4SLinus Torvalds extern int core_uses_pid;
75d6e71144SAlan Cox extern int suid_dumpable;
761da177e4SLinus Torvalds extern char core_pattern[];
77a293980cSNeil Horman extern unsigned int core_pipe_limit;
781da177e4SLinus Torvalds extern int pid_max;
791da177e4SLinus Torvalds extern int min_free_kbytes;
801da177e4SLinus Torvalds extern int pid_max_min, pid_max_max;
819d0243bcSAndrew Morton extern int sysctl_drop_caches;
828ad4b1fbSRohit Seth extern int percpu_pagelist_fraction;
83bebfa101SAndi Kleen extern int compat_log;
849745512cSArjan van de Ven extern int latencytop_enabled;
85eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max;
86dd8632a1SPaul Mundt #ifndef CONFIG_MMU
87dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages;
88dd8632a1SPaul Mundt #endif
8931a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
9031a72bceSPaul E. McKenney extern int rcutorture_runnable;
9131a72bceSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
92cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
935e605b64SJens Axboe extern int blk_iopoll_enabled;
94cb684b5bSJens Axboe #endif
951da177e4SLinus Torvalds 
96c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and  maximum */
97195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP
98c4f3b63fSRavikiran G Thirumalai static int sixty = 60;
999383d967SDimitri Sivanich static int neg_one = -1;
100c4f3b63fSRavikiran G Thirumalai #endif
101c4f3b63fSRavikiran G Thirumalai 
102c4f3b63fSRavikiran G Thirumalai static int zero;
103cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1;
104cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2;
105fc3501d4SSven Wegener static unsigned long one_ul = 1;
106c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100;
107af91322eSDave Young #ifdef CONFIG_PRINTK
108af91322eSDave Young static int ten_thousand = 10000;
109af91322eSDave Young #endif
110c4f3b63fSRavikiran G Thirumalai 
1119e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
1129e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1139e4a5bdaSAndrea Righi 
1141da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1151da177e4SLinus Torvalds static int maxolduid = 65535;
1161da177e4SLinus Torvalds static int minolduid;
1178ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8;
1181da177e4SLinus Torvalds 
1191da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
1201da177e4SLinus Torvalds 
121a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
1221da177e4SLinus Torvalds extern char modprobe_path[];
1233d43321bSKees Cook extern int modules_disabled;
1241da177e4SLinus Torvalds #endif
1251da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
1261da177e4SLinus Torvalds extern int sg_big_buff;
1271da177e4SLinus Torvalds #endif
1281da177e4SLinus Torvalds 
12972c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
13017f04fbbSDavid S. Miller #include <asm/system.h>
1311da177e4SLinus Torvalds #endif
1321da177e4SLinus Torvalds 
1330871420fSDavid S. Miller #ifdef CONFIG_SPARC64
1340871420fSDavid S. Miller extern int sysctl_tsb_ratio;
1350871420fSDavid S. Miller #endif
1360871420fSDavid S. Miller 
1371da177e4SLinus Torvalds #ifdef __hppa__
1381da177e4SLinus Torvalds extern int pwrsw_enabled;
1391da177e4SLinus Torvalds extern int unaligned_enabled;
1401da177e4SLinus Torvalds #endif
1411da177e4SLinus Torvalds 
142347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
1431da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
1441da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings;
1451da177e4SLinus Torvalds #endif
1461da177e4SLinus Torvalds extern int sysctl_userprocess_debug;
147951f22d5SMartin Schwidefsky extern int spin_retry;
1481da177e4SLinus Torvalds #endif
1491da177e4SLinus Torvalds 
1501da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
1511da177e4SLinus Torvalds extern int acct_parm[];
1521da177e4SLinus Torvalds #endif
1531da177e4SLinus Torvalds 
154d2b176edSJes Sorensen #ifdef CONFIG_IA64
155d2b176edSJes Sorensen extern int no_unaligned_warning;
15688fc241fSDoug Chapman extern int unaligned_dump_stack;
157d2b176edSJes Sorensen #endif
158d2b176edSJes Sorensen 
15923f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
16023f78d4aSIngo Molnar extern int max_lock_depth;
16123f78d4aSIngo Molnar #endif
16223f78d4aSIngo Molnar 
163d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
1648d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write,
1659ec52099SCedric Le Goater 		  void __user *buffer, size_t *lenp, loff_t *ppos);
1668d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write,
16734f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos);
168d6f8ff73SRandy Dunlap #endif
1699ec52099SCedric Le Goater 
170d8217f07SEric W. Biederman static struct ctl_table root_table[];
171e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root;
172e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = {
173b380b0d4SAl Viro 	.count = 1,
174e51b6ba0SEric W. Biederman 	.ctl_table = root_table,
17573455092SAl Viro 	.ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
176e51b6ba0SEric W. Biederman 	.root = &sysctl_table_root,
17773455092SAl Viro 	.set = &sysctl_table_root.default_set,
178e51b6ba0SEric W. Biederman };
179e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = {
180e51b6ba0SEric W. Biederman 	.root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
18173455092SAl Viro 	.default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
182e51b6ba0SEric W. Biederman };
1831da177e4SLinus Torvalds 
184d8217f07SEric W. Biederman static struct ctl_table kern_table[];
185d8217f07SEric W. Biederman static struct ctl_table vm_table[];
186d8217f07SEric W. Biederman static struct ctl_table fs_table[];
187d8217f07SEric W. Biederman static struct ctl_table debug_table[];
188d8217f07SEric W. Biederman static struct ctl_table dev_table[];
189d8217f07SEric W. Biederman extern struct ctl_table random_table[];
1902d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
191d8217f07SEric W. Biederman extern struct ctl_table inotify_table[];
1920399cb08SRobert Love #endif
1937ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
1947ef9964eSDavide Libenzi extern struct ctl_table epoll_table[];
1957ef9964eSDavide Libenzi #endif
1961da177e4SLinus Torvalds 
1971da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1981da177e4SLinus Torvalds int sysctl_legacy_va_layout;
1991da177e4SLinus Torvalds #endif
2001da177e4SLinus Torvalds 
201f20786ffSPeter Zijlstra extern int prove_locking;
202f20786ffSPeter Zijlstra extern int lock_stat;
2039bc9a6bdSEric W. Biederman 
2041da177e4SLinus Torvalds /* The default sysctl tables: */
2051da177e4SLinus Torvalds 
206d8217f07SEric W. Biederman static struct ctl_table root_table[] = {
2071da177e4SLinus Torvalds 	{
2081da177e4SLinus Torvalds 		.procname	= "kernel",
2091da177e4SLinus Torvalds 		.mode		= 0555,
2101da177e4SLinus Torvalds 		.child		= kern_table,
2111da177e4SLinus Torvalds 	},
2121da177e4SLinus Torvalds 	{
2131da177e4SLinus Torvalds 		.procname	= "vm",
2141da177e4SLinus Torvalds 		.mode		= 0555,
2151da177e4SLinus Torvalds 		.child		= vm_table,
2161da177e4SLinus Torvalds 	},
2171da177e4SLinus Torvalds 	{
2181da177e4SLinus Torvalds 		.procname	= "fs",
2191da177e4SLinus Torvalds 		.mode		= 0555,
2201da177e4SLinus Torvalds 		.child		= fs_table,
2211da177e4SLinus Torvalds 	},
2221da177e4SLinus Torvalds 	{
2231da177e4SLinus Torvalds 		.procname	= "debug",
2241da177e4SLinus Torvalds 		.mode		= 0555,
2251da177e4SLinus Torvalds 		.child		= debug_table,
2261da177e4SLinus Torvalds 	},
2271da177e4SLinus Torvalds 	{
2281da177e4SLinus Torvalds 		.procname	= "dev",
2291da177e4SLinus Torvalds 		.mode		= 0555,
2301da177e4SLinus Torvalds 		.child		= dev_table,
2311da177e4SLinus Torvalds 	},
2322be7fe07SAndrew Morton /*
2332be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
2342be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
2352be7fe07SAndrew Morton  */
2366fce56ecSEric W. Biederman 	{ }
2371da177e4SLinus Torvalds };
2381da177e4SLinus Torvalds 
23977e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
24073c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000;		/* 100 usecs */
24173c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
24273c4efd2SEric Dumazet static int min_wakeup_granularity_ns;			/* 0 usecs */
24373c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
24477e54a1fSIngo Molnar #endif
24577e54a1fSIngo Molnar 
246d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
2472bba22c5SMike Galbraith 	{
2482bba22c5SMike Galbraith 		.procname	= "sched_child_runs_first",
2492bba22c5SMike Galbraith 		.data		= &sysctl_sched_child_runs_first,
2502bba22c5SMike Galbraith 		.maxlen		= sizeof(unsigned int),
2512bba22c5SMike Galbraith 		.mode		= 0644,
252*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2532bba22c5SMike Galbraith 	},
25477e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
25577e54a1fSIngo Molnar 	{
256b2be5e96SPeter Zijlstra 		.procname	= "sched_min_granularity_ns",
257b2be5e96SPeter Zijlstra 		.data		= &sysctl_sched_min_granularity,
25877e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
25977e54a1fSIngo Molnar 		.mode		= 0644,
260*6d456111SEric W. Biederman 		.proc_handler	= sched_nr_latency_handler,
261b2be5e96SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
262b2be5e96SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
26377e54a1fSIngo Molnar 	},
26477e54a1fSIngo Molnar 	{
26521805085SPeter Zijlstra 		.procname	= "sched_latency_ns",
26621805085SPeter Zijlstra 		.data		= &sysctl_sched_latency,
26721805085SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
26821805085SPeter Zijlstra 		.mode		= 0644,
269*6d456111SEric W. Biederman 		.proc_handler	= sched_nr_latency_handler,
27021805085SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
27121805085SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
27221805085SPeter Zijlstra 	},
27321805085SPeter Zijlstra 	{
27477e54a1fSIngo Molnar 		.procname	= "sched_wakeup_granularity_ns",
27577e54a1fSIngo Molnar 		.data		= &sysctl_sched_wakeup_granularity,
27677e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
27777e54a1fSIngo Molnar 		.mode		= 0644,
278*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
27977e54a1fSIngo Molnar 		.extra1		= &min_wakeup_granularity_ns,
28077e54a1fSIngo Molnar 		.extra2		= &max_wakeup_granularity_ns,
28177e54a1fSIngo Molnar 	},
28277e54a1fSIngo Molnar 	{
2832398f2c6SPeter Zijlstra 		.procname	= "sched_shares_ratelimit",
2842398f2c6SPeter Zijlstra 		.data		= &sysctl_sched_shares_ratelimit,
2852398f2c6SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
2862398f2c6SPeter Zijlstra 		.mode		= 0644,
287*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2882398f2c6SPeter Zijlstra 	},
2892398f2c6SPeter Zijlstra 	{
290ffda12a1SPeter Zijlstra 		.procname	= "sched_shares_thresh",
291ffda12a1SPeter Zijlstra 		.data		= &sysctl_sched_shares_thresh,
292ffda12a1SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
293ffda12a1SPeter Zijlstra 		.mode		= 0644,
294*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
295ffda12a1SPeter Zijlstra 		.extra1		= &zero,
296ffda12a1SPeter Zijlstra 	},
297ffda12a1SPeter Zijlstra 	{
2981fc84aaaSPeter Zijlstra 		.procname	= "sched_features",
2991fc84aaaSPeter Zijlstra 		.data		= &sysctl_sched_features,
3001fc84aaaSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3011fc84aaaSPeter Zijlstra 		.mode		= 0644,
302*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3031fc84aaaSPeter Zijlstra 	},
304da84d961SIngo Molnar 	{
305da84d961SIngo Molnar 		.procname	= "sched_migration_cost",
306da84d961SIngo Molnar 		.data		= &sysctl_sched_migration_cost,
307da84d961SIngo Molnar 		.maxlen		= sizeof(unsigned int),
308da84d961SIngo Molnar 		.mode		= 0644,
309*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
310da84d961SIngo Molnar 	},
311b82d9fddSPeter Zijlstra 	{
312b82d9fddSPeter Zijlstra 		.procname	= "sched_nr_migrate",
313b82d9fddSPeter Zijlstra 		.data		= &sysctl_sched_nr_migrate,
314b82d9fddSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
315fa85ae24SPeter Zijlstra 		.mode		= 0644,
316*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
317fa85ae24SPeter Zijlstra 	},
318cd1bb94bSArun R Bharadwaj 	{
319e9e9250bSPeter Zijlstra 		.procname	= "sched_time_avg",
320e9e9250bSPeter Zijlstra 		.data		= &sysctl_sched_time_avg,
321e9e9250bSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
322e9e9250bSPeter Zijlstra 		.mode		= 0644,
323*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
324e9e9250bSPeter Zijlstra 	},
325e9e9250bSPeter Zijlstra 	{
326cd1bb94bSArun R Bharadwaj 		.procname	= "timer_migration",
327cd1bb94bSArun R Bharadwaj 		.data		= &sysctl_timer_migration,
328cd1bb94bSArun R Bharadwaj 		.maxlen		= sizeof(unsigned int),
329cd1bb94bSArun R Bharadwaj 		.mode		= 0644,
330*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
331bfdb4d9fSArun R Bharadwaj 		.extra1		= &zero,
332bfdb4d9fSArun R Bharadwaj 		.extra2		= &one,
333cd1bb94bSArun R Bharadwaj 	},
3341fc84aaaSPeter Zijlstra #endif
3351799e35dSIngo Molnar 	{
3369f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
3379f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
3389f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3399f0c1e56SPeter Zijlstra 		.mode		= 0644,
340*6d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
3419f0c1e56SPeter Zijlstra 	},
3429f0c1e56SPeter Zijlstra 	{
3439f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
3449f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
3459f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
3469f0c1e56SPeter Zijlstra 		.mode		= 0644,
347*6d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
3489f0c1e56SPeter Zijlstra 	},
3499f0c1e56SPeter Zijlstra 	{
3501799e35dSIngo Molnar 		.procname	= "sched_compat_yield",
3511799e35dSIngo Molnar 		.data		= &sysctl_sched_compat_yield,
3521799e35dSIngo Molnar 		.maxlen		= sizeof(unsigned int),
3531799e35dSIngo Molnar 		.mode		= 0644,
354*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3551799e35dSIngo Molnar 	},
356f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
357f20786ffSPeter Zijlstra 	{
358f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
359f20786ffSPeter Zijlstra 		.data		= &prove_locking,
360f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
361f20786ffSPeter Zijlstra 		.mode		= 0644,
362*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
363f20786ffSPeter Zijlstra 	},
364f20786ffSPeter Zijlstra #endif
365f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
366f20786ffSPeter Zijlstra 	{
367f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
368f20786ffSPeter Zijlstra 		.data		= &lock_stat,
369f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
370f20786ffSPeter Zijlstra 		.mode		= 0644,
371*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
372f20786ffSPeter Zijlstra 	},
373f20786ffSPeter Zijlstra #endif
37477e54a1fSIngo Molnar 	{
3751da177e4SLinus Torvalds 		.procname	= "panic",
3761da177e4SLinus Torvalds 		.data		= &panic_timeout,
3771da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
3781da177e4SLinus Torvalds 		.mode		= 0644,
379*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3801da177e4SLinus Torvalds 	},
3811da177e4SLinus Torvalds 	{
3821da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
3831da177e4SLinus Torvalds 		.data		= &core_uses_pid,
3841da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
3851da177e4SLinus Torvalds 		.mode		= 0644,
386*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3871da177e4SLinus Torvalds 	},
3881da177e4SLinus Torvalds 	{
3891da177e4SLinus Torvalds 		.procname	= "core_pattern",
3901da177e4SLinus Torvalds 		.data		= core_pattern,
39171ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
3921da177e4SLinus Torvalds 		.mode		= 0644,
393*6d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
3941da177e4SLinus Torvalds 	},
395a293980cSNeil Horman 	{
396a293980cSNeil Horman 		.procname	= "core_pipe_limit",
397a293980cSNeil Horman 		.data		= &core_pipe_limit,
398a293980cSNeil Horman 		.maxlen		= sizeof(unsigned int),
399a293980cSNeil Horman 		.mode		= 0644,
400*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
401a293980cSNeil Horman 	},
40234f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
4031da177e4SLinus Torvalds 	{
4041da177e4SLinus Torvalds 		.procname	= "tainted",
40525ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
40634f5a398STheodore Ts'o 		.mode		= 0644,
407*6d456111SEric W. Biederman 		.proc_handler	= proc_taint,
4081da177e4SLinus Torvalds 	},
40934f5a398STheodore Ts'o #endif
4109745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
4119745512cSArjan van de Ven 	{
4129745512cSArjan van de Ven 		.procname	= "latencytop",
4139745512cSArjan van de Ven 		.data		= &latencytop_enabled,
4149745512cSArjan van de Ven 		.maxlen		= sizeof(int),
4159745512cSArjan van de Ven 		.mode		= 0644,
416*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4179745512cSArjan van de Ven 	},
4189745512cSArjan van de Ven #endif
4191da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
4201da177e4SLinus Torvalds 	{
4211da177e4SLinus Torvalds 		.procname	= "real-root-dev",
4221da177e4SLinus Torvalds 		.data		= &real_root_dev,
4231da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4241da177e4SLinus Torvalds 		.mode		= 0644,
425*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4261da177e4SLinus Torvalds 	},
4271da177e4SLinus Torvalds #endif
42845807a1dSIngo Molnar 	{
42945807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
43045807a1dSIngo Molnar 		.data		= &print_fatal_signals,
43145807a1dSIngo Molnar 		.maxlen		= sizeof(int),
43245807a1dSIngo Molnar 		.mode		= 0644,
433*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
43445807a1dSIngo Molnar 	},
43572c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
4361da177e4SLinus Torvalds 	{
4371da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
4381da177e4SLinus Torvalds 		.data		= reboot_command,
4391da177e4SLinus Torvalds 		.maxlen		= 256,
4401da177e4SLinus Torvalds 		.mode		= 0644,
441*6d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
4421da177e4SLinus Torvalds 	},
4431da177e4SLinus Torvalds 	{
4441da177e4SLinus Torvalds 		.procname	= "stop-a",
4451da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
4461da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4471da177e4SLinus Torvalds 		.mode		= 0644,
448*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4491da177e4SLinus Torvalds 	},
4501da177e4SLinus Torvalds 	{
4511da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
4521da177e4SLinus Torvalds 		.data		= &scons_pwroff,
4531da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4541da177e4SLinus Torvalds 		.mode		= 0644,
455*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4561da177e4SLinus Torvalds 	},
4571da177e4SLinus Torvalds #endif
4580871420fSDavid S. Miller #ifdef CONFIG_SPARC64
4590871420fSDavid S. Miller 	{
4600871420fSDavid S. Miller 		.procname	= "tsb-ratio",
4610871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
4620871420fSDavid S. Miller 		.maxlen		= sizeof (int),
4630871420fSDavid S. Miller 		.mode		= 0644,
464*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4650871420fSDavid S. Miller 	},
4660871420fSDavid S. Miller #endif
4671da177e4SLinus Torvalds #ifdef __hppa__
4681da177e4SLinus Torvalds 	{
4691da177e4SLinus Torvalds 		.procname	= "soft-power",
4701da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
4711da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4721da177e4SLinus Torvalds 	 	.mode		= 0644,
473*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4741da177e4SLinus Torvalds 	},
4751da177e4SLinus Torvalds 	{
4761da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
4771da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
4781da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4791da177e4SLinus Torvalds 		.mode		= 0644,
480*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4811da177e4SLinus Torvalds 	},
4821da177e4SLinus Torvalds #endif
4831da177e4SLinus Torvalds 	{
4841da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
4851da177e4SLinus Torvalds 		.data		= &C_A_D,
4861da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4871da177e4SLinus Torvalds 		.mode		= 0644,
488*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4891da177e4SLinus Torvalds 	},
490606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
491b0fc494fSSteven Rostedt 	{
492b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
493b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
494b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
495b0fc494fSSteven Rostedt 		.mode		= 0644,
496*6d456111SEric W. Biederman 		.proc_handler	= ftrace_enable_sysctl,
497b0fc494fSSteven Rostedt 	},
498b0fc494fSSteven Rostedt #endif
499f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
500f38f1d2aSSteven Rostedt 	{
501f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
502f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
503f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
504f38f1d2aSSteven Rostedt 		.mode		= 0644,
505*6d456111SEric W. Biederman 		.proc_handler	= stack_trace_sysctl,
506f38f1d2aSSteven Rostedt 	},
507f38f1d2aSSteven Rostedt #endif
508944ac425SSteven Rostedt #ifdef CONFIG_TRACING
509944ac425SSteven Rostedt 	{
5103299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
511944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
512944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
513944ac425SSteven Rostedt 		.mode		= 0644,
514*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
515944ac425SSteven Rostedt 	},
516944ac425SSteven Rostedt #endif
517a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
5181da177e4SLinus Torvalds 	{
5191da177e4SLinus Torvalds 		.procname	= "modprobe",
5201da177e4SLinus Torvalds 		.data		= &modprobe_path,
5211da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
5221da177e4SLinus Torvalds 		.mode		= 0644,
523*6d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
5241da177e4SLinus Torvalds 	},
5253d43321bSKees Cook 	{
5263d43321bSKees Cook 		.procname	= "modules_disabled",
5273d43321bSKees Cook 		.data		= &modules_disabled,
5283d43321bSKees Cook 		.maxlen		= sizeof(int),
5293d43321bSKees Cook 		.mode		= 0644,
5303d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
531*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
5323d43321bSKees Cook 		.extra1		= &one,
5333d43321bSKees Cook 		.extra2		= &one,
5343d43321bSKees Cook 	},
5351da177e4SLinus Torvalds #endif
53657ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
5371da177e4SLinus Torvalds 	{
5381da177e4SLinus Torvalds 		.procname	= "hotplug",
539312c004dSKay Sievers 		.data		= &uevent_helper,
540312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
5411da177e4SLinus Torvalds 		.mode		= 0644,
542*6d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
5431da177e4SLinus Torvalds 	},
5441da177e4SLinus Torvalds #endif
5451da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
5461da177e4SLinus Torvalds 	{
5471da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
5481da177e4SLinus Torvalds 		.data		= &sg_big_buff,
5491da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5501da177e4SLinus Torvalds 		.mode		= 0444,
551*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5521da177e4SLinus Torvalds 	},
5531da177e4SLinus Torvalds #endif
5541da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
5551da177e4SLinus Torvalds 	{
5561da177e4SLinus Torvalds 		.procname	= "acct",
5571da177e4SLinus Torvalds 		.data		= &acct_parm,
5581da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
5591da177e4SLinus Torvalds 		.mode		= 0644,
560*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5611da177e4SLinus Torvalds 	},
5621da177e4SLinus Torvalds #endif
5631da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
5641da177e4SLinus Torvalds 	{
5651da177e4SLinus Torvalds 		.procname	= "sysrq",
5665d6f647fSIngo Molnar 		.data		= &__sysrq_enabled,
5671da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5681da177e4SLinus Torvalds 		.mode		= 0644,
569*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5701da177e4SLinus Torvalds 	},
5711da177e4SLinus Torvalds #endif
572d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
5731da177e4SLinus Torvalds 	{
5741da177e4SLinus Torvalds 		.procname	= "cad_pid",
5759ec52099SCedric Le Goater 		.data		= NULL,
5761da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5771da177e4SLinus Torvalds 		.mode		= 0600,
578*6d456111SEric W. Biederman 		.proc_handler	= proc_do_cad_pid,
5791da177e4SLinus Torvalds 	},
580d6f8ff73SRandy Dunlap #endif
5811da177e4SLinus Torvalds 	{
5821da177e4SLinus Torvalds 		.procname	= "threads-max",
5831da177e4SLinus Torvalds 		.data		= &max_threads,
5841da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5851da177e4SLinus Torvalds 		.mode		= 0644,
586*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5871da177e4SLinus Torvalds 	},
5881da177e4SLinus Torvalds 	{
5891da177e4SLinus Torvalds 		.procname	= "random",
5901da177e4SLinus Torvalds 		.mode		= 0555,
5911da177e4SLinus Torvalds 		.child		= random_table,
5921da177e4SLinus Torvalds 	},
5931da177e4SLinus Torvalds 	{
5941da177e4SLinus Torvalds 		.procname	= "overflowuid",
5951da177e4SLinus Torvalds 		.data		= &overflowuid,
5961da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5971da177e4SLinus Torvalds 		.mode		= 0644,
598*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
5991da177e4SLinus Torvalds 		.extra1		= &minolduid,
6001da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6011da177e4SLinus Torvalds 	},
6021da177e4SLinus Torvalds 	{
6031da177e4SLinus Torvalds 		.procname	= "overflowgid",
6041da177e4SLinus Torvalds 		.data		= &overflowgid,
6051da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6061da177e4SLinus Torvalds 		.mode		= 0644,
607*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6081da177e4SLinus Torvalds 		.extra1		= &minolduid,
6091da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6101da177e4SLinus Torvalds 	},
611347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
6121da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
6131da177e4SLinus Torvalds 	{
6141da177e4SLinus Torvalds 		.procname	= "ieee_emulation_warnings",
6151da177e4SLinus Torvalds 		.data		= &sysctl_ieee_emulation_warnings,
6161da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6171da177e4SLinus Torvalds 		.mode		= 0644,
618*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6191da177e4SLinus Torvalds 	},
6201da177e4SLinus Torvalds #endif
6211da177e4SLinus Torvalds 	{
6221da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
6231da177e4SLinus Torvalds 		.data		= &sysctl_userprocess_debug,
6241da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6251da177e4SLinus Torvalds 		.mode		= 0644,
626*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6271da177e4SLinus Torvalds 	},
6281da177e4SLinus Torvalds #endif
6291da177e4SLinus Torvalds 	{
6301da177e4SLinus Torvalds 		.procname	= "pid_max",
6311da177e4SLinus Torvalds 		.data		= &pid_max,
6321da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6331da177e4SLinus Torvalds 		.mode		= 0644,
634*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6351da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
6361da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
6371da177e4SLinus Torvalds 	},
6381da177e4SLinus Torvalds 	{
6391da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
6401da177e4SLinus Torvalds 		.data		= &panic_on_oops,
6411da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6421da177e4SLinus Torvalds 		.mode		= 0644,
643*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6441da177e4SLinus Torvalds 	},
6457ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
6467ef3d2fdSJoe Perches 	{
6477ef3d2fdSJoe Perches 		.procname	= "printk",
6487ef3d2fdSJoe Perches 		.data		= &console_loglevel,
6497ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
6507ef3d2fdSJoe Perches 		.mode		= 0644,
651*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6527ef3d2fdSJoe Perches 	},
6531da177e4SLinus Torvalds 	{
6541da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
655717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
6561da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6571da177e4SLinus Torvalds 		.mode		= 0644,
658*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
6591da177e4SLinus Torvalds 	},
6601da177e4SLinus Torvalds 	{
6611da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
662717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
6631da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6641da177e4SLinus Torvalds 		.mode		= 0644,
665*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6661da177e4SLinus Torvalds 	},
667af91322eSDave Young 	{
668af91322eSDave Young 		.procname	= "printk_delay",
669af91322eSDave Young 		.data		= &printk_delay_msec,
670af91322eSDave Young 		.maxlen		= sizeof(int),
671af91322eSDave Young 		.mode		= 0644,
672*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
673af91322eSDave Young 		.extra1		= &zero,
674af91322eSDave Young 		.extra2		= &ten_thousand,
675af91322eSDave Young 	},
6767ef3d2fdSJoe Perches #endif
6771da177e4SLinus Torvalds 	{
6781da177e4SLinus Torvalds 		.procname	= "ngroups_max",
6791da177e4SLinus Torvalds 		.data		= &ngroups_max,
6801da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6811da177e4SLinus Torvalds 		.mode		= 0444,
682*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6831da177e4SLinus Torvalds 	},
6841da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
6851da177e4SLinus Torvalds 	{
6861da177e4SLinus Torvalds 		.procname       = "unknown_nmi_panic",
6871da177e4SLinus Torvalds 		.data           = &unknown_nmi_panic,
6881da177e4SLinus Torvalds 		.maxlen         = sizeof (int),
6891da177e4SLinus Torvalds 		.mode           = 0644,
690*6d456111SEric W. Biederman 		.proc_handler   = proc_dointvec,
6911da177e4SLinus Torvalds 	},
692407984f1SDon Zickus 	{
693407984f1SDon Zickus 		.procname       = "nmi_watchdog",
694407984f1SDon Zickus 		.data           = &nmi_watchdog_enabled,
695407984f1SDon Zickus 		.maxlen         = sizeof (int),
696407984f1SDon Zickus 		.mode           = 0644,
697*6d456111SEric W. Biederman 		.proc_handler   = proc_nmi_enabled,
6981da177e4SLinus Torvalds 	},
6991da177e4SLinus Torvalds #endif
7001da177e4SLinus Torvalds #if defined(CONFIG_X86)
7011da177e4SLinus Torvalds 	{
7028da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
7038da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
7048da5addaSDon Zickus 		.maxlen		= sizeof(int),
7058da5addaSDon Zickus 		.mode		= 0644,
706*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7078da5addaSDon Zickus 	},
7088da5addaSDon Zickus 	{
7095211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
7105211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
7115211a242SKurt Garloff 		.maxlen		= sizeof(int),
7125211a242SKurt Garloff 		.mode		= 0644,
713*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7145211a242SKurt Garloff 	},
7155211a242SKurt Garloff 	{
7161da177e4SLinus Torvalds 		.procname	= "bootloader_type",
7171da177e4SLinus Torvalds 		.data		= &bootloader_type,
7181da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7191da177e4SLinus Torvalds 		.mode		= 0444,
720*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7211da177e4SLinus Torvalds 	},
7220741f4d2SChuck Ebbert 	{
7235031296cSH. Peter Anvin 		.procname	= "bootloader_version",
7245031296cSH. Peter Anvin 		.data		= &bootloader_version,
7255031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
7265031296cSH. Peter Anvin 		.mode		= 0444,
727*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7285031296cSH. Peter Anvin 	},
7295031296cSH. Peter Anvin 	{
7300741f4d2SChuck Ebbert 		.procname	= "kstack_depth_to_print",
7310741f4d2SChuck Ebbert 		.data		= &kstack_depth_to_print,
7320741f4d2SChuck Ebbert 		.maxlen		= sizeof(int),
7330741f4d2SChuck Ebbert 		.mode		= 0644,
734*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7350741f4d2SChuck Ebbert 	},
7366e7c4025SIngo Molnar 	{
7376e7c4025SIngo Molnar 		.procname	= "io_delay_type",
7386e7c4025SIngo Molnar 		.data		= &io_delay_type,
7396e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
7406e7c4025SIngo Molnar 		.mode		= 0644,
741*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7426e7c4025SIngo Molnar 	},
7431da177e4SLinus Torvalds #endif
7447a9166e3SLuke Yang #if defined(CONFIG_MMU)
7451da177e4SLinus Torvalds 	{
7461da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
7471da177e4SLinus Torvalds 		.data		= &randomize_va_space,
7481da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7491da177e4SLinus Torvalds 		.mode		= 0644,
750*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7511da177e4SLinus Torvalds 	},
7527a9166e3SLuke Yang #endif
7530152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
754951f22d5SMartin Schwidefsky 	{
755951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
756951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
757951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
758951f22d5SMartin Schwidefsky 		.mode		= 0644,
759*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
760951f22d5SMartin Schwidefsky 	},
761951f22d5SMartin Schwidefsky #endif
762673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
763c255d844SPavel Machek 	{
764c255d844SPavel Machek 		.procname	= "acpi_video_flags",
76577afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
766c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
767c255d844SPavel Machek 		.mode		= 0644,
768*6d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
769c255d844SPavel Machek 	},
770c255d844SPavel Machek #endif
771d2b176edSJes Sorensen #ifdef CONFIG_IA64
772d2b176edSJes Sorensen 	{
773d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
774d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
775d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
776d2b176edSJes Sorensen 	 	.mode		= 0644,
777*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
778d2b176edSJes Sorensen 	},
77988fc241fSDoug Chapman 	{
78088fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
78188fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
78288fc241fSDoug Chapman 		.maxlen		= sizeof (int),
78388fc241fSDoug Chapman 		.mode		= 0644,
784*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
78588fc241fSDoug Chapman 	},
786d2b176edSJes Sorensen #endif
787c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP
788c4f3b63fSRavikiran G Thirumalai 	{
7899c44bc03SIngo Molnar 		.procname	= "softlockup_panic",
7909c44bc03SIngo Molnar 		.data		= &softlockup_panic,
7919c44bc03SIngo Molnar 		.maxlen		= sizeof(int),
7929c44bc03SIngo Molnar 		.mode		= 0644,
793*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
7949c44bc03SIngo Molnar 		.extra1		= &zero,
7959c44bc03SIngo Molnar 		.extra2		= &one,
7969c44bc03SIngo Molnar 	},
7979c44bc03SIngo Molnar 	{
798c4f3b63fSRavikiran G Thirumalai 		.procname	= "softlockup_thresh",
799c4f3b63fSRavikiran G Thirumalai 		.data		= &softlockup_thresh,
8009383d967SDimitri Sivanich 		.maxlen		= sizeof(int),
801c4f3b63fSRavikiran G Thirumalai 		.mode		= 0644,
802*6d456111SEric W. Biederman 		.proc_handler	= proc_dosoftlockup_thresh,
8039383d967SDimitri Sivanich 		.extra1		= &neg_one,
804c4f3b63fSRavikiran G Thirumalai 		.extra2		= &sixty,
805c4f3b63fSRavikiran G Thirumalai 	},
806e162b39aSMandeep Singh Baines #endif
807e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
808e162b39aSMandeep Singh Baines 	{
809e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
810e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
811e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
812e162b39aSMandeep Singh Baines 		.mode		= 0644,
813*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
814e162b39aSMandeep Singh Baines 		.extra1		= &zero,
815e162b39aSMandeep Singh Baines 		.extra2		= &one,
816e162b39aSMandeep Singh Baines 	},
81782a1fcb9SIngo Molnar 	{
81882a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
81982a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
82090739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
82182a1fcb9SIngo Molnar 		.mode		= 0644,
822*6d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
82382a1fcb9SIngo Molnar 	},
82482a1fcb9SIngo Molnar 	{
82582a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
82682a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
82790739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
82882a1fcb9SIngo Molnar 		.mode		= 0644,
829*6d456111SEric W. Biederman 		.proc_handler	= proc_dohung_task_timeout_secs,
83082a1fcb9SIngo Molnar 	},
83182a1fcb9SIngo Molnar 	{
83282a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
83382a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
83490739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
83582a1fcb9SIngo Molnar 		.mode		= 0644,
836*6d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
83782a1fcb9SIngo Molnar 	},
838c4f3b63fSRavikiran G Thirumalai #endif
839bebfa101SAndi Kleen #ifdef CONFIG_COMPAT
840bebfa101SAndi Kleen 	{
841bebfa101SAndi Kleen 		.procname	= "compat-log",
842bebfa101SAndi Kleen 		.data		= &compat_log,
843bebfa101SAndi Kleen 		.maxlen		= sizeof (int),
844bebfa101SAndi Kleen 	 	.mode		= 0644,
845*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
846bebfa101SAndi Kleen 	},
847bebfa101SAndi Kleen #endif
84823f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
84923f78d4aSIngo Molnar 	{
85023f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
85123f78d4aSIngo Molnar 		.data		= &max_lock_depth,
85223f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
85323f78d4aSIngo Molnar 		.mode		= 0644,
854*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
85523f78d4aSIngo Molnar 	},
85623f78d4aSIngo Molnar #endif
85710a0a8d4SJeremy Fitzhardinge 	{
85810a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
85910a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
86010a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
86110a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
862*6d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
86310a0a8d4SJeremy Fitzhardinge 	},
8640b77f5bfSDavid Howells #ifdef CONFIG_KEYS
8650b77f5bfSDavid Howells 	{
8660b77f5bfSDavid Howells 		.procname	= "keys",
8670b77f5bfSDavid Howells 		.mode		= 0555,
8680b77f5bfSDavid Howells 		.child		= key_sysctls,
8690b77f5bfSDavid Howells 	},
8700b77f5bfSDavid Howells #endif
87131a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
87231a72bceSPaul E. McKenney 	{
87331a72bceSPaul E. McKenney 		.procname       = "rcutorture_runnable",
87431a72bceSPaul E. McKenney 		.data           = &rcutorture_runnable,
87531a72bceSPaul E. McKenney 		.maxlen         = sizeof(int),
87631a72bceSPaul E. McKenney 		.mode           = 0644,
877*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
87831a72bceSPaul E. McKenney 	},
87931a72bceSPaul E. McKenney #endif
88012e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK
88112e22c5eSDavid Howells 	{
88212e22c5eSDavid Howells 		.procname	= "slow-work",
88312e22c5eSDavid Howells 		.mode		= 0555,
88412e22c5eSDavid Howells 		.child		= slow_work_sysctls,
88512e22c5eSDavid Howells 	},
88612e22c5eSDavid Howells #endif
887cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS
8881ccd1549SPeter Zijlstra 	{
889cdd6c482SIngo Molnar 		.procname	= "perf_event_paranoid",
890cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_paranoid,
891cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_paranoid),
8921ccd1549SPeter Zijlstra 		.mode		= 0644,
893*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
8941ccd1549SPeter Zijlstra 	},
895c5078f78SPeter Zijlstra 	{
896cdd6c482SIngo Molnar 		.procname	= "perf_event_mlock_kb",
897cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_mlock,
898cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_mlock),
899c5078f78SPeter Zijlstra 		.mode		= 0644,
900*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
901c5078f78SPeter Zijlstra 	},
902a78ac325SPeter Zijlstra 	{
903cdd6c482SIngo Molnar 		.procname	= "perf_event_max_sample_rate",
904cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_sample_rate,
905cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
906a78ac325SPeter Zijlstra 		.mode		= 0644,
907*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
908a78ac325SPeter Zijlstra 	},
9091ccd1549SPeter Zijlstra #endif
910dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK
911dfec072eSVegard Nossum 	{
912dfec072eSVegard Nossum 		.procname	= "kmemcheck",
913dfec072eSVegard Nossum 		.data		= &kmemcheck_enabled,
914dfec072eSVegard Nossum 		.maxlen		= sizeof(int),
915dfec072eSVegard Nossum 		.mode		= 0644,
916*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
917dfec072eSVegard Nossum 	},
918dfec072eSVegard Nossum #endif
919cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
9205e605b64SJens Axboe 	{
9215e605b64SJens Axboe 		.procname	= "blk_iopoll",
9225e605b64SJens Axboe 		.data		= &blk_iopoll_enabled,
9235e605b64SJens Axboe 		.maxlen		= sizeof(int),
9245e605b64SJens Axboe 		.mode		= 0644,
925*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9265e605b64SJens Axboe 	},
927cb684b5bSJens Axboe #endif
928ed2c12f3SAndrew Morton /*
929ed2c12f3SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
930ed2c12f3SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
931ed2c12f3SAndrew Morton  */
9326fce56ecSEric W. Biederman 	{ }
9331da177e4SLinus Torvalds };
9341da177e4SLinus Torvalds 
935d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
9361da177e4SLinus Torvalds 	{
9371da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
9381da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
9391da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
9401da177e4SLinus Torvalds 		.mode		= 0644,
941*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9421da177e4SLinus Torvalds 	},
9431da177e4SLinus Torvalds 	{
944fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
945fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
946fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
947fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
948*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
949fadd8fbdSKAMEZAWA Hiroyuki 	},
950fadd8fbdSKAMEZAWA Hiroyuki 	{
951fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
952fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
953fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
954fe071d7eSDavid Rientjes 		.mode		= 0644,
955*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
956fe071d7eSDavid Rientjes 	},
957fe071d7eSDavid Rientjes 	{
958fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
959fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
960fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
961fef1bdd6SDavid Rientjes 		.mode		= 0644,
962*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
963fef1bdd6SDavid Rientjes 	},
964fef1bdd6SDavid Rientjes 	{
9651da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
9661da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
9671da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
9681da177e4SLinus Torvalds 		.mode		= 0644,
969*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9701da177e4SLinus Torvalds 	},
9711da177e4SLinus Torvalds 	{
9721da177e4SLinus Torvalds 		.procname	= "page-cluster",
9731da177e4SLinus Torvalds 		.data		= &page_cluster,
9741da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
9751da177e4SLinus Torvalds 		.mode		= 0644,
976*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9771da177e4SLinus Torvalds 	},
9781da177e4SLinus Torvalds 	{
9791da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
9801da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
9811da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
9821da177e4SLinus Torvalds 		.mode		= 0644,
983*6d456111SEric W. Biederman 		.proc_handler	= dirty_background_ratio_handler,
9841da177e4SLinus Torvalds 		.extra1		= &zero,
9851da177e4SLinus Torvalds 		.extra2		= &one_hundred,
9861da177e4SLinus Torvalds 	},
9871da177e4SLinus Torvalds 	{
9882da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
9892da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
9902da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
9912da02997SDavid Rientjes 		.mode		= 0644,
992*6d456111SEric W. Biederman 		.proc_handler	= dirty_background_bytes_handler,
993fc3501d4SSven Wegener 		.extra1		= &one_ul,
9942da02997SDavid Rientjes 	},
9952da02997SDavid Rientjes 	{
9961da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
9971da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
9981da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
9991da177e4SLinus Torvalds 		.mode		= 0644,
1000*6d456111SEric W. Biederman 		.proc_handler	= dirty_ratio_handler,
10011da177e4SLinus Torvalds 		.extra1		= &zero,
10021da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10031da177e4SLinus Torvalds 	},
10041da177e4SLinus Torvalds 	{
10052da02997SDavid Rientjes 		.procname	= "dirty_bytes",
10062da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
10072da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
10082da02997SDavid Rientjes 		.mode		= 0644,
1009*6d456111SEric W. Biederman 		.proc_handler	= dirty_bytes_handler,
10109e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
10112da02997SDavid Rientjes 	},
10122da02997SDavid Rientjes 	{
10131da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
1014f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
1015f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
10161da177e4SLinus Torvalds 		.mode		= 0644,
1017*6d456111SEric W. Biederman 		.proc_handler	= dirty_writeback_centisecs_handler,
10181da177e4SLinus Torvalds 	},
10191da177e4SLinus Torvalds 	{
10201da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
1021f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
1022f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
10231da177e4SLinus Torvalds 		.mode		= 0644,
1024*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10251da177e4SLinus Torvalds 	},
10261da177e4SLinus Torvalds 	{
10271da177e4SLinus Torvalds 		.procname	= "nr_pdflush_threads",
10281da177e4SLinus Torvalds 		.data		= &nr_pdflush_threads,
10291da177e4SLinus Torvalds 		.maxlen		= sizeof nr_pdflush_threads,
10301da177e4SLinus Torvalds 		.mode		= 0444 /* read-only*/,
1031*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10321da177e4SLinus Torvalds 	},
10331da177e4SLinus Torvalds 	{
10341da177e4SLinus Torvalds 		.procname	= "swappiness",
10351da177e4SLinus Torvalds 		.data		= &vm_swappiness,
10361da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
10371da177e4SLinus Torvalds 		.mode		= 0644,
1038*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
10391da177e4SLinus Torvalds 		.extra1		= &zero,
10401da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10411da177e4SLinus Torvalds 	},
10421da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
10431da177e4SLinus Torvalds 	 {
10441da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
1045e5ff2159SAndi Kleen 		.data		= NULL,
10461da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
10471da177e4SLinus Torvalds 		.mode		= 0644,
1048*6d456111SEric W. Biederman 		.proc_handler	= hugetlb_sysctl_handler,
10491da177e4SLinus Torvalds 		.extra1		= (void *)&hugetlb_zero,
10501da177e4SLinus Torvalds 		.extra2		= (void *)&hugetlb_infinity,
10511da177e4SLinus Torvalds 	 },
10521da177e4SLinus Torvalds 	 {
10531da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
10541da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
10551da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
10561da177e4SLinus Torvalds 		.mode		= 0644,
1057*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10581da177e4SLinus Torvalds 	 },
1059396faf03SMel Gorman 	 {
1060396faf03SMel Gorman 		.procname	= "hugepages_treat_as_movable",
1061396faf03SMel Gorman 		.data		= &hugepages_treat_as_movable,
1062396faf03SMel Gorman 		.maxlen		= sizeof(int),
1063396faf03SMel Gorman 		.mode		= 0644,
1064*6d456111SEric W. Biederman 		.proc_handler	= hugetlb_treat_movable_handler,
1065396faf03SMel Gorman 	},
106654f9f80dSAdam Litke 	{
1067d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
1068e5ff2159SAndi Kleen 		.data		= NULL,
1069e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
1070d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
1071*6d456111SEric W. Biederman 		.proc_handler	= hugetlb_overcommit_handler,
1072e5ff2159SAndi Kleen 		.extra1		= (void *)&hugetlb_zero,
1073e5ff2159SAndi Kleen 		.extra2		= (void *)&hugetlb_infinity,
1074d1c3fb1fSNishanth Aravamudan 	},
10751da177e4SLinus Torvalds #endif
10761da177e4SLinus Torvalds 	{
10771da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
10781da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
10791da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
10801da177e4SLinus Torvalds 		.mode		= 0644,
1081*6d456111SEric W. Biederman 		.proc_handler	= lowmem_reserve_ratio_sysctl_handler,
10821da177e4SLinus Torvalds 	},
10831da177e4SLinus Torvalds 	{
10849d0243bcSAndrew Morton 		.procname	= "drop_caches",
10859d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
10869d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
10879d0243bcSAndrew Morton 		.mode		= 0644,
10889d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
10899d0243bcSAndrew Morton 	},
10909d0243bcSAndrew Morton 	{
10911da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
10921da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
10931da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
10941da177e4SLinus Torvalds 		.mode		= 0644,
1095*6d456111SEric W. Biederman 		.proc_handler	= min_free_kbytes_sysctl_handler,
10961da177e4SLinus Torvalds 		.extra1		= &zero,
10971da177e4SLinus Torvalds 	},
10988ad4b1fbSRohit Seth 	{
10998ad4b1fbSRohit Seth 		.procname	= "percpu_pagelist_fraction",
11008ad4b1fbSRohit Seth 		.data		= &percpu_pagelist_fraction,
11018ad4b1fbSRohit Seth 		.maxlen		= sizeof(percpu_pagelist_fraction),
11028ad4b1fbSRohit Seth 		.mode		= 0644,
1103*6d456111SEric W. Biederman 		.proc_handler	= percpu_pagelist_fraction_sysctl_handler,
11048ad4b1fbSRohit Seth 		.extra1		= &min_percpu_pagelist_fract,
11058ad4b1fbSRohit Seth 	},
11061da177e4SLinus Torvalds #ifdef CONFIG_MMU
11071da177e4SLinus Torvalds 	{
11081da177e4SLinus Torvalds 		.procname	= "max_map_count",
11091da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
11101da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
11111da177e4SLinus Torvalds 		.mode		= 0644,
1112*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec
11131da177e4SLinus Torvalds 	},
1114dd8632a1SPaul Mundt #else
1115dd8632a1SPaul Mundt 	{
1116dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
1117dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
1118dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
1119dd8632a1SPaul Mundt 		.mode		= 0644,
1120*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1121dd8632a1SPaul Mundt 		.extra1		= &zero,
1122dd8632a1SPaul Mundt 	},
11231da177e4SLinus Torvalds #endif
11241da177e4SLinus Torvalds 	{
11251da177e4SLinus Torvalds 		.procname	= "laptop_mode",
11261da177e4SLinus Torvalds 		.data		= &laptop_mode,
11271da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
11281da177e4SLinus Torvalds 		.mode		= 0644,
1129*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
11301da177e4SLinus Torvalds 	},
11311da177e4SLinus Torvalds 	{
11321da177e4SLinus Torvalds 		.procname	= "block_dump",
11331da177e4SLinus Torvalds 		.data		= &block_dump,
11341da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
11351da177e4SLinus Torvalds 		.mode		= 0644,
1136*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
11371da177e4SLinus Torvalds 		.extra1		= &zero,
11381da177e4SLinus Torvalds 	},
11391da177e4SLinus Torvalds 	{
11401da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
11411da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
11421da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
11431da177e4SLinus Torvalds 		.mode		= 0644,
1144*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
11451da177e4SLinus Torvalds 		.extra1		= &zero,
11461da177e4SLinus Torvalds 	},
11471da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
11481da177e4SLinus Torvalds 	{
11491da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
11501da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
11511da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
11521da177e4SLinus Torvalds 		.mode		= 0644,
1153*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
11541da177e4SLinus Torvalds 		.extra1		= &zero,
11551da177e4SLinus Torvalds 	},
11561da177e4SLinus Torvalds #endif
11571743660bSChristoph Lameter #ifdef CONFIG_NUMA
11581743660bSChristoph Lameter 	{
11591743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
11601743660bSChristoph Lameter 		.data		= &zone_reclaim_mode,
11611743660bSChristoph Lameter 		.maxlen		= sizeof(zone_reclaim_mode),
11621743660bSChristoph Lameter 		.mode		= 0644,
1163*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1164c84db23cSChristoph Lameter 		.extra1		= &zero,
11651743660bSChristoph Lameter 	},
11669614634fSChristoph Lameter 	{
11679614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
11689614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
11699614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
11709614634fSChristoph Lameter 		.mode		= 0644,
1171*6d456111SEric W. Biederman 		.proc_handler	= sysctl_min_unmapped_ratio_sysctl_handler,
11729614634fSChristoph Lameter 		.extra1		= &zero,
11739614634fSChristoph Lameter 		.extra2		= &one_hundred,
11749614634fSChristoph Lameter 	},
11750ff38490SChristoph Lameter 	{
11760ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
11770ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
11780ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
11790ff38490SChristoph Lameter 		.mode		= 0644,
1180*6d456111SEric W. Biederman 		.proc_handler	= sysctl_min_slab_ratio_sysctl_handler,
11810ff38490SChristoph Lameter 		.extra1		= &zero,
11820ff38490SChristoph Lameter 		.extra2		= &one_hundred,
11830ff38490SChristoph Lameter 	},
11841743660bSChristoph Lameter #endif
118577461ab3SChristoph Lameter #ifdef CONFIG_SMP
118677461ab3SChristoph Lameter 	{
118777461ab3SChristoph Lameter 		.procname	= "stat_interval",
118877461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
118977461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
119077461ab3SChristoph Lameter 		.mode		= 0644,
1191*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
119277461ab3SChristoph Lameter 	},
119377461ab3SChristoph Lameter #endif
1194ed032189SEric Paris 	{
1195ed032189SEric Paris 		.procname	= "mmap_min_addr",
1196788084abSEric Paris 		.data		= &dac_mmap_min_addr,
1197ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
1198ed032189SEric Paris 		.mode		= 0644,
1199*6d456111SEric W. Biederman 		.proc_handler	= mmap_min_addr_handler,
1200ed032189SEric Paris 	},
1201f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
1202f0c0b2b8SKAMEZAWA Hiroyuki 	{
1203f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
1204f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
1205f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
1206f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
1207*6d456111SEric W. Biederman 		.proc_handler	= numa_zonelist_order_handler,
1208f0c0b2b8SKAMEZAWA Hiroyuki 	},
1209f0c0b2b8SKAMEZAWA Hiroyuki #endif
12102b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
12115c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1212e6e5494cSIngo Molnar 	{
1213e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
1214e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
1215e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
1216e6e5494cSIngo Molnar 		.mode		= 0644,
1217*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1218e6e5494cSIngo Molnar 		.extra1		= &zero,
1219e6e5494cSIngo Molnar 	},
1220e6e5494cSIngo Molnar #endif
1221195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
1222195cf453SBron Gondwana 	{
1223195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
1224195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
1225195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
1226195cf453SBron Gondwana 		.mode		= 0644,
1227*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1228195cf453SBron Gondwana 		.extra1		= &zero,
1229195cf453SBron Gondwana 		.extra2		= &one,
1230195cf453SBron Gondwana 	},
1231195cf453SBron Gondwana #endif
12324be6f6bbSPeter Zijlstra 	{
12334be6f6bbSPeter Zijlstra 		.procname	= "scan_unevictable_pages",
12344be6f6bbSPeter Zijlstra 		.data		= &scan_unevictable_pages,
12354be6f6bbSPeter Zijlstra 		.maxlen		= sizeof(scan_unevictable_pages),
12364be6f6bbSPeter Zijlstra 		.mode		= 0644,
1237*6d456111SEric W. Biederman 		.proc_handler	= scan_unevictable_handler,
12384be6f6bbSPeter Zijlstra 	},
12396a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE
12406a46079cSAndi Kleen 	{
12416a46079cSAndi Kleen 		.procname	= "memory_failure_early_kill",
12426a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_early_kill,
12436a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_early_kill),
12446a46079cSAndi Kleen 		.mode		= 0644,
1245*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
12466a46079cSAndi Kleen 		.extra1		= &zero,
12476a46079cSAndi Kleen 		.extra2		= &one,
12486a46079cSAndi Kleen 	},
12496a46079cSAndi Kleen 	{
12506a46079cSAndi Kleen 		.procname	= "memory_failure_recovery",
12516a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_recovery,
12526a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_recovery),
12536a46079cSAndi Kleen 		.mode		= 0644,
1254*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
12556a46079cSAndi Kleen 		.extra1		= &zero,
12566a46079cSAndi Kleen 		.extra2		= &one,
12576a46079cSAndi Kleen 	},
12586a46079cSAndi Kleen #endif
12596a46079cSAndi Kleen 
12602be7fe07SAndrew Morton /*
12612be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
12622be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
12632be7fe07SAndrew Morton  */
12646fce56ecSEric W. Biederman 	{ }
12651da177e4SLinus Torvalds };
12661da177e4SLinus Torvalds 
12672abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1268d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = {
12696fce56ecSEric W. Biederman 	{ }
12702abc26fcSEric W. Biederman };
12712abc26fcSEric W. Biederman #endif
12722abc26fcSEric W. Biederman 
1273d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
12741da177e4SLinus Torvalds 	{
12751da177e4SLinus Torvalds 		.procname	= "inode-nr",
12761da177e4SLinus Torvalds 		.data		= &inodes_stat,
12771da177e4SLinus Torvalds 		.maxlen		= 2*sizeof(int),
12781da177e4SLinus Torvalds 		.mode		= 0444,
1279*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
12801da177e4SLinus Torvalds 	},
12811da177e4SLinus Torvalds 	{
12821da177e4SLinus Torvalds 		.procname	= "inode-state",
12831da177e4SLinus Torvalds 		.data		= &inodes_stat,
12841da177e4SLinus Torvalds 		.maxlen		= 7*sizeof(int),
12851da177e4SLinus Torvalds 		.mode		= 0444,
1286*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
12871da177e4SLinus Torvalds 	},
12881da177e4SLinus Torvalds 	{
12891da177e4SLinus Torvalds 		.procname	= "file-nr",
12901da177e4SLinus Torvalds 		.data		= &files_stat,
12911da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
12921da177e4SLinus Torvalds 		.mode		= 0444,
1293*6d456111SEric W. Biederman 		.proc_handler	= proc_nr_files,
12941da177e4SLinus Torvalds 	},
12951da177e4SLinus Torvalds 	{
12961da177e4SLinus Torvalds 		.procname	= "file-max",
12971da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
12981da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
12991da177e4SLinus Torvalds 		.mode		= 0644,
1300*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13011da177e4SLinus Torvalds 	},
13021da177e4SLinus Torvalds 	{
13039cfe015aSEric Dumazet 		.procname	= "nr_open",
13049cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
13059cfe015aSEric Dumazet 		.maxlen		= sizeof(int),
13069cfe015aSEric Dumazet 		.mode		= 0644,
1307*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1308eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
1309eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
13109cfe015aSEric Dumazet 	},
13119cfe015aSEric Dumazet 	{
13121da177e4SLinus Torvalds 		.procname	= "dentry-state",
13131da177e4SLinus Torvalds 		.data		= &dentry_stat,
13141da177e4SLinus Torvalds 		.maxlen		= 6*sizeof(int),
13151da177e4SLinus Torvalds 		.mode		= 0444,
1316*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13171da177e4SLinus Torvalds 	},
13181da177e4SLinus Torvalds 	{
13191da177e4SLinus Torvalds 		.procname	= "overflowuid",
13201da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
13211da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13221da177e4SLinus Torvalds 		.mode		= 0644,
1323*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13241da177e4SLinus Torvalds 		.extra1		= &minolduid,
13251da177e4SLinus Torvalds 		.extra2		= &maxolduid,
13261da177e4SLinus Torvalds 	},
13271da177e4SLinus Torvalds 	{
13281da177e4SLinus Torvalds 		.procname	= "overflowgid",
13291da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
13301da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13311da177e4SLinus Torvalds 		.mode		= 0644,
1332*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13331da177e4SLinus Torvalds 		.extra1		= &minolduid,
13341da177e4SLinus Torvalds 		.extra2		= &maxolduid,
13351da177e4SLinus Torvalds 	},
1336bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
13371da177e4SLinus Torvalds 	{
13381da177e4SLinus Torvalds 		.procname	= "leases-enable",
13391da177e4SLinus Torvalds 		.data		= &leases_enable,
13401da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13411da177e4SLinus Torvalds 		.mode		= 0644,
1342*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13431da177e4SLinus Torvalds 	},
1344bfcd17a6SThomas Petazzoni #endif
13451da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
13461da177e4SLinus Torvalds 	{
13471da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
13481da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
13491da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13501da177e4SLinus Torvalds 		.mode		= 0644,
1351*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13521da177e4SLinus Torvalds 	},
13531da177e4SLinus Torvalds #endif
13541da177e4SLinus Torvalds #ifdef CONFIG_MMU
1355bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
13561da177e4SLinus Torvalds 	{
13571da177e4SLinus Torvalds 		.procname	= "lease-break-time",
13581da177e4SLinus Torvalds 		.data		= &lease_break_time,
13591da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13601da177e4SLinus Torvalds 		.mode		= 0644,
1361*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13621da177e4SLinus Torvalds 	},
1363bfcd17a6SThomas Petazzoni #endif
1364ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
13651da177e4SLinus Torvalds 	{
13661da177e4SLinus Torvalds 		.procname	= "aio-nr",
13671da177e4SLinus Torvalds 		.data		= &aio_nr,
13681da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
13691da177e4SLinus Torvalds 		.mode		= 0444,
1370*6d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
13711da177e4SLinus Torvalds 	},
13721da177e4SLinus Torvalds 	{
13731da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
13741da177e4SLinus Torvalds 		.data		= &aio_max_nr,
13751da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
13761da177e4SLinus Torvalds 		.mode		= 0644,
1377*6d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
13781da177e4SLinus Torvalds 	},
1379ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
13802d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
13810399cb08SRobert Love 	{
13820399cb08SRobert Love 		.procname	= "inotify",
13830399cb08SRobert Love 		.mode		= 0555,
13840399cb08SRobert Love 		.child		= inotify_table,
13850399cb08SRobert Love 	},
13860399cb08SRobert Love #endif
13877ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
13887ef9964eSDavide Libenzi 	{
13897ef9964eSDavide Libenzi 		.procname	= "epoll",
13907ef9964eSDavide Libenzi 		.mode		= 0555,
13917ef9964eSDavide Libenzi 		.child		= epoll_table,
13927ef9964eSDavide Libenzi 	},
13937ef9964eSDavide Libenzi #endif
13941da177e4SLinus Torvalds #endif
1395d6e71144SAlan Cox 	{
1396d6e71144SAlan Cox 		.procname	= "suid_dumpable",
1397d6e71144SAlan Cox 		.data		= &suid_dumpable,
1398d6e71144SAlan Cox 		.maxlen		= sizeof(int),
1399d6e71144SAlan Cox 		.mode		= 0644,
1400*6d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
14018e654fbaSMatthew Wilcox 		.extra1		= &zero,
14028e654fbaSMatthew Wilcox 		.extra2		= &two,
1403d6e71144SAlan Cox 	},
14042abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
14052abc26fcSEric W. Biederman 	{
14062abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
14072abc26fcSEric W. Biederman 		.mode		= 0555,
14082abc26fcSEric W. Biederman 		.child		= binfmt_misc_table,
14092abc26fcSEric W. Biederman 	},
14102abc26fcSEric W. Biederman #endif
14112be7fe07SAndrew Morton /*
14122be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
14132be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
14142be7fe07SAndrew Morton  */
14156fce56ecSEric W. Biederman 	{ }
14161da177e4SLinus Torvalds };
14171da177e4SLinus Torvalds 
1418d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
1419d0c3d534SOlof Johansson #if defined(CONFIG_X86) || defined(CONFIG_PPC)
1420abd4f750SMasoud Asgharifard Sharbiani 	{
1421abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
1422abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
1423abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
1424abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
1425abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
1426abd4f750SMasoud Asgharifard Sharbiani 	},
1427abd4f750SMasoud Asgharifard Sharbiani #endif
14286fce56ecSEric W. Biederman 	{ }
14291da177e4SLinus Torvalds };
14301da177e4SLinus Torvalds 
1431d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
14326fce56ecSEric W. Biederman 	{ }
14331da177e4SLinus Torvalds };
14341da177e4SLinus Torvalds 
1435330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock);
1436330d57fbSAl Viro 
1437330d57fbSAl Viro /* called under sysctl_lock */
1438330d57fbSAl Viro static int use_table(struct ctl_table_header *p)
1439330d57fbSAl Viro {
1440330d57fbSAl Viro 	if (unlikely(p->unregistering))
1441330d57fbSAl Viro 		return 0;
1442330d57fbSAl Viro 	p->used++;
1443330d57fbSAl Viro 	return 1;
1444330d57fbSAl Viro }
1445330d57fbSAl Viro 
1446330d57fbSAl Viro /* called under sysctl_lock */
1447330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p)
1448330d57fbSAl Viro {
1449330d57fbSAl Viro 	if (!--p->used)
1450330d57fbSAl Viro 		if (unlikely(p->unregistering))
1451330d57fbSAl Viro 			complete(p->unregistering);
1452330d57fbSAl Viro }
1453330d57fbSAl Viro 
1454330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */
1455330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p)
1456330d57fbSAl Viro {
1457330d57fbSAl Viro 	/*
1458330d57fbSAl Viro 	 * if p->used is 0, nobody will ever touch that entry again;
1459330d57fbSAl Viro 	 * we'll eliminate all paths to it before dropping sysctl_lock
1460330d57fbSAl Viro 	 */
1461330d57fbSAl Viro 	if (unlikely(p->used)) {
1462330d57fbSAl Viro 		struct completion wait;
1463330d57fbSAl Viro 		init_completion(&wait);
1464330d57fbSAl Viro 		p->unregistering = &wait;
1465330d57fbSAl Viro 		spin_unlock(&sysctl_lock);
1466330d57fbSAl Viro 		wait_for_completion(&wait);
1467330d57fbSAl Viro 		spin_lock(&sysctl_lock);
1468f7e6ced4SAl Viro 	} else {
1469f7e6ced4SAl Viro 		/* anything non-NULL; we'll never dereference it */
1470f7e6ced4SAl Viro 		p->unregistering = ERR_PTR(-EINVAL);
1471330d57fbSAl Viro 	}
1472330d57fbSAl Viro 	/*
1473330d57fbSAl Viro 	 * do not remove from the list until nobody holds it; walking the
1474330d57fbSAl Viro 	 * list in do_sysctl() relies on that.
1475330d57fbSAl Viro 	 */
1476330d57fbSAl Viro 	list_del_init(&p->ctl_entry);
1477330d57fbSAl Viro }
1478330d57fbSAl Viro 
1479f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head)
1480f7e6ced4SAl Viro {
1481f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1482f7e6ced4SAl Viro 	head->count++;
1483f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1484f7e6ced4SAl Viro }
1485f7e6ced4SAl Viro 
1486f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
1487f7e6ced4SAl Viro {
1488f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1489f7e6ced4SAl Viro 	if (!--head->count)
1490f7e6ced4SAl Viro 		kfree(head);
1491f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1492f7e6ced4SAl Viro }
1493f7e6ced4SAl Viro 
1494f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1495f7e6ced4SAl Viro {
1496f7e6ced4SAl Viro 	if (!head)
1497f7e6ced4SAl Viro 		BUG();
1498f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1499f7e6ced4SAl Viro 	if (!use_table(head))
1500f7e6ced4SAl Viro 		head = ERR_PTR(-ENOENT);
1501f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1502f7e6ced4SAl Viro 	return head;
1503f7e6ced4SAl Viro }
1504f7e6ced4SAl Viro 
1505805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head)
1506805b5d5eSEric W. Biederman {
1507805b5d5eSEric W. Biederman 	if (!head)
1508805b5d5eSEric W. Biederman 		return;
1509805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1510805b5d5eSEric W. Biederman 	unuse_table(head);
1511805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1512805b5d5eSEric W. Biederman }
1513805b5d5eSEric W. Biederman 
151473455092SAl Viro static struct ctl_table_set *
151573455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
151673455092SAl Viro {
151773455092SAl Viro 	struct ctl_table_set *set = &root->default_set;
151873455092SAl Viro 	if (root->lookup)
151973455092SAl Viro 		set = root->lookup(root, namespaces);
152073455092SAl Viro 	return set;
152173455092SAl Viro }
152273455092SAl Viro 
1523e51b6ba0SEric W. Biederman static struct list_head *
1524e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1525805b5d5eSEric W. Biederman {
152673455092SAl Viro 	struct ctl_table_set *set = lookup_header_set(root, namespaces);
152773455092SAl Viro 	return &set->list;
1528e51b6ba0SEric W. Biederman }
1529e51b6ba0SEric W. Biederman 
1530e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1531e51b6ba0SEric W. Biederman 					    struct ctl_table_header *prev)
1532e51b6ba0SEric W. Biederman {
1533e51b6ba0SEric W. Biederman 	struct ctl_table_root *root;
1534e51b6ba0SEric W. Biederman 	struct list_head *header_list;
1535805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1536805b5d5eSEric W. Biederman 	struct list_head *tmp;
1537e51b6ba0SEric W. Biederman 
1538805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1539805b5d5eSEric W. Biederman 	if (prev) {
1540e51b6ba0SEric W. Biederman 		head = prev;
1541805b5d5eSEric W. Biederman 		tmp = &prev->ctl_entry;
1542805b5d5eSEric W. Biederman 		unuse_table(prev);
1543805b5d5eSEric W. Biederman 		goto next;
1544805b5d5eSEric W. Biederman 	}
1545805b5d5eSEric W. Biederman 	tmp = &root_table_header.ctl_entry;
1546805b5d5eSEric W. Biederman 	for (;;) {
1547805b5d5eSEric W. Biederman 		head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1548805b5d5eSEric W. Biederman 
1549805b5d5eSEric W. Biederman 		if (!use_table(head))
1550805b5d5eSEric W. Biederman 			goto next;
1551805b5d5eSEric W. Biederman 		spin_unlock(&sysctl_lock);
1552805b5d5eSEric W. Biederman 		return head;
1553805b5d5eSEric W. Biederman 	next:
1554e51b6ba0SEric W. Biederman 		root = head->root;
1555805b5d5eSEric W. Biederman 		tmp = tmp->next;
1556e51b6ba0SEric W. Biederman 		header_list = lookup_header_list(root, namespaces);
1557e51b6ba0SEric W. Biederman 		if (tmp != header_list)
1558e51b6ba0SEric W. Biederman 			continue;
1559e51b6ba0SEric W. Biederman 
1560e51b6ba0SEric W. Biederman 		do {
1561e51b6ba0SEric W. Biederman 			root = list_entry(root->root_list.next,
1562e51b6ba0SEric W. Biederman 					struct ctl_table_root, root_list);
1563e51b6ba0SEric W. Biederman 			if (root == &sysctl_table_root)
1564e51b6ba0SEric W. Biederman 				goto out;
1565e51b6ba0SEric W. Biederman 			header_list = lookup_header_list(root, namespaces);
1566e51b6ba0SEric W. Biederman 		} while (list_empty(header_list));
1567e51b6ba0SEric W. Biederman 		tmp = header_list->next;
1568805b5d5eSEric W. Biederman 	}
1569e51b6ba0SEric W. Biederman out:
1570805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1571805b5d5eSEric W. Biederman 	return NULL;
1572805b5d5eSEric W. Biederman }
1573805b5d5eSEric W. Biederman 
1574e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1575e51b6ba0SEric W. Biederman {
1576e51b6ba0SEric W. Biederman 	return __sysctl_head_next(current->nsproxy, prev);
1577e51b6ba0SEric W. Biederman }
1578e51b6ba0SEric W. Biederman 
1579e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root)
1580e51b6ba0SEric W. Biederman {
1581e51b6ba0SEric W. Biederman 	spin_lock(&sysctl_lock);
1582e51b6ba0SEric W. Biederman 	list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1583e51b6ba0SEric W. Biederman 	spin_unlock(&sysctl_lock);
1584e51b6ba0SEric W. Biederman }
1585e51b6ba0SEric W. Biederman 
15861da177e4SLinus Torvalds /*
15871ff007ebSEric W. Biederman  * sysctl_perm does NOT grant the superuser all rights automatically, because
15881da177e4SLinus Torvalds  * some sysctl variables are readonly even to root.
15891da177e4SLinus Torvalds  */
15901da177e4SLinus Torvalds 
15911da177e4SLinus Torvalds static int test_perm(int mode, int op)
15921da177e4SLinus Torvalds {
159376aac0e9SDavid Howells 	if (!current_euid())
15941da177e4SLinus Torvalds 		mode >>= 6;
15951da177e4SLinus Torvalds 	else if (in_egroup_p(0))
15961da177e4SLinus Torvalds 		mode >>= 3;
1597e6305c43SAl Viro 	if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
15981da177e4SLinus Torvalds 		return 0;
15991da177e4SLinus Torvalds 	return -EACCES;
16001da177e4SLinus Torvalds }
16011da177e4SLinus Torvalds 
1602d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
16031da177e4SLinus Torvalds {
16041da177e4SLinus Torvalds 	int error;
1605d7321cd6SPavel Emelyanov 	int mode;
1606d7321cd6SPavel Emelyanov 
1607e6305c43SAl Viro 	error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
16081da177e4SLinus Torvalds 	if (error)
16091da177e4SLinus Torvalds 		return error;
1610d7321cd6SPavel Emelyanov 
1611d7321cd6SPavel Emelyanov 	if (root->permissions)
1612d7321cd6SPavel Emelyanov 		mode = root->permissions(root, current->nsproxy, table);
1613d7321cd6SPavel Emelyanov 	else
1614d7321cd6SPavel Emelyanov 		mode = table->mode;
1615d7321cd6SPavel Emelyanov 
1616d7321cd6SPavel Emelyanov 	return test_perm(mode, op);
16171da177e4SLinus Torvalds }
16181da177e4SLinus Torvalds 
1619d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1620d912b0ccSEric W. Biederman {
16212315ffa0SEric W. Biederman 	for (; table->procname; table++) {
1622d912b0ccSEric W. Biederman 		table->parent = parent;
1623d912b0ccSEric W. Biederman 		if (table->child)
1624d912b0ccSEric W. Biederman 			sysctl_set_parent(table, table->child);
1625d912b0ccSEric W. Biederman 	}
1626d912b0ccSEric W. Biederman }
1627d912b0ccSEric W. Biederman 
1628d912b0ccSEric W. Biederman static __init int sysctl_init(void)
1629d912b0ccSEric W. Biederman {
1630d912b0ccSEric W. Biederman 	sysctl_set_parent(NULL, root_table);
163188f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
163288f458e4SHolger Schurig 	{
163388f458e4SHolger Schurig 		int err;
1634e51b6ba0SEric W. Biederman 		err = sysctl_check_table(current->nsproxy, root_table);
163588f458e4SHolger Schurig 	}
163688f458e4SHolger Schurig #endif
1637d912b0ccSEric W. Biederman 	return 0;
1638d912b0ccSEric W. Biederman }
1639d912b0ccSEric W. Biederman 
1640d912b0ccSEric W. Biederman core_initcall(sysctl_init);
1641d912b0ccSEric W. Biederman 
1642bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch,
1643bfbcf034SAl Viro 				      struct ctl_table *table)
1644ae7edeccSAl Viro {
1645ae7edeccSAl Viro 	struct ctl_table *p;
1646ae7edeccSAl Viro 	const char *s = branch->procname;
1647ae7edeccSAl Viro 
1648ae7edeccSAl Viro 	/* branch should have named subdirectory as its first element */
1649ae7edeccSAl Viro 	if (!s || !branch->child)
1650bfbcf034SAl Viro 		return NULL;
1651ae7edeccSAl Viro 
1652ae7edeccSAl Viro 	/* ... and nothing else */
16532315ffa0SEric W. Biederman 	if (branch[1].procname)
1654bfbcf034SAl Viro 		return NULL;
1655ae7edeccSAl Viro 
1656ae7edeccSAl Viro 	/* table should contain subdirectory with the same name */
16572315ffa0SEric W. Biederman 	for (p = table; p->procname; p++) {
1658ae7edeccSAl Viro 		if (!p->child)
1659ae7edeccSAl Viro 			continue;
1660ae7edeccSAl Viro 		if (p->procname && strcmp(p->procname, s) == 0)
1661bfbcf034SAl Viro 			return p;
1662ae7edeccSAl Viro 	}
1663bfbcf034SAl Viro 	return NULL;
1664ae7edeccSAl Viro }
1665ae7edeccSAl Viro 
1666ae7edeccSAl Viro /* see if attaching q to p would be an improvement */
1667ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1668ae7edeccSAl Viro {
1669ae7edeccSAl Viro 	struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1670bfbcf034SAl Viro 	struct ctl_table *next;
1671ae7edeccSAl Viro 	int is_better = 0;
1672ae7edeccSAl Viro 	int not_in_parent = !p->attached_by;
1673ae7edeccSAl Viro 
1674bfbcf034SAl Viro 	while ((next = is_branch_in(by, to)) != NULL) {
1675ae7edeccSAl Viro 		if (by == q->attached_by)
1676ae7edeccSAl Viro 			is_better = 1;
1677ae7edeccSAl Viro 		if (to == p->attached_by)
1678ae7edeccSAl Viro 			not_in_parent = 1;
1679ae7edeccSAl Viro 		by = by->child;
1680bfbcf034SAl Viro 		to = next->child;
1681ae7edeccSAl Viro 	}
1682ae7edeccSAl Viro 
1683ae7edeccSAl Viro 	if (is_better && not_in_parent) {
1684ae7edeccSAl Viro 		q->attached_by = by;
1685ae7edeccSAl Viro 		q->attached_to = to;
1686ae7edeccSAl Viro 		q->parent = p;
1687ae7edeccSAl Viro 	}
1688ae7edeccSAl Viro }
1689ae7edeccSAl Viro 
16901da177e4SLinus Torvalds /**
1691e51b6ba0SEric W. Biederman  * __register_sysctl_paths - register a sysctl hierarchy
1692e51b6ba0SEric W. Biederman  * @root: List of sysctl headers to register on
1693e51b6ba0SEric W. Biederman  * @namespaces: Data to compute which lists of sysctl entries are visible
169429e796fdSEric W. Biederman  * @path: The path to the directory the sysctl table is in.
16951da177e4SLinus Torvalds  * @table: the top-level table structure
16961da177e4SLinus Torvalds  *
16971da177e4SLinus Torvalds  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
169829e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
16991da177e4SLinus Torvalds  *
1700d8217f07SEric W. Biederman  * The members of the &struct ctl_table structure are used as follows:
17011da177e4SLinus Torvalds  *
17021da177e4SLinus Torvalds  * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
17031da177e4SLinus Torvalds  *            enter a sysctl file
17041da177e4SLinus Torvalds  *
17051da177e4SLinus Torvalds  * data - a pointer to data for use by proc_handler
17061da177e4SLinus Torvalds  *
17071da177e4SLinus Torvalds  * maxlen - the maximum size in bytes of the data
17081da177e4SLinus Torvalds  *
17091da177e4SLinus Torvalds  * mode - the file permissions for the /proc/sys file, and for sysctl(2)
17101da177e4SLinus Torvalds  *
17111da177e4SLinus Torvalds  * child - a pointer to the child sysctl table if this entry is a directory, or
17121da177e4SLinus Torvalds  *         %NULL.
17131da177e4SLinus Torvalds  *
17141da177e4SLinus Torvalds  * proc_handler - the text handler routine (described below)
17151da177e4SLinus Torvalds  *
17161da177e4SLinus Torvalds  * de - for internal use by the sysctl routines
17171da177e4SLinus Torvalds  *
17181da177e4SLinus Torvalds  * extra1, extra2 - extra pointers usable by the proc handler routines
17191da177e4SLinus Torvalds  *
17201da177e4SLinus Torvalds  * Leaf nodes in the sysctl tree will be represented by a single file
17211da177e4SLinus Torvalds  * under /proc; non-leaf nodes will be represented by directories.
17221da177e4SLinus Torvalds  *
17231da177e4SLinus Torvalds  * sysctl(2) can automatically manage read and write requests through
17241da177e4SLinus Torvalds  * the sysctl table.  The data and maxlen fields of the ctl_table
17251da177e4SLinus Torvalds  * struct enable minimal validation of the values being written to be
17261da177e4SLinus Torvalds  * performed, and the mode field allows minimal authentication.
17271da177e4SLinus Torvalds  *
17281da177e4SLinus Torvalds  * There must be a proc_handler routine for any terminal nodes
17291da177e4SLinus Torvalds  * mirrored under /proc/sys (non-terminals are handled by a built-in
17301da177e4SLinus Torvalds  * directory handler).  Several default handlers are available to
17311da177e4SLinus Torvalds  * cover common cases -
17321da177e4SLinus Torvalds  *
17331da177e4SLinus Torvalds  * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
17341da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
17351da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
17361da177e4SLinus Torvalds  *
17371da177e4SLinus Torvalds  * It is the handler's job to read the input buffer from user memory
17381da177e4SLinus Torvalds  * and process it. The handler should return 0 on success.
17391da177e4SLinus Torvalds  *
17401da177e4SLinus Torvalds  * This routine returns %NULL on a failure to register, and a pointer
17411da177e4SLinus Torvalds  * to the table header on success.
17421da177e4SLinus Torvalds  */
1743e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths(
1744e51b6ba0SEric W. Biederman 	struct ctl_table_root *root,
1745e51b6ba0SEric W. Biederman 	struct nsproxy *namespaces,
1746e51b6ba0SEric W. Biederman 	const struct ctl_path *path, struct ctl_table *table)
17471da177e4SLinus Torvalds {
174829e796fdSEric W. Biederman 	struct ctl_table_header *header;
174929e796fdSEric W. Biederman 	struct ctl_table *new, **prevp;
175029e796fdSEric W. Biederman 	unsigned int n, npath;
1751ae7edeccSAl Viro 	struct ctl_table_set *set;
175229e796fdSEric W. Biederman 
175329e796fdSEric W. Biederman 	/* Count the path components */
17542315ffa0SEric W. Biederman 	for (npath = 0; path[npath].procname; ++npath)
175529e796fdSEric W. Biederman 		;
175629e796fdSEric W. Biederman 
175729e796fdSEric W. Biederman 	/*
175829e796fdSEric W. Biederman 	 * For each path component, allocate a 2-element ctl_table array.
175929e796fdSEric W. Biederman 	 * The first array element will be filled with the sysctl entry
17602315ffa0SEric W. Biederman 	 * for this, the second will be the sentinel (procname == 0).
176129e796fdSEric W. Biederman 	 *
176229e796fdSEric W. Biederman 	 * We allocate everything in one go so that we don't have to
176329e796fdSEric W. Biederman 	 * worry about freeing additional memory in unregister_sysctl_table.
176429e796fdSEric W. Biederman 	 */
176529e796fdSEric W. Biederman 	header = kzalloc(sizeof(struct ctl_table_header) +
176629e796fdSEric W. Biederman 			 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
176729e796fdSEric W. Biederman 	if (!header)
17681da177e4SLinus Torvalds 		return NULL;
176929e796fdSEric W. Biederman 
177029e796fdSEric W. Biederman 	new = (struct ctl_table *) (header + 1);
177129e796fdSEric W. Biederman 
177229e796fdSEric W. Biederman 	/* Now connect the dots */
177329e796fdSEric W. Biederman 	prevp = &header->ctl_table;
177429e796fdSEric W. Biederman 	for (n = 0; n < npath; ++n, ++path) {
177529e796fdSEric W. Biederman 		/* Copy the procname */
177629e796fdSEric W. Biederman 		new->procname = path->procname;
177729e796fdSEric W. Biederman 		new->mode     = 0555;
177829e796fdSEric W. Biederman 
177929e796fdSEric W. Biederman 		*prevp = new;
178029e796fdSEric W. Biederman 		prevp = &new->child;
178129e796fdSEric W. Biederman 
178229e796fdSEric W. Biederman 		new += 2;
178329e796fdSEric W. Biederman 	}
178429e796fdSEric W. Biederman 	*prevp = table;
178523eb06deSEric W. Biederman 	header->ctl_table_arg = table;
178629e796fdSEric W. Biederman 
178729e796fdSEric W. Biederman 	INIT_LIST_HEAD(&header->ctl_entry);
178829e796fdSEric W. Biederman 	header->used = 0;
178929e796fdSEric W. Biederman 	header->unregistering = NULL;
1790e51b6ba0SEric W. Biederman 	header->root = root;
179129e796fdSEric W. Biederman 	sysctl_set_parent(NULL, header->ctl_table);
1792f7e6ced4SAl Viro 	header->count = 1;
179388f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1794e51b6ba0SEric W. Biederman 	if (sysctl_check_table(namespaces, header->ctl_table)) {
179529e796fdSEric W. Biederman 		kfree(header);
1796fc6cd25bSEric W. Biederman 		return NULL;
1797fc6cd25bSEric W. Biederman 	}
179888f458e4SHolger Schurig #endif
1799330d57fbSAl Viro 	spin_lock(&sysctl_lock);
180073455092SAl Viro 	header->set = lookup_header_set(root, namespaces);
1801ae7edeccSAl Viro 	header->attached_by = header->ctl_table;
1802ae7edeccSAl Viro 	header->attached_to = root_table;
1803ae7edeccSAl Viro 	header->parent = &root_table_header;
1804ae7edeccSAl Viro 	for (set = header->set; set; set = set->parent) {
1805ae7edeccSAl Viro 		struct ctl_table_header *p;
1806ae7edeccSAl Viro 		list_for_each_entry(p, &set->list, ctl_entry) {
1807ae7edeccSAl Viro 			if (p->unregistering)
1808ae7edeccSAl Viro 				continue;
1809ae7edeccSAl Viro 			try_attach(p, header);
1810ae7edeccSAl Viro 		}
1811ae7edeccSAl Viro 	}
1812ae7edeccSAl Viro 	header->parent->count++;
181373455092SAl Viro 	list_add_tail(&header->ctl_entry, &header->set->list);
1814330d57fbSAl Viro 	spin_unlock(&sysctl_lock);
181529e796fdSEric W. Biederman 
181629e796fdSEric W. Biederman 	return header;
181729e796fdSEric W. Biederman }
181829e796fdSEric W. Biederman 
181929e796fdSEric W. Biederman /**
1820e51b6ba0SEric W. Biederman  * register_sysctl_table_path - register a sysctl table hierarchy
1821e51b6ba0SEric W. Biederman  * @path: The path to the directory the sysctl table is in.
1822e51b6ba0SEric W. Biederman  * @table: the top-level table structure
1823e51b6ba0SEric W. Biederman  *
1824e51b6ba0SEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1825e51b6ba0SEric W. Biederman  * array. A completely 0 filled entry terminates the table.
1826e51b6ba0SEric W. Biederman  *
1827e51b6ba0SEric W. Biederman  * See __register_sysctl_paths for more details.
1828e51b6ba0SEric W. Biederman  */
1829e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1830e51b6ba0SEric W. Biederman 						struct ctl_table *table)
1831e51b6ba0SEric W. Biederman {
1832e51b6ba0SEric W. Biederman 	return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1833e51b6ba0SEric W. Biederman 					path, table);
1834e51b6ba0SEric W. Biederman }
1835e51b6ba0SEric W. Biederman 
1836e51b6ba0SEric W. Biederman /**
183729e796fdSEric W. Biederman  * register_sysctl_table - register a sysctl table hierarchy
183829e796fdSEric W. Biederman  * @table: the top-level table structure
183929e796fdSEric W. Biederman  *
184029e796fdSEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
184129e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
184229e796fdSEric W. Biederman  *
184329e796fdSEric W. Biederman  * See register_sysctl_paths for more details.
184429e796fdSEric W. Biederman  */
184529e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
184629e796fdSEric W. Biederman {
184729e796fdSEric W. Biederman 	static const struct ctl_path null_path[] = { {} };
184829e796fdSEric W. Biederman 
184929e796fdSEric W. Biederman 	return register_sysctl_paths(null_path, table);
18501da177e4SLinus Torvalds }
18511da177e4SLinus Torvalds 
18521da177e4SLinus Torvalds /**
18531da177e4SLinus Torvalds  * unregister_sysctl_table - unregister a sysctl table hierarchy
18541da177e4SLinus Torvalds  * @header: the header returned from register_sysctl_table
18551da177e4SLinus Torvalds  *
18561da177e4SLinus Torvalds  * Unregisters the sysctl table and all children. proc entries may not
18571da177e4SLinus Torvalds  * actually be removed until they are no longer used by anyone.
18581da177e4SLinus Torvalds  */
18591da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header)
18601da177e4SLinus Torvalds {
1861330d57fbSAl Viro 	might_sleep();
1862f1dad166SPavel Emelyanov 
1863f1dad166SPavel Emelyanov 	if (header == NULL)
1864f1dad166SPavel Emelyanov 		return;
1865f1dad166SPavel Emelyanov 
1866330d57fbSAl Viro 	spin_lock(&sysctl_lock);
1867330d57fbSAl Viro 	start_unregistering(header);
1868ae7edeccSAl Viro 	if (!--header->parent->count) {
1869ae7edeccSAl Viro 		WARN_ON(1);
1870ae7edeccSAl Viro 		kfree(header->parent);
1871ae7edeccSAl Viro 	}
1872f7e6ced4SAl Viro 	if (!--header->count)
18731da177e4SLinus Torvalds 		kfree(header);
1874f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
18751da177e4SLinus Torvalds }
18761da177e4SLinus Torvalds 
18779043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p)
18789043476fSAl Viro {
18799043476fSAl Viro 	struct ctl_table_set *set = p->set;
18809043476fSAl Viro 	int res;
18819043476fSAl Viro 	spin_lock(&sysctl_lock);
18829043476fSAl Viro 	if (p->unregistering)
18839043476fSAl Viro 		res = 0;
18849043476fSAl Viro 	else if (!set->is_seen)
18859043476fSAl Viro 		res = 1;
18869043476fSAl Viro 	else
18879043476fSAl Viro 		res = set->is_seen(set);
18889043476fSAl Viro 	spin_unlock(&sysctl_lock);
18899043476fSAl Viro 	return res;
18909043476fSAl Viro }
18919043476fSAl Viro 
189273455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
189373455092SAl Viro 	struct ctl_table_set *parent,
189473455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
189573455092SAl Viro {
189673455092SAl Viro 	INIT_LIST_HEAD(&p->list);
189773455092SAl Viro 	p->parent = parent ? parent : &sysctl_table_root.default_set;
189873455092SAl Viro 	p->is_seen = is_seen;
189973455092SAl Viro }
190073455092SAl Viro 
1901b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */
1902d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
1903b89a8171SEric W. Biederman {
1904b89a8171SEric W. Biederman 	return NULL;
1905b89a8171SEric W. Biederman }
1906b89a8171SEric W. Biederman 
190729e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
190829e796fdSEric W. Biederman 						    struct ctl_table *table)
190929e796fdSEric W. Biederman {
191029e796fdSEric W. Biederman 	return NULL;
191129e796fdSEric W. Biederman }
191229e796fdSEric W. Biederman 
1913b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table)
1914b89a8171SEric W. Biederman {
1915b89a8171SEric W. Biederman }
1916b89a8171SEric W. Biederman 
191773455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
191873455092SAl Viro 	struct ctl_table_set *parent,
191973455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
192073455092SAl Viro {
192173455092SAl Viro }
192273455092SAl Viro 
1923f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
1924f7e6ced4SAl Viro {
1925f7e6ced4SAl Viro }
1926f7e6ced4SAl Viro 
1927b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
1928b89a8171SEric W. Biederman 
19291da177e4SLinus Torvalds /*
19301da177e4SLinus Torvalds  * /proc/sys support
19311da177e4SLinus Torvalds  */
19321da177e4SLinus Torvalds 
1933b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL
19341da177e4SLinus Torvalds 
1935b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write,
19368d65af78SAlexey Dobriyan 			   void __user *buffer,
1937b1ba4dddSAdrian Bunk 			   size_t *lenp, loff_t *ppos)
1938f5dd3d6fSSam Vilain {
1939f5dd3d6fSSam Vilain 	size_t len;
1940f5dd3d6fSSam Vilain 	char __user *p;
1941f5dd3d6fSSam Vilain 	char c;
1942f5dd3d6fSSam Vilain 
19438d060877SOleg Nesterov 	if (!data || !maxlen || !*lenp) {
1944f5dd3d6fSSam Vilain 		*lenp = 0;
1945f5dd3d6fSSam Vilain 		return 0;
1946f5dd3d6fSSam Vilain 	}
1947f5dd3d6fSSam Vilain 
1948f5dd3d6fSSam Vilain 	if (write) {
1949f5dd3d6fSSam Vilain 		len = 0;
1950f5dd3d6fSSam Vilain 		p = buffer;
1951f5dd3d6fSSam Vilain 		while (len < *lenp) {
1952f5dd3d6fSSam Vilain 			if (get_user(c, p++))
1953f5dd3d6fSSam Vilain 				return -EFAULT;
1954f5dd3d6fSSam Vilain 			if (c == 0 || c == '\n')
1955f5dd3d6fSSam Vilain 				break;
1956f5dd3d6fSSam Vilain 			len++;
1957f5dd3d6fSSam Vilain 		}
1958f5dd3d6fSSam Vilain 		if (len >= maxlen)
1959f5dd3d6fSSam Vilain 			len = maxlen-1;
1960f5dd3d6fSSam Vilain 		if(copy_from_user(data, buffer, len))
1961f5dd3d6fSSam Vilain 			return -EFAULT;
1962f5dd3d6fSSam Vilain 		((char *) data)[len] = 0;
1963f5dd3d6fSSam Vilain 		*ppos += *lenp;
1964f5dd3d6fSSam Vilain 	} else {
1965f5dd3d6fSSam Vilain 		len = strlen(data);
1966f5dd3d6fSSam Vilain 		if (len > maxlen)
1967f5dd3d6fSSam Vilain 			len = maxlen;
19688d060877SOleg Nesterov 
19698d060877SOleg Nesterov 		if (*ppos > len) {
19708d060877SOleg Nesterov 			*lenp = 0;
19718d060877SOleg Nesterov 			return 0;
19728d060877SOleg Nesterov 		}
19738d060877SOleg Nesterov 
19748d060877SOleg Nesterov 		data += *ppos;
19758d060877SOleg Nesterov 		len  -= *ppos;
19768d060877SOleg Nesterov 
1977f5dd3d6fSSam Vilain 		if (len > *lenp)
1978f5dd3d6fSSam Vilain 			len = *lenp;
1979f5dd3d6fSSam Vilain 		if (len)
1980f5dd3d6fSSam Vilain 			if(copy_to_user(buffer, data, len))
1981f5dd3d6fSSam Vilain 				return -EFAULT;
1982f5dd3d6fSSam Vilain 		if (len < *lenp) {
1983f5dd3d6fSSam Vilain 			if(put_user('\n', ((char __user *) buffer) + len))
1984f5dd3d6fSSam Vilain 				return -EFAULT;
1985f5dd3d6fSSam Vilain 			len++;
1986f5dd3d6fSSam Vilain 		}
1987f5dd3d6fSSam Vilain 		*lenp = len;
1988f5dd3d6fSSam Vilain 		*ppos += len;
1989f5dd3d6fSSam Vilain 	}
1990f5dd3d6fSSam Vilain 	return 0;
1991f5dd3d6fSSam Vilain }
1992f5dd3d6fSSam Vilain 
19931da177e4SLinus Torvalds /**
19941da177e4SLinus Torvalds  * proc_dostring - read a string sysctl
19951da177e4SLinus Torvalds  * @table: the sysctl table
19961da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
19971da177e4SLinus Torvalds  * @buffer: the user buffer
19981da177e4SLinus Torvalds  * @lenp: the size of the user buffer
19991da177e4SLinus Torvalds  * @ppos: file position
20001da177e4SLinus Torvalds  *
20011da177e4SLinus Torvalds  * Reads/writes a string from/to the user buffer. If the kernel
20021da177e4SLinus Torvalds  * buffer provided is not large enough to hold the string, the
20031da177e4SLinus Torvalds  * string is truncated. The copied string is %NULL-terminated.
20041da177e4SLinus Torvalds  * If the string is being read by the user process, it is copied
20051da177e4SLinus Torvalds  * and a newline '\n' is added. It is truncated if the buffer is
20061da177e4SLinus Torvalds  * not large enough.
20071da177e4SLinus Torvalds  *
20081da177e4SLinus Torvalds  * Returns 0 on success.
20091da177e4SLinus Torvalds  */
20108d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write,
20111da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
20121da177e4SLinus Torvalds {
20138d65af78SAlexey Dobriyan 	return _proc_do_string(table->data, table->maxlen, write,
2014f5dd3d6fSSam Vilain 			       buffer, lenp, ppos);
20151da177e4SLinus Torvalds }
20161da177e4SLinus Torvalds 
20171da177e4SLinus Torvalds 
20181da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
20191da177e4SLinus Torvalds 				 int *valp,
20201da177e4SLinus Torvalds 				 int write, void *data)
20211da177e4SLinus Torvalds {
20221da177e4SLinus Torvalds 	if (write) {
20231da177e4SLinus Torvalds 		*valp = *negp ? -*lvalp : *lvalp;
20241da177e4SLinus Torvalds 	} else {
20251da177e4SLinus Torvalds 		int val = *valp;
20261da177e4SLinus Torvalds 		if (val < 0) {
20271da177e4SLinus Torvalds 			*negp = -1;
20281da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
20291da177e4SLinus Torvalds 		} else {
20301da177e4SLinus Torvalds 			*negp = 0;
20311da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
20321da177e4SLinus Torvalds 		}
20331da177e4SLinus Torvalds 	}
20341da177e4SLinus Torvalds 	return 0;
20351da177e4SLinus Torvalds }
20361da177e4SLinus Torvalds 
2037d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
20388d65af78SAlexey Dobriyan 		  int write, void __user *buffer,
2039fcfbd547SKirill Korotaev 		  size_t *lenp, loff_t *ppos,
20401da177e4SLinus Torvalds 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
20411da177e4SLinus Torvalds 			      int write, void *data),
20421da177e4SLinus Torvalds 		  void *data)
20431da177e4SLinus Torvalds {
20441da177e4SLinus Torvalds #define TMPBUFLEN 21
20457338f299SSukanto Ghosh 	int *i, vleft, first = 1, neg;
20461da177e4SLinus Torvalds 	unsigned long lval;
20471da177e4SLinus Torvalds 	size_t left, len;
20481da177e4SLinus Torvalds 
20491da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
20501da177e4SLinus Torvalds 	char __user *s = buffer;
20511da177e4SLinus Torvalds 
2052fcfbd547SKirill Korotaev 	if (!tbl_data || !table->maxlen || !*lenp ||
20531da177e4SLinus Torvalds 	    (*ppos && !write)) {
20541da177e4SLinus Torvalds 		*lenp = 0;
20551da177e4SLinus Torvalds 		return 0;
20561da177e4SLinus Torvalds 	}
20571da177e4SLinus Torvalds 
2058fcfbd547SKirill Korotaev 	i = (int *) tbl_data;
20591da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(*i);
20601da177e4SLinus Torvalds 	left = *lenp;
20611da177e4SLinus Torvalds 
20621da177e4SLinus Torvalds 	if (!conv)
20631da177e4SLinus Torvalds 		conv = do_proc_dointvec_conv;
20641da177e4SLinus Torvalds 
20651da177e4SLinus Torvalds 	for (; left && vleft--; i++, first=0) {
20661da177e4SLinus Torvalds 		if (write) {
20671da177e4SLinus Torvalds 			while (left) {
20681da177e4SLinus Torvalds 				char c;
20691da177e4SLinus Torvalds 				if (get_user(c, s))
20701da177e4SLinus Torvalds 					return -EFAULT;
20711da177e4SLinus Torvalds 				if (!isspace(c))
20721da177e4SLinus Torvalds 					break;
20731da177e4SLinus Torvalds 				left--;
20741da177e4SLinus Torvalds 				s++;
20751da177e4SLinus Torvalds 			}
20761da177e4SLinus Torvalds 			if (!left)
20771da177e4SLinus Torvalds 				break;
20781da177e4SLinus Torvalds 			neg = 0;
20791da177e4SLinus Torvalds 			len = left;
20801da177e4SLinus Torvalds 			if (len > sizeof(buf) - 1)
20811da177e4SLinus Torvalds 				len = sizeof(buf) - 1;
20821da177e4SLinus Torvalds 			if (copy_from_user(buf, s, len))
20831da177e4SLinus Torvalds 				return -EFAULT;
20841da177e4SLinus Torvalds 			buf[len] = 0;
20851da177e4SLinus Torvalds 			p = buf;
20861da177e4SLinus Torvalds 			if (*p == '-' && left > 1) {
20871da177e4SLinus Torvalds 				neg = 1;
2088bd9b0bacSBP, Praveen 				p++;
20891da177e4SLinus Torvalds 			}
20901da177e4SLinus Torvalds 			if (*p < '0' || *p > '9')
20911da177e4SLinus Torvalds 				break;
20921da177e4SLinus Torvalds 
20931da177e4SLinus Torvalds 			lval = simple_strtoul(p, &p, 0);
20941da177e4SLinus Torvalds 
20951da177e4SLinus Torvalds 			len = p-buf;
20961da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
20971da177e4SLinus Torvalds 				break;
20981da177e4SLinus Torvalds 			s += len;
20991da177e4SLinus Torvalds 			left -= len;
21001da177e4SLinus Torvalds 
21011da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 1, data))
21021da177e4SLinus Torvalds 				break;
21031da177e4SLinus Torvalds 		} else {
21041da177e4SLinus Torvalds 			p = buf;
21051da177e4SLinus Torvalds 			if (!first)
21061da177e4SLinus Torvalds 				*p++ = '\t';
21071da177e4SLinus Torvalds 
21081da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 0, data))
21091da177e4SLinus Torvalds 				break;
21101da177e4SLinus Torvalds 
21111da177e4SLinus Torvalds 			sprintf(p, "%s%lu", neg ? "-" : "", lval);
21121da177e4SLinus Torvalds 			len = strlen(buf);
21131da177e4SLinus Torvalds 			if (len > left)
21141da177e4SLinus Torvalds 				len = left;
21151da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
21161da177e4SLinus Torvalds 				return -EFAULT;
21171da177e4SLinus Torvalds 			left -= len;
21181da177e4SLinus Torvalds 			s += len;
21191da177e4SLinus Torvalds 		}
21201da177e4SLinus Torvalds 	}
21211da177e4SLinus Torvalds 
21221da177e4SLinus Torvalds 	if (!write && !first && left) {
21231da177e4SLinus Torvalds 		if(put_user('\n', s))
21241da177e4SLinus Torvalds 			return -EFAULT;
21251da177e4SLinus Torvalds 		left--, s++;
21261da177e4SLinus Torvalds 	}
21271da177e4SLinus Torvalds 	if (write) {
21281da177e4SLinus Torvalds 		while (left) {
21291da177e4SLinus Torvalds 			char c;
21301da177e4SLinus Torvalds 			if (get_user(c, s++))
21311da177e4SLinus Torvalds 				return -EFAULT;
21321da177e4SLinus Torvalds 			if (!isspace(c))
21331da177e4SLinus Torvalds 				break;
21341da177e4SLinus Torvalds 			left--;
21351da177e4SLinus Torvalds 		}
21361da177e4SLinus Torvalds 	}
21371da177e4SLinus Torvalds 	if (write && first)
21381da177e4SLinus Torvalds 		return -EINVAL;
21391da177e4SLinus Torvalds 	*lenp -= left;
21401da177e4SLinus Torvalds 	*ppos += *lenp;
21411da177e4SLinus Torvalds 	return 0;
21421da177e4SLinus Torvalds #undef TMPBUFLEN
21431da177e4SLinus Torvalds }
21441da177e4SLinus Torvalds 
21458d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write,
2146fcfbd547SKirill Korotaev 		  void __user *buffer, size_t *lenp, loff_t *ppos,
2147fcfbd547SKirill Korotaev 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2148fcfbd547SKirill Korotaev 			      int write, void *data),
2149fcfbd547SKirill Korotaev 		  void *data)
2150fcfbd547SKirill Korotaev {
21518d65af78SAlexey Dobriyan 	return __do_proc_dointvec(table->data, table, write,
2152fcfbd547SKirill Korotaev 			buffer, lenp, ppos, conv, data);
2153fcfbd547SKirill Korotaev }
2154fcfbd547SKirill Korotaev 
21551da177e4SLinus Torvalds /**
21561da177e4SLinus Torvalds  * proc_dointvec - read a vector of integers
21571da177e4SLinus Torvalds  * @table: the sysctl table
21581da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
21591da177e4SLinus Torvalds  * @buffer: the user buffer
21601da177e4SLinus Torvalds  * @lenp: the size of the user buffer
21611da177e4SLinus Torvalds  * @ppos: file position
21621da177e4SLinus Torvalds  *
21631da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
21641da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
21651da177e4SLinus Torvalds  *
21661da177e4SLinus Torvalds  * Returns 0 on success.
21671da177e4SLinus Torvalds  */
21688d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write,
21691da177e4SLinus Torvalds 		     void __user *buffer, size_t *lenp, loff_t *ppos)
21701da177e4SLinus Torvalds {
21718d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
21721da177e4SLinus Torvalds 		    	    NULL,NULL);
21731da177e4SLinus Torvalds }
21741da177e4SLinus Torvalds 
217534f5a398STheodore Ts'o /*
217634f5a398STheodore Ts'o  * Taint values can only be increased
217725ddbb18SAndi Kleen  * This means we can safely use a temporary.
217834f5a398STheodore Ts'o  */
21798d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write,
218034f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos)
218134f5a398STheodore Ts'o {
218225ddbb18SAndi Kleen 	struct ctl_table t;
218325ddbb18SAndi Kleen 	unsigned long tmptaint = get_taint();
218425ddbb18SAndi Kleen 	int err;
218534f5a398STheodore Ts'o 
218691fcd412SBastian Blank 	if (write && !capable(CAP_SYS_ADMIN))
218734f5a398STheodore Ts'o 		return -EPERM;
218834f5a398STheodore Ts'o 
218925ddbb18SAndi Kleen 	t = *table;
219025ddbb18SAndi Kleen 	t.data = &tmptaint;
21918d65af78SAlexey Dobriyan 	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
219225ddbb18SAndi Kleen 	if (err < 0)
219325ddbb18SAndi Kleen 		return err;
219425ddbb18SAndi Kleen 
219525ddbb18SAndi Kleen 	if (write) {
219625ddbb18SAndi Kleen 		/*
219725ddbb18SAndi Kleen 		 * Poor man's atomic or. Not worth adding a primitive
219825ddbb18SAndi Kleen 		 * to everyone's atomic.h for this
219925ddbb18SAndi Kleen 		 */
220025ddbb18SAndi Kleen 		int i;
220125ddbb18SAndi Kleen 		for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
220225ddbb18SAndi Kleen 			if ((tmptaint >> i) & 1)
220325ddbb18SAndi Kleen 				add_taint(i);
220425ddbb18SAndi Kleen 		}
220525ddbb18SAndi Kleen 	}
220625ddbb18SAndi Kleen 
220725ddbb18SAndi Kleen 	return err;
220834f5a398STheodore Ts'o }
220934f5a398STheodore Ts'o 
22101da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param {
22111da177e4SLinus Torvalds 	int *min;
22121da177e4SLinus Torvalds 	int *max;
22131da177e4SLinus Torvalds };
22141da177e4SLinus Torvalds 
22151da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
22161da177e4SLinus Torvalds 					int *valp,
22171da177e4SLinus Torvalds 					int write, void *data)
22181da177e4SLinus Torvalds {
22191da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param *param = data;
22201da177e4SLinus Torvalds 	if (write) {
22211da177e4SLinus Torvalds 		int val = *negp ? -*lvalp : *lvalp;
22221da177e4SLinus Torvalds 		if ((param->min && *param->min > val) ||
22231da177e4SLinus Torvalds 		    (param->max && *param->max < val))
22241da177e4SLinus Torvalds 			return -EINVAL;
22251da177e4SLinus Torvalds 		*valp = val;
22261da177e4SLinus Torvalds 	} else {
22271da177e4SLinus Torvalds 		int val = *valp;
22281da177e4SLinus Torvalds 		if (val < 0) {
22291da177e4SLinus Torvalds 			*negp = -1;
22301da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
22311da177e4SLinus Torvalds 		} else {
22321da177e4SLinus Torvalds 			*negp = 0;
22331da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
22341da177e4SLinus Torvalds 		}
22351da177e4SLinus Torvalds 	}
22361da177e4SLinus Torvalds 	return 0;
22371da177e4SLinus Torvalds }
22381da177e4SLinus Torvalds 
22391da177e4SLinus Torvalds /**
22401da177e4SLinus Torvalds  * proc_dointvec_minmax - read a vector of integers with min/max values
22411da177e4SLinus Torvalds  * @table: the sysctl table
22421da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
22431da177e4SLinus Torvalds  * @buffer: the user buffer
22441da177e4SLinus Torvalds  * @lenp: the size of the user buffer
22451da177e4SLinus Torvalds  * @ppos: file position
22461da177e4SLinus Torvalds  *
22471da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
22481da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
22491da177e4SLinus Torvalds  *
22501da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
22511da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
22521da177e4SLinus Torvalds  *
22531da177e4SLinus Torvalds  * Returns 0 on success.
22541da177e4SLinus Torvalds  */
22558d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write,
22561da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
22571da177e4SLinus Torvalds {
22581da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param param = {
22591da177e4SLinus Torvalds 		.min = (int *) table->extra1,
22601da177e4SLinus Torvalds 		.max = (int *) table->extra2,
22611da177e4SLinus Torvalds 	};
22628d65af78SAlexey Dobriyan 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
22631da177e4SLinus Torvalds 				do_proc_dointvec_minmax_conv, &param);
22641da177e4SLinus Torvalds }
22651da177e4SLinus Torvalds 
2266d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
22671da177e4SLinus Torvalds 				     void __user *buffer,
22681da177e4SLinus Torvalds 				     size_t *lenp, loff_t *ppos,
22691da177e4SLinus Torvalds 				     unsigned long convmul,
22701da177e4SLinus Torvalds 				     unsigned long convdiv)
22711da177e4SLinus Torvalds {
22721da177e4SLinus Torvalds #define TMPBUFLEN 21
22731da177e4SLinus Torvalds 	unsigned long *i, *min, *max, val;
22741da177e4SLinus Torvalds 	int vleft, first=1, neg;
22751da177e4SLinus Torvalds 	size_t len, left;
22761da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
22771da177e4SLinus Torvalds 	char __user *s = buffer;
22781da177e4SLinus Torvalds 
2279fcfbd547SKirill Korotaev 	if (!data || !table->maxlen || !*lenp ||
22801da177e4SLinus Torvalds 	    (*ppos && !write)) {
22811da177e4SLinus Torvalds 		*lenp = 0;
22821da177e4SLinus Torvalds 		return 0;
22831da177e4SLinus Torvalds 	}
22841da177e4SLinus Torvalds 
2285fcfbd547SKirill Korotaev 	i = (unsigned long *) data;
22861da177e4SLinus Torvalds 	min = (unsigned long *) table->extra1;
22871da177e4SLinus Torvalds 	max = (unsigned long *) table->extra2;
22881da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(unsigned long);
22891da177e4SLinus Torvalds 	left = *lenp;
22901da177e4SLinus Torvalds 
22911da177e4SLinus Torvalds 	for (; left && vleft--; i++, min++, max++, first=0) {
22921da177e4SLinus Torvalds 		if (write) {
22931da177e4SLinus Torvalds 			while (left) {
22941da177e4SLinus Torvalds 				char c;
22951da177e4SLinus Torvalds 				if (get_user(c, s))
22961da177e4SLinus Torvalds 					return -EFAULT;
22971da177e4SLinus Torvalds 				if (!isspace(c))
22981da177e4SLinus Torvalds 					break;
22991da177e4SLinus Torvalds 				left--;
23001da177e4SLinus Torvalds 				s++;
23011da177e4SLinus Torvalds 			}
23021da177e4SLinus Torvalds 			if (!left)
23031da177e4SLinus Torvalds 				break;
23041da177e4SLinus Torvalds 			neg = 0;
23051da177e4SLinus Torvalds 			len = left;
23061da177e4SLinus Torvalds 			if (len > TMPBUFLEN-1)
23071da177e4SLinus Torvalds 				len = TMPBUFLEN-1;
23081da177e4SLinus Torvalds 			if (copy_from_user(buf, s, len))
23091da177e4SLinus Torvalds 				return -EFAULT;
23101da177e4SLinus Torvalds 			buf[len] = 0;
23111da177e4SLinus Torvalds 			p = buf;
23121da177e4SLinus Torvalds 			if (*p == '-' && left > 1) {
23131da177e4SLinus Torvalds 				neg = 1;
2314bd9b0bacSBP, Praveen 				p++;
23151da177e4SLinus Torvalds 			}
23161da177e4SLinus Torvalds 			if (*p < '0' || *p > '9')
23171da177e4SLinus Torvalds 				break;
23181da177e4SLinus Torvalds 			val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
23191da177e4SLinus Torvalds 			len = p-buf;
23201da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
23211da177e4SLinus Torvalds 				break;
23221da177e4SLinus Torvalds 			if (neg)
23231da177e4SLinus Torvalds 				val = -val;
23241da177e4SLinus Torvalds 			s += len;
23251da177e4SLinus Torvalds 			left -= len;
23261da177e4SLinus Torvalds 
23271da177e4SLinus Torvalds 			if(neg)
23281da177e4SLinus Torvalds 				continue;
23291da177e4SLinus Torvalds 			if ((min && val < *min) || (max && val > *max))
23301da177e4SLinus Torvalds 				continue;
23311da177e4SLinus Torvalds 			*i = val;
23321da177e4SLinus Torvalds 		} else {
23331da177e4SLinus Torvalds 			p = buf;
23341da177e4SLinus Torvalds 			if (!first)
23351da177e4SLinus Torvalds 				*p++ = '\t';
23361da177e4SLinus Torvalds 			sprintf(p, "%lu", convdiv * (*i) / convmul);
23371da177e4SLinus Torvalds 			len = strlen(buf);
23381da177e4SLinus Torvalds 			if (len > left)
23391da177e4SLinus Torvalds 				len = left;
23401da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
23411da177e4SLinus Torvalds 				return -EFAULT;
23421da177e4SLinus Torvalds 			left -= len;
23431da177e4SLinus Torvalds 			s += len;
23441da177e4SLinus Torvalds 		}
23451da177e4SLinus Torvalds 	}
23461da177e4SLinus Torvalds 
23471da177e4SLinus Torvalds 	if (!write && !first && left) {
23481da177e4SLinus Torvalds 		if(put_user('\n', s))
23491da177e4SLinus Torvalds 			return -EFAULT;
23501da177e4SLinus Torvalds 		left--, s++;
23511da177e4SLinus Torvalds 	}
23521da177e4SLinus Torvalds 	if (write) {
23531da177e4SLinus Torvalds 		while (left) {
23541da177e4SLinus Torvalds 			char c;
23551da177e4SLinus Torvalds 			if (get_user(c, s++))
23561da177e4SLinus Torvalds 				return -EFAULT;
23571da177e4SLinus Torvalds 			if (!isspace(c))
23581da177e4SLinus Torvalds 				break;
23591da177e4SLinus Torvalds 			left--;
23601da177e4SLinus Torvalds 		}
23611da177e4SLinus Torvalds 	}
23621da177e4SLinus Torvalds 	if (write && first)
23631da177e4SLinus Torvalds 		return -EINVAL;
23641da177e4SLinus Torvalds 	*lenp -= left;
23651da177e4SLinus Torvalds 	*ppos += *lenp;
23661da177e4SLinus Torvalds 	return 0;
23671da177e4SLinus Torvalds #undef TMPBUFLEN
23681da177e4SLinus Torvalds }
23691da177e4SLinus Torvalds 
2370d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2371fcfbd547SKirill Korotaev 				     void __user *buffer,
2372fcfbd547SKirill Korotaev 				     size_t *lenp, loff_t *ppos,
2373fcfbd547SKirill Korotaev 				     unsigned long convmul,
2374fcfbd547SKirill Korotaev 				     unsigned long convdiv)
2375fcfbd547SKirill Korotaev {
2376fcfbd547SKirill Korotaev 	return __do_proc_doulongvec_minmax(table->data, table, write,
23778d65af78SAlexey Dobriyan 			buffer, lenp, ppos, convmul, convdiv);
2378fcfbd547SKirill Korotaev }
2379fcfbd547SKirill Korotaev 
23801da177e4SLinus Torvalds /**
23811da177e4SLinus Torvalds  * proc_doulongvec_minmax - read a vector of long integers with min/max values
23821da177e4SLinus Torvalds  * @table: the sysctl table
23831da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
23841da177e4SLinus Torvalds  * @buffer: the user buffer
23851da177e4SLinus Torvalds  * @lenp: the size of the user buffer
23861da177e4SLinus Torvalds  * @ppos: file position
23871da177e4SLinus Torvalds  *
23881da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
23891da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
23901da177e4SLinus Torvalds  *
23911da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
23921da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
23931da177e4SLinus Torvalds  *
23941da177e4SLinus Torvalds  * Returns 0 on success.
23951da177e4SLinus Torvalds  */
23968d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write,
23971da177e4SLinus Torvalds 			   void __user *buffer, size_t *lenp, loff_t *ppos)
23981da177e4SLinus Torvalds {
23998d65af78SAlexey Dobriyan     return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
24001da177e4SLinus Torvalds }
24011da177e4SLinus Torvalds 
24021da177e4SLinus Torvalds /**
24031da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
24041da177e4SLinus Torvalds  * @table: the sysctl table
24051da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24061da177e4SLinus Torvalds  * @buffer: the user buffer
24071da177e4SLinus Torvalds  * @lenp: the size of the user buffer
24081da177e4SLinus Torvalds  * @ppos: file position
24091da177e4SLinus Torvalds  *
24101da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
24111da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string. The values
24121da177e4SLinus Torvalds  * are treated as milliseconds, and converted to jiffies when they are stored.
24131da177e4SLinus Torvalds  *
24141da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
24151da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
24161da177e4SLinus Torvalds  *
24171da177e4SLinus Torvalds  * Returns 0 on success.
24181da177e4SLinus Torvalds  */
2419d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
24201da177e4SLinus Torvalds 				      void __user *buffer,
24211da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
24221da177e4SLinus Torvalds {
24238d65af78SAlexey Dobriyan     return do_proc_doulongvec_minmax(table, write, buffer,
24241da177e4SLinus Torvalds 				     lenp, ppos, HZ, 1000l);
24251da177e4SLinus Torvalds }
24261da177e4SLinus Torvalds 
24271da177e4SLinus Torvalds 
24281da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
24291da177e4SLinus Torvalds 					 int *valp,
24301da177e4SLinus Torvalds 					 int write, void *data)
24311da177e4SLinus Torvalds {
24321da177e4SLinus Torvalds 	if (write) {
2433cba9f33dSBart Samwel 		if (*lvalp > LONG_MAX / HZ)
2434cba9f33dSBart Samwel 			return 1;
24351da177e4SLinus Torvalds 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
24361da177e4SLinus Torvalds 	} else {
24371da177e4SLinus Torvalds 		int val = *valp;
24381da177e4SLinus Torvalds 		unsigned long lval;
24391da177e4SLinus Torvalds 		if (val < 0) {
24401da177e4SLinus Torvalds 			*negp = -1;
24411da177e4SLinus Torvalds 			lval = (unsigned long)-val;
24421da177e4SLinus Torvalds 		} else {
24431da177e4SLinus Torvalds 			*negp = 0;
24441da177e4SLinus Torvalds 			lval = (unsigned long)val;
24451da177e4SLinus Torvalds 		}
24461da177e4SLinus Torvalds 		*lvalp = lval / HZ;
24471da177e4SLinus Torvalds 	}
24481da177e4SLinus Torvalds 	return 0;
24491da177e4SLinus Torvalds }
24501da177e4SLinus Torvalds 
24511da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
24521da177e4SLinus Torvalds 						int *valp,
24531da177e4SLinus Torvalds 						int write, void *data)
24541da177e4SLinus Torvalds {
24551da177e4SLinus Torvalds 	if (write) {
2456cba9f33dSBart Samwel 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2457cba9f33dSBart Samwel 			return 1;
24581da177e4SLinus Torvalds 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
24591da177e4SLinus Torvalds 	} else {
24601da177e4SLinus Torvalds 		int val = *valp;
24611da177e4SLinus Torvalds 		unsigned long lval;
24621da177e4SLinus Torvalds 		if (val < 0) {
24631da177e4SLinus Torvalds 			*negp = -1;
24641da177e4SLinus Torvalds 			lval = (unsigned long)-val;
24651da177e4SLinus Torvalds 		} else {
24661da177e4SLinus Torvalds 			*negp = 0;
24671da177e4SLinus Torvalds 			lval = (unsigned long)val;
24681da177e4SLinus Torvalds 		}
24691da177e4SLinus Torvalds 		*lvalp = jiffies_to_clock_t(lval);
24701da177e4SLinus Torvalds 	}
24711da177e4SLinus Torvalds 	return 0;
24721da177e4SLinus Torvalds }
24731da177e4SLinus Torvalds 
24741da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
24751da177e4SLinus Torvalds 					    int *valp,
24761da177e4SLinus Torvalds 					    int write, void *data)
24771da177e4SLinus Torvalds {
24781da177e4SLinus Torvalds 	if (write) {
24791da177e4SLinus Torvalds 		*valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
24801da177e4SLinus Torvalds 	} else {
24811da177e4SLinus Torvalds 		int val = *valp;
24821da177e4SLinus Torvalds 		unsigned long lval;
24831da177e4SLinus Torvalds 		if (val < 0) {
24841da177e4SLinus Torvalds 			*negp = -1;
24851da177e4SLinus Torvalds 			lval = (unsigned long)-val;
24861da177e4SLinus Torvalds 		} else {
24871da177e4SLinus Torvalds 			*negp = 0;
24881da177e4SLinus Torvalds 			lval = (unsigned long)val;
24891da177e4SLinus Torvalds 		}
24901da177e4SLinus Torvalds 		*lvalp = jiffies_to_msecs(lval);
24911da177e4SLinus Torvalds 	}
24921da177e4SLinus Torvalds 	return 0;
24931da177e4SLinus Torvalds }
24941da177e4SLinus Torvalds 
24951da177e4SLinus Torvalds /**
24961da177e4SLinus Torvalds  * proc_dointvec_jiffies - read a vector of integers as seconds
24971da177e4SLinus Torvalds  * @table: the sysctl table
24981da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24991da177e4SLinus Torvalds  * @buffer: the user buffer
25001da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25011da177e4SLinus Torvalds  * @ppos: file position
25021da177e4SLinus Torvalds  *
25031da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
25041da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25051da177e4SLinus Torvalds  * The values read are assumed to be in seconds, and are converted into
25061da177e4SLinus Torvalds  * jiffies.
25071da177e4SLinus Torvalds  *
25081da177e4SLinus Torvalds  * Returns 0 on success.
25091da177e4SLinus Torvalds  */
25108d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write,
25111da177e4SLinus Torvalds 			  void __user *buffer, size_t *lenp, loff_t *ppos)
25121da177e4SLinus Torvalds {
25138d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
25141da177e4SLinus Torvalds 		    	    do_proc_dointvec_jiffies_conv,NULL);
25151da177e4SLinus Torvalds }
25161da177e4SLinus Torvalds 
25171da177e4SLinus Torvalds /**
25181da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
25191da177e4SLinus Torvalds  * @table: the sysctl table
25201da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25211da177e4SLinus Torvalds  * @buffer: the user buffer
25221da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25231e5d5331SRandy Dunlap  * @ppos: pointer to the file position
25241da177e4SLinus Torvalds  *
25251da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
25261da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25271da177e4SLinus Torvalds  * The values read are assumed to be in 1/USER_HZ seconds, and
25281da177e4SLinus Torvalds  * are converted into jiffies.
25291da177e4SLinus Torvalds  *
25301da177e4SLinus Torvalds  * Returns 0 on success.
25311da177e4SLinus Torvalds  */
25328d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
25331da177e4SLinus Torvalds 				 void __user *buffer, size_t *lenp, loff_t *ppos)
25341da177e4SLinus Torvalds {
25358d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
25361da177e4SLinus Torvalds 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
25371da177e4SLinus Torvalds }
25381da177e4SLinus Torvalds 
25391da177e4SLinus Torvalds /**
25401da177e4SLinus Torvalds  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
25411da177e4SLinus Torvalds  * @table: the sysctl table
25421da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25431da177e4SLinus Torvalds  * @buffer: the user buffer
25441da177e4SLinus Torvalds  * @lenp: the size of the user buffer
254567be2dd1SMartin Waitz  * @ppos: file position
254667be2dd1SMartin Waitz  * @ppos: the current position in the file
25471da177e4SLinus Torvalds  *
25481da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
25491da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25501da177e4SLinus Torvalds  * The values read are assumed to be in 1/1000 seconds, and
25511da177e4SLinus Torvalds  * are converted into jiffies.
25521da177e4SLinus Torvalds  *
25531da177e4SLinus Torvalds  * Returns 0 on success.
25541da177e4SLinus Torvalds  */
25558d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
25561da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
25571da177e4SLinus Torvalds {
25588d65af78SAlexey Dobriyan 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
25591da177e4SLinus Torvalds 				do_proc_dointvec_ms_jiffies_conv, NULL);
25601da177e4SLinus Torvalds }
25611da177e4SLinus Torvalds 
25628d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write,
25639ec52099SCedric Le Goater 			   void __user *buffer, size_t *lenp, loff_t *ppos)
25649ec52099SCedric Le Goater {
25659ec52099SCedric Le Goater 	struct pid *new_pid;
25669ec52099SCedric Le Goater 	pid_t tmp;
25679ec52099SCedric Le Goater 	int r;
25689ec52099SCedric Le Goater 
25696c5f3e7bSPavel Emelyanov 	tmp = pid_vnr(cad_pid);
25709ec52099SCedric Le Goater 
25718d65af78SAlexey Dobriyan 	r = __do_proc_dointvec(&tmp, table, write, buffer,
25729ec52099SCedric Le Goater 			       lenp, ppos, NULL, NULL);
25739ec52099SCedric Le Goater 	if (r || !write)
25749ec52099SCedric Le Goater 		return r;
25759ec52099SCedric Le Goater 
25769ec52099SCedric Le Goater 	new_pid = find_get_pid(tmp);
25779ec52099SCedric Le Goater 	if (!new_pid)
25789ec52099SCedric Le Goater 		return -ESRCH;
25799ec52099SCedric Le Goater 
25809ec52099SCedric Le Goater 	put_pid(xchg(&cad_pid, new_pid));
25819ec52099SCedric Le Goater 	return 0;
25829ec52099SCedric Le Goater }
25839ec52099SCedric Le Goater 
25841da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */
25851da177e4SLinus Torvalds 
25868d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write,
25871da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
25881da177e4SLinus Torvalds {
25891da177e4SLinus Torvalds 	return -ENOSYS;
25901da177e4SLinus Torvalds }
25911da177e4SLinus Torvalds 
25928d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write,
25931da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
25941da177e4SLinus Torvalds {
25951da177e4SLinus Torvalds 	return -ENOSYS;
25961da177e4SLinus Torvalds }
25971da177e4SLinus Torvalds 
25988d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write,
25991da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
26001da177e4SLinus Torvalds {
26011da177e4SLinus Torvalds 	return -ENOSYS;
26021da177e4SLinus Torvalds }
26031da177e4SLinus Torvalds 
26048d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write,
26051da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
26061da177e4SLinus Torvalds {
26071da177e4SLinus Torvalds 	return -ENOSYS;
26081da177e4SLinus Torvalds }
26091da177e4SLinus Torvalds 
26108d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
26111da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
26121da177e4SLinus Torvalds {
26131da177e4SLinus Torvalds 	return -ENOSYS;
26141da177e4SLinus Torvalds }
26151da177e4SLinus Torvalds 
26168d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
26171da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
26181da177e4SLinus Torvalds {
26191da177e4SLinus Torvalds 	return -ENOSYS;
26201da177e4SLinus Torvalds }
26211da177e4SLinus Torvalds 
26228d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write,
26231da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
26241da177e4SLinus Torvalds {
26251da177e4SLinus Torvalds 	return -ENOSYS;
26261da177e4SLinus Torvalds }
26271da177e4SLinus Torvalds 
2628d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
26291da177e4SLinus Torvalds 				      void __user *buffer,
26301da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
26311da177e4SLinus Torvalds {
26321da177e4SLinus Torvalds     return -ENOSYS;
26331da177e4SLinus Torvalds }
26341da177e4SLinus Torvalds 
26351da177e4SLinus Torvalds 
26361da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */
26371da177e4SLinus Torvalds 
26381da177e4SLinus Torvalds /*
26391da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
26401da177e4SLinus Torvalds  * exception granted :-)
26411da177e4SLinus Torvalds  */
26421da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
26431da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
26441da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
26451da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
26461da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
26471da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
26481da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
26491da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
26501da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table);
265129e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths);
26521da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table);
2653