blob: 04402ab7a0466ca02d221531b96cb20b80d66398 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
22#include <linux/mm.h>
23#include <linux/swap.h>
24#include <linux/slab.h>
25#include <linux/sysctl.h>
Dave Youngd33ed522010-03-10 15:23:59 -080026#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080027#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070029#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020031#include <linux/kmemcheck.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070032#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <linux/init.h>
34#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010035#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030036#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#include <linux/sysrq.h>
38#include <linux/highuid.h>
39#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020040#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070041#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070044#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/times.h>
46#include <linux/limits.h>
47#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020048#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070050#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080051#include <linux/nfs_fs.h>
52#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070053#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020054#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020055#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050056#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020057#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070058#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040059#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070060#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000061#include <linux/binfmts.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63#include <asm/uaccess.h>
64#include <asm/processor.h>
65
Andi Kleen29cbc782006-09-30 01:47:55 +020066#ifdef CONFIG_X86
67#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010068#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010069#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020070#endif
David Howellsd550bbd2012-03-28 18:30:03 +010071#ifdef CONFIG_SPARC
72#include <asm/setup.h>
73#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080074#ifdef CONFIG_BSD_PROCESS_ACCT
75#include <linux/acct.h>
76#endif
Dave Young4f0e0562010-03-10 15:24:09 -080077#ifdef CONFIG_RT_MUTEXES
78#include <linux/rtmutex.h>
79#endif
Dave Young2edf5e42010-03-10 15:24:10 -080080#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
81#include <linux/lockdep.h>
82#endif
Dave Young15485a42010-03-10 15:24:07 -080083#ifdef CONFIG_CHR_DEV_SG
84#include <scsi/sg.h>
85#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020086
Don Zickus58687ac2010-05-07 17:11:44 -040087#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050088#include <linux/nmi.h>
89#endif
90
Eric W. Biederman7058cb02007-10-18 03:05:58 -070091
Linus Torvalds1da177e2005-04-16 15:20:36 -070092#if defined(CONFIG_SYSCTL)
93
94/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070095extern int sysctl_overcommit_memory;
96extern int sysctl_overcommit_ratio;
97extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070098extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070099extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700101extern unsigned int core_pipe_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102extern int pid_max;
103extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -0800105extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800106extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200107extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100108extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400109extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000110#ifndef CONFIG_MMU
111extern int sysctl_nr_trim_pages;
112#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200113#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200114extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200115#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700117/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400118#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700119static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200120static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700121#endif
122
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700123static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700124static int __maybe_unused one = 1;
125static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700126static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800127static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700128static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700129#ifdef CONFIG_PRINTK
130static int ten_thousand = 10000;
131#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700132
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700133/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
134static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
135
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
137static int maxolduid = 65535;
138static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800139static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
141static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700142static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
Dave Youngd14f1722010-02-25 20:28:57 -0500144#ifdef CONFIG_INOTIFY_USER
145#include <linux/inotify.h>
146#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700147#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700148#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149#endif
150
David S. Miller08714202008-11-16 23:49:24 -0800151#ifdef CONFIG_SPARC64
152extern int sysctl_tsb_ratio;
153#endif
154
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155#ifdef __hppa__
156extern int pwrsw_enabled;
157extern int unaligned_enabled;
158#endif
159
Jes Sorensend2b176e2006-02-28 09:42:23 -0800160#ifdef CONFIG_IA64
161extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800162extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800163#endif
164
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700165#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700166static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700167 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700168static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800169 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700170#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700171
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700172#ifdef CONFIG_PRINTK
173static int proc_dmesg_restrict(struct ctl_table *table, int write,
174 void __user *buffer, size_t *lenp, loff_t *ppos);
175#endif
176
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700177#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800178/* Note: sysrq code uses it's own private copy */
179static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700180
181static int sysrq_sysctl_handler(ctl_table *table, int write,
182 void __user *buffer, size_t *lenp,
183 loff_t *ppos)
184{
185 int error;
186
187 error = proc_dointvec(table, write, buffer, lenp, ppos);
188 if (error)
189 return error;
190
191 if (write)
192 sysrq_toggle_support(__sysrq_enabled);
193
194 return 0;
195}
196
197#endif
198
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700199static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100200static struct ctl_table_root sysctl_table_root;
201static struct ctl_table_header root_table_header = {
Al Virodfef6dcd32011-03-08 01:25:28 -0500202 {{.count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100203 .ctl_table = root_table,
Al Virodfef6dcd32011-03-08 01:25:28 -0500204 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),}},
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100205 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400206 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100207};
208static struct ctl_table_root sysctl_table_root = {
209 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400210 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100211};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700213static struct ctl_table kern_table[];
214static struct ctl_table vm_table[];
215static struct ctl_table fs_table[];
216static struct ctl_table debug_table[];
217static struct ctl_table dev_table[];
218extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800219#ifdef CONFIG_EPOLL
220extern struct ctl_table epoll_table[];
221#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
223#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
224int sysctl_legacy_va_layout;
225#endif
226
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227/* The default sysctl tables: */
228
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700229static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 .procname = "kernel",
232 .mode = 0555,
233 .child = kern_table,
234 },
235 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 .procname = "vm",
237 .mode = 0555,
238 .child = vm_table,
239 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 .procname = "fs",
242 .mode = 0555,
243 .child = fs_table,
244 },
245 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 .procname = "debug",
247 .mode = 0555,
248 .child = debug_table,
249 },
250 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 .procname = "dev",
252 .mode = 0555,
253 .child = dev_table,
254 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700255 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256};
257
Ingo Molnar77e54a12007-07-09 18:52:00 +0200258#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100259static int min_sched_granularity_ns = 100000; /* 100 usecs */
260static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
261static int min_wakeup_granularity_ns; /* 0 usecs */
262static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100263static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
264static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Ingo Molnar77e54a12007-07-09 18:52:00 +0200265#endif
266
Mel Gorman5e771902010-05-24 14:32:31 -0700267#ifdef CONFIG_COMPACTION
268static int min_extfrag_threshold;
269static int max_extfrag_threshold = 1000;
270#endif
271
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700272static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200273 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200274 .procname = "sched_child_runs_first",
275 .data = &sysctl_sched_child_runs_first,
276 .maxlen = sizeof(unsigned int),
277 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800278 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200279 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200280#ifdef CONFIG_SCHED_DEBUG
281 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100282 .procname = "sched_min_granularity_ns",
283 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200284 .maxlen = sizeof(unsigned int),
285 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800286 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100287 .extra1 = &min_sched_granularity_ns,
288 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200289 },
290 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200291 .procname = "sched_latency_ns",
292 .data = &sysctl_sched_latency,
293 .maxlen = sizeof(unsigned int),
294 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800295 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200296 .extra1 = &min_sched_granularity_ns,
297 .extra2 = &max_sched_granularity_ns,
298 },
299 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200300 .procname = "sched_wakeup_granularity_ns",
301 .data = &sysctl_sched_wakeup_granularity,
302 .maxlen = sizeof(unsigned int),
303 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800304 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200305 .extra1 = &min_wakeup_granularity_ns,
306 .extra2 = &max_wakeup_granularity_ns,
307 },
308 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100309 .procname = "sched_tunable_scaling",
310 .data = &sysctl_sched_tunable_scaling,
311 .maxlen = sizeof(enum sched_tunable_scaling),
312 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800313 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100314 .extra1 = &min_sched_tunable_scaling,
315 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200316 },
317 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200318 .procname = "sched_migration_cost",
319 .data = &sysctl_sched_migration_cost,
320 .maxlen = sizeof(unsigned int),
321 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800322 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200323 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100324 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100325 .procname = "sched_nr_migrate",
326 .data = &sysctl_sched_nr_migrate,
327 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100328 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800329 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100330 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530331 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200332 .procname = "sched_time_avg",
333 .data = &sysctl_sched_time_avg,
334 .maxlen = sizeof(unsigned int),
335 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800336 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200337 },
338 {
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800339 .procname = "sched_shares_window",
340 .data = &sysctl_sched_shares_window,
341 .maxlen = sizeof(unsigned int),
342 .mode = 0644,
343 .proc_handler = proc_dointvec,
344 },
345 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530346 .procname = "timer_migration",
347 .data = &sysctl_timer_migration,
348 .maxlen = sizeof(unsigned int),
349 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800350 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530351 .extra1 = &zero,
352 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530353 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200354#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200355 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100356 .procname = "sched_rt_period_us",
357 .data = &sysctl_sched_rt_period,
358 .maxlen = sizeof(unsigned int),
359 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800360 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100361 },
362 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100363 .procname = "sched_rt_runtime_us",
364 .data = &sysctl_sched_rt_runtime,
365 .maxlen = sizeof(int),
366 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800367 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100368 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100369#ifdef CONFIG_SCHED_AUTOGROUP
370 {
371 .procname = "sched_autogroup_enabled",
372 .data = &sysctl_sched_autogroup_enabled,
373 .maxlen = sizeof(unsigned int),
374 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800375 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100376 .extra1 = &zero,
377 .extra2 = &one,
378 },
379#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700380#ifdef CONFIG_CFS_BANDWIDTH
381 {
382 .procname = "sched_cfs_bandwidth_slice_us",
383 .data = &sysctl_sched_cfs_bandwidth_slice,
384 .maxlen = sizeof(unsigned int),
385 .mode = 0644,
386 .proc_handler = proc_dointvec_minmax,
387 .extra1 = &one,
388 },
389#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700390#ifdef CONFIG_PROVE_LOCKING
391 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700392 .procname = "prove_locking",
393 .data = &prove_locking,
394 .maxlen = sizeof(int),
395 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800396 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700397 },
398#endif
399#ifdef CONFIG_LOCK_STAT
400 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700401 .procname = "lock_stat",
402 .data = &lock_stat,
403 .maxlen = sizeof(int),
404 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800405 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700406 },
407#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200408 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 .procname = "panic",
410 .data = &panic_timeout,
411 .maxlen = sizeof(int),
412 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800413 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 },
415 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 .procname = "core_uses_pid",
417 .data = &core_uses_pid,
418 .maxlen = sizeof(int),
419 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800420 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 },
422 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 .procname = "core_pattern",
424 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700425 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800427 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 },
Neil Hormana2939802009-09-23 15:56:56 -0700429 {
Neil Hormana2939802009-09-23 15:56:56 -0700430 .procname = "core_pipe_limit",
431 .data = &core_pipe_limit,
432 .maxlen = sizeof(unsigned int),
433 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800434 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700435 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800436#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700439 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800440 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800441 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800443#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100444#ifdef CONFIG_LATENCYTOP
445 {
446 .procname = "latencytop",
447 .data = &latencytop_enabled,
448 .maxlen = sizeof(int),
449 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800450 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100451 },
452#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453#ifdef CONFIG_BLK_DEV_INITRD
454 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 .procname = "real-root-dev",
456 .data = &real_root_dev,
457 .maxlen = sizeof(int),
458 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800459 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 },
461#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700462 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700463 .procname = "print-fatal-signals",
464 .data = &print_fatal_signals,
465 .maxlen = sizeof(int),
466 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800467 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700468 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700469#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 .procname = "reboot-cmd",
472 .data = reboot_command,
473 .maxlen = 256,
474 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800475 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 },
477 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 .procname = "stop-a",
479 .data = &stop_a_enabled,
480 .maxlen = sizeof (int),
481 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800482 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 },
484 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 .procname = "scons-poweroff",
486 .data = &scons_pwroff,
487 .maxlen = sizeof (int),
488 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800489 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 },
491#endif
David S. Miller08714202008-11-16 23:49:24 -0800492#ifdef CONFIG_SPARC64
493 {
David S. Miller08714202008-11-16 23:49:24 -0800494 .procname = "tsb-ratio",
495 .data = &sysctl_tsb_ratio,
496 .maxlen = sizeof (int),
497 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800498 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800499 },
500#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501#ifdef __hppa__
502 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 .procname = "soft-power",
504 .data = &pwrsw_enabled,
505 .maxlen = sizeof (int),
506 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800507 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508 },
509 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 .procname = "unaligned-trap",
511 .data = &unaligned_enabled,
512 .maxlen = sizeof (int),
513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800514 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 },
516#endif
517 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 .procname = "ctrl-alt-del",
519 .data = &C_A_D,
520 .maxlen = sizeof(int),
521 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800522 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400524#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200525 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200526 .procname = "ftrace_enabled",
527 .data = &ftrace_enabled,
528 .maxlen = sizeof(int),
529 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800530 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200531 },
532#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500533#ifdef CONFIG_STACK_TRACER
534 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500535 .procname = "stack_tracer_enabled",
536 .data = &stack_tracer_enabled,
537 .maxlen = sizeof(int),
538 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800539 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500540 },
541#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400542#ifdef CONFIG_TRACING
543 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100544 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400545 .data = &ftrace_dump_on_oops,
546 .maxlen = sizeof(int),
547 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800548 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400549 },
550#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200551#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 .procname = "modprobe",
554 .data = &modprobe_path,
555 .maxlen = KMOD_PATH_LEN,
556 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800557 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 },
Kees Cook3d433212009-04-02 15:49:29 -0700559 {
Kees Cook3d433212009-04-02 15:49:29 -0700560 .procname = "modules_disabled",
561 .data = &modules_disabled,
562 .maxlen = sizeof(int),
563 .mode = 0644,
564 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800565 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700566 .extra1 = &one,
567 .extra2 = &one,
568 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569#endif
Ian Abbott94f17cd2010-06-07 12:57:12 +0100570#ifdef CONFIG_HOTPLUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100573 .data = &uevent_helper,
574 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800576 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 },
578#endif
579#ifdef CONFIG_CHR_DEV_SG
580 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 .procname = "sg-big-buff",
582 .data = &sg_big_buff,
583 .maxlen = sizeof (int),
584 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800585 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 },
587#endif
588#ifdef CONFIG_BSD_PROCESS_ACCT
589 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 .procname = "acct",
591 .data = &acct_parm,
592 .maxlen = 3*sizeof(int),
593 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800594 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 },
596#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597#ifdef CONFIG_MAGIC_SYSRQ
598 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800600 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 .maxlen = sizeof (int),
602 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700603 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 },
605#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700606#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700609 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 .maxlen = sizeof (int),
611 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800612 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700614#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 .procname = "threads-max",
617 .data = &max_threads,
618 .maxlen = sizeof(int),
619 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800620 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 },
622 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 .procname = "random",
624 .mode = 0555,
625 .child = random_table,
626 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 {
Eric Paris17f60a72011-04-01 17:07:50 -0400628 .procname = "usermodehelper",
629 .mode = 0555,
630 .child = usermodehelper_table,
631 },
632 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 .procname = "overflowuid",
634 .data = &overflowuid,
635 .maxlen = sizeof(int),
636 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800637 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 .extra1 = &minolduid,
639 .extra2 = &maxolduid,
640 },
641 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 .procname = "overflowgid",
643 .data = &overflowgid,
644 .maxlen = sizeof(int),
645 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800646 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 .extra1 = &minolduid,
648 .extra2 = &maxolduid,
649 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800650#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651#ifdef CONFIG_MATHEMU
652 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 .procname = "ieee_emulation_warnings",
654 .data = &sysctl_ieee_emulation_warnings,
655 .maxlen = sizeof(int),
656 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800657 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 },
659#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200662 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 .maxlen = sizeof(int),
664 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800665 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 },
667#endif
668 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 .procname = "pid_max",
670 .data = &pid_max,
671 .maxlen = sizeof (int),
672 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800673 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 .extra1 = &pid_max_min,
675 .extra2 = &pid_max_max,
676 },
677 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 .procname = "panic_on_oops",
679 .data = &panic_on_oops,
680 .maxlen = sizeof(int),
681 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800682 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800684#if defined CONFIG_PRINTK
685 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800686 .procname = "printk",
687 .data = &console_loglevel,
688 .maxlen = 4*sizeof(int),
689 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800690 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800691 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700694 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 .maxlen = sizeof(int),
696 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800697 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 },
699 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700701 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 .maxlen = sizeof(int),
703 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800704 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 },
Dave Youngaf913222009-09-22 16:43:33 -0700706 {
Dave Youngaf913222009-09-22 16:43:33 -0700707 .procname = "printk_delay",
708 .data = &printk_delay_msec,
709 .maxlen = sizeof(int),
710 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800711 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700712 .extra1 = &zero,
713 .extra2 = &ten_thousand,
714 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800716 .procname = "dmesg_restrict",
717 .data = &dmesg_restrict,
718 .maxlen = sizeof(int),
719 .mode = 0644,
720 .proc_handler = proc_dointvec_minmax,
721 .extra1 = &zero,
722 .extra2 = &one,
723 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800724 {
725 .procname = "kptr_restrict",
726 .data = &kptr_restrict,
727 .maxlen = sizeof(int),
728 .mode = 0644,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700729 .proc_handler = proc_dmesg_restrict,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800730 .extra1 = &zero,
731 .extra2 = &two,
732 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800733#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800734 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 .procname = "ngroups_max",
736 .data = &ngroups_max,
737 .maxlen = sizeof (int),
738 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800739 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 },
Dan Ballard73efc032011-10-31 17:11:20 -0700741 {
742 .procname = "cap_last_cap",
743 .data = (void *)&cap_last_cap,
744 .maxlen = sizeof(int),
745 .mode = 0444,
746 .proc_handler = proc_dointvec,
747 },
Don Zickus58687ac2010-05-07 17:11:44 -0400748#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500749 {
Don Zickus58687ac2010-05-07 17:11:44 -0400750 .procname = "watchdog",
751 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500752 .maxlen = sizeof (int),
753 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700754 .proc_handler = proc_dowatchdog,
755 .extra1 = &zero,
756 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400757 },
758 {
759 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700760 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400761 .maxlen = sizeof(int),
762 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700763 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400764 .extra1 = &neg_one,
765 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500766 },
Don Zickus2508ce12010-05-07 17:11:46 -0400767 {
768 .procname = "softlockup_panic",
769 .data = &softlockup_panic,
770 .maxlen = sizeof(int),
771 .mode = 0644,
772 .proc_handler = proc_dointvec_minmax,
773 .extra1 = &zero,
774 .extra2 = &one,
775 },
Don Zickus5dc30552010-11-29 17:07:17 -0500776 {
777 .procname = "nmi_watchdog",
778 .data = &watchdog_enabled,
779 .maxlen = sizeof (int),
780 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700781 .proc_handler = proc_dowatchdog,
782 .extra1 = &zero,
783 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500784 },
785#endif
786#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
787 {
788 .procname = "unknown_nmi_panic",
789 .data = &unknown_nmi_panic,
790 .maxlen = sizeof (int),
791 .mode = 0644,
792 .proc_handler = proc_dointvec,
793 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500794#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795#if defined(CONFIG_X86)
796 {
Don Zickus8da5add2006-09-26 10:52:27 +0200797 .procname = "panic_on_unrecovered_nmi",
798 .data = &panic_on_unrecovered_nmi,
799 .maxlen = sizeof(int),
800 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800801 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200802 },
803 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700804 .procname = "panic_on_io_nmi",
805 .data = &panic_on_io_nmi,
806 .maxlen = sizeof(int),
807 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800808 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700809 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900810#ifdef CONFIG_DEBUG_STACKOVERFLOW
811 {
812 .procname = "panic_on_stackoverflow",
813 .data = &sysctl_panic_on_stackoverflow,
814 .maxlen = sizeof(int),
815 .mode = 0644,
816 .proc_handler = proc_dointvec,
817 },
818#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700819 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 .procname = "bootloader_type",
821 .data = &bootloader_type,
822 .maxlen = sizeof (int),
823 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800824 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100826 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700827 .procname = "bootloader_version",
828 .data = &bootloader_version,
829 .maxlen = sizeof (int),
830 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800831 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700832 },
833 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100834 .procname = "kstack_depth_to_print",
835 .data = &kstack_depth_to_print,
836 .maxlen = sizeof(int),
837 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800838 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100839 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100840 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100841 .procname = "io_delay_type",
842 .data = &io_delay_type,
843 .maxlen = sizeof(int),
844 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800845 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100846 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800848#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 .procname = "randomize_va_space",
851 .data = &randomize_va_space,
852 .maxlen = sizeof(int),
853 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800854 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800856#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800857#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700858 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700859 .procname = "spin_retry",
860 .data = &spin_retry,
861 .maxlen = sizeof (int),
862 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800863 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700864 },
865#endif
Len Brown673d5b42007-07-28 03:33:16 -0400866#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800867 {
Pavel Machekc255d842006-02-20 18:27:58 -0800868 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700869 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800870 .maxlen = sizeof (unsigned long),
871 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800872 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800873 },
874#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800875#ifdef CONFIG_IA64
876 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800877 .procname = "ignore-unaligned-usertrap",
878 .data = &no_unaligned_warning,
879 .maxlen = sizeof (int),
880 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800881 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800882 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800883 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800884 .procname = "unaligned-dump-stack",
885 .data = &unaligned_dump_stack,
886 .maxlen = sizeof (int),
887 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800888 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800889 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800890#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800891#ifdef CONFIG_DETECT_HUNG_TASK
892 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800893 .procname = "hung_task_panic",
894 .data = &sysctl_hung_task_panic,
895 .maxlen = sizeof(int),
896 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800897 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800898 .extra1 = &zero,
899 .extra2 = &one,
900 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100901 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100902 .procname = "hung_task_check_count",
903 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100904 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100905 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800906 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100907 },
908 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100909 .procname = "hung_task_timeout_secs",
910 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100911 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100912 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800913 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100914 },
915 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100916 .procname = "hung_task_warnings",
917 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100918 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100919 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800920 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100921 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700922#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200923#ifdef CONFIG_COMPAT
924 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200925 .procname = "compat-log",
926 .data = &compat_log,
927 .maxlen = sizeof (int),
928 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800929 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200930 },
931#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700932#ifdef CONFIG_RT_MUTEXES
933 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700934 .procname = "max_lock_depth",
935 .data = &max_lock_depth,
936 .maxlen = sizeof(int),
937 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800938 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700939 },
940#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700941 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700942 .procname = "poweroff_cmd",
943 .data = &poweroff_cmd,
944 .maxlen = POWEROFF_CMD_PATH_LEN,
945 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800946 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700947 },
David Howells0b77f5b2008-04-29 01:01:32 -0700948#ifdef CONFIG_KEYS
949 {
David Howells0b77f5b2008-04-29 01:01:32 -0700950 .procname = "keys",
951 .mode = 0555,
952 .child = key_sysctls,
953 },
954#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700955#ifdef CONFIG_RCU_TORTURE_TEST
956 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700957 .procname = "rcutorture_runnable",
958 .data = &rcutorture_runnable,
959 .maxlen = sizeof(int),
960 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800961 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700962 },
963#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200964#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -0400965 /*
966 * User-space scripts rely on the existence of this file
967 * as a feature check for perf_events being enabled.
968 *
969 * So it's an ABI, do not remove!
970 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200971 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200972 .procname = "perf_event_paranoid",
973 .data = &sysctl_perf_event_paranoid,
974 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200975 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800976 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200977 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200978 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200979 .procname = "perf_event_mlock_kb",
980 .data = &sysctl_perf_event_mlock,
981 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200982 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800983 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200984 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200985 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200986 .procname = "perf_event_max_sample_rate",
987 .data = &sysctl_perf_event_sample_rate,
988 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200989 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +0100990 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200991 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200992#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200993#ifdef CONFIG_KMEMCHECK
994 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200995 .procname = "kmemcheck",
996 .data = &kmemcheck_enabled,
997 .maxlen = sizeof(int),
998 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800999 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001000 },
1001#endif
Jens Axboecb684b52009-09-15 21:53:11 +02001002#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +02001003 {
Jens Axboe5e605b62009-08-05 09:07:21 +02001004 .procname = "blk_iopoll",
1005 .data = &blk_iopoll_enabled,
1006 .maxlen = sizeof(int),
1007 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001008 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +02001009 },
Jens Axboecb684b52009-09-15 21:53:11 +02001010#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001011 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012};
1013
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001014static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001016 .procname = "overcommit_memory",
1017 .data = &sysctl_overcommit_memory,
1018 .maxlen = sizeof(sysctl_overcommit_memory),
1019 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001020 .proc_handler = proc_dointvec_minmax,
1021 .extra1 = &zero,
1022 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001023 },
1024 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001025 .procname = "panic_on_oom",
1026 .data = &sysctl_panic_on_oom,
1027 .maxlen = sizeof(sysctl_panic_on_oom),
1028 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001029 .proc_handler = proc_dointvec_minmax,
1030 .extra1 = &zero,
1031 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001032 },
1033 {
David Rientjesfe071d72007-10-16 23:25:56 -07001034 .procname = "oom_kill_allocating_task",
1035 .data = &sysctl_oom_kill_allocating_task,
1036 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1037 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001038 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001039 },
1040 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001041 .procname = "oom_dump_tasks",
1042 .data = &sysctl_oom_dump_tasks,
1043 .maxlen = sizeof(sysctl_oom_dump_tasks),
1044 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001045 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001046 },
1047 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048 .procname = "overcommit_ratio",
1049 .data = &sysctl_overcommit_ratio,
1050 .maxlen = sizeof(sysctl_overcommit_ratio),
1051 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001052 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053 },
1054 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055 .procname = "page-cluster",
1056 .data = &page_cluster,
1057 .maxlen = sizeof(int),
1058 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001059 .proc_handler = proc_dointvec_minmax,
1060 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001061 },
1062 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 .procname = "dirty_background_ratio",
1064 .data = &dirty_background_ratio,
1065 .maxlen = sizeof(dirty_background_ratio),
1066 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001067 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068 .extra1 = &zero,
1069 .extra2 = &one_hundred,
1070 },
1071 {
David Rientjes2da02992009-01-06 14:39:31 -08001072 .procname = "dirty_background_bytes",
1073 .data = &dirty_background_bytes,
1074 .maxlen = sizeof(dirty_background_bytes),
1075 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001076 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001077 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001078 },
1079 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080 .procname = "dirty_ratio",
1081 .data = &vm_dirty_ratio,
1082 .maxlen = sizeof(vm_dirty_ratio),
1083 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001084 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001085 .extra1 = &zero,
1086 .extra2 = &one_hundred,
1087 },
1088 {
David Rientjes2da02992009-01-06 14:39:31 -08001089 .procname = "dirty_bytes",
1090 .data = &vm_dirty_bytes,
1091 .maxlen = sizeof(vm_dirty_bytes),
1092 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001093 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001094 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001095 },
1096 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001098 .data = &dirty_writeback_interval,
1099 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001101 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102 },
1103 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001105 .data = &dirty_expire_interval,
1106 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001108 .proc_handler = proc_dointvec_minmax,
1109 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 },
1111 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001112 .procname = "nr_pdflush_threads",
1113 .data = &nr_pdflush_threads,
1114 .maxlen = sizeof nr_pdflush_threads,
1115 .mode = 0444 /* read-only*/,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001116 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117 },
1118 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119 .procname = "swappiness",
1120 .data = &vm_swappiness,
1121 .maxlen = sizeof(vm_swappiness),
1122 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001123 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124 .extra1 = &zero,
1125 .extra2 = &one_hundred,
1126 },
1127#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001128 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001130 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001131 .maxlen = sizeof(unsigned long),
1132 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001133 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134 .extra1 = (void *)&hugetlb_zero,
1135 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001136 },
1137#ifdef CONFIG_NUMA
1138 {
1139 .procname = "nr_hugepages_mempolicy",
1140 .data = NULL,
1141 .maxlen = sizeof(unsigned long),
1142 .mode = 0644,
1143 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1144 .extra1 = (void *)&hugetlb_zero,
1145 .extra2 = (void *)&hugetlb_infinity,
1146 },
1147#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149 .procname = "hugetlb_shm_group",
1150 .data = &sysctl_hugetlb_shm_group,
1151 .maxlen = sizeof(gid_t),
1152 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001153 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 },
Mel Gorman396faf02007-07-17 04:03:13 -07001155 {
Mel Gorman396faf02007-07-17 04:03:13 -07001156 .procname = "hugepages_treat_as_movable",
1157 .data = &hugepages_treat_as_movable,
1158 .maxlen = sizeof(int),
1159 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001160 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001161 },
Adam Litke54f9f802007-10-16 01:26:20 -07001162 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001163 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001164 .data = NULL,
1165 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001166 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001167 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001168 .extra1 = (void *)&hugetlb_zero,
1169 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001170 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001171#endif
1172 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 .procname = "lowmem_reserve_ratio",
1174 .data = &sysctl_lowmem_reserve_ratio,
1175 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1176 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001177 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178 },
1179 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001180 .procname = "drop_caches",
1181 .data = &sysctl_drop_caches,
1182 .maxlen = sizeof(int),
1183 .mode = 0644,
1184 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001185 .extra1 = &one,
1186 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001187 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001188#ifdef CONFIG_COMPACTION
1189 {
1190 .procname = "compact_memory",
1191 .data = &sysctl_compact_memory,
1192 .maxlen = sizeof(int),
1193 .mode = 0200,
1194 .proc_handler = sysctl_compaction_handler,
1195 },
Mel Gorman5e771902010-05-24 14:32:31 -07001196 {
1197 .procname = "extfrag_threshold",
1198 .data = &sysctl_extfrag_threshold,
1199 .maxlen = sizeof(int),
1200 .mode = 0644,
1201 .proc_handler = sysctl_extfrag_handler,
1202 .extra1 = &min_extfrag_threshold,
1203 .extra2 = &max_extfrag_threshold,
1204 },
1205
Mel Gorman76ab0f52010-05-24 14:32:28 -07001206#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001207 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001208 .procname = "min_free_kbytes",
1209 .data = &min_free_kbytes,
1210 .maxlen = sizeof(min_free_kbytes),
1211 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001212 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001213 .extra1 = &zero,
1214 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001215 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001216 .procname = "percpu_pagelist_fraction",
1217 .data = &percpu_pagelist_fraction,
1218 .maxlen = sizeof(percpu_pagelist_fraction),
1219 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001220 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001221 .extra1 = &min_percpu_pagelist_fract,
1222 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001223#ifdef CONFIG_MMU
1224 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225 .procname = "max_map_count",
1226 .data = &sysctl_max_map_count,
1227 .maxlen = sizeof(sysctl_max_map_count),
1228 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001229 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001230 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001231 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001232#else
1233 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001234 .procname = "nr_trim_pages",
1235 .data = &sysctl_nr_trim_pages,
1236 .maxlen = sizeof(sysctl_nr_trim_pages),
1237 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001238 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001239 .extra1 = &zero,
1240 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241#endif
1242 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243 .procname = "laptop_mode",
1244 .data = &laptop_mode,
1245 .maxlen = sizeof(laptop_mode),
1246 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001247 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001248 },
1249 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001250 .procname = "block_dump",
1251 .data = &block_dump,
1252 .maxlen = sizeof(block_dump),
1253 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001254 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255 .extra1 = &zero,
1256 },
1257 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001258 .procname = "vfs_cache_pressure",
1259 .data = &sysctl_vfs_cache_pressure,
1260 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1261 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001262 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001263 .extra1 = &zero,
1264 },
1265#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1266 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001267 .procname = "legacy_va_layout",
1268 .data = &sysctl_legacy_va_layout,
1269 .maxlen = sizeof(sysctl_legacy_va_layout),
1270 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001271 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001272 .extra1 = &zero,
1273 },
1274#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001275#ifdef CONFIG_NUMA
1276 {
Christoph Lameter17436602006-01-18 17:42:32 -08001277 .procname = "zone_reclaim_mode",
1278 .data = &zone_reclaim_mode,
1279 .maxlen = sizeof(zone_reclaim_mode),
1280 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001281 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001282 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001283 },
Christoph Lameter96146342006-07-03 00:24:13 -07001284 {
Christoph Lameter96146342006-07-03 00:24:13 -07001285 .procname = "min_unmapped_ratio",
1286 .data = &sysctl_min_unmapped_ratio,
1287 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1288 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001289 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001290 .extra1 = &zero,
1291 .extra2 = &one_hundred,
1292 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001293 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001294 .procname = "min_slab_ratio",
1295 .data = &sysctl_min_slab_ratio,
1296 .maxlen = sizeof(sysctl_min_slab_ratio),
1297 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001298 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001299 .extra1 = &zero,
1300 .extra2 = &one_hundred,
1301 },
Christoph Lameter17436602006-01-18 17:42:32 -08001302#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001303#ifdef CONFIG_SMP
1304 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001305 .procname = "stat_interval",
1306 .data = &sysctl_stat_interval,
1307 .maxlen = sizeof(sysctl_stat_interval),
1308 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001309 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001310 },
1311#endif
David Howells6e141542009-12-15 19:27:45 +00001312#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001313 {
Eric Parised032182007-06-28 15:55:21 -04001314 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001315 .data = &dac_mmap_min_addr,
1316 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001317 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001318 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001319 },
David Howells6e141542009-12-15 19:27:45 +00001320#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001321#ifdef CONFIG_NUMA
1322 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001323 .procname = "numa_zonelist_order",
1324 .data = &numa_zonelist_order,
1325 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1326 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001327 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001328 },
1329#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001330#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e6572007-03-01 10:07:42 +09001331 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001332 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001333 .procname = "vdso_enabled",
1334 .data = &vdso_enabled,
1335 .maxlen = sizeof(vdso_enabled),
1336 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001337 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001338 .extra1 = &zero,
1339 },
1340#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001341#ifdef CONFIG_HIGHMEM
1342 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001343 .procname = "highmem_is_dirtyable",
1344 .data = &vm_highmem_is_dirtyable,
1345 .maxlen = sizeof(vm_highmem_is_dirtyable),
1346 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001347 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001348 .extra1 = &zero,
1349 .extra2 = &one,
1350 },
1351#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001352 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001353 .procname = "scan_unevictable_pages",
1354 .data = &scan_unevictable_pages,
1355 .maxlen = sizeof(scan_unevictable_pages),
1356 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001357 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001358 },
Andi Kleen6a460792009-09-16 11:50:15 +02001359#ifdef CONFIG_MEMORY_FAILURE
1360 {
Andi Kleen6a460792009-09-16 11:50:15 +02001361 .procname = "memory_failure_early_kill",
1362 .data = &sysctl_memory_failure_early_kill,
1363 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1364 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001365 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001366 .extra1 = &zero,
1367 .extra2 = &one,
1368 },
1369 {
Andi Kleen6a460792009-09-16 11:50:15 +02001370 .procname = "memory_failure_recovery",
1371 .data = &sysctl_memory_failure_recovery,
1372 .maxlen = sizeof(sysctl_memory_failure_recovery),
1373 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001374 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001375 .extra1 = &zero,
1376 .extra2 = &one,
1377 },
1378#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001379 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380};
1381
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001382#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001383static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001384 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001385};
1386#endif
1387
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001388static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390 .procname = "inode-nr",
1391 .data = &inodes_stat,
1392 .maxlen = 2*sizeof(int),
1393 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001394 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001395 },
1396 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001397 .procname = "inode-state",
1398 .data = &inodes_stat,
1399 .maxlen = 7*sizeof(int),
1400 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001401 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001402 },
1403 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001404 .procname = "file-nr",
1405 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001406 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001407 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001408 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001409 },
1410 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411 .procname = "file-max",
1412 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001413 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001414 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001415 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001416 },
1417 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001418 .procname = "nr_open",
1419 .data = &sysctl_nr_open,
1420 .maxlen = sizeof(int),
1421 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001422 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001423 .extra1 = &sysctl_nr_open_min,
1424 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001425 },
1426 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001427 .procname = "dentry-state",
1428 .data = &dentry_stat,
1429 .maxlen = 6*sizeof(int),
1430 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001431 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001432 },
1433 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001434 .procname = "overflowuid",
1435 .data = &fs_overflowuid,
1436 .maxlen = sizeof(int),
1437 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001438 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439 .extra1 = &minolduid,
1440 .extra2 = &maxolduid,
1441 },
1442 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001443 .procname = "overflowgid",
1444 .data = &fs_overflowgid,
1445 .maxlen = sizeof(int),
1446 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001447 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001448 .extra1 = &minolduid,
1449 .extra2 = &maxolduid,
1450 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001451#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001452 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001453 .procname = "leases-enable",
1454 .data = &leases_enable,
1455 .maxlen = sizeof(int),
1456 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001457 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001458 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001459#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001460#ifdef CONFIG_DNOTIFY
1461 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462 .procname = "dir-notify-enable",
1463 .data = &dir_notify_enable,
1464 .maxlen = sizeof(int),
1465 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001466 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467 },
1468#endif
1469#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001470#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001471 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472 .procname = "lease-break-time",
1473 .data = &lease_break_time,
1474 .maxlen = sizeof(int),
1475 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001476 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001478#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001479#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001480 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 .procname = "aio-nr",
1482 .data = &aio_nr,
1483 .maxlen = sizeof(aio_nr),
1484 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001485 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486 },
1487 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001488 .procname = "aio-max-nr",
1489 .data = &aio_max_nr,
1490 .maxlen = sizeof(aio_max_nr),
1491 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001492 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001494#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001495#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001496 {
Robert Love0399cb02005-07-13 12:38:18 -04001497 .procname = "inotify",
1498 .mode = 0555,
1499 .child = inotify_table,
1500 },
1501#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001502#ifdef CONFIG_EPOLL
1503 {
1504 .procname = "epoll",
1505 .mode = 0555,
1506 .child = epoll_table,
1507 },
1508#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001509#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001510 {
Alan Coxd6e71142005-06-23 00:09:43 -07001511 .procname = "suid_dumpable",
1512 .data = &suid_dumpable,
1513 .maxlen = sizeof(int),
1514 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001515 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001516 .extra1 = &zero,
1517 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001518 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001519#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1520 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001521 .procname = "binfmt_misc",
1522 .mode = 0555,
1523 .child = binfmt_misc_table,
1524 },
1525#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001526 {
Jens Axboeff9da692010-06-03 14:54:39 +02001527 .procname = "pipe-max-size",
1528 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001529 .maxlen = sizeof(int),
1530 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001531 .proc_handler = &pipe_proc_fn,
1532 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001533 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001534 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001535};
1536
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001537static struct ctl_table debug_table[] = {
Heiko Carstensab3c68e2010-05-17 10:00:21 +02001538#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \
Chris Metcalf571d76a2011-05-16 14:23:44 -04001539 defined(CONFIG_S390) || defined(CONFIG_TILE)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001540 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001541 .procname = "exception-trace",
1542 .data = &show_unhandled_signals,
1543 .maxlen = sizeof(int),
1544 .mode = 0644,
1545 .proc_handler = proc_dointvec
1546 },
1547#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001548#if defined(CONFIG_OPTPROBES)
1549 {
1550 .procname = "kprobes-optimization",
1551 .data = &sysctl_kprobes_optimization,
1552 .maxlen = sizeof(int),
1553 .mode = 0644,
1554 .proc_handler = proc_kprobes_optimization_handler,
1555 .extra1 = &zero,
1556 .extra2 = &one,
1557 },
1558#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001559 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001560};
1561
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001562static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001563 { }
Robert Love0eeca282005-07-12 17:06:03 -04001564};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001565
Al Viro330d57f2005-11-04 10:18:40 +00001566static DEFINE_SPINLOCK(sysctl_lock);
1567
1568/* called under sysctl_lock */
1569static int use_table(struct ctl_table_header *p)
1570{
1571 if (unlikely(p->unregistering))
1572 return 0;
1573 p->used++;
1574 return 1;
1575}
1576
1577/* called under sysctl_lock */
1578static void unuse_table(struct ctl_table_header *p)
1579{
1580 if (!--p->used)
1581 if (unlikely(p->unregistering))
1582 complete(p->unregistering);
1583}
1584
1585/* called under sysctl_lock, will reacquire if has to wait */
1586static void start_unregistering(struct ctl_table_header *p)
1587{
1588 /*
1589 * if p->used is 0, nobody will ever touch that entry again;
1590 * we'll eliminate all paths to it before dropping sysctl_lock
1591 */
1592 if (unlikely(p->used)) {
1593 struct completion wait;
1594 init_completion(&wait);
1595 p->unregistering = &wait;
1596 spin_unlock(&sysctl_lock);
1597 wait_for_completion(&wait);
1598 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001599 } else {
1600 /* anything non-NULL; we'll never dereference it */
1601 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001602 }
1603 /*
1604 * do not remove from the list until nobody holds it; walking the
1605 * list in do_sysctl() relies on that.
1606 */
1607 list_del_init(&p->ctl_entry);
1608}
1609
Al Virof7e6ced2008-07-15 01:44:23 -04001610void sysctl_head_get(struct ctl_table_header *head)
1611{
1612 spin_lock(&sysctl_lock);
1613 head->count++;
1614 spin_unlock(&sysctl_lock);
1615}
1616
1617void sysctl_head_put(struct ctl_table_header *head)
1618{
1619 spin_lock(&sysctl_lock);
1620 if (!--head->count)
Paul E. McKenneya95cded2011-05-01 23:21:00 -07001621 kfree_rcu(head, rcu);
Al Virof7e6ced2008-07-15 01:44:23 -04001622 spin_unlock(&sysctl_lock);
1623}
1624
1625struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1626{
1627 if (!head)
1628 BUG();
1629 spin_lock(&sysctl_lock);
1630 if (!use_table(head))
1631 head = ERR_PTR(-ENOENT);
1632 spin_unlock(&sysctl_lock);
1633 return head;
1634}
1635
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001636void sysctl_head_finish(struct ctl_table_header *head)
1637{
1638 if (!head)
1639 return;
1640 spin_lock(&sysctl_lock);
1641 unuse_table(head);
1642 spin_unlock(&sysctl_lock);
1643}
1644
Al Viro73455092008-07-14 21:22:20 -04001645static struct ctl_table_set *
1646lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1647{
1648 struct ctl_table_set *set = &root->default_set;
1649 if (root->lookup)
1650 set = root->lookup(root, namespaces);
1651 return set;
1652}
1653
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001654static struct list_head *
1655lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001656{
Al Viro73455092008-07-14 21:22:20 -04001657 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1658 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001659}
1660
1661struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1662 struct ctl_table_header *prev)
1663{
1664 struct ctl_table_root *root;
1665 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001666 struct ctl_table_header *head;
1667 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001668
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001669 spin_lock(&sysctl_lock);
1670 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001671 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001672 tmp = &prev->ctl_entry;
1673 unuse_table(prev);
1674 goto next;
1675 }
1676 tmp = &root_table_header.ctl_entry;
1677 for (;;) {
1678 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1679
1680 if (!use_table(head))
1681 goto next;
1682 spin_unlock(&sysctl_lock);
1683 return head;
1684 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001685 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001686 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001687 header_list = lookup_header_list(root, namespaces);
1688 if (tmp != header_list)
1689 continue;
1690
1691 do {
1692 root = list_entry(root->root_list.next,
1693 struct ctl_table_root, root_list);
1694 if (root == &sysctl_table_root)
1695 goto out;
1696 header_list = lookup_header_list(root, namespaces);
1697 } while (list_empty(header_list));
1698 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001699 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001700out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001701 spin_unlock(&sysctl_lock);
1702 return NULL;
1703}
1704
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001705struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1706{
1707 return __sysctl_head_next(current->nsproxy, prev);
1708}
1709
1710void register_sysctl_root(struct ctl_table_root *root)
1711{
1712 spin_lock(&sysctl_lock);
1713 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1714 spin_unlock(&sysctl_lock);
1715}
1716
Linus Torvalds1da177e2005-04-16 15:20:36 -07001717/*
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001718 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001719 * some sysctl variables are readonly even to root.
1720 */
1721
1722static int test_perm(int mode, int op)
1723{
David Howells76aac0e2008-11-14 10:39:12 +11001724 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001725 mode >>= 6;
1726 else if (in_egroup_p(0))
1727 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001728 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729 return 0;
1730 return -EACCES;
1731}
1732
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001733int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001734{
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001735 int mode;
1736
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001737 if (root->permissions)
1738 mode = root->permissions(root, current->nsproxy, table);
1739 else
1740 mode = table->mode;
1741
1742 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001743}
1744
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001745static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1746{
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001747 for (; table->procname; table++) {
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001748 table->parent = parent;
1749 if (table->child)
1750 sysctl_set_parent(table, table->child);
1751 }
1752}
1753
1754static __init int sysctl_init(void)
1755{
1756 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001757#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Andi Kleenb3bd3de2010-08-10 14:17:51 -07001758 sysctl_check_table(current->nsproxy, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001759#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001760 return 0;
1761}
1762
1763core_initcall(sysctl_init);
1764
Al Virobfbcf032008-07-27 06:31:22 +01001765static struct ctl_table *is_branch_in(struct ctl_table *branch,
1766 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001767{
1768 struct ctl_table *p;
1769 const char *s = branch->procname;
1770
1771 /* branch should have named subdirectory as its first element */
1772 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001773 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001774
1775 /* ... and nothing else */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001776 if (branch[1].procname)
Al Virobfbcf032008-07-27 06:31:22 +01001777 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001778
1779 /* table should contain subdirectory with the same name */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001780 for (p = table; p->procname; p++) {
Al Viroae7edec2008-07-15 06:33:31 -04001781 if (!p->child)
1782 continue;
1783 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001784 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001785 }
Al Virobfbcf032008-07-27 06:31:22 +01001786 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001787}
1788
1789/* see if attaching q to p would be an improvement */
1790static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1791{
1792 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001793 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001794 int is_better = 0;
1795 int not_in_parent = !p->attached_by;
1796
Al Virobfbcf032008-07-27 06:31:22 +01001797 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001798 if (by == q->attached_by)
1799 is_better = 1;
1800 if (to == p->attached_by)
1801 not_in_parent = 1;
1802 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001803 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001804 }
1805
1806 if (is_better && not_in_parent) {
1807 q->attached_by = by;
1808 q->attached_to = to;
1809 q->parent = p;
1810 }
1811}
1812
Linus Torvalds1da177e2005-04-16 15:20:36 -07001813/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001814 * __register_sysctl_paths - register a sysctl hierarchy
1815 * @root: List of sysctl headers to register on
1816 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001817 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001818 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001819 *
1820 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001821 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001822 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001823 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001824 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001825 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1826 * enter a sysctl file
1827 *
1828 * data - a pointer to data for use by proc_handler
1829 *
1830 * maxlen - the maximum size in bytes of the data
1831 *
1832 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1833 *
1834 * child - a pointer to the child sysctl table if this entry is a directory, or
1835 * %NULL.
1836 *
1837 * proc_handler - the text handler routine (described below)
1838 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001839 * de - for internal use by the sysctl routines
1840 *
1841 * extra1, extra2 - extra pointers usable by the proc handler routines
1842 *
1843 * Leaf nodes in the sysctl tree will be represented by a single file
1844 * under /proc; non-leaf nodes will be represented by directories.
1845 *
1846 * sysctl(2) can automatically manage read and write requests through
1847 * the sysctl table. The data and maxlen fields of the ctl_table
1848 * struct enable minimal validation of the values being written to be
1849 * performed, and the mode field allows minimal authentication.
1850 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001851 * There must be a proc_handler routine for any terminal nodes
1852 * mirrored under /proc/sys (non-terminals are handled by a built-in
1853 * directory handler). Several default handlers are available to
1854 * cover common cases -
1855 *
1856 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1857 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1858 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1859 *
1860 * It is the handler's job to read the input buffer from user memory
1861 * and process it. The handler should return 0 on success.
1862 *
1863 * This routine returns %NULL on a failure to register, and a pointer
1864 * to the table header on success.
1865 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001866struct ctl_table_header *__register_sysctl_paths(
1867 struct ctl_table_root *root,
1868 struct nsproxy *namespaces,
1869 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001870{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001871 struct ctl_table_header *header;
1872 struct ctl_table *new, **prevp;
1873 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001874 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001875
1876 /* Count the path components */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001877 for (npath = 0; path[npath].procname; ++npath)
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001878 ;
1879
1880 /*
1881 * For each path component, allocate a 2-element ctl_table array.
1882 * The first array element will be filled with the sysctl entry
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001883 * for this, the second will be the sentinel (procname == 0).
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001884 *
1885 * We allocate everything in one go so that we don't have to
1886 * worry about freeing additional memory in unregister_sysctl_table.
1887 */
1888 header = kzalloc(sizeof(struct ctl_table_header) +
1889 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1890 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001891 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001892
1893 new = (struct ctl_table *) (header + 1);
1894
1895 /* Now connect the dots */
1896 prevp = &header->ctl_table;
1897 for (n = 0; n < npath; ++n, ++path) {
1898 /* Copy the procname */
1899 new->procname = path->procname;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001900 new->mode = 0555;
1901
1902 *prevp = new;
1903 prevp = &new->child;
1904
1905 new += 2;
1906 }
1907 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001908 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001909
1910 INIT_LIST_HEAD(&header->ctl_entry);
1911 header->used = 0;
1912 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001913 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001914 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001915 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001916#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001917 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001918 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001919 return NULL;
1920 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001921#endif
Al Viro330d57f2005-11-04 10:18:40 +00001922 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001923 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001924 header->attached_by = header->ctl_table;
1925 header->attached_to = root_table;
1926 header->parent = &root_table_header;
1927 for (set = header->set; set; set = set->parent) {
1928 struct ctl_table_header *p;
1929 list_for_each_entry(p, &set->list, ctl_entry) {
1930 if (p->unregistering)
1931 continue;
1932 try_attach(p, header);
1933 }
1934 }
1935 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001936 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001937 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001938
1939 return header;
1940}
1941
1942/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001943 * register_sysctl_table_path - register a sysctl table hierarchy
1944 * @path: The path to the directory the sysctl table is in.
1945 * @table: the top-level table structure
1946 *
1947 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1948 * array. A completely 0 filled entry terminates the table.
1949 *
1950 * See __register_sysctl_paths for more details.
1951 */
1952struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1953 struct ctl_table *table)
1954{
1955 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1956 path, table);
1957}
1958
1959/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001960 * register_sysctl_table - register a sysctl table hierarchy
1961 * @table: the top-level table structure
1962 *
1963 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1964 * array. A completely 0 filled entry terminates the table.
1965 *
1966 * See register_sysctl_paths for more details.
1967 */
1968struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1969{
1970 static const struct ctl_path null_path[] = { {} };
1971
1972 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001973}
1974
1975/**
1976 * unregister_sysctl_table - unregister a sysctl table hierarchy
1977 * @header: the header returned from register_sysctl_table
1978 *
1979 * Unregisters the sysctl table and all children. proc entries may not
1980 * actually be removed until they are no longer used by anyone.
1981 */
1982void unregister_sysctl_table(struct ctl_table_header * header)
1983{
Al Viro330d57f2005-11-04 10:18:40 +00001984 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08001985
1986 if (header == NULL)
1987 return;
1988
Al Viro330d57f2005-11-04 10:18:40 +00001989 spin_lock(&sysctl_lock);
1990 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04001991 if (!--header->parent->count) {
1992 WARN_ON(1);
Paul E. McKenneya95cded2011-05-01 23:21:00 -07001993 kfree_rcu(header->parent, rcu);
Al Viroae7edec2008-07-15 06:33:31 -04001994 }
Al Virof7e6ced2008-07-15 01:44:23 -04001995 if (!--header->count)
Paul E. McKenneya95cded2011-05-01 23:21:00 -07001996 kfree_rcu(header, rcu);
Al Viro330d57f2005-11-04 10:18:40 +00001997 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001998}
1999
Al Viro9043476f2008-07-15 08:54:06 -04002000int sysctl_is_seen(struct ctl_table_header *p)
2001{
2002 struct ctl_table_set *set = p->set;
2003 int res;
2004 spin_lock(&sysctl_lock);
2005 if (p->unregistering)
2006 res = 0;
2007 else if (!set->is_seen)
2008 res = 1;
2009 else
2010 res = set->is_seen(set);
2011 spin_unlock(&sysctl_lock);
2012 return res;
2013}
2014
Al Viro73455092008-07-14 21:22:20 -04002015void setup_sysctl_set(struct ctl_table_set *p,
2016 struct ctl_table_set *parent,
2017 int (*is_seen)(struct ctl_table_set *))
2018{
2019 INIT_LIST_HEAD(&p->list);
2020 p->parent = parent ? parent : &sysctl_table_root.default_set;
2021 p->is_seen = is_seen;
2022}
2023
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002024#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002025struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002026{
2027 return NULL;
2028}
2029
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002030struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2031 struct ctl_table *table)
2032{
2033 return NULL;
2034}
2035
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002036void unregister_sysctl_table(struct ctl_table_header * table)
2037{
2038}
2039
Al Viro73455092008-07-14 21:22:20 -04002040void setup_sysctl_set(struct ctl_table_set *p,
2041 struct ctl_table_set *parent,
2042 int (*is_seen)(struct ctl_table_set *))
2043{
2044}
2045
Al Virof7e6ced2008-07-15 01:44:23 -04002046void sysctl_head_put(struct ctl_table_header *head)
2047{
2048}
2049
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002050#endif /* CONFIG_SYSCTL */
2051
Linus Torvalds1da177e2005-04-16 15:20:36 -07002052/*
2053 * /proc/sys support
2054 */
2055
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002056#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002057
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002058static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002059 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002060 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002061{
2062 size_t len;
2063 char __user *p;
2064 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002065
2066 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002067 *lenp = 0;
2068 return 0;
2069 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002070
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002071 if (write) {
2072 len = 0;
2073 p = buffer;
2074 while (len < *lenp) {
2075 if (get_user(c, p++))
2076 return -EFAULT;
2077 if (c == 0 || c == '\n')
2078 break;
2079 len++;
2080 }
2081 if (len >= maxlen)
2082 len = maxlen-1;
2083 if(copy_from_user(data, buffer, len))
2084 return -EFAULT;
2085 ((char *) data)[len] = 0;
2086 *ppos += *lenp;
2087 } else {
2088 len = strlen(data);
2089 if (len > maxlen)
2090 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002091
2092 if (*ppos > len) {
2093 *lenp = 0;
2094 return 0;
2095 }
2096
2097 data += *ppos;
2098 len -= *ppos;
2099
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002100 if (len > *lenp)
2101 len = *lenp;
2102 if (len)
2103 if(copy_to_user(buffer, data, len))
2104 return -EFAULT;
2105 if (len < *lenp) {
2106 if(put_user('\n', ((char __user *) buffer) + len))
2107 return -EFAULT;
2108 len++;
2109 }
2110 *lenp = len;
2111 *ppos += len;
2112 }
2113 return 0;
2114}
2115
Linus Torvalds1da177e2005-04-16 15:20:36 -07002116/**
2117 * proc_dostring - read a string sysctl
2118 * @table: the sysctl table
2119 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002120 * @buffer: the user buffer
2121 * @lenp: the size of the user buffer
2122 * @ppos: file position
2123 *
2124 * Reads/writes a string from/to the user buffer. If the kernel
2125 * buffer provided is not large enough to hold the string, the
2126 * string is truncated. The copied string is %NULL-terminated.
2127 * If the string is being read by the user process, it is copied
2128 * and a newline '\n' is added. It is truncated if the buffer is
2129 * not large enough.
2130 *
2131 * Returns 0 on success.
2132 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002133int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002134 void __user *buffer, size_t *lenp, loff_t *ppos)
2135{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002136 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002137 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002138}
2139
Amerigo Wang00b7c332010-05-05 00:26:45 +00002140static size_t proc_skip_spaces(char **buf)
2141{
2142 size_t ret;
2143 char *tmp = skip_spaces(*buf);
2144 ret = tmp - *buf;
2145 *buf = tmp;
2146 return ret;
2147}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002148
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002149static void proc_skip_char(char **buf, size_t *size, const char v)
2150{
2151 while (*size) {
2152 if (**buf != v)
2153 break;
2154 (*size)--;
2155 (*buf)++;
2156 }
2157}
2158
Amerigo Wang00b7c332010-05-05 00:26:45 +00002159#define TMPBUFLEN 22
2160/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002161 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002162 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002163 * @buf: a kernel buffer
2164 * @size: size of the kernel buffer
2165 * @val: this is where the number will be stored
2166 * @neg: set to %TRUE if number is negative
2167 * @perm_tr: a vector which contains the allowed trailers
2168 * @perm_tr_len: size of the perm_tr vector
2169 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002170 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002171 * In case of success %0 is returned and @buf and @size are updated with
2172 * the amount of bytes read. If @tr is non-NULL and a trailing
2173 * character exists (size is non-zero after returning from this
2174 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002175 */
2176static int proc_get_long(char **buf, size_t *size,
2177 unsigned long *val, bool *neg,
2178 const char *perm_tr, unsigned perm_tr_len, char *tr)
2179{
2180 int len;
2181 char *p, tmp[TMPBUFLEN];
2182
2183 if (!*size)
2184 return -EINVAL;
2185
2186 len = *size;
2187 if (len > TMPBUFLEN - 1)
2188 len = TMPBUFLEN - 1;
2189
2190 memcpy(tmp, *buf, len);
2191
2192 tmp[len] = 0;
2193 p = tmp;
2194 if (*p == '-' && *size > 1) {
2195 *neg = true;
2196 p++;
2197 } else
2198 *neg = false;
2199 if (!isdigit(*p))
2200 return -EINVAL;
2201
2202 *val = simple_strtoul(p, &p, 0);
2203
2204 len = p - tmp;
2205
2206 /* We don't know if the next char is whitespace thus we may accept
2207 * invalid integers (e.g. 1234...a) or two integers instead of one
2208 * (e.g. 123...1). So lets not allow such large numbers. */
2209 if (len == TMPBUFLEN - 1)
2210 return -EINVAL;
2211
2212 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2213 return -EINVAL;
2214
2215 if (tr && (len < *size))
2216 *tr = *p;
2217
2218 *buf += len;
2219 *size -= len;
2220
2221 return 0;
2222}
2223
2224/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002225 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002226 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002227 * @buf: the user buffer
2228 * @size: the size of the user buffer
2229 * @val: the integer to be converted
2230 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002231 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002232 * In case of success %0 is returned and @buf and @size are updated with
2233 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002234 */
2235static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2236 bool neg)
2237{
2238 int len;
2239 char tmp[TMPBUFLEN], *p = tmp;
2240
2241 sprintf(p, "%s%lu", neg ? "-" : "", val);
2242 len = strlen(tmp);
2243 if (len > *size)
2244 len = *size;
2245 if (copy_to_user(*buf, tmp, len))
2246 return -EFAULT;
2247 *size -= len;
2248 *buf += len;
2249 return 0;
2250}
2251#undef TMPBUFLEN
2252
2253static int proc_put_char(void __user **buf, size_t *size, char c)
2254{
2255 if (*size) {
2256 char __user **buffer = (char __user **)buf;
2257 if (put_user(c, *buffer))
2258 return -EFAULT;
2259 (*size)--, (*buffer)++;
2260 *buf = *buffer;
2261 }
2262 return 0;
2263}
2264
2265static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002266 int *valp,
2267 int write, void *data)
2268{
2269 if (write) {
2270 *valp = *negp ? -*lvalp : *lvalp;
2271 } else {
2272 int val = *valp;
2273 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002274 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275 *lvalp = (unsigned long)-val;
2276 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002277 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278 *lvalp = (unsigned long)val;
2279 }
2280 }
2281 return 0;
2282}
2283
Amerigo Wang00b7c332010-05-05 00:26:45 +00002284static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2285
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002286static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002287 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002288 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002289 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002290 int write, void *data),
2291 void *data)
2292{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002293 int *i, vleft, first = 1, err = 0;
2294 unsigned long page = 0;
2295 size_t left;
2296 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002297
Amerigo Wang00b7c332010-05-05 00:26:45 +00002298 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299 *lenp = 0;
2300 return 0;
2301 }
2302
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002303 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002304 vleft = table->maxlen / sizeof(*i);
2305 left = *lenp;
2306
2307 if (!conv)
2308 conv = do_proc_dointvec_conv;
2309
Linus Torvalds1da177e2005-04-16 15:20:36 -07002310 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002311 if (left > PAGE_SIZE - 1)
2312 left = PAGE_SIZE - 1;
2313 page = __get_free_page(GFP_TEMPORARY);
2314 kbuf = (char *) page;
2315 if (!kbuf)
2316 return -ENOMEM;
2317 if (copy_from_user(kbuf, buffer, left)) {
2318 err = -EFAULT;
2319 goto free;
2320 }
2321 kbuf[left] = 0;
2322 }
2323
2324 for (; left && vleft--; i++, first=0) {
2325 unsigned long lval;
2326 bool neg;
2327
2328 if (write) {
2329 left -= proc_skip_spaces(&kbuf);
2330
J. R. Okajima563b0462010-05-25 16:10:14 -07002331 if (!left)
2332 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002333 err = proc_get_long(&kbuf, &left, &lval, &neg,
2334 proc_wspace_sep,
2335 sizeof(proc_wspace_sep), NULL);
2336 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002338 if (conv(&neg, &lval, i, 1, data)) {
2339 err = -EINVAL;
2340 break;
2341 }
2342 } else {
2343 if (conv(&neg, &lval, i, 0, data)) {
2344 err = -EINVAL;
2345 break;
2346 }
2347 if (!first)
2348 err = proc_put_char(&buffer, &left, '\t');
2349 if (err)
2350 break;
2351 err = proc_put_long(&buffer, &left, lval, neg);
2352 if (err)
2353 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354 }
2355 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002356
2357 if (!write && !first && left && !err)
2358 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002359 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002360 left -= proc_skip_spaces(&kbuf);
2361free:
2362 if (write) {
2363 free_page(page);
2364 if (first)
2365 return err ? : -EINVAL;
2366 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002367 *lenp -= left;
2368 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002369 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370}
2371
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002372static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002373 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002374 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002375 int write, void *data),
2376 void *data)
2377{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002378 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002379 buffer, lenp, ppos, conv, data);
2380}
2381
Linus Torvalds1da177e2005-04-16 15:20:36 -07002382/**
2383 * proc_dointvec - read a vector of integers
2384 * @table: the sysctl table
2385 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002386 * @buffer: the user buffer
2387 * @lenp: the size of the user buffer
2388 * @ppos: file position
2389 *
2390 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2391 * values from/to the user buffer, treated as an ASCII string.
2392 *
2393 * Returns 0 on success.
2394 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002395int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002396 void __user *buffer, size_t *lenp, loff_t *ppos)
2397{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002398 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002399 NULL,NULL);
2400}
2401
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002402/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002403 * Taint values can only be increased
2404 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002405 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002406static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002407 void __user *buffer, size_t *lenp, loff_t *ppos)
2408{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002409 struct ctl_table t;
2410 unsigned long tmptaint = get_taint();
2411 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002412
Bastian Blank91fcd412007-04-23 14:41:14 -07002413 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002414 return -EPERM;
2415
Andi Kleen25ddbb12008-10-15 22:01:41 -07002416 t = *table;
2417 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002418 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002419 if (err < 0)
2420 return err;
2421
2422 if (write) {
2423 /*
2424 * Poor man's atomic or. Not worth adding a primitive
2425 * to everyone's atomic.h for this
2426 */
2427 int i;
2428 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2429 if ((tmptaint >> i) & 1)
2430 add_taint(i);
2431 }
2432 }
2433
2434 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002435}
2436
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002437#ifdef CONFIG_PRINTK
2438static int proc_dmesg_restrict(struct ctl_table *table, int write,
2439 void __user *buffer, size_t *lenp, loff_t *ppos)
2440{
2441 if (write && !capable(CAP_SYS_ADMIN))
2442 return -EPERM;
2443
2444 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2445}
2446#endif
2447
Linus Torvalds1da177e2005-04-16 15:20:36 -07002448struct do_proc_dointvec_minmax_conv_param {
2449 int *min;
2450 int *max;
2451};
2452
Amerigo Wang00b7c332010-05-05 00:26:45 +00002453static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2454 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002455 int write, void *data)
2456{
2457 struct do_proc_dointvec_minmax_conv_param *param = data;
2458 if (write) {
2459 int val = *negp ? -*lvalp : *lvalp;
2460 if ((param->min && *param->min > val) ||
2461 (param->max && *param->max < val))
2462 return -EINVAL;
2463 *valp = val;
2464 } else {
2465 int val = *valp;
2466 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002467 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002468 *lvalp = (unsigned long)-val;
2469 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002470 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471 *lvalp = (unsigned long)val;
2472 }
2473 }
2474 return 0;
2475}
2476
2477/**
2478 * proc_dointvec_minmax - read a vector of integers with min/max values
2479 * @table: the sysctl table
2480 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002481 * @buffer: the user buffer
2482 * @lenp: the size of the user buffer
2483 * @ppos: file position
2484 *
2485 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2486 * values from/to the user buffer, treated as an ASCII string.
2487 *
2488 * This routine will ensure the values are within the range specified by
2489 * table->extra1 (min) and table->extra2 (max).
2490 *
2491 * Returns 0 on success.
2492 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002493int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494 void __user *buffer, size_t *lenp, loff_t *ppos)
2495{
2496 struct do_proc_dointvec_minmax_conv_param param = {
2497 .min = (int *) table->extra1,
2498 .max = (int *) table->extra2,
2499 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002500 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002501 do_proc_dointvec_minmax_conv, &param);
2502}
2503
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002504static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002505 void __user *buffer,
2506 size_t *lenp, loff_t *ppos,
2507 unsigned long convmul,
2508 unsigned long convdiv)
2509{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002510 unsigned long *i, *min, *max;
2511 int vleft, first = 1, err = 0;
2512 unsigned long page = 0;
2513 size_t left;
2514 char *kbuf;
2515
2516 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002517 *lenp = 0;
2518 return 0;
2519 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002520
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002521 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002522 min = (unsigned long *) table->extra1;
2523 max = (unsigned long *) table->extra2;
2524 vleft = table->maxlen / sizeof(unsigned long);
2525 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002526
2527 if (write) {
2528 if (left > PAGE_SIZE - 1)
2529 left = PAGE_SIZE - 1;
2530 page = __get_free_page(GFP_TEMPORARY);
2531 kbuf = (char *) page;
2532 if (!kbuf)
2533 return -ENOMEM;
2534 if (copy_from_user(kbuf, buffer, left)) {
2535 err = -EFAULT;
2536 goto free;
2537 }
2538 kbuf[left] = 0;
2539 }
2540
Eric Dumazet27b3d802010-10-07 12:59:29 -07002541 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002542 unsigned long val;
2543
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002545 bool neg;
2546
2547 left -= proc_skip_spaces(&kbuf);
2548
2549 err = proc_get_long(&kbuf, &left, &val, &neg,
2550 proc_wspace_sep,
2551 sizeof(proc_wspace_sep), NULL);
2552 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002553 break;
2554 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002555 continue;
2556 if ((min && val < *min) || (max && val > *max))
2557 continue;
2558 *i = val;
2559 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002560 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002561 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002562 err = proc_put_char(&buffer, &left, '\t');
2563 err = proc_put_long(&buffer, &left, val, false);
2564 if (err)
2565 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002566 }
2567 }
2568
Amerigo Wang00b7c332010-05-05 00:26:45 +00002569 if (!write && !first && left && !err)
2570 err = proc_put_char(&buffer, &left, '\n');
2571 if (write && !err)
2572 left -= proc_skip_spaces(&kbuf);
2573free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002574 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002575 free_page(page);
2576 if (first)
2577 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002578 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002579 *lenp -= left;
2580 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002581 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002582}
2583
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002584static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002585 void __user *buffer,
2586 size_t *lenp, loff_t *ppos,
2587 unsigned long convmul,
2588 unsigned long convdiv)
2589{
2590 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002591 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002592}
2593
Linus Torvalds1da177e2005-04-16 15:20:36 -07002594/**
2595 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2596 * @table: the sysctl table
2597 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002598 * @buffer: the user buffer
2599 * @lenp: the size of the user buffer
2600 * @ppos: file position
2601 *
2602 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2603 * values from/to the user buffer, treated as an ASCII string.
2604 *
2605 * This routine will ensure the values are within the range specified by
2606 * table->extra1 (min) and table->extra2 (max).
2607 *
2608 * Returns 0 on success.
2609 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002610int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002611 void __user *buffer, size_t *lenp, loff_t *ppos)
2612{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002613 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002614}
2615
2616/**
2617 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2618 * @table: the sysctl table
2619 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620 * @buffer: the user buffer
2621 * @lenp: the size of the user buffer
2622 * @ppos: file position
2623 *
2624 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2625 * values from/to the user buffer, treated as an ASCII string. The values
2626 * are treated as milliseconds, and converted to jiffies when they are stored.
2627 *
2628 * This routine will ensure the values are within the range specified by
2629 * table->extra1 (min) and table->extra2 (max).
2630 *
2631 * Returns 0 on success.
2632 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002633int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002634 void __user *buffer,
2635 size_t *lenp, loff_t *ppos)
2636{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002637 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002638 lenp, ppos, HZ, 1000l);
2639}
2640
2641
Amerigo Wang00b7c332010-05-05 00:26:45 +00002642static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002643 int *valp,
2644 int write, void *data)
2645{
2646 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002647 if (*lvalp > LONG_MAX / HZ)
2648 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002649 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2650 } else {
2651 int val = *valp;
2652 unsigned long lval;
2653 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002654 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002655 lval = (unsigned long)-val;
2656 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002657 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002658 lval = (unsigned long)val;
2659 }
2660 *lvalp = lval / HZ;
2661 }
2662 return 0;
2663}
2664
Amerigo Wang00b7c332010-05-05 00:26:45 +00002665static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002666 int *valp,
2667 int write, void *data)
2668{
2669 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002670 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2671 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002672 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2673 } else {
2674 int val = *valp;
2675 unsigned long lval;
2676 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002677 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002678 lval = (unsigned long)-val;
2679 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002680 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002681 lval = (unsigned long)val;
2682 }
2683 *lvalp = jiffies_to_clock_t(lval);
2684 }
2685 return 0;
2686}
2687
Amerigo Wang00b7c332010-05-05 00:26:45 +00002688static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002689 int *valp,
2690 int write, void *data)
2691{
2692 if (write) {
2693 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2694 } else {
2695 int val = *valp;
2696 unsigned long lval;
2697 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002698 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002699 lval = (unsigned long)-val;
2700 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002701 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002702 lval = (unsigned long)val;
2703 }
2704 *lvalp = jiffies_to_msecs(lval);
2705 }
2706 return 0;
2707}
2708
2709/**
2710 * proc_dointvec_jiffies - read a vector of integers as seconds
2711 * @table: the sysctl table
2712 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002713 * @buffer: the user buffer
2714 * @lenp: the size of the user buffer
2715 * @ppos: file position
2716 *
2717 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2718 * values from/to the user buffer, treated as an ASCII string.
2719 * The values read are assumed to be in seconds, and are converted into
2720 * jiffies.
2721 *
2722 * Returns 0 on success.
2723 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002724int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002725 void __user *buffer, size_t *lenp, loff_t *ppos)
2726{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002727 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002728 do_proc_dointvec_jiffies_conv,NULL);
2729}
2730
2731/**
2732 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2733 * @table: the sysctl table
2734 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002735 * @buffer: the user buffer
2736 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002737 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002738 *
2739 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2740 * values from/to the user buffer, treated as an ASCII string.
2741 * The values read are assumed to be in 1/USER_HZ seconds, and
2742 * are converted into jiffies.
2743 *
2744 * Returns 0 on success.
2745 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002746int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002747 void __user *buffer, size_t *lenp, loff_t *ppos)
2748{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002749 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002750 do_proc_dointvec_userhz_jiffies_conv,NULL);
2751}
2752
2753/**
2754 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2755 * @table: the sysctl table
2756 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002757 * @buffer: the user buffer
2758 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002759 * @ppos: file position
2760 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002761 *
2762 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2763 * values from/to the user buffer, treated as an ASCII string.
2764 * The values read are assumed to be in 1/1000 seconds, and
2765 * are converted into jiffies.
2766 *
2767 * Returns 0 on success.
2768 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002769int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002770 void __user *buffer, size_t *lenp, loff_t *ppos)
2771{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002772 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002773 do_proc_dointvec_ms_jiffies_conv, NULL);
2774}
2775
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002776static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002777 void __user *buffer, size_t *lenp, loff_t *ppos)
2778{
2779 struct pid *new_pid;
2780 pid_t tmp;
2781 int r;
2782
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002783 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002784
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002785 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002786 lenp, ppos, NULL, NULL);
2787 if (r || !write)
2788 return r;
2789
2790 new_pid = find_get_pid(tmp);
2791 if (!new_pid)
2792 return -ESRCH;
2793
2794 put_pid(xchg(&cad_pid, new_pid));
2795 return 0;
2796}
2797
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002798/**
2799 * proc_do_large_bitmap - read/write from/to a large bitmap
2800 * @table: the sysctl table
2801 * @write: %TRUE if this is a write to the sysctl file
2802 * @buffer: the user buffer
2803 * @lenp: the size of the user buffer
2804 * @ppos: file position
2805 *
2806 * The bitmap is stored at table->data and the bitmap length (in bits)
2807 * in table->maxlen.
2808 *
2809 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2810 * large bitmaps may be represented in a compact manner. Writing into
2811 * the file will clear the bitmap then update it with the given input.
2812 *
2813 * Returns 0 on success.
2814 */
2815int proc_do_large_bitmap(struct ctl_table *table, int write,
2816 void __user *buffer, size_t *lenp, loff_t *ppos)
2817{
2818 int err = 0;
2819 bool first = 1;
2820 size_t left = *lenp;
2821 unsigned long bitmap_len = table->maxlen;
2822 unsigned long *bitmap = (unsigned long *) table->data;
2823 unsigned long *tmp_bitmap = NULL;
2824 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2825
2826 if (!bitmap_len || !left || (*ppos && !write)) {
2827 *lenp = 0;
2828 return 0;
2829 }
2830
2831 if (write) {
2832 unsigned long page = 0;
2833 char *kbuf;
2834
2835 if (left > PAGE_SIZE - 1)
2836 left = PAGE_SIZE - 1;
2837
2838 page = __get_free_page(GFP_TEMPORARY);
2839 kbuf = (char *) page;
2840 if (!kbuf)
2841 return -ENOMEM;
2842 if (copy_from_user(kbuf, buffer, left)) {
2843 free_page(page);
2844 return -EFAULT;
2845 }
2846 kbuf[left] = 0;
2847
2848 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2849 GFP_KERNEL);
2850 if (!tmp_bitmap) {
2851 free_page(page);
2852 return -ENOMEM;
2853 }
2854 proc_skip_char(&kbuf, &left, '\n');
2855 while (!err && left) {
2856 unsigned long val_a, val_b;
2857 bool neg;
2858
2859 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2860 sizeof(tr_a), &c);
2861 if (err)
2862 break;
2863 if (val_a >= bitmap_len || neg) {
2864 err = -EINVAL;
2865 break;
2866 }
2867
2868 val_b = val_a;
2869 if (left) {
2870 kbuf++;
2871 left--;
2872 }
2873
2874 if (c == '-') {
2875 err = proc_get_long(&kbuf, &left, &val_b,
2876 &neg, tr_b, sizeof(tr_b),
2877 &c);
2878 if (err)
2879 break;
2880 if (val_b >= bitmap_len || neg ||
2881 val_a > val_b) {
2882 err = -EINVAL;
2883 break;
2884 }
2885 if (left) {
2886 kbuf++;
2887 left--;
2888 }
2889 }
2890
2891 while (val_a <= val_b)
2892 set_bit(val_a++, tmp_bitmap);
2893
2894 first = 0;
2895 proc_skip_char(&kbuf, &left, '\n');
2896 }
2897 free_page(page);
2898 } else {
2899 unsigned long bit_a, bit_b = 0;
2900
2901 while (left) {
2902 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2903 if (bit_a >= bitmap_len)
2904 break;
2905 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2906 bit_a + 1) - 1;
2907
2908 if (!first) {
2909 err = proc_put_char(&buffer, &left, ',');
2910 if (err)
2911 break;
2912 }
2913 err = proc_put_long(&buffer, &left, bit_a, false);
2914 if (err)
2915 break;
2916 if (bit_a != bit_b) {
2917 err = proc_put_char(&buffer, &left, '-');
2918 if (err)
2919 break;
2920 err = proc_put_long(&buffer, &left, bit_b, false);
2921 if (err)
2922 break;
2923 }
2924
2925 first = 0; bit_b++;
2926 }
2927 if (!err)
2928 err = proc_put_char(&buffer, &left, '\n');
2929 }
2930
2931 if (!err) {
2932 if (write) {
2933 if (*ppos)
2934 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2935 else
2936 memcpy(bitmap, tmp_bitmap,
2937 BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long));
2938 }
2939 kfree(tmp_bitmap);
2940 *lenp -= left;
2941 *ppos += *lenp;
2942 return 0;
2943 } else {
2944 kfree(tmp_bitmap);
2945 return err;
2946 }
2947}
2948
Jovi Zhang55610502011-01-12 17:00:45 -08002949#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002950
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002951int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002952 void __user *buffer, size_t *lenp, loff_t *ppos)
2953{
2954 return -ENOSYS;
2955}
2956
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002957int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002958 void __user *buffer, size_t *lenp, loff_t *ppos)
2959{
2960 return -ENOSYS;
2961}
2962
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002963int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002964 void __user *buffer, size_t *lenp, loff_t *ppos)
2965{
2966 return -ENOSYS;
2967}
2968
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002969int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002970 void __user *buffer, size_t *lenp, loff_t *ppos)
2971{
2972 return -ENOSYS;
2973}
2974
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002975int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002976 void __user *buffer, size_t *lenp, loff_t *ppos)
2977{
2978 return -ENOSYS;
2979}
2980
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002981int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002982 void __user *buffer, size_t *lenp, loff_t *ppos)
2983{
2984 return -ENOSYS;
2985}
2986
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002987int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002988 void __user *buffer, size_t *lenp, loff_t *ppos)
2989{
2990 return -ENOSYS;
2991}
2992
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002993int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002994 void __user *buffer,
2995 size_t *lenp, loff_t *ppos)
2996{
2997 return -ENOSYS;
2998}
2999
3000
Jovi Zhang55610502011-01-12 17:00:45 -08003001#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003002
Linus Torvalds1da177e2005-04-16 15:20:36 -07003003/*
3004 * No sense putting this after each symbol definition, twice,
3005 * exception granted :-)
3006 */
3007EXPORT_SYMBOL(proc_dointvec);
3008EXPORT_SYMBOL(proc_dointvec_jiffies);
3009EXPORT_SYMBOL(proc_dointvec_minmax);
3010EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3011EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3012EXPORT_SYMBOL(proc_dostring);
3013EXPORT_SYMBOL(proc_doulongvec_minmax);
3014EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3015EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11003016EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003017EXPORT_SYMBOL(unregister_sysctl_table);