blob: 44e9492368fdd2a79a9703fbb2140673c8a3f784 [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
Jens Axboecb684b52009-09-15 21:53:11 +020090#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +020091extern int blk_iopoll_enabled;
Jens Axboecb684b52009-09-15 21:53:11 +020092#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070093
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070094/* Constants used for minimum and maximum */
Bron Gondwana195cf452008-02-04 22:29:20 -080095#ifdef CONFIG_DETECT_SOFTLOCKUP
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070096static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +020097static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070098#endif
99
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700100static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700101static int __maybe_unused one = 1;
102static int __maybe_unused two = 2;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800103static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700104static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700105#ifdef CONFIG_PRINTK
106static int ten_thousand = 10000;
107#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700108
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700109/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
110static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
111
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
113static int maxolduid = 65535;
114static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800115static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
117static int ngroups_max = NGROUPS_MAX;
118
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119#ifdef CONFIG_CHR_DEV_SG
120extern int sg_big_buff;
121#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122
David S. Miller72c57ed2008-09-11 23:29:54 -0700123#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700124#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125#endif
126
David S. Miller08714202008-11-16 23:49:24 -0800127#ifdef CONFIG_SPARC64
128extern int sysctl_tsb_ratio;
129#endif
130
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131#ifdef __hppa__
132extern int pwrsw_enabled;
133extern int unaligned_enabled;
134#endif
135
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800136#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137#ifdef CONFIG_MATHEMU
138extern int sysctl_ieee_emulation_warnings;
139#endif
140extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700141extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142#endif
143
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144#ifdef CONFIG_BSD_PROCESS_ACCT
145extern int acct_parm[];
146#endif
147
Jes Sorensend2b176e2006-02-28 09:42:23 -0800148#ifdef CONFIG_IA64
149extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800150extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800151#endif
152
Ingo Molnar3fff4c42009-09-22 16:18:09 +0200153extern struct ratelimit_state printk_ratelimit_state;
154
Ingo Molnar23f78d42006-06-27 02:54:53 -0700155#ifdef CONFIG_RT_MUTEXES
156extern int max_lock_depth;
157#endif
158
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700159#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700160static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700161 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700162static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800163 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700164#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700165
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700166static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100167static struct ctl_table_root sysctl_table_root;
168static struct ctl_table_header root_table_header = {
Al Virob380b0d2008-09-04 17:05:57 +0100169 .count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100170 .ctl_table = root_table,
Al Viro73455092008-07-14 21:22:20 -0400171 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100172 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400173 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100174};
175static struct ctl_table_root sysctl_table_root = {
176 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400177 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100178};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700180static struct ctl_table kern_table[];
181static struct ctl_table vm_table[];
182static struct ctl_table fs_table[];
183static struct ctl_table debug_table[];
184static struct ctl_table dev_table[];
185extern struct ctl_table random_table[];
Amy Griffis2d9048e2006-06-01 13:10:59 -0700186#ifdef CONFIG_INOTIFY_USER
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700187extern struct ctl_table inotify_table[];
Robert Love0399cb02005-07-13 12:38:18 -0400188#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -0800189#ifdef CONFIG_EPOLL
190extern struct ctl_table epoll_table[];
191#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192
193#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
194int sysctl_legacy_va_layout;
195#endif
196
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700197extern int prove_locking;
198extern int lock_stat;
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800199
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200/* The default sysctl tables: */
201
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700202static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204 .procname = "kernel",
205 .mode = 0555,
206 .child = kern_table,
207 },
208 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 .procname = "vm",
210 .mode = 0555,
211 .child = vm_table,
212 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214 .procname = "fs",
215 .mode = 0555,
216 .child = fs_table,
217 },
218 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 .procname = "debug",
220 .mode = 0555,
221 .child = debug_table,
222 },
223 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 .procname = "dev",
225 .mode = 0555,
226 .child = dev_table,
227 },
Andrew Morton2be7fe02007-07-15 23:41:21 -0700228/*
229 * NOTE: do not add new entries to this table unless you have read
230 * Documentation/sysctl/ctl_unnumbered.txt
231 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700232 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233};
234
Ingo Molnar77e54a12007-07-09 18:52:00 +0200235#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100236static int min_sched_granularity_ns = 100000; /* 100 usecs */
237static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
238static int min_wakeup_granularity_ns; /* 0 usecs */
239static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100240static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
241static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100242static int min_sched_shares_ratelimit = 100000; /* 100 usec */
243static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200244#endif
245
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700246static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200247 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200248 .procname = "sched_child_runs_first",
249 .data = &sysctl_sched_child_runs_first,
250 .maxlen = sizeof(unsigned int),
251 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800252 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200253 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200254#ifdef CONFIG_SCHED_DEBUG
255 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100256 .procname = "sched_min_granularity_ns",
257 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200258 .maxlen = sizeof(unsigned int),
259 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800260 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100261 .extra1 = &min_sched_granularity_ns,
262 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200263 },
264 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200265 .procname = "sched_latency_ns",
266 .data = &sysctl_sched_latency,
267 .maxlen = sizeof(unsigned int),
268 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800269 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200270 .extra1 = &min_sched_granularity_ns,
271 .extra2 = &max_sched_granularity_ns,
272 },
273 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200274 .procname = "sched_wakeup_granularity_ns",
275 .data = &sysctl_sched_wakeup_granularity,
276 .maxlen = sizeof(unsigned int),
277 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800278 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200279 .extra1 = &min_wakeup_granularity_ns,
280 .extra2 = &max_wakeup_granularity_ns,
281 },
282 {
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200283 .procname = "sched_shares_ratelimit",
284 .data = &sysctl_sched_shares_ratelimit,
285 .maxlen = sizeof(unsigned int),
286 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800287 .proc_handler = sched_proc_update_handler,
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100288 .extra1 = &min_sched_shares_ratelimit,
289 .extra2 = &max_sched_shares_ratelimit,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200290 },
291 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100292 .procname = "sched_tunable_scaling",
293 .data = &sysctl_sched_tunable_scaling,
294 .maxlen = sizeof(enum sched_tunable_scaling),
295 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800296 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100297 .extra1 = &min_sched_tunable_scaling,
298 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200299 },
300 {
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200301 .procname = "sched_shares_thresh",
302 .data = &sysctl_sched_shares_thresh,
303 .maxlen = sizeof(unsigned int),
304 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800305 .proc_handler = proc_dointvec_minmax,
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200306 .extra1 = &zero,
307 },
308 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200309 .procname = "sched_migration_cost",
310 .data = &sysctl_sched_migration_cost,
311 .maxlen = sizeof(unsigned int),
312 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800313 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200314 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100315 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100316 .procname = "sched_nr_migrate",
317 .data = &sysctl_sched_nr_migrate,
318 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100319 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800320 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100321 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530322 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200323 .procname = "sched_time_avg",
324 .data = &sysctl_sched_time_avg,
325 .maxlen = sizeof(unsigned int),
326 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800327 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200328 },
329 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530330 .procname = "timer_migration",
331 .data = &sysctl_timer_migration,
332 .maxlen = sizeof(unsigned int),
333 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800334 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530335 .extra1 = &zero,
336 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530337 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200338#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200339 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100340 .procname = "sched_rt_period_us",
341 .data = &sysctl_sched_rt_period,
342 .maxlen = sizeof(unsigned int),
343 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800344 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100345 },
346 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100347 .procname = "sched_rt_runtime_us",
348 .data = &sysctl_sched_rt_runtime,
349 .maxlen = sizeof(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 {
Ingo Molnar1799e352007-09-19 23:34:46 +0200354 .procname = "sched_compat_yield",
355 .data = &sysctl_sched_compat_yield,
356 .maxlen = sizeof(unsigned int),
357 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800358 .proc_handler = proc_dointvec,
Ingo Molnar1799e352007-09-19 23:34:46 +0200359 },
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700360#ifdef CONFIG_PROVE_LOCKING
361 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700362 .procname = "prove_locking",
363 .data = &prove_locking,
364 .maxlen = sizeof(int),
365 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800366 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700367 },
368#endif
369#ifdef CONFIG_LOCK_STAT
370 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700371 .procname = "lock_stat",
372 .data = &lock_stat,
373 .maxlen = sizeof(int),
374 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800375 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700376 },
377#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200378 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 .procname = "panic",
380 .data = &panic_timeout,
381 .maxlen = sizeof(int),
382 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800383 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 },
385 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 .procname = "core_uses_pid",
387 .data = &core_uses_pid,
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_pattern",
394 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700395 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800397 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 },
Neil Hormana2939802009-09-23 15:56:56 -0700399 {
Neil Hormana2939802009-09-23 15:56:56 -0700400 .procname = "core_pipe_limit",
401 .data = &core_pipe_limit,
402 .maxlen = sizeof(unsigned int),
403 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800404 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700405 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800406#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700409 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800410 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800411 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800413#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100414#ifdef CONFIG_LATENCYTOP
415 {
416 .procname = "latencytop",
417 .data = &latencytop_enabled,
418 .maxlen = sizeof(int),
419 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800420 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100421 },
422#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423#ifdef CONFIG_BLK_DEV_INITRD
424 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 .procname = "real-root-dev",
426 .data = &real_root_dev,
427 .maxlen = sizeof(int),
428 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800429 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 },
431#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700432 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700433 .procname = "print-fatal-signals",
434 .data = &print_fatal_signals,
435 .maxlen = sizeof(int),
436 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800437 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700438 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700439#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 .procname = "reboot-cmd",
442 .data = reboot_command,
443 .maxlen = 256,
444 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800445 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446 },
447 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 .procname = "stop-a",
449 .data = &stop_a_enabled,
450 .maxlen = sizeof (int),
451 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800452 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 },
454 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 .procname = "scons-poweroff",
456 .data = &scons_pwroff,
457 .maxlen = sizeof (int),
458 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800459 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 },
461#endif
David S. Miller08714202008-11-16 23:49:24 -0800462#ifdef CONFIG_SPARC64
463 {
David S. Miller08714202008-11-16 23:49:24 -0800464 .procname = "tsb-ratio",
465 .data = &sysctl_tsb_ratio,
466 .maxlen = sizeof (int),
467 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800468 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800469 },
470#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471#ifdef __hppa__
472 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 .procname = "soft-power",
474 .data = &pwrsw_enabled,
475 .maxlen = sizeof (int),
476 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800477 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 },
479 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 .procname = "unaligned-trap",
481 .data = &unaligned_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#endif
487 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 .procname = "ctrl-alt-del",
489 .data = &C_A_D,
490 .maxlen = sizeof(int),
491 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800492 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400494#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200495 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200496 .procname = "ftrace_enabled",
497 .data = &ftrace_enabled,
498 .maxlen = sizeof(int),
499 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800500 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200501 },
502#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500503#ifdef CONFIG_STACK_TRACER
504 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500505 .procname = "stack_tracer_enabled",
506 .data = &stack_tracer_enabled,
507 .maxlen = sizeof(int),
508 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800509 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500510 },
511#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400512#ifdef CONFIG_TRACING
513 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100514 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400515 .data = &ftrace_dump_on_oops,
516 .maxlen = sizeof(int),
517 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800518 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400519 },
520#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200521#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 .procname = "modprobe",
524 .data = &modprobe_path,
525 .maxlen = KMOD_PATH_LEN,
526 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800527 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 },
Kees Cook3d433212009-04-02 15:49:29 -0700529 {
Kees Cook3d433212009-04-02 15:49:29 -0700530 .procname = "modules_disabled",
531 .data = &modules_disabled,
532 .maxlen = sizeof(int),
533 .mode = 0644,
534 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800535 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700536 .extra1 = &one,
537 .extra2 = &one,
538 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539#endif
Andrew Morton57ae2502006-06-23 02:05:47 -0700540#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100543 .data = &uevent_helper,
544 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800546 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 },
548#endif
549#ifdef CONFIG_CHR_DEV_SG
550 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 .procname = "sg-big-buff",
552 .data = &sg_big_buff,
553 .maxlen = sizeof (int),
554 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800555 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 },
557#endif
558#ifdef CONFIG_BSD_PROCESS_ACCT
559 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 .procname = "acct",
561 .data = &acct_parm,
562 .maxlen = 3*sizeof(int),
563 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800564 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 },
566#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567#ifdef CONFIG_MAGIC_SYSRQ
568 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800570 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 .maxlen = sizeof (int),
572 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800573 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 },
575#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700576#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700579 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 .maxlen = sizeof (int),
581 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800582 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700584#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 .procname = "threads-max",
587 .data = &max_threads,
588 .maxlen = sizeof(int),
589 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800590 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 },
592 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 .procname = "random",
594 .mode = 0555,
595 .child = random_table,
596 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 .procname = "overflowuid",
599 .data = &overflowuid,
600 .maxlen = sizeof(int),
601 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800602 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 .extra1 = &minolduid,
604 .extra2 = &maxolduid,
605 },
606 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 .procname = "overflowgid",
608 .data = &overflowgid,
609 .maxlen = sizeof(int),
610 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800611 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 .extra1 = &minolduid,
613 .extra2 = &maxolduid,
614 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800615#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616#ifdef CONFIG_MATHEMU
617 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 .procname = "ieee_emulation_warnings",
619 .data = &sysctl_ieee_emulation_warnings,
620 .maxlen = sizeof(int),
621 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800622 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 },
624#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 .procname = "userprocess_debug",
627 .data = &sysctl_userprocess_debug,
628 .maxlen = sizeof(int),
629 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800630 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631 },
632#endif
633 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 .procname = "pid_max",
635 .data = &pid_max,
636 .maxlen = sizeof (int),
637 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800638 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 .extra1 = &pid_max_min,
640 .extra2 = &pid_max_max,
641 },
642 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 .procname = "panic_on_oops",
644 .data = &panic_on_oops,
645 .maxlen = sizeof(int),
646 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800647 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800649#if defined CONFIG_PRINTK
650 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800651 .procname = "printk",
652 .data = &console_loglevel,
653 .maxlen = 4*sizeof(int),
654 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800655 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800656 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700659 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 .maxlen = sizeof(int),
661 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800662 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 },
664 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700666 .data = &printk_ratelimit_state.burst,
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,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 },
Dave Youngaf913222009-09-22 16:43:33 -0700671 {
Dave Youngaf913222009-09-22 16:43:33 -0700672 .procname = "printk_delay",
673 .data = &printk_delay_msec,
674 .maxlen = sizeof(int),
675 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800676 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700677 .extra1 = &zero,
678 .extra2 = &ten_thousand,
679 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800680#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 .procname = "ngroups_max",
683 .data = &ngroups_max,
684 .maxlen = sizeof (int),
685 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800686 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 },
688#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
689 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 .procname = "unknown_nmi_panic",
691 .data = &unknown_nmi_panic,
692 .maxlen = sizeof (int),
693 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800694 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 },
Don Zickus407984f2006-09-26 10:52:27 +0200696 {
Don Zickus407984f2006-09-26 10:52:27 +0200697 .procname = "nmi_watchdog",
698 .data = &nmi_watchdog_enabled,
699 .maxlen = sizeof (int),
700 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800701 .proc_handler = proc_nmi_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 },
703#endif
704#if defined(CONFIG_X86)
705 {
Don Zickus8da5add2006-09-26 10:52:27 +0200706 .procname = "panic_on_unrecovered_nmi",
707 .data = &panic_on_unrecovered_nmi,
708 .maxlen = sizeof(int),
709 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800710 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200711 },
712 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700713 .procname = "panic_on_io_nmi",
714 .data = &panic_on_io_nmi,
715 .maxlen = sizeof(int),
716 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800717 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700718 },
719 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 .procname = "bootloader_type",
721 .data = &bootloader_type,
722 .maxlen = sizeof (int),
723 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800724 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100726 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700727 .procname = "bootloader_version",
728 .data = &bootloader_version,
729 .maxlen = sizeof (int),
730 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800731 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700732 },
733 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100734 .procname = "kstack_depth_to_print",
735 .data = &kstack_depth_to_print,
736 .maxlen = sizeof(int),
737 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800738 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100739 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100740 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100741 .procname = "io_delay_type",
742 .data = &io_delay_type,
743 .maxlen = sizeof(int),
744 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800745 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100746 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800748#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 .procname = "randomize_va_space",
751 .data = &randomize_va_space,
752 .maxlen = sizeof(int),
753 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800754 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800756#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800757#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700758 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700759 .procname = "spin_retry",
760 .data = &spin_retry,
761 .maxlen = sizeof (int),
762 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800763 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700764 },
765#endif
Len Brown673d5b42007-07-28 03:33:16 -0400766#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800767 {
Pavel Machekc255d842006-02-20 18:27:58 -0800768 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700769 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800770 .maxlen = sizeof (unsigned long),
771 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800772 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800773 },
774#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800775#ifdef CONFIG_IA64
776 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800777 .procname = "ignore-unaligned-usertrap",
778 .data = &no_unaligned_warning,
779 .maxlen = sizeof (int),
780 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800781 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800782 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800783 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800784 .procname = "unaligned-dump-stack",
785 .data = &unaligned_dump_stack,
786 .maxlen = sizeof (int),
787 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800788 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800789 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800790#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700791#ifdef CONFIG_DETECT_SOFTLOCKUP
792 {
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200793 .procname = "softlockup_panic",
794 .data = &softlockup_panic,
795 .maxlen = sizeof(int),
796 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800797 .proc_handler = proc_dointvec_minmax,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200798 .extra1 = &zero,
799 .extra2 = &one,
800 },
801 {
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700802 .procname = "softlockup_thresh",
803 .data = &softlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200804 .maxlen = sizeof(int),
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700805 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800806 .proc_handler = proc_dosoftlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200807 .extra1 = &neg_one,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700808 .extra2 = &sixty,
809 },
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800810#endif
811#ifdef CONFIG_DETECT_HUNG_TASK
812 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800813 .procname = "hung_task_panic",
814 .data = &sysctl_hung_task_panic,
815 .maxlen = sizeof(int),
816 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800817 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800818 .extra1 = &zero,
819 .extra2 = &one,
820 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100821 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100822 .procname = "hung_task_check_count",
823 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100824 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100825 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800826 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100827 },
828 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100829 .procname = "hung_task_timeout_secs",
830 .data = &sysctl_hung_task_timeout_secs,
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_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100834 },
835 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100836 .procname = "hung_task_warnings",
837 .data = &sysctl_hung_task_warnings,
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_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100841 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700842#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200843#ifdef CONFIG_COMPAT
844 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200845 .procname = "compat-log",
846 .data = &compat_log,
847 .maxlen = sizeof (int),
848 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800849 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200850 },
851#endif
Ingo Molnar23f78d42006-06-27 02:54:53 -0700852#ifdef CONFIG_RT_MUTEXES
853 {
Ingo Molnar23f78d42006-06-27 02:54:53 -0700854 .procname = "max_lock_depth",
855 .data = &max_lock_depth,
856 .maxlen = sizeof(int),
857 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800858 .proc_handler = proc_dointvec,
Ingo Molnar23f78d42006-06-27 02:54:53 -0700859 },
860#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700861 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700862 .procname = "poweroff_cmd",
863 .data = &poweroff_cmd,
864 .maxlen = POWEROFF_CMD_PATH_LEN,
865 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800866 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700867 },
David Howells0b77f5b2008-04-29 01:01:32 -0700868#ifdef CONFIG_KEYS
869 {
David Howells0b77f5b2008-04-29 01:01:32 -0700870 .procname = "keys",
871 .mode = 0555,
872 .child = key_sysctls,
873 },
874#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700875#ifdef CONFIG_RCU_TORTURE_TEST
876 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700877 .procname = "rcutorture_runnable",
878 .data = &rcutorture_runnable,
879 .maxlen = sizeof(int),
880 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800881 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700882 },
883#endif
David Howells12e22c52009-04-03 16:42:35 +0100884#ifdef CONFIG_SLOW_WORK
885 {
David Howells12e22c52009-04-03 16:42:35 +0100886 .procname = "slow-work",
887 .mode = 0555,
888 .child = slow_work_sysctls,
889 },
890#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200891#ifdef CONFIG_PERF_EVENTS
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200892 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200893 .procname = "perf_event_paranoid",
894 .data = &sysctl_perf_event_paranoid,
895 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200896 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800897 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200898 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200899 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200900 .procname = "perf_event_mlock_kb",
901 .data = &sysctl_perf_event_mlock,
902 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200903 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800904 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200905 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200906 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200907 .procname = "perf_event_max_sample_rate",
908 .data = &sysctl_perf_event_sample_rate,
909 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200910 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800911 .proc_handler = proc_dointvec,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200912 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200913#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200914#ifdef CONFIG_KMEMCHECK
915 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200916 .procname = "kmemcheck",
917 .data = &kmemcheck_enabled,
918 .maxlen = sizeof(int),
919 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800920 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +0200921 },
922#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200923#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200924 {
Jens Axboe5e605b62009-08-05 09:07:21 +0200925 .procname = "blk_iopoll",
926 .data = &blk_iopoll_enabled,
927 .maxlen = sizeof(int),
928 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800929 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +0200930 },
Jens Axboecb684b52009-09-15 21:53:11 +0200931#endif
Andrew Mortoned2c12f2007-07-19 01:50:35 -0700932/*
933 * NOTE: do not add new entries to this table unless you have read
934 * Documentation/sysctl/ctl_unnumbered.txt
935 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700936 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700937};
938
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700939static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941 .procname = "overcommit_memory",
942 .data = &sysctl_overcommit_memory,
943 .maxlen = sizeof(sysctl_overcommit_memory),
944 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800945 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946 },
947 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700948 .procname = "panic_on_oom",
949 .data = &sysctl_panic_on_oom,
950 .maxlen = sizeof(sysctl_panic_on_oom),
951 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800952 .proc_handler = proc_dointvec,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700953 },
954 {
David Rientjesfe071d72007-10-16 23:25:56 -0700955 .procname = "oom_kill_allocating_task",
956 .data = &sysctl_oom_kill_allocating_task,
957 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
958 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800959 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -0700960 },
961 {
David Rientjesfef1bdd2008-02-07 00:14:07 -0800962 .procname = "oom_dump_tasks",
963 .data = &sysctl_oom_dump_tasks,
964 .maxlen = sizeof(sysctl_oom_dump_tasks),
965 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800966 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -0800967 },
968 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969 .procname = "overcommit_ratio",
970 .data = &sysctl_overcommit_ratio,
971 .maxlen = sizeof(sysctl_overcommit_ratio),
972 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800973 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700974 },
975 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700976 .procname = "page-cluster",
977 .data = &page_cluster,
978 .maxlen = sizeof(int),
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 = "dirty_background_ratio",
984 .data = &dirty_background_ratio,
985 .maxlen = sizeof(dirty_background_ratio),
986 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800987 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700988 .extra1 = &zero,
989 .extra2 = &one_hundred,
990 },
991 {
David Rientjes2da02992009-01-06 14:39:31 -0800992 .procname = "dirty_background_bytes",
993 .data = &dirty_background_bytes,
994 .maxlen = sizeof(dirty_background_bytes),
995 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800996 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800997 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -0800998 },
999 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000 .procname = "dirty_ratio",
1001 .data = &vm_dirty_ratio,
1002 .maxlen = sizeof(vm_dirty_ratio),
1003 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001004 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005 .extra1 = &zero,
1006 .extra2 = &one_hundred,
1007 },
1008 {
David Rientjes2da02992009-01-06 14:39:31 -08001009 .procname = "dirty_bytes",
1010 .data = &vm_dirty_bytes,
1011 .maxlen = sizeof(vm_dirty_bytes),
1012 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001013 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001014 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001015 },
1016 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001017 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001018 .data = &dirty_writeback_interval,
1019 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001020 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001021 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001022 },
1023 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001024 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001025 .data = &dirty_expire_interval,
1026 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001028 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001029 },
1030 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001031 .procname = "nr_pdflush_threads",
1032 .data = &nr_pdflush_threads,
1033 .maxlen = sizeof nr_pdflush_threads,
1034 .mode = 0444 /* read-only*/,
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 = "swappiness",
1039 .data = &vm_swappiness,
1040 .maxlen = sizeof(vm_swappiness),
1041 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001042 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043 .extra1 = &zero,
1044 .extra2 = &one_hundred,
1045 },
1046#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001047 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001049 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001050 .maxlen = sizeof(unsigned long),
1051 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001052 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053 .extra1 = (void *)&hugetlb_zero,
1054 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001055 },
1056#ifdef CONFIG_NUMA
1057 {
1058 .procname = "nr_hugepages_mempolicy",
1059 .data = NULL,
1060 .maxlen = sizeof(unsigned long),
1061 .mode = 0644,
1062 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1063 .extra1 = (void *)&hugetlb_zero,
1064 .extra2 = (void *)&hugetlb_infinity,
1065 },
1066#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001067 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068 .procname = "hugetlb_shm_group",
1069 .data = &sysctl_hugetlb_shm_group,
1070 .maxlen = sizeof(gid_t),
1071 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001072 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073 },
Mel Gorman396faf02007-07-17 04:03:13 -07001074 {
Mel Gorman396faf02007-07-17 04:03:13 -07001075 .procname = "hugepages_treat_as_movable",
1076 .data = &hugepages_treat_as_movable,
1077 .maxlen = sizeof(int),
1078 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001079 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001080 },
Adam Litke54f9f802007-10-16 01:26:20 -07001081 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001082 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001083 .data = NULL,
1084 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001085 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001086 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001087 .extra1 = (void *)&hugetlb_zero,
1088 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001089 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001090#endif
1091 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092 .procname = "lowmem_reserve_ratio",
1093 .data = &sysctl_lowmem_reserve_ratio,
1094 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1095 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001096 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097 },
1098 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001099 .procname = "drop_caches",
1100 .data = &sysctl_drop_caches,
1101 .maxlen = sizeof(int),
1102 .mode = 0644,
1103 .proc_handler = drop_caches_sysctl_handler,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001104 },
1105 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001106 .procname = "min_free_kbytes",
1107 .data = &min_free_kbytes,
1108 .maxlen = sizeof(min_free_kbytes),
1109 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001110 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001111 .extra1 = &zero,
1112 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001113 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001114 .procname = "percpu_pagelist_fraction",
1115 .data = &percpu_pagelist_fraction,
1116 .maxlen = sizeof(percpu_pagelist_fraction),
1117 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001118 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001119 .extra1 = &min_percpu_pagelist_fract,
1120 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121#ifdef CONFIG_MMU
1122 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001123 .procname = "max_map_count",
1124 .data = &sysctl_max_map_count,
1125 .maxlen = sizeof(sysctl_max_map_count),
1126 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001127 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001128 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001130#else
1131 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001132 .procname = "nr_trim_pages",
1133 .data = &sysctl_nr_trim_pages,
1134 .maxlen = sizeof(sysctl_nr_trim_pages),
1135 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001136 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001137 .extra1 = &zero,
1138 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139#endif
1140 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141 .procname = "laptop_mode",
1142 .data = &laptop_mode,
1143 .maxlen = sizeof(laptop_mode),
1144 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001145 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001146 },
1147 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148 .procname = "block_dump",
1149 .data = &block_dump,
1150 .maxlen = sizeof(block_dump),
1151 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001152 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001153 .extra1 = &zero,
1154 },
1155 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156 .procname = "vfs_cache_pressure",
1157 .data = &sysctl_vfs_cache_pressure,
1158 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1159 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001160 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 .extra1 = &zero,
1162 },
1163#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1164 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165 .procname = "legacy_va_layout",
1166 .data = &sysctl_legacy_va_layout,
1167 .maxlen = sizeof(sysctl_legacy_va_layout),
1168 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001169 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 .extra1 = &zero,
1171 },
1172#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001173#ifdef CONFIG_NUMA
1174 {
Christoph Lameter17436602006-01-18 17:42:32 -08001175 .procname = "zone_reclaim_mode",
1176 .data = &zone_reclaim_mode,
1177 .maxlen = sizeof(zone_reclaim_mode),
1178 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001179 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001180 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001181 },
Christoph Lameter96146342006-07-03 00:24:13 -07001182 {
Christoph Lameter96146342006-07-03 00:24:13 -07001183 .procname = "min_unmapped_ratio",
1184 .data = &sysctl_min_unmapped_ratio,
1185 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1186 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001187 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001188 .extra1 = &zero,
1189 .extra2 = &one_hundred,
1190 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001191 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001192 .procname = "min_slab_ratio",
1193 .data = &sysctl_min_slab_ratio,
1194 .maxlen = sizeof(sysctl_min_slab_ratio),
1195 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001196 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001197 .extra1 = &zero,
1198 .extra2 = &one_hundred,
1199 },
Christoph Lameter17436602006-01-18 17:42:32 -08001200#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001201#ifdef CONFIG_SMP
1202 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001203 .procname = "stat_interval",
1204 .data = &sysctl_stat_interval,
1205 .maxlen = sizeof(sysctl_stat_interval),
1206 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001207 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001208 },
1209#endif
David Howells6e141542009-12-15 19:27:45 +00001210#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001211 {
Eric Parised032182007-06-28 15:55:21 -04001212 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001213 .data = &dac_mmap_min_addr,
1214 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001215 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001216 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001217 },
David Howells6e141542009-12-15 19:27:45 +00001218#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001219#ifdef CONFIG_NUMA
1220 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001221 .procname = "numa_zonelist_order",
1222 .data = &numa_zonelist_order,
1223 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1224 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001225 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001226 },
1227#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001228#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001229 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001230 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001231 .procname = "vdso_enabled",
1232 .data = &vdso_enabled,
1233 .maxlen = sizeof(vdso_enabled),
1234 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001235 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001236 .extra1 = &zero,
1237 },
1238#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001239#ifdef CONFIG_HIGHMEM
1240 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001241 .procname = "highmem_is_dirtyable",
1242 .data = &vm_highmem_is_dirtyable,
1243 .maxlen = sizeof(vm_highmem_is_dirtyable),
1244 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001245 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001246 .extra1 = &zero,
1247 .extra2 = &one,
1248 },
1249#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001250 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001251 .procname = "scan_unevictable_pages",
1252 .data = &scan_unevictable_pages,
1253 .maxlen = sizeof(scan_unevictable_pages),
1254 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001255 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001256 },
Andi Kleen6a460792009-09-16 11:50:15 +02001257#ifdef CONFIG_MEMORY_FAILURE
1258 {
Andi Kleen6a460792009-09-16 11:50:15 +02001259 .procname = "memory_failure_early_kill",
1260 .data = &sysctl_memory_failure_early_kill,
1261 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1262 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001263 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001264 .extra1 = &zero,
1265 .extra2 = &one,
1266 },
1267 {
Andi Kleen6a460792009-09-16 11:50:15 +02001268 .procname = "memory_failure_recovery",
1269 .data = &sysctl_memory_failure_recovery,
1270 .maxlen = sizeof(sysctl_memory_failure_recovery),
1271 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001272 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001273 .extra1 = &zero,
1274 .extra2 = &one,
1275 },
1276#endif
1277
Andrew Morton2be7fe02007-07-15 23:41:21 -07001278/*
1279 * NOTE: do not add new entries to this table unless you have read
1280 * Documentation/sysctl/ctl_unnumbered.txt
1281 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001282 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001283};
1284
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001285#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001286static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001287 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001288};
1289#endif
1290
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001291static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001292 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001293 .procname = "inode-nr",
1294 .data = &inodes_stat,
1295 .maxlen = 2*sizeof(int),
1296 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001297 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001298 },
1299 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300 .procname = "inode-state",
1301 .data = &inodes_stat,
1302 .maxlen = 7*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 = "file-nr",
1308 .data = &files_stat,
1309 .maxlen = 3*sizeof(int),
1310 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001311 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312 },
1313 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001314 .procname = "file-max",
1315 .data = &files_stat.max_files,
1316 .maxlen = sizeof(int),
1317 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001318 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001319 },
1320 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001321 .procname = "nr_open",
1322 .data = &sysctl_nr_open,
1323 .maxlen = sizeof(int),
1324 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001325 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001326 .extra1 = &sysctl_nr_open_min,
1327 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001328 },
1329 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001330 .procname = "dentry-state",
1331 .data = &dentry_stat,
1332 .maxlen = 6*sizeof(int),
1333 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001334 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001335 },
1336 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337 .procname = "overflowuid",
1338 .data = &fs_overflowuid,
1339 .maxlen = sizeof(int),
1340 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001341 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342 .extra1 = &minolduid,
1343 .extra2 = &maxolduid,
1344 },
1345 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001346 .procname = "overflowgid",
1347 .data = &fs_overflowgid,
1348 .maxlen = sizeof(int),
1349 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001350 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001351 .extra1 = &minolduid,
1352 .extra2 = &maxolduid,
1353 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001354#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001356 .procname = "leases-enable",
1357 .data = &leases_enable,
1358 .maxlen = sizeof(int),
1359 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001360 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001361 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001362#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001363#ifdef CONFIG_DNOTIFY
1364 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001365 .procname = "dir-notify-enable",
1366 .data = &dir_notify_enable,
1367 .maxlen = sizeof(int),
1368 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001369 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001370 },
1371#endif
1372#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001373#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001374 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001375 .procname = "lease-break-time",
1376 .data = &lease_break_time,
1377 .maxlen = sizeof(int),
1378 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001379 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001381#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001382#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001383 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384 .procname = "aio-nr",
1385 .data = &aio_nr,
1386 .maxlen = sizeof(aio_nr),
1387 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001388 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389 },
1390 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391 .procname = "aio-max-nr",
1392 .data = &aio_max_nr,
1393 .maxlen = sizeof(aio_max_nr),
1394 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001395 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001396 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001397#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001398#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001399 {
Robert Love0399cb02005-07-13 12:38:18 -04001400 .procname = "inotify",
1401 .mode = 0555,
1402 .child = inotify_table,
1403 },
1404#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001405#ifdef CONFIG_EPOLL
1406 {
1407 .procname = "epoll",
1408 .mode = 0555,
1409 .child = epoll_table,
1410 },
1411#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001412#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001413 {
Alan Coxd6e71142005-06-23 00:09:43 -07001414 .procname = "suid_dumpable",
1415 .data = &suid_dumpable,
1416 .maxlen = sizeof(int),
1417 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001418 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001419 .extra1 = &zero,
1420 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001421 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001422#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1423 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001424 .procname = "binfmt_misc",
1425 .mode = 0555,
1426 .child = binfmt_misc_table,
1427 },
1428#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001429/*
1430 * NOTE: do not add new entries to this table unless you have read
1431 * Documentation/sysctl/ctl_unnumbered.txt
1432 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001433 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001434};
1435
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001436static struct ctl_table debug_table[] = {
David S. Miller4b177642010-03-01 00:02:23 -08001437#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001438 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001439 .procname = "exception-trace",
1440 .data = &show_unhandled_signals,
1441 .maxlen = sizeof(int),
1442 .mode = 0644,
1443 .proc_handler = proc_dointvec
1444 },
1445#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001446#if defined(CONFIG_OPTPROBES)
1447 {
1448 .procname = "kprobes-optimization",
1449 .data = &sysctl_kprobes_optimization,
1450 .maxlen = sizeof(int),
1451 .mode = 0644,
1452 .proc_handler = proc_kprobes_optimization_handler,
1453 .extra1 = &zero,
1454 .extra2 = &one,
1455 },
1456#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001457 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001458};
1459
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001460static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001461 { }
Robert Love0eeca282005-07-12 17:06:03 -04001462};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001463
Al Viro330d57f2005-11-04 10:18:40 +00001464static DEFINE_SPINLOCK(sysctl_lock);
1465
1466/* called under sysctl_lock */
1467static int use_table(struct ctl_table_header *p)
1468{
1469 if (unlikely(p->unregistering))
1470 return 0;
1471 p->used++;
1472 return 1;
1473}
1474
1475/* called under sysctl_lock */
1476static void unuse_table(struct ctl_table_header *p)
1477{
1478 if (!--p->used)
1479 if (unlikely(p->unregistering))
1480 complete(p->unregistering);
1481}
1482
1483/* called under sysctl_lock, will reacquire if has to wait */
1484static void start_unregistering(struct ctl_table_header *p)
1485{
1486 /*
1487 * if p->used is 0, nobody will ever touch that entry again;
1488 * we'll eliminate all paths to it before dropping sysctl_lock
1489 */
1490 if (unlikely(p->used)) {
1491 struct completion wait;
1492 init_completion(&wait);
1493 p->unregistering = &wait;
1494 spin_unlock(&sysctl_lock);
1495 wait_for_completion(&wait);
1496 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001497 } else {
1498 /* anything non-NULL; we'll never dereference it */
1499 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001500 }
1501 /*
1502 * do not remove from the list until nobody holds it; walking the
1503 * list in do_sysctl() relies on that.
1504 */
1505 list_del_init(&p->ctl_entry);
1506}
1507
Al Virof7e6ced2008-07-15 01:44:23 -04001508void sysctl_head_get(struct ctl_table_header *head)
1509{
1510 spin_lock(&sysctl_lock);
1511 head->count++;
1512 spin_unlock(&sysctl_lock);
1513}
1514
1515void sysctl_head_put(struct ctl_table_header *head)
1516{
1517 spin_lock(&sysctl_lock);
1518 if (!--head->count)
1519 kfree(head);
1520 spin_unlock(&sysctl_lock);
1521}
1522
1523struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1524{
1525 if (!head)
1526 BUG();
1527 spin_lock(&sysctl_lock);
1528 if (!use_table(head))
1529 head = ERR_PTR(-ENOENT);
1530 spin_unlock(&sysctl_lock);
1531 return head;
1532}
1533
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001534void sysctl_head_finish(struct ctl_table_header *head)
1535{
1536 if (!head)
1537 return;
1538 spin_lock(&sysctl_lock);
1539 unuse_table(head);
1540 spin_unlock(&sysctl_lock);
1541}
1542
Al Viro73455092008-07-14 21:22:20 -04001543static struct ctl_table_set *
1544lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1545{
1546 struct ctl_table_set *set = &root->default_set;
1547 if (root->lookup)
1548 set = root->lookup(root, namespaces);
1549 return set;
1550}
1551
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001552static struct list_head *
1553lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001554{
Al Viro73455092008-07-14 21:22:20 -04001555 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1556 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001557}
1558
1559struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1560 struct ctl_table_header *prev)
1561{
1562 struct ctl_table_root *root;
1563 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001564 struct ctl_table_header *head;
1565 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001566
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001567 spin_lock(&sysctl_lock);
1568 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001569 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001570 tmp = &prev->ctl_entry;
1571 unuse_table(prev);
1572 goto next;
1573 }
1574 tmp = &root_table_header.ctl_entry;
1575 for (;;) {
1576 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1577
1578 if (!use_table(head))
1579 goto next;
1580 spin_unlock(&sysctl_lock);
1581 return head;
1582 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001583 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001584 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001585 header_list = lookup_header_list(root, namespaces);
1586 if (tmp != header_list)
1587 continue;
1588
1589 do {
1590 root = list_entry(root->root_list.next,
1591 struct ctl_table_root, root_list);
1592 if (root == &sysctl_table_root)
1593 goto out;
1594 header_list = lookup_header_list(root, namespaces);
1595 } while (list_empty(header_list));
1596 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001597 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001598out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001599 spin_unlock(&sysctl_lock);
1600 return NULL;
1601}
1602
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001603struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1604{
1605 return __sysctl_head_next(current->nsproxy, prev);
1606}
1607
1608void register_sysctl_root(struct ctl_table_root *root)
1609{
1610 spin_lock(&sysctl_lock);
1611 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1612 spin_unlock(&sysctl_lock);
1613}
1614
Linus Torvalds1da177e2005-04-16 15:20:36 -07001615/*
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001616 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001617 * some sysctl variables are readonly even to root.
1618 */
1619
1620static int test_perm(int mode, int op)
1621{
David Howells76aac0e2008-11-14 10:39:12 +11001622 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001623 mode >>= 6;
1624 else if (in_egroup_p(0))
1625 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001626 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001627 return 0;
1628 return -EACCES;
1629}
1630
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001631int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001632{
1633 int error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001634 int mode;
1635
Al Viroe6305c42008-07-15 21:03:57 -04001636 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001637 if (error)
1638 return error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001639
1640 if (root->permissions)
1641 mode = root->permissions(root, current->nsproxy, table);
1642 else
1643 mode = table->mode;
1644
1645 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001646}
1647
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001648static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1649{
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001650 for (; table->procname; table++) {
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001651 table->parent = parent;
1652 if (table->child)
1653 sysctl_set_parent(table, table->child);
1654 }
1655}
1656
1657static __init int sysctl_init(void)
1658{
1659 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001660#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1661 {
1662 int err;
1663 err = sysctl_check_table(current->nsproxy, root_table);
1664 }
1665#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001666 return 0;
1667}
1668
1669core_initcall(sysctl_init);
1670
Al Virobfbcf032008-07-27 06:31:22 +01001671static struct ctl_table *is_branch_in(struct ctl_table *branch,
1672 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001673{
1674 struct ctl_table *p;
1675 const char *s = branch->procname;
1676
1677 /* branch should have named subdirectory as its first element */
1678 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001679 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001680
1681 /* ... and nothing else */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001682 if (branch[1].procname)
Al Virobfbcf032008-07-27 06:31:22 +01001683 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001684
1685 /* table should contain subdirectory with the same name */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001686 for (p = table; p->procname; p++) {
Al Viroae7edec2008-07-15 06:33:31 -04001687 if (!p->child)
1688 continue;
1689 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001690 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001691 }
Al Virobfbcf032008-07-27 06:31:22 +01001692 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001693}
1694
1695/* see if attaching q to p would be an improvement */
1696static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1697{
1698 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001699 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001700 int is_better = 0;
1701 int not_in_parent = !p->attached_by;
1702
Al Virobfbcf032008-07-27 06:31:22 +01001703 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001704 if (by == q->attached_by)
1705 is_better = 1;
1706 if (to == p->attached_by)
1707 not_in_parent = 1;
1708 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001709 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001710 }
1711
1712 if (is_better && not_in_parent) {
1713 q->attached_by = by;
1714 q->attached_to = to;
1715 q->parent = p;
1716 }
1717}
1718
Linus Torvalds1da177e2005-04-16 15:20:36 -07001719/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001720 * __register_sysctl_paths - register a sysctl hierarchy
1721 * @root: List of sysctl headers to register on
1722 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001723 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001724 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001725 *
1726 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001727 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001728 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001729 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001730 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001731 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1732 * enter a sysctl file
1733 *
1734 * data - a pointer to data for use by proc_handler
1735 *
1736 * maxlen - the maximum size in bytes of the data
1737 *
1738 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1739 *
1740 * child - a pointer to the child sysctl table if this entry is a directory, or
1741 * %NULL.
1742 *
1743 * proc_handler - the text handler routine (described below)
1744 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001745 * de - for internal use by the sysctl routines
1746 *
1747 * extra1, extra2 - extra pointers usable by the proc handler routines
1748 *
1749 * Leaf nodes in the sysctl tree will be represented by a single file
1750 * under /proc; non-leaf nodes will be represented by directories.
1751 *
1752 * sysctl(2) can automatically manage read and write requests through
1753 * the sysctl table. The data and maxlen fields of the ctl_table
1754 * struct enable minimal validation of the values being written to be
1755 * performed, and the mode field allows minimal authentication.
1756 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001757 * There must be a proc_handler routine for any terminal nodes
1758 * mirrored under /proc/sys (non-terminals are handled by a built-in
1759 * directory handler). Several default handlers are available to
1760 * cover common cases -
1761 *
1762 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1763 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1764 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1765 *
1766 * It is the handler's job to read the input buffer from user memory
1767 * and process it. The handler should return 0 on success.
1768 *
1769 * This routine returns %NULL on a failure to register, and a pointer
1770 * to the table header on success.
1771 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001772struct ctl_table_header *__register_sysctl_paths(
1773 struct ctl_table_root *root,
1774 struct nsproxy *namespaces,
1775 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001776{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001777 struct ctl_table_header *header;
1778 struct ctl_table *new, **prevp;
1779 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001780 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001781
1782 /* Count the path components */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001783 for (npath = 0; path[npath].procname; ++npath)
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001784 ;
1785
1786 /*
1787 * For each path component, allocate a 2-element ctl_table array.
1788 * The first array element will be filled with the sysctl entry
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001789 * for this, the second will be the sentinel (procname == 0).
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001790 *
1791 * We allocate everything in one go so that we don't have to
1792 * worry about freeing additional memory in unregister_sysctl_table.
1793 */
1794 header = kzalloc(sizeof(struct ctl_table_header) +
1795 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1796 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001797 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001798
1799 new = (struct ctl_table *) (header + 1);
1800
1801 /* Now connect the dots */
1802 prevp = &header->ctl_table;
1803 for (n = 0; n < npath; ++n, ++path) {
1804 /* Copy the procname */
1805 new->procname = path->procname;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001806 new->mode = 0555;
1807
1808 *prevp = new;
1809 prevp = &new->child;
1810
1811 new += 2;
1812 }
1813 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001814 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001815
1816 INIT_LIST_HEAD(&header->ctl_entry);
1817 header->used = 0;
1818 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001819 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001820 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001821 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001822#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001823 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001824 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001825 return NULL;
1826 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001827#endif
Al Viro330d57f2005-11-04 10:18:40 +00001828 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001829 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001830 header->attached_by = header->ctl_table;
1831 header->attached_to = root_table;
1832 header->parent = &root_table_header;
1833 for (set = header->set; set; set = set->parent) {
1834 struct ctl_table_header *p;
1835 list_for_each_entry(p, &set->list, ctl_entry) {
1836 if (p->unregistering)
1837 continue;
1838 try_attach(p, header);
1839 }
1840 }
1841 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001842 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001843 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001844
1845 return header;
1846}
1847
1848/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001849 * register_sysctl_table_path - register a sysctl table hierarchy
1850 * @path: The path to the directory the sysctl table is in.
1851 * @table: the top-level table structure
1852 *
1853 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1854 * array. A completely 0 filled entry terminates the table.
1855 *
1856 * See __register_sysctl_paths for more details.
1857 */
1858struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1859 struct ctl_table *table)
1860{
1861 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1862 path, table);
1863}
1864
1865/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001866 * register_sysctl_table - register a sysctl table hierarchy
1867 * @table: the top-level table structure
1868 *
1869 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1870 * array. A completely 0 filled entry terminates the table.
1871 *
1872 * See register_sysctl_paths for more details.
1873 */
1874struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1875{
1876 static const struct ctl_path null_path[] = { {} };
1877
1878 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001879}
1880
1881/**
1882 * unregister_sysctl_table - unregister a sysctl table hierarchy
1883 * @header: the header returned from register_sysctl_table
1884 *
1885 * Unregisters the sysctl table and all children. proc entries may not
1886 * actually be removed until they are no longer used by anyone.
1887 */
1888void unregister_sysctl_table(struct ctl_table_header * header)
1889{
Al Viro330d57f2005-11-04 10:18:40 +00001890 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08001891
1892 if (header == NULL)
1893 return;
1894
Al Viro330d57f2005-11-04 10:18:40 +00001895 spin_lock(&sysctl_lock);
1896 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04001897 if (!--header->parent->count) {
1898 WARN_ON(1);
1899 kfree(header->parent);
1900 }
Al Virof7e6ced2008-07-15 01:44:23 -04001901 if (!--header->count)
1902 kfree(header);
Al Viro330d57f2005-11-04 10:18:40 +00001903 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001904}
1905
Al Viro90434762008-07-15 08:54:06 -04001906int sysctl_is_seen(struct ctl_table_header *p)
1907{
1908 struct ctl_table_set *set = p->set;
1909 int res;
1910 spin_lock(&sysctl_lock);
1911 if (p->unregistering)
1912 res = 0;
1913 else if (!set->is_seen)
1914 res = 1;
1915 else
1916 res = set->is_seen(set);
1917 spin_unlock(&sysctl_lock);
1918 return res;
1919}
1920
Al Viro73455092008-07-14 21:22:20 -04001921void setup_sysctl_set(struct ctl_table_set *p,
1922 struct ctl_table_set *parent,
1923 int (*is_seen)(struct ctl_table_set *))
1924{
1925 INIT_LIST_HEAD(&p->list);
1926 p->parent = parent ? parent : &sysctl_table_root.default_set;
1927 p->is_seen = is_seen;
1928}
1929
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001930#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001931struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001932{
1933 return NULL;
1934}
1935
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001936struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1937 struct ctl_table *table)
1938{
1939 return NULL;
1940}
1941
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001942void unregister_sysctl_table(struct ctl_table_header * table)
1943{
1944}
1945
Al Viro73455092008-07-14 21:22:20 -04001946void setup_sysctl_set(struct ctl_table_set *p,
1947 struct ctl_table_set *parent,
1948 int (*is_seen)(struct ctl_table_set *))
1949{
1950}
1951
Al Virof7e6ced2008-07-15 01:44:23 -04001952void sysctl_head_put(struct ctl_table_header *head)
1953{
1954}
1955
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001956#endif /* CONFIG_SYSCTL */
1957
Linus Torvalds1da177e2005-04-16 15:20:36 -07001958/*
1959 * /proc/sys support
1960 */
1961
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001962#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001963
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001964static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001965 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001966 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001967{
1968 size_t len;
1969 char __user *p;
1970 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001971
1972 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001973 *lenp = 0;
1974 return 0;
1975 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001976
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001977 if (write) {
1978 len = 0;
1979 p = buffer;
1980 while (len < *lenp) {
1981 if (get_user(c, p++))
1982 return -EFAULT;
1983 if (c == 0 || c == '\n')
1984 break;
1985 len++;
1986 }
1987 if (len >= maxlen)
1988 len = maxlen-1;
1989 if(copy_from_user(data, buffer, len))
1990 return -EFAULT;
1991 ((char *) data)[len] = 0;
1992 *ppos += *lenp;
1993 } else {
1994 len = strlen(data);
1995 if (len > maxlen)
1996 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001997
1998 if (*ppos > len) {
1999 *lenp = 0;
2000 return 0;
2001 }
2002
2003 data += *ppos;
2004 len -= *ppos;
2005
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002006 if (len > *lenp)
2007 len = *lenp;
2008 if (len)
2009 if(copy_to_user(buffer, data, len))
2010 return -EFAULT;
2011 if (len < *lenp) {
2012 if(put_user('\n', ((char __user *) buffer) + len))
2013 return -EFAULT;
2014 len++;
2015 }
2016 *lenp = len;
2017 *ppos += len;
2018 }
2019 return 0;
2020}
2021
Linus Torvalds1da177e2005-04-16 15:20:36 -07002022/**
2023 * proc_dostring - read a string sysctl
2024 * @table: the sysctl table
2025 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002026 * @buffer: the user buffer
2027 * @lenp: the size of the user buffer
2028 * @ppos: file position
2029 *
2030 * Reads/writes a string from/to the user buffer. If the kernel
2031 * buffer provided is not large enough to hold the string, the
2032 * string is truncated. The copied string is %NULL-terminated.
2033 * If the string is being read by the user process, it is copied
2034 * and a newline '\n' is added. It is truncated if the buffer is
2035 * not large enough.
2036 *
2037 * Returns 0 on success.
2038 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002039int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002040 void __user *buffer, size_t *lenp, loff_t *ppos)
2041{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002042 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002043 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002044}
2045
Linus Torvalds1da177e2005-04-16 15:20:36 -07002046
2047static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2048 int *valp,
2049 int write, void *data)
2050{
2051 if (write) {
2052 *valp = *negp ? -*lvalp : *lvalp;
2053 } else {
2054 int val = *valp;
2055 if (val < 0) {
2056 *negp = -1;
2057 *lvalp = (unsigned long)-val;
2058 } else {
2059 *negp = 0;
2060 *lvalp = (unsigned long)val;
2061 }
2062 }
2063 return 0;
2064}
2065
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002066static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002067 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002068 size_t *lenp, loff_t *ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002069 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2070 int write, void *data),
2071 void *data)
2072{
2073#define TMPBUFLEN 21
Sukanto Ghosh7338f292009-06-17 16:27:50 -07002074 int *i, vleft, first = 1, neg;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002075 unsigned long lval;
2076 size_t left, len;
2077
2078 char buf[TMPBUFLEN], *p;
2079 char __user *s = buffer;
2080
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002081 if (!tbl_data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002082 (*ppos && !write)) {
2083 *lenp = 0;
2084 return 0;
2085 }
2086
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002087 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002088 vleft = table->maxlen / sizeof(*i);
2089 left = *lenp;
2090
2091 if (!conv)
2092 conv = do_proc_dointvec_conv;
2093
2094 for (; left && vleft--; i++, first=0) {
2095 if (write) {
2096 while (left) {
2097 char c;
2098 if (get_user(c, s))
2099 return -EFAULT;
2100 if (!isspace(c))
2101 break;
2102 left--;
2103 s++;
2104 }
2105 if (!left)
2106 break;
2107 neg = 0;
2108 len = left;
2109 if (len > sizeof(buf) - 1)
2110 len = sizeof(buf) - 1;
2111 if (copy_from_user(buf, s, len))
2112 return -EFAULT;
2113 buf[len] = 0;
2114 p = buf;
2115 if (*p == '-' && left > 1) {
2116 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002117 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002118 }
2119 if (*p < '0' || *p > '9')
2120 break;
2121
2122 lval = simple_strtoul(p, &p, 0);
2123
2124 len = p-buf;
2125 if ((len < left) && *p && !isspace(*p))
2126 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002127 s += len;
2128 left -= len;
2129
2130 if (conv(&neg, &lval, i, 1, data))
2131 break;
2132 } else {
2133 p = buf;
2134 if (!first)
2135 *p++ = '\t';
2136
2137 if (conv(&neg, &lval, i, 0, data))
2138 break;
2139
2140 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2141 len = strlen(buf);
2142 if (len > left)
2143 len = left;
2144 if(copy_to_user(s, buf, len))
2145 return -EFAULT;
2146 left -= len;
2147 s += len;
2148 }
2149 }
2150
2151 if (!write && !first && left) {
2152 if(put_user('\n', s))
2153 return -EFAULT;
2154 left--, s++;
2155 }
2156 if (write) {
2157 while (left) {
2158 char c;
2159 if (get_user(c, s++))
2160 return -EFAULT;
2161 if (!isspace(c))
2162 break;
2163 left--;
2164 }
2165 }
2166 if (write && first)
2167 return -EINVAL;
2168 *lenp -= left;
2169 *ppos += *lenp;
2170 return 0;
2171#undef TMPBUFLEN
2172}
2173
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002174static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002175 void __user *buffer, size_t *lenp, loff_t *ppos,
2176 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2177 int write, void *data),
2178 void *data)
2179{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002180 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002181 buffer, lenp, ppos, conv, data);
2182}
2183
Linus Torvalds1da177e2005-04-16 15:20:36 -07002184/**
2185 * proc_dointvec - read a vector of integers
2186 * @table: the sysctl table
2187 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188 * @buffer: the user buffer
2189 * @lenp: the size of the user buffer
2190 * @ppos: file position
2191 *
2192 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2193 * values from/to the user buffer, treated as an ASCII string.
2194 *
2195 * Returns 0 on success.
2196 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002197int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002198 void __user *buffer, size_t *lenp, loff_t *ppos)
2199{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002200 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002201 NULL,NULL);
2202}
2203
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002204/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002205 * Taint values can only be increased
2206 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002207 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002208static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002209 void __user *buffer, size_t *lenp, loff_t *ppos)
2210{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002211 struct ctl_table t;
2212 unsigned long tmptaint = get_taint();
2213 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002214
Bastian Blank91fcd412007-04-23 14:41:14 -07002215 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002216 return -EPERM;
2217
Andi Kleen25ddbb12008-10-15 22:01:41 -07002218 t = *table;
2219 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002220 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002221 if (err < 0)
2222 return err;
2223
2224 if (write) {
2225 /*
2226 * Poor man's atomic or. Not worth adding a primitive
2227 * to everyone's atomic.h for this
2228 */
2229 int i;
2230 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2231 if ((tmptaint >> i) & 1)
2232 add_taint(i);
2233 }
2234 }
2235
2236 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002237}
2238
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239struct do_proc_dointvec_minmax_conv_param {
2240 int *min;
2241 int *max;
2242};
2243
2244static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2245 int *valp,
2246 int write, void *data)
2247{
2248 struct do_proc_dointvec_minmax_conv_param *param = data;
2249 if (write) {
2250 int val = *negp ? -*lvalp : *lvalp;
2251 if ((param->min && *param->min > val) ||
2252 (param->max && *param->max < val))
2253 return -EINVAL;
2254 *valp = val;
2255 } else {
2256 int val = *valp;
2257 if (val < 0) {
2258 *negp = -1;
2259 *lvalp = (unsigned long)-val;
2260 } else {
2261 *negp = 0;
2262 *lvalp = (unsigned long)val;
2263 }
2264 }
2265 return 0;
2266}
2267
2268/**
2269 * proc_dointvec_minmax - read a vector of integers with min/max values
2270 * @table: the sysctl table
2271 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002272 * @buffer: the user buffer
2273 * @lenp: the size of the user buffer
2274 * @ppos: file position
2275 *
2276 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2277 * values from/to the user buffer, treated as an ASCII string.
2278 *
2279 * This routine will ensure the values are within the range specified by
2280 * table->extra1 (min) and table->extra2 (max).
2281 *
2282 * Returns 0 on success.
2283 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002284int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002285 void __user *buffer, size_t *lenp, loff_t *ppos)
2286{
2287 struct do_proc_dointvec_minmax_conv_param param = {
2288 .min = (int *) table->extra1,
2289 .max = (int *) table->extra2,
2290 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002291 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002292 do_proc_dointvec_minmax_conv, &param);
2293}
2294
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002295static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002296 void __user *buffer,
2297 size_t *lenp, loff_t *ppos,
2298 unsigned long convmul,
2299 unsigned long convdiv)
2300{
2301#define TMPBUFLEN 21
2302 unsigned long *i, *min, *max, val;
2303 int vleft, first=1, neg;
2304 size_t len, left;
2305 char buf[TMPBUFLEN], *p;
2306 char __user *s = buffer;
2307
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002308 if (!data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002309 (*ppos && !write)) {
2310 *lenp = 0;
2311 return 0;
2312 }
2313
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002314 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002315 min = (unsigned long *) table->extra1;
2316 max = (unsigned long *) table->extra2;
2317 vleft = table->maxlen / sizeof(unsigned long);
2318 left = *lenp;
2319
2320 for (; left && vleft--; i++, min++, max++, first=0) {
2321 if (write) {
2322 while (left) {
2323 char c;
2324 if (get_user(c, s))
2325 return -EFAULT;
2326 if (!isspace(c))
2327 break;
2328 left--;
2329 s++;
2330 }
2331 if (!left)
2332 break;
2333 neg = 0;
2334 len = left;
2335 if (len > TMPBUFLEN-1)
2336 len = TMPBUFLEN-1;
2337 if (copy_from_user(buf, s, len))
2338 return -EFAULT;
2339 buf[len] = 0;
2340 p = buf;
2341 if (*p == '-' && left > 1) {
2342 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002343 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002344 }
2345 if (*p < '0' || *p > '9')
2346 break;
2347 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2348 len = p-buf;
2349 if ((len < left) && *p && !isspace(*p))
2350 break;
2351 if (neg)
2352 val = -val;
2353 s += len;
2354 left -= len;
2355
2356 if(neg)
2357 continue;
2358 if ((min && val < *min) || (max && val > *max))
2359 continue;
2360 *i = val;
2361 } else {
2362 p = buf;
2363 if (!first)
2364 *p++ = '\t';
2365 sprintf(p, "%lu", convdiv * (*i) / convmul);
2366 len = strlen(buf);
2367 if (len > left)
2368 len = left;
2369 if(copy_to_user(s, buf, len))
2370 return -EFAULT;
2371 left -= len;
2372 s += len;
2373 }
2374 }
2375
2376 if (!write && !first && left) {
2377 if(put_user('\n', s))
2378 return -EFAULT;
2379 left--, s++;
2380 }
2381 if (write) {
2382 while (left) {
2383 char c;
2384 if (get_user(c, s++))
2385 return -EFAULT;
2386 if (!isspace(c))
2387 break;
2388 left--;
2389 }
2390 }
2391 if (write && first)
2392 return -EINVAL;
2393 *lenp -= left;
2394 *ppos += *lenp;
2395 return 0;
2396#undef TMPBUFLEN
2397}
2398
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002399static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002400 void __user *buffer,
2401 size_t *lenp, loff_t *ppos,
2402 unsigned long convmul,
2403 unsigned long convdiv)
2404{
2405 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002406 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002407}
2408
Linus Torvalds1da177e2005-04-16 15:20:36 -07002409/**
2410 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2411 * @table: the sysctl table
2412 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002413 * @buffer: the user buffer
2414 * @lenp: the size of the user buffer
2415 * @ppos: file position
2416 *
2417 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2418 * values from/to the user buffer, treated as an ASCII string.
2419 *
2420 * This routine will ensure the values are within the range specified by
2421 * table->extra1 (min) and table->extra2 (max).
2422 *
2423 * Returns 0 on success.
2424 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002425int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002426 void __user *buffer, size_t *lenp, loff_t *ppos)
2427{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002428 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002429}
2430
2431/**
2432 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2433 * @table: the sysctl table
2434 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002435 * @buffer: the user buffer
2436 * @lenp: the size of the user buffer
2437 * @ppos: file position
2438 *
2439 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2440 * values from/to the user buffer, treated as an ASCII string. The values
2441 * are treated as milliseconds, and converted to jiffies when they are stored.
2442 *
2443 * This routine will ensure the values are within the range specified by
2444 * table->extra1 (min) and table->extra2 (max).
2445 *
2446 * Returns 0 on success.
2447 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002448int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002449 void __user *buffer,
2450 size_t *lenp, loff_t *ppos)
2451{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002452 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453 lenp, ppos, HZ, 1000l);
2454}
2455
2456
2457static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2458 int *valp,
2459 int write, void *data)
2460{
2461 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002462 if (*lvalp > LONG_MAX / HZ)
2463 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002464 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2465 } else {
2466 int val = *valp;
2467 unsigned long lval;
2468 if (val < 0) {
2469 *negp = -1;
2470 lval = (unsigned long)-val;
2471 } else {
2472 *negp = 0;
2473 lval = (unsigned long)val;
2474 }
2475 *lvalp = lval / HZ;
2476 }
2477 return 0;
2478}
2479
2480static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2481 int *valp,
2482 int write, void *data)
2483{
2484 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002485 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2486 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002487 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2488 } else {
2489 int val = *valp;
2490 unsigned long lval;
2491 if (val < 0) {
2492 *negp = -1;
2493 lval = (unsigned long)-val;
2494 } else {
2495 *negp = 0;
2496 lval = (unsigned long)val;
2497 }
2498 *lvalp = jiffies_to_clock_t(lval);
2499 }
2500 return 0;
2501}
2502
2503static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2504 int *valp,
2505 int write, void *data)
2506{
2507 if (write) {
2508 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2509 } else {
2510 int val = *valp;
2511 unsigned long lval;
2512 if (val < 0) {
2513 *negp = -1;
2514 lval = (unsigned long)-val;
2515 } else {
2516 *negp = 0;
2517 lval = (unsigned long)val;
2518 }
2519 *lvalp = jiffies_to_msecs(lval);
2520 }
2521 return 0;
2522}
2523
2524/**
2525 * proc_dointvec_jiffies - read a vector of integers as seconds
2526 * @table: the sysctl table
2527 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002528 * @buffer: the user buffer
2529 * @lenp: the size of the user buffer
2530 * @ppos: file position
2531 *
2532 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2533 * values from/to the user buffer, treated as an ASCII string.
2534 * The values read are assumed to be in seconds, and are converted into
2535 * jiffies.
2536 *
2537 * Returns 0 on success.
2538 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002539int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002540 void __user *buffer, size_t *lenp, loff_t *ppos)
2541{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002542 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002543 do_proc_dointvec_jiffies_conv,NULL);
2544}
2545
2546/**
2547 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2548 * @table: the sysctl table
2549 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550 * @buffer: the user buffer
2551 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002552 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002553 *
2554 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2555 * values from/to the user buffer, treated as an ASCII string.
2556 * The values read are assumed to be in 1/USER_HZ seconds, and
2557 * are converted into jiffies.
2558 *
2559 * Returns 0 on success.
2560 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002561int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002562 void __user *buffer, size_t *lenp, loff_t *ppos)
2563{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002564 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002565 do_proc_dointvec_userhz_jiffies_conv,NULL);
2566}
2567
2568/**
2569 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2570 * @table: the sysctl table
2571 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002572 * @buffer: the user buffer
2573 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002574 * @ppos: file position
2575 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002576 *
2577 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2578 * values from/to the user buffer, treated as an ASCII string.
2579 * The values read are assumed to be in 1/1000 seconds, and
2580 * are converted into jiffies.
2581 *
2582 * Returns 0 on success.
2583 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002584int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002585 void __user *buffer, size_t *lenp, loff_t *ppos)
2586{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002587 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002588 do_proc_dointvec_ms_jiffies_conv, NULL);
2589}
2590
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002591static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002592 void __user *buffer, size_t *lenp, loff_t *ppos)
2593{
2594 struct pid *new_pid;
2595 pid_t tmp;
2596 int r;
2597
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002598 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002599
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002600 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002601 lenp, ppos, NULL, NULL);
2602 if (r || !write)
2603 return r;
2604
2605 new_pid = find_get_pid(tmp);
2606 if (!new_pid)
2607 return -ESRCH;
2608
2609 put_pid(xchg(&cad_pid, new_pid));
2610 return 0;
2611}
2612
Linus Torvalds1da177e2005-04-16 15:20:36 -07002613#else /* CONFIG_PROC_FS */
2614
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002615int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002616 void __user *buffer, size_t *lenp, loff_t *ppos)
2617{
2618 return -ENOSYS;
2619}
2620
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002621int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002622 void __user *buffer, size_t *lenp, loff_t *ppos)
2623{
2624 return -ENOSYS;
2625}
2626
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002627int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002628 void __user *buffer, size_t *lenp, loff_t *ppos)
2629{
2630 return -ENOSYS;
2631}
2632
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002633int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002634 void __user *buffer, size_t *lenp, loff_t *ppos)
2635{
2636 return -ENOSYS;
2637}
2638
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002639int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002640 void __user *buffer, size_t *lenp, loff_t *ppos)
2641{
2642 return -ENOSYS;
2643}
2644
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002645int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002646 void __user *buffer, size_t *lenp, loff_t *ppos)
2647{
2648 return -ENOSYS;
2649}
2650
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002651int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652 void __user *buffer, size_t *lenp, loff_t *ppos)
2653{
2654 return -ENOSYS;
2655}
2656
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002657int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002658 void __user *buffer,
2659 size_t *lenp, loff_t *ppos)
2660{
2661 return -ENOSYS;
2662}
2663
2664
2665#endif /* CONFIG_PROC_FS */
2666
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667/*
2668 * No sense putting this after each symbol definition, twice,
2669 * exception granted :-)
2670 */
2671EXPORT_SYMBOL(proc_dointvec);
2672EXPORT_SYMBOL(proc_dointvec_jiffies);
2673EXPORT_SYMBOL(proc_dointvec_minmax);
2674EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2675EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2676EXPORT_SYMBOL(proc_dostring);
2677EXPORT_SYMBOL(proc_doulongvec_minmax);
2678EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2679EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002680EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002681EXPORT_SYMBOL(unregister_sysctl_table);