xref: /openbmc/linux/kernel/sysctl.c (revision ff9da691c0498ff81fdd014e7a0731dab2337dac)
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>
4076ab0f53SMel Gorman #include <linux/compaction.h>
411da177e4SLinus Torvalds #include <linux/hugetlb.h>
421da177e4SLinus Torvalds #include <linux/initrd.h>
430b77f5bfSDavid Howells #include <linux/key.h>
441da177e4SLinus Torvalds #include <linux/times.h>
451da177e4SLinus Torvalds #include <linux/limits.h>
461da177e4SLinus Torvalds #include <linux/dcache.h>
471da177e4SLinus Torvalds #include <linux/syscalls.h>
48c748e134SAdrian Bunk #include <linux/vmstat.h>
49c255d844SPavel Machek #include <linux/nfs_fs.h>
50c255d844SPavel Machek #include <linux/acpi.h>
5110a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h>
52b0fc494fSSteven Rostedt #include <linux/ftrace.h>
5312e22c5eSDavid Howells #include <linux/slow-work.h>
54cdd6c482SIngo Molnar #include <linux/perf_event.h>
55b2be84dfSMasami Hiramatsu #include <linux/kprobes.h>
56b492e95bSJens Axboe #include <linux/pipe_fs_i.h>
571da177e4SLinus Torvalds 
581da177e4SLinus Torvalds #include <asm/uaccess.h>
591da177e4SLinus Torvalds #include <asm/processor.h>
601da177e4SLinus Torvalds 
6129cbc78bSAndi Kleen #ifdef CONFIG_X86
6229cbc78bSAndi Kleen #include <asm/nmi.h>
630741f4d2SChuck Ebbert #include <asm/stacktrace.h>
646e7c4025SIngo Molnar #include <asm/io.h>
6529cbc78bSAndi Kleen #endif
66c55b7c3eSDave Young #ifdef CONFIG_BSD_PROCESS_ACCT
67c55b7c3eSDave Young #include <linux/acct.h>
68c55b7c3eSDave Young #endif
694f0e056fSDave Young #ifdef CONFIG_RT_MUTEXES
704f0e056fSDave Young #include <linux/rtmutex.h>
714f0e056fSDave Young #endif
722edf5e49SDave Young #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
732edf5e49SDave Young #include <linux/lockdep.h>
742edf5e49SDave Young #endif
7515485a46SDave Young #ifdef CONFIG_CHR_DEV_SG
7615485a46SDave Young #include <scsi/sg.h>
7715485a46SDave Young #endif
7829cbc78bSAndi Kleen 
797058cb02SEric W. Biederman 
801da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL)
811da177e4SLinus Torvalds 
821da177e4SLinus Torvalds /* External variables not in a header file. */
831da177e4SLinus Torvalds extern int sysctl_overcommit_memory;
841da177e4SLinus Torvalds extern int sysctl_overcommit_ratio;
85fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom;
86fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task;
87fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks;
881da177e4SLinus Torvalds extern int max_threads;
891da177e4SLinus Torvalds extern int core_uses_pid;
90d6e71144SAlan Cox extern int suid_dumpable;
911da177e4SLinus Torvalds extern char core_pattern[];
92a293980cSNeil Horman extern unsigned int core_pipe_limit;
931da177e4SLinus Torvalds extern int pid_max;
941da177e4SLinus Torvalds extern int min_free_kbytes;
951da177e4SLinus Torvalds extern int pid_max_min, pid_max_max;
969d0243bcSAndrew Morton extern int sysctl_drop_caches;
978ad4b1fbSRohit Seth extern int percpu_pagelist_fraction;
98bebfa101SAndi Kleen extern int compat_log;
999745512cSArjan van de Ven extern int latencytop_enabled;
100eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max;
101dd8632a1SPaul Mundt #ifndef CONFIG_MMU
102dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages;
103dd8632a1SPaul Mundt #endif
104cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
1055e605b64SJens Axboe extern int blk_iopoll_enabled;
106cb684b5bSJens Axboe #endif
1071da177e4SLinus Torvalds 
108c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and  maximum */
109195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP
110c4f3b63fSRavikiran G Thirumalai static int sixty = 60;
1119383d967SDimitri Sivanich static int neg_one = -1;
112c4f3b63fSRavikiran G Thirumalai #endif
113c4f3b63fSRavikiran G Thirumalai 
114c4f3b63fSRavikiran G Thirumalai static int zero;
115cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1;
116cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2;
117fc3501d4SSven Wegener static unsigned long one_ul = 1;
118c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100;
119af91322eSDave Young #ifdef CONFIG_PRINTK
120af91322eSDave Young static int ten_thousand = 10000;
121af91322eSDave Young #endif
122c4f3b63fSRavikiran G Thirumalai 
1239e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
1249e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1259e4a5bdaSAndrea Righi 
1261da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1271da177e4SLinus Torvalds static int maxolduid = 65535;
1281da177e4SLinus Torvalds static int minolduid;
1298ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8;
1301da177e4SLinus Torvalds 
1311da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
1321da177e4SLinus Torvalds 
13372c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
13417f04fbbSDavid S. Miller #include <asm/system.h>
1351da177e4SLinus Torvalds #endif
1361da177e4SLinus Torvalds 
1370871420fSDavid S. Miller #ifdef CONFIG_SPARC64
1380871420fSDavid S. Miller extern int sysctl_tsb_ratio;
1390871420fSDavid S. Miller #endif
1400871420fSDavid S. Miller 
1411da177e4SLinus Torvalds #ifdef __hppa__
1421da177e4SLinus Torvalds extern int pwrsw_enabled;
1431da177e4SLinus Torvalds extern int unaligned_enabled;
1441da177e4SLinus Torvalds #endif
1451da177e4SLinus Torvalds 
146347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
1471da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
1481da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings;
1491da177e4SLinus Torvalds #endif
1501da177e4SLinus Torvalds extern int sysctl_userprocess_debug;
151951f22d5SMartin Schwidefsky extern int spin_retry;
1521da177e4SLinus Torvalds #endif
1531da177e4SLinus Torvalds 
154d2b176edSJes Sorensen #ifdef CONFIG_IA64
155d2b176edSJes Sorensen extern int no_unaligned_warning;
15688fc241fSDoug Chapman extern int unaligned_dump_stack;
157d2b176edSJes Sorensen #endif
158d2b176edSJes Sorensen 
1593fff4c42SIngo Molnar extern struct ratelimit_state printk_ratelimit_state;
1603fff4c42SIngo Molnar 
161d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
1628d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write,
1639ec52099SCedric Le Goater 		  void __user *buffer, size_t *lenp, loff_t *ppos);
1648d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write,
16534f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos);
166d6f8ff73SRandy Dunlap #endif
1679ec52099SCedric Le Goater 
16897f5f0cdSDmitry Torokhov #ifdef CONFIG_MAGIC_SYSRQ
16997f5f0cdSDmitry Torokhov static int __sysrq_enabled; /* Note: sysrq code ises it's own private copy */
17097f5f0cdSDmitry Torokhov 
17197f5f0cdSDmitry Torokhov static int sysrq_sysctl_handler(ctl_table *table, int write,
17297f5f0cdSDmitry Torokhov 				void __user *buffer, size_t *lenp,
17397f5f0cdSDmitry Torokhov 				loff_t *ppos)
17497f5f0cdSDmitry Torokhov {
17597f5f0cdSDmitry Torokhov 	int error;
17697f5f0cdSDmitry Torokhov 
17797f5f0cdSDmitry Torokhov 	error = proc_dointvec(table, write, buffer, lenp, ppos);
17897f5f0cdSDmitry Torokhov 	if (error)
17997f5f0cdSDmitry Torokhov 		return error;
18097f5f0cdSDmitry Torokhov 
18197f5f0cdSDmitry Torokhov 	if (write)
18297f5f0cdSDmitry Torokhov 		sysrq_toggle_support(__sysrq_enabled);
18397f5f0cdSDmitry Torokhov 
18497f5f0cdSDmitry Torokhov 	return 0;
18597f5f0cdSDmitry Torokhov }
18697f5f0cdSDmitry Torokhov 
18797f5f0cdSDmitry Torokhov #endif
18897f5f0cdSDmitry Torokhov 
189d8217f07SEric W. Biederman static struct ctl_table root_table[];
190e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root;
191e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = {
192b380b0d4SAl Viro 	.count = 1,
193e51b6ba0SEric W. Biederman 	.ctl_table = root_table,
19473455092SAl Viro 	.ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
195e51b6ba0SEric W. Biederman 	.root = &sysctl_table_root,
19673455092SAl Viro 	.set = &sysctl_table_root.default_set,
197e51b6ba0SEric W. Biederman };
198e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = {
199e51b6ba0SEric W. Biederman 	.root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
20073455092SAl Viro 	.default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
201e51b6ba0SEric W. Biederman };
2021da177e4SLinus Torvalds 
203d8217f07SEric W. Biederman static struct ctl_table kern_table[];
204d8217f07SEric W. Biederman static struct ctl_table vm_table[];
205d8217f07SEric W. Biederman static struct ctl_table fs_table[];
206d8217f07SEric W. Biederman static struct ctl_table debug_table[];
207d8217f07SEric W. Biederman static struct ctl_table dev_table[];
208d8217f07SEric W. Biederman extern struct ctl_table random_table[];
2092d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
210d8217f07SEric W. Biederman extern struct ctl_table inotify_table[];
2110399cb08SRobert Love #endif
2127ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
2137ef9964eSDavide Libenzi extern struct ctl_table epoll_table[];
2147ef9964eSDavide Libenzi #endif
2151da177e4SLinus Torvalds 
2161da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
2171da177e4SLinus Torvalds int sysctl_legacy_va_layout;
2181da177e4SLinus Torvalds #endif
2191da177e4SLinus Torvalds 
2201da177e4SLinus Torvalds /* The default sysctl tables: */
2211da177e4SLinus Torvalds 
222d8217f07SEric W. Biederman static struct ctl_table root_table[] = {
2231da177e4SLinus Torvalds 	{
2241da177e4SLinus Torvalds 		.procname	= "kernel",
2251da177e4SLinus Torvalds 		.mode		= 0555,
2261da177e4SLinus Torvalds 		.child		= kern_table,
2271da177e4SLinus Torvalds 	},
2281da177e4SLinus Torvalds 	{
2291da177e4SLinus Torvalds 		.procname	= "vm",
2301da177e4SLinus Torvalds 		.mode		= 0555,
2311da177e4SLinus Torvalds 		.child		= vm_table,
2321da177e4SLinus Torvalds 	},
2331da177e4SLinus Torvalds 	{
2341da177e4SLinus Torvalds 		.procname	= "fs",
2351da177e4SLinus Torvalds 		.mode		= 0555,
2361da177e4SLinus Torvalds 		.child		= fs_table,
2371da177e4SLinus Torvalds 	},
2381da177e4SLinus Torvalds 	{
2391da177e4SLinus Torvalds 		.procname	= "debug",
2401da177e4SLinus Torvalds 		.mode		= 0555,
2411da177e4SLinus Torvalds 		.child		= debug_table,
2421da177e4SLinus Torvalds 	},
2431da177e4SLinus Torvalds 	{
2441da177e4SLinus Torvalds 		.procname	= "dev",
2451da177e4SLinus Torvalds 		.mode		= 0555,
2461da177e4SLinus Torvalds 		.child		= dev_table,
2471da177e4SLinus Torvalds 	},
2482be7fe07SAndrew Morton /*
2492be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
2502be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
2512be7fe07SAndrew Morton  */
2526fce56ecSEric W. Biederman 	{ }
2531da177e4SLinus Torvalds };
2541da177e4SLinus Torvalds 
25577e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
25673c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000;		/* 100 usecs */
25773c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
25873c4efd2SEric Dumazet static int min_wakeup_granularity_ns;			/* 0 usecs */
25973c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
2601983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
2611983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
262acb4a848SChristian Ehrhardt static int min_sched_shares_ratelimit = 100000; /* 100 usec */
263acb4a848SChristian Ehrhardt static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
26477e54a1fSIngo Molnar #endif
26577e54a1fSIngo Molnar 
2665e771905SMel Gorman #ifdef CONFIG_COMPACTION
2675e771905SMel Gorman static int min_extfrag_threshold;
2685e771905SMel Gorman static int max_extfrag_threshold = 1000;
2695e771905SMel Gorman #endif
2705e771905SMel Gorman 
271d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
2722bba22c5SMike Galbraith 	{
2732bba22c5SMike Galbraith 		.procname	= "sched_child_runs_first",
2742bba22c5SMike Galbraith 		.data		= &sysctl_sched_child_runs_first,
2752bba22c5SMike Galbraith 		.maxlen		= sizeof(unsigned int),
2762bba22c5SMike Galbraith 		.mode		= 0644,
2776d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
2782bba22c5SMike Galbraith 	},
27977e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
28077e54a1fSIngo Molnar 	{
281b2be5e96SPeter Zijlstra 		.procname	= "sched_min_granularity_ns",
282b2be5e96SPeter Zijlstra 		.data		= &sysctl_sched_min_granularity,
28377e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
28477e54a1fSIngo Molnar 		.mode		= 0644,
285702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
286b2be5e96SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
287b2be5e96SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
28877e54a1fSIngo Molnar 	},
28977e54a1fSIngo Molnar 	{
29021805085SPeter Zijlstra 		.procname	= "sched_latency_ns",
29121805085SPeter Zijlstra 		.data		= &sysctl_sched_latency,
29221805085SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
29321805085SPeter Zijlstra 		.mode		= 0644,
294702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
29521805085SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
29621805085SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
29721805085SPeter Zijlstra 	},
29821805085SPeter Zijlstra 	{
29977e54a1fSIngo Molnar 		.procname	= "sched_wakeup_granularity_ns",
30077e54a1fSIngo Molnar 		.data		= &sysctl_sched_wakeup_granularity,
30177e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
30277e54a1fSIngo Molnar 		.mode		= 0644,
303702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
30477e54a1fSIngo Molnar 		.extra1		= &min_wakeup_granularity_ns,
30577e54a1fSIngo Molnar 		.extra2		= &max_wakeup_granularity_ns,
30677e54a1fSIngo Molnar 	},
30777e54a1fSIngo Molnar 	{
3082398f2c6SPeter Zijlstra 		.procname	= "sched_shares_ratelimit",
3092398f2c6SPeter Zijlstra 		.data		= &sysctl_sched_shares_ratelimit,
3102398f2c6SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3112398f2c6SPeter Zijlstra 		.mode		= 0644,
312702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
313acb4a848SChristian Ehrhardt 		.extra1		= &min_sched_shares_ratelimit,
314acb4a848SChristian Ehrhardt 		.extra2		= &max_sched_shares_ratelimit,
3152398f2c6SPeter Zijlstra 	},
3162398f2c6SPeter Zijlstra 	{
3171983a922SChristian Ehrhardt 		.procname	= "sched_tunable_scaling",
3181983a922SChristian Ehrhardt 		.data		= &sysctl_sched_tunable_scaling,
3191983a922SChristian Ehrhardt 		.maxlen		= sizeof(enum sched_tunable_scaling),
3201983a922SChristian Ehrhardt 		.mode		= 0644,
321702a7c76SLinus Torvalds 		.proc_handler	= sched_proc_update_handler,
3221983a922SChristian Ehrhardt 		.extra1		= &min_sched_tunable_scaling,
3231983a922SChristian Ehrhardt 		.extra2		= &max_sched_tunable_scaling,
3242398f2c6SPeter Zijlstra 	},
3252398f2c6SPeter Zijlstra 	{
326ffda12a1SPeter Zijlstra 		.procname	= "sched_shares_thresh",
327ffda12a1SPeter Zijlstra 		.data		= &sysctl_sched_shares_thresh,
328ffda12a1SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
329ffda12a1SPeter Zijlstra 		.mode		= 0644,
3306d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
331ffda12a1SPeter Zijlstra 		.extra1		= &zero,
332ffda12a1SPeter Zijlstra 	},
333ffda12a1SPeter Zijlstra 	{
334da84d961SIngo Molnar 		.procname	= "sched_migration_cost",
335da84d961SIngo Molnar 		.data		= &sysctl_sched_migration_cost,
336da84d961SIngo Molnar 		.maxlen		= sizeof(unsigned int),
337da84d961SIngo Molnar 		.mode		= 0644,
3386d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
339da84d961SIngo Molnar 	},
340b82d9fddSPeter Zijlstra 	{
341b82d9fddSPeter Zijlstra 		.procname	= "sched_nr_migrate",
342b82d9fddSPeter Zijlstra 		.data		= &sysctl_sched_nr_migrate,
343b82d9fddSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
344fa85ae24SPeter Zijlstra 		.mode		= 0644,
3456d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
346fa85ae24SPeter Zijlstra 	},
347cd1bb94bSArun R Bharadwaj 	{
348e9e9250bSPeter Zijlstra 		.procname	= "sched_time_avg",
349e9e9250bSPeter Zijlstra 		.data		= &sysctl_sched_time_avg,
350e9e9250bSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
351e9e9250bSPeter Zijlstra 		.mode		= 0644,
3526d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
353e9e9250bSPeter Zijlstra 	},
354e9e9250bSPeter Zijlstra 	{
355cd1bb94bSArun R Bharadwaj 		.procname	= "timer_migration",
356cd1bb94bSArun R Bharadwaj 		.data		= &sysctl_timer_migration,
357cd1bb94bSArun R Bharadwaj 		.maxlen		= sizeof(unsigned int),
358cd1bb94bSArun R Bharadwaj 		.mode		= 0644,
3596d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
360bfdb4d9fSArun R Bharadwaj 		.extra1		= &zero,
361bfdb4d9fSArun R Bharadwaj 		.extra2		= &one,
362cd1bb94bSArun R Bharadwaj 	},
3631fc84aaaSPeter Zijlstra #endif
3641799e35dSIngo Molnar 	{
3659f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
3669f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
3679f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3689f0c1e56SPeter Zijlstra 		.mode		= 0644,
3696d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
3709f0c1e56SPeter Zijlstra 	},
3719f0c1e56SPeter Zijlstra 	{
3729f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
3739f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
3749f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
3759f0c1e56SPeter Zijlstra 		.mode		= 0644,
3766d456111SEric W. Biederman 		.proc_handler	= sched_rt_handler,
3779f0c1e56SPeter Zijlstra 	},
3789f0c1e56SPeter Zijlstra 	{
3791799e35dSIngo Molnar 		.procname	= "sched_compat_yield",
3801799e35dSIngo Molnar 		.data		= &sysctl_sched_compat_yield,
3811799e35dSIngo Molnar 		.maxlen		= sizeof(unsigned int),
3821799e35dSIngo Molnar 		.mode		= 0644,
3836d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
3841799e35dSIngo Molnar 	},
385f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
386f20786ffSPeter Zijlstra 	{
387f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
388f20786ffSPeter Zijlstra 		.data		= &prove_locking,
389f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
390f20786ffSPeter Zijlstra 		.mode		= 0644,
3916d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
392f20786ffSPeter Zijlstra 	},
393f20786ffSPeter Zijlstra #endif
394f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
395f20786ffSPeter Zijlstra 	{
396f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
397f20786ffSPeter Zijlstra 		.data		= &lock_stat,
398f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
399f20786ffSPeter Zijlstra 		.mode		= 0644,
4006d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
401f20786ffSPeter Zijlstra 	},
402f20786ffSPeter Zijlstra #endif
40377e54a1fSIngo Molnar 	{
4041da177e4SLinus Torvalds 		.procname	= "panic",
4051da177e4SLinus Torvalds 		.data		= &panic_timeout,
4061da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4071da177e4SLinus Torvalds 		.mode		= 0644,
4086d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4091da177e4SLinus Torvalds 	},
4101da177e4SLinus Torvalds 	{
4111da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
4121da177e4SLinus Torvalds 		.data		= &core_uses_pid,
4131da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4141da177e4SLinus Torvalds 		.mode		= 0644,
4156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4161da177e4SLinus Torvalds 	},
4171da177e4SLinus Torvalds 	{
4181da177e4SLinus Torvalds 		.procname	= "core_pattern",
4191da177e4SLinus Torvalds 		.data		= core_pattern,
42071ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
4211da177e4SLinus Torvalds 		.mode		= 0644,
4226d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
4231da177e4SLinus Torvalds 	},
424a293980cSNeil Horman 	{
425a293980cSNeil Horman 		.procname	= "core_pipe_limit",
426a293980cSNeil Horman 		.data		= &core_pipe_limit,
427a293980cSNeil Horman 		.maxlen		= sizeof(unsigned int),
428a293980cSNeil Horman 		.mode		= 0644,
4296d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
430a293980cSNeil Horman 	},
43134f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
4321da177e4SLinus Torvalds 	{
4331da177e4SLinus Torvalds 		.procname	= "tainted",
43425ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
43534f5a398STheodore Ts'o 		.mode		= 0644,
4366d456111SEric W. Biederman 		.proc_handler	= proc_taint,
4371da177e4SLinus Torvalds 	},
43834f5a398STheodore Ts'o #endif
4399745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
4409745512cSArjan van de Ven 	{
4419745512cSArjan van de Ven 		.procname	= "latencytop",
4429745512cSArjan van de Ven 		.data		= &latencytop_enabled,
4439745512cSArjan van de Ven 		.maxlen		= sizeof(int),
4449745512cSArjan van de Ven 		.mode		= 0644,
4456d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4469745512cSArjan van de Ven 	},
4479745512cSArjan van de Ven #endif
4481da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
4491da177e4SLinus Torvalds 	{
4501da177e4SLinus Torvalds 		.procname	= "real-root-dev",
4511da177e4SLinus Torvalds 		.data		= &real_root_dev,
4521da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4531da177e4SLinus Torvalds 		.mode		= 0644,
4546d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4551da177e4SLinus Torvalds 	},
4561da177e4SLinus Torvalds #endif
45745807a1dSIngo Molnar 	{
45845807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
45945807a1dSIngo Molnar 		.data		= &print_fatal_signals,
46045807a1dSIngo Molnar 		.maxlen		= sizeof(int),
46145807a1dSIngo Molnar 		.mode		= 0644,
4626d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
46345807a1dSIngo Molnar 	},
46472c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
4651da177e4SLinus Torvalds 	{
4661da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
4671da177e4SLinus Torvalds 		.data		= reboot_command,
4681da177e4SLinus Torvalds 		.maxlen		= 256,
4691da177e4SLinus Torvalds 		.mode		= 0644,
4706d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
4711da177e4SLinus Torvalds 	},
4721da177e4SLinus Torvalds 	{
4731da177e4SLinus Torvalds 		.procname	= "stop-a",
4741da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
4751da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4761da177e4SLinus Torvalds 		.mode		= 0644,
4776d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4781da177e4SLinus Torvalds 	},
4791da177e4SLinus Torvalds 	{
4801da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
4811da177e4SLinus Torvalds 		.data		= &scons_pwroff,
4821da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4831da177e4SLinus Torvalds 		.mode		= 0644,
4846d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4851da177e4SLinus Torvalds 	},
4861da177e4SLinus Torvalds #endif
4870871420fSDavid S. Miller #ifdef CONFIG_SPARC64
4880871420fSDavid S. Miller 	{
4890871420fSDavid S. Miller 		.procname	= "tsb-ratio",
4900871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
4910871420fSDavid S. Miller 		.maxlen		= sizeof (int),
4920871420fSDavid S. Miller 		.mode		= 0644,
4936d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
4940871420fSDavid S. Miller 	},
4950871420fSDavid S. Miller #endif
4961da177e4SLinus Torvalds #ifdef __hppa__
4971da177e4SLinus Torvalds 	{
4981da177e4SLinus Torvalds 		.procname	= "soft-power",
4991da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
5001da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5011da177e4SLinus Torvalds 	 	.mode		= 0644,
5026d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5031da177e4SLinus Torvalds 	},
5041da177e4SLinus Torvalds 	{
5051da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
5061da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
5071da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5081da177e4SLinus Torvalds 		.mode		= 0644,
5096d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5101da177e4SLinus Torvalds 	},
5111da177e4SLinus Torvalds #endif
5121da177e4SLinus Torvalds 	{
5131da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
5141da177e4SLinus Torvalds 		.data		= &C_A_D,
5151da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5161da177e4SLinus Torvalds 		.mode		= 0644,
5176d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5181da177e4SLinus Torvalds 	},
519606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
520b0fc494fSSteven Rostedt 	{
521b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
522b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
523b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
524b0fc494fSSteven Rostedt 		.mode		= 0644,
5256d456111SEric W. Biederman 		.proc_handler	= ftrace_enable_sysctl,
526b0fc494fSSteven Rostedt 	},
527b0fc494fSSteven Rostedt #endif
528f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
529f38f1d2aSSteven Rostedt 	{
530f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
531f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
532f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
533f38f1d2aSSteven Rostedt 		.mode		= 0644,
5346d456111SEric W. Biederman 		.proc_handler	= stack_trace_sysctl,
535f38f1d2aSSteven Rostedt 	},
536f38f1d2aSSteven Rostedt #endif
537944ac425SSteven Rostedt #ifdef CONFIG_TRACING
538944ac425SSteven Rostedt 	{
5393299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
540944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
541944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
542944ac425SSteven Rostedt 		.mode		= 0644,
5436d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
544944ac425SSteven Rostedt 	},
545944ac425SSteven Rostedt #endif
546a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
5471da177e4SLinus Torvalds 	{
5481da177e4SLinus Torvalds 		.procname	= "modprobe",
5491da177e4SLinus Torvalds 		.data		= &modprobe_path,
5501da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
5511da177e4SLinus Torvalds 		.mode		= 0644,
5526d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
5531da177e4SLinus Torvalds 	},
5543d43321bSKees Cook 	{
5553d43321bSKees Cook 		.procname	= "modules_disabled",
5563d43321bSKees Cook 		.data		= &modules_disabled,
5573d43321bSKees Cook 		.maxlen		= sizeof(int),
5583d43321bSKees Cook 		.mode		= 0644,
5593d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
5606d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
5613d43321bSKees Cook 		.extra1		= &one,
5623d43321bSKees Cook 		.extra2		= &one,
5633d43321bSKees Cook 	},
5641da177e4SLinus Torvalds #endif
56557ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
5661da177e4SLinus Torvalds 	{
5671da177e4SLinus Torvalds 		.procname	= "hotplug",
568312c004dSKay Sievers 		.data		= &uevent_helper,
569312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
5701da177e4SLinus Torvalds 		.mode		= 0644,
5716d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
5721da177e4SLinus Torvalds 	},
5731da177e4SLinus Torvalds #endif
5741da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
5751da177e4SLinus Torvalds 	{
5761da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
5771da177e4SLinus Torvalds 		.data		= &sg_big_buff,
5781da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5791da177e4SLinus Torvalds 		.mode		= 0444,
5806d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5811da177e4SLinus Torvalds 	},
5821da177e4SLinus Torvalds #endif
5831da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
5841da177e4SLinus Torvalds 	{
5851da177e4SLinus Torvalds 		.procname	= "acct",
5861da177e4SLinus Torvalds 		.data		= &acct_parm,
5871da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
5881da177e4SLinus Torvalds 		.mode		= 0644,
5896d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
5901da177e4SLinus Torvalds 	},
5911da177e4SLinus Torvalds #endif
5921da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
5931da177e4SLinus Torvalds 	{
5941da177e4SLinus Torvalds 		.procname	= "sysrq",
5955d6f647fSIngo Molnar 		.data		= &__sysrq_enabled,
5961da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5971da177e4SLinus Torvalds 		.mode		= 0644,
59897f5f0cdSDmitry Torokhov 		.proc_handler	= sysrq_sysctl_handler,
5991da177e4SLinus Torvalds 	},
6001da177e4SLinus Torvalds #endif
601d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
6021da177e4SLinus Torvalds 	{
6031da177e4SLinus Torvalds 		.procname	= "cad_pid",
6049ec52099SCedric Le Goater 		.data		= NULL,
6051da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6061da177e4SLinus Torvalds 		.mode		= 0600,
6076d456111SEric W. Biederman 		.proc_handler	= proc_do_cad_pid,
6081da177e4SLinus Torvalds 	},
609d6f8ff73SRandy Dunlap #endif
6101da177e4SLinus Torvalds 	{
6111da177e4SLinus Torvalds 		.procname	= "threads-max",
6121da177e4SLinus Torvalds 		.data		= &max_threads,
6131da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6141da177e4SLinus Torvalds 		.mode		= 0644,
6156d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6161da177e4SLinus Torvalds 	},
6171da177e4SLinus Torvalds 	{
6181da177e4SLinus Torvalds 		.procname	= "random",
6191da177e4SLinus Torvalds 		.mode		= 0555,
6201da177e4SLinus Torvalds 		.child		= random_table,
6211da177e4SLinus Torvalds 	},
6221da177e4SLinus Torvalds 	{
6231da177e4SLinus Torvalds 		.procname	= "overflowuid",
6241da177e4SLinus Torvalds 		.data		= &overflowuid,
6251da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6261da177e4SLinus Torvalds 		.mode		= 0644,
6276d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6281da177e4SLinus Torvalds 		.extra1		= &minolduid,
6291da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6301da177e4SLinus Torvalds 	},
6311da177e4SLinus Torvalds 	{
6321da177e4SLinus Torvalds 		.procname	= "overflowgid",
6331da177e4SLinus Torvalds 		.data		= &overflowgid,
6341da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6351da177e4SLinus Torvalds 		.mode		= 0644,
6366d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6371da177e4SLinus Torvalds 		.extra1		= &minolduid,
6381da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6391da177e4SLinus Torvalds 	},
640347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
6411da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
6421da177e4SLinus Torvalds 	{
6431da177e4SLinus Torvalds 		.procname	= "ieee_emulation_warnings",
6441da177e4SLinus Torvalds 		.data		= &sysctl_ieee_emulation_warnings,
6451da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6461da177e4SLinus Torvalds 		.mode		= 0644,
6476d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6481da177e4SLinus Torvalds 	},
6491da177e4SLinus Torvalds #endif
6501da177e4SLinus Torvalds 	{
6511da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
652ab3c68eeSHeiko Carstens 		.data		= &show_unhandled_signals,
6531da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6541da177e4SLinus Torvalds 		.mode		= 0644,
6556d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6561da177e4SLinus Torvalds 	},
6571da177e4SLinus Torvalds #endif
6581da177e4SLinus Torvalds 	{
6591da177e4SLinus Torvalds 		.procname	= "pid_max",
6601da177e4SLinus Torvalds 		.data		= &pid_max,
6611da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6621da177e4SLinus Torvalds 		.mode		= 0644,
6636d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
6641da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
6651da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
6661da177e4SLinus Torvalds 	},
6671da177e4SLinus Torvalds 	{
6681da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
6691da177e4SLinus Torvalds 		.data		= &panic_on_oops,
6701da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6711da177e4SLinus Torvalds 		.mode		= 0644,
6726d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6731da177e4SLinus Torvalds 	},
6747ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
6757ef3d2fdSJoe Perches 	{
6767ef3d2fdSJoe Perches 		.procname	= "printk",
6777ef3d2fdSJoe Perches 		.data		= &console_loglevel,
6787ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
6797ef3d2fdSJoe Perches 		.mode		= 0644,
6806d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6817ef3d2fdSJoe Perches 	},
6821da177e4SLinus Torvalds 	{
6831da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
684717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
6851da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6861da177e4SLinus Torvalds 		.mode		= 0644,
6876d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
6881da177e4SLinus Torvalds 	},
6891da177e4SLinus Torvalds 	{
6901da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
691717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
6921da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6931da177e4SLinus Torvalds 		.mode		= 0644,
6946d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
6951da177e4SLinus Torvalds 	},
696af91322eSDave Young 	{
697af91322eSDave Young 		.procname	= "printk_delay",
698af91322eSDave Young 		.data		= &printk_delay_msec,
699af91322eSDave Young 		.maxlen		= sizeof(int),
700af91322eSDave Young 		.mode		= 0644,
7016d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
702af91322eSDave Young 		.extra1		= &zero,
703af91322eSDave Young 		.extra2		= &ten_thousand,
704af91322eSDave Young 	},
7057ef3d2fdSJoe Perches #endif
7061da177e4SLinus Torvalds 	{
7071da177e4SLinus Torvalds 		.procname	= "ngroups_max",
7081da177e4SLinus Torvalds 		.data		= &ngroups_max,
7091da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7101da177e4SLinus Torvalds 		.mode		= 0444,
7116d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7121da177e4SLinus Torvalds 	},
7131da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
7141da177e4SLinus Torvalds 	{
7151da177e4SLinus Torvalds 		.procname       = "unknown_nmi_panic",
7161da177e4SLinus Torvalds 		.data           = &unknown_nmi_panic,
7171da177e4SLinus Torvalds 		.maxlen         = sizeof (int),
7181da177e4SLinus Torvalds 		.mode           = 0644,
7196d456111SEric W. Biederman 		.proc_handler   = proc_dointvec,
7201da177e4SLinus Torvalds 	},
721407984f1SDon Zickus 	{
722407984f1SDon Zickus 		.procname       = "nmi_watchdog",
723407984f1SDon Zickus 		.data           = &nmi_watchdog_enabled,
724407984f1SDon Zickus 		.maxlen         = sizeof (int),
725407984f1SDon Zickus 		.mode           = 0644,
7266d456111SEric W. Biederman 		.proc_handler   = proc_nmi_enabled,
7271da177e4SLinus Torvalds 	},
7281da177e4SLinus Torvalds #endif
7291da177e4SLinus Torvalds #if defined(CONFIG_X86)
7301da177e4SLinus Torvalds 	{
7318da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
7328da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
7338da5addaSDon Zickus 		.maxlen		= sizeof(int),
7348da5addaSDon Zickus 		.mode		= 0644,
7356d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7368da5addaSDon Zickus 	},
7378da5addaSDon Zickus 	{
7385211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
7395211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
7405211a242SKurt Garloff 		.maxlen		= sizeof(int),
7415211a242SKurt Garloff 		.mode		= 0644,
7426d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7435211a242SKurt Garloff 	},
7445211a242SKurt Garloff 	{
7451da177e4SLinus Torvalds 		.procname	= "bootloader_type",
7461da177e4SLinus Torvalds 		.data		= &bootloader_type,
7471da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7481da177e4SLinus Torvalds 		.mode		= 0444,
7496d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7501da177e4SLinus Torvalds 	},
7510741f4d2SChuck Ebbert 	{
7525031296cSH. Peter Anvin 		.procname	= "bootloader_version",
7535031296cSH. Peter Anvin 		.data		= &bootloader_version,
7545031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
7555031296cSH. Peter Anvin 		.mode		= 0444,
7566d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7575031296cSH. Peter Anvin 	},
7585031296cSH. Peter Anvin 	{
7590741f4d2SChuck Ebbert 		.procname	= "kstack_depth_to_print",
7600741f4d2SChuck Ebbert 		.data		= &kstack_depth_to_print,
7610741f4d2SChuck Ebbert 		.maxlen		= sizeof(int),
7620741f4d2SChuck Ebbert 		.mode		= 0644,
7636d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7640741f4d2SChuck Ebbert 	},
7656e7c4025SIngo Molnar 	{
7666e7c4025SIngo Molnar 		.procname	= "io_delay_type",
7676e7c4025SIngo Molnar 		.data		= &io_delay_type,
7686e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
7696e7c4025SIngo Molnar 		.mode		= 0644,
7706d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7716e7c4025SIngo Molnar 	},
7721da177e4SLinus Torvalds #endif
7737a9166e3SLuke Yang #if defined(CONFIG_MMU)
7741da177e4SLinus Torvalds 	{
7751da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
7761da177e4SLinus Torvalds 		.data		= &randomize_va_space,
7771da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7781da177e4SLinus Torvalds 		.mode		= 0644,
7796d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
7801da177e4SLinus Torvalds 	},
7817a9166e3SLuke Yang #endif
7820152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
783951f22d5SMartin Schwidefsky 	{
784951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
785951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
786951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
787951f22d5SMartin Schwidefsky 		.mode		= 0644,
7886d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
789951f22d5SMartin Schwidefsky 	},
790951f22d5SMartin Schwidefsky #endif
791673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
792c255d844SPavel Machek 	{
793c255d844SPavel Machek 		.procname	= "acpi_video_flags",
79477afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
795c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
796c255d844SPavel Machek 		.mode		= 0644,
7976d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
798c255d844SPavel Machek 	},
799c255d844SPavel Machek #endif
800d2b176edSJes Sorensen #ifdef CONFIG_IA64
801d2b176edSJes Sorensen 	{
802d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
803d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
804d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
805d2b176edSJes Sorensen 	 	.mode		= 0644,
8066d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
807d2b176edSJes Sorensen 	},
80888fc241fSDoug Chapman 	{
80988fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
81088fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
81188fc241fSDoug Chapman 		.maxlen		= sizeof (int),
81288fc241fSDoug Chapman 		.mode		= 0644,
8136d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
81488fc241fSDoug Chapman 	},
815d2b176edSJes Sorensen #endif
816c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP
817c4f3b63fSRavikiran G Thirumalai 	{
8189c44bc03SIngo Molnar 		.procname	= "softlockup_panic",
8199c44bc03SIngo Molnar 		.data		= &softlockup_panic,
8209c44bc03SIngo Molnar 		.maxlen		= sizeof(int),
8219c44bc03SIngo Molnar 		.mode		= 0644,
8226d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
8239c44bc03SIngo Molnar 		.extra1		= &zero,
8249c44bc03SIngo Molnar 		.extra2		= &one,
8259c44bc03SIngo Molnar 	},
8269c44bc03SIngo Molnar 	{
827c4f3b63fSRavikiran G Thirumalai 		.procname	= "softlockup_thresh",
828c4f3b63fSRavikiran G Thirumalai 		.data		= &softlockup_thresh,
8299383d967SDimitri Sivanich 		.maxlen		= sizeof(int),
830c4f3b63fSRavikiran G Thirumalai 		.mode		= 0644,
8316d456111SEric W. Biederman 		.proc_handler	= proc_dosoftlockup_thresh,
8329383d967SDimitri Sivanich 		.extra1		= &neg_one,
833c4f3b63fSRavikiran G Thirumalai 		.extra2		= &sixty,
834c4f3b63fSRavikiran G Thirumalai 	},
835e162b39aSMandeep Singh Baines #endif
836e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
837e162b39aSMandeep Singh Baines 	{
838e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
839e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
840e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
841e162b39aSMandeep Singh Baines 		.mode		= 0644,
8426d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
843e162b39aSMandeep Singh Baines 		.extra1		= &zero,
844e162b39aSMandeep Singh Baines 		.extra2		= &one,
845e162b39aSMandeep Singh Baines 	},
84682a1fcb9SIngo Molnar 	{
84782a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
84882a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
84990739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
85082a1fcb9SIngo Molnar 		.mode		= 0644,
8516d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
85282a1fcb9SIngo Molnar 	},
85382a1fcb9SIngo Molnar 	{
85482a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
85582a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
85690739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
85782a1fcb9SIngo Molnar 		.mode		= 0644,
8586d456111SEric W. Biederman 		.proc_handler	= proc_dohung_task_timeout_secs,
85982a1fcb9SIngo Molnar 	},
86082a1fcb9SIngo Molnar 	{
86182a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
86282a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
86390739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
86482a1fcb9SIngo Molnar 		.mode		= 0644,
8656d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
86682a1fcb9SIngo Molnar 	},
867c4f3b63fSRavikiran G Thirumalai #endif
868bebfa101SAndi Kleen #ifdef CONFIG_COMPAT
869bebfa101SAndi Kleen 	{
870bebfa101SAndi Kleen 		.procname	= "compat-log",
871bebfa101SAndi Kleen 		.data		= &compat_log,
872bebfa101SAndi Kleen 		.maxlen		= sizeof (int),
873bebfa101SAndi Kleen 	 	.mode		= 0644,
8746d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
875bebfa101SAndi Kleen 	},
876bebfa101SAndi Kleen #endif
87723f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
87823f78d4aSIngo Molnar 	{
87923f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
88023f78d4aSIngo Molnar 		.data		= &max_lock_depth,
88123f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
88223f78d4aSIngo Molnar 		.mode		= 0644,
8836d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
88423f78d4aSIngo Molnar 	},
88523f78d4aSIngo Molnar #endif
88610a0a8d4SJeremy Fitzhardinge 	{
88710a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
88810a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
88910a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
89010a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
8916d456111SEric W. Biederman 		.proc_handler	= proc_dostring,
89210a0a8d4SJeremy Fitzhardinge 	},
8930b77f5bfSDavid Howells #ifdef CONFIG_KEYS
8940b77f5bfSDavid Howells 	{
8950b77f5bfSDavid Howells 		.procname	= "keys",
8960b77f5bfSDavid Howells 		.mode		= 0555,
8970b77f5bfSDavid Howells 		.child		= key_sysctls,
8980b77f5bfSDavid Howells 	},
8990b77f5bfSDavid Howells #endif
90031a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
90131a72bceSPaul E. McKenney 	{
90231a72bceSPaul E. McKenney 		.procname       = "rcutorture_runnable",
90331a72bceSPaul E. McKenney 		.data           = &rcutorture_runnable,
90431a72bceSPaul E. McKenney 		.maxlen         = sizeof(int),
90531a72bceSPaul E. McKenney 		.mode           = 0644,
9066d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
90731a72bceSPaul E. McKenney 	},
90831a72bceSPaul E. McKenney #endif
90912e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK
91012e22c5eSDavid Howells 	{
91112e22c5eSDavid Howells 		.procname	= "slow-work",
91212e22c5eSDavid Howells 		.mode		= 0555,
91312e22c5eSDavid Howells 		.child		= slow_work_sysctls,
91412e22c5eSDavid Howells 	},
91512e22c5eSDavid Howells #endif
916cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS
9171ccd1549SPeter Zijlstra 	{
918cdd6c482SIngo Molnar 		.procname	= "perf_event_paranoid",
919cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_paranoid,
920cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_paranoid),
9211ccd1549SPeter Zijlstra 		.mode		= 0644,
9226d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9231ccd1549SPeter Zijlstra 	},
924c5078f78SPeter Zijlstra 	{
925cdd6c482SIngo Molnar 		.procname	= "perf_event_mlock_kb",
926cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_mlock,
927cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_mlock),
928c5078f78SPeter Zijlstra 		.mode		= 0644,
9296d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
930c5078f78SPeter Zijlstra 	},
931a78ac325SPeter Zijlstra 	{
932cdd6c482SIngo Molnar 		.procname	= "perf_event_max_sample_rate",
933cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_sample_rate,
934cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
935a78ac325SPeter Zijlstra 		.mode		= 0644,
9366d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
937a78ac325SPeter Zijlstra 	},
9381ccd1549SPeter Zijlstra #endif
939dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK
940dfec072eSVegard Nossum 	{
941dfec072eSVegard Nossum 		.procname	= "kmemcheck",
942dfec072eSVegard Nossum 		.data		= &kmemcheck_enabled,
943dfec072eSVegard Nossum 		.maxlen		= sizeof(int),
944dfec072eSVegard Nossum 		.mode		= 0644,
9456d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
946dfec072eSVegard Nossum 	},
947dfec072eSVegard Nossum #endif
948cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
9495e605b64SJens Axboe 	{
9505e605b64SJens Axboe 		.procname	= "blk_iopoll",
9515e605b64SJens Axboe 		.data		= &blk_iopoll_enabled,
9525e605b64SJens Axboe 		.maxlen		= sizeof(int),
9535e605b64SJens Axboe 		.mode		= 0644,
9546d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9555e605b64SJens Axboe 	},
956cb684b5bSJens Axboe #endif
957ed2c12f3SAndrew Morton /*
958ed2c12f3SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
959ed2c12f3SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
960ed2c12f3SAndrew Morton  */
9616fce56ecSEric W. Biederman 	{ }
9621da177e4SLinus Torvalds };
9631da177e4SLinus Torvalds 
964d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
9651da177e4SLinus Torvalds 	{
9661da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
9671da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
9681da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
9691da177e4SLinus Torvalds 		.mode		= 0644,
9706d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9711da177e4SLinus Torvalds 	},
9721da177e4SLinus Torvalds 	{
973fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
974fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
975fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
976fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
9776d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
978fadd8fbdSKAMEZAWA Hiroyuki 	},
979fadd8fbdSKAMEZAWA Hiroyuki 	{
980fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
981fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
982fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
983fe071d7eSDavid Rientjes 		.mode		= 0644,
9846d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
985fe071d7eSDavid Rientjes 	},
986fe071d7eSDavid Rientjes 	{
987fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
988fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
989fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
990fef1bdd6SDavid Rientjes 		.mode		= 0644,
9916d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
992fef1bdd6SDavid Rientjes 	},
993fef1bdd6SDavid Rientjes 	{
9941da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
9951da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
9961da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
9971da177e4SLinus Torvalds 		.mode		= 0644,
9986d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
9991da177e4SLinus Torvalds 	},
10001da177e4SLinus Torvalds 	{
10011da177e4SLinus Torvalds 		.procname	= "page-cluster",
10021da177e4SLinus Torvalds 		.data		= &page_cluster,
10031da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
10041da177e4SLinus Torvalds 		.mode		= 0644,
10056d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10061da177e4SLinus Torvalds 	},
10071da177e4SLinus Torvalds 	{
10081da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
10091da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
10101da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
10111da177e4SLinus Torvalds 		.mode		= 0644,
10126d456111SEric W. Biederman 		.proc_handler	= dirty_background_ratio_handler,
10131da177e4SLinus Torvalds 		.extra1		= &zero,
10141da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10151da177e4SLinus Torvalds 	},
10161da177e4SLinus Torvalds 	{
10172da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
10182da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
10192da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
10202da02997SDavid Rientjes 		.mode		= 0644,
10216d456111SEric W. Biederman 		.proc_handler	= dirty_background_bytes_handler,
1022fc3501d4SSven Wegener 		.extra1		= &one_ul,
10232da02997SDavid Rientjes 	},
10242da02997SDavid Rientjes 	{
10251da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
10261da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
10271da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
10281da177e4SLinus Torvalds 		.mode		= 0644,
10296d456111SEric W. Biederman 		.proc_handler	= dirty_ratio_handler,
10301da177e4SLinus Torvalds 		.extra1		= &zero,
10311da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10321da177e4SLinus Torvalds 	},
10331da177e4SLinus Torvalds 	{
10342da02997SDavid Rientjes 		.procname	= "dirty_bytes",
10352da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
10362da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
10372da02997SDavid Rientjes 		.mode		= 0644,
10386d456111SEric W. Biederman 		.proc_handler	= dirty_bytes_handler,
10399e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
10402da02997SDavid Rientjes 	},
10412da02997SDavid Rientjes 	{
10421da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
1043f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
1044f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
10451da177e4SLinus Torvalds 		.mode		= 0644,
10466d456111SEric W. Biederman 		.proc_handler	= dirty_writeback_centisecs_handler,
10471da177e4SLinus Torvalds 	},
10481da177e4SLinus Torvalds 	{
10491da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
1050f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
1051f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
10521da177e4SLinus Torvalds 		.mode		= 0644,
10536d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10541da177e4SLinus Torvalds 	},
10551da177e4SLinus Torvalds 	{
10561da177e4SLinus Torvalds 		.procname	= "nr_pdflush_threads",
10571da177e4SLinus Torvalds 		.data		= &nr_pdflush_threads,
10581da177e4SLinus Torvalds 		.maxlen		= sizeof nr_pdflush_threads,
10591da177e4SLinus Torvalds 		.mode		= 0444 /* read-only*/,
10606d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10611da177e4SLinus Torvalds 	},
10621da177e4SLinus Torvalds 	{
10631da177e4SLinus Torvalds 		.procname	= "swappiness",
10641da177e4SLinus Torvalds 		.data		= &vm_swappiness,
10651da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
10661da177e4SLinus Torvalds 		.mode		= 0644,
10676d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
10681da177e4SLinus Torvalds 		.extra1		= &zero,
10691da177e4SLinus Torvalds 		.extra2		= &one_hundred,
10701da177e4SLinus Torvalds 	},
10711da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
10721da177e4SLinus Torvalds 	{
10731da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
1074e5ff2159SAndi Kleen 		.data		= NULL,
10751da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
10761da177e4SLinus Torvalds 		.mode		= 0644,
10776d456111SEric W. Biederman 		.proc_handler	= hugetlb_sysctl_handler,
10781da177e4SLinus Torvalds 		.extra1		= (void *)&hugetlb_zero,
10791da177e4SLinus Torvalds 		.extra2		= (void *)&hugetlb_infinity,
10801da177e4SLinus Torvalds 	},
108106808b08SLee Schermerhorn #ifdef CONFIG_NUMA
108206808b08SLee Schermerhorn 	{
108306808b08SLee Schermerhorn 		.procname       = "nr_hugepages_mempolicy",
108406808b08SLee Schermerhorn 		.data           = NULL,
108506808b08SLee Schermerhorn 		.maxlen         = sizeof(unsigned long),
108606808b08SLee Schermerhorn 		.mode           = 0644,
108706808b08SLee Schermerhorn 		.proc_handler   = &hugetlb_mempolicy_sysctl_handler,
108806808b08SLee Schermerhorn 		.extra1		= (void *)&hugetlb_zero,
108906808b08SLee Schermerhorn 		.extra2		= (void *)&hugetlb_infinity,
109006808b08SLee Schermerhorn 	},
109106808b08SLee Schermerhorn #endif
10921da177e4SLinus Torvalds 	 {
10931da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
10941da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
10951da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
10961da177e4SLinus Torvalds 		.mode		= 0644,
10976d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
10981da177e4SLinus Torvalds 	 },
1099396faf03SMel Gorman 	 {
1100396faf03SMel Gorman 		.procname	= "hugepages_treat_as_movable",
1101396faf03SMel Gorman 		.data		= &hugepages_treat_as_movable,
1102396faf03SMel Gorman 		.maxlen		= sizeof(int),
1103396faf03SMel Gorman 		.mode		= 0644,
11046d456111SEric W. Biederman 		.proc_handler	= hugetlb_treat_movable_handler,
1105396faf03SMel Gorman 	},
110654f9f80dSAdam Litke 	{
1107d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
1108e5ff2159SAndi Kleen 		.data		= NULL,
1109e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
1110d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
11116d456111SEric W. Biederman 		.proc_handler	= hugetlb_overcommit_handler,
1112e5ff2159SAndi Kleen 		.extra1		= (void *)&hugetlb_zero,
1113e5ff2159SAndi Kleen 		.extra2		= (void *)&hugetlb_infinity,
1114d1c3fb1fSNishanth Aravamudan 	},
11151da177e4SLinus Torvalds #endif
11161da177e4SLinus Torvalds 	{
11171da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
11181da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
11191da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
11201da177e4SLinus Torvalds 		.mode		= 0644,
11216d456111SEric W. Biederman 		.proc_handler	= lowmem_reserve_ratio_sysctl_handler,
11221da177e4SLinus Torvalds 	},
11231da177e4SLinus Torvalds 	{
11249d0243bcSAndrew Morton 		.procname	= "drop_caches",
11259d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
11269d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
11279d0243bcSAndrew Morton 		.mode		= 0644,
11289d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
11299d0243bcSAndrew Morton 	},
113076ab0f53SMel Gorman #ifdef CONFIG_COMPACTION
113176ab0f53SMel Gorman 	{
113276ab0f53SMel Gorman 		.procname	= "compact_memory",
113376ab0f53SMel Gorman 		.data		= &sysctl_compact_memory,
113476ab0f53SMel Gorman 		.maxlen		= sizeof(int),
113576ab0f53SMel Gorman 		.mode		= 0200,
113676ab0f53SMel Gorman 		.proc_handler	= sysctl_compaction_handler,
113776ab0f53SMel Gorman 	},
11385e771905SMel Gorman 	{
11395e771905SMel Gorman 		.procname	= "extfrag_threshold",
11405e771905SMel Gorman 		.data		= &sysctl_extfrag_threshold,
11415e771905SMel Gorman 		.maxlen		= sizeof(int),
11425e771905SMel Gorman 		.mode		= 0644,
11435e771905SMel Gorman 		.proc_handler	= sysctl_extfrag_handler,
11445e771905SMel Gorman 		.extra1		= &min_extfrag_threshold,
11455e771905SMel Gorman 		.extra2		= &max_extfrag_threshold,
11465e771905SMel Gorman 	},
11475e771905SMel Gorman 
114876ab0f53SMel Gorman #endif /* CONFIG_COMPACTION */
11499d0243bcSAndrew Morton 	{
11501da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
11511da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
11521da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
11531da177e4SLinus Torvalds 		.mode		= 0644,
11546d456111SEric W. Biederman 		.proc_handler	= min_free_kbytes_sysctl_handler,
11551da177e4SLinus Torvalds 		.extra1		= &zero,
11561da177e4SLinus Torvalds 	},
11578ad4b1fbSRohit Seth 	{
11588ad4b1fbSRohit Seth 		.procname	= "percpu_pagelist_fraction",
11598ad4b1fbSRohit Seth 		.data		= &percpu_pagelist_fraction,
11608ad4b1fbSRohit Seth 		.maxlen		= sizeof(percpu_pagelist_fraction),
11618ad4b1fbSRohit Seth 		.mode		= 0644,
11626d456111SEric W. Biederman 		.proc_handler	= percpu_pagelist_fraction_sysctl_handler,
11638ad4b1fbSRohit Seth 		.extra1		= &min_percpu_pagelist_fract,
11648ad4b1fbSRohit Seth 	},
11651da177e4SLinus Torvalds #ifdef CONFIG_MMU
11661da177e4SLinus Torvalds 	{
11671da177e4SLinus Torvalds 		.procname	= "max_map_count",
11681da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
11691da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
11701da177e4SLinus Torvalds 		.mode		= 0644,
11713e26120cSWANG Cong 		.proc_handler	= proc_dointvec_minmax,
117270da2340SAmerigo Wang 		.extra1		= &zero,
11731da177e4SLinus Torvalds 	},
1174dd8632a1SPaul Mundt #else
1175dd8632a1SPaul Mundt 	{
1176dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
1177dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
1178dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
1179dd8632a1SPaul Mundt 		.mode		= 0644,
11806d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1181dd8632a1SPaul Mundt 		.extra1		= &zero,
1182dd8632a1SPaul Mundt 	},
11831da177e4SLinus Torvalds #endif
11841da177e4SLinus Torvalds 	{
11851da177e4SLinus Torvalds 		.procname	= "laptop_mode",
11861da177e4SLinus Torvalds 		.data		= &laptop_mode,
11871da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
11881da177e4SLinus Torvalds 		.mode		= 0644,
11896d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
11901da177e4SLinus Torvalds 	},
11911da177e4SLinus Torvalds 	{
11921da177e4SLinus Torvalds 		.procname	= "block_dump",
11931da177e4SLinus Torvalds 		.data		= &block_dump,
11941da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
11951da177e4SLinus Torvalds 		.mode		= 0644,
11966d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
11971da177e4SLinus Torvalds 		.extra1		= &zero,
11981da177e4SLinus Torvalds 	},
11991da177e4SLinus Torvalds 	{
12001da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
12011da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
12021da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
12031da177e4SLinus Torvalds 		.mode		= 0644,
12046d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
12051da177e4SLinus Torvalds 		.extra1		= &zero,
12061da177e4SLinus Torvalds 	},
12071da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
12081da177e4SLinus Torvalds 	{
12091da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
12101da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
12111da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
12121da177e4SLinus Torvalds 		.mode		= 0644,
12136d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
12141da177e4SLinus Torvalds 		.extra1		= &zero,
12151da177e4SLinus Torvalds 	},
12161da177e4SLinus Torvalds #endif
12171743660bSChristoph Lameter #ifdef CONFIG_NUMA
12181743660bSChristoph Lameter 	{
12191743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
12201743660bSChristoph Lameter 		.data		= &zone_reclaim_mode,
12211743660bSChristoph Lameter 		.maxlen		= sizeof(zone_reclaim_mode),
12221743660bSChristoph Lameter 		.mode		= 0644,
12236d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1224c84db23cSChristoph Lameter 		.extra1		= &zero,
12251743660bSChristoph Lameter 	},
12269614634fSChristoph Lameter 	{
12279614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
12289614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
12299614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
12309614634fSChristoph Lameter 		.mode		= 0644,
12316d456111SEric W. Biederman 		.proc_handler	= sysctl_min_unmapped_ratio_sysctl_handler,
12329614634fSChristoph Lameter 		.extra1		= &zero,
12339614634fSChristoph Lameter 		.extra2		= &one_hundred,
12349614634fSChristoph Lameter 	},
12350ff38490SChristoph Lameter 	{
12360ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
12370ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
12380ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
12390ff38490SChristoph Lameter 		.mode		= 0644,
12406d456111SEric W. Biederman 		.proc_handler	= sysctl_min_slab_ratio_sysctl_handler,
12410ff38490SChristoph Lameter 		.extra1		= &zero,
12420ff38490SChristoph Lameter 		.extra2		= &one_hundred,
12430ff38490SChristoph Lameter 	},
12441743660bSChristoph Lameter #endif
124577461ab3SChristoph Lameter #ifdef CONFIG_SMP
124677461ab3SChristoph Lameter 	{
124777461ab3SChristoph Lameter 		.procname	= "stat_interval",
124877461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
124977461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
125077461ab3SChristoph Lameter 		.mode		= 0644,
12516d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_jiffies,
125277461ab3SChristoph Lameter 	},
125377461ab3SChristoph Lameter #endif
12546e141546SDavid Howells #ifdef CONFIG_MMU
1255ed032189SEric Paris 	{
1256ed032189SEric Paris 		.procname	= "mmap_min_addr",
1257788084abSEric Paris 		.data		= &dac_mmap_min_addr,
1258ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
1259ed032189SEric Paris 		.mode		= 0644,
12606d456111SEric W. Biederman 		.proc_handler	= mmap_min_addr_handler,
1261ed032189SEric Paris 	},
12626e141546SDavid Howells #endif
1263f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
1264f0c0b2b8SKAMEZAWA Hiroyuki 	{
1265f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
1266f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
1267f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
1268f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
12696d456111SEric W. Biederman 		.proc_handler	= numa_zonelist_order_handler,
1270f0c0b2b8SKAMEZAWA Hiroyuki 	},
1271f0c0b2b8SKAMEZAWA Hiroyuki #endif
12722b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
12735c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1274e6e5494cSIngo Molnar 	{
1275e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
1276e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
1277e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
1278e6e5494cSIngo Molnar 		.mode		= 0644,
12796d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
1280e6e5494cSIngo Molnar 		.extra1		= &zero,
1281e6e5494cSIngo Molnar 	},
1282e6e5494cSIngo Molnar #endif
1283195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
1284195cf453SBron Gondwana 	{
1285195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
1286195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
1287195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
1288195cf453SBron Gondwana 		.mode		= 0644,
12896d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1290195cf453SBron Gondwana 		.extra1		= &zero,
1291195cf453SBron Gondwana 		.extra2		= &one,
1292195cf453SBron Gondwana 	},
1293195cf453SBron Gondwana #endif
12944be6f6bbSPeter Zijlstra 	{
12954be6f6bbSPeter Zijlstra 		.procname	= "scan_unevictable_pages",
12964be6f6bbSPeter Zijlstra 		.data		= &scan_unevictable_pages,
12974be6f6bbSPeter Zijlstra 		.maxlen		= sizeof(scan_unevictable_pages),
12984be6f6bbSPeter Zijlstra 		.mode		= 0644,
12996d456111SEric W. Biederman 		.proc_handler	= scan_unevictable_handler,
13004be6f6bbSPeter Zijlstra 	},
13016a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE
13026a46079cSAndi Kleen 	{
13036a46079cSAndi Kleen 		.procname	= "memory_failure_early_kill",
13046a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_early_kill,
13056a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_early_kill),
13066a46079cSAndi Kleen 		.mode		= 0644,
13076d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13086a46079cSAndi Kleen 		.extra1		= &zero,
13096a46079cSAndi Kleen 		.extra2		= &one,
13106a46079cSAndi Kleen 	},
13116a46079cSAndi Kleen 	{
13126a46079cSAndi Kleen 		.procname	= "memory_failure_recovery",
13136a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_recovery,
13146a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_recovery),
13156a46079cSAndi Kleen 		.mode		= 0644,
13166d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13176a46079cSAndi Kleen 		.extra1		= &zero,
13186a46079cSAndi Kleen 		.extra2		= &one,
13196a46079cSAndi Kleen 	},
13206a46079cSAndi Kleen #endif
13216a46079cSAndi Kleen 
13222be7fe07SAndrew Morton /*
13232be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
13242be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
13252be7fe07SAndrew Morton  */
13266fce56ecSEric W. Biederman 	{ }
13271da177e4SLinus Torvalds };
13281da177e4SLinus Torvalds 
13292abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1330d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = {
13316fce56ecSEric W. Biederman 	{ }
13322abc26fcSEric W. Biederman };
13332abc26fcSEric W. Biederman #endif
13342abc26fcSEric W. Biederman 
1335d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
13361da177e4SLinus Torvalds 	{
13371da177e4SLinus Torvalds 		.procname	= "inode-nr",
13381da177e4SLinus Torvalds 		.data		= &inodes_stat,
13391da177e4SLinus Torvalds 		.maxlen		= 2*sizeof(int),
13401da177e4SLinus Torvalds 		.mode		= 0444,
13416d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13421da177e4SLinus Torvalds 	},
13431da177e4SLinus Torvalds 	{
13441da177e4SLinus Torvalds 		.procname	= "inode-state",
13451da177e4SLinus Torvalds 		.data		= &inodes_stat,
13461da177e4SLinus Torvalds 		.maxlen		= 7*sizeof(int),
13471da177e4SLinus Torvalds 		.mode		= 0444,
13486d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13491da177e4SLinus Torvalds 	},
13501da177e4SLinus Torvalds 	{
13511da177e4SLinus Torvalds 		.procname	= "file-nr",
13521da177e4SLinus Torvalds 		.data		= &files_stat,
13531da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
13541da177e4SLinus Torvalds 		.mode		= 0444,
13556d456111SEric W. Biederman 		.proc_handler	= proc_nr_files,
13561da177e4SLinus Torvalds 	},
13571da177e4SLinus Torvalds 	{
13581da177e4SLinus Torvalds 		.procname	= "file-max",
13591da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
13601da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13611da177e4SLinus Torvalds 		.mode		= 0644,
13626d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13631da177e4SLinus Torvalds 	},
13641da177e4SLinus Torvalds 	{
13659cfe015aSEric Dumazet 		.procname	= "nr_open",
13669cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
13679cfe015aSEric Dumazet 		.maxlen		= sizeof(int),
13689cfe015aSEric Dumazet 		.mode		= 0644,
13696d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
1370eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
1371eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
13729cfe015aSEric Dumazet 	},
13739cfe015aSEric Dumazet 	{
13741da177e4SLinus Torvalds 		.procname	= "dentry-state",
13751da177e4SLinus Torvalds 		.data		= &dentry_stat,
13761da177e4SLinus Torvalds 		.maxlen		= 6*sizeof(int),
13771da177e4SLinus Torvalds 		.mode		= 0444,
13786d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
13791da177e4SLinus Torvalds 	},
13801da177e4SLinus Torvalds 	{
13811da177e4SLinus Torvalds 		.procname	= "overflowuid",
13821da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
13831da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13841da177e4SLinus Torvalds 		.mode		= 0644,
13856d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13861da177e4SLinus Torvalds 		.extra1		= &minolduid,
13871da177e4SLinus Torvalds 		.extra2		= &maxolduid,
13881da177e4SLinus Torvalds 	},
13891da177e4SLinus Torvalds 	{
13901da177e4SLinus Torvalds 		.procname	= "overflowgid",
13911da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
13921da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
13931da177e4SLinus Torvalds 		.mode		= 0644,
13946d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
13951da177e4SLinus Torvalds 		.extra1		= &minolduid,
13961da177e4SLinus Torvalds 		.extra2		= &maxolduid,
13971da177e4SLinus Torvalds 	},
1398bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
13991da177e4SLinus Torvalds 	{
14001da177e4SLinus Torvalds 		.procname	= "leases-enable",
14011da177e4SLinus Torvalds 		.data		= &leases_enable,
14021da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14031da177e4SLinus Torvalds 		.mode		= 0644,
14046d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
14051da177e4SLinus Torvalds 	},
1406bfcd17a6SThomas Petazzoni #endif
14071da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
14081da177e4SLinus Torvalds 	{
14091da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
14101da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
14111da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14121da177e4SLinus Torvalds 		.mode		= 0644,
14136d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
14141da177e4SLinus Torvalds 	},
14151da177e4SLinus Torvalds #endif
14161da177e4SLinus Torvalds #ifdef CONFIG_MMU
1417bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
14181da177e4SLinus Torvalds 	{
14191da177e4SLinus Torvalds 		.procname	= "lease-break-time",
14201da177e4SLinus Torvalds 		.data		= &lease_break_time,
14211da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14221da177e4SLinus Torvalds 		.mode		= 0644,
14236d456111SEric W. Biederman 		.proc_handler	= proc_dointvec,
14241da177e4SLinus Torvalds 	},
1425bfcd17a6SThomas Petazzoni #endif
1426ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
14271da177e4SLinus Torvalds 	{
14281da177e4SLinus Torvalds 		.procname	= "aio-nr",
14291da177e4SLinus Torvalds 		.data		= &aio_nr,
14301da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
14311da177e4SLinus Torvalds 		.mode		= 0444,
14326d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
14331da177e4SLinus Torvalds 	},
14341da177e4SLinus Torvalds 	{
14351da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
14361da177e4SLinus Torvalds 		.data		= &aio_max_nr,
14371da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
14381da177e4SLinus Torvalds 		.mode		= 0644,
14396d456111SEric W. Biederman 		.proc_handler	= proc_doulongvec_minmax,
14401da177e4SLinus Torvalds 	},
1441ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
14422d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
14430399cb08SRobert Love 	{
14440399cb08SRobert Love 		.procname	= "inotify",
14450399cb08SRobert Love 		.mode		= 0555,
14460399cb08SRobert Love 		.child		= inotify_table,
14470399cb08SRobert Love 	},
14480399cb08SRobert Love #endif
14497ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
14507ef9964eSDavide Libenzi 	{
14517ef9964eSDavide Libenzi 		.procname	= "epoll",
14527ef9964eSDavide Libenzi 		.mode		= 0555,
14537ef9964eSDavide Libenzi 		.child		= epoll_table,
14547ef9964eSDavide Libenzi 	},
14557ef9964eSDavide Libenzi #endif
14561da177e4SLinus Torvalds #endif
1457d6e71144SAlan Cox 	{
1458d6e71144SAlan Cox 		.procname	= "suid_dumpable",
1459d6e71144SAlan Cox 		.data		= &suid_dumpable,
1460d6e71144SAlan Cox 		.maxlen		= sizeof(int),
1461d6e71144SAlan Cox 		.mode		= 0644,
14626d456111SEric W. Biederman 		.proc_handler	= proc_dointvec_minmax,
14638e654fbaSMatthew Wilcox 		.extra1		= &zero,
14648e654fbaSMatthew Wilcox 		.extra2		= &two,
1465d6e71144SAlan Cox 	},
14662abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
14672abc26fcSEric W. Biederman 	{
14682abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
14692abc26fcSEric W. Biederman 		.mode		= 0555,
14702abc26fcSEric W. Biederman 		.child		= binfmt_misc_table,
14712abc26fcSEric W. Biederman 	},
14722abc26fcSEric W. Biederman #endif
1473b492e95bSJens Axboe 	{
1474*ff9da691SJens Axboe 		.procname	= "pipe-max-size",
1475*ff9da691SJens Axboe 		.data		= &pipe_max_size,
1476b492e95bSJens Axboe 		.maxlen		= sizeof(int),
1477b492e95bSJens Axboe 		.mode		= 0644,
1478*ff9da691SJens Axboe 		.proc_handler	= &pipe_proc_fn,
1479*ff9da691SJens Axboe 		.extra1		= &pipe_min_size,
1480b492e95bSJens Axboe 	},
14812be7fe07SAndrew Morton /*
14822be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
14832be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
14842be7fe07SAndrew Morton  */
14856fce56ecSEric W. Biederman 	{ }
14861da177e4SLinus Torvalds };
14871da177e4SLinus Torvalds 
1488d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
1489ab3c68eeSHeiko Carstens #if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \
1490ab3c68eeSHeiko Carstens     defined(CONFIG_S390)
1491abd4f750SMasoud Asgharifard Sharbiani 	{
1492abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
1493abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
1494abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
1495abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
1496abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
1497abd4f750SMasoud Asgharifard Sharbiani 	},
1498abd4f750SMasoud Asgharifard Sharbiani #endif
1499b2be84dfSMasami Hiramatsu #if defined(CONFIG_OPTPROBES)
1500b2be84dfSMasami Hiramatsu 	{
1501b2be84dfSMasami Hiramatsu 		.procname	= "kprobes-optimization",
1502b2be84dfSMasami Hiramatsu 		.data		= &sysctl_kprobes_optimization,
1503b2be84dfSMasami Hiramatsu 		.maxlen		= sizeof(int),
1504b2be84dfSMasami Hiramatsu 		.mode		= 0644,
1505b2be84dfSMasami Hiramatsu 		.proc_handler	= proc_kprobes_optimization_handler,
1506b2be84dfSMasami Hiramatsu 		.extra1		= &zero,
1507b2be84dfSMasami Hiramatsu 		.extra2		= &one,
1508b2be84dfSMasami Hiramatsu 	},
1509b2be84dfSMasami Hiramatsu #endif
15106fce56ecSEric W. Biederman 	{ }
15111da177e4SLinus Torvalds };
15121da177e4SLinus Torvalds 
1513d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
15146fce56ecSEric W. Biederman 	{ }
15151da177e4SLinus Torvalds };
15161da177e4SLinus Torvalds 
1517330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock);
1518330d57fbSAl Viro 
1519330d57fbSAl Viro /* called under sysctl_lock */
1520330d57fbSAl Viro static int use_table(struct ctl_table_header *p)
1521330d57fbSAl Viro {
1522330d57fbSAl Viro 	if (unlikely(p->unregistering))
1523330d57fbSAl Viro 		return 0;
1524330d57fbSAl Viro 	p->used++;
1525330d57fbSAl Viro 	return 1;
1526330d57fbSAl Viro }
1527330d57fbSAl Viro 
1528330d57fbSAl Viro /* called under sysctl_lock */
1529330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p)
1530330d57fbSAl Viro {
1531330d57fbSAl Viro 	if (!--p->used)
1532330d57fbSAl Viro 		if (unlikely(p->unregistering))
1533330d57fbSAl Viro 			complete(p->unregistering);
1534330d57fbSAl Viro }
1535330d57fbSAl Viro 
1536330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */
1537330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p)
1538330d57fbSAl Viro {
1539330d57fbSAl Viro 	/*
1540330d57fbSAl Viro 	 * if p->used is 0, nobody will ever touch that entry again;
1541330d57fbSAl Viro 	 * we'll eliminate all paths to it before dropping sysctl_lock
1542330d57fbSAl Viro 	 */
1543330d57fbSAl Viro 	if (unlikely(p->used)) {
1544330d57fbSAl Viro 		struct completion wait;
1545330d57fbSAl Viro 		init_completion(&wait);
1546330d57fbSAl Viro 		p->unregistering = &wait;
1547330d57fbSAl Viro 		spin_unlock(&sysctl_lock);
1548330d57fbSAl Viro 		wait_for_completion(&wait);
1549330d57fbSAl Viro 		spin_lock(&sysctl_lock);
1550f7e6ced4SAl Viro 	} else {
1551f7e6ced4SAl Viro 		/* anything non-NULL; we'll never dereference it */
1552f7e6ced4SAl Viro 		p->unregistering = ERR_PTR(-EINVAL);
1553330d57fbSAl Viro 	}
1554330d57fbSAl Viro 	/*
1555330d57fbSAl Viro 	 * do not remove from the list until nobody holds it; walking the
1556330d57fbSAl Viro 	 * list in do_sysctl() relies on that.
1557330d57fbSAl Viro 	 */
1558330d57fbSAl Viro 	list_del_init(&p->ctl_entry);
1559330d57fbSAl Viro }
1560330d57fbSAl Viro 
1561f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head)
1562f7e6ced4SAl Viro {
1563f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1564f7e6ced4SAl Viro 	head->count++;
1565f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1566f7e6ced4SAl Viro }
1567f7e6ced4SAl Viro 
1568f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
1569f7e6ced4SAl Viro {
1570f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1571f7e6ced4SAl Viro 	if (!--head->count)
1572f7e6ced4SAl Viro 		kfree(head);
1573f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1574f7e6ced4SAl Viro }
1575f7e6ced4SAl Viro 
1576f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1577f7e6ced4SAl Viro {
1578f7e6ced4SAl Viro 	if (!head)
1579f7e6ced4SAl Viro 		BUG();
1580f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1581f7e6ced4SAl Viro 	if (!use_table(head))
1582f7e6ced4SAl Viro 		head = ERR_PTR(-ENOENT);
1583f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1584f7e6ced4SAl Viro 	return head;
1585f7e6ced4SAl Viro }
1586f7e6ced4SAl Viro 
1587805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head)
1588805b5d5eSEric W. Biederman {
1589805b5d5eSEric W. Biederman 	if (!head)
1590805b5d5eSEric W. Biederman 		return;
1591805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1592805b5d5eSEric W. Biederman 	unuse_table(head);
1593805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1594805b5d5eSEric W. Biederman }
1595805b5d5eSEric W. Biederman 
159673455092SAl Viro static struct ctl_table_set *
159773455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
159873455092SAl Viro {
159973455092SAl Viro 	struct ctl_table_set *set = &root->default_set;
160073455092SAl Viro 	if (root->lookup)
160173455092SAl Viro 		set = root->lookup(root, namespaces);
160273455092SAl Viro 	return set;
160373455092SAl Viro }
160473455092SAl Viro 
1605e51b6ba0SEric W. Biederman static struct list_head *
1606e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1607805b5d5eSEric W. Biederman {
160873455092SAl Viro 	struct ctl_table_set *set = lookup_header_set(root, namespaces);
160973455092SAl Viro 	return &set->list;
1610e51b6ba0SEric W. Biederman }
1611e51b6ba0SEric W. Biederman 
1612e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1613e51b6ba0SEric W. Biederman 					    struct ctl_table_header *prev)
1614e51b6ba0SEric W. Biederman {
1615e51b6ba0SEric W. Biederman 	struct ctl_table_root *root;
1616e51b6ba0SEric W. Biederman 	struct list_head *header_list;
1617805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1618805b5d5eSEric W. Biederman 	struct list_head *tmp;
1619e51b6ba0SEric W. Biederman 
1620805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1621805b5d5eSEric W. Biederman 	if (prev) {
1622e51b6ba0SEric W. Biederman 		head = prev;
1623805b5d5eSEric W. Biederman 		tmp = &prev->ctl_entry;
1624805b5d5eSEric W. Biederman 		unuse_table(prev);
1625805b5d5eSEric W. Biederman 		goto next;
1626805b5d5eSEric W. Biederman 	}
1627805b5d5eSEric W. Biederman 	tmp = &root_table_header.ctl_entry;
1628805b5d5eSEric W. Biederman 	for (;;) {
1629805b5d5eSEric W. Biederman 		head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1630805b5d5eSEric W. Biederman 
1631805b5d5eSEric W. Biederman 		if (!use_table(head))
1632805b5d5eSEric W. Biederman 			goto next;
1633805b5d5eSEric W. Biederman 		spin_unlock(&sysctl_lock);
1634805b5d5eSEric W. Biederman 		return head;
1635805b5d5eSEric W. Biederman 	next:
1636e51b6ba0SEric W. Biederman 		root = head->root;
1637805b5d5eSEric W. Biederman 		tmp = tmp->next;
1638e51b6ba0SEric W. Biederman 		header_list = lookup_header_list(root, namespaces);
1639e51b6ba0SEric W. Biederman 		if (tmp != header_list)
1640e51b6ba0SEric W. Biederman 			continue;
1641e51b6ba0SEric W. Biederman 
1642e51b6ba0SEric W. Biederman 		do {
1643e51b6ba0SEric W. Biederman 			root = list_entry(root->root_list.next,
1644e51b6ba0SEric W. Biederman 					struct ctl_table_root, root_list);
1645e51b6ba0SEric W. Biederman 			if (root == &sysctl_table_root)
1646e51b6ba0SEric W. Biederman 				goto out;
1647e51b6ba0SEric W. Biederman 			header_list = lookup_header_list(root, namespaces);
1648e51b6ba0SEric W. Biederman 		} while (list_empty(header_list));
1649e51b6ba0SEric W. Biederman 		tmp = header_list->next;
1650805b5d5eSEric W. Biederman 	}
1651e51b6ba0SEric W. Biederman out:
1652805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1653805b5d5eSEric W. Biederman 	return NULL;
1654805b5d5eSEric W. Biederman }
1655805b5d5eSEric W. Biederman 
1656e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1657e51b6ba0SEric W. Biederman {
1658e51b6ba0SEric W. Biederman 	return __sysctl_head_next(current->nsproxy, prev);
1659e51b6ba0SEric W. Biederman }
1660e51b6ba0SEric W. Biederman 
1661e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root)
1662e51b6ba0SEric W. Biederman {
1663e51b6ba0SEric W. Biederman 	spin_lock(&sysctl_lock);
1664e51b6ba0SEric W. Biederman 	list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1665e51b6ba0SEric W. Biederman 	spin_unlock(&sysctl_lock);
1666e51b6ba0SEric W. Biederman }
1667e51b6ba0SEric W. Biederman 
16681da177e4SLinus Torvalds /*
16691ff007ebSEric W. Biederman  * sysctl_perm does NOT grant the superuser all rights automatically, because
16701da177e4SLinus Torvalds  * some sysctl variables are readonly even to root.
16711da177e4SLinus Torvalds  */
16721da177e4SLinus Torvalds 
16731da177e4SLinus Torvalds static int test_perm(int mode, int op)
16741da177e4SLinus Torvalds {
167576aac0e9SDavid Howells 	if (!current_euid())
16761da177e4SLinus Torvalds 		mode >>= 6;
16771da177e4SLinus Torvalds 	else if (in_egroup_p(0))
16781da177e4SLinus Torvalds 		mode >>= 3;
1679e6305c43SAl Viro 	if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
16801da177e4SLinus Torvalds 		return 0;
16811da177e4SLinus Torvalds 	return -EACCES;
16821da177e4SLinus Torvalds }
16831da177e4SLinus Torvalds 
1684d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
16851da177e4SLinus Torvalds {
16861da177e4SLinus Torvalds 	int error;
1687d7321cd6SPavel Emelyanov 	int mode;
1688d7321cd6SPavel Emelyanov 
1689e6305c43SAl Viro 	error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
16901da177e4SLinus Torvalds 	if (error)
16911da177e4SLinus Torvalds 		return error;
1692d7321cd6SPavel Emelyanov 
1693d7321cd6SPavel Emelyanov 	if (root->permissions)
1694d7321cd6SPavel Emelyanov 		mode = root->permissions(root, current->nsproxy, table);
1695d7321cd6SPavel Emelyanov 	else
1696d7321cd6SPavel Emelyanov 		mode = table->mode;
1697d7321cd6SPavel Emelyanov 
1698d7321cd6SPavel Emelyanov 	return test_perm(mode, op);
16991da177e4SLinus Torvalds }
17001da177e4SLinus Torvalds 
1701d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1702d912b0ccSEric W. Biederman {
17032315ffa0SEric W. Biederman 	for (; table->procname; table++) {
1704d912b0ccSEric W. Biederman 		table->parent = parent;
1705d912b0ccSEric W. Biederman 		if (table->child)
1706d912b0ccSEric W. Biederman 			sysctl_set_parent(table, table->child);
1707d912b0ccSEric W. Biederman 	}
1708d912b0ccSEric W. Biederman }
1709d912b0ccSEric W. Biederman 
1710d912b0ccSEric W. Biederman static __init int sysctl_init(void)
1711d912b0ccSEric W. Biederman {
1712d912b0ccSEric W. Biederman 	sysctl_set_parent(NULL, root_table);
171388f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
171488f458e4SHolger Schurig 	{
171588f458e4SHolger Schurig 		int err;
1716e51b6ba0SEric W. Biederman 		err = sysctl_check_table(current->nsproxy, root_table);
171788f458e4SHolger Schurig 	}
171888f458e4SHolger Schurig #endif
1719d912b0ccSEric W. Biederman 	return 0;
1720d912b0ccSEric W. Biederman }
1721d912b0ccSEric W. Biederman 
1722d912b0ccSEric W. Biederman core_initcall(sysctl_init);
1723d912b0ccSEric W. Biederman 
1724bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch,
1725bfbcf034SAl Viro 				      struct ctl_table *table)
1726ae7edeccSAl Viro {
1727ae7edeccSAl Viro 	struct ctl_table *p;
1728ae7edeccSAl Viro 	const char *s = branch->procname;
1729ae7edeccSAl Viro 
1730ae7edeccSAl Viro 	/* branch should have named subdirectory as its first element */
1731ae7edeccSAl Viro 	if (!s || !branch->child)
1732bfbcf034SAl Viro 		return NULL;
1733ae7edeccSAl Viro 
1734ae7edeccSAl Viro 	/* ... and nothing else */
17352315ffa0SEric W. Biederman 	if (branch[1].procname)
1736bfbcf034SAl Viro 		return NULL;
1737ae7edeccSAl Viro 
1738ae7edeccSAl Viro 	/* table should contain subdirectory with the same name */
17392315ffa0SEric W. Biederman 	for (p = table; p->procname; p++) {
1740ae7edeccSAl Viro 		if (!p->child)
1741ae7edeccSAl Viro 			continue;
1742ae7edeccSAl Viro 		if (p->procname && strcmp(p->procname, s) == 0)
1743bfbcf034SAl Viro 			return p;
1744ae7edeccSAl Viro 	}
1745bfbcf034SAl Viro 	return NULL;
1746ae7edeccSAl Viro }
1747ae7edeccSAl Viro 
1748ae7edeccSAl Viro /* see if attaching q to p would be an improvement */
1749ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1750ae7edeccSAl Viro {
1751ae7edeccSAl Viro 	struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1752bfbcf034SAl Viro 	struct ctl_table *next;
1753ae7edeccSAl Viro 	int is_better = 0;
1754ae7edeccSAl Viro 	int not_in_parent = !p->attached_by;
1755ae7edeccSAl Viro 
1756bfbcf034SAl Viro 	while ((next = is_branch_in(by, to)) != NULL) {
1757ae7edeccSAl Viro 		if (by == q->attached_by)
1758ae7edeccSAl Viro 			is_better = 1;
1759ae7edeccSAl Viro 		if (to == p->attached_by)
1760ae7edeccSAl Viro 			not_in_parent = 1;
1761ae7edeccSAl Viro 		by = by->child;
1762bfbcf034SAl Viro 		to = next->child;
1763ae7edeccSAl Viro 	}
1764ae7edeccSAl Viro 
1765ae7edeccSAl Viro 	if (is_better && not_in_parent) {
1766ae7edeccSAl Viro 		q->attached_by = by;
1767ae7edeccSAl Viro 		q->attached_to = to;
1768ae7edeccSAl Viro 		q->parent = p;
1769ae7edeccSAl Viro 	}
1770ae7edeccSAl Viro }
1771ae7edeccSAl Viro 
17721da177e4SLinus Torvalds /**
1773e51b6ba0SEric W. Biederman  * __register_sysctl_paths - register a sysctl hierarchy
1774e51b6ba0SEric W. Biederman  * @root: List of sysctl headers to register on
1775e51b6ba0SEric W. Biederman  * @namespaces: Data to compute which lists of sysctl entries are visible
177629e796fdSEric W. Biederman  * @path: The path to the directory the sysctl table is in.
17771da177e4SLinus Torvalds  * @table: the top-level table structure
17781da177e4SLinus Torvalds  *
17791da177e4SLinus Torvalds  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
178029e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
17811da177e4SLinus Torvalds  *
1782d8217f07SEric W. Biederman  * The members of the &struct ctl_table structure are used as follows:
17831da177e4SLinus Torvalds  *
17841da177e4SLinus Torvalds  * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
17851da177e4SLinus Torvalds  *            enter a sysctl file
17861da177e4SLinus Torvalds  *
17871da177e4SLinus Torvalds  * data - a pointer to data for use by proc_handler
17881da177e4SLinus Torvalds  *
17891da177e4SLinus Torvalds  * maxlen - the maximum size in bytes of the data
17901da177e4SLinus Torvalds  *
17911da177e4SLinus Torvalds  * mode - the file permissions for the /proc/sys file, and for sysctl(2)
17921da177e4SLinus Torvalds  *
17931da177e4SLinus Torvalds  * child - a pointer to the child sysctl table if this entry is a directory, or
17941da177e4SLinus Torvalds  *         %NULL.
17951da177e4SLinus Torvalds  *
17961da177e4SLinus Torvalds  * proc_handler - the text handler routine (described below)
17971da177e4SLinus Torvalds  *
17981da177e4SLinus Torvalds  * de - for internal use by the sysctl routines
17991da177e4SLinus Torvalds  *
18001da177e4SLinus Torvalds  * extra1, extra2 - extra pointers usable by the proc handler routines
18011da177e4SLinus Torvalds  *
18021da177e4SLinus Torvalds  * Leaf nodes in the sysctl tree will be represented by a single file
18031da177e4SLinus Torvalds  * under /proc; non-leaf nodes will be represented by directories.
18041da177e4SLinus Torvalds  *
18051da177e4SLinus Torvalds  * sysctl(2) can automatically manage read and write requests through
18061da177e4SLinus Torvalds  * the sysctl table.  The data and maxlen fields of the ctl_table
18071da177e4SLinus Torvalds  * struct enable minimal validation of the values being written to be
18081da177e4SLinus Torvalds  * performed, and the mode field allows minimal authentication.
18091da177e4SLinus Torvalds  *
18101da177e4SLinus Torvalds  * There must be a proc_handler routine for any terminal nodes
18111da177e4SLinus Torvalds  * mirrored under /proc/sys (non-terminals are handled by a built-in
18121da177e4SLinus Torvalds  * directory handler).  Several default handlers are available to
18131da177e4SLinus Torvalds  * cover common cases -
18141da177e4SLinus Torvalds  *
18151da177e4SLinus Torvalds  * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
18161da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
18171da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
18181da177e4SLinus Torvalds  *
18191da177e4SLinus Torvalds  * It is the handler's job to read the input buffer from user memory
18201da177e4SLinus Torvalds  * and process it. The handler should return 0 on success.
18211da177e4SLinus Torvalds  *
18221da177e4SLinus Torvalds  * This routine returns %NULL on a failure to register, and a pointer
18231da177e4SLinus Torvalds  * to the table header on success.
18241da177e4SLinus Torvalds  */
1825e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths(
1826e51b6ba0SEric W. Biederman 	struct ctl_table_root *root,
1827e51b6ba0SEric W. Biederman 	struct nsproxy *namespaces,
1828e51b6ba0SEric W. Biederman 	const struct ctl_path *path, struct ctl_table *table)
18291da177e4SLinus Torvalds {
183029e796fdSEric W. Biederman 	struct ctl_table_header *header;
183129e796fdSEric W. Biederman 	struct ctl_table *new, **prevp;
183229e796fdSEric W. Biederman 	unsigned int n, npath;
1833ae7edeccSAl Viro 	struct ctl_table_set *set;
183429e796fdSEric W. Biederman 
183529e796fdSEric W. Biederman 	/* Count the path components */
18362315ffa0SEric W. Biederman 	for (npath = 0; path[npath].procname; ++npath)
183729e796fdSEric W. Biederman 		;
183829e796fdSEric W. Biederman 
183929e796fdSEric W. Biederman 	/*
184029e796fdSEric W. Biederman 	 * For each path component, allocate a 2-element ctl_table array.
184129e796fdSEric W. Biederman 	 * The first array element will be filled with the sysctl entry
18422315ffa0SEric W. Biederman 	 * for this, the second will be the sentinel (procname == 0).
184329e796fdSEric W. Biederman 	 *
184429e796fdSEric W. Biederman 	 * We allocate everything in one go so that we don't have to
184529e796fdSEric W. Biederman 	 * worry about freeing additional memory in unregister_sysctl_table.
184629e796fdSEric W. Biederman 	 */
184729e796fdSEric W. Biederman 	header = kzalloc(sizeof(struct ctl_table_header) +
184829e796fdSEric W. Biederman 			 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
184929e796fdSEric W. Biederman 	if (!header)
18501da177e4SLinus Torvalds 		return NULL;
185129e796fdSEric W. Biederman 
185229e796fdSEric W. Biederman 	new = (struct ctl_table *) (header + 1);
185329e796fdSEric W. Biederman 
185429e796fdSEric W. Biederman 	/* Now connect the dots */
185529e796fdSEric W. Biederman 	prevp = &header->ctl_table;
185629e796fdSEric W. Biederman 	for (n = 0; n < npath; ++n, ++path) {
185729e796fdSEric W. Biederman 		/* Copy the procname */
185829e796fdSEric W. Biederman 		new->procname = path->procname;
185929e796fdSEric W. Biederman 		new->mode     = 0555;
186029e796fdSEric W. Biederman 
186129e796fdSEric W. Biederman 		*prevp = new;
186229e796fdSEric W. Biederman 		prevp = &new->child;
186329e796fdSEric W. Biederman 
186429e796fdSEric W. Biederman 		new += 2;
186529e796fdSEric W. Biederman 	}
186629e796fdSEric W. Biederman 	*prevp = table;
186723eb06deSEric W. Biederman 	header->ctl_table_arg = table;
186829e796fdSEric W. Biederman 
186929e796fdSEric W. Biederman 	INIT_LIST_HEAD(&header->ctl_entry);
187029e796fdSEric W. Biederman 	header->used = 0;
187129e796fdSEric W. Biederman 	header->unregistering = NULL;
1872e51b6ba0SEric W. Biederman 	header->root = root;
187329e796fdSEric W. Biederman 	sysctl_set_parent(NULL, header->ctl_table);
1874f7e6ced4SAl Viro 	header->count = 1;
187588f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1876e51b6ba0SEric W. Biederman 	if (sysctl_check_table(namespaces, header->ctl_table)) {
187729e796fdSEric W. Biederman 		kfree(header);
1878fc6cd25bSEric W. Biederman 		return NULL;
1879fc6cd25bSEric W. Biederman 	}
188088f458e4SHolger Schurig #endif
1881330d57fbSAl Viro 	spin_lock(&sysctl_lock);
188273455092SAl Viro 	header->set = lookup_header_set(root, namespaces);
1883ae7edeccSAl Viro 	header->attached_by = header->ctl_table;
1884ae7edeccSAl Viro 	header->attached_to = root_table;
1885ae7edeccSAl Viro 	header->parent = &root_table_header;
1886ae7edeccSAl Viro 	for (set = header->set; set; set = set->parent) {
1887ae7edeccSAl Viro 		struct ctl_table_header *p;
1888ae7edeccSAl Viro 		list_for_each_entry(p, &set->list, ctl_entry) {
1889ae7edeccSAl Viro 			if (p->unregistering)
1890ae7edeccSAl Viro 				continue;
1891ae7edeccSAl Viro 			try_attach(p, header);
1892ae7edeccSAl Viro 		}
1893ae7edeccSAl Viro 	}
1894ae7edeccSAl Viro 	header->parent->count++;
189573455092SAl Viro 	list_add_tail(&header->ctl_entry, &header->set->list);
1896330d57fbSAl Viro 	spin_unlock(&sysctl_lock);
189729e796fdSEric W. Biederman 
189829e796fdSEric W. Biederman 	return header;
189929e796fdSEric W. Biederman }
190029e796fdSEric W. Biederman 
190129e796fdSEric W. Biederman /**
1902e51b6ba0SEric W. Biederman  * register_sysctl_table_path - register a sysctl table hierarchy
1903e51b6ba0SEric W. Biederman  * @path: The path to the directory the sysctl table is in.
1904e51b6ba0SEric W. Biederman  * @table: the top-level table structure
1905e51b6ba0SEric W. Biederman  *
1906e51b6ba0SEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1907e51b6ba0SEric W. Biederman  * array. A completely 0 filled entry terminates the table.
1908e51b6ba0SEric W. Biederman  *
1909e51b6ba0SEric W. Biederman  * See __register_sysctl_paths for more details.
1910e51b6ba0SEric W. Biederman  */
1911e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1912e51b6ba0SEric W. Biederman 						struct ctl_table *table)
1913e51b6ba0SEric W. Biederman {
1914e51b6ba0SEric W. Biederman 	return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1915e51b6ba0SEric W. Biederman 					path, table);
1916e51b6ba0SEric W. Biederman }
1917e51b6ba0SEric W. Biederman 
1918e51b6ba0SEric W. Biederman /**
191929e796fdSEric W. Biederman  * register_sysctl_table - register a sysctl table hierarchy
192029e796fdSEric W. Biederman  * @table: the top-level table structure
192129e796fdSEric W. Biederman  *
192229e796fdSEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
192329e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
192429e796fdSEric W. Biederman  *
192529e796fdSEric W. Biederman  * See register_sysctl_paths for more details.
192629e796fdSEric W. Biederman  */
192729e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
192829e796fdSEric W. Biederman {
192929e796fdSEric W. Biederman 	static const struct ctl_path null_path[] = { {} };
193029e796fdSEric W. Biederman 
193129e796fdSEric W. Biederman 	return register_sysctl_paths(null_path, table);
19321da177e4SLinus Torvalds }
19331da177e4SLinus Torvalds 
19341da177e4SLinus Torvalds /**
19351da177e4SLinus Torvalds  * unregister_sysctl_table - unregister a sysctl table hierarchy
19361da177e4SLinus Torvalds  * @header: the header returned from register_sysctl_table
19371da177e4SLinus Torvalds  *
19381da177e4SLinus Torvalds  * Unregisters the sysctl table and all children. proc entries may not
19391da177e4SLinus Torvalds  * actually be removed until they are no longer used by anyone.
19401da177e4SLinus Torvalds  */
19411da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header)
19421da177e4SLinus Torvalds {
1943330d57fbSAl Viro 	might_sleep();
1944f1dad166SPavel Emelyanov 
1945f1dad166SPavel Emelyanov 	if (header == NULL)
1946f1dad166SPavel Emelyanov 		return;
1947f1dad166SPavel Emelyanov 
1948330d57fbSAl Viro 	spin_lock(&sysctl_lock);
1949330d57fbSAl Viro 	start_unregistering(header);
1950ae7edeccSAl Viro 	if (!--header->parent->count) {
1951ae7edeccSAl Viro 		WARN_ON(1);
1952ae7edeccSAl Viro 		kfree(header->parent);
1953ae7edeccSAl Viro 	}
1954f7e6ced4SAl Viro 	if (!--header->count)
19551da177e4SLinus Torvalds 		kfree(header);
1956f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
19571da177e4SLinus Torvalds }
19581da177e4SLinus Torvalds 
19599043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p)
19609043476fSAl Viro {
19619043476fSAl Viro 	struct ctl_table_set *set = p->set;
19629043476fSAl Viro 	int res;
19639043476fSAl Viro 	spin_lock(&sysctl_lock);
19649043476fSAl Viro 	if (p->unregistering)
19659043476fSAl Viro 		res = 0;
19669043476fSAl Viro 	else if (!set->is_seen)
19679043476fSAl Viro 		res = 1;
19689043476fSAl Viro 	else
19699043476fSAl Viro 		res = set->is_seen(set);
19709043476fSAl Viro 	spin_unlock(&sysctl_lock);
19719043476fSAl Viro 	return res;
19729043476fSAl Viro }
19739043476fSAl Viro 
197473455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
197573455092SAl Viro 	struct ctl_table_set *parent,
197673455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
197773455092SAl Viro {
197873455092SAl Viro 	INIT_LIST_HEAD(&p->list);
197973455092SAl Viro 	p->parent = parent ? parent : &sysctl_table_root.default_set;
198073455092SAl Viro 	p->is_seen = is_seen;
198173455092SAl Viro }
198273455092SAl Viro 
1983b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */
1984d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
1985b89a8171SEric W. Biederman {
1986b89a8171SEric W. Biederman 	return NULL;
1987b89a8171SEric W. Biederman }
1988b89a8171SEric W. Biederman 
198929e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
199029e796fdSEric W. Biederman 						    struct ctl_table *table)
199129e796fdSEric W. Biederman {
199229e796fdSEric W. Biederman 	return NULL;
199329e796fdSEric W. Biederman }
199429e796fdSEric W. Biederman 
1995b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table)
1996b89a8171SEric W. Biederman {
1997b89a8171SEric W. Biederman }
1998b89a8171SEric W. Biederman 
199973455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
200073455092SAl Viro 	struct ctl_table_set *parent,
200173455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
200273455092SAl Viro {
200373455092SAl Viro }
200473455092SAl Viro 
2005f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
2006f7e6ced4SAl Viro {
2007f7e6ced4SAl Viro }
2008f7e6ced4SAl Viro 
2009b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
2010b89a8171SEric W. Biederman 
20111da177e4SLinus Torvalds /*
20121da177e4SLinus Torvalds  * /proc/sys support
20131da177e4SLinus Torvalds  */
20141da177e4SLinus Torvalds 
2015b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL
20161da177e4SLinus Torvalds 
2017b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write,
20188d65af78SAlexey Dobriyan 			   void __user *buffer,
2019b1ba4dddSAdrian Bunk 			   size_t *lenp, loff_t *ppos)
2020f5dd3d6fSSam Vilain {
2021f5dd3d6fSSam Vilain 	size_t len;
2022f5dd3d6fSSam Vilain 	char __user *p;
2023f5dd3d6fSSam Vilain 	char c;
2024f5dd3d6fSSam Vilain 
20258d060877SOleg Nesterov 	if (!data || !maxlen || !*lenp) {
2026f5dd3d6fSSam Vilain 		*lenp = 0;
2027f5dd3d6fSSam Vilain 		return 0;
2028f5dd3d6fSSam Vilain 	}
2029f5dd3d6fSSam Vilain 
2030f5dd3d6fSSam Vilain 	if (write) {
2031f5dd3d6fSSam Vilain 		len = 0;
2032f5dd3d6fSSam Vilain 		p = buffer;
2033f5dd3d6fSSam Vilain 		while (len < *lenp) {
2034f5dd3d6fSSam Vilain 			if (get_user(c, p++))
2035f5dd3d6fSSam Vilain 				return -EFAULT;
2036f5dd3d6fSSam Vilain 			if (c == 0 || c == '\n')
2037f5dd3d6fSSam Vilain 				break;
2038f5dd3d6fSSam Vilain 			len++;
2039f5dd3d6fSSam Vilain 		}
2040f5dd3d6fSSam Vilain 		if (len >= maxlen)
2041f5dd3d6fSSam Vilain 			len = maxlen-1;
2042f5dd3d6fSSam Vilain 		if(copy_from_user(data, buffer, len))
2043f5dd3d6fSSam Vilain 			return -EFAULT;
2044f5dd3d6fSSam Vilain 		((char *) data)[len] = 0;
2045f5dd3d6fSSam Vilain 		*ppos += *lenp;
2046f5dd3d6fSSam Vilain 	} else {
2047f5dd3d6fSSam Vilain 		len = strlen(data);
2048f5dd3d6fSSam Vilain 		if (len > maxlen)
2049f5dd3d6fSSam Vilain 			len = maxlen;
20508d060877SOleg Nesterov 
20518d060877SOleg Nesterov 		if (*ppos > len) {
20528d060877SOleg Nesterov 			*lenp = 0;
20538d060877SOleg Nesterov 			return 0;
20548d060877SOleg Nesterov 		}
20558d060877SOleg Nesterov 
20568d060877SOleg Nesterov 		data += *ppos;
20578d060877SOleg Nesterov 		len  -= *ppos;
20588d060877SOleg Nesterov 
2059f5dd3d6fSSam Vilain 		if (len > *lenp)
2060f5dd3d6fSSam Vilain 			len = *lenp;
2061f5dd3d6fSSam Vilain 		if (len)
2062f5dd3d6fSSam Vilain 			if(copy_to_user(buffer, data, len))
2063f5dd3d6fSSam Vilain 				return -EFAULT;
2064f5dd3d6fSSam Vilain 		if (len < *lenp) {
2065f5dd3d6fSSam Vilain 			if(put_user('\n', ((char __user *) buffer) + len))
2066f5dd3d6fSSam Vilain 				return -EFAULT;
2067f5dd3d6fSSam Vilain 			len++;
2068f5dd3d6fSSam Vilain 		}
2069f5dd3d6fSSam Vilain 		*lenp = len;
2070f5dd3d6fSSam Vilain 		*ppos += len;
2071f5dd3d6fSSam Vilain 	}
2072f5dd3d6fSSam Vilain 	return 0;
2073f5dd3d6fSSam Vilain }
2074f5dd3d6fSSam Vilain 
20751da177e4SLinus Torvalds /**
20761da177e4SLinus Torvalds  * proc_dostring - read a string sysctl
20771da177e4SLinus Torvalds  * @table: the sysctl table
20781da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
20791da177e4SLinus Torvalds  * @buffer: the user buffer
20801da177e4SLinus Torvalds  * @lenp: the size of the user buffer
20811da177e4SLinus Torvalds  * @ppos: file position
20821da177e4SLinus Torvalds  *
20831da177e4SLinus Torvalds  * Reads/writes a string from/to the user buffer. If the kernel
20841da177e4SLinus Torvalds  * buffer provided is not large enough to hold the string, the
20851da177e4SLinus Torvalds  * string is truncated. The copied string is %NULL-terminated.
20861da177e4SLinus Torvalds  * If the string is being read by the user process, it is copied
20871da177e4SLinus Torvalds  * and a newline '\n' is added. It is truncated if the buffer is
20881da177e4SLinus Torvalds  * not large enough.
20891da177e4SLinus Torvalds  *
20901da177e4SLinus Torvalds  * Returns 0 on success.
20911da177e4SLinus Torvalds  */
20928d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write,
20931da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
20941da177e4SLinus Torvalds {
20958d65af78SAlexey Dobriyan 	return _proc_do_string(table->data, table->maxlen, write,
2096f5dd3d6fSSam Vilain 			       buffer, lenp, ppos);
20971da177e4SLinus Torvalds }
20981da177e4SLinus Torvalds 
209900b7c339SAmerigo Wang static size_t proc_skip_spaces(char **buf)
210000b7c339SAmerigo Wang {
210100b7c339SAmerigo Wang 	size_t ret;
210200b7c339SAmerigo Wang 	char *tmp = skip_spaces(*buf);
210300b7c339SAmerigo Wang 	ret = tmp - *buf;
210400b7c339SAmerigo Wang 	*buf = tmp;
210500b7c339SAmerigo Wang 	return ret;
210600b7c339SAmerigo Wang }
21071da177e4SLinus Torvalds 
21089f977fb7SOctavian Purdila static void proc_skip_char(char **buf, size_t *size, const char v)
21099f977fb7SOctavian Purdila {
21109f977fb7SOctavian Purdila 	while (*size) {
21119f977fb7SOctavian Purdila 		if (**buf != v)
21129f977fb7SOctavian Purdila 			break;
21139f977fb7SOctavian Purdila 		(*size)--;
21149f977fb7SOctavian Purdila 		(*buf)++;
21159f977fb7SOctavian Purdila 	}
21169f977fb7SOctavian Purdila }
21179f977fb7SOctavian Purdila 
211800b7c339SAmerigo Wang #define TMPBUFLEN 22
211900b7c339SAmerigo Wang /**
21200fc377bdSRandy Dunlap  * proc_get_long - reads an ASCII formatted integer from a user buffer
212100b7c339SAmerigo Wang  *
21220fc377bdSRandy Dunlap  * @buf: a kernel buffer
21230fc377bdSRandy Dunlap  * @size: size of the kernel buffer
21240fc377bdSRandy Dunlap  * @val: this is where the number will be stored
21250fc377bdSRandy Dunlap  * @neg: set to %TRUE if number is negative
21260fc377bdSRandy Dunlap  * @perm_tr: a vector which contains the allowed trailers
21270fc377bdSRandy Dunlap  * @perm_tr_len: size of the perm_tr vector
21280fc377bdSRandy Dunlap  * @tr: pointer to store the trailer character
212900b7c339SAmerigo Wang  *
21300fc377bdSRandy Dunlap  * In case of success %0 is returned and @buf and @size are updated with
21310fc377bdSRandy Dunlap  * the amount of bytes read. If @tr is non-NULL and a trailing
21320fc377bdSRandy Dunlap  * character exists (size is non-zero after returning from this
21330fc377bdSRandy Dunlap  * function), @tr is updated with the trailing character.
213400b7c339SAmerigo Wang  */
213500b7c339SAmerigo Wang static int proc_get_long(char **buf, size_t *size,
213600b7c339SAmerigo Wang 			  unsigned long *val, bool *neg,
213700b7c339SAmerigo Wang 			  const char *perm_tr, unsigned perm_tr_len, char *tr)
213800b7c339SAmerigo Wang {
213900b7c339SAmerigo Wang 	int len;
214000b7c339SAmerigo Wang 	char *p, tmp[TMPBUFLEN];
214100b7c339SAmerigo Wang 
214200b7c339SAmerigo Wang 	if (!*size)
214300b7c339SAmerigo Wang 		return -EINVAL;
214400b7c339SAmerigo Wang 
214500b7c339SAmerigo Wang 	len = *size;
214600b7c339SAmerigo Wang 	if (len > TMPBUFLEN - 1)
214700b7c339SAmerigo Wang 		len = TMPBUFLEN - 1;
214800b7c339SAmerigo Wang 
214900b7c339SAmerigo Wang 	memcpy(tmp, *buf, len);
215000b7c339SAmerigo Wang 
215100b7c339SAmerigo Wang 	tmp[len] = 0;
215200b7c339SAmerigo Wang 	p = tmp;
215300b7c339SAmerigo Wang 	if (*p == '-' && *size > 1) {
215400b7c339SAmerigo Wang 		*neg = true;
215500b7c339SAmerigo Wang 		p++;
215600b7c339SAmerigo Wang 	} else
215700b7c339SAmerigo Wang 		*neg = false;
215800b7c339SAmerigo Wang 	if (!isdigit(*p))
215900b7c339SAmerigo Wang 		return -EINVAL;
216000b7c339SAmerigo Wang 
216100b7c339SAmerigo Wang 	*val = simple_strtoul(p, &p, 0);
216200b7c339SAmerigo Wang 
216300b7c339SAmerigo Wang 	len = p - tmp;
216400b7c339SAmerigo Wang 
216500b7c339SAmerigo Wang 	/* We don't know if the next char is whitespace thus we may accept
216600b7c339SAmerigo Wang 	 * invalid integers (e.g. 1234...a) or two integers instead of one
216700b7c339SAmerigo Wang 	 * (e.g. 123...1). So lets not allow such large numbers. */
216800b7c339SAmerigo Wang 	if (len == TMPBUFLEN - 1)
216900b7c339SAmerigo Wang 		return -EINVAL;
217000b7c339SAmerigo Wang 
217100b7c339SAmerigo Wang 	if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
217200b7c339SAmerigo Wang 		return -EINVAL;
217300b7c339SAmerigo Wang 
217400b7c339SAmerigo Wang 	if (tr && (len < *size))
217500b7c339SAmerigo Wang 		*tr = *p;
217600b7c339SAmerigo Wang 
217700b7c339SAmerigo Wang 	*buf += len;
217800b7c339SAmerigo Wang 	*size -= len;
217900b7c339SAmerigo Wang 
218000b7c339SAmerigo Wang 	return 0;
218100b7c339SAmerigo Wang }
218200b7c339SAmerigo Wang 
218300b7c339SAmerigo Wang /**
21840fc377bdSRandy Dunlap  * proc_put_long - converts an integer to a decimal ASCII formatted string
218500b7c339SAmerigo Wang  *
21860fc377bdSRandy Dunlap  * @buf: the user buffer
21870fc377bdSRandy Dunlap  * @size: the size of the user buffer
21880fc377bdSRandy Dunlap  * @val: the integer to be converted
21890fc377bdSRandy Dunlap  * @neg: sign of the number, %TRUE for negative
219000b7c339SAmerigo Wang  *
21910fc377bdSRandy Dunlap  * In case of success %0 is returned and @buf and @size are updated with
21920fc377bdSRandy Dunlap  * the amount of bytes written.
219300b7c339SAmerigo Wang  */
219400b7c339SAmerigo Wang static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
219500b7c339SAmerigo Wang 			  bool neg)
219600b7c339SAmerigo Wang {
219700b7c339SAmerigo Wang 	int len;
219800b7c339SAmerigo Wang 	char tmp[TMPBUFLEN], *p = tmp;
219900b7c339SAmerigo Wang 
220000b7c339SAmerigo Wang 	sprintf(p, "%s%lu", neg ? "-" : "", val);
220100b7c339SAmerigo Wang 	len = strlen(tmp);
220200b7c339SAmerigo Wang 	if (len > *size)
220300b7c339SAmerigo Wang 		len = *size;
220400b7c339SAmerigo Wang 	if (copy_to_user(*buf, tmp, len))
220500b7c339SAmerigo Wang 		return -EFAULT;
220600b7c339SAmerigo Wang 	*size -= len;
220700b7c339SAmerigo Wang 	*buf += len;
220800b7c339SAmerigo Wang 	return 0;
220900b7c339SAmerigo Wang }
221000b7c339SAmerigo Wang #undef TMPBUFLEN
221100b7c339SAmerigo Wang 
221200b7c339SAmerigo Wang static int proc_put_char(void __user **buf, size_t *size, char c)
221300b7c339SAmerigo Wang {
221400b7c339SAmerigo Wang 	if (*size) {
221500b7c339SAmerigo Wang 		char __user **buffer = (char __user **)buf;
221600b7c339SAmerigo Wang 		if (put_user(c, *buffer))
221700b7c339SAmerigo Wang 			return -EFAULT;
221800b7c339SAmerigo Wang 		(*size)--, (*buffer)++;
221900b7c339SAmerigo Wang 		*buf = *buffer;
222000b7c339SAmerigo Wang 	}
222100b7c339SAmerigo Wang 	return 0;
222200b7c339SAmerigo Wang }
222300b7c339SAmerigo Wang 
222400b7c339SAmerigo Wang static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
22251da177e4SLinus Torvalds 				 int *valp,
22261da177e4SLinus Torvalds 				 int write, void *data)
22271da177e4SLinus Torvalds {
22281da177e4SLinus Torvalds 	if (write) {
22291da177e4SLinus Torvalds 		*valp = *negp ? -*lvalp : *lvalp;
22301da177e4SLinus Torvalds 	} else {
22311da177e4SLinus Torvalds 		int val = *valp;
22321da177e4SLinus Torvalds 		if (val < 0) {
223300b7c339SAmerigo Wang 			*negp = true;
22341da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
22351da177e4SLinus Torvalds 		} else {
223600b7c339SAmerigo Wang 			*negp = false;
22371da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
22381da177e4SLinus Torvalds 		}
22391da177e4SLinus Torvalds 	}
22401da177e4SLinus Torvalds 	return 0;
22411da177e4SLinus Torvalds }
22421da177e4SLinus Torvalds 
224300b7c339SAmerigo Wang static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
224400b7c339SAmerigo Wang 
2245d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
22468d65af78SAlexey Dobriyan 		  int write, void __user *buffer,
2247fcfbd547SKirill Korotaev 		  size_t *lenp, loff_t *ppos,
224800b7c339SAmerigo Wang 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
22491da177e4SLinus Torvalds 			      int write, void *data),
22501da177e4SLinus Torvalds 		  void *data)
22511da177e4SLinus Torvalds {
225200b7c339SAmerigo Wang 	int *i, vleft, first = 1, err = 0;
225300b7c339SAmerigo Wang 	unsigned long page = 0;
225400b7c339SAmerigo Wang 	size_t left;
225500b7c339SAmerigo Wang 	char *kbuf;
22561da177e4SLinus Torvalds 
225700b7c339SAmerigo Wang 	if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
22581da177e4SLinus Torvalds 		*lenp = 0;
22591da177e4SLinus Torvalds 		return 0;
22601da177e4SLinus Torvalds 	}
22611da177e4SLinus Torvalds 
2262fcfbd547SKirill Korotaev 	i = (int *) tbl_data;
22631da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(*i);
22641da177e4SLinus Torvalds 	left = *lenp;
22651da177e4SLinus Torvalds 
22661da177e4SLinus Torvalds 	if (!conv)
22671da177e4SLinus Torvalds 		conv = do_proc_dointvec_conv;
22681da177e4SLinus Torvalds 
226900b7c339SAmerigo Wang 	if (write) {
227000b7c339SAmerigo Wang 		if (left > PAGE_SIZE - 1)
227100b7c339SAmerigo Wang 			left = PAGE_SIZE - 1;
227200b7c339SAmerigo Wang 		page = __get_free_page(GFP_TEMPORARY);
227300b7c339SAmerigo Wang 		kbuf = (char *) page;
227400b7c339SAmerigo Wang 		if (!kbuf)
227500b7c339SAmerigo Wang 			return -ENOMEM;
227600b7c339SAmerigo Wang 		if (copy_from_user(kbuf, buffer, left)) {
227700b7c339SAmerigo Wang 			err = -EFAULT;
227800b7c339SAmerigo Wang 			goto free;
227900b7c339SAmerigo Wang 		}
228000b7c339SAmerigo Wang 		kbuf[left] = 0;
228100b7c339SAmerigo Wang 	}
228200b7c339SAmerigo Wang 
22831da177e4SLinus Torvalds 	for (; left && vleft--; i++, first=0) {
228400b7c339SAmerigo Wang 		unsigned long lval;
228500b7c339SAmerigo Wang 		bool neg;
228600b7c339SAmerigo Wang 
22871da177e4SLinus Torvalds 		if (write) {
228800b7c339SAmerigo Wang 			left -= proc_skip_spaces(&kbuf);
228900b7c339SAmerigo Wang 
2290563b0467SJ. R. Okajima 			if (!left)
2291563b0467SJ. R. Okajima 				break;
229200b7c339SAmerigo Wang 			err = proc_get_long(&kbuf, &left, &lval, &neg,
229300b7c339SAmerigo Wang 					     proc_wspace_sep,
229400b7c339SAmerigo Wang 					     sizeof(proc_wspace_sep), NULL);
229500b7c339SAmerigo Wang 			if (err)
22961da177e4SLinus Torvalds 				break;
229700b7c339SAmerigo Wang 			if (conv(&neg, &lval, i, 1, data)) {
229800b7c339SAmerigo Wang 				err = -EINVAL;
229900b7c339SAmerigo Wang 				break;
23001da177e4SLinus Torvalds 			}
23011da177e4SLinus Torvalds 		} else {
230200b7c339SAmerigo Wang 			if (conv(&neg, &lval, i, 0, data)) {
230300b7c339SAmerigo Wang 				err = -EINVAL;
230400b7c339SAmerigo Wang 				break;
230500b7c339SAmerigo Wang 			}
23061da177e4SLinus Torvalds 			if (!first)
230700b7c339SAmerigo Wang 				err = proc_put_char(&buffer, &left, '\t');
230800b7c339SAmerigo Wang 			if (err)
23091da177e4SLinus Torvalds 				break;
231000b7c339SAmerigo Wang 			err = proc_put_long(&buffer, &left, lval, neg);
231100b7c339SAmerigo Wang 			if (err)
231200b7c339SAmerigo Wang 				break;
23131da177e4SLinus Torvalds 		}
23141da177e4SLinus Torvalds 	}
23151da177e4SLinus Torvalds 
231600b7c339SAmerigo Wang 	if (!write && !first && left && !err)
231700b7c339SAmerigo Wang 		err = proc_put_char(&buffer, &left, '\n');
2318563b0467SJ. R. Okajima 	if (write && !err && left)
231900b7c339SAmerigo Wang 		left -= proc_skip_spaces(&kbuf);
232000b7c339SAmerigo Wang free:
23211da177e4SLinus Torvalds 	if (write) {
232200b7c339SAmerigo Wang 		free_page(page);
232300b7c339SAmerigo Wang 		if (first)
232400b7c339SAmerigo Wang 			return err ? : -EINVAL;
23251da177e4SLinus Torvalds 	}
23261da177e4SLinus Torvalds 	*lenp -= left;
23271da177e4SLinus Torvalds 	*ppos += *lenp;
232800b7c339SAmerigo Wang 	return err;
23291da177e4SLinus Torvalds }
23301da177e4SLinus Torvalds 
23318d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write,
2332fcfbd547SKirill Korotaev 		  void __user *buffer, size_t *lenp, loff_t *ppos,
233300b7c339SAmerigo Wang 		  int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2334fcfbd547SKirill Korotaev 			      int write, void *data),
2335fcfbd547SKirill Korotaev 		  void *data)
2336fcfbd547SKirill Korotaev {
23378d65af78SAlexey Dobriyan 	return __do_proc_dointvec(table->data, table, write,
2338fcfbd547SKirill Korotaev 			buffer, lenp, ppos, conv, data);
2339fcfbd547SKirill Korotaev }
2340fcfbd547SKirill Korotaev 
23411da177e4SLinus Torvalds /**
23421da177e4SLinus Torvalds  * proc_dointvec - read a vector of integers
23431da177e4SLinus Torvalds  * @table: the sysctl table
23441da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
23451da177e4SLinus Torvalds  * @buffer: the user buffer
23461da177e4SLinus Torvalds  * @lenp: the size of the user buffer
23471da177e4SLinus Torvalds  * @ppos: file position
23481da177e4SLinus Torvalds  *
23491da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
23501da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
23511da177e4SLinus Torvalds  *
23521da177e4SLinus Torvalds  * Returns 0 on success.
23531da177e4SLinus Torvalds  */
23548d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write,
23551da177e4SLinus Torvalds 		     void __user *buffer, size_t *lenp, loff_t *ppos)
23561da177e4SLinus Torvalds {
23578d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
23581da177e4SLinus Torvalds 		    	    NULL,NULL);
23591da177e4SLinus Torvalds }
23601da177e4SLinus Torvalds 
236134f5a398STheodore Ts'o /*
236234f5a398STheodore Ts'o  * Taint values can only be increased
236325ddbb18SAndi Kleen  * This means we can safely use a temporary.
236434f5a398STheodore Ts'o  */
23658d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write,
236634f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos)
236734f5a398STheodore Ts'o {
236825ddbb18SAndi Kleen 	struct ctl_table t;
236925ddbb18SAndi Kleen 	unsigned long tmptaint = get_taint();
237025ddbb18SAndi Kleen 	int err;
237134f5a398STheodore Ts'o 
237291fcd412SBastian Blank 	if (write && !capable(CAP_SYS_ADMIN))
237334f5a398STheodore Ts'o 		return -EPERM;
237434f5a398STheodore Ts'o 
237525ddbb18SAndi Kleen 	t = *table;
237625ddbb18SAndi Kleen 	t.data = &tmptaint;
23778d65af78SAlexey Dobriyan 	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
237825ddbb18SAndi Kleen 	if (err < 0)
237925ddbb18SAndi Kleen 		return err;
238025ddbb18SAndi Kleen 
238125ddbb18SAndi Kleen 	if (write) {
238225ddbb18SAndi Kleen 		/*
238325ddbb18SAndi Kleen 		 * Poor man's atomic or. Not worth adding a primitive
238425ddbb18SAndi Kleen 		 * to everyone's atomic.h for this
238525ddbb18SAndi Kleen 		 */
238625ddbb18SAndi Kleen 		int i;
238725ddbb18SAndi Kleen 		for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
238825ddbb18SAndi Kleen 			if ((tmptaint >> i) & 1)
238925ddbb18SAndi Kleen 				add_taint(i);
239025ddbb18SAndi Kleen 		}
239125ddbb18SAndi Kleen 	}
239225ddbb18SAndi Kleen 
239325ddbb18SAndi Kleen 	return err;
239434f5a398STheodore Ts'o }
239534f5a398STheodore Ts'o 
23961da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param {
23971da177e4SLinus Torvalds 	int *min;
23981da177e4SLinus Torvalds 	int *max;
23991da177e4SLinus Torvalds };
24001da177e4SLinus Torvalds 
240100b7c339SAmerigo Wang static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
24021da177e4SLinus Torvalds 					int *valp,
24031da177e4SLinus Torvalds 					int write, void *data)
24041da177e4SLinus Torvalds {
24051da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param *param = data;
24061da177e4SLinus Torvalds 	if (write) {
24071da177e4SLinus Torvalds 		int val = *negp ? -*lvalp : *lvalp;
24081da177e4SLinus Torvalds 		if ((param->min && *param->min > val) ||
24091da177e4SLinus Torvalds 		    (param->max && *param->max < val))
24101da177e4SLinus Torvalds 			return -EINVAL;
24111da177e4SLinus Torvalds 		*valp = val;
24121da177e4SLinus Torvalds 	} else {
24131da177e4SLinus Torvalds 		int val = *valp;
24141da177e4SLinus Torvalds 		if (val < 0) {
241500b7c339SAmerigo Wang 			*negp = true;
24161da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
24171da177e4SLinus Torvalds 		} else {
241800b7c339SAmerigo Wang 			*negp = false;
24191da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
24201da177e4SLinus Torvalds 		}
24211da177e4SLinus Torvalds 	}
24221da177e4SLinus Torvalds 	return 0;
24231da177e4SLinus Torvalds }
24241da177e4SLinus Torvalds 
24251da177e4SLinus Torvalds /**
24261da177e4SLinus Torvalds  * proc_dointvec_minmax - read a vector of integers with min/max values
24271da177e4SLinus Torvalds  * @table: the sysctl table
24281da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24291da177e4SLinus Torvalds  * @buffer: the user buffer
24301da177e4SLinus Torvalds  * @lenp: the size of the user buffer
24311da177e4SLinus Torvalds  * @ppos: file position
24321da177e4SLinus Torvalds  *
24331da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
24341da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
24351da177e4SLinus Torvalds  *
24361da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
24371da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
24381da177e4SLinus Torvalds  *
24391da177e4SLinus Torvalds  * Returns 0 on success.
24401da177e4SLinus Torvalds  */
24418d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write,
24421da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
24431da177e4SLinus Torvalds {
24441da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param param = {
24451da177e4SLinus Torvalds 		.min = (int *) table->extra1,
24461da177e4SLinus Torvalds 		.max = (int *) table->extra2,
24471da177e4SLinus Torvalds 	};
24488d65af78SAlexey Dobriyan 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
24491da177e4SLinus Torvalds 				do_proc_dointvec_minmax_conv, &param);
24501da177e4SLinus Torvalds }
24511da177e4SLinus Torvalds 
2452d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
24531da177e4SLinus Torvalds 				     void __user *buffer,
24541da177e4SLinus Torvalds 				     size_t *lenp, loff_t *ppos,
24551da177e4SLinus Torvalds 				     unsigned long convmul,
24561da177e4SLinus Torvalds 				     unsigned long convdiv)
24571da177e4SLinus Torvalds {
245800b7c339SAmerigo Wang 	unsigned long *i, *min, *max;
245900b7c339SAmerigo Wang 	int vleft, first = 1, err = 0;
246000b7c339SAmerigo Wang 	unsigned long page = 0;
246100b7c339SAmerigo Wang 	size_t left;
246200b7c339SAmerigo Wang 	char *kbuf;
24631da177e4SLinus Torvalds 
246400b7c339SAmerigo Wang 	if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
24651da177e4SLinus Torvalds 		*lenp = 0;
24661da177e4SLinus Torvalds 		return 0;
24671da177e4SLinus Torvalds 	}
24681da177e4SLinus Torvalds 
2469fcfbd547SKirill Korotaev 	i = (unsigned long *) data;
24701da177e4SLinus Torvalds 	min = (unsigned long *) table->extra1;
24711da177e4SLinus Torvalds 	max = (unsigned long *) table->extra2;
24721da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(unsigned long);
24731da177e4SLinus Torvalds 	left = *lenp;
24741da177e4SLinus Torvalds 
24751da177e4SLinus Torvalds 	if (write) {
247600b7c339SAmerigo Wang 		if (left > PAGE_SIZE - 1)
247700b7c339SAmerigo Wang 			left = PAGE_SIZE - 1;
247800b7c339SAmerigo Wang 		page = __get_free_page(GFP_TEMPORARY);
247900b7c339SAmerigo Wang 		kbuf = (char *) page;
248000b7c339SAmerigo Wang 		if (!kbuf)
248100b7c339SAmerigo Wang 			return -ENOMEM;
248200b7c339SAmerigo Wang 		if (copy_from_user(kbuf, buffer, left)) {
248300b7c339SAmerigo Wang 			err = -EFAULT;
248400b7c339SAmerigo Wang 			goto free;
24851da177e4SLinus Torvalds 		}
248600b7c339SAmerigo Wang 		kbuf[left] = 0;
24871da177e4SLinus Torvalds 	}
24881da177e4SLinus Torvalds 
248900b7c339SAmerigo Wang 	for (; left && vleft--; i++, min++, max++, first=0) {
249000b7c339SAmerigo Wang 		unsigned long val;
249100b7c339SAmerigo Wang 
249200b7c339SAmerigo Wang 		if (write) {
249300b7c339SAmerigo Wang 			bool neg;
249400b7c339SAmerigo Wang 
249500b7c339SAmerigo Wang 			left -= proc_skip_spaces(&kbuf);
249600b7c339SAmerigo Wang 
249700b7c339SAmerigo Wang 			err = proc_get_long(&kbuf, &left, &val, &neg,
249800b7c339SAmerigo Wang 					     proc_wspace_sep,
249900b7c339SAmerigo Wang 					     sizeof(proc_wspace_sep), NULL);
250000b7c339SAmerigo Wang 			if (err)
250100b7c339SAmerigo Wang 				break;
25021da177e4SLinus Torvalds 			if (neg)
25031da177e4SLinus Torvalds 				continue;
25041da177e4SLinus Torvalds 			if ((min && val < *min) || (max && val > *max))
25051da177e4SLinus Torvalds 				continue;
25061da177e4SLinus Torvalds 			*i = val;
25071da177e4SLinus Torvalds 		} else {
250800b7c339SAmerigo Wang 			val = convdiv * (*i) / convmul;
25091da177e4SLinus Torvalds 			if (!first)
251000b7c339SAmerigo Wang 				err = proc_put_char(&buffer, &left, '\t');
251100b7c339SAmerigo Wang 			err = proc_put_long(&buffer, &left, val, false);
251200b7c339SAmerigo Wang 			if (err)
251300b7c339SAmerigo Wang 				break;
25141da177e4SLinus Torvalds 		}
25151da177e4SLinus Torvalds 	}
25161da177e4SLinus Torvalds 
251700b7c339SAmerigo Wang 	if (!write && !first && left && !err)
251800b7c339SAmerigo Wang 		err = proc_put_char(&buffer, &left, '\n');
251900b7c339SAmerigo Wang 	if (write && !err)
252000b7c339SAmerigo Wang 		left -= proc_skip_spaces(&kbuf);
252100b7c339SAmerigo Wang free:
25221da177e4SLinus Torvalds 	if (write) {
252300b7c339SAmerigo Wang 		free_page(page);
252400b7c339SAmerigo Wang 		if (first)
252500b7c339SAmerigo Wang 			return err ? : -EINVAL;
25261da177e4SLinus Torvalds 	}
25271da177e4SLinus Torvalds 	*lenp -= left;
25281da177e4SLinus Torvalds 	*ppos += *lenp;
252900b7c339SAmerigo Wang 	return err;
25301da177e4SLinus Torvalds }
25311da177e4SLinus Torvalds 
2532d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2533fcfbd547SKirill Korotaev 				     void __user *buffer,
2534fcfbd547SKirill Korotaev 				     size_t *lenp, loff_t *ppos,
2535fcfbd547SKirill Korotaev 				     unsigned long convmul,
2536fcfbd547SKirill Korotaev 				     unsigned long convdiv)
2537fcfbd547SKirill Korotaev {
2538fcfbd547SKirill Korotaev 	return __do_proc_doulongvec_minmax(table->data, table, write,
25398d65af78SAlexey Dobriyan 			buffer, lenp, ppos, convmul, convdiv);
2540fcfbd547SKirill Korotaev }
2541fcfbd547SKirill Korotaev 
25421da177e4SLinus Torvalds /**
25431da177e4SLinus Torvalds  * proc_doulongvec_minmax - read a vector of long integers with min/max values
25441da177e4SLinus Torvalds  * @table: the sysctl table
25451da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25461da177e4SLinus Torvalds  * @buffer: the user buffer
25471da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25481da177e4SLinus Torvalds  * @ppos: file position
25491da177e4SLinus Torvalds  *
25501da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
25511da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25521da177e4SLinus Torvalds  *
25531da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
25541da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
25551da177e4SLinus Torvalds  *
25561da177e4SLinus Torvalds  * Returns 0 on success.
25571da177e4SLinus Torvalds  */
25588d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write,
25591da177e4SLinus Torvalds 			   void __user *buffer, size_t *lenp, loff_t *ppos)
25601da177e4SLinus Torvalds {
25618d65af78SAlexey Dobriyan     return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
25621da177e4SLinus Torvalds }
25631da177e4SLinus Torvalds 
25641da177e4SLinus Torvalds /**
25651da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
25661da177e4SLinus Torvalds  * @table: the sysctl table
25671da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25681da177e4SLinus Torvalds  * @buffer: the user buffer
25691da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25701da177e4SLinus Torvalds  * @ppos: file position
25711da177e4SLinus Torvalds  *
25721da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
25731da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string. The values
25741da177e4SLinus Torvalds  * are treated as milliseconds, and converted to jiffies when they are stored.
25751da177e4SLinus Torvalds  *
25761da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
25771da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
25781da177e4SLinus Torvalds  *
25791da177e4SLinus Torvalds  * Returns 0 on success.
25801da177e4SLinus Torvalds  */
2581d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
25821da177e4SLinus Torvalds 				      void __user *buffer,
25831da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
25841da177e4SLinus Torvalds {
25858d65af78SAlexey Dobriyan     return do_proc_doulongvec_minmax(table, write, buffer,
25861da177e4SLinus Torvalds 				     lenp, ppos, HZ, 1000l);
25871da177e4SLinus Torvalds }
25881da177e4SLinus Torvalds 
25891da177e4SLinus Torvalds 
259000b7c339SAmerigo Wang static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
25911da177e4SLinus Torvalds 					 int *valp,
25921da177e4SLinus Torvalds 					 int write, void *data)
25931da177e4SLinus Torvalds {
25941da177e4SLinus Torvalds 	if (write) {
2595cba9f33dSBart Samwel 		if (*lvalp > LONG_MAX / HZ)
2596cba9f33dSBart Samwel 			return 1;
25971da177e4SLinus Torvalds 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
25981da177e4SLinus Torvalds 	} else {
25991da177e4SLinus Torvalds 		int val = *valp;
26001da177e4SLinus Torvalds 		unsigned long lval;
26011da177e4SLinus Torvalds 		if (val < 0) {
260200b7c339SAmerigo Wang 			*negp = true;
26031da177e4SLinus Torvalds 			lval = (unsigned long)-val;
26041da177e4SLinus Torvalds 		} else {
260500b7c339SAmerigo Wang 			*negp = false;
26061da177e4SLinus Torvalds 			lval = (unsigned long)val;
26071da177e4SLinus Torvalds 		}
26081da177e4SLinus Torvalds 		*lvalp = lval / HZ;
26091da177e4SLinus Torvalds 	}
26101da177e4SLinus Torvalds 	return 0;
26111da177e4SLinus Torvalds }
26121da177e4SLinus Torvalds 
261300b7c339SAmerigo Wang static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
26141da177e4SLinus Torvalds 						int *valp,
26151da177e4SLinus Torvalds 						int write, void *data)
26161da177e4SLinus Torvalds {
26171da177e4SLinus Torvalds 	if (write) {
2618cba9f33dSBart Samwel 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2619cba9f33dSBart Samwel 			return 1;
26201da177e4SLinus Torvalds 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
26211da177e4SLinus Torvalds 	} else {
26221da177e4SLinus Torvalds 		int val = *valp;
26231da177e4SLinus Torvalds 		unsigned long lval;
26241da177e4SLinus Torvalds 		if (val < 0) {
262500b7c339SAmerigo Wang 			*negp = true;
26261da177e4SLinus Torvalds 			lval = (unsigned long)-val;
26271da177e4SLinus Torvalds 		} else {
262800b7c339SAmerigo Wang 			*negp = false;
26291da177e4SLinus Torvalds 			lval = (unsigned long)val;
26301da177e4SLinus Torvalds 		}
26311da177e4SLinus Torvalds 		*lvalp = jiffies_to_clock_t(lval);
26321da177e4SLinus Torvalds 	}
26331da177e4SLinus Torvalds 	return 0;
26341da177e4SLinus Torvalds }
26351da177e4SLinus Torvalds 
263600b7c339SAmerigo Wang static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
26371da177e4SLinus Torvalds 					    int *valp,
26381da177e4SLinus Torvalds 					    int write, void *data)
26391da177e4SLinus Torvalds {
26401da177e4SLinus Torvalds 	if (write) {
26411da177e4SLinus Torvalds 		*valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
26421da177e4SLinus Torvalds 	} else {
26431da177e4SLinus Torvalds 		int val = *valp;
26441da177e4SLinus Torvalds 		unsigned long lval;
26451da177e4SLinus Torvalds 		if (val < 0) {
264600b7c339SAmerigo Wang 			*negp = true;
26471da177e4SLinus Torvalds 			lval = (unsigned long)-val;
26481da177e4SLinus Torvalds 		} else {
264900b7c339SAmerigo Wang 			*negp = false;
26501da177e4SLinus Torvalds 			lval = (unsigned long)val;
26511da177e4SLinus Torvalds 		}
26521da177e4SLinus Torvalds 		*lvalp = jiffies_to_msecs(lval);
26531da177e4SLinus Torvalds 	}
26541da177e4SLinus Torvalds 	return 0;
26551da177e4SLinus Torvalds }
26561da177e4SLinus Torvalds 
26571da177e4SLinus Torvalds /**
26581da177e4SLinus Torvalds  * proc_dointvec_jiffies - read a vector of integers as seconds
26591da177e4SLinus Torvalds  * @table: the sysctl table
26601da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
26611da177e4SLinus Torvalds  * @buffer: the user buffer
26621da177e4SLinus Torvalds  * @lenp: the size of the user buffer
26631da177e4SLinus Torvalds  * @ppos: file position
26641da177e4SLinus Torvalds  *
26651da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
26661da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
26671da177e4SLinus Torvalds  * The values read are assumed to be in seconds, and are converted into
26681da177e4SLinus Torvalds  * jiffies.
26691da177e4SLinus Torvalds  *
26701da177e4SLinus Torvalds  * Returns 0 on success.
26711da177e4SLinus Torvalds  */
26728d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write,
26731da177e4SLinus Torvalds 			  void __user *buffer, size_t *lenp, loff_t *ppos)
26741da177e4SLinus Torvalds {
26758d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
26761da177e4SLinus Torvalds 		    	    do_proc_dointvec_jiffies_conv,NULL);
26771da177e4SLinus Torvalds }
26781da177e4SLinus Torvalds 
26791da177e4SLinus Torvalds /**
26801da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
26811da177e4SLinus Torvalds  * @table: the sysctl table
26821da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
26831da177e4SLinus Torvalds  * @buffer: the user buffer
26841da177e4SLinus Torvalds  * @lenp: the size of the user buffer
26851e5d5331SRandy Dunlap  * @ppos: pointer to the file position
26861da177e4SLinus Torvalds  *
26871da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
26881da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
26891da177e4SLinus Torvalds  * The values read are assumed to be in 1/USER_HZ seconds, and
26901da177e4SLinus Torvalds  * are converted into jiffies.
26911da177e4SLinus Torvalds  *
26921da177e4SLinus Torvalds  * Returns 0 on success.
26931da177e4SLinus Torvalds  */
26948d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
26951da177e4SLinus Torvalds 				 void __user *buffer, size_t *lenp, loff_t *ppos)
26961da177e4SLinus Torvalds {
26978d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
26981da177e4SLinus Torvalds 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
26991da177e4SLinus Torvalds }
27001da177e4SLinus Torvalds 
27011da177e4SLinus Torvalds /**
27021da177e4SLinus Torvalds  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
27031da177e4SLinus Torvalds  * @table: the sysctl table
27041da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
27051da177e4SLinus Torvalds  * @buffer: the user buffer
27061da177e4SLinus Torvalds  * @lenp: the size of the user buffer
270767be2dd1SMartin Waitz  * @ppos: file position
270867be2dd1SMartin Waitz  * @ppos: the current position in the file
27091da177e4SLinus Torvalds  *
27101da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
27111da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
27121da177e4SLinus Torvalds  * The values read are assumed to be in 1/1000 seconds, and
27131da177e4SLinus Torvalds  * are converted into jiffies.
27141da177e4SLinus Torvalds  *
27151da177e4SLinus Torvalds  * Returns 0 on success.
27161da177e4SLinus Torvalds  */
27178d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
27181da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
27191da177e4SLinus Torvalds {
27208d65af78SAlexey Dobriyan 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
27211da177e4SLinus Torvalds 				do_proc_dointvec_ms_jiffies_conv, NULL);
27221da177e4SLinus Torvalds }
27231da177e4SLinus Torvalds 
27248d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write,
27259ec52099SCedric Le Goater 			   void __user *buffer, size_t *lenp, loff_t *ppos)
27269ec52099SCedric Le Goater {
27279ec52099SCedric Le Goater 	struct pid *new_pid;
27289ec52099SCedric Le Goater 	pid_t tmp;
27299ec52099SCedric Le Goater 	int r;
27309ec52099SCedric Le Goater 
27316c5f3e7bSPavel Emelyanov 	tmp = pid_vnr(cad_pid);
27329ec52099SCedric Le Goater 
27338d65af78SAlexey Dobriyan 	r = __do_proc_dointvec(&tmp, table, write, buffer,
27349ec52099SCedric Le Goater 			       lenp, ppos, NULL, NULL);
27359ec52099SCedric Le Goater 	if (r || !write)
27369ec52099SCedric Le Goater 		return r;
27379ec52099SCedric Le Goater 
27389ec52099SCedric Le Goater 	new_pid = find_get_pid(tmp);
27399ec52099SCedric Le Goater 	if (!new_pid)
27409ec52099SCedric Le Goater 		return -ESRCH;
27419ec52099SCedric Le Goater 
27429ec52099SCedric Le Goater 	put_pid(xchg(&cad_pid, new_pid));
27439ec52099SCedric Le Goater 	return 0;
27449ec52099SCedric Le Goater }
27459ec52099SCedric Le Goater 
27469f977fb7SOctavian Purdila /**
27479f977fb7SOctavian Purdila  * proc_do_large_bitmap - read/write from/to a large bitmap
27489f977fb7SOctavian Purdila  * @table: the sysctl table
27499f977fb7SOctavian Purdila  * @write: %TRUE if this is a write to the sysctl file
27509f977fb7SOctavian Purdila  * @buffer: the user buffer
27519f977fb7SOctavian Purdila  * @lenp: the size of the user buffer
27529f977fb7SOctavian Purdila  * @ppos: file position
27539f977fb7SOctavian Purdila  *
27549f977fb7SOctavian Purdila  * The bitmap is stored at table->data and the bitmap length (in bits)
27559f977fb7SOctavian Purdila  * in table->maxlen.
27569f977fb7SOctavian Purdila  *
27579f977fb7SOctavian Purdila  * We use a range comma separated format (e.g. 1,3-4,10-10) so that
27589f977fb7SOctavian Purdila  * large bitmaps may be represented in a compact manner. Writing into
27599f977fb7SOctavian Purdila  * the file will clear the bitmap then update it with the given input.
27609f977fb7SOctavian Purdila  *
27619f977fb7SOctavian Purdila  * Returns 0 on success.
27629f977fb7SOctavian Purdila  */
27639f977fb7SOctavian Purdila int proc_do_large_bitmap(struct ctl_table *table, int write,
27649f977fb7SOctavian Purdila 			 void __user *buffer, size_t *lenp, loff_t *ppos)
27659f977fb7SOctavian Purdila {
27669f977fb7SOctavian Purdila 	int err = 0;
27679f977fb7SOctavian Purdila 	bool first = 1;
27689f977fb7SOctavian Purdila 	size_t left = *lenp;
27699f977fb7SOctavian Purdila 	unsigned long bitmap_len = table->maxlen;
27709f977fb7SOctavian Purdila 	unsigned long *bitmap = (unsigned long *) table->data;
27719f977fb7SOctavian Purdila 	unsigned long *tmp_bitmap = NULL;
27729f977fb7SOctavian Purdila 	char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
27739f977fb7SOctavian Purdila 
27749f977fb7SOctavian Purdila 	if (!bitmap_len || !left || (*ppos && !write)) {
27759f977fb7SOctavian Purdila 		*lenp = 0;
27769f977fb7SOctavian Purdila 		return 0;
27779f977fb7SOctavian Purdila 	}
27789f977fb7SOctavian Purdila 
27799f977fb7SOctavian Purdila 	if (write) {
27809f977fb7SOctavian Purdila 		unsigned long page = 0;
27819f977fb7SOctavian Purdila 		char *kbuf;
27829f977fb7SOctavian Purdila 
27839f977fb7SOctavian Purdila 		if (left > PAGE_SIZE - 1)
27849f977fb7SOctavian Purdila 			left = PAGE_SIZE - 1;
27859f977fb7SOctavian Purdila 
27869f977fb7SOctavian Purdila 		page = __get_free_page(GFP_TEMPORARY);
27879f977fb7SOctavian Purdila 		kbuf = (char *) page;
27889f977fb7SOctavian Purdila 		if (!kbuf)
27899f977fb7SOctavian Purdila 			return -ENOMEM;
27909f977fb7SOctavian Purdila 		if (copy_from_user(kbuf, buffer, left)) {
27919f977fb7SOctavian Purdila 			free_page(page);
27929f977fb7SOctavian Purdila 			return -EFAULT;
27939f977fb7SOctavian Purdila                 }
27949f977fb7SOctavian Purdila 		kbuf[left] = 0;
27959f977fb7SOctavian Purdila 
27969f977fb7SOctavian Purdila 		tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
27979f977fb7SOctavian Purdila 				     GFP_KERNEL);
27989f977fb7SOctavian Purdila 		if (!tmp_bitmap) {
27999f977fb7SOctavian Purdila 			free_page(page);
28009f977fb7SOctavian Purdila 			return -ENOMEM;
28019f977fb7SOctavian Purdila 		}
28029f977fb7SOctavian Purdila 		proc_skip_char(&kbuf, &left, '\n');
28039f977fb7SOctavian Purdila 		while (!err && left) {
28049f977fb7SOctavian Purdila 			unsigned long val_a, val_b;
28059f977fb7SOctavian Purdila 			bool neg;
28069f977fb7SOctavian Purdila 
28079f977fb7SOctavian Purdila 			err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
28089f977fb7SOctavian Purdila 					     sizeof(tr_a), &c);
28099f977fb7SOctavian Purdila 			if (err)
28109f977fb7SOctavian Purdila 				break;
28119f977fb7SOctavian Purdila 			if (val_a >= bitmap_len || neg) {
28129f977fb7SOctavian Purdila 				err = -EINVAL;
28139f977fb7SOctavian Purdila 				break;
28149f977fb7SOctavian Purdila 			}
28159f977fb7SOctavian Purdila 
28169f977fb7SOctavian Purdila 			val_b = val_a;
28179f977fb7SOctavian Purdila 			if (left) {
28189f977fb7SOctavian Purdila 				kbuf++;
28199f977fb7SOctavian Purdila 				left--;
28209f977fb7SOctavian Purdila 			}
28219f977fb7SOctavian Purdila 
28229f977fb7SOctavian Purdila 			if (c == '-') {
28239f977fb7SOctavian Purdila 				err = proc_get_long(&kbuf, &left, &val_b,
28249f977fb7SOctavian Purdila 						     &neg, tr_b, sizeof(tr_b),
28259f977fb7SOctavian Purdila 						     &c);
28269f977fb7SOctavian Purdila 				if (err)
28279f977fb7SOctavian Purdila 					break;
28289f977fb7SOctavian Purdila 				if (val_b >= bitmap_len || neg ||
28299f977fb7SOctavian Purdila 				    val_a > val_b) {
28309f977fb7SOctavian Purdila 					err = -EINVAL;
28319f977fb7SOctavian Purdila 					break;
28329f977fb7SOctavian Purdila 				}
28339f977fb7SOctavian Purdila 				if (left) {
28349f977fb7SOctavian Purdila 					kbuf++;
28359f977fb7SOctavian Purdila 					left--;
28369f977fb7SOctavian Purdila 				}
28379f977fb7SOctavian Purdila 			}
28389f977fb7SOctavian Purdila 
28399f977fb7SOctavian Purdila 			while (val_a <= val_b)
28409f977fb7SOctavian Purdila 				set_bit(val_a++, tmp_bitmap);
28419f977fb7SOctavian Purdila 
28429f977fb7SOctavian Purdila 			first = 0;
28439f977fb7SOctavian Purdila 			proc_skip_char(&kbuf, &left, '\n');
28449f977fb7SOctavian Purdila 		}
28459f977fb7SOctavian Purdila 		free_page(page);
28469f977fb7SOctavian Purdila 	} else {
28479f977fb7SOctavian Purdila 		unsigned long bit_a, bit_b = 0;
28489f977fb7SOctavian Purdila 
28499f977fb7SOctavian Purdila 		while (left) {
28509f977fb7SOctavian Purdila 			bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
28519f977fb7SOctavian Purdila 			if (bit_a >= bitmap_len)
28529f977fb7SOctavian Purdila 				break;
28539f977fb7SOctavian Purdila 			bit_b = find_next_zero_bit(bitmap, bitmap_len,
28549f977fb7SOctavian Purdila 						   bit_a + 1) - 1;
28559f977fb7SOctavian Purdila 
28569f977fb7SOctavian Purdila 			if (!first) {
28579f977fb7SOctavian Purdila 				err = proc_put_char(&buffer, &left, ',');
28589f977fb7SOctavian Purdila 				if (err)
28599f977fb7SOctavian Purdila 					break;
28609f977fb7SOctavian Purdila 			}
28619f977fb7SOctavian Purdila 			err = proc_put_long(&buffer, &left, bit_a, false);
28629f977fb7SOctavian Purdila 			if (err)
28639f977fb7SOctavian Purdila 				break;
28649f977fb7SOctavian Purdila 			if (bit_a != bit_b) {
28659f977fb7SOctavian Purdila 				err = proc_put_char(&buffer, &left, '-');
28669f977fb7SOctavian Purdila 				if (err)
28679f977fb7SOctavian Purdila 					break;
28689f977fb7SOctavian Purdila 				err = proc_put_long(&buffer, &left, bit_b, false);
28699f977fb7SOctavian Purdila 				if (err)
28709f977fb7SOctavian Purdila 					break;
28719f977fb7SOctavian Purdila 			}
28729f977fb7SOctavian Purdila 
28739f977fb7SOctavian Purdila 			first = 0; bit_b++;
28749f977fb7SOctavian Purdila 		}
28759f977fb7SOctavian Purdila 		if (!err)
28769f977fb7SOctavian Purdila 			err = proc_put_char(&buffer, &left, '\n');
28779f977fb7SOctavian Purdila 	}
28789f977fb7SOctavian Purdila 
28799f977fb7SOctavian Purdila 	if (!err) {
28809f977fb7SOctavian Purdila 		if (write) {
28819f977fb7SOctavian Purdila 			if (*ppos)
28829f977fb7SOctavian Purdila 				bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
28839f977fb7SOctavian Purdila 			else
28849f977fb7SOctavian Purdila 				memcpy(bitmap, tmp_bitmap,
28859f977fb7SOctavian Purdila 					BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long));
28869f977fb7SOctavian Purdila 		}
28879f977fb7SOctavian Purdila 		kfree(tmp_bitmap);
28889f977fb7SOctavian Purdila 		*lenp -= left;
28899f977fb7SOctavian Purdila 		*ppos += *lenp;
28909f977fb7SOctavian Purdila 		return 0;
28919f977fb7SOctavian Purdila 	} else {
28929f977fb7SOctavian Purdila 		kfree(tmp_bitmap);
28939f977fb7SOctavian Purdila 		return err;
28949f977fb7SOctavian Purdila 	}
28959f977fb7SOctavian Purdila }
28969f977fb7SOctavian Purdila 
28971da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */
28981da177e4SLinus Torvalds 
28998d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write,
29001da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
29011da177e4SLinus Torvalds {
29021da177e4SLinus Torvalds 	return -ENOSYS;
29031da177e4SLinus Torvalds }
29041da177e4SLinus Torvalds 
29058d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write,
29061da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
29071da177e4SLinus Torvalds {
29081da177e4SLinus Torvalds 	return -ENOSYS;
29091da177e4SLinus Torvalds }
29101da177e4SLinus Torvalds 
29118d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write,
29121da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
29131da177e4SLinus Torvalds {
29141da177e4SLinus Torvalds 	return -ENOSYS;
29151da177e4SLinus Torvalds }
29161da177e4SLinus Torvalds 
29178d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write,
29181da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
29191da177e4SLinus Torvalds {
29201da177e4SLinus Torvalds 	return -ENOSYS;
29211da177e4SLinus Torvalds }
29221da177e4SLinus Torvalds 
29238d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
29241da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
29251da177e4SLinus Torvalds {
29261da177e4SLinus Torvalds 	return -ENOSYS;
29271da177e4SLinus Torvalds }
29281da177e4SLinus Torvalds 
29298d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
29301da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
29311da177e4SLinus Torvalds {
29321da177e4SLinus Torvalds 	return -ENOSYS;
29331da177e4SLinus Torvalds }
29341da177e4SLinus Torvalds 
29358d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write,
29361da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
29371da177e4SLinus Torvalds {
29381da177e4SLinus Torvalds 	return -ENOSYS;
29391da177e4SLinus Torvalds }
29401da177e4SLinus Torvalds 
2941d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
29421da177e4SLinus Torvalds 				      void __user *buffer,
29431da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
29441da177e4SLinus Torvalds {
29451da177e4SLinus Torvalds     return -ENOSYS;
29461da177e4SLinus Torvalds }
29471da177e4SLinus Torvalds 
29481da177e4SLinus Torvalds 
29491da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */
29501da177e4SLinus Torvalds 
29511da177e4SLinus Torvalds /*
29521da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
29531da177e4SLinus Torvalds  * exception granted :-)
29541da177e4SLinus Torvalds  */
29551da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
29561da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
29571da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
29581da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
29591da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
29601da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
29611da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
29621da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
29631da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table);
296429e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths);
29651da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table);
2966