blob: ac72c9e6bd9b153b03b5ec55773a6ce16aeaf492 [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>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020038#include <linux/ratelimit.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070041#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#include <linux/times.h>
43#include <linux/limits.h>
44#include <linux/dcache.h>
45#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070046#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080047#include <linux/nfs_fs.h>
48#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070049#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020050#include <linux/ftrace.h>
David Howells12e22c52009-04-03 16:42:35 +010051#include <linux/slow-work.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020052#include <linux/perf_event.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
54#include <asm/uaccess.h>
55#include <asm/processor.h>
56
Andi Kleen29cbc782006-09-30 01:47:55 +020057#ifdef CONFIG_X86
58#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010059#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010060#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020061#endif
62
Don Zickus504d7cf2010-02-12 17:19:19 -050063#ifdef CONFIG_NMI_WATCHDOG
64#include <linux/nmi.h>
65#endif
66
Eric W. Biederman7058cb02007-10-18 03:05:58 -070067
Linus Torvalds1da177e2005-04-16 15:20:36 -070068#if defined(CONFIG_SYSCTL)
69
70/* External variables not in a header file. */
71extern int C_A_D;
Ingo Molnar45807a12007-07-15 23:40:10 -070072extern int print_fatal_signals;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073extern int sysctl_overcommit_memory;
74extern int sysctl_overcommit_ratio;
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -070075extern int sysctl_panic_on_oom;
David Rientjesfe071d72007-10-16 23:25:56 -070076extern int sysctl_oom_kill_allocating_task;
David Rientjesfef1bdd2008-02-07 00:14:07 -080077extern int sysctl_oom_dump_tasks;
Linus Torvalds1da177e2005-04-16 15:20:36 -070078extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070080extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -070082extern unsigned int core_pipe_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -070083extern int pid_max;
84extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -070085extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -080086extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -080087extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +020088extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +010089extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -040090extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +000091#ifndef CONFIG_MMU
92extern int sysctl_nr_trim_pages;
93#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -070094#ifdef CONFIG_RCU_TORTURE_TEST
95extern int rcutorture_runnable;
96#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
Jens Axboecb684b52009-09-15 21:53:11 +020097#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +020098extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +020099#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700101/* Constants used for minimum and maximum */
Bron Gondwana195cf4532008-02-04 22:29:20 -0800102#ifdef CONFIG_DETECT_SOFTLOCKUP
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700103static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200104static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700105#endif
106
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700107static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700108static int __maybe_unused one = 1;
109static int __maybe_unused two = 2;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800110static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700111static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700112#ifdef CONFIG_PRINTK
113static int ten_thousand = 10000;
114#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700115
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700116/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
117static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
118
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
120static int maxolduid = 65535;
121static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800122static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123
124static int ngroups_max = NGROUPS_MAX;
125
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200126#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127extern char modprobe_path[];
Kees Cook3d433212009-04-02 15:49:29 -0700128extern int modules_disabled;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130#ifdef CONFIG_CHR_DEV_SG
131extern int sg_big_buff;
132#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133
David S. Miller72c57ed2008-09-11 23:29:54 -0700134#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700135#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136#endif
137
David S. Miller08714202008-11-16 23:49:24 -0800138#ifdef CONFIG_SPARC64
139extern int sysctl_tsb_ratio;
140#endif
141
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142#ifdef __hppa__
143extern int pwrsw_enabled;
144extern int unaligned_enabled;
145#endif
146
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800147#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148#ifdef CONFIG_MATHEMU
149extern int sysctl_ieee_emulation_warnings;
150#endif
151extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700152extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153#endif
154
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155#ifdef CONFIG_BSD_PROCESS_ACCT
156extern int acct_parm[];
157#endif
158
Jes Sorensend2b176e2006-02-28 09:42:23 -0800159#ifdef CONFIG_IA64
160extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800161extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800162#endif
163
Ingo Molnar3fff4c42009-09-22 16:18:09 +0200164extern struct ratelimit_state printk_ratelimit_state;
165
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700166#ifdef CONFIG_RT_MUTEXES
167extern int max_lock_depth;
168#endif
169
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700170#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700171static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700172 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700173static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800174 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700175#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700176
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700177static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100178static struct ctl_table_root sysctl_table_root;
179static struct ctl_table_header root_table_header = {
Al Virob380b0d2008-09-04 17:05:57 +0100180 .count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100181 .ctl_table = root_table,
Al Viro73455092008-07-14 21:22:20 -0400182 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100183 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400184 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100185};
186static struct ctl_table_root sysctl_table_root = {
187 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400188 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100189};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700191static struct ctl_table kern_table[];
192static struct ctl_table vm_table[];
193static struct ctl_table fs_table[];
194static struct ctl_table debug_table[];
195static struct ctl_table dev_table[];
196extern struct ctl_table random_table[];
Amy Griffis2d9048e2006-06-01 13:10:59 -0700197#ifdef CONFIG_INOTIFY_USER
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700198extern struct ctl_table inotify_table[];
Robert Love0399cb02005-07-13 12:38:18 -0400199#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -0800200#ifdef CONFIG_EPOLL
201extern struct ctl_table epoll_table[];
202#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
204#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
205int sysctl_legacy_va_layout;
206#endif
207
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700208extern int prove_locking;
209extern int lock_stat;
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800210
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211/* The default sysctl tables: */
212
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700213static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 .procname = "kernel",
216 .mode = 0555,
217 .child = kern_table,
218 },
219 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 .procname = "vm",
221 .mode = 0555,
222 .child = vm_table,
223 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 .procname = "fs",
226 .mode = 0555,
227 .child = fs_table,
228 },
229 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 .procname = "debug",
231 .mode = 0555,
232 .child = debug_table,
233 },
234 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 .procname = "dev",
236 .mode = 0555,
237 .child = dev_table,
238 },
Andrew Morton2be7fe02007-07-15 23:41:21 -0700239/*
240 * NOTE: do not add new entries to this table unless you have read
241 * Documentation/sysctl/ctl_unnumbered.txt
242 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700243 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244};
245
Ingo Molnar77e54a12007-07-09 18:52:00 +0200246#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100247static int min_sched_granularity_ns = 100000; /* 100 usecs */
248static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
249static int min_wakeup_granularity_ns; /* 0 usecs */
250static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100251static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
252static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100253static int min_sched_shares_ratelimit = 100000; /* 100 usec */
254static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200255#endif
256
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700257static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200258 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200259 .procname = "sched_child_runs_first",
260 .data = &sysctl_sched_child_runs_first,
261 .maxlen = sizeof(unsigned int),
262 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800263 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200264 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200265#ifdef CONFIG_SCHED_DEBUG
266 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100267 .procname = "sched_min_granularity_ns",
268 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200269 .maxlen = sizeof(unsigned int),
270 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800271 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100272 .extra1 = &min_sched_granularity_ns,
273 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200274 },
275 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200276 .procname = "sched_latency_ns",
277 .data = &sysctl_sched_latency,
278 .maxlen = sizeof(unsigned int),
279 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800280 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200281 .extra1 = &min_sched_granularity_ns,
282 .extra2 = &max_sched_granularity_ns,
283 },
284 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200285 .procname = "sched_wakeup_granularity_ns",
286 .data = &sysctl_sched_wakeup_granularity,
287 .maxlen = sizeof(unsigned int),
288 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800289 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200290 .extra1 = &min_wakeup_granularity_ns,
291 .extra2 = &max_wakeup_granularity_ns,
292 },
293 {
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200294 .procname = "sched_shares_ratelimit",
295 .data = &sysctl_sched_shares_ratelimit,
296 .maxlen = sizeof(unsigned int),
297 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800298 .proc_handler = sched_proc_update_handler,
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100299 .extra1 = &min_sched_shares_ratelimit,
300 .extra2 = &max_sched_shares_ratelimit,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200301 },
302 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100303 .procname = "sched_tunable_scaling",
304 .data = &sysctl_sched_tunable_scaling,
305 .maxlen = sizeof(enum sched_tunable_scaling),
306 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800307 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100308 .extra1 = &min_sched_tunable_scaling,
309 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200310 },
311 {
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200312 .procname = "sched_shares_thresh",
313 .data = &sysctl_sched_shares_thresh,
314 .maxlen = sizeof(unsigned int),
315 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800316 .proc_handler = proc_dointvec_minmax,
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200317 .extra1 = &zero,
318 },
319 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200320 .procname = "sched_migration_cost",
321 .data = &sysctl_sched_migration_cost,
322 .maxlen = sizeof(unsigned int),
323 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800324 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200325 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100326 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100327 .procname = "sched_nr_migrate",
328 .data = &sysctl_sched_nr_migrate,
329 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100330 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800331 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100332 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530333 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200334 .procname = "sched_time_avg",
335 .data = &sysctl_sched_time_avg,
336 .maxlen = sizeof(unsigned int),
337 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800338 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200339 },
340 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530341 .procname = "timer_migration",
342 .data = &sysctl_timer_migration,
343 .maxlen = sizeof(unsigned int),
344 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800345 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530346 .extra1 = &zero,
347 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530348 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200349#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200350 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100351 .procname = "sched_rt_period_us",
352 .data = &sysctl_sched_rt_period,
353 .maxlen = sizeof(unsigned int),
354 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800355 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100356 },
357 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100358 .procname = "sched_rt_runtime_us",
359 .data = &sysctl_sched_rt_runtime,
360 .maxlen = sizeof(int),
361 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800362 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100363 },
364 {
Ingo Molnar1799e352007-09-19 23:34:46 +0200365 .procname = "sched_compat_yield",
366 .data = &sysctl_sched_compat_yield,
367 .maxlen = sizeof(unsigned int),
368 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800369 .proc_handler = proc_dointvec,
Ingo Molnar1799e352007-09-19 23:34:46 +0200370 },
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700371#ifdef CONFIG_PROVE_LOCKING
372 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700373 .procname = "prove_locking",
374 .data = &prove_locking,
375 .maxlen = sizeof(int),
376 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800377 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700378 },
379#endif
380#ifdef CONFIG_LOCK_STAT
381 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700382 .procname = "lock_stat",
383 .data = &lock_stat,
384 .maxlen = sizeof(int),
385 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800386 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700387 },
388#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200389 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 .procname = "panic",
391 .data = &panic_timeout,
392 .maxlen = sizeof(int),
393 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800394 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 },
396 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 .procname = "core_uses_pid",
398 .data = &core_uses_pid,
399 .maxlen = sizeof(int),
400 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800401 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 },
403 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 .procname = "core_pattern",
405 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700406 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800408 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 },
Neil Hormana2939802009-09-23 15:56:56 -0700410 {
Neil Hormana2939802009-09-23 15:56:56 -0700411 .procname = "core_pipe_limit",
412 .data = &core_pipe_limit,
413 .maxlen = sizeof(unsigned int),
414 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800415 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700416 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800417#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700420 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800421 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800422 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800424#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100425#ifdef CONFIG_LATENCYTOP
426 {
427 .procname = "latencytop",
428 .data = &latencytop_enabled,
429 .maxlen = sizeof(int),
430 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800431 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100432 },
433#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434#ifdef CONFIG_BLK_DEV_INITRD
435 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 .procname = "real-root-dev",
437 .data = &real_root_dev,
438 .maxlen = sizeof(int),
439 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800440 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 },
442#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700443 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700444 .procname = "print-fatal-signals",
445 .data = &print_fatal_signals,
446 .maxlen = sizeof(int),
447 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800448 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700449 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700450#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 .procname = "reboot-cmd",
453 .data = reboot_command,
454 .maxlen = 256,
455 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800456 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 },
458 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 .procname = "stop-a",
460 .data = &stop_a_enabled,
461 .maxlen = sizeof (int),
462 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800463 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 },
465 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 .procname = "scons-poweroff",
467 .data = &scons_pwroff,
468 .maxlen = sizeof (int),
469 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800470 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 },
472#endif
David S. Miller08714202008-11-16 23:49:24 -0800473#ifdef CONFIG_SPARC64
474 {
David S. Miller08714202008-11-16 23:49:24 -0800475 .procname = "tsb-ratio",
476 .data = &sysctl_tsb_ratio,
477 .maxlen = sizeof (int),
478 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800479 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800480 },
481#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482#ifdef __hppa__
483 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 .procname = "soft-power",
485 .data = &pwrsw_enabled,
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 },
490 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 .procname = "unaligned-trap",
492 .data = &unaligned_enabled,
493 .maxlen = sizeof (int),
494 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800495 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 },
497#endif
498 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 .procname = "ctrl-alt-del",
500 .data = &C_A_D,
501 .maxlen = sizeof(int),
502 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800503 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400505#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200506 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200507 .procname = "ftrace_enabled",
508 .data = &ftrace_enabled,
509 .maxlen = sizeof(int),
510 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800511 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200512 },
513#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500514#ifdef CONFIG_STACK_TRACER
515 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500516 .procname = "stack_tracer_enabled",
517 .data = &stack_tracer_enabled,
518 .maxlen = sizeof(int),
519 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800520 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500521 },
522#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400523#ifdef CONFIG_TRACING
524 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100525 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400526 .data = &ftrace_dump_on_oops,
527 .maxlen = sizeof(int),
528 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800529 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400530 },
531#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200532#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 .procname = "modprobe",
535 .data = &modprobe_path,
536 .maxlen = KMOD_PATH_LEN,
537 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800538 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 },
Kees Cook3d433212009-04-02 15:49:29 -0700540 {
Kees Cook3d433212009-04-02 15:49:29 -0700541 .procname = "modules_disabled",
542 .data = &modules_disabled,
543 .maxlen = sizeof(int),
544 .mode = 0644,
545 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800546 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700547 .extra1 = &one,
548 .extra2 = &one,
549 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550#endif
Andrew Morton57ae2502006-06-23 02:05:47 -0700551#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100554 .data = &uevent_helper,
555 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800557 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 },
559#endif
560#ifdef CONFIG_CHR_DEV_SG
561 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 .procname = "sg-big-buff",
563 .data = &sg_big_buff,
564 .maxlen = sizeof (int),
565 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800566 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 },
568#endif
569#ifdef CONFIG_BSD_PROCESS_ACCT
570 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 .procname = "acct",
572 .data = &acct_parm,
573 .maxlen = 3*sizeof(int),
574 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800575 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 },
577#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578#ifdef CONFIG_MAGIC_SYSRQ
579 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800581 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 .maxlen = sizeof (int),
583 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800584 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 },
586#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700587#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700590 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 .maxlen = sizeof (int),
592 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800593 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700595#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 .procname = "threads-max",
598 .data = &max_threads,
599 .maxlen = sizeof(int),
600 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800601 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 },
603 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 .procname = "random",
605 .mode = 0555,
606 .child = random_table,
607 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700608 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 .procname = "overflowuid",
610 .data = &overflowuid,
611 .maxlen = sizeof(int),
612 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800613 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 .extra1 = &minolduid,
615 .extra2 = &maxolduid,
616 },
617 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 .procname = "overflowgid",
619 .data = &overflowgid,
620 .maxlen = sizeof(int),
621 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800622 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 .extra1 = &minolduid,
624 .extra2 = &maxolduid,
625 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800626#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627#ifdef CONFIG_MATHEMU
628 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 .procname = "ieee_emulation_warnings",
630 .data = &sysctl_ieee_emulation_warnings,
631 .maxlen = sizeof(int),
632 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800633 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 },
635#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 .procname = "userprocess_debug",
638 .data = &sysctl_userprocess_debug,
639 .maxlen = sizeof(int),
640 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800641 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 },
643#endif
644 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 .procname = "pid_max",
646 .data = &pid_max,
647 .maxlen = sizeof (int),
648 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800649 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 .extra1 = &pid_max_min,
651 .extra2 = &pid_max_max,
652 },
653 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 .procname = "panic_on_oops",
655 .data = &panic_on_oops,
656 .maxlen = sizeof(int),
657 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800658 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800660#if defined CONFIG_PRINTK
661 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800662 .procname = "printk",
663 .data = &console_loglevel,
664 .maxlen = 4*sizeof(int),
665 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800666 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800667 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700670 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 .maxlen = sizeof(int),
672 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800673 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 },
675 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700677 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 .maxlen = sizeof(int),
679 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800680 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 },
Dave Youngaf913222009-09-22 16:43:33 -0700682 {
Dave Youngaf913222009-09-22 16:43:33 -0700683 .procname = "printk_delay",
684 .data = &printk_delay_msec,
685 .maxlen = sizeof(int),
686 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800687 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700688 .extra1 = &zero,
689 .extra2 = &ten_thousand,
690 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800691#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 .procname = "ngroups_max",
694 .data = &ngroups_max,
695 .maxlen = sizeof (int),
696 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800697 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500699#if defined(CONFIG_NMI_WATCHDOG)
700 {
701 .procname = "nmi_watchdog",
702 .data = &nmi_watchdog_enabled,
703 .maxlen = sizeof (int),
704 .mode = 0644,
705 .proc_handler = proc_nmi_enabled,
706 },
707#endif
708#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86) && !defined(CONFIG_NMI_WATCHDOG)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 .procname = "unknown_nmi_panic",
711 .data = &unknown_nmi_panic,
712 .maxlen = sizeof (int),
713 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800714 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 },
Don Zickus407984f2006-09-26 10:52:27 +0200716 {
Don Zickus407984f2006-09-26 10:52:27 +0200717 .procname = "nmi_watchdog",
718 .data = &nmi_watchdog_enabled,
719 .maxlen = sizeof (int),
720 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800721 .proc_handler = proc_nmi_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 },
723#endif
724#if defined(CONFIG_X86)
725 {
Don Zickus8da5add2006-09-26 10:52:27 +0200726 .procname = "panic_on_unrecovered_nmi",
727 .data = &panic_on_unrecovered_nmi,
728 .maxlen = sizeof(int),
729 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800730 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200731 },
732 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700733 .procname = "panic_on_io_nmi",
734 .data = &panic_on_io_nmi,
735 .maxlen = sizeof(int),
736 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800737 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700738 },
739 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 .procname = "bootloader_type",
741 .data = &bootloader_type,
742 .maxlen = sizeof (int),
743 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800744 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100746 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700747 .procname = "bootloader_version",
748 .data = &bootloader_version,
749 .maxlen = sizeof (int),
750 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800751 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700752 },
753 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100754 .procname = "kstack_depth_to_print",
755 .data = &kstack_depth_to_print,
756 .maxlen = sizeof(int),
757 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800758 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100759 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100760 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100761 .procname = "io_delay_type",
762 .data = &io_delay_type,
763 .maxlen = sizeof(int),
764 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800765 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100766 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800768#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 .procname = "randomize_va_space",
771 .data = &randomize_va_space,
772 .maxlen = sizeof(int),
773 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800774 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800776#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800777#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700778 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700779 .procname = "spin_retry",
780 .data = &spin_retry,
781 .maxlen = sizeof (int),
782 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800783 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700784 },
785#endif
Len Brown673d5b42007-07-28 03:33:16 -0400786#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800787 {
Pavel Machekc255d842006-02-20 18:27:58 -0800788 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700789 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800790 .maxlen = sizeof (unsigned long),
791 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800792 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800793 },
794#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800795#ifdef CONFIG_IA64
796 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800797 .procname = "ignore-unaligned-usertrap",
798 .data = &no_unaligned_warning,
799 .maxlen = sizeof (int),
800 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800801 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800802 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800803 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800804 .procname = "unaligned-dump-stack",
805 .data = &unaligned_dump_stack,
806 .maxlen = sizeof (int),
807 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800808 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800809 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800810#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700811#ifdef CONFIG_DETECT_SOFTLOCKUP
812 {
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200813 .procname = "softlockup_panic",
814 .data = &softlockup_panic,
815 .maxlen = sizeof(int),
816 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800817 .proc_handler = proc_dointvec_minmax,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200818 .extra1 = &zero,
819 .extra2 = &one,
820 },
821 {
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700822 .procname = "softlockup_thresh",
823 .data = &softlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200824 .maxlen = sizeof(int),
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700825 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800826 .proc_handler = proc_dosoftlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200827 .extra1 = &neg_one,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700828 .extra2 = &sixty,
829 },
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800830#endif
831#ifdef CONFIG_DETECT_HUNG_TASK
832 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800833 .procname = "hung_task_panic",
834 .data = &sysctl_hung_task_panic,
835 .maxlen = sizeof(int),
836 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800837 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800838 .extra1 = &zero,
839 .extra2 = &one,
840 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100841 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100842 .procname = "hung_task_check_count",
843 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100844 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100845 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800846 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100847 },
848 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100849 .procname = "hung_task_timeout_secs",
850 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100851 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100852 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800853 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100854 },
855 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100856 .procname = "hung_task_warnings",
857 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100858 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100859 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800860 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100861 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700862#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200863#ifdef CONFIG_COMPAT
864 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200865 .procname = "compat-log",
866 .data = &compat_log,
867 .maxlen = sizeof (int),
868 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800869 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200870 },
871#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700872#ifdef CONFIG_RT_MUTEXES
873 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700874 .procname = "max_lock_depth",
875 .data = &max_lock_depth,
876 .maxlen = sizeof(int),
877 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800878 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700879 },
880#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700881 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700882 .procname = "poweroff_cmd",
883 .data = &poweroff_cmd,
884 .maxlen = POWEROFF_CMD_PATH_LEN,
885 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800886 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700887 },
David Howells0b77f5b2008-04-29 01:01:32 -0700888#ifdef CONFIG_KEYS
889 {
David Howells0b77f5b2008-04-29 01:01:32 -0700890 .procname = "keys",
891 .mode = 0555,
892 .child = key_sysctls,
893 },
894#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700895#ifdef CONFIG_RCU_TORTURE_TEST
896 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700897 .procname = "rcutorture_runnable",
898 .data = &rcutorture_runnable,
899 .maxlen = sizeof(int),
900 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800901 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700902 },
903#endif
David Howells12e22c52009-04-03 16:42:35 +0100904#ifdef CONFIG_SLOW_WORK
905 {
David Howells12e22c52009-04-03 16:42:35 +0100906 .procname = "slow-work",
907 .mode = 0555,
908 .child = slow_work_sysctls,
909 },
910#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200911#ifdef CONFIG_PERF_EVENTS
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200912 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200913 .procname = "perf_event_paranoid",
914 .data = &sysctl_perf_event_paranoid,
915 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200916 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800917 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200918 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200919 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200920 .procname = "perf_event_mlock_kb",
921 .data = &sysctl_perf_event_mlock,
922 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200923 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800924 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200925 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200926 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200927 .procname = "perf_event_max_sample_rate",
928 .data = &sysctl_perf_event_sample_rate,
929 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200930 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800931 .proc_handler = proc_dointvec,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200932 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200933#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200934#ifdef CONFIG_KMEMCHECK
935 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200936 .procname = "kmemcheck",
937 .data = &kmemcheck_enabled,
938 .maxlen = sizeof(int),
939 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800940 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +0200941 },
942#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200943#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200944 {
Jens Axboe5e605b62009-08-05 09:07:21 +0200945 .procname = "blk_iopoll",
946 .data = &blk_iopoll_enabled,
947 .maxlen = sizeof(int),
948 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800949 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +0200950 },
Jens Axboecb684b52009-09-15 21:53:11 +0200951#endif
Andrew Mortoned2c12f2007-07-19 01:50:35 -0700952/*
953 * NOTE: do not add new entries to this table unless you have read
954 * Documentation/sysctl/ctl_unnumbered.txt
955 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700956 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957};
958
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700959static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700960 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961 .procname = "overcommit_memory",
962 .data = &sysctl_overcommit_memory,
963 .maxlen = sizeof(sysctl_overcommit_memory),
964 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800965 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966 },
967 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700968 .procname = "panic_on_oom",
969 .data = &sysctl_panic_on_oom,
970 .maxlen = sizeof(sysctl_panic_on_oom),
971 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800972 .proc_handler = proc_dointvec,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700973 },
974 {
David Rientjesfe071d72007-10-16 23:25:56 -0700975 .procname = "oom_kill_allocating_task",
976 .data = &sysctl_oom_kill_allocating_task,
977 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
978 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800979 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -0700980 },
981 {
David Rientjesfef1bdd2008-02-07 00:14:07 -0800982 .procname = "oom_dump_tasks",
983 .data = &sysctl_oom_dump_tasks,
984 .maxlen = sizeof(sysctl_oom_dump_tasks),
985 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800986 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -0800987 },
988 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700989 .procname = "overcommit_ratio",
990 .data = &sysctl_overcommit_ratio,
991 .maxlen = sizeof(sysctl_overcommit_ratio),
992 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800993 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 },
995 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996 .procname = "page-cluster",
997 .data = &page_cluster,
998 .maxlen = sizeof(int),
999 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001000 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001 },
1002 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001003 .procname = "dirty_background_ratio",
1004 .data = &dirty_background_ratio,
1005 .maxlen = sizeof(dirty_background_ratio),
1006 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001007 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001008 .extra1 = &zero,
1009 .extra2 = &one_hundred,
1010 },
1011 {
David Rientjes2da02992009-01-06 14:39:31 -08001012 .procname = "dirty_background_bytes",
1013 .data = &dirty_background_bytes,
1014 .maxlen = sizeof(dirty_background_bytes),
1015 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001016 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001017 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001018 },
1019 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001020 .procname = "dirty_ratio",
1021 .data = &vm_dirty_ratio,
1022 .maxlen = sizeof(vm_dirty_ratio),
1023 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001024 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001025 .extra1 = &zero,
1026 .extra2 = &one_hundred,
1027 },
1028 {
David Rientjes2da02992009-01-06 14:39:31 -08001029 .procname = "dirty_bytes",
1030 .data = &vm_dirty_bytes,
1031 .maxlen = sizeof(vm_dirty_bytes),
1032 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001033 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001034 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001035 },
1036 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001037 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001038 .data = &dirty_writeback_interval,
1039 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001040 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001041 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001042 },
1043 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001044 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001045 .data = &dirty_expire_interval,
1046 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001048 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049 },
1050 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051 .procname = "nr_pdflush_threads",
1052 .data = &nr_pdflush_threads,
1053 .maxlen = sizeof nr_pdflush_threads,
1054 .mode = 0444 /* read-only*/,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001055 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056 },
1057 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058 .procname = "swappiness",
1059 .data = &vm_swappiness,
1060 .maxlen = sizeof(vm_swappiness),
1061 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001062 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 .extra1 = &zero,
1064 .extra2 = &one_hundred,
1065 },
1066#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001067 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001069 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 .maxlen = sizeof(unsigned long),
1071 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001072 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073 .extra1 = (void *)&hugetlb_zero,
1074 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001075 },
1076#ifdef CONFIG_NUMA
1077 {
1078 .procname = "nr_hugepages_mempolicy",
1079 .data = NULL,
1080 .maxlen = sizeof(unsigned long),
1081 .mode = 0644,
1082 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1083 .extra1 = (void *)&hugetlb_zero,
1084 .extra2 = (void *)&hugetlb_infinity,
1085 },
1086#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001087 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088 .procname = "hugetlb_shm_group",
1089 .data = &sysctl_hugetlb_shm_group,
1090 .maxlen = sizeof(gid_t),
1091 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001092 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093 },
Mel Gorman396faf02007-07-17 04:03:13 -07001094 {
Mel Gorman396faf02007-07-17 04:03:13 -07001095 .procname = "hugepages_treat_as_movable",
1096 .data = &hugepages_treat_as_movable,
1097 .maxlen = sizeof(int),
1098 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001099 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001100 },
Adam Litke54f9f802007-10-16 01:26:20 -07001101 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001102 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001103 .data = NULL,
1104 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001105 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001106 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001107 .extra1 = (void *)&hugetlb_zero,
1108 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001109 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110#endif
1111 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001112 .procname = "lowmem_reserve_ratio",
1113 .data = &sysctl_lowmem_reserve_ratio,
1114 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1115 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001116 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001117 },
1118 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001119 .procname = "drop_caches",
1120 .data = &sysctl_drop_caches,
1121 .maxlen = sizeof(int),
1122 .mode = 0644,
1123 .proc_handler = drop_caches_sysctl_handler,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001124 },
1125 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126 .procname = "min_free_kbytes",
1127 .data = &min_free_kbytes,
1128 .maxlen = sizeof(min_free_kbytes),
1129 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001130 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001131 .extra1 = &zero,
1132 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001133 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001134 .procname = "percpu_pagelist_fraction",
1135 .data = &percpu_pagelist_fraction,
1136 .maxlen = sizeof(percpu_pagelist_fraction),
1137 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001138 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001139 .extra1 = &min_percpu_pagelist_fract,
1140 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141#ifdef CONFIG_MMU
1142 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143 .procname = "max_map_count",
1144 .data = &sysctl_max_map_count,
1145 .maxlen = sizeof(sysctl_max_map_count),
1146 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001147 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001148 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001150#else
1151 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001152 .procname = "nr_trim_pages",
1153 .data = &sysctl_nr_trim_pages,
1154 .maxlen = sizeof(sysctl_nr_trim_pages),
1155 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001156 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001157 .extra1 = &zero,
1158 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159#endif
1160 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 .procname = "laptop_mode",
1162 .data = &laptop_mode,
1163 .maxlen = sizeof(laptop_mode),
1164 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001165 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166 },
1167 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168 .procname = "block_dump",
1169 .data = &block_dump,
1170 .maxlen = sizeof(block_dump),
1171 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001172 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 .extra1 = &zero,
1174 },
1175 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176 .procname = "vfs_cache_pressure",
1177 .data = &sysctl_vfs_cache_pressure,
1178 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1179 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001180 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181 .extra1 = &zero,
1182 },
1183#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1184 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185 .procname = "legacy_va_layout",
1186 .data = &sysctl_legacy_va_layout,
1187 .maxlen = sizeof(sysctl_legacy_va_layout),
1188 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001189 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 .extra1 = &zero,
1191 },
1192#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001193#ifdef CONFIG_NUMA
1194 {
Christoph Lameter17436602006-01-18 17:42:32 -08001195 .procname = "zone_reclaim_mode",
1196 .data = &zone_reclaim_mode,
1197 .maxlen = sizeof(zone_reclaim_mode),
1198 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001199 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001200 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001201 },
Christoph Lameter96146342006-07-03 00:24:13 -07001202 {
Christoph Lameter96146342006-07-03 00:24:13 -07001203 .procname = "min_unmapped_ratio",
1204 .data = &sysctl_min_unmapped_ratio,
1205 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1206 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001207 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001208 .extra1 = &zero,
1209 .extra2 = &one_hundred,
1210 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001211 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001212 .procname = "min_slab_ratio",
1213 .data = &sysctl_min_slab_ratio,
1214 .maxlen = sizeof(sysctl_min_slab_ratio),
1215 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001216 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001217 .extra1 = &zero,
1218 .extra2 = &one_hundred,
1219 },
Christoph Lameter17436602006-01-18 17:42:32 -08001220#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001221#ifdef CONFIG_SMP
1222 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001223 .procname = "stat_interval",
1224 .data = &sysctl_stat_interval,
1225 .maxlen = sizeof(sysctl_stat_interval),
1226 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001227 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001228 },
1229#endif
David Howells6e141542009-12-15 19:27:45 +00001230#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001231 {
Eric Parised032182007-06-28 15:55:21 -04001232 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001233 .data = &dac_mmap_min_addr,
1234 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001235 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001236 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001237 },
David Howells6e141542009-12-15 19:27:45 +00001238#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001239#ifdef CONFIG_NUMA
1240 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001241 .procname = "numa_zonelist_order",
1242 .data = &numa_zonelist_order,
1243 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1244 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001245 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001246 },
1247#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001248#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001249 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001250 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001251 .procname = "vdso_enabled",
1252 .data = &vdso_enabled,
1253 .maxlen = sizeof(vdso_enabled),
1254 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001255 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001256 .extra1 = &zero,
1257 },
1258#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001259#ifdef CONFIG_HIGHMEM
1260 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001261 .procname = "highmem_is_dirtyable",
1262 .data = &vm_highmem_is_dirtyable,
1263 .maxlen = sizeof(vm_highmem_is_dirtyable),
1264 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001265 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001266 .extra1 = &zero,
1267 .extra2 = &one,
1268 },
1269#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001270 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001271 .procname = "scan_unevictable_pages",
1272 .data = &scan_unevictable_pages,
1273 .maxlen = sizeof(scan_unevictable_pages),
1274 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001275 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001276 },
Andi Kleen6a460792009-09-16 11:50:15 +02001277#ifdef CONFIG_MEMORY_FAILURE
1278 {
Andi Kleen6a460792009-09-16 11:50:15 +02001279 .procname = "memory_failure_early_kill",
1280 .data = &sysctl_memory_failure_early_kill,
1281 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1282 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001283 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001284 .extra1 = &zero,
1285 .extra2 = &one,
1286 },
1287 {
Andi Kleen6a460792009-09-16 11:50:15 +02001288 .procname = "memory_failure_recovery",
1289 .data = &sysctl_memory_failure_recovery,
1290 .maxlen = sizeof(sysctl_memory_failure_recovery),
1291 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001292 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001293 .extra1 = &zero,
1294 .extra2 = &one,
1295 },
1296#endif
1297
Andrew Morton2be7fe02007-07-15 23:41:21 -07001298/*
1299 * NOTE: do not add new entries to this table unless you have read
1300 * Documentation/sysctl/ctl_unnumbered.txt
1301 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001302 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001303};
1304
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001305#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001306static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001307 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001308};
1309#endif
1310
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001311static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001313 .procname = "inode-nr",
1314 .data = &inodes_stat,
1315 .maxlen = 2*sizeof(int),
1316 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001317 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001318 },
1319 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320 .procname = "inode-state",
1321 .data = &inodes_stat,
1322 .maxlen = 7*sizeof(int),
1323 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001324 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 },
1326 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001327 .procname = "file-nr",
1328 .data = &files_stat,
1329 .maxlen = 3*sizeof(int),
1330 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001331 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001332 },
1333 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001334 .procname = "file-max",
1335 .data = &files_stat.max_files,
1336 .maxlen = sizeof(int),
1337 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001338 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339 },
1340 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001341 .procname = "nr_open",
1342 .data = &sysctl_nr_open,
1343 .maxlen = sizeof(int),
1344 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001345 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001346 .extra1 = &sysctl_nr_open_min,
1347 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001348 },
1349 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350 .procname = "dentry-state",
1351 .data = &dentry_stat,
1352 .maxlen = 6*sizeof(int),
1353 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001354 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355 },
1356 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001357 .procname = "overflowuid",
1358 .data = &fs_overflowuid,
1359 .maxlen = sizeof(int),
1360 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001361 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001362 .extra1 = &minolduid,
1363 .extra2 = &maxolduid,
1364 },
1365 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001366 .procname = "overflowgid",
1367 .data = &fs_overflowgid,
1368 .maxlen = sizeof(int),
1369 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001370 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001371 .extra1 = &minolduid,
1372 .extra2 = &maxolduid,
1373 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001374#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001375 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001376 .procname = "leases-enable",
1377 .data = &leases_enable,
1378 .maxlen = sizeof(int),
1379 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001380 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001381 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001382#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001383#ifdef CONFIG_DNOTIFY
1384 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385 .procname = "dir-notify-enable",
1386 .data = &dir_notify_enable,
1387 .maxlen = sizeof(int),
1388 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001389 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390 },
1391#endif
1392#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001393#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001394 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001395 .procname = "lease-break-time",
1396 .data = &lease_break_time,
1397 .maxlen = sizeof(int),
1398 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001399 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001400 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001401#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001402#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001403 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001404 .procname = "aio-nr",
1405 .data = &aio_nr,
1406 .maxlen = sizeof(aio_nr),
1407 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001408 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001409 },
1410 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411 .procname = "aio-max-nr",
1412 .data = &aio_max_nr,
1413 .maxlen = sizeof(aio_max_nr),
1414 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001415 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001416 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001417#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001418#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001419 {
Robert Love0399cb02005-07-13 12:38:18 -04001420 .procname = "inotify",
1421 .mode = 0555,
1422 .child = inotify_table,
1423 },
1424#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001425#ifdef CONFIG_EPOLL
1426 {
1427 .procname = "epoll",
1428 .mode = 0555,
1429 .child = epoll_table,
1430 },
1431#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001432#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001433 {
Alan Coxd6e71142005-06-23 00:09:43 -07001434 .procname = "suid_dumpable",
1435 .data = &suid_dumpable,
1436 .maxlen = sizeof(int),
1437 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001438 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001439 .extra1 = &zero,
1440 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001441 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001442#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1443 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001444 .procname = "binfmt_misc",
1445 .mode = 0555,
1446 .child = binfmt_misc_table,
1447 },
1448#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001449/*
1450 * NOTE: do not add new entries to this table unless you have read
1451 * Documentation/sysctl/ctl_unnumbered.txt
1452 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001453 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001454};
1455
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001456static struct ctl_table debug_table[] = {
Olof Johanssond0c3d532007-10-12 10:20:07 +10001457#if defined(CONFIG_X86) || defined(CONFIG_PPC)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001458 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001459 .procname = "exception-trace",
1460 .data = &show_unhandled_signals,
1461 .maxlen = sizeof(int),
1462 .mode = 0644,
1463 .proc_handler = proc_dointvec
1464 },
1465#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001466 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467};
1468
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001469static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001470 { }
Robert Love0eeca282005-07-12 17:06:03 -04001471};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472
Al Viro330d57f2005-11-04 10:18:40 +00001473static DEFINE_SPINLOCK(sysctl_lock);
1474
1475/* called under sysctl_lock */
1476static int use_table(struct ctl_table_header *p)
1477{
1478 if (unlikely(p->unregistering))
1479 return 0;
1480 p->used++;
1481 return 1;
1482}
1483
1484/* called under sysctl_lock */
1485static void unuse_table(struct ctl_table_header *p)
1486{
1487 if (!--p->used)
1488 if (unlikely(p->unregistering))
1489 complete(p->unregistering);
1490}
1491
1492/* called under sysctl_lock, will reacquire if has to wait */
1493static void start_unregistering(struct ctl_table_header *p)
1494{
1495 /*
1496 * if p->used is 0, nobody will ever touch that entry again;
1497 * we'll eliminate all paths to it before dropping sysctl_lock
1498 */
1499 if (unlikely(p->used)) {
1500 struct completion wait;
1501 init_completion(&wait);
1502 p->unregistering = &wait;
1503 spin_unlock(&sysctl_lock);
1504 wait_for_completion(&wait);
1505 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001506 } else {
1507 /* anything non-NULL; we'll never dereference it */
1508 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001509 }
1510 /*
1511 * do not remove from the list until nobody holds it; walking the
1512 * list in do_sysctl() relies on that.
1513 */
1514 list_del_init(&p->ctl_entry);
1515}
1516
Al Virof7e6ced2008-07-15 01:44:23 -04001517void sysctl_head_get(struct ctl_table_header *head)
1518{
1519 spin_lock(&sysctl_lock);
1520 head->count++;
1521 spin_unlock(&sysctl_lock);
1522}
1523
1524void sysctl_head_put(struct ctl_table_header *head)
1525{
1526 spin_lock(&sysctl_lock);
1527 if (!--head->count)
1528 kfree(head);
1529 spin_unlock(&sysctl_lock);
1530}
1531
1532struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1533{
1534 if (!head)
1535 BUG();
1536 spin_lock(&sysctl_lock);
1537 if (!use_table(head))
1538 head = ERR_PTR(-ENOENT);
1539 spin_unlock(&sysctl_lock);
1540 return head;
1541}
1542
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001543void sysctl_head_finish(struct ctl_table_header *head)
1544{
1545 if (!head)
1546 return;
1547 spin_lock(&sysctl_lock);
1548 unuse_table(head);
1549 spin_unlock(&sysctl_lock);
1550}
1551
Al Viro73455092008-07-14 21:22:20 -04001552static struct ctl_table_set *
1553lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1554{
1555 struct ctl_table_set *set = &root->default_set;
1556 if (root->lookup)
1557 set = root->lookup(root, namespaces);
1558 return set;
1559}
1560
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001561static struct list_head *
1562lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001563{
Al Viro73455092008-07-14 21:22:20 -04001564 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1565 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001566}
1567
1568struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1569 struct ctl_table_header *prev)
1570{
1571 struct ctl_table_root *root;
1572 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001573 struct ctl_table_header *head;
1574 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001575
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001576 spin_lock(&sysctl_lock);
1577 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001578 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001579 tmp = &prev->ctl_entry;
1580 unuse_table(prev);
1581 goto next;
1582 }
1583 tmp = &root_table_header.ctl_entry;
1584 for (;;) {
1585 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1586
1587 if (!use_table(head))
1588 goto next;
1589 spin_unlock(&sysctl_lock);
1590 return head;
1591 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001592 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001593 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001594 header_list = lookup_header_list(root, namespaces);
1595 if (tmp != header_list)
1596 continue;
1597
1598 do {
1599 root = list_entry(root->root_list.next,
1600 struct ctl_table_root, root_list);
1601 if (root == &sysctl_table_root)
1602 goto out;
1603 header_list = lookup_header_list(root, namespaces);
1604 } while (list_empty(header_list));
1605 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001606 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001607out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001608 spin_unlock(&sysctl_lock);
1609 return NULL;
1610}
1611
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001612struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1613{
1614 return __sysctl_head_next(current->nsproxy, prev);
1615}
1616
1617void register_sysctl_root(struct ctl_table_root *root)
1618{
1619 spin_lock(&sysctl_lock);
1620 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1621 spin_unlock(&sysctl_lock);
1622}
1623
Linus Torvalds1da177e2005-04-16 15:20:36 -07001624/*
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001625 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001626 * some sysctl variables are readonly even to root.
1627 */
1628
1629static int test_perm(int mode, int op)
1630{
David Howells76aac0e2008-11-14 10:39:12 +11001631 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001632 mode >>= 6;
1633 else if (in_egroup_p(0))
1634 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001635 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001636 return 0;
1637 return -EACCES;
1638}
1639
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001640int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001641{
1642 int error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001643 int mode;
1644
Al Viroe6305c42008-07-15 21:03:57 -04001645 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001646 if (error)
1647 return error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001648
1649 if (root->permissions)
1650 mode = root->permissions(root, current->nsproxy, table);
1651 else
1652 mode = table->mode;
1653
1654 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655}
1656
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001657static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1658{
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001659 for (; table->procname; table++) {
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001660 table->parent = parent;
1661 if (table->child)
1662 sysctl_set_parent(table, table->child);
1663 }
1664}
1665
1666static __init int sysctl_init(void)
1667{
1668 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001669#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1670 {
1671 int err;
1672 err = sysctl_check_table(current->nsproxy, root_table);
1673 }
1674#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001675 return 0;
1676}
1677
1678core_initcall(sysctl_init);
1679
Al Virobfbcf032008-07-27 06:31:22 +01001680static struct ctl_table *is_branch_in(struct ctl_table *branch,
1681 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001682{
1683 struct ctl_table *p;
1684 const char *s = branch->procname;
1685
1686 /* branch should have named subdirectory as its first element */
1687 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001688 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001689
1690 /* ... and nothing else */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001691 if (branch[1].procname)
Al Virobfbcf032008-07-27 06:31:22 +01001692 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001693
1694 /* table should contain subdirectory with the same name */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001695 for (p = table; p->procname; p++) {
Al Viroae7edec2008-07-15 06:33:31 -04001696 if (!p->child)
1697 continue;
1698 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001699 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001700 }
Al Virobfbcf032008-07-27 06:31:22 +01001701 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001702}
1703
1704/* see if attaching q to p would be an improvement */
1705static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1706{
1707 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001708 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001709 int is_better = 0;
1710 int not_in_parent = !p->attached_by;
1711
Al Virobfbcf032008-07-27 06:31:22 +01001712 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001713 if (by == q->attached_by)
1714 is_better = 1;
1715 if (to == p->attached_by)
1716 not_in_parent = 1;
1717 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001718 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001719 }
1720
1721 if (is_better && not_in_parent) {
1722 q->attached_by = by;
1723 q->attached_to = to;
1724 q->parent = p;
1725 }
1726}
1727
Linus Torvalds1da177e2005-04-16 15:20:36 -07001728/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001729 * __register_sysctl_paths - register a sysctl hierarchy
1730 * @root: List of sysctl headers to register on
1731 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001732 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001733 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001734 *
1735 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001736 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001737 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001738 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001739 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1741 * enter a sysctl file
1742 *
1743 * data - a pointer to data for use by proc_handler
1744 *
1745 * maxlen - the maximum size in bytes of the data
1746 *
1747 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1748 *
1749 * child - a pointer to the child sysctl table if this entry is a directory, or
1750 * %NULL.
1751 *
1752 * proc_handler - the text handler routine (described below)
1753 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001754 * de - for internal use by the sysctl routines
1755 *
1756 * extra1, extra2 - extra pointers usable by the proc handler routines
1757 *
1758 * Leaf nodes in the sysctl tree will be represented by a single file
1759 * under /proc; non-leaf nodes will be represented by directories.
1760 *
1761 * sysctl(2) can automatically manage read and write requests through
1762 * the sysctl table. The data and maxlen fields of the ctl_table
1763 * struct enable minimal validation of the values being written to be
1764 * performed, and the mode field allows minimal authentication.
1765 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001766 * There must be a proc_handler routine for any terminal nodes
1767 * mirrored under /proc/sys (non-terminals are handled by a built-in
1768 * directory handler). Several default handlers are available to
1769 * cover common cases -
1770 *
1771 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1772 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1773 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1774 *
1775 * It is the handler's job to read the input buffer from user memory
1776 * and process it. The handler should return 0 on success.
1777 *
1778 * This routine returns %NULL on a failure to register, and a pointer
1779 * to the table header on success.
1780 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001781struct ctl_table_header *__register_sysctl_paths(
1782 struct ctl_table_root *root,
1783 struct nsproxy *namespaces,
1784 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001785{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001786 struct ctl_table_header *header;
1787 struct ctl_table *new, **prevp;
1788 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001789 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001790
1791 /* Count the path components */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001792 for (npath = 0; path[npath].procname; ++npath)
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001793 ;
1794
1795 /*
1796 * For each path component, allocate a 2-element ctl_table array.
1797 * The first array element will be filled with the sysctl entry
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001798 * for this, the second will be the sentinel (procname == 0).
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001799 *
1800 * We allocate everything in one go so that we don't have to
1801 * worry about freeing additional memory in unregister_sysctl_table.
1802 */
1803 header = kzalloc(sizeof(struct ctl_table_header) +
1804 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1805 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001806 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001807
1808 new = (struct ctl_table *) (header + 1);
1809
1810 /* Now connect the dots */
1811 prevp = &header->ctl_table;
1812 for (n = 0; n < npath; ++n, ++path) {
1813 /* Copy the procname */
1814 new->procname = path->procname;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001815 new->mode = 0555;
1816
1817 *prevp = new;
1818 prevp = &new->child;
1819
1820 new += 2;
1821 }
1822 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001823 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001824
1825 INIT_LIST_HEAD(&header->ctl_entry);
1826 header->used = 0;
1827 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001828 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001829 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001830 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001831#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001832 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001833 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001834 return NULL;
1835 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001836#endif
Al Viro330d57f2005-11-04 10:18:40 +00001837 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001838 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001839 header->attached_by = header->ctl_table;
1840 header->attached_to = root_table;
1841 header->parent = &root_table_header;
1842 for (set = header->set; set; set = set->parent) {
1843 struct ctl_table_header *p;
1844 list_for_each_entry(p, &set->list, ctl_entry) {
1845 if (p->unregistering)
1846 continue;
1847 try_attach(p, header);
1848 }
1849 }
1850 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001851 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001852 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001853
1854 return header;
1855}
1856
1857/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001858 * register_sysctl_table_path - register a sysctl table hierarchy
1859 * @path: The path to the directory the sysctl table is in.
1860 * @table: the top-level table structure
1861 *
1862 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1863 * array. A completely 0 filled entry terminates the table.
1864 *
1865 * See __register_sysctl_paths for more details.
1866 */
1867struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1868 struct ctl_table *table)
1869{
1870 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1871 path, table);
1872}
1873
1874/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001875 * register_sysctl_table - register a sysctl table hierarchy
1876 * @table: the top-level table structure
1877 *
1878 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1879 * array. A completely 0 filled entry terminates the table.
1880 *
1881 * See register_sysctl_paths for more details.
1882 */
1883struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1884{
1885 static const struct ctl_path null_path[] = { {} };
1886
1887 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001888}
1889
1890/**
1891 * unregister_sysctl_table - unregister a sysctl table hierarchy
1892 * @header: the header returned from register_sysctl_table
1893 *
1894 * Unregisters the sysctl table and all children. proc entries may not
1895 * actually be removed until they are no longer used by anyone.
1896 */
1897void unregister_sysctl_table(struct ctl_table_header * header)
1898{
Al Viro330d57f2005-11-04 10:18:40 +00001899 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08001900
1901 if (header == NULL)
1902 return;
1903
Al Viro330d57f2005-11-04 10:18:40 +00001904 spin_lock(&sysctl_lock);
1905 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04001906 if (!--header->parent->count) {
1907 WARN_ON(1);
1908 kfree(header->parent);
1909 }
Al Virof7e6ced2008-07-15 01:44:23 -04001910 if (!--header->count)
1911 kfree(header);
Al Viro330d57f2005-11-04 10:18:40 +00001912 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001913}
1914
Al Viro9043476f2008-07-15 08:54:06 -04001915int sysctl_is_seen(struct ctl_table_header *p)
1916{
1917 struct ctl_table_set *set = p->set;
1918 int res;
1919 spin_lock(&sysctl_lock);
1920 if (p->unregistering)
1921 res = 0;
1922 else if (!set->is_seen)
1923 res = 1;
1924 else
1925 res = set->is_seen(set);
1926 spin_unlock(&sysctl_lock);
1927 return res;
1928}
1929
Al Viro73455092008-07-14 21:22:20 -04001930void setup_sysctl_set(struct ctl_table_set *p,
1931 struct ctl_table_set *parent,
1932 int (*is_seen)(struct ctl_table_set *))
1933{
1934 INIT_LIST_HEAD(&p->list);
1935 p->parent = parent ? parent : &sysctl_table_root.default_set;
1936 p->is_seen = is_seen;
1937}
1938
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001939#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001940struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001941{
1942 return NULL;
1943}
1944
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001945struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1946 struct ctl_table *table)
1947{
1948 return NULL;
1949}
1950
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001951void unregister_sysctl_table(struct ctl_table_header * table)
1952{
1953}
1954
Al Viro73455092008-07-14 21:22:20 -04001955void setup_sysctl_set(struct ctl_table_set *p,
1956 struct ctl_table_set *parent,
1957 int (*is_seen)(struct ctl_table_set *))
1958{
1959}
1960
Al Virof7e6ced2008-07-15 01:44:23 -04001961void sysctl_head_put(struct ctl_table_header *head)
1962{
1963}
1964
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001965#endif /* CONFIG_SYSCTL */
1966
Linus Torvalds1da177e2005-04-16 15:20:36 -07001967/*
1968 * /proc/sys support
1969 */
1970
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001971#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001972
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001973static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001974 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001975 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001976{
1977 size_t len;
1978 char __user *p;
1979 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001980
1981 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001982 *lenp = 0;
1983 return 0;
1984 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001985
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001986 if (write) {
1987 len = 0;
1988 p = buffer;
1989 while (len < *lenp) {
1990 if (get_user(c, p++))
1991 return -EFAULT;
1992 if (c == 0 || c == '\n')
1993 break;
1994 len++;
1995 }
1996 if (len >= maxlen)
1997 len = maxlen-1;
1998 if(copy_from_user(data, buffer, len))
1999 return -EFAULT;
2000 ((char *) data)[len] = 0;
2001 *ppos += *lenp;
2002 } else {
2003 len = strlen(data);
2004 if (len > maxlen)
2005 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002006
2007 if (*ppos > len) {
2008 *lenp = 0;
2009 return 0;
2010 }
2011
2012 data += *ppos;
2013 len -= *ppos;
2014
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002015 if (len > *lenp)
2016 len = *lenp;
2017 if (len)
2018 if(copy_to_user(buffer, data, len))
2019 return -EFAULT;
2020 if (len < *lenp) {
2021 if(put_user('\n', ((char __user *) buffer) + len))
2022 return -EFAULT;
2023 len++;
2024 }
2025 *lenp = len;
2026 *ppos += len;
2027 }
2028 return 0;
2029}
2030
Linus Torvalds1da177e2005-04-16 15:20:36 -07002031/**
2032 * proc_dostring - read a string sysctl
2033 * @table: the sysctl table
2034 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002035 * @buffer: the user buffer
2036 * @lenp: the size of the user buffer
2037 * @ppos: file position
2038 *
2039 * Reads/writes a string from/to the user buffer. If the kernel
2040 * buffer provided is not large enough to hold the string, the
2041 * string is truncated. The copied string is %NULL-terminated.
2042 * If the string is being read by the user process, it is copied
2043 * and a newline '\n' is added. It is truncated if the buffer is
2044 * not large enough.
2045 *
2046 * Returns 0 on success.
2047 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002048int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002049 void __user *buffer, size_t *lenp, loff_t *ppos)
2050{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002051 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002052 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002053}
2054
Linus Torvalds1da177e2005-04-16 15:20:36 -07002055
2056static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2057 int *valp,
2058 int write, void *data)
2059{
2060 if (write) {
2061 *valp = *negp ? -*lvalp : *lvalp;
2062 } else {
2063 int val = *valp;
2064 if (val < 0) {
2065 *negp = -1;
2066 *lvalp = (unsigned long)-val;
2067 } else {
2068 *negp = 0;
2069 *lvalp = (unsigned long)val;
2070 }
2071 }
2072 return 0;
2073}
2074
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002075static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002076 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002077 size_t *lenp, loff_t *ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002078 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2079 int write, void *data),
2080 void *data)
2081{
2082#define TMPBUFLEN 21
Sukanto Ghosh7338f292009-06-17 16:27:50 -07002083 int *i, vleft, first = 1, neg;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002084 unsigned long lval;
2085 size_t left, len;
2086
2087 char buf[TMPBUFLEN], *p;
2088 char __user *s = buffer;
2089
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002090 if (!tbl_data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002091 (*ppos && !write)) {
2092 *lenp = 0;
2093 return 0;
2094 }
2095
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002096 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002097 vleft = table->maxlen / sizeof(*i);
2098 left = *lenp;
2099
2100 if (!conv)
2101 conv = do_proc_dointvec_conv;
2102
2103 for (; left && vleft--; i++, first=0) {
2104 if (write) {
2105 while (left) {
2106 char c;
2107 if (get_user(c, s))
2108 return -EFAULT;
2109 if (!isspace(c))
2110 break;
2111 left--;
2112 s++;
2113 }
2114 if (!left)
2115 break;
2116 neg = 0;
2117 len = left;
2118 if (len > sizeof(buf) - 1)
2119 len = sizeof(buf) - 1;
2120 if (copy_from_user(buf, s, len))
2121 return -EFAULT;
2122 buf[len] = 0;
2123 p = buf;
2124 if (*p == '-' && left > 1) {
2125 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002126 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002127 }
2128 if (*p < '0' || *p > '9')
2129 break;
2130
2131 lval = simple_strtoul(p, &p, 0);
2132
2133 len = p-buf;
2134 if ((len < left) && *p && !isspace(*p))
2135 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002136 s += len;
2137 left -= len;
2138
2139 if (conv(&neg, &lval, i, 1, data))
2140 break;
2141 } else {
2142 p = buf;
2143 if (!first)
2144 *p++ = '\t';
2145
2146 if (conv(&neg, &lval, i, 0, data))
2147 break;
2148
2149 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2150 len = strlen(buf);
2151 if (len > left)
2152 len = left;
2153 if(copy_to_user(s, buf, len))
2154 return -EFAULT;
2155 left -= len;
2156 s += len;
2157 }
2158 }
2159
2160 if (!write && !first && left) {
2161 if(put_user('\n', s))
2162 return -EFAULT;
2163 left--, s++;
2164 }
2165 if (write) {
2166 while (left) {
2167 char c;
2168 if (get_user(c, s++))
2169 return -EFAULT;
2170 if (!isspace(c))
2171 break;
2172 left--;
2173 }
2174 }
2175 if (write && first)
2176 return -EINVAL;
2177 *lenp -= left;
2178 *ppos += *lenp;
2179 return 0;
2180#undef TMPBUFLEN
2181}
2182
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002183static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002184 void __user *buffer, size_t *lenp, loff_t *ppos,
2185 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2186 int write, void *data),
2187 void *data)
2188{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002189 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002190 buffer, lenp, ppos, conv, data);
2191}
2192
Linus Torvalds1da177e2005-04-16 15:20:36 -07002193/**
2194 * proc_dointvec - read a vector of integers
2195 * @table: the sysctl table
2196 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002197 * @buffer: the user buffer
2198 * @lenp: the size of the user buffer
2199 * @ppos: file position
2200 *
2201 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2202 * values from/to the user buffer, treated as an ASCII string.
2203 *
2204 * Returns 0 on success.
2205 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002206int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002207 void __user *buffer, size_t *lenp, loff_t *ppos)
2208{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002209 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002210 NULL,NULL);
2211}
2212
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002213/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002214 * Taint values can only be increased
2215 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002216 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002217static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002218 void __user *buffer, size_t *lenp, loff_t *ppos)
2219{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002220 struct ctl_table t;
2221 unsigned long tmptaint = get_taint();
2222 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002223
Bastian Blank91fcd412007-04-23 14:41:14 -07002224 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002225 return -EPERM;
2226
Andi Kleen25ddbb12008-10-15 22:01:41 -07002227 t = *table;
2228 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002229 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002230 if (err < 0)
2231 return err;
2232
2233 if (write) {
2234 /*
2235 * Poor man's atomic or. Not worth adding a primitive
2236 * to everyone's atomic.h for this
2237 */
2238 int i;
2239 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2240 if ((tmptaint >> i) & 1)
2241 add_taint(i);
2242 }
2243 }
2244
2245 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002246}
2247
Linus Torvalds1da177e2005-04-16 15:20:36 -07002248struct do_proc_dointvec_minmax_conv_param {
2249 int *min;
2250 int *max;
2251};
2252
2253static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2254 int *valp,
2255 int write, void *data)
2256{
2257 struct do_proc_dointvec_minmax_conv_param *param = data;
2258 if (write) {
2259 int val = *negp ? -*lvalp : *lvalp;
2260 if ((param->min && *param->min > val) ||
2261 (param->max && *param->max < val))
2262 return -EINVAL;
2263 *valp = val;
2264 } else {
2265 int val = *valp;
2266 if (val < 0) {
2267 *negp = -1;
2268 *lvalp = (unsigned long)-val;
2269 } else {
2270 *negp = 0;
2271 *lvalp = (unsigned long)val;
2272 }
2273 }
2274 return 0;
2275}
2276
2277/**
2278 * proc_dointvec_minmax - read a vector of integers with min/max values
2279 * @table: the sysctl table
2280 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002281 * @buffer: the user buffer
2282 * @lenp: the size of the user buffer
2283 * @ppos: file position
2284 *
2285 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2286 * values from/to the user buffer, treated as an ASCII string.
2287 *
2288 * This routine will ensure the values are within the range specified by
2289 * table->extra1 (min) and table->extra2 (max).
2290 *
2291 * Returns 0 on success.
2292 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002293int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002294 void __user *buffer, size_t *lenp, loff_t *ppos)
2295{
2296 struct do_proc_dointvec_minmax_conv_param param = {
2297 .min = (int *) table->extra1,
2298 .max = (int *) table->extra2,
2299 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002300 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002301 do_proc_dointvec_minmax_conv, &param);
2302}
2303
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002304static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002305 void __user *buffer,
2306 size_t *lenp, loff_t *ppos,
2307 unsigned long convmul,
2308 unsigned long convdiv)
2309{
2310#define TMPBUFLEN 21
2311 unsigned long *i, *min, *max, val;
2312 int vleft, first=1, neg;
2313 size_t len, left;
2314 char buf[TMPBUFLEN], *p;
2315 char __user *s = buffer;
2316
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002317 if (!data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002318 (*ppos && !write)) {
2319 *lenp = 0;
2320 return 0;
2321 }
2322
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002323 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002324 min = (unsigned long *) table->extra1;
2325 max = (unsigned long *) table->extra2;
2326 vleft = table->maxlen / sizeof(unsigned long);
2327 left = *lenp;
2328
2329 for (; left && vleft--; i++, min++, max++, first=0) {
2330 if (write) {
2331 while (left) {
2332 char c;
2333 if (get_user(c, s))
2334 return -EFAULT;
2335 if (!isspace(c))
2336 break;
2337 left--;
2338 s++;
2339 }
2340 if (!left)
2341 break;
2342 neg = 0;
2343 len = left;
2344 if (len > TMPBUFLEN-1)
2345 len = TMPBUFLEN-1;
2346 if (copy_from_user(buf, s, len))
2347 return -EFAULT;
2348 buf[len] = 0;
2349 p = buf;
2350 if (*p == '-' && left > 1) {
2351 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002352 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002353 }
2354 if (*p < '0' || *p > '9')
2355 break;
2356 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2357 len = p-buf;
2358 if ((len < left) && *p && !isspace(*p))
2359 break;
2360 if (neg)
2361 val = -val;
2362 s += len;
2363 left -= len;
2364
2365 if(neg)
2366 continue;
2367 if ((min && val < *min) || (max && val > *max))
2368 continue;
2369 *i = val;
2370 } else {
2371 p = buf;
2372 if (!first)
2373 *p++ = '\t';
2374 sprintf(p, "%lu", convdiv * (*i) / convmul);
2375 len = strlen(buf);
2376 if (len > left)
2377 len = left;
2378 if(copy_to_user(s, buf, len))
2379 return -EFAULT;
2380 left -= len;
2381 s += len;
2382 }
2383 }
2384
2385 if (!write && !first && left) {
2386 if(put_user('\n', s))
2387 return -EFAULT;
2388 left--, s++;
2389 }
2390 if (write) {
2391 while (left) {
2392 char c;
2393 if (get_user(c, s++))
2394 return -EFAULT;
2395 if (!isspace(c))
2396 break;
2397 left--;
2398 }
2399 }
2400 if (write && first)
2401 return -EINVAL;
2402 *lenp -= left;
2403 *ppos += *lenp;
2404 return 0;
2405#undef TMPBUFLEN
2406}
2407
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002408static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002409 void __user *buffer,
2410 size_t *lenp, loff_t *ppos,
2411 unsigned long convmul,
2412 unsigned long convdiv)
2413{
2414 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002415 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002416}
2417
Linus Torvalds1da177e2005-04-16 15:20:36 -07002418/**
2419 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2420 * @table: the sysctl table
2421 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002422 * @buffer: the user buffer
2423 * @lenp: the size of the user buffer
2424 * @ppos: file position
2425 *
2426 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2427 * values from/to the user buffer, treated as an ASCII string.
2428 *
2429 * This routine will ensure the values are within the range specified by
2430 * table->extra1 (min) and table->extra2 (max).
2431 *
2432 * Returns 0 on success.
2433 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002434int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002435 void __user *buffer, size_t *lenp, loff_t *ppos)
2436{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002437 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002438}
2439
2440/**
2441 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2442 * @table: the sysctl table
2443 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002444 * @buffer: the user buffer
2445 * @lenp: the size of the user buffer
2446 * @ppos: file position
2447 *
2448 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2449 * values from/to the user buffer, treated as an ASCII string. The values
2450 * are treated as milliseconds, and converted to jiffies when they are stored.
2451 *
2452 * This routine will ensure the values are within the range specified by
2453 * table->extra1 (min) and table->extra2 (max).
2454 *
2455 * Returns 0 on success.
2456 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002457int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002458 void __user *buffer,
2459 size_t *lenp, loff_t *ppos)
2460{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002461 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002462 lenp, ppos, HZ, 1000l);
2463}
2464
2465
2466static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2467 int *valp,
2468 int write, void *data)
2469{
2470 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002471 if (*lvalp > LONG_MAX / HZ)
2472 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002473 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2474 } else {
2475 int val = *valp;
2476 unsigned long lval;
2477 if (val < 0) {
2478 *negp = -1;
2479 lval = (unsigned long)-val;
2480 } else {
2481 *negp = 0;
2482 lval = (unsigned long)val;
2483 }
2484 *lvalp = lval / HZ;
2485 }
2486 return 0;
2487}
2488
2489static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2490 int *valp,
2491 int write, void *data)
2492{
2493 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002494 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2495 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002496 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2497 } else {
2498 int val = *valp;
2499 unsigned long lval;
2500 if (val < 0) {
2501 *negp = -1;
2502 lval = (unsigned long)-val;
2503 } else {
2504 *negp = 0;
2505 lval = (unsigned long)val;
2506 }
2507 *lvalp = jiffies_to_clock_t(lval);
2508 }
2509 return 0;
2510}
2511
2512static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2513 int *valp,
2514 int write, void *data)
2515{
2516 if (write) {
2517 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2518 } else {
2519 int val = *valp;
2520 unsigned long lval;
2521 if (val < 0) {
2522 *negp = -1;
2523 lval = (unsigned long)-val;
2524 } else {
2525 *negp = 0;
2526 lval = (unsigned long)val;
2527 }
2528 *lvalp = jiffies_to_msecs(lval);
2529 }
2530 return 0;
2531}
2532
2533/**
2534 * proc_dointvec_jiffies - read a vector of integers as seconds
2535 * @table: the sysctl table
2536 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002537 * @buffer: the user buffer
2538 * @lenp: the size of the user buffer
2539 * @ppos: file position
2540 *
2541 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2542 * values from/to the user buffer, treated as an ASCII string.
2543 * The values read are assumed to be in seconds, and are converted into
2544 * jiffies.
2545 *
2546 * Returns 0 on success.
2547 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002548int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002549 void __user *buffer, size_t *lenp, loff_t *ppos)
2550{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002551 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002552 do_proc_dointvec_jiffies_conv,NULL);
2553}
2554
2555/**
2556 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2557 * @table: the sysctl table
2558 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002559 * @buffer: the user buffer
2560 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002561 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002562 *
2563 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2564 * values from/to the user buffer, treated as an ASCII string.
2565 * The values read are assumed to be in 1/USER_HZ seconds, and
2566 * are converted into jiffies.
2567 *
2568 * Returns 0 on success.
2569 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002570int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571 void __user *buffer, size_t *lenp, loff_t *ppos)
2572{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002573 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002574 do_proc_dointvec_userhz_jiffies_conv,NULL);
2575}
2576
2577/**
2578 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2579 * @table: the sysctl table
2580 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002581 * @buffer: the user buffer
2582 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002583 * @ppos: file position
2584 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002585 *
2586 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2587 * values from/to the user buffer, treated as an ASCII string.
2588 * The values read are assumed to be in 1/1000 seconds, and
2589 * are converted into jiffies.
2590 *
2591 * Returns 0 on success.
2592 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002593int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002594 void __user *buffer, size_t *lenp, loff_t *ppos)
2595{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002596 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002597 do_proc_dointvec_ms_jiffies_conv, NULL);
2598}
2599
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002600static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002601 void __user *buffer, size_t *lenp, loff_t *ppos)
2602{
2603 struct pid *new_pid;
2604 pid_t tmp;
2605 int r;
2606
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002607 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002608
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002609 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002610 lenp, ppos, NULL, NULL);
2611 if (r || !write)
2612 return r;
2613
2614 new_pid = find_get_pid(tmp);
2615 if (!new_pid)
2616 return -ESRCH;
2617
2618 put_pid(xchg(&cad_pid, new_pid));
2619 return 0;
2620}
2621
Linus Torvalds1da177e2005-04-16 15:20:36 -07002622#else /* CONFIG_PROC_FS */
2623
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002624int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002625 void __user *buffer, size_t *lenp, loff_t *ppos)
2626{
2627 return -ENOSYS;
2628}
2629
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002630int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631 void __user *buffer, size_t *lenp, loff_t *ppos)
2632{
2633 return -ENOSYS;
2634}
2635
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002636int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002637 void __user *buffer, size_t *lenp, loff_t *ppos)
2638{
2639 return -ENOSYS;
2640}
2641
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002642int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002643 void __user *buffer, size_t *lenp, loff_t *ppos)
2644{
2645 return -ENOSYS;
2646}
2647
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002648int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002649 void __user *buffer, size_t *lenp, loff_t *ppos)
2650{
2651 return -ENOSYS;
2652}
2653
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002654int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002655 void __user *buffer, size_t *lenp, loff_t *ppos)
2656{
2657 return -ENOSYS;
2658}
2659
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002660int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002661 void __user *buffer, size_t *lenp, loff_t *ppos)
2662{
2663 return -ENOSYS;
2664}
2665
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002666int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667 void __user *buffer,
2668 size_t *lenp, loff_t *ppos)
2669{
2670 return -ENOSYS;
2671}
2672
2673
2674#endif /* CONFIG_PROC_FS */
2675
Linus Torvalds1da177e2005-04-16 15:20:36 -07002676/*
2677 * No sense putting this after each symbol definition, twice,
2678 * exception granted :-)
2679 */
2680EXPORT_SYMBOL(proc_dointvec);
2681EXPORT_SYMBOL(proc_dointvec_jiffies);
2682EXPORT_SYMBOL(proc_dointvec_minmax);
2683EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2684EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2685EXPORT_SYMBOL(proc_dostring);
2686EXPORT_SYMBOL(proc_doulongvec_minmax);
2687EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2688EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002689EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002690EXPORT_SYMBOL(unregister_sysctl_table);