blob: a8fd10a9a501687f551ff4ea43d54832fa61764c [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
22#include <linux/mm.h>
23#include <linux/swap.h>
24#include <linux/slab.h>
25#include <linux/sysctl.h>
Dave Youngd33ed522010-03-10 15:23:59 -080026#include <linux/signal.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070028#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020030#include <linux/kmemcheck.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070031#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/init.h>
33#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010034#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030035#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/sysrq.h>
37#include <linux/highuid.h>
38#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020039#include <linux/ratelimit.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070041#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070042#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070043#include <linux/times.h>
44#include <linux/limits.h>
45#include <linux/dcache.h>
46#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070047#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080048#include <linux/nfs_fs.h>
49#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070050#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020051#include <linux/ftrace.h>
David Howells12e22c52009-04-03 16:42:35 +010052#include <linux/slow-work.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020053#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050054#include <linux/kprobes.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56#include <asm/uaccess.h>
57#include <asm/processor.h>
58
Andi Kleen29cbc782006-09-30 01:47:55 +020059#ifdef CONFIG_X86
60#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010061#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010062#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020063#endif
64
Eric W. Biederman7058cb02007-10-18 03:05:58 -070065
Linus Torvalds1da177e2005-04-16 15:20:36 -070066#if defined(CONFIG_SYSCTL)
67
68/* External variables not in a header file. */
Linus Torvalds1da177e2005-04-16 15:20:36 -070069extern int sysctl_overcommit_memory;
70extern int sysctl_overcommit_ratio;
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -070071extern int sysctl_panic_on_oom;
David Rientjesfe071d72007-10-16 23:25:56 -070072extern int sysctl_oom_kill_allocating_task;
David Rientjesfef1bdd2008-02-07 00:14:07 -080073extern int sysctl_oom_dump_tasks;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070076extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -070078extern unsigned int core_pipe_limit;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079extern int pid_max;
80extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -070081extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -080082extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -080083extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +020084extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +010085extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -040086extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +000087#ifndef CONFIG_MMU
88extern int sysctl_nr_trim_pages;
89#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -070090#ifdef CONFIG_RCU_TORTURE_TEST
91extern int rcutorture_runnable;
92#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
Jens Axboecb684b52009-09-15 21:53:11 +020093#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +020094extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +020095#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070096
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070097/* Constants used for minimum and maximum */
Bron Gondwana195cf4532008-02-04 22:29:20 -080098#ifdef CONFIG_DETECT_SOFTLOCKUP
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070099static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200100static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700101#endif
102
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700103static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700104static int __maybe_unused one = 1;
105static int __maybe_unused two = 2;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800106static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700107static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700108#ifdef CONFIG_PRINTK
109static int ten_thousand = 10000;
110#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700111
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700112/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
113static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
114
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
116static int maxolduid = 65535;
117static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800118static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
120static int ngroups_max = NGROUPS_MAX;
121
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200122#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123extern char modprobe_path[];
Kees Cook3d433212009-04-02 15:49:29 -0700124extern int modules_disabled;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126#ifdef CONFIG_CHR_DEV_SG
127extern int sg_big_buff;
128#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129
David S. Miller72c57ed2008-09-11 23:29:54 -0700130#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700131#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132#endif
133
David S. Miller08714202008-11-16 23:49:24 -0800134#ifdef CONFIG_SPARC64
135extern int sysctl_tsb_ratio;
136#endif
137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138#ifdef __hppa__
139extern int pwrsw_enabled;
140extern int unaligned_enabled;
141#endif
142
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800143#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144#ifdef CONFIG_MATHEMU
145extern int sysctl_ieee_emulation_warnings;
146#endif
147extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700148extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149#endif
150
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151#ifdef CONFIG_BSD_PROCESS_ACCT
152extern int acct_parm[];
153#endif
154
Jes Sorensend2b176e2006-02-28 09:42:23 -0800155#ifdef CONFIG_IA64
156extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800157extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800158#endif
159
Ingo Molnar3fff4c42009-09-22 16:18:09 +0200160extern struct ratelimit_state printk_ratelimit_state;
161
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700162#ifdef CONFIG_RT_MUTEXES
163extern int max_lock_depth;
164#endif
165
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700166#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700167static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700168 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700169static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800170 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700171#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700172
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700173static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100174static struct ctl_table_root sysctl_table_root;
175static struct ctl_table_header root_table_header = {
Al Virob380b0d2008-09-04 17:05:57 +0100176 .count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100177 .ctl_table = root_table,
Al Viro73455092008-07-14 21:22:20 -0400178 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100179 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400180 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100181};
182static struct ctl_table_root sysctl_table_root = {
183 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400184 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100185};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700187static struct ctl_table kern_table[];
188static struct ctl_table vm_table[];
189static struct ctl_table fs_table[];
190static struct ctl_table debug_table[];
191static struct ctl_table dev_table[];
192extern struct ctl_table random_table[];
Amy Griffis2d9048e2006-06-01 13:10:59 -0700193#ifdef CONFIG_INOTIFY_USER
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700194extern struct ctl_table inotify_table[];
Robert Love0399cb02005-07-13 12:38:18 -0400195#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -0800196#ifdef CONFIG_EPOLL
197extern struct ctl_table epoll_table[];
198#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
200#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
201int sysctl_legacy_va_layout;
202#endif
203
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700204extern int prove_locking;
205extern int lock_stat;
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800206
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207/* The default sysctl tables: */
208
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700209static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 .procname = "kernel",
212 .mode = 0555,
213 .child = kern_table,
214 },
215 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 .procname = "vm",
217 .mode = 0555,
218 .child = vm_table,
219 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 .procname = "fs",
222 .mode = 0555,
223 .child = fs_table,
224 },
225 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 .procname = "debug",
227 .mode = 0555,
228 .child = debug_table,
229 },
230 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 .procname = "dev",
232 .mode = 0555,
233 .child = dev_table,
234 },
Andrew Morton2be7fe02007-07-15 23:41:21 -0700235/*
236 * NOTE: do not add new entries to this table unless you have read
237 * Documentation/sysctl/ctl_unnumbered.txt
238 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700239 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240};
241
Ingo Molnar77e54a12007-07-09 18:52:00 +0200242#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100243static int min_sched_granularity_ns = 100000; /* 100 usecs */
244static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
245static int min_wakeup_granularity_ns; /* 0 usecs */
246static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100247static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
248static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100249static int min_sched_shares_ratelimit = 100000; /* 100 usec */
250static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200251#endif
252
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700253static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200254 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200255 .procname = "sched_child_runs_first",
256 .data = &sysctl_sched_child_runs_first,
257 .maxlen = sizeof(unsigned int),
258 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800259 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200260 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200261#ifdef CONFIG_SCHED_DEBUG
262 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100263 .procname = "sched_min_granularity_ns",
264 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200265 .maxlen = sizeof(unsigned int),
266 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800267 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100268 .extra1 = &min_sched_granularity_ns,
269 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200270 },
271 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200272 .procname = "sched_latency_ns",
273 .data = &sysctl_sched_latency,
274 .maxlen = sizeof(unsigned int),
275 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800276 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200277 .extra1 = &min_sched_granularity_ns,
278 .extra2 = &max_sched_granularity_ns,
279 },
280 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200281 .procname = "sched_wakeup_granularity_ns",
282 .data = &sysctl_sched_wakeup_granularity,
283 .maxlen = sizeof(unsigned int),
284 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800285 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200286 .extra1 = &min_wakeup_granularity_ns,
287 .extra2 = &max_wakeup_granularity_ns,
288 },
289 {
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200290 .procname = "sched_shares_ratelimit",
291 .data = &sysctl_sched_shares_ratelimit,
292 .maxlen = sizeof(unsigned int),
293 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800294 .proc_handler = sched_proc_update_handler,
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100295 .extra1 = &min_sched_shares_ratelimit,
296 .extra2 = &max_sched_shares_ratelimit,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200297 },
298 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100299 .procname = "sched_tunable_scaling",
300 .data = &sysctl_sched_tunable_scaling,
301 .maxlen = sizeof(enum sched_tunable_scaling),
302 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800303 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100304 .extra1 = &min_sched_tunable_scaling,
305 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200306 },
307 {
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200308 .procname = "sched_shares_thresh",
309 .data = &sysctl_sched_shares_thresh,
310 .maxlen = sizeof(unsigned int),
311 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800312 .proc_handler = proc_dointvec_minmax,
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200313 .extra1 = &zero,
314 },
315 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200316 .procname = "sched_migration_cost",
317 .data = &sysctl_sched_migration_cost,
318 .maxlen = sizeof(unsigned int),
319 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800320 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200321 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100322 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100323 .procname = "sched_nr_migrate",
324 .data = &sysctl_sched_nr_migrate,
325 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100326 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800327 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100328 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530329 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200330 .procname = "sched_time_avg",
331 .data = &sysctl_sched_time_avg,
332 .maxlen = sizeof(unsigned int),
333 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800334 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200335 },
336 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530337 .procname = "timer_migration",
338 .data = &sysctl_timer_migration,
339 .maxlen = sizeof(unsigned int),
340 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800341 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530342 .extra1 = &zero,
343 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530344 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200345#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200346 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100347 .procname = "sched_rt_period_us",
348 .data = &sysctl_sched_rt_period,
349 .maxlen = sizeof(unsigned int),
350 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800351 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100352 },
353 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100354 .procname = "sched_rt_runtime_us",
355 .data = &sysctl_sched_rt_runtime,
356 .maxlen = sizeof(int),
357 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800358 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100359 },
360 {
Ingo Molnar1799e352007-09-19 23:34:46 +0200361 .procname = "sched_compat_yield",
362 .data = &sysctl_sched_compat_yield,
363 .maxlen = sizeof(unsigned int),
364 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800365 .proc_handler = proc_dointvec,
Ingo Molnar1799e352007-09-19 23:34:46 +0200366 },
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700367#ifdef CONFIG_PROVE_LOCKING
368 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700369 .procname = "prove_locking",
370 .data = &prove_locking,
371 .maxlen = sizeof(int),
372 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800373 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700374 },
375#endif
376#ifdef CONFIG_LOCK_STAT
377 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700378 .procname = "lock_stat",
379 .data = &lock_stat,
380 .maxlen = sizeof(int),
381 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800382 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700383 },
384#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200385 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 .procname = "panic",
387 .data = &panic_timeout,
388 .maxlen = sizeof(int),
389 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800390 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 },
392 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 .procname = "core_uses_pid",
394 .data = &core_uses_pid,
395 .maxlen = sizeof(int),
396 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800397 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 },
399 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 .procname = "core_pattern",
401 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700402 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800404 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 },
Neil Hormana2939802009-09-23 15:56:56 -0700406 {
Neil Hormana2939802009-09-23 15:56:56 -0700407 .procname = "core_pipe_limit",
408 .data = &core_pipe_limit,
409 .maxlen = sizeof(unsigned int),
410 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800411 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700412 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800413#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700416 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800417 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800418 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800420#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100421#ifdef CONFIG_LATENCYTOP
422 {
423 .procname = "latencytop",
424 .data = &latencytop_enabled,
425 .maxlen = sizeof(int),
426 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800427 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100428 },
429#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430#ifdef CONFIG_BLK_DEV_INITRD
431 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 .procname = "real-root-dev",
433 .data = &real_root_dev,
434 .maxlen = sizeof(int),
435 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800436 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 },
438#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700439 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700440 .procname = "print-fatal-signals",
441 .data = &print_fatal_signals,
442 .maxlen = sizeof(int),
443 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800444 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700445 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700446#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 .procname = "reboot-cmd",
449 .data = reboot_command,
450 .maxlen = 256,
451 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800452 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 },
454 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 .procname = "stop-a",
456 .data = &stop_a_enabled,
457 .maxlen = sizeof (int),
458 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800459 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 },
461 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 .procname = "scons-poweroff",
463 .data = &scons_pwroff,
464 .maxlen = sizeof (int),
465 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800466 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 },
468#endif
David S. Miller08714202008-11-16 23:49:24 -0800469#ifdef CONFIG_SPARC64
470 {
David S. Miller08714202008-11-16 23:49:24 -0800471 .procname = "tsb-ratio",
472 .data = &sysctl_tsb_ratio,
473 .maxlen = sizeof (int),
474 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800475 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800476 },
477#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478#ifdef __hppa__
479 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 .procname = "soft-power",
481 .data = &pwrsw_enabled,
482 .maxlen = sizeof (int),
483 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800484 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 },
486 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 .procname = "unaligned-trap",
488 .data = &unaligned_enabled,
489 .maxlen = sizeof (int),
490 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800491 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 },
493#endif
494 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 .procname = "ctrl-alt-del",
496 .data = &C_A_D,
497 .maxlen = sizeof(int),
498 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800499 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400501#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200502 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200503 .procname = "ftrace_enabled",
504 .data = &ftrace_enabled,
505 .maxlen = sizeof(int),
506 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800507 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200508 },
509#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500510#ifdef CONFIG_STACK_TRACER
511 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500512 .procname = "stack_tracer_enabled",
513 .data = &stack_tracer_enabled,
514 .maxlen = sizeof(int),
515 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800516 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500517 },
518#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400519#ifdef CONFIG_TRACING
520 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100521 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400522 .data = &ftrace_dump_on_oops,
523 .maxlen = sizeof(int),
524 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800525 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400526 },
527#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200528#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 .procname = "modprobe",
531 .data = &modprobe_path,
532 .maxlen = KMOD_PATH_LEN,
533 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800534 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 },
Kees Cook3d433212009-04-02 15:49:29 -0700536 {
Kees Cook3d433212009-04-02 15:49:29 -0700537 .procname = "modules_disabled",
538 .data = &modules_disabled,
539 .maxlen = sizeof(int),
540 .mode = 0644,
541 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800542 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700543 .extra1 = &one,
544 .extra2 = &one,
545 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546#endif
Andrew Morton57ae2502006-06-23 02:05:47 -0700547#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100550 .data = &uevent_helper,
551 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800553 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 },
555#endif
556#ifdef CONFIG_CHR_DEV_SG
557 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 .procname = "sg-big-buff",
559 .data = &sg_big_buff,
560 .maxlen = sizeof (int),
561 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800562 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 },
564#endif
565#ifdef CONFIG_BSD_PROCESS_ACCT
566 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 .procname = "acct",
568 .data = &acct_parm,
569 .maxlen = 3*sizeof(int),
570 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800571 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 },
573#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574#ifdef CONFIG_MAGIC_SYSRQ
575 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800577 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 .maxlen = sizeof (int),
579 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800580 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 },
582#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700583#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700586 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 .maxlen = sizeof (int),
588 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800589 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700591#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 .procname = "threads-max",
594 .data = &max_threads,
595 .maxlen = sizeof(int),
596 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800597 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 },
599 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 .procname = "random",
601 .mode = 0555,
602 .child = random_table,
603 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 .procname = "overflowuid",
606 .data = &overflowuid,
607 .maxlen = sizeof(int),
608 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800609 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 .extra1 = &minolduid,
611 .extra2 = &maxolduid,
612 },
613 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 .procname = "overflowgid",
615 .data = &overflowgid,
616 .maxlen = sizeof(int),
617 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800618 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 .extra1 = &minolduid,
620 .extra2 = &maxolduid,
621 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800622#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623#ifdef CONFIG_MATHEMU
624 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 .procname = "ieee_emulation_warnings",
626 .data = &sysctl_ieee_emulation_warnings,
627 .maxlen = sizeof(int),
628 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800629 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 },
631#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 .procname = "userprocess_debug",
634 .data = &sysctl_userprocess_debug,
635 .maxlen = sizeof(int),
636 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800637 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 },
639#endif
640 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 .procname = "pid_max",
642 .data = &pid_max,
643 .maxlen = sizeof (int),
644 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800645 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 .extra1 = &pid_max_min,
647 .extra2 = &pid_max_max,
648 },
649 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 .procname = "panic_on_oops",
651 .data = &panic_on_oops,
652 .maxlen = sizeof(int),
653 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800654 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800656#if defined CONFIG_PRINTK
657 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800658 .procname = "printk",
659 .data = &console_loglevel,
660 .maxlen = 4*sizeof(int),
661 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800662 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800663 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700666 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 .maxlen = sizeof(int),
668 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800669 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 },
671 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700673 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 .maxlen = sizeof(int),
675 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800676 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 },
Dave Youngaf913222009-09-22 16:43:33 -0700678 {
Dave Youngaf913222009-09-22 16:43:33 -0700679 .procname = "printk_delay",
680 .data = &printk_delay_msec,
681 .maxlen = sizeof(int),
682 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800683 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700684 .extra1 = &zero,
685 .extra2 = &ten_thousand,
686 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800687#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 .procname = "ngroups_max",
690 .data = &ngroups_max,
691 .maxlen = sizeof (int),
692 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800693 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 },
695#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
696 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 .procname = "unknown_nmi_panic",
698 .data = &unknown_nmi_panic,
699 .maxlen = sizeof (int),
700 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800701 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 },
Don Zickus407984f2006-09-26 10:52:27 +0200703 {
Don Zickus407984f2006-09-26 10:52:27 +0200704 .procname = "nmi_watchdog",
705 .data = &nmi_watchdog_enabled,
706 .maxlen = sizeof (int),
707 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800708 .proc_handler = proc_nmi_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 },
710#endif
711#if defined(CONFIG_X86)
712 {
Don Zickus8da5add2006-09-26 10:52:27 +0200713 .procname = "panic_on_unrecovered_nmi",
714 .data = &panic_on_unrecovered_nmi,
715 .maxlen = sizeof(int),
716 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800717 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200718 },
719 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700720 .procname = "panic_on_io_nmi",
721 .data = &panic_on_io_nmi,
722 .maxlen = sizeof(int),
723 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800724 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700725 },
726 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 .procname = "bootloader_type",
728 .data = &bootloader_type,
729 .maxlen = sizeof (int),
730 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800731 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100733 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700734 .procname = "bootloader_version",
735 .data = &bootloader_version,
736 .maxlen = sizeof (int),
737 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800738 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700739 },
740 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100741 .procname = "kstack_depth_to_print",
742 .data = &kstack_depth_to_print,
743 .maxlen = sizeof(int),
744 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800745 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100746 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100747 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100748 .procname = "io_delay_type",
749 .data = &io_delay_type,
750 .maxlen = sizeof(int),
751 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800752 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100753 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800755#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 .procname = "randomize_va_space",
758 .data = &randomize_va_space,
759 .maxlen = sizeof(int),
760 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800761 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800763#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800764#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700765 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700766 .procname = "spin_retry",
767 .data = &spin_retry,
768 .maxlen = sizeof (int),
769 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800770 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700771 },
772#endif
Len Brown673d5b42007-07-28 03:33:16 -0400773#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800774 {
Pavel Machekc255d842006-02-20 18:27:58 -0800775 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700776 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800777 .maxlen = sizeof (unsigned long),
778 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800779 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800780 },
781#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800782#ifdef CONFIG_IA64
783 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800784 .procname = "ignore-unaligned-usertrap",
785 .data = &no_unaligned_warning,
786 .maxlen = sizeof (int),
787 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800788 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800789 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800790 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800791 .procname = "unaligned-dump-stack",
792 .data = &unaligned_dump_stack,
793 .maxlen = sizeof (int),
794 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800795 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800796 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800797#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700798#ifdef CONFIG_DETECT_SOFTLOCKUP
799 {
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200800 .procname = "softlockup_panic",
801 .data = &softlockup_panic,
802 .maxlen = sizeof(int),
803 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800804 .proc_handler = proc_dointvec_minmax,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200805 .extra1 = &zero,
806 .extra2 = &one,
807 },
808 {
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700809 .procname = "softlockup_thresh",
810 .data = &softlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200811 .maxlen = sizeof(int),
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700812 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800813 .proc_handler = proc_dosoftlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200814 .extra1 = &neg_one,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700815 .extra2 = &sixty,
816 },
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800817#endif
818#ifdef CONFIG_DETECT_HUNG_TASK
819 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800820 .procname = "hung_task_panic",
821 .data = &sysctl_hung_task_panic,
822 .maxlen = sizeof(int),
823 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800824 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800825 .extra1 = &zero,
826 .extra2 = &one,
827 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100828 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100829 .procname = "hung_task_check_count",
830 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100831 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100832 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800833 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100834 },
835 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100836 .procname = "hung_task_timeout_secs",
837 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100838 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100839 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800840 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100841 },
842 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100843 .procname = "hung_task_warnings",
844 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100845 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100846 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800847 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100848 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700849#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200850#ifdef CONFIG_COMPAT
851 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200852 .procname = "compat-log",
853 .data = &compat_log,
854 .maxlen = sizeof (int),
855 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800856 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200857 },
858#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700859#ifdef CONFIG_RT_MUTEXES
860 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700861 .procname = "max_lock_depth",
862 .data = &max_lock_depth,
863 .maxlen = sizeof(int),
864 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800865 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700866 },
867#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700868 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700869 .procname = "poweroff_cmd",
870 .data = &poweroff_cmd,
871 .maxlen = POWEROFF_CMD_PATH_LEN,
872 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800873 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700874 },
David Howells0b77f5b2008-04-29 01:01:32 -0700875#ifdef CONFIG_KEYS
876 {
David Howells0b77f5b2008-04-29 01:01:32 -0700877 .procname = "keys",
878 .mode = 0555,
879 .child = key_sysctls,
880 },
881#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700882#ifdef CONFIG_RCU_TORTURE_TEST
883 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700884 .procname = "rcutorture_runnable",
885 .data = &rcutorture_runnable,
886 .maxlen = sizeof(int),
887 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800888 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700889 },
890#endif
David Howells12e22c52009-04-03 16:42:35 +0100891#ifdef CONFIG_SLOW_WORK
892 {
David Howells12e22c52009-04-03 16:42:35 +0100893 .procname = "slow-work",
894 .mode = 0555,
895 .child = slow_work_sysctls,
896 },
897#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200898#ifdef CONFIG_PERF_EVENTS
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200899 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200900 .procname = "perf_event_paranoid",
901 .data = &sysctl_perf_event_paranoid,
902 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200903 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800904 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200905 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200906 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200907 .procname = "perf_event_mlock_kb",
908 .data = &sysctl_perf_event_mlock,
909 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200910 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800911 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200912 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200913 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200914 .procname = "perf_event_max_sample_rate",
915 .data = &sysctl_perf_event_sample_rate,
916 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200917 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800918 .proc_handler = proc_dointvec,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200919 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200920#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200921#ifdef CONFIG_KMEMCHECK
922 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200923 .procname = "kmemcheck",
924 .data = &kmemcheck_enabled,
925 .maxlen = sizeof(int),
926 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800927 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +0200928 },
929#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200930#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200931 {
Jens Axboe5e605b62009-08-05 09:07:21 +0200932 .procname = "blk_iopoll",
933 .data = &blk_iopoll_enabled,
934 .maxlen = sizeof(int),
935 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800936 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +0200937 },
Jens Axboecb684b52009-09-15 21:53:11 +0200938#endif
Andrew Mortoned2c12f2007-07-19 01:50:35 -0700939/*
940 * NOTE: do not add new entries to this table unless you have read
941 * Documentation/sysctl/ctl_unnumbered.txt
942 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700943 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944};
945
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700946static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948 .procname = "overcommit_memory",
949 .data = &sysctl_overcommit_memory,
950 .maxlen = sizeof(sysctl_overcommit_memory),
951 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800952 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953 },
954 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700955 .procname = "panic_on_oom",
956 .data = &sysctl_panic_on_oom,
957 .maxlen = sizeof(sysctl_panic_on_oom),
958 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800959 .proc_handler = proc_dointvec,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700960 },
961 {
David Rientjesfe071d72007-10-16 23:25:56 -0700962 .procname = "oom_kill_allocating_task",
963 .data = &sysctl_oom_kill_allocating_task,
964 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
965 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800966 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -0700967 },
968 {
David Rientjesfef1bdd2008-02-07 00:14:07 -0800969 .procname = "oom_dump_tasks",
970 .data = &sysctl_oom_dump_tasks,
971 .maxlen = sizeof(sysctl_oom_dump_tasks),
972 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800973 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -0800974 },
975 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700976 .procname = "overcommit_ratio",
977 .data = &sysctl_overcommit_ratio,
978 .maxlen = sizeof(sysctl_overcommit_ratio),
979 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800980 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700981 },
982 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700983 .procname = "page-cluster",
984 .data = &page_cluster,
985 .maxlen = sizeof(int),
986 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800987 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700988 },
989 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990 .procname = "dirty_background_ratio",
991 .data = &dirty_background_ratio,
992 .maxlen = sizeof(dirty_background_ratio),
993 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800994 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995 .extra1 = &zero,
996 .extra2 = &one_hundred,
997 },
998 {
David Rientjes2da02992009-01-06 14:39:31 -0800999 .procname = "dirty_background_bytes",
1000 .data = &dirty_background_bytes,
1001 .maxlen = sizeof(dirty_background_bytes),
1002 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001003 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001004 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001005 },
1006 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001007 .procname = "dirty_ratio",
1008 .data = &vm_dirty_ratio,
1009 .maxlen = sizeof(vm_dirty_ratio),
1010 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001011 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012 .extra1 = &zero,
1013 .extra2 = &one_hundred,
1014 },
1015 {
David Rientjes2da02992009-01-06 14:39:31 -08001016 .procname = "dirty_bytes",
1017 .data = &vm_dirty_bytes,
1018 .maxlen = sizeof(vm_dirty_bytes),
1019 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001020 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001021 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001022 },
1023 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001024 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001025 .data = &dirty_writeback_interval,
1026 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001028 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001029 },
1030 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001031 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001032 .data = &dirty_expire_interval,
1033 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001035 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001036 },
1037 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038 .procname = "nr_pdflush_threads",
1039 .data = &nr_pdflush_threads,
1040 .maxlen = sizeof nr_pdflush_threads,
1041 .mode = 0444 /* read-only*/,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001042 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043 },
1044 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001045 .procname = "swappiness",
1046 .data = &vm_swappiness,
1047 .maxlen = sizeof(vm_swappiness),
1048 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001049 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001050 .extra1 = &zero,
1051 .extra2 = &one_hundred,
1052 },
1053#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001054 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001056 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001057 .maxlen = sizeof(unsigned long),
1058 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001059 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060 .extra1 = (void *)&hugetlb_zero,
1061 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001062 },
1063#ifdef CONFIG_NUMA
1064 {
1065 .procname = "nr_hugepages_mempolicy",
1066 .data = NULL,
1067 .maxlen = sizeof(unsigned long),
1068 .mode = 0644,
1069 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1070 .extra1 = (void *)&hugetlb_zero,
1071 .extra2 = (void *)&hugetlb_infinity,
1072 },
1073#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001074 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001075 .procname = "hugetlb_shm_group",
1076 .data = &sysctl_hugetlb_shm_group,
1077 .maxlen = sizeof(gid_t),
1078 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001079 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080 },
Mel Gorman396faf02007-07-17 04:03:13 -07001081 {
Mel Gorman396faf02007-07-17 04:03:13 -07001082 .procname = "hugepages_treat_as_movable",
1083 .data = &hugepages_treat_as_movable,
1084 .maxlen = sizeof(int),
1085 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001086 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001087 },
Adam Litke54f9f802007-10-16 01:26:20 -07001088 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001089 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001090 .data = NULL,
1091 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001092 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001093 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001094 .extra1 = (void *)&hugetlb_zero,
1095 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001096 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097#endif
1098 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099 .procname = "lowmem_reserve_ratio",
1100 .data = &sysctl_lowmem_reserve_ratio,
1101 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1102 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001103 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104 },
1105 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001106 .procname = "drop_caches",
1107 .data = &sysctl_drop_caches,
1108 .maxlen = sizeof(int),
1109 .mode = 0644,
1110 .proc_handler = drop_caches_sysctl_handler,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001111 },
1112 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001113 .procname = "min_free_kbytes",
1114 .data = &min_free_kbytes,
1115 .maxlen = sizeof(min_free_kbytes),
1116 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001117 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001118 .extra1 = &zero,
1119 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001120 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001121 .procname = "percpu_pagelist_fraction",
1122 .data = &percpu_pagelist_fraction,
1123 .maxlen = sizeof(percpu_pagelist_fraction),
1124 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001125 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001126 .extra1 = &min_percpu_pagelist_fract,
1127 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128#ifdef CONFIG_MMU
1129 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001130 .procname = "max_map_count",
1131 .data = &sysctl_max_map_count,
1132 .maxlen = sizeof(sysctl_max_map_count),
1133 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001134 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001135 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001137#else
1138 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001139 .procname = "nr_trim_pages",
1140 .data = &sysctl_nr_trim_pages,
1141 .maxlen = sizeof(sysctl_nr_trim_pages),
1142 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001143 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001144 .extra1 = &zero,
1145 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001146#endif
1147 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148 .procname = "laptop_mode",
1149 .data = &laptop_mode,
1150 .maxlen = sizeof(laptop_mode),
1151 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001152 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001153 },
1154 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001155 .procname = "block_dump",
1156 .data = &block_dump,
1157 .maxlen = sizeof(block_dump),
1158 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001159 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001160 .extra1 = &zero,
1161 },
1162 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163 .procname = "vfs_cache_pressure",
1164 .data = &sysctl_vfs_cache_pressure,
1165 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1166 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001167 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168 .extra1 = &zero,
1169 },
1170#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1171 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001172 .procname = "legacy_va_layout",
1173 .data = &sysctl_legacy_va_layout,
1174 .maxlen = sizeof(sysctl_legacy_va_layout),
1175 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001176 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177 .extra1 = &zero,
1178 },
1179#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001180#ifdef CONFIG_NUMA
1181 {
Christoph Lameter17436602006-01-18 17:42:32 -08001182 .procname = "zone_reclaim_mode",
1183 .data = &zone_reclaim_mode,
1184 .maxlen = sizeof(zone_reclaim_mode),
1185 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001186 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001187 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001188 },
Christoph Lameter96146342006-07-03 00:24:13 -07001189 {
Christoph Lameter96146342006-07-03 00:24:13 -07001190 .procname = "min_unmapped_ratio",
1191 .data = &sysctl_min_unmapped_ratio,
1192 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1193 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001194 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001195 .extra1 = &zero,
1196 .extra2 = &one_hundred,
1197 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001198 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001199 .procname = "min_slab_ratio",
1200 .data = &sysctl_min_slab_ratio,
1201 .maxlen = sizeof(sysctl_min_slab_ratio),
1202 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001203 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001204 .extra1 = &zero,
1205 .extra2 = &one_hundred,
1206 },
Christoph Lameter17436602006-01-18 17:42:32 -08001207#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001208#ifdef CONFIG_SMP
1209 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001210 .procname = "stat_interval",
1211 .data = &sysctl_stat_interval,
1212 .maxlen = sizeof(sysctl_stat_interval),
1213 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001214 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001215 },
1216#endif
David Howells6e141542009-12-15 19:27:45 +00001217#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001218 {
Eric Parised032182007-06-28 15:55:21 -04001219 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001220 .data = &dac_mmap_min_addr,
1221 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001222 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001223 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001224 },
David Howells6e141542009-12-15 19:27:45 +00001225#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001226#ifdef CONFIG_NUMA
1227 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001228 .procname = "numa_zonelist_order",
1229 .data = &numa_zonelist_order,
1230 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1231 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001232 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001233 },
1234#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001235#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001236 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001237 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001238 .procname = "vdso_enabled",
1239 .data = &vdso_enabled,
1240 .maxlen = sizeof(vdso_enabled),
1241 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001242 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001243 .extra1 = &zero,
1244 },
1245#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001246#ifdef CONFIG_HIGHMEM
1247 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001248 .procname = "highmem_is_dirtyable",
1249 .data = &vm_highmem_is_dirtyable,
1250 .maxlen = sizeof(vm_highmem_is_dirtyable),
1251 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001252 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001253 .extra1 = &zero,
1254 .extra2 = &one,
1255 },
1256#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001257 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001258 .procname = "scan_unevictable_pages",
1259 .data = &scan_unevictable_pages,
1260 .maxlen = sizeof(scan_unevictable_pages),
1261 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001262 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001263 },
Andi Kleen6a460792009-09-16 11:50:15 +02001264#ifdef CONFIG_MEMORY_FAILURE
1265 {
Andi Kleen6a460792009-09-16 11:50:15 +02001266 .procname = "memory_failure_early_kill",
1267 .data = &sysctl_memory_failure_early_kill,
1268 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1269 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001270 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001271 .extra1 = &zero,
1272 .extra2 = &one,
1273 },
1274 {
Andi Kleen6a460792009-09-16 11:50:15 +02001275 .procname = "memory_failure_recovery",
1276 .data = &sysctl_memory_failure_recovery,
1277 .maxlen = sizeof(sysctl_memory_failure_recovery),
1278 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001279 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001280 .extra1 = &zero,
1281 .extra2 = &one,
1282 },
1283#endif
1284
Andrew Morton2be7fe02007-07-15 23:41:21 -07001285/*
1286 * NOTE: do not add new entries to this table unless you have read
1287 * Documentation/sysctl/ctl_unnumbered.txt
1288 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001289 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001290};
1291
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001292#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001293static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001294 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001295};
1296#endif
1297
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001298static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001299 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300 .procname = "inode-nr",
1301 .data = &inodes_stat,
1302 .maxlen = 2*sizeof(int),
1303 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001304 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001305 },
1306 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001307 .procname = "inode-state",
1308 .data = &inodes_stat,
1309 .maxlen = 7*sizeof(int),
1310 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001311 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312 },
1313 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001314 .procname = "file-nr",
1315 .data = &files_stat,
1316 .maxlen = 3*sizeof(int),
1317 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001318 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001319 },
1320 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001321 .procname = "file-max",
1322 .data = &files_stat.max_files,
1323 .maxlen = sizeof(int),
1324 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001325 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001326 },
1327 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001328 .procname = "nr_open",
1329 .data = &sysctl_nr_open,
1330 .maxlen = sizeof(int),
1331 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001332 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001333 .extra1 = &sysctl_nr_open_min,
1334 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001335 },
1336 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337 .procname = "dentry-state",
1338 .data = &dentry_stat,
1339 .maxlen = 6*sizeof(int),
1340 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001341 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342 },
1343 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001344 .procname = "overflowuid",
1345 .data = &fs_overflowuid,
1346 .maxlen = sizeof(int),
1347 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001348 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001349 .extra1 = &minolduid,
1350 .extra2 = &maxolduid,
1351 },
1352 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 .procname = "overflowgid",
1354 .data = &fs_overflowgid,
1355 .maxlen = sizeof(int),
1356 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001357 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001358 .extra1 = &minolduid,
1359 .extra2 = &maxolduid,
1360 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001361#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001362 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001363 .procname = "leases-enable",
1364 .data = &leases_enable,
1365 .maxlen = sizeof(int),
1366 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001367 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001368 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001369#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001370#ifdef CONFIG_DNOTIFY
1371 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372 .procname = "dir-notify-enable",
1373 .data = &dir_notify_enable,
1374 .maxlen = sizeof(int),
1375 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001376 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001377 },
1378#endif
1379#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001380#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001381 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001382 .procname = "lease-break-time",
1383 .data = &lease_break_time,
1384 .maxlen = sizeof(int),
1385 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001386 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001387 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001388#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001389#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391 .procname = "aio-nr",
1392 .data = &aio_nr,
1393 .maxlen = sizeof(aio_nr),
1394 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001395 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001396 },
1397 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001398 .procname = "aio-max-nr",
1399 .data = &aio_max_nr,
1400 .maxlen = sizeof(aio_max_nr),
1401 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001402 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001403 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001404#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001405#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001406 {
Robert Love0399cb02005-07-13 12:38:18 -04001407 .procname = "inotify",
1408 .mode = 0555,
1409 .child = inotify_table,
1410 },
1411#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001412#ifdef CONFIG_EPOLL
1413 {
1414 .procname = "epoll",
1415 .mode = 0555,
1416 .child = epoll_table,
1417 },
1418#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001419#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001420 {
Alan Coxd6e71142005-06-23 00:09:43 -07001421 .procname = "suid_dumpable",
1422 .data = &suid_dumpable,
1423 .maxlen = sizeof(int),
1424 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001425 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001426 .extra1 = &zero,
1427 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001428 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001429#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1430 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001431 .procname = "binfmt_misc",
1432 .mode = 0555,
1433 .child = binfmt_misc_table,
1434 },
1435#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001436/*
1437 * NOTE: do not add new entries to this table unless you have read
1438 * Documentation/sysctl/ctl_unnumbered.txt
1439 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001440 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001441};
1442
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001443static struct ctl_table debug_table[] = {
David S. Miller4b177642010-03-01 00:02:23 -08001444#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001445 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001446 .procname = "exception-trace",
1447 .data = &show_unhandled_signals,
1448 .maxlen = sizeof(int),
1449 .mode = 0644,
1450 .proc_handler = proc_dointvec
1451 },
1452#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001453#if defined(CONFIG_OPTPROBES)
1454 {
1455 .procname = "kprobes-optimization",
1456 .data = &sysctl_kprobes_optimization,
1457 .maxlen = sizeof(int),
1458 .mode = 0644,
1459 .proc_handler = proc_kprobes_optimization_handler,
1460 .extra1 = &zero,
1461 .extra2 = &one,
1462 },
1463#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001464 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465};
1466
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001467static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001468 { }
Robert Love0eeca282005-07-12 17:06:03 -04001469};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001470
Al Viro330d57f2005-11-04 10:18:40 +00001471static DEFINE_SPINLOCK(sysctl_lock);
1472
1473/* called under sysctl_lock */
1474static int use_table(struct ctl_table_header *p)
1475{
1476 if (unlikely(p->unregistering))
1477 return 0;
1478 p->used++;
1479 return 1;
1480}
1481
1482/* called under sysctl_lock */
1483static void unuse_table(struct ctl_table_header *p)
1484{
1485 if (!--p->used)
1486 if (unlikely(p->unregistering))
1487 complete(p->unregistering);
1488}
1489
1490/* called under sysctl_lock, will reacquire if has to wait */
1491static void start_unregistering(struct ctl_table_header *p)
1492{
1493 /*
1494 * if p->used is 0, nobody will ever touch that entry again;
1495 * we'll eliminate all paths to it before dropping sysctl_lock
1496 */
1497 if (unlikely(p->used)) {
1498 struct completion wait;
1499 init_completion(&wait);
1500 p->unregistering = &wait;
1501 spin_unlock(&sysctl_lock);
1502 wait_for_completion(&wait);
1503 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001504 } else {
1505 /* anything non-NULL; we'll never dereference it */
1506 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001507 }
1508 /*
1509 * do not remove from the list until nobody holds it; walking the
1510 * list in do_sysctl() relies on that.
1511 */
1512 list_del_init(&p->ctl_entry);
1513}
1514
Al Virof7e6ced2008-07-15 01:44:23 -04001515void sysctl_head_get(struct ctl_table_header *head)
1516{
1517 spin_lock(&sysctl_lock);
1518 head->count++;
1519 spin_unlock(&sysctl_lock);
1520}
1521
1522void sysctl_head_put(struct ctl_table_header *head)
1523{
1524 spin_lock(&sysctl_lock);
1525 if (!--head->count)
1526 kfree(head);
1527 spin_unlock(&sysctl_lock);
1528}
1529
1530struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1531{
1532 if (!head)
1533 BUG();
1534 spin_lock(&sysctl_lock);
1535 if (!use_table(head))
1536 head = ERR_PTR(-ENOENT);
1537 spin_unlock(&sysctl_lock);
1538 return head;
1539}
1540
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001541void sysctl_head_finish(struct ctl_table_header *head)
1542{
1543 if (!head)
1544 return;
1545 spin_lock(&sysctl_lock);
1546 unuse_table(head);
1547 spin_unlock(&sysctl_lock);
1548}
1549
Al Viro73455092008-07-14 21:22:20 -04001550static struct ctl_table_set *
1551lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1552{
1553 struct ctl_table_set *set = &root->default_set;
1554 if (root->lookup)
1555 set = root->lookup(root, namespaces);
1556 return set;
1557}
1558
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001559static struct list_head *
1560lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001561{
Al Viro73455092008-07-14 21:22:20 -04001562 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1563 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001564}
1565
1566struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1567 struct ctl_table_header *prev)
1568{
1569 struct ctl_table_root *root;
1570 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001571 struct ctl_table_header *head;
1572 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001573
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001574 spin_lock(&sysctl_lock);
1575 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001576 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001577 tmp = &prev->ctl_entry;
1578 unuse_table(prev);
1579 goto next;
1580 }
1581 tmp = &root_table_header.ctl_entry;
1582 for (;;) {
1583 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1584
1585 if (!use_table(head))
1586 goto next;
1587 spin_unlock(&sysctl_lock);
1588 return head;
1589 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001590 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001591 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001592 header_list = lookup_header_list(root, namespaces);
1593 if (tmp != header_list)
1594 continue;
1595
1596 do {
1597 root = list_entry(root->root_list.next,
1598 struct ctl_table_root, root_list);
1599 if (root == &sysctl_table_root)
1600 goto out;
1601 header_list = lookup_header_list(root, namespaces);
1602 } while (list_empty(header_list));
1603 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001604 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001605out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001606 spin_unlock(&sysctl_lock);
1607 return NULL;
1608}
1609
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001610struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1611{
1612 return __sysctl_head_next(current->nsproxy, prev);
1613}
1614
1615void register_sysctl_root(struct ctl_table_root *root)
1616{
1617 spin_lock(&sysctl_lock);
1618 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1619 spin_unlock(&sysctl_lock);
1620}
1621
Linus Torvalds1da177e2005-04-16 15:20:36 -07001622/*
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001623 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001624 * some sysctl variables are readonly even to root.
1625 */
1626
1627static int test_perm(int mode, int op)
1628{
David Howells76aac0e2008-11-14 10:39:12 +11001629 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001630 mode >>= 6;
1631 else if (in_egroup_p(0))
1632 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001633 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001634 return 0;
1635 return -EACCES;
1636}
1637
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001638int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001639{
1640 int error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001641 int mode;
1642
Al Viroe6305c42008-07-15 21:03:57 -04001643 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001644 if (error)
1645 return error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001646
1647 if (root->permissions)
1648 mode = root->permissions(root, current->nsproxy, table);
1649 else
1650 mode = table->mode;
1651
1652 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001653}
1654
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001655static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1656{
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001657 for (; table->procname; table++) {
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001658 table->parent = parent;
1659 if (table->child)
1660 sysctl_set_parent(table, table->child);
1661 }
1662}
1663
1664static __init int sysctl_init(void)
1665{
1666 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001667#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1668 {
1669 int err;
1670 err = sysctl_check_table(current->nsproxy, root_table);
1671 }
1672#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001673 return 0;
1674}
1675
1676core_initcall(sysctl_init);
1677
Al Virobfbcf032008-07-27 06:31:22 +01001678static struct ctl_table *is_branch_in(struct ctl_table *branch,
1679 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001680{
1681 struct ctl_table *p;
1682 const char *s = branch->procname;
1683
1684 /* branch should have named subdirectory as its first element */
1685 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001686 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001687
1688 /* ... and nothing else */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001689 if (branch[1].procname)
Al Virobfbcf032008-07-27 06:31:22 +01001690 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001691
1692 /* table should contain subdirectory with the same name */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001693 for (p = table; p->procname; p++) {
Al Viroae7edec2008-07-15 06:33:31 -04001694 if (!p->child)
1695 continue;
1696 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001697 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001698 }
Al Virobfbcf032008-07-27 06:31:22 +01001699 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001700}
1701
1702/* see if attaching q to p would be an improvement */
1703static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1704{
1705 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001706 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001707 int is_better = 0;
1708 int not_in_parent = !p->attached_by;
1709
Al Virobfbcf032008-07-27 06:31:22 +01001710 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001711 if (by == q->attached_by)
1712 is_better = 1;
1713 if (to == p->attached_by)
1714 not_in_parent = 1;
1715 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001716 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001717 }
1718
1719 if (is_better && not_in_parent) {
1720 q->attached_by = by;
1721 q->attached_to = to;
1722 q->parent = p;
1723 }
1724}
1725
Linus Torvalds1da177e2005-04-16 15:20:36 -07001726/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001727 * __register_sysctl_paths - register a sysctl hierarchy
1728 * @root: List of sysctl headers to register on
1729 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001730 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001731 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001732 *
1733 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001734 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001735 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001736 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001737 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001738 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1739 * enter a sysctl file
1740 *
1741 * data - a pointer to data for use by proc_handler
1742 *
1743 * maxlen - the maximum size in bytes of the data
1744 *
1745 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1746 *
1747 * child - a pointer to the child sysctl table if this entry is a directory, or
1748 * %NULL.
1749 *
1750 * proc_handler - the text handler routine (described below)
1751 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001752 * de - for internal use by the sysctl routines
1753 *
1754 * extra1, extra2 - extra pointers usable by the proc handler routines
1755 *
1756 * Leaf nodes in the sysctl tree will be represented by a single file
1757 * under /proc; non-leaf nodes will be represented by directories.
1758 *
1759 * sysctl(2) can automatically manage read and write requests through
1760 * the sysctl table. The data and maxlen fields of the ctl_table
1761 * struct enable minimal validation of the values being written to be
1762 * performed, and the mode field allows minimal authentication.
1763 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001764 * There must be a proc_handler routine for any terminal nodes
1765 * mirrored under /proc/sys (non-terminals are handled by a built-in
1766 * directory handler). Several default handlers are available to
1767 * cover common cases -
1768 *
1769 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1770 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1771 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1772 *
1773 * It is the handler's job to read the input buffer from user memory
1774 * and process it. The handler should return 0 on success.
1775 *
1776 * This routine returns %NULL on a failure to register, and a pointer
1777 * to the table header on success.
1778 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001779struct ctl_table_header *__register_sysctl_paths(
1780 struct ctl_table_root *root,
1781 struct nsproxy *namespaces,
1782 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001783{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001784 struct ctl_table_header *header;
1785 struct ctl_table *new, **prevp;
1786 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001787 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001788
1789 /* Count the path components */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001790 for (npath = 0; path[npath].procname; ++npath)
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001791 ;
1792
1793 /*
1794 * For each path component, allocate a 2-element ctl_table array.
1795 * The first array element will be filled with the sysctl entry
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001796 * for this, the second will be the sentinel (procname == 0).
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001797 *
1798 * We allocate everything in one go so that we don't have to
1799 * worry about freeing additional memory in unregister_sysctl_table.
1800 */
1801 header = kzalloc(sizeof(struct ctl_table_header) +
1802 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1803 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001804 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001805
1806 new = (struct ctl_table *) (header + 1);
1807
1808 /* Now connect the dots */
1809 prevp = &header->ctl_table;
1810 for (n = 0; n < npath; ++n, ++path) {
1811 /* Copy the procname */
1812 new->procname = path->procname;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001813 new->mode = 0555;
1814
1815 *prevp = new;
1816 prevp = &new->child;
1817
1818 new += 2;
1819 }
1820 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001821 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001822
1823 INIT_LIST_HEAD(&header->ctl_entry);
1824 header->used = 0;
1825 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001826 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001827 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001828 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001829#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001830 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001831 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001832 return NULL;
1833 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001834#endif
Al Viro330d57f2005-11-04 10:18:40 +00001835 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001836 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001837 header->attached_by = header->ctl_table;
1838 header->attached_to = root_table;
1839 header->parent = &root_table_header;
1840 for (set = header->set; set; set = set->parent) {
1841 struct ctl_table_header *p;
1842 list_for_each_entry(p, &set->list, ctl_entry) {
1843 if (p->unregistering)
1844 continue;
1845 try_attach(p, header);
1846 }
1847 }
1848 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001849 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001850 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001851
1852 return header;
1853}
1854
1855/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001856 * register_sysctl_table_path - register a sysctl table hierarchy
1857 * @path: The path to the directory the sysctl table is in.
1858 * @table: the top-level table structure
1859 *
1860 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1861 * array. A completely 0 filled entry terminates the table.
1862 *
1863 * See __register_sysctl_paths for more details.
1864 */
1865struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1866 struct ctl_table *table)
1867{
1868 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1869 path, table);
1870}
1871
1872/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001873 * register_sysctl_table - register a sysctl table hierarchy
1874 * @table: the top-level table structure
1875 *
1876 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1877 * array. A completely 0 filled entry terminates the table.
1878 *
1879 * See register_sysctl_paths for more details.
1880 */
1881struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1882{
1883 static const struct ctl_path null_path[] = { {} };
1884
1885 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001886}
1887
1888/**
1889 * unregister_sysctl_table - unregister a sysctl table hierarchy
1890 * @header: the header returned from register_sysctl_table
1891 *
1892 * Unregisters the sysctl table and all children. proc entries may not
1893 * actually be removed until they are no longer used by anyone.
1894 */
1895void unregister_sysctl_table(struct ctl_table_header * header)
1896{
Al Viro330d57f2005-11-04 10:18:40 +00001897 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08001898
1899 if (header == NULL)
1900 return;
1901
Al Viro330d57f2005-11-04 10:18:40 +00001902 spin_lock(&sysctl_lock);
1903 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04001904 if (!--header->parent->count) {
1905 WARN_ON(1);
1906 kfree(header->parent);
1907 }
Al Virof7e6ced2008-07-15 01:44:23 -04001908 if (!--header->count)
1909 kfree(header);
Al Viro330d57f2005-11-04 10:18:40 +00001910 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001911}
1912
Al Viro9043476f2008-07-15 08:54:06 -04001913int sysctl_is_seen(struct ctl_table_header *p)
1914{
1915 struct ctl_table_set *set = p->set;
1916 int res;
1917 spin_lock(&sysctl_lock);
1918 if (p->unregistering)
1919 res = 0;
1920 else if (!set->is_seen)
1921 res = 1;
1922 else
1923 res = set->is_seen(set);
1924 spin_unlock(&sysctl_lock);
1925 return res;
1926}
1927
Al Viro73455092008-07-14 21:22:20 -04001928void setup_sysctl_set(struct ctl_table_set *p,
1929 struct ctl_table_set *parent,
1930 int (*is_seen)(struct ctl_table_set *))
1931{
1932 INIT_LIST_HEAD(&p->list);
1933 p->parent = parent ? parent : &sysctl_table_root.default_set;
1934 p->is_seen = is_seen;
1935}
1936
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001937#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001938struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001939{
1940 return NULL;
1941}
1942
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001943struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1944 struct ctl_table *table)
1945{
1946 return NULL;
1947}
1948
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001949void unregister_sysctl_table(struct ctl_table_header * table)
1950{
1951}
1952
Al Viro73455092008-07-14 21:22:20 -04001953void setup_sysctl_set(struct ctl_table_set *p,
1954 struct ctl_table_set *parent,
1955 int (*is_seen)(struct ctl_table_set *))
1956{
1957}
1958
Al Virof7e6ced2008-07-15 01:44:23 -04001959void sysctl_head_put(struct ctl_table_header *head)
1960{
1961}
1962
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001963#endif /* CONFIG_SYSCTL */
1964
Linus Torvalds1da177e2005-04-16 15:20:36 -07001965/*
1966 * /proc/sys support
1967 */
1968
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001969#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001970
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001971static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001972 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001973 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001974{
1975 size_t len;
1976 char __user *p;
1977 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001978
1979 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001980 *lenp = 0;
1981 return 0;
1982 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001983
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001984 if (write) {
1985 len = 0;
1986 p = buffer;
1987 while (len < *lenp) {
1988 if (get_user(c, p++))
1989 return -EFAULT;
1990 if (c == 0 || c == '\n')
1991 break;
1992 len++;
1993 }
1994 if (len >= maxlen)
1995 len = maxlen-1;
1996 if(copy_from_user(data, buffer, len))
1997 return -EFAULT;
1998 ((char *) data)[len] = 0;
1999 *ppos += *lenp;
2000 } else {
2001 len = strlen(data);
2002 if (len > maxlen)
2003 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002004
2005 if (*ppos > len) {
2006 *lenp = 0;
2007 return 0;
2008 }
2009
2010 data += *ppos;
2011 len -= *ppos;
2012
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002013 if (len > *lenp)
2014 len = *lenp;
2015 if (len)
2016 if(copy_to_user(buffer, data, len))
2017 return -EFAULT;
2018 if (len < *lenp) {
2019 if(put_user('\n', ((char __user *) buffer) + len))
2020 return -EFAULT;
2021 len++;
2022 }
2023 *lenp = len;
2024 *ppos += len;
2025 }
2026 return 0;
2027}
2028
Linus Torvalds1da177e2005-04-16 15:20:36 -07002029/**
2030 * proc_dostring - read a string sysctl
2031 * @table: the sysctl table
2032 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002033 * @buffer: the user buffer
2034 * @lenp: the size of the user buffer
2035 * @ppos: file position
2036 *
2037 * Reads/writes a string from/to the user buffer. If the kernel
2038 * buffer provided is not large enough to hold the string, the
2039 * string is truncated. The copied string is %NULL-terminated.
2040 * If the string is being read by the user process, it is copied
2041 * and a newline '\n' is added. It is truncated if the buffer is
2042 * not large enough.
2043 *
2044 * Returns 0 on success.
2045 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002046int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002047 void __user *buffer, size_t *lenp, loff_t *ppos)
2048{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002049 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002050 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002051}
2052
Linus Torvalds1da177e2005-04-16 15:20:36 -07002053
2054static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2055 int *valp,
2056 int write, void *data)
2057{
2058 if (write) {
2059 *valp = *negp ? -*lvalp : *lvalp;
2060 } else {
2061 int val = *valp;
2062 if (val < 0) {
2063 *negp = -1;
2064 *lvalp = (unsigned long)-val;
2065 } else {
2066 *negp = 0;
2067 *lvalp = (unsigned long)val;
2068 }
2069 }
2070 return 0;
2071}
2072
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002073static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002074 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002075 size_t *lenp, loff_t *ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002076 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2077 int write, void *data),
2078 void *data)
2079{
2080#define TMPBUFLEN 21
Sukanto Ghosh7338f292009-06-17 16:27:50 -07002081 int *i, vleft, first = 1, neg;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002082 unsigned long lval;
2083 size_t left, len;
2084
2085 char buf[TMPBUFLEN], *p;
2086 char __user *s = buffer;
2087
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002088 if (!tbl_data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002089 (*ppos && !write)) {
2090 *lenp = 0;
2091 return 0;
2092 }
2093
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002094 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002095 vleft = table->maxlen / sizeof(*i);
2096 left = *lenp;
2097
2098 if (!conv)
2099 conv = do_proc_dointvec_conv;
2100
2101 for (; left && vleft--; i++, first=0) {
2102 if (write) {
2103 while (left) {
2104 char c;
2105 if (get_user(c, s))
2106 return -EFAULT;
2107 if (!isspace(c))
2108 break;
2109 left--;
2110 s++;
2111 }
2112 if (!left)
2113 break;
2114 neg = 0;
2115 len = left;
2116 if (len > sizeof(buf) - 1)
2117 len = sizeof(buf) - 1;
2118 if (copy_from_user(buf, s, len))
2119 return -EFAULT;
2120 buf[len] = 0;
2121 p = buf;
2122 if (*p == '-' && left > 1) {
2123 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002124 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002125 }
2126 if (*p < '0' || *p > '9')
2127 break;
2128
2129 lval = simple_strtoul(p, &p, 0);
2130
2131 len = p-buf;
2132 if ((len < left) && *p && !isspace(*p))
2133 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002134 s += len;
2135 left -= len;
2136
2137 if (conv(&neg, &lval, i, 1, data))
2138 break;
2139 } else {
2140 p = buf;
2141 if (!first)
2142 *p++ = '\t';
2143
2144 if (conv(&neg, &lval, i, 0, data))
2145 break;
2146
2147 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2148 len = strlen(buf);
2149 if (len > left)
2150 len = left;
2151 if(copy_to_user(s, buf, len))
2152 return -EFAULT;
2153 left -= len;
2154 s += len;
2155 }
2156 }
2157
2158 if (!write && !first && left) {
2159 if(put_user('\n', s))
2160 return -EFAULT;
2161 left--, s++;
2162 }
2163 if (write) {
2164 while (left) {
2165 char c;
2166 if (get_user(c, s++))
2167 return -EFAULT;
2168 if (!isspace(c))
2169 break;
2170 left--;
2171 }
2172 }
2173 if (write && first)
2174 return -EINVAL;
2175 *lenp -= left;
2176 *ppos += *lenp;
2177 return 0;
2178#undef TMPBUFLEN
2179}
2180
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002181static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002182 void __user *buffer, size_t *lenp, loff_t *ppos,
2183 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2184 int write, void *data),
2185 void *data)
2186{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002187 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002188 buffer, lenp, ppos, conv, data);
2189}
2190
Linus Torvalds1da177e2005-04-16 15:20:36 -07002191/**
2192 * proc_dointvec - read a vector of integers
2193 * @table: the sysctl table
2194 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002195 * @buffer: the user buffer
2196 * @lenp: the size of the user buffer
2197 * @ppos: file position
2198 *
2199 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2200 * values from/to the user buffer, treated as an ASCII string.
2201 *
2202 * Returns 0 on success.
2203 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002204int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002205 void __user *buffer, size_t *lenp, loff_t *ppos)
2206{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002207 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002208 NULL,NULL);
2209}
2210
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002211/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002212 * Taint values can only be increased
2213 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002214 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002215static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002216 void __user *buffer, size_t *lenp, loff_t *ppos)
2217{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002218 struct ctl_table t;
2219 unsigned long tmptaint = get_taint();
2220 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002221
Bastian Blank91fcd412007-04-23 14:41:14 -07002222 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002223 return -EPERM;
2224
Andi Kleen25ddbb12008-10-15 22:01:41 -07002225 t = *table;
2226 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002227 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002228 if (err < 0)
2229 return err;
2230
2231 if (write) {
2232 /*
2233 * Poor man's atomic or. Not worth adding a primitive
2234 * to everyone's atomic.h for this
2235 */
2236 int i;
2237 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2238 if ((tmptaint >> i) & 1)
2239 add_taint(i);
2240 }
2241 }
2242
2243 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002244}
2245
Linus Torvalds1da177e2005-04-16 15:20:36 -07002246struct do_proc_dointvec_minmax_conv_param {
2247 int *min;
2248 int *max;
2249};
2250
2251static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2252 int *valp,
2253 int write, void *data)
2254{
2255 struct do_proc_dointvec_minmax_conv_param *param = data;
2256 if (write) {
2257 int val = *negp ? -*lvalp : *lvalp;
2258 if ((param->min && *param->min > val) ||
2259 (param->max && *param->max < val))
2260 return -EINVAL;
2261 *valp = val;
2262 } else {
2263 int val = *valp;
2264 if (val < 0) {
2265 *negp = -1;
2266 *lvalp = (unsigned long)-val;
2267 } else {
2268 *negp = 0;
2269 *lvalp = (unsigned long)val;
2270 }
2271 }
2272 return 0;
2273}
2274
2275/**
2276 * proc_dointvec_minmax - read a vector of integers with min/max values
2277 * @table: the sysctl table
2278 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002279 * @buffer: the user buffer
2280 * @lenp: the size of the user buffer
2281 * @ppos: file position
2282 *
2283 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2284 * values from/to the user buffer, treated as an ASCII string.
2285 *
2286 * This routine will ensure the values are within the range specified by
2287 * table->extra1 (min) and table->extra2 (max).
2288 *
2289 * Returns 0 on success.
2290 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002291int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002292 void __user *buffer, size_t *lenp, loff_t *ppos)
2293{
2294 struct do_proc_dointvec_minmax_conv_param param = {
2295 .min = (int *) table->extra1,
2296 .max = (int *) table->extra2,
2297 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002298 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299 do_proc_dointvec_minmax_conv, &param);
2300}
2301
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002302static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002303 void __user *buffer,
2304 size_t *lenp, loff_t *ppos,
2305 unsigned long convmul,
2306 unsigned long convdiv)
2307{
2308#define TMPBUFLEN 21
2309 unsigned long *i, *min, *max, val;
2310 int vleft, first=1, neg;
2311 size_t len, left;
2312 char buf[TMPBUFLEN], *p;
2313 char __user *s = buffer;
2314
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002315 if (!data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002316 (*ppos && !write)) {
2317 *lenp = 0;
2318 return 0;
2319 }
2320
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002321 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002322 min = (unsigned long *) table->extra1;
2323 max = (unsigned long *) table->extra2;
2324 vleft = table->maxlen / sizeof(unsigned long);
2325 left = *lenp;
2326
2327 for (; left && vleft--; i++, min++, max++, first=0) {
2328 if (write) {
2329 while (left) {
2330 char c;
2331 if (get_user(c, s))
2332 return -EFAULT;
2333 if (!isspace(c))
2334 break;
2335 left--;
2336 s++;
2337 }
2338 if (!left)
2339 break;
2340 neg = 0;
2341 len = left;
2342 if (len > TMPBUFLEN-1)
2343 len = TMPBUFLEN-1;
2344 if (copy_from_user(buf, s, len))
2345 return -EFAULT;
2346 buf[len] = 0;
2347 p = buf;
2348 if (*p == '-' && left > 1) {
2349 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002350 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002351 }
2352 if (*p < '0' || *p > '9')
2353 break;
2354 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2355 len = p-buf;
2356 if ((len < left) && *p && !isspace(*p))
2357 break;
2358 if (neg)
2359 val = -val;
2360 s += len;
2361 left -= len;
2362
2363 if(neg)
2364 continue;
2365 if ((min && val < *min) || (max && val > *max))
2366 continue;
2367 *i = val;
2368 } else {
2369 p = buf;
2370 if (!first)
2371 *p++ = '\t';
2372 sprintf(p, "%lu", convdiv * (*i) / convmul);
2373 len = strlen(buf);
2374 if (len > left)
2375 len = left;
2376 if(copy_to_user(s, buf, len))
2377 return -EFAULT;
2378 left -= len;
2379 s += len;
2380 }
2381 }
2382
2383 if (!write && !first && left) {
2384 if(put_user('\n', s))
2385 return -EFAULT;
2386 left--, s++;
2387 }
2388 if (write) {
2389 while (left) {
2390 char c;
2391 if (get_user(c, s++))
2392 return -EFAULT;
2393 if (!isspace(c))
2394 break;
2395 left--;
2396 }
2397 }
2398 if (write && first)
2399 return -EINVAL;
2400 *lenp -= left;
2401 *ppos += *lenp;
2402 return 0;
2403#undef TMPBUFLEN
2404}
2405
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002406static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002407 void __user *buffer,
2408 size_t *lenp, loff_t *ppos,
2409 unsigned long convmul,
2410 unsigned long convdiv)
2411{
2412 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002413 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002414}
2415
Linus Torvalds1da177e2005-04-16 15:20:36 -07002416/**
2417 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2418 * @table: the sysctl table
2419 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002420 * @buffer: the user buffer
2421 * @lenp: the size of the user buffer
2422 * @ppos: file position
2423 *
2424 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2425 * values from/to the user buffer, treated as an ASCII string.
2426 *
2427 * This routine will ensure the values are within the range specified by
2428 * table->extra1 (min) and table->extra2 (max).
2429 *
2430 * Returns 0 on success.
2431 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002432int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002433 void __user *buffer, size_t *lenp, loff_t *ppos)
2434{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002435 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436}
2437
2438/**
2439 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2440 * @table: the sysctl table
2441 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002442 * @buffer: the user buffer
2443 * @lenp: the size of the user buffer
2444 * @ppos: file position
2445 *
2446 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2447 * values from/to the user buffer, treated as an ASCII string. The values
2448 * are treated as milliseconds, and converted to jiffies when they are stored.
2449 *
2450 * This routine will ensure the values are within the range specified by
2451 * table->extra1 (min) and table->extra2 (max).
2452 *
2453 * Returns 0 on success.
2454 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002455int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002456 void __user *buffer,
2457 size_t *lenp, loff_t *ppos)
2458{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002459 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002460 lenp, ppos, HZ, 1000l);
2461}
2462
2463
2464static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2465 int *valp,
2466 int write, void *data)
2467{
2468 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002469 if (*lvalp > LONG_MAX / HZ)
2470 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2472 } else {
2473 int val = *valp;
2474 unsigned long lval;
2475 if (val < 0) {
2476 *negp = -1;
2477 lval = (unsigned long)-val;
2478 } else {
2479 *negp = 0;
2480 lval = (unsigned long)val;
2481 }
2482 *lvalp = lval / HZ;
2483 }
2484 return 0;
2485}
2486
2487static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2488 int *valp,
2489 int write, void *data)
2490{
2491 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002492 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2493 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2495 } else {
2496 int val = *valp;
2497 unsigned long lval;
2498 if (val < 0) {
2499 *negp = -1;
2500 lval = (unsigned long)-val;
2501 } else {
2502 *negp = 0;
2503 lval = (unsigned long)val;
2504 }
2505 *lvalp = jiffies_to_clock_t(lval);
2506 }
2507 return 0;
2508}
2509
2510static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2511 int *valp,
2512 int write, void *data)
2513{
2514 if (write) {
2515 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2516 } else {
2517 int val = *valp;
2518 unsigned long lval;
2519 if (val < 0) {
2520 *negp = -1;
2521 lval = (unsigned long)-val;
2522 } else {
2523 *negp = 0;
2524 lval = (unsigned long)val;
2525 }
2526 *lvalp = jiffies_to_msecs(lval);
2527 }
2528 return 0;
2529}
2530
2531/**
2532 * proc_dointvec_jiffies - read a vector of integers as seconds
2533 * @table: the sysctl table
2534 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002535 * @buffer: the user buffer
2536 * @lenp: the size of the user buffer
2537 * @ppos: file position
2538 *
2539 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2540 * values from/to the user buffer, treated as an ASCII string.
2541 * The values read are assumed to be in seconds, and are converted into
2542 * jiffies.
2543 *
2544 * Returns 0 on success.
2545 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002546int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002547 void __user *buffer, size_t *lenp, loff_t *ppos)
2548{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002549 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550 do_proc_dointvec_jiffies_conv,NULL);
2551}
2552
2553/**
2554 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2555 * @table: the sysctl table
2556 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002557 * @buffer: the user buffer
2558 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002559 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002560 *
2561 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2562 * values from/to the user buffer, treated as an ASCII string.
2563 * The values read are assumed to be in 1/USER_HZ seconds, and
2564 * are converted into jiffies.
2565 *
2566 * Returns 0 on success.
2567 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002568int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002569 void __user *buffer, size_t *lenp, loff_t *ppos)
2570{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002571 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002572 do_proc_dointvec_userhz_jiffies_conv,NULL);
2573}
2574
2575/**
2576 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2577 * @table: the sysctl table
2578 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002579 * @buffer: the user buffer
2580 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002581 * @ppos: file position
2582 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002583 *
2584 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2585 * values from/to the user buffer, treated as an ASCII string.
2586 * The values read are assumed to be in 1/1000 seconds, and
2587 * are converted into jiffies.
2588 *
2589 * Returns 0 on success.
2590 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002591int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002592 void __user *buffer, size_t *lenp, loff_t *ppos)
2593{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002594 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002595 do_proc_dointvec_ms_jiffies_conv, NULL);
2596}
2597
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002598static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002599 void __user *buffer, size_t *lenp, loff_t *ppos)
2600{
2601 struct pid *new_pid;
2602 pid_t tmp;
2603 int r;
2604
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002605 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002606
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002607 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002608 lenp, ppos, NULL, NULL);
2609 if (r || !write)
2610 return r;
2611
2612 new_pid = find_get_pid(tmp);
2613 if (!new_pid)
2614 return -ESRCH;
2615
2616 put_pid(xchg(&cad_pid, new_pid));
2617 return 0;
2618}
2619
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620#else /* CONFIG_PROC_FS */
2621
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002622int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002623 void __user *buffer, size_t *lenp, loff_t *ppos)
2624{
2625 return -ENOSYS;
2626}
2627
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002628int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629 void __user *buffer, size_t *lenp, loff_t *ppos)
2630{
2631 return -ENOSYS;
2632}
2633
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002634int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002635 void __user *buffer, size_t *lenp, loff_t *ppos)
2636{
2637 return -ENOSYS;
2638}
2639
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002640int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002641 void __user *buffer, size_t *lenp, loff_t *ppos)
2642{
2643 return -ENOSYS;
2644}
2645
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002646int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002647 void __user *buffer, size_t *lenp, loff_t *ppos)
2648{
2649 return -ENOSYS;
2650}
2651
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002652int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002653 void __user *buffer, size_t *lenp, loff_t *ppos)
2654{
2655 return -ENOSYS;
2656}
2657
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002658int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002659 void __user *buffer, size_t *lenp, loff_t *ppos)
2660{
2661 return -ENOSYS;
2662}
2663
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002664int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002665 void __user *buffer,
2666 size_t *lenp, loff_t *ppos)
2667{
2668 return -ENOSYS;
2669}
2670
2671
2672#endif /* CONFIG_PROC_FS */
2673
Linus Torvalds1da177e2005-04-16 15:20:36 -07002674/*
2675 * No sense putting this after each symbol definition, twice,
2676 * exception granted :-)
2677 */
2678EXPORT_SYMBOL(proc_dointvec);
2679EXPORT_SYMBOL(proc_dointvec_jiffies);
2680EXPORT_SYMBOL(proc_dointvec_minmax);
2681EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2682EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2683EXPORT_SYMBOL(proc_dostring);
2684EXPORT_SYMBOL(proc_doulongvec_minmax);
2685EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2686EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002687EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002688EXPORT_SYMBOL(unregister_sysctl_table);