blob: e2ccc89382cbc50cda9a5216cc91abe780dad1d2 [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>
26#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070027#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020029#include <linux/kmemcheck.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070030#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <linux/init.h>
32#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010033#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030034#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <linux/sysrq.h>
36#include <linux/highuid.h>
37#include <linux/writeback.h>
38#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070040#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#include <linux/times.h>
42#include <linux/limits.h>
43#include <linux/dcache.h>
44#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070045#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080046#include <linux/nfs_fs.h>
47#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070048#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020049#include <linux/ftrace.h>
David Howells12e22c52009-04-03 16:42:35 +010050#include <linux/slow-work.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020051#include <linux/perf_event.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53#include <asm/uaccess.h>
54#include <asm/processor.h>
55
Andi Kleen29cbc782006-09-30 01:47:55 +020056#ifdef CONFIG_X86
57#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010058#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010059#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020060#endif
61
Eric W. Biederman7058cb02007-10-18 03:05:58 -070062
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#if defined(CONFIG_SYSCTL)
64
65/* External variables not in a header file. */
66extern int C_A_D;
Ingo Molnar45807a12007-07-15 23:40:10 -070067extern int print_fatal_signals;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068extern int sysctl_overcommit_memory;
69extern int sysctl_overcommit_ratio;
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -070070extern int sysctl_panic_on_oom;
David Rientjesfe071d72007-10-16 23:25:56 -070071extern int sysctl_oom_kill_allocating_task;
David Rientjesfef1bdd2008-02-07 00:14:07 -080072extern int sysctl_oom_dump_tasks;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070075extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -070077extern unsigned int core_pipe_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078extern int pid_max;
79extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -080081extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -080082extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +020083extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +010084extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -040085extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +000086#ifndef CONFIG_MMU
87extern int sysctl_nr_trim_pages;
88#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -070089#ifdef CONFIG_RCU_TORTURE_TEST
90extern int rcutorture_runnable;
91#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
Jens Axboecb684b52009-09-15 21:53:11 +020092#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +020093extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +020094#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070095
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070096/* Constants used for minimum and maximum */
Bron Gondwana195cf4532008-02-04 22:29:20 -080097#ifdef CONFIG_DETECT_SOFTLOCKUP
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070098static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +020099static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700100#endif
101
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700102static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700103static int __maybe_unused one = 1;
104static int __maybe_unused two = 2;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800105static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700106static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700107#ifdef CONFIG_PRINTK
108static int ten_thousand = 10000;
109#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700110
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700111/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
112static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
113
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
115static int maxolduid = 65535;
116static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800117static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
119static int ngroups_max = NGROUPS_MAX;
120
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200121#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122extern char modprobe_path[];
Kees Cook3d433212009-04-02 15:49:29 -0700123extern int modules_disabled;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125#ifdef CONFIG_CHR_DEV_SG
126extern int sg_big_buff;
127#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128
David S. Miller72c57ed2008-09-11 23:29:54 -0700129#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700130#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131#endif
132
David S. Miller08714202008-11-16 23:49:24 -0800133#ifdef CONFIG_SPARC64
134extern int sysctl_tsb_ratio;
135#endif
136
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137#ifdef __hppa__
138extern int pwrsw_enabled;
139extern int unaligned_enabled;
140#endif
141
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800142#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143#ifdef CONFIG_MATHEMU
144extern int sysctl_ieee_emulation_warnings;
145#endif
146extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700147extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148#endif
149
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150#ifdef CONFIG_BSD_PROCESS_ACCT
151extern int acct_parm[];
152#endif
153
Jes Sorensend2b176e2006-02-28 09:42:23 -0800154#ifdef CONFIG_IA64
155extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800156extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800157#endif
158
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700159#ifdef CONFIG_RT_MUTEXES
160extern int max_lock_depth;
161#endif
162
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700163#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700164static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700165 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700166static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800167 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700168#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700169
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700170static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100171static struct ctl_table_root sysctl_table_root;
172static struct ctl_table_header root_table_header = {
Al Virob380b0d2008-09-04 17:05:57 +0100173 .count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100174 .ctl_table = root_table,
Al Viro73455092008-07-14 21:22:20 -0400175 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100176 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400177 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100178};
179static struct ctl_table_root sysctl_table_root = {
180 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400181 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100182};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700184static struct ctl_table kern_table[];
185static struct ctl_table vm_table[];
186static struct ctl_table fs_table[];
187static struct ctl_table debug_table[];
188static struct ctl_table dev_table[];
189extern struct ctl_table random_table[];
Amy Griffis2d9048e2006-06-01 13:10:59 -0700190#ifdef CONFIG_INOTIFY_USER
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700191extern struct ctl_table inotify_table[];
Robert Love0399cb02005-07-13 12:38:18 -0400192#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -0800193#ifdef CONFIG_EPOLL
194extern struct ctl_table epoll_table[];
195#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
197#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
198int sysctl_legacy_va_layout;
199#endif
200
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700201extern int prove_locking;
202extern int lock_stat;
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800203
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204/* The default sysctl tables: */
205
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700206static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 .procname = "kernel",
209 .mode = 0555,
210 .child = kern_table,
211 },
212 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 .procname = "vm",
214 .mode = 0555,
215 .child = vm_table,
216 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 .procname = "fs",
219 .mode = 0555,
220 .child = fs_table,
221 },
222 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 .procname = "debug",
224 .mode = 0555,
225 .child = debug_table,
226 },
227 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 .procname = "dev",
229 .mode = 0555,
230 .child = dev_table,
231 },
Andrew Morton2be7fe02007-07-15 23:41:21 -0700232/*
233 * NOTE: do not add new entries to this table unless you have read
234 * Documentation/sysctl/ctl_unnumbered.txt
235 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700236 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237};
238
Ingo Molnar77e54a12007-07-09 18:52:00 +0200239#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100240static int min_sched_granularity_ns = 100000; /* 100 usecs */
241static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
242static int min_wakeup_granularity_ns; /* 0 usecs */
243static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200244#endif
245
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700246static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200247 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200248 .procname = "sched_child_runs_first",
249 .data = &sysctl_sched_child_runs_first,
250 .maxlen = sizeof(unsigned int),
251 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800252 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200253 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200254#ifdef CONFIG_SCHED_DEBUG
255 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100256 .procname = "sched_min_granularity_ns",
257 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200258 .maxlen = sizeof(unsigned int),
259 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800260 .proc_handler = sched_nr_latency_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100261 .extra1 = &min_sched_granularity_ns,
262 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200263 },
264 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200265 .procname = "sched_latency_ns",
266 .data = &sysctl_sched_latency,
267 .maxlen = sizeof(unsigned int),
268 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800269 .proc_handler = sched_nr_latency_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200270 .extra1 = &min_sched_granularity_ns,
271 .extra2 = &max_sched_granularity_ns,
272 },
273 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200274 .procname = "sched_wakeup_granularity_ns",
275 .data = &sysctl_sched_wakeup_granularity,
276 .maxlen = sizeof(unsigned int),
277 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800278 .proc_handler = proc_dointvec_minmax,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200279 .extra1 = &min_wakeup_granularity_ns,
280 .extra2 = &max_wakeup_granularity_ns,
281 },
282 {
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200283 .procname = "sched_shares_ratelimit",
284 .data = &sysctl_sched_shares_ratelimit,
285 .maxlen = sizeof(unsigned int),
286 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800287 .proc_handler = proc_dointvec,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200288 },
289 {
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200290 .procname = "sched_shares_thresh",
291 .data = &sysctl_sched_shares_thresh,
292 .maxlen = sizeof(unsigned int),
293 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800294 .proc_handler = proc_dointvec_minmax,
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200295 .extra1 = &zero,
296 },
297 {
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200298 .procname = "sched_features",
299 .data = &sysctl_sched_features,
300 .maxlen = sizeof(unsigned int),
301 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800302 .proc_handler = proc_dointvec,
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200303 },
Ingo Molnarda84d962007-10-15 17:00:18 +0200304 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200305 .procname = "sched_migration_cost",
306 .data = &sysctl_sched_migration_cost,
307 .maxlen = sizeof(unsigned int),
308 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800309 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200310 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100311 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100312 .procname = "sched_nr_migrate",
313 .data = &sysctl_sched_nr_migrate,
314 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100315 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800316 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100317 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530318 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200319 .procname = "sched_time_avg",
320 .data = &sysctl_sched_time_avg,
321 .maxlen = sizeof(unsigned int),
322 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800323 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200324 },
325 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530326 .procname = "timer_migration",
327 .data = &sysctl_timer_migration,
328 .maxlen = sizeof(unsigned int),
329 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800330 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530331 .extra1 = &zero,
332 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530333 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200334#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200335 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100336 .procname = "sched_rt_period_us",
337 .data = &sysctl_sched_rt_period,
338 .maxlen = sizeof(unsigned int),
339 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800340 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100341 },
342 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100343 .procname = "sched_rt_runtime_us",
344 .data = &sysctl_sched_rt_runtime,
345 .maxlen = sizeof(int),
346 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800347 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100348 },
349 {
Ingo Molnar1799e352007-09-19 23:34:46 +0200350 .procname = "sched_compat_yield",
351 .data = &sysctl_sched_compat_yield,
352 .maxlen = sizeof(unsigned int),
353 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800354 .proc_handler = proc_dointvec,
Ingo Molnar1799e352007-09-19 23:34:46 +0200355 },
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700356#ifdef CONFIG_PROVE_LOCKING
357 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700358 .procname = "prove_locking",
359 .data = &prove_locking,
360 .maxlen = sizeof(int),
361 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800362 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700363 },
364#endif
365#ifdef CONFIG_LOCK_STAT
366 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700367 .procname = "lock_stat",
368 .data = &lock_stat,
369 .maxlen = sizeof(int),
370 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800371 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700372 },
373#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200374 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 .procname = "panic",
376 .data = &panic_timeout,
377 .maxlen = sizeof(int),
378 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800379 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 },
381 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 .procname = "core_uses_pid",
383 .data = &core_uses_pid,
384 .maxlen = sizeof(int),
385 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800386 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 },
388 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 .procname = "core_pattern",
390 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700391 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800393 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 },
Neil Hormana2939802009-09-23 15:56:56 -0700395 {
Neil Hormana2939802009-09-23 15:56:56 -0700396 .procname = "core_pipe_limit",
397 .data = &core_pipe_limit,
398 .maxlen = sizeof(unsigned int),
399 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800400 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700401 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800402#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700405 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800406 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800407 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800409#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100410#ifdef CONFIG_LATENCYTOP
411 {
412 .procname = "latencytop",
413 .data = &latencytop_enabled,
414 .maxlen = sizeof(int),
415 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800416 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100417 },
418#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419#ifdef CONFIG_BLK_DEV_INITRD
420 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421 .procname = "real-root-dev",
422 .data = &real_root_dev,
423 .maxlen = sizeof(int),
424 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800425 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 },
427#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700428 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700429 .procname = "print-fatal-signals",
430 .data = &print_fatal_signals,
431 .maxlen = sizeof(int),
432 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800433 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700434 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700435#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 .procname = "reboot-cmd",
438 .data = reboot_command,
439 .maxlen = 256,
440 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800441 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 },
443 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 .procname = "stop-a",
445 .data = &stop_a_enabled,
446 .maxlen = sizeof (int),
447 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800448 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 },
450 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 .procname = "scons-poweroff",
452 .data = &scons_pwroff,
453 .maxlen = sizeof (int),
454 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800455 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 },
457#endif
David S. Miller08714202008-11-16 23:49:24 -0800458#ifdef CONFIG_SPARC64
459 {
David S. Miller08714202008-11-16 23:49:24 -0800460 .procname = "tsb-ratio",
461 .data = &sysctl_tsb_ratio,
462 .maxlen = sizeof (int),
463 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800464 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800465 },
466#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467#ifdef __hppa__
468 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 .procname = "soft-power",
470 .data = &pwrsw_enabled,
471 .maxlen = sizeof (int),
472 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800473 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 },
475 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 .procname = "unaligned-trap",
477 .data = &unaligned_enabled,
478 .maxlen = sizeof (int),
479 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800480 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 },
482#endif
483 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 .procname = "ctrl-alt-del",
485 .data = &C_A_D,
486 .maxlen = sizeof(int),
487 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800488 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400490#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200491 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200492 .procname = "ftrace_enabled",
493 .data = &ftrace_enabled,
494 .maxlen = sizeof(int),
495 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800496 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200497 },
498#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500499#ifdef CONFIG_STACK_TRACER
500 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500501 .procname = "stack_tracer_enabled",
502 .data = &stack_tracer_enabled,
503 .maxlen = sizeof(int),
504 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800505 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500506 },
507#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400508#ifdef CONFIG_TRACING
509 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100510 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400511 .data = &ftrace_dump_on_oops,
512 .maxlen = sizeof(int),
513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800514 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400515 },
516#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200517#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 .procname = "modprobe",
520 .data = &modprobe_path,
521 .maxlen = KMOD_PATH_LEN,
522 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800523 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 },
Kees Cook3d433212009-04-02 15:49:29 -0700525 {
Kees Cook3d433212009-04-02 15:49:29 -0700526 .procname = "modules_disabled",
527 .data = &modules_disabled,
528 .maxlen = sizeof(int),
529 .mode = 0644,
530 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800531 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700532 .extra1 = &one,
533 .extra2 = &one,
534 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535#endif
Andrew Morton57ae2502006-06-23 02:05:47 -0700536#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100539 .data = &uevent_helper,
540 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800542 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 },
544#endif
545#ifdef CONFIG_CHR_DEV_SG
546 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 .procname = "sg-big-buff",
548 .data = &sg_big_buff,
549 .maxlen = sizeof (int),
550 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800551 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 },
553#endif
554#ifdef CONFIG_BSD_PROCESS_ACCT
555 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 .procname = "acct",
557 .data = &acct_parm,
558 .maxlen = 3*sizeof(int),
559 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800560 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 },
562#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563#ifdef CONFIG_MAGIC_SYSRQ
564 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800566 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 .maxlen = sizeof (int),
568 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800569 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 },
571#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700572#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700575 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 .maxlen = sizeof (int),
577 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800578 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700580#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 .procname = "threads-max",
583 .data = &max_threads,
584 .maxlen = sizeof(int),
585 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800586 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 },
588 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 .procname = "random",
590 .mode = 0555,
591 .child = random_table,
592 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 .procname = "overflowuid",
595 .data = &overflowuid,
596 .maxlen = sizeof(int),
597 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800598 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 .extra1 = &minolduid,
600 .extra2 = &maxolduid,
601 },
602 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 .procname = "overflowgid",
604 .data = &overflowgid,
605 .maxlen = sizeof(int),
606 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800607 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 .extra1 = &minolduid,
609 .extra2 = &maxolduid,
610 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800611#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612#ifdef CONFIG_MATHEMU
613 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 .procname = "ieee_emulation_warnings",
615 .data = &sysctl_ieee_emulation_warnings,
616 .maxlen = sizeof(int),
617 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800618 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 },
620#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 .procname = "userprocess_debug",
623 .data = &sysctl_userprocess_debug,
624 .maxlen = sizeof(int),
625 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800626 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 },
628#endif
629 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 .procname = "pid_max",
631 .data = &pid_max,
632 .maxlen = sizeof (int),
633 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800634 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 .extra1 = &pid_max_min,
636 .extra2 = &pid_max_max,
637 },
638 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 .procname = "panic_on_oops",
640 .data = &panic_on_oops,
641 .maxlen = sizeof(int),
642 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800643 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800645#if defined CONFIG_PRINTK
646 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800647 .procname = "printk",
648 .data = &console_loglevel,
649 .maxlen = 4*sizeof(int),
650 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800651 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800652 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700655 .data = &printk_ratelimit_state.interval,
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_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 },
660 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700662 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 .maxlen = sizeof(int),
664 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800665 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 },
Dave Youngaf913222009-09-22 16:43:33 -0700667 {
Dave Youngaf913222009-09-22 16:43:33 -0700668 .procname = "printk_delay",
669 .data = &printk_delay_msec,
670 .maxlen = sizeof(int),
671 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800672 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700673 .extra1 = &zero,
674 .extra2 = &ten_thousand,
675 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800676#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 .procname = "ngroups_max",
679 .data = &ngroups_max,
680 .maxlen = sizeof (int),
681 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800682 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 },
684#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
685 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 .procname = "unknown_nmi_panic",
687 .data = &unknown_nmi_panic,
688 .maxlen = sizeof (int),
689 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800690 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 },
Don Zickus407984f2006-09-26 10:52:27 +0200692 {
Don Zickus407984f2006-09-26 10:52:27 +0200693 .procname = "nmi_watchdog",
694 .data = &nmi_watchdog_enabled,
695 .maxlen = sizeof (int),
696 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800697 .proc_handler = proc_nmi_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 },
699#endif
700#if defined(CONFIG_X86)
701 {
Don Zickus8da5add2006-09-26 10:52:27 +0200702 .procname = "panic_on_unrecovered_nmi",
703 .data = &panic_on_unrecovered_nmi,
704 .maxlen = sizeof(int),
705 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800706 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200707 },
708 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700709 .procname = "panic_on_io_nmi",
710 .data = &panic_on_io_nmi,
711 .maxlen = sizeof(int),
712 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800713 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700714 },
715 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 .procname = "bootloader_type",
717 .data = &bootloader_type,
718 .maxlen = sizeof (int),
719 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800720 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100722 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700723 .procname = "bootloader_version",
724 .data = &bootloader_version,
725 .maxlen = sizeof (int),
726 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800727 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700728 },
729 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100730 .procname = "kstack_depth_to_print",
731 .data = &kstack_depth_to_print,
732 .maxlen = sizeof(int),
733 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800734 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100735 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100736 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100737 .procname = "io_delay_type",
738 .data = &io_delay_type,
739 .maxlen = sizeof(int),
740 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800741 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100742 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800744#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 .procname = "randomize_va_space",
747 .data = &randomize_va_space,
748 .maxlen = sizeof(int),
749 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800750 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800752#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800753#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700754 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700755 .procname = "spin_retry",
756 .data = &spin_retry,
757 .maxlen = sizeof (int),
758 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800759 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700760 },
761#endif
Len Brown673d5b42007-07-28 03:33:16 -0400762#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800763 {
Pavel Machekc255d842006-02-20 18:27:58 -0800764 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700765 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800766 .maxlen = sizeof (unsigned long),
767 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800768 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800769 },
770#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800771#ifdef CONFIG_IA64
772 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800773 .procname = "ignore-unaligned-usertrap",
774 .data = &no_unaligned_warning,
775 .maxlen = sizeof (int),
776 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800777 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800778 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800779 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800780 .procname = "unaligned-dump-stack",
781 .data = &unaligned_dump_stack,
782 .maxlen = sizeof (int),
783 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800784 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800785 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800786#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700787#ifdef CONFIG_DETECT_SOFTLOCKUP
788 {
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200789 .procname = "softlockup_panic",
790 .data = &softlockup_panic,
791 .maxlen = sizeof(int),
792 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800793 .proc_handler = proc_dointvec_minmax,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200794 .extra1 = &zero,
795 .extra2 = &one,
796 },
797 {
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700798 .procname = "softlockup_thresh",
799 .data = &softlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200800 .maxlen = sizeof(int),
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700801 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800802 .proc_handler = proc_dosoftlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200803 .extra1 = &neg_one,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700804 .extra2 = &sixty,
805 },
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800806#endif
807#ifdef CONFIG_DETECT_HUNG_TASK
808 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800809 .procname = "hung_task_panic",
810 .data = &sysctl_hung_task_panic,
811 .maxlen = sizeof(int),
812 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800813 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800814 .extra1 = &zero,
815 .extra2 = &one,
816 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100817 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100818 .procname = "hung_task_check_count",
819 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100820 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100821 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800822 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100823 },
824 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100825 .procname = "hung_task_timeout_secs",
826 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100827 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100828 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800829 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100830 },
831 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100832 .procname = "hung_task_warnings",
833 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100834 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100835 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800836 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100837 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700838#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200839#ifdef CONFIG_COMPAT
840 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200841 .procname = "compat-log",
842 .data = &compat_log,
843 .maxlen = sizeof (int),
844 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800845 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200846 },
847#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700848#ifdef CONFIG_RT_MUTEXES
849 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700850 .procname = "max_lock_depth",
851 .data = &max_lock_depth,
852 .maxlen = sizeof(int),
853 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800854 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700855 },
856#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700857 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700858 .procname = "poweroff_cmd",
859 .data = &poweroff_cmd,
860 .maxlen = POWEROFF_CMD_PATH_LEN,
861 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800862 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700863 },
David Howells0b77f5b2008-04-29 01:01:32 -0700864#ifdef CONFIG_KEYS
865 {
David Howells0b77f5b2008-04-29 01:01:32 -0700866 .procname = "keys",
867 .mode = 0555,
868 .child = key_sysctls,
869 },
870#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700871#ifdef CONFIG_RCU_TORTURE_TEST
872 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700873 .procname = "rcutorture_runnable",
874 .data = &rcutorture_runnable,
875 .maxlen = sizeof(int),
876 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800877 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700878 },
879#endif
David Howells12e22c52009-04-03 16:42:35 +0100880#ifdef CONFIG_SLOW_WORK
881 {
David Howells12e22c52009-04-03 16:42:35 +0100882 .procname = "slow-work",
883 .mode = 0555,
884 .child = slow_work_sysctls,
885 },
886#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200887#ifdef CONFIG_PERF_EVENTS
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200888 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200889 .procname = "perf_event_paranoid",
890 .data = &sysctl_perf_event_paranoid,
891 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200892 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800893 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200894 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200895 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200896 .procname = "perf_event_mlock_kb",
897 .data = &sysctl_perf_event_mlock,
898 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200899 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800900 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200901 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200902 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200903 .procname = "perf_event_max_sample_rate",
904 .data = &sysctl_perf_event_sample_rate,
905 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200906 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800907 .proc_handler = proc_dointvec,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200908 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200909#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200910#ifdef CONFIG_KMEMCHECK
911 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200912 .procname = "kmemcheck",
913 .data = &kmemcheck_enabled,
914 .maxlen = sizeof(int),
915 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800916 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +0200917 },
918#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200919#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200920 {
Jens Axboe5e605b62009-08-05 09:07:21 +0200921 .procname = "blk_iopoll",
922 .data = &blk_iopoll_enabled,
923 .maxlen = sizeof(int),
924 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800925 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +0200926 },
Jens Axboecb684b52009-09-15 21:53:11 +0200927#endif
Andrew Mortoned2c12f2007-07-19 01:50:35 -0700928/*
929 * NOTE: do not add new entries to this table unless you have read
930 * Documentation/sysctl/ctl_unnumbered.txt
931 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700932 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933};
934
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700935static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700937 .procname = "overcommit_memory",
938 .data = &sysctl_overcommit_memory,
939 .maxlen = sizeof(sysctl_overcommit_memory),
940 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800941 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942 },
943 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700944 .procname = "panic_on_oom",
945 .data = &sysctl_panic_on_oom,
946 .maxlen = sizeof(sysctl_panic_on_oom),
947 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800948 .proc_handler = proc_dointvec,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700949 },
950 {
David Rientjesfe071d72007-10-16 23:25:56 -0700951 .procname = "oom_kill_allocating_task",
952 .data = &sysctl_oom_kill_allocating_task,
953 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
954 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800955 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -0700956 },
957 {
David Rientjesfef1bdd2008-02-07 00:14:07 -0800958 .procname = "oom_dump_tasks",
959 .data = &sysctl_oom_dump_tasks,
960 .maxlen = sizeof(sysctl_oom_dump_tasks),
961 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800962 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -0800963 },
964 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700965 .procname = "overcommit_ratio",
966 .data = &sysctl_overcommit_ratio,
967 .maxlen = sizeof(sysctl_overcommit_ratio),
968 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800969 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700970 },
971 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700972 .procname = "page-cluster",
973 .data = &page_cluster,
974 .maxlen = sizeof(int),
975 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800976 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977 },
978 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 .procname = "dirty_background_ratio",
980 .data = &dirty_background_ratio,
981 .maxlen = sizeof(dirty_background_ratio),
982 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800983 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984 .extra1 = &zero,
985 .extra2 = &one_hundred,
986 },
987 {
David Rientjes2da02992009-01-06 14:39:31 -0800988 .procname = "dirty_background_bytes",
989 .data = &dirty_background_bytes,
990 .maxlen = sizeof(dirty_background_bytes),
991 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800992 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800993 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -0800994 },
995 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996 .procname = "dirty_ratio",
997 .data = &vm_dirty_ratio,
998 .maxlen = sizeof(vm_dirty_ratio),
999 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001000 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001 .extra1 = &zero,
1002 .extra2 = &one_hundred,
1003 },
1004 {
David Rientjes2da02992009-01-06 14:39:31 -08001005 .procname = "dirty_bytes",
1006 .data = &vm_dirty_bytes,
1007 .maxlen = sizeof(vm_dirty_bytes),
1008 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001009 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001010 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001011 },
1012 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001013 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001014 .data = &dirty_writeback_interval,
1015 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001016 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001017 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018 },
1019 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001020 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001021 .data = &dirty_expire_interval,
1022 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001023 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001024 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001025 },
1026 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027 .procname = "nr_pdflush_threads",
1028 .data = &nr_pdflush_threads,
1029 .maxlen = sizeof nr_pdflush_threads,
1030 .mode = 0444 /* read-only*/,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001031 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001032 },
1033 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034 .procname = "swappiness",
1035 .data = &vm_swappiness,
1036 .maxlen = sizeof(vm_swappiness),
1037 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001038 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001039 .extra1 = &zero,
1040 .extra2 = &one_hundred,
1041 },
1042#ifdef CONFIG_HUGETLB_PAGE
1043 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001044 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001045 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046 .maxlen = sizeof(unsigned long),
1047 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001048 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049 .extra1 = (void *)&hugetlb_zero,
1050 .extra2 = (void *)&hugetlb_infinity,
1051 },
1052 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053 .procname = "hugetlb_shm_group",
1054 .data = &sysctl_hugetlb_shm_group,
1055 .maxlen = sizeof(gid_t),
1056 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001057 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058 },
Mel Gorman396faf02007-07-17 04:03:13 -07001059 {
Mel Gorman396faf02007-07-17 04:03:13 -07001060 .procname = "hugepages_treat_as_movable",
1061 .data = &hugepages_treat_as_movable,
1062 .maxlen = sizeof(int),
1063 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001064 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001065 },
Adam Litke54f9f802007-10-16 01:26:20 -07001066 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001067 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001068 .data = NULL,
1069 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001070 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001071 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001072 .extra1 = (void *)&hugetlb_zero,
1073 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001074 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001075#endif
1076 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001077 .procname = "lowmem_reserve_ratio",
1078 .data = &sysctl_lowmem_reserve_ratio,
1079 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1080 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001081 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082 },
1083 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001084 .procname = "drop_caches",
1085 .data = &sysctl_drop_caches,
1086 .maxlen = sizeof(int),
1087 .mode = 0644,
1088 .proc_handler = drop_caches_sysctl_handler,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001089 },
1090 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091 .procname = "min_free_kbytes",
1092 .data = &min_free_kbytes,
1093 .maxlen = sizeof(min_free_kbytes),
1094 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001095 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001096 .extra1 = &zero,
1097 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001098 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001099 .procname = "percpu_pagelist_fraction",
1100 .data = &percpu_pagelist_fraction,
1101 .maxlen = sizeof(percpu_pagelist_fraction),
1102 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001103 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001104 .extra1 = &min_percpu_pagelist_fract,
1105 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001106#ifdef CONFIG_MMU
1107 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108 .procname = "max_map_count",
1109 .data = &sysctl_max_map_count,
1110 .maxlen = sizeof(sysctl_max_map_count),
1111 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001112 .proc_handler = proc_dointvec
Linus Torvalds1da177e2005-04-16 15:20:36 -07001113 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001114#else
1115 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001116 .procname = "nr_trim_pages",
1117 .data = &sysctl_nr_trim_pages,
1118 .maxlen = sizeof(sysctl_nr_trim_pages),
1119 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001120 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001121 .extra1 = &zero,
1122 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001123#endif
1124 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125 .procname = "laptop_mode",
1126 .data = &laptop_mode,
1127 .maxlen = sizeof(laptop_mode),
1128 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001129 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001130 },
1131 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132 .procname = "block_dump",
1133 .data = &block_dump,
1134 .maxlen = sizeof(block_dump),
1135 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001136 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001137 .extra1 = &zero,
1138 },
1139 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 .procname = "vfs_cache_pressure",
1141 .data = &sysctl_vfs_cache_pressure,
1142 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1143 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001144 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001145 .extra1 = &zero,
1146 },
1147#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1148 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149 .procname = "legacy_va_layout",
1150 .data = &sysctl_legacy_va_layout,
1151 .maxlen = sizeof(sysctl_legacy_va_layout),
1152 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001153 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 .extra1 = &zero,
1155 },
1156#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001157#ifdef CONFIG_NUMA
1158 {
Christoph Lameter17436602006-01-18 17:42:32 -08001159 .procname = "zone_reclaim_mode",
1160 .data = &zone_reclaim_mode,
1161 .maxlen = sizeof(zone_reclaim_mode),
1162 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001163 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001164 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001165 },
Christoph Lameter96146342006-07-03 00:24:13 -07001166 {
Christoph Lameter96146342006-07-03 00:24:13 -07001167 .procname = "min_unmapped_ratio",
1168 .data = &sysctl_min_unmapped_ratio,
1169 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1170 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001171 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001172 .extra1 = &zero,
1173 .extra2 = &one_hundred,
1174 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001175 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001176 .procname = "min_slab_ratio",
1177 .data = &sysctl_min_slab_ratio,
1178 .maxlen = sizeof(sysctl_min_slab_ratio),
1179 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001180 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001181 .extra1 = &zero,
1182 .extra2 = &one_hundred,
1183 },
Christoph Lameter17436602006-01-18 17:42:32 -08001184#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001185#ifdef CONFIG_SMP
1186 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001187 .procname = "stat_interval",
1188 .data = &sysctl_stat_interval,
1189 .maxlen = sizeof(sysctl_stat_interval),
1190 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001191 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001192 },
1193#endif
Eric Parised032182007-06-28 15:55:21 -04001194 {
Eric Parised032182007-06-28 15:55:21 -04001195 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001196 .data = &dac_mmap_min_addr,
1197 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001198 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001199 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001200 },
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001201#ifdef CONFIG_NUMA
1202 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001203 .procname = "numa_zonelist_order",
1204 .data = &numa_zonelist_order,
1205 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1206 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001207 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001208 },
1209#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001210#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001211 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001212 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001213 .procname = "vdso_enabled",
1214 .data = &vdso_enabled,
1215 .maxlen = sizeof(vdso_enabled),
1216 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001217 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001218 .extra1 = &zero,
1219 },
1220#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001221#ifdef CONFIG_HIGHMEM
1222 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001223 .procname = "highmem_is_dirtyable",
1224 .data = &vm_highmem_is_dirtyable,
1225 .maxlen = sizeof(vm_highmem_is_dirtyable),
1226 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001227 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001228 .extra1 = &zero,
1229 .extra2 = &one,
1230 },
1231#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001232 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001233 .procname = "scan_unevictable_pages",
1234 .data = &scan_unevictable_pages,
1235 .maxlen = sizeof(scan_unevictable_pages),
1236 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001237 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001238 },
Andi Kleen6a460792009-09-16 11:50:15 +02001239#ifdef CONFIG_MEMORY_FAILURE
1240 {
Andi Kleen6a460792009-09-16 11:50:15 +02001241 .procname = "memory_failure_early_kill",
1242 .data = &sysctl_memory_failure_early_kill,
1243 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1244 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001245 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001246 .extra1 = &zero,
1247 .extra2 = &one,
1248 },
1249 {
Andi Kleen6a460792009-09-16 11:50:15 +02001250 .procname = "memory_failure_recovery",
1251 .data = &sysctl_memory_failure_recovery,
1252 .maxlen = sizeof(sysctl_memory_failure_recovery),
1253 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001254 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001255 .extra1 = &zero,
1256 .extra2 = &one,
1257 },
1258#endif
1259
Andrew Morton2be7fe02007-07-15 23:41:21 -07001260/*
1261 * NOTE: do not add new entries to this table unless you have read
1262 * Documentation/sysctl/ctl_unnumbered.txt
1263 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001264 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001265};
1266
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001267#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001268static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001269 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001270};
1271#endif
1272
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001273static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001274 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001275 .procname = "inode-nr",
1276 .data = &inodes_stat,
1277 .maxlen = 2*sizeof(int),
1278 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001279 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 },
1281 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001282 .procname = "inode-state",
1283 .data = &inodes_stat,
1284 .maxlen = 7*sizeof(int),
1285 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001286 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001287 },
1288 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001289 .procname = "file-nr",
1290 .data = &files_stat,
1291 .maxlen = 3*sizeof(int),
1292 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001293 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294 },
1295 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001296 .procname = "file-max",
1297 .data = &files_stat.max_files,
1298 .maxlen = sizeof(int),
1299 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001300 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001301 },
1302 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001303 .procname = "nr_open",
1304 .data = &sysctl_nr_open,
1305 .maxlen = sizeof(int),
1306 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001307 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001308 .extra1 = &sysctl_nr_open_min,
1309 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001310 },
1311 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312 .procname = "dentry-state",
1313 .data = &dentry_stat,
1314 .maxlen = 6*sizeof(int),
1315 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001316 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317 },
1318 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001319 .procname = "overflowuid",
1320 .data = &fs_overflowuid,
1321 .maxlen = sizeof(int),
1322 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001323 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001324 .extra1 = &minolduid,
1325 .extra2 = &maxolduid,
1326 },
1327 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001328 .procname = "overflowgid",
1329 .data = &fs_overflowgid,
1330 .maxlen = sizeof(int),
1331 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001332 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001333 .extra1 = &minolduid,
1334 .extra2 = &maxolduid,
1335 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001336#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001338 .procname = "leases-enable",
1339 .data = &leases_enable,
1340 .maxlen = sizeof(int),
1341 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001342 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001343 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001344#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001345#ifdef CONFIG_DNOTIFY
1346 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001347 .procname = "dir-notify-enable",
1348 .data = &dir_notify_enable,
1349 .maxlen = sizeof(int),
1350 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001351 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001352 },
1353#endif
1354#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001355#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001356 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001357 .procname = "lease-break-time",
1358 .data = &lease_break_time,
1359 .maxlen = sizeof(int),
1360 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001361 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001362 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001363#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001364#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001365 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001366 .procname = "aio-nr",
1367 .data = &aio_nr,
1368 .maxlen = sizeof(aio_nr),
1369 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001370 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001371 },
1372 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001373 .procname = "aio-max-nr",
1374 .data = &aio_max_nr,
1375 .maxlen = sizeof(aio_max_nr),
1376 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001377 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001379#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001380#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001381 {
Robert Love0399cb02005-07-13 12:38:18 -04001382 .procname = "inotify",
1383 .mode = 0555,
1384 .child = inotify_table,
1385 },
1386#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001387#ifdef CONFIG_EPOLL
1388 {
1389 .procname = "epoll",
1390 .mode = 0555,
1391 .child = epoll_table,
1392 },
1393#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001394#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001395 {
Alan Coxd6e71142005-06-23 00:09:43 -07001396 .procname = "suid_dumpable",
1397 .data = &suid_dumpable,
1398 .maxlen = sizeof(int),
1399 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001400 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001401 .extra1 = &zero,
1402 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001403 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001404#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1405 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001406 .procname = "binfmt_misc",
1407 .mode = 0555,
1408 .child = binfmt_misc_table,
1409 },
1410#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001411/*
1412 * NOTE: do not add new entries to this table unless you have read
1413 * Documentation/sysctl/ctl_unnumbered.txt
1414 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001415 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001416};
1417
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001418static struct ctl_table debug_table[] = {
Olof Johanssond0c3d532007-10-12 10:20:07 +10001419#if defined(CONFIG_X86) || defined(CONFIG_PPC)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001420 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001421 .procname = "exception-trace",
1422 .data = &show_unhandled_signals,
1423 .maxlen = sizeof(int),
1424 .mode = 0644,
1425 .proc_handler = proc_dointvec
1426 },
1427#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001428 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001429};
1430
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001431static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001432 { }
Robert Love0eeca282005-07-12 17:06:03 -04001433};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001434
Al Viro330d57f2005-11-04 10:18:40 +00001435static DEFINE_SPINLOCK(sysctl_lock);
1436
1437/* called under sysctl_lock */
1438static int use_table(struct ctl_table_header *p)
1439{
1440 if (unlikely(p->unregistering))
1441 return 0;
1442 p->used++;
1443 return 1;
1444}
1445
1446/* called under sysctl_lock */
1447static void unuse_table(struct ctl_table_header *p)
1448{
1449 if (!--p->used)
1450 if (unlikely(p->unregistering))
1451 complete(p->unregistering);
1452}
1453
1454/* called under sysctl_lock, will reacquire if has to wait */
1455static void start_unregistering(struct ctl_table_header *p)
1456{
1457 /*
1458 * if p->used is 0, nobody will ever touch that entry again;
1459 * we'll eliminate all paths to it before dropping sysctl_lock
1460 */
1461 if (unlikely(p->used)) {
1462 struct completion wait;
1463 init_completion(&wait);
1464 p->unregistering = &wait;
1465 spin_unlock(&sysctl_lock);
1466 wait_for_completion(&wait);
1467 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001468 } else {
1469 /* anything non-NULL; we'll never dereference it */
1470 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001471 }
1472 /*
1473 * do not remove from the list until nobody holds it; walking the
1474 * list in do_sysctl() relies on that.
1475 */
1476 list_del_init(&p->ctl_entry);
1477}
1478
Al Virof7e6ced2008-07-15 01:44:23 -04001479void sysctl_head_get(struct ctl_table_header *head)
1480{
1481 spin_lock(&sysctl_lock);
1482 head->count++;
1483 spin_unlock(&sysctl_lock);
1484}
1485
1486void sysctl_head_put(struct ctl_table_header *head)
1487{
1488 spin_lock(&sysctl_lock);
1489 if (!--head->count)
1490 kfree(head);
1491 spin_unlock(&sysctl_lock);
1492}
1493
1494struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1495{
1496 if (!head)
1497 BUG();
1498 spin_lock(&sysctl_lock);
1499 if (!use_table(head))
1500 head = ERR_PTR(-ENOENT);
1501 spin_unlock(&sysctl_lock);
1502 return head;
1503}
1504
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001505void sysctl_head_finish(struct ctl_table_header *head)
1506{
1507 if (!head)
1508 return;
1509 spin_lock(&sysctl_lock);
1510 unuse_table(head);
1511 spin_unlock(&sysctl_lock);
1512}
1513
Al Viro73455092008-07-14 21:22:20 -04001514static struct ctl_table_set *
1515lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1516{
1517 struct ctl_table_set *set = &root->default_set;
1518 if (root->lookup)
1519 set = root->lookup(root, namespaces);
1520 return set;
1521}
1522
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001523static struct list_head *
1524lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001525{
Al Viro73455092008-07-14 21:22:20 -04001526 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1527 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001528}
1529
1530struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1531 struct ctl_table_header *prev)
1532{
1533 struct ctl_table_root *root;
1534 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001535 struct ctl_table_header *head;
1536 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001537
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001538 spin_lock(&sysctl_lock);
1539 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001540 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001541 tmp = &prev->ctl_entry;
1542 unuse_table(prev);
1543 goto next;
1544 }
1545 tmp = &root_table_header.ctl_entry;
1546 for (;;) {
1547 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1548
1549 if (!use_table(head))
1550 goto next;
1551 spin_unlock(&sysctl_lock);
1552 return head;
1553 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001554 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001555 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001556 header_list = lookup_header_list(root, namespaces);
1557 if (tmp != header_list)
1558 continue;
1559
1560 do {
1561 root = list_entry(root->root_list.next,
1562 struct ctl_table_root, root_list);
1563 if (root == &sysctl_table_root)
1564 goto out;
1565 header_list = lookup_header_list(root, namespaces);
1566 } while (list_empty(header_list));
1567 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001568 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001569out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001570 spin_unlock(&sysctl_lock);
1571 return NULL;
1572}
1573
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001574struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1575{
1576 return __sysctl_head_next(current->nsproxy, prev);
1577}
1578
1579void register_sysctl_root(struct ctl_table_root *root)
1580{
1581 spin_lock(&sysctl_lock);
1582 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1583 spin_unlock(&sysctl_lock);
1584}
1585
Linus Torvalds1da177e2005-04-16 15:20:36 -07001586/*
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001587 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001588 * some sysctl variables are readonly even to root.
1589 */
1590
1591static int test_perm(int mode, int op)
1592{
David Howells76aac0e2008-11-14 10:39:12 +11001593 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001594 mode >>= 6;
1595 else if (in_egroup_p(0))
1596 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001597 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001598 return 0;
1599 return -EACCES;
1600}
1601
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001602int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001603{
1604 int error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001605 int mode;
1606
Al Viroe6305c42008-07-15 21:03:57 -04001607 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001608 if (error)
1609 return error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001610
1611 if (root->permissions)
1612 mode = root->permissions(root, current->nsproxy, table);
1613 else
1614 mode = table->mode;
1615
1616 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001617}
1618
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001619static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1620{
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001621 for (; table->procname; table++) {
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001622 table->parent = parent;
1623 if (table->child)
1624 sysctl_set_parent(table, table->child);
1625 }
1626}
1627
1628static __init int sysctl_init(void)
1629{
1630 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001631#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1632 {
1633 int err;
1634 err = sysctl_check_table(current->nsproxy, root_table);
1635 }
1636#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001637 return 0;
1638}
1639
1640core_initcall(sysctl_init);
1641
Al Virobfbcf032008-07-27 06:31:22 +01001642static struct ctl_table *is_branch_in(struct ctl_table *branch,
1643 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001644{
1645 struct ctl_table *p;
1646 const char *s = branch->procname;
1647
1648 /* branch should have named subdirectory as its first element */
1649 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001650 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001651
1652 /* ... and nothing else */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001653 if (branch[1].procname)
Al Virobfbcf032008-07-27 06:31:22 +01001654 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001655
1656 /* table should contain subdirectory with the same name */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001657 for (p = table; p->procname; p++) {
Al Viroae7edec2008-07-15 06:33:31 -04001658 if (!p->child)
1659 continue;
1660 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001661 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001662 }
Al Virobfbcf032008-07-27 06:31:22 +01001663 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001664}
1665
1666/* see if attaching q to p would be an improvement */
1667static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1668{
1669 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001670 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001671 int is_better = 0;
1672 int not_in_parent = !p->attached_by;
1673
Al Virobfbcf032008-07-27 06:31:22 +01001674 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001675 if (by == q->attached_by)
1676 is_better = 1;
1677 if (to == p->attached_by)
1678 not_in_parent = 1;
1679 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001680 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001681 }
1682
1683 if (is_better && not_in_parent) {
1684 q->attached_by = by;
1685 q->attached_to = to;
1686 q->parent = p;
1687 }
1688}
1689
Linus Torvalds1da177e2005-04-16 15:20:36 -07001690/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001691 * __register_sysctl_paths - register a sysctl hierarchy
1692 * @root: List of sysctl headers to register on
1693 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001694 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001695 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696 *
1697 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001698 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001699 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001700 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001701 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001702 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1703 * enter a sysctl file
1704 *
1705 * data - a pointer to data for use by proc_handler
1706 *
1707 * maxlen - the maximum size in bytes of the data
1708 *
1709 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1710 *
1711 * child - a pointer to the child sysctl table if this entry is a directory, or
1712 * %NULL.
1713 *
1714 * proc_handler - the text handler routine (described below)
1715 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001716 * de - for internal use by the sysctl routines
1717 *
1718 * extra1, extra2 - extra pointers usable by the proc handler routines
1719 *
1720 * Leaf nodes in the sysctl tree will be represented by a single file
1721 * under /proc; non-leaf nodes will be represented by directories.
1722 *
1723 * sysctl(2) can automatically manage read and write requests through
1724 * the sysctl table. The data and maxlen fields of the ctl_table
1725 * struct enable minimal validation of the values being written to be
1726 * performed, and the mode field allows minimal authentication.
1727 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001728 * There must be a proc_handler routine for any terminal nodes
1729 * mirrored under /proc/sys (non-terminals are handled by a built-in
1730 * directory handler). Several default handlers are available to
1731 * cover common cases -
1732 *
1733 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1734 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1735 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1736 *
1737 * It is the handler's job to read the input buffer from user memory
1738 * and process it. The handler should return 0 on success.
1739 *
1740 * This routine returns %NULL on a failure to register, and a pointer
1741 * to the table header on success.
1742 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001743struct ctl_table_header *__register_sysctl_paths(
1744 struct ctl_table_root *root,
1745 struct nsproxy *namespaces,
1746 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001747{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001748 struct ctl_table_header *header;
1749 struct ctl_table *new, **prevp;
1750 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001751 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001752
1753 /* Count the path components */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001754 for (npath = 0; path[npath].procname; ++npath)
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001755 ;
1756
1757 /*
1758 * For each path component, allocate a 2-element ctl_table array.
1759 * The first array element will be filled with the sysctl entry
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001760 * for this, the second will be the sentinel (procname == 0).
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001761 *
1762 * We allocate everything in one go so that we don't have to
1763 * worry about freeing additional memory in unregister_sysctl_table.
1764 */
1765 header = kzalloc(sizeof(struct ctl_table_header) +
1766 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1767 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001768 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001769
1770 new = (struct ctl_table *) (header + 1);
1771
1772 /* Now connect the dots */
1773 prevp = &header->ctl_table;
1774 for (n = 0; n < npath; ++n, ++path) {
1775 /* Copy the procname */
1776 new->procname = path->procname;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001777 new->mode = 0555;
1778
1779 *prevp = new;
1780 prevp = &new->child;
1781
1782 new += 2;
1783 }
1784 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001785 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001786
1787 INIT_LIST_HEAD(&header->ctl_entry);
1788 header->used = 0;
1789 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001790 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001791 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001792 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001793#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001794 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001795 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001796 return NULL;
1797 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001798#endif
Al Viro330d57f2005-11-04 10:18:40 +00001799 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001800 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001801 header->attached_by = header->ctl_table;
1802 header->attached_to = root_table;
1803 header->parent = &root_table_header;
1804 for (set = header->set; set; set = set->parent) {
1805 struct ctl_table_header *p;
1806 list_for_each_entry(p, &set->list, ctl_entry) {
1807 if (p->unregistering)
1808 continue;
1809 try_attach(p, header);
1810 }
1811 }
1812 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001813 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001814 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001815
1816 return header;
1817}
1818
1819/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001820 * register_sysctl_table_path - register a sysctl table hierarchy
1821 * @path: The path to the directory the sysctl table is in.
1822 * @table: the top-level table structure
1823 *
1824 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1825 * array. A completely 0 filled entry terminates the table.
1826 *
1827 * See __register_sysctl_paths for more details.
1828 */
1829struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1830 struct ctl_table *table)
1831{
1832 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1833 path, table);
1834}
1835
1836/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001837 * register_sysctl_table - register a sysctl table hierarchy
1838 * @table: the top-level table structure
1839 *
1840 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1841 * array. A completely 0 filled entry terminates the table.
1842 *
1843 * See register_sysctl_paths for more details.
1844 */
1845struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1846{
1847 static const struct ctl_path null_path[] = { {} };
1848
1849 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001850}
1851
1852/**
1853 * unregister_sysctl_table - unregister a sysctl table hierarchy
1854 * @header: the header returned from register_sysctl_table
1855 *
1856 * Unregisters the sysctl table and all children. proc entries may not
1857 * actually be removed until they are no longer used by anyone.
1858 */
1859void unregister_sysctl_table(struct ctl_table_header * header)
1860{
Al Viro330d57f2005-11-04 10:18:40 +00001861 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08001862
1863 if (header == NULL)
1864 return;
1865
Al Viro330d57f2005-11-04 10:18:40 +00001866 spin_lock(&sysctl_lock);
1867 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04001868 if (!--header->parent->count) {
1869 WARN_ON(1);
1870 kfree(header->parent);
1871 }
Al Virof7e6ced2008-07-15 01:44:23 -04001872 if (!--header->count)
1873 kfree(header);
Al Viro330d57f2005-11-04 10:18:40 +00001874 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001875}
1876
Al Viro9043476f2008-07-15 08:54:06 -04001877int sysctl_is_seen(struct ctl_table_header *p)
1878{
1879 struct ctl_table_set *set = p->set;
1880 int res;
1881 spin_lock(&sysctl_lock);
1882 if (p->unregistering)
1883 res = 0;
1884 else if (!set->is_seen)
1885 res = 1;
1886 else
1887 res = set->is_seen(set);
1888 spin_unlock(&sysctl_lock);
1889 return res;
1890}
1891
Al Viro73455092008-07-14 21:22:20 -04001892void setup_sysctl_set(struct ctl_table_set *p,
1893 struct ctl_table_set *parent,
1894 int (*is_seen)(struct ctl_table_set *))
1895{
1896 INIT_LIST_HEAD(&p->list);
1897 p->parent = parent ? parent : &sysctl_table_root.default_set;
1898 p->is_seen = is_seen;
1899}
1900
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001901#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001902struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001903{
1904 return NULL;
1905}
1906
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001907struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1908 struct ctl_table *table)
1909{
1910 return NULL;
1911}
1912
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001913void unregister_sysctl_table(struct ctl_table_header * table)
1914{
1915}
1916
Al Viro73455092008-07-14 21:22:20 -04001917void setup_sysctl_set(struct ctl_table_set *p,
1918 struct ctl_table_set *parent,
1919 int (*is_seen)(struct ctl_table_set *))
1920{
1921}
1922
Al Virof7e6ced2008-07-15 01:44:23 -04001923void sysctl_head_put(struct ctl_table_header *head)
1924{
1925}
1926
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001927#endif /* CONFIG_SYSCTL */
1928
Linus Torvalds1da177e2005-04-16 15:20:36 -07001929/*
1930 * /proc/sys support
1931 */
1932
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001933#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001934
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001935static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001936 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001937 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001938{
1939 size_t len;
1940 char __user *p;
1941 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001942
1943 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001944 *lenp = 0;
1945 return 0;
1946 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001947
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001948 if (write) {
1949 len = 0;
1950 p = buffer;
1951 while (len < *lenp) {
1952 if (get_user(c, p++))
1953 return -EFAULT;
1954 if (c == 0 || c == '\n')
1955 break;
1956 len++;
1957 }
1958 if (len >= maxlen)
1959 len = maxlen-1;
1960 if(copy_from_user(data, buffer, len))
1961 return -EFAULT;
1962 ((char *) data)[len] = 0;
1963 *ppos += *lenp;
1964 } else {
1965 len = strlen(data);
1966 if (len > maxlen)
1967 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001968
1969 if (*ppos > len) {
1970 *lenp = 0;
1971 return 0;
1972 }
1973
1974 data += *ppos;
1975 len -= *ppos;
1976
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001977 if (len > *lenp)
1978 len = *lenp;
1979 if (len)
1980 if(copy_to_user(buffer, data, len))
1981 return -EFAULT;
1982 if (len < *lenp) {
1983 if(put_user('\n', ((char __user *) buffer) + len))
1984 return -EFAULT;
1985 len++;
1986 }
1987 *lenp = len;
1988 *ppos += len;
1989 }
1990 return 0;
1991}
1992
Linus Torvalds1da177e2005-04-16 15:20:36 -07001993/**
1994 * proc_dostring - read a string sysctl
1995 * @table: the sysctl table
1996 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001997 * @buffer: the user buffer
1998 * @lenp: the size of the user buffer
1999 * @ppos: file position
2000 *
2001 * Reads/writes a string from/to the user buffer. If the kernel
2002 * buffer provided is not large enough to hold the string, the
2003 * string is truncated. The copied string is %NULL-terminated.
2004 * If the string is being read by the user process, it is copied
2005 * and a newline '\n' is added. It is truncated if the buffer is
2006 * not large enough.
2007 *
2008 * Returns 0 on success.
2009 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002010int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002011 void __user *buffer, size_t *lenp, loff_t *ppos)
2012{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002013 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002014 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002015}
2016
Linus Torvalds1da177e2005-04-16 15:20:36 -07002017
2018static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2019 int *valp,
2020 int write, void *data)
2021{
2022 if (write) {
2023 *valp = *negp ? -*lvalp : *lvalp;
2024 } else {
2025 int val = *valp;
2026 if (val < 0) {
2027 *negp = -1;
2028 *lvalp = (unsigned long)-val;
2029 } else {
2030 *negp = 0;
2031 *lvalp = (unsigned long)val;
2032 }
2033 }
2034 return 0;
2035}
2036
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002037static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002038 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002039 size_t *lenp, loff_t *ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002040 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2041 int write, void *data),
2042 void *data)
2043{
2044#define TMPBUFLEN 21
Sukanto Ghosh7338f292009-06-17 16:27:50 -07002045 int *i, vleft, first = 1, neg;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002046 unsigned long lval;
2047 size_t left, len;
2048
2049 char buf[TMPBUFLEN], *p;
2050 char __user *s = buffer;
2051
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002052 if (!tbl_data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002053 (*ppos && !write)) {
2054 *lenp = 0;
2055 return 0;
2056 }
2057
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002058 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002059 vleft = table->maxlen / sizeof(*i);
2060 left = *lenp;
2061
2062 if (!conv)
2063 conv = do_proc_dointvec_conv;
2064
2065 for (; left && vleft--; i++, first=0) {
2066 if (write) {
2067 while (left) {
2068 char c;
2069 if (get_user(c, s))
2070 return -EFAULT;
2071 if (!isspace(c))
2072 break;
2073 left--;
2074 s++;
2075 }
2076 if (!left)
2077 break;
2078 neg = 0;
2079 len = left;
2080 if (len > sizeof(buf) - 1)
2081 len = sizeof(buf) - 1;
2082 if (copy_from_user(buf, s, len))
2083 return -EFAULT;
2084 buf[len] = 0;
2085 p = buf;
2086 if (*p == '-' && left > 1) {
2087 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002088 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002089 }
2090 if (*p < '0' || *p > '9')
2091 break;
2092
2093 lval = simple_strtoul(p, &p, 0);
2094
2095 len = p-buf;
2096 if ((len < left) && *p && !isspace(*p))
2097 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002098 s += len;
2099 left -= len;
2100
2101 if (conv(&neg, &lval, i, 1, data))
2102 break;
2103 } else {
2104 p = buf;
2105 if (!first)
2106 *p++ = '\t';
2107
2108 if (conv(&neg, &lval, i, 0, data))
2109 break;
2110
2111 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2112 len = strlen(buf);
2113 if (len > left)
2114 len = left;
2115 if(copy_to_user(s, buf, len))
2116 return -EFAULT;
2117 left -= len;
2118 s += len;
2119 }
2120 }
2121
2122 if (!write && !first && left) {
2123 if(put_user('\n', s))
2124 return -EFAULT;
2125 left--, s++;
2126 }
2127 if (write) {
2128 while (left) {
2129 char c;
2130 if (get_user(c, s++))
2131 return -EFAULT;
2132 if (!isspace(c))
2133 break;
2134 left--;
2135 }
2136 }
2137 if (write && first)
2138 return -EINVAL;
2139 *lenp -= left;
2140 *ppos += *lenp;
2141 return 0;
2142#undef TMPBUFLEN
2143}
2144
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002145static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002146 void __user *buffer, size_t *lenp, loff_t *ppos,
2147 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2148 int write, void *data),
2149 void *data)
2150{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002151 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002152 buffer, lenp, ppos, conv, data);
2153}
2154
Linus Torvalds1da177e2005-04-16 15:20:36 -07002155/**
2156 * proc_dointvec - read a vector of integers
2157 * @table: the sysctl table
2158 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002159 * @buffer: the user buffer
2160 * @lenp: the size of the user buffer
2161 * @ppos: file position
2162 *
2163 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2164 * values from/to the user buffer, treated as an ASCII string.
2165 *
2166 * Returns 0 on success.
2167 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002168int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002169 void __user *buffer, size_t *lenp, loff_t *ppos)
2170{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002171 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002172 NULL,NULL);
2173}
2174
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002175/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002176 * Taint values can only be increased
2177 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002178 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002179static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002180 void __user *buffer, size_t *lenp, loff_t *ppos)
2181{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002182 struct ctl_table t;
2183 unsigned long tmptaint = get_taint();
2184 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002185
Bastian Blank91fcd412007-04-23 14:41:14 -07002186 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002187 return -EPERM;
2188
Andi Kleen25ddbb12008-10-15 22:01:41 -07002189 t = *table;
2190 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002191 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002192 if (err < 0)
2193 return err;
2194
2195 if (write) {
2196 /*
2197 * Poor man's atomic or. Not worth adding a primitive
2198 * to everyone's atomic.h for this
2199 */
2200 int i;
2201 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2202 if ((tmptaint >> i) & 1)
2203 add_taint(i);
2204 }
2205 }
2206
2207 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002208}
2209
Linus Torvalds1da177e2005-04-16 15:20:36 -07002210struct do_proc_dointvec_minmax_conv_param {
2211 int *min;
2212 int *max;
2213};
2214
2215static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2216 int *valp,
2217 int write, void *data)
2218{
2219 struct do_proc_dointvec_minmax_conv_param *param = data;
2220 if (write) {
2221 int val = *negp ? -*lvalp : *lvalp;
2222 if ((param->min && *param->min > val) ||
2223 (param->max && *param->max < val))
2224 return -EINVAL;
2225 *valp = val;
2226 } else {
2227 int val = *valp;
2228 if (val < 0) {
2229 *negp = -1;
2230 *lvalp = (unsigned long)-val;
2231 } else {
2232 *negp = 0;
2233 *lvalp = (unsigned long)val;
2234 }
2235 }
2236 return 0;
2237}
2238
2239/**
2240 * proc_dointvec_minmax - read a vector of integers with min/max values
2241 * @table: the sysctl table
2242 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002243 * @buffer: the user buffer
2244 * @lenp: the size of the user buffer
2245 * @ppos: file position
2246 *
2247 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2248 * values from/to the user buffer, treated as an ASCII string.
2249 *
2250 * This routine will ensure the values are within the range specified by
2251 * table->extra1 (min) and table->extra2 (max).
2252 *
2253 * Returns 0 on success.
2254 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002255int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002256 void __user *buffer, size_t *lenp, loff_t *ppos)
2257{
2258 struct do_proc_dointvec_minmax_conv_param param = {
2259 .min = (int *) table->extra1,
2260 .max = (int *) table->extra2,
2261 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002262 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002263 do_proc_dointvec_minmax_conv, &param);
2264}
2265
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002266static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002267 void __user *buffer,
2268 size_t *lenp, loff_t *ppos,
2269 unsigned long convmul,
2270 unsigned long convdiv)
2271{
2272#define TMPBUFLEN 21
2273 unsigned long *i, *min, *max, val;
2274 int vleft, first=1, neg;
2275 size_t len, left;
2276 char buf[TMPBUFLEN], *p;
2277 char __user *s = buffer;
2278
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002279 if (!data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002280 (*ppos && !write)) {
2281 *lenp = 0;
2282 return 0;
2283 }
2284
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002285 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002286 min = (unsigned long *) table->extra1;
2287 max = (unsigned long *) table->extra2;
2288 vleft = table->maxlen / sizeof(unsigned long);
2289 left = *lenp;
2290
2291 for (; left && vleft--; i++, min++, max++, first=0) {
2292 if (write) {
2293 while (left) {
2294 char c;
2295 if (get_user(c, s))
2296 return -EFAULT;
2297 if (!isspace(c))
2298 break;
2299 left--;
2300 s++;
2301 }
2302 if (!left)
2303 break;
2304 neg = 0;
2305 len = left;
2306 if (len > TMPBUFLEN-1)
2307 len = TMPBUFLEN-1;
2308 if (copy_from_user(buf, s, len))
2309 return -EFAULT;
2310 buf[len] = 0;
2311 p = buf;
2312 if (*p == '-' && left > 1) {
2313 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002314 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002315 }
2316 if (*p < '0' || *p > '9')
2317 break;
2318 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2319 len = p-buf;
2320 if ((len < left) && *p && !isspace(*p))
2321 break;
2322 if (neg)
2323 val = -val;
2324 s += len;
2325 left -= len;
2326
2327 if(neg)
2328 continue;
2329 if ((min && val < *min) || (max && val > *max))
2330 continue;
2331 *i = val;
2332 } else {
2333 p = buf;
2334 if (!first)
2335 *p++ = '\t';
2336 sprintf(p, "%lu", convdiv * (*i) / convmul);
2337 len = strlen(buf);
2338 if (len > left)
2339 len = left;
2340 if(copy_to_user(s, buf, len))
2341 return -EFAULT;
2342 left -= len;
2343 s += len;
2344 }
2345 }
2346
2347 if (!write && !first && left) {
2348 if(put_user('\n', s))
2349 return -EFAULT;
2350 left--, s++;
2351 }
2352 if (write) {
2353 while (left) {
2354 char c;
2355 if (get_user(c, s++))
2356 return -EFAULT;
2357 if (!isspace(c))
2358 break;
2359 left--;
2360 }
2361 }
2362 if (write && first)
2363 return -EINVAL;
2364 *lenp -= left;
2365 *ppos += *lenp;
2366 return 0;
2367#undef TMPBUFLEN
2368}
2369
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002370static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002371 void __user *buffer,
2372 size_t *lenp, loff_t *ppos,
2373 unsigned long convmul,
2374 unsigned long convdiv)
2375{
2376 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002377 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002378}
2379
Linus Torvalds1da177e2005-04-16 15:20:36 -07002380/**
2381 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2382 * @table: the sysctl table
2383 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384 * @buffer: the user buffer
2385 * @lenp: the size of the user buffer
2386 * @ppos: file position
2387 *
2388 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2389 * values from/to the user buffer, treated as an ASCII string.
2390 *
2391 * This routine will ensure the values are within the range specified by
2392 * table->extra1 (min) and table->extra2 (max).
2393 *
2394 * Returns 0 on success.
2395 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002396int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002397 void __user *buffer, size_t *lenp, loff_t *ppos)
2398{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002399 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002400}
2401
2402/**
2403 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2404 * @table: the sysctl table
2405 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002406 * @buffer: the user buffer
2407 * @lenp: the size of the user buffer
2408 * @ppos: file position
2409 *
2410 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2411 * values from/to the user buffer, treated as an ASCII string. The values
2412 * are treated as milliseconds, and converted to jiffies when they are stored.
2413 *
2414 * This routine will ensure the values are within the range specified by
2415 * table->extra1 (min) and table->extra2 (max).
2416 *
2417 * Returns 0 on success.
2418 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002419int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002420 void __user *buffer,
2421 size_t *lenp, loff_t *ppos)
2422{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002423 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002424 lenp, ppos, HZ, 1000l);
2425}
2426
2427
2428static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2429 int *valp,
2430 int write, void *data)
2431{
2432 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002433 if (*lvalp > LONG_MAX / HZ)
2434 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002435 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2436 } else {
2437 int val = *valp;
2438 unsigned long lval;
2439 if (val < 0) {
2440 *negp = -1;
2441 lval = (unsigned long)-val;
2442 } else {
2443 *negp = 0;
2444 lval = (unsigned long)val;
2445 }
2446 *lvalp = lval / HZ;
2447 }
2448 return 0;
2449}
2450
2451static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2452 int *valp,
2453 int write, void *data)
2454{
2455 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002456 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2457 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002458 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2459 } else {
2460 int val = *valp;
2461 unsigned long lval;
2462 if (val < 0) {
2463 *negp = -1;
2464 lval = (unsigned long)-val;
2465 } else {
2466 *negp = 0;
2467 lval = (unsigned long)val;
2468 }
2469 *lvalp = jiffies_to_clock_t(lval);
2470 }
2471 return 0;
2472}
2473
2474static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2475 int *valp,
2476 int write, void *data)
2477{
2478 if (write) {
2479 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2480 } else {
2481 int val = *valp;
2482 unsigned long lval;
2483 if (val < 0) {
2484 *negp = -1;
2485 lval = (unsigned long)-val;
2486 } else {
2487 *negp = 0;
2488 lval = (unsigned long)val;
2489 }
2490 *lvalp = jiffies_to_msecs(lval);
2491 }
2492 return 0;
2493}
2494
2495/**
2496 * proc_dointvec_jiffies - read a vector of integers as seconds
2497 * @table: the sysctl table
2498 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002499 * @buffer: the user buffer
2500 * @lenp: the size of the user buffer
2501 * @ppos: file position
2502 *
2503 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2504 * values from/to the user buffer, treated as an ASCII string.
2505 * The values read are assumed to be in seconds, and are converted into
2506 * jiffies.
2507 *
2508 * Returns 0 on success.
2509 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002510int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002511 void __user *buffer, size_t *lenp, loff_t *ppos)
2512{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002513 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514 do_proc_dointvec_jiffies_conv,NULL);
2515}
2516
2517/**
2518 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2519 * @table: the sysctl table
2520 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002521 * @buffer: the user buffer
2522 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002523 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002524 *
2525 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2526 * values from/to the user buffer, treated as an ASCII string.
2527 * The values read are assumed to be in 1/USER_HZ seconds, and
2528 * are converted into jiffies.
2529 *
2530 * Returns 0 on success.
2531 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002532int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002533 void __user *buffer, size_t *lenp, loff_t *ppos)
2534{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002535 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002536 do_proc_dointvec_userhz_jiffies_conv,NULL);
2537}
2538
2539/**
2540 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2541 * @table: the sysctl table
2542 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002543 * @buffer: the user buffer
2544 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002545 * @ppos: file position
2546 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002547 *
2548 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2549 * values from/to the user buffer, treated as an ASCII string.
2550 * The values read are assumed to be in 1/1000 seconds, and
2551 * are converted into jiffies.
2552 *
2553 * Returns 0 on success.
2554 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002555int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002556 void __user *buffer, size_t *lenp, loff_t *ppos)
2557{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002558 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002559 do_proc_dointvec_ms_jiffies_conv, NULL);
2560}
2561
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002562static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002563 void __user *buffer, size_t *lenp, loff_t *ppos)
2564{
2565 struct pid *new_pid;
2566 pid_t tmp;
2567 int r;
2568
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002569 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002570
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002571 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002572 lenp, ppos, NULL, NULL);
2573 if (r || !write)
2574 return r;
2575
2576 new_pid = find_get_pid(tmp);
2577 if (!new_pid)
2578 return -ESRCH;
2579
2580 put_pid(xchg(&cad_pid, new_pid));
2581 return 0;
2582}
2583
Linus Torvalds1da177e2005-04-16 15:20:36 -07002584#else /* CONFIG_PROC_FS */
2585
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002586int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002587 void __user *buffer, size_t *lenp, loff_t *ppos)
2588{
2589 return -ENOSYS;
2590}
2591
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002592int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593 void __user *buffer, size_t *lenp, loff_t *ppos)
2594{
2595 return -ENOSYS;
2596}
2597
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002598int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002599 void __user *buffer, size_t *lenp, loff_t *ppos)
2600{
2601 return -ENOSYS;
2602}
2603
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002604int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002605 void __user *buffer, size_t *lenp, loff_t *ppos)
2606{
2607 return -ENOSYS;
2608}
2609
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002610int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002611 void __user *buffer, size_t *lenp, loff_t *ppos)
2612{
2613 return -ENOSYS;
2614}
2615
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002616int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002617 void __user *buffer, size_t *lenp, loff_t *ppos)
2618{
2619 return -ENOSYS;
2620}
2621
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002622int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002623 void __user *buffer, size_t *lenp, loff_t *ppos)
2624{
2625 return -ENOSYS;
2626}
2627
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002628int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629 void __user *buffer,
2630 size_t *lenp, loff_t *ppos)
2631{
2632 return -ENOSYS;
2633}
2634
2635
2636#endif /* CONFIG_PROC_FS */
2637
Linus Torvalds1da177e2005-04-16 15:20:36 -07002638/*
2639 * No sense putting this after each symbol definition, twice,
2640 * exception granted :-)
2641 */
2642EXPORT_SYMBOL(proc_dointvec);
2643EXPORT_SYMBOL(proc_dointvec_jiffies);
2644EXPORT_SYMBOL(proc_dointvec_minmax);
2645EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2646EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2647EXPORT_SYMBOL(proc_dostring);
2648EXPORT_SYMBOL(proc_doulongvec_minmax);
2649EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2650EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002651EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652EXPORT_SYMBOL(unregister_sysctl_table);