xref: /openbmc/linux/kernel/sysctl.c (revision 563b04671017ea00ba563ebeebdc36bce79b1b60)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * sysctl.c: General linux system control interface
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  * Begun 24 March 1995, Stephen Tweedie
51da177e4SLinus Torvalds  * Added /proc support, Dec 1995
61da177e4SLinus Torvalds  * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
71da177e4SLinus Torvalds  * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
81da177e4SLinus Torvalds  * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
91da177e4SLinus Torvalds  * Dynamic registration fixes, Stephen Tweedie.
101da177e4SLinus Torvalds  * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
111da177e4SLinus Torvalds  * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
121da177e4SLinus Torvalds  *  Horn.
131da177e4SLinus Torvalds  * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
141da177e4SLinus Torvalds  * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
151da177e4SLinus Torvalds  * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
161da177e4SLinus Torvalds  *  Wendling.
171da177e4SLinus Torvalds  * The list_for_each() macro wasn't appropriate for the sysctl loop.
181da177e4SLinus Torvalds  *  Removed it and replaced it with older style, 03/23/00, Bill Wendling
191da177e4SLinus Torvalds  */
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds #include <linux/module.h>
221da177e4SLinus Torvalds #include <linux/mm.h>
231da177e4SLinus Torvalds #include <linux/swap.h>
241da177e4SLinus Torvalds #include <linux/slab.h>
251da177e4SLinus Torvalds #include <linux/sysctl.h>
26d33ed52dSDave Young #include <linux/signal.h>
271da177e4SLinus Torvalds #include <linux/proc_fs.h>
2872c2d582SAndrew Morgan #include <linux/security.h>
291da177e4SLinus Torvalds #include <linux/ctype.h>
30dfec072eSVegard Nossum #include <linux/kmemcheck.h>
3162239ac2SAdrian Bunk #include <linux/fs.h>
321da177e4SLinus Torvalds #include <linux/init.h>
331da177e4SLinus Torvalds #include <linux/kernel.h>
340296b228SKay Sievers #include <linux/kobject.h>
3520380731SArnaldo Carvalho de Melo #include <linux/net.h>
361da177e4SLinus Torvalds #include <linux/sysrq.h>
371da177e4SLinus Torvalds #include <linux/highuid.h>
381da177e4SLinus Torvalds #include <linux/writeback.h>
393fff4c42SIngo Molnar #include <linux/ratelimit.h>
401da177e4SLinus Torvalds #include <linux/hugetlb.h>
411da177e4SLinus Torvalds #include <linux/initrd.h>
420b77f5bfSDavid Howells #include <linux/key.h>
431da177e4SLinus Torvalds #include <linux/times.h>
441da177e4SLinus Torvalds #include <linux/limits.h>
451da177e4SLinus Torvalds #include <linux/dcache.h>
461da177e4SLinus Torvalds #include <linux/syscalls.h>
47c748e134SAdrian Bunk #include <linux/vmstat.h>
48c255d844SPavel Machek #include <linux/nfs_fs.h>
49c255d844SPavel Machek #include <linux/acpi.h>
5010a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h>
51b0fc494fSSteven Rostedt #include <linux/ftrace.h>
5212e22c5eSDavid Howells #include <linux/slow-work.h>
53cdd6c482SIngo Molnar #include <linux/perf_event.h>
54b2be84dfSMasami Hiramatsu #include <linux/kprobes.h>
551da177e4SLinus Torvalds 
561da177e4SLinus Torvalds #include <asm/uaccess.h>
571da177e4SLinus Torvalds #include <asm/processor.h>
581da177e4SLinus Torvalds 
5929cbc78bSAndi Kleen #ifdef CONFIG_X86
6029cbc78bSAndi Kleen #include <asm/nmi.h>
610741f4d2SChuck Ebbert #include <asm/stacktrace.h>
626e7c4025SIngo Molnar #include <asm/io.h>
6329cbc78bSAndi Kleen #endif
64c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT
65c55b7c3eSDave Young #include <linux/acct.h>
66c55b7c3eSDave Young #endif
674f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES
684f0e056fSDave Young #include <linux/rtmutex.h>
694f0e056fSDave Young #endif
702edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
712edf5e49SDave Young #include <linux/lockdep.h>
722edf5e49SDave Young #endif
7315485a46SDave Young #ifdef CONFIG_CHR_DEV_SG
7415485a46SDave Young #include <scsi/sg.h>
7515485a46SDave Young #endif
7629cbc78bSAndi Kleen 
777058cb02SEric W. Biederman 
781da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL)
791da177e4SLinus Torvalds 
801da177e4SLinus Torvalds /* External variables not in a header file. */
811da177e4SLinus Torvalds extern int sysctl_overcommit_memory;
821da177e4SLinus Torvalds extern int sysctl_overcommit_ratio;
83fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom;
84fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task;
85fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks;
861da177e4SLinus Torvalds extern int max_threads;
871da177e4SLinus Torvalds extern int core_uses_pid;
88d6e71144SAlan Cox extern int suid_dumpable;
891da177e4SLinus Torvalds extern char core_pattern[];
90a293980cSNeil Horman extern unsigned int core_pipe_limit;
911da177e4SLinus Torvalds extern int pid_max;
921da177e4SLinus Torvalds extern int min_free_kbytes;
931da177e4SLinus Torvalds extern int pid_max_min, pid_max_max;
949d0243bcSAndrew Morton extern int sysctl_drop_caches;
958ad4b1fbSRohit Seth extern int percpu_pagelist_fraction;
96bebfa101SAndi Kleen extern int compat_log;
979745512cSArjan van de Ven extern int latencytop_enabled;
98eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max;
99dd8632a1SPaul Mundt #ifndef CONFIG_MMU
100dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages;
101dd8632a1SPaul Mundt #endif
102cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
1035e605b64SJens Axboe extern int blk_iopoll_enabled;
104cb684b5bSJens Axboe #endif
1051da177e4SLinus Torvalds 
106c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and  maximum */
107195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP
108c4f3b63fSRavikiran G Thirumalai static int sixty = 60;
1099383d967SDimitri Sivanich static int neg_one = -1;
110c4f3b63fSRavikiran G Thirumalai #endif
111c4f3b63fSRavikiran G Thirumalai 
112c4f3b63fSRavikiran G Thirumalai static int zero;
113cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1;
114cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2;
115fc3501d4SSven Wegener static unsigned long one_ul = 1;
116c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100;
117af91322eSDave Young #ifdef CONFIG_PRINTK
118af91322eSDave Young static int ten_thousand = 10000;
119af91322eSDave Young #endif
120c4f3b63fSRavikiran G Thirumalai 
1219e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
1229e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1239e4a5bdaSAndrea Righi 
1241da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1251da177e4SLinus Torvalds static int maxolduid = 65535;
1261da177e4SLinus Torvalds static int minolduid;
1278ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8;
1281da177e4SLinus Torvalds 
1291da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
1301da177e4SLinus Torvalds 
13172c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
13217f04fbbSDavid S. Miller #include <asm/system.h>
1331da177e4SLinus Torvalds #endif
1341da177e4SLinus Torvalds 
1350871420fSDavid S. Miller #ifdef CONFIG_SPARC64
1360871420fSDavid S. Miller extern int sysctl_tsb_ratio;
1370871420fSDavid S. Miller #endif
1380871420fSDavid S. Miller 
1391da177e4SLinus Torvalds #ifdef __hppa__
1401da177e4SLinus Torvalds extern int pwrsw_enabled;
1411da177e4SLinus Torvalds extern int unaligned_enabled;
1421da177e4SLinus Torvalds #endif
1431da177e4SLinus Torvalds 
144347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
1451da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
1461da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings;
1471da177e4SLinus Torvalds #endif
1481da177e4SLinus Torvalds extern int sysctl_userprocess_debug;
149951f22d5SMartin Schwidefsky extern int spin_retry;
1501da177e4SLinus Torvalds #endif
1511da177e4SLinus Torvalds 
152d2b176edSJes Sorensen #ifdef CONFIG_IA64
153d2b176edSJes Sorensen extern int no_unaligned_warning;
15488fc241fSDoug Chapman extern int unaligned_dump_stack;
155d2b176edSJes Sorensen #endif
156d2b176edSJes Sorensen 
1573fff4c42SIngo Molnar extern struct ratelimit_state printk_ratelimit_state;
1583fff4c42SIngo Molnar 
159d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
1608d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write,
1619ec52099SCedric Le Goater 		  void __user *buffer, size_t *lenp, loff_t *ppos);
1628d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write,
16334f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos);
164d6f8ff73SRandy Dunlap #endif
1659ec52099SCedric Le Goater 
16697f5f0cdSDmitry Torokhov #ifdef CONFIG_MAGIC_SYSRQ
16797f5f0cdSDmitry Torokhov static int __sysrq_enabled; /* Note: sysrq code ises it's own private copy */
16897f5f0cdSDmitry Torokhov 
16997f5f0cdSDmitry Torokhov static int sysrq_sysctl_handler(ctl_table *table, int write,
17097f5f0cdSDmitry Torokhov 				void __user *buffer, size_t *lenp,
17197f5f0cdSDmitry Torokhov 				loff_t *ppos)
17297f5f0cdSDmitry Torokhov {
17397f5f0cdSDmitry Torokhov 	int error;
17497f5f0cdSDmitry Torokhov 
17597f5f0cdSDmitry Torokhov 	error = proc_dointvec(table, write, buffer, lenp, ppos);
17697f5f0cdSDmitry Torokhov 	if (error)
17797f5f0cdSDmitry Torokhov 		return error;
17897f5f0cdSDmitry Torokhov 
17997f5f0cdSDmitry Torokhov 	if (write)
18097f5f0cdSDmitry Torokhov 		sysrq_toggle_support(__sysrq_enabled);
18197f5f0cdSDmitry Torokhov 
18297f5f0cdSDmitry Torokhov 	return 0;
18397f5f0cdSDmitry Torokhov }
18497f5f0cdSDmitry Torokhov 
18597f5f0cdSDmitry Torokhov #endif
18697f5f0cdSDmitry Torokhov 
187d8217f07SEric W. Biederman static struct ctl_table root_table[];
188e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root;
189e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = {
190b380b0d4SAl Viro 	.count = 1,
191e51b6ba0SEric W. Biederman 	.ctl_table = root_table,
19273455092SAl Viro 	.ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
193e51b6ba0SEric W. Biederman 	.root = &sysctl_table_root,
19473455092SAl Viro 	.set = &sysctl_table_root.default_set,
195e51b6ba0SEric W. Biederman };
196e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = {
197e51b6ba0SEric W. Biederman 	.root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
19873455092SAl Viro 	.default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
199e51b6ba0SEric W. Biederman };
2001da177e4SLinus Torvalds 
201d8217f07SEric W. Biederman static struct ctl_table kern_table[];
202d8217f07SEric W. Biederman static struct ctl_table vm_table[];
203d8217f07SEric W. Biederman static struct ctl_table fs_table[];
204d8217f07SEric W. Biederman static struct ctl_table debug_table[];
205d8217f07SEric W. Biederman static struct ctl_table dev_table[];
206d8217f07SEric W. Biederman extern struct ctl_table random_table[];
2072d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
208d8217f07SEric W. Biederman extern struct ctl_table inotify_table[];
2090399cb08SRobert Love #endif
2107ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
2117ef9964eSDavide Libenzi extern struct ctl_table epoll_table[];
2127ef9964eSDavide Libenzi #endif
2131da177e4SLinus Torvalds 
2141da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
2151da177e4SLinus Torvalds int sysctl_legacy_va_layout;
2161da177e4SLinus Torvalds #endif
2171da177e4SLinus Torvalds 
2181da177e4SLinus Torvalds /* The default sysctl tables: */
2191da177e4SLinus Torvalds 
220d8217f07SEric W. Biederman static struct ctl_table root_table[] = {
2211da177e4SLinus Torvalds 	{
2221da177e4SLinus Torvalds 		.procname	= "kernel",
2231da177e4SLinus Torvalds 		.mode		= 0555,
2241da177e4SLinus Torvalds 		.child		= kern_table,
2251da177e4SLinus Torvalds 	},
2261da177e4SLinus Torvalds 	{
2271da177e4SLinus Torvalds 		.procname	= "vm",
2281da177e4SLinus Torvalds 		.mode		= 0555,
2291da177e4SLinus Torvalds 		.child		= vm_table,
2301da177e4SLinus Torvalds 	},
2311da177e4SLinus Torvalds 	{
2321da177e4SLinus Torvalds 		.procname	= "fs",
2331da177e4SLinus Torvalds 		.mode		= 0555,
2341da177e4SLinus Torvalds 		.child		= fs_table,
2351da177e4SLinus Torvalds 	},
2361da177e4SLinus Torvalds 	{
2371da177e4SLinus Torvalds 		.procname	= "debug",
2381da177e4SLinus Torvalds 		.mode		= 0555,
2391da177e4SLinus Torvalds 		.child		= debug_table,
2401da177e4SLinus Torvalds 	},
2411da177e4SLinus Torvalds 	{
2421da177e4SLinus Torvalds 		.procname	= "dev",
2431da177e4SLinus Torvalds 		.mode		= 0555,
2441da177e4SLinus Torvalds 		.child		= dev_table,
2451da177e4SLinus Torvalds 	},
2462be7fe07SAndrew Morton /*
2472be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
2482be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
2492be7fe07SAndrew Morton  */
2506fce56ecSEric W. Biederman 	{ }
2511da177e4SLinus Torvalds };
2521da177e4SLinus Torvalds 
25377e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
25473c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000;		/* 100 usecs */
25573c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
25673c4efd2SEric Dumazet static int min_wakeup_granularity_ns;			/* 0 usecs */
25773c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
2581983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
2591983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
260acb4a848SChristian Ehrhardt static int min_sched_shares_ratelimit = 100000; /* 100 usec */
261acb4a848SChristian Ehrhardt static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
26277e54a1fSIngo Molnar #endif
26377e54a1fSIngo Molnar 
264d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
2652bba22c5SMike Galbraith 	{
2662bba22c5SMike Galbraith 		.procname	= "sched_child_runs_first",
2672bba22c5SMike Galbraith 		.data		= &sysctl_sched_child_runs_first,
2682bba22c5SMike Galbraith 		.maxlen		= sizeof(unsigned int),
2692bba22c5SMike Galbraith 		.mode		= 0644,
2706d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2712bba22c5SMike Galbraith 	},
27277e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
27377e54a1fSIngo Molnar 	{
274b2be5e96SPeter Zijlstra 		.procname	= "sched_min_granularity_ns",
275b2be5e96SPeter Zijlstra 		.data		= &sysctl_sched_min_granularity,
27677e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
27777e54a1fSIngo Molnar 		.mode		= 0644,
278702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
279b2be5e96SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
280b2be5e96SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
28177e54a1fSIngo Molnar 	},
28277e54a1fSIngo Molnar 	{
28321805085SPeter Zijlstra 		.procname	= "sched_latency_ns",
28421805085SPeter Zijlstra 		.data		= &sysctl_sched_latency,
28521805085SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
28621805085SPeter Zijlstra 		.mode		= 0644,
287702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
28821805085SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
28921805085SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
29021805085SPeter Zijlstra 	},
29121805085SPeter Zijlstra 	{
29277e54a1fSIngo Molnar 		.procname	= "sched_wakeup_granularity_ns",
29377e54a1fSIngo Molnar 		.data		= &sysctl_sched_wakeup_granularity,
29477e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
29577e54a1fSIngo Molnar 		.mode		= 0644,
296702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
29777e54a1fSIngo Molnar 		.extra1		= &min_wakeup_granularity_ns,
29877e54a1fSIngo Molnar 		.extra2		= &max_wakeup_granularity_ns,
29977e54a1fSIngo Molnar 	},
30077e54a1fSIngo Molnar 	{
3012398f2c6SPeter Zijlstra 		.procname	= "sched_shares_ratelimit",
3022398f2c6SPeter Zijlstra 		.data		= &sysctl_sched_shares_ratelimit,
3032398f2c6SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3042398f2c6SPeter Zijlstra 		.mode		= 0644,
305702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
306acb4a848SChristian Ehrhardt 		.extra1		= &min_sched_shares_ratelimit,
307acb4a848SChristian Ehrhardt 		.extra2		= &max_sched_shares_ratelimit,
3082398f2c6SPeter Zijlstra 	},
3092398f2c6SPeter Zijlstra 	{
3101983a922SChristian Ehrhardt 		.procname	= "sched_tunable_scaling",
3111983a922SChristian Ehrhardt 		.data		= &sysctl_sched_tunable_scaling,
3121983a922SChristian Ehrhardt 		.maxlen		= sizeof(enum sched_tunable_scaling),
3131983a922SChristian Ehrhardt 		.mode		= 0644,
314702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
3151983a922SChristian Ehrhardt 		.extra1		= &min_sched_tunable_scaling,
3161983a922SChristian Ehrhardt 		.extra2		= &max_sched_tunable_scaling,
3172398f2c6SPeter Zijlstra 	},
3182398f2c6SPeter Zijlstra 	{
319ffda12a1SPeter Zijlstra 		.procname	= "sched_shares_thresh",
320ffda12a1SPeter Zijlstra 		.data		= &sysctl_sched_shares_thresh,
321ffda12a1SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
322ffda12a1SPeter Zijlstra 		.mode		= 0644,
3236d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
324ffda12a1SPeter Zijlstra 		.extra1		= &zero,
325ffda12a1SPeter Zijlstra 	},
326ffda12a1SPeter Zijlstra 	{
327da84d961SIngo Molnar 		.procname	= "sched_migration_cost",
328da84d961SIngo Molnar 		.data		= &sysctl_sched_migration_cost,
329da84d961SIngo Molnar 		.maxlen		= sizeof(unsigned int),
330da84d961SIngo Molnar 		.mode		= 0644,
3316d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
332da84d961SIngo Molnar 	},
333b82d9fddSPeter Zijlstra 	{
334b82d9fddSPeter Zijlstra 		.procname	= "sched_nr_migrate",
335b82d9fddSPeter Zijlstra 		.data		= &sysctl_sched_nr_migrate,
336b82d9fddSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
337fa85ae24SPeter Zijlstra 		.mode		= 0644,
3386d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
339fa85ae24SPeter Zijlstra 	},
340cd1bb94bSArun R Bharadwaj 	{
341e9e9250bSPeter Zijlstra 		.procname	= "sched_time_avg",
342e9e9250bSPeter Zijlstra 		.data		= &sysctl_sched_time_avg,
343e9e9250bSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
344e9e9250bSPeter Zijlstra 		.mode		= 0644,
3456d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
346e9e9250bSPeter Zijlstra 	},
347e9e9250bSPeter Zijlstra 	{
348cd1bb94bSArun R Bharadwaj 		.procname	= "timer_migration",
349cd1bb94bSArun R Bharadwaj 		.data		= &sysctl_timer_migration,
350cd1bb94bSArun R Bharadwaj 		.maxlen		= sizeof(unsigned int),
351cd1bb94bSArun R Bharadwaj 		.mode		= 0644,
3526d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
353bfdb4d9fSArun R Bharadwaj 		.extra1		= &zero,
354bfdb4d9fSArun R Bharadwaj 		.extra2		= &one,
355cd1bb94bSArun R Bharadwaj 	},
3561fc84aaaSPeter Zijlstra #endif
3571799e35dSIngo Molnar 	{
3589f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
3599f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
3609f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3619f0c1e56SPeter Zijlstra 		.mode		= 0644,
3626d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
3639f0c1e56SPeter Zijlstra 	},
3649f0c1e56SPeter Zijlstra 	{
3659f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
3669f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
3679f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
3689f0c1e56SPeter Zijlstra 		.mode		= 0644,
3696d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
3709f0c1e56SPeter Zijlstra 	},
3719f0c1e56SPeter Zijlstra 	{
3721799e35dSIngo Molnar 		.procname	= "sched_compat_yield",
3731799e35dSIngo Molnar 		.data		= &sysctl_sched_compat_yield,
3741799e35dSIngo Molnar 		.maxlen		= sizeof(unsigned int),
3751799e35dSIngo Molnar 		.mode		= 0644,
3766d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3771799e35dSIngo Molnar 	},
378f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
379f20786ffSPeter Zijlstra 	{
380f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
381f20786ffSPeter Zijlstra 		.data		= &prove_locking,
382f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
383f20786ffSPeter Zijlstra 		.mode		= 0644,
3846d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
385f20786ffSPeter Zijlstra 	},
386f20786ffSPeter Zijlstra #endif
387f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
388f20786ffSPeter Zijlstra 	{
389f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
390f20786ffSPeter Zijlstra 		.data		= &lock_stat,
391f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
392f20786ffSPeter Zijlstra 		.mode		= 0644,
3936d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
394f20786ffSPeter Zijlstra 	},
395f20786ffSPeter Zijlstra #endif
39677e54a1fSIngo Molnar 	{
3971da177e4SLinus Torvalds 		.procname	= "panic",
3981da177e4SLinus Torvalds 		.data		= &panic_timeout,
3991da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4001da177e4SLinus Torvalds 		.mode		= 0644,
4016d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4021da177e4SLinus Torvalds 	},
4031da177e4SLinus Torvalds 	{
4041da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
4051da177e4SLinus Torvalds 		.data		= &core_uses_pid,
4061da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4071da177e4SLinus Torvalds 		.mode		= 0644,
4086d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4091da177e4SLinus Torvalds 	},
4101da177e4SLinus Torvalds 	{
4111da177e4SLinus Torvalds 		.procname	= "core_pattern",
4121da177e4SLinus Torvalds 		.data		= core_pattern,
41371ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
4141da177e4SLinus Torvalds 		.mode		= 0644,
4156d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
4161da177e4SLinus Torvalds 	},
417a293980cSNeil Horman 	{
418a293980cSNeil Horman 		.procname	= "core_pipe_limit",
419a293980cSNeil Horman 		.data		= &core_pipe_limit,
420a293980cSNeil Horman 		.maxlen		= sizeof(unsigned int),
421a293980cSNeil Horman 		.mode		= 0644,
4226d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
423a293980cSNeil Horman 	},
42434f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
4251da177e4SLinus Torvalds 	{
4261da177e4SLinus Torvalds 		.procname	= "tainted",
42725ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
42834f5a398STheodore Ts'o 		.mode		= 0644,
4296d456111SEric W. Biederman 		.proc_handler	= proc_taint,
4301da177e4SLinus Torvalds 	},
43134f5a398STheodore Ts'o #endif
4329745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
4339745512cSArjan van de Ven 	{
4349745512cSArjan van de Ven 		.procname	= "latencytop",
4359745512cSArjan van de Ven 		.data		= &latencytop_enabled,
4369745512cSArjan van de Ven 		.maxlen		= sizeof(int),
4379745512cSArjan van de Ven 		.mode		= 0644,
4386d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4399745512cSArjan van de Ven 	},
4409745512cSArjan van de Ven #endif
4411da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
4421da177e4SLinus Torvalds 	{
4431da177e4SLinus Torvalds 		.procname	= "real-root-dev",
4441da177e4SLinus Torvalds 		.data		= &real_root_dev,
4451da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4461da177e4SLinus Torvalds 		.mode		= 0644,
4476d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4481da177e4SLinus Torvalds 	},
4491da177e4SLinus Torvalds #endif
45045807a1dSIngo Molnar 	{
45145807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
45245807a1dSIngo Molnar 		.data		= &print_fatal_signals,
45345807a1dSIngo Molnar 		.maxlen		= sizeof(int),
45445807a1dSIngo Molnar 		.mode		= 0644,
4556d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
45645807a1dSIngo Molnar 	},
45772c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
4581da177e4SLinus Torvalds 	{
4591da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
4601da177e4SLinus Torvalds 		.data		= reboot_command,
4611da177e4SLinus Torvalds 		.maxlen		= 256,
4621da177e4SLinus Torvalds 		.mode		= 0644,
4636d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
4641da177e4SLinus Torvalds 	},
4651da177e4SLinus Torvalds 	{
4661da177e4SLinus Torvalds 		.procname	= "stop-a",
4671da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
4681da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4691da177e4SLinus Torvalds 		.mode		= 0644,
4706d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4711da177e4SLinus Torvalds 	},
4721da177e4SLinus Torvalds 	{
4731da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
4741da177e4SLinus Torvalds 		.data		= &scons_pwroff,
4751da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4761da177e4SLinus Torvalds 		.mode		= 0644,
4776d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4781da177e4SLinus Torvalds 	},
4791da177e4SLinus Torvalds #endif
4800871420fSDavid S. Miller #ifdef CONFIG_SPARC64
4810871420fSDavid S. Miller 	{
4820871420fSDavid S. Miller 		.procname	= "tsb-ratio",
4830871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
4840871420fSDavid S. Miller 		.maxlen		= sizeof (int),
4850871420fSDavid S. Miller 		.mode		= 0644,
4866d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4870871420fSDavid S. Miller 	},
4880871420fSDavid S. Miller #endif
4891da177e4SLinus Torvalds #ifdef __hppa__
4901da177e4SLinus Torvalds 	{
4911da177e4SLinus Torvalds 		.procname	= "soft-power",
4921da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
4931da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4941da177e4SLinus Torvalds 	 	.mode		= 0644,
4956d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4961da177e4SLinus Torvalds 	},
4971da177e4SLinus Torvalds 	{
4981da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
4991da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
5001da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5011da177e4SLinus Torvalds 		.mode		= 0644,
5026d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5031da177e4SLinus Torvalds 	},
5041da177e4SLinus Torvalds #endif
5051da177e4SLinus Torvalds 	{
5061da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
5071da177e4SLinus Torvalds 		.data		= &C_A_D,
5081da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5091da177e4SLinus Torvalds 		.mode		= 0644,
5106d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5111da177e4SLinus Torvalds 	},
512606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
513b0fc494fSSteven Rostedt 	{
514b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
515b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
516b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
517b0fc494fSSteven Rostedt 		.mode		= 0644,
5186d456111SEric W. Biederman 		.proc_handler	= ftrace_enable_sysctl,
519b0fc494fSSteven Rostedt 	},
520b0fc494fSSteven Rostedt #endif
521f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
522f38f1d2aSSteven Rostedt 	{
523f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
524f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
525f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
526f38f1d2aSSteven Rostedt 		.mode		= 0644,
5276d456111SEric W. Biederman 		.proc_handler	= stack_trace_sysctl,
528f38f1d2aSSteven Rostedt 	},
529f38f1d2aSSteven Rostedt #endif
530944ac425SSteven Rostedt #ifdef CONFIG_TRACING
531944ac425SSteven Rostedt 	{
5323299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
533944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
534944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
535944ac425SSteven Rostedt 		.mode		= 0644,
5366d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
537944ac425SSteven Rostedt 	},
538944ac425SSteven Rostedt #endif
539a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
5401da177e4SLinus Torvalds 	{
5411da177e4SLinus Torvalds 		.procname	= "modprobe",
5421da177e4SLinus Torvalds 		.data		= &modprobe_path,
5431da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
5441da177e4SLinus Torvalds 		.mode		= 0644,
5456d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
5461da177e4SLinus Torvalds 	},
5473d43321bSKees Cook 	{
5483d43321bSKees Cook 		.procname	= "modules_disabled",
5493d43321bSKees Cook 		.data		= &modules_disabled,
5503d43321bSKees Cook 		.maxlen		= sizeof(int),
5513d43321bSKees Cook 		.mode		= 0644,
5523d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
5536d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
5543d43321bSKees Cook 		.extra1		= &one,
5553d43321bSKees Cook 		.extra2		= &one,
5563d43321bSKees Cook 	},
5571da177e4SLinus Torvalds #endif
55857ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
5591da177e4SLinus Torvalds 	{
5601da177e4SLinus Torvalds 		.procname	= "hotplug",
561312c004dSKay Sievers 		.data		= &uevent_helper,
562312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
5631da177e4SLinus Torvalds 		.mode		= 0644,
5646d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
5651da177e4SLinus Torvalds 	},
5661da177e4SLinus Torvalds #endif
5671da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
5681da177e4SLinus Torvalds 	{
5691da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
5701da177e4SLinus Torvalds 		.data		= &sg_big_buff,
5711da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5721da177e4SLinus Torvalds 		.mode		= 0444,
5736d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5741da177e4SLinus Torvalds 	},
5751da177e4SLinus Torvalds #endif
5761da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
5771da177e4SLinus Torvalds 	{
5781da177e4SLinus Torvalds 		.procname	= "acct",
5791da177e4SLinus Torvalds 		.data		= &acct_parm,
5801da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
5811da177e4SLinus Torvalds 		.mode		= 0644,
5826d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5831da177e4SLinus Torvalds 	},
5841da177e4SLinus Torvalds #endif
5851da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
5861da177e4SLinus Torvalds 	{
5871da177e4SLinus Torvalds 		.procname	= "sysrq",
5885d6f647fSIngo Molnar 		.data		= &__sysrq_enabled,
5891da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5901da177e4SLinus Torvalds 		.mode		= 0644,
59197f5f0cdSDmitry Torokhov 		.proc_handler	= sysrq_sysctl_handler,
5921da177e4SLinus Torvalds 	},
5931da177e4SLinus Torvalds #endif
594d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
5951da177e4SLinus Torvalds 	{
5961da177e4SLinus Torvalds 		.procname	= "cad_pid",
5979ec52099SCedric Le Goater 		.data		= NULL,
5981da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5991da177e4SLinus Torvalds 		.mode		= 0600,
6006d456111SEric W. Biederman 		.proc_handler	= proc_do_cad_pid,
6011da177e4SLinus Torvalds 	},
602d6f8ff73SRandy Dunlap #endif
6031da177e4SLinus Torvalds 	{
6041da177e4SLinus Torvalds 		.procname	= "threads-max",
6051da177e4SLinus Torvalds 		.data		= &max_threads,
6061da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6071da177e4SLinus Torvalds 		.mode		= 0644,
6086d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6091da177e4SLinus Torvalds 	},
6101da177e4SLinus Torvalds 	{
6111da177e4SLinus Torvalds 		.procname	= "random",
6121da177e4SLinus Torvalds 		.mode		= 0555,
6131da177e4SLinus Torvalds 		.child		= random_table,
6141da177e4SLinus Torvalds 	},
6151da177e4SLinus Torvalds 	{
6161da177e4SLinus Torvalds 		.procname	= "overflowuid",
6171da177e4SLinus Torvalds 		.data		= &overflowuid,
6181da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6191da177e4SLinus Torvalds 		.mode		= 0644,
6206d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6211da177e4SLinus Torvalds 		.extra1		= &minolduid,
6221da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6231da177e4SLinus Torvalds 	},
6241da177e4SLinus Torvalds 	{
6251da177e4SLinus Torvalds 		.procname	= "overflowgid",
6261da177e4SLinus Torvalds 		.data		= &overflowgid,
6271da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6281da177e4SLinus Torvalds 		.mode		= 0644,
6296d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6301da177e4SLinus Torvalds 		.extra1		= &minolduid,
6311da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6321da177e4SLinus Torvalds 	},
633347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
6341da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
6351da177e4SLinus Torvalds 	{
6361da177e4SLinus Torvalds 		.procname	= "ieee_emulation_warnings",
6371da177e4SLinus Torvalds 		.data		= &sysctl_ieee_emulation_warnings,
6381da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6391da177e4SLinus Torvalds 		.mode		= 0644,
6406d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6411da177e4SLinus Torvalds 	},
6421da177e4SLinus Torvalds #endif
6431da177e4SLinus Torvalds 	{
6441da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
645ab3c68eeSHeiko Carstens 		.data		= &show_unhandled_signals,
6461da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6471da177e4SLinus Torvalds 		.mode		= 0644,
6486d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6491da177e4SLinus Torvalds 	},
6501da177e4SLinus Torvalds #endif
6511da177e4SLinus Torvalds 	{
6521da177e4SLinus Torvalds 		.procname	= "pid_max",
6531da177e4SLinus Torvalds 		.data		= &pid_max,
6541da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6551da177e4SLinus Torvalds 		.mode		= 0644,
6566d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6571da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
6581da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
6591da177e4SLinus Torvalds 	},
6601da177e4SLinus Torvalds 	{
6611da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
6621da177e4SLinus Torvalds 		.data		= &panic_on_oops,
6631da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6641da177e4SLinus Torvalds 		.mode		= 0644,
6656d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6661da177e4SLinus Torvalds 	},
6677ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
6687ef3d2fdSJoe Perches 	{
6697ef3d2fdSJoe Perches 		.procname	= "printk",
6707ef3d2fdSJoe Perches 		.data		= &console_loglevel,
6717ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
6727ef3d2fdSJoe Perches 		.mode		= 0644,
6736d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6747ef3d2fdSJoe Perches 	},
6751da177e4SLinus Torvalds 	{
6761da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
677717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
6781da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6791da177e4SLinus Torvalds 		.mode		= 0644,
6806d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
6811da177e4SLinus Torvalds 	},
6821da177e4SLinus Torvalds 	{
6831da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
684717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
6851da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6861da177e4SLinus Torvalds 		.mode		= 0644,
6876d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6881da177e4SLinus Torvalds 	},
689af91322eSDave Young 	{
690af91322eSDave Young 		.procname	= "printk_delay",
691af91322eSDave Young 		.data		= &printk_delay_msec,
692af91322eSDave Young 		.maxlen		= sizeof(int),
693af91322eSDave Young 		.mode		= 0644,
6946d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
695af91322eSDave Young 		.extra1		= &zero,
696af91322eSDave Young 		.extra2		= &ten_thousand,
697af91322eSDave Young 	},
6987ef3d2fdSJoe Perches #endif
6991da177e4SLinus Torvalds 	{
7001da177e4SLinus Torvalds 		.procname	= "ngroups_max",
7011da177e4SLinus Torvalds 		.data		= &ngroups_max,
7021da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7031da177e4SLinus Torvalds 		.mode		= 0444,
7046d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7051da177e4SLinus Torvalds 	},
7061da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
7071da177e4SLinus Torvalds 	{
7081da177e4SLinus Torvalds 		.procname       = "unknown_nmi_panic",
7091da177e4SLinus Torvalds 		.data           = &unknown_nmi_panic,
7101da177e4SLinus Torvalds 		.maxlen         = sizeof (int),
7111da177e4SLinus Torvalds 		.mode           = 0644,
7126d456111SEric W. Biederman 		.proc_handler   = proc_dointvec,
7131da177e4SLinus Torvalds 	},
714407984f1SDon Zickus 	{
715407984f1SDon Zickus 		.procname       = "nmi_watchdog",
716407984f1SDon Zickus 		.data           = &nmi_watchdog_enabled,
717407984f1SDon Zickus 		.maxlen         = sizeof (int),
718407984f1SDon Zickus 		.mode           = 0644,
7196d456111SEric W. Biederman 		.proc_handler   = proc_nmi_enabled,
7201da177e4SLinus Torvalds 	},
7211da177e4SLinus Torvalds #endif
7221da177e4SLinus Torvalds #if defined(CONFIG_X86)
7231da177e4SLinus Torvalds 	{
7248da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
7258da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
7268da5addaSDon Zickus 		.maxlen		= sizeof(int),
7278da5addaSDon Zickus 		.mode		= 0644,
7286d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7298da5addaSDon Zickus 	},
7308da5addaSDon Zickus 	{
7315211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
7325211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
7335211a242SKurt Garloff 		.maxlen		= sizeof(int),
7345211a242SKurt Garloff 		.mode		= 0644,
7356d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7365211a242SKurt Garloff 	},
7375211a242SKurt Garloff 	{
7381da177e4SLinus Torvalds 		.procname	= "bootloader_type",
7391da177e4SLinus Torvalds 		.data		= &bootloader_type,
7401da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7411da177e4SLinus Torvalds 		.mode		= 0444,
7426d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7431da177e4SLinus Torvalds 	},
7440741f4d2SChuck Ebbert 	{
7455031296cSH. Peter Anvin 		.procname	= "bootloader_version",
7465031296cSH. Peter Anvin 		.data		= &bootloader_version,
7475031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
7485031296cSH. Peter Anvin 		.mode		= 0444,
7496d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7505031296cSH. Peter Anvin 	},
7515031296cSH. Peter Anvin 	{
7520741f4d2SChuck Ebbert 		.procname	= "kstack_depth_to_print",
7530741f4d2SChuck Ebbert 		.data		= &kstack_depth_to_print,
7540741f4d2SChuck Ebbert 		.maxlen		= sizeof(int),
7550741f4d2SChuck Ebbert 		.mode		= 0644,
7566d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7570741f4d2SChuck Ebbert 	},
7586e7c4025SIngo Molnar 	{
7596e7c4025SIngo Molnar 		.procname	= "io_delay_type",
7606e7c4025SIngo Molnar 		.data		= &io_delay_type,
7616e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
7626e7c4025SIngo Molnar 		.mode		= 0644,
7636d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7646e7c4025SIngo Molnar 	},
7651da177e4SLinus Torvalds #endif
7667a9166e3SLuke Yang #if defined(CONFIG_MMU)
7671da177e4SLinus Torvalds 	{
7681da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
7691da177e4SLinus Torvalds 		.data		= &randomize_va_space,
7701da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7711da177e4SLinus Torvalds 		.mode		= 0644,
7726d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7731da177e4SLinus Torvalds 	},
7747a9166e3SLuke Yang #endif
7750152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
776951f22d5SMartin Schwidefsky 	{
777951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
778951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
779951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
780951f22d5SMartin Schwidefsky 		.mode		= 0644,
7816d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
782951f22d5SMartin Schwidefsky 	},
783951f22d5SMartin Schwidefsky #endif
784673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
785c255d844SPavel Machek 	{
786c255d844SPavel Machek 		.procname	= "acpi_video_flags",
78777afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
788c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
789c255d844SPavel Machek 		.mode		= 0644,
7906d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
791c255d844SPavel Machek 	},
792c255d844SPavel Machek #endif
793d2b176edSJes Sorensen #ifdef CONFIG_IA64
794d2b176edSJes Sorensen 	{
795d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
796d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
797d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
798d2b176edSJes Sorensen 	 	.mode		= 0644,
7996d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
800d2b176edSJes Sorensen 	},
80188fc241fSDoug Chapman 	{
80288fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
80388fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
80488fc241fSDoug Chapman 		.maxlen		= sizeof (int),
80588fc241fSDoug Chapman 		.mode		= 0644,
8066d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
80788fc241fSDoug Chapman 	},
808d2b176edSJes Sorensen #endif
809c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP
810c4f3b63fSRavikiran G Thirumalai 	{
8119c44bc03SIngo Molnar 		.procname	= "softlockup_panic",
8129c44bc03SIngo Molnar 		.data		= &softlockup_panic,
8139c44bc03SIngo Molnar 		.maxlen		= sizeof(int),
8149c44bc03SIngo Molnar 		.mode		= 0644,
8156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
8169c44bc03SIngo Molnar 		.extra1		= &zero,
8179c44bc03SIngo Molnar 		.extra2		= &one,
8189c44bc03SIngo Molnar 	},
8199c44bc03SIngo Molnar 	{
820c4f3b63fSRavikiran G Thirumalai 		.procname	= "softlockup_thresh",
821c4f3b63fSRavikiran G Thirumalai 		.data		= &softlockup_thresh,
8229383d967SDimitri Sivanich 		.maxlen		= sizeof(int),
823c4f3b63fSRavikiran G Thirumalai 		.mode		= 0644,
8246d456111SEric W. Biederman 		.proc_handler	= proc_dosoftlockup_thresh,
8259383d967SDimitri Sivanich 		.extra1		= &neg_one,
826c4f3b63fSRavikiran G Thirumalai 		.extra2		= &sixty,
827c4f3b63fSRavikiran G Thirumalai 	},
828e162b39aSMandeep Singh Baines #endif
829e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
830e162b39aSMandeep Singh Baines 	{
831e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
832e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
833e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
834e162b39aSMandeep Singh Baines 		.mode		= 0644,
8356d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
836e162b39aSMandeep Singh Baines 		.extra1		= &zero,
837e162b39aSMandeep Singh Baines 		.extra2		= &one,
838e162b39aSMandeep Singh Baines 	},
83982a1fcb9SIngo Molnar 	{
84082a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
84182a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
84290739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
84382a1fcb9SIngo Molnar 		.mode		= 0644,
8446d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
84582a1fcb9SIngo Molnar 	},
84682a1fcb9SIngo Molnar 	{
84782a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
84882a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
84990739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
85082a1fcb9SIngo Molnar 		.mode		= 0644,
8516d456111SEric W. Biederman 		.proc_handler	= proc_dohung_task_timeout_secs,
85282a1fcb9SIngo Molnar 	},
85382a1fcb9SIngo Molnar 	{
85482a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
85582a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
85690739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
85782a1fcb9SIngo Molnar 		.mode		= 0644,
8586d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
85982a1fcb9SIngo Molnar 	},
860c4f3b63fSRavikiran G Thirumalai #endif
861bebfa101SAndi Kleen #ifdef CONFIG_COMPAT
862bebfa101SAndi Kleen 	{
863bebfa101SAndi Kleen 		.procname	= "compat-log",
864bebfa101SAndi Kleen 		.data		= &compat_log,
865bebfa101SAndi Kleen 		.maxlen		= sizeof (int),
866bebfa101SAndi Kleen 	 	.mode		= 0644,
8676d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
868bebfa101SAndi Kleen 	},
869bebfa101SAndi Kleen #endif
87023f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
87123f78d4aSIngo Molnar 	{
87223f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
87323f78d4aSIngo Molnar 		.data		= &max_lock_depth,
87423f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
87523f78d4aSIngo Molnar 		.mode		= 0644,
8766d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
87723f78d4aSIngo Molnar 	},
87823f78d4aSIngo Molnar #endif
87910a0a8d4SJeremy Fitzhardinge 	{
88010a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
88110a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
88210a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
88310a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
8846d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
88510a0a8d4SJeremy Fitzhardinge 	},
8860b77f5bfSDavid Howells #ifdef CONFIG_KEYS
8870b77f5bfSDavid Howells 	{
8880b77f5bfSDavid Howells 		.procname	= "keys",
8890b77f5bfSDavid Howells 		.mode		= 0555,
8900b77f5bfSDavid Howells 		.child		= key_sysctls,
8910b77f5bfSDavid Howells 	},
8920b77f5bfSDavid Howells #endif
89331a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
89431a72bceSPaul E. McKenney 	{
89531a72bceSPaul E. McKenney 		.procname       = "rcutorture_runnable",
89631a72bceSPaul E. McKenney 		.data           = &rcutorture_runnable,
89731a72bceSPaul E. McKenney 		.maxlen         = sizeof(int),
89831a72bceSPaul E. McKenney 		.mode           = 0644,
8996d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
90031a72bceSPaul E. McKenney 	},
90131a72bceSPaul E. McKenney #endif
90212e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK
90312e22c5eSDavid Howells 	{
90412e22c5eSDavid Howells 		.procname	= "slow-work",
90512e22c5eSDavid Howells 		.mode		= 0555,
90612e22c5eSDavid Howells 		.child		= slow_work_sysctls,
90712e22c5eSDavid Howells 	},
90812e22c5eSDavid Howells #endif
909cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS
9101ccd1549SPeter Zijlstra 	{
911cdd6c482SIngo Molnar 		.procname	= "perf_event_paranoid",
912cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_paranoid,
913cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_paranoid),
9141ccd1549SPeter Zijlstra 		.mode		= 0644,
9156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9161ccd1549SPeter Zijlstra 	},
917c5078f78SPeter Zijlstra 	{
918cdd6c482SIngo Molnar 		.procname	= "perf_event_mlock_kb",
919cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_mlock,
920cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_mlock),
921c5078f78SPeter Zijlstra 		.mode		= 0644,
9226d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
923c5078f78SPeter Zijlstra 	},
924a78ac325SPeter Zijlstra 	{
925cdd6c482SIngo Molnar 		.procname	= "perf_event_max_sample_rate",
926cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_sample_rate,
927cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
928a78ac325SPeter Zijlstra 		.mode		= 0644,
9296d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
930a78ac325SPeter Zijlstra 	},
9311ccd1549SPeter Zijlstra #endif
932dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK
933dfec072eSVegard Nossum 	{
934dfec072eSVegard Nossum 		.procname	= "kmemcheck",
935dfec072eSVegard Nossum 		.data		= &kmemcheck_enabled,
936dfec072eSVegard Nossum 		.maxlen		= sizeof(int),
937dfec072eSVegard Nossum 		.mode		= 0644,
9386d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
939dfec072eSVegard Nossum 	},
940dfec072eSVegard Nossum #endif
941cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
9425e605b64SJens Axboe 	{
9435e605b64SJens Axboe 		.procname	= "blk_iopoll",
9445e605b64SJens Axboe 		.data		= &blk_iopoll_enabled,
9455e605b64SJens Axboe 		.maxlen		= sizeof(int),
9465e605b64SJens Axboe 		.mode		= 0644,
9476d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9485e605b64SJens Axboe 	},
949cb684b5bSJens Axboe #endif
950ed2c12f3SAndrew Morton /*
951ed2c12f3SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
952ed2c12f3SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
953ed2c12f3SAndrew Morton  */
9546fce56ecSEric W. Biederman 	{ }
9551da177e4SLinus Torvalds };
9561da177e4SLinus Torvalds 
957d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
9581da177e4SLinus Torvalds 	{
9591da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
9601da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
9611da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
9621da177e4SLinus Torvalds 		.mode		= 0644,
9636d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9641da177e4SLinus Torvalds 	},
9651da177e4SLinus Torvalds 	{
966fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
967fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
968fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
969fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
9706d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
971fadd8fbdSKAMEZAWA Hiroyuki 	},
972fadd8fbdSKAMEZAWA Hiroyuki 	{
973fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
974fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
975fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
976fe071d7eSDavid Rientjes 		.mode		= 0644,
9776d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
978fe071d7eSDavid Rientjes 	},
979fe071d7eSDavid Rientjes 	{
980fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
981fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
982fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
983fef1bdd6SDavid Rientjes 		.mode		= 0644,
9846d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
985fef1bdd6SDavid Rientjes 	},
986fef1bdd6SDavid Rientjes 	{
9871da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
9881da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
9891da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
9901da177e4SLinus Torvalds 		.mode		= 0644,
9916d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9921da177e4SLinus Torvalds 	},
9931da177e4SLinus Torvalds 	{
9941da177e4SLinus Torvalds 		.procname	= "page-cluster",
9951da177e4SLinus Torvalds 		.data		= &page_cluster,
9961da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
9971da177e4SLinus Torvalds 		.mode		= 0644,
9986d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9991da177e4SLinus Torvalds 	},
10001da177e4SLinus Torvalds 	{
10011da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
10021da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
10031da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
10041da177e4SLinus Torvalds 		.mode		= 0644,
10056d456111SEric W. Biederman 		.proc_handler	= dirty_background_ratio_handler,
10061da177e4SLinus Torvalds 		.extra1		= &zero,
10071da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10081da177e4SLinus Torvalds 	},
10091da177e4SLinus Torvalds 	{
10102da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
10112da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
10122da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
10132da02997SDavid Rientjes 		.mode		= 0644,
10146d456111SEric W. Biederman 		.proc_handler	= dirty_background_bytes_handler,
1015fc3501d4SSven Wegener 		.extra1		= &one_ul,
10162da02997SDavid Rientjes 	},
10172da02997SDavid Rientjes 	{
10181da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
10191da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
10201da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
10211da177e4SLinus Torvalds 		.mode		= 0644,
10226d456111SEric W. Biederman 		.proc_handler	= dirty_ratio_handler,
10231da177e4SLinus Torvalds 		.extra1		= &zero,
10241da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10251da177e4SLinus Torvalds 	},
10261da177e4SLinus Torvalds 	{
10272da02997SDavid Rientjes 		.procname	= "dirty_bytes",
10282da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
10292da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
10302da02997SDavid Rientjes 		.mode		= 0644,
10316d456111SEric W. Biederman 		.proc_handler	= dirty_bytes_handler,
10329e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
10332da02997SDavid Rientjes 	},
10342da02997SDavid Rientjes 	{
10351da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
1036f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
1037f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
10381da177e4SLinus Torvalds 		.mode		= 0644,
10396d456111SEric W. Biederman 		.proc_handler	= dirty_writeback_centisecs_handler,
10401da177e4SLinus Torvalds 	},
10411da177e4SLinus Torvalds 	{
10421da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
1043f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
1044f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
10451da177e4SLinus Torvalds 		.mode		= 0644,
10466d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10471da177e4SLinus Torvalds 	},
10481da177e4SLinus Torvalds 	{
10491da177e4SLinus Torvalds 		.procname	= "nr_pdflush_threads",
10501da177e4SLinus Torvalds 		.data		= &nr_pdflush_threads,
10511da177e4SLinus Torvalds 		.maxlen		= sizeof nr_pdflush_threads,
10521da177e4SLinus Torvalds 		.mode		= 0444 /* read-only*/,
10536d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10541da177e4SLinus Torvalds 	},
10551da177e4SLinus Torvalds 	{
10561da177e4SLinus Torvalds 		.procname	= "swappiness",
10571da177e4SLinus Torvalds 		.data		= &vm_swappiness,
10581da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
10591da177e4SLinus Torvalds 		.mode		= 0644,
10606d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
10611da177e4SLinus Torvalds 		.extra1		= &zero,
10621da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10631da177e4SLinus Torvalds 	},
10641da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
10651da177e4SLinus Torvalds 	{
10661da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
1067e5ff2159SAndi Kleen 		.data		= NULL,
10681da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
10691da177e4SLinus Torvalds 		.mode		= 0644,
10706d456111SEric W. Biederman 		.proc_handler	= hugetlb_sysctl_handler,
10711da177e4SLinus Torvalds 		.extra1		= (void *)&hugetlb_zero,
10721da177e4SLinus Torvalds 		.extra2		= (void *)&hugetlb_infinity,
10731da177e4SLinus Torvalds 	},
107406808b08SLee Schermerhorn #ifdef CONFIG_NUMA
107506808b08SLee Schermerhorn 	{
107606808b08SLee Schermerhorn 		.procname       = "nr_hugepages_mempolicy",
107706808b08SLee Schermerhorn 		.data           = NULL,
107806808b08SLee Schermerhorn 		.maxlen         = sizeof(unsigned long),
107906808b08SLee Schermerhorn 		.mode           = 0644,
108006808b08SLee Schermerhorn 		.proc_handler   = &hugetlb_mempolicy_sysctl_handler,
108106808b08SLee Schermerhorn 		.extra1		= (void *)&hugetlb_zero,
108206808b08SLee Schermerhorn 		.extra2		= (void *)&hugetlb_infinity,
108306808b08SLee Schermerhorn 	},
108406808b08SLee Schermerhorn #endif
10851da177e4SLinus Torvalds 	 {
10861da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
10871da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
10881da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
10891da177e4SLinus Torvalds 		.mode		= 0644,
10906d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10911da177e4SLinus Torvalds 	 },
1092396faf03SMel Gorman 	 {
1093396faf03SMel Gorman 		.procname	= "hugepages_treat_as_movable",
1094396faf03SMel Gorman 		.data		= &hugepages_treat_as_movable,
1095396faf03SMel Gorman 		.maxlen		= sizeof(int),
1096396faf03SMel Gorman 		.mode		= 0644,
10976d456111SEric W. Biederman 		.proc_handler	= hugetlb_treat_movable_handler,
1098396faf03SMel Gorman 	},
109954f9f80dSAdam Litke 	{
1100d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
1101e5ff2159SAndi Kleen 		.data		= NULL,
1102e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
1103d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
11046d456111SEric W. Biederman 		.proc_handler	= hugetlb_overcommit_handler,
1105e5ff2159SAndi Kleen 		.extra1		= (void *)&hugetlb_zero,
1106e5ff2159SAndi Kleen 		.extra2		= (void *)&hugetlb_infinity,
1107d1c3fb1fSNishanth Aravamudan 	},
11081da177e4SLinus Torvalds #endif
11091da177e4SLinus Torvalds 	{
11101da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
11111da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
11121da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
11131da177e4SLinus Torvalds 		.mode		= 0644,
11146d456111SEric W. Biederman 		.proc_handler	= lowmem_reserve_ratio_sysctl_handler,
11151da177e4SLinus Torvalds 	},
11161da177e4SLinus Torvalds 	{
11179d0243bcSAndrew Morton 		.procname	= "drop_caches",
11189d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
11199d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
11209d0243bcSAndrew Morton 		.mode		= 0644,
11219d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
11229d0243bcSAndrew Morton 	},
11239d0243bcSAndrew Morton 	{
11241da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
11251da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
11261da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
11271da177e4SLinus Torvalds 		.mode		= 0644,
11286d456111SEric W. Biederman 		.proc_handler	= min_free_kbytes_sysctl_handler,
11291da177e4SLinus Torvalds 		.extra1		= &zero,
11301da177e4SLinus Torvalds 	},
11318ad4b1fbSRohit Seth 	{
11328ad4b1fbSRohit Seth 		.procname	= "percpu_pagelist_fraction",
11338ad4b1fbSRohit Seth 		.data		= &percpu_pagelist_fraction,
11348ad4b1fbSRohit Seth 		.maxlen		= sizeof(percpu_pagelist_fraction),
11358ad4b1fbSRohit Seth 		.mode		= 0644,
11366d456111SEric W. Biederman 		.proc_handler	= percpu_pagelist_fraction_sysctl_handler,
11378ad4b1fbSRohit Seth 		.extra1		= &min_percpu_pagelist_fract,
11388ad4b1fbSRohit Seth 	},
11391da177e4SLinus Torvalds #ifdef CONFIG_MMU
11401da177e4SLinus Torvalds 	{
11411da177e4SLinus Torvalds 		.procname	= "max_map_count",
11421da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
11431da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
11441da177e4SLinus Torvalds 		.mode		= 0644,
11453e26120cSWANG Cong 		.proc_handler	= proc_dointvec_minmax,
114670da2340SAmerigo Wang 		.extra1		= &zero,
11471da177e4SLinus Torvalds 	},
1148dd8632a1SPaul Mundt #else
1149dd8632a1SPaul Mundt 	{
1150dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
1151dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
1152dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
1153dd8632a1SPaul Mundt 		.mode		= 0644,
11546d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1155dd8632a1SPaul Mundt 		.extra1		= &zero,
1156dd8632a1SPaul Mundt 	},
11571da177e4SLinus Torvalds #endif
11581da177e4SLinus Torvalds 	{
11591da177e4SLinus Torvalds 		.procname	= "laptop_mode",
11601da177e4SLinus Torvalds 		.data		= &laptop_mode,
11611da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
11621da177e4SLinus Torvalds 		.mode		= 0644,
11636d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
11641da177e4SLinus Torvalds 	},
11651da177e4SLinus Torvalds 	{
11661da177e4SLinus Torvalds 		.procname	= "block_dump",
11671da177e4SLinus Torvalds 		.data		= &block_dump,
11681da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
11691da177e4SLinus Torvalds 		.mode		= 0644,
11706d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
11711da177e4SLinus Torvalds 		.extra1		= &zero,
11721da177e4SLinus Torvalds 	},
11731da177e4SLinus Torvalds 	{
11741da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
11751da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
11761da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
11771da177e4SLinus Torvalds 		.mode		= 0644,
11786d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
11791da177e4SLinus Torvalds 		.extra1		= &zero,
11801da177e4SLinus Torvalds 	},
11811da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
11821da177e4SLinus Torvalds 	{
11831da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
11841da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
11851da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
11861da177e4SLinus Torvalds 		.mode		= 0644,
11876d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
11881da177e4SLinus Torvalds 		.extra1		= &zero,
11891da177e4SLinus Torvalds 	},
11901da177e4SLinus Torvalds #endif
11911743660bSChristoph Lameter #ifdef CONFIG_NUMA
11921743660bSChristoph Lameter 	{
11931743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
11941743660bSChristoph Lameter 		.data		= &zone_reclaim_mode,
11951743660bSChristoph Lameter 		.maxlen		= sizeof(zone_reclaim_mode),
11961743660bSChristoph Lameter 		.mode		= 0644,
11976d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1198c84db23cSChristoph Lameter 		.extra1		= &zero,
11991743660bSChristoph Lameter 	},
12009614634fSChristoph Lameter 	{
12019614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
12029614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
12039614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
12049614634fSChristoph Lameter 		.mode		= 0644,
12056d456111SEric W. Biederman 		.proc_handler	= sysctl_min_unmapped_ratio_sysctl_handler,
12069614634fSChristoph Lameter 		.extra1		= &zero,
12079614634fSChristoph Lameter 		.extra2		= &one_hundred,
12089614634fSChristoph Lameter 	},
12090ff38490SChristoph Lameter 	{
12100ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
12110ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
12120ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
12130ff38490SChristoph Lameter 		.mode		= 0644,
12146d456111SEric W. Biederman 		.proc_handler	= sysctl_min_slab_ratio_sysctl_handler,
12150ff38490SChristoph Lameter 		.extra1		= &zero,
12160ff38490SChristoph Lameter 		.extra2		= &one_hundred,
12170ff38490SChristoph Lameter 	},
12181743660bSChristoph Lameter #endif
121977461ab3SChristoph Lameter #ifdef CONFIG_SMP
122077461ab3SChristoph Lameter 	{
122177461ab3SChristoph Lameter 		.procname	= "stat_interval",
122277461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
122377461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
122477461ab3SChristoph Lameter 		.mode		= 0644,
12256d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
122677461ab3SChristoph Lameter 	},
122777461ab3SChristoph Lameter #endif
12286e141546SDavid Howells #ifdef CONFIG_MMU
1229ed032189SEric Paris 	{
1230ed032189SEric Paris 		.procname	= "mmap_min_addr",
1231788084abSEric Paris 		.data		= &dac_mmap_min_addr,
1232ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
1233ed032189SEric Paris 		.mode		= 0644,
12346d456111SEric W. Biederman 		.proc_handler	= mmap_min_addr_handler,
1235ed032189SEric Paris 	},
12366e141546SDavid Howells #endif
1237f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
1238f0c0b2b8SKAMEZAWA Hiroyuki 	{
1239f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
1240f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
1241f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
1242f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
12436d456111SEric W. Biederman 		.proc_handler	= numa_zonelist_order_handler,
1244f0c0b2b8SKAMEZAWA Hiroyuki 	},
1245f0c0b2b8SKAMEZAWA Hiroyuki #endif
12462b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
12475c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1248e6e5494cSIngo Molnar 	{
1249e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
1250e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
1251e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
1252e6e5494cSIngo Molnar 		.mode		= 0644,
12536d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1254e6e5494cSIngo Molnar 		.extra1		= &zero,
1255e6e5494cSIngo Molnar 	},
1256e6e5494cSIngo Molnar #endif
1257195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
1258195cf453SBron Gondwana 	{
1259195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
1260195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
1261195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
1262195cf453SBron Gondwana 		.mode		= 0644,
12636d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1264195cf453SBron Gondwana 		.extra1		= &zero,
1265195cf453SBron Gondwana 		.extra2		= &one,
1266195cf453SBron Gondwana 	},
1267195cf453SBron Gondwana #endif
12684be6f6bbSPeter Zijlstra 	{
12694be6f6bbSPeter Zijlstra 		.procname	= "scan_unevictable_pages",
12704be6f6bbSPeter Zijlstra 		.data		= &scan_unevictable_pages,
12714be6f6bbSPeter Zijlstra 		.maxlen		= sizeof(scan_unevictable_pages),
12724be6f6bbSPeter Zijlstra 		.mode		= 0644,
12736d456111SEric W. Biederman 		.proc_handler	= scan_unevictable_handler,
12744be6f6bbSPeter Zijlstra 	},
12756a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE
12766a46079cSAndi Kleen 	{
12776a46079cSAndi Kleen 		.procname	= "memory_failure_early_kill",
12786a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_early_kill,
12796a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_early_kill),
12806a46079cSAndi Kleen 		.mode		= 0644,
12816d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
12826a46079cSAndi Kleen 		.extra1		= &zero,
12836a46079cSAndi Kleen 		.extra2		= &one,
12846a46079cSAndi Kleen 	},
12856a46079cSAndi Kleen 	{
12866a46079cSAndi Kleen 		.procname	= "memory_failure_recovery",
12876a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_recovery,
12886a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_recovery),
12896a46079cSAndi Kleen 		.mode		= 0644,
12906d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
12916a46079cSAndi Kleen 		.extra1		= &zero,
12926a46079cSAndi Kleen 		.extra2		= &one,
12936a46079cSAndi Kleen 	},
12946a46079cSAndi Kleen #endif
12956a46079cSAndi Kleen 
12962be7fe07SAndrew Morton /*
12972be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
12982be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
12992be7fe07SAndrew Morton  */
13006fce56ecSEric W. Biederman 	{ }
13011da177e4SLinus Torvalds };
13021da177e4SLinus Torvalds 
13032abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1304d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = {
13056fce56ecSEric W. Biederman 	{ }
13062abc26fcSEric W. Biederman };
13072abc26fcSEric W. Biederman #endif
13082abc26fcSEric W. Biederman 
1309d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
13101da177e4SLinus Torvalds 	{
13111da177e4SLinus Torvalds 		.procname	= "inode-nr",
13121da177e4SLinus Torvalds 		.data		= &inodes_stat,
13131da177e4SLinus Torvalds 		.maxlen		= 2*sizeof(int),
13141da177e4SLinus Torvalds 		.mode		= 0444,
13156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13161da177e4SLinus Torvalds 	},
13171da177e4SLinus Torvalds 	{
13181da177e4SLinus Torvalds 		.procname	= "inode-state",
13191da177e4SLinus Torvalds 		.data		= &inodes_stat,
13201da177e4SLinus Torvalds 		.maxlen		= 7*sizeof(int),
13211da177e4SLinus Torvalds 		.mode		= 0444,
13226d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13231da177e4SLinus Torvalds 	},
13241da177e4SLinus Torvalds 	{
13251da177e4SLinus Torvalds 		.procname	= "file-nr",
13261da177e4SLinus Torvalds 		.data		= &files_stat,
13271da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
13281da177e4SLinus Torvalds 		.mode		= 0444,
13296d456111SEric W. Biederman 		.proc_handler	= proc_nr_files,
13301da177e4SLinus Torvalds 	},
13311da177e4SLinus Torvalds 	{
13321da177e4SLinus Torvalds 		.procname	= "file-max",
13331da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
13341da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13351da177e4SLinus Torvalds 		.mode		= 0644,
13366d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13371da177e4SLinus Torvalds 	},
13381da177e4SLinus Torvalds 	{
13399cfe015aSEric Dumazet 		.procname	= "nr_open",
13409cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
13419cfe015aSEric Dumazet 		.maxlen		= sizeof(int),
13429cfe015aSEric Dumazet 		.mode		= 0644,
13436d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1344eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
1345eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
13469cfe015aSEric Dumazet 	},
13479cfe015aSEric Dumazet 	{
13481da177e4SLinus Torvalds 		.procname	= "dentry-state",
13491da177e4SLinus Torvalds 		.data		= &dentry_stat,
13501da177e4SLinus Torvalds 		.maxlen		= 6*sizeof(int),
13511da177e4SLinus Torvalds 		.mode		= 0444,
13526d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13531da177e4SLinus Torvalds 	},
13541da177e4SLinus Torvalds 	{
13551da177e4SLinus Torvalds 		.procname	= "overflowuid",
13561da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
13571da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13581da177e4SLinus Torvalds 		.mode		= 0644,
13596d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13601da177e4SLinus Torvalds 		.extra1		= &minolduid,
13611da177e4SLinus Torvalds 		.extra2		= &maxolduid,
13621da177e4SLinus Torvalds 	},
13631da177e4SLinus Torvalds 	{
13641da177e4SLinus Torvalds 		.procname	= "overflowgid",
13651da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
13661da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13671da177e4SLinus Torvalds 		.mode		= 0644,
13686d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13691da177e4SLinus Torvalds 		.extra1		= &minolduid,
13701da177e4SLinus Torvalds 		.extra2		= &maxolduid,
13711da177e4SLinus Torvalds 	},
1372bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
13731da177e4SLinus Torvalds 	{
13741da177e4SLinus Torvalds 		.procname	= "leases-enable",
13751da177e4SLinus Torvalds 		.data		= &leases_enable,
13761da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13771da177e4SLinus Torvalds 		.mode		= 0644,
13786d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13791da177e4SLinus Torvalds 	},
1380bfcd17a6SThomas Petazzoni #endif
13811da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
13821da177e4SLinus Torvalds 	{
13831da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
13841da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
13851da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13861da177e4SLinus Torvalds 		.mode		= 0644,
13876d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13881da177e4SLinus Torvalds 	},
13891da177e4SLinus Torvalds #endif
13901da177e4SLinus Torvalds #ifdef CONFIG_MMU
1391bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
13921da177e4SLinus Torvalds 	{
13931da177e4SLinus Torvalds 		.procname	= "lease-break-time",
13941da177e4SLinus Torvalds 		.data		= &lease_break_time,
13951da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13961da177e4SLinus Torvalds 		.mode		= 0644,
13976d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13981da177e4SLinus Torvalds 	},
1399bfcd17a6SThomas Petazzoni #endif
1400ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
14011da177e4SLinus Torvalds 	{
14021da177e4SLinus Torvalds 		.procname	= "aio-nr",
14031da177e4SLinus Torvalds 		.data		= &aio_nr,
14041da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
14051da177e4SLinus Torvalds 		.mode		= 0444,
14066d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
14071da177e4SLinus Torvalds 	},
14081da177e4SLinus Torvalds 	{
14091da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
14101da177e4SLinus Torvalds 		.data		= &aio_max_nr,
14111da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
14121da177e4SLinus Torvalds 		.mode		= 0644,
14136d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
14141da177e4SLinus Torvalds 	},
1415ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
14162d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
14170399cb08SRobert Love 	{
14180399cb08SRobert Love 		.procname	= "inotify",
14190399cb08SRobert Love 		.mode		= 0555,
14200399cb08SRobert Love 		.child		= inotify_table,
14210399cb08SRobert Love 	},
14220399cb08SRobert Love #endif
14237ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
14247ef9964eSDavide Libenzi 	{
14257ef9964eSDavide Libenzi 		.procname	= "epoll",
14267ef9964eSDavide Libenzi 		.mode		= 0555,
14277ef9964eSDavide Libenzi 		.child		= epoll_table,
14287ef9964eSDavide Libenzi 	},
14297ef9964eSDavide Libenzi #endif
14301da177e4SLinus Torvalds #endif
1431d6e71144SAlan Cox 	{
1432d6e71144SAlan Cox 		.procname	= "suid_dumpable",
1433d6e71144SAlan Cox 		.data		= &suid_dumpable,
1434d6e71144SAlan Cox 		.maxlen		= sizeof(int),
1435d6e71144SAlan Cox 		.mode		= 0644,
14366d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
14378e654fbaSMatthew Wilcox 		.extra1		= &zero,
14388e654fbaSMatthew Wilcox 		.extra2		= &two,
1439d6e71144SAlan Cox 	},
14402abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
14412abc26fcSEric W. Biederman 	{
14422abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
14432abc26fcSEric W. Biederman 		.mode		= 0555,
14442abc26fcSEric W. Biederman 		.child		= binfmt_misc_table,
14452abc26fcSEric W. Biederman 	},
14462abc26fcSEric W. Biederman #endif
14472be7fe07SAndrew Morton /*
14482be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
14492be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
14502be7fe07SAndrew Morton  */
14516fce56ecSEric W. Biederman 	{ }
14521da177e4SLinus Torvalds };
14531da177e4SLinus Torvalds 
1454d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
1455ab3c68eeSHeiko Carstens #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \
1456ab3c68eeSHeiko Carstens     defined(CONFIG_S390)
1457abd4f750SMasoud Asgharifard Sharbiani 	{
1458abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
1459abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
1460abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
1461abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
1462abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
1463abd4f750SMasoud Asgharifard Sharbiani 	},
1464abd4f750SMasoud Asgharifard Sharbiani #endif
1465b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES)
1466b2be84dfSMasami Hiramatsu 	{
1467b2be84dfSMasami Hiramatsu 		.procname	= "kprobes-optimization",
1468b2be84dfSMasami Hiramatsu 		.data		= &sysctl_kprobes_optimization,
1469b2be84dfSMasami Hiramatsu 		.maxlen		= sizeof(int),
1470b2be84dfSMasami Hiramatsu 		.mode		= 0644,
1471b2be84dfSMasami Hiramatsu 		.proc_handler	= proc_kprobes_optimization_handler,
1472b2be84dfSMasami Hiramatsu 		.extra1		= &zero,
1473b2be84dfSMasami Hiramatsu 		.extra2		= &one,
1474b2be84dfSMasami Hiramatsu 	},
1475b2be84dfSMasami Hiramatsu #endif
14766fce56ecSEric W. Biederman 	{ }
14771da177e4SLinus Torvalds };
14781da177e4SLinus Torvalds 
1479d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
14806fce56ecSEric W. Biederman 	{ }
14811da177e4SLinus Torvalds };
14821da177e4SLinus Torvalds 
1483330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock);
1484330d57fbSAl Viro 
1485330d57fbSAl Viro /* called under sysctl_lock */
1486330d57fbSAl Viro static int use_table(struct ctl_table_header *p)
1487330d57fbSAl Viro {
1488330d57fbSAl Viro 	if (unlikely(p->unregistering))
1489330d57fbSAl Viro 		return 0;
1490330d57fbSAl Viro 	p->used++;
1491330d57fbSAl Viro 	return 1;
1492330d57fbSAl Viro }
1493330d57fbSAl Viro 
1494330d57fbSAl Viro /* called under sysctl_lock */
1495330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p)
1496330d57fbSAl Viro {
1497330d57fbSAl Viro 	if (!--p->used)
1498330d57fbSAl Viro 		if (unlikely(p->unregistering))
1499330d57fbSAl Viro 			complete(p->unregistering);
1500330d57fbSAl Viro }
1501330d57fbSAl Viro 
1502330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */
1503330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p)
1504330d57fbSAl Viro {
1505330d57fbSAl Viro 	/*
1506330d57fbSAl Viro 	 * if p->used is 0, nobody will ever touch that entry again;
1507330d57fbSAl Viro 	 * we'll eliminate all paths to it before dropping sysctl_lock
1508330d57fbSAl Viro 	 */
1509330d57fbSAl Viro 	if (unlikely(p->used)) {
1510330d57fbSAl Viro 		struct completion wait;
1511330d57fbSAl Viro 		init_completion(&wait);
1512330d57fbSAl Viro 		p->unregistering = &wait;
1513330d57fbSAl Viro 		spin_unlock(&sysctl_lock);
1514330d57fbSAl Viro 		wait_for_completion(&wait);
1515330d57fbSAl Viro 		spin_lock(&sysctl_lock);
1516f7e6ced4SAl Viro 	} else {
1517f7e6ced4SAl Viro 		/* anything non-NULL; we'll never dereference it */
1518f7e6ced4SAl Viro 		p->unregistering = ERR_PTR(-EINVAL);
1519330d57fbSAl Viro 	}
1520330d57fbSAl Viro 	/*
1521330d57fbSAl Viro 	 * do not remove from the list until nobody holds it; walking the
1522330d57fbSAl Viro 	 * list in do_sysctl() relies on that.
1523330d57fbSAl Viro 	 */
1524330d57fbSAl Viro 	list_del_init(&p->ctl_entry);
1525330d57fbSAl Viro }
1526330d57fbSAl Viro 
1527f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head)
1528f7e6ced4SAl Viro {
1529f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1530f7e6ced4SAl Viro 	head->count++;
1531f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1532f7e6ced4SAl Viro }
1533f7e6ced4SAl Viro 
1534f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
1535f7e6ced4SAl Viro {
1536f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1537f7e6ced4SAl Viro 	if (!--head->count)
1538f7e6ced4SAl Viro 		kfree(head);
1539f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1540f7e6ced4SAl Viro }
1541f7e6ced4SAl Viro 
1542f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1543f7e6ced4SAl Viro {
1544f7e6ced4SAl Viro 	if (!head)
1545f7e6ced4SAl Viro 		BUG();
1546f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1547f7e6ced4SAl Viro 	if (!use_table(head))
1548f7e6ced4SAl Viro 		head = ERR_PTR(-ENOENT);
1549f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1550f7e6ced4SAl Viro 	return head;
1551f7e6ced4SAl Viro }
1552f7e6ced4SAl Viro 
1553805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head)
1554805b5d5eSEric W. Biederman {
1555805b5d5eSEric W. Biederman 	if (!head)
1556805b5d5eSEric W. Biederman 		return;
1557805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1558805b5d5eSEric W. Biederman 	unuse_table(head);
1559805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1560805b5d5eSEric W. Biederman }
1561805b5d5eSEric W. Biederman 
156273455092SAl Viro static struct ctl_table_set *
156373455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
156473455092SAl Viro {
156573455092SAl Viro 	struct ctl_table_set *set = &root->default_set;
156673455092SAl Viro 	if (root->lookup)
156773455092SAl Viro 		set = root->lookup(root, namespaces);
156873455092SAl Viro 	return set;
156973455092SAl Viro }
157073455092SAl Viro 
1571e51b6ba0SEric W. Biederman static struct list_head *
1572e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1573805b5d5eSEric W. Biederman {
157473455092SAl Viro 	struct ctl_table_set *set = lookup_header_set(root, namespaces);
157573455092SAl Viro 	return &set->list;
1576e51b6ba0SEric W. Biederman }
1577e51b6ba0SEric W. Biederman 
1578e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1579e51b6ba0SEric W. Biederman 					    struct ctl_table_header *prev)
1580e51b6ba0SEric W. Biederman {
1581e51b6ba0SEric W. Biederman 	struct ctl_table_root *root;
1582e51b6ba0SEric W. Biederman 	struct list_head *header_list;
1583805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1584805b5d5eSEric W. Biederman 	struct list_head *tmp;
1585e51b6ba0SEric W. Biederman 
1586805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1587805b5d5eSEric W. Biederman 	if (prev) {
1588e51b6ba0SEric W. Biederman 		head = prev;
1589805b5d5eSEric W. Biederman 		tmp = &prev->ctl_entry;
1590805b5d5eSEric W. Biederman 		unuse_table(prev);
1591805b5d5eSEric W. Biederman 		goto next;
1592805b5d5eSEric W. Biederman 	}
1593805b5d5eSEric W. Biederman 	tmp = &root_table_header.ctl_entry;
1594805b5d5eSEric W. Biederman 	for (;;) {
1595805b5d5eSEric W. Biederman 		head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1596805b5d5eSEric W. Biederman 
1597805b5d5eSEric W. Biederman 		if (!use_table(head))
1598805b5d5eSEric W. Biederman 			goto next;
1599805b5d5eSEric W. Biederman 		spin_unlock(&sysctl_lock);
1600805b5d5eSEric W. Biederman 		return head;
1601805b5d5eSEric W. Biederman 	next:
1602e51b6ba0SEric W. Biederman 		root = head->root;
1603805b5d5eSEric W. Biederman 		tmp = tmp->next;
1604e51b6ba0SEric W. Biederman 		header_list = lookup_header_list(root, namespaces);
1605e51b6ba0SEric W. Biederman 		if (tmp != header_list)
1606e51b6ba0SEric W. Biederman 			continue;
1607e51b6ba0SEric W. Biederman 
1608e51b6ba0SEric W. Biederman 		do {
1609e51b6ba0SEric W. Biederman 			root = list_entry(root->root_list.next,
1610e51b6ba0SEric W. Biederman 					struct ctl_table_root, root_list);
1611e51b6ba0SEric W. Biederman 			if (root == &sysctl_table_root)
1612e51b6ba0SEric W. Biederman 				goto out;
1613e51b6ba0SEric W. Biederman 			header_list = lookup_header_list(root, namespaces);
1614e51b6ba0SEric W. Biederman 		} while (list_empty(header_list));
1615e51b6ba0SEric W. Biederman 		tmp = header_list->next;
1616805b5d5eSEric W. Biederman 	}
1617e51b6ba0SEric W. Biederman out:
1618805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1619805b5d5eSEric W. Biederman 	return NULL;
1620805b5d5eSEric W. Biederman }
1621805b5d5eSEric W. Biederman 
1622e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1623e51b6ba0SEric W. Biederman {
1624e51b6ba0SEric W. Biederman 	return __sysctl_head_next(current->nsproxy, prev);
1625e51b6ba0SEric W. Biederman }
1626e51b6ba0SEric W. Biederman 
1627e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root)
1628e51b6ba0SEric W. Biederman {
1629e51b6ba0SEric W. Biederman 	spin_lock(&sysctl_lock);
1630e51b6ba0SEric W. Biederman 	list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1631e51b6ba0SEric W. Biederman 	spin_unlock(&sysctl_lock);
1632e51b6ba0SEric W. Biederman }
1633e51b6ba0SEric W. Biederman 
16341da177e4SLinus Torvalds /*
16351ff007ebSEric W. Biederman  * sysctl_perm does NOT grant the superuser all rights automatically, because
16361da177e4SLinus Torvalds  * some sysctl variables are readonly even to root.
16371da177e4SLinus Torvalds  */
16381da177e4SLinus Torvalds 
16391da177e4SLinus Torvalds static int test_perm(int mode, int op)
16401da177e4SLinus Torvalds {
164176aac0e9SDavid Howells 	if (!current_euid())
16421da177e4SLinus Torvalds 		mode >>= 6;
16431da177e4SLinus Torvalds 	else if (in_egroup_p(0))
16441da177e4SLinus Torvalds 		mode >>= 3;
1645e6305c43SAl Viro 	if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
16461da177e4SLinus Torvalds 		return 0;
16471da177e4SLinus Torvalds 	return -EACCES;
16481da177e4SLinus Torvalds }
16491da177e4SLinus Torvalds 
1650d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
16511da177e4SLinus Torvalds {
16521da177e4SLinus Torvalds 	int error;
1653d7321cd6SPavel Emelyanov 	int mode;
1654d7321cd6SPavel Emelyanov 
1655e6305c43SAl Viro 	error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
16561da177e4SLinus Torvalds 	if (error)
16571da177e4SLinus Torvalds 		return error;
1658d7321cd6SPavel Emelyanov 
1659d7321cd6SPavel Emelyanov 	if (root->permissions)
1660d7321cd6SPavel Emelyanov 		mode = root->permissions(root, current->nsproxy, table);
1661d7321cd6SPavel Emelyanov 	else
1662d7321cd6SPavel Emelyanov 		mode = table->mode;
1663d7321cd6SPavel Emelyanov 
1664d7321cd6SPavel Emelyanov 	return test_perm(mode, op);
16651da177e4SLinus Torvalds }
16661da177e4SLinus Torvalds 
1667d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1668d912b0ccSEric W. Biederman {
16692315ffa0SEric W. Biederman 	for (; table->procname; table++) {
1670d912b0ccSEric W. Biederman 		table->parent = parent;
1671d912b0ccSEric W. Biederman 		if (table->child)
1672d912b0ccSEric W. Biederman 			sysctl_set_parent(table, table->child);
1673d912b0ccSEric W. Biederman 	}
1674d912b0ccSEric W. Biederman }
1675d912b0ccSEric W. Biederman 
1676d912b0ccSEric W. Biederman static __init int sysctl_init(void)
1677d912b0ccSEric W. Biederman {
1678d912b0ccSEric W. Biederman 	sysctl_set_parent(NULL, root_table);
167988f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
168088f458e4SHolger Schurig 	{
168188f458e4SHolger Schurig 		int err;
1682e51b6ba0SEric W. Biederman 		err = sysctl_check_table(current->nsproxy, root_table);
168388f458e4SHolger Schurig 	}
168488f458e4SHolger Schurig #endif
1685d912b0ccSEric W. Biederman 	return 0;
1686d912b0ccSEric W. Biederman }
1687d912b0ccSEric W. Biederman 
1688d912b0ccSEric W. Biederman core_initcall(sysctl_init);
1689d912b0ccSEric W. Biederman 
1690bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch,
1691bfbcf034SAl Viro 				      struct ctl_table *table)
1692ae7edeccSAl Viro {
1693ae7edeccSAl Viro 	struct ctl_table *p;
1694ae7edeccSAl Viro 	const char *s = branch->procname;
1695ae7edeccSAl Viro 
1696ae7edeccSAl Viro 	/* branch should have named subdirectory as its first element */
1697ae7edeccSAl Viro 	if (!s || !branch->child)
1698bfbcf034SAl Viro 		return NULL;
1699ae7edeccSAl Viro 
1700ae7edeccSAl Viro 	/* ... and nothing else */
17012315ffa0SEric W. Biederman 	if (branch[1].procname)
1702bfbcf034SAl Viro 		return NULL;
1703ae7edeccSAl Viro 
1704ae7edeccSAl Viro 	/* table should contain subdirectory with the same name */
17052315ffa0SEric W. Biederman 	for (p = table; p->procname; p++) {
1706ae7edeccSAl Viro 		if (!p->child)
1707ae7edeccSAl Viro 			continue;
1708ae7edeccSAl Viro 		if (p->procname && strcmp(p->procname, s) == 0)
1709bfbcf034SAl Viro 			return p;
1710ae7edeccSAl Viro 	}
1711bfbcf034SAl Viro 	return NULL;
1712ae7edeccSAl Viro }
1713ae7edeccSAl Viro 
1714ae7edeccSAl Viro /* see if attaching q to p would be an improvement */
1715ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1716ae7edeccSAl Viro {
1717ae7edeccSAl Viro 	struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1718bfbcf034SAl Viro 	struct ctl_table *next;
1719ae7edeccSAl Viro 	int is_better = 0;
1720ae7edeccSAl Viro 	int not_in_parent = !p->attached_by;
1721ae7edeccSAl Viro 
1722bfbcf034SAl Viro 	while ((next = is_branch_in(by, to)) != NULL) {
1723ae7edeccSAl Viro 		if (by == q->attached_by)
1724ae7edeccSAl Viro 			is_better = 1;
1725ae7edeccSAl Viro 		if (to == p->attached_by)
1726ae7edeccSAl Viro 			not_in_parent = 1;
1727ae7edeccSAl Viro 		by = by->child;
1728bfbcf034SAl Viro 		to = next->child;
1729ae7edeccSAl Viro 	}
1730ae7edeccSAl Viro 
1731ae7edeccSAl Viro 	if (is_better && not_in_parent) {
1732ae7edeccSAl Viro 		q->attached_by = by;
1733ae7edeccSAl Viro 		q->attached_to = to;
1734ae7edeccSAl Viro 		q->parent = p;
1735ae7edeccSAl Viro 	}
1736ae7edeccSAl Viro }
1737ae7edeccSAl Viro 
17381da177e4SLinus Torvalds /**
1739e51b6ba0SEric W. Biederman  * __register_sysctl_paths - register a sysctl hierarchy
1740e51b6ba0SEric W. Biederman  * @root: List of sysctl headers to register on
1741e51b6ba0SEric W. Biederman  * @namespaces: Data to compute which lists of sysctl entries are visible
174229e796fdSEric W. Biederman  * @path: The path to the directory the sysctl table is in.
17431da177e4SLinus Torvalds  * @table: the top-level table structure
17441da177e4SLinus Torvalds  *
17451da177e4SLinus Torvalds  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
174629e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
17471da177e4SLinus Torvalds  *
1748d8217f07SEric W. Biederman  * The members of the &struct ctl_table structure are used as follows:
17491da177e4SLinus Torvalds  *
17501da177e4SLinus Torvalds  * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
17511da177e4SLinus Torvalds  *            enter a sysctl file
17521da177e4SLinus Torvalds  *
17531da177e4SLinus Torvalds  * data - a pointer to data for use by proc_handler
17541da177e4SLinus Torvalds  *
17551da177e4SLinus Torvalds  * maxlen - the maximum size in bytes of the data
17561da177e4SLinus Torvalds  *
17571da177e4SLinus Torvalds  * mode - the file permissions for the /proc/sys file, and for sysctl(2)
17581da177e4SLinus Torvalds  *
17591da177e4SLinus Torvalds  * child - a pointer to the child sysctl table if this entry is a directory, or
17601da177e4SLinus Torvalds  *         %NULL.
17611da177e4SLinus Torvalds  *
17621da177e4SLinus Torvalds  * proc_handler - the text handler routine (described below)
17631da177e4SLinus Torvalds  *
17641da177e4SLinus Torvalds  * de - for internal use by the sysctl routines
17651da177e4SLinus Torvalds  *
17661da177e4SLinus Torvalds  * extra1, extra2 - extra pointers usable by the proc handler routines
17671da177e4SLinus Torvalds  *
17681da177e4SLinus Torvalds  * Leaf nodes in the sysctl tree will be represented by a single file
17691da177e4SLinus Torvalds  * under /proc; non-leaf nodes will be represented by directories.
17701da177e4SLinus Torvalds  *
17711da177e4SLinus Torvalds  * sysctl(2) can automatically manage read and write requests through
17721da177e4SLinus Torvalds  * the sysctl table.  The data and maxlen fields of the ctl_table
17731da177e4SLinus Torvalds  * struct enable minimal validation of the values being written to be
17741da177e4SLinus Torvalds  * performed, and the mode field allows minimal authentication.
17751da177e4SLinus Torvalds  *
17761da177e4SLinus Torvalds  * There must be a proc_handler routine for any terminal nodes
17771da177e4SLinus Torvalds  * mirrored under /proc/sys (non-terminals are handled by a built-in
17781da177e4SLinus Torvalds  * directory handler).  Several default handlers are available to
17791da177e4SLinus Torvalds  * cover common cases -
17801da177e4SLinus Torvalds  *
17811da177e4SLinus Torvalds  * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
17821da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
17831da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
17841da177e4SLinus Torvalds  *
17851da177e4SLinus Torvalds  * It is the handler's job to read the input buffer from user memory
17861da177e4SLinus Torvalds  * and process it. The handler should return 0 on success.
17871da177e4SLinus Torvalds  *
17881da177e4SLinus Torvalds  * This routine returns %NULL on a failure to register, and a pointer
17891da177e4SLinus Torvalds  * to the table header on success.
17901da177e4SLinus Torvalds  */
1791e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths(
1792e51b6ba0SEric W. Biederman 	struct ctl_table_root *root,
1793e51b6ba0SEric W. Biederman 	struct nsproxy *namespaces,
1794e51b6ba0SEric W. Biederman 	const struct ctl_path *path, struct ctl_table *table)
17951da177e4SLinus Torvalds {
179629e796fdSEric W. Biederman 	struct ctl_table_header *header;
179729e796fdSEric W. Biederman 	struct ctl_table *new, **prevp;
179829e796fdSEric W. Biederman 	unsigned int n, npath;
1799ae7edeccSAl Viro 	struct ctl_table_set *set;
180029e796fdSEric W. Biederman 
180129e796fdSEric W. Biederman 	/* Count the path components */
18022315ffa0SEric W. Biederman 	for (npath = 0; path[npath].procname; ++npath)
180329e796fdSEric W. Biederman 		;
180429e796fdSEric W. Biederman 
180529e796fdSEric W. Biederman 	/*
180629e796fdSEric W. Biederman 	 * For each path component, allocate a 2-element ctl_table array.
180729e796fdSEric W. Biederman 	 * The first array element will be filled with the sysctl entry
18082315ffa0SEric W. Biederman 	 * for this, the second will be the sentinel (procname == 0).
180929e796fdSEric W. Biederman 	 *
181029e796fdSEric W. Biederman 	 * We allocate everything in one go so that we don't have to
181129e796fdSEric W. Biederman 	 * worry about freeing additional memory in unregister_sysctl_table.
181229e796fdSEric W. Biederman 	 */
181329e796fdSEric W. Biederman 	header = kzalloc(sizeof(struct ctl_table_header) +
181429e796fdSEric W. Biederman 			 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
181529e796fdSEric W. Biederman 	if (!header)
18161da177e4SLinus Torvalds 		return NULL;
181729e796fdSEric W. Biederman 
181829e796fdSEric W. Biederman 	new = (struct ctl_table *) (header + 1);
181929e796fdSEric W. Biederman 
182029e796fdSEric W. Biederman 	/* Now connect the dots */
182129e796fdSEric W. Biederman 	prevp = &header->ctl_table;
182229e796fdSEric W. Biederman 	for (n = 0; n < npath; ++n, ++path) {
182329e796fdSEric W. Biederman 		/* Copy the procname */
182429e796fdSEric W. Biederman 		new->procname = path->procname;
182529e796fdSEric W. Biederman 		new->mode     = 0555;
182629e796fdSEric W. Biederman 
182729e796fdSEric W. Biederman 		*prevp = new;
182829e796fdSEric W. Biederman 		prevp = &new->child;
182929e796fdSEric W. Biederman 
183029e796fdSEric W. Biederman 		new += 2;
183129e796fdSEric W. Biederman 	}
183229e796fdSEric W. Biederman 	*prevp = table;
183323eb06deSEric W. Biederman 	header->ctl_table_arg = table;
183429e796fdSEric W. Biederman 
183529e796fdSEric W. Biederman 	INIT_LIST_HEAD(&header->ctl_entry);
183629e796fdSEric W. Biederman 	header->used = 0;
183729e796fdSEric W. Biederman 	header->unregistering = NULL;
1838e51b6ba0SEric W. Biederman 	header->root = root;
183929e796fdSEric W. Biederman 	sysctl_set_parent(NULL, header->ctl_table);
1840f7e6ced4SAl Viro 	header->count = 1;
184188f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1842e51b6ba0SEric W. Biederman 	if (sysctl_check_table(namespaces, header->ctl_table)) {
184329e796fdSEric W. Biederman 		kfree(header);
1844fc6cd25bSEric W. Biederman 		return NULL;
1845fc6cd25bSEric W. Biederman 	}
184688f458e4SHolger Schurig #endif
1847330d57fbSAl Viro 	spin_lock(&sysctl_lock);
184873455092SAl Viro 	header->set = lookup_header_set(root, namespaces);
1849ae7edeccSAl Viro 	header->attached_by = header->ctl_table;
1850ae7edeccSAl Viro 	header->attached_to = root_table;
1851ae7edeccSAl Viro 	header->parent = &root_table_header;
1852ae7edeccSAl Viro 	for (set = header->set; set; set = set->parent) {
1853ae7edeccSAl Viro 		struct ctl_table_header *p;
1854ae7edeccSAl Viro 		list_for_each_entry(p, &set->list, ctl_entry) {
1855ae7edeccSAl Viro 			if (p->unregistering)
1856ae7edeccSAl Viro 				continue;
1857ae7edeccSAl Viro 			try_attach(p, header);
1858ae7edeccSAl Viro 		}
1859ae7edeccSAl Viro 	}
1860ae7edeccSAl Viro 	header->parent->count++;
186173455092SAl Viro 	list_add_tail(&header->ctl_entry, &header->set->list);
1862330d57fbSAl Viro 	spin_unlock(&sysctl_lock);
186329e796fdSEric W. Biederman 
186429e796fdSEric W. Biederman 	return header;
186529e796fdSEric W. Biederman }
186629e796fdSEric W. Biederman 
186729e796fdSEric W. Biederman /**
1868e51b6ba0SEric W. Biederman  * register_sysctl_table_path - register a sysctl table hierarchy
1869e51b6ba0SEric W. Biederman  * @path: The path to the directory the sysctl table is in.
1870e51b6ba0SEric W. Biederman  * @table: the top-level table structure
1871e51b6ba0SEric W. Biederman  *
1872e51b6ba0SEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1873e51b6ba0SEric W. Biederman  * array. A completely 0 filled entry terminates the table.
1874e51b6ba0SEric W. Biederman  *
1875e51b6ba0SEric W. Biederman  * See __register_sysctl_paths for more details.
1876e51b6ba0SEric W. Biederman  */
1877e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1878e51b6ba0SEric W. Biederman 						struct ctl_table *table)
1879e51b6ba0SEric W. Biederman {
1880e51b6ba0SEric W. Biederman 	return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1881e51b6ba0SEric W. Biederman 					path, table);
1882e51b6ba0SEric W. Biederman }
1883e51b6ba0SEric W. Biederman 
1884e51b6ba0SEric W. Biederman /**
188529e796fdSEric W. Biederman  * register_sysctl_table - register a sysctl table hierarchy
188629e796fdSEric W. Biederman  * @table: the top-level table structure
188729e796fdSEric W. Biederman  *
188829e796fdSEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
188929e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
189029e796fdSEric W. Biederman  *
189129e796fdSEric W. Biederman  * See register_sysctl_paths for more details.
189229e796fdSEric W. Biederman  */
189329e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
189429e796fdSEric W. Biederman {
189529e796fdSEric W. Biederman 	static const struct ctl_path null_path[] = { {} };
189629e796fdSEric W. Biederman 
189729e796fdSEric W. Biederman 	return register_sysctl_paths(null_path, table);
18981da177e4SLinus Torvalds }
18991da177e4SLinus Torvalds 
19001da177e4SLinus Torvalds /**
19011da177e4SLinus Torvalds  * unregister_sysctl_table - unregister a sysctl table hierarchy
19021da177e4SLinus Torvalds  * @header: the header returned from register_sysctl_table
19031da177e4SLinus Torvalds  *
19041da177e4SLinus Torvalds  * Unregisters the sysctl table and all children. proc entries may not
19051da177e4SLinus Torvalds  * actually be removed until they are no longer used by anyone.
19061da177e4SLinus Torvalds  */
19071da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header)
19081da177e4SLinus Torvalds {
1909330d57fbSAl Viro 	might_sleep();
1910f1dad166SPavel Emelyanov 
1911f1dad166SPavel Emelyanov 	if (header == NULL)
1912f1dad166SPavel Emelyanov 		return;
1913f1dad166SPavel Emelyanov 
1914330d57fbSAl Viro 	spin_lock(&sysctl_lock);
1915330d57fbSAl Viro 	start_unregistering(header);
1916ae7edeccSAl Viro 	if (!--header->parent->count) {
1917ae7edeccSAl Viro 		WARN_ON(1);
1918ae7edeccSAl Viro 		kfree(header->parent);
1919ae7edeccSAl Viro 	}
1920f7e6ced4SAl Viro 	if (!--header->count)
19211da177e4SLinus Torvalds 		kfree(header);
1922f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
19231da177e4SLinus Torvalds }
19241da177e4SLinus Torvalds 
19259043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p)
19269043476fSAl Viro {
19279043476fSAl Viro 	struct ctl_table_set *set = p->set;
19289043476fSAl Viro 	int res;
19299043476fSAl Viro 	spin_lock(&sysctl_lock);
19309043476fSAl Viro 	if (p->unregistering)
19319043476fSAl Viro 		res = 0;
19329043476fSAl Viro 	else if (!set->is_seen)
19339043476fSAl Viro 		res = 1;
19349043476fSAl Viro 	else
19359043476fSAl Viro 		res = set->is_seen(set);
19369043476fSAl Viro 	spin_unlock(&sysctl_lock);
19379043476fSAl Viro 	return res;
19389043476fSAl Viro }
19399043476fSAl Viro 
194073455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
194173455092SAl Viro 	struct ctl_table_set *parent,
194273455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
194373455092SAl Viro {
194473455092SAl Viro 	INIT_LIST_HEAD(&p->list);
194573455092SAl Viro 	p->parent = parent ? parent : &sysctl_table_root.default_set;
194673455092SAl Viro 	p->is_seen = is_seen;
194773455092SAl Viro }
194873455092SAl Viro 
1949b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */
1950d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
1951b89a8171SEric W. Biederman {
1952b89a8171SEric W. Biederman 	return NULL;
1953b89a8171SEric W. Biederman }
1954b89a8171SEric W. Biederman 
195529e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
195629e796fdSEric W. Biederman 						    struct ctl_table *table)
195729e796fdSEric W. Biederman {
195829e796fdSEric W. Biederman 	return NULL;
195929e796fdSEric W. Biederman }
196029e796fdSEric W. Biederman 
1961b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table)
1962b89a8171SEric W. Biederman {
1963b89a8171SEric W. Biederman }
1964b89a8171SEric W. Biederman 
196573455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
196673455092SAl Viro 	struct ctl_table_set *parent,
196773455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
196873455092SAl Viro {
196973455092SAl Viro }
197073455092SAl Viro 
1971f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
1972f7e6ced4SAl Viro {
1973f7e6ced4SAl Viro }
1974f7e6ced4SAl Viro 
1975b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
1976b89a8171SEric W. Biederman 
19771da177e4SLinus Torvalds /*
19781da177e4SLinus Torvalds  * /proc/sys support
19791da177e4SLinus Torvalds  */
19801da177e4SLinus Torvalds 
1981b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL
19821da177e4SLinus Torvalds 
1983b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write,
19848d65af78SAlexey Dobriyan 			   void __user *buffer,
1985b1ba4dddSAdrian Bunk 			   size_t *lenp, loff_t *ppos)
1986f5dd3d6fSSam Vilain {
1987f5dd3d6fSSam Vilain 	size_t len;
1988f5dd3d6fSSam Vilain 	char __user *p;
1989f5dd3d6fSSam Vilain 	char c;
1990f5dd3d6fSSam Vilain 
19918d060877SOleg Nesterov 	if (!data || !maxlen || !*lenp) {
1992f5dd3d6fSSam Vilain 		*lenp = 0;
1993f5dd3d6fSSam Vilain 		return 0;
1994f5dd3d6fSSam Vilain 	}
1995f5dd3d6fSSam Vilain 
1996f5dd3d6fSSam Vilain 	if (write) {
1997f5dd3d6fSSam Vilain 		len = 0;
1998f5dd3d6fSSam Vilain 		p = buffer;
1999f5dd3d6fSSam Vilain 		while (len < *lenp) {
2000f5dd3d6fSSam Vilain 			if (get_user(c, p++))
2001f5dd3d6fSSam Vilain 				return -EFAULT;
2002f5dd3d6fSSam Vilain 			if (c == 0 || c == '\n')
2003f5dd3d6fSSam Vilain 				break;
2004f5dd3d6fSSam Vilain 			len++;
2005f5dd3d6fSSam Vilain 		}
2006f5dd3d6fSSam Vilain 		if (len >= maxlen)
2007f5dd3d6fSSam Vilain 			len = maxlen-1;
2008f5dd3d6fSSam Vilain 		if(copy_from_user(data, buffer, len))
2009f5dd3d6fSSam Vilain 			return -EFAULT;
2010f5dd3d6fSSam Vilain 		((char *) data)[len] = 0;
2011f5dd3d6fSSam Vilain 		*ppos += *lenp;
2012f5dd3d6fSSam Vilain 	} else {
2013f5dd3d6fSSam Vilain 		len = strlen(data);
2014f5dd3d6fSSam Vilain 		if (len > maxlen)
2015f5dd3d6fSSam Vilain 			len = maxlen;
20168d060877SOleg Nesterov 
20178d060877SOleg Nesterov 		if (*ppos > len) {
20188d060877SOleg Nesterov 			*lenp = 0;
20198d060877SOleg Nesterov 			return 0;
20208d060877SOleg Nesterov 		}
20218d060877SOleg Nesterov 
20228d060877SOleg Nesterov 		data += *ppos;
20238d060877SOleg Nesterov 		len  -= *ppos;
20248d060877SOleg Nesterov 
2025f5dd3d6fSSam Vilain 		if (len > *lenp)
2026f5dd3d6fSSam Vilain 			len = *lenp;
2027f5dd3d6fSSam Vilain 		if (len)
2028f5dd3d6fSSam Vilain 			if(copy_to_user(buffer, data, len))
2029f5dd3d6fSSam Vilain 				return -EFAULT;
2030f5dd3d6fSSam Vilain 		if (len < *lenp) {
2031f5dd3d6fSSam Vilain 			if(put_user('\n', ((char __user *) buffer) + len))
2032f5dd3d6fSSam Vilain 				return -EFAULT;
2033f5dd3d6fSSam Vilain 			len++;
2034f5dd3d6fSSam Vilain 		}
2035f5dd3d6fSSam Vilain 		*lenp = len;
2036f5dd3d6fSSam Vilain 		*ppos += len;
2037f5dd3d6fSSam Vilain 	}
2038f5dd3d6fSSam Vilain 	return 0;
2039f5dd3d6fSSam Vilain }
2040f5dd3d6fSSam Vilain 
20411da177e4SLinus Torvalds /**
20421da177e4SLinus Torvalds  * proc_dostring - read a string sysctl
20431da177e4SLinus Torvalds  * @table: the sysctl table
20441da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
20451da177e4SLinus Torvalds  * @buffer: the user buffer
20461da177e4SLinus Torvalds  * @lenp: the size of the user buffer
20471da177e4SLinus Torvalds  * @ppos: file position
20481da177e4SLinus Torvalds  *
20491da177e4SLinus Torvalds  * Reads/writes a string from/to the user buffer. If the kernel
20501da177e4SLinus Torvalds  * buffer provided is not large enough to hold the string, the
20511da177e4SLinus Torvalds  * string is truncated. The copied string is %NULL-terminated.
20521da177e4SLinus Torvalds  * If the string is being read by the user process, it is copied
20531da177e4SLinus Torvalds  * and a newline '\n' is added. It is truncated if the buffer is
20541da177e4SLinus Torvalds  * not large enough.
20551da177e4SLinus Torvalds  *
20561da177e4SLinus Torvalds  * Returns 0 on success.
20571da177e4SLinus Torvalds  */
20588d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write,
20591da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
20601da177e4SLinus Torvalds {
20618d65af78SAlexey Dobriyan 	return _proc_do_string(table->data, table->maxlen, write,
2062f5dd3d6fSSam Vilain 			       buffer, lenp, ppos);
20631da177e4SLinus Torvalds }
20641da177e4SLinus Torvalds 
206500b7c339SAmerigo Wang static size_t proc_skip_spaces(char **buf)
206600b7c339SAmerigo Wang {
206700b7c339SAmerigo Wang 	size_t ret;
206800b7c339SAmerigo Wang 	char *tmp = skip_spaces(*buf);
206900b7c339SAmerigo Wang 	ret = tmp - *buf;
207000b7c339SAmerigo Wang 	*buf = tmp;
207100b7c339SAmerigo Wang 	return ret;
207200b7c339SAmerigo Wang }
20731da177e4SLinus Torvalds 
20749f977fb7SOctavian Purdila static void proc_skip_char(char **buf, size_t *size, const char v)
20759f977fb7SOctavian Purdila {
20769f977fb7SOctavian Purdila 	while (*size) {
20779f977fb7SOctavian Purdila 		if (**buf != v)
20789f977fb7SOctavian Purdila 			break;
20799f977fb7SOctavian Purdila 		(*size)--;
20809f977fb7SOctavian Purdila 		(*buf)++;
20819f977fb7SOctavian Purdila 	}
20829f977fb7SOctavian Purdila }
20839f977fb7SOctavian Purdila 
208400b7c339SAmerigo Wang #define TMPBUFLEN 22
208500b7c339SAmerigo Wang /**
208600b7c339SAmerigo Wang  * proc_get_long - reads an ASCII formated integer from a user buffer
208700b7c339SAmerigo Wang  *
208800b7c339SAmerigo Wang  * @buf - a kernel buffer
208900b7c339SAmerigo Wang  * @size - size of the kernel buffer
209000b7c339SAmerigo Wang  * @val - this is where the number will be stored
209100b7c339SAmerigo Wang  * @neg - set to %TRUE if number is negative
209200b7c339SAmerigo Wang  * @perm_tr - a vector which contains the allowed trailers
209300b7c339SAmerigo Wang  * @perm_tr_len - size of the perm_tr vector
209400b7c339SAmerigo Wang  * @tr - pointer to store the trailer character
209500b7c339SAmerigo Wang  *
209600b7c339SAmerigo Wang  * In case of success 0 is returned and buf and size are updated with
209700b7c339SAmerigo Wang  * the amount of bytes read. If tr is non NULL and a trailing
209800b7c339SAmerigo Wang  * character exist (size is non zero after returning from this
209900b7c339SAmerigo Wang  * function) tr is updated with the trailing character.
210000b7c339SAmerigo Wang  */
210100b7c339SAmerigo Wang static int proc_get_long(char **buf, size_t *size,
210200b7c339SAmerigo Wang 			  unsigned long *val, bool *neg,
210300b7c339SAmerigo Wang 			  const char *perm_tr, unsigned perm_tr_len, char *tr)
210400b7c339SAmerigo Wang {
210500b7c339SAmerigo Wang 	int len;
210600b7c339SAmerigo Wang 	char *p, tmp[TMPBUFLEN];
210700b7c339SAmerigo Wang 
210800b7c339SAmerigo Wang 	if (!*size)
210900b7c339SAmerigo Wang 		return -EINVAL;
211000b7c339SAmerigo Wang 
211100b7c339SAmerigo Wang 	len = *size;
211200b7c339SAmerigo Wang 	if (len > TMPBUFLEN - 1)
211300b7c339SAmerigo Wang 		len = TMPBUFLEN - 1;
211400b7c339SAmerigo Wang 
211500b7c339SAmerigo Wang 	memcpy(tmp, *buf, len);
211600b7c339SAmerigo Wang 
211700b7c339SAmerigo Wang 	tmp[len] = 0;
211800b7c339SAmerigo Wang 	p = tmp;
211900b7c339SAmerigo Wang 	if (*p == '-' && *size > 1) {
212000b7c339SAmerigo Wang 		*neg = true;
212100b7c339SAmerigo Wang 		p++;
212200b7c339SAmerigo Wang 	} else
212300b7c339SAmerigo Wang 		*neg = false;
212400b7c339SAmerigo Wang 	if (!isdigit(*p))
212500b7c339SAmerigo Wang 		return -EINVAL;
212600b7c339SAmerigo Wang 
212700b7c339SAmerigo Wang 	*val = simple_strtoul(p, &p, 0);
212800b7c339SAmerigo Wang 
212900b7c339SAmerigo Wang 	len = p - tmp;
213000b7c339SAmerigo Wang 
213100b7c339SAmerigo Wang 	/* We don't know if the next char is whitespace thus we may accept
213200b7c339SAmerigo Wang 	 * invalid integers (e.g. 1234...a) or two integers instead of one
213300b7c339SAmerigo Wang 	 * (e.g. 123...1). So lets not allow such large numbers. */
213400b7c339SAmerigo Wang 	if (len == TMPBUFLEN - 1)
213500b7c339SAmerigo Wang 		return -EINVAL;
213600b7c339SAmerigo Wang 
213700b7c339SAmerigo Wang 	if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
213800b7c339SAmerigo Wang 		return -EINVAL;
213900b7c339SAmerigo Wang 
214000b7c339SAmerigo Wang 	if (tr && (len < *size))
214100b7c339SAmerigo Wang 		*tr = *p;
214200b7c339SAmerigo Wang 
214300b7c339SAmerigo Wang 	*buf += len;
214400b7c339SAmerigo Wang 	*size -= len;
214500b7c339SAmerigo Wang 
214600b7c339SAmerigo Wang 	return 0;
214700b7c339SAmerigo Wang }
214800b7c339SAmerigo Wang 
214900b7c339SAmerigo Wang /**
215000b7c339SAmerigo Wang  * proc_put_long - coverts an integer to a decimal ASCII formated string
215100b7c339SAmerigo Wang  *
215200b7c339SAmerigo Wang  * @buf - the user buffer
215300b7c339SAmerigo Wang  * @size - the size of the user buffer
215400b7c339SAmerigo Wang  * @val - the integer to be converted
215500b7c339SAmerigo Wang  * @neg - sign of the number, %TRUE for negative
215600b7c339SAmerigo Wang  *
215700b7c339SAmerigo Wang  * In case of success 0 is returned and buf and size are updated with
215800b7c339SAmerigo Wang  * the amount of bytes read.
215900b7c339SAmerigo Wang  */
216000b7c339SAmerigo Wang static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
216100b7c339SAmerigo Wang 			  bool neg)
216200b7c339SAmerigo Wang {
216300b7c339SAmerigo Wang 	int len;
216400b7c339SAmerigo Wang 	char tmp[TMPBUFLEN], *p = tmp;
216500b7c339SAmerigo Wang 
216600b7c339SAmerigo Wang 	sprintf(p, "%s%lu", neg ? "-" : "", val);
216700b7c339SAmerigo Wang 	len = strlen(tmp);
216800b7c339SAmerigo Wang 	if (len > *size)
216900b7c339SAmerigo Wang 		len = *size;
217000b7c339SAmerigo Wang 	if (copy_to_user(*buf, tmp, len))
217100b7c339SAmerigo Wang 		return -EFAULT;
217200b7c339SAmerigo Wang 	*size -= len;
217300b7c339SAmerigo Wang 	*buf += len;
217400b7c339SAmerigo Wang 	return 0;
217500b7c339SAmerigo Wang }
217600b7c339SAmerigo Wang #undef TMPBUFLEN
217700b7c339SAmerigo Wang 
217800b7c339SAmerigo Wang static int proc_put_char(void __user **buf, size_t *size, char c)
217900b7c339SAmerigo Wang {
218000b7c339SAmerigo Wang 	if (*size) {
218100b7c339SAmerigo Wang 		char __user **buffer = (char __user **)buf;
218200b7c339SAmerigo Wang 		if (put_user(c, *buffer))
218300b7c339SAmerigo Wang 			return -EFAULT;
218400b7c339SAmerigo Wang 		(*size)--, (*buffer)++;
218500b7c339SAmerigo Wang 		*buf = *buffer;
218600b7c339SAmerigo Wang 	}
218700b7c339SAmerigo Wang 	return 0;
218800b7c339SAmerigo Wang }
218900b7c339SAmerigo Wang 
219000b7c339SAmerigo Wang static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
21911da177e4SLinus Torvalds 				 int *valp,
21921da177e4SLinus Torvalds 				 int write, void *data)
21931da177e4SLinus Torvalds {
21941da177e4SLinus Torvalds 	if (write) {
21951da177e4SLinus Torvalds 		*valp = *negp ? -*lvalp : *lvalp;
21961da177e4SLinus Torvalds 	} else {
21971da177e4SLinus Torvalds 		int val = *valp;
21981da177e4SLinus Torvalds 		if (val < 0) {
219900b7c339SAmerigo Wang 			*negp = true;
22001da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
22011da177e4SLinus Torvalds 		} else {
220200b7c339SAmerigo Wang 			*negp = false;
22031da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
22041da177e4SLinus Torvalds 		}
22051da177e4SLinus Torvalds 	}
22061da177e4SLinus Torvalds 	return 0;
22071da177e4SLinus Torvalds }
22081da177e4SLinus Torvalds 
220900b7c339SAmerigo Wang static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
221000b7c339SAmerigo Wang 
2211d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
22128d65af78SAlexey Dobriyan 		  int write, void __user *buffer,
2213fcfbd547SKirill Korotaev 		  size_t *lenp, loff_t *ppos,
221400b7c339SAmerigo Wang 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
22151da177e4SLinus Torvalds 			      int write, void *data),
22161da177e4SLinus Torvalds 		  void *data)
22171da177e4SLinus Torvalds {
221800b7c339SAmerigo Wang 	int *i, vleft, first = 1, err = 0;
221900b7c339SAmerigo Wang 	unsigned long page = 0;
222000b7c339SAmerigo Wang 	size_t left;
222100b7c339SAmerigo Wang 	char *kbuf;
22221da177e4SLinus Torvalds 
222300b7c339SAmerigo Wang 	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
22241da177e4SLinus Torvalds 		*lenp = 0;
22251da177e4SLinus Torvalds 		return 0;
22261da177e4SLinus Torvalds 	}
22271da177e4SLinus Torvalds 
2228fcfbd547SKirill Korotaev 	i = (int *) tbl_data;
22291da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(*i);
22301da177e4SLinus Torvalds 	left = *lenp;
22311da177e4SLinus Torvalds 
22321da177e4SLinus Torvalds 	if (!conv)
22331da177e4SLinus Torvalds 		conv = do_proc_dointvec_conv;
22341da177e4SLinus Torvalds 
223500b7c339SAmerigo Wang 	if (write) {
223600b7c339SAmerigo Wang 		if (left > PAGE_SIZE - 1)
223700b7c339SAmerigo Wang 			left = PAGE_SIZE - 1;
223800b7c339SAmerigo Wang 		page = __get_free_page(GFP_TEMPORARY);
223900b7c339SAmerigo Wang 		kbuf = (char *) page;
224000b7c339SAmerigo Wang 		if (!kbuf)
224100b7c339SAmerigo Wang 			return -ENOMEM;
224200b7c339SAmerigo Wang 		if (copy_from_user(kbuf, buffer, left)) {
224300b7c339SAmerigo Wang 			err = -EFAULT;
224400b7c339SAmerigo Wang 			goto free;
224500b7c339SAmerigo Wang 		}
224600b7c339SAmerigo Wang 		kbuf[left] = 0;
224700b7c339SAmerigo Wang 	}
224800b7c339SAmerigo Wang 
22491da177e4SLinus Torvalds 	for (; left && vleft--; i++, first=0) {
225000b7c339SAmerigo Wang 		unsigned long lval;
225100b7c339SAmerigo Wang 		bool neg;
225200b7c339SAmerigo Wang 
22531da177e4SLinus Torvalds 		if (write) {
225400b7c339SAmerigo Wang 			left -= proc_skip_spaces(&kbuf);
225500b7c339SAmerigo Wang 
2256*563b0467SJ. R. Okajima 			if (!left)
2257*563b0467SJ. R. Okajima 				break;
225800b7c339SAmerigo Wang 			err = proc_get_long(&kbuf, &left, &lval, &neg,
225900b7c339SAmerigo Wang 					     proc_wspace_sep,
226000b7c339SAmerigo Wang 					     sizeof(proc_wspace_sep), NULL);
226100b7c339SAmerigo Wang 			if (err)
22621da177e4SLinus Torvalds 				break;
226300b7c339SAmerigo Wang 			if (conv(&neg, &lval, i, 1, data)) {
226400b7c339SAmerigo Wang 				err = -EINVAL;
226500b7c339SAmerigo Wang 				break;
22661da177e4SLinus Torvalds 			}
22671da177e4SLinus Torvalds 		} else {
226800b7c339SAmerigo Wang 			if (conv(&neg, &lval, i, 0, data)) {
226900b7c339SAmerigo Wang 				err = -EINVAL;
227000b7c339SAmerigo Wang 				break;
227100b7c339SAmerigo Wang 			}
22721da177e4SLinus Torvalds 			if (!first)
227300b7c339SAmerigo Wang 				err = proc_put_char(&buffer, &left, '\t');
227400b7c339SAmerigo Wang 			if (err)
22751da177e4SLinus Torvalds 				break;
227600b7c339SAmerigo Wang 			err = proc_put_long(&buffer, &left, lval, neg);
227700b7c339SAmerigo Wang 			if (err)
227800b7c339SAmerigo Wang 				break;
22791da177e4SLinus Torvalds 		}
22801da177e4SLinus Torvalds 	}
22811da177e4SLinus Torvalds 
228200b7c339SAmerigo Wang 	if (!write && !first && left && !err)
228300b7c339SAmerigo Wang 		err = proc_put_char(&buffer, &left, '\n');
2284*563b0467SJ. R. Okajima 	if (write && !err && left)
228500b7c339SAmerigo Wang 		left -= proc_skip_spaces(&kbuf);
228600b7c339SAmerigo Wang free:
22871da177e4SLinus Torvalds 	if (write) {
228800b7c339SAmerigo Wang 		free_page(page);
228900b7c339SAmerigo Wang 		if (first)
229000b7c339SAmerigo Wang 			return err ? : -EINVAL;
22911da177e4SLinus Torvalds 	}
22921da177e4SLinus Torvalds 	*lenp -= left;
22931da177e4SLinus Torvalds 	*ppos += *lenp;
229400b7c339SAmerigo Wang 	return err;
22951da177e4SLinus Torvalds }
22961da177e4SLinus Torvalds 
22978d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write,
2298fcfbd547SKirill Korotaev 		  void __user *buffer, size_t *lenp, loff_t *ppos,
229900b7c339SAmerigo Wang 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2300fcfbd547SKirill Korotaev 			      int write, void *data),
2301fcfbd547SKirill Korotaev 		  void *data)
2302fcfbd547SKirill Korotaev {
23038d65af78SAlexey Dobriyan 	return __do_proc_dointvec(table->data, table, write,
2304fcfbd547SKirill Korotaev 			buffer, lenp, ppos, conv, data);
2305fcfbd547SKirill Korotaev }
2306fcfbd547SKirill Korotaev 
23071da177e4SLinus Torvalds /**
23081da177e4SLinus Torvalds  * proc_dointvec - read a vector of integers
23091da177e4SLinus Torvalds  * @table: the sysctl table
23101da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
23111da177e4SLinus Torvalds  * @buffer: the user buffer
23121da177e4SLinus Torvalds  * @lenp: the size of the user buffer
23131da177e4SLinus Torvalds  * @ppos: file position
23141da177e4SLinus Torvalds  *
23151da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
23161da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
23171da177e4SLinus Torvalds  *
23181da177e4SLinus Torvalds  * Returns 0 on success.
23191da177e4SLinus Torvalds  */
23208d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write,
23211da177e4SLinus Torvalds 		     void __user *buffer, size_t *lenp, loff_t *ppos)
23221da177e4SLinus Torvalds {
23238d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
23241da177e4SLinus Torvalds 		    	    NULL,NULL);
23251da177e4SLinus Torvalds }
23261da177e4SLinus Torvalds 
232734f5a398STheodore Ts'o /*
232834f5a398STheodore Ts'o  * Taint values can only be increased
232925ddbb18SAndi Kleen  * This means we can safely use a temporary.
233034f5a398STheodore Ts'o  */
23318d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write,
233234f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos)
233334f5a398STheodore Ts'o {
233425ddbb18SAndi Kleen 	struct ctl_table t;
233525ddbb18SAndi Kleen 	unsigned long tmptaint = get_taint();
233625ddbb18SAndi Kleen 	int err;
233734f5a398STheodore Ts'o 
233891fcd412SBastian Blank 	if (write && !capable(CAP_SYS_ADMIN))
233934f5a398STheodore Ts'o 		return -EPERM;
234034f5a398STheodore Ts'o 
234125ddbb18SAndi Kleen 	t = *table;
234225ddbb18SAndi Kleen 	t.data = &tmptaint;
23438d65af78SAlexey Dobriyan 	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
234425ddbb18SAndi Kleen 	if (err < 0)
234525ddbb18SAndi Kleen 		return err;
234625ddbb18SAndi Kleen 
234725ddbb18SAndi Kleen 	if (write) {
234825ddbb18SAndi Kleen 		/*
234925ddbb18SAndi Kleen 		 * Poor man's atomic or. Not worth adding a primitive
235025ddbb18SAndi Kleen 		 * to everyone's atomic.h for this
235125ddbb18SAndi Kleen 		 */
235225ddbb18SAndi Kleen 		int i;
235325ddbb18SAndi Kleen 		for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
235425ddbb18SAndi Kleen 			if ((tmptaint >> i) & 1)
235525ddbb18SAndi Kleen 				add_taint(i);
235625ddbb18SAndi Kleen 		}
235725ddbb18SAndi Kleen 	}
235825ddbb18SAndi Kleen 
235925ddbb18SAndi Kleen 	return err;
236034f5a398STheodore Ts'o }
236134f5a398STheodore Ts'o 
23621da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param {
23631da177e4SLinus Torvalds 	int *min;
23641da177e4SLinus Torvalds 	int *max;
23651da177e4SLinus Torvalds };
23661da177e4SLinus Torvalds 
236700b7c339SAmerigo Wang static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
23681da177e4SLinus Torvalds 					int *valp,
23691da177e4SLinus Torvalds 					int write, void *data)
23701da177e4SLinus Torvalds {
23711da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param *param = data;
23721da177e4SLinus Torvalds 	if (write) {
23731da177e4SLinus Torvalds 		int val = *negp ? -*lvalp : *lvalp;
23741da177e4SLinus Torvalds 		if ((param->min && *param->min > val) ||
23751da177e4SLinus Torvalds 		    (param->max && *param->max < val))
23761da177e4SLinus Torvalds 			return -EINVAL;
23771da177e4SLinus Torvalds 		*valp = val;
23781da177e4SLinus Torvalds 	} else {
23791da177e4SLinus Torvalds 		int val = *valp;
23801da177e4SLinus Torvalds 		if (val < 0) {
238100b7c339SAmerigo Wang 			*negp = true;
23821da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
23831da177e4SLinus Torvalds 		} else {
238400b7c339SAmerigo Wang 			*negp = false;
23851da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
23861da177e4SLinus Torvalds 		}
23871da177e4SLinus Torvalds 	}
23881da177e4SLinus Torvalds 	return 0;
23891da177e4SLinus Torvalds }
23901da177e4SLinus Torvalds 
23911da177e4SLinus Torvalds /**
23921da177e4SLinus Torvalds  * proc_dointvec_minmax - read a vector of integers with min/max values
23931da177e4SLinus Torvalds  * @table: the sysctl table
23941da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
23951da177e4SLinus Torvalds  * @buffer: the user buffer
23961da177e4SLinus Torvalds  * @lenp: the size of the user buffer
23971da177e4SLinus Torvalds  * @ppos: file position
23981da177e4SLinus Torvalds  *
23991da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
24001da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
24011da177e4SLinus Torvalds  *
24021da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
24031da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
24041da177e4SLinus Torvalds  *
24051da177e4SLinus Torvalds  * Returns 0 on success.
24061da177e4SLinus Torvalds  */
24078d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write,
24081da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
24091da177e4SLinus Torvalds {
24101da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param param = {
24111da177e4SLinus Torvalds 		.min = (int *) table->extra1,
24121da177e4SLinus Torvalds 		.max = (int *) table->extra2,
24131da177e4SLinus Torvalds 	};
24148d65af78SAlexey Dobriyan 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
24151da177e4SLinus Torvalds 				do_proc_dointvec_minmax_conv, &param);
24161da177e4SLinus Torvalds }
24171da177e4SLinus Torvalds 
2418d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
24191da177e4SLinus Torvalds 				     void __user *buffer,
24201da177e4SLinus Torvalds 				     size_t *lenp, loff_t *ppos,
24211da177e4SLinus Torvalds 				     unsigned long convmul,
24221da177e4SLinus Torvalds 				     unsigned long convdiv)
24231da177e4SLinus Torvalds {
242400b7c339SAmerigo Wang 	unsigned long *i, *min, *max;
242500b7c339SAmerigo Wang 	int vleft, first = 1, err = 0;
242600b7c339SAmerigo Wang 	unsigned long page = 0;
242700b7c339SAmerigo Wang 	size_t left;
242800b7c339SAmerigo Wang 	char *kbuf;
24291da177e4SLinus Torvalds 
243000b7c339SAmerigo Wang 	if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
24311da177e4SLinus Torvalds 		*lenp = 0;
24321da177e4SLinus Torvalds 		return 0;
24331da177e4SLinus Torvalds 	}
24341da177e4SLinus Torvalds 
2435fcfbd547SKirill Korotaev 	i = (unsigned long *) data;
24361da177e4SLinus Torvalds 	min = (unsigned long *) table->extra1;
24371da177e4SLinus Torvalds 	max = (unsigned long *) table->extra2;
24381da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(unsigned long);
24391da177e4SLinus Torvalds 	left = *lenp;
24401da177e4SLinus Torvalds 
24411da177e4SLinus Torvalds 	if (write) {
244200b7c339SAmerigo Wang 		if (left > PAGE_SIZE - 1)
244300b7c339SAmerigo Wang 			left = PAGE_SIZE - 1;
244400b7c339SAmerigo Wang 		page = __get_free_page(GFP_TEMPORARY);
244500b7c339SAmerigo Wang 		kbuf = (char *) page;
244600b7c339SAmerigo Wang 		if (!kbuf)
244700b7c339SAmerigo Wang 			return -ENOMEM;
244800b7c339SAmerigo Wang 		if (copy_from_user(kbuf, buffer, left)) {
244900b7c339SAmerigo Wang 			err = -EFAULT;
245000b7c339SAmerigo Wang 			goto free;
24511da177e4SLinus Torvalds 		}
245200b7c339SAmerigo Wang 		kbuf[left] = 0;
24531da177e4SLinus Torvalds 	}
24541da177e4SLinus Torvalds 
245500b7c339SAmerigo Wang 	for (; left && vleft--; i++, min++, max++, first=0) {
245600b7c339SAmerigo Wang 		unsigned long val;
245700b7c339SAmerigo Wang 
245800b7c339SAmerigo Wang 		if (write) {
245900b7c339SAmerigo Wang 			bool neg;
246000b7c339SAmerigo Wang 
246100b7c339SAmerigo Wang 			left -= proc_skip_spaces(&kbuf);
246200b7c339SAmerigo Wang 
246300b7c339SAmerigo Wang 			err = proc_get_long(&kbuf, &left, &val, &neg,
246400b7c339SAmerigo Wang 					     proc_wspace_sep,
246500b7c339SAmerigo Wang 					     sizeof(proc_wspace_sep), NULL);
246600b7c339SAmerigo Wang 			if (err)
246700b7c339SAmerigo Wang 				break;
24681da177e4SLinus Torvalds 			if (neg)
24691da177e4SLinus Torvalds 				continue;
24701da177e4SLinus Torvalds 			if ((min && val < *min) || (max && val > *max))
24711da177e4SLinus Torvalds 				continue;
24721da177e4SLinus Torvalds 			*i = val;
24731da177e4SLinus Torvalds 		} else {
247400b7c339SAmerigo Wang 			val = convdiv * (*i) / convmul;
24751da177e4SLinus Torvalds 			if (!first)
247600b7c339SAmerigo Wang 				err = proc_put_char(&buffer, &left, '\t');
247700b7c339SAmerigo Wang 			err = proc_put_long(&buffer, &left, val, false);
247800b7c339SAmerigo Wang 			if (err)
247900b7c339SAmerigo Wang 				break;
24801da177e4SLinus Torvalds 		}
24811da177e4SLinus Torvalds 	}
24821da177e4SLinus Torvalds 
248300b7c339SAmerigo Wang 	if (!write && !first && left && !err)
248400b7c339SAmerigo Wang 		err = proc_put_char(&buffer, &left, '\n');
248500b7c339SAmerigo Wang 	if (write && !err)
248600b7c339SAmerigo Wang 		left -= proc_skip_spaces(&kbuf);
248700b7c339SAmerigo Wang free:
24881da177e4SLinus Torvalds 	if (write) {
248900b7c339SAmerigo Wang 		free_page(page);
249000b7c339SAmerigo Wang 		if (first)
249100b7c339SAmerigo Wang 			return err ? : -EINVAL;
24921da177e4SLinus Torvalds 	}
24931da177e4SLinus Torvalds 	*lenp -= left;
24941da177e4SLinus Torvalds 	*ppos += *lenp;
249500b7c339SAmerigo Wang 	return err;
24961da177e4SLinus Torvalds }
24971da177e4SLinus Torvalds 
2498d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2499fcfbd547SKirill Korotaev 				     void __user *buffer,
2500fcfbd547SKirill Korotaev 				     size_t *lenp, loff_t *ppos,
2501fcfbd547SKirill Korotaev 				     unsigned long convmul,
2502fcfbd547SKirill Korotaev 				     unsigned long convdiv)
2503fcfbd547SKirill Korotaev {
2504fcfbd547SKirill Korotaev 	return __do_proc_doulongvec_minmax(table->data, table, write,
25058d65af78SAlexey Dobriyan 			buffer, lenp, ppos, convmul, convdiv);
2506fcfbd547SKirill Korotaev }
2507fcfbd547SKirill Korotaev 
25081da177e4SLinus Torvalds /**
25091da177e4SLinus Torvalds  * proc_doulongvec_minmax - read a vector of long integers with min/max values
25101da177e4SLinus Torvalds  * @table: the sysctl table
25111da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25121da177e4SLinus Torvalds  * @buffer: the user buffer
25131da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25141da177e4SLinus Torvalds  * @ppos: file position
25151da177e4SLinus Torvalds  *
25161da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
25171da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25181da177e4SLinus Torvalds  *
25191da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
25201da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
25211da177e4SLinus Torvalds  *
25221da177e4SLinus Torvalds  * Returns 0 on success.
25231da177e4SLinus Torvalds  */
25248d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write,
25251da177e4SLinus Torvalds 			   void __user *buffer, size_t *lenp, loff_t *ppos)
25261da177e4SLinus Torvalds {
25278d65af78SAlexey Dobriyan     return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
25281da177e4SLinus Torvalds }
25291da177e4SLinus Torvalds 
25301da177e4SLinus Torvalds /**
25311da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
25321da177e4SLinus Torvalds  * @table: the sysctl table
25331da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25341da177e4SLinus Torvalds  * @buffer: the user buffer
25351da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25361da177e4SLinus Torvalds  * @ppos: file position
25371da177e4SLinus Torvalds  *
25381da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
25391da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string. The values
25401da177e4SLinus Torvalds  * are treated as milliseconds, and converted to jiffies when they are stored.
25411da177e4SLinus Torvalds  *
25421da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
25431da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
25441da177e4SLinus Torvalds  *
25451da177e4SLinus Torvalds  * Returns 0 on success.
25461da177e4SLinus Torvalds  */
2547d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
25481da177e4SLinus Torvalds 				      void __user *buffer,
25491da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
25501da177e4SLinus Torvalds {
25518d65af78SAlexey Dobriyan     return do_proc_doulongvec_minmax(table, write, buffer,
25521da177e4SLinus Torvalds 				     lenp, ppos, HZ, 1000l);
25531da177e4SLinus Torvalds }
25541da177e4SLinus Torvalds 
25551da177e4SLinus Torvalds 
255600b7c339SAmerigo Wang static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
25571da177e4SLinus Torvalds 					 int *valp,
25581da177e4SLinus Torvalds 					 int write, void *data)
25591da177e4SLinus Torvalds {
25601da177e4SLinus Torvalds 	if (write) {
2561cba9f33dSBart Samwel 		if (*lvalp > LONG_MAX / HZ)
2562cba9f33dSBart Samwel 			return 1;
25631da177e4SLinus Torvalds 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
25641da177e4SLinus Torvalds 	} else {
25651da177e4SLinus Torvalds 		int val = *valp;
25661da177e4SLinus Torvalds 		unsigned long lval;
25671da177e4SLinus Torvalds 		if (val < 0) {
256800b7c339SAmerigo Wang 			*negp = true;
25691da177e4SLinus Torvalds 			lval = (unsigned long)-val;
25701da177e4SLinus Torvalds 		} else {
257100b7c339SAmerigo Wang 			*negp = false;
25721da177e4SLinus Torvalds 			lval = (unsigned long)val;
25731da177e4SLinus Torvalds 		}
25741da177e4SLinus Torvalds 		*lvalp = lval / HZ;
25751da177e4SLinus Torvalds 	}
25761da177e4SLinus Torvalds 	return 0;
25771da177e4SLinus Torvalds }
25781da177e4SLinus Torvalds 
257900b7c339SAmerigo Wang static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
25801da177e4SLinus Torvalds 						int *valp,
25811da177e4SLinus Torvalds 						int write, void *data)
25821da177e4SLinus Torvalds {
25831da177e4SLinus Torvalds 	if (write) {
2584cba9f33dSBart Samwel 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2585cba9f33dSBart Samwel 			return 1;
25861da177e4SLinus Torvalds 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
25871da177e4SLinus Torvalds 	} else {
25881da177e4SLinus Torvalds 		int val = *valp;
25891da177e4SLinus Torvalds 		unsigned long lval;
25901da177e4SLinus Torvalds 		if (val < 0) {
259100b7c339SAmerigo Wang 			*negp = true;
25921da177e4SLinus Torvalds 			lval = (unsigned long)-val;
25931da177e4SLinus Torvalds 		} else {
259400b7c339SAmerigo Wang 			*negp = false;
25951da177e4SLinus Torvalds 			lval = (unsigned long)val;
25961da177e4SLinus Torvalds 		}
25971da177e4SLinus Torvalds 		*lvalp = jiffies_to_clock_t(lval);
25981da177e4SLinus Torvalds 	}
25991da177e4SLinus Torvalds 	return 0;
26001da177e4SLinus Torvalds }
26011da177e4SLinus Torvalds 
260200b7c339SAmerigo Wang static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
26031da177e4SLinus Torvalds 					    int *valp,
26041da177e4SLinus Torvalds 					    int write, void *data)
26051da177e4SLinus Torvalds {
26061da177e4SLinus Torvalds 	if (write) {
26071da177e4SLinus Torvalds 		*valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
26081da177e4SLinus Torvalds 	} else {
26091da177e4SLinus Torvalds 		int val = *valp;
26101da177e4SLinus Torvalds 		unsigned long lval;
26111da177e4SLinus Torvalds 		if (val < 0) {
261200b7c339SAmerigo Wang 			*negp = true;
26131da177e4SLinus Torvalds 			lval = (unsigned long)-val;
26141da177e4SLinus Torvalds 		} else {
261500b7c339SAmerigo Wang 			*negp = false;
26161da177e4SLinus Torvalds 			lval = (unsigned long)val;
26171da177e4SLinus Torvalds 		}
26181da177e4SLinus Torvalds 		*lvalp = jiffies_to_msecs(lval);
26191da177e4SLinus Torvalds 	}
26201da177e4SLinus Torvalds 	return 0;
26211da177e4SLinus Torvalds }
26221da177e4SLinus Torvalds 
26231da177e4SLinus Torvalds /**
26241da177e4SLinus Torvalds  * proc_dointvec_jiffies - read a vector of integers as seconds
26251da177e4SLinus Torvalds  * @table: the sysctl table
26261da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
26271da177e4SLinus Torvalds  * @buffer: the user buffer
26281da177e4SLinus Torvalds  * @lenp: the size of the user buffer
26291da177e4SLinus Torvalds  * @ppos: file position
26301da177e4SLinus Torvalds  *
26311da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
26321da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
26331da177e4SLinus Torvalds  * The values read are assumed to be in seconds, and are converted into
26341da177e4SLinus Torvalds  * jiffies.
26351da177e4SLinus Torvalds  *
26361da177e4SLinus Torvalds  * Returns 0 on success.
26371da177e4SLinus Torvalds  */
26388d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write,
26391da177e4SLinus Torvalds 			  void __user *buffer, size_t *lenp, loff_t *ppos)
26401da177e4SLinus Torvalds {
26418d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
26421da177e4SLinus Torvalds 		    	    do_proc_dointvec_jiffies_conv,NULL);
26431da177e4SLinus Torvalds }
26441da177e4SLinus Torvalds 
26451da177e4SLinus Torvalds /**
26461da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
26471da177e4SLinus Torvalds  * @table: the sysctl table
26481da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
26491da177e4SLinus Torvalds  * @buffer: the user buffer
26501da177e4SLinus Torvalds  * @lenp: the size of the user buffer
26511e5d5331SRandy Dunlap  * @ppos: pointer to the file position
26521da177e4SLinus Torvalds  *
26531da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
26541da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
26551da177e4SLinus Torvalds  * The values read are assumed to be in 1/USER_HZ seconds, and
26561da177e4SLinus Torvalds  * are converted into jiffies.
26571da177e4SLinus Torvalds  *
26581da177e4SLinus Torvalds  * Returns 0 on success.
26591da177e4SLinus Torvalds  */
26608d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
26611da177e4SLinus Torvalds 				 void __user *buffer, size_t *lenp, loff_t *ppos)
26621da177e4SLinus Torvalds {
26638d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
26641da177e4SLinus Torvalds 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
26651da177e4SLinus Torvalds }
26661da177e4SLinus Torvalds 
26671da177e4SLinus Torvalds /**
26681da177e4SLinus Torvalds  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
26691da177e4SLinus Torvalds  * @table: the sysctl table
26701da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
26711da177e4SLinus Torvalds  * @buffer: the user buffer
26721da177e4SLinus Torvalds  * @lenp: the size of the user buffer
267367be2dd1SMartin Waitz  * @ppos: file position
267467be2dd1SMartin Waitz  * @ppos: the current position in the file
26751da177e4SLinus Torvalds  *
26761da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
26771da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
26781da177e4SLinus Torvalds  * The values read are assumed to be in 1/1000 seconds, and
26791da177e4SLinus Torvalds  * are converted into jiffies.
26801da177e4SLinus Torvalds  *
26811da177e4SLinus Torvalds  * Returns 0 on success.
26821da177e4SLinus Torvalds  */
26838d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
26841da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
26851da177e4SLinus Torvalds {
26868d65af78SAlexey Dobriyan 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
26871da177e4SLinus Torvalds 				do_proc_dointvec_ms_jiffies_conv, NULL);
26881da177e4SLinus Torvalds }
26891da177e4SLinus Torvalds 
26908d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write,
26919ec52099SCedric Le Goater 			   void __user *buffer, size_t *lenp, loff_t *ppos)
26929ec52099SCedric Le Goater {
26939ec52099SCedric Le Goater 	struct pid *new_pid;
26949ec52099SCedric Le Goater 	pid_t tmp;
26959ec52099SCedric Le Goater 	int r;
26969ec52099SCedric Le Goater 
26976c5f3e7bSPavel Emelyanov 	tmp = pid_vnr(cad_pid);
26989ec52099SCedric Le Goater 
26998d65af78SAlexey Dobriyan 	r = __do_proc_dointvec(&tmp, table, write, buffer,
27009ec52099SCedric Le Goater 			       lenp, ppos, NULL, NULL);
27019ec52099SCedric Le Goater 	if (r || !write)
27029ec52099SCedric Le Goater 		return r;
27039ec52099SCedric Le Goater 
27049ec52099SCedric Le Goater 	new_pid = find_get_pid(tmp);
27059ec52099SCedric Le Goater 	if (!new_pid)
27069ec52099SCedric Le Goater 		return -ESRCH;
27079ec52099SCedric Le Goater 
27089ec52099SCedric Le Goater 	put_pid(xchg(&cad_pid, new_pid));
27099ec52099SCedric Le Goater 	return 0;
27109ec52099SCedric Le Goater }
27119ec52099SCedric Le Goater 
27129f977fb7SOctavian Purdila /**
27139f977fb7SOctavian Purdila  * proc_do_large_bitmap - read/write from/to a large bitmap
27149f977fb7SOctavian Purdila  * @table: the sysctl table
27159f977fb7SOctavian Purdila  * @write: %TRUE if this is a write to the sysctl file
27169f977fb7SOctavian Purdila  * @buffer: the user buffer
27179f977fb7SOctavian Purdila  * @lenp: the size of the user buffer
27189f977fb7SOctavian Purdila  * @ppos: file position
27199f977fb7SOctavian Purdila  *
27209f977fb7SOctavian Purdila  * The bitmap is stored at table->data and the bitmap length (in bits)
27219f977fb7SOctavian Purdila  * in table->maxlen.
27229f977fb7SOctavian Purdila  *
27239f977fb7SOctavian Purdila  * We use a range comma separated format (e.g. 1,3-4,10-10) so that
27249f977fb7SOctavian Purdila  * large bitmaps may be represented in a compact manner. Writing into
27259f977fb7SOctavian Purdila  * the file will clear the bitmap then update it with the given input.
27269f977fb7SOctavian Purdila  *
27279f977fb7SOctavian Purdila  * Returns 0 on success.
27289f977fb7SOctavian Purdila  */
27299f977fb7SOctavian Purdila int proc_do_large_bitmap(struct ctl_table *table, int write,
27309f977fb7SOctavian Purdila 			 void __user *buffer, size_t *lenp, loff_t *ppos)
27319f977fb7SOctavian Purdila {
27329f977fb7SOctavian Purdila 	int err = 0;
27339f977fb7SOctavian Purdila 	bool first = 1;
27349f977fb7SOctavian Purdila 	size_t left = *lenp;
27359f977fb7SOctavian Purdila 	unsigned long bitmap_len = table->maxlen;
27369f977fb7SOctavian Purdila 	unsigned long *bitmap = (unsigned long *) table->data;
27379f977fb7SOctavian Purdila 	unsigned long *tmp_bitmap = NULL;
27389f977fb7SOctavian Purdila 	char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
27399f977fb7SOctavian Purdila 
27409f977fb7SOctavian Purdila 	if (!bitmap_len || !left || (*ppos && !write)) {
27419f977fb7SOctavian Purdila 		*lenp = 0;
27429f977fb7SOctavian Purdila 		return 0;
27439f977fb7SOctavian Purdila 	}
27449f977fb7SOctavian Purdila 
27459f977fb7SOctavian Purdila 	if (write) {
27469f977fb7SOctavian Purdila 		unsigned long page = 0;
27479f977fb7SOctavian Purdila 		char *kbuf;
27489f977fb7SOctavian Purdila 
27499f977fb7SOctavian Purdila 		if (left > PAGE_SIZE - 1)
27509f977fb7SOctavian Purdila 			left = PAGE_SIZE - 1;
27519f977fb7SOctavian Purdila 
27529f977fb7SOctavian Purdila 		page = __get_free_page(GFP_TEMPORARY);
27539f977fb7SOctavian Purdila 		kbuf = (char *) page;
27549f977fb7SOctavian Purdila 		if (!kbuf)
27559f977fb7SOctavian Purdila 			return -ENOMEM;
27569f977fb7SOctavian Purdila 		if (copy_from_user(kbuf, buffer, left)) {
27579f977fb7SOctavian Purdila 			free_page(page);
27589f977fb7SOctavian Purdila 			return -EFAULT;
27599f977fb7SOctavian Purdila                 }
27609f977fb7SOctavian Purdila 		kbuf[left] = 0;
27619f977fb7SOctavian Purdila 
27629f977fb7SOctavian Purdila 		tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
27639f977fb7SOctavian Purdila 				     GFP_KERNEL);
27649f977fb7SOctavian Purdila 		if (!tmp_bitmap) {
27659f977fb7SOctavian Purdila 			free_page(page);
27669f977fb7SOctavian Purdila 			return -ENOMEM;
27679f977fb7SOctavian Purdila 		}
27689f977fb7SOctavian Purdila 		proc_skip_char(&kbuf, &left, '\n');
27699f977fb7SOctavian Purdila 		while (!err && left) {
27709f977fb7SOctavian Purdila 			unsigned long val_a, val_b;
27719f977fb7SOctavian Purdila 			bool neg;
27729f977fb7SOctavian Purdila 
27739f977fb7SOctavian Purdila 			err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
27749f977fb7SOctavian Purdila 					     sizeof(tr_a), &c);
27759f977fb7SOctavian Purdila 			if (err)
27769f977fb7SOctavian Purdila 				break;
27779f977fb7SOctavian Purdila 			if (val_a >= bitmap_len || neg) {
27789f977fb7SOctavian Purdila 				err = -EINVAL;
27799f977fb7SOctavian Purdila 				break;
27809f977fb7SOctavian Purdila 			}
27819f977fb7SOctavian Purdila 
27829f977fb7SOctavian Purdila 			val_b = val_a;
27839f977fb7SOctavian Purdila 			if (left) {
27849f977fb7SOctavian Purdila 				kbuf++;
27859f977fb7SOctavian Purdila 				left--;
27869f977fb7SOctavian Purdila 			}
27879f977fb7SOctavian Purdila 
27889f977fb7SOctavian Purdila 			if (c == '-') {
27899f977fb7SOctavian Purdila 				err = proc_get_long(&kbuf, &left, &val_b,
27909f977fb7SOctavian Purdila 						     &neg, tr_b, sizeof(tr_b),
27919f977fb7SOctavian Purdila 						     &c);
27929f977fb7SOctavian Purdila 				if (err)
27939f977fb7SOctavian Purdila 					break;
27949f977fb7SOctavian Purdila 				if (val_b >= bitmap_len || neg ||
27959f977fb7SOctavian Purdila 				    val_a > val_b) {
27969f977fb7SOctavian Purdila 					err = -EINVAL;
27979f977fb7SOctavian Purdila 					break;
27989f977fb7SOctavian Purdila 				}
27999f977fb7SOctavian Purdila 				if (left) {
28009f977fb7SOctavian Purdila 					kbuf++;
28019f977fb7SOctavian Purdila 					left--;
28029f977fb7SOctavian Purdila 				}
28039f977fb7SOctavian Purdila 			}
28049f977fb7SOctavian Purdila 
28059f977fb7SOctavian Purdila 			while (val_a <= val_b)
28069f977fb7SOctavian Purdila 				set_bit(val_a++, tmp_bitmap);
28079f977fb7SOctavian Purdila 
28089f977fb7SOctavian Purdila 			first = 0;
28099f977fb7SOctavian Purdila 			proc_skip_char(&kbuf, &left, '\n');
28109f977fb7SOctavian Purdila 		}
28119f977fb7SOctavian Purdila 		free_page(page);
28129f977fb7SOctavian Purdila 	} else {
28139f977fb7SOctavian Purdila 		unsigned long bit_a, bit_b = 0;
28149f977fb7SOctavian Purdila 
28159f977fb7SOctavian Purdila 		while (left) {
28169f977fb7SOctavian Purdila 			bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
28179f977fb7SOctavian Purdila 			if (bit_a >= bitmap_len)
28189f977fb7SOctavian Purdila 				break;
28199f977fb7SOctavian Purdila 			bit_b = find_next_zero_bit(bitmap, bitmap_len,
28209f977fb7SOctavian Purdila 						   bit_a + 1) - 1;
28219f977fb7SOctavian Purdila 
28229f977fb7SOctavian Purdila 			if (!first) {
28239f977fb7SOctavian Purdila 				err = proc_put_char(&buffer, &left, ',');
28249f977fb7SOctavian Purdila 				if (err)
28259f977fb7SOctavian Purdila 					break;
28269f977fb7SOctavian Purdila 			}
28279f977fb7SOctavian Purdila 			err = proc_put_long(&buffer, &left, bit_a, false);
28289f977fb7SOctavian Purdila 			if (err)
28299f977fb7SOctavian Purdila 				break;
28309f977fb7SOctavian Purdila 			if (bit_a != bit_b) {
28319f977fb7SOctavian Purdila 				err = proc_put_char(&buffer, &left, '-');
28329f977fb7SOctavian Purdila 				if (err)
28339f977fb7SOctavian Purdila 					break;
28349f977fb7SOctavian Purdila 				err = proc_put_long(&buffer, &left, bit_b, false);
28359f977fb7SOctavian Purdila 				if (err)
28369f977fb7SOctavian Purdila 					break;
28379f977fb7SOctavian Purdila 			}
28389f977fb7SOctavian Purdila 
28399f977fb7SOctavian Purdila 			first = 0; bit_b++;
28409f977fb7SOctavian Purdila 		}
28419f977fb7SOctavian Purdila 		if (!err)
28429f977fb7SOctavian Purdila 			err = proc_put_char(&buffer, &left, '\n');
28439f977fb7SOctavian Purdila 	}
28449f977fb7SOctavian Purdila 
28459f977fb7SOctavian Purdila 	if (!err) {
28469f977fb7SOctavian Purdila 		if (write) {
28479f977fb7SOctavian Purdila 			if (*ppos)
28489f977fb7SOctavian Purdila 				bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
28499f977fb7SOctavian Purdila 			else
28509f977fb7SOctavian Purdila 				memcpy(bitmap, tmp_bitmap,
28519f977fb7SOctavian Purdila 					BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long));
28529f977fb7SOctavian Purdila 		}
28539f977fb7SOctavian Purdila 		kfree(tmp_bitmap);
28549f977fb7SOctavian Purdila 		*lenp -= left;
28559f977fb7SOctavian Purdila 		*ppos += *lenp;
28569f977fb7SOctavian Purdila 		return 0;
28579f977fb7SOctavian Purdila 	} else {
28589f977fb7SOctavian Purdila 		kfree(tmp_bitmap);
28599f977fb7SOctavian Purdila 		return err;
28609f977fb7SOctavian Purdila 	}
28619f977fb7SOctavian Purdila }
28629f977fb7SOctavian Purdila 
28631da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */
28641da177e4SLinus Torvalds 
28658d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write,
28661da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
28671da177e4SLinus Torvalds {
28681da177e4SLinus Torvalds 	return -ENOSYS;
28691da177e4SLinus Torvalds }
28701da177e4SLinus Torvalds 
28718d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write,
28721da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
28731da177e4SLinus Torvalds {
28741da177e4SLinus Torvalds 	return -ENOSYS;
28751da177e4SLinus Torvalds }
28761da177e4SLinus Torvalds 
28778d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write,
28781da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
28791da177e4SLinus Torvalds {
28801da177e4SLinus Torvalds 	return -ENOSYS;
28811da177e4SLinus Torvalds }
28821da177e4SLinus Torvalds 
28838d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write,
28841da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
28851da177e4SLinus Torvalds {
28861da177e4SLinus Torvalds 	return -ENOSYS;
28871da177e4SLinus Torvalds }
28881da177e4SLinus Torvalds 
28898d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
28901da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
28911da177e4SLinus Torvalds {
28921da177e4SLinus Torvalds 	return -ENOSYS;
28931da177e4SLinus Torvalds }
28941da177e4SLinus Torvalds 
28958d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
28961da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
28971da177e4SLinus Torvalds {
28981da177e4SLinus Torvalds 	return -ENOSYS;
28991da177e4SLinus Torvalds }
29001da177e4SLinus Torvalds 
29018d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write,
29021da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
29031da177e4SLinus Torvalds {
29041da177e4SLinus Torvalds 	return -ENOSYS;
29051da177e4SLinus Torvalds }
29061da177e4SLinus Torvalds 
2907d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
29081da177e4SLinus Torvalds 				      void __user *buffer,
29091da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
29101da177e4SLinus Torvalds {
29111da177e4SLinus Torvalds     return -ENOSYS;
29121da177e4SLinus Torvalds }
29131da177e4SLinus Torvalds 
29141da177e4SLinus Torvalds 
29151da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */
29161da177e4SLinus Torvalds 
29171da177e4SLinus Torvalds /*
29181da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
29191da177e4SLinus Torvalds  * exception granted :-)
29201da177e4SLinus Torvalds  */
29211da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
29221da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
29231da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
29241da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
29251da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
29261da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
29271da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
29281da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
29291da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table);
293029e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths);
29311da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table);
2932