xref: /openbmc/linux/kernel/sysctl.c (revision 9c44bc03fff44ff04237a7d92e35304a0e50c331)
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>
291da177e4SLinus Torvalds #include <linux/utsname.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>
391da177e4SLinus Torvalds #include <linux/hugetlb.h>
401da177e4SLinus Torvalds #include <linux/initrd.h>
410b77f5bfSDavid Howells #include <linux/key.h>
421da177e4SLinus Torvalds #include <linux/times.h>
431da177e4SLinus Torvalds #include <linux/limits.h>
441da177e4SLinus Torvalds #include <linux/dcache.h>
451da177e4SLinus Torvalds #include <linux/syscalls.h>
46c255d844SPavel Machek #include <linux/nfs_fs.h>
47c255d844SPavel Machek #include <linux/acpi.h>
4810a0a8d4SJeremy Fitzhardinge #include <linux/reboot.h>
491da177e4SLinus Torvalds 
501da177e4SLinus Torvalds #include <asm/uaccess.h>
511da177e4SLinus Torvalds #include <asm/processor.h>
521da177e4SLinus Torvalds 
5329cbc78bSAndi Kleen #ifdef CONFIG_X86
5429cbc78bSAndi Kleen #include <asm/nmi.h>
550741f4d2SChuck Ebbert #include <asm/stacktrace.h>
566e7c4025SIngo Molnar #include <asm/io.h>
5729cbc78bSAndi Kleen #endif
5829cbc78bSAndi Kleen 
597058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args);
607058cb02SEric W. Biederman 
611da177e4SLinus Torvalds #if defined(CONFIG_SYSCTL)
621da177e4SLinus Torvalds 
631da177e4SLinus Torvalds /* External variables not in a header file. */
641da177e4SLinus Torvalds extern int C_A_D;
6545807a1dSIngo Molnar extern int print_fatal_signals;
661da177e4SLinus Torvalds extern int sysctl_overcommit_memory;
671da177e4SLinus Torvalds extern int sysctl_overcommit_ratio;
68fadd8fbdSKAMEZAWA Hiroyuki extern int sysctl_panic_on_oom;
69fe071d7eSDavid Rientjes extern int sysctl_oom_kill_allocating_task;
70fef1bdd6SDavid Rientjes extern int sysctl_oom_dump_tasks;
711da177e4SLinus Torvalds extern int max_threads;
721da177e4SLinus Torvalds extern int core_uses_pid;
73d6e71144SAlan Cox extern int suid_dumpable;
741da177e4SLinus Torvalds extern char core_pattern[];
751da177e4SLinus Torvalds extern int pid_max;
761da177e4SLinus Torvalds extern int min_free_kbytes;
771da177e4SLinus Torvalds extern int pid_max_min, pid_max_max;
789d0243bcSAndrew Morton extern int sysctl_drop_caches;
798ad4b1fbSRohit Seth extern int percpu_pagelist_fraction;
80bebfa101SAndi Kleen extern int compat_log;
815096add8SKees Cook extern int maps_protect;
8277461ab3SChristoph Lameter extern int sysctl_stat_interval;
839745512cSArjan van de Ven extern int latencytop_enabled;
84eceea0b3SAl Viro extern int sysctl_nr_open_min, sysctl_nr_open_max;
851da177e4SLinus Torvalds 
86c4f3b63fSRavikiran G Thirumalai /* Constants used for minimum and  maximum */
87195cf453SBron Gondwana #if defined(CONFIG_DETECT_SOFTLOCKUP) || defined(CONFIG_HIGHMEM)
88c4f3b63fSRavikiran G Thirumalai static int one = 1;
89195cf453SBron Gondwana #endif
90195cf453SBron Gondwana 
91195cf453SBron Gondwana #ifdef CONFIG_DETECT_SOFTLOCKUP
92c4f3b63fSRavikiran G Thirumalai static int sixty = 60;
93c4f3b63fSRavikiran G Thirumalai #endif
94c4f3b63fSRavikiran G Thirumalai 
95c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_MMU
96c4f3b63fSRavikiran G Thirumalai static int two = 2;
97c4f3b63fSRavikiran G Thirumalai #endif
98c4f3b63fSRavikiran G Thirumalai 
99c4f3b63fSRavikiran G Thirumalai static int zero;
100c4f3b63fSRavikiran G Thirumalai static int one_hundred = 100;
101c4f3b63fSRavikiran G Thirumalai 
1021da177e4SLinus Torvalds /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
1031da177e4SLinus Torvalds static int maxolduid = 65535;
1041da177e4SLinus Torvalds static int minolduid;
1058ad4b1fbSRohit Seth static int min_percpu_pagelist_fract = 8;
1061da177e4SLinus Torvalds 
1071da177e4SLinus Torvalds static int ngroups_max = NGROUPS_MAX;
1081da177e4SLinus Torvalds 
1091da177e4SLinus Torvalds #ifdef CONFIG_KMOD
1101da177e4SLinus Torvalds extern char modprobe_path[];
1111da177e4SLinus Torvalds #endif
1121da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
1131da177e4SLinus Torvalds extern int sg_big_buff;
1141da177e4SLinus Torvalds #endif
1151da177e4SLinus Torvalds 
1161da177e4SLinus Torvalds #ifdef __sparc__
1171da177e4SLinus Torvalds extern char reboot_command [];
1181da177e4SLinus Torvalds extern int stop_a_enabled;
1191da177e4SLinus Torvalds extern int scons_pwroff;
1201da177e4SLinus Torvalds #endif
1211da177e4SLinus Torvalds 
1221da177e4SLinus Torvalds #ifdef __hppa__
1231da177e4SLinus Torvalds extern int pwrsw_enabled;
1241da177e4SLinus Torvalds extern int unaligned_enabled;
1251da177e4SLinus Torvalds #endif
1261da177e4SLinus Torvalds 
127347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
1281da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
1291da177e4SLinus Torvalds extern int sysctl_ieee_emulation_warnings;
1301da177e4SLinus Torvalds #endif
1311da177e4SLinus Torvalds extern int sysctl_userprocess_debug;
132951f22d5SMartin Schwidefsky extern int spin_retry;
1331da177e4SLinus Torvalds #endif
1341da177e4SLinus Torvalds 
1351da177e4SLinus Torvalds extern int sysctl_hz_timer;
1361da177e4SLinus Torvalds 
1371da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
1381da177e4SLinus Torvalds extern int acct_parm[];
1391da177e4SLinus Torvalds #endif
1401da177e4SLinus Torvalds 
141d2b176edSJes Sorensen #ifdef CONFIG_IA64
142d2b176edSJes Sorensen extern int no_unaligned_warning;
143d2b176edSJes Sorensen #endif
144d2b176edSJes Sorensen 
14523f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
14623f78d4aSIngo Molnar extern int max_lock_depth;
14723f78d4aSIngo Molnar #endif
14823f78d4aSIngo Molnar 
149d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
150d8217f07SEric W. Biederman static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
1519ec52099SCedric Le Goater 		  void __user *buffer, size_t *lenp, loff_t *ppos);
152d8217f07SEric W. Biederman static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp,
15334f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos);
154d6f8ff73SRandy Dunlap #endif
1559ec52099SCedric Le Goater 
156d8217f07SEric W. Biederman static struct ctl_table root_table[];
157e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root;
158e51b6ba0SEric W. Biederman static struct ctl_table_header root_table_header = {
159e51b6ba0SEric W. Biederman 	.ctl_table = root_table,
160e51b6ba0SEric W. Biederman 	.ctl_entry = LIST_HEAD_INIT(sysctl_table_root.header_list),
161e51b6ba0SEric W. Biederman 	.root = &sysctl_table_root,
162e51b6ba0SEric W. Biederman };
163e51b6ba0SEric W. Biederman static struct ctl_table_root sysctl_table_root = {
164e51b6ba0SEric W. Biederman 	.root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
165e51b6ba0SEric W. Biederman 	.header_list = LIST_HEAD_INIT(root_table_header.ctl_entry),
166e51b6ba0SEric W. Biederman };
1671da177e4SLinus Torvalds 
168d8217f07SEric W. Biederman static struct ctl_table kern_table[];
169d8217f07SEric W. Biederman static struct ctl_table vm_table[];
170d8217f07SEric W. Biederman static struct ctl_table fs_table[];
171d8217f07SEric W. Biederman static struct ctl_table debug_table[];
172d8217f07SEric W. Biederman static struct ctl_table dev_table[];
173d8217f07SEric W. Biederman extern struct ctl_table random_table[];
1742d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
175d8217f07SEric W. Biederman extern struct ctl_table inotify_table[];
1760399cb08SRobert Love #endif
1771da177e4SLinus Torvalds 
1781da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1791da177e4SLinus Torvalds int sysctl_legacy_va_layout;
1801da177e4SLinus Torvalds #endif
1811da177e4SLinus Torvalds 
182f20786ffSPeter Zijlstra extern int prove_locking;
183f20786ffSPeter Zijlstra extern int lock_stat;
1849bc9a6bdSEric W. Biederman 
1851da177e4SLinus Torvalds /* The default sysctl tables: */
1861da177e4SLinus Torvalds 
187d8217f07SEric W. Biederman static struct ctl_table root_table[] = {
1881da177e4SLinus Torvalds 	{
1891da177e4SLinus Torvalds 		.ctl_name	= CTL_KERN,
1901da177e4SLinus Torvalds 		.procname	= "kernel",
1911da177e4SLinus Torvalds 		.mode		= 0555,
1921da177e4SLinus Torvalds 		.child		= kern_table,
1931da177e4SLinus Torvalds 	},
1941da177e4SLinus Torvalds 	{
1951da177e4SLinus Torvalds 		.ctl_name	= CTL_VM,
1961da177e4SLinus Torvalds 		.procname	= "vm",
1971da177e4SLinus Torvalds 		.mode		= 0555,
1981da177e4SLinus Torvalds 		.child		= vm_table,
1991da177e4SLinus Torvalds 	},
2001da177e4SLinus Torvalds 	{
2011da177e4SLinus Torvalds 		.ctl_name	= CTL_FS,
2021da177e4SLinus Torvalds 		.procname	= "fs",
2031da177e4SLinus Torvalds 		.mode		= 0555,
2041da177e4SLinus Torvalds 		.child		= fs_table,
2051da177e4SLinus Torvalds 	},
2061da177e4SLinus Torvalds 	{
2071da177e4SLinus Torvalds 		.ctl_name	= CTL_DEBUG,
2081da177e4SLinus Torvalds 		.procname	= "debug",
2091da177e4SLinus Torvalds 		.mode		= 0555,
2101da177e4SLinus Torvalds 		.child		= debug_table,
2111da177e4SLinus Torvalds 	},
2121da177e4SLinus Torvalds 	{
2131da177e4SLinus Torvalds 		.ctl_name	= CTL_DEV,
2141da177e4SLinus Torvalds 		.procname	= "dev",
2151da177e4SLinus Torvalds 		.mode		= 0555,
2161da177e4SLinus Torvalds 		.child		= dev_table,
2171da177e4SLinus Torvalds 	},
2182be7fe07SAndrew Morton /*
2192be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
2202be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
2212be7fe07SAndrew Morton  */
2221da177e4SLinus Torvalds 	{ .ctl_name = 0 }
2231da177e4SLinus Torvalds };
2241da177e4SLinus Torvalds 
22577e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
22673c4efd2SEric Dumazet static int min_sched_granularity_ns = 100000;		/* 100 usecs */
22773c4efd2SEric Dumazet static int max_sched_granularity_ns = NSEC_PER_SEC;	/* 1 second */
22873c4efd2SEric Dumazet static int min_wakeup_granularity_ns;			/* 0 usecs */
22973c4efd2SEric Dumazet static int max_wakeup_granularity_ns = NSEC_PER_SEC;	/* 1 second */
23077e54a1fSIngo Molnar #endif
23177e54a1fSIngo Molnar 
232d8217f07SEric W. Biederman static struct ctl_table kern_table[] = {
23377e54a1fSIngo Molnar #ifdef CONFIG_SCHED_DEBUG
23477e54a1fSIngo Molnar 	{
23577e54a1fSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
236b2be5e96SPeter Zijlstra 		.procname	= "sched_min_granularity_ns",
237b2be5e96SPeter Zijlstra 		.data		= &sysctl_sched_min_granularity,
23877e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
23977e54a1fSIngo Molnar 		.mode		= 0644,
240b2be5e96SPeter Zijlstra 		.proc_handler	= &sched_nr_latency_handler,
241b2be5e96SPeter Zijlstra 		.strategy	= &sysctl_intvec,
242b2be5e96SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
243b2be5e96SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
24477e54a1fSIngo Molnar 	},
24577e54a1fSIngo Molnar 	{
24677e54a1fSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
24721805085SPeter Zijlstra 		.procname	= "sched_latency_ns",
24821805085SPeter Zijlstra 		.data		= &sysctl_sched_latency,
24921805085SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
25021805085SPeter Zijlstra 		.mode		= 0644,
251b2be5e96SPeter Zijlstra 		.proc_handler	= &sched_nr_latency_handler,
25221805085SPeter Zijlstra 		.strategy	= &sysctl_intvec,
25321805085SPeter Zijlstra 		.extra1		= &min_sched_granularity_ns,
25421805085SPeter Zijlstra 		.extra2		= &max_sched_granularity_ns,
25521805085SPeter Zijlstra 	},
25621805085SPeter Zijlstra 	{
25721805085SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
25877e54a1fSIngo Molnar 		.procname	= "sched_wakeup_granularity_ns",
25977e54a1fSIngo Molnar 		.data		= &sysctl_sched_wakeup_granularity,
26077e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
26177e54a1fSIngo Molnar 		.mode		= 0644,
26277e54a1fSIngo Molnar 		.proc_handler	= &proc_dointvec_minmax,
26377e54a1fSIngo Molnar 		.strategy	= &sysctl_intvec,
26477e54a1fSIngo Molnar 		.extra1		= &min_wakeup_granularity_ns,
26577e54a1fSIngo Molnar 		.extra2		= &max_wakeup_granularity_ns,
26677e54a1fSIngo Molnar 	},
26777e54a1fSIngo Molnar 	{
26877e54a1fSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
26977e54a1fSIngo Molnar 		.procname	= "sched_child_runs_first",
27077e54a1fSIngo Molnar 		.data		= &sysctl_sched_child_runs_first,
27177e54a1fSIngo Molnar 		.maxlen		= sizeof(unsigned int),
27277e54a1fSIngo Molnar 		.mode		= 0644,
27377e54a1fSIngo Molnar 		.proc_handler	= &proc_dointvec,
27477e54a1fSIngo Molnar 	},
2751fc84aaaSPeter Zijlstra 	{
2761fc84aaaSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
2771fc84aaaSPeter Zijlstra 		.procname	= "sched_features",
2781fc84aaaSPeter Zijlstra 		.data		= &sysctl_sched_features,
2791fc84aaaSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
2801fc84aaaSPeter Zijlstra 		.mode		= 0644,
2811fc84aaaSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
2821fc84aaaSPeter Zijlstra 	},
283da84d961SIngo Molnar 	{
284da84d961SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
285da84d961SIngo Molnar 		.procname	= "sched_migration_cost",
286da84d961SIngo Molnar 		.data		= &sysctl_sched_migration_cost,
287da84d961SIngo Molnar 		.maxlen		= sizeof(unsigned int),
288da84d961SIngo Molnar 		.mode		= 0644,
289da84d961SIngo Molnar 		.proc_handler	= &proc_dointvec,
290da84d961SIngo Molnar 	},
291b82d9fddSPeter Zijlstra 	{
292b82d9fddSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
293b82d9fddSPeter Zijlstra 		.procname	= "sched_nr_migrate",
294b82d9fddSPeter Zijlstra 		.data		= &sysctl_sched_nr_migrate,
295b82d9fddSPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
296fa85ae24SPeter Zijlstra 		.mode		= 0644,
297fa85ae24SPeter Zijlstra 		.proc_handler	= &proc_dointvec,
298fa85ae24SPeter Zijlstra 	},
2991fc84aaaSPeter Zijlstra #endif
3001799e35dSIngo Molnar 	{
3011799e35dSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
3029f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_period_us",
3039f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_period,
3049f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(unsigned int),
3059f0c1e56SPeter Zijlstra 		.mode		= 0644,
306d0b27fa7SPeter Zijlstra 		.proc_handler	= &sched_rt_handler,
3079f0c1e56SPeter Zijlstra 	},
3089f0c1e56SPeter Zijlstra 	{
3099f0c1e56SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
3109f0c1e56SPeter Zijlstra 		.procname	= "sched_rt_runtime_us",
3119f0c1e56SPeter Zijlstra 		.data		= &sysctl_sched_rt_runtime,
3129f0c1e56SPeter Zijlstra 		.maxlen		= sizeof(int),
3139f0c1e56SPeter Zijlstra 		.mode		= 0644,
314d0b27fa7SPeter Zijlstra 		.proc_handler	= &sched_rt_handler,
3159f0c1e56SPeter Zijlstra 	},
3169f0c1e56SPeter Zijlstra 	{
3179f0c1e56SPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
3181799e35dSIngo Molnar 		.procname	= "sched_compat_yield",
3191799e35dSIngo Molnar 		.data		= &sysctl_sched_compat_yield,
3201799e35dSIngo Molnar 		.maxlen		= sizeof(unsigned int),
3211799e35dSIngo Molnar 		.mode		= 0644,
3221799e35dSIngo Molnar 		.proc_handler	= &proc_dointvec,
3231799e35dSIngo Molnar 	},
324f20786ffSPeter Zijlstra #ifdef CONFIG_PROVE_LOCKING
325f20786ffSPeter Zijlstra 	{
326f20786ffSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
327f20786ffSPeter Zijlstra 		.procname	= "prove_locking",
328f20786ffSPeter Zijlstra 		.data		= &prove_locking,
329f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
330f20786ffSPeter Zijlstra 		.mode		= 0644,
331f20786ffSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
332f20786ffSPeter Zijlstra 	},
333f20786ffSPeter Zijlstra #endif
334f20786ffSPeter Zijlstra #ifdef CONFIG_LOCK_STAT
335f20786ffSPeter Zijlstra 	{
336f20786ffSPeter Zijlstra 		.ctl_name	= CTL_UNNUMBERED,
337f20786ffSPeter Zijlstra 		.procname	= "lock_stat",
338f20786ffSPeter Zijlstra 		.data		= &lock_stat,
339f20786ffSPeter Zijlstra 		.maxlen		= sizeof(int),
340f20786ffSPeter Zijlstra 		.mode		= 0644,
341f20786ffSPeter Zijlstra 		.proc_handler	= &proc_dointvec,
342f20786ffSPeter Zijlstra 	},
343f20786ffSPeter Zijlstra #endif
34477e54a1fSIngo Molnar 	{
3451da177e4SLinus Torvalds 		.ctl_name	= KERN_PANIC,
3461da177e4SLinus Torvalds 		.procname	= "panic",
3471da177e4SLinus Torvalds 		.data		= &panic_timeout,
3481da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
3491da177e4SLinus Torvalds 		.mode		= 0644,
3501da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
3511da177e4SLinus Torvalds 	},
3521da177e4SLinus Torvalds 	{
3531da177e4SLinus Torvalds 		.ctl_name	= KERN_CORE_USES_PID,
3541da177e4SLinus Torvalds 		.procname	= "core_uses_pid",
3551da177e4SLinus Torvalds 		.data		= &core_uses_pid,
3561da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
3571da177e4SLinus Torvalds 		.mode		= 0644,
3581da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
3591da177e4SLinus Torvalds 	},
3601da177e4SLinus Torvalds 	{
3611da177e4SLinus Torvalds 		.ctl_name	= KERN_CORE_PATTERN,
3621da177e4SLinus Torvalds 		.procname	= "core_pattern",
3631da177e4SLinus Torvalds 		.data		= core_pattern,
36471ce92f3SDan Aloni 		.maxlen		= CORENAME_MAX_SIZE,
3651da177e4SLinus Torvalds 		.mode		= 0644,
3661da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
3671da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
3681da177e4SLinus Torvalds 	},
36934f5a398STheodore Ts'o #ifdef CONFIG_PROC_SYSCTL
3701da177e4SLinus Torvalds 	{
3711da177e4SLinus Torvalds 		.procname	= "tainted",
3721da177e4SLinus Torvalds 		.data		= &tainted,
3731da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
37434f5a398STheodore Ts'o 		.mode		= 0644,
37534f5a398STheodore Ts'o 		.proc_handler	= &proc_dointvec_taint,
3761da177e4SLinus Torvalds 	},
37734f5a398STheodore Ts'o #endif
3789745512cSArjan van de Ven #ifdef CONFIG_LATENCYTOP
3799745512cSArjan van de Ven 	{
3809745512cSArjan van de Ven 		.procname	= "latencytop",
3819745512cSArjan van de Ven 		.data		= &latencytop_enabled,
3829745512cSArjan van de Ven 		.maxlen		= sizeof(int),
3839745512cSArjan van de Ven 		.mode		= 0644,
3849745512cSArjan van de Ven 		.proc_handler	= &proc_dointvec,
3859745512cSArjan van de Ven 	},
3869745512cSArjan van de Ven #endif
3871da177e4SLinus Torvalds #ifdef CONFIG_BLK_DEV_INITRD
3881da177e4SLinus Torvalds 	{
3891da177e4SLinus Torvalds 		.ctl_name	= KERN_REALROOTDEV,
3901da177e4SLinus Torvalds 		.procname	= "real-root-dev",
3911da177e4SLinus Torvalds 		.data		= &real_root_dev,
3921da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
3931da177e4SLinus Torvalds 		.mode		= 0644,
3941da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
3951da177e4SLinus Torvalds 	},
3961da177e4SLinus Torvalds #endif
39745807a1dSIngo Molnar 	{
39845807a1dSIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
39945807a1dSIngo Molnar 		.procname	= "print-fatal-signals",
40045807a1dSIngo Molnar 		.data		= &print_fatal_signals,
40145807a1dSIngo Molnar 		.maxlen		= sizeof(int),
40245807a1dSIngo Molnar 		.mode		= 0644,
40345807a1dSIngo Molnar 		.proc_handler	= &proc_dointvec,
40445807a1dSIngo Molnar 	},
4051da177e4SLinus Torvalds #ifdef __sparc__
4061da177e4SLinus Torvalds 	{
4071da177e4SLinus Torvalds 		.ctl_name	= KERN_SPARC_REBOOT,
4081da177e4SLinus Torvalds 		.procname	= "reboot-cmd",
4091da177e4SLinus Torvalds 		.data		= reboot_command,
4101da177e4SLinus Torvalds 		.maxlen		= 256,
4111da177e4SLinus Torvalds 		.mode		= 0644,
4121da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
4131da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
4141da177e4SLinus Torvalds 	},
4151da177e4SLinus Torvalds 	{
4161da177e4SLinus Torvalds 		.ctl_name	= KERN_SPARC_STOP_A,
4171da177e4SLinus Torvalds 		.procname	= "stop-a",
4181da177e4SLinus Torvalds 		.data		= &stop_a_enabled,
4191da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4201da177e4SLinus Torvalds 		.mode		= 0644,
4211da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4221da177e4SLinus Torvalds 	},
4231da177e4SLinus Torvalds 	{
4241da177e4SLinus Torvalds 		.ctl_name	= KERN_SPARC_SCONS_PWROFF,
4251da177e4SLinus Torvalds 		.procname	= "scons-poweroff",
4261da177e4SLinus Torvalds 		.data		= &scons_pwroff,
4271da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4281da177e4SLinus Torvalds 		.mode		= 0644,
4291da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4301da177e4SLinus Torvalds 	},
4311da177e4SLinus Torvalds #endif
4321da177e4SLinus Torvalds #ifdef __hppa__
4331da177e4SLinus Torvalds 	{
4341da177e4SLinus Torvalds 		.ctl_name	= KERN_HPPA_PWRSW,
4351da177e4SLinus Torvalds 		.procname	= "soft-power",
4361da177e4SLinus Torvalds 		.data		= &pwrsw_enabled,
4371da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4381da177e4SLinus Torvalds 	 	.mode		= 0644,
4391da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4401da177e4SLinus Torvalds 	},
4411da177e4SLinus Torvalds 	{
4421da177e4SLinus Torvalds 		.ctl_name	= KERN_HPPA_UNALIGNED,
4431da177e4SLinus Torvalds 		.procname	= "unaligned-trap",
4441da177e4SLinus Torvalds 		.data		= &unaligned_enabled,
4451da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4461da177e4SLinus Torvalds 		.mode		= 0644,
4471da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4481da177e4SLinus Torvalds 	},
4491da177e4SLinus Torvalds #endif
4501da177e4SLinus Torvalds 	{
4511da177e4SLinus Torvalds 		.ctl_name	= KERN_CTLALTDEL,
4521da177e4SLinus Torvalds 		.procname	= "ctrl-alt-del",
4531da177e4SLinus Torvalds 		.data		= &C_A_D,
4541da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
4551da177e4SLinus Torvalds 		.mode		= 0644,
4561da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4571da177e4SLinus Torvalds 	},
4581da177e4SLinus Torvalds #ifdef CONFIG_KMOD
4591da177e4SLinus Torvalds 	{
4601da177e4SLinus Torvalds 		.ctl_name	= KERN_MODPROBE,
4611da177e4SLinus Torvalds 		.procname	= "modprobe",
4621da177e4SLinus Torvalds 		.data		= &modprobe_path,
4631da177e4SLinus Torvalds 		.maxlen		= KMOD_PATH_LEN,
4641da177e4SLinus Torvalds 		.mode		= 0644,
4651da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
4661da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
4671da177e4SLinus Torvalds 	},
4681da177e4SLinus Torvalds #endif
46957ae2508SAndrew Morton #if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
4701da177e4SLinus Torvalds 	{
4711da177e4SLinus Torvalds 		.ctl_name	= KERN_HOTPLUG,
4721da177e4SLinus Torvalds 		.procname	= "hotplug",
473312c004dSKay Sievers 		.data		= &uevent_helper,
474312c004dSKay Sievers 		.maxlen		= UEVENT_HELPER_PATH_LEN,
4751da177e4SLinus Torvalds 		.mode		= 0644,
4761da177e4SLinus Torvalds 		.proc_handler	= &proc_dostring,
4771da177e4SLinus Torvalds 		.strategy	= &sysctl_string,
4781da177e4SLinus Torvalds 	},
4791da177e4SLinus Torvalds #endif
4801da177e4SLinus Torvalds #ifdef CONFIG_CHR_DEV_SG
4811da177e4SLinus Torvalds 	{
4821da177e4SLinus Torvalds 		.ctl_name	= KERN_SG_BIG_BUFF,
4831da177e4SLinus Torvalds 		.procname	= "sg-big-buff",
4841da177e4SLinus Torvalds 		.data		= &sg_big_buff,
4851da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
4861da177e4SLinus Torvalds 		.mode		= 0444,
4871da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4881da177e4SLinus Torvalds 	},
4891da177e4SLinus Torvalds #endif
4901da177e4SLinus Torvalds #ifdef CONFIG_BSD_PROCESS_ACCT
4911da177e4SLinus Torvalds 	{
4921da177e4SLinus Torvalds 		.ctl_name	= KERN_ACCT,
4931da177e4SLinus Torvalds 		.procname	= "acct",
4941da177e4SLinus Torvalds 		.data		= &acct_parm,
4951da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
4961da177e4SLinus Torvalds 		.mode		= 0644,
4971da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
4981da177e4SLinus Torvalds 	},
4991da177e4SLinus Torvalds #endif
5001da177e4SLinus Torvalds #ifdef CONFIG_MAGIC_SYSRQ
5011da177e4SLinus Torvalds 	{
5021da177e4SLinus Torvalds 		.ctl_name	= KERN_SYSRQ,
5031da177e4SLinus Torvalds 		.procname	= "sysrq",
5045d6f647fSIngo Molnar 		.data		= &__sysrq_enabled,
5051da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5061da177e4SLinus Torvalds 		.mode		= 0644,
5071da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5081da177e4SLinus Torvalds 	},
5091da177e4SLinus Torvalds #endif
510d6f8ff73SRandy Dunlap #ifdef CONFIG_PROC_SYSCTL
5111da177e4SLinus Torvalds 	{
5121da177e4SLinus Torvalds 		.procname	= "cad_pid",
5139ec52099SCedric Le Goater 		.data		= NULL,
5141da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5151da177e4SLinus Torvalds 		.mode		= 0600,
5169ec52099SCedric Le Goater 		.proc_handler	= &proc_do_cad_pid,
5171da177e4SLinus Torvalds 	},
518d6f8ff73SRandy Dunlap #endif
5191da177e4SLinus Torvalds 	{
5201da177e4SLinus Torvalds 		.ctl_name	= KERN_MAX_THREADS,
5211da177e4SLinus Torvalds 		.procname	= "threads-max",
5221da177e4SLinus Torvalds 		.data		= &max_threads,
5231da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5241da177e4SLinus Torvalds 		.mode		= 0644,
5251da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5261da177e4SLinus Torvalds 	},
5271da177e4SLinus Torvalds 	{
5281da177e4SLinus Torvalds 		.ctl_name	= KERN_RANDOM,
5291da177e4SLinus Torvalds 		.procname	= "random",
5301da177e4SLinus Torvalds 		.mode		= 0555,
5311da177e4SLinus Torvalds 		.child		= random_table,
5321da177e4SLinus Torvalds 	},
5331da177e4SLinus Torvalds 	{
5341da177e4SLinus Torvalds 		.ctl_name	= KERN_OVERFLOWUID,
5351da177e4SLinus Torvalds 		.procname	= "overflowuid",
5361da177e4SLinus Torvalds 		.data		= &overflowuid,
5371da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5381da177e4SLinus Torvalds 		.mode		= 0644,
5391da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
5401da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
5411da177e4SLinus Torvalds 		.extra1		= &minolduid,
5421da177e4SLinus Torvalds 		.extra2		= &maxolduid,
5431da177e4SLinus Torvalds 	},
5441da177e4SLinus Torvalds 	{
5451da177e4SLinus Torvalds 		.ctl_name	= KERN_OVERFLOWGID,
5461da177e4SLinus Torvalds 		.procname	= "overflowgid",
5471da177e4SLinus Torvalds 		.data		= &overflowgid,
5481da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5491da177e4SLinus Torvalds 		.mode		= 0644,
5501da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
5511da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
5521da177e4SLinus Torvalds 		.extra1		= &minolduid,
5531da177e4SLinus Torvalds 		.extra2		= &maxolduid,
5541da177e4SLinus Torvalds 	},
555347a8dc3SMartin Schwidefsky #ifdef CONFIG_S390
5561da177e4SLinus Torvalds #ifdef CONFIG_MATHEMU
5571da177e4SLinus Torvalds 	{
5581da177e4SLinus Torvalds 		.ctl_name	= KERN_IEEE_EMULATION_WARNINGS,
5591da177e4SLinus Torvalds 		.procname	= "ieee_emulation_warnings",
5601da177e4SLinus Torvalds 		.data		= &sysctl_ieee_emulation_warnings,
5611da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5621da177e4SLinus Torvalds 		.mode		= 0644,
5631da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5641da177e4SLinus Torvalds 	},
5651da177e4SLinus Torvalds #endif
5661da177e4SLinus Torvalds #ifdef CONFIG_NO_IDLE_HZ
5671da177e4SLinus Torvalds 	{
5681da177e4SLinus Torvalds 		.ctl_name       = KERN_HZ_TIMER,
5691da177e4SLinus Torvalds 		.procname       = "hz_timer",
5701da177e4SLinus Torvalds 		.data           = &sysctl_hz_timer,
5711da177e4SLinus Torvalds 		.maxlen         = sizeof(int),
5721da177e4SLinus Torvalds 		.mode           = 0644,
5731da177e4SLinus Torvalds 		.proc_handler   = &proc_dointvec,
5741da177e4SLinus Torvalds 	},
5751da177e4SLinus Torvalds #endif
5761da177e4SLinus Torvalds 	{
5771da177e4SLinus Torvalds 		.ctl_name	= KERN_S390_USER_DEBUG_LOGGING,
5781da177e4SLinus Torvalds 		.procname	= "userprocess_debug",
5791da177e4SLinus Torvalds 		.data		= &sysctl_userprocess_debug,
5801da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
5811da177e4SLinus Torvalds 		.mode		= 0644,
5821da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
5831da177e4SLinus Torvalds 	},
5841da177e4SLinus Torvalds #endif
5851da177e4SLinus Torvalds 	{
5861da177e4SLinus Torvalds 		.ctl_name	= KERN_PIDMAX,
5871da177e4SLinus Torvalds 		.procname	= "pid_max",
5881da177e4SLinus Torvalds 		.data		= &pid_max,
5891da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
5901da177e4SLinus Torvalds 		.mode		= 0644,
5911da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
5921da177e4SLinus Torvalds 		.strategy	= sysctl_intvec,
5931da177e4SLinus Torvalds 		.extra1		= &pid_max_min,
5941da177e4SLinus Torvalds 		.extra2		= &pid_max_max,
5951da177e4SLinus Torvalds 	},
5961da177e4SLinus Torvalds 	{
5971da177e4SLinus Torvalds 		.ctl_name	= KERN_PANIC_ON_OOPS,
5981da177e4SLinus Torvalds 		.procname	= "panic_on_oops",
5991da177e4SLinus Torvalds 		.data		= &panic_on_oops,
6001da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6011da177e4SLinus Torvalds 		.mode		= 0644,
6021da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6031da177e4SLinus Torvalds 	},
6047ef3d2fdSJoe Perches #if defined CONFIG_PRINTK
6057ef3d2fdSJoe Perches 	{
6067ef3d2fdSJoe Perches 		.ctl_name	= KERN_PRINTK,
6077ef3d2fdSJoe Perches 		.procname	= "printk",
6087ef3d2fdSJoe Perches 		.data		= &console_loglevel,
6097ef3d2fdSJoe Perches 		.maxlen		= 4*sizeof(int),
6107ef3d2fdSJoe Perches 		.mode		= 0644,
6117ef3d2fdSJoe Perches 		.proc_handler	= &proc_dointvec,
6127ef3d2fdSJoe Perches 	},
6131da177e4SLinus Torvalds 	{
6141da177e4SLinus Torvalds 		.ctl_name	= KERN_PRINTK_RATELIMIT,
6151da177e4SLinus Torvalds 		.procname	= "printk_ratelimit",
6161da177e4SLinus Torvalds 		.data		= &printk_ratelimit_jiffies,
6171da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6181da177e4SLinus Torvalds 		.mode		= 0644,
6191da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_jiffies,
6201da177e4SLinus Torvalds 		.strategy	= &sysctl_jiffies,
6211da177e4SLinus Torvalds 	},
6221da177e4SLinus Torvalds 	{
6231da177e4SLinus Torvalds 		.ctl_name	= KERN_PRINTK_RATELIMIT_BURST,
6241da177e4SLinus Torvalds 		.procname	= "printk_ratelimit_burst",
6251da177e4SLinus Torvalds 		.data		= &printk_ratelimit_burst,
6261da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6271da177e4SLinus Torvalds 		.mode		= 0644,
6281da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6291da177e4SLinus Torvalds 	},
6307ef3d2fdSJoe Perches #endif
6311da177e4SLinus Torvalds 	{
6321da177e4SLinus Torvalds 		.ctl_name	= KERN_NGROUPS_MAX,
6331da177e4SLinus Torvalds 		.procname	= "ngroups_max",
6341da177e4SLinus Torvalds 		.data		= &ngroups_max,
6351da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6361da177e4SLinus Torvalds 		.mode		= 0444,
6371da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6381da177e4SLinus Torvalds 	},
6391da177e4SLinus Torvalds #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
6401da177e4SLinus Torvalds 	{
6411da177e4SLinus Torvalds 		.ctl_name       = KERN_UNKNOWN_NMI_PANIC,
6421da177e4SLinus Torvalds 		.procname       = "unknown_nmi_panic",
6431da177e4SLinus Torvalds 		.data           = &unknown_nmi_panic,
6441da177e4SLinus Torvalds 		.maxlen         = sizeof (int),
6451da177e4SLinus Torvalds 		.mode           = 0644,
6462fbe7b25SDon Zickus 		.proc_handler   = &proc_dointvec,
6471da177e4SLinus Torvalds 	},
648407984f1SDon Zickus 	{
649407984f1SDon Zickus 		.procname       = "nmi_watchdog",
650407984f1SDon Zickus 		.data           = &nmi_watchdog_enabled,
651407984f1SDon Zickus 		.maxlen         = sizeof (int),
652407984f1SDon Zickus 		.mode           = 0644,
653407984f1SDon Zickus 		.proc_handler   = &proc_nmi_enabled,
6541da177e4SLinus Torvalds 	},
6551da177e4SLinus Torvalds #endif
6561da177e4SLinus Torvalds #if defined(CONFIG_X86)
6571da177e4SLinus Torvalds 	{
6588da5addaSDon Zickus 		.ctl_name	= KERN_PANIC_ON_NMI,
6598da5addaSDon Zickus 		.procname	= "panic_on_unrecovered_nmi",
6608da5addaSDon Zickus 		.data		= &panic_on_unrecovered_nmi,
6618da5addaSDon Zickus 		.maxlen		= sizeof(int),
6628da5addaSDon Zickus 		.mode		= 0644,
6638da5addaSDon Zickus 		.proc_handler	= &proc_dointvec,
6648da5addaSDon Zickus 	},
6658da5addaSDon Zickus 	{
6661da177e4SLinus Torvalds 		.ctl_name	= KERN_BOOTLOADER_TYPE,
6671da177e4SLinus Torvalds 		.procname	= "bootloader_type",
6681da177e4SLinus Torvalds 		.data		= &bootloader_type,
6691da177e4SLinus Torvalds 		.maxlen		= sizeof (int),
6701da177e4SLinus Torvalds 		.mode		= 0444,
6711da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6721da177e4SLinus Torvalds 	},
6730741f4d2SChuck Ebbert 	{
6740741f4d2SChuck Ebbert 		.ctl_name	= CTL_UNNUMBERED,
6750741f4d2SChuck Ebbert 		.procname	= "kstack_depth_to_print",
6760741f4d2SChuck Ebbert 		.data		= &kstack_depth_to_print,
6770741f4d2SChuck Ebbert 		.maxlen		= sizeof(int),
6780741f4d2SChuck Ebbert 		.mode		= 0644,
6790741f4d2SChuck Ebbert 		.proc_handler	= &proc_dointvec,
6800741f4d2SChuck Ebbert 	},
6816e7c4025SIngo Molnar 	{
6826e7c4025SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
6836e7c4025SIngo Molnar 		.procname	= "io_delay_type",
6846e7c4025SIngo Molnar 		.data		= &io_delay_type,
6856e7c4025SIngo Molnar 		.maxlen		= sizeof(int),
6866e7c4025SIngo Molnar 		.mode		= 0644,
6876e7c4025SIngo Molnar 		.proc_handler	= &proc_dointvec,
6886e7c4025SIngo Molnar 	},
6891da177e4SLinus Torvalds #endif
6907a9166e3SLuke Yang #if defined(CONFIG_MMU)
6911da177e4SLinus Torvalds 	{
6921da177e4SLinus Torvalds 		.ctl_name	= KERN_RANDOMIZE,
6931da177e4SLinus Torvalds 		.procname	= "randomize_va_space",
6941da177e4SLinus Torvalds 		.data		= &randomize_va_space,
6951da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
6961da177e4SLinus Torvalds 		.mode		= 0644,
6971da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
6981da177e4SLinus Torvalds 	},
6997a9166e3SLuke Yang #endif
7000152fb37SMartin Schwidefsky #if defined(CONFIG_S390) && defined(CONFIG_SMP)
701951f22d5SMartin Schwidefsky 	{
702951f22d5SMartin Schwidefsky 		.ctl_name	= KERN_SPIN_RETRY,
703951f22d5SMartin Schwidefsky 		.procname	= "spin_retry",
704951f22d5SMartin Schwidefsky 		.data		= &spin_retry,
705951f22d5SMartin Schwidefsky 		.maxlen		= sizeof (int),
706951f22d5SMartin Schwidefsky 		.mode		= 0644,
707951f22d5SMartin Schwidefsky 		.proc_handler	= &proc_dointvec,
708951f22d5SMartin Schwidefsky 	},
709951f22d5SMartin Schwidefsky #endif
710673d5b43SLen Brown #if	defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
711c255d844SPavel Machek 	{
712c255d844SPavel Machek 		.procname	= "acpi_video_flags",
71377afcf78SPavel Machek 		.data		= &acpi_realmode_flags,
714c255d844SPavel Machek 		.maxlen		= sizeof (unsigned long),
715c255d844SPavel Machek 		.mode		= 0644,
7167f99f06fSStefan Seyfried 		.proc_handler	= &proc_doulongvec_minmax,
717c255d844SPavel Machek 	},
718c255d844SPavel Machek #endif
719d2b176edSJes Sorensen #ifdef CONFIG_IA64
720d2b176edSJes Sorensen 	{
721d2b176edSJes Sorensen 		.ctl_name	= KERN_IA64_UNALIGNED,
722d2b176edSJes Sorensen 		.procname	= "ignore-unaligned-usertrap",
723d2b176edSJes Sorensen 		.data		= &no_unaligned_warning,
724d2b176edSJes Sorensen 		.maxlen		= sizeof (int),
725d2b176edSJes Sorensen 	 	.mode		= 0644,
726d2b176edSJes Sorensen 		.proc_handler	= &proc_dointvec,
727d2b176edSJes Sorensen 	},
728d2b176edSJes Sorensen #endif
729c4f3b63fSRavikiran G Thirumalai #ifdef CONFIG_DETECT_SOFTLOCKUP
730c4f3b63fSRavikiran G Thirumalai 	{
731c4f3b63fSRavikiran G Thirumalai 		.ctl_name	= CTL_UNNUMBERED,
732*9c44bc03SIngo Molnar 		.procname	= "softlockup_panic",
733*9c44bc03SIngo Molnar 		.data		= &softlockup_panic,
734*9c44bc03SIngo Molnar 		.maxlen		= sizeof(int),
735*9c44bc03SIngo Molnar 		.mode		= 0644,
736*9c44bc03SIngo Molnar 		.proc_handler	= &proc_doulongvec_minmax,
737*9c44bc03SIngo Molnar 		.strategy	= &sysctl_intvec,
738*9c44bc03SIngo Molnar 		.extra1		= &zero,
739*9c44bc03SIngo Molnar 		.extra2		= &one,
740*9c44bc03SIngo Molnar 	},
741*9c44bc03SIngo Molnar 	{
742*9c44bc03SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
743c4f3b63fSRavikiran G Thirumalai 		.procname	= "softlockup_thresh",
744c4f3b63fSRavikiran G Thirumalai 		.data		= &softlockup_thresh,
74590739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
746c4f3b63fSRavikiran G Thirumalai 		.mode		= 0644,
74790739081SIngo Molnar 		.proc_handler	= &proc_doulongvec_minmax,
748c4f3b63fSRavikiran G Thirumalai 		.strategy	= &sysctl_intvec,
749c4f3b63fSRavikiran G Thirumalai 		.extra1		= &one,
750c4f3b63fSRavikiran G Thirumalai 		.extra2		= &sixty,
751c4f3b63fSRavikiran G Thirumalai 	},
75282a1fcb9SIngo Molnar 	{
75382a1fcb9SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
75482a1fcb9SIngo Molnar 		.procname	= "hung_task_check_count",
75582a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_check_count,
75690739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
75782a1fcb9SIngo Molnar 		.mode		= 0644,
75890739081SIngo Molnar 		.proc_handler	= &proc_doulongvec_minmax,
75982a1fcb9SIngo Molnar 		.strategy	= &sysctl_intvec,
76082a1fcb9SIngo Molnar 	},
76182a1fcb9SIngo Molnar 	{
76282a1fcb9SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
76382a1fcb9SIngo Molnar 		.procname	= "hung_task_timeout_secs",
76482a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_timeout_secs,
76590739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
76682a1fcb9SIngo Molnar 		.mode		= 0644,
76790739081SIngo Molnar 		.proc_handler	= &proc_doulongvec_minmax,
76882a1fcb9SIngo Molnar 		.strategy	= &sysctl_intvec,
76982a1fcb9SIngo Molnar 	},
77082a1fcb9SIngo Molnar 	{
77182a1fcb9SIngo Molnar 		.ctl_name	= CTL_UNNUMBERED,
77282a1fcb9SIngo Molnar 		.procname	= "hung_task_warnings",
77382a1fcb9SIngo Molnar 		.data		= &sysctl_hung_task_warnings,
77490739081SIngo Molnar 		.maxlen		= sizeof(unsigned long),
77582a1fcb9SIngo Molnar 		.mode		= 0644,
77690739081SIngo Molnar 		.proc_handler	= &proc_doulongvec_minmax,
77782a1fcb9SIngo Molnar 		.strategy	= &sysctl_intvec,
77882a1fcb9SIngo Molnar 	},
779c4f3b63fSRavikiran G Thirumalai #endif
780bebfa101SAndi Kleen #ifdef CONFIG_COMPAT
781bebfa101SAndi Kleen 	{
782bebfa101SAndi Kleen 		.ctl_name	= KERN_COMPAT_LOG,
783bebfa101SAndi Kleen 		.procname	= "compat-log",
784bebfa101SAndi Kleen 		.data		= &compat_log,
785bebfa101SAndi Kleen 		.maxlen		= sizeof (int),
786bebfa101SAndi Kleen 	 	.mode		= 0644,
787bebfa101SAndi Kleen 		.proc_handler	= &proc_dointvec,
788bebfa101SAndi Kleen 	},
789bebfa101SAndi Kleen #endif
79023f78d4aSIngo Molnar #ifdef CONFIG_RT_MUTEXES
79123f78d4aSIngo Molnar 	{
79223f78d4aSIngo Molnar 		.ctl_name	= KERN_MAX_LOCK_DEPTH,
79323f78d4aSIngo Molnar 		.procname	= "max_lock_depth",
79423f78d4aSIngo Molnar 		.data		= &max_lock_depth,
79523f78d4aSIngo Molnar 		.maxlen		= sizeof(int),
79623f78d4aSIngo Molnar 		.mode		= 0644,
79723f78d4aSIngo Molnar 		.proc_handler	= &proc_dointvec,
79823f78d4aSIngo Molnar 	},
79923f78d4aSIngo Molnar #endif
8005096add8SKees Cook #ifdef CONFIG_PROC_FS
8015096add8SKees Cook 	{
8025096add8SKees Cook 		.ctl_name       = CTL_UNNUMBERED,
8035096add8SKees Cook 		.procname       = "maps_protect",
8045096add8SKees Cook 		.data           = &maps_protect,
8055096add8SKees Cook 		.maxlen         = sizeof(int),
8065096add8SKees Cook 		.mode           = 0644,
8075096add8SKees Cook 		.proc_handler   = &proc_dointvec,
8085096add8SKees Cook 	},
8095096add8SKees Cook #endif
81010a0a8d4SJeremy Fitzhardinge 	{
81110a0a8d4SJeremy Fitzhardinge 		.ctl_name	= CTL_UNNUMBERED,
81210a0a8d4SJeremy Fitzhardinge 		.procname	= "poweroff_cmd",
81310a0a8d4SJeremy Fitzhardinge 		.data		= &poweroff_cmd,
81410a0a8d4SJeremy Fitzhardinge 		.maxlen		= POWEROFF_CMD_PATH_LEN,
81510a0a8d4SJeremy Fitzhardinge 		.mode		= 0644,
81610a0a8d4SJeremy Fitzhardinge 		.proc_handler	= &proc_dostring,
81710a0a8d4SJeremy Fitzhardinge 		.strategy	= &sysctl_string,
81810a0a8d4SJeremy Fitzhardinge 	},
8190b77f5bfSDavid Howells #ifdef CONFIG_KEYS
8200b77f5bfSDavid Howells 	{
8210b77f5bfSDavid Howells 		.ctl_name	= CTL_UNNUMBERED,
8220b77f5bfSDavid Howells 		.procname	= "keys",
8230b77f5bfSDavid Howells 		.mode		= 0555,
8240b77f5bfSDavid Howells 		.child		= key_sysctls,
8250b77f5bfSDavid Howells 	},
8260b77f5bfSDavid Howells #endif
827ed2c12f3SAndrew Morton /*
828ed2c12f3SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
829ed2c12f3SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
830ed2c12f3SAndrew Morton  */
8311da177e4SLinus Torvalds 	{ .ctl_name = 0 }
8321da177e4SLinus Torvalds };
8331da177e4SLinus Torvalds 
834d8217f07SEric W. Biederman static struct ctl_table vm_table[] = {
8351da177e4SLinus Torvalds 	{
8361da177e4SLinus Torvalds 		.ctl_name	= VM_OVERCOMMIT_MEMORY,
8371da177e4SLinus Torvalds 		.procname	= "overcommit_memory",
8381da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_memory,
8391da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_memory),
8401da177e4SLinus Torvalds 		.mode		= 0644,
8411da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
8421da177e4SLinus Torvalds 	},
8431da177e4SLinus Torvalds 	{
844fadd8fbdSKAMEZAWA Hiroyuki 		.ctl_name	= VM_PANIC_ON_OOM,
845fadd8fbdSKAMEZAWA Hiroyuki 		.procname	= "panic_on_oom",
846fadd8fbdSKAMEZAWA Hiroyuki 		.data		= &sysctl_panic_on_oom,
847fadd8fbdSKAMEZAWA Hiroyuki 		.maxlen		= sizeof(sysctl_panic_on_oom),
848fadd8fbdSKAMEZAWA Hiroyuki 		.mode		= 0644,
849fadd8fbdSKAMEZAWA Hiroyuki 		.proc_handler	= &proc_dointvec,
850fadd8fbdSKAMEZAWA Hiroyuki 	},
851fadd8fbdSKAMEZAWA Hiroyuki 	{
852fe071d7eSDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
853fe071d7eSDavid Rientjes 		.procname	= "oom_kill_allocating_task",
854fe071d7eSDavid Rientjes 		.data		= &sysctl_oom_kill_allocating_task,
855fe071d7eSDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_kill_allocating_task),
856fe071d7eSDavid Rientjes 		.mode		= 0644,
857fe071d7eSDavid Rientjes 		.proc_handler	= &proc_dointvec,
858fe071d7eSDavid Rientjes 	},
859fe071d7eSDavid Rientjes 	{
860fef1bdd6SDavid Rientjes 		.ctl_name	= CTL_UNNUMBERED,
861fef1bdd6SDavid Rientjes 		.procname	= "oom_dump_tasks",
862fef1bdd6SDavid Rientjes 		.data		= &sysctl_oom_dump_tasks,
863fef1bdd6SDavid Rientjes 		.maxlen		= sizeof(sysctl_oom_dump_tasks),
864fef1bdd6SDavid Rientjes 		.mode		= 0644,
865fef1bdd6SDavid Rientjes 		.proc_handler	= &proc_dointvec,
866fef1bdd6SDavid Rientjes 	},
867fef1bdd6SDavid Rientjes 	{
8681da177e4SLinus Torvalds 		.ctl_name	= VM_OVERCOMMIT_RATIO,
8691da177e4SLinus Torvalds 		.procname	= "overcommit_ratio",
8701da177e4SLinus Torvalds 		.data		= &sysctl_overcommit_ratio,
8711da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_overcommit_ratio),
8721da177e4SLinus Torvalds 		.mode		= 0644,
8731da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
8741da177e4SLinus Torvalds 	},
8751da177e4SLinus Torvalds 	{
8761da177e4SLinus Torvalds 		.ctl_name	= VM_PAGE_CLUSTER,
8771da177e4SLinus Torvalds 		.procname	= "page-cluster",
8781da177e4SLinus Torvalds 		.data		= &page_cluster,
8791da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
8801da177e4SLinus Torvalds 		.mode		= 0644,
8811da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
8821da177e4SLinus Torvalds 	},
8831da177e4SLinus Torvalds 	{
8841da177e4SLinus Torvalds 		.ctl_name	= VM_DIRTY_BACKGROUND,
8851da177e4SLinus Torvalds 		.procname	= "dirty_background_ratio",
8861da177e4SLinus Torvalds 		.data		= &dirty_background_ratio,
8871da177e4SLinus Torvalds 		.maxlen		= sizeof(dirty_background_ratio),
8881da177e4SLinus Torvalds 		.mode		= 0644,
8891da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
8901da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
8911da177e4SLinus Torvalds 		.extra1		= &zero,
8921da177e4SLinus Torvalds 		.extra2		= &one_hundred,
8931da177e4SLinus Torvalds 	},
8941da177e4SLinus Torvalds 	{
8951da177e4SLinus Torvalds 		.ctl_name	= VM_DIRTY_RATIO,
8961da177e4SLinus Torvalds 		.procname	= "dirty_ratio",
8971da177e4SLinus Torvalds 		.data		= &vm_dirty_ratio,
8981da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_dirty_ratio),
8991da177e4SLinus Torvalds 		.mode		= 0644,
90004fbfdc1SPeter Zijlstra 		.proc_handler	= &dirty_ratio_handler,
9011da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
9021da177e4SLinus Torvalds 		.extra1		= &zero,
9031da177e4SLinus Torvalds 		.extra2		= &one_hundred,
9041da177e4SLinus Torvalds 	},
9051da177e4SLinus Torvalds 	{
9061da177e4SLinus Torvalds 		.procname	= "dirty_writeback_centisecs",
907f6ef9438SBart Samwel 		.data		= &dirty_writeback_interval,
908f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_writeback_interval),
9091da177e4SLinus Torvalds 		.mode		= 0644,
9101da177e4SLinus Torvalds 		.proc_handler	= &dirty_writeback_centisecs_handler,
9111da177e4SLinus Torvalds 	},
9121da177e4SLinus Torvalds 	{
9131da177e4SLinus Torvalds 		.procname	= "dirty_expire_centisecs",
914f6ef9438SBart Samwel 		.data		= &dirty_expire_interval,
915f6ef9438SBart Samwel 		.maxlen		= sizeof(dirty_expire_interval),
9161da177e4SLinus Torvalds 		.mode		= 0644,
917f6ef9438SBart Samwel 		.proc_handler	= &proc_dointvec_userhz_jiffies,
9181da177e4SLinus Torvalds 	},
9191da177e4SLinus Torvalds 	{
9201da177e4SLinus Torvalds 		.ctl_name	= VM_NR_PDFLUSH_THREADS,
9211da177e4SLinus Torvalds 		.procname	= "nr_pdflush_threads",
9221da177e4SLinus Torvalds 		.data		= &nr_pdflush_threads,
9231da177e4SLinus Torvalds 		.maxlen		= sizeof nr_pdflush_threads,
9241da177e4SLinus Torvalds 		.mode		= 0444 /* read-only*/,
9251da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
9261da177e4SLinus Torvalds 	},
9271da177e4SLinus Torvalds 	{
9281da177e4SLinus Torvalds 		.ctl_name	= VM_SWAPPINESS,
9291da177e4SLinus Torvalds 		.procname	= "swappiness",
9301da177e4SLinus Torvalds 		.data		= &vm_swappiness,
9311da177e4SLinus Torvalds 		.maxlen		= sizeof(vm_swappiness),
9321da177e4SLinus Torvalds 		.mode		= 0644,
9331da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
9341da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
9351da177e4SLinus Torvalds 		.extra1		= &zero,
9361da177e4SLinus Torvalds 		.extra2		= &one_hundred,
9371da177e4SLinus Torvalds 	},
9381da177e4SLinus Torvalds #ifdef CONFIG_HUGETLB_PAGE
9391da177e4SLinus Torvalds 	 {
9401da177e4SLinus Torvalds 		.procname	= "nr_hugepages",
9411da177e4SLinus Torvalds 		.data		= &max_huge_pages,
9421da177e4SLinus Torvalds 		.maxlen		= sizeof(unsigned long),
9431da177e4SLinus Torvalds 		.mode		= 0644,
9441da177e4SLinus Torvalds 		.proc_handler	= &hugetlb_sysctl_handler,
9451da177e4SLinus Torvalds 		.extra1		= (void *)&hugetlb_zero,
9461da177e4SLinus Torvalds 		.extra2		= (void *)&hugetlb_infinity,
9471da177e4SLinus Torvalds 	 },
9481da177e4SLinus Torvalds 	 {
9491da177e4SLinus Torvalds 		.ctl_name	= VM_HUGETLB_GROUP,
9501da177e4SLinus Torvalds 		.procname	= "hugetlb_shm_group",
9511da177e4SLinus Torvalds 		.data		= &sysctl_hugetlb_shm_group,
9521da177e4SLinus Torvalds 		.maxlen		= sizeof(gid_t),
9531da177e4SLinus Torvalds 		.mode		= 0644,
9541da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
9551da177e4SLinus Torvalds 	 },
956396faf03SMel Gorman 	 {
957396faf03SMel Gorman 		.ctl_name	= CTL_UNNUMBERED,
958396faf03SMel Gorman 		.procname	= "hugepages_treat_as_movable",
959396faf03SMel Gorman 		.data		= &hugepages_treat_as_movable,
960396faf03SMel Gorman 		.maxlen		= sizeof(int),
961396faf03SMel Gorman 		.mode		= 0644,
962396faf03SMel Gorman 		.proc_handler	= &hugetlb_treat_movable_handler,
963396faf03SMel Gorman 	},
96454f9f80dSAdam Litke 	{
96554f9f80dSAdam Litke 		.ctl_name	= CTL_UNNUMBERED,
966d1c3fb1fSNishanth Aravamudan 		.procname	= "nr_overcommit_hugepages",
967064d9efeSNishanth Aravamudan 		.data		= &sysctl_overcommit_huge_pages,
968064d9efeSNishanth Aravamudan 		.maxlen		= sizeof(sysctl_overcommit_huge_pages),
969d1c3fb1fSNishanth Aravamudan 		.mode		= 0644,
970a3d0c6aaSNishanth Aravamudan 		.proc_handler	= &hugetlb_overcommit_handler,
971d1c3fb1fSNishanth Aravamudan 	},
9721da177e4SLinus Torvalds #endif
9731da177e4SLinus Torvalds 	{
9741da177e4SLinus Torvalds 		.ctl_name	= VM_LOWMEM_RESERVE_RATIO,
9751da177e4SLinus Torvalds 		.procname	= "lowmem_reserve_ratio",
9761da177e4SLinus Torvalds 		.data		= &sysctl_lowmem_reserve_ratio,
9771da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_lowmem_reserve_ratio),
9781da177e4SLinus Torvalds 		.mode		= 0644,
9791da177e4SLinus Torvalds 		.proc_handler	= &lowmem_reserve_ratio_sysctl_handler,
9801da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
9811da177e4SLinus Torvalds 	},
9821da177e4SLinus Torvalds 	{
9839d0243bcSAndrew Morton 		.ctl_name	= VM_DROP_PAGECACHE,
9849d0243bcSAndrew Morton 		.procname	= "drop_caches",
9859d0243bcSAndrew Morton 		.data		= &sysctl_drop_caches,
9869d0243bcSAndrew Morton 		.maxlen		= sizeof(int),
9879d0243bcSAndrew Morton 		.mode		= 0644,
9889d0243bcSAndrew Morton 		.proc_handler	= drop_caches_sysctl_handler,
9899d0243bcSAndrew Morton 		.strategy	= &sysctl_intvec,
9909d0243bcSAndrew Morton 	},
9919d0243bcSAndrew Morton 	{
9921da177e4SLinus Torvalds 		.ctl_name	= VM_MIN_FREE_KBYTES,
9931da177e4SLinus Torvalds 		.procname	= "min_free_kbytes",
9941da177e4SLinus Torvalds 		.data		= &min_free_kbytes,
9951da177e4SLinus Torvalds 		.maxlen		= sizeof(min_free_kbytes),
9961da177e4SLinus Torvalds 		.mode		= 0644,
9971da177e4SLinus Torvalds 		.proc_handler	= &min_free_kbytes_sysctl_handler,
9981da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
9991da177e4SLinus Torvalds 		.extra1		= &zero,
10001da177e4SLinus Torvalds 	},
10018ad4b1fbSRohit Seth 	{
10028ad4b1fbSRohit Seth 		.ctl_name	= VM_PERCPU_PAGELIST_FRACTION,
10038ad4b1fbSRohit Seth 		.procname	= "percpu_pagelist_fraction",
10048ad4b1fbSRohit Seth 		.data		= &percpu_pagelist_fraction,
10058ad4b1fbSRohit Seth 		.maxlen		= sizeof(percpu_pagelist_fraction),
10068ad4b1fbSRohit Seth 		.mode		= 0644,
10078ad4b1fbSRohit Seth 		.proc_handler	= &percpu_pagelist_fraction_sysctl_handler,
10088ad4b1fbSRohit Seth 		.strategy	= &sysctl_intvec,
10098ad4b1fbSRohit Seth 		.extra1		= &min_percpu_pagelist_fract,
10108ad4b1fbSRohit Seth 	},
10111da177e4SLinus Torvalds #ifdef CONFIG_MMU
10121da177e4SLinus Torvalds 	{
10131da177e4SLinus Torvalds 		.ctl_name	= VM_MAX_MAP_COUNT,
10141da177e4SLinus Torvalds 		.procname	= "max_map_count",
10151da177e4SLinus Torvalds 		.data		= &sysctl_max_map_count,
10161da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_max_map_count),
10171da177e4SLinus Torvalds 		.mode		= 0644,
10181da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec
10191da177e4SLinus Torvalds 	},
10201da177e4SLinus Torvalds #endif
10211da177e4SLinus Torvalds 	{
10221da177e4SLinus Torvalds 		.ctl_name	= VM_LAPTOP_MODE,
10231da177e4SLinus Torvalds 		.procname	= "laptop_mode",
10241da177e4SLinus Torvalds 		.data		= &laptop_mode,
10251da177e4SLinus Torvalds 		.maxlen		= sizeof(laptop_mode),
10261da177e4SLinus Torvalds 		.mode		= 0644,
1027ed5b43f1SBart Samwel 		.proc_handler	= &proc_dointvec_jiffies,
1028ed5b43f1SBart Samwel 		.strategy	= &sysctl_jiffies,
10291da177e4SLinus Torvalds 	},
10301da177e4SLinus Torvalds 	{
10311da177e4SLinus Torvalds 		.ctl_name	= VM_BLOCK_DUMP,
10321da177e4SLinus Torvalds 		.procname	= "block_dump",
10331da177e4SLinus Torvalds 		.data		= &block_dump,
10341da177e4SLinus Torvalds 		.maxlen		= sizeof(block_dump),
10351da177e4SLinus Torvalds 		.mode		= 0644,
10361da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10371da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
10381da177e4SLinus Torvalds 		.extra1		= &zero,
10391da177e4SLinus Torvalds 	},
10401da177e4SLinus Torvalds 	{
10411da177e4SLinus Torvalds 		.ctl_name	= VM_VFS_CACHE_PRESSURE,
10421da177e4SLinus Torvalds 		.procname	= "vfs_cache_pressure",
10431da177e4SLinus Torvalds 		.data		= &sysctl_vfs_cache_pressure,
10441da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_vfs_cache_pressure),
10451da177e4SLinus Torvalds 		.mode		= 0644,
10461da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10471da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
10481da177e4SLinus Torvalds 		.extra1		= &zero,
10491da177e4SLinus Torvalds 	},
10501da177e4SLinus Torvalds #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
10511da177e4SLinus Torvalds 	{
10521da177e4SLinus Torvalds 		.ctl_name	= VM_LEGACY_VA_LAYOUT,
10531da177e4SLinus Torvalds 		.procname	= "legacy_va_layout",
10541da177e4SLinus Torvalds 		.data		= &sysctl_legacy_va_layout,
10551da177e4SLinus Torvalds 		.maxlen		= sizeof(sysctl_legacy_va_layout),
10561da177e4SLinus Torvalds 		.mode		= 0644,
10571da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
10581da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
10591da177e4SLinus Torvalds 		.extra1		= &zero,
10601da177e4SLinus Torvalds 	},
10611da177e4SLinus Torvalds #endif
10621743660bSChristoph Lameter #ifdef CONFIG_NUMA
10631743660bSChristoph Lameter 	{
10641743660bSChristoph Lameter 		.ctl_name	= VM_ZONE_RECLAIM_MODE,
10651743660bSChristoph Lameter 		.procname	= "zone_reclaim_mode",
10661743660bSChristoph Lameter 		.data		= &zone_reclaim_mode,
10671743660bSChristoph Lameter 		.maxlen		= sizeof(zone_reclaim_mode),
10681743660bSChristoph Lameter 		.mode		= 0644,
10691743660bSChristoph Lameter 		.proc_handler	= &proc_dointvec,
1070c84db23cSChristoph Lameter 		.strategy	= &sysctl_intvec,
1071c84db23cSChristoph Lameter 		.extra1		= &zero,
10721743660bSChristoph Lameter 	},
10739614634fSChristoph Lameter 	{
10749614634fSChristoph Lameter 		.ctl_name	= VM_MIN_UNMAPPED,
10759614634fSChristoph Lameter 		.procname	= "min_unmapped_ratio",
10769614634fSChristoph Lameter 		.data		= &sysctl_min_unmapped_ratio,
10779614634fSChristoph Lameter 		.maxlen		= sizeof(sysctl_min_unmapped_ratio),
10789614634fSChristoph Lameter 		.mode		= 0644,
10799614634fSChristoph Lameter 		.proc_handler	= &sysctl_min_unmapped_ratio_sysctl_handler,
10809614634fSChristoph Lameter 		.strategy	= &sysctl_intvec,
10819614634fSChristoph Lameter 		.extra1		= &zero,
10829614634fSChristoph Lameter 		.extra2		= &one_hundred,
10839614634fSChristoph Lameter 	},
10840ff38490SChristoph Lameter 	{
10850ff38490SChristoph Lameter 		.ctl_name	= VM_MIN_SLAB,
10860ff38490SChristoph Lameter 		.procname	= "min_slab_ratio",
10870ff38490SChristoph Lameter 		.data		= &sysctl_min_slab_ratio,
10880ff38490SChristoph Lameter 		.maxlen		= sizeof(sysctl_min_slab_ratio),
10890ff38490SChristoph Lameter 		.mode		= 0644,
10900ff38490SChristoph Lameter 		.proc_handler	= &sysctl_min_slab_ratio_sysctl_handler,
10910ff38490SChristoph Lameter 		.strategy	= &sysctl_intvec,
10920ff38490SChristoph Lameter 		.extra1		= &zero,
10930ff38490SChristoph Lameter 		.extra2		= &one_hundred,
10940ff38490SChristoph Lameter 	},
10951743660bSChristoph Lameter #endif
109677461ab3SChristoph Lameter #ifdef CONFIG_SMP
109777461ab3SChristoph Lameter 	{
109877461ab3SChristoph Lameter 		.ctl_name	= CTL_UNNUMBERED,
109977461ab3SChristoph Lameter 		.procname	= "stat_interval",
110077461ab3SChristoph Lameter 		.data		= &sysctl_stat_interval,
110177461ab3SChristoph Lameter 		.maxlen		= sizeof(sysctl_stat_interval),
110277461ab3SChristoph Lameter 		.mode		= 0644,
110377461ab3SChristoph Lameter 		.proc_handler	= &proc_dointvec_jiffies,
110477461ab3SChristoph Lameter 		.strategy	= &sysctl_jiffies,
110577461ab3SChristoph Lameter 	},
110677461ab3SChristoph Lameter #endif
1107ed032189SEric Paris #ifdef CONFIG_SECURITY
1108ed032189SEric Paris 	{
1109ed032189SEric Paris 		.ctl_name	= CTL_UNNUMBERED,
1110ed032189SEric Paris 		.procname	= "mmap_min_addr",
1111ed032189SEric Paris 		.data		= &mmap_min_addr,
1112ed032189SEric Paris 		.maxlen         = sizeof(unsigned long),
1113ed032189SEric Paris 		.mode		= 0644,
1114ed032189SEric Paris 		.proc_handler	= &proc_doulongvec_minmax,
1115ed032189SEric Paris 	},
11168daec965SLee Schermerhorn #endif
1117f0c0b2b8SKAMEZAWA Hiroyuki #ifdef CONFIG_NUMA
1118f0c0b2b8SKAMEZAWA Hiroyuki 	{
1119f0c0b2b8SKAMEZAWA Hiroyuki 		.ctl_name	= CTL_UNNUMBERED,
1120f0c0b2b8SKAMEZAWA Hiroyuki 		.procname	= "numa_zonelist_order",
1121f0c0b2b8SKAMEZAWA Hiroyuki 		.data		= &numa_zonelist_order,
1122f0c0b2b8SKAMEZAWA Hiroyuki 		.maxlen		= NUMA_ZONELIST_ORDER_LEN,
1123f0c0b2b8SKAMEZAWA Hiroyuki 		.mode		= 0644,
1124f0c0b2b8SKAMEZAWA Hiroyuki 		.proc_handler	= &numa_zonelist_order_handler,
1125f0c0b2b8SKAMEZAWA Hiroyuki 		.strategy	= &sysctl_string,
1126f0c0b2b8SKAMEZAWA Hiroyuki 	},
1127f0c0b2b8SKAMEZAWA Hiroyuki #endif
11282b8232ceSAl Viro #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
11295c36e657SPaul Mundt    (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1130e6e5494cSIngo Molnar 	{
1131e6e5494cSIngo Molnar 		.ctl_name	= VM_VDSO_ENABLED,
1132e6e5494cSIngo Molnar 		.procname	= "vdso_enabled",
1133e6e5494cSIngo Molnar 		.data		= &vdso_enabled,
1134e6e5494cSIngo Molnar 		.maxlen		= sizeof(vdso_enabled),
1135e6e5494cSIngo Molnar 		.mode		= 0644,
1136e6e5494cSIngo Molnar 		.proc_handler	= &proc_dointvec,
1137e6e5494cSIngo Molnar 		.strategy	= &sysctl_intvec,
1138e6e5494cSIngo Molnar 		.extra1		= &zero,
1139e6e5494cSIngo Molnar 	},
1140e6e5494cSIngo Molnar #endif
1141195cf453SBron Gondwana #ifdef CONFIG_HIGHMEM
1142195cf453SBron Gondwana 	{
1143195cf453SBron Gondwana 		.ctl_name	= CTL_UNNUMBERED,
1144195cf453SBron Gondwana 		.procname	= "highmem_is_dirtyable",
1145195cf453SBron Gondwana 		.data		= &vm_highmem_is_dirtyable,
1146195cf453SBron Gondwana 		.maxlen		= sizeof(vm_highmem_is_dirtyable),
1147195cf453SBron Gondwana 		.mode		= 0644,
1148195cf453SBron Gondwana 		.proc_handler	= &proc_dointvec_minmax,
1149195cf453SBron Gondwana 		.strategy	= &sysctl_intvec,
1150195cf453SBron Gondwana 		.extra1		= &zero,
1151195cf453SBron Gondwana 		.extra2		= &one,
1152195cf453SBron Gondwana 	},
1153195cf453SBron Gondwana #endif
11542be7fe07SAndrew Morton /*
11552be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
11562be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
11572be7fe07SAndrew Morton  */
11581da177e4SLinus Torvalds 	{ .ctl_name = 0 }
11591da177e4SLinus Torvalds };
11601da177e4SLinus Torvalds 
11612abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1162d8217f07SEric W. Biederman static struct ctl_table binfmt_misc_table[] = {
11632abc26fcSEric W. Biederman 	{ .ctl_name = 0 }
11642abc26fcSEric W. Biederman };
11652abc26fcSEric W. Biederman #endif
11662abc26fcSEric W. Biederman 
1167d8217f07SEric W. Biederman static struct ctl_table fs_table[] = {
11681da177e4SLinus Torvalds 	{
11691da177e4SLinus Torvalds 		.ctl_name	= FS_NRINODE,
11701da177e4SLinus Torvalds 		.procname	= "inode-nr",
11711da177e4SLinus Torvalds 		.data		= &inodes_stat,
11721da177e4SLinus Torvalds 		.maxlen		= 2*sizeof(int),
11731da177e4SLinus Torvalds 		.mode		= 0444,
11741da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
11751da177e4SLinus Torvalds 	},
11761da177e4SLinus Torvalds 	{
11771da177e4SLinus Torvalds 		.ctl_name	= FS_STATINODE,
11781da177e4SLinus Torvalds 		.procname	= "inode-state",
11791da177e4SLinus Torvalds 		.data		= &inodes_stat,
11801da177e4SLinus Torvalds 		.maxlen		= 7*sizeof(int),
11811da177e4SLinus Torvalds 		.mode		= 0444,
11821da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
11831da177e4SLinus Torvalds 	},
11841da177e4SLinus Torvalds 	{
11851da177e4SLinus Torvalds 		.procname	= "file-nr",
11861da177e4SLinus Torvalds 		.data		= &files_stat,
11871da177e4SLinus Torvalds 		.maxlen		= 3*sizeof(int),
11881da177e4SLinus Torvalds 		.mode		= 0444,
1189529bf6beSDipankar Sarma 		.proc_handler	= &proc_nr_files,
11901da177e4SLinus Torvalds 	},
11911da177e4SLinus Torvalds 	{
11921da177e4SLinus Torvalds 		.ctl_name	= FS_MAXFILE,
11931da177e4SLinus Torvalds 		.procname	= "file-max",
11941da177e4SLinus Torvalds 		.data		= &files_stat.max_files,
11951da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
11961da177e4SLinus Torvalds 		.mode		= 0644,
11971da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
11981da177e4SLinus Torvalds 	},
11991da177e4SLinus Torvalds 	{
12009cfe015aSEric Dumazet 		.ctl_name	= CTL_UNNUMBERED,
12019cfe015aSEric Dumazet 		.procname	= "nr_open",
12029cfe015aSEric Dumazet 		.data		= &sysctl_nr_open,
12039cfe015aSEric Dumazet 		.maxlen		= sizeof(int),
12049cfe015aSEric Dumazet 		.mode		= 0644,
1205eceea0b3SAl Viro 		.proc_handler	= &proc_dointvec_minmax,
1206eceea0b3SAl Viro 		.extra1		= &sysctl_nr_open_min,
1207eceea0b3SAl Viro 		.extra2		= &sysctl_nr_open_max,
12089cfe015aSEric Dumazet 	},
12099cfe015aSEric Dumazet 	{
12101da177e4SLinus Torvalds 		.ctl_name	= FS_DENTRY,
12111da177e4SLinus Torvalds 		.procname	= "dentry-state",
12121da177e4SLinus Torvalds 		.data		= &dentry_stat,
12131da177e4SLinus Torvalds 		.maxlen		= 6*sizeof(int),
12141da177e4SLinus Torvalds 		.mode		= 0444,
12151da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
12161da177e4SLinus Torvalds 	},
12171da177e4SLinus Torvalds 	{
12181da177e4SLinus Torvalds 		.ctl_name	= FS_OVERFLOWUID,
12191da177e4SLinus Torvalds 		.procname	= "overflowuid",
12201da177e4SLinus Torvalds 		.data		= &fs_overflowuid,
12211da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
12221da177e4SLinus Torvalds 		.mode		= 0644,
12231da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
12241da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
12251da177e4SLinus Torvalds 		.extra1		= &minolduid,
12261da177e4SLinus Torvalds 		.extra2		= &maxolduid,
12271da177e4SLinus Torvalds 	},
12281da177e4SLinus Torvalds 	{
12291da177e4SLinus Torvalds 		.ctl_name	= FS_OVERFLOWGID,
12301da177e4SLinus Torvalds 		.procname	= "overflowgid",
12311da177e4SLinus Torvalds 		.data		= &fs_overflowgid,
12321da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
12331da177e4SLinus Torvalds 		.mode		= 0644,
12341da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec_minmax,
12351da177e4SLinus Torvalds 		.strategy	= &sysctl_intvec,
12361da177e4SLinus Torvalds 		.extra1		= &minolduid,
12371da177e4SLinus Torvalds 		.extra2		= &maxolduid,
12381da177e4SLinus Torvalds 	},
12391da177e4SLinus Torvalds 	{
12401da177e4SLinus Torvalds 		.ctl_name	= FS_LEASES,
12411da177e4SLinus Torvalds 		.procname	= "leases-enable",
12421da177e4SLinus Torvalds 		.data		= &leases_enable,
12431da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
12441da177e4SLinus Torvalds 		.mode		= 0644,
12451da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
12461da177e4SLinus Torvalds 	},
12471da177e4SLinus Torvalds #ifdef CONFIG_DNOTIFY
12481da177e4SLinus Torvalds 	{
12491da177e4SLinus Torvalds 		.ctl_name	= FS_DIR_NOTIFY,
12501da177e4SLinus Torvalds 		.procname	= "dir-notify-enable",
12511da177e4SLinus Torvalds 		.data		= &dir_notify_enable,
12521da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
12531da177e4SLinus Torvalds 		.mode		= 0644,
12541da177e4SLinus Torvalds 		.proc_handler	= &proc_dointvec,
12551da177e4SLinus Torvalds 	},
12561da177e4SLinus Torvalds #endif
12571da177e4SLinus Torvalds #ifdef CONFIG_MMU
12581da177e4SLinus Torvalds 	{
12591da177e4SLinus Torvalds 		.ctl_name	= FS_LEASE_TIME,
12601da177e4SLinus Torvalds 		.procname	= "lease-break-time",
12611da177e4SLinus Torvalds 		.data		= &lease_break_time,
12621da177e4SLinus Torvalds 		.maxlen		= sizeof(int),
12631da177e4SLinus Torvalds 		.mode		= 0644,
126476fdbb25SKawai, Hidehiro 		.proc_handler	= &proc_dointvec_minmax,
126576fdbb25SKawai, Hidehiro 		.strategy	= &sysctl_intvec,
126676fdbb25SKawai, Hidehiro 		.extra1		= &zero,
126776fdbb25SKawai, Hidehiro 		.extra2		= &two,
12681da177e4SLinus Torvalds 	},
12691da177e4SLinus Torvalds 	{
12701da177e4SLinus Torvalds 		.procname	= "aio-nr",
12711da177e4SLinus Torvalds 		.data		= &aio_nr,
12721da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_nr),
12731da177e4SLinus Torvalds 		.mode		= 0444,
1274d55b5fdaSZach Brown 		.proc_handler	= &proc_doulongvec_minmax,
12751da177e4SLinus Torvalds 	},
12761da177e4SLinus Torvalds 	{
12771da177e4SLinus Torvalds 		.procname	= "aio-max-nr",
12781da177e4SLinus Torvalds 		.data		= &aio_max_nr,
12791da177e4SLinus Torvalds 		.maxlen		= sizeof(aio_max_nr),
12801da177e4SLinus Torvalds 		.mode		= 0644,
1281d55b5fdaSZach Brown 		.proc_handler	= &proc_doulongvec_minmax,
12821da177e4SLinus Torvalds 	},
12832d9048e2SAmy Griffis #ifdef CONFIG_INOTIFY_USER
12840399cb08SRobert Love 	{
12850399cb08SRobert Love 		.ctl_name	= FS_INOTIFY,
12860399cb08SRobert Love 		.procname	= "inotify",
12870399cb08SRobert Love 		.mode		= 0555,
12880399cb08SRobert Love 		.child		= inotify_table,
12890399cb08SRobert Love 	},
12900399cb08SRobert Love #endif
12911da177e4SLinus Torvalds #endif
1292d6e71144SAlan Cox 	{
1293d6e71144SAlan Cox 		.ctl_name	= KERN_SETUID_DUMPABLE,
1294d6e71144SAlan Cox 		.procname	= "suid_dumpable",
1295d6e71144SAlan Cox 		.data		= &suid_dumpable,
1296d6e71144SAlan Cox 		.maxlen		= sizeof(int),
1297d6e71144SAlan Cox 		.mode		= 0644,
1298d6e71144SAlan Cox 		.proc_handler	= &proc_dointvec,
1299d6e71144SAlan Cox 	},
13002abc26fcSEric W. Biederman #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
13012abc26fcSEric W. Biederman 	{
13022abc26fcSEric W. Biederman 		.ctl_name	= CTL_UNNUMBERED,
13032abc26fcSEric W. Biederman 		.procname	= "binfmt_misc",
13042abc26fcSEric W. Biederman 		.mode		= 0555,
13052abc26fcSEric W. Biederman 		.child		= binfmt_misc_table,
13062abc26fcSEric W. Biederman 	},
13072abc26fcSEric W. Biederman #endif
13082be7fe07SAndrew Morton /*
13092be7fe07SAndrew Morton  * NOTE: do not add new entries to this table unless you have read
13102be7fe07SAndrew Morton  * Documentation/sysctl/ctl_unnumbered.txt
13112be7fe07SAndrew Morton  */
13121da177e4SLinus Torvalds 	{ .ctl_name = 0 }
13131da177e4SLinus Torvalds };
13141da177e4SLinus Torvalds 
1315d8217f07SEric W. Biederman static struct ctl_table debug_table[] = {
1316d0c3d534SOlof Johansson #if defined(CONFIG_X86) || defined(CONFIG_PPC)
1317abd4f750SMasoud Asgharifard Sharbiani 	{
1318abd4f750SMasoud Asgharifard Sharbiani 		.ctl_name	= CTL_UNNUMBERED,
1319abd4f750SMasoud Asgharifard Sharbiani 		.procname	= "exception-trace",
1320abd4f750SMasoud Asgharifard Sharbiani 		.data		= &show_unhandled_signals,
1321abd4f750SMasoud Asgharifard Sharbiani 		.maxlen		= sizeof(int),
1322abd4f750SMasoud Asgharifard Sharbiani 		.mode		= 0644,
1323abd4f750SMasoud Asgharifard Sharbiani 		.proc_handler	= proc_dointvec
1324abd4f750SMasoud Asgharifard Sharbiani 	},
1325abd4f750SMasoud Asgharifard Sharbiani #endif
13261da177e4SLinus Torvalds 	{ .ctl_name = 0 }
13271da177e4SLinus Torvalds };
13281da177e4SLinus Torvalds 
1329d8217f07SEric W. Biederman static struct ctl_table dev_table[] = {
13301da177e4SLinus Torvalds 	{ .ctl_name = 0 }
13311da177e4SLinus Torvalds };
13321da177e4SLinus Torvalds 
1333330d57fbSAl Viro static DEFINE_SPINLOCK(sysctl_lock);
1334330d57fbSAl Viro 
1335330d57fbSAl Viro /* called under sysctl_lock */
1336330d57fbSAl Viro static int use_table(struct ctl_table_header *p)
1337330d57fbSAl Viro {
1338330d57fbSAl Viro 	if (unlikely(p->unregistering))
1339330d57fbSAl Viro 		return 0;
1340330d57fbSAl Viro 	p->used++;
1341330d57fbSAl Viro 	return 1;
1342330d57fbSAl Viro }
1343330d57fbSAl Viro 
1344330d57fbSAl Viro /* called under sysctl_lock */
1345330d57fbSAl Viro static void unuse_table(struct ctl_table_header *p)
1346330d57fbSAl Viro {
1347330d57fbSAl Viro 	if (!--p->used)
1348330d57fbSAl Viro 		if (unlikely(p->unregistering))
1349330d57fbSAl Viro 			complete(p->unregistering);
1350330d57fbSAl Viro }
1351330d57fbSAl Viro 
1352330d57fbSAl Viro /* called under sysctl_lock, will reacquire if has to wait */
1353330d57fbSAl Viro static void start_unregistering(struct ctl_table_header *p)
1354330d57fbSAl Viro {
1355330d57fbSAl Viro 	/*
1356330d57fbSAl Viro 	 * if p->used is 0, nobody will ever touch that entry again;
1357330d57fbSAl Viro 	 * we'll eliminate all paths to it before dropping sysctl_lock
1358330d57fbSAl Viro 	 */
1359330d57fbSAl Viro 	if (unlikely(p->used)) {
1360330d57fbSAl Viro 		struct completion wait;
1361330d57fbSAl Viro 		init_completion(&wait);
1362330d57fbSAl Viro 		p->unregistering = &wait;
1363330d57fbSAl Viro 		spin_unlock(&sysctl_lock);
1364330d57fbSAl Viro 		wait_for_completion(&wait);
1365330d57fbSAl Viro 		spin_lock(&sysctl_lock);
1366330d57fbSAl Viro 	}
1367330d57fbSAl Viro 	/*
1368330d57fbSAl Viro 	 * do not remove from the list until nobody holds it; walking the
1369330d57fbSAl Viro 	 * list in do_sysctl() relies on that.
1370330d57fbSAl Viro 	 */
1371330d57fbSAl Viro 	list_del_init(&p->ctl_entry);
1372330d57fbSAl Viro }
1373330d57fbSAl Viro 
1374805b5d5eSEric W. Biederman void sysctl_head_finish(struct ctl_table_header *head)
1375805b5d5eSEric W. Biederman {
1376805b5d5eSEric W. Biederman 	if (!head)
1377805b5d5eSEric W. Biederman 		return;
1378805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1379805b5d5eSEric W. Biederman 	unuse_table(head);
1380805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1381805b5d5eSEric W. Biederman }
1382805b5d5eSEric W. Biederman 
1383e51b6ba0SEric W. Biederman static struct list_head *
1384e51b6ba0SEric W. Biederman lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
1385805b5d5eSEric W. Biederman {
1386e51b6ba0SEric W. Biederman 	struct list_head *header_list;
1387e51b6ba0SEric W. Biederman 	header_list = &root->header_list;
1388e51b6ba0SEric W. Biederman 	if (root->lookup)
1389e51b6ba0SEric W. Biederman 		header_list = root->lookup(root, namespaces);
1390e51b6ba0SEric W. Biederman 	return header_list;
1391e51b6ba0SEric W. Biederman }
1392e51b6ba0SEric W. Biederman 
1393e51b6ba0SEric W. Biederman struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1394e51b6ba0SEric W. Biederman 					    struct ctl_table_header *prev)
1395e51b6ba0SEric W. Biederman {
1396e51b6ba0SEric W. Biederman 	struct ctl_table_root *root;
1397e51b6ba0SEric W. Biederman 	struct list_head *header_list;
1398805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1399805b5d5eSEric W. Biederman 	struct list_head *tmp;
1400e51b6ba0SEric W. Biederman 
1401805b5d5eSEric W. Biederman 	spin_lock(&sysctl_lock);
1402805b5d5eSEric W. Biederman 	if (prev) {
1403e51b6ba0SEric W. Biederman 		head = prev;
1404805b5d5eSEric W. Biederman 		tmp = &prev->ctl_entry;
1405805b5d5eSEric W. Biederman 		unuse_table(prev);
1406805b5d5eSEric W. Biederman 		goto next;
1407805b5d5eSEric W. Biederman 	}
1408805b5d5eSEric W. Biederman 	tmp = &root_table_header.ctl_entry;
1409805b5d5eSEric W. Biederman 	for (;;) {
1410805b5d5eSEric W. Biederman 		head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1411805b5d5eSEric W. Biederman 
1412805b5d5eSEric W. Biederman 		if (!use_table(head))
1413805b5d5eSEric W. Biederman 			goto next;
1414805b5d5eSEric W. Biederman 		spin_unlock(&sysctl_lock);
1415805b5d5eSEric W. Biederman 		return head;
1416805b5d5eSEric W. Biederman 	next:
1417e51b6ba0SEric W. Biederman 		root = head->root;
1418805b5d5eSEric W. Biederman 		tmp = tmp->next;
1419e51b6ba0SEric W. Biederman 		header_list = lookup_header_list(root, namespaces);
1420e51b6ba0SEric W. Biederman 		if (tmp != header_list)
1421e51b6ba0SEric W. Biederman 			continue;
1422e51b6ba0SEric W. Biederman 
1423e51b6ba0SEric W. Biederman 		do {
1424e51b6ba0SEric W. Biederman 			root = list_entry(root->root_list.next,
1425e51b6ba0SEric W. Biederman 					struct ctl_table_root, root_list);
1426e51b6ba0SEric W. Biederman 			if (root == &sysctl_table_root)
1427e51b6ba0SEric W. Biederman 				goto out;
1428e51b6ba0SEric W. Biederman 			header_list = lookup_header_list(root, namespaces);
1429e51b6ba0SEric W. Biederman 		} while (list_empty(header_list));
1430e51b6ba0SEric W. Biederman 		tmp = header_list->next;
1431805b5d5eSEric W. Biederman 	}
1432e51b6ba0SEric W. Biederman out:
1433805b5d5eSEric W. Biederman 	spin_unlock(&sysctl_lock);
1434805b5d5eSEric W. Biederman 	return NULL;
1435805b5d5eSEric W. Biederman }
1436805b5d5eSEric W. Biederman 
1437e51b6ba0SEric W. Biederman struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1438e51b6ba0SEric W. Biederman {
1439e51b6ba0SEric W. Biederman 	return __sysctl_head_next(current->nsproxy, prev);
1440e51b6ba0SEric W. Biederman }
1441e51b6ba0SEric W. Biederman 
1442e51b6ba0SEric W. Biederman void register_sysctl_root(struct ctl_table_root *root)
1443e51b6ba0SEric W. Biederman {
1444e51b6ba0SEric W. Biederman 	spin_lock(&sysctl_lock);
1445e51b6ba0SEric W. Biederman 	list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1446e51b6ba0SEric W. Biederman 	spin_unlock(&sysctl_lock);
1447e51b6ba0SEric W. Biederman }
1448e51b6ba0SEric W. Biederman 
1449b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL
14502c4c7155SPavel Emelyanov /* Perform the actual read/write of a sysctl table entry. */
1451d7321cd6SPavel Emelyanov static int do_sysctl_strategy(struct ctl_table_root *root,
1452d7321cd6SPavel Emelyanov 			struct ctl_table *table,
14532c4c7155SPavel Emelyanov 			int __user *name, int nlen,
14542c4c7155SPavel Emelyanov 			void __user *oldval, size_t __user *oldlenp,
14552c4c7155SPavel Emelyanov 			void __user *newval, size_t newlen)
14562c4c7155SPavel Emelyanov {
14572c4c7155SPavel Emelyanov 	int op = 0, rc;
14582c4c7155SPavel Emelyanov 
14592c4c7155SPavel Emelyanov 	if (oldval)
14602c4c7155SPavel Emelyanov 		op |= 004;
14612c4c7155SPavel Emelyanov 	if (newval)
14622c4c7155SPavel Emelyanov 		op |= 002;
1463d7321cd6SPavel Emelyanov 	if (sysctl_perm(root, table, op))
14642c4c7155SPavel Emelyanov 		return -EPERM;
14652c4c7155SPavel Emelyanov 
14662c4c7155SPavel Emelyanov 	if (table->strategy) {
14672c4c7155SPavel Emelyanov 		rc = table->strategy(table, name, nlen, oldval, oldlenp,
14682c4c7155SPavel Emelyanov 				     newval, newlen);
14692c4c7155SPavel Emelyanov 		if (rc < 0)
14702c4c7155SPavel Emelyanov 			return rc;
14712c4c7155SPavel Emelyanov 		if (rc > 0)
14722c4c7155SPavel Emelyanov 			return 0;
14732c4c7155SPavel Emelyanov 	}
14742c4c7155SPavel Emelyanov 
14752c4c7155SPavel Emelyanov 	/* If there is no strategy routine, or if the strategy returns
14762c4c7155SPavel Emelyanov 	 * zero, proceed with automatic r/w */
14772c4c7155SPavel Emelyanov 	if (table->data && table->maxlen) {
14782c4c7155SPavel Emelyanov 		rc = sysctl_data(table, name, nlen, oldval, oldlenp,
14792c4c7155SPavel Emelyanov 				 newval, newlen);
14802c4c7155SPavel Emelyanov 		if (rc < 0)
14812c4c7155SPavel Emelyanov 			return rc;
14822c4c7155SPavel Emelyanov 	}
14832c4c7155SPavel Emelyanov 	return 0;
14842c4c7155SPavel Emelyanov }
14852c4c7155SPavel Emelyanov 
14862c4c7155SPavel Emelyanov static int parse_table(int __user *name, int nlen,
14872c4c7155SPavel Emelyanov 		       void __user *oldval, size_t __user *oldlenp,
14882c4c7155SPavel Emelyanov 		       void __user *newval, size_t newlen,
1489d7321cd6SPavel Emelyanov 		       struct ctl_table_root *root,
14902c4c7155SPavel Emelyanov 		       struct ctl_table *table)
14912c4c7155SPavel Emelyanov {
14922c4c7155SPavel Emelyanov 	int n;
14932c4c7155SPavel Emelyanov repeat:
14942c4c7155SPavel Emelyanov 	if (!nlen)
14952c4c7155SPavel Emelyanov 		return -ENOTDIR;
14962c4c7155SPavel Emelyanov 	if (get_user(n, name))
14972c4c7155SPavel Emelyanov 		return -EFAULT;
14982c4c7155SPavel Emelyanov 	for ( ; table->ctl_name || table->procname; table++) {
14992c4c7155SPavel Emelyanov 		if (!table->ctl_name)
15002c4c7155SPavel Emelyanov 			continue;
15012c4c7155SPavel Emelyanov 		if (n == table->ctl_name) {
15022c4c7155SPavel Emelyanov 			int error;
15032c4c7155SPavel Emelyanov 			if (table->child) {
1504d7321cd6SPavel Emelyanov 				if (sysctl_perm(root, table, 001))
15052c4c7155SPavel Emelyanov 					return -EPERM;
15062c4c7155SPavel Emelyanov 				name++;
15072c4c7155SPavel Emelyanov 				nlen--;
15082c4c7155SPavel Emelyanov 				table = table->child;
15092c4c7155SPavel Emelyanov 				goto repeat;
15102c4c7155SPavel Emelyanov 			}
1511d7321cd6SPavel Emelyanov 			error = do_sysctl_strategy(root, table, name, nlen,
15122c4c7155SPavel Emelyanov 						   oldval, oldlenp,
15132c4c7155SPavel Emelyanov 						   newval, newlen);
15142c4c7155SPavel Emelyanov 			return error;
15152c4c7155SPavel Emelyanov 		}
15162c4c7155SPavel Emelyanov 	}
15172c4c7155SPavel Emelyanov 	return -ENOTDIR;
15182c4c7155SPavel Emelyanov }
15192c4c7155SPavel Emelyanov 
15201da177e4SLinus Torvalds int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
15211da177e4SLinus Torvalds 	       void __user *newval, size_t newlen)
15221da177e4SLinus Torvalds {
1523805b5d5eSEric W. Biederman 	struct ctl_table_header *head;
1524330d57fbSAl Viro 	int error = -ENOTDIR;
15251da177e4SLinus Torvalds 
15261da177e4SLinus Torvalds 	if (nlen <= 0 || nlen >= CTL_MAXNAME)
15271da177e4SLinus Torvalds 		return -ENOTDIR;
15281da177e4SLinus Torvalds 	if (oldval) {
15291da177e4SLinus Torvalds 		int old_len;
15301da177e4SLinus Torvalds 		if (!oldlenp || get_user(old_len, oldlenp))
15311da177e4SLinus Torvalds 			return -EFAULT;
15321da177e4SLinus Torvalds 	}
1533330d57fbSAl Viro 
1534805b5d5eSEric W. Biederman 	for (head = sysctl_head_next(NULL); head;
1535805b5d5eSEric W. Biederman 			head = sysctl_head_next(head)) {
1536330d57fbSAl Viro 		error = parse_table(name, nlen, oldval, oldlenp,
1537d7321cd6SPavel Emelyanov 					newval, newlen,
1538d7321cd6SPavel Emelyanov 					head->root, head->ctl_table);
1539805b5d5eSEric W. Biederman 		if (error != -ENOTDIR) {
1540805b5d5eSEric W. Biederman 			sysctl_head_finish(head);
1541330d57fbSAl Viro 			break;
1542805b5d5eSEric W. Biederman 		}
1543805b5d5eSEric W. Biederman 	}
15441da177e4SLinus Torvalds 	return error;
15451da177e4SLinus Torvalds }
15461da177e4SLinus Torvalds 
15471da177e4SLinus Torvalds asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
15481da177e4SLinus Torvalds {
15491da177e4SLinus Torvalds 	struct __sysctl_args tmp;
15501da177e4SLinus Torvalds 	int error;
15511da177e4SLinus Torvalds 
15521da177e4SLinus Torvalds 	if (copy_from_user(&tmp, args, sizeof(tmp)))
15531da177e4SLinus Torvalds 		return -EFAULT;
15541da177e4SLinus Torvalds 
15557058cb02SEric W. Biederman 	error = deprecated_sysctl_warning(&tmp);
15567058cb02SEric W. Biederman 	if (error)
15577058cb02SEric W. Biederman 		goto out;
15587058cb02SEric W. Biederman 
15591da177e4SLinus Torvalds 	lock_kernel();
15601da177e4SLinus Torvalds 	error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
15611da177e4SLinus Torvalds 			  tmp.newval, tmp.newlen);
15621da177e4SLinus Torvalds 	unlock_kernel();
15637058cb02SEric W. Biederman out:
15641da177e4SLinus Torvalds 	return error;
15651da177e4SLinus Torvalds }
1566b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */
15671da177e4SLinus Torvalds 
15681da177e4SLinus Torvalds /*
15691ff007ebSEric W. Biederman  * sysctl_perm does NOT grant the superuser all rights automatically, because
15701da177e4SLinus Torvalds  * some sysctl variables are readonly even to root.
15711da177e4SLinus Torvalds  */
15721da177e4SLinus Torvalds 
15731da177e4SLinus Torvalds static int test_perm(int mode, int op)
15741da177e4SLinus Torvalds {
15751da177e4SLinus Torvalds 	if (!current->euid)
15761da177e4SLinus Torvalds 		mode >>= 6;
15771da177e4SLinus Torvalds 	else if (in_egroup_p(0))
15781da177e4SLinus Torvalds 		mode >>= 3;
15791da177e4SLinus Torvalds 	if ((mode & op & 0007) == op)
15801da177e4SLinus Torvalds 		return 0;
15811da177e4SLinus Torvalds 	return -EACCES;
15821da177e4SLinus Torvalds }
15831da177e4SLinus Torvalds 
1584d7321cd6SPavel Emelyanov int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
15851da177e4SLinus Torvalds {
15861da177e4SLinus Torvalds 	int error;
1587d7321cd6SPavel Emelyanov 	int mode;
1588d7321cd6SPavel Emelyanov 
15891da177e4SLinus Torvalds 	error = security_sysctl(table, op);
15901da177e4SLinus Torvalds 	if (error)
15911da177e4SLinus Torvalds 		return error;
1592d7321cd6SPavel Emelyanov 
1593d7321cd6SPavel Emelyanov 	if (root->permissions)
1594d7321cd6SPavel Emelyanov 		mode = root->permissions(root, current->nsproxy, table);
1595d7321cd6SPavel Emelyanov 	else
1596d7321cd6SPavel Emelyanov 		mode = table->mode;
1597d7321cd6SPavel Emelyanov 
1598d7321cd6SPavel Emelyanov 	return test_perm(mode, op);
15991da177e4SLinus Torvalds }
16001da177e4SLinus Torvalds 
1601d912b0ccSEric W. Biederman static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1602d912b0ccSEric W. Biederman {
1603d912b0ccSEric W. Biederman 	for (; table->ctl_name || table->procname; table++) {
1604d912b0ccSEric W. Biederman 		table->parent = parent;
1605d912b0ccSEric W. Biederman 		if (table->child)
1606d912b0ccSEric W. Biederman 			sysctl_set_parent(table, table->child);
1607d912b0ccSEric W. Biederman 	}
1608d912b0ccSEric W. Biederman }
1609d912b0ccSEric W. Biederman 
1610d912b0ccSEric W. Biederman static __init int sysctl_init(void)
1611d912b0ccSEric W. Biederman {
1612d912b0ccSEric W. Biederman 	sysctl_set_parent(NULL, root_table);
161388f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
161488f458e4SHolger Schurig 	{
161588f458e4SHolger Schurig 		int err;
1616e51b6ba0SEric W. Biederman 		err = sysctl_check_table(current->nsproxy, root_table);
161788f458e4SHolger Schurig 	}
161888f458e4SHolger Schurig #endif
1619d912b0ccSEric W. Biederman 	return 0;
1620d912b0ccSEric W. Biederman }
1621d912b0ccSEric W. Biederman 
1622d912b0ccSEric W. Biederman core_initcall(sysctl_init);
1623d912b0ccSEric W. Biederman 
16241da177e4SLinus Torvalds /**
1625e51b6ba0SEric W. Biederman  * __register_sysctl_paths - register a sysctl hierarchy
1626e51b6ba0SEric W. Biederman  * @root: List of sysctl headers to register on
1627e51b6ba0SEric W. Biederman  * @namespaces: Data to compute which lists of sysctl entries are visible
162829e796fdSEric W. Biederman  * @path: The path to the directory the sysctl table is in.
16291da177e4SLinus Torvalds  * @table: the top-level table structure
16301da177e4SLinus Torvalds  *
16311da177e4SLinus Torvalds  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
163229e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
16331da177e4SLinus Torvalds  *
1634d8217f07SEric W. Biederman  * The members of the &struct ctl_table structure are used as follows:
16351da177e4SLinus Torvalds  *
16361da177e4SLinus Torvalds  * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
16371da177e4SLinus Torvalds  *            must be unique within that level of sysctl
16381da177e4SLinus Torvalds  *
16391da177e4SLinus Torvalds  * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
16401da177e4SLinus Torvalds  *            enter a sysctl file
16411da177e4SLinus Torvalds  *
16421da177e4SLinus Torvalds  * data - a pointer to data for use by proc_handler
16431da177e4SLinus Torvalds  *
16441da177e4SLinus Torvalds  * maxlen - the maximum size in bytes of the data
16451da177e4SLinus Torvalds  *
16461da177e4SLinus Torvalds  * mode - the file permissions for the /proc/sys file, and for sysctl(2)
16471da177e4SLinus Torvalds  *
16481da177e4SLinus Torvalds  * child - a pointer to the child sysctl table if this entry is a directory, or
16491da177e4SLinus Torvalds  *         %NULL.
16501da177e4SLinus Torvalds  *
16511da177e4SLinus Torvalds  * proc_handler - the text handler routine (described below)
16521da177e4SLinus Torvalds  *
16531da177e4SLinus Torvalds  * strategy - the strategy routine (described below)
16541da177e4SLinus Torvalds  *
16551da177e4SLinus Torvalds  * de - for internal use by the sysctl routines
16561da177e4SLinus Torvalds  *
16571da177e4SLinus Torvalds  * extra1, extra2 - extra pointers usable by the proc handler routines
16581da177e4SLinus Torvalds  *
16591da177e4SLinus Torvalds  * Leaf nodes in the sysctl tree will be represented by a single file
16601da177e4SLinus Torvalds  * under /proc; non-leaf nodes will be represented by directories.
16611da177e4SLinus Torvalds  *
16621da177e4SLinus Torvalds  * sysctl(2) can automatically manage read and write requests through
16631da177e4SLinus Torvalds  * the sysctl table.  The data and maxlen fields of the ctl_table
16641da177e4SLinus Torvalds  * struct enable minimal validation of the values being written to be
16651da177e4SLinus Torvalds  * performed, and the mode field allows minimal authentication.
16661da177e4SLinus Torvalds  *
16671da177e4SLinus Torvalds  * More sophisticated management can be enabled by the provision of a
16681da177e4SLinus Torvalds  * strategy routine with the table entry.  This will be called before
16691da177e4SLinus Torvalds  * any automatic read or write of the data is performed.
16701da177e4SLinus Torvalds  *
16711da177e4SLinus Torvalds  * The strategy routine may return
16721da177e4SLinus Torvalds  *
16731da177e4SLinus Torvalds  * < 0 - Error occurred (error is passed to user process)
16741da177e4SLinus Torvalds  *
16751da177e4SLinus Torvalds  * 0   - OK - proceed with automatic read or write.
16761da177e4SLinus Torvalds  *
16771da177e4SLinus Torvalds  * > 0 - OK - read or write has been done by the strategy routine, so
16781da177e4SLinus Torvalds  *       return immediately.
16791da177e4SLinus Torvalds  *
16801da177e4SLinus Torvalds  * There must be a proc_handler routine for any terminal nodes
16811da177e4SLinus Torvalds  * mirrored under /proc/sys (non-terminals are handled by a built-in
16821da177e4SLinus Torvalds  * directory handler).  Several default handlers are available to
16831da177e4SLinus Torvalds  * cover common cases -
16841da177e4SLinus Torvalds  *
16851da177e4SLinus Torvalds  * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
16861da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
16871da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
16881da177e4SLinus Torvalds  *
16891da177e4SLinus Torvalds  * It is the handler's job to read the input buffer from user memory
16901da177e4SLinus Torvalds  * and process it. The handler should return 0 on success.
16911da177e4SLinus Torvalds  *
16921da177e4SLinus Torvalds  * This routine returns %NULL on a failure to register, and a pointer
16931da177e4SLinus Torvalds  * to the table header on success.
16941da177e4SLinus Torvalds  */
1695e51b6ba0SEric W. Biederman struct ctl_table_header *__register_sysctl_paths(
1696e51b6ba0SEric W. Biederman 	struct ctl_table_root *root,
1697e51b6ba0SEric W. Biederman 	struct nsproxy *namespaces,
1698e51b6ba0SEric W. Biederman 	const struct ctl_path *path, struct ctl_table *table)
16991da177e4SLinus Torvalds {
1700e51b6ba0SEric W. Biederman 	struct list_head *header_list;
170129e796fdSEric W. Biederman 	struct ctl_table_header *header;
170229e796fdSEric W. Biederman 	struct ctl_table *new, **prevp;
170329e796fdSEric W. Biederman 	unsigned int n, npath;
170429e796fdSEric W. Biederman 
170529e796fdSEric W. Biederman 	/* Count the path components */
170629e796fdSEric W. Biederman 	for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
170729e796fdSEric W. Biederman 		;
170829e796fdSEric W. Biederman 
170929e796fdSEric W. Biederman 	/*
171029e796fdSEric W. Biederman 	 * For each path component, allocate a 2-element ctl_table array.
171129e796fdSEric W. Biederman 	 * The first array element will be filled with the sysctl entry
171229e796fdSEric W. Biederman 	 * for this, the second will be the sentinel (ctl_name == 0).
171329e796fdSEric W. Biederman 	 *
171429e796fdSEric W. Biederman 	 * We allocate everything in one go so that we don't have to
171529e796fdSEric W. Biederman 	 * worry about freeing additional memory in unregister_sysctl_table.
171629e796fdSEric W. Biederman 	 */
171729e796fdSEric W. Biederman 	header = kzalloc(sizeof(struct ctl_table_header) +
171829e796fdSEric W. Biederman 			 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
171929e796fdSEric W. Biederman 	if (!header)
17201da177e4SLinus Torvalds 		return NULL;
172129e796fdSEric W. Biederman 
172229e796fdSEric W. Biederman 	new = (struct ctl_table *) (header + 1);
172329e796fdSEric W. Biederman 
172429e796fdSEric W. Biederman 	/* Now connect the dots */
172529e796fdSEric W. Biederman 	prevp = &header->ctl_table;
172629e796fdSEric W. Biederman 	for (n = 0; n < npath; ++n, ++path) {
172729e796fdSEric W. Biederman 		/* Copy the procname */
172829e796fdSEric W. Biederman 		new->procname = path->procname;
172929e796fdSEric W. Biederman 		new->ctl_name = path->ctl_name;
173029e796fdSEric W. Biederman 		new->mode     = 0555;
173129e796fdSEric W. Biederman 
173229e796fdSEric W. Biederman 		*prevp = new;
173329e796fdSEric W. Biederman 		prevp = &new->child;
173429e796fdSEric W. Biederman 
173529e796fdSEric W. Biederman 		new += 2;
173629e796fdSEric W. Biederman 	}
173729e796fdSEric W. Biederman 	*prevp = table;
173823eb06deSEric W. Biederman 	header->ctl_table_arg = table;
173929e796fdSEric W. Biederman 
174029e796fdSEric W. Biederman 	INIT_LIST_HEAD(&header->ctl_entry);
174129e796fdSEric W. Biederman 	header->used = 0;
174229e796fdSEric W. Biederman 	header->unregistering = NULL;
1743e51b6ba0SEric W. Biederman 	header->root = root;
174429e796fdSEric W. Biederman 	sysctl_set_parent(NULL, header->ctl_table);
174588f458e4SHolger Schurig #ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1746e51b6ba0SEric W. Biederman 	if (sysctl_check_table(namespaces, header->ctl_table)) {
174729e796fdSEric W. Biederman 		kfree(header);
1748fc6cd25bSEric W. Biederman 		return NULL;
1749fc6cd25bSEric W. Biederman 	}
175088f458e4SHolger Schurig #endif
1751330d57fbSAl Viro 	spin_lock(&sysctl_lock);
1752e51b6ba0SEric W. Biederman 	header_list = lookup_header_list(root, namespaces);
1753e51b6ba0SEric W. Biederman 	list_add_tail(&header->ctl_entry, header_list);
1754330d57fbSAl Viro 	spin_unlock(&sysctl_lock);
175529e796fdSEric W. Biederman 
175629e796fdSEric W. Biederman 	return header;
175729e796fdSEric W. Biederman }
175829e796fdSEric W. Biederman 
175929e796fdSEric W. Biederman /**
1760e51b6ba0SEric W. Biederman  * register_sysctl_table_path - register a sysctl table hierarchy
1761e51b6ba0SEric W. Biederman  * @path: The path to the directory the sysctl table is in.
1762e51b6ba0SEric W. Biederman  * @table: the top-level table structure
1763e51b6ba0SEric W. Biederman  *
1764e51b6ba0SEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1765e51b6ba0SEric W. Biederman  * array. A completely 0 filled entry terminates the table.
1766e51b6ba0SEric W. Biederman  *
1767e51b6ba0SEric W. Biederman  * See __register_sysctl_paths for more details.
1768e51b6ba0SEric W. Biederman  */
1769e51b6ba0SEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1770e51b6ba0SEric W. Biederman 						struct ctl_table *table)
1771e51b6ba0SEric W. Biederman {
1772e51b6ba0SEric W. Biederman 	return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1773e51b6ba0SEric W. Biederman 					path, table);
1774e51b6ba0SEric W. Biederman }
1775e51b6ba0SEric W. Biederman 
1776e51b6ba0SEric W. Biederman /**
177729e796fdSEric W. Biederman  * register_sysctl_table - register a sysctl table hierarchy
177829e796fdSEric W. Biederman  * @table: the top-level table structure
177929e796fdSEric W. Biederman  *
178029e796fdSEric W. Biederman  * Register a sysctl table hierarchy. @table should be a filled in ctl_table
178129e796fdSEric W. Biederman  * array. A completely 0 filled entry terminates the table.
178229e796fdSEric W. Biederman  *
178329e796fdSEric W. Biederman  * See register_sysctl_paths for more details.
178429e796fdSEric W. Biederman  */
178529e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
178629e796fdSEric W. Biederman {
178729e796fdSEric W. Biederman 	static const struct ctl_path null_path[] = { {} };
178829e796fdSEric W. Biederman 
178929e796fdSEric W. Biederman 	return register_sysctl_paths(null_path, table);
17901da177e4SLinus Torvalds }
17911da177e4SLinus Torvalds 
17921da177e4SLinus Torvalds /**
17931da177e4SLinus Torvalds  * unregister_sysctl_table - unregister a sysctl table hierarchy
17941da177e4SLinus Torvalds  * @header: the header returned from register_sysctl_table
17951da177e4SLinus Torvalds  *
17961da177e4SLinus Torvalds  * Unregisters the sysctl table and all children. proc entries may not
17971da177e4SLinus Torvalds  * actually be removed until they are no longer used by anyone.
17981da177e4SLinus Torvalds  */
17991da177e4SLinus Torvalds void unregister_sysctl_table(struct ctl_table_header * header)
18001da177e4SLinus Torvalds {
1801330d57fbSAl Viro 	might_sleep();
1802f1dad166SPavel Emelyanov 
1803f1dad166SPavel Emelyanov 	if (header == NULL)
1804f1dad166SPavel Emelyanov 		return;
1805f1dad166SPavel Emelyanov 
1806330d57fbSAl Viro 	spin_lock(&sysctl_lock);
1807330d57fbSAl Viro 	start_unregistering(header);
1808330d57fbSAl Viro 	spin_unlock(&sysctl_lock);
18091da177e4SLinus Torvalds 	kfree(header);
18101da177e4SLinus Torvalds }
18111da177e4SLinus Torvalds 
1812b89a8171SEric W. Biederman #else /* !CONFIG_SYSCTL */
1813d8217f07SEric W. Biederman struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
1814b89a8171SEric W. Biederman {
1815b89a8171SEric W. Biederman 	return NULL;
1816b89a8171SEric W. Biederman }
1817b89a8171SEric W. Biederman 
181829e796fdSEric W. Biederman struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
181929e796fdSEric W. Biederman 						    struct ctl_table *table)
182029e796fdSEric W. Biederman {
182129e796fdSEric W. Biederman 	return NULL;
182229e796fdSEric W. Biederman }
182329e796fdSEric W. Biederman 
1824b89a8171SEric W. Biederman void unregister_sysctl_table(struct ctl_table_header * table)
1825b89a8171SEric W. Biederman {
1826b89a8171SEric W. Biederman }
1827b89a8171SEric W. Biederman 
1828b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL */
1829b89a8171SEric W. Biederman 
18301da177e4SLinus Torvalds /*
18311da177e4SLinus Torvalds  * /proc/sys support
18321da177e4SLinus Torvalds  */
18331da177e4SLinus Torvalds 
1834b89a8171SEric W. Biederman #ifdef CONFIG_PROC_SYSCTL
18351da177e4SLinus Torvalds 
1836b1ba4dddSAdrian Bunk static int _proc_do_string(void* data, int maxlen, int write,
1837b1ba4dddSAdrian Bunk 			   struct file *filp, void __user *buffer,
1838b1ba4dddSAdrian Bunk 			   size_t *lenp, loff_t *ppos)
1839f5dd3d6fSSam Vilain {
1840f5dd3d6fSSam Vilain 	size_t len;
1841f5dd3d6fSSam Vilain 	char __user *p;
1842f5dd3d6fSSam Vilain 	char c;
1843f5dd3d6fSSam Vilain 
18448d060877SOleg Nesterov 	if (!data || !maxlen || !*lenp) {
1845f5dd3d6fSSam Vilain 		*lenp = 0;
1846f5dd3d6fSSam Vilain 		return 0;
1847f5dd3d6fSSam Vilain 	}
1848f5dd3d6fSSam Vilain 
1849f5dd3d6fSSam Vilain 	if (write) {
1850f5dd3d6fSSam Vilain 		len = 0;
1851f5dd3d6fSSam Vilain 		p = buffer;
1852f5dd3d6fSSam Vilain 		while (len < *lenp) {
1853f5dd3d6fSSam Vilain 			if (get_user(c, p++))
1854f5dd3d6fSSam Vilain 				return -EFAULT;
1855f5dd3d6fSSam Vilain 			if (c == 0 || c == '\n')
1856f5dd3d6fSSam Vilain 				break;
1857f5dd3d6fSSam Vilain 			len++;
1858f5dd3d6fSSam Vilain 		}
1859f5dd3d6fSSam Vilain 		if (len >= maxlen)
1860f5dd3d6fSSam Vilain 			len = maxlen-1;
1861f5dd3d6fSSam Vilain 		if(copy_from_user(data, buffer, len))
1862f5dd3d6fSSam Vilain 			return -EFAULT;
1863f5dd3d6fSSam Vilain 		((char *) data)[len] = 0;
1864f5dd3d6fSSam Vilain 		*ppos += *lenp;
1865f5dd3d6fSSam Vilain 	} else {
1866f5dd3d6fSSam Vilain 		len = strlen(data);
1867f5dd3d6fSSam Vilain 		if (len > maxlen)
1868f5dd3d6fSSam Vilain 			len = maxlen;
18698d060877SOleg Nesterov 
18708d060877SOleg Nesterov 		if (*ppos > len) {
18718d060877SOleg Nesterov 			*lenp = 0;
18728d060877SOleg Nesterov 			return 0;
18738d060877SOleg Nesterov 		}
18748d060877SOleg Nesterov 
18758d060877SOleg Nesterov 		data += *ppos;
18768d060877SOleg Nesterov 		len  -= *ppos;
18778d060877SOleg Nesterov 
1878f5dd3d6fSSam Vilain 		if (len > *lenp)
1879f5dd3d6fSSam Vilain 			len = *lenp;
1880f5dd3d6fSSam Vilain 		if (len)
1881f5dd3d6fSSam Vilain 			if(copy_to_user(buffer, data, len))
1882f5dd3d6fSSam Vilain 				return -EFAULT;
1883f5dd3d6fSSam Vilain 		if (len < *lenp) {
1884f5dd3d6fSSam Vilain 			if(put_user('\n', ((char __user *) buffer) + len))
1885f5dd3d6fSSam Vilain 				return -EFAULT;
1886f5dd3d6fSSam Vilain 			len++;
1887f5dd3d6fSSam Vilain 		}
1888f5dd3d6fSSam Vilain 		*lenp = len;
1889f5dd3d6fSSam Vilain 		*ppos += len;
1890f5dd3d6fSSam Vilain 	}
1891f5dd3d6fSSam Vilain 	return 0;
1892f5dd3d6fSSam Vilain }
1893f5dd3d6fSSam Vilain 
18941da177e4SLinus Torvalds /**
18951da177e4SLinus Torvalds  * proc_dostring - read a string sysctl
18961da177e4SLinus Torvalds  * @table: the sysctl table
18971da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
18981da177e4SLinus Torvalds  * @filp: the file structure
18991da177e4SLinus Torvalds  * @buffer: the user buffer
19001da177e4SLinus Torvalds  * @lenp: the size of the user buffer
19011da177e4SLinus Torvalds  * @ppos: file position
19021da177e4SLinus Torvalds  *
19031da177e4SLinus Torvalds  * Reads/writes a string from/to the user buffer. If the kernel
19041da177e4SLinus Torvalds  * buffer provided is not large enough to hold the string, the
19051da177e4SLinus Torvalds  * string is truncated. The copied string is %NULL-terminated.
19061da177e4SLinus Torvalds  * If the string is being read by the user process, it is copied
19071da177e4SLinus Torvalds  * and a newline '\n' is added. It is truncated if the buffer is
19081da177e4SLinus Torvalds  * not large enough.
19091da177e4SLinus Torvalds  *
19101da177e4SLinus Torvalds  * Returns 0 on success.
19111da177e4SLinus Torvalds  */
1912d8217f07SEric W. Biederman int proc_dostring(struct ctl_table *table, int write, struct file *filp,
19131da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
19141da177e4SLinus Torvalds {
1915f5dd3d6fSSam Vilain 	return _proc_do_string(table->data, table->maxlen, write, filp,
1916f5dd3d6fSSam Vilain 			       buffer, lenp, ppos);
19171da177e4SLinus Torvalds }
19181da177e4SLinus Torvalds 
19191da177e4SLinus Torvalds 
19201da177e4SLinus Torvalds static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
19211da177e4SLinus Torvalds 				 int *valp,
19221da177e4SLinus Torvalds 				 int write, void *data)
19231da177e4SLinus Torvalds {
19241da177e4SLinus Torvalds 	if (write) {
19251da177e4SLinus Torvalds 		*valp = *negp ? -*lvalp : *lvalp;
19261da177e4SLinus Torvalds 	} else {
19271da177e4SLinus Torvalds 		int val = *valp;
19281da177e4SLinus Torvalds 		if (val < 0) {
19291da177e4SLinus Torvalds 			*negp = -1;
19301da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
19311da177e4SLinus Torvalds 		} else {
19321da177e4SLinus Torvalds 			*negp = 0;
19331da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
19341da177e4SLinus Torvalds 		}
19351da177e4SLinus Torvalds 	}
19361da177e4SLinus Torvalds 	return 0;
19371da177e4SLinus Torvalds }
19381da177e4SLinus Torvalds 
1939d8217f07SEric W. Biederman static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
1940fcfbd547SKirill Korotaev 		  int write, struct file *filp, void __user *buffer,
1941fcfbd547SKirill Korotaev 		  size_t *lenp, loff_t *ppos,
19421da177e4SLinus Torvalds 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
19431da177e4SLinus Torvalds 			      int write, void *data),
19441da177e4SLinus Torvalds 		  void *data)
19451da177e4SLinus Torvalds {
19461da177e4SLinus Torvalds #define TMPBUFLEN 21
19471da177e4SLinus Torvalds 	int *i, vleft, first=1, neg, val;
19481da177e4SLinus Torvalds 	unsigned long lval;
19491da177e4SLinus Torvalds 	size_t left, len;
19501da177e4SLinus Torvalds 
19511da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
19521da177e4SLinus Torvalds 	char __user *s = buffer;
19531da177e4SLinus Torvalds 
1954fcfbd547SKirill Korotaev 	if (!tbl_data || !table->maxlen || !*lenp ||
19551da177e4SLinus Torvalds 	    (*ppos && !write)) {
19561da177e4SLinus Torvalds 		*lenp = 0;
19571da177e4SLinus Torvalds 		return 0;
19581da177e4SLinus Torvalds 	}
19591da177e4SLinus Torvalds 
1960fcfbd547SKirill Korotaev 	i = (int *) tbl_data;
19611da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(*i);
19621da177e4SLinus Torvalds 	left = *lenp;
19631da177e4SLinus Torvalds 
19641da177e4SLinus Torvalds 	if (!conv)
19651da177e4SLinus Torvalds 		conv = do_proc_dointvec_conv;
19661da177e4SLinus Torvalds 
19671da177e4SLinus Torvalds 	for (; left && vleft--; i++, first=0) {
19681da177e4SLinus Torvalds 		if (write) {
19691da177e4SLinus Torvalds 			while (left) {
19701da177e4SLinus Torvalds 				char c;
19711da177e4SLinus Torvalds 				if (get_user(c, s))
19721da177e4SLinus Torvalds 					return -EFAULT;
19731da177e4SLinus Torvalds 				if (!isspace(c))
19741da177e4SLinus Torvalds 					break;
19751da177e4SLinus Torvalds 				left--;
19761da177e4SLinus Torvalds 				s++;
19771da177e4SLinus Torvalds 			}
19781da177e4SLinus Torvalds 			if (!left)
19791da177e4SLinus Torvalds 				break;
19801da177e4SLinus Torvalds 			neg = 0;
19811da177e4SLinus Torvalds 			len = left;
19821da177e4SLinus Torvalds 			if (len > sizeof(buf) - 1)
19831da177e4SLinus Torvalds 				len = sizeof(buf) - 1;
19841da177e4SLinus Torvalds 			if (copy_from_user(buf, s, len))
19851da177e4SLinus Torvalds 				return -EFAULT;
19861da177e4SLinus Torvalds 			buf[len] = 0;
19871da177e4SLinus Torvalds 			p = buf;
19881da177e4SLinus Torvalds 			if (*p == '-' && left > 1) {
19891da177e4SLinus Torvalds 				neg = 1;
1990bd9b0bacSBP, Praveen 				p++;
19911da177e4SLinus Torvalds 			}
19921da177e4SLinus Torvalds 			if (*p < '0' || *p > '9')
19931da177e4SLinus Torvalds 				break;
19941da177e4SLinus Torvalds 
19951da177e4SLinus Torvalds 			lval = simple_strtoul(p, &p, 0);
19961da177e4SLinus Torvalds 
19971da177e4SLinus Torvalds 			len = p-buf;
19981da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
19991da177e4SLinus Torvalds 				break;
20001da177e4SLinus Torvalds 			if (neg)
20011da177e4SLinus Torvalds 				val = -val;
20021da177e4SLinus Torvalds 			s += len;
20031da177e4SLinus Torvalds 			left -= len;
20041da177e4SLinus Torvalds 
20051da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 1, data))
20061da177e4SLinus Torvalds 				break;
20071da177e4SLinus Torvalds 		} else {
20081da177e4SLinus Torvalds 			p = buf;
20091da177e4SLinus Torvalds 			if (!first)
20101da177e4SLinus Torvalds 				*p++ = '\t';
20111da177e4SLinus Torvalds 
20121da177e4SLinus Torvalds 			if (conv(&neg, &lval, i, 0, data))
20131da177e4SLinus Torvalds 				break;
20141da177e4SLinus Torvalds 
20151da177e4SLinus Torvalds 			sprintf(p, "%s%lu", neg ? "-" : "", lval);
20161da177e4SLinus Torvalds 			len = strlen(buf);
20171da177e4SLinus Torvalds 			if (len > left)
20181da177e4SLinus Torvalds 				len = left;
20191da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
20201da177e4SLinus Torvalds 				return -EFAULT;
20211da177e4SLinus Torvalds 			left -= len;
20221da177e4SLinus Torvalds 			s += len;
20231da177e4SLinus Torvalds 		}
20241da177e4SLinus Torvalds 	}
20251da177e4SLinus Torvalds 
20261da177e4SLinus Torvalds 	if (!write && !first && left) {
20271da177e4SLinus Torvalds 		if(put_user('\n', s))
20281da177e4SLinus Torvalds 			return -EFAULT;
20291da177e4SLinus Torvalds 		left--, s++;
20301da177e4SLinus Torvalds 	}
20311da177e4SLinus Torvalds 	if (write) {
20321da177e4SLinus Torvalds 		while (left) {
20331da177e4SLinus Torvalds 			char c;
20341da177e4SLinus Torvalds 			if (get_user(c, s++))
20351da177e4SLinus Torvalds 				return -EFAULT;
20361da177e4SLinus Torvalds 			if (!isspace(c))
20371da177e4SLinus Torvalds 				break;
20381da177e4SLinus Torvalds 			left--;
20391da177e4SLinus Torvalds 		}
20401da177e4SLinus Torvalds 	}
20411da177e4SLinus Torvalds 	if (write && first)
20421da177e4SLinus Torvalds 		return -EINVAL;
20431da177e4SLinus Torvalds 	*lenp -= left;
20441da177e4SLinus Torvalds 	*ppos += *lenp;
20451da177e4SLinus Torvalds 	return 0;
20461da177e4SLinus Torvalds #undef TMPBUFLEN
20471da177e4SLinus Torvalds }
20481da177e4SLinus Torvalds 
2049d8217f07SEric W. Biederman static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
2050fcfbd547SKirill Korotaev 		  void __user *buffer, size_t *lenp, loff_t *ppos,
2051fcfbd547SKirill Korotaev 		  int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2052fcfbd547SKirill Korotaev 			      int write, void *data),
2053fcfbd547SKirill Korotaev 		  void *data)
2054fcfbd547SKirill Korotaev {
2055fcfbd547SKirill Korotaev 	return __do_proc_dointvec(table->data, table, write, filp,
2056fcfbd547SKirill Korotaev 			buffer, lenp, ppos, conv, data);
2057fcfbd547SKirill Korotaev }
2058fcfbd547SKirill Korotaev 
20591da177e4SLinus Torvalds /**
20601da177e4SLinus Torvalds  * proc_dointvec - read a vector of integers
20611da177e4SLinus Torvalds  * @table: the sysctl table
20621da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
20631da177e4SLinus Torvalds  * @filp: the file structure
20641da177e4SLinus Torvalds  * @buffer: the user buffer
20651da177e4SLinus Torvalds  * @lenp: the size of the user buffer
20661da177e4SLinus Torvalds  * @ppos: file position
20671da177e4SLinus Torvalds  *
20681da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
20691da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
20701da177e4SLinus Torvalds  *
20711da177e4SLinus Torvalds  * Returns 0 on success.
20721da177e4SLinus Torvalds  */
2073d8217f07SEric W. Biederman int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
20741da177e4SLinus Torvalds 		     void __user *buffer, size_t *lenp, loff_t *ppos)
20751da177e4SLinus Torvalds {
20761da177e4SLinus Torvalds     return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
20771da177e4SLinus Torvalds 		    	    NULL,NULL);
20781da177e4SLinus Torvalds }
20791da177e4SLinus Torvalds 
20801da177e4SLinus Torvalds #define OP_SET	0
20811da177e4SLinus Torvalds #define OP_AND	1
208234f5a398STheodore Ts'o #define OP_OR	2
20831da177e4SLinus Torvalds 
20841da177e4SLinus Torvalds static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
20851da177e4SLinus Torvalds 				      int *valp,
20861da177e4SLinus Torvalds 				      int write, void *data)
20871da177e4SLinus Torvalds {
20881da177e4SLinus Torvalds 	int op = *(int *)data;
20891da177e4SLinus Torvalds 	if (write) {
20901da177e4SLinus Torvalds 		int val = *negp ? -*lvalp : *lvalp;
20911da177e4SLinus Torvalds 		switch(op) {
20921da177e4SLinus Torvalds 		case OP_SET:	*valp = val; break;
20931da177e4SLinus Torvalds 		case OP_AND:	*valp &= val; break;
209434f5a398STheodore Ts'o 		case OP_OR:	*valp |= val; break;
20951da177e4SLinus Torvalds 		}
20961da177e4SLinus Torvalds 	} else {
20971da177e4SLinus Torvalds 		int val = *valp;
20981da177e4SLinus Torvalds 		if (val < 0) {
20991da177e4SLinus Torvalds 			*negp = -1;
21001da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
21011da177e4SLinus Torvalds 		} else {
21021da177e4SLinus Torvalds 			*negp = 0;
21031da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
21041da177e4SLinus Torvalds 		}
21051da177e4SLinus Torvalds 	}
21061da177e4SLinus Torvalds 	return 0;
21071da177e4SLinus Torvalds }
21081da177e4SLinus Torvalds 
210934f5a398STheodore Ts'o /*
211034f5a398STheodore Ts'o  *	Taint values can only be increased
211134f5a398STheodore Ts'o  */
2112d8217f07SEric W. Biederman static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp,
211334f5a398STheodore Ts'o 			       void __user *buffer, size_t *lenp, loff_t *ppos)
211434f5a398STheodore Ts'o {
211534f5a398STheodore Ts'o 	int op;
211634f5a398STheodore Ts'o 
211791fcd412SBastian Blank 	if (write && !capable(CAP_SYS_ADMIN))
211834f5a398STheodore Ts'o 		return -EPERM;
211934f5a398STheodore Ts'o 
212034f5a398STheodore Ts'o 	op = OP_OR;
212134f5a398STheodore Ts'o 	return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
212234f5a398STheodore Ts'o 				do_proc_dointvec_bset_conv,&op);
212334f5a398STheodore Ts'o }
212434f5a398STheodore Ts'o 
21251da177e4SLinus Torvalds struct do_proc_dointvec_minmax_conv_param {
21261da177e4SLinus Torvalds 	int *min;
21271da177e4SLinus Torvalds 	int *max;
21281da177e4SLinus Torvalds };
21291da177e4SLinus Torvalds 
21301da177e4SLinus Torvalds static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
21311da177e4SLinus Torvalds 					int *valp,
21321da177e4SLinus Torvalds 					int write, void *data)
21331da177e4SLinus Torvalds {
21341da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param *param = data;
21351da177e4SLinus Torvalds 	if (write) {
21361da177e4SLinus Torvalds 		int val = *negp ? -*lvalp : *lvalp;
21371da177e4SLinus Torvalds 		if ((param->min && *param->min > val) ||
21381da177e4SLinus Torvalds 		    (param->max && *param->max < val))
21391da177e4SLinus Torvalds 			return -EINVAL;
21401da177e4SLinus Torvalds 		*valp = val;
21411da177e4SLinus Torvalds 	} else {
21421da177e4SLinus Torvalds 		int val = *valp;
21431da177e4SLinus Torvalds 		if (val < 0) {
21441da177e4SLinus Torvalds 			*negp = -1;
21451da177e4SLinus Torvalds 			*lvalp = (unsigned long)-val;
21461da177e4SLinus Torvalds 		} else {
21471da177e4SLinus Torvalds 			*negp = 0;
21481da177e4SLinus Torvalds 			*lvalp = (unsigned long)val;
21491da177e4SLinus Torvalds 		}
21501da177e4SLinus Torvalds 	}
21511da177e4SLinus Torvalds 	return 0;
21521da177e4SLinus Torvalds }
21531da177e4SLinus Torvalds 
21541da177e4SLinus Torvalds /**
21551da177e4SLinus Torvalds  * proc_dointvec_minmax - read a vector of integers with min/max values
21561da177e4SLinus Torvalds  * @table: the sysctl table
21571da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
21581da177e4SLinus Torvalds  * @filp: the file structure
21591da177e4SLinus Torvalds  * @buffer: the user buffer
21601da177e4SLinus Torvalds  * @lenp: the size of the user buffer
21611da177e4SLinus Torvalds  * @ppos: file position
21621da177e4SLinus Torvalds  *
21631da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
21641da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
21651da177e4SLinus Torvalds  *
21661da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
21671da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
21681da177e4SLinus Torvalds  *
21691da177e4SLinus Torvalds  * Returns 0 on success.
21701da177e4SLinus Torvalds  */
2171d8217f07SEric W. Biederman int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
21721da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
21731da177e4SLinus Torvalds {
21741da177e4SLinus Torvalds 	struct do_proc_dointvec_minmax_conv_param param = {
21751da177e4SLinus Torvalds 		.min = (int *) table->extra1,
21761da177e4SLinus Torvalds 		.max = (int *) table->extra2,
21771da177e4SLinus Torvalds 	};
21781da177e4SLinus Torvalds 	return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
21791da177e4SLinus Torvalds 				do_proc_dointvec_minmax_conv, &param);
21801da177e4SLinus Torvalds }
21811da177e4SLinus Torvalds 
2182d8217f07SEric W. Biederman static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
21831da177e4SLinus Torvalds 				     struct file *filp,
21841da177e4SLinus Torvalds 				     void __user *buffer,
21851da177e4SLinus Torvalds 				     size_t *lenp, loff_t *ppos,
21861da177e4SLinus Torvalds 				     unsigned long convmul,
21871da177e4SLinus Torvalds 				     unsigned long convdiv)
21881da177e4SLinus Torvalds {
21891da177e4SLinus Torvalds #define TMPBUFLEN 21
21901da177e4SLinus Torvalds 	unsigned long *i, *min, *max, val;
21911da177e4SLinus Torvalds 	int vleft, first=1, neg;
21921da177e4SLinus Torvalds 	size_t len, left;
21931da177e4SLinus Torvalds 	char buf[TMPBUFLEN], *p;
21941da177e4SLinus Torvalds 	char __user *s = buffer;
21951da177e4SLinus Torvalds 
2196fcfbd547SKirill Korotaev 	if (!data || !table->maxlen || !*lenp ||
21971da177e4SLinus Torvalds 	    (*ppos && !write)) {
21981da177e4SLinus Torvalds 		*lenp = 0;
21991da177e4SLinus Torvalds 		return 0;
22001da177e4SLinus Torvalds 	}
22011da177e4SLinus Torvalds 
2202fcfbd547SKirill Korotaev 	i = (unsigned long *) data;
22031da177e4SLinus Torvalds 	min = (unsigned long *) table->extra1;
22041da177e4SLinus Torvalds 	max = (unsigned long *) table->extra2;
22051da177e4SLinus Torvalds 	vleft = table->maxlen / sizeof(unsigned long);
22061da177e4SLinus Torvalds 	left = *lenp;
22071da177e4SLinus Torvalds 
22081da177e4SLinus Torvalds 	for (; left && vleft--; i++, min++, max++, first=0) {
22091da177e4SLinus Torvalds 		if (write) {
22101da177e4SLinus Torvalds 			while (left) {
22111da177e4SLinus Torvalds 				char c;
22121da177e4SLinus Torvalds 				if (get_user(c, s))
22131da177e4SLinus Torvalds 					return -EFAULT;
22141da177e4SLinus Torvalds 				if (!isspace(c))
22151da177e4SLinus Torvalds 					break;
22161da177e4SLinus Torvalds 				left--;
22171da177e4SLinus Torvalds 				s++;
22181da177e4SLinus Torvalds 			}
22191da177e4SLinus Torvalds 			if (!left)
22201da177e4SLinus Torvalds 				break;
22211da177e4SLinus Torvalds 			neg = 0;
22221da177e4SLinus Torvalds 			len = left;
22231da177e4SLinus Torvalds 			if (len > TMPBUFLEN-1)
22241da177e4SLinus Torvalds 				len = TMPBUFLEN-1;
22251da177e4SLinus Torvalds 			if (copy_from_user(buf, s, len))
22261da177e4SLinus Torvalds 				return -EFAULT;
22271da177e4SLinus Torvalds 			buf[len] = 0;
22281da177e4SLinus Torvalds 			p = buf;
22291da177e4SLinus Torvalds 			if (*p == '-' && left > 1) {
22301da177e4SLinus Torvalds 				neg = 1;
2231bd9b0bacSBP, Praveen 				p++;
22321da177e4SLinus Torvalds 			}
22331da177e4SLinus Torvalds 			if (*p < '0' || *p > '9')
22341da177e4SLinus Torvalds 				break;
22351da177e4SLinus Torvalds 			val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
22361da177e4SLinus Torvalds 			len = p-buf;
22371da177e4SLinus Torvalds 			if ((len < left) && *p && !isspace(*p))
22381da177e4SLinus Torvalds 				break;
22391da177e4SLinus Torvalds 			if (neg)
22401da177e4SLinus Torvalds 				val = -val;
22411da177e4SLinus Torvalds 			s += len;
22421da177e4SLinus Torvalds 			left -= len;
22431da177e4SLinus Torvalds 
22441da177e4SLinus Torvalds 			if(neg)
22451da177e4SLinus Torvalds 				continue;
22461da177e4SLinus Torvalds 			if ((min && val < *min) || (max && val > *max))
22471da177e4SLinus Torvalds 				continue;
22481da177e4SLinus Torvalds 			*i = val;
22491da177e4SLinus Torvalds 		} else {
22501da177e4SLinus Torvalds 			p = buf;
22511da177e4SLinus Torvalds 			if (!first)
22521da177e4SLinus Torvalds 				*p++ = '\t';
22531da177e4SLinus Torvalds 			sprintf(p, "%lu", convdiv * (*i) / convmul);
22541da177e4SLinus Torvalds 			len = strlen(buf);
22551da177e4SLinus Torvalds 			if (len > left)
22561da177e4SLinus Torvalds 				len = left;
22571da177e4SLinus Torvalds 			if(copy_to_user(s, buf, len))
22581da177e4SLinus Torvalds 				return -EFAULT;
22591da177e4SLinus Torvalds 			left -= len;
22601da177e4SLinus Torvalds 			s += len;
22611da177e4SLinus Torvalds 		}
22621da177e4SLinus Torvalds 	}
22631da177e4SLinus Torvalds 
22641da177e4SLinus Torvalds 	if (!write && !first && left) {
22651da177e4SLinus Torvalds 		if(put_user('\n', s))
22661da177e4SLinus Torvalds 			return -EFAULT;
22671da177e4SLinus Torvalds 		left--, s++;
22681da177e4SLinus Torvalds 	}
22691da177e4SLinus Torvalds 	if (write) {
22701da177e4SLinus Torvalds 		while (left) {
22711da177e4SLinus Torvalds 			char c;
22721da177e4SLinus Torvalds 			if (get_user(c, s++))
22731da177e4SLinus Torvalds 				return -EFAULT;
22741da177e4SLinus Torvalds 			if (!isspace(c))
22751da177e4SLinus Torvalds 				break;
22761da177e4SLinus Torvalds 			left--;
22771da177e4SLinus Torvalds 		}
22781da177e4SLinus Torvalds 	}
22791da177e4SLinus Torvalds 	if (write && first)
22801da177e4SLinus Torvalds 		return -EINVAL;
22811da177e4SLinus Torvalds 	*lenp -= left;
22821da177e4SLinus Torvalds 	*ppos += *lenp;
22831da177e4SLinus Torvalds 	return 0;
22841da177e4SLinus Torvalds #undef TMPBUFLEN
22851da177e4SLinus Torvalds }
22861da177e4SLinus Torvalds 
2287d8217f07SEric W. Biederman static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2288fcfbd547SKirill Korotaev 				     struct file *filp,
2289fcfbd547SKirill Korotaev 				     void __user *buffer,
2290fcfbd547SKirill Korotaev 				     size_t *lenp, loff_t *ppos,
2291fcfbd547SKirill Korotaev 				     unsigned long convmul,
2292fcfbd547SKirill Korotaev 				     unsigned long convdiv)
2293fcfbd547SKirill Korotaev {
2294fcfbd547SKirill Korotaev 	return __do_proc_doulongvec_minmax(table->data, table, write,
2295fcfbd547SKirill Korotaev 			filp, buffer, lenp, ppos, convmul, convdiv);
2296fcfbd547SKirill Korotaev }
2297fcfbd547SKirill Korotaev 
22981da177e4SLinus Torvalds /**
22991da177e4SLinus Torvalds  * proc_doulongvec_minmax - read a vector of long integers with min/max values
23001da177e4SLinus Torvalds  * @table: the sysctl table
23011da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
23021da177e4SLinus Torvalds  * @filp: the file structure
23031da177e4SLinus Torvalds  * @buffer: the user buffer
23041da177e4SLinus Torvalds  * @lenp: the size of the user buffer
23051da177e4SLinus Torvalds  * @ppos: file position
23061da177e4SLinus Torvalds  *
23071da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
23081da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
23091da177e4SLinus Torvalds  *
23101da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
23111da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
23121da177e4SLinus Torvalds  *
23131da177e4SLinus Torvalds  * Returns 0 on success.
23141da177e4SLinus Torvalds  */
2315d8217f07SEric W. Biederman int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
23161da177e4SLinus Torvalds 			   void __user *buffer, size_t *lenp, loff_t *ppos)
23171da177e4SLinus Torvalds {
23181da177e4SLinus Torvalds     return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
23191da177e4SLinus Torvalds }
23201da177e4SLinus Torvalds 
23211da177e4SLinus Torvalds /**
23221da177e4SLinus Torvalds  * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
23231da177e4SLinus Torvalds  * @table: the sysctl table
23241da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
23251da177e4SLinus Torvalds  * @filp: the file structure
23261da177e4SLinus Torvalds  * @buffer: the user buffer
23271da177e4SLinus Torvalds  * @lenp: the size of the user buffer
23281da177e4SLinus Torvalds  * @ppos: file position
23291da177e4SLinus Torvalds  *
23301da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
23311da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string. The values
23321da177e4SLinus Torvalds  * are treated as milliseconds, and converted to jiffies when they are stored.
23331da177e4SLinus Torvalds  *
23341da177e4SLinus Torvalds  * This routine will ensure the values are within the range specified by
23351da177e4SLinus Torvalds  * table->extra1 (min) and table->extra2 (max).
23361da177e4SLinus Torvalds  *
23371da177e4SLinus Torvalds  * Returns 0 on success.
23381da177e4SLinus Torvalds  */
2339d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
23401da177e4SLinus Torvalds 				      struct file *filp,
23411da177e4SLinus Torvalds 				      void __user *buffer,
23421da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
23431da177e4SLinus Torvalds {
23441da177e4SLinus Torvalds     return do_proc_doulongvec_minmax(table, write, filp, buffer,
23451da177e4SLinus Torvalds 				     lenp, ppos, HZ, 1000l);
23461da177e4SLinus Torvalds }
23471da177e4SLinus Torvalds 
23481da177e4SLinus Torvalds 
23491da177e4SLinus Torvalds static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
23501da177e4SLinus Torvalds 					 int *valp,
23511da177e4SLinus Torvalds 					 int write, void *data)
23521da177e4SLinus Torvalds {
23531da177e4SLinus Torvalds 	if (write) {
2354cba9f33dSBart Samwel 		if (*lvalp > LONG_MAX / HZ)
2355cba9f33dSBart Samwel 			return 1;
23561da177e4SLinus Torvalds 		*valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
23571da177e4SLinus Torvalds 	} else {
23581da177e4SLinus Torvalds 		int val = *valp;
23591da177e4SLinus Torvalds 		unsigned long lval;
23601da177e4SLinus Torvalds 		if (val < 0) {
23611da177e4SLinus Torvalds 			*negp = -1;
23621da177e4SLinus Torvalds 			lval = (unsigned long)-val;
23631da177e4SLinus Torvalds 		} else {
23641da177e4SLinus Torvalds 			*negp = 0;
23651da177e4SLinus Torvalds 			lval = (unsigned long)val;
23661da177e4SLinus Torvalds 		}
23671da177e4SLinus Torvalds 		*lvalp = lval / HZ;
23681da177e4SLinus Torvalds 	}
23691da177e4SLinus Torvalds 	return 0;
23701da177e4SLinus Torvalds }
23711da177e4SLinus Torvalds 
23721da177e4SLinus Torvalds static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
23731da177e4SLinus Torvalds 						int *valp,
23741da177e4SLinus Torvalds 						int write, void *data)
23751da177e4SLinus Torvalds {
23761da177e4SLinus Torvalds 	if (write) {
2377cba9f33dSBart Samwel 		if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2378cba9f33dSBart Samwel 			return 1;
23791da177e4SLinus Torvalds 		*valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
23801da177e4SLinus Torvalds 	} else {
23811da177e4SLinus Torvalds 		int val = *valp;
23821da177e4SLinus Torvalds 		unsigned long lval;
23831da177e4SLinus Torvalds 		if (val < 0) {
23841da177e4SLinus Torvalds 			*negp = -1;
23851da177e4SLinus Torvalds 			lval = (unsigned long)-val;
23861da177e4SLinus Torvalds 		} else {
23871da177e4SLinus Torvalds 			*negp = 0;
23881da177e4SLinus Torvalds 			lval = (unsigned long)val;
23891da177e4SLinus Torvalds 		}
23901da177e4SLinus Torvalds 		*lvalp = jiffies_to_clock_t(lval);
23911da177e4SLinus Torvalds 	}
23921da177e4SLinus Torvalds 	return 0;
23931da177e4SLinus Torvalds }
23941da177e4SLinus Torvalds 
23951da177e4SLinus Torvalds static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
23961da177e4SLinus Torvalds 					    int *valp,
23971da177e4SLinus Torvalds 					    int write, void *data)
23981da177e4SLinus Torvalds {
23991da177e4SLinus Torvalds 	if (write) {
24001da177e4SLinus Torvalds 		*valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
24011da177e4SLinus Torvalds 	} else {
24021da177e4SLinus Torvalds 		int val = *valp;
24031da177e4SLinus Torvalds 		unsigned long lval;
24041da177e4SLinus Torvalds 		if (val < 0) {
24051da177e4SLinus Torvalds 			*negp = -1;
24061da177e4SLinus Torvalds 			lval = (unsigned long)-val;
24071da177e4SLinus Torvalds 		} else {
24081da177e4SLinus Torvalds 			*negp = 0;
24091da177e4SLinus Torvalds 			lval = (unsigned long)val;
24101da177e4SLinus Torvalds 		}
24111da177e4SLinus Torvalds 		*lvalp = jiffies_to_msecs(lval);
24121da177e4SLinus Torvalds 	}
24131da177e4SLinus Torvalds 	return 0;
24141da177e4SLinus Torvalds }
24151da177e4SLinus Torvalds 
24161da177e4SLinus Torvalds /**
24171da177e4SLinus Torvalds  * proc_dointvec_jiffies - read a vector of integers as seconds
24181da177e4SLinus Torvalds  * @table: the sysctl table
24191da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24201da177e4SLinus Torvalds  * @filp: the file structure
24211da177e4SLinus Torvalds  * @buffer: the user buffer
24221da177e4SLinus Torvalds  * @lenp: the size of the user buffer
24231da177e4SLinus Torvalds  * @ppos: file position
24241da177e4SLinus Torvalds  *
24251da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
24261da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
24271da177e4SLinus Torvalds  * The values read are assumed to be in seconds, and are converted into
24281da177e4SLinus Torvalds  * jiffies.
24291da177e4SLinus Torvalds  *
24301da177e4SLinus Torvalds  * Returns 0 on success.
24311da177e4SLinus Torvalds  */
2432d8217f07SEric W. Biederman int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
24331da177e4SLinus Torvalds 			  void __user *buffer, size_t *lenp, loff_t *ppos)
24341da177e4SLinus Torvalds {
24351da177e4SLinus Torvalds     return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
24361da177e4SLinus Torvalds 		    	    do_proc_dointvec_jiffies_conv,NULL);
24371da177e4SLinus Torvalds }
24381da177e4SLinus Torvalds 
24391da177e4SLinus Torvalds /**
24401da177e4SLinus Torvalds  * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
24411da177e4SLinus Torvalds  * @table: the sysctl table
24421da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24431da177e4SLinus Torvalds  * @filp: the file structure
24441da177e4SLinus Torvalds  * @buffer: the user buffer
24451da177e4SLinus Torvalds  * @lenp: the size of the user buffer
24461e5d5331SRandy Dunlap  * @ppos: pointer to the file position
24471da177e4SLinus Torvalds  *
24481da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
24491da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
24501da177e4SLinus Torvalds  * The values read are assumed to be in 1/USER_HZ seconds, and
24511da177e4SLinus Torvalds  * are converted into jiffies.
24521da177e4SLinus Torvalds  *
24531da177e4SLinus Torvalds  * Returns 0 on success.
24541da177e4SLinus Torvalds  */
2455d8217f07SEric W. Biederman int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
24561da177e4SLinus Torvalds 				 void __user *buffer, size_t *lenp, loff_t *ppos)
24571da177e4SLinus Torvalds {
24581da177e4SLinus Torvalds     return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
24591da177e4SLinus Torvalds 		    	    do_proc_dointvec_userhz_jiffies_conv,NULL);
24601da177e4SLinus Torvalds }
24611da177e4SLinus Torvalds 
24621da177e4SLinus Torvalds /**
24631da177e4SLinus Torvalds  * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
24641da177e4SLinus Torvalds  * @table: the sysctl table
24651da177e4SLinus Torvalds  * @write: %TRUE if this is a write to the sysctl file
24661da177e4SLinus Torvalds  * @filp: the file structure
24671da177e4SLinus Torvalds  * @buffer: the user buffer
24681da177e4SLinus Torvalds  * @lenp: the size of the user buffer
246967be2dd1SMartin Waitz  * @ppos: file position
247067be2dd1SMartin Waitz  * @ppos: the current position in the file
24711da177e4SLinus Torvalds  *
24721da177e4SLinus Torvalds  * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
24731da177e4SLinus Torvalds  * values from/to the user buffer, treated as an ASCII string.
24741da177e4SLinus Torvalds  * The values read are assumed to be in 1/1000 seconds, and
24751da177e4SLinus Torvalds  * are converted into jiffies.
24761da177e4SLinus Torvalds  *
24771da177e4SLinus Torvalds  * Returns 0 on success.
24781da177e4SLinus Torvalds  */
2479d8217f07SEric W. Biederman int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
24801da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
24811da177e4SLinus Torvalds {
24821da177e4SLinus Torvalds 	return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
24831da177e4SLinus Torvalds 				do_proc_dointvec_ms_jiffies_conv, NULL);
24841da177e4SLinus Torvalds }
24851da177e4SLinus Torvalds 
2486d8217f07SEric W. Biederman static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
24879ec52099SCedric Le Goater 			   void __user *buffer, size_t *lenp, loff_t *ppos)
24889ec52099SCedric Le Goater {
24899ec52099SCedric Le Goater 	struct pid *new_pid;
24909ec52099SCedric Le Goater 	pid_t tmp;
24919ec52099SCedric Le Goater 	int r;
24929ec52099SCedric Le Goater 
24936c5f3e7bSPavel Emelyanov 	tmp = pid_vnr(cad_pid);
24949ec52099SCedric Le Goater 
24959ec52099SCedric Le Goater 	r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
24969ec52099SCedric Le Goater 			       lenp, ppos, NULL, NULL);
24979ec52099SCedric Le Goater 	if (r || !write)
24989ec52099SCedric Le Goater 		return r;
24999ec52099SCedric Le Goater 
25009ec52099SCedric Le Goater 	new_pid = find_get_pid(tmp);
25019ec52099SCedric Le Goater 	if (!new_pid)
25029ec52099SCedric Le Goater 		return -ESRCH;
25039ec52099SCedric Le Goater 
25049ec52099SCedric Le Goater 	put_pid(xchg(&cad_pid, new_pid));
25059ec52099SCedric Le Goater 	return 0;
25069ec52099SCedric Le Goater }
25079ec52099SCedric Le Goater 
25081da177e4SLinus Torvalds #else /* CONFIG_PROC_FS */
25091da177e4SLinus Torvalds 
2510d8217f07SEric W. Biederman int proc_dostring(struct ctl_table *table, int write, struct file *filp,
25111da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
25121da177e4SLinus Torvalds {
25131da177e4SLinus Torvalds 	return -ENOSYS;
25141da177e4SLinus Torvalds }
25151da177e4SLinus Torvalds 
2516d8217f07SEric W. Biederman int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
25171da177e4SLinus Torvalds 		  void __user *buffer, size_t *lenp, loff_t *ppos)
25181da177e4SLinus Torvalds {
25191da177e4SLinus Torvalds 	return -ENOSYS;
25201da177e4SLinus Torvalds }
25211da177e4SLinus Torvalds 
2522d8217f07SEric W. Biederman int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
25231da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
25241da177e4SLinus Torvalds {
25251da177e4SLinus Torvalds 	return -ENOSYS;
25261da177e4SLinus Torvalds }
25271da177e4SLinus Torvalds 
2528d8217f07SEric W. Biederman int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
25291da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
25301da177e4SLinus Torvalds {
25311da177e4SLinus Torvalds 	return -ENOSYS;
25321da177e4SLinus Torvalds }
25331da177e4SLinus Torvalds 
2534d8217f07SEric W. Biederman int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
25351da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
25361da177e4SLinus Torvalds {
25371da177e4SLinus Torvalds 	return -ENOSYS;
25381da177e4SLinus Torvalds }
25391da177e4SLinus Torvalds 
2540d8217f07SEric W. Biederman int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
25411da177e4SLinus Torvalds 			     void __user *buffer, size_t *lenp, loff_t *ppos)
25421da177e4SLinus Torvalds {
25431da177e4SLinus Torvalds 	return -ENOSYS;
25441da177e4SLinus Torvalds }
25451da177e4SLinus Torvalds 
2546d8217f07SEric W. Biederman int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
25471da177e4SLinus Torvalds 		    void __user *buffer, size_t *lenp, loff_t *ppos)
25481da177e4SLinus Torvalds {
25491da177e4SLinus Torvalds 	return -ENOSYS;
25501da177e4SLinus Torvalds }
25511da177e4SLinus Torvalds 
2552d8217f07SEric W. Biederman int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
25531da177e4SLinus Torvalds 				      struct file *filp,
25541da177e4SLinus Torvalds 				      void __user *buffer,
25551da177e4SLinus Torvalds 				      size_t *lenp, loff_t *ppos)
25561da177e4SLinus Torvalds {
25571da177e4SLinus Torvalds     return -ENOSYS;
25581da177e4SLinus Torvalds }
25591da177e4SLinus Torvalds 
25601da177e4SLinus Torvalds 
25611da177e4SLinus Torvalds #endif /* CONFIG_PROC_FS */
25621da177e4SLinus Torvalds 
25631da177e4SLinus Torvalds 
2564b89a8171SEric W. Biederman #ifdef CONFIG_SYSCTL_SYSCALL
25651da177e4SLinus Torvalds /*
25661da177e4SLinus Torvalds  * General sysctl support routines
25671da177e4SLinus Torvalds  */
25681da177e4SLinus Torvalds 
256949a0c458SEric W. Biederman /* The generic sysctl data routine (used if no strategy routine supplied) */
257049a0c458SEric W. Biederman int sysctl_data(struct ctl_table *table, int __user *name, int nlen,
257149a0c458SEric W. Biederman 		void __user *oldval, size_t __user *oldlenp,
257249a0c458SEric W. Biederman 		void __user *newval, size_t newlen)
257349a0c458SEric W. Biederman {
257449a0c458SEric W. Biederman 	size_t len;
257549a0c458SEric W. Biederman 
257649a0c458SEric W. Biederman 	/* Get out of I don't have a variable */
257749a0c458SEric W. Biederman 	if (!table->data || !table->maxlen)
257849a0c458SEric W. Biederman 		return -ENOTDIR;
257949a0c458SEric W. Biederman 
258049a0c458SEric W. Biederman 	if (oldval && oldlenp) {
258149a0c458SEric W. Biederman 		if (get_user(len, oldlenp))
258249a0c458SEric W. Biederman 			return -EFAULT;
258349a0c458SEric W. Biederman 		if (len) {
258449a0c458SEric W. Biederman 			if (len > table->maxlen)
258549a0c458SEric W. Biederman 				len = table->maxlen;
258649a0c458SEric W. Biederman 			if (copy_to_user(oldval, table->data, len))
258749a0c458SEric W. Biederman 				return -EFAULT;
258849a0c458SEric W. Biederman 			if (put_user(len, oldlenp))
258949a0c458SEric W. Biederman 				return -EFAULT;
259049a0c458SEric W. Biederman 		}
259149a0c458SEric W. Biederman 	}
259249a0c458SEric W. Biederman 
259349a0c458SEric W. Biederman 	if (newval && newlen) {
259449a0c458SEric W. Biederman 		if (newlen > table->maxlen)
259549a0c458SEric W. Biederman 			newlen = table->maxlen;
259649a0c458SEric W. Biederman 
259749a0c458SEric W. Biederman 		if (copy_from_user(table->data, newval, newlen))
259849a0c458SEric W. Biederman 			return -EFAULT;
259949a0c458SEric W. Biederman 	}
260049a0c458SEric W. Biederman 	return 1;
260149a0c458SEric W. Biederman }
260249a0c458SEric W. Biederman 
26031da177e4SLinus Torvalds /* The generic string strategy routine: */
2604d8217f07SEric W. Biederman int sysctl_string(struct ctl_table *table, int __user *name, int nlen,
26051da177e4SLinus Torvalds 		  void __user *oldval, size_t __user *oldlenp,
26061f29bcd7SAlexey Dobriyan 		  void __user *newval, size_t newlen)
26071da177e4SLinus Torvalds {
26081da177e4SLinus Torvalds 	if (!table->data || !table->maxlen)
26091da177e4SLinus Torvalds 		return -ENOTDIR;
26101da177e4SLinus Torvalds 
26111da177e4SLinus Torvalds 	if (oldval && oldlenp) {
2612de9e007dSLinus Torvalds 		size_t bufsize;
2613de9e007dSLinus Torvalds 		if (get_user(bufsize, oldlenp))
26141da177e4SLinus Torvalds 			return -EFAULT;
2615de9e007dSLinus Torvalds 		if (bufsize) {
2616de9e007dSLinus Torvalds 			size_t len = strlen(table->data), copied;
2617de9e007dSLinus Torvalds 
2618de9e007dSLinus Torvalds 			/* This shouldn't trigger for a well-formed sysctl */
2619de9e007dSLinus Torvalds 			if (len > table->maxlen)
26201da177e4SLinus Torvalds 				len = table->maxlen;
2621de9e007dSLinus Torvalds 
2622de9e007dSLinus Torvalds 			/* Copy up to a max of bufsize-1 bytes of the string */
2623de9e007dSLinus Torvalds 			copied = (len >= bufsize) ? bufsize - 1 : len;
2624de9e007dSLinus Torvalds 
2625de9e007dSLinus Torvalds 			if (copy_to_user(oldval, table->data, copied) ||
2626de9e007dSLinus Torvalds 			    put_user(0, (char __user *)(oldval + copied)))
26271da177e4SLinus Torvalds 				return -EFAULT;
26281da177e4SLinus Torvalds 			if (put_user(len, oldlenp))
26291da177e4SLinus Torvalds 				return -EFAULT;
26301da177e4SLinus Torvalds 		}
26311da177e4SLinus Torvalds 	}
26321da177e4SLinus Torvalds 	if (newval && newlen) {
2633de9e007dSLinus Torvalds 		size_t len = newlen;
26341da177e4SLinus Torvalds 		if (len > table->maxlen)
26351da177e4SLinus Torvalds 			len = table->maxlen;
26361da177e4SLinus Torvalds 		if(copy_from_user(table->data, newval, len))
26371da177e4SLinus Torvalds 			return -EFAULT;
26381da177e4SLinus Torvalds 		if (len == table->maxlen)
26391da177e4SLinus Torvalds 			len--;
26401da177e4SLinus Torvalds 		((char *) table->data)[len] = 0;
26411da177e4SLinus Torvalds 	}
264282c9df82SYi Yang 	return 1;
26431da177e4SLinus Torvalds }
26441da177e4SLinus Torvalds 
26451da177e4SLinus Torvalds /*
26461da177e4SLinus Torvalds  * This function makes sure that all of the integers in the vector
26471da177e4SLinus Torvalds  * are between the minimum and maximum values given in the arrays
26481da177e4SLinus Torvalds  * table->extra1 and table->extra2, respectively.
26491da177e4SLinus Torvalds  */
2650d8217f07SEric W. Biederman int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen,
26511da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
26521f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
26531da177e4SLinus Torvalds {
26541da177e4SLinus Torvalds 
26551da177e4SLinus Torvalds 	if (newval && newlen) {
26561da177e4SLinus Torvalds 		int __user *vec = (int __user *) newval;
26571da177e4SLinus Torvalds 		int *min = (int *) table->extra1;
26581da177e4SLinus Torvalds 		int *max = (int *) table->extra2;
26591da177e4SLinus Torvalds 		size_t length;
26601da177e4SLinus Torvalds 		int i;
26611da177e4SLinus Torvalds 
26621da177e4SLinus Torvalds 		if (newlen % sizeof(int) != 0)
26631da177e4SLinus Torvalds 			return -EINVAL;
26641da177e4SLinus Torvalds 
26651da177e4SLinus Torvalds 		if (!table->extra1 && !table->extra2)
26661da177e4SLinus Torvalds 			return 0;
26671da177e4SLinus Torvalds 
26681da177e4SLinus Torvalds 		if (newlen > table->maxlen)
26691da177e4SLinus Torvalds 			newlen = table->maxlen;
26701da177e4SLinus Torvalds 		length = newlen / sizeof(int);
26711da177e4SLinus Torvalds 
26721da177e4SLinus Torvalds 		for (i = 0; i < length; i++) {
26731da177e4SLinus Torvalds 			int value;
26741da177e4SLinus Torvalds 			if (get_user(value, vec + i))
26751da177e4SLinus Torvalds 				return -EFAULT;
26761da177e4SLinus Torvalds 			if (min && value < min[i])
26771da177e4SLinus Torvalds 				return -EINVAL;
26781da177e4SLinus Torvalds 			if (max && value > max[i])
26791da177e4SLinus Torvalds 				return -EINVAL;
26801da177e4SLinus Torvalds 		}
26811da177e4SLinus Torvalds 	}
26821da177e4SLinus Torvalds 	return 0;
26831da177e4SLinus Torvalds }
26841da177e4SLinus Torvalds 
26851da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */
2686d8217f07SEric W. Biederman int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen,
26871da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
26881f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
26891da177e4SLinus Torvalds {
26903ee75ac3SAlexey Dobriyan 	if (oldval && oldlenp) {
26911da177e4SLinus Torvalds 		size_t olen;
26923ee75ac3SAlexey Dobriyan 
26931da177e4SLinus Torvalds 		if (get_user(olen, oldlenp))
26941da177e4SLinus Torvalds 			return -EFAULT;
26953ee75ac3SAlexey Dobriyan 		if (olen) {
26963ee75ac3SAlexey Dobriyan 			int val;
26973ee75ac3SAlexey Dobriyan 
26983ee75ac3SAlexey Dobriyan 			if (olen < sizeof(int))
26991da177e4SLinus Torvalds 				return -EINVAL;
27003ee75ac3SAlexey Dobriyan 
27013ee75ac3SAlexey Dobriyan 			val = *(int *)(table->data) / HZ;
27023ee75ac3SAlexey Dobriyan 			if (put_user(val, (int __user *)oldval))
27031da177e4SLinus Torvalds 				return -EFAULT;
27043ee75ac3SAlexey Dobriyan 			if (put_user(sizeof(int), oldlenp))
27053ee75ac3SAlexey Dobriyan 				return -EFAULT;
27063ee75ac3SAlexey Dobriyan 		}
27071da177e4SLinus Torvalds 	}
27081da177e4SLinus Torvalds 	if (newval && newlen) {
27091da177e4SLinus Torvalds 		int new;
27101da177e4SLinus Torvalds 		if (newlen != sizeof(int))
27111da177e4SLinus Torvalds 			return -EINVAL;
27121da177e4SLinus Torvalds 		if (get_user(new, (int __user *)newval))
27131da177e4SLinus Torvalds 			return -EFAULT;
27141da177e4SLinus Torvalds 		*(int *)(table->data) = new*HZ;
27151da177e4SLinus Torvalds 	}
27161da177e4SLinus Torvalds 	return 1;
27171da177e4SLinus Torvalds }
27181da177e4SLinus Torvalds 
27191da177e4SLinus Torvalds /* Strategy function to convert jiffies to seconds */
2720d8217f07SEric W. Biederman int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen,
27211da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
27221f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
27231da177e4SLinus Torvalds {
27243ee75ac3SAlexey Dobriyan 	if (oldval && oldlenp) {
27251da177e4SLinus Torvalds 		size_t olen;
27263ee75ac3SAlexey Dobriyan 
27271da177e4SLinus Torvalds 		if (get_user(olen, oldlenp))
27281da177e4SLinus Torvalds 			return -EFAULT;
27293ee75ac3SAlexey Dobriyan 		if (olen) {
27303ee75ac3SAlexey Dobriyan 			int val;
27313ee75ac3SAlexey Dobriyan 
27323ee75ac3SAlexey Dobriyan 			if (olen < sizeof(int))
27331da177e4SLinus Torvalds 				return -EINVAL;
27343ee75ac3SAlexey Dobriyan 
27353ee75ac3SAlexey Dobriyan 			val = jiffies_to_msecs(*(int *)(table->data));
27363ee75ac3SAlexey Dobriyan 			if (put_user(val, (int __user *)oldval))
27371da177e4SLinus Torvalds 				return -EFAULT;
27383ee75ac3SAlexey Dobriyan 			if (put_user(sizeof(int), oldlenp))
27393ee75ac3SAlexey Dobriyan 				return -EFAULT;
27403ee75ac3SAlexey Dobriyan 		}
27411da177e4SLinus Torvalds 	}
27421da177e4SLinus Torvalds 	if (newval && newlen) {
27431da177e4SLinus Torvalds 		int new;
27441da177e4SLinus Torvalds 		if (newlen != sizeof(int))
27451da177e4SLinus Torvalds 			return -EINVAL;
27461da177e4SLinus Torvalds 		if (get_user(new, (int __user *)newval))
27471da177e4SLinus Torvalds 			return -EFAULT;
27481da177e4SLinus Torvalds 		*(int *)(table->data) = msecs_to_jiffies(new);
27491da177e4SLinus Torvalds 	}
27501da177e4SLinus Torvalds 	return 1;
27511da177e4SLinus Torvalds }
27521da177e4SLinus Torvalds 
2753c4b8b769SEric W. Biederman 
2754c4b8b769SEric W. Biederman 
2755b89a8171SEric W. Biederman #else /* CONFIG_SYSCTL_SYSCALL */
27561da177e4SLinus Torvalds 
27571da177e4SLinus Torvalds 
27581da177e4SLinus Torvalds asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
27591da177e4SLinus Torvalds {
27600e009be8SEric W. Biederman 	struct __sysctl_args tmp;
27617058cb02SEric W. Biederman 	int error;
27620e009be8SEric W. Biederman 
27630e009be8SEric W. Biederman 	if (copy_from_user(&tmp, args, sizeof(tmp)))
27640e009be8SEric W. Biederman 		return -EFAULT;
27650e009be8SEric W. Biederman 
27667058cb02SEric W. Biederman 	error = deprecated_sysctl_warning(&tmp);
2767b89a8171SEric W. Biederman 
27687058cb02SEric W. Biederman 	/* If no error reading the parameters then just -ENOSYS ... */
27697058cb02SEric W. Biederman 	if (!error)
27707058cb02SEric W. Biederman 		error = -ENOSYS;
27717058cb02SEric W. Biederman 
27727058cb02SEric W. Biederman 	return error;
27731da177e4SLinus Torvalds }
27741da177e4SLinus Torvalds 
277549a0c458SEric W. Biederman int sysctl_data(struct ctl_table *table, int __user *name, int nlen,
277649a0c458SEric W. Biederman 		  void __user *oldval, size_t __user *oldlenp,
277749a0c458SEric W. Biederman 		  void __user *newval, size_t newlen)
277849a0c458SEric W. Biederman {
277949a0c458SEric W. Biederman 	return -ENOSYS;
278049a0c458SEric W. Biederman }
278149a0c458SEric W. Biederman 
2782d8217f07SEric W. Biederman int sysctl_string(struct ctl_table *table, int __user *name, int nlen,
27831da177e4SLinus Torvalds 		  void __user *oldval, size_t __user *oldlenp,
27841f29bcd7SAlexey Dobriyan 		  void __user *newval, size_t newlen)
27851da177e4SLinus Torvalds {
27861da177e4SLinus Torvalds 	return -ENOSYS;
27871da177e4SLinus Torvalds }
27881da177e4SLinus Torvalds 
2789d8217f07SEric W. Biederman int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen,
27901da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
27911f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
27921da177e4SLinus Torvalds {
27931da177e4SLinus Torvalds 	return -ENOSYS;
27941da177e4SLinus Torvalds }
27951da177e4SLinus Torvalds 
2796d8217f07SEric W. Biederman int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen,
27971da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
27981f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
27991da177e4SLinus Torvalds {
28001da177e4SLinus Torvalds 	return -ENOSYS;
28011da177e4SLinus Torvalds }
28021da177e4SLinus Torvalds 
2803d8217f07SEric W. Biederman int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen,
28041da177e4SLinus Torvalds 		void __user *oldval, size_t __user *oldlenp,
28051f29bcd7SAlexey Dobriyan 		void __user *newval, size_t newlen)
28061da177e4SLinus Torvalds {
28071da177e4SLinus Torvalds 	return -ENOSYS;
28081da177e4SLinus Torvalds }
28091da177e4SLinus Torvalds 
2810b89a8171SEric W. Biederman #endif /* CONFIG_SYSCTL_SYSCALL */
28111da177e4SLinus Torvalds 
28127058cb02SEric W. Biederman static int deprecated_sysctl_warning(struct __sysctl_args *args)
28137058cb02SEric W. Biederman {
28147058cb02SEric W. Biederman 	static int msg_count;
28157058cb02SEric W. Biederman 	int name[CTL_MAXNAME];
28167058cb02SEric W. Biederman 	int i;
28177058cb02SEric W. Biederman 
28186fc48af8STetsuo Handa 	/* Check args->nlen. */
28196fc48af8STetsuo Handa 	if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
28206fc48af8STetsuo Handa 		return -ENOTDIR;
28216fc48af8STetsuo Handa 
28227058cb02SEric W. Biederman 	/* Read in the sysctl name for better debug message logging */
28237058cb02SEric W. Biederman 	for (i = 0; i < args->nlen; i++)
28247058cb02SEric W. Biederman 		if (get_user(name[i], args->name + i))
28257058cb02SEric W. Biederman 			return -EFAULT;
28267058cb02SEric W. Biederman 
28277058cb02SEric W. Biederman 	/* Ignore accesses to kernel.version */
28287058cb02SEric W. Biederman 	if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
28297058cb02SEric W. Biederman 		return 0;
28307058cb02SEric W. Biederman 
28317058cb02SEric W. Biederman 	if (msg_count < 5) {
28327058cb02SEric W. Biederman 		msg_count++;
28337058cb02SEric W. Biederman 		printk(KERN_INFO
28347058cb02SEric W. Biederman 			"warning: process `%s' used the deprecated sysctl "
28357058cb02SEric W. Biederman 			"system call with ", current->comm);
28367058cb02SEric W. Biederman 		for (i = 0; i < args->nlen; i++)
28377058cb02SEric W. Biederman 			printk("%d.", name[i]);
28387058cb02SEric W. Biederman 		printk("\n");
28397058cb02SEric W. Biederman 	}
28407058cb02SEric W. Biederman 	return 0;
28417058cb02SEric W. Biederman }
28427058cb02SEric W. Biederman 
28431da177e4SLinus Torvalds /*
28441da177e4SLinus Torvalds  * No sense putting this after each symbol definition, twice,
28451da177e4SLinus Torvalds  * exception granted :-)
28461da177e4SLinus Torvalds  */
28471da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec);
28481da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_jiffies);
28491da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_minmax);
28501da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
28511da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
28521da177e4SLinus Torvalds EXPORT_SYMBOL(proc_dostring);
28531da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_minmax);
28541da177e4SLinus Torvalds EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
28551da177e4SLinus Torvalds EXPORT_SYMBOL(register_sysctl_table);
285629e796fdSEric W. Biederman EXPORT_SYMBOL(register_sysctl_paths);
28571da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_intvec);
28581da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_jiffies);
28591da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_ms_jiffies);
28601da177e4SLinus Torvalds EXPORT_SYMBOL(sysctl_string);
286149a0c458SEric W. Biederman EXPORT_SYMBOL(sysctl_data);
28621da177e4SLinus Torvalds EXPORT_SYMBOL(unregister_sysctl_table);
2863