blob: 4c5eac46cd4b41f544fabe4793958ac129a65701 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070060
61#include <asm/uaccess.h>
62#include <asm/processor.h>
63
Andi Kleen29cbc782006-09-30 01:47:55 +020064#ifdef CONFIG_X86
65#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010066#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010067#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020068#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080069#ifdef CONFIG_BSD_PROCESS_ACCT
70#include <linux/acct.h>
71#endif
Dave Young4f0e0562010-03-10 15:24:09 -080072#ifdef CONFIG_RT_MUTEXES
73#include <linux/rtmutex.h>
74#endif
Dave Young2edf5e42010-03-10 15:24:10 -080075#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
76#include <linux/lockdep.h>
77#endif
Dave Young15485a42010-03-10 15:24:07 -080078#ifdef CONFIG_CHR_DEV_SG
79#include <scsi/sg.h>
80#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020081
Don Zickus58687ac2010-05-07 17:11:44 -040082#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050083#include <linux/nmi.h>
84#endif
85
Eric W. Biederman7058cb02007-10-18 03:05:58 -070086
Linus Torvalds1da177e2005-04-16 15:20:36 -070087#if defined(CONFIG_SYSCTL)
88
89/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070090extern int sysctl_overcommit_memory;
91extern int sysctl_overcommit_ratio;
92extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070093extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070094extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070095extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -070096extern unsigned int core_pipe_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -070097extern int pid_max;
98extern int min_free_kbytes;
Arve Hjønnevåg83de7312009-02-17 14:51:02 -080099extern int min_free_order_shift;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -0800101extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800102extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200103extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100104extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400105extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000106#ifndef CONFIG_MMU
107extern int sysctl_nr_trim_pages;
108#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200109#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200110extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +0200111#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700113/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400114#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700115static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200116static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700117#endif
118
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700119static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700120static int __maybe_unused one = 1;
121static int __maybe_unused two = 2;
Petr Holasekcb16e952011-03-23 16:43:09 -0700122static int __maybe_unused three = 3;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800123static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700124static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700125#ifdef CONFIG_PRINTK
126static int ten_thousand = 10000;
127#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700128
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700129/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
130static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
131
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
133static int maxolduid = 65535;
134static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800135static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
137static int ngroups_max = NGROUPS_MAX;
138
Dave Youngd14f1722010-02-25 20:28:57 -0500139#ifdef CONFIG_INOTIFY_USER
140#include <linux/inotify.h>
141#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700142#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700143#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144#endif
145
David S. Miller08714202008-11-16 23:49:24 -0800146#ifdef CONFIG_SPARC64
147extern int sysctl_tsb_ratio;
148#endif
149
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150#ifdef __hppa__
151extern int pwrsw_enabled;
152extern int unaligned_enabled;
153#endif
154
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800155#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156#ifdef CONFIG_MATHEMU
157extern int sysctl_ieee_emulation_warnings;
158#endif
159extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700160extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161#endif
162
Jes Sorensend2b176e2006-02-28 09:42:23 -0800163#ifdef CONFIG_IA64
164extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800165extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800166#endif
167
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700168#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700169static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700170 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700171static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800172 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700173#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700174
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700175#ifdef CONFIG_PRINTK
176static int proc_dmesg_restrict(struct ctl_table *table, int write,
177 void __user *buffer, size_t *lenp, loff_t *ppos);
178#endif
179
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700180#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800181/* Note: sysrq code uses it's own private copy */
182static int __sysrq_enabled = SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700183
184static int sysrq_sysctl_handler(ctl_table *table, int write,
185 void __user *buffer, size_t *lenp,
186 loff_t *ppos)
187{
188 int error;
189
190 error = proc_dointvec(table, write, buffer, lenp, ppos);
191 if (error)
192 return error;
193
194 if (write)
195 sysrq_toggle_support(__sysrq_enabled);
196
197 return 0;
198}
199
200#endif
201
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700202static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100203static struct ctl_table_root sysctl_table_root;
204static struct ctl_table_header root_table_header = {
Al Virodfef6dc2011-03-08 01:25:28 -0500205 {{.count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100206 .ctl_table = root_table,
Al Virodfef6dc2011-03-08 01:25:28 -0500207 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),}},
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100208 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400209 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100210};
211static struct ctl_table_root sysctl_table_root = {
212 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400213 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100214};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700216static struct ctl_table kern_table[];
217static struct ctl_table vm_table[];
218static struct ctl_table fs_table[];
219static struct ctl_table debug_table[];
220static struct ctl_table dev_table[];
221extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800222#ifdef CONFIG_EPOLL
223extern struct ctl_table epoll_table[];
224#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225
226#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
227int sysctl_legacy_va_layout;
228#endif
229
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230/* The default sysctl tables: */
231
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700232static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 .procname = "kernel",
235 .mode = 0555,
236 .child = kern_table,
237 },
238 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 .procname = "vm",
240 .mode = 0555,
241 .child = vm_table,
242 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 .procname = "fs",
245 .mode = 0555,
246 .child = fs_table,
247 },
248 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 .procname = "debug",
250 .mode = 0555,
251 .child = debug_table,
252 },
253 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 .procname = "dev",
255 .mode = 0555,
256 .child = dev_table,
257 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700258 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259};
260
Ingo Molnar77e54a12007-07-09 18:52:00 +0200261#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100262static int min_sched_granularity_ns = 100000; /* 100 usecs */
263static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
264static int min_wakeup_granularity_ns; /* 0 usecs */
265static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100266static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
267static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Ingo Molnar77e54a12007-07-09 18:52:00 +0200268#endif
269
Mel Gorman5e771902010-05-24 14:32:31 -0700270#ifdef CONFIG_COMPACTION
271static int min_extfrag_threshold;
272static int max_extfrag_threshold = 1000;
273#endif
274
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700275static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200276 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200277 .procname = "sched_child_runs_first",
278 .data = &sysctl_sched_child_runs_first,
279 .maxlen = sizeof(unsigned int),
280 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800281 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200282 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200283#ifdef CONFIG_SCHED_DEBUG
284 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100285 .procname = "sched_min_granularity_ns",
286 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200287 .maxlen = sizeof(unsigned int),
288 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800289 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100290 .extra1 = &min_sched_granularity_ns,
291 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200292 },
293 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200294 .procname = "sched_latency_ns",
295 .data = &sysctl_sched_latency,
296 .maxlen = sizeof(unsigned int),
297 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800298 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200299 .extra1 = &min_sched_granularity_ns,
300 .extra2 = &max_sched_granularity_ns,
301 },
302 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200303 .procname = "sched_wakeup_granularity_ns",
304 .data = &sysctl_sched_wakeup_granularity,
305 .maxlen = sizeof(unsigned int),
306 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800307 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200308 .extra1 = &min_wakeup_granularity_ns,
309 .extra2 = &max_wakeup_granularity_ns,
310 },
311 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100312 .procname = "sched_tunable_scaling",
313 .data = &sysctl_sched_tunable_scaling,
314 .maxlen = sizeof(enum sched_tunable_scaling),
315 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800316 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100317 .extra1 = &min_sched_tunable_scaling,
318 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200319 },
320 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200321 .procname = "sched_migration_cost",
322 .data = &sysctl_sched_migration_cost,
323 .maxlen = sizeof(unsigned int),
324 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800325 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200326 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100327 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100328 .procname = "sched_nr_migrate",
329 .data = &sysctl_sched_nr_migrate,
330 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100331 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800332 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100333 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530334 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200335 .procname = "sched_time_avg",
336 .data = &sysctl_sched_time_avg,
337 .maxlen = sizeof(unsigned int),
338 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800339 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200340 },
341 {
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800342 .procname = "sched_shares_window",
343 .data = &sysctl_sched_shares_window,
344 .maxlen = sizeof(unsigned int),
345 .mode = 0644,
346 .proc_handler = proc_dointvec,
347 },
348 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530349 .procname = "timer_migration",
350 .data = &sysctl_timer_migration,
351 .maxlen = sizeof(unsigned int),
352 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800353 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530354 .extra1 = &zero,
355 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530356 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200357#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200358 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100359 .procname = "sched_rt_period_us",
360 .data = &sysctl_sched_rt_period,
361 .maxlen = sizeof(unsigned int),
362 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800363 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100364 },
365 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100366 .procname = "sched_rt_runtime_us",
367 .data = &sysctl_sched_rt_runtime,
368 .maxlen = sizeof(int),
369 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800370 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100371 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100372#ifdef CONFIG_SCHED_AUTOGROUP
373 {
374 .procname = "sched_autogroup_enabled",
375 .data = &sysctl_sched_autogroup_enabled,
376 .maxlen = sizeof(unsigned int),
377 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800378 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100379 .extra1 = &zero,
380 .extra2 = &one,
381 },
382#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700383#ifdef CONFIG_PROVE_LOCKING
384 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700385 .procname = "prove_locking",
386 .data = &prove_locking,
387 .maxlen = sizeof(int),
388 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800389 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700390 },
391#endif
392#ifdef CONFIG_LOCK_STAT
393 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700394 .procname = "lock_stat",
395 .data = &lock_stat,
396 .maxlen = sizeof(int),
397 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800398 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700399 },
400#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200401 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 .procname = "panic",
403 .data = &panic_timeout,
404 .maxlen = sizeof(int),
405 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800406 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 },
408 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 .procname = "core_uses_pid",
410 .data = &core_uses_pid,
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_pattern",
417 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700418 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800420 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 },
Neil Hormana2939802009-09-23 15:56:56 -0700422 {
Neil Hormana2939802009-09-23 15:56:56 -0700423 .procname = "core_pipe_limit",
424 .data = &core_pipe_limit,
425 .maxlen = sizeof(unsigned int),
426 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800427 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700428 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800429#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700432 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800433 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800434 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800436#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100437#ifdef CONFIG_LATENCYTOP
438 {
439 .procname = "latencytop",
440 .data = &latencytop_enabled,
441 .maxlen = sizeof(int),
442 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800443 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100444 },
445#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446#ifdef CONFIG_BLK_DEV_INITRD
447 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 .procname = "real-root-dev",
449 .data = &real_root_dev,
450 .maxlen = sizeof(int),
451 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800452 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 },
454#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700455 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700456 .procname = "print-fatal-signals",
457 .data = &print_fatal_signals,
458 .maxlen = sizeof(int),
459 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800460 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700461 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700462#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 .procname = "reboot-cmd",
465 .data = reboot_command,
466 .maxlen = 256,
467 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800468 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 },
470 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 .procname = "stop-a",
472 .data = &stop_a_enabled,
473 .maxlen = sizeof (int),
474 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800475 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 },
477 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 .procname = "scons-poweroff",
479 .data = &scons_pwroff,
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#endif
David S. Miller08714202008-11-16 23:49:24 -0800485#ifdef CONFIG_SPARC64
486 {
David S. Miller08714202008-11-16 23:49:24 -0800487 .procname = "tsb-ratio",
488 .data = &sysctl_tsb_ratio,
489 .maxlen = sizeof (int),
490 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800491 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800492 },
493#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494#ifdef __hppa__
495 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 .procname = "soft-power",
497 .data = &pwrsw_enabled,
498 .maxlen = sizeof (int),
499 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800500 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 },
502 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 .procname = "unaligned-trap",
504 .data = &unaligned_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#endif
510 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 .procname = "ctrl-alt-del",
512 .data = &C_A_D,
513 .maxlen = sizeof(int),
514 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800515 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400517#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200518 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200519 .procname = "ftrace_enabled",
520 .data = &ftrace_enabled,
521 .maxlen = sizeof(int),
522 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800523 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200524 },
525#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500526#ifdef CONFIG_STACK_TRACER
527 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500528 .procname = "stack_tracer_enabled",
529 .data = &stack_tracer_enabled,
530 .maxlen = sizeof(int),
531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800532 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500533 },
534#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400535#ifdef CONFIG_TRACING
536 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100537 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400538 .data = &ftrace_dump_on_oops,
539 .maxlen = sizeof(int),
540 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800541 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400542 },
543#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200544#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 .procname = "modprobe",
547 .data = &modprobe_path,
548 .maxlen = KMOD_PATH_LEN,
549 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800550 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 },
Kees Cook3d433212009-04-02 15:49:29 -0700552 {
Kees Cook3d433212009-04-02 15:49:29 -0700553 .procname = "modules_disabled",
554 .data = &modules_disabled,
555 .maxlen = sizeof(int),
556 .mode = 0644,
557 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800558 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700559 .extra1 = &one,
560 .extra2 = &one,
561 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562#endif
Ian Abbott94f17cd2010-06-07 12:57:12 +0100563#ifdef CONFIG_HOTPLUG
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100566 .data = &uevent_helper,
567 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800569 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 },
571#endif
572#ifdef CONFIG_CHR_DEV_SG
573 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 .procname = "sg-big-buff",
575 .data = &sg_big_buff,
576 .maxlen = sizeof (int),
577 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800578 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 },
580#endif
581#ifdef CONFIG_BSD_PROCESS_ACCT
582 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 .procname = "acct",
584 .data = &acct_parm,
585 .maxlen = 3*sizeof(int),
586 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800587 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 },
589#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590#ifdef CONFIG_MAGIC_SYSRQ
591 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800593 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 .maxlen = sizeof (int),
595 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700596 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 },
598#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700599#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700602 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 .maxlen = sizeof (int),
604 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800605 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700607#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 .procname = "threads-max",
610 .data = &max_threads,
611 .maxlen = sizeof(int),
612 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800613 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 },
615 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 .procname = "random",
617 .mode = 0555,
618 .child = random_table,
619 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 {
Eric Paris17f60a72011-04-01 17:07:50 -0400621 .procname = "usermodehelper",
622 .mode = 0555,
623 .child = usermodehelper_table,
624 },
625 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 .procname = "overflowuid",
627 .data = &overflowuid,
628 .maxlen = sizeof(int),
629 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800630 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 .extra1 = &minolduid,
632 .extra2 = &maxolduid,
633 },
634 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 .procname = "overflowgid",
636 .data = &overflowgid,
637 .maxlen = sizeof(int),
638 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800639 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 .extra1 = &minolduid,
641 .extra2 = &maxolduid,
642 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800643#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644#ifdef CONFIG_MATHEMU
645 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 .procname = "ieee_emulation_warnings",
647 .data = &sysctl_ieee_emulation_warnings,
648 .maxlen = sizeof(int),
649 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800650 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 },
652#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200655 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 .maxlen = sizeof(int),
657 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800658 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 },
660#endif
661 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 .procname = "pid_max",
663 .data = &pid_max,
664 .maxlen = sizeof (int),
665 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800666 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 .extra1 = &pid_max_min,
668 .extra2 = &pid_max_max,
669 },
670 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 .procname = "panic_on_oops",
672 .data = &panic_on_oops,
673 .maxlen = sizeof(int),
674 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800675 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800677#if defined CONFIG_PRINTK
678 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800679 .procname = "printk",
680 .data = &console_loglevel,
681 .maxlen = 4*sizeof(int),
682 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800683 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800684 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700687 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 .maxlen = sizeof(int),
689 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800690 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 },
692 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700694 .data = &printk_ratelimit_state.burst,
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,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 },
Dave Youngaf913222009-09-22 16:43:33 -0700699 {
Dave Youngaf913222009-09-22 16:43:33 -0700700 .procname = "printk_delay",
701 .data = &printk_delay_msec,
702 .maxlen = sizeof(int),
703 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800704 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700705 .extra1 = &zero,
706 .extra2 = &ten_thousand,
707 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800709 .procname = "dmesg_restrict",
710 .data = &dmesg_restrict,
711 .maxlen = sizeof(int),
712 .mode = 0644,
713 .proc_handler = proc_dointvec_minmax,
714 .extra1 = &zero,
715 .extra2 = &one,
716 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800717 {
718 .procname = "kptr_restrict",
719 .data = &kptr_restrict,
720 .maxlen = sizeof(int),
721 .mode = 0644,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700722 .proc_handler = proc_dmesg_restrict,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800723 .extra1 = &zero,
724 .extra2 = &two,
725 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800726#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800727 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 .procname = "ngroups_max",
729 .data = &ngroups_max,
730 .maxlen = sizeof (int),
731 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800732 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 },
Don Zickus58687ac2010-05-07 17:11:44 -0400734#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500735 {
Don Zickus58687ac2010-05-07 17:11:44 -0400736 .procname = "watchdog",
737 .data = &watchdog_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500738 .maxlen = sizeof (int),
739 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700740 .proc_handler = proc_dowatchdog,
741 .extra1 = &zero,
742 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400743 },
744 {
745 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700746 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400747 .maxlen = sizeof(int),
748 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700749 .proc_handler = proc_dowatchdog,
Don Zickus58687ac2010-05-07 17:11:44 -0400750 .extra1 = &neg_one,
751 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500752 },
Don Zickus2508ce12010-05-07 17:11:46 -0400753 {
754 .procname = "softlockup_panic",
755 .data = &softlockup_panic,
756 .maxlen = sizeof(int),
757 .mode = 0644,
758 .proc_handler = proc_dointvec_minmax,
759 .extra1 = &zero,
760 .extra2 = &one,
761 },
Don Zickus5dc30552010-11-29 17:07:17 -0500762 {
763 .procname = "nmi_watchdog",
764 .data = &watchdog_enabled,
765 .maxlen = sizeof (int),
766 .mode = 0644,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700767 .proc_handler = proc_dowatchdog,
768 .extra1 = &zero,
769 .extra2 = &one,
Don Zickus5dc30552010-11-29 17:07:17 -0500770 },
771#endif
772#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
773 {
774 .procname = "unknown_nmi_panic",
775 .data = &unknown_nmi_panic,
776 .maxlen = sizeof (int),
777 .mode = 0644,
778 .proc_handler = proc_dointvec,
779 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500780#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781#if defined(CONFIG_X86)
782 {
Don Zickus8da5add2006-09-26 10:52:27 +0200783 .procname = "panic_on_unrecovered_nmi",
784 .data = &panic_on_unrecovered_nmi,
785 .maxlen = sizeof(int),
786 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800787 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200788 },
789 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700790 .procname = "panic_on_io_nmi",
791 .data = &panic_on_io_nmi,
792 .maxlen = sizeof(int),
793 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800794 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700795 },
796 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 .procname = "bootloader_type",
798 .data = &bootloader_type,
799 .maxlen = sizeof (int),
800 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800801 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100803 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700804 .procname = "bootloader_version",
805 .data = &bootloader_version,
806 .maxlen = sizeof (int),
807 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800808 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700809 },
810 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100811 .procname = "kstack_depth_to_print",
812 .data = &kstack_depth_to_print,
813 .maxlen = sizeof(int),
814 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800815 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100816 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100817 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100818 .procname = "io_delay_type",
819 .data = &io_delay_type,
820 .maxlen = sizeof(int),
821 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800822 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100823 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800825#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 .procname = "randomize_va_space",
828 .data = &randomize_va_space,
829 .maxlen = sizeof(int),
830 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800831 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800833#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800834#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700835 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700836 .procname = "spin_retry",
837 .data = &spin_retry,
838 .maxlen = sizeof (int),
839 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800840 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700841 },
842#endif
Len Brown673d5b42007-07-28 03:33:16 -0400843#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800844 {
Pavel Machekc255d842006-02-20 18:27:58 -0800845 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700846 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800847 .maxlen = sizeof (unsigned long),
848 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800849 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800850 },
851#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800852#ifdef CONFIG_IA64
853 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800854 .procname = "ignore-unaligned-usertrap",
855 .data = &no_unaligned_warning,
856 .maxlen = sizeof (int),
857 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800858 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800859 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800860 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800861 .procname = "unaligned-dump-stack",
862 .data = &unaligned_dump_stack,
863 .maxlen = sizeof (int),
864 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800865 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800866 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800867#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800868#ifdef CONFIG_DETECT_HUNG_TASK
869 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800870 .procname = "hung_task_panic",
871 .data = &sysctl_hung_task_panic,
872 .maxlen = sizeof(int),
873 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800874 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800875 .extra1 = &zero,
876 .extra2 = &one,
877 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100878 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100879 .procname = "hung_task_check_count",
880 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100881 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100882 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800883 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100884 },
885 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100886 .procname = "hung_task_timeout_secs",
887 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100888 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100889 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800890 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100891 },
892 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100893 .procname = "hung_task_warnings",
894 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100895 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100896 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800897 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100898 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700899#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200900#ifdef CONFIG_COMPAT
901 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200902 .procname = "compat-log",
903 .data = &compat_log,
904 .maxlen = sizeof (int),
905 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800906 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200907 },
908#endif
Ingo Molnar23f78d42006-06-27 02:54:53 -0700909#ifdef CONFIG_RT_MUTEXES
910 {
Ingo Molnar23f78d42006-06-27 02:54:53 -0700911 .procname = "max_lock_depth",
912 .data = &max_lock_depth,
913 .maxlen = sizeof(int),
914 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800915 .proc_handler = proc_dointvec,
Ingo Molnar23f78d42006-06-27 02:54:53 -0700916 },
917#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700918 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700919 .procname = "poweroff_cmd",
920 .data = &poweroff_cmd,
921 .maxlen = POWEROFF_CMD_PATH_LEN,
922 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800923 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700924 },
David Howells0b77f5b2008-04-29 01:01:32 -0700925#ifdef CONFIG_KEYS
926 {
David Howells0b77f5b2008-04-29 01:01:32 -0700927 .procname = "keys",
928 .mode = 0555,
929 .child = key_sysctls,
930 },
931#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700932#ifdef CONFIG_RCU_TORTURE_TEST
933 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700934 .procname = "rcutorture_runnable",
935 .data = &rcutorture_runnable,
936 .maxlen = sizeof(int),
937 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800938 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700939 },
940#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200941#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -0400942 /*
943 * User-space scripts rely on the existence of this file
944 * as a feature check for perf_events being enabled.
945 *
946 * So it's an ABI, do not remove!
947 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200948 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200949 .procname = "perf_event_paranoid",
950 .data = &sysctl_perf_event_paranoid,
951 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200952 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800953 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200954 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200955 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200956 .procname = "perf_event_mlock_kb",
957 .data = &sysctl_perf_event_mlock,
958 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200959 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800960 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200961 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200962 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200963 .procname = "perf_event_max_sample_rate",
964 .data = &sysctl_perf_event_sample_rate,
965 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200966 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +0100967 .proc_handler = perf_proc_update_handler,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200968 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200969#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200970#ifdef CONFIG_KMEMCHECK
971 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200972 .procname = "kmemcheck",
973 .data = &kmemcheck_enabled,
974 .maxlen = sizeof(int),
975 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800976 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +0200977 },
978#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200979#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200980 {
Jens Axboe5e605b62009-08-05 09:07:21 +0200981 .procname = "blk_iopoll",
982 .data = &blk_iopoll_enabled,
983 .maxlen = sizeof(int),
984 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800985 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +0200986 },
Jens Axboecb684b52009-09-15 21:53:11 +0200987#endif
Bryan Huntsman3f2bc4d2011-08-16 17:27:22 -0700988#ifdef CONFIG_ARM
989 {
990 .procname = "boot_reason",
991 .data = &boot_reason,
992 .maxlen = sizeof(int),
993 .mode = 0444,
994 .proc_handler = proc_dointvec,
995},
996#endif
997/*
998 * NOTE: do not add new entries to this table unless you have read
999 * Documentation/sysctl/ctl_unnumbered.txt
1000 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001001 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002};
1003
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001004static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006 .procname = "overcommit_memory",
1007 .data = &sysctl_overcommit_memory,
1008 .maxlen = sizeof(sysctl_overcommit_memory),
1009 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001010 .proc_handler = proc_dointvec_minmax,
1011 .extra1 = &zero,
1012 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013 },
1014 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001015 .procname = "panic_on_oom",
1016 .data = &sysctl_panic_on_oom,
1017 .maxlen = sizeof(sysctl_panic_on_oom),
1018 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001019 .proc_handler = proc_dointvec_minmax,
1020 .extra1 = &zero,
1021 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001022 },
1023 {
David Rientjesfe071d72007-10-16 23:25:56 -07001024 .procname = "oom_kill_allocating_task",
1025 .data = &sysctl_oom_kill_allocating_task,
1026 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1027 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001028 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001029 },
1030 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001031 .procname = "oom_dump_tasks",
1032 .data = &sysctl_oom_dump_tasks,
1033 .maxlen = sizeof(sysctl_oom_dump_tasks),
1034 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001035 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001036 },
1037 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038 .procname = "overcommit_ratio",
1039 .data = &sysctl_overcommit_ratio,
1040 .maxlen = sizeof(sysctl_overcommit_ratio),
1041 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001042 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043 },
1044 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001045 .procname = "page-cluster",
1046 .data = &page_cluster,
1047 .maxlen = sizeof(int),
1048 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001049 .proc_handler = proc_dointvec_minmax,
1050 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051 },
1052 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053 .procname = "dirty_background_ratio",
1054 .data = &dirty_background_ratio,
1055 .maxlen = sizeof(dirty_background_ratio),
1056 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001057 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058 .extra1 = &zero,
1059 .extra2 = &one_hundred,
1060 },
1061 {
David Rientjes2da02992009-01-06 14:39:31 -08001062 .procname = "dirty_background_bytes",
1063 .data = &dirty_background_bytes,
1064 .maxlen = sizeof(dirty_background_bytes),
1065 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001066 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001067 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001068 },
1069 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 .procname = "dirty_ratio",
1071 .data = &vm_dirty_ratio,
1072 .maxlen = sizeof(vm_dirty_ratio),
1073 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001074 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001075 .extra1 = &zero,
1076 .extra2 = &one_hundred,
1077 },
1078 {
David Rientjes2da02992009-01-06 14:39:31 -08001079 .procname = "dirty_bytes",
1080 .data = &vm_dirty_bytes,
1081 .maxlen = sizeof(vm_dirty_bytes),
1082 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001083 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001084 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001085 },
1086 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001087 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001088 .data = &dirty_writeback_interval,
1089 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001090 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001091 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092 },
1093 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001095 .data = &dirty_expire_interval,
1096 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001098 .proc_handler = proc_dointvec_minmax,
1099 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001100 },
1101 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102 .procname = "nr_pdflush_threads",
1103 .data = &nr_pdflush_threads,
1104 .maxlen = sizeof nr_pdflush_threads,
1105 .mode = 0444 /* read-only*/,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001106 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107 },
1108 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001109 .procname = "swappiness",
1110 .data = &vm_swappiness,
1111 .maxlen = sizeof(vm_swappiness),
1112 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001113 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001114 .extra1 = &zero,
1115 .extra2 = &one_hundred,
1116 },
1117#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001118 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001120 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121 .maxlen = sizeof(unsigned long),
1122 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001123 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001124 .extra1 = (void *)&hugetlb_zero,
1125 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001126 },
1127#ifdef CONFIG_NUMA
1128 {
1129 .procname = "nr_hugepages_mempolicy",
1130 .data = NULL,
1131 .maxlen = sizeof(unsigned long),
1132 .mode = 0644,
1133 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1134 .extra1 = (void *)&hugetlb_zero,
1135 .extra2 = (void *)&hugetlb_infinity,
1136 },
1137#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139 .procname = "hugetlb_shm_group",
1140 .data = &sysctl_hugetlb_shm_group,
1141 .maxlen = sizeof(gid_t),
1142 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001143 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 },
Mel Gorman396faf02007-07-17 04:03:13 -07001145 {
Mel Gorman396faf02007-07-17 04:03:13 -07001146 .procname = "hugepages_treat_as_movable",
1147 .data = &hugepages_treat_as_movable,
1148 .maxlen = sizeof(int),
1149 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001150 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001151 },
Adam Litke54f9f802007-10-16 01:26:20 -07001152 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001153 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001154 .data = NULL,
1155 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001156 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001157 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001158 .extra1 = (void *)&hugetlb_zero,
1159 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001160 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161#endif
1162 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163 .procname = "lowmem_reserve_ratio",
1164 .data = &sysctl_lowmem_reserve_ratio,
1165 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1166 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001167 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168 },
1169 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001170 .procname = "drop_caches",
1171 .data = &sysctl_drop_caches,
1172 .maxlen = sizeof(int),
1173 .mode = 0644,
1174 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001175 .extra1 = &one,
1176 .extra2 = &three,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001177 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001178#ifdef CONFIG_COMPACTION
1179 {
1180 .procname = "compact_memory",
1181 .data = &sysctl_compact_memory,
1182 .maxlen = sizeof(int),
1183 .mode = 0200,
1184 .proc_handler = sysctl_compaction_handler,
1185 },
Mel Gorman5e771902010-05-24 14:32:31 -07001186 {
1187 .procname = "extfrag_threshold",
1188 .data = &sysctl_extfrag_threshold,
1189 .maxlen = sizeof(int),
1190 .mode = 0644,
1191 .proc_handler = sysctl_extfrag_handler,
1192 .extra1 = &min_extfrag_threshold,
1193 .extra2 = &max_extfrag_threshold,
1194 },
1195
Mel Gorman76ab0f52010-05-24 14:32:28 -07001196#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001197 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001198 .procname = "min_free_kbytes",
1199 .data = &min_free_kbytes,
1200 .maxlen = sizeof(min_free_kbytes),
1201 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001202 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001203 .extra1 = &zero,
1204 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001205 {
Arve Hjønnevåg83de7312009-02-17 14:51:02 -08001206 .procname = "min_free_order_shift",
1207 .data = &min_free_order_shift,
1208 .maxlen = sizeof(min_free_order_shift),
1209 .mode = 0644,
1210 .proc_handler = &proc_dointvec
1211 },
1212 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001213 .procname = "percpu_pagelist_fraction",
1214 .data = &percpu_pagelist_fraction,
1215 .maxlen = sizeof(percpu_pagelist_fraction),
1216 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001217 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001218 .extra1 = &min_percpu_pagelist_fract,
1219 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220#ifdef CONFIG_MMU
1221 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001222 .procname = "max_map_count",
1223 .data = &sysctl_max_map_count,
1224 .maxlen = sizeof(sysctl_max_map_count),
1225 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001226 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001227 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001228 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001229#else
1230 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001231 .procname = "nr_trim_pages",
1232 .data = &sysctl_nr_trim_pages,
1233 .maxlen = sizeof(sysctl_nr_trim_pages),
1234 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001235 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001236 .extra1 = &zero,
1237 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238#endif
1239 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001240 .procname = "laptop_mode",
1241 .data = &laptop_mode,
1242 .maxlen = sizeof(laptop_mode),
1243 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001244 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001245 },
1246 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001247 .procname = "block_dump",
1248 .data = &block_dump,
1249 .maxlen = sizeof(block_dump),
1250 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001251 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001252 .extra1 = &zero,
1253 },
1254 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255 .procname = "vfs_cache_pressure",
1256 .data = &sysctl_vfs_cache_pressure,
1257 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1258 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001259 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001260 .extra1 = &zero,
1261 },
1262#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1263 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001264 .procname = "legacy_va_layout",
1265 .data = &sysctl_legacy_va_layout,
1266 .maxlen = sizeof(sysctl_legacy_va_layout),
1267 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001268 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001269 .extra1 = &zero,
1270 },
1271#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001272#ifdef CONFIG_NUMA
1273 {
Christoph Lameter17436602006-01-18 17:42:32 -08001274 .procname = "zone_reclaim_mode",
1275 .data = &zone_reclaim_mode,
1276 .maxlen = sizeof(zone_reclaim_mode),
1277 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001278 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001279 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001280 },
Christoph Lameter96146342006-07-03 00:24:13 -07001281 {
Christoph Lameter96146342006-07-03 00:24:13 -07001282 .procname = "min_unmapped_ratio",
1283 .data = &sysctl_min_unmapped_ratio,
1284 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1285 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001286 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001287 .extra1 = &zero,
1288 .extra2 = &one_hundred,
1289 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001290 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001291 .procname = "min_slab_ratio",
1292 .data = &sysctl_min_slab_ratio,
1293 .maxlen = sizeof(sysctl_min_slab_ratio),
1294 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001295 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001296 .extra1 = &zero,
1297 .extra2 = &one_hundred,
1298 },
Christoph Lameter17436602006-01-18 17:42:32 -08001299#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001300#ifdef CONFIG_SMP
1301 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001302 .procname = "stat_interval",
1303 .data = &sysctl_stat_interval,
1304 .maxlen = sizeof(sysctl_stat_interval),
1305 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001306 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001307 },
1308#endif
David Howells6e141542009-12-15 19:27:45 +00001309#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001310 {
Eric Parised032182007-06-28 15:55:21 -04001311 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001312 .data = &dac_mmap_min_addr,
1313 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001314 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001315 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001316 },
David Howells6e141542009-12-15 19:27:45 +00001317#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001318#ifdef CONFIG_NUMA
1319 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001320 .procname = "numa_zonelist_order",
1321 .data = &numa_zonelist_order,
1322 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1323 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001324 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001325 },
1326#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001327#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001328 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001329 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001330 .procname = "vdso_enabled",
1331 .data = &vdso_enabled,
1332 .maxlen = sizeof(vdso_enabled),
1333 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001334 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001335 .extra1 = &zero,
1336 },
1337#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001338#ifdef CONFIG_HIGHMEM
1339 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001340 .procname = "highmem_is_dirtyable",
1341 .data = &vm_highmem_is_dirtyable,
1342 .maxlen = sizeof(vm_highmem_is_dirtyable),
1343 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001344 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001345 .extra1 = &zero,
1346 .extra2 = &one,
1347 },
1348#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001349 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001350 .procname = "scan_unevictable_pages",
1351 .data = &scan_unevictable_pages,
1352 .maxlen = sizeof(scan_unevictable_pages),
1353 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001354 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001355 },
Andi Kleen6a460792009-09-16 11:50:15 +02001356#ifdef CONFIG_MEMORY_FAILURE
1357 {
Andi Kleen6a460792009-09-16 11:50:15 +02001358 .procname = "memory_failure_early_kill",
1359 .data = &sysctl_memory_failure_early_kill,
1360 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1361 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001362 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001363 .extra1 = &zero,
1364 .extra2 = &one,
1365 },
1366 {
Andi Kleen6a460792009-09-16 11:50:15 +02001367 .procname = "memory_failure_recovery",
1368 .data = &sysctl_memory_failure_recovery,
1369 .maxlen = sizeof(sysctl_memory_failure_recovery),
1370 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001371 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001372 .extra1 = &zero,
1373 .extra2 = &one,
1374 },
1375#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001376 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001377};
1378
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001379#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001380static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001381 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001382};
1383#endif
1384
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001385static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001386 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001387 .procname = "inode-nr",
1388 .data = &inodes_stat,
1389 .maxlen = 2*sizeof(int),
1390 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001391 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392 },
1393 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001394 .procname = "inode-state",
1395 .data = &inodes_stat,
1396 .maxlen = 7*sizeof(int),
1397 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001398 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001399 },
1400 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401 .procname = "file-nr",
1402 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001403 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001404 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001405 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001406 },
1407 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408 .procname = "file-max",
1409 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001410 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001412 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413 },
1414 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001415 .procname = "nr_open",
1416 .data = &sysctl_nr_open,
1417 .maxlen = sizeof(int),
1418 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001419 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001420 .extra1 = &sysctl_nr_open_min,
1421 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001422 },
1423 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001424 .procname = "dentry-state",
1425 .data = &dentry_stat,
1426 .maxlen = 6*sizeof(int),
1427 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001428 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001429 },
1430 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001431 .procname = "overflowuid",
1432 .data = &fs_overflowuid,
1433 .maxlen = sizeof(int),
1434 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001435 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001436 .extra1 = &minolduid,
1437 .extra2 = &maxolduid,
1438 },
1439 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001440 .procname = "overflowgid",
1441 .data = &fs_overflowgid,
1442 .maxlen = sizeof(int),
1443 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001444 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001445 .extra1 = &minolduid,
1446 .extra2 = &maxolduid,
1447 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001448#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001449 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001450 .procname = "leases-enable",
1451 .data = &leases_enable,
1452 .maxlen = sizeof(int),
1453 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001454 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001456#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457#ifdef CONFIG_DNOTIFY
1458 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459 .procname = "dir-notify-enable",
1460 .data = &dir_notify_enable,
1461 .maxlen = sizeof(int),
1462 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001463 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 },
1465#endif
1466#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001467#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001468 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 .procname = "lease-break-time",
1470 .data = &lease_break_time,
1471 .maxlen = sizeof(int),
1472 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001473 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001475#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001476#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001478 .procname = "aio-nr",
1479 .data = &aio_nr,
1480 .maxlen = sizeof(aio_nr),
1481 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001482 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483 },
1484 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001485 .procname = "aio-max-nr",
1486 .data = &aio_max_nr,
1487 .maxlen = sizeof(aio_max_nr),
1488 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001489 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001491#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001492#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001493 {
Robert Love0399cb02005-07-13 12:38:18 -04001494 .procname = "inotify",
1495 .mode = 0555,
1496 .child = inotify_table,
1497 },
1498#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001499#ifdef CONFIG_EPOLL
1500 {
1501 .procname = "epoll",
1502 .mode = 0555,
1503 .child = epoll_table,
1504 },
1505#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001507 {
Alan Coxd6e71142005-06-23 00:09:43 -07001508 .procname = "suid_dumpable",
1509 .data = &suid_dumpable,
1510 .maxlen = sizeof(int),
1511 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001512 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001513 .extra1 = &zero,
1514 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001515 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001516#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1517 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001518 .procname = "binfmt_misc",
1519 .mode = 0555,
1520 .child = binfmt_misc_table,
1521 },
1522#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001523 {
Jens Axboeff9da692010-06-03 14:54:39 +02001524 .procname = "pipe-max-size",
1525 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001526 .maxlen = sizeof(int),
1527 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001528 .proc_handler = &pipe_proc_fn,
1529 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001530 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001531 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001532};
1533
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001534static struct ctl_table debug_table[] = {
Heiko Carstensab3c68e2010-05-17 10:00:21 +02001535#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC) || \
Chris Metcalf571d76a2011-05-16 14:23:44 -04001536 defined(CONFIG_S390) || defined(CONFIG_TILE)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001537 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001538 .procname = "exception-trace",
1539 .data = &show_unhandled_signals,
1540 .maxlen = sizeof(int),
1541 .mode = 0644,
1542 .proc_handler = proc_dointvec
1543 },
1544#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001545#if defined(CONFIG_OPTPROBES)
1546 {
1547 .procname = "kprobes-optimization",
1548 .data = &sysctl_kprobes_optimization,
1549 .maxlen = sizeof(int),
1550 .mode = 0644,
1551 .proc_handler = proc_kprobes_optimization_handler,
1552 .extra1 = &zero,
1553 .extra2 = &one,
1554 },
1555#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001556 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001557};
1558
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001559static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001560 { }
Robert Love0eeca282005-07-12 17:06:03 -04001561};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001562
Al Viro330d57f2005-11-04 10:18:40 +00001563static DEFINE_SPINLOCK(sysctl_lock);
1564
1565/* called under sysctl_lock */
1566static int use_table(struct ctl_table_header *p)
1567{
1568 if (unlikely(p->unregistering))
1569 return 0;
1570 p->used++;
1571 return 1;
1572}
1573
1574/* called under sysctl_lock */
1575static void unuse_table(struct ctl_table_header *p)
1576{
1577 if (!--p->used)
1578 if (unlikely(p->unregistering))
1579 complete(p->unregistering);
1580}
1581
1582/* called under sysctl_lock, will reacquire if has to wait */
1583static void start_unregistering(struct ctl_table_header *p)
1584{
1585 /*
1586 * if p->used is 0, nobody will ever touch that entry again;
1587 * we'll eliminate all paths to it before dropping sysctl_lock
1588 */
1589 if (unlikely(p->used)) {
1590 struct completion wait;
1591 init_completion(&wait);
1592 p->unregistering = &wait;
1593 spin_unlock(&sysctl_lock);
1594 wait_for_completion(&wait);
1595 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001596 } else {
1597 /* anything non-NULL; we'll never dereference it */
1598 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001599 }
1600 /*
1601 * do not remove from the list until nobody holds it; walking the
1602 * list in do_sysctl() relies on that.
1603 */
1604 list_del_init(&p->ctl_entry);
1605}
1606
Al Virof7e6ced2008-07-15 01:44:23 -04001607void sysctl_head_get(struct ctl_table_header *head)
1608{
1609 spin_lock(&sysctl_lock);
1610 head->count++;
1611 spin_unlock(&sysctl_lock);
1612}
1613
Al Virodfef6dc2011-03-08 01:25:28 -05001614static void free_head(struct rcu_head *rcu)
1615{
1616 kfree(container_of(rcu, struct ctl_table_header, rcu));
1617}
1618
Al Virof7e6ced2008-07-15 01:44:23 -04001619void sysctl_head_put(struct ctl_table_header *head)
1620{
1621 spin_lock(&sysctl_lock);
1622 if (!--head->count)
Al Virodfef6dc2011-03-08 01:25:28 -05001623 call_rcu(&head->rcu, free_head);
Al Virof7e6ced2008-07-15 01:44:23 -04001624 spin_unlock(&sysctl_lock);
1625}
1626
1627struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1628{
1629 if (!head)
1630 BUG();
1631 spin_lock(&sysctl_lock);
1632 if (!use_table(head))
1633 head = ERR_PTR(-ENOENT);
1634 spin_unlock(&sysctl_lock);
1635 return head;
1636}
1637
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001638void sysctl_head_finish(struct ctl_table_header *head)
1639{
1640 if (!head)
1641 return;
1642 spin_lock(&sysctl_lock);
1643 unuse_table(head);
1644 spin_unlock(&sysctl_lock);
1645}
1646
Al Viro73455092008-07-14 21:22:20 -04001647static struct ctl_table_set *
1648lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1649{
1650 struct ctl_table_set *set = &root->default_set;
1651 if (root->lookup)
1652 set = root->lookup(root, namespaces);
1653 return set;
1654}
1655
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001656static struct list_head *
1657lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001658{
Al Viro73455092008-07-14 21:22:20 -04001659 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1660 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001661}
1662
1663struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1664 struct ctl_table_header *prev)
1665{
1666 struct ctl_table_root *root;
1667 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001668 struct ctl_table_header *head;
1669 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001670
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001671 spin_lock(&sysctl_lock);
1672 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001673 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001674 tmp = &prev->ctl_entry;
1675 unuse_table(prev);
1676 goto next;
1677 }
1678 tmp = &root_table_header.ctl_entry;
1679 for (;;) {
1680 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1681
1682 if (!use_table(head))
1683 goto next;
1684 spin_unlock(&sysctl_lock);
1685 return head;
1686 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001687 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001688 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001689 header_list = lookup_header_list(root, namespaces);
1690 if (tmp != header_list)
1691 continue;
1692
1693 do {
1694 root = list_entry(root->root_list.next,
1695 struct ctl_table_root, root_list);
1696 if (root == &sysctl_table_root)
1697 goto out;
1698 header_list = lookup_header_list(root, namespaces);
1699 } while (list_empty(header_list));
1700 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001701 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001702out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001703 spin_unlock(&sysctl_lock);
1704 return NULL;
1705}
1706
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001707struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1708{
1709 return __sysctl_head_next(current->nsproxy, prev);
1710}
1711
1712void register_sysctl_root(struct ctl_table_root *root)
1713{
1714 spin_lock(&sysctl_lock);
1715 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1716 spin_unlock(&sysctl_lock);
1717}
1718
Linus Torvalds1da177e2005-04-16 15:20:36 -07001719/*
Eric W. Biederman1ff007eb2007-02-14 00:34:11 -08001720 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001721 * some sysctl variables are readonly even to root.
1722 */
1723
1724static int test_perm(int mode, int op)
1725{
David Howells76aac0e2008-11-14 10:39:12 +11001726 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001727 mode >>= 6;
1728 else if (in_egroup_p(0))
1729 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001730 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001731 return 0;
1732 return -EACCES;
1733}
1734
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001735int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736{
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001737 int mode;
1738
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001739 if (root->permissions)
1740 mode = root->permissions(root, current->nsproxy, table);
1741 else
1742 mode = table->mode;
1743
1744 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001745}
1746
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001747static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1748{
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001749 for (; table->procname; table++) {
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001750 table->parent = parent;
1751 if (table->child)
1752 sysctl_set_parent(table, table->child);
1753 }
1754}
1755
1756static __init int sysctl_init(void)
1757{
1758 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001759#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Andi Kleenb3bd3de2010-08-10 14:17:51 -07001760 sysctl_check_table(current->nsproxy, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001761#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001762 return 0;
1763}
1764
1765core_initcall(sysctl_init);
1766
Al Virobfbcf032008-07-27 06:31:22 +01001767static struct ctl_table *is_branch_in(struct ctl_table *branch,
1768 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001769{
1770 struct ctl_table *p;
1771 const char *s = branch->procname;
1772
1773 /* branch should have named subdirectory as its first element */
1774 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001775 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001776
1777 /* ... and nothing else */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001778 if (branch[1].procname)
Al Virobfbcf032008-07-27 06:31:22 +01001779 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001780
1781 /* table should contain subdirectory with the same name */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001782 for (p = table; p->procname; p++) {
Al Viroae7edec2008-07-15 06:33:31 -04001783 if (!p->child)
1784 continue;
1785 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001786 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001787 }
Al Virobfbcf032008-07-27 06:31:22 +01001788 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001789}
1790
1791/* see if attaching q to p would be an improvement */
1792static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1793{
1794 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001795 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001796 int is_better = 0;
1797 int not_in_parent = !p->attached_by;
1798
Al Virobfbcf032008-07-27 06:31:22 +01001799 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001800 if (by == q->attached_by)
1801 is_better = 1;
1802 if (to == p->attached_by)
1803 not_in_parent = 1;
1804 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001805 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001806 }
1807
1808 if (is_better && not_in_parent) {
1809 q->attached_by = by;
1810 q->attached_to = to;
1811 q->parent = p;
1812 }
1813}
1814
Linus Torvalds1da177e2005-04-16 15:20:36 -07001815/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001816 * __register_sysctl_paths - register a sysctl hierarchy
1817 * @root: List of sysctl headers to register on
1818 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001819 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001820 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001821 *
1822 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001823 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001824 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001825 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001826 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001827 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1828 * enter a sysctl file
1829 *
1830 * data - a pointer to data for use by proc_handler
1831 *
1832 * maxlen - the maximum size in bytes of the data
1833 *
1834 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1835 *
1836 * child - a pointer to the child sysctl table if this entry is a directory, or
1837 * %NULL.
1838 *
1839 * proc_handler - the text handler routine (described below)
1840 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001841 * de - for internal use by the sysctl routines
1842 *
1843 * extra1, extra2 - extra pointers usable by the proc handler routines
1844 *
1845 * Leaf nodes in the sysctl tree will be represented by a single file
1846 * under /proc; non-leaf nodes will be represented by directories.
1847 *
1848 * sysctl(2) can automatically manage read and write requests through
1849 * the sysctl table. The data and maxlen fields of the ctl_table
1850 * struct enable minimal validation of the values being written to be
1851 * performed, and the mode field allows minimal authentication.
1852 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001853 * There must be a proc_handler routine for any terminal nodes
1854 * mirrored under /proc/sys (non-terminals are handled by a built-in
1855 * directory handler). Several default handlers are available to
1856 * cover common cases -
1857 *
1858 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1859 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1860 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1861 *
1862 * It is the handler's job to read the input buffer from user memory
1863 * and process it. The handler should return 0 on success.
1864 *
1865 * This routine returns %NULL on a failure to register, and a pointer
1866 * to the table header on success.
1867 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001868struct ctl_table_header *__register_sysctl_paths(
1869 struct ctl_table_root *root,
1870 struct nsproxy *namespaces,
1871 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001872{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001873 struct ctl_table_header *header;
1874 struct ctl_table *new, **prevp;
1875 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001876 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001877
1878 /* Count the path components */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001879 for (npath = 0; path[npath].procname; ++npath)
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001880 ;
1881
1882 /*
1883 * For each path component, allocate a 2-element ctl_table array.
1884 * The first array element will be filled with the sysctl entry
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001885 * for this, the second will be the sentinel (procname == 0).
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001886 *
1887 * We allocate everything in one go so that we don't have to
1888 * worry about freeing additional memory in unregister_sysctl_table.
1889 */
1890 header = kzalloc(sizeof(struct ctl_table_header) +
1891 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1892 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001893 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001894
1895 new = (struct ctl_table *) (header + 1);
1896
1897 /* Now connect the dots */
1898 prevp = &header->ctl_table;
1899 for (n = 0; n < npath; ++n, ++path) {
1900 /* Copy the procname */
1901 new->procname = path->procname;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001902 new->mode = 0555;
1903
1904 *prevp = new;
1905 prevp = &new->child;
1906
1907 new += 2;
1908 }
1909 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001910 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001911
1912 INIT_LIST_HEAD(&header->ctl_entry);
1913 header->used = 0;
1914 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001915 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001916 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001917 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001918#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001919 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001920 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001921 return NULL;
1922 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001923#endif
Al Viro330d57f2005-11-04 10:18:40 +00001924 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001925 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001926 header->attached_by = header->ctl_table;
1927 header->attached_to = root_table;
1928 header->parent = &root_table_header;
1929 for (set = header->set; set; set = set->parent) {
1930 struct ctl_table_header *p;
1931 list_for_each_entry(p, &set->list, ctl_entry) {
1932 if (p->unregistering)
1933 continue;
1934 try_attach(p, header);
1935 }
1936 }
1937 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001938 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001939 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001940
1941 return header;
1942}
1943
1944/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001945 * register_sysctl_table_path - register a sysctl table hierarchy
1946 * @path: The path to the directory the sysctl table is in.
1947 * @table: the top-level table structure
1948 *
1949 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1950 * array. A completely 0 filled entry terminates the table.
1951 *
1952 * See __register_sysctl_paths for more details.
1953 */
1954struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1955 struct ctl_table *table)
1956{
1957 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1958 path, table);
1959}
1960
1961/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001962 * register_sysctl_table - register a sysctl table hierarchy
1963 * @table: the top-level table structure
1964 *
1965 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1966 * array. A completely 0 filled entry terminates the table.
1967 *
1968 * See register_sysctl_paths for more details.
1969 */
1970struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1971{
1972 static const struct ctl_path null_path[] = { {} };
1973
1974 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001975}
1976
1977/**
1978 * unregister_sysctl_table - unregister a sysctl table hierarchy
1979 * @header: the header returned from register_sysctl_table
1980 *
1981 * Unregisters the sysctl table and all children. proc entries may not
1982 * actually be removed until they are no longer used by anyone.
1983 */
1984void unregister_sysctl_table(struct ctl_table_header * header)
1985{
Al Viro330d57f2005-11-04 10:18:40 +00001986 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08001987
1988 if (header == NULL)
1989 return;
1990
Al Viro330d57f2005-11-04 10:18:40 +00001991 spin_lock(&sysctl_lock);
1992 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04001993 if (!--header->parent->count) {
1994 WARN_ON(1);
Al Virodfef6dc2011-03-08 01:25:28 -05001995 call_rcu(&header->parent->rcu, free_head);
Al Viroae7edec2008-07-15 06:33:31 -04001996 }
Al Virof7e6ced2008-07-15 01:44:23 -04001997 if (!--header->count)
Al Virodfef6dc2011-03-08 01:25:28 -05001998 call_rcu(&header->rcu, free_head);
Al Viro330d57f2005-11-04 10:18:40 +00001999 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002000}
2001
Al Viro90434762008-07-15 08:54:06 -04002002int sysctl_is_seen(struct ctl_table_header *p)
2003{
2004 struct ctl_table_set *set = p->set;
2005 int res;
2006 spin_lock(&sysctl_lock);
2007 if (p->unregistering)
2008 res = 0;
2009 else if (!set->is_seen)
2010 res = 1;
2011 else
2012 res = set->is_seen(set);
2013 spin_unlock(&sysctl_lock);
2014 return res;
2015}
2016
Al Viro73455092008-07-14 21:22:20 -04002017void setup_sysctl_set(struct ctl_table_set *p,
2018 struct ctl_table_set *parent,
2019 int (*is_seen)(struct ctl_table_set *))
2020{
2021 INIT_LIST_HEAD(&p->list);
2022 p->parent = parent ? parent : &sysctl_table_root.default_set;
2023 p->is_seen = is_seen;
2024}
2025
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002026#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002027struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002028{
2029 return NULL;
2030}
2031
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002032struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2033 struct ctl_table *table)
2034{
2035 return NULL;
2036}
2037
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002038void unregister_sysctl_table(struct ctl_table_header * table)
2039{
2040}
2041
Al Viro73455092008-07-14 21:22:20 -04002042void setup_sysctl_set(struct ctl_table_set *p,
2043 struct ctl_table_set *parent,
2044 int (*is_seen)(struct ctl_table_set *))
2045{
2046}
2047
Al Virof7e6ced2008-07-15 01:44:23 -04002048void sysctl_head_put(struct ctl_table_header *head)
2049{
2050}
2051
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002052#endif /* CONFIG_SYSCTL */
2053
Linus Torvalds1da177e2005-04-16 15:20:36 -07002054/*
2055 * /proc/sys support
2056 */
2057
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002058#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002059
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002060static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002061 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002062 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002063{
2064 size_t len;
2065 char __user *p;
2066 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002067
2068 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002069 *lenp = 0;
2070 return 0;
2071 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002072
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002073 if (write) {
2074 len = 0;
2075 p = buffer;
2076 while (len < *lenp) {
2077 if (get_user(c, p++))
2078 return -EFAULT;
2079 if (c == 0 || c == '\n')
2080 break;
2081 len++;
2082 }
2083 if (len >= maxlen)
2084 len = maxlen-1;
2085 if(copy_from_user(data, buffer, len))
2086 return -EFAULT;
2087 ((char *) data)[len] = 0;
2088 *ppos += *lenp;
2089 } else {
2090 len = strlen(data);
2091 if (len > maxlen)
2092 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002093
2094 if (*ppos > len) {
2095 *lenp = 0;
2096 return 0;
2097 }
2098
2099 data += *ppos;
2100 len -= *ppos;
2101
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002102 if (len > *lenp)
2103 len = *lenp;
2104 if (len)
2105 if(copy_to_user(buffer, data, len))
2106 return -EFAULT;
2107 if (len < *lenp) {
2108 if(put_user('\n', ((char __user *) buffer) + len))
2109 return -EFAULT;
2110 len++;
2111 }
2112 *lenp = len;
2113 *ppos += len;
2114 }
2115 return 0;
2116}
2117
Linus Torvalds1da177e2005-04-16 15:20:36 -07002118/**
2119 * proc_dostring - read a string sysctl
2120 * @table: the sysctl table
2121 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002122 * @buffer: the user buffer
2123 * @lenp: the size of the user buffer
2124 * @ppos: file position
2125 *
2126 * Reads/writes a string from/to the user buffer. If the kernel
2127 * buffer provided is not large enough to hold the string, the
2128 * string is truncated. The copied string is %NULL-terminated.
2129 * If the string is being read by the user process, it is copied
2130 * and a newline '\n' is added. It is truncated if the buffer is
2131 * not large enough.
2132 *
2133 * Returns 0 on success.
2134 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002135int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002136 void __user *buffer, size_t *lenp, loff_t *ppos)
2137{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002138 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002139 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002140}
2141
Amerigo Wang00b7c332010-05-05 00:26:45 +00002142static size_t proc_skip_spaces(char **buf)
2143{
2144 size_t ret;
2145 char *tmp = skip_spaces(*buf);
2146 ret = tmp - *buf;
2147 *buf = tmp;
2148 return ret;
2149}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002150
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002151static void proc_skip_char(char **buf, size_t *size, const char v)
2152{
2153 while (*size) {
2154 if (**buf != v)
2155 break;
2156 (*size)--;
2157 (*buf)++;
2158 }
2159}
2160
Amerigo Wang00b7c332010-05-05 00:26:45 +00002161#define TMPBUFLEN 22
2162/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002163 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002164 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002165 * @buf: a kernel buffer
2166 * @size: size of the kernel buffer
2167 * @val: this is where the number will be stored
2168 * @neg: set to %TRUE if number is negative
2169 * @perm_tr: a vector which contains the allowed trailers
2170 * @perm_tr_len: size of the perm_tr vector
2171 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002172 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002173 * In case of success %0 is returned and @buf and @size are updated with
2174 * the amount of bytes read. If @tr is non-NULL and a trailing
2175 * character exists (size is non-zero after returning from this
2176 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002177 */
2178static int proc_get_long(char **buf, size_t *size,
2179 unsigned long *val, bool *neg,
2180 const char *perm_tr, unsigned perm_tr_len, char *tr)
2181{
2182 int len;
2183 char *p, tmp[TMPBUFLEN];
2184
2185 if (!*size)
2186 return -EINVAL;
2187
2188 len = *size;
2189 if (len > TMPBUFLEN - 1)
2190 len = TMPBUFLEN - 1;
2191
2192 memcpy(tmp, *buf, len);
2193
2194 tmp[len] = 0;
2195 p = tmp;
2196 if (*p == '-' && *size > 1) {
2197 *neg = true;
2198 p++;
2199 } else
2200 *neg = false;
2201 if (!isdigit(*p))
2202 return -EINVAL;
2203
2204 *val = simple_strtoul(p, &p, 0);
2205
2206 len = p - tmp;
2207
2208 /* We don't know if the next char is whitespace thus we may accept
2209 * invalid integers (e.g. 1234...a) or two integers instead of one
2210 * (e.g. 123...1). So lets not allow such large numbers. */
2211 if (len == TMPBUFLEN - 1)
2212 return -EINVAL;
2213
2214 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2215 return -EINVAL;
2216
2217 if (tr && (len < *size))
2218 *tr = *p;
2219
2220 *buf += len;
2221 *size -= len;
2222
2223 return 0;
2224}
2225
2226/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002227 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002228 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002229 * @buf: the user buffer
2230 * @size: the size of the user buffer
2231 * @val: the integer to be converted
2232 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002233 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002234 * In case of success %0 is returned and @buf and @size are updated with
2235 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002236 */
2237static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2238 bool neg)
2239{
2240 int len;
2241 char tmp[TMPBUFLEN], *p = tmp;
2242
2243 sprintf(p, "%s%lu", neg ? "-" : "", val);
2244 len = strlen(tmp);
2245 if (len > *size)
2246 len = *size;
2247 if (copy_to_user(*buf, tmp, len))
2248 return -EFAULT;
2249 *size -= len;
2250 *buf += len;
2251 return 0;
2252}
2253#undef TMPBUFLEN
2254
2255static int proc_put_char(void __user **buf, size_t *size, char c)
2256{
2257 if (*size) {
2258 char __user **buffer = (char __user **)buf;
2259 if (put_user(c, *buffer))
2260 return -EFAULT;
2261 (*size)--, (*buffer)++;
2262 *buf = *buffer;
2263 }
2264 return 0;
2265}
2266
2267static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002268 int *valp,
2269 int write, void *data)
2270{
2271 if (write) {
2272 *valp = *negp ? -*lvalp : *lvalp;
2273 } else {
2274 int val = *valp;
2275 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002276 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002277 *lvalp = (unsigned long)-val;
2278 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002279 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002280 *lvalp = (unsigned long)val;
2281 }
2282 }
2283 return 0;
2284}
2285
Amerigo Wang00b7c332010-05-05 00:26:45 +00002286static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2287
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002288static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002289 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002290 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002291 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002292 int write, void *data),
2293 void *data)
2294{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002295 int *i, vleft, first = 1, err = 0;
2296 unsigned long page = 0;
2297 size_t left;
2298 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299
Amerigo Wang00b7c332010-05-05 00:26:45 +00002300 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002301 *lenp = 0;
2302 return 0;
2303 }
2304
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002305 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002306 vleft = table->maxlen / sizeof(*i);
2307 left = *lenp;
2308
2309 if (!conv)
2310 conv = do_proc_dointvec_conv;
2311
Linus Torvalds1da177e2005-04-16 15:20:36 -07002312 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002313 if (left > PAGE_SIZE - 1)
2314 left = PAGE_SIZE - 1;
2315 page = __get_free_page(GFP_TEMPORARY);
2316 kbuf = (char *) page;
2317 if (!kbuf)
2318 return -ENOMEM;
2319 if (copy_from_user(kbuf, buffer, left)) {
2320 err = -EFAULT;
2321 goto free;
2322 }
2323 kbuf[left] = 0;
2324 }
2325
2326 for (; left && vleft--; i++, first=0) {
2327 unsigned long lval;
2328 bool neg;
2329
2330 if (write) {
2331 left -= proc_skip_spaces(&kbuf);
2332
J. R. Okajima563b0462010-05-25 16:10:14 -07002333 if (!left)
2334 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002335 err = proc_get_long(&kbuf, &left, &lval, &neg,
2336 proc_wspace_sep,
2337 sizeof(proc_wspace_sep), NULL);
2338 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002339 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002340 if (conv(&neg, &lval, i, 1, data)) {
2341 err = -EINVAL;
2342 break;
2343 }
2344 } else {
2345 if (conv(&neg, &lval, i, 0, data)) {
2346 err = -EINVAL;
2347 break;
2348 }
2349 if (!first)
2350 err = proc_put_char(&buffer, &left, '\t');
2351 if (err)
2352 break;
2353 err = proc_put_long(&buffer, &left, lval, neg);
2354 if (err)
2355 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356 }
2357 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002358
2359 if (!write && !first && left && !err)
2360 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002361 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002362 left -= proc_skip_spaces(&kbuf);
2363free:
2364 if (write) {
2365 free_page(page);
2366 if (first)
2367 return err ? : -EINVAL;
2368 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369 *lenp -= left;
2370 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002371 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002372}
2373
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002374static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002375 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002376 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002377 int write, void *data),
2378 void *data)
2379{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002380 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002381 buffer, lenp, ppos, conv, data);
2382}
2383
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384/**
2385 * proc_dointvec - read a vector of integers
2386 * @table: the sysctl table
2387 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388 * @buffer: the user buffer
2389 * @lenp: the size of the user buffer
2390 * @ppos: file position
2391 *
2392 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2393 * values from/to the user buffer, treated as an ASCII string.
2394 *
2395 * Returns 0 on success.
2396 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002397int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002398 void __user *buffer, size_t *lenp, loff_t *ppos)
2399{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002400 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 NULL,NULL);
2402}
2403
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002404/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002405 * Taint values can only be increased
2406 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002407 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002408static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002409 void __user *buffer, size_t *lenp, loff_t *ppos)
2410{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002411 struct ctl_table t;
2412 unsigned long tmptaint = get_taint();
2413 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002414
Bastian Blank91fcd412007-04-23 14:41:14 -07002415 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002416 return -EPERM;
2417
Andi Kleen25ddbb12008-10-15 22:01:41 -07002418 t = *table;
2419 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002420 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002421 if (err < 0)
2422 return err;
2423
2424 if (write) {
2425 /*
2426 * Poor man's atomic or. Not worth adding a primitive
2427 * to everyone's atomic.h for this
2428 */
2429 int i;
2430 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2431 if ((tmptaint >> i) & 1)
2432 add_taint(i);
2433 }
2434 }
2435
2436 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002437}
2438
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002439#ifdef CONFIG_PRINTK
2440static int proc_dmesg_restrict(struct ctl_table *table, int write,
2441 void __user *buffer, size_t *lenp, loff_t *ppos)
2442{
2443 if (write && !capable(CAP_SYS_ADMIN))
2444 return -EPERM;
2445
2446 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2447}
2448#endif
2449
Linus Torvalds1da177e2005-04-16 15:20:36 -07002450struct do_proc_dointvec_minmax_conv_param {
2451 int *min;
2452 int *max;
2453};
2454
Amerigo Wang00b7c332010-05-05 00:26:45 +00002455static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2456 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002457 int write, void *data)
2458{
2459 struct do_proc_dointvec_minmax_conv_param *param = data;
2460 if (write) {
2461 int val = *negp ? -*lvalp : *lvalp;
2462 if ((param->min && *param->min > val) ||
2463 (param->max && *param->max < val))
2464 return -EINVAL;
2465 *valp = val;
2466 } else {
2467 int val = *valp;
2468 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002469 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002470 *lvalp = (unsigned long)-val;
2471 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002472 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002473 *lvalp = (unsigned long)val;
2474 }
2475 }
2476 return 0;
2477}
2478
2479/**
2480 * proc_dointvec_minmax - read a vector of integers with min/max values
2481 * @table: the sysctl table
2482 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483 * @buffer: the user buffer
2484 * @lenp: the size of the user buffer
2485 * @ppos: file position
2486 *
2487 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2488 * values from/to the user buffer, treated as an ASCII string.
2489 *
2490 * This routine will ensure the values are within the range specified by
2491 * table->extra1 (min) and table->extra2 (max).
2492 *
2493 * Returns 0 on success.
2494 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002495int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002496 void __user *buffer, size_t *lenp, loff_t *ppos)
2497{
2498 struct do_proc_dointvec_minmax_conv_param param = {
2499 .min = (int *) table->extra1,
2500 .max = (int *) table->extra2,
2501 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002502 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002503 do_proc_dointvec_minmax_conv, &param);
2504}
2505
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002506static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002507 void __user *buffer,
2508 size_t *lenp, loff_t *ppos,
2509 unsigned long convmul,
2510 unsigned long convdiv)
2511{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002512 unsigned long *i, *min, *max;
2513 int vleft, first = 1, err = 0;
2514 unsigned long page = 0;
2515 size_t left;
2516 char *kbuf;
2517
2518 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002519 *lenp = 0;
2520 return 0;
2521 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002522
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002523 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002524 min = (unsigned long *) table->extra1;
2525 max = (unsigned long *) table->extra2;
2526 vleft = table->maxlen / sizeof(unsigned long);
2527 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002528
2529 if (write) {
2530 if (left > PAGE_SIZE - 1)
2531 left = PAGE_SIZE - 1;
2532 page = __get_free_page(GFP_TEMPORARY);
2533 kbuf = (char *) page;
2534 if (!kbuf)
2535 return -ENOMEM;
2536 if (copy_from_user(kbuf, buffer, left)) {
2537 err = -EFAULT;
2538 goto free;
2539 }
2540 kbuf[left] = 0;
2541 }
2542
Eric Dumazet27b3d802010-10-07 12:59:29 -07002543 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002544 unsigned long val;
2545
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002547 bool neg;
2548
2549 left -= proc_skip_spaces(&kbuf);
2550
2551 err = proc_get_long(&kbuf, &left, &val, &neg,
2552 proc_wspace_sep,
2553 sizeof(proc_wspace_sep), NULL);
2554 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002555 break;
2556 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002557 continue;
2558 if ((min && val < *min) || (max && val > *max))
2559 continue;
2560 *i = val;
2561 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002562 val = convdiv * (*i) / convmul;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002563 if (!first)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002564 err = proc_put_char(&buffer, &left, '\t');
2565 err = proc_put_long(&buffer, &left, val, false);
2566 if (err)
2567 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002568 }
2569 }
2570
Amerigo Wang00b7c332010-05-05 00:26:45 +00002571 if (!write && !first && left && !err)
2572 err = proc_put_char(&buffer, &left, '\n');
2573 if (write && !err)
2574 left -= proc_skip_spaces(&kbuf);
2575free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002576 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002577 free_page(page);
2578 if (first)
2579 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002580 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002581 *lenp -= left;
2582 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002583 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002584}
2585
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002586static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002587 void __user *buffer,
2588 size_t *lenp, loff_t *ppos,
2589 unsigned long convmul,
2590 unsigned long convdiv)
2591{
2592 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002593 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002594}
2595
Linus Torvalds1da177e2005-04-16 15:20:36 -07002596/**
2597 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2598 * @table: the sysctl table
2599 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002600 * @buffer: the user buffer
2601 * @lenp: the size of the user buffer
2602 * @ppos: file position
2603 *
2604 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2605 * values from/to the user buffer, treated as an ASCII string.
2606 *
2607 * This routine will ensure the values are within the range specified by
2608 * table->extra1 (min) and table->extra2 (max).
2609 *
2610 * Returns 0 on success.
2611 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002612int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002613 void __user *buffer, size_t *lenp, loff_t *ppos)
2614{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002615 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002616}
2617
2618/**
2619 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2620 * @table: the sysctl table
2621 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002622 * @buffer: the user buffer
2623 * @lenp: the size of the user buffer
2624 * @ppos: file position
2625 *
2626 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2627 * values from/to the user buffer, treated as an ASCII string. The values
2628 * are treated as milliseconds, and converted to jiffies when they are stored.
2629 *
2630 * This routine will ensure the values are within the range specified by
2631 * table->extra1 (min) and table->extra2 (max).
2632 *
2633 * Returns 0 on success.
2634 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002635int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002636 void __user *buffer,
2637 size_t *lenp, loff_t *ppos)
2638{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002639 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640 lenp, ppos, HZ, 1000l);
2641}
2642
2643
Amerigo Wang00b7c332010-05-05 00:26:45 +00002644static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002645 int *valp,
2646 int write, void *data)
2647{
2648 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002649 if (*lvalp > LONG_MAX / HZ)
2650 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002651 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2652 } else {
2653 int val = *valp;
2654 unsigned long lval;
2655 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002656 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002657 lval = (unsigned long)-val;
2658 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002659 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002660 lval = (unsigned long)val;
2661 }
2662 *lvalp = lval / HZ;
2663 }
2664 return 0;
2665}
2666
Amerigo Wang00b7c332010-05-05 00:26:45 +00002667static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002668 int *valp,
2669 int write, void *data)
2670{
2671 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002672 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2673 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002674 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2675 } else {
2676 int val = *valp;
2677 unsigned long lval;
2678 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002679 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002680 lval = (unsigned long)-val;
2681 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002682 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002683 lval = (unsigned long)val;
2684 }
2685 *lvalp = jiffies_to_clock_t(lval);
2686 }
2687 return 0;
2688}
2689
Amerigo Wang00b7c332010-05-05 00:26:45 +00002690static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002691 int *valp,
2692 int write, void *data)
2693{
2694 if (write) {
2695 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2696 } else {
2697 int val = *valp;
2698 unsigned long lval;
2699 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002700 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002701 lval = (unsigned long)-val;
2702 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002703 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002704 lval = (unsigned long)val;
2705 }
2706 *lvalp = jiffies_to_msecs(lval);
2707 }
2708 return 0;
2709}
2710
2711/**
2712 * proc_dointvec_jiffies - read a vector of integers as seconds
2713 * @table: the sysctl table
2714 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002715 * @buffer: the user buffer
2716 * @lenp: the size of the user buffer
2717 * @ppos: file position
2718 *
2719 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2720 * values from/to the user buffer, treated as an ASCII string.
2721 * The values read are assumed to be in seconds, and are converted into
2722 * jiffies.
2723 *
2724 * Returns 0 on success.
2725 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002726int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002727 void __user *buffer, size_t *lenp, loff_t *ppos)
2728{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002729 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002730 do_proc_dointvec_jiffies_conv,NULL);
2731}
2732
2733/**
2734 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2735 * @table: the sysctl table
2736 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002737 * @buffer: the user buffer
2738 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002739 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002740 *
2741 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2742 * values from/to the user buffer, treated as an ASCII string.
2743 * The values read are assumed to be in 1/USER_HZ seconds, and
2744 * are converted into jiffies.
2745 *
2746 * Returns 0 on success.
2747 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002748int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002749 void __user *buffer, size_t *lenp, loff_t *ppos)
2750{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002751 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002752 do_proc_dointvec_userhz_jiffies_conv,NULL);
2753}
2754
2755/**
2756 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2757 * @table: the sysctl table
2758 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002759 * @buffer: the user buffer
2760 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002761 * @ppos: file position
2762 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002763 *
2764 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2765 * values from/to the user buffer, treated as an ASCII string.
2766 * The values read are assumed to be in 1/1000 seconds, and
2767 * are converted into jiffies.
2768 *
2769 * Returns 0 on success.
2770 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002771int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002772 void __user *buffer, size_t *lenp, loff_t *ppos)
2773{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002774 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002775 do_proc_dointvec_ms_jiffies_conv, NULL);
2776}
2777
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002778static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002779 void __user *buffer, size_t *lenp, loff_t *ppos)
2780{
2781 struct pid *new_pid;
2782 pid_t tmp;
2783 int r;
2784
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002785 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002786
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002787 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002788 lenp, ppos, NULL, NULL);
2789 if (r || !write)
2790 return r;
2791
2792 new_pid = find_get_pid(tmp);
2793 if (!new_pid)
2794 return -ESRCH;
2795
2796 put_pid(xchg(&cad_pid, new_pid));
2797 return 0;
2798}
2799
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002800/**
2801 * proc_do_large_bitmap - read/write from/to a large bitmap
2802 * @table: the sysctl table
2803 * @write: %TRUE if this is a write to the sysctl file
2804 * @buffer: the user buffer
2805 * @lenp: the size of the user buffer
2806 * @ppos: file position
2807 *
2808 * The bitmap is stored at table->data and the bitmap length (in bits)
2809 * in table->maxlen.
2810 *
2811 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2812 * large bitmaps may be represented in a compact manner. Writing into
2813 * the file will clear the bitmap then update it with the given input.
2814 *
2815 * Returns 0 on success.
2816 */
2817int proc_do_large_bitmap(struct ctl_table *table, int write,
2818 void __user *buffer, size_t *lenp, loff_t *ppos)
2819{
2820 int err = 0;
2821 bool first = 1;
2822 size_t left = *lenp;
2823 unsigned long bitmap_len = table->maxlen;
2824 unsigned long *bitmap = (unsigned long *) table->data;
2825 unsigned long *tmp_bitmap = NULL;
2826 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2827
2828 if (!bitmap_len || !left || (*ppos && !write)) {
2829 *lenp = 0;
2830 return 0;
2831 }
2832
2833 if (write) {
2834 unsigned long page = 0;
2835 char *kbuf;
2836
2837 if (left > PAGE_SIZE - 1)
2838 left = PAGE_SIZE - 1;
2839
2840 page = __get_free_page(GFP_TEMPORARY);
2841 kbuf = (char *) page;
2842 if (!kbuf)
2843 return -ENOMEM;
2844 if (copy_from_user(kbuf, buffer, left)) {
2845 free_page(page);
2846 return -EFAULT;
2847 }
2848 kbuf[left] = 0;
2849
2850 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2851 GFP_KERNEL);
2852 if (!tmp_bitmap) {
2853 free_page(page);
2854 return -ENOMEM;
2855 }
2856 proc_skip_char(&kbuf, &left, '\n');
2857 while (!err && left) {
2858 unsigned long val_a, val_b;
2859 bool neg;
2860
2861 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2862 sizeof(tr_a), &c);
2863 if (err)
2864 break;
2865 if (val_a >= bitmap_len || neg) {
2866 err = -EINVAL;
2867 break;
2868 }
2869
2870 val_b = val_a;
2871 if (left) {
2872 kbuf++;
2873 left--;
2874 }
2875
2876 if (c == '-') {
2877 err = proc_get_long(&kbuf, &left, &val_b,
2878 &neg, tr_b, sizeof(tr_b),
2879 &c);
2880 if (err)
2881 break;
2882 if (val_b >= bitmap_len || neg ||
2883 val_a > val_b) {
2884 err = -EINVAL;
2885 break;
2886 }
2887 if (left) {
2888 kbuf++;
2889 left--;
2890 }
2891 }
2892
2893 while (val_a <= val_b)
2894 set_bit(val_a++, tmp_bitmap);
2895
2896 first = 0;
2897 proc_skip_char(&kbuf, &left, '\n');
2898 }
2899 free_page(page);
2900 } else {
2901 unsigned long bit_a, bit_b = 0;
2902
2903 while (left) {
2904 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2905 if (bit_a >= bitmap_len)
2906 break;
2907 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2908 bit_a + 1) - 1;
2909
2910 if (!first) {
2911 err = proc_put_char(&buffer, &left, ',');
2912 if (err)
2913 break;
2914 }
2915 err = proc_put_long(&buffer, &left, bit_a, false);
2916 if (err)
2917 break;
2918 if (bit_a != bit_b) {
2919 err = proc_put_char(&buffer, &left, '-');
2920 if (err)
2921 break;
2922 err = proc_put_long(&buffer, &left, bit_b, false);
2923 if (err)
2924 break;
2925 }
2926
2927 first = 0; bit_b++;
2928 }
2929 if (!err)
2930 err = proc_put_char(&buffer, &left, '\n');
2931 }
2932
2933 if (!err) {
2934 if (write) {
2935 if (*ppos)
2936 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2937 else
2938 memcpy(bitmap, tmp_bitmap,
2939 BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long));
2940 }
2941 kfree(tmp_bitmap);
2942 *lenp -= left;
2943 *ppos += *lenp;
2944 return 0;
2945 } else {
2946 kfree(tmp_bitmap);
2947 return err;
2948 }
2949}
2950
Jovi Zhang55610502011-01-12 17:00:45 -08002951#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002952
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002953int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002954 void __user *buffer, size_t *lenp, loff_t *ppos)
2955{
2956 return -ENOSYS;
2957}
2958
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002959int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002960 void __user *buffer, size_t *lenp, loff_t *ppos)
2961{
2962 return -ENOSYS;
2963}
2964
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002965int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002966 void __user *buffer, size_t *lenp, loff_t *ppos)
2967{
2968 return -ENOSYS;
2969}
2970
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002971int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002972 void __user *buffer, size_t *lenp, loff_t *ppos)
2973{
2974 return -ENOSYS;
2975}
2976
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002977int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002978 void __user *buffer, size_t *lenp, loff_t *ppos)
2979{
2980 return -ENOSYS;
2981}
2982
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002983int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002984 void __user *buffer, size_t *lenp, loff_t *ppos)
2985{
2986 return -ENOSYS;
2987}
2988
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002989int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002990 void __user *buffer, size_t *lenp, loff_t *ppos)
2991{
2992 return -ENOSYS;
2993}
2994
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002995int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002996 void __user *buffer,
2997 size_t *lenp, loff_t *ppos)
2998{
2999 return -ENOSYS;
3000}
3001
3002
Jovi Zhang55610502011-01-12 17:00:45 -08003003#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003004
Linus Torvalds1da177e2005-04-16 15:20:36 -07003005/*
3006 * No sense putting this after each symbol definition, twice,
3007 * exception granted :-)
3008 */
3009EXPORT_SYMBOL(proc_dointvec);
3010EXPORT_SYMBOL(proc_dointvec_jiffies);
3011EXPORT_SYMBOL(proc_dointvec_minmax);
3012EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3013EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3014EXPORT_SYMBOL(proc_dostring);
3015EXPORT_SYMBOL(proc_doulongvec_minmax);
3016EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3017EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11003018EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003019EXPORT_SYMBOL(unregister_sysctl_table);