xref: /openbmc/linux/kernel/sysctl.c (revision acb4a848da821a095ae9e4d8b22ae2d9633ba5cd)
11da177e4SLinus Torvalds /*
21da177e4SLinus Torvalds  * sysctl.c: General linux system control interface
31da177e4SLinus Torvalds  *
41da177e4SLinus Torvalds  * Begun 24 March 1995, Stephen Tweedie
51da177e4SLinus Torvalds  * Added /proc support, Dec 1995
61da177e4SLinus Torvalds  * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
71da177e4SLinus Torvalds  * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
81da177e4SLinus Torvalds  * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
91da177e4SLinus Torvalds  * Dynamic registration fixes, Stephen Tweedie.
101da177e4SLinus Torvalds  * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
111da177e4SLinus Torvalds  * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
121da177e4SLinus Torvalds  *  Horn.
131da177e4SLinus Torvalds  * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
141da177e4SLinus Torvalds  * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
151da177e4SLinus Torvalds  * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
161da177e4SLinus Torvalds  *  Wendling.
171da177e4SLinus Torvalds  * The list_for_each() macro wasn't appropriate for the sysctl loop.
181da177e4SLinus Torvalds  *  Removed it and replaced it with older style, 03/23/00, Bill Wendling
191da177e4SLinus Torvalds  */
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds #include <linux/module.h>
221da177e4SLinus Torvalds #include <linux/mm.h>
231da177e4SLinus Torvalds #include <linux/swap.h>
241da177e4SLinus Torvalds #include <linux/slab.h>
251da177e4SLinus Torvalds #include <linux/sysctl.h>
261da177e4SLinus Torvalds #include <linux/proc_fs.h>
2772c2d582SAndrew Morgan #include <linux/security.h>
281da177e4SLinus Torvalds #include <linux/ctype.h>
29dfec072eSVegard Nossum #include <linux/kmemcheck.h>
301da177e4SLinus Torvalds #include <linux/smp_lock.h>
3162239ac2SAdrian Bunk #include <linux/fs.h>
321da177e4SLinus Torvalds #include <linux/init.h>
331da177e4SLinus Torvalds #include <linux/kernel.h>
340296b228SKay Sievers #include <linux/kobject.h>
3520380731SArnaldo Carvalho de Melo #include <linux/net.h>
361da177e4SLinus Torvalds #include <linux/sysrq.h>
371da177e4SLinus Torvalds #include <linux/highuid.h>
381da177e4SLinus Torvalds #include <linux/writeback.h>
393fff4c42SIngo Molnar #include <linux/ratelimit.h>
401da177e4SLinus Torvalds #include <linux/hugetlb.h>
411da177e4SLinus Torvalds #include <linux/initrd.h>
420b77f5bfSDavid Howells #include <linux/key.h>
431da177e4SLinus Torvalds #include <linux/times.h>
441da177e4SLinus Torvalds #include <linux/limits.h>
451da177e4SLinus Torvalds #include <linux/dcache.h>
461da177e4SLinus Torvalds #include <linux/syscalls.h>
47c748e134SAdrian Bunk #include <linux/vmstat.h>
48c255d844SPavel Machek #include <linux/nfs_fs.h>
49c255d844SPavel Machek #include <linux/acpi.h>
5010a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h>
51b0fc494fSSteven Rostedt #include <linux/ftrace.h>
5212e22c5eSDavid Howells #include <linux/slow-work.h>
53cdd6c482SIngo Molnar #include <linux/perf_event.h>
541da177e4SLinus Torvalds 
551da177e4SLinus Torvalds #include <asm/uaccess.h>
561da177e4SLinus Torvalds #include <asm/processor.h>
571da177e4SLinus Torvalds 
5829cbc78bSAndi Kleen #ifdef CONFIG_X86
5929cbc78bSAndi Kleen #include <asm/nmi.h>
600741f4d2SChuck Ebbert #include <asm/stacktrace.h>
616e7c4025SIngo Molnar #include <asm/io.h>
6229cbc78bSAndi Kleen #endif
6329cbc78bSAndi Kleen 
647058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args);
657058cb02SEric W. Biederman 
661da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL)
671da177e4SLinus Torvalds 
681da177e4SLinus Torvalds /* External variables not in a header file. */
691da177e4SLinus Torvalds extern int C_A_D;
7045807a1dSIngo Molnar extern int print_fatal_signals;
711da177e4SLinus Torvalds extern int sysctl_overcommit_memory;
721da177e4SLinus Torvalds extern int sysctl_overcommit_ratio;
73fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom;
74fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task;
75fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks;
761da177e4SLinus Torvalds extern int max_threads;
771da177e4SLinus Torvalds extern int core_uses_pid;
78d6e71144SAlan Cox extern int suid_dumpable;
791da177e4SLinus Torvalds extern char core_pattern[];
80a293980cSNeil Horman extern unsigned int core_pipe_limit;
811da177e4SLinus Torvalds extern int pid_max;
821da177e4SLinus Torvalds extern int min_free_kbytes;
831da177e4SLinus Torvalds extern int pid_max_min, pid_max_max;
849d0243bcSAndrew Morton extern int sysctl_drop_caches;
858ad4b1fbSRohit Seth extern int percpu_pagelist_fraction;
86bebfa101SAndi Kleen extern int compat_log;
879745512cSArjan van de Ven extern int latencytop_enabled;
88eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max;
89dd8632a1SPaul Mundt #ifndef CONFIG_MMU
90dd8632a1SPaul Mundt extern int sysctl_nr_trim_pages;
91dd8632a1SPaul Mundt #endif
9231a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
9331a72bceSPaul E. McKenney extern int rcutorture_runnable;
9431a72bceSPaul E. McKenney #endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
95cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
965e605b64SJens Axboe extern int blk_iopoll_enabled;
97cb684b5bSJens Axboe #endif
981da177e4SLinus Torvalds 
99c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and  maximum */
100195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP
101c4f3b63fSRavikiran G Thirumalai static int sixty = 60;
1029383d967SDimitri Sivanich static int neg_one = -1;
103c4f3b63fSRavikiran G Thirumalai #endif
104c4f3b63fSRavikiran G Thirumalai 
105c4f3b63fSRavikiran G Thirumalai static int zero;
106cd5f9a4cSLinus Torvalds static int __maybe_unused one = 1;
107cd5f9a4cSLinus Torvalds static int __maybe_unused two = 2;
108fc3501d4SSven Wegener static unsigned long one_ul = 1;
109c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100;
110af91322eSDave Young #ifdef CONFIG_PRINTK
111af91322eSDave Young static int ten_thousand = 10000;
112af91322eSDave Young #endif
113c4f3b63fSRavikiran G Thirumalai 
1149e4a5bdaSAndrea Righi /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
1159e4a5bdaSAndrea Righi static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
1169e4a5bdaSAndrea Righi 
1171da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1181da177e4SLinus Torvalds static int maxolduid = 65535;
1191da177e4SLinus Torvalds static int minolduid;
1208ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8;
1211da177e4SLinus Torvalds 
1221da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
1231da177e4SLinus Torvalds 
124a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
1251da177e4SLinus Torvalds extern char modprobe_path[];
1263d43321bSKees Cook extern int modules_disabled;
1271da177e4SLinus Torvalds #endif
1281da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
1291da177e4SLinus Torvalds extern int sg_big_buff;
1301da177e4SLinus Torvalds #endif
1311da177e4SLinus Torvalds 
13272c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
13317f04fbbSDavid S. Miller #include <asm/system.h>
1341da177e4SLinus Torvalds #endif
1351da177e4SLinus Torvalds 
1360871420fSDavid S. Miller #ifdef CONFIG_SPARC64
1370871420fSDavid S. Miller extern int sysctl_tsb_ratio;
1380871420fSDavid S. Miller #endif
1390871420fSDavid S. Miller 
1401da177e4SLinus Torvalds #ifdef __hppa__
1411da177e4SLinus Torvalds extern int pwrsw_enabled;
1421da177e4SLinus Torvalds extern int unaligned_enabled;
1431da177e4SLinus Torvalds #endif
1441da177e4SLinus Torvalds 
145347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
1461da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
1471da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings;
1481da177e4SLinus Torvalds #endif
1491da177e4SLinus Torvalds extern int sysctl_userprocess_debug;
150951f22d5SMartin Schwidefsky extern int spin_retry;
1511da177e4SLinus Torvalds #endif
1521da177e4SLinus Torvalds 
1531da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
1541da177e4SLinus Torvalds extern int acct_parm[];
1551da177e4SLinus Torvalds #endif
1561da177e4SLinus Torvalds 
157d2b176edSJes Sorensen #ifdef CONFIG_IA64
158d2b176edSJes Sorensen extern int no_unaligned_warning;
15988fc241fSDoug Chapman extern int unaligned_dump_stack;
160d2b176edSJes Sorensen #endif
161d2b176edSJes Sorensen 
1623fff4c42SIngo Molnar extern struct ratelimit_state printk_ratelimit_state;
1633fff4c42SIngo Molnar 
16423f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
16523f78d4aSIngo Molnar extern int max_lock_depth;
16623f78d4aSIngo Molnar #endif
16723f78d4aSIngo Molnar 
168d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
1698d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write,
1709ec52099SCedric Le Goater 		  void __user *buffer, size_t *lenp, loff_t *ppos);
1718d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write,
17234f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos);
173d6f8ff73SRandy Dunlap #endif
1749ec52099SCedric Le Goater 
175d8217f07SEric W. Biederman static struct ctl_table root_table[];
176e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root;
177e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = {
178b380b0d4SAl Viro 	.count = 1,
179e51b6ba0SEric W. Biederman 	.ctl_table = root_table,
18073455092SAl Viro 	.ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
181e51b6ba0SEric W. Biederman 	.root = &sysctl_table_root,
18273455092SAl Viro 	.set = &sysctl_table_root.default_set,
183e51b6ba0SEric W. Biederman };
184e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = {
185e51b6ba0SEric W. Biederman 	.root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
18673455092SAl Viro 	.default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
187e51b6ba0SEric W. Biederman };
1881da177e4SLinus Torvalds 
189d8217f07SEric W. Biederman static struct ctl_table kern_table[];
190d8217f07SEric W. Biederman static struct ctl_table vm_table[];
191d8217f07SEric W. Biederman static struct ctl_table fs_table[];
192d8217f07SEric W. Biederman static struct ctl_table debug_table[];
193d8217f07SEric W. Biederman static struct ctl_table dev_table[];
194d8217f07SEric W. Biederman extern struct ctl_table random_table[];
1952d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
196d8217f07SEric W. Biederman extern struct ctl_table inotify_table[];
1970399cb08SRobert Love #endif
1987ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
1997ef9964eSDavide Libenzi extern struct ctl_table epoll_table[];
2007ef9964eSDavide Libenzi #endif
2011da177e4SLinus Torvalds 
2021da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
2031da177e4SLinus Torvalds int sysctl_legacy_va_layout;
2041da177e4SLinus Torvalds #endif
2051da177e4SLinus Torvalds 
206f20786ffSPeter Zijlstra extern int prove_locking;
207f20786ffSPeter Zijlstra extern int lock_stat;
2089bc9a6bdSEric W. Biederman 
2091da177e4SLinus Torvalds /* The default sysctl tables: */
2101da177e4SLinus Torvalds 
211d8217f07SEric W. Biederman static struct ctl_table root_table[] = {
2121da177e4SLinus Torvalds 	{
2131da177e4SLinus Torvalds 		.ctl_name	= CTL_KERN,
2141da177e4SLinus Torvalds 		.procname	= "kernel",
2151da177e4SLinus Torvalds 		.mode		= 0555,
2161da177e4SLinus Torvalds 		.child		= kern_table,
2171da177e4SLinus Torvalds 	},
2181da177e4SLinus Torvalds 	{
2191da177e4SLinus Torvalds 		.ctl_name	= CTL_VM,
2201da177e4SLinus Torvalds 		.procname	= "vm",
2211da177e4SLinus Torvalds 		.mode		= 0555,
2221da177e4SLinus Torvalds 		.child		= vm_table,
2231da177e4SLinus Torvalds 	},
2241da177e4SLinus Torvalds 	{
2251da177e4SLinus Torvalds 		.ctl_name	= CTL_FS,
2261da177e4SLinus Torvalds 		.procname	= "fs",
2271da177e4SLinus Torvalds 		.mode		= 0555,
2281da177e4SLinus Torvalds 		.child		= fs_table,
2291da177e4SLinus Torvalds 	},
2301da177e4SLinus Torvalds 	{
2311da177e4SLinus Torvalds 		.ctl_name	= CTL_DEBUG,
2321da177e4SLinus Torvalds 		.procname	= "debug",
2331da177e4SLinus Torvalds 		.mode		= 0555,
2341da177e4SLinus Torvalds 		.child		= debug_table,
2351da177e4SLinus Torvalds 	},
2361da177e4SLinus Torvalds 	{
2371da177e4SLinus Torvalds 		.ctl_name	= CTL_DEV,
2381da177e4SLinus Torvalds 		.procname	= "dev",
2391da177e4SLinus Torvalds 		.mode		= 0555,
2401da177e4SLinus Torvalds 		.child		= dev_table,
2411da177e4SLinus Torvalds 	},
2422be7fe07SAndrew Morton /*
2432be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
2442be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
2452be7fe07SAndrew Morton  */
2461da177e4SLinus Torvalds 	{ .ctl_name = 0 }
2471da177e4SLinus Torvalds };
2481da177e4SLinus Torvalds 
24977e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
25073c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000;		/* 100 usecs */
25173c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
25273c4efd2SEric Dumazet static int min_wakeup_granularity_ns;			/* 0 usecs */
25373c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
2541983a922SChristian Ehrhardt static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
2551983a922SChristian Ehrhardt static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
256*acb4a848SChristian Ehrhardt static int min_sched_shares_ratelimit = 100000; /* 100 usec */
257*acb4a848SChristian Ehrhardt static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
25877e54a1fSIngo Molnar #endif
25977e54a1fSIngo Molnar 
260d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
2612bba22c5SMike Galbraith 	{
2622bba22c5SMike Galbraith 		.ctl_name	= CTL_UNNUMBERED,
2632bba22c5SMike Galbraith 		.procname	= "sched_child_runs_first",
2642bba22c5SMike Galbraith 		.data		= &sysctl_sched_child_runs_first,
2652bba22c5SMike Galbraith 		.maxlen		= sizeof(unsigned int),
2662bba22c5SMike Galbraith 		.mode		= 0644,
2672bba22c5SMike Galbraith 		.proc_handler	= &proc_dointvec,
2682bba22c5SMike Galbraith 	},
26977e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
27077e54a1fSIngo Molnar 	{
27177e54a1fSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
272b2be5e96SPeter Zijlstra 		.procname	= "sched_min_granularity_ns",
273b2be5e96SPeter Zijlstra 		.data		= &sysctl_sched_min_granularity,
27477e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
27577e54a1fSIngo Molnar 		.mode		= 0644,
276*acb4a848SChristian Ehrhardt 		.proc_handler	= &sched_proc_update_handler,
277b2be5e96SPeter Zijlstra 		.strategy	= &sysctl_intvec,
278b2be5e96SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
279b2be5e96SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
28077e54a1fSIngo Molnar 	},
28177e54a1fSIngo Molnar 	{
28277e54a1fSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
28321805085SPeter Zijlstra 		.procname	= "sched_latency_ns",
28421805085SPeter Zijlstra 		.data		= &sysctl_sched_latency,
28521805085SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
28621805085SPeter Zijlstra 		.mode		= 0644,
287*acb4a848SChristian Ehrhardt 		.proc_handler	= &sched_proc_update_handler,
28821805085SPeter Zijlstra 		.strategy	= &sysctl_intvec,
28921805085SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
29021805085SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
29121805085SPeter Zijlstra 	},
29221805085SPeter Zijlstra 	{
29321805085SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
29477e54a1fSIngo Molnar 		.procname	= "sched_wakeup_granularity_ns",
29577e54a1fSIngo Molnar 		.data		= &sysctl_sched_wakeup_granularity,
29677e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
29777e54a1fSIngo Molnar 		.mode		= 0644,
298*acb4a848SChristian Ehrhardt 		.proc_handler	= &sched_proc_update_handler,
29977e54a1fSIngo Molnar 		.strategy	= &sysctl_intvec,
30077e54a1fSIngo Molnar 		.extra1		= &min_wakeup_granularity_ns,
30177e54a1fSIngo Molnar 		.extra2		= &max_wakeup_granularity_ns,
30277e54a1fSIngo Molnar 	},
30377e54a1fSIngo Molnar 	{
30477e54a1fSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
3052398f2c6SPeter Zijlstra 		.procname	= "sched_shares_ratelimit",
3062398f2c6SPeter Zijlstra 		.data		= &sysctl_sched_shares_ratelimit,
3072398f2c6SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3082398f2c6SPeter Zijlstra 		.mode		= 0644,
309*acb4a848SChristian Ehrhardt 		.proc_handler	= &sched_proc_update_handler,
310*acb4a848SChristian Ehrhardt 		.extra1		= &min_sched_shares_ratelimit,
311*acb4a848SChristian Ehrhardt 		.extra2		= &max_sched_shares_ratelimit,
3122398f2c6SPeter Zijlstra 	},
3132398f2c6SPeter Zijlstra 	{
3142398f2c6SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
3151983a922SChristian Ehrhardt 		.procname	= "sched_tunable_scaling",
3161983a922SChristian Ehrhardt 		.data		= &sysctl_sched_tunable_scaling,
3171983a922SChristian Ehrhardt 		.maxlen		= sizeof(enum sched_tunable_scaling),
3181983a922SChristian Ehrhardt 		.mode		= 0644,
319*acb4a848SChristian Ehrhardt 		.proc_handler	= &sched_proc_update_handler,
3201983a922SChristian Ehrhardt 		.strategy	= &sysctl_intvec,
3211983a922SChristian Ehrhardt 		.extra1		= &min_sched_tunable_scaling,
3221983a922SChristian Ehrhardt 		.extra2		= &max_sched_tunable_scaling,
3231983a922SChristian Ehrhardt 	},
3241983a922SChristian Ehrhardt 
3251983a922SChristian Ehrhardt 	{
3261983a922SChristian Ehrhardt 		.ctl_name	= CTL_UNNUMBERED,
327ffda12a1SPeter Zijlstra 		.procname	= "sched_shares_thresh",
328ffda12a1SPeter Zijlstra 		.data		= &sysctl_sched_shares_thresh,
329ffda12a1SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
330ffda12a1SPeter Zijlstra 		.mode		= 0644,
331ffda12a1SPeter Zijlstra 		.proc_handler	= &proc_dointvec_minmax,
332ffda12a1SPeter Zijlstra 		.strategy	= &sysctl_intvec,
333ffda12a1SPeter Zijlstra 		.extra1		= &zero,
334ffda12a1SPeter Zijlstra 	},
335ffda12a1SPeter Zijlstra 	{
336ffda12a1SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
337da84d961SIngo Molnar 		.procname	= "sched_migration_cost",
338da84d961SIngo Molnar 		.data		= &sysctl_sched_migration_cost,
339da84d961SIngo Molnar 		.maxlen		= sizeof(unsigned int),
340da84d961SIngo Molnar 		.mode		= 0644,
341da84d961SIngo Molnar 		.proc_handler	= &proc_dointvec,
342da84d961SIngo Molnar 	},
343b82d9fddSPeter Zijlstra 	{
344b82d9fddSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
345b82d9fddSPeter Zijlstra 		.procname	= "sched_nr_migrate",
346b82d9fddSPeter Zijlstra 		.data		= &sysctl_sched_nr_migrate,
347b82d9fddSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
348fa85ae24SPeter Zijlstra 		.mode		= 0644,
349fa85ae24SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
350fa85ae24SPeter Zijlstra 	},
351cd1bb94bSArun R Bharadwaj 	{
352cd1bb94bSArun R Bharadwaj 		.ctl_name	= CTL_UNNUMBERED,
353e9e9250bSPeter Zijlstra 		.procname	= "sched_time_avg",
354e9e9250bSPeter Zijlstra 		.data		= &sysctl_sched_time_avg,
355e9e9250bSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
356e9e9250bSPeter Zijlstra 		.mode		= 0644,
357e9e9250bSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
358e9e9250bSPeter Zijlstra 	},
359e9e9250bSPeter Zijlstra 	{
360e9e9250bSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
361cd1bb94bSArun R Bharadwaj 		.procname	= "timer_migration",
362cd1bb94bSArun R Bharadwaj 		.data		= &sysctl_timer_migration,
363cd1bb94bSArun R Bharadwaj 		.maxlen		= sizeof(unsigned int),
364cd1bb94bSArun R Bharadwaj 		.mode		= 0644,
365bfdb4d9fSArun R Bharadwaj 		.proc_handler	= &proc_dointvec_minmax,
366bfdb4d9fSArun R Bharadwaj 		.strategy	= &sysctl_intvec,
367bfdb4d9fSArun R Bharadwaj 		.extra1		= &zero,
368bfdb4d9fSArun R Bharadwaj 		.extra2		= &one,
369cd1bb94bSArun R Bharadwaj 	},
3701fc84aaaSPeter Zijlstra #endif
3711799e35dSIngo Molnar 	{
3721799e35dSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
3739f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
3749f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
3759f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3769f0c1e56SPeter Zijlstra 		.mode		= 0644,
377d0b27fa7SPeter Zijlstra 		.proc_handler	= &sched_rt_handler,
3789f0c1e56SPeter Zijlstra 	},
3799f0c1e56SPeter Zijlstra 	{
3809f0c1e56SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
3819f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
3829f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
3839f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
3849f0c1e56SPeter Zijlstra 		.mode		= 0644,
385d0b27fa7SPeter Zijlstra 		.proc_handler	= &sched_rt_handler,
3869f0c1e56SPeter Zijlstra 	},
3879f0c1e56SPeter Zijlstra 	{
3889f0c1e56SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
3891799e35dSIngo Molnar 		.procname	= "sched_compat_yield",
3901799e35dSIngo Molnar 		.data		= &sysctl_sched_compat_yield,
3911799e35dSIngo Molnar 		.maxlen		= sizeof(unsigned int),
3921799e35dSIngo Molnar 		.mode		= 0644,
3931799e35dSIngo Molnar 		.proc_handler	= &proc_dointvec,
3941799e35dSIngo Molnar 	},
395f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
396f20786ffSPeter Zijlstra 	{
397f20786ffSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
398f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
399f20786ffSPeter Zijlstra 		.data		= &prove_locking,
400f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
401f20786ffSPeter Zijlstra 		.mode		= 0644,
402f20786ffSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
403f20786ffSPeter Zijlstra 	},
404f20786ffSPeter Zijlstra #endif
405f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
406f20786ffSPeter Zijlstra 	{
407f20786ffSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
408f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
409f20786ffSPeter Zijlstra 		.data		= &lock_stat,
410f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
411f20786ffSPeter Zijlstra 		.mode		= 0644,
412f20786ffSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
413f20786ffSPeter Zijlstra 	},
414f20786ffSPeter Zijlstra #endif
41577e54a1fSIngo Molnar 	{
4161da177e4SLinus Torvalds 		.ctl_name	= KERN_PANIC,
4171da177e4SLinus Torvalds 		.procname	= "panic",
4181da177e4SLinus Torvalds 		.data		= &panic_timeout,
4191da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4201da177e4SLinus Torvalds 		.mode		= 0644,
4211da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4221da177e4SLinus Torvalds 	},
4231da177e4SLinus Torvalds 	{
4241da177e4SLinus Torvalds 		.ctl_name	= KERN_CORE_USES_PID,
4251da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
4261da177e4SLinus Torvalds 		.data		= &core_uses_pid,
4271da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4281da177e4SLinus Torvalds 		.mode		= 0644,
4291da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4301da177e4SLinus Torvalds 	},
4311da177e4SLinus Torvalds 	{
4321da177e4SLinus Torvalds 		.ctl_name	= KERN_CORE_PATTERN,
4331da177e4SLinus Torvalds 		.procname	= "core_pattern",
4341da177e4SLinus Torvalds 		.data		= core_pattern,
43571ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
4361da177e4SLinus Torvalds 		.mode		= 0644,
4371da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
4381da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
4391da177e4SLinus Torvalds 	},
440a293980cSNeil Horman 	{
441a293980cSNeil Horman 		.ctl_name	= CTL_UNNUMBERED,
442a293980cSNeil Horman 		.procname	= "core_pipe_limit",
443a293980cSNeil Horman 		.data		= &core_pipe_limit,
444a293980cSNeil Horman 		.maxlen		= sizeof(unsigned int),
445a293980cSNeil Horman 		.mode		= 0644,
446a293980cSNeil Horman 		.proc_handler	= &proc_dointvec,
447a293980cSNeil Horman 	},
44834f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
4491da177e4SLinus Torvalds 	{
4501da177e4SLinus Torvalds 		.procname	= "tainted",
45125ddbb18SAndi Kleen 		.maxlen 	= sizeof(long),
45234f5a398STheodore Ts'o 		.mode		= 0644,
45325ddbb18SAndi Kleen 		.proc_handler	= &proc_taint,
4541da177e4SLinus Torvalds 	},
45534f5a398STheodore Ts'o #endif
4569745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
4579745512cSArjan van de Ven 	{
4589745512cSArjan van de Ven 		.procname	= "latencytop",
4599745512cSArjan van de Ven 		.data		= &latencytop_enabled,
4609745512cSArjan van de Ven 		.maxlen		= sizeof(int),
4619745512cSArjan van de Ven 		.mode		= 0644,
4629745512cSArjan van de Ven 		.proc_handler	= &proc_dointvec,
4639745512cSArjan van de Ven 	},
4649745512cSArjan van de Ven #endif
4651da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
4661da177e4SLinus Torvalds 	{
4671da177e4SLinus Torvalds 		.ctl_name	= KERN_REALROOTDEV,
4681da177e4SLinus Torvalds 		.procname	= "real-root-dev",
4691da177e4SLinus Torvalds 		.data		= &real_root_dev,
4701da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4711da177e4SLinus Torvalds 		.mode		= 0644,
4721da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4731da177e4SLinus Torvalds 	},
4741da177e4SLinus Torvalds #endif
47545807a1dSIngo Molnar 	{
47645807a1dSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
47745807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
47845807a1dSIngo Molnar 		.data		= &print_fatal_signals,
47945807a1dSIngo Molnar 		.maxlen		= sizeof(int),
48045807a1dSIngo Molnar 		.mode		= 0644,
48145807a1dSIngo Molnar 		.proc_handler	= &proc_dointvec,
48245807a1dSIngo Molnar 	},
48372c57ed5SDavid S. Miller #ifdef CONFIG_SPARC
4841da177e4SLinus Torvalds 	{
4851da177e4SLinus Torvalds 		.ctl_name	= KERN_SPARC_REBOOT,
4861da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
4871da177e4SLinus Torvalds 		.data		= reboot_command,
4881da177e4SLinus Torvalds 		.maxlen		= 256,
4891da177e4SLinus Torvalds 		.mode		= 0644,
4901da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
4911da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
4921da177e4SLinus Torvalds 	},
4931da177e4SLinus Torvalds 	{
4941da177e4SLinus Torvalds 		.ctl_name	= KERN_SPARC_STOP_A,
4951da177e4SLinus Torvalds 		.procname	= "stop-a",
4961da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
4971da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4981da177e4SLinus Torvalds 		.mode		= 0644,
4991da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5001da177e4SLinus Torvalds 	},
5011da177e4SLinus Torvalds 	{
5021da177e4SLinus Torvalds 		.ctl_name	= KERN_SPARC_SCONS_PWROFF,
5031da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
5041da177e4SLinus Torvalds 		.data		= &scons_pwroff,
5051da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5061da177e4SLinus Torvalds 		.mode		= 0644,
5071da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5081da177e4SLinus Torvalds 	},
5091da177e4SLinus Torvalds #endif
5100871420fSDavid S. Miller #ifdef CONFIG_SPARC64
5110871420fSDavid S. Miller 	{
5120871420fSDavid S. Miller 		.ctl_name	= CTL_UNNUMBERED,
5130871420fSDavid S. Miller 		.procname	= "tsb-ratio",
5140871420fSDavid S. Miller 		.data		= &sysctl_tsb_ratio,
5150871420fSDavid S. Miller 		.maxlen		= sizeof (int),
5160871420fSDavid S. Miller 		.mode		= 0644,
5170871420fSDavid S. Miller 		.proc_handler	= &proc_dointvec,
5180871420fSDavid S. Miller 	},
5190871420fSDavid S. Miller #endif
5201da177e4SLinus Torvalds #ifdef __hppa__
5211da177e4SLinus Torvalds 	{
5221da177e4SLinus Torvalds 		.ctl_name	= KERN_HPPA_PWRSW,
5231da177e4SLinus Torvalds 		.procname	= "soft-power",
5241da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
5251da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5261da177e4SLinus Torvalds 	 	.mode		= 0644,
5271da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5281da177e4SLinus Torvalds 	},
5291da177e4SLinus Torvalds 	{
5301da177e4SLinus Torvalds 		.ctl_name	= KERN_HPPA_UNALIGNED,
5311da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
5321da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
5331da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5341da177e4SLinus Torvalds 		.mode		= 0644,
5351da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5361da177e4SLinus Torvalds 	},
5371da177e4SLinus Torvalds #endif
5381da177e4SLinus Torvalds 	{
5391da177e4SLinus Torvalds 		.ctl_name	= KERN_CTLALTDEL,
5401da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
5411da177e4SLinus Torvalds 		.data		= &C_A_D,
5421da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5431da177e4SLinus Torvalds 		.mode		= 0644,
5441da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5451da177e4SLinus Torvalds 	},
546606576ceSSteven Rostedt #ifdef CONFIG_FUNCTION_TRACER
547b0fc494fSSteven Rostedt 	{
548b0fc494fSSteven Rostedt 		.ctl_name	= CTL_UNNUMBERED,
549b0fc494fSSteven Rostedt 		.procname	= "ftrace_enabled",
550b0fc494fSSteven Rostedt 		.data		= &ftrace_enabled,
551b0fc494fSSteven Rostedt 		.maxlen		= sizeof(int),
552b0fc494fSSteven Rostedt 		.mode		= 0644,
553b0fc494fSSteven Rostedt 		.proc_handler	= &ftrace_enable_sysctl,
554b0fc494fSSteven Rostedt 	},
555b0fc494fSSteven Rostedt #endif
556f38f1d2aSSteven Rostedt #ifdef CONFIG_STACK_TRACER
557f38f1d2aSSteven Rostedt 	{
558f38f1d2aSSteven Rostedt 		.ctl_name	= CTL_UNNUMBERED,
559f38f1d2aSSteven Rostedt 		.procname	= "stack_tracer_enabled",
560f38f1d2aSSteven Rostedt 		.data		= &stack_tracer_enabled,
561f38f1d2aSSteven Rostedt 		.maxlen		= sizeof(int),
562f38f1d2aSSteven Rostedt 		.mode		= 0644,
563f38f1d2aSSteven Rostedt 		.proc_handler	= &stack_trace_sysctl,
564f38f1d2aSSteven Rostedt 	},
565f38f1d2aSSteven Rostedt #endif
566944ac425SSteven Rostedt #ifdef CONFIG_TRACING
567944ac425SSteven Rostedt 	{
568944ac425SSteven Rostedt 		.ctl_name	= CTL_UNNUMBERED,
5693299b4ddSPeter Zijlstra 		.procname	= "ftrace_dump_on_oops",
570944ac425SSteven Rostedt 		.data		= &ftrace_dump_on_oops,
571944ac425SSteven Rostedt 		.maxlen		= sizeof(int),
572944ac425SSteven Rostedt 		.mode		= 0644,
573944ac425SSteven Rostedt 		.proc_handler	= &proc_dointvec,
574944ac425SSteven Rostedt 	},
575944ac425SSteven Rostedt #endif
576a1ef5adbSJohannes Berg #ifdef CONFIG_MODULES
5771da177e4SLinus Torvalds 	{
5781da177e4SLinus Torvalds 		.ctl_name	= KERN_MODPROBE,
5791da177e4SLinus Torvalds 		.procname	= "modprobe",
5801da177e4SLinus Torvalds 		.data		= &modprobe_path,
5811da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
5821da177e4SLinus Torvalds 		.mode		= 0644,
5831da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
5841da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
5851da177e4SLinus Torvalds 	},
5863d43321bSKees Cook 	{
5873d43321bSKees Cook 		.ctl_name	= CTL_UNNUMBERED,
5883d43321bSKees Cook 		.procname	= "modules_disabled",
5893d43321bSKees Cook 		.data		= &modules_disabled,
5903d43321bSKees Cook 		.maxlen		= sizeof(int),
5913d43321bSKees Cook 		.mode		= 0644,
5923d43321bSKees Cook 		/* only handle a transition from default "0" to "1" */
5933d43321bSKees Cook 		.proc_handler	= &proc_dointvec_minmax,
5943d43321bSKees Cook 		.extra1		= &one,
5953d43321bSKees Cook 		.extra2		= &one,
5963d43321bSKees Cook 	},
5971da177e4SLinus Torvalds #endif
59857ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
5991da177e4SLinus Torvalds 	{
6001da177e4SLinus Torvalds 		.ctl_name	= KERN_HOTPLUG,
6011da177e4SLinus Torvalds 		.procname	= "hotplug",
602312c004dSKay Sievers 		.data		= &uevent_helper,
603312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
6041da177e4SLinus Torvalds 		.mode		= 0644,
6051da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
6061da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
6071da177e4SLinus Torvalds 	},
6081da177e4SLinus Torvalds #endif
6091da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
6101da177e4SLinus Torvalds 	{
6111da177e4SLinus Torvalds 		.ctl_name	= KERN_SG_BIG_BUFF,
6121da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
6131da177e4SLinus Torvalds 		.data		= &sg_big_buff,
6141da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6151da177e4SLinus Torvalds 		.mode		= 0444,
6161da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6171da177e4SLinus Torvalds 	},
6181da177e4SLinus Torvalds #endif
6191da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
6201da177e4SLinus Torvalds 	{
6211da177e4SLinus Torvalds 		.ctl_name	= KERN_ACCT,
6221da177e4SLinus Torvalds 		.procname	= "acct",
6231da177e4SLinus Torvalds 		.data		= &acct_parm,
6241da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
6251da177e4SLinus Torvalds 		.mode		= 0644,
6261da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6271da177e4SLinus Torvalds 	},
6281da177e4SLinus Torvalds #endif
6291da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
6301da177e4SLinus Torvalds 	{
6311da177e4SLinus Torvalds 		.ctl_name	= KERN_SYSRQ,
6321da177e4SLinus Torvalds 		.procname	= "sysrq",
6335d6f647fSIngo Molnar 		.data		= &__sysrq_enabled,
6341da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6351da177e4SLinus Torvalds 		.mode		= 0644,
6361da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6371da177e4SLinus Torvalds 	},
6381da177e4SLinus Torvalds #endif
639d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
6401da177e4SLinus Torvalds 	{
6411da177e4SLinus Torvalds 		.procname	= "cad_pid",
6429ec52099SCedric Le Goater 		.data		= NULL,
6431da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6441da177e4SLinus Torvalds 		.mode		= 0600,
6459ec52099SCedric Le Goater 		.proc_handler	= &proc_do_cad_pid,
6461da177e4SLinus Torvalds 	},
647d6f8ff73SRandy Dunlap #endif
6481da177e4SLinus Torvalds 	{
6491da177e4SLinus Torvalds 		.ctl_name	= KERN_MAX_THREADS,
6501da177e4SLinus Torvalds 		.procname	= "threads-max",
6511da177e4SLinus Torvalds 		.data		= &max_threads,
6521da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6531da177e4SLinus Torvalds 		.mode		= 0644,
6541da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6551da177e4SLinus Torvalds 	},
6561da177e4SLinus Torvalds 	{
6571da177e4SLinus Torvalds 		.ctl_name	= KERN_RANDOM,
6581da177e4SLinus Torvalds 		.procname	= "random",
6591da177e4SLinus Torvalds 		.mode		= 0555,
6601da177e4SLinus Torvalds 		.child		= random_table,
6611da177e4SLinus Torvalds 	},
6621da177e4SLinus Torvalds 	{
6631da177e4SLinus Torvalds 		.ctl_name	= KERN_OVERFLOWUID,
6641da177e4SLinus Torvalds 		.procname	= "overflowuid",
6651da177e4SLinus Torvalds 		.data		= &overflowuid,
6661da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6671da177e4SLinus Torvalds 		.mode		= 0644,
6681da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
6691da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
6701da177e4SLinus Torvalds 		.extra1		= &minolduid,
6711da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6721da177e4SLinus Torvalds 	},
6731da177e4SLinus Torvalds 	{
6741da177e4SLinus Torvalds 		.ctl_name	= KERN_OVERFLOWGID,
6751da177e4SLinus Torvalds 		.procname	= "overflowgid",
6761da177e4SLinus Torvalds 		.data		= &overflowgid,
6771da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6781da177e4SLinus Torvalds 		.mode		= 0644,
6791da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
6801da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
6811da177e4SLinus Torvalds 		.extra1		= &minolduid,
6821da177e4SLinus Torvalds 		.extra2		= &maxolduid,
6831da177e4SLinus Torvalds 	},
684347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
6851da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
6861da177e4SLinus Torvalds 	{
6871da177e4SLinus Torvalds 		.ctl_name	= KERN_IEEE_EMULATION_WARNINGS,
6881da177e4SLinus Torvalds 		.procname	= "ieee_emulation_warnings",
6891da177e4SLinus Torvalds 		.data		= &sysctl_ieee_emulation_warnings,
6901da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6911da177e4SLinus Torvalds 		.mode		= 0644,
6921da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6931da177e4SLinus Torvalds 	},
6941da177e4SLinus Torvalds #endif
6951da177e4SLinus Torvalds 	{
6961da177e4SLinus Torvalds 		.ctl_name	= KERN_S390_USER_DEBUG_LOGGING,
6971da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
6981da177e4SLinus Torvalds 		.data		= &sysctl_userprocess_debug,
6991da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7001da177e4SLinus Torvalds 		.mode		= 0644,
7011da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7021da177e4SLinus Torvalds 	},
7031da177e4SLinus Torvalds #endif
7041da177e4SLinus Torvalds 	{
7051da177e4SLinus Torvalds 		.ctl_name	= KERN_PIDMAX,
7061da177e4SLinus Torvalds 		.procname	= "pid_max",
7071da177e4SLinus Torvalds 		.data		= &pid_max,
7081da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7091da177e4SLinus Torvalds 		.mode		= 0644,
7101da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
7111da177e4SLinus Torvalds 		.strategy	= sysctl_intvec,
7121da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
7131da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
7141da177e4SLinus Torvalds 	},
7151da177e4SLinus Torvalds 	{
7161da177e4SLinus Torvalds 		.ctl_name	= KERN_PANIC_ON_OOPS,
7171da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
7181da177e4SLinus Torvalds 		.data		= &panic_on_oops,
7191da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7201da177e4SLinus Torvalds 		.mode		= 0644,
7211da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7221da177e4SLinus Torvalds 	},
7237ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
7247ef3d2fdSJoe Perches 	{
7257ef3d2fdSJoe Perches 		.ctl_name	= KERN_PRINTK,
7267ef3d2fdSJoe Perches 		.procname	= "printk",
7277ef3d2fdSJoe Perches 		.data		= &console_loglevel,
7287ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
7297ef3d2fdSJoe Perches 		.mode		= 0644,
7307ef3d2fdSJoe Perches 		.proc_handler	= &proc_dointvec,
7317ef3d2fdSJoe Perches 	},
7321da177e4SLinus Torvalds 	{
7331da177e4SLinus Torvalds 		.ctl_name	= KERN_PRINTK_RATELIMIT,
7341da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
735717115e1SDave Young 		.data		= &printk_ratelimit_state.interval,
7361da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7371da177e4SLinus Torvalds 		.mode		= 0644,
7381da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_jiffies,
7391da177e4SLinus Torvalds 		.strategy	= &sysctl_jiffies,
7401da177e4SLinus Torvalds 	},
7411da177e4SLinus Torvalds 	{
7421da177e4SLinus Torvalds 		.ctl_name	= KERN_PRINTK_RATELIMIT_BURST,
7431da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
744717115e1SDave Young 		.data		= &printk_ratelimit_state.burst,
7451da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
7461da177e4SLinus Torvalds 		.mode		= 0644,
7471da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7481da177e4SLinus Torvalds 	},
749af91322eSDave Young 	{
750af91322eSDave Young 		.ctl_name	= CTL_UNNUMBERED,
751af91322eSDave Young 		.procname	= "printk_delay",
752af91322eSDave Young 		.data		= &printk_delay_msec,
753af91322eSDave Young 		.maxlen		= sizeof(int),
754af91322eSDave Young 		.mode		= 0644,
755af91322eSDave Young 		.proc_handler	= &proc_dointvec_minmax,
756af91322eSDave Young 		.strategy	= &sysctl_intvec,
757af91322eSDave Young 		.extra1		= &zero,
758af91322eSDave Young 		.extra2		= &ten_thousand,
759af91322eSDave Young 	},
7607ef3d2fdSJoe Perches #endif
7611da177e4SLinus Torvalds 	{
7621da177e4SLinus Torvalds 		.ctl_name	= KERN_NGROUPS_MAX,
7631da177e4SLinus Torvalds 		.procname	= "ngroups_max",
7641da177e4SLinus Torvalds 		.data		= &ngroups_max,
7651da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
7661da177e4SLinus Torvalds 		.mode		= 0444,
7671da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
7681da177e4SLinus Torvalds 	},
7691da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
7701da177e4SLinus Torvalds 	{
7711da177e4SLinus Torvalds 		.ctl_name       = KERN_UNKNOWN_NMI_PANIC,
7721da177e4SLinus Torvalds 		.procname       = "unknown_nmi_panic",
7731da177e4SLinus Torvalds 		.data           = &unknown_nmi_panic,
7741da177e4SLinus Torvalds 		.maxlen         = sizeof (int),
7751da177e4SLinus Torvalds 		.mode           = 0644,
7762fbe7b25SDon Zickus 		.proc_handler   = &proc_dointvec,
7771da177e4SLinus Torvalds 	},
778407984f1SDon Zickus 	{
779407984f1SDon Zickus 		.procname       = "nmi_watchdog",
780407984f1SDon Zickus 		.data           = &nmi_watchdog_enabled,
781407984f1SDon Zickus 		.maxlen         = sizeof (int),
782407984f1SDon Zickus 		.mode           = 0644,
783407984f1SDon Zickus 		.proc_handler   = &proc_nmi_enabled,
7841da177e4SLinus Torvalds 	},
7851da177e4SLinus Torvalds #endif
7861da177e4SLinus Torvalds #if defined(CONFIG_X86)
7871da177e4SLinus Torvalds 	{
7888da5addaSDon Zickus 		.ctl_name	= KERN_PANIC_ON_NMI,
7898da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
7908da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
7918da5addaSDon Zickus 		.maxlen		= sizeof(int),
7928da5addaSDon Zickus 		.mode		= 0644,
7938da5addaSDon Zickus 		.proc_handler	= &proc_dointvec,
7948da5addaSDon Zickus 	},
7958da5addaSDon Zickus 	{
7965211a242SKurt Garloff 		.ctl_name	= CTL_UNNUMBERED,
7975211a242SKurt Garloff 		.procname	= "panic_on_io_nmi",
7985211a242SKurt Garloff 		.data		= &panic_on_io_nmi,
7995211a242SKurt Garloff 		.maxlen		= sizeof(int),
8005211a242SKurt Garloff 		.mode		= 0644,
8015211a242SKurt Garloff 		.proc_handler	= &proc_dointvec,
8025211a242SKurt Garloff 	},
8035211a242SKurt Garloff 	{
8041da177e4SLinus Torvalds 		.ctl_name	= KERN_BOOTLOADER_TYPE,
8051da177e4SLinus Torvalds 		.procname	= "bootloader_type",
8061da177e4SLinus Torvalds 		.data		= &bootloader_type,
8071da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
8081da177e4SLinus Torvalds 		.mode		= 0444,
8091da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
8101da177e4SLinus Torvalds 	},
8110741f4d2SChuck Ebbert 	{
8120741f4d2SChuck Ebbert 		.ctl_name	= CTL_UNNUMBERED,
8135031296cSH. Peter Anvin 		.procname	= "bootloader_version",
8145031296cSH. Peter Anvin 		.data		= &bootloader_version,
8155031296cSH. Peter Anvin 		.maxlen		= sizeof (int),
8165031296cSH. Peter Anvin 		.mode		= 0444,
8175031296cSH. Peter Anvin 		.proc_handler	= &proc_dointvec,
8185031296cSH. Peter Anvin 	},
8195031296cSH. Peter Anvin 	{
8205031296cSH. Peter Anvin 		.ctl_name	= CTL_UNNUMBERED,
8210741f4d2SChuck Ebbert 		.procname	= "kstack_depth_to_print",
8220741f4d2SChuck Ebbert 		.data		= &kstack_depth_to_print,
8230741f4d2SChuck Ebbert 		.maxlen		= sizeof(int),
8240741f4d2SChuck Ebbert 		.mode		= 0644,
8250741f4d2SChuck Ebbert 		.proc_handler	= &proc_dointvec,
8260741f4d2SChuck Ebbert 	},
8276e7c4025SIngo Molnar 	{
8286e7c4025SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
8296e7c4025SIngo Molnar 		.procname	= "io_delay_type",
8306e7c4025SIngo Molnar 		.data		= &io_delay_type,
8316e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
8326e7c4025SIngo Molnar 		.mode		= 0644,
8336e7c4025SIngo Molnar 		.proc_handler	= &proc_dointvec,
8346e7c4025SIngo Molnar 	},
8351da177e4SLinus Torvalds #endif
8367a9166e3SLuke Yang #if defined(CONFIG_MMU)
8371da177e4SLinus Torvalds 	{
8381da177e4SLinus Torvalds 		.ctl_name	= KERN_RANDOMIZE,
8391da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
8401da177e4SLinus Torvalds 		.data		= &randomize_va_space,
8411da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
8421da177e4SLinus Torvalds 		.mode		= 0644,
8431da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
8441da177e4SLinus Torvalds 	},
8457a9166e3SLuke Yang #endif
8460152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
847951f22d5SMartin Schwidefsky 	{
848951f22d5SMartin Schwidefsky 		.ctl_name	= KERN_SPIN_RETRY,
849951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
850951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
851951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
852951f22d5SMartin Schwidefsky 		.mode		= 0644,
853951f22d5SMartin Schwidefsky 		.proc_handler	= &proc_dointvec,
854951f22d5SMartin Schwidefsky 	},
855951f22d5SMartin Schwidefsky #endif
856673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
857c255d844SPavel Machek 	{
858c255d844SPavel Machek 		.procname	= "acpi_video_flags",
85977afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
860c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
861c255d844SPavel Machek 		.mode		= 0644,
8627f99f06fSStefan Seyfried 		.proc_handler	= &proc_doulongvec_minmax,
863c255d844SPavel Machek 	},
864c255d844SPavel Machek #endif
865d2b176edSJes Sorensen #ifdef CONFIG_IA64
866d2b176edSJes Sorensen 	{
867d2b176edSJes Sorensen 		.ctl_name	= KERN_IA64_UNALIGNED,
868d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
869d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
870d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
871d2b176edSJes Sorensen 	 	.mode		= 0644,
872d2b176edSJes Sorensen 		.proc_handler	= &proc_dointvec,
873d2b176edSJes Sorensen 	},
87488fc241fSDoug Chapman 	{
87588fc241fSDoug Chapman 		.ctl_name	= CTL_UNNUMBERED,
87688fc241fSDoug Chapman 		.procname	= "unaligned-dump-stack",
87788fc241fSDoug Chapman 		.data		= &unaligned_dump_stack,
87888fc241fSDoug Chapman 		.maxlen		= sizeof (int),
87988fc241fSDoug Chapman 		.mode		= 0644,
88088fc241fSDoug Chapman 		.proc_handler	= &proc_dointvec,
88188fc241fSDoug Chapman 	},
882d2b176edSJes Sorensen #endif
883c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP
884c4f3b63fSRavikiran G Thirumalai 	{
885c4f3b63fSRavikiran G Thirumalai 		.ctl_name	= CTL_UNNUMBERED,
8869c44bc03SIngo Molnar 		.procname	= "softlockup_panic",
8879c44bc03SIngo Molnar 		.data		= &softlockup_panic,
8889c44bc03SIngo Molnar 		.maxlen		= sizeof(int),
8899c44bc03SIngo Molnar 		.mode		= 0644,
8904dca10a9SHiroshi Shimamoto 		.proc_handler	= &proc_dointvec_minmax,
8919c44bc03SIngo Molnar 		.strategy	= &sysctl_intvec,
8929c44bc03SIngo Molnar 		.extra1		= &zero,
8939c44bc03SIngo Molnar 		.extra2		= &one,
8949c44bc03SIngo Molnar 	},
8959c44bc03SIngo Molnar 	{
8969c44bc03SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
897c4f3b63fSRavikiran G Thirumalai 		.procname	= "softlockup_thresh",
898c4f3b63fSRavikiran G Thirumalai 		.data		= &softlockup_thresh,
8999383d967SDimitri Sivanich 		.maxlen		= sizeof(int),
900c4f3b63fSRavikiran G Thirumalai 		.mode		= 0644,
901baf48f65SMandeep Singh Baines 		.proc_handler	= &proc_dosoftlockup_thresh,
902c4f3b63fSRavikiran G Thirumalai 		.strategy	= &sysctl_intvec,
9039383d967SDimitri Sivanich 		.extra1		= &neg_one,
904c4f3b63fSRavikiran G Thirumalai 		.extra2		= &sixty,
905c4f3b63fSRavikiran G Thirumalai 	},
906e162b39aSMandeep Singh Baines #endif
907e162b39aSMandeep Singh Baines #ifdef CONFIG_DETECT_HUNG_TASK
908e162b39aSMandeep Singh Baines 	{
909e162b39aSMandeep Singh Baines 		.ctl_name	= CTL_UNNUMBERED,
910e162b39aSMandeep Singh Baines 		.procname	= "hung_task_panic",
911e162b39aSMandeep Singh Baines 		.data		= &sysctl_hung_task_panic,
912e162b39aSMandeep Singh Baines 		.maxlen		= sizeof(int),
913e162b39aSMandeep Singh Baines 		.mode		= 0644,
914e162b39aSMandeep Singh Baines 		.proc_handler	= &proc_dointvec_minmax,
915e162b39aSMandeep Singh Baines 		.strategy	= &sysctl_intvec,
916e162b39aSMandeep Singh Baines 		.extra1		= &zero,
917e162b39aSMandeep Singh Baines 		.extra2		= &one,
918e162b39aSMandeep Singh Baines 	},
91982a1fcb9SIngo Molnar 	{
92082a1fcb9SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
92182a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
92282a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
92390739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
92482a1fcb9SIngo Molnar 		.mode		= 0644,
92590739081SIngo Molnar 		.proc_handler	= &proc_doulongvec_minmax,
92682a1fcb9SIngo Molnar 		.strategy	= &sysctl_intvec,
92782a1fcb9SIngo Molnar 	},
92882a1fcb9SIngo Molnar 	{
92982a1fcb9SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
93082a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
93182a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
93290739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
93382a1fcb9SIngo Molnar 		.mode		= 0644,
934e162b39aSMandeep Singh Baines 		.proc_handler	= &proc_dohung_task_timeout_secs,
93582a1fcb9SIngo Molnar 		.strategy	= &sysctl_intvec,
93682a1fcb9SIngo Molnar 	},
93782a1fcb9SIngo Molnar 	{
93882a1fcb9SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
93982a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
94082a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
94190739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
94282a1fcb9SIngo Molnar 		.mode		= 0644,
94390739081SIngo Molnar 		.proc_handler	= &proc_doulongvec_minmax,
94482a1fcb9SIngo Molnar 		.strategy	= &sysctl_intvec,
94582a1fcb9SIngo Molnar 	},
946c4f3b63fSRavikiran G Thirumalai #endif
947bebfa101SAndi Kleen #ifdef CONFIG_COMPAT
948bebfa101SAndi Kleen 	{
949bebfa101SAndi Kleen 		.ctl_name	= KERN_COMPAT_LOG,
950bebfa101SAndi Kleen 		.procname	= "compat-log",
951bebfa101SAndi Kleen 		.data		= &compat_log,
952bebfa101SAndi Kleen 		.maxlen		= sizeof (int),
953bebfa101SAndi Kleen 	 	.mode		= 0644,
954bebfa101SAndi Kleen 		.proc_handler	= &proc_dointvec,
955bebfa101SAndi Kleen 	},
956bebfa101SAndi Kleen #endif
95723f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
95823f78d4aSIngo Molnar 	{
95923f78d4aSIngo Molnar 		.ctl_name	= KERN_MAX_LOCK_DEPTH,
96023f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
96123f78d4aSIngo Molnar 		.data		= &max_lock_depth,
96223f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
96323f78d4aSIngo Molnar 		.mode		= 0644,
96423f78d4aSIngo Molnar 		.proc_handler	= &proc_dointvec,
96523f78d4aSIngo Molnar 	},
96623f78d4aSIngo Molnar #endif
96710a0a8d4SJeremy Fitzhardinge 	{
96810a0a8d4SJeremy Fitzhardinge 		.ctl_name	= CTL_UNNUMBERED,
96910a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
97010a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
97110a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
97210a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
97310a0a8d4SJeremy Fitzhardinge 		.proc_handler	= &proc_dostring,
97410a0a8d4SJeremy Fitzhardinge 		.strategy	= &sysctl_string,
97510a0a8d4SJeremy Fitzhardinge 	},
9760b77f5bfSDavid Howells #ifdef CONFIG_KEYS
9770b77f5bfSDavid Howells 	{
9780b77f5bfSDavid Howells 		.ctl_name	= CTL_UNNUMBERED,
9790b77f5bfSDavid Howells 		.procname	= "keys",
9800b77f5bfSDavid Howells 		.mode		= 0555,
9810b77f5bfSDavid Howells 		.child		= key_sysctls,
9820b77f5bfSDavid Howells 	},
9830b77f5bfSDavid Howells #endif
98431a72bceSPaul E. McKenney #ifdef CONFIG_RCU_TORTURE_TEST
98531a72bceSPaul E. McKenney 	{
98631a72bceSPaul E. McKenney 		.ctl_name       = CTL_UNNUMBERED,
98731a72bceSPaul E. McKenney 		.procname       = "rcutorture_runnable",
98831a72bceSPaul E. McKenney 		.data           = &rcutorture_runnable,
98931a72bceSPaul E. McKenney 		.maxlen         = sizeof(int),
99031a72bceSPaul E. McKenney 		.mode           = 0644,
99131a72bceSPaul E. McKenney 		.proc_handler   = &proc_dointvec,
99231a72bceSPaul E. McKenney 	},
99331a72bceSPaul E. McKenney #endif
99412e22c5eSDavid Howells #ifdef CONFIG_SLOW_WORK
99512e22c5eSDavid Howells 	{
99612e22c5eSDavid Howells 		.ctl_name	= CTL_UNNUMBERED,
99712e22c5eSDavid Howells 		.procname	= "slow-work",
99812e22c5eSDavid Howells 		.mode		= 0555,
99912e22c5eSDavid Howells 		.child		= slow_work_sysctls,
100012e22c5eSDavid Howells 	},
100112e22c5eSDavid Howells #endif
1002cdd6c482SIngo Molnar #ifdef CONFIG_PERF_EVENTS
10031ccd1549SPeter Zijlstra 	{
10041ccd1549SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
1005cdd6c482SIngo Molnar 		.procname	= "perf_event_paranoid",
1006cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_paranoid,
1007cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_paranoid),
10081ccd1549SPeter Zijlstra 		.mode		= 0644,
10091ccd1549SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
10101ccd1549SPeter Zijlstra 	},
1011c5078f78SPeter Zijlstra 	{
1012c5078f78SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
1013cdd6c482SIngo Molnar 		.procname	= "perf_event_mlock_kb",
1014cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_mlock,
1015cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_mlock),
1016c5078f78SPeter Zijlstra 		.mode		= 0644,
1017c5078f78SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
1018c5078f78SPeter Zijlstra 	},
1019a78ac325SPeter Zijlstra 	{
1020a78ac325SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
1021cdd6c482SIngo Molnar 		.procname	= "perf_event_max_sample_rate",
1022cdd6c482SIngo Molnar 		.data		= &sysctl_perf_event_sample_rate,
1023cdd6c482SIngo Molnar 		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
1024a78ac325SPeter Zijlstra 		.mode		= 0644,
1025a78ac325SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
1026a78ac325SPeter Zijlstra 	},
10271ccd1549SPeter Zijlstra #endif
1028dfec072eSVegard Nossum #ifdef CONFIG_KMEMCHECK
1029dfec072eSVegard Nossum 	{
1030dfec072eSVegard Nossum 		.ctl_name	= CTL_UNNUMBERED,
1031dfec072eSVegard Nossum 		.procname	= "kmemcheck",
1032dfec072eSVegard Nossum 		.data		= &kmemcheck_enabled,
1033dfec072eSVegard Nossum 		.maxlen		= sizeof(int),
1034dfec072eSVegard Nossum 		.mode		= 0644,
1035dfec072eSVegard Nossum 		.proc_handler	= &proc_dointvec,
1036dfec072eSVegard Nossum 	},
1037dfec072eSVegard Nossum #endif
1038cb684b5bSJens Axboe #ifdef CONFIG_BLOCK
10395e605b64SJens Axboe 	{
10405e605b64SJens Axboe 		.ctl_name	= CTL_UNNUMBERED,
10415e605b64SJens Axboe 		.procname	= "blk_iopoll",
10425e605b64SJens Axboe 		.data		= &blk_iopoll_enabled,
10435e605b64SJens Axboe 		.maxlen		= sizeof(int),
10445e605b64SJens Axboe 		.mode		= 0644,
10455e605b64SJens Axboe 		.proc_handler	= &proc_dointvec,
10465e605b64SJens Axboe 	},
1047cb684b5bSJens Axboe #endif
1048ed2c12f3SAndrew Morton /*
1049ed2c12f3SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
1050ed2c12f3SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
1051ed2c12f3SAndrew Morton  */
10521da177e4SLinus Torvalds 	{ .ctl_name = 0 }
10531da177e4SLinus Torvalds };
10541da177e4SLinus Torvalds 
1055d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
10561da177e4SLinus Torvalds 	{
10571da177e4SLinus Torvalds 		.ctl_name	= VM_OVERCOMMIT_MEMORY,
10581da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
10591da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
10601da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
10611da177e4SLinus Torvalds 		.mode		= 0644,
10621da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10631da177e4SLinus Torvalds 	},
10641da177e4SLinus Torvalds 	{
1065fadd8fbdSKAMEZAWA Hiroyuki 		.ctl_name	= VM_PANIC_ON_OOM,
1066fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
1067fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
1068fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
1069fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
1070fadd8fbdSKAMEZAWA Hiroyuki 		.proc_handler	= &proc_dointvec,
1071fadd8fbdSKAMEZAWA Hiroyuki 	},
1072fadd8fbdSKAMEZAWA Hiroyuki 	{
1073fe071d7eSDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
1074fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
1075fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
1076fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
1077fe071d7eSDavid Rientjes 		.mode		= 0644,
1078fe071d7eSDavid Rientjes 		.proc_handler	= &proc_dointvec,
1079fe071d7eSDavid Rientjes 	},
1080fe071d7eSDavid Rientjes 	{
1081fef1bdd6SDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
1082fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
1083fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
1084fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
1085fef1bdd6SDavid Rientjes 		.mode		= 0644,
1086fef1bdd6SDavid Rientjes 		.proc_handler	= &proc_dointvec,
1087fef1bdd6SDavid Rientjes 	},
1088fef1bdd6SDavid Rientjes 	{
10891da177e4SLinus Torvalds 		.ctl_name	= VM_OVERCOMMIT_RATIO,
10901da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
10911da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
10921da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
10931da177e4SLinus Torvalds 		.mode		= 0644,
10941da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10951da177e4SLinus Torvalds 	},
10961da177e4SLinus Torvalds 	{
10971da177e4SLinus Torvalds 		.ctl_name	= VM_PAGE_CLUSTER,
10981da177e4SLinus Torvalds 		.procname	= "page-cluster",
10991da177e4SLinus Torvalds 		.data		= &page_cluster,
11001da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
11011da177e4SLinus Torvalds 		.mode		= 0644,
11021da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
11031da177e4SLinus Torvalds 	},
11041da177e4SLinus Torvalds 	{
11051da177e4SLinus Torvalds 		.ctl_name	= VM_DIRTY_BACKGROUND,
11061da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
11071da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
11081da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
11091da177e4SLinus Torvalds 		.mode		= 0644,
11102da02997SDavid Rientjes 		.proc_handler	= &dirty_background_ratio_handler,
11111da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
11121da177e4SLinus Torvalds 		.extra1		= &zero,
11131da177e4SLinus Torvalds 		.extra2		= &one_hundred,
11141da177e4SLinus Torvalds 	},
11151da177e4SLinus Torvalds 	{
11162da02997SDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
11172da02997SDavid Rientjes 		.procname	= "dirty_background_bytes",
11182da02997SDavid Rientjes 		.data		= &dirty_background_bytes,
11192da02997SDavid Rientjes 		.maxlen		= sizeof(dirty_background_bytes),
11202da02997SDavid Rientjes 		.mode		= 0644,
11212da02997SDavid Rientjes 		.proc_handler	= &dirty_background_bytes_handler,
11222da02997SDavid Rientjes 		.strategy	= &sysctl_intvec,
1123fc3501d4SSven Wegener 		.extra1		= &one_ul,
11242da02997SDavid Rientjes 	},
11252da02997SDavid Rientjes 	{
11261da177e4SLinus Torvalds 		.ctl_name	= VM_DIRTY_RATIO,
11271da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
11281da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
11291da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
11301da177e4SLinus Torvalds 		.mode		= 0644,
113104fbfdc1SPeter Zijlstra 		.proc_handler	= &dirty_ratio_handler,
11321da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
11331da177e4SLinus Torvalds 		.extra1		= &zero,
11341da177e4SLinus Torvalds 		.extra2		= &one_hundred,
11351da177e4SLinus Torvalds 	},
11361da177e4SLinus Torvalds 	{
11372da02997SDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
11382da02997SDavid Rientjes 		.procname	= "dirty_bytes",
11392da02997SDavid Rientjes 		.data		= &vm_dirty_bytes,
11402da02997SDavid Rientjes 		.maxlen		= sizeof(vm_dirty_bytes),
11412da02997SDavid Rientjes 		.mode		= 0644,
11422da02997SDavid Rientjes 		.proc_handler	= &dirty_bytes_handler,
11432da02997SDavid Rientjes 		.strategy	= &sysctl_intvec,
11449e4a5bdaSAndrea Righi 		.extra1		= &dirty_bytes_min,
11452da02997SDavid Rientjes 	},
11462da02997SDavid Rientjes 	{
11471da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
1148f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
1149f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
11501da177e4SLinus Torvalds 		.mode		= 0644,
11511da177e4SLinus Torvalds 		.proc_handler	= &dirty_writeback_centisecs_handler,
11521da177e4SLinus Torvalds 	},
11531da177e4SLinus Torvalds 	{
11541da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
1155f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
1156f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
11571da177e4SLinus Torvalds 		.mode		= 0644,
1158704503d8SAlexey Dobriyan 		.proc_handler	= &proc_dointvec,
11591da177e4SLinus Torvalds 	},
11601da177e4SLinus Torvalds 	{
11611da177e4SLinus Torvalds 		.ctl_name	= VM_NR_PDFLUSH_THREADS,
11621da177e4SLinus Torvalds 		.procname	= "nr_pdflush_threads",
11631da177e4SLinus Torvalds 		.data		= &nr_pdflush_threads,
11641da177e4SLinus Torvalds 		.maxlen		= sizeof nr_pdflush_threads,
11651da177e4SLinus Torvalds 		.mode		= 0444 /* read-only*/,
11661da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
11671da177e4SLinus Torvalds 	},
11681da177e4SLinus Torvalds 	{
11691da177e4SLinus Torvalds 		.ctl_name	= VM_SWAPPINESS,
11701da177e4SLinus Torvalds 		.procname	= "swappiness",
11711da177e4SLinus Torvalds 		.data		= &vm_swappiness,
11721da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
11731da177e4SLinus Torvalds 		.mode		= 0644,
11741da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
11751da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
11761da177e4SLinus Torvalds 		.extra1		= &zero,
11771da177e4SLinus Torvalds 		.extra2		= &one_hundred,
11781da177e4SLinus Torvalds 	},
11791da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
11801da177e4SLinus Torvalds 	 {
11811da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
1182e5ff2159SAndi Kleen 		.data		= NULL,
11831da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
11841da177e4SLinus Torvalds 		.mode		= 0644,
11851da177e4SLinus Torvalds 		.proc_handler	= &hugetlb_sysctl_handler,
11861da177e4SLinus Torvalds 		.extra1		= (void *)&hugetlb_zero,
11871da177e4SLinus Torvalds 		.extra2		= (void *)&hugetlb_infinity,
11881da177e4SLinus Torvalds 	 },
11891da177e4SLinus Torvalds 	 {
11901da177e4SLinus Torvalds 		.ctl_name	= VM_HUGETLB_GROUP,
11911da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
11921da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
11931da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
11941da177e4SLinus Torvalds 		.mode		= 0644,
11951da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
11961da177e4SLinus Torvalds 	 },
1197396faf03SMel Gorman 	 {
1198396faf03SMel Gorman 		.ctl_name	= CTL_UNNUMBERED,
1199396faf03SMel Gorman 		.procname	= "hugepages_treat_as_movable",
1200396faf03SMel Gorman 		.data		= &hugepages_treat_as_movable,
1201396faf03SMel Gorman 		.maxlen		= sizeof(int),
1202396faf03SMel Gorman 		.mode		= 0644,
1203396faf03SMel Gorman 		.proc_handler	= &hugetlb_treat_movable_handler,
1204396faf03SMel Gorman 	},
120554f9f80dSAdam Litke 	{
120654f9f80dSAdam Litke 		.ctl_name	= CTL_UNNUMBERED,
1207d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
1208e5ff2159SAndi Kleen 		.data		= NULL,
1209e5ff2159SAndi Kleen 		.maxlen		= sizeof(unsigned long),
1210d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
1211a3d0c6aaSNishanth Aravamudan 		.proc_handler	= &hugetlb_overcommit_handler,
1212e5ff2159SAndi Kleen 		.extra1		= (void *)&hugetlb_zero,
1213e5ff2159SAndi Kleen 		.extra2		= (void *)&hugetlb_infinity,
1214d1c3fb1fSNishanth Aravamudan 	},
12151da177e4SLinus Torvalds #endif
12161da177e4SLinus Torvalds 	{
12171da177e4SLinus Torvalds 		.ctl_name	= VM_LOWMEM_RESERVE_RATIO,
12181da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
12191da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
12201da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
12211da177e4SLinus Torvalds 		.mode		= 0644,
12221da177e4SLinus Torvalds 		.proc_handler	= &lowmem_reserve_ratio_sysctl_handler,
12231da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
12241da177e4SLinus Torvalds 	},
12251da177e4SLinus Torvalds 	{
12269d0243bcSAndrew Morton 		.ctl_name	= VM_DROP_PAGECACHE,
12279d0243bcSAndrew Morton 		.procname	= "drop_caches",
12289d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
12299d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
12309d0243bcSAndrew Morton 		.mode		= 0644,
12319d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
12329d0243bcSAndrew Morton 		.strategy	= &sysctl_intvec,
12339d0243bcSAndrew Morton 	},
12349d0243bcSAndrew Morton 	{
12351da177e4SLinus Torvalds 		.ctl_name	= VM_MIN_FREE_KBYTES,
12361da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
12371da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
12381da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
12391da177e4SLinus Torvalds 		.mode		= 0644,
12401da177e4SLinus Torvalds 		.proc_handler	= &min_free_kbytes_sysctl_handler,
12411da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
12421da177e4SLinus Torvalds 		.extra1		= &zero,
12431da177e4SLinus Torvalds 	},
12448ad4b1fbSRohit Seth 	{
12458ad4b1fbSRohit Seth 		.ctl_name	= VM_PERCPU_PAGELIST_FRACTION,
12468ad4b1fbSRohit Seth 		.procname	= "percpu_pagelist_fraction",
12478ad4b1fbSRohit Seth 		.data		= &percpu_pagelist_fraction,
12488ad4b1fbSRohit Seth 		.maxlen		= sizeof(percpu_pagelist_fraction),
12498ad4b1fbSRohit Seth 		.mode		= 0644,
12508ad4b1fbSRohit Seth 		.proc_handler	= &percpu_pagelist_fraction_sysctl_handler,
12518ad4b1fbSRohit Seth 		.strategy	= &sysctl_intvec,
12528ad4b1fbSRohit Seth 		.extra1		= &min_percpu_pagelist_fract,
12538ad4b1fbSRohit Seth 	},
12541da177e4SLinus Torvalds #ifdef CONFIG_MMU
12551da177e4SLinus Torvalds 	{
12561da177e4SLinus Torvalds 		.ctl_name	= VM_MAX_MAP_COUNT,
12571da177e4SLinus Torvalds 		.procname	= "max_map_count",
12581da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
12591da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
12601da177e4SLinus Torvalds 		.mode		= 0644,
12611da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec
12621da177e4SLinus Torvalds 	},
1263dd8632a1SPaul Mundt #else
1264dd8632a1SPaul Mundt 	{
1265dd8632a1SPaul Mundt 		.ctl_name	= CTL_UNNUMBERED,
1266dd8632a1SPaul Mundt 		.procname	= "nr_trim_pages",
1267dd8632a1SPaul Mundt 		.data		= &sysctl_nr_trim_pages,
1268dd8632a1SPaul Mundt 		.maxlen		= sizeof(sysctl_nr_trim_pages),
1269dd8632a1SPaul Mundt 		.mode		= 0644,
1270dd8632a1SPaul Mundt 		.proc_handler	= &proc_dointvec_minmax,
1271dd8632a1SPaul Mundt 		.strategy	= &sysctl_intvec,
1272dd8632a1SPaul Mundt 		.extra1		= &zero,
1273dd8632a1SPaul Mundt 	},
12741da177e4SLinus Torvalds #endif
12751da177e4SLinus Torvalds 	{
12761da177e4SLinus Torvalds 		.ctl_name	= VM_LAPTOP_MODE,
12771da177e4SLinus Torvalds 		.procname	= "laptop_mode",
12781da177e4SLinus Torvalds 		.data		= &laptop_mode,
12791da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
12801da177e4SLinus Torvalds 		.mode		= 0644,
1281ed5b43f1SBart Samwel 		.proc_handler	= &proc_dointvec_jiffies,
1282ed5b43f1SBart Samwel 		.strategy	= &sysctl_jiffies,
12831da177e4SLinus Torvalds 	},
12841da177e4SLinus Torvalds 	{
12851da177e4SLinus Torvalds 		.ctl_name	= VM_BLOCK_DUMP,
12861da177e4SLinus Torvalds 		.procname	= "block_dump",
12871da177e4SLinus Torvalds 		.data		= &block_dump,
12881da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
12891da177e4SLinus Torvalds 		.mode		= 0644,
12901da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
12911da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
12921da177e4SLinus Torvalds 		.extra1		= &zero,
12931da177e4SLinus Torvalds 	},
12941da177e4SLinus Torvalds 	{
12951da177e4SLinus Torvalds 		.ctl_name	= VM_VFS_CACHE_PRESSURE,
12961da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
12971da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
12981da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
12991da177e4SLinus Torvalds 		.mode		= 0644,
13001da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
13011da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
13021da177e4SLinus Torvalds 		.extra1		= &zero,
13031da177e4SLinus Torvalds 	},
13041da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
13051da177e4SLinus Torvalds 	{
13061da177e4SLinus Torvalds 		.ctl_name	= VM_LEGACY_VA_LAYOUT,
13071da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
13081da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
13091da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
13101da177e4SLinus Torvalds 		.mode		= 0644,
13111da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
13121da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
13131da177e4SLinus Torvalds 		.extra1		= &zero,
13141da177e4SLinus Torvalds 	},
13151da177e4SLinus Torvalds #endif
13161743660bSChristoph Lameter #ifdef CONFIG_NUMA
13171743660bSChristoph Lameter 	{
13181743660bSChristoph Lameter 		.ctl_name	= VM_ZONE_RECLAIM_MODE,
13191743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
13201743660bSChristoph Lameter 		.data		= &zone_reclaim_mode,
13211743660bSChristoph Lameter 		.maxlen		= sizeof(zone_reclaim_mode),
13221743660bSChristoph Lameter 		.mode		= 0644,
13231743660bSChristoph Lameter 		.proc_handler	= &proc_dointvec,
1324c84db23cSChristoph Lameter 		.strategy	= &sysctl_intvec,
1325c84db23cSChristoph Lameter 		.extra1		= &zero,
13261743660bSChristoph Lameter 	},
13279614634fSChristoph Lameter 	{
13289614634fSChristoph Lameter 		.ctl_name	= VM_MIN_UNMAPPED,
13299614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
13309614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
13319614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
13329614634fSChristoph Lameter 		.mode		= 0644,
13339614634fSChristoph Lameter 		.proc_handler	= &sysctl_min_unmapped_ratio_sysctl_handler,
13349614634fSChristoph Lameter 		.strategy	= &sysctl_intvec,
13359614634fSChristoph Lameter 		.extra1		= &zero,
13369614634fSChristoph Lameter 		.extra2		= &one_hundred,
13379614634fSChristoph Lameter 	},
13380ff38490SChristoph Lameter 	{
13390ff38490SChristoph Lameter 		.ctl_name	= VM_MIN_SLAB,
13400ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
13410ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
13420ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
13430ff38490SChristoph Lameter 		.mode		= 0644,
13440ff38490SChristoph Lameter 		.proc_handler	= &sysctl_min_slab_ratio_sysctl_handler,
13450ff38490SChristoph Lameter 		.strategy	= &sysctl_intvec,
13460ff38490SChristoph Lameter 		.extra1		= &zero,
13470ff38490SChristoph Lameter 		.extra2		= &one_hundred,
13480ff38490SChristoph Lameter 	},
13491743660bSChristoph Lameter #endif
135077461ab3SChristoph Lameter #ifdef CONFIG_SMP
135177461ab3SChristoph Lameter 	{
135277461ab3SChristoph Lameter 		.ctl_name	= CTL_UNNUMBERED,
135377461ab3SChristoph Lameter 		.procname	= "stat_interval",
135477461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
135577461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
135677461ab3SChristoph Lameter 		.mode		= 0644,
135777461ab3SChristoph Lameter 		.proc_handler	= &proc_dointvec_jiffies,
135877461ab3SChristoph Lameter 		.strategy	= &sysctl_jiffies,
135977461ab3SChristoph Lameter 	},
136077461ab3SChristoph Lameter #endif
1361ed032189SEric Paris 	{
1362ed032189SEric Paris 		.ctl_name	= CTL_UNNUMBERED,
1363ed032189SEric Paris 		.procname	= "mmap_min_addr",
1364788084abSEric Paris 		.data		= &dac_mmap_min_addr,
1365ed032189SEric Paris 		.maxlen		= sizeof(unsigned long),
1366ed032189SEric Paris 		.mode		= 0644,
1367788084abSEric Paris 		.proc_handler	= &mmap_min_addr_handler,
1368ed032189SEric Paris 	},
1369f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
1370f0c0b2b8SKAMEZAWA Hiroyuki 	{
1371f0c0b2b8SKAMEZAWA Hiroyuki 		.ctl_name	= CTL_UNNUMBERED,
1372f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
1373f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
1374f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
1375f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
1376f0c0b2b8SKAMEZAWA Hiroyuki 		.proc_handler	= &numa_zonelist_order_handler,
1377f0c0b2b8SKAMEZAWA Hiroyuki 		.strategy	= &sysctl_string,
1378f0c0b2b8SKAMEZAWA Hiroyuki 	},
1379f0c0b2b8SKAMEZAWA Hiroyuki #endif
13802b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
13815c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1382e6e5494cSIngo Molnar 	{
1383e6e5494cSIngo Molnar 		.ctl_name	= VM_VDSO_ENABLED,
1384e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
1385e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
1386e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
1387e6e5494cSIngo Molnar 		.mode		= 0644,
1388e6e5494cSIngo Molnar 		.proc_handler	= &proc_dointvec,
1389e6e5494cSIngo Molnar 		.strategy	= &sysctl_intvec,
1390e6e5494cSIngo Molnar 		.extra1		= &zero,
1391e6e5494cSIngo Molnar 	},
1392e6e5494cSIngo Molnar #endif
1393195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
1394195cf453SBron Gondwana 	{
1395195cf453SBron Gondwana 		.ctl_name	= CTL_UNNUMBERED,
1396195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
1397195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
1398195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
1399195cf453SBron Gondwana 		.mode		= 0644,
1400195cf453SBron Gondwana 		.proc_handler	= &proc_dointvec_minmax,
1401195cf453SBron Gondwana 		.strategy	= &sysctl_intvec,
1402195cf453SBron Gondwana 		.extra1		= &zero,
1403195cf453SBron Gondwana 		.extra2		= &one,
1404195cf453SBron Gondwana 	},
1405195cf453SBron Gondwana #endif
14064be6f6bbSPeter Zijlstra 	{
14074be6f6bbSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
14084be6f6bbSPeter Zijlstra 		.procname	= "scan_unevictable_pages",
14094be6f6bbSPeter Zijlstra 		.data		= &scan_unevictable_pages,
14104be6f6bbSPeter Zijlstra 		.maxlen		= sizeof(scan_unevictable_pages),
14114be6f6bbSPeter Zijlstra 		.mode		= 0644,
14124be6f6bbSPeter Zijlstra 		.proc_handler	= &scan_unevictable_handler,
14134be6f6bbSPeter Zijlstra 	},
14146a46079cSAndi Kleen #ifdef CONFIG_MEMORY_FAILURE
14156a46079cSAndi Kleen 	{
14166a46079cSAndi Kleen 		.ctl_name	= CTL_UNNUMBERED,
14176a46079cSAndi Kleen 		.procname	= "memory_failure_early_kill",
14186a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_early_kill,
14196a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_early_kill),
14206a46079cSAndi Kleen 		.mode		= 0644,
14216a46079cSAndi Kleen 		.proc_handler	= &proc_dointvec_minmax,
14226a46079cSAndi Kleen 		.strategy	= &sysctl_intvec,
14236a46079cSAndi Kleen 		.extra1		= &zero,
14246a46079cSAndi Kleen 		.extra2		= &one,
14256a46079cSAndi Kleen 	},
14266a46079cSAndi Kleen 	{
14276a46079cSAndi Kleen 		.ctl_name	= CTL_UNNUMBERED,
14286a46079cSAndi Kleen 		.procname	= "memory_failure_recovery",
14296a46079cSAndi Kleen 		.data		= &sysctl_memory_failure_recovery,
14306a46079cSAndi Kleen 		.maxlen		= sizeof(sysctl_memory_failure_recovery),
14316a46079cSAndi Kleen 		.mode		= 0644,
14326a46079cSAndi Kleen 		.proc_handler	= &proc_dointvec_minmax,
14336a46079cSAndi Kleen 		.strategy	= &sysctl_intvec,
14346a46079cSAndi Kleen 		.extra1		= &zero,
14356a46079cSAndi Kleen 		.extra2		= &one,
14366a46079cSAndi Kleen 	},
14376a46079cSAndi Kleen #endif
14386a46079cSAndi Kleen 
14392be7fe07SAndrew Morton /*
14402be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
14412be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
14422be7fe07SAndrew Morton  */
14431da177e4SLinus Torvalds 	{ .ctl_name = 0 }
14441da177e4SLinus Torvalds };
14451da177e4SLinus Torvalds 
14462abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1447d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = {
14482abc26fcSEric W. Biederman 	{ .ctl_name = 0 }
14492abc26fcSEric W. Biederman };
14502abc26fcSEric W. Biederman #endif
14512abc26fcSEric W. Biederman 
1452d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
14531da177e4SLinus Torvalds 	{
14541da177e4SLinus Torvalds 		.ctl_name	= FS_NRINODE,
14551da177e4SLinus Torvalds 		.procname	= "inode-nr",
14561da177e4SLinus Torvalds 		.data		= &inodes_stat,
14571da177e4SLinus Torvalds 		.maxlen		= 2*sizeof(int),
14581da177e4SLinus Torvalds 		.mode		= 0444,
14591da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14601da177e4SLinus Torvalds 	},
14611da177e4SLinus Torvalds 	{
14621da177e4SLinus Torvalds 		.ctl_name	= FS_STATINODE,
14631da177e4SLinus Torvalds 		.procname	= "inode-state",
14641da177e4SLinus Torvalds 		.data		= &inodes_stat,
14651da177e4SLinus Torvalds 		.maxlen		= 7*sizeof(int),
14661da177e4SLinus Torvalds 		.mode		= 0444,
14671da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14681da177e4SLinus Torvalds 	},
14691da177e4SLinus Torvalds 	{
14701da177e4SLinus Torvalds 		.procname	= "file-nr",
14711da177e4SLinus Torvalds 		.data		= &files_stat,
14721da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
14731da177e4SLinus Torvalds 		.mode		= 0444,
1474529bf6beSDipankar Sarma 		.proc_handler	= &proc_nr_files,
14751da177e4SLinus Torvalds 	},
14761da177e4SLinus Torvalds 	{
14771da177e4SLinus Torvalds 		.ctl_name	= FS_MAXFILE,
14781da177e4SLinus Torvalds 		.procname	= "file-max",
14791da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
14801da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
14811da177e4SLinus Torvalds 		.mode		= 0644,
14821da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
14831da177e4SLinus Torvalds 	},
14841da177e4SLinus Torvalds 	{
14859cfe015aSEric Dumazet 		.ctl_name	= CTL_UNNUMBERED,
14869cfe015aSEric Dumazet 		.procname	= "nr_open",
14879cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
14889cfe015aSEric Dumazet 		.maxlen		= sizeof(int),
14899cfe015aSEric Dumazet 		.mode		= 0644,
1490eceea0b3SAl Viro 		.proc_handler	= &proc_dointvec_minmax,
1491eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
1492eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
14939cfe015aSEric Dumazet 	},
14949cfe015aSEric Dumazet 	{
14951da177e4SLinus Torvalds 		.ctl_name	= FS_DENTRY,
14961da177e4SLinus Torvalds 		.procname	= "dentry-state",
14971da177e4SLinus Torvalds 		.data		= &dentry_stat,
14981da177e4SLinus Torvalds 		.maxlen		= 6*sizeof(int),
14991da177e4SLinus Torvalds 		.mode		= 0444,
15001da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
15011da177e4SLinus Torvalds 	},
15021da177e4SLinus Torvalds 	{
15031da177e4SLinus Torvalds 		.ctl_name	= FS_OVERFLOWUID,
15041da177e4SLinus Torvalds 		.procname	= "overflowuid",
15051da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
15061da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
15071da177e4SLinus Torvalds 		.mode		= 0644,
15081da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
15091da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
15101da177e4SLinus Torvalds 		.extra1		= &minolduid,
15111da177e4SLinus Torvalds 		.extra2		= &maxolduid,
15121da177e4SLinus Torvalds 	},
15131da177e4SLinus Torvalds 	{
15141da177e4SLinus Torvalds 		.ctl_name	= FS_OVERFLOWGID,
15151da177e4SLinus Torvalds 		.procname	= "overflowgid",
15161da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
15171da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
15181da177e4SLinus Torvalds 		.mode		= 0644,
15191da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
15201da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
15211da177e4SLinus Torvalds 		.extra1		= &minolduid,
15221da177e4SLinus Torvalds 		.extra2		= &maxolduid,
15231da177e4SLinus Torvalds 	},
1524bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
15251da177e4SLinus Torvalds 	{
15261da177e4SLinus Torvalds 		.ctl_name	= FS_LEASES,
15271da177e4SLinus Torvalds 		.procname	= "leases-enable",
15281da177e4SLinus Torvalds 		.data		= &leases_enable,
15291da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
15301da177e4SLinus Torvalds 		.mode		= 0644,
15311da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
15321da177e4SLinus Torvalds 	},
1533bfcd17a6SThomas Petazzoni #endif
15341da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
15351da177e4SLinus Torvalds 	{
15361da177e4SLinus Torvalds 		.ctl_name	= FS_DIR_NOTIFY,
15371da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
15381da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
15391da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
15401da177e4SLinus Torvalds 		.mode		= 0644,
15411da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
15421da177e4SLinus Torvalds 	},
15431da177e4SLinus Torvalds #endif
15441da177e4SLinus Torvalds #ifdef CONFIG_MMU
1545bfcd17a6SThomas Petazzoni #ifdef CONFIG_FILE_LOCKING
15461da177e4SLinus Torvalds 	{
15471da177e4SLinus Torvalds 		.ctl_name	= FS_LEASE_TIME,
15481da177e4SLinus Torvalds 		.procname	= "lease-break-time",
15491da177e4SLinus Torvalds 		.data		= &lease_break_time,
15501da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
15511da177e4SLinus Torvalds 		.mode		= 0644,
15528e654fbaSMatthew Wilcox 		.proc_handler	= &proc_dointvec,
15531da177e4SLinus Torvalds 	},
1554bfcd17a6SThomas Petazzoni #endif
1555ebf3f09cSThomas Petazzoni #ifdef CONFIG_AIO
15561da177e4SLinus Torvalds 	{
15571da177e4SLinus Torvalds 		.procname	= "aio-nr",
15581da177e4SLinus Torvalds 		.data		= &aio_nr,
15591da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
15601da177e4SLinus Torvalds 		.mode		= 0444,
1561d55b5fdaSZach Brown 		.proc_handler	= &proc_doulongvec_minmax,
15621da177e4SLinus Torvalds 	},
15631da177e4SLinus Torvalds 	{
15641da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
15651da177e4SLinus Torvalds 		.data		= &aio_max_nr,
15661da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
15671da177e4SLinus Torvalds 		.mode		= 0644,
1568d55b5fdaSZach Brown 		.proc_handler	= &proc_doulongvec_minmax,
15691da177e4SLinus Torvalds 	},
1570ebf3f09cSThomas Petazzoni #endif /* CONFIG_AIO */
15712d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
15720399cb08SRobert Love 	{
15730399cb08SRobert Love 		.ctl_name	= FS_INOTIFY,
15740399cb08SRobert Love 		.procname	= "inotify",
15750399cb08SRobert Love 		.mode		= 0555,
15760399cb08SRobert Love 		.child		= inotify_table,
15770399cb08SRobert Love 	},
15780399cb08SRobert Love #endif
15797ef9964eSDavide Libenzi #ifdef CONFIG_EPOLL
15807ef9964eSDavide Libenzi 	{
15817ef9964eSDavide Libenzi 		.procname	= "epoll",
15827ef9964eSDavide Libenzi 		.mode		= 0555,
15837ef9964eSDavide Libenzi 		.child		= epoll_table,
15847ef9964eSDavide Libenzi 	},
15857ef9964eSDavide Libenzi #endif
15861da177e4SLinus Torvalds #endif
1587d6e71144SAlan Cox 	{
1588d6e71144SAlan Cox 		.ctl_name	= KERN_SETUID_DUMPABLE,
1589d6e71144SAlan Cox 		.procname	= "suid_dumpable",
1590d6e71144SAlan Cox 		.data		= &suid_dumpable,
1591d6e71144SAlan Cox 		.maxlen		= sizeof(int),
1592d6e71144SAlan Cox 		.mode		= 0644,
15938e654fbaSMatthew Wilcox 		.proc_handler	= &proc_dointvec_minmax,
15948e654fbaSMatthew Wilcox 		.strategy	= &sysctl_intvec,
15958e654fbaSMatthew Wilcox 		.extra1		= &zero,
15968e654fbaSMatthew Wilcox 		.extra2		= &two,
1597d6e71144SAlan Cox 	},
15982abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
15992abc26fcSEric W. Biederman 	{
16002abc26fcSEric W. Biederman 		.ctl_name	= CTL_UNNUMBERED,
16012abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
16022abc26fcSEric W. Biederman 		.mode		= 0555,
16032abc26fcSEric W. Biederman 		.child		= binfmt_misc_table,
16042abc26fcSEric W. Biederman 	},
16052abc26fcSEric W. Biederman #endif
16062be7fe07SAndrew Morton /*
16072be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
16082be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
16092be7fe07SAndrew Morton  */
16101da177e4SLinus Torvalds 	{ .ctl_name = 0 }
16111da177e4SLinus Torvalds };
16121da177e4SLinus Torvalds 
1613d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
1614d0c3d534SOlof Johansson #if defined(CONFIG_X86) || defined(CONFIG_PPC)
1615abd4f750SMasoud Asgharifard Sharbiani 	{
1616abd4f750SMasoud Asgharifard Sharbiani 		.ctl_name	= CTL_UNNUMBERED,
1617abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
1618abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
1619abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
1620abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
1621abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
1622abd4f750SMasoud Asgharifard Sharbiani 	},
1623abd4f750SMasoud Asgharifard Sharbiani #endif
16241da177e4SLinus Torvalds 	{ .ctl_name = 0 }
16251da177e4SLinus Torvalds };
16261da177e4SLinus Torvalds 
1627d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
16281da177e4SLinus Torvalds 	{ .ctl_name = 0 }
16291da177e4SLinus Torvalds };
16301da177e4SLinus Torvalds 
1631330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock);
1632330d57fbSAl Viro 
1633330d57fbSAl Viro /* called under sysctl_lock */
1634330d57fbSAl Viro static int use_table(struct ctl_table_header *p)
1635330d57fbSAl Viro {
1636330d57fbSAl Viro 	if (unlikely(p->unregistering))
1637330d57fbSAl Viro 		return 0;
1638330d57fbSAl Viro 	p->used++;
1639330d57fbSAl Viro 	return 1;
1640330d57fbSAl Viro }
1641330d57fbSAl Viro 
1642330d57fbSAl Viro /* called under sysctl_lock */
1643330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p)
1644330d57fbSAl Viro {
1645330d57fbSAl Viro 	if (!--p->used)
1646330d57fbSAl Viro 		if (unlikely(p->unregistering))
1647330d57fbSAl Viro 			complete(p->unregistering);
1648330d57fbSAl Viro }
1649330d57fbSAl Viro 
1650330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */
1651330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p)
1652330d57fbSAl Viro {
1653330d57fbSAl Viro 	/*
1654330d57fbSAl Viro 	 * if p->used is 0, nobody will ever touch that entry again;
1655330d57fbSAl Viro 	 * we'll eliminate all paths to it before dropping sysctl_lock
1656330d57fbSAl Viro 	 */
1657330d57fbSAl Viro 	if (unlikely(p->used)) {
1658330d57fbSAl Viro 		struct completion wait;
1659330d57fbSAl Viro 		init_completion(&wait);
1660330d57fbSAl Viro 		p->unregistering = &wait;
1661330d57fbSAl Viro 		spin_unlock(&sysctl_lock);
1662330d57fbSAl Viro 		wait_for_completion(&wait);
1663330d57fbSAl Viro 		spin_lock(&sysctl_lock);
1664f7e6ced4SAl Viro 	} else {
1665f7e6ced4SAl Viro 		/* anything non-NULL; we'll never dereference it */
1666f7e6ced4SAl Viro 		p->unregistering = ERR_PTR(-EINVAL);
1667330d57fbSAl Viro 	}
1668330d57fbSAl Viro 	/*
1669330d57fbSAl Viro 	 * do not remove from the list until nobody holds it; walking the
1670330d57fbSAl Viro 	 * list in do_sysctl() relies on that.
1671330d57fbSAl Viro 	 */
1672330d57fbSAl Viro 	list_del_init(&p->ctl_entry);
1673330d57fbSAl Viro }
1674330d57fbSAl Viro 
1675f7e6ced4SAl Viro void sysctl_head_get(struct ctl_table_header *head)
1676f7e6ced4SAl Viro {
1677f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1678f7e6ced4SAl Viro 	head->count++;
1679f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1680f7e6ced4SAl Viro }
1681f7e6ced4SAl Viro 
1682f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
1683f7e6ced4SAl Viro {
1684f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1685f7e6ced4SAl Viro 	if (!--head->count)
1686f7e6ced4SAl Viro 		kfree(head);
1687f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1688f7e6ced4SAl Viro }
1689f7e6ced4SAl Viro 
1690f7e6ced4SAl Viro struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1691f7e6ced4SAl Viro {
1692f7e6ced4SAl Viro 	if (!head)
1693f7e6ced4SAl Viro 		BUG();
1694f7e6ced4SAl Viro 	spin_lock(&sysctl_lock);
1695f7e6ced4SAl Viro 	if (!use_table(head))
1696f7e6ced4SAl Viro 		head = ERR_PTR(-ENOENT);
1697f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
1698f7e6ced4SAl Viro 	return head;
1699f7e6ced4SAl Viro }
1700f7e6ced4SAl Viro 
1701805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head)
1702805b5d5eSEric W. Biederman {
1703805b5d5eSEric W. Biederman 	if (!head)
1704805b5d5eSEric W. Biederman 		return;
1705805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1706805b5d5eSEric W. Biederman 	unuse_table(head);
1707805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1708805b5d5eSEric W. Biederman }
1709805b5d5eSEric W. Biederman 
171073455092SAl Viro static struct ctl_table_set *
171173455092SAl Viro lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
171273455092SAl Viro {
171373455092SAl Viro 	struct ctl_table_set *set = &root->default_set;
171473455092SAl Viro 	if (root->lookup)
171573455092SAl Viro 		set = root->lookup(root, namespaces);
171673455092SAl Viro 	return set;
171773455092SAl Viro }
171873455092SAl Viro 
1719e51b6ba0SEric W. Biederman static struct list_head *
1720e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1721805b5d5eSEric W. Biederman {
172273455092SAl Viro 	struct ctl_table_set *set = lookup_header_set(root, namespaces);
172373455092SAl Viro 	return &set->list;
1724e51b6ba0SEric W. Biederman }
1725e51b6ba0SEric W. Biederman 
1726e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1727e51b6ba0SEric W. Biederman 					    struct ctl_table_header *prev)
1728e51b6ba0SEric W. Biederman {
1729e51b6ba0SEric W. Biederman 	struct ctl_table_root *root;
1730e51b6ba0SEric W. Biederman 	struct list_head *header_list;
1731805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1732805b5d5eSEric W. Biederman 	struct list_head *tmp;
1733e51b6ba0SEric W. Biederman 
1734805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1735805b5d5eSEric W. Biederman 	if (prev) {
1736e51b6ba0SEric W. Biederman 		head = prev;
1737805b5d5eSEric W. Biederman 		tmp = &prev->ctl_entry;
1738805b5d5eSEric W. Biederman 		unuse_table(prev);
1739805b5d5eSEric W. Biederman 		goto next;
1740805b5d5eSEric W. Biederman 	}
1741805b5d5eSEric W. Biederman 	tmp = &root_table_header.ctl_entry;
1742805b5d5eSEric W. Biederman 	for (;;) {
1743805b5d5eSEric W. Biederman 		head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1744805b5d5eSEric W. Biederman 
1745805b5d5eSEric W. Biederman 		if (!use_table(head))
1746805b5d5eSEric W. Biederman 			goto next;
1747805b5d5eSEric W. Biederman 		spin_unlock(&sysctl_lock);
1748805b5d5eSEric W. Biederman 		return head;
1749805b5d5eSEric W. Biederman 	next:
1750e51b6ba0SEric W. Biederman 		root = head->root;
1751805b5d5eSEric W. Biederman 		tmp = tmp->next;
1752e51b6ba0SEric W. Biederman 		header_list = lookup_header_list(root, namespaces);
1753e51b6ba0SEric W. Biederman 		if (tmp != header_list)
1754e51b6ba0SEric W. Biederman 			continue;
1755e51b6ba0SEric W. Biederman 
1756e51b6ba0SEric W. Biederman 		do {
1757e51b6ba0SEric W. Biederman 			root = list_entry(root->root_list.next,
1758e51b6ba0SEric W. Biederman 					struct ctl_table_root, root_list);
1759e51b6ba0SEric W. Biederman 			if (root == &sysctl_table_root)
1760e51b6ba0SEric W. Biederman 				goto out;
1761e51b6ba0SEric W. Biederman 			header_list = lookup_header_list(root, namespaces);
1762e51b6ba0SEric W. Biederman 		} while (list_empty(header_list));
1763e51b6ba0SEric W. Biederman 		tmp = header_list->next;
1764805b5d5eSEric W. Biederman 	}
1765e51b6ba0SEric W. Biederman out:
1766805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1767805b5d5eSEric W. Biederman 	return NULL;
1768805b5d5eSEric W. Biederman }
1769805b5d5eSEric W. Biederman 
1770e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1771e51b6ba0SEric W. Biederman {
1772e51b6ba0SEric W. Biederman 	return __sysctl_head_next(current->nsproxy, prev);
1773e51b6ba0SEric W. Biederman }
1774e51b6ba0SEric W. Biederman 
1775e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root)
1776e51b6ba0SEric W. Biederman {
1777e51b6ba0SEric W. Biederman 	spin_lock(&sysctl_lock);
1778e51b6ba0SEric W. Biederman 	list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1779e51b6ba0SEric W. Biederman 	spin_unlock(&sysctl_lock);
1780e51b6ba0SEric W. Biederman }
1781e51b6ba0SEric W. Biederman 
1782b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL
17832c4c7155SPavel Emelyanov /* Perform the actual read/write of a sysctl table entry. */
1784d7321cd6SPavel Emelyanov static int do_sysctl_strategy(struct ctl_table_root *root,
1785d7321cd6SPavel Emelyanov 			struct ctl_table *table,
17862c4c7155SPavel Emelyanov 			void __user *oldval, size_t __user *oldlenp,
17872c4c7155SPavel Emelyanov 			void __user *newval, size_t newlen)
17882c4c7155SPavel Emelyanov {
17892c4c7155SPavel Emelyanov 	int op = 0, rc;
17902c4c7155SPavel Emelyanov 
17912c4c7155SPavel Emelyanov 	if (oldval)
1792e6305c43SAl Viro 		op |= MAY_READ;
17932c4c7155SPavel Emelyanov 	if (newval)
1794e6305c43SAl Viro 		op |= MAY_WRITE;
1795d7321cd6SPavel Emelyanov 	if (sysctl_perm(root, table, op))
17962c4c7155SPavel Emelyanov 		return -EPERM;
17972c4c7155SPavel Emelyanov 
17982c4c7155SPavel Emelyanov 	if (table->strategy) {
1799f221e726SAlexey Dobriyan 		rc = table->strategy(table, oldval, oldlenp, newval, newlen);
18002c4c7155SPavel Emelyanov 		if (rc < 0)
18012c4c7155SPavel Emelyanov 			return rc;
18022c4c7155SPavel Emelyanov 		if (rc > 0)
18032c4c7155SPavel Emelyanov 			return 0;
18042c4c7155SPavel Emelyanov 	}
18052c4c7155SPavel Emelyanov 
18062c4c7155SPavel Emelyanov 	/* If there is no strategy routine, or if the strategy returns
18072c4c7155SPavel Emelyanov 	 * zero, proceed with automatic r/w */
18082c4c7155SPavel Emelyanov 	if (table->data && table->maxlen) {
1809f221e726SAlexey Dobriyan 		rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
18102c4c7155SPavel Emelyanov 		if (rc < 0)
18112c4c7155SPavel Emelyanov 			return rc;
18122c4c7155SPavel Emelyanov 	}
18132c4c7155SPavel Emelyanov 	return 0;
18142c4c7155SPavel Emelyanov }
18152c4c7155SPavel Emelyanov 
18162c4c7155SPavel Emelyanov static int parse_table(int __user *name, int nlen,
18172c4c7155SPavel Emelyanov 		       void __user *oldval, size_t __user *oldlenp,
18182c4c7155SPavel Emelyanov 		       void __user *newval, size_t newlen,
1819d7321cd6SPavel Emelyanov 		       struct ctl_table_root *root,
18202c4c7155SPavel Emelyanov 		       struct ctl_table *table)
18212c4c7155SPavel Emelyanov {
18222c4c7155SPavel Emelyanov 	int n;
18232c4c7155SPavel Emelyanov repeat:
18242c4c7155SPavel Emelyanov 	if (!nlen)
18252c4c7155SPavel Emelyanov 		return -ENOTDIR;
18262c4c7155SPavel Emelyanov 	if (get_user(n, name))
18272c4c7155SPavel Emelyanov 		return -EFAULT;
18282c4c7155SPavel Emelyanov 	for ( ; table->ctl_name || table->procname; table++) {
18292c4c7155SPavel Emelyanov 		if (!table->ctl_name)
18302c4c7155SPavel Emelyanov 			continue;
18312c4c7155SPavel Emelyanov 		if (n == table->ctl_name) {
18322c4c7155SPavel Emelyanov 			int error;
18332c4c7155SPavel Emelyanov 			if (table->child) {
1834e6305c43SAl Viro 				if (sysctl_perm(root, table, MAY_EXEC))
18352c4c7155SPavel Emelyanov 					return -EPERM;
18362c4c7155SPavel Emelyanov 				name++;
18372c4c7155SPavel Emelyanov 				nlen--;
18382c4c7155SPavel Emelyanov 				table = table->child;
18392c4c7155SPavel Emelyanov 				goto repeat;
18402c4c7155SPavel Emelyanov 			}
1841f221e726SAlexey Dobriyan 			error = do_sysctl_strategy(root, table,
18422c4c7155SPavel Emelyanov 						   oldval, oldlenp,
18432c4c7155SPavel Emelyanov 						   newval, newlen);
18442c4c7155SPavel Emelyanov 			return error;
18452c4c7155SPavel Emelyanov 		}
18462c4c7155SPavel Emelyanov 	}
18472c4c7155SPavel Emelyanov 	return -ENOTDIR;
18482c4c7155SPavel Emelyanov }
18492c4c7155SPavel Emelyanov 
18501da177e4SLinus Torvalds int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
18511da177e4SLinus Torvalds 	       void __user *newval, size_t newlen)
18521da177e4SLinus Torvalds {
1853805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1854330d57fbSAl Viro 	int error = -ENOTDIR;
18551da177e4SLinus Torvalds 
18561da177e4SLinus Torvalds 	if (nlen <= 0 || nlen >= CTL_MAXNAME)
18571da177e4SLinus Torvalds 		return -ENOTDIR;
18581da177e4SLinus Torvalds 	if (oldval) {
18591da177e4SLinus Torvalds 		int old_len;
18601da177e4SLinus Torvalds 		if (!oldlenp || get_user(old_len, oldlenp))
18611da177e4SLinus Torvalds 			return -EFAULT;
18621da177e4SLinus Torvalds 	}
1863330d57fbSAl Viro 
1864805b5d5eSEric W. Biederman 	for (head = sysctl_head_next(NULL); head;
1865805b5d5eSEric W. Biederman 			head = sysctl_head_next(head)) {
1866330d57fbSAl Viro 		error = parse_table(name, nlen, oldval, oldlenp,
1867d7321cd6SPavel Emelyanov 					newval, newlen,
1868d7321cd6SPavel Emelyanov 					head->root, head->ctl_table);
1869805b5d5eSEric W. Biederman 		if (error != -ENOTDIR) {
1870805b5d5eSEric W. Biederman 			sysctl_head_finish(head);
1871330d57fbSAl Viro 			break;
1872805b5d5eSEric W. Biederman 		}
1873805b5d5eSEric W. Biederman 	}
18741da177e4SLinus Torvalds 	return error;
18751da177e4SLinus Torvalds }
18761da177e4SLinus Torvalds 
18771e7bfb21SHeiko Carstens SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
18781da177e4SLinus Torvalds {
18791da177e4SLinus Torvalds 	struct __sysctl_args tmp;
18801da177e4SLinus Torvalds 	int error;
18811da177e4SLinus Torvalds 
18821da177e4SLinus Torvalds 	if (copy_from_user(&tmp, args, sizeof(tmp)))
18831da177e4SLinus Torvalds 		return -EFAULT;
18841da177e4SLinus Torvalds 
18857058cb02SEric W. Biederman 	error = deprecated_sysctl_warning(&tmp);
18867058cb02SEric W. Biederman 	if (error)
18877058cb02SEric W. Biederman 		goto out;
18887058cb02SEric W. Biederman 
18891da177e4SLinus Torvalds 	lock_kernel();
18901da177e4SLinus Torvalds 	error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
18911da177e4SLinus Torvalds 			  tmp.newval, tmp.newlen);
18921da177e4SLinus Torvalds 	unlock_kernel();
18937058cb02SEric W. Biederman out:
18941da177e4SLinus Torvalds 	return error;
18951da177e4SLinus Torvalds }
1896b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */
18971da177e4SLinus Torvalds 
18981da177e4SLinus Torvalds /*
18991ff007ebSEric W. Biederman  * sysctl_perm does NOT grant the superuser all rights automatically, because
19001da177e4SLinus Torvalds  * some sysctl variables are readonly even to root.
19011da177e4SLinus Torvalds  */
19021da177e4SLinus Torvalds 
19031da177e4SLinus Torvalds static int test_perm(int mode, int op)
19041da177e4SLinus Torvalds {
190576aac0e9SDavid Howells 	if (!current_euid())
19061da177e4SLinus Torvalds 		mode >>= 6;
19071da177e4SLinus Torvalds 	else if (in_egroup_p(0))
19081da177e4SLinus Torvalds 		mode >>= 3;
1909e6305c43SAl Viro 	if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
19101da177e4SLinus Torvalds 		return 0;
19111da177e4SLinus Torvalds 	return -EACCES;
19121da177e4SLinus Torvalds }
19131da177e4SLinus Torvalds 
1914d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
19151da177e4SLinus Torvalds {
19161da177e4SLinus Torvalds 	int error;
1917d7321cd6SPavel Emelyanov 	int mode;
1918d7321cd6SPavel Emelyanov 
1919e6305c43SAl Viro 	error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
19201da177e4SLinus Torvalds 	if (error)
19211da177e4SLinus Torvalds 		return error;
1922d7321cd6SPavel Emelyanov 
1923d7321cd6SPavel Emelyanov 	if (root->permissions)
1924d7321cd6SPavel Emelyanov 		mode = root->permissions(root, current->nsproxy, table);
1925d7321cd6SPavel Emelyanov 	else
1926d7321cd6SPavel Emelyanov 		mode = table->mode;
1927d7321cd6SPavel Emelyanov 
1928d7321cd6SPavel Emelyanov 	return test_perm(mode, op);
19291da177e4SLinus Torvalds }
19301da177e4SLinus Torvalds 
1931d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1932d912b0ccSEric W. Biederman {
1933d912b0ccSEric W. Biederman 	for (; table->ctl_name || table->procname; table++) {
1934d912b0ccSEric W. Biederman 		table->parent = parent;
1935d912b0ccSEric W. Biederman 		if (table->child)
1936d912b0ccSEric W. Biederman 			sysctl_set_parent(table, table->child);
1937d912b0ccSEric W. Biederman 	}
1938d912b0ccSEric W. Biederman }
1939d912b0ccSEric W. Biederman 
1940d912b0ccSEric W. Biederman static __init int sysctl_init(void)
1941d912b0ccSEric W. Biederman {
1942d912b0ccSEric W. Biederman 	sysctl_set_parent(NULL, root_table);
194388f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
194488f458e4SHolger Schurig 	{
194588f458e4SHolger Schurig 		int err;
1946e51b6ba0SEric W. Biederman 		err = sysctl_check_table(current->nsproxy, root_table);
194788f458e4SHolger Schurig 	}
194888f458e4SHolger Schurig #endif
1949d912b0ccSEric W. Biederman 	return 0;
1950d912b0ccSEric W. Biederman }
1951d912b0ccSEric W. Biederman 
1952d912b0ccSEric W. Biederman core_initcall(sysctl_init);
1953d912b0ccSEric W. Biederman 
1954bfbcf034SAl Viro static struct ctl_table *is_branch_in(struct ctl_table *branch,
1955bfbcf034SAl Viro 				      struct ctl_table *table)
1956ae7edeccSAl Viro {
1957ae7edeccSAl Viro 	struct ctl_table *p;
1958ae7edeccSAl Viro 	const char *s = branch->procname;
1959ae7edeccSAl Viro 
1960ae7edeccSAl Viro 	/* branch should have named subdirectory as its first element */
1961ae7edeccSAl Viro 	if (!s || !branch->child)
1962bfbcf034SAl Viro 		return NULL;
1963ae7edeccSAl Viro 
1964ae7edeccSAl Viro 	/* ... and nothing else */
1965ae7edeccSAl Viro 	if (branch[1].procname || branch[1].ctl_name)
1966bfbcf034SAl Viro 		return NULL;
1967ae7edeccSAl Viro 
1968ae7edeccSAl Viro 	/* table should contain subdirectory with the same name */
1969ae7edeccSAl Viro 	for (p = table; p->procname || p->ctl_name; p++) {
1970ae7edeccSAl Viro 		if (!p->child)
1971ae7edeccSAl Viro 			continue;
1972ae7edeccSAl Viro 		if (p->procname && strcmp(p->procname, s) == 0)
1973bfbcf034SAl Viro 			return p;
1974ae7edeccSAl Viro 	}
1975bfbcf034SAl Viro 	return NULL;
1976ae7edeccSAl Viro }
1977ae7edeccSAl Viro 
1978ae7edeccSAl Viro /* see if attaching q to p would be an improvement */
1979ae7edeccSAl Viro static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1980ae7edeccSAl Viro {
1981ae7edeccSAl Viro 	struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
1982bfbcf034SAl Viro 	struct ctl_table *next;
1983ae7edeccSAl Viro 	int is_better = 0;
1984ae7edeccSAl Viro 	int not_in_parent = !p->attached_by;
1985ae7edeccSAl Viro 
1986bfbcf034SAl Viro 	while ((next = is_branch_in(by, to)) != NULL) {
1987ae7edeccSAl Viro 		if (by == q->attached_by)
1988ae7edeccSAl Viro 			is_better = 1;
1989ae7edeccSAl Viro 		if (to == p->attached_by)
1990ae7edeccSAl Viro 			not_in_parent = 1;
1991ae7edeccSAl Viro 		by = by->child;
1992bfbcf034SAl Viro 		to = next->child;
1993ae7edeccSAl Viro 	}
1994ae7edeccSAl Viro 
1995ae7edeccSAl Viro 	if (is_better && not_in_parent) {
1996ae7edeccSAl Viro 		q->attached_by = by;
1997ae7edeccSAl Viro 		q->attached_to = to;
1998ae7edeccSAl Viro 		q->parent = p;
1999ae7edeccSAl Viro 	}
2000ae7edeccSAl Viro }
2001ae7edeccSAl Viro 
20021da177e4SLinus Torvalds /**
2003e51b6ba0SEric W. Biederman  * __register_sysctl_paths - register a sysctl hierarchy
2004e51b6ba0SEric W. Biederman  * @root: List of sysctl headers to register on
2005e51b6ba0SEric W. Biederman  * @namespaces: Data to compute which lists of sysctl entries are visible
200629e796fdSEric W. Biederman  * @path: The path to the directory the sysctl table is in.
20071da177e4SLinus Torvalds  * @table: the top-level table structure
20081da177e4SLinus Torvalds  *
20091da177e4SLinus Torvalds  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
201029e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
20111da177e4SLinus Torvalds  *
2012d8217f07SEric W. Biederman  * The members of the &struct ctl_table structure are used as follows:
20131da177e4SLinus Torvalds  *
20141da177e4SLinus Torvalds  * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
20151da177e4SLinus Torvalds  *            must be unique within that level of sysctl
20161da177e4SLinus Torvalds  *
20171da177e4SLinus Torvalds  * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
20181da177e4SLinus Torvalds  *            enter a sysctl file
20191da177e4SLinus Torvalds  *
20201da177e4SLinus Torvalds  * data - a pointer to data for use by proc_handler
20211da177e4SLinus Torvalds  *
20221da177e4SLinus Torvalds  * maxlen - the maximum size in bytes of the data
20231da177e4SLinus Torvalds  *
20241da177e4SLinus Torvalds  * mode - the file permissions for the /proc/sys file, and for sysctl(2)
20251da177e4SLinus Torvalds  *
20261da177e4SLinus Torvalds  * child - a pointer to the child sysctl table if this entry is a directory, or
20271da177e4SLinus Torvalds  *         %NULL.
20281da177e4SLinus Torvalds  *
20291da177e4SLinus Torvalds  * proc_handler - the text handler routine (described below)
20301da177e4SLinus Torvalds  *
20311da177e4SLinus Torvalds  * strategy - the strategy routine (described below)
20321da177e4SLinus Torvalds  *
20331da177e4SLinus Torvalds  * de - for internal use by the sysctl routines
20341da177e4SLinus Torvalds  *
20351da177e4SLinus Torvalds  * extra1, extra2 - extra pointers usable by the proc handler routines
20361da177e4SLinus Torvalds  *
20371da177e4SLinus Torvalds  * Leaf nodes in the sysctl tree will be represented by a single file
20381da177e4SLinus Torvalds  * under /proc; non-leaf nodes will be represented by directories.
20391da177e4SLinus Torvalds  *
20401da177e4SLinus Torvalds  * sysctl(2) can automatically manage read and write requests through
20411da177e4SLinus Torvalds  * the sysctl table.  The data and maxlen fields of the ctl_table
20421da177e4SLinus Torvalds  * struct enable minimal validation of the values being written to be
20431da177e4SLinus Torvalds  * performed, and the mode field allows minimal authentication.
20441da177e4SLinus Torvalds  *
20451da177e4SLinus Torvalds  * More sophisticated management can be enabled by the provision of a
20461da177e4SLinus Torvalds  * strategy routine with the table entry.  This will be called before
20471da177e4SLinus Torvalds  * any automatic read or write of the data is performed.
20481da177e4SLinus Torvalds  *
20491da177e4SLinus Torvalds  * The strategy routine may return
20501da177e4SLinus Torvalds  *
20511da177e4SLinus Torvalds  * < 0 - Error occurred (error is passed to user process)
20521da177e4SLinus Torvalds  *
20531da177e4SLinus Torvalds  * 0   - OK - proceed with automatic read or write.
20541da177e4SLinus Torvalds  *
20551da177e4SLinus Torvalds  * > 0 - OK - read or write has been done by the strategy routine, so
20561da177e4SLinus Torvalds  *       return immediately.
20571da177e4SLinus Torvalds  *
20581da177e4SLinus Torvalds  * There must be a proc_handler routine for any terminal nodes
20591da177e4SLinus Torvalds  * mirrored under /proc/sys (non-terminals are handled by a built-in
20601da177e4SLinus Torvalds  * directory handler).  Several default handlers are available to
20611da177e4SLinus Torvalds  * cover common cases -
20621da177e4SLinus Torvalds  *
20631da177e4SLinus Torvalds  * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
20641da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
20651da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
20661da177e4SLinus Torvalds  *
20671da177e4SLinus Torvalds  * It is the handler's job to read the input buffer from user memory
20681da177e4SLinus Torvalds  * and process it. The handler should return 0 on success.
20691da177e4SLinus Torvalds  *
20701da177e4SLinus Torvalds  * This routine returns %NULL on a failure to register, and a pointer
20711da177e4SLinus Torvalds  * to the table header on success.
20721da177e4SLinus Torvalds  */
2073e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths(
2074e51b6ba0SEric W. Biederman 	struct ctl_table_root *root,
2075e51b6ba0SEric W. Biederman 	struct nsproxy *namespaces,
2076e51b6ba0SEric W. Biederman 	const struct ctl_path *path, struct ctl_table *table)
20771da177e4SLinus Torvalds {
207829e796fdSEric W. Biederman 	struct ctl_table_header *header;
207929e796fdSEric W. Biederman 	struct ctl_table *new, **prevp;
208029e796fdSEric W. Biederman 	unsigned int n, npath;
2081ae7edeccSAl Viro 	struct ctl_table_set *set;
208229e796fdSEric W. Biederman 
208329e796fdSEric W. Biederman 	/* Count the path components */
208429e796fdSEric W. Biederman 	for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
208529e796fdSEric W. Biederman 		;
208629e796fdSEric W. Biederman 
208729e796fdSEric W. Biederman 	/*
208829e796fdSEric W. Biederman 	 * For each path component, allocate a 2-element ctl_table array.
208929e796fdSEric W. Biederman 	 * The first array element will be filled with the sysctl entry
209029e796fdSEric W. Biederman 	 * for this, the second will be the sentinel (ctl_name == 0).
209129e796fdSEric W. Biederman 	 *
209229e796fdSEric W. Biederman 	 * We allocate everything in one go so that we don't have to
209329e796fdSEric W. Biederman 	 * worry about freeing additional memory in unregister_sysctl_table.
209429e796fdSEric W. Biederman 	 */
209529e796fdSEric W. Biederman 	header = kzalloc(sizeof(struct ctl_table_header) +
209629e796fdSEric W. Biederman 			 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
209729e796fdSEric W. Biederman 	if (!header)
20981da177e4SLinus Torvalds 		return NULL;
209929e796fdSEric W. Biederman 
210029e796fdSEric W. Biederman 	new = (struct ctl_table *) (header + 1);
210129e796fdSEric W. Biederman 
210229e796fdSEric W. Biederman 	/* Now connect the dots */
210329e796fdSEric W. Biederman 	prevp = &header->ctl_table;
210429e796fdSEric W. Biederman 	for (n = 0; n < npath; ++n, ++path) {
210529e796fdSEric W. Biederman 		/* Copy the procname */
210629e796fdSEric W. Biederman 		new->procname = path->procname;
210729e796fdSEric W. Biederman 		new->ctl_name = path->ctl_name;
210829e796fdSEric W. Biederman 		new->mode     = 0555;
210929e796fdSEric W. Biederman 
211029e796fdSEric W. Biederman 		*prevp = new;
211129e796fdSEric W. Biederman 		prevp = &new->child;
211229e796fdSEric W. Biederman 
211329e796fdSEric W. Biederman 		new += 2;
211429e796fdSEric W. Biederman 	}
211529e796fdSEric W. Biederman 	*prevp = table;
211623eb06deSEric W. Biederman 	header->ctl_table_arg = table;
211729e796fdSEric W. Biederman 
211829e796fdSEric W. Biederman 	INIT_LIST_HEAD(&header->ctl_entry);
211929e796fdSEric W. Biederman 	header->used = 0;
212029e796fdSEric W. Biederman 	header->unregistering = NULL;
2121e51b6ba0SEric W. Biederman 	header->root = root;
212229e796fdSEric W. Biederman 	sysctl_set_parent(NULL, header->ctl_table);
2123f7e6ced4SAl Viro 	header->count = 1;
212488f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
2125e51b6ba0SEric W. Biederman 	if (sysctl_check_table(namespaces, header->ctl_table)) {
212629e796fdSEric W. Biederman 		kfree(header);
2127fc6cd25bSEric W. Biederman 		return NULL;
2128fc6cd25bSEric W. Biederman 	}
212988f458e4SHolger Schurig #endif
2130330d57fbSAl Viro 	spin_lock(&sysctl_lock);
213173455092SAl Viro 	header->set = lookup_header_set(root, namespaces);
2132ae7edeccSAl Viro 	header->attached_by = header->ctl_table;
2133ae7edeccSAl Viro 	header->attached_to = root_table;
2134ae7edeccSAl Viro 	header->parent = &root_table_header;
2135ae7edeccSAl Viro 	for (set = header->set; set; set = set->parent) {
2136ae7edeccSAl Viro 		struct ctl_table_header *p;
2137ae7edeccSAl Viro 		list_for_each_entry(p, &set->list, ctl_entry) {
2138ae7edeccSAl Viro 			if (p->unregistering)
2139ae7edeccSAl Viro 				continue;
2140ae7edeccSAl Viro 			try_attach(p, header);
2141ae7edeccSAl Viro 		}
2142ae7edeccSAl Viro 	}
2143ae7edeccSAl Viro 	header->parent->count++;
214473455092SAl Viro 	list_add_tail(&header->ctl_entry, &header->set->list);
2145330d57fbSAl Viro 	spin_unlock(&sysctl_lock);
214629e796fdSEric W. Biederman 
214729e796fdSEric W. Biederman 	return header;
214829e796fdSEric W. Biederman }
214929e796fdSEric W. Biederman 
215029e796fdSEric W. Biederman /**
2151e51b6ba0SEric W. Biederman  * register_sysctl_table_path - register a sysctl table hierarchy
2152e51b6ba0SEric W. Biederman  * @path: The path to the directory the sysctl table is in.
2153e51b6ba0SEric W. Biederman  * @table: the top-level table structure
2154e51b6ba0SEric W. Biederman  *
2155e51b6ba0SEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2156e51b6ba0SEric W. Biederman  * array. A completely 0 filled entry terminates the table.
2157e51b6ba0SEric W. Biederman  *
2158e51b6ba0SEric W. Biederman  * See __register_sysctl_paths for more details.
2159e51b6ba0SEric W. Biederman  */
2160e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2161e51b6ba0SEric W. Biederman 						struct ctl_table *table)
2162e51b6ba0SEric W. Biederman {
2163e51b6ba0SEric W. Biederman 	return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
2164e51b6ba0SEric W. Biederman 					path, table);
2165e51b6ba0SEric W. Biederman }
2166e51b6ba0SEric W. Biederman 
2167e51b6ba0SEric W. Biederman /**
216829e796fdSEric W. Biederman  * register_sysctl_table - register a sysctl table hierarchy
216929e796fdSEric W. Biederman  * @table: the top-level table structure
217029e796fdSEric W. Biederman  *
217129e796fdSEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
217229e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
217329e796fdSEric W. Biederman  *
217429e796fdSEric W. Biederman  * See register_sysctl_paths for more details.
217529e796fdSEric W. Biederman  */
217629e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
217729e796fdSEric W. Biederman {
217829e796fdSEric W. Biederman 	static const struct ctl_path null_path[] = { {} };
217929e796fdSEric W. Biederman 
218029e796fdSEric W. Biederman 	return register_sysctl_paths(null_path, table);
21811da177e4SLinus Torvalds }
21821da177e4SLinus Torvalds 
21831da177e4SLinus Torvalds /**
21841da177e4SLinus Torvalds  * unregister_sysctl_table - unregister a sysctl table hierarchy
21851da177e4SLinus Torvalds  * @header: the header returned from register_sysctl_table
21861da177e4SLinus Torvalds  *
21871da177e4SLinus Torvalds  * Unregisters the sysctl table and all children. proc entries may not
21881da177e4SLinus Torvalds  * actually be removed until they are no longer used by anyone.
21891da177e4SLinus Torvalds  */
21901da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header)
21911da177e4SLinus Torvalds {
2192330d57fbSAl Viro 	might_sleep();
2193f1dad166SPavel Emelyanov 
2194f1dad166SPavel Emelyanov 	if (header == NULL)
2195f1dad166SPavel Emelyanov 		return;
2196f1dad166SPavel Emelyanov 
2197330d57fbSAl Viro 	spin_lock(&sysctl_lock);
2198330d57fbSAl Viro 	start_unregistering(header);
2199ae7edeccSAl Viro 	if (!--header->parent->count) {
2200ae7edeccSAl Viro 		WARN_ON(1);
2201ae7edeccSAl Viro 		kfree(header->parent);
2202ae7edeccSAl Viro 	}
2203f7e6ced4SAl Viro 	if (!--header->count)
22041da177e4SLinus Torvalds 		kfree(header);
2205f7e6ced4SAl Viro 	spin_unlock(&sysctl_lock);
22061da177e4SLinus Torvalds }
22071da177e4SLinus Torvalds 
22089043476fSAl Viro int sysctl_is_seen(struct ctl_table_header *p)
22099043476fSAl Viro {
22109043476fSAl Viro 	struct ctl_table_set *set = p->set;
22119043476fSAl Viro 	int res;
22129043476fSAl Viro 	spin_lock(&sysctl_lock);
22139043476fSAl Viro 	if (p->unregistering)
22149043476fSAl Viro 		res = 0;
22159043476fSAl Viro 	else if (!set->is_seen)
22169043476fSAl Viro 		res = 1;
22179043476fSAl Viro 	else
22189043476fSAl Viro 		res = set->is_seen(set);
22199043476fSAl Viro 	spin_unlock(&sysctl_lock);
22209043476fSAl Viro 	return res;
22219043476fSAl Viro }
22229043476fSAl Viro 
222373455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
222473455092SAl Viro 	struct ctl_table_set *parent,
222573455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
222673455092SAl Viro {
222773455092SAl Viro 	INIT_LIST_HEAD(&p->list);
222873455092SAl Viro 	p->parent = parent ? parent : &sysctl_table_root.default_set;
222973455092SAl Viro 	p->is_seen = is_seen;
223073455092SAl Viro }
223173455092SAl Viro 
2232b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */
2233d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
2234b89a8171SEric W. Biederman {
2235b89a8171SEric W. Biederman 	return NULL;
2236b89a8171SEric W. Biederman }
2237b89a8171SEric W. Biederman 
223829e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
223929e796fdSEric W. Biederman 						    struct ctl_table *table)
224029e796fdSEric W. Biederman {
224129e796fdSEric W. Biederman 	return NULL;
224229e796fdSEric W. Biederman }
224329e796fdSEric W. Biederman 
2244b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table)
2245b89a8171SEric W. Biederman {
2246b89a8171SEric W. Biederman }
2247b89a8171SEric W. Biederman 
224873455092SAl Viro void setup_sysctl_set(struct ctl_table_set *p,
224973455092SAl Viro 	struct ctl_table_set *parent,
225073455092SAl Viro 	int (*is_seen)(struct ctl_table_set *))
225173455092SAl Viro {
225273455092SAl Viro }
225373455092SAl Viro 
2254f7e6ced4SAl Viro void sysctl_head_put(struct ctl_table_header *head)
2255f7e6ced4SAl Viro {
2256f7e6ced4SAl Viro }
2257f7e6ced4SAl Viro 
2258b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
2259b89a8171SEric W. Biederman 
22601da177e4SLinus Torvalds /*
22611da177e4SLinus Torvalds  * /proc/sys support
22621da177e4SLinus Torvalds  */
22631da177e4SLinus Torvalds 
2264b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL
22651da177e4SLinus Torvalds 
2266b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write,
22678d65af78SAlexey Dobriyan 			   void __user *buffer,
2268b1ba4dddSAdrian Bunk 			   size_t *lenp, loff_t *ppos)
2269f5dd3d6fSSam Vilain {
2270f5dd3d6fSSam Vilain 	size_t len;
2271f5dd3d6fSSam Vilain 	char __user *p;
2272f5dd3d6fSSam Vilain 	char c;
2273f5dd3d6fSSam Vilain 
22748d060877SOleg Nesterov 	if (!data || !maxlen || !*lenp) {
2275f5dd3d6fSSam Vilain 		*lenp = 0;
2276f5dd3d6fSSam Vilain 		return 0;
2277f5dd3d6fSSam Vilain 	}
2278f5dd3d6fSSam Vilain 
2279f5dd3d6fSSam Vilain 	if (write) {
2280f5dd3d6fSSam Vilain 		len = 0;
2281f5dd3d6fSSam Vilain 		p = buffer;
2282f5dd3d6fSSam Vilain 		while (len < *lenp) {
2283f5dd3d6fSSam Vilain 			if (get_user(c, p++))
2284f5dd3d6fSSam Vilain 				return -EFAULT;
2285f5dd3d6fSSam Vilain 			if (c == 0 || c == '\n')
2286f5dd3d6fSSam Vilain 				break;
2287f5dd3d6fSSam Vilain 			len++;
2288f5dd3d6fSSam Vilain 		}
2289f5dd3d6fSSam Vilain 		if (len >= maxlen)
2290f5dd3d6fSSam Vilain 			len = maxlen-1;
2291f5dd3d6fSSam Vilain 		if(copy_from_user(data, buffer, len))
2292f5dd3d6fSSam Vilain 			return -EFAULT;
2293f5dd3d6fSSam Vilain 		((char *) data)[len] = 0;
2294f5dd3d6fSSam Vilain 		*ppos += *lenp;
2295f5dd3d6fSSam Vilain 	} else {
2296f5dd3d6fSSam Vilain 		len = strlen(data);
2297f5dd3d6fSSam Vilain 		if (len > maxlen)
2298f5dd3d6fSSam Vilain 			len = maxlen;
22998d060877SOleg Nesterov 
23008d060877SOleg Nesterov 		if (*ppos > len) {
23018d060877SOleg Nesterov 			*lenp = 0;
23028d060877SOleg Nesterov 			return 0;
23038d060877SOleg Nesterov 		}
23048d060877SOleg Nesterov 
23058d060877SOleg Nesterov 		data += *ppos;
23068d060877SOleg Nesterov 		len  -= *ppos;
23078d060877SOleg Nesterov 
2308f5dd3d6fSSam Vilain 		if (len > *lenp)
2309f5dd3d6fSSam Vilain 			len = *lenp;
2310f5dd3d6fSSam Vilain 		if (len)
2311f5dd3d6fSSam Vilain 			if(copy_to_user(buffer, data, len))
2312f5dd3d6fSSam Vilain 				return -EFAULT;
2313f5dd3d6fSSam Vilain 		if (len < *lenp) {
2314f5dd3d6fSSam Vilain 			if(put_user('\n', ((char __user *) buffer) + len))
2315f5dd3d6fSSam Vilain 				return -EFAULT;
2316f5dd3d6fSSam Vilain 			len++;
2317f5dd3d6fSSam Vilain 		}
2318f5dd3d6fSSam Vilain 		*lenp = len;
2319f5dd3d6fSSam Vilain 		*ppos += len;
2320f5dd3d6fSSam Vilain 	}
2321f5dd3d6fSSam Vilain 	return 0;
2322f5dd3d6fSSam Vilain }
2323f5dd3d6fSSam Vilain 
23241da177e4SLinus Torvalds /**
23251da177e4SLinus Torvalds  * proc_dostring - read a string sysctl
23261da177e4SLinus Torvalds  * @table: the sysctl table
23271da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
23281da177e4SLinus Torvalds  * @buffer: the user buffer
23291da177e4SLinus Torvalds  * @lenp: the size of the user buffer
23301da177e4SLinus Torvalds  * @ppos: file position
23311da177e4SLinus Torvalds  *
23321da177e4SLinus Torvalds  * Reads/writes a string from/to the user buffer. If the kernel
23331da177e4SLinus Torvalds  * buffer provided is not large enough to hold the string, the
23341da177e4SLinus Torvalds  * string is truncated. The copied string is %NULL-terminated.
23351da177e4SLinus Torvalds  * If the string is being read by the user process, it is copied
23361da177e4SLinus Torvalds  * and a newline '\n' is added. It is truncated if the buffer is
23371da177e4SLinus Torvalds  * not large enough.
23381da177e4SLinus Torvalds  *
23391da177e4SLinus Torvalds  * Returns 0 on success.
23401da177e4SLinus Torvalds  */
23418d65af78SAlexey Dobriyan int proc_dostring(struct ctl_table *table, int write,
23421da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
23431da177e4SLinus Torvalds {
23448d65af78SAlexey Dobriyan 	return _proc_do_string(table->data, table->maxlen, write,
2345f5dd3d6fSSam Vilain 			       buffer, lenp, ppos);
23461da177e4SLinus Torvalds }
23471da177e4SLinus Torvalds 
23481da177e4SLinus Torvalds 
23491da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
23501da177e4SLinus Torvalds 				 int *valp,
23511da177e4SLinus Torvalds 				 int write, void *data)
23521da177e4SLinus Torvalds {
23531da177e4SLinus Torvalds 	if (write) {
23541da177e4SLinus Torvalds 		*valp = *negp ? -*lvalp : *lvalp;
23551da177e4SLinus Torvalds 	} else {
23561da177e4SLinus Torvalds 		int val = *valp;
23571da177e4SLinus Torvalds 		if (val < 0) {
23581da177e4SLinus Torvalds 			*negp = -1;
23591da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
23601da177e4SLinus Torvalds 		} else {
23611da177e4SLinus Torvalds 			*negp = 0;
23621da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
23631da177e4SLinus Torvalds 		}
23641da177e4SLinus Torvalds 	}
23651da177e4SLinus Torvalds 	return 0;
23661da177e4SLinus Torvalds }
23671da177e4SLinus Torvalds 
2368d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
23698d65af78SAlexey Dobriyan 		  int write, void __user *buffer,
2370fcfbd547SKirill Korotaev 		  size_t *lenp, loff_t *ppos,
23711da177e4SLinus Torvalds 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
23721da177e4SLinus Torvalds 			      int write, void *data),
23731da177e4SLinus Torvalds 		  void *data)
23741da177e4SLinus Torvalds {
23751da177e4SLinus Torvalds #define TMPBUFLEN 21
23767338f299SSukanto Ghosh 	int *i, vleft, first = 1, neg;
23771da177e4SLinus Torvalds 	unsigned long lval;
23781da177e4SLinus Torvalds 	size_t left, len;
23791da177e4SLinus Torvalds 
23801da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
23811da177e4SLinus Torvalds 	char __user *s = buffer;
23821da177e4SLinus Torvalds 
2383fcfbd547SKirill Korotaev 	if (!tbl_data || !table->maxlen || !*lenp ||
23841da177e4SLinus Torvalds 	    (*ppos && !write)) {
23851da177e4SLinus Torvalds 		*lenp = 0;
23861da177e4SLinus Torvalds 		return 0;
23871da177e4SLinus Torvalds 	}
23881da177e4SLinus Torvalds 
2389fcfbd547SKirill Korotaev 	i = (int *) tbl_data;
23901da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(*i);
23911da177e4SLinus Torvalds 	left = *lenp;
23921da177e4SLinus Torvalds 
23931da177e4SLinus Torvalds 	if (!conv)
23941da177e4SLinus Torvalds 		conv = do_proc_dointvec_conv;
23951da177e4SLinus Torvalds 
23961da177e4SLinus Torvalds 	for (; left && vleft--; i++, first=0) {
23971da177e4SLinus Torvalds 		if (write) {
23981da177e4SLinus Torvalds 			while (left) {
23991da177e4SLinus Torvalds 				char c;
24001da177e4SLinus Torvalds 				if (get_user(c, s))
24011da177e4SLinus Torvalds 					return -EFAULT;
24021da177e4SLinus Torvalds 				if (!isspace(c))
24031da177e4SLinus Torvalds 					break;
24041da177e4SLinus Torvalds 				left--;
24051da177e4SLinus Torvalds 				s++;
24061da177e4SLinus Torvalds 			}
24071da177e4SLinus Torvalds 			if (!left)
24081da177e4SLinus Torvalds 				break;
24091da177e4SLinus Torvalds 			neg = 0;
24101da177e4SLinus Torvalds 			len = left;
24111da177e4SLinus Torvalds 			if (len > sizeof(buf) - 1)
24121da177e4SLinus Torvalds 				len = sizeof(buf) - 1;
24131da177e4SLinus Torvalds 			if (copy_from_user(buf, s, len))
24141da177e4SLinus Torvalds 				return -EFAULT;
24151da177e4SLinus Torvalds 			buf[len] = 0;
24161da177e4SLinus Torvalds 			p = buf;
24171da177e4SLinus Torvalds 			if (*p == '-' && left > 1) {
24181da177e4SLinus Torvalds 				neg = 1;
2419bd9b0bacSBP, Praveen 				p++;
24201da177e4SLinus Torvalds 			}
24211da177e4SLinus Torvalds 			if (*p < '0' || *p > '9')
24221da177e4SLinus Torvalds 				break;
24231da177e4SLinus Torvalds 
24241da177e4SLinus Torvalds 			lval = simple_strtoul(p, &p, 0);
24251da177e4SLinus Torvalds 
24261da177e4SLinus Torvalds 			len = p-buf;
24271da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
24281da177e4SLinus Torvalds 				break;
24291da177e4SLinus Torvalds 			s += len;
24301da177e4SLinus Torvalds 			left -= len;
24311da177e4SLinus Torvalds 
24321da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 1, data))
24331da177e4SLinus Torvalds 				break;
24341da177e4SLinus Torvalds 		} else {
24351da177e4SLinus Torvalds 			p = buf;
24361da177e4SLinus Torvalds 			if (!first)
24371da177e4SLinus Torvalds 				*p++ = '\t';
24381da177e4SLinus Torvalds 
24391da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 0, data))
24401da177e4SLinus Torvalds 				break;
24411da177e4SLinus Torvalds 
24421da177e4SLinus Torvalds 			sprintf(p, "%s%lu", neg ? "-" : "", lval);
24431da177e4SLinus Torvalds 			len = strlen(buf);
24441da177e4SLinus Torvalds 			if (len > left)
24451da177e4SLinus Torvalds 				len = left;
24461da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
24471da177e4SLinus Torvalds 				return -EFAULT;
24481da177e4SLinus Torvalds 			left -= len;
24491da177e4SLinus Torvalds 			s += len;
24501da177e4SLinus Torvalds 		}
24511da177e4SLinus Torvalds 	}
24521da177e4SLinus Torvalds 
24531da177e4SLinus Torvalds 	if (!write && !first && left) {
24541da177e4SLinus Torvalds 		if(put_user('\n', s))
24551da177e4SLinus Torvalds 			return -EFAULT;
24561da177e4SLinus Torvalds 		left--, s++;
24571da177e4SLinus Torvalds 	}
24581da177e4SLinus Torvalds 	if (write) {
24591da177e4SLinus Torvalds 		while (left) {
24601da177e4SLinus Torvalds 			char c;
24611da177e4SLinus Torvalds 			if (get_user(c, s++))
24621da177e4SLinus Torvalds 				return -EFAULT;
24631da177e4SLinus Torvalds 			if (!isspace(c))
24641da177e4SLinus Torvalds 				break;
24651da177e4SLinus Torvalds 			left--;
24661da177e4SLinus Torvalds 		}
24671da177e4SLinus Torvalds 	}
24681da177e4SLinus Torvalds 	if (write && first)
24691da177e4SLinus Torvalds 		return -EINVAL;
24701da177e4SLinus Torvalds 	*lenp -= left;
24711da177e4SLinus Torvalds 	*ppos += *lenp;
24721da177e4SLinus Torvalds 	return 0;
24731da177e4SLinus Torvalds #undef TMPBUFLEN
24741da177e4SLinus Torvalds }
24751da177e4SLinus Torvalds 
24768d65af78SAlexey Dobriyan static int do_proc_dointvec(struct ctl_table *table, int write,
2477fcfbd547SKirill Korotaev 		  void __user *buffer, size_t *lenp, loff_t *ppos,
2478fcfbd547SKirill Korotaev 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2479fcfbd547SKirill Korotaev 			      int write, void *data),
2480fcfbd547SKirill Korotaev 		  void *data)
2481fcfbd547SKirill Korotaev {
24828d65af78SAlexey Dobriyan 	return __do_proc_dointvec(table->data, table, write,
2483fcfbd547SKirill Korotaev 			buffer, lenp, ppos, conv, data);
2484fcfbd547SKirill Korotaev }
2485fcfbd547SKirill Korotaev 
24861da177e4SLinus Torvalds /**
24871da177e4SLinus Torvalds  * proc_dointvec - read a vector of integers
24881da177e4SLinus Torvalds  * @table: the sysctl table
24891da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24901da177e4SLinus Torvalds  * @buffer: the user buffer
24911da177e4SLinus Torvalds  * @lenp: the size of the user buffer
24921da177e4SLinus Torvalds  * @ppos: file position
24931da177e4SLinus Torvalds  *
24941da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
24951da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
24961da177e4SLinus Torvalds  *
24971da177e4SLinus Torvalds  * Returns 0 on success.
24981da177e4SLinus Torvalds  */
24998d65af78SAlexey Dobriyan int proc_dointvec(struct ctl_table *table, int write,
25001da177e4SLinus Torvalds 		     void __user *buffer, size_t *lenp, loff_t *ppos)
25011da177e4SLinus Torvalds {
25028d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
25031da177e4SLinus Torvalds 		    	    NULL,NULL);
25041da177e4SLinus Torvalds }
25051da177e4SLinus Torvalds 
250634f5a398STheodore Ts'o /*
250734f5a398STheodore Ts'o  * Taint values can only be increased
250825ddbb18SAndi Kleen  * This means we can safely use a temporary.
250934f5a398STheodore Ts'o  */
25108d65af78SAlexey Dobriyan static int proc_taint(struct ctl_table *table, int write,
251134f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos)
251234f5a398STheodore Ts'o {
251325ddbb18SAndi Kleen 	struct ctl_table t;
251425ddbb18SAndi Kleen 	unsigned long tmptaint = get_taint();
251525ddbb18SAndi Kleen 	int err;
251634f5a398STheodore Ts'o 
251791fcd412SBastian Blank 	if (write && !capable(CAP_SYS_ADMIN))
251834f5a398STheodore Ts'o 		return -EPERM;
251934f5a398STheodore Ts'o 
252025ddbb18SAndi Kleen 	t = *table;
252125ddbb18SAndi Kleen 	t.data = &tmptaint;
25228d65af78SAlexey Dobriyan 	err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
252325ddbb18SAndi Kleen 	if (err < 0)
252425ddbb18SAndi Kleen 		return err;
252525ddbb18SAndi Kleen 
252625ddbb18SAndi Kleen 	if (write) {
252725ddbb18SAndi Kleen 		/*
252825ddbb18SAndi Kleen 		 * Poor man's atomic or. Not worth adding a primitive
252925ddbb18SAndi Kleen 		 * to everyone's atomic.h for this
253025ddbb18SAndi Kleen 		 */
253125ddbb18SAndi Kleen 		int i;
253225ddbb18SAndi Kleen 		for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
253325ddbb18SAndi Kleen 			if ((tmptaint >> i) & 1)
253425ddbb18SAndi Kleen 				add_taint(i);
253525ddbb18SAndi Kleen 		}
253625ddbb18SAndi Kleen 	}
253725ddbb18SAndi Kleen 
253825ddbb18SAndi Kleen 	return err;
253934f5a398STheodore Ts'o }
254034f5a398STheodore Ts'o 
25411da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param {
25421da177e4SLinus Torvalds 	int *min;
25431da177e4SLinus Torvalds 	int *max;
25441da177e4SLinus Torvalds };
25451da177e4SLinus Torvalds 
25461da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
25471da177e4SLinus Torvalds 					int *valp,
25481da177e4SLinus Torvalds 					int write, void *data)
25491da177e4SLinus Torvalds {
25501da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param *param = data;
25511da177e4SLinus Torvalds 	if (write) {
25521da177e4SLinus Torvalds 		int val = *negp ? -*lvalp : *lvalp;
25531da177e4SLinus Torvalds 		if ((param->min && *param->min > val) ||
25541da177e4SLinus Torvalds 		    (param->max && *param->max < val))
25551da177e4SLinus Torvalds 			return -EINVAL;
25561da177e4SLinus Torvalds 		*valp = val;
25571da177e4SLinus Torvalds 	} else {
25581da177e4SLinus Torvalds 		int val = *valp;
25591da177e4SLinus Torvalds 		if (val < 0) {
25601da177e4SLinus Torvalds 			*negp = -1;
25611da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
25621da177e4SLinus Torvalds 		} else {
25631da177e4SLinus Torvalds 			*negp = 0;
25641da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
25651da177e4SLinus Torvalds 		}
25661da177e4SLinus Torvalds 	}
25671da177e4SLinus Torvalds 	return 0;
25681da177e4SLinus Torvalds }
25691da177e4SLinus Torvalds 
25701da177e4SLinus Torvalds /**
25711da177e4SLinus Torvalds  * proc_dointvec_minmax - read a vector of integers with min/max values
25721da177e4SLinus Torvalds  * @table: the sysctl table
25731da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
25741da177e4SLinus Torvalds  * @buffer: the user buffer
25751da177e4SLinus Torvalds  * @lenp: the size of the user buffer
25761da177e4SLinus Torvalds  * @ppos: file position
25771da177e4SLinus Torvalds  *
25781da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
25791da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
25801da177e4SLinus Torvalds  *
25811da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
25821da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
25831da177e4SLinus Torvalds  *
25841da177e4SLinus Torvalds  * Returns 0 on success.
25851da177e4SLinus Torvalds  */
25868d65af78SAlexey Dobriyan int proc_dointvec_minmax(struct ctl_table *table, int write,
25871da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
25881da177e4SLinus Torvalds {
25891da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param param = {
25901da177e4SLinus Torvalds 		.min = (int *) table->extra1,
25911da177e4SLinus Torvalds 		.max = (int *) table->extra2,
25921da177e4SLinus Torvalds 	};
25938d65af78SAlexey Dobriyan 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
25941da177e4SLinus Torvalds 				do_proc_dointvec_minmax_conv, &param);
25951da177e4SLinus Torvalds }
25961da177e4SLinus Torvalds 
2597d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
25981da177e4SLinus Torvalds 				     void __user *buffer,
25991da177e4SLinus Torvalds 				     size_t *lenp, loff_t *ppos,
26001da177e4SLinus Torvalds 				     unsigned long convmul,
26011da177e4SLinus Torvalds 				     unsigned long convdiv)
26021da177e4SLinus Torvalds {
26031da177e4SLinus Torvalds #define TMPBUFLEN 21
26041da177e4SLinus Torvalds 	unsigned long *i, *min, *max, val;
26051da177e4SLinus Torvalds 	int vleft, first=1, neg;
26061da177e4SLinus Torvalds 	size_t len, left;
26071da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
26081da177e4SLinus Torvalds 	char __user *s = buffer;
26091da177e4SLinus Torvalds 
2610fcfbd547SKirill Korotaev 	if (!data || !table->maxlen || !*lenp ||
26111da177e4SLinus Torvalds 	    (*ppos && !write)) {
26121da177e4SLinus Torvalds 		*lenp = 0;
26131da177e4SLinus Torvalds 		return 0;
26141da177e4SLinus Torvalds 	}
26151da177e4SLinus Torvalds 
2616fcfbd547SKirill Korotaev 	i = (unsigned long *) data;
26171da177e4SLinus Torvalds 	min = (unsigned long *) table->extra1;
26181da177e4SLinus Torvalds 	max = (unsigned long *) table->extra2;
26191da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(unsigned long);
26201da177e4SLinus Torvalds 	left = *lenp;
26211da177e4SLinus Torvalds 
26221da177e4SLinus Torvalds 	for (; left && vleft--; i++, min++, max++, first=0) {
26231da177e4SLinus Torvalds 		if (write) {
26241da177e4SLinus Torvalds 			while (left) {
26251da177e4SLinus Torvalds 				char c;
26261da177e4SLinus Torvalds 				if (get_user(c, s))
26271da177e4SLinus Torvalds 					return -EFAULT;
26281da177e4SLinus Torvalds 				if (!isspace(c))
26291da177e4SLinus Torvalds 					break;
26301da177e4SLinus Torvalds 				left--;
26311da177e4SLinus Torvalds 				s++;
26321da177e4SLinus Torvalds 			}
26331da177e4SLinus Torvalds 			if (!left)
26341da177e4SLinus Torvalds 				break;
26351da177e4SLinus Torvalds 			neg = 0;
26361da177e4SLinus Torvalds 			len = left;
26371da177e4SLinus Torvalds 			if (len > TMPBUFLEN-1)
26381da177e4SLinus Torvalds 				len = TMPBUFLEN-1;
26391da177e4SLinus Torvalds 			if (copy_from_user(buf, s, len))
26401da177e4SLinus Torvalds 				return -EFAULT;
26411da177e4SLinus Torvalds 			buf[len] = 0;
26421da177e4SLinus Torvalds 			p = buf;
26431da177e4SLinus Torvalds 			if (*p == '-' && left > 1) {
26441da177e4SLinus Torvalds 				neg = 1;
2645bd9b0bacSBP, Praveen 				p++;
26461da177e4SLinus Torvalds 			}
26471da177e4SLinus Torvalds 			if (*p < '0' || *p > '9')
26481da177e4SLinus Torvalds 				break;
26491da177e4SLinus Torvalds 			val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
26501da177e4SLinus Torvalds 			len = p-buf;
26511da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
26521da177e4SLinus Torvalds 				break;
26531da177e4SLinus Torvalds 			if (neg)
26541da177e4SLinus Torvalds 				val = -val;
26551da177e4SLinus Torvalds 			s += len;
26561da177e4SLinus Torvalds 			left -= len;
26571da177e4SLinus Torvalds 
26581da177e4SLinus Torvalds 			if(neg)
26591da177e4SLinus Torvalds 				continue;
26601da177e4SLinus Torvalds 			if ((min && val < *min) || (max && val > *max))
26611da177e4SLinus Torvalds 				continue;
26621da177e4SLinus Torvalds 			*i = val;
26631da177e4SLinus Torvalds 		} else {
26641da177e4SLinus Torvalds 			p = buf;
26651da177e4SLinus Torvalds 			if (!first)
26661da177e4SLinus Torvalds 				*p++ = '\t';
26671da177e4SLinus Torvalds 			sprintf(p, "%lu", convdiv * (*i) / convmul);
26681da177e4SLinus Torvalds 			len = strlen(buf);
26691da177e4SLinus Torvalds 			if (len > left)
26701da177e4SLinus Torvalds 				len = left;
26711da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
26721da177e4SLinus Torvalds 				return -EFAULT;
26731da177e4SLinus Torvalds 			left -= len;
26741da177e4SLinus Torvalds 			s += len;
26751da177e4SLinus Torvalds 		}
26761da177e4SLinus Torvalds 	}
26771da177e4SLinus Torvalds 
26781da177e4SLinus Torvalds 	if (!write && !first && left) {
26791da177e4SLinus Torvalds 		if(put_user('\n', s))
26801da177e4SLinus Torvalds 			return -EFAULT;
26811da177e4SLinus Torvalds 		left--, s++;
26821da177e4SLinus Torvalds 	}
26831da177e4SLinus Torvalds 	if (write) {
26841da177e4SLinus Torvalds 		while (left) {
26851da177e4SLinus Torvalds 			char c;
26861da177e4SLinus Torvalds 			if (get_user(c, s++))
26871da177e4SLinus Torvalds 				return -EFAULT;
26881da177e4SLinus Torvalds 			if (!isspace(c))
26891da177e4SLinus Torvalds 				break;
26901da177e4SLinus Torvalds 			left--;
26911da177e4SLinus Torvalds 		}
26921da177e4SLinus Torvalds 	}
26931da177e4SLinus Torvalds 	if (write && first)
26941da177e4SLinus Torvalds 		return -EINVAL;
26951da177e4SLinus Torvalds 	*lenp -= left;
26961da177e4SLinus Torvalds 	*ppos += *lenp;
26971da177e4SLinus Torvalds 	return 0;
26981da177e4SLinus Torvalds #undef TMPBUFLEN
26991da177e4SLinus Torvalds }
27001da177e4SLinus Torvalds 
2701d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2702fcfbd547SKirill Korotaev 				     void __user *buffer,
2703fcfbd547SKirill Korotaev 				     size_t *lenp, loff_t *ppos,
2704fcfbd547SKirill Korotaev 				     unsigned long convmul,
2705fcfbd547SKirill Korotaev 				     unsigned long convdiv)
2706fcfbd547SKirill Korotaev {
2707fcfbd547SKirill Korotaev 	return __do_proc_doulongvec_minmax(table->data, table, write,
27088d65af78SAlexey Dobriyan 			buffer, lenp, ppos, convmul, convdiv);
2709fcfbd547SKirill Korotaev }
2710fcfbd547SKirill Korotaev 
27111da177e4SLinus Torvalds /**
27121da177e4SLinus Torvalds  * proc_doulongvec_minmax - read a vector of long integers with min/max values
27131da177e4SLinus Torvalds  * @table: the sysctl table
27141da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
27151da177e4SLinus Torvalds  * @buffer: the user buffer
27161da177e4SLinus Torvalds  * @lenp: the size of the user buffer
27171da177e4SLinus Torvalds  * @ppos: file position
27181da177e4SLinus Torvalds  *
27191da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
27201da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
27211da177e4SLinus Torvalds  *
27221da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
27231da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
27241da177e4SLinus Torvalds  *
27251da177e4SLinus Torvalds  * Returns 0 on success.
27261da177e4SLinus Torvalds  */
27278d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write,
27281da177e4SLinus Torvalds 			   void __user *buffer, size_t *lenp, loff_t *ppos)
27291da177e4SLinus Torvalds {
27308d65af78SAlexey Dobriyan     return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
27311da177e4SLinus Torvalds }
27321da177e4SLinus Torvalds 
27331da177e4SLinus Torvalds /**
27341da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
27351da177e4SLinus Torvalds  * @table: the sysctl table
27361da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
27371da177e4SLinus Torvalds  * @buffer: the user buffer
27381da177e4SLinus Torvalds  * @lenp: the size of the user buffer
27391da177e4SLinus Torvalds  * @ppos: file position
27401da177e4SLinus Torvalds  *
27411da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
27421da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string. The values
27431da177e4SLinus Torvalds  * are treated as milliseconds, and converted to jiffies when they are stored.
27441da177e4SLinus Torvalds  *
27451da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
27461da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
27471da177e4SLinus Torvalds  *
27481da177e4SLinus Torvalds  * Returns 0 on success.
27491da177e4SLinus Torvalds  */
2750d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
27511da177e4SLinus Torvalds 				      void __user *buffer,
27521da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
27531da177e4SLinus Torvalds {
27548d65af78SAlexey Dobriyan     return do_proc_doulongvec_minmax(table, write, buffer,
27551da177e4SLinus Torvalds 				     lenp, ppos, HZ, 1000l);
27561da177e4SLinus Torvalds }
27571da177e4SLinus Torvalds 
27581da177e4SLinus Torvalds 
27591da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
27601da177e4SLinus Torvalds 					 int *valp,
27611da177e4SLinus Torvalds 					 int write, void *data)
27621da177e4SLinus Torvalds {
27631da177e4SLinus Torvalds 	if (write) {
2764cba9f33dSBart Samwel 		if (*lvalp > LONG_MAX / HZ)
2765cba9f33dSBart Samwel 			return 1;
27661da177e4SLinus Torvalds 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
27671da177e4SLinus Torvalds 	} else {
27681da177e4SLinus Torvalds 		int val = *valp;
27691da177e4SLinus Torvalds 		unsigned long lval;
27701da177e4SLinus Torvalds 		if (val < 0) {
27711da177e4SLinus Torvalds 			*negp = -1;
27721da177e4SLinus Torvalds 			lval = (unsigned long)-val;
27731da177e4SLinus Torvalds 		} else {
27741da177e4SLinus Torvalds 			*negp = 0;
27751da177e4SLinus Torvalds 			lval = (unsigned long)val;
27761da177e4SLinus Torvalds 		}
27771da177e4SLinus Torvalds 		*lvalp = lval / HZ;
27781da177e4SLinus Torvalds 	}
27791da177e4SLinus Torvalds 	return 0;
27801da177e4SLinus Torvalds }
27811da177e4SLinus Torvalds 
27821da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
27831da177e4SLinus Torvalds 						int *valp,
27841da177e4SLinus Torvalds 						int write, void *data)
27851da177e4SLinus Torvalds {
27861da177e4SLinus Torvalds 	if (write) {
2787cba9f33dSBart Samwel 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2788cba9f33dSBart Samwel 			return 1;
27891da177e4SLinus Torvalds 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
27901da177e4SLinus Torvalds 	} else {
27911da177e4SLinus Torvalds 		int val = *valp;
27921da177e4SLinus Torvalds 		unsigned long lval;
27931da177e4SLinus Torvalds 		if (val < 0) {
27941da177e4SLinus Torvalds 			*negp = -1;
27951da177e4SLinus Torvalds 			lval = (unsigned long)-val;
27961da177e4SLinus Torvalds 		} else {
27971da177e4SLinus Torvalds 			*negp = 0;
27981da177e4SLinus Torvalds 			lval = (unsigned long)val;
27991da177e4SLinus Torvalds 		}
28001da177e4SLinus Torvalds 		*lvalp = jiffies_to_clock_t(lval);
28011da177e4SLinus Torvalds 	}
28021da177e4SLinus Torvalds 	return 0;
28031da177e4SLinus Torvalds }
28041da177e4SLinus Torvalds 
28051da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
28061da177e4SLinus Torvalds 					    int *valp,
28071da177e4SLinus Torvalds 					    int write, void *data)
28081da177e4SLinus Torvalds {
28091da177e4SLinus Torvalds 	if (write) {
28101da177e4SLinus Torvalds 		*valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
28111da177e4SLinus Torvalds 	} else {
28121da177e4SLinus Torvalds 		int val = *valp;
28131da177e4SLinus Torvalds 		unsigned long lval;
28141da177e4SLinus Torvalds 		if (val < 0) {
28151da177e4SLinus Torvalds 			*negp = -1;
28161da177e4SLinus Torvalds 			lval = (unsigned long)-val;
28171da177e4SLinus Torvalds 		} else {
28181da177e4SLinus Torvalds 			*negp = 0;
28191da177e4SLinus Torvalds 			lval = (unsigned long)val;
28201da177e4SLinus Torvalds 		}
28211da177e4SLinus Torvalds 		*lvalp = jiffies_to_msecs(lval);
28221da177e4SLinus Torvalds 	}
28231da177e4SLinus Torvalds 	return 0;
28241da177e4SLinus Torvalds }
28251da177e4SLinus Torvalds 
28261da177e4SLinus Torvalds /**
28271da177e4SLinus Torvalds  * proc_dointvec_jiffies - read a vector of integers as seconds
28281da177e4SLinus Torvalds  * @table: the sysctl table
28291da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
28301da177e4SLinus Torvalds  * @buffer: the user buffer
28311da177e4SLinus Torvalds  * @lenp: the size of the user buffer
28321da177e4SLinus Torvalds  * @ppos: file position
28331da177e4SLinus Torvalds  *
28341da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
28351da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
28361da177e4SLinus Torvalds  * The values read are assumed to be in seconds, and are converted into
28371da177e4SLinus Torvalds  * jiffies.
28381da177e4SLinus Torvalds  *
28391da177e4SLinus Torvalds  * Returns 0 on success.
28401da177e4SLinus Torvalds  */
28418d65af78SAlexey Dobriyan int proc_dointvec_jiffies(struct ctl_table *table, int write,
28421da177e4SLinus Torvalds 			  void __user *buffer, size_t *lenp, loff_t *ppos)
28431da177e4SLinus Torvalds {
28448d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
28451da177e4SLinus Torvalds 		    	    do_proc_dointvec_jiffies_conv,NULL);
28461da177e4SLinus Torvalds }
28471da177e4SLinus Torvalds 
28481da177e4SLinus Torvalds /**
28491da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
28501da177e4SLinus Torvalds  * @table: the sysctl table
28511da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
28521da177e4SLinus Torvalds  * @buffer: the user buffer
28531da177e4SLinus Torvalds  * @lenp: the size of the user buffer
28541e5d5331SRandy Dunlap  * @ppos: pointer to the file position
28551da177e4SLinus Torvalds  *
28561da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
28571da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
28581da177e4SLinus Torvalds  * The values read are assumed to be in 1/USER_HZ seconds, and
28591da177e4SLinus Torvalds  * are converted into jiffies.
28601da177e4SLinus Torvalds  *
28611da177e4SLinus Torvalds  * Returns 0 on success.
28621da177e4SLinus Torvalds  */
28638d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
28641da177e4SLinus Torvalds 				 void __user *buffer, size_t *lenp, loff_t *ppos)
28651da177e4SLinus Torvalds {
28668d65af78SAlexey Dobriyan     return do_proc_dointvec(table,write,buffer,lenp,ppos,
28671da177e4SLinus Torvalds 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
28681da177e4SLinus Torvalds }
28691da177e4SLinus Torvalds 
28701da177e4SLinus Torvalds /**
28711da177e4SLinus Torvalds  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
28721da177e4SLinus Torvalds  * @table: the sysctl table
28731da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
28741da177e4SLinus Torvalds  * @buffer: the user buffer
28751da177e4SLinus Torvalds  * @lenp: the size of the user buffer
287667be2dd1SMartin Waitz  * @ppos: file position
287767be2dd1SMartin Waitz  * @ppos: the current position in the file
28781da177e4SLinus Torvalds  *
28791da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
28801da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
28811da177e4SLinus Torvalds  * The values read are assumed to be in 1/1000 seconds, and
28821da177e4SLinus Torvalds  * are converted into jiffies.
28831da177e4SLinus Torvalds  *
28841da177e4SLinus Torvalds  * Returns 0 on success.
28851da177e4SLinus Torvalds  */
28868d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
28871da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
28881da177e4SLinus Torvalds {
28898d65af78SAlexey Dobriyan 	return do_proc_dointvec(table, write, buffer, lenp, ppos,
28901da177e4SLinus Torvalds 				do_proc_dointvec_ms_jiffies_conv, NULL);
28911da177e4SLinus Torvalds }
28921da177e4SLinus Torvalds 
28938d65af78SAlexey Dobriyan static int proc_do_cad_pid(struct ctl_table *table, int write,
28949ec52099SCedric Le Goater 			   void __user *buffer, size_t *lenp, loff_t *ppos)
28959ec52099SCedric Le Goater {
28969ec52099SCedric Le Goater 	struct pid *new_pid;
28979ec52099SCedric Le Goater 	pid_t tmp;
28989ec52099SCedric Le Goater 	int r;
28999ec52099SCedric Le Goater 
29006c5f3e7bSPavel Emelyanov 	tmp = pid_vnr(cad_pid);
29019ec52099SCedric Le Goater 
29028d65af78SAlexey Dobriyan 	r = __do_proc_dointvec(&tmp, table, write, buffer,
29039ec52099SCedric Le Goater 			       lenp, ppos, NULL, NULL);
29049ec52099SCedric Le Goater 	if (r || !write)
29059ec52099SCedric Le Goater 		return r;
29069ec52099SCedric Le Goater 
29079ec52099SCedric Le Goater 	new_pid = find_get_pid(tmp);
29089ec52099SCedric Le Goater 	if (!new_pid)
29099ec52099SCedric Le Goater 		return -ESRCH;
29109ec52099SCedric Le Goater 
29119ec52099SCedric Le Goater 	put_pid(xchg(&cad_pid, new_pid));
29129ec52099SCedric Le Goater 	return 0;
29139ec52099SCedric Le Goater }
29149ec52099SCedric Le Goater 
29151da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */
29161da177e4SLinus Torvalds 
29178d65af78SAlexey Dobriyan int proc_dostring(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(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_minmax(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_dointvec_jiffies(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 
29418d65af78SAlexey Dobriyan int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
29421da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
29431da177e4SLinus Torvalds {
29441da177e4SLinus Torvalds 	return -ENOSYS;
29451da177e4SLinus Torvalds }
29461da177e4SLinus Torvalds 
29478d65af78SAlexey Dobriyan int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
29481da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
29491da177e4SLinus Torvalds {
29501da177e4SLinus Torvalds 	return -ENOSYS;
29511da177e4SLinus Torvalds }
29521da177e4SLinus Torvalds 
29538d65af78SAlexey Dobriyan int proc_doulongvec_minmax(struct ctl_table *table, int write,
29541da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
29551da177e4SLinus Torvalds {
29561da177e4SLinus Torvalds 	return -ENOSYS;
29571da177e4SLinus Torvalds }
29581da177e4SLinus Torvalds 
2959d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
29601da177e4SLinus Torvalds 				      void __user *buffer,
29611da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
29621da177e4SLinus Torvalds {
29631da177e4SLinus Torvalds     return -ENOSYS;
29641da177e4SLinus Torvalds }
29651da177e4SLinus Torvalds 
29661da177e4SLinus Torvalds 
29671da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */
29681da177e4SLinus Torvalds 
29691da177e4SLinus Torvalds 
2970b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL
29711da177e4SLinus Torvalds /*
29721da177e4SLinus Torvalds  * General sysctl support routines
29731da177e4SLinus Torvalds  */
29741da177e4SLinus Torvalds 
297549a0c458SEric W. Biederman /* The generic sysctl data routine (used if no strategy routine supplied) */
2976f221e726SAlexey Dobriyan int sysctl_data(struct ctl_table *table,
297749a0c458SEric W. Biederman 		void __user *oldval, size_t __user *oldlenp,
297849a0c458SEric W. Biederman 		void __user *newval, size_t newlen)
297949a0c458SEric W. Biederman {
298049a0c458SEric W. Biederman 	size_t len;
298149a0c458SEric W. Biederman 
298249a0c458SEric W. Biederman 	/* Get out of I don't have a variable */
298349a0c458SEric W. Biederman 	if (!table->data || !table->maxlen)
298449a0c458SEric W. Biederman 		return -ENOTDIR;
298549a0c458SEric W. Biederman 
298649a0c458SEric W. Biederman 	if (oldval && oldlenp) {
298749a0c458SEric W. Biederman 		if (get_user(len, oldlenp))
298849a0c458SEric W. Biederman 			return -EFAULT;
298949a0c458SEric W. Biederman 		if (len) {
299049a0c458SEric W. Biederman 			if (len > table->maxlen)
299149a0c458SEric W. Biederman 				len = table->maxlen;
299249a0c458SEric W. Biederman 			if (copy_to_user(oldval, table->data, len))
299349a0c458SEric W. Biederman 				return -EFAULT;
299449a0c458SEric W. Biederman 			if (put_user(len, oldlenp))
299549a0c458SEric W. Biederman 				return -EFAULT;
299649a0c458SEric W. Biederman 		}
299749a0c458SEric W. Biederman 	}
299849a0c458SEric W. Biederman 
299949a0c458SEric W. Biederman 	if (newval && newlen) {
300049a0c458SEric W. Biederman 		if (newlen > table->maxlen)
300149a0c458SEric W. Biederman 			newlen = table->maxlen;
300249a0c458SEric W. Biederman 
300349a0c458SEric W. Biederman 		if (copy_from_user(table->data, newval, newlen))
300449a0c458SEric W. Biederman 			return -EFAULT;
300549a0c458SEric W. Biederman 	}
300649a0c458SEric W. Biederman 	return 1;
300749a0c458SEric W. Biederman }
300849a0c458SEric W. Biederman 
30091da177e4SLinus Torvalds /* The generic string strategy routine: */
3010f221e726SAlexey Dobriyan int sysctl_string(struct ctl_table *table,
30111da177e4SLinus Torvalds 		  void __user *oldval, size_t __user *oldlenp,
30121f29bcd7SAlexey Dobriyan 		  void __user *newval, size_t newlen)
30131da177e4SLinus Torvalds {
30141da177e4SLinus Torvalds 	if (!table->data || !table->maxlen)
30151da177e4SLinus Torvalds 		return -ENOTDIR;
30161da177e4SLinus Torvalds 
30171da177e4SLinus Torvalds 	if (oldval && oldlenp) {
3018de9e007dSLinus Torvalds 		size_t bufsize;
3019de9e007dSLinus Torvalds 		if (get_user(bufsize, oldlenp))
30201da177e4SLinus Torvalds 			return -EFAULT;
3021de9e007dSLinus Torvalds 		if (bufsize) {
3022de9e007dSLinus Torvalds 			size_t len = strlen(table->data), copied;
3023de9e007dSLinus Torvalds 
3024de9e007dSLinus Torvalds 			/* This shouldn't trigger for a well-formed sysctl */
3025de9e007dSLinus Torvalds 			if (len > table->maxlen)
30261da177e4SLinus Torvalds 				len = table->maxlen;
3027de9e007dSLinus Torvalds 
3028de9e007dSLinus Torvalds 			/* Copy up to a max of bufsize-1 bytes of the string */
3029de9e007dSLinus Torvalds 			copied = (len >= bufsize) ? bufsize - 1 : len;
3030de9e007dSLinus Torvalds 
3031de9e007dSLinus Torvalds 			if (copy_to_user(oldval, table->data, copied) ||
3032de9e007dSLinus Torvalds 			    put_user(0, (char __user *)(oldval + copied)))
30331da177e4SLinus Torvalds 				return -EFAULT;
30341da177e4SLinus Torvalds 			if (put_user(len, oldlenp))
30351da177e4SLinus Torvalds 				return -EFAULT;
30361da177e4SLinus Torvalds 		}
30371da177e4SLinus Torvalds 	}
30381da177e4SLinus Torvalds 	if (newval && newlen) {
3039de9e007dSLinus Torvalds 		size_t len = newlen;
30401da177e4SLinus Torvalds 		if (len > table->maxlen)
30411da177e4SLinus Torvalds 			len = table->maxlen;
30421da177e4SLinus Torvalds 		if(copy_from_user(table->data, newval, len))
30431da177e4SLinus Torvalds 			return -EFAULT;
30441da177e4SLinus Torvalds 		if (len == table->maxlen)
30451da177e4SLinus Torvalds 			len--;
30461da177e4SLinus Torvalds 		((char *) table->data)[len] = 0;
30471da177e4SLinus Torvalds 	}
304882c9df82SYi Yang 	return 1;
30491da177e4SLinus Torvalds }
30501da177e4SLinus Torvalds 
30511da177e4SLinus Torvalds /*
30521da177e4SLinus Torvalds  * This function makes sure that all of the integers in the vector
30531da177e4SLinus Torvalds  * are between the minimum and maximum values given in the arrays
30541da177e4SLinus Torvalds  * table->extra1 and table->extra2, respectively.
30551da177e4SLinus Torvalds  */
3056f221e726SAlexey Dobriyan int sysctl_intvec(struct ctl_table *table,
30571da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
30581f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
30591da177e4SLinus Torvalds {
30601da177e4SLinus Torvalds 
30611da177e4SLinus Torvalds 	if (newval && newlen) {
30621da177e4SLinus Torvalds 		int __user *vec = (int __user *) newval;
30631da177e4SLinus Torvalds 		int *min = (int *) table->extra1;
30641da177e4SLinus Torvalds 		int *max = (int *) table->extra2;
30651da177e4SLinus Torvalds 		size_t length;
30661da177e4SLinus Torvalds 		int i;
30671da177e4SLinus Torvalds 
30681da177e4SLinus Torvalds 		if (newlen % sizeof(int) != 0)
30691da177e4SLinus Torvalds 			return -EINVAL;
30701da177e4SLinus Torvalds 
30711da177e4SLinus Torvalds 		if (!table->extra1 && !table->extra2)
30721da177e4SLinus Torvalds 			return 0;
30731da177e4SLinus Torvalds 
30741da177e4SLinus Torvalds 		if (newlen > table->maxlen)
30751da177e4SLinus Torvalds 			newlen = table->maxlen;
30761da177e4SLinus Torvalds 		length = newlen / sizeof(int);
30771da177e4SLinus Torvalds 
30781da177e4SLinus Torvalds 		for (i = 0; i < length; i++) {
30791da177e4SLinus Torvalds 			int value;
30801da177e4SLinus Torvalds 			if (get_user(value, vec + i))
30811da177e4SLinus Torvalds 				return -EFAULT;
30821da177e4SLinus Torvalds 			if (min && value < min[i])
30831da177e4SLinus Torvalds 				return -EINVAL;
30841da177e4SLinus Torvalds 			if (max && value > max[i])
30851da177e4SLinus Torvalds 				return -EINVAL;
30861da177e4SLinus Torvalds 		}
30871da177e4SLinus Torvalds 	}
30881da177e4SLinus Torvalds 	return 0;
30891da177e4SLinus Torvalds }
30901da177e4SLinus Torvalds 
30911da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */
3092f221e726SAlexey Dobriyan int sysctl_jiffies(struct ctl_table *table,
30931da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
30941f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
30951da177e4SLinus Torvalds {
30963ee75ac3SAlexey Dobriyan 	if (oldval && oldlenp) {
30971da177e4SLinus Torvalds 		size_t olen;
30983ee75ac3SAlexey Dobriyan 
30991da177e4SLinus Torvalds 		if (get_user(olen, oldlenp))
31001da177e4SLinus Torvalds 			return -EFAULT;
31013ee75ac3SAlexey Dobriyan 		if (olen) {
31023ee75ac3SAlexey Dobriyan 			int val;
31033ee75ac3SAlexey Dobriyan 
31043ee75ac3SAlexey Dobriyan 			if (olen < sizeof(int))
31051da177e4SLinus Torvalds 				return -EINVAL;
31063ee75ac3SAlexey Dobriyan 
31073ee75ac3SAlexey Dobriyan 			val = *(int *)(table->data) / HZ;
31083ee75ac3SAlexey Dobriyan 			if (put_user(val, (int __user *)oldval))
31091da177e4SLinus Torvalds 				return -EFAULT;
31103ee75ac3SAlexey Dobriyan 			if (put_user(sizeof(int), oldlenp))
31113ee75ac3SAlexey Dobriyan 				return -EFAULT;
31123ee75ac3SAlexey Dobriyan 		}
31131da177e4SLinus Torvalds 	}
31141da177e4SLinus Torvalds 	if (newval && newlen) {
31151da177e4SLinus Torvalds 		int new;
31161da177e4SLinus Torvalds 		if (newlen != sizeof(int))
31171da177e4SLinus Torvalds 			return -EINVAL;
31181da177e4SLinus Torvalds 		if (get_user(new, (int __user *)newval))
31191da177e4SLinus Torvalds 			return -EFAULT;
31201da177e4SLinus Torvalds 		*(int *)(table->data) = new*HZ;
31211da177e4SLinus Torvalds 	}
31221da177e4SLinus Torvalds 	return 1;
31231da177e4SLinus Torvalds }
31241da177e4SLinus Torvalds 
31251da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */
3126f221e726SAlexey Dobriyan int sysctl_ms_jiffies(struct ctl_table *table,
31271da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
31281f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
31291da177e4SLinus Torvalds {
31303ee75ac3SAlexey Dobriyan 	if (oldval && oldlenp) {
31311da177e4SLinus Torvalds 		size_t olen;
31323ee75ac3SAlexey Dobriyan 
31331da177e4SLinus Torvalds 		if (get_user(olen, oldlenp))
31341da177e4SLinus Torvalds 			return -EFAULT;
31353ee75ac3SAlexey Dobriyan 		if (olen) {
31363ee75ac3SAlexey Dobriyan 			int val;
31373ee75ac3SAlexey Dobriyan 
31383ee75ac3SAlexey Dobriyan 			if (olen < sizeof(int))
31391da177e4SLinus Torvalds 				return -EINVAL;
31403ee75ac3SAlexey Dobriyan 
31413ee75ac3SAlexey Dobriyan 			val = jiffies_to_msecs(*(int *)(table->data));
31423ee75ac3SAlexey Dobriyan 			if (put_user(val, (int __user *)oldval))
31431da177e4SLinus Torvalds 				return -EFAULT;
31443ee75ac3SAlexey Dobriyan 			if (put_user(sizeof(int), oldlenp))
31453ee75ac3SAlexey Dobriyan 				return -EFAULT;
31463ee75ac3SAlexey Dobriyan 		}
31471da177e4SLinus Torvalds 	}
31481da177e4SLinus Torvalds 	if (newval && newlen) {
31491da177e4SLinus Torvalds 		int new;
31501da177e4SLinus Torvalds 		if (newlen != sizeof(int))
31511da177e4SLinus Torvalds 			return -EINVAL;
31521da177e4SLinus Torvalds 		if (get_user(new, (int __user *)newval))
31531da177e4SLinus Torvalds 			return -EFAULT;
31541da177e4SLinus Torvalds 		*(int *)(table->data) = msecs_to_jiffies(new);
31551da177e4SLinus Torvalds 	}
31561da177e4SLinus Torvalds 	return 1;
31571da177e4SLinus Torvalds }
31581da177e4SLinus Torvalds 
3159c4b8b769SEric W. Biederman 
3160c4b8b769SEric W. Biederman 
3161b89a8171SEric W. Biederman #else /* CONFIG_SYSCTL_SYSCALL */
31621da177e4SLinus Torvalds 
31631da177e4SLinus Torvalds 
31641e7bfb21SHeiko Carstens SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
31651da177e4SLinus Torvalds {
31660e009be8SEric W. Biederman 	struct __sysctl_args tmp;
31677058cb02SEric W. Biederman 	int error;
31680e009be8SEric W. Biederman 
31690e009be8SEric W. Biederman 	if (copy_from_user(&tmp, args, sizeof(tmp)))
31700e009be8SEric W. Biederman 		return -EFAULT;
31710e009be8SEric W. Biederman 
31727058cb02SEric W. Biederman 	error = deprecated_sysctl_warning(&tmp);
3173b89a8171SEric W. Biederman 
31747058cb02SEric W. Biederman 	/* If no error reading the parameters then just -ENOSYS ... */
31757058cb02SEric W. Biederman 	if (!error)
31767058cb02SEric W. Biederman 		error = -ENOSYS;
31777058cb02SEric W. Biederman 
31787058cb02SEric W. Biederman 	return error;
31791da177e4SLinus Torvalds }
31801da177e4SLinus Torvalds 
3181f221e726SAlexey Dobriyan int sysctl_data(struct ctl_table *table,
318249a0c458SEric W. Biederman 		  void __user *oldval, size_t __user *oldlenp,
318349a0c458SEric W. Biederman 		  void __user *newval, size_t newlen)
318449a0c458SEric W. Biederman {
318549a0c458SEric W. Biederman 	return -ENOSYS;
318649a0c458SEric W. Biederman }
318749a0c458SEric W. Biederman 
3188f221e726SAlexey Dobriyan int sysctl_string(struct ctl_table *table,
31891da177e4SLinus Torvalds 		  void __user *oldval, size_t __user *oldlenp,
31901f29bcd7SAlexey Dobriyan 		  void __user *newval, size_t newlen)
31911da177e4SLinus Torvalds {
31921da177e4SLinus Torvalds 	return -ENOSYS;
31931da177e4SLinus Torvalds }
31941da177e4SLinus Torvalds 
3195f221e726SAlexey Dobriyan int sysctl_intvec(struct ctl_table *table,
31961da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
31971f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
31981da177e4SLinus Torvalds {
31991da177e4SLinus Torvalds 	return -ENOSYS;
32001da177e4SLinus Torvalds }
32011da177e4SLinus Torvalds 
3202f221e726SAlexey Dobriyan int sysctl_jiffies(struct ctl_table *table,
32031da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
32041f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
32051da177e4SLinus Torvalds {
32061da177e4SLinus Torvalds 	return -ENOSYS;
32071da177e4SLinus Torvalds }
32081da177e4SLinus Torvalds 
3209f221e726SAlexey Dobriyan int sysctl_ms_jiffies(struct ctl_table *table,
32101da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
32111f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
32121da177e4SLinus Torvalds {
32131da177e4SLinus Torvalds 	return -ENOSYS;
32141da177e4SLinus Torvalds }
32151da177e4SLinus Torvalds 
3216b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */
32171da177e4SLinus Torvalds 
32187058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args)
32197058cb02SEric W. Biederman {
32207058cb02SEric W. Biederman 	static int msg_count;
32217058cb02SEric W. Biederman 	int name[CTL_MAXNAME];
32227058cb02SEric W. Biederman 	int i;
32237058cb02SEric W. Biederman 
32246fc48af8STetsuo Handa 	/* Check args->nlen. */
32256fc48af8STetsuo Handa 	if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
32266fc48af8STetsuo Handa 		return -ENOTDIR;
32276fc48af8STetsuo Handa 
32287058cb02SEric W. Biederman 	/* Read in the sysctl name for better debug message logging */
32297058cb02SEric W. Biederman 	for (i = 0; i < args->nlen; i++)
32307058cb02SEric W. Biederman 		if (get_user(name[i], args->name + i))
32317058cb02SEric W. Biederman 			return -EFAULT;
32327058cb02SEric W. Biederman 
32337058cb02SEric W. Biederman 	/* Ignore accesses to kernel.version */
32347058cb02SEric W. Biederman 	if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
32357058cb02SEric W. Biederman 		return 0;
32367058cb02SEric W. Biederman 
32377058cb02SEric W. Biederman 	if (msg_count < 5) {
32387058cb02SEric W. Biederman 		msg_count++;
32397058cb02SEric W. Biederman 		printk(KERN_INFO
32407058cb02SEric W. Biederman 			"warning: process `%s' used the deprecated sysctl "
32417058cb02SEric W. Biederman 			"system call with ", current->comm);
32427058cb02SEric W. Biederman 		for (i = 0; i < args->nlen; i++)
32437058cb02SEric W. Biederman 			printk("%d.", name[i]);
32447058cb02SEric W. Biederman 		printk("\n");
32457058cb02SEric W. Biederman 	}
32467058cb02SEric W. Biederman 	return 0;
32477058cb02SEric W. Biederman }
32487058cb02SEric W. Biederman 
32491da177e4SLinus Torvalds /*
32501da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
32511da177e4SLinus Torvalds  * exception granted :-)
32521da177e4SLinus Torvalds  */
32531da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
32541da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
32551da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
32561da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
32571da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
32581da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
32591da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
32601da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
32611da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table);
326229e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths);
32631da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_intvec);
32641da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_jiffies);
32651da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_ms_jiffies);
32661da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_string);
326749a0c458SEric W. Biederman EXPORT_SYMBOL(sysctl_data);
32681da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table);
3269