blob: f18aaa7b0d654df7a1c758b116164a8e9b3d3834 [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
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200119#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120extern char modprobe_path[];
Kees Cook3d433212009-04-02 15:49:29 -0700121extern int modules_disabled;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123#ifdef CONFIG_CHR_DEV_SG
124extern int sg_big_buff;
125#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126
David S. Miller72c57ed2008-09-11 23:29:54 -0700127#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700128#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129#endif
130
David S. Miller08714202008-11-16 23:49:24 -0800131#ifdef CONFIG_SPARC64
132extern int sysctl_tsb_ratio;
133#endif
134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135#ifdef __hppa__
136extern int pwrsw_enabled;
137extern int unaligned_enabled;
138#endif
139
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800140#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141#ifdef CONFIG_MATHEMU
142extern int sysctl_ieee_emulation_warnings;
143#endif
144extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700145extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146#endif
147
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148#ifdef CONFIG_BSD_PROCESS_ACCT
149extern int acct_parm[];
150#endif
151
Jes Sorensend2b176e2006-02-28 09:42:23 -0800152#ifdef CONFIG_IA64
153extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800154extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800155#endif
156
Ingo Molnar3fff4c42009-09-22 16:18:09 +0200157extern struct ratelimit_state printk_ratelimit_state;
158
Ingo Molnar23f78d42006-06-27 02:54:53 -0700159#ifdef CONFIG_RT_MUTEXES
160extern int max_lock_depth;
161#endif
162
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700163#ifdef CONFIG_PROC_SYSCTL
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700164static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700165 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700166static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800167 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700168#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700169
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700170static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100171static struct ctl_table_root sysctl_table_root;
172static struct ctl_table_header root_table_header = {
Al Virob380b0d2008-09-04 17:05:57 +0100173 .count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100174 .ctl_table = root_table,
Al Viro73455092008-07-14 21:22:20 -0400175 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100176 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400177 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100178};
179static struct ctl_table_root sysctl_table_root = {
180 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400181 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100182};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700184static struct ctl_table kern_table[];
185static struct ctl_table vm_table[];
186static struct ctl_table fs_table[];
187static struct ctl_table debug_table[];
188static struct ctl_table dev_table[];
189extern struct ctl_table random_table[];
Amy Griffis2d9048e2006-06-01 13:10:59 -0700190#ifdef CONFIG_INOTIFY_USER
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700191extern struct ctl_table inotify_table[];
Robert Love0399cb02005-07-13 12:38:18 -0400192#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -0800193#ifdef CONFIG_EPOLL
194extern struct ctl_table epoll_table[];
195#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196
197#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
198int sysctl_legacy_va_layout;
199#endif
200
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700201extern int prove_locking;
202extern int lock_stat;
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800203
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204/* The default sysctl tables: */
205
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700206static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 .procname = "kernel",
209 .mode = 0555,
210 .child = kern_table,
211 },
212 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 .procname = "vm",
214 .mode = 0555,
215 .child = vm_table,
216 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 .procname = "fs",
219 .mode = 0555,
220 .child = fs_table,
221 },
222 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 .procname = "debug",
224 .mode = 0555,
225 .child = debug_table,
226 },
227 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 .procname = "dev",
229 .mode = 0555,
230 .child = dev_table,
231 },
Andrew Morton2be7fe02007-07-15 23:41:21 -0700232/*
233 * NOTE: do not add new entries to this table unless you have read
234 * Documentation/sysctl/ctl_unnumbered.txt
235 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700236 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237};
238
Ingo Molnar77e54a12007-07-09 18:52:00 +0200239#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100240static int min_sched_granularity_ns = 100000; /* 100 usecs */
241static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
242static int min_wakeup_granularity_ns; /* 0 usecs */
243static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100244static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
245static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100246static int min_sched_shares_ratelimit = 100000; /* 100 usec */
247static int max_sched_shares_ratelimit = NSEC_PER_SEC; /* 1 second */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200248#endif
249
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700250static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200251 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200252 .procname = "sched_child_runs_first",
253 .data = &sysctl_sched_child_runs_first,
254 .maxlen = sizeof(unsigned int),
255 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800256 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200257 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200258#ifdef CONFIG_SCHED_DEBUG
259 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100260 .procname = "sched_min_granularity_ns",
261 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200262 .maxlen = sizeof(unsigned int),
263 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800264 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100265 .extra1 = &min_sched_granularity_ns,
266 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200267 },
268 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200269 .procname = "sched_latency_ns",
270 .data = &sysctl_sched_latency,
271 .maxlen = sizeof(unsigned int),
272 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800273 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200274 .extra1 = &min_sched_granularity_ns,
275 .extra2 = &max_sched_granularity_ns,
276 },
277 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200278 .procname = "sched_wakeup_granularity_ns",
279 .data = &sysctl_sched_wakeup_granularity,
280 .maxlen = sizeof(unsigned int),
281 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800282 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200283 .extra1 = &min_wakeup_granularity_ns,
284 .extra2 = &max_wakeup_granularity_ns,
285 },
286 {
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200287 .procname = "sched_shares_ratelimit",
288 .data = &sysctl_sched_shares_ratelimit,
289 .maxlen = sizeof(unsigned int),
290 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800291 .proc_handler = sched_proc_update_handler,
Christian Ehrhardtacb4a842009-11-30 12:16:48 +0100292 .extra1 = &min_sched_shares_ratelimit,
293 .extra2 = &max_sched_shares_ratelimit,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200294 },
295 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100296 .procname = "sched_tunable_scaling",
297 .data = &sysctl_sched_tunable_scaling,
298 .maxlen = sizeof(enum sched_tunable_scaling),
299 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800300 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100301 .extra1 = &min_sched_tunable_scaling,
302 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200303 },
304 {
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200305 .procname = "sched_shares_thresh",
306 .data = &sysctl_sched_shares_thresh,
307 .maxlen = sizeof(unsigned int),
308 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800309 .proc_handler = proc_dointvec_minmax,
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200310 .extra1 = &zero,
311 },
312 {
Ingo Molnarda84d962007-10-15 17:00:18 +0200313 .procname = "sched_migration_cost",
314 .data = &sysctl_sched_migration_cost,
315 .maxlen = sizeof(unsigned int),
316 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800317 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200318 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100319 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100320 .procname = "sched_nr_migrate",
321 .data = &sysctl_sched_nr_migrate,
322 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100323 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800324 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100325 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530326 {
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200327 .procname = "sched_time_avg",
328 .data = &sysctl_sched_time_avg,
329 .maxlen = sizeof(unsigned int),
330 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800331 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200332 },
333 {
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530334 .procname = "timer_migration",
335 .data = &sysctl_timer_migration,
336 .maxlen = sizeof(unsigned int),
337 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800338 .proc_handler = proc_dointvec_minmax,
Arun R Bharadwajbfdb4d92009-06-23 10:00:58 +0530339 .extra1 = &zero,
340 .extra2 = &one,
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530341 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200342#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200343 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100344 .procname = "sched_rt_period_us",
345 .data = &sysctl_sched_rt_period,
346 .maxlen = sizeof(unsigned int),
347 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800348 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100349 },
350 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100351 .procname = "sched_rt_runtime_us",
352 .data = &sysctl_sched_rt_runtime,
353 .maxlen = sizeof(int),
354 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800355 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100356 },
357 {
Ingo Molnar1799e352007-09-19 23:34:46 +0200358 .procname = "sched_compat_yield",
359 .data = &sysctl_sched_compat_yield,
360 .maxlen = sizeof(unsigned int),
361 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800362 .proc_handler = proc_dointvec,
Ingo Molnar1799e352007-09-19 23:34:46 +0200363 },
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700364#ifdef CONFIG_PROVE_LOCKING
365 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700366 .procname = "prove_locking",
367 .data = &prove_locking,
368 .maxlen = sizeof(int),
369 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800370 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700371 },
372#endif
373#ifdef CONFIG_LOCK_STAT
374 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700375 .procname = "lock_stat",
376 .data = &lock_stat,
377 .maxlen = sizeof(int),
378 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800379 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700380 },
381#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200382 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 .procname = "panic",
384 .data = &panic_timeout,
385 .maxlen = sizeof(int),
386 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800387 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 },
389 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 .procname = "core_uses_pid",
391 .data = &core_uses_pid,
392 .maxlen = sizeof(int),
393 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800394 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 },
396 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 .procname = "core_pattern",
398 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700399 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800401 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 },
Neil Hormana2939802009-09-23 15:56:56 -0700403 {
Neil Hormana2939802009-09-23 15:56:56 -0700404 .procname = "core_pipe_limit",
405 .data = &core_pipe_limit,
406 .maxlen = sizeof(unsigned int),
407 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800408 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700409 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800410#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700413 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800414 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800415 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800417#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100418#ifdef CONFIG_LATENCYTOP
419 {
420 .procname = "latencytop",
421 .data = &latencytop_enabled,
422 .maxlen = sizeof(int),
423 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800424 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100425 },
426#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427#ifdef CONFIG_BLK_DEV_INITRD
428 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 .procname = "real-root-dev",
430 .data = &real_root_dev,
431 .maxlen = sizeof(int),
432 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800433 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 },
435#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700436 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700437 .procname = "print-fatal-signals",
438 .data = &print_fatal_signals,
439 .maxlen = sizeof(int),
440 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800441 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700442 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700443#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 .procname = "reboot-cmd",
446 .data = reboot_command,
447 .maxlen = 256,
448 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800449 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 },
451 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452 .procname = "stop-a",
453 .data = &stop_a_enabled,
454 .maxlen = sizeof (int),
455 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800456 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 },
458 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 .procname = "scons-poweroff",
460 .data = &scons_pwroff,
461 .maxlen = sizeof (int),
462 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800463 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 },
465#endif
David S. Miller08714202008-11-16 23:49:24 -0800466#ifdef CONFIG_SPARC64
467 {
David S. Miller08714202008-11-16 23:49:24 -0800468 .procname = "tsb-ratio",
469 .data = &sysctl_tsb_ratio,
470 .maxlen = sizeof (int),
471 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800472 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800473 },
474#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475#ifdef __hppa__
476 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 .procname = "soft-power",
478 .data = &pwrsw_enabled,
479 .maxlen = sizeof (int),
480 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800481 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 },
483 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 .procname = "unaligned-trap",
485 .data = &unaligned_enabled,
486 .maxlen = sizeof (int),
487 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800488 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 },
490#endif
491 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 .procname = "ctrl-alt-del",
493 .data = &C_A_D,
494 .maxlen = sizeof(int),
495 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800496 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400498#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200499 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200500 .procname = "ftrace_enabled",
501 .data = &ftrace_enabled,
502 .maxlen = sizeof(int),
503 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800504 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200505 },
506#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500507#ifdef CONFIG_STACK_TRACER
508 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500509 .procname = "stack_tracer_enabled",
510 .data = &stack_tracer_enabled,
511 .maxlen = sizeof(int),
512 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800513 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500514 },
515#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400516#ifdef CONFIG_TRACING
517 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100518 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400519 .data = &ftrace_dump_on_oops,
520 .maxlen = sizeof(int),
521 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800522 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400523 },
524#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200525#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 .procname = "modprobe",
528 .data = &modprobe_path,
529 .maxlen = KMOD_PATH_LEN,
530 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800531 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 },
Kees Cook3d433212009-04-02 15:49:29 -0700533 {
Kees Cook3d433212009-04-02 15:49:29 -0700534 .procname = "modules_disabled",
535 .data = &modules_disabled,
536 .maxlen = sizeof(int),
537 .mode = 0644,
538 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800539 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700540 .extra1 = &one,
541 .extra2 = &one,
542 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543#endif
Andrew Morton57ae2502006-06-23 02:05:47 -0700544#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100547 .data = &uevent_helper,
548 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800550 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 },
552#endif
553#ifdef CONFIG_CHR_DEV_SG
554 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 .procname = "sg-big-buff",
556 .data = &sg_big_buff,
557 .maxlen = sizeof (int),
558 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800559 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 },
561#endif
562#ifdef CONFIG_BSD_PROCESS_ACCT
563 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 .procname = "acct",
565 .data = &acct_parm,
566 .maxlen = 3*sizeof(int),
567 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800568 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 },
570#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571#ifdef CONFIG_MAGIC_SYSRQ
572 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800574 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 .maxlen = sizeof (int),
576 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800577 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 },
579#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700580#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700583 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 .maxlen = sizeof (int),
585 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800586 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700588#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 .procname = "threads-max",
591 .data = &max_threads,
592 .maxlen = sizeof(int),
593 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800594 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 },
596 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 .procname = "random",
598 .mode = 0555,
599 .child = random_table,
600 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 .procname = "overflowuid",
603 .data = &overflowuid,
604 .maxlen = sizeof(int),
605 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800606 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 .extra1 = &minolduid,
608 .extra2 = &maxolduid,
609 },
610 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611 .procname = "overflowgid",
612 .data = &overflowgid,
613 .maxlen = sizeof(int),
614 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800615 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 .extra1 = &minolduid,
617 .extra2 = &maxolduid,
618 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800619#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620#ifdef CONFIG_MATHEMU
621 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 .procname = "ieee_emulation_warnings",
623 .data = &sysctl_ieee_emulation_warnings,
624 .maxlen = sizeof(int),
625 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800626 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 },
628#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 .procname = "userprocess_debug",
631 .data = &sysctl_userprocess_debug,
632 .maxlen = sizeof(int),
633 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800634 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 },
636#endif
637 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 .procname = "pid_max",
639 .data = &pid_max,
640 .maxlen = sizeof (int),
641 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800642 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 .extra1 = &pid_max_min,
644 .extra2 = &pid_max_max,
645 },
646 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 .procname = "panic_on_oops",
648 .data = &panic_on_oops,
649 .maxlen = sizeof(int),
650 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800651 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800653#if defined CONFIG_PRINTK
654 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800655 .procname = "printk",
656 .data = &console_loglevel,
657 .maxlen = 4*sizeof(int),
658 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800659 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800660 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700663 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 .maxlen = sizeof(int),
665 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800666 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 },
668 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700670 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 .maxlen = sizeof(int),
672 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800673 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 },
Dave Youngaf913222009-09-22 16:43:33 -0700675 {
Dave Youngaf913222009-09-22 16:43:33 -0700676 .procname = "printk_delay",
677 .data = &printk_delay_msec,
678 .maxlen = sizeof(int),
679 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800680 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700681 .extra1 = &zero,
682 .extra2 = &ten_thousand,
683 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800684#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 .procname = "ngroups_max",
687 .data = &ngroups_max,
688 .maxlen = sizeof (int),
689 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800690 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 },
692#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
693 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 .procname = "unknown_nmi_panic",
695 .data = &unknown_nmi_panic,
696 .maxlen = sizeof (int),
697 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800698 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 },
Don Zickus407984f2006-09-26 10:52:27 +0200700 {
Don Zickus407984f2006-09-26 10:52:27 +0200701 .procname = "nmi_watchdog",
702 .data = &nmi_watchdog_enabled,
703 .maxlen = sizeof (int),
704 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800705 .proc_handler = proc_nmi_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 },
707#endif
708#if defined(CONFIG_X86)
709 {
Don Zickus8da5add2006-09-26 10:52:27 +0200710 .procname = "panic_on_unrecovered_nmi",
711 .data = &panic_on_unrecovered_nmi,
712 .maxlen = sizeof(int),
713 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800714 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200715 },
716 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700717 .procname = "panic_on_io_nmi",
718 .data = &panic_on_io_nmi,
719 .maxlen = sizeof(int),
720 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800721 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700722 },
723 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 .procname = "bootloader_type",
725 .data = &bootloader_type,
726 .maxlen = sizeof (int),
727 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800728 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100730 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700731 .procname = "bootloader_version",
732 .data = &bootloader_version,
733 .maxlen = sizeof (int),
734 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800735 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700736 },
737 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100738 .procname = "kstack_depth_to_print",
739 .data = &kstack_depth_to_print,
740 .maxlen = sizeof(int),
741 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800742 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100743 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100744 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100745 .procname = "io_delay_type",
746 .data = &io_delay_type,
747 .maxlen = sizeof(int),
748 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800749 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100750 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800752#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 .procname = "randomize_va_space",
755 .data = &randomize_va_space,
756 .maxlen = sizeof(int),
757 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800758 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800760#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800761#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700762 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700763 .procname = "spin_retry",
764 .data = &spin_retry,
765 .maxlen = sizeof (int),
766 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800767 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700768 },
769#endif
Len Brown673d5b42007-07-28 03:33:16 -0400770#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800771 {
Pavel Machekc255d842006-02-20 18:27:58 -0800772 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700773 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800774 .maxlen = sizeof (unsigned long),
775 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800776 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800777 },
778#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800779#ifdef CONFIG_IA64
780 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800781 .procname = "ignore-unaligned-usertrap",
782 .data = &no_unaligned_warning,
783 .maxlen = sizeof (int),
784 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800785 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800786 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800787 {
Doug Chapman88fc2412009-01-15 10:38:56 -0800788 .procname = "unaligned-dump-stack",
789 .data = &unaligned_dump_stack,
790 .maxlen = sizeof (int),
791 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800792 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -0800793 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800794#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700795#ifdef CONFIG_DETECT_SOFTLOCKUP
796 {
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200797 .procname = "softlockup_panic",
798 .data = &softlockup_panic,
799 .maxlen = sizeof(int),
800 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800801 .proc_handler = proc_dointvec_minmax,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200802 .extra1 = &zero,
803 .extra2 = &one,
804 },
805 {
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700806 .procname = "softlockup_thresh",
807 .data = &softlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200808 .maxlen = sizeof(int),
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700809 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800810 .proc_handler = proc_dosoftlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200811 .extra1 = &neg_one,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700812 .extra2 = &sixty,
813 },
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800814#endif
815#ifdef CONFIG_DETECT_HUNG_TASK
816 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800817 .procname = "hung_task_panic",
818 .data = &sysctl_hung_task_panic,
819 .maxlen = sizeof(int),
820 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800821 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800822 .extra1 = &zero,
823 .extra2 = &one,
824 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100825 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100826 .procname = "hung_task_check_count",
827 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100828 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100829 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800830 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100831 },
832 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100833 .procname = "hung_task_timeout_secs",
834 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100835 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100836 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800837 .proc_handler = proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100838 },
839 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100840 .procname = "hung_task_warnings",
841 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100842 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100843 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800844 .proc_handler = proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100845 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700846#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200847#ifdef CONFIG_COMPAT
848 {
Andi Kleenbebfa102006-06-26 13:56:52 +0200849 .procname = "compat-log",
850 .data = &compat_log,
851 .maxlen = sizeof (int),
852 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800853 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +0200854 },
855#endif
Ingo Molnar23f78d42006-06-27 02:54:53 -0700856#ifdef CONFIG_RT_MUTEXES
857 {
Ingo Molnar23f78d42006-06-27 02:54:53 -0700858 .procname = "max_lock_depth",
859 .data = &max_lock_depth,
860 .maxlen = sizeof(int),
861 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800862 .proc_handler = proc_dointvec,
Ingo Molnar23f78d42006-06-27 02:54:53 -0700863 },
864#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700865 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700866 .procname = "poweroff_cmd",
867 .data = &poweroff_cmd,
868 .maxlen = POWEROFF_CMD_PATH_LEN,
869 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800870 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700871 },
David Howells0b77f5b2008-04-29 01:01:32 -0700872#ifdef CONFIG_KEYS
873 {
David Howells0b77f5b2008-04-29 01:01:32 -0700874 .procname = "keys",
875 .mode = 0555,
876 .child = key_sysctls,
877 },
878#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700879#ifdef CONFIG_RCU_TORTURE_TEST
880 {
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700881 .procname = "rcutorture_runnable",
882 .data = &rcutorture_runnable,
883 .maxlen = sizeof(int),
884 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800885 .proc_handler = proc_dointvec,
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700886 },
887#endif
David Howells12e22c52009-04-03 16:42:35 +0100888#ifdef CONFIG_SLOW_WORK
889 {
David Howells12e22c52009-04-03 16:42:35 +0100890 .procname = "slow-work",
891 .mode = 0555,
892 .child = slow_work_sysctls,
893 },
894#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200895#ifdef CONFIG_PERF_EVENTS
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200896 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200897 .procname = "perf_event_paranoid",
898 .data = &sysctl_perf_event_paranoid,
899 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200900 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800901 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200902 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200903 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200904 .procname = "perf_event_mlock_kb",
905 .data = &sysctl_perf_event_mlock,
906 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200907 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800908 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +0200909 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200910 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +0200911 .procname = "perf_event_max_sample_rate",
912 .data = &sysctl_perf_event_sample_rate,
913 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200914 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800915 .proc_handler = proc_dointvec,
Peter Zijlstraa78ac322009-05-25 17:39:05 +0200916 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +0200917#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +0200918#ifdef CONFIG_KMEMCHECK
919 {
Vegard Nossumdfec0722008-04-04 00:51:41 +0200920 .procname = "kmemcheck",
921 .data = &kmemcheck_enabled,
922 .maxlen = sizeof(int),
923 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800924 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +0200925 },
926#endif
Jens Axboecb684b52009-09-15 21:53:11 +0200927#ifdef CONFIG_BLOCK
Jens Axboe5e605b62009-08-05 09:07:21 +0200928 {
Jens Axboe5e605b62009-08-05 09:07:21 +0200929 .procname = "blk_iopoll",
930 .data = &blk_iopoll_enabled,
931 .maxlen = sizeof(int),
932 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800933 .proc_handler = proc_dointvec,
Jens Axboe5e605b62009-08-05 09:07:21 +0200934 },
Jens Axboecb684b52009-09-15 21:53:11 +0200935#endif
Andrew Mortoned2c12f2007-07-19 01:50:35 -0700936/*
937 * NOTE: do not add new entries to this table unless you have read
938 * Documentation/sysctl/ctl_unnumbered.txt
939 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700940 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941};
942
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700943static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700945 .procname = "overcommit_memory",
946 .data = &sysctl_overcommit_memory,
947 .maxlen = sizeof(sysctl_overcommit_memory),
948 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800949 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950 },
951 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700952 .procname = "panic_on_oom",
953 .data = &sysctl_panic_on_oom,
954 .maxlen = sizeof(sysctl_panic_on_oom),
955 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800956 .proc_handler = proc_dointvec,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700957 },
958 {
David Rientjesfe071d72007-10-16 23:25:56 -0700959 .procname = "oom_kill_allocating_task",
960 .data = &sysctl_oom_kill_allocating_task,
961 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
962 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800963 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -0700964 },
965 {
David Rientjesfef1bdd2008-02-07 00:14:07 -0800966 .procname = "oom_dump_tasks",
967 .data = &sysctl_oom_dump_tasks,
968 .maxlen = sizeof(sysctl_oom_dump_tasks),
969 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800970 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -0800971 },
972 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973 .procname = "overcommit_ratio",
974 .data = &sysctl_overcommit_ratio,
975 .maxlen = sizeof(sysctl_overcommit_ratio),
976 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800977 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700978 },
979 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 .procname = "page-cluster",
981 .data = &page_cluster,
982 .maxlen = sizeof(int),
983 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800984 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985 },
986 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 .procname = "dirty_background_ratio",
988 .data = &dirty_background_ratio,
989 .maxlen = sizeof(dirty_background_ratio),
990 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800991 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700992 .extra1 = &zero,
993 .extra2 = &one_hundred,
994 },
995 {
David Rientjes2da02992009-01-06 14:39:31 -0800996 .procname = "dirty_background_bytes",
997 .data = &dirty_background_bytes,
998 .maxlen = sizeof(dirty_background_bytes),
999 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001000 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001001 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001002 },
1003 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001004 .procname = "dirty_ratio",
1005 .data = &vm_dirty_ratio,
1006 .maxlen = sizeof(vm_dirty_ratio),
1007 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001008 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001009 .extra1 = &zero,
1010 .extra2 = &one_hundred,
1011 },
1012 {
David Rientjes2da02992009-01-06 14:39:31 -08001013 .procname = "dirty_bytes",
1014 .data = &vm_dirty_bytes,
1015 .maxlen = sizeof(vm_dirty_bytes),
1016 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001017 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001018 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001019 },
1020 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001021 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001022 .data = &dirty_writeback_interval,
1023 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001024 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001025 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026 },
1027 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001028 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001029 .data = &dirty_expire_interval,
1030 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001031 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001032 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001033 },
1034 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001035 .procname = "nr_pdflush_threads",
1036 .data = &nr_pdflush_threads,
1037 .maxlen = sizeof nr_pdflush_threads,
1038 .mode = 0444 /* read-only*/,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001039 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001040 },
1041 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001042 .procname = "swappiness",
1043 .data = &vm_swappiness,
1044 .maxlen = sizeof(vm_swappiness),
1045 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001046 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047 .extra1 = &zero,
1048 .extra2 = &one_hundred,
1049 },
1050#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001051 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001052 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001053 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054 .maxlen = sizeof(unsigned long),
1055 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001056 .proc_handler = hugetlb_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001057 .extra1 = (void *)&hugetlb_zero,
1058 .extra2 = (void *)&hugetlb_infinity,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001059 },
1060#ifdef CONFIG_NUMA
1061 {
1062 .procname = "nr_hugepages_mempolicy",
1063 .data = NULL,
1064 .maxlen = sizeof(unsigned long),
1065 .mode = 0644,
1066 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1067 .extra1 = (void *)&hugetlb_zero,
1068 .extra2 = (void *)&hugetlb_infinity,
1069 },
1070#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001071 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001072 .procname = "hugetlb_shm_group",
1073 .data = &sysctl_hugetlb_shm_group,
1074 .maxlen = sizeof(gid_t),
1075 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001076 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001077 },
Mel Gorman396faf02007-07-17 04:03:13 -07001078 {
Mel Gorman396faf02007-07-17 04:03:13 -07001079 .procname = "hugepages_treat_as_movable",
1080 .data = &hugepages_treat_as_movable,
1081 .maxlen = sizeof(int),
1082 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001083 .proc_handler = hugetlb_treat_movable_handler,
Mel Gorman396faf02007-07-17 04:03:13 -07001084 },
Adam Litke54f9f802007-10-16 01:26:20 -07001085 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001086 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001087 .data = NULL,
1088 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001089 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001090 .proc_handler = hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001091 .extra1 = (void *)&hugetlb_zero,
1092 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001093 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094#endif
1095 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001096 .procname = "lowmem_reserve_ratio",
1097 .data = &sysctl_lowmem_reserve_ratio,
1098 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1099 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001100 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001101 },
1102 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001103 .procname = "drop_caches",
1104 .data = &sysctl_drop_caches,
1105 .maxlen = sizeof(int),
1106 .mode = 0644,
1107 .proc_handler = drop_caches_sysctl_handler,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001108 },
1109 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 .procname = "min_free_kbytes",
1111 .data = &min_free_kbytes,
1112 .maxlen = sizeof(min_free_kbytes),
1113 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001114 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115 .extra1 = &zero,
1116 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001117 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001118 .procname = "percpu_pagelist_fraction",
1119 .data = &percpu_pagelist_fraction,
1120 .maxlen = sizeof(percpu_pagelist_fraction),
1121 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001122 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001123 .extra1 = &min_percpu_pagelist_fract,
1124 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125#ifdef CONFIG_MMU
1126 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 .procname = "max_map_count",
1128 .data = &sysctl_max_map_count,
1129 .maxlen = sizeof(sysctl_max_map_count),
1130 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001131 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001132 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001134#else
1135 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001136 .procname = "nr_trim_pages",
1137 .data = &sysctl_nr_trim_pages,
1138 .maxlen = sizeof(sysctl_nr_trim_pages),
1139 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001140 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001141 .extra1 = &zero,
1142 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143#endif
1144 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001145 .procname = "laptop_mode",
1146 .data = &laptop_mode,
1147 .maxlen = sizeof(laptop_mode),
1148 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001149 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001150 },
1151 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152 .procname = "block_dump",
1153 .data = &block_dump,
1154 .maxlen = sizeof(block_dump),
1155 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001156 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001157 .extra1 = &zero,
1158 },
1159 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001160 .procname = "vfs_cache_pressure",
1161 .data = &sysctl_vfs_cache_pressure,
1162 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1163 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001164 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165 .extra1 = &zero,
1166 },
1167#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1168 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001169 .procname = "legacy_va_layout",
1170 .data = &sysctl_legacy_va_layout,
1171 .maxlen = sizeof(sysctl_legacy_va_layout),
1172 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001173 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 .extra1 = &zero,
1175 },
1176#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001177#ifdef CONFIG_NUMA
1178 {
Christoph Lameter17436602006-01-18 17:42:32 -08001179 .procname = "zone_reclaim_mode",
1180 .data = &zone_reclaim_mode,
1181 .maxlen = sizeof(zone_reclaim_mode),
1182 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001183 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001184 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001185 },
Christoph Lameter96146342006-07-03 00:24:13 -07001186 {
Christoph Lameter96146342006-07-03 00:24:13 -07001187 .procname = "min_unmapped_ratio",
1188 .data = &sysctl_min_unmapped_ratio,
1189 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1190 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001191 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001192 .extra1 = &zero,
1193 .extra2 = &one_hundred,
1194 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001195 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001196 .procname = "min_slab_ratio",
1197 .data = &sysctl_min_slab_ratio,
1198 .maxlen = sizeof(sysctl_min_slab_ratio),
1199 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001200 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001201 .extra1 = &zero,
1202 .extra2 = &one_hundred,
1203 },
Christoph Lameter17436602006-01-18 17:42:32 -08001204#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001205#ifdef CONFIG_SMP
1206 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001207 .procname = "stat_interval",
1208 .data = &sysctl_stat_interval,
1209 .maxlen = sizeof(sysctl_stat_interval),
1210 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001211 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001212 },
1213#endif
David Howells6e141542009-12-15 19:27:45 +00001214#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001215 {
Eric Parised032182007-06-28 15:55:21 -04001216 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001217 .data = &dac_mmap_min_addr,
1218 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001219 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001220 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001221 },
David Howells6e141542009-12-15 19:27:45 +00001222#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001223#ifdef CONFIG_NUMA
1224 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001225 .procname = "numa_zonelist_order",
1226 .data = &numa_zonelist_order,
1227 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1228 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001229 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001230 },
1231#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001232#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001233 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001234 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001235 .procname = "vdso_enabled",
1236 .data = &vdso_enabled,
1237 .maxlen = sizeof(vdso_enabled),
1238 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001239 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001240 .extra1 = &zero,
1241 },
1242#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001243#ifdef CONFIG_HIGHMEM
1244 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001245 .procname = "highmem_is_dirtyable",
1246 .data = &vm_highmem_is_dirtyable,
1247 .maxlen = sizeof(vm_highmem_is_dirtyable),
1248 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001249 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001250 .extra1 = &zero,
1251 .extra2 = &one,
1252 },
1253#endif
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001254 {
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001255 .procname = "scan_unevictable_pages",
1256 .data = &scan_unevictable_pages,
1257 .maxlen = sizeof(scan_unevictable_pages),
1258 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001259 .proc_handler = scan_unevictable_handler,
Peter Zijlstra4be6f6b2009-04-13 14:39:33 -07001260 },
Andi Kleen6a460792009-09-16 11:50:15 +02001261#ifdef CONFIG_MEMORY_FAILURE
1262 {
Andi Kleen6a460792009-09-16 11:50:15 +02001263 .procname = "memory_failure_early_kill",
1264 .data = &sysctl_memory_failure_early_kill,
1265 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1266 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001267 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001268 .extra1 = &zero,
1269 .extra2 = &one,
1270 },
1271 {
Andi Kleen6a460792009-09-16 11:50:15 +02001272 .procname = "memory_failure_recovery",
1273 .data = &sysctl_memory_failure_recovery,
1274 .maxlen = sizeof(sysctl_memory_failure_recovery),
1275 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001276 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001277 .extra1 = &zero,
1278 .extra2 = &one,
1279 },
1280#endif
1281
Andrew Morton2be7fe02007-07-15 23:41:21 -07001282/*
1283 * NOTE: do not add new entries to this table unless you have read
1284 * Documentation/sysctl/ctl_unnumbered.txt
1285 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001286 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001287};
1288
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001289#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001290static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001291 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001292};
1293#endif
1294
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001295static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001296 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297 .procname = "inode-nr",
1298 .data = &inodes_stat,
1299 .maxlen = 2*sizeof(int),
1300 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001301 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001302 },
1303 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001304 .procname = "inode-state",
1305 .data = &inodes_stat,
1306 .maxlen = 7*sizeof(int),
1307 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001308 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001309 },
1310 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311 .procname = "file-nr",
1312 .data = &files_stat,
1313 .maxlen = 3*sizeof(int),
1314 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001315 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316 },
1317 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001318 .procname = "file-max",
1319 .data = &files_stat.max_files,
1320 .maxlen = sizeof(int),
1321 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001322 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323 },
1324 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001325 .procname = "nr_open",
1326 .data = &sysctl_nr_open,
1327 .maxlen = sizeof(int),
1328 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001329 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001330 .extra1 = &sysctl_nr_open_min,
1331 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001332 },
1333 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001334 .procname = "dentry-state",
1335 .data = &dentry_stat,
1336 .maxlen = 6*sizeof(int),
1337 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001338 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339 },
1340 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001341 .procname = "overflowuid",
1342 .data = &fs_overflowuid,
1343 .maxlen = sizeof(int),
1344 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001345 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001346 .extra1 = &minolduid,
1347 .extra2 = &maxolduid,
1348 },
1349 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350 .procname = "overflowgid",
1351 .data = &fs_overflowgid,
1352 .maxlen = sizeof(int),
1353 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001354 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355 .extra1 = &minolduid,
1356 .extra2 = &maxolduid,
1357 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001358#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001359 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001360 .procname = "leases-enable",
1361 .data = &leases_enable,
1362 .maxlen = sizeof(int),
1363 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001364 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001365 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001366#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001367#ifdef CONFIG_DNOTIFY
1368 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001369 .procname = "dir-notify-enable",
1370 .data = &dir_notify_enable,
1371 .maxlen = sizeof(int),
1372 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001373 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001374 },
1375#endif
1376#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001377#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001379 .procname = "lease-break-time",
1380 .data = &lease_break_time,
1381 .maxlen = sizeof(int),
1382 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001383 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001385#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001386#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001387 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001388 .procname = "aio-nr",
1389 .data = &aio_nr,
1390 .maxlen = sizeof(aio_nr),
1391 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001392 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001393 },
1394 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001395 .procname = "aio-max-nr",
1396 .data = &aio_max_nr,
1397 .maxlen = sizeof(aio_max_nr),
1398 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001399 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001400 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001401#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001402#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001403 {
Robert Love0399cb02005-07-13 12:38:18 -04001404 .procname = "inotify",
1405 .mode = 0555,
1406 .child = inotify_table,
1407 },
1408#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001409#ifdef CONFIG_EPOLL
1410 {
1411 .procname = "epoll",
1412 .mode = 0555,
1413 .child = epoll_table,
1414 },
1415#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001416#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001417 {
Alan Coxd6e71142005-06-23 00:09:43 -07001418 .procname = "suid_dumpable",
1419 .data = &suid_dumpable,
1420 .maxlen = sizeof(int),
1421 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001422 .proc_handler = proc_dointvec_minmax,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001423 .extra1 = &zero,
1424 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001425 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001426#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1427 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001428 .procname = "binfmt_misc",
1429 .mode = 0555,
1430 .child = binfmt_misc_table,
1431 },
1432#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001433/*
1434 * NOTE: do not add new entries to this table unless you have read
1435 * Documentation/sysctl/ctl_unnumbered.txt
1436 */
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001437 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001438};
1439
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001440static struct ctl_table debug_table[] = {
David S. Miller4b177642010-03-01 00:02:23 -08001441#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_SPARC)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001442 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001443 .procname = "exception-trace",
1444 .data = &show_unhandled_signals,
1445 .maxlen = sizeof(int),
1446 .mode = 0644,
1447 .proc_handler = proc_dointvec
1448 },
1449#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001450#if defined(CONFIG_OPTPROBES)
1451 {
1452 .procname = "kprobes-optimization",
1453 .data = &sysctl_kprobes_optimization,
1454 .maxlen = sizeof(int),
1455 .mode = 0644,
1456 .proc_handler = proc_kprobes_optimization_handler,
1457 .extra1 = &zero,
1458 .extra2 = &one,
1459 },
1460#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001461 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462};
1463
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001464static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001465 { }
Robert Love0eeca282005-07-12 17:06:03 -04001466};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467
Al Viro330d57f2005-11-04 10:18:40 +00001468static DEFINE_SPINLOCK(sysctl_lock);
1469
1470/* called under sysctl_lock */
1471static int use_table(struct ctl_table_header *p)
1472{
1473 if (unlikely(p->unregistering))
1474 return 0;
1475 p->used++;
1476 return 1;
1477}
1478
1479/* called under sysctl_lock */
1480static void unuse_table(struct ctl_table_header *p)
1481{
1482 if (!--p->used)
1483 if (unlikely(p->unregistering))
1484 complete(p->unregistering);
1485}
1486
1487/* called under sysctl_lock, will reacquire if has to wait */
1488static void start_unregistering(struct ctl_table_header *p)
1489{
1490 /*
1491 * if p->used is 0, nobody will ever touch that entry again;
1492 * we'll eliminate all paths to it before dropping sysctl_lock
1493 */
1494 if (unlikely(p->used)) {
1495 struct completion wait;
1496 init_completion(&wait);
1497 p->unregistering = &wait;
1498 spin_unlock(&sysctl_lock);
1499 wait_for_completion(&wait);
1500 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001501 } else {
1502 /* anything non-NULL; we'll never dereference it */
1503 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001504 }
1505 /*
1506 * do not remove from the list until nobody holds it; walking the
1507 * list in do_sysctl() relies on that.
1508 */
1509 list_del_init(&p->ctl_entry);
1510}
1511
Al Virof7e6ced2008-07-15 01:44:23 -04001512void sysctl_head_get(struct ctl_table_header *head)
1513{
1514 spin_lock(&sysctl_lock);
1515 head->count++;
1516 spin_unlock(&sysctl_lock);
1517}
1518
1519void sysctl_head_put(struct ctl_table_header *head)
1520{
1521 spin_lock(&sysctl_lock);
1522 if (!--head->count)
1523 kfree(head);
1524 spin_unlock(&sysctl_lock);
1525}
1526
1527struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1528{
1529 if (!head)
1530 BUG();
1531 spin_lock(&sysctl_lock);
1532 if (!use_table(head))
1533 head = ERR_PTR(-ENOENT);
1534 spin_unlock(&sysctl_lock);
1535 return head;
1536}
1537
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001538void sysctl_head_finish(struct ctl_table_header *head)
1539{
1540 if (!head)
1541 return;
1542 spin_lock(&sysctl_lock);
1543 unuse_table(head);
1544 spin_unlock(&sysctl_lock);
1545}
1546
Al Viro73455092008-07-14 21:22:20 -04001547static struct ctl_table_set *
1548lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1549{
1550 struct ctl_table_set *set = &root->default_set;
1551 if (root->lookup)
1552 set = root->lookup(root, namespaces);
1553 return set;
1554}
1555
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001556static struct list_head *
1557lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001558{
Al Viro73455092008-07-14 21:22:20 -04001559 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1560 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001561}
1562
1563struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1564 struct ctl_table_header *prev)
1565{
1566 struct ctl_table_root *root;
1567 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001568 struct ctl_table_header *head;
1569 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001570
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001571 spin_lock(&sysctl_lock);
1572 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001573 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001574 tmp = &prev->ctl_entry;
1575 unuse_table(prev);
1576 goto next;
1577 }
1578 tmp = &root_table_header.ctl_entry;
1579 for (;;) {
1580 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1581
1582 if (!use_table(head))
1583 goto next;
1584 spin_unlock(&sysctl_lock);
1585 return head;
1586 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001587 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001588 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001589 header_list = lookup_header_list(root, namespaces);
1590 if (tmp != header_list)
1591 continue;
1592
1593 do {
1594 root = list_entry(root->root_list.next,
1595 struct ctl_table_root, root_list);
1596 if (root == &sysctl_table_root)
1597 goto out;
1598 header_list = lookup_header_list(root, namespaces);
1599 } while (list_empty(header_list));
1600 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001601 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001602out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001603 spin_unlock(&sysctl_lock);
1604 return NULL;
1605}
1606
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001607struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1608{
1609 return __sysctl_head_next(current->nsproxy, prev);
1610}
1611
1612void register_sysctl_root(struct ctl_table_root *root)
1613{
1614 spin_lock(&sysctl_lock);
1615 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1616 spin_unlock(&sysctl_lock);
1617}
1618
Linus Torvalds1da177e2005-04-16 15:20:36 -07001619/*
Eric W. Biederman1ff007eb2007-02-14 00:34:11 -08001620 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001621 * some sysctl variables are readonly even to root.
1622 */
1623
1624static int test_perm(int mode, int op)
1625{
David Howells76aac0e2008-11-14 10:39:12 +11001626 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001627 mode >>= 6;
1628 else if (in_egroup_p(0))
1629 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001630 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001631 return 0;
1632 return -EACCES;
1633}
1634
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001635int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001636{
1637 int error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001638 int mode;
1639
Al Viroe6305c42008-07-15 21:03:57 -04001640 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001641 if (error)
1642 return error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001643
1644 if (root->permissions)
1645 mode = root->permissions(root, current->nsproxy, table);
1646 else
1647 mode = table->mode;
1648
1649 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001650}
1651
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001652static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1653{
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001654 for (; table->procname; table++) {
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001655 table->parent = parent;
1656 if (table->child)
1657 sysctl_set_parent(table, table->child);
1658 }
1659}
1660
1661static __init int sysctl_init(void)
1662{
1663 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001664#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1665 {
1666 int err;
1667 err = sysctl_check_table(current->nsproxy, root_table);
1668 }
1669#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001670 return 0;
1671}
1672
1673core_initcall(sysctl_init);
1674
Al Virobfbcf032008-07-27 06:31:22 +01001675static struct ctl_table *is_branch_in(struct ctl_table *branch,
1676 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001677{
1678 struct ctl_table *p;
1679 const char *s = branch->procname;
1680
1681 /* branch should have named subdirectory as its first element */
1682 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001683 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001684
1685 /* ... and nothing else */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001686 if (branch[1].procname)
Al Virobfbcf032008-07-27 06:31:22 +01001687 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001688
1689 /* table should contain subdirectory with the same name */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001690 for (p = table; p->procname; p++) {
Al Viroae7edec2008-07-15 06:33:31 -04001691 if (!p->child)
1692 continue;
1693 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001694 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001695 }
Al Virobfbcf032008-07-27 06:31:22 +01001696 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001697}
1698
1699/* see if attaching q to p would be an improvement */
1700static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1701{
1702 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001703 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001704 int is_better = 0;
1705 int not_in_parent = !p->attached_by;
1706
Al Virobfbcf032008-07-27 06:31:22 +01001707 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001708 if (by == q->attached_by)
1709 is_better = 1;
1710 if (to == p->attached_by)
1711 not_in_parent = 1;
1712 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001713 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001714 }
1715
1716 if (is_better && not_in_parent) {
1717 q->attached_by = by;
1718 q->attached_to = to;
1719 q->parent = p;
1720 }
1721}
1722
Linus Torvalds1da177e2005-04-16 15:20:36 -07001723/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001724 * __register_sysctl_paths - register a sysctl hierarchy
1725 * @root: List of sysctl headers to register on
1726 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001727 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001728 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729 *
1730 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001731 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001732 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001733 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001734 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001735 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1736 * enter a sysctl file
1737 *
1738 * data - a pointer to data for use by proc_handler
1739 *
1740 * maxlen - the maximum size in bytes of the data
1741 *
1742 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1743 *
1744 * child - a pointer to the child sysctl table if this entry is a directory, or
1745 * %NULL.
1746 *
1747 * proc_handler - the text handler routine (described below)
1748 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001749 * de - for internal use by the sysctl routines
1750 *
1751 * extra1, extra2 - extra pointers usable by the proc handler routines
1752 *
1753 * Leaf nodes in the sysctl tree will be represented by a single file
1754 * under /proc; non-leaf nodes will be represented by directories.
1755 *
1756 * sysctl(2) can automatically manage read and write requests through
1757 * the sysctl table. The data and maxlen fields of the ctl_table
1758 * struct enable minimal validation of the values being written to be
1759 * performed, and the mode field allows minimal authentication.
1760 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07001761 * There must be a proc_handler routine for any terminal nodes
1762 * mirrored under /proc/sys (non-terminals are handled by a built-in
1763 * directory handler). Several default handlers are available to
1764 * cover common cases -
1765 *
1766 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1767 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1768 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1769 *
1770 * It is the handler's job to read the input buffer from user memory
1771 * and process it. The handler should return 0 on success.
1772 *
1773 * This routine returns %NULL on a failure to register, and a pointer
1774 * to the table header on success.
1775 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001776struct ctl_table_header *__register_sysctl_paths(
1777 struct ctl_table_root *root,
1778 struct nsproxy *namespaces,
1779 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001780{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001781 struct ctl_table_header *header;
1782 struct ctl_table *new, **prevp;
1783 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001784 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001785
1786 /* Count the path components */
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001787 for (npath = 0; path[npath].procname; ++npath)
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001788 ;
1789
1790 /*
1791 * For each path component, allocate a 2-element ctl_table array.
1792 * The first array element will be filled with the sysctl entry
Eric W. Biederman2315ffa2009-04-03 03:18:02 -07001793 * for this, the second will be the sentinel (procname == 0).
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001794 *
1795 * We allocate everything in one go so that we don't have to
1796 * worry about freeing additional memory in unregister_sysctl_table.
1797 */
1798 header = kzalloc(sizeof(struct ctl_table_header) +
1799 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1800 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001801 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001802
1803 new = (struct ctl_table *) (header + 1);
1804
1805 /* Now connect the dots */
1806 prevp = &header->ctl_table;
1807 for (n = 0; n < npath; ++n, ++path) {
1808 /* Copy the procname */
1809 new->procname = path->procname;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001810 new->mode = 0555;
1811
1812 *prevp = new;
1813 prevp = &new->child;
1814
1815 new += 2;
1816 }
1817 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001818 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001819
1820 INIT_LIST_HEAD(&header->ctl_entry);
1821 header->used = 0;
1822 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001823 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001824 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001825 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001826#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001827 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001828 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001829 return NULL;
1830 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001831#endif
Al Viro330d57f2005-11-04 10:18:40 +00001832 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001833 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001834 header->attached_by = header->ctl_table;
1835 header->attached_to = root_table;
1836 header->parent = &root_table_header;
1837 for (set = header->set; set; set = set->parent) {
1838 struct ctl_table_header *p;
1839 list_for_each_entry(p, &set->list, ctl_entry) {
1840 if (p->unregistering)
1841 continue;
1842 try_attach(p, header);
1843 }
1844 }
1845 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001846 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001847 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001848
1849 return header;
1850}
1851
1852/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001853 * register_sysctl_table_path - register a sysctl table hierarchy
1854 * @path: The path to the directory the sysctl table is in.
1855 * @table: the top-level table structure
1856 *
1857 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1858 * array. A completely 0 filled entry terminates the table.
1859 *
1860 * See __register_sysctl_paths for more details.
1861 */
1862struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1863 struct ctl_table *table)
1864{
1865 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1866 path, table);
1867}
1868
1869/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001870 * register_sysctl_table - register a sysctl table hierarchy
1871 * @table: the top-level table structure
1872 *
1873 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1874 * array. A completely 0 filled entry terminates the table.
1875 *
1876 * See register_sysctl_paths for more details.
1877 */
1878struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1879{
1880 static const struct ctl_path null_path[] = { {} };
1881
1882 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001883}
1884
1885/**
1886 * unregister_sysctl_table - unregister a sysctl table hierarchy
1887 * @header: the header returned from register_sysctl_table
1888 *
1889 * Unregisters the sysctl table and all children. proc entries may not
1890 * actually be removed until they are no longer used by anyone.
1891 */
1892void unregister_sysctl_table(struct ctl_table_header * header)
1893{
Al Viro330d57f2005-11-04 10:18:40 +00001894 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08001895
1896 if (header == NULL)
1897 return;
1898
Al Viro330d57f2005-11-04 10:18:40 +00001899 spin_lock(&sysctl_lock);
1900 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04001901 if (!--header->parent->count) {
1902 WARN_ON(1);
1903 kfree(header->parent);
1904 }
Al Virof7e6ced2008-07-15 01:44:23 -04001905 if (!--header->count)
1906 kfree(header);
Al Viro330d57f2005-11-04 10:18:40 +00001907 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001908}
1909
Al Viro90434762008-07-15 08:54:06 -04001910int sysctl_is_seen(struct ctl_table_header *p)
1911{
1912 struct ctl_table_set *set = p->set;
1913 int res;
1914 spin_lock(&sysctl_lock);
1915 if (p->unregistering)
1916 res = 0;
1917 else if (!set->is_seen)
1918 res = 1;
1919 else
1920 res = set->is_seen(set);
1921 spin_unlock(&sysctl_lock);
1922 return res;
1923}
1924
Al Viro73455092008-07-14 21:22:20 -04001925void setup_sysctl_set(struct ctl_table_set *p,
1926 struct ctl_table_set *parent,
1927 int (*is_seen)(struct ctl_table_set *))
1928{
1929 INIT_LIST_HEAD(&p->list);
1930 p->parent = parent ? parent : &sysctl_table_root.default_set;
1931 p->is_seen = is_seen;
1932}
1933
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001934#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001935struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001936{
1937 return NULL;
1938}
1939
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001940struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1941 struct ctl_table *table)
1942{
1943 return NULL;
1944}
1945
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001946void unregister_sysctl_table(struct ctl_table_header * table)
1947{
1948}
1949
Al Viro73455092008-07-14 21:22:20 -04001950void setup_sysctl_set(struct ctl_table_set *p,
1951 struct ctl_table_set *parent,
1952 int (*is_seen)(struct ctl_table_set *))
1953{
1954}
1955
Al Virof7e6ced2008-07-15 01:44:23 -04001956void sysctl_head_put(struct ctl_table_header *head)
1957{
1958}
1959
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001960#endif /* CONFIG_SYSCTL */
1961
Linus Torvalds1da177e2005-04-16 15:20:36 -07001962/*
1963 * /proc/sys support
1964 */
1965
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001966#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001967
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001968static int _proc_do_string(void* data, int maxlen, int write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001969 void __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001970 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001971{
1972 size_t len;
1973 char __user *p;
1974 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001975
1976 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001977 *lenp = 0;
1978 return 0;
1979 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001980
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001981 if (write) {
1982 len = 0;
1983 p = buffer;
1984 while (len < *lenp) {
1985 if (get_user(c, p++))
1986 return -EFAULT;
1987 if (c == 0 || c == '\n')
1988 break;
1989 len++;
1990 }
1991 if (len >= maxlen)
1992 len = maxlen-1;
1993 if(copy_from_user(data, buffer, len))
1994 return -EFAULT;
1995 ((char *) data)[len] = 0;
1996 *ppos += *lenp;
1997 } else {
1998 len = strlen(data);
1999 if (len > maxlen)
2000 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002001
2002 if (*ppos > len) {
2003 *lenp = 0;
2004 return 0;
2005 }
2006
2007 data += *ppos;
2008 len -= *ppos;
2009
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002010 if (len > *lenp)
2011 len = *lenp;
2012 if (len)
2013 if(copy_to_user(buffer, data, len))
2014 return -EFAULT;
2015 if (len < *lenp) {
2016 if(put_user('\n', ((char __user *) buffer) + len))
2017 return -EFAULT;
2018 len++;
2019 }
2020 *lenp = len;
2021 *ppos += len;
2022 }
2023 return 0;
2024}
2025
Linus Torvalds1da177e2005-04-16 15:20:36 -07002026/**
2027 * proc_dostring - read a string sysctl
2028 * @table: the sysctl table
2029 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002030 * @buffer: the user buffer
2031 * @lenp: the size of the user buffer
2032 * @ppos: file position
2033 *
2034 * Reads/writes a string from/to the user buffer. If the kernel
2035 * buffer provided is not large enough to hold the string, the
2036 * string is truncated. The copied string is %NULL-terminated.
2037 * If the string is being read by the user process, it is copied
2038 * and a newline '\n' is added. It is truncated if the buffer is
2039 * not large enough.
2040 *
2041 * Returns 0 on success.
2042 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002043int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002044 void __user *buffer, size_t *lenp, loff_t *ppos)
2045{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002046 return _proc_do_string(table->data, table->maxlen, write,
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002047 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002048}
2049
Linus Torvalds1da177e2005-04-16 15:20:36 -07002050
2051static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2052 int *valp,
2053 int write, void *data)
2054{
2055 if (write) {
2056 *valp = *negp ? -*lvalp : *lvalp;
2057 } else {
2058 int val = *valp;
2059 if (val < 0) {
2060 *negp = -1;
2061 *lvalp = (unsigned long)-val;
2062 } else {
2063 *negp = 0;
2064 *lvalp = (unsigned long)val;
2065 }
2066 }
2067 return 0;
2068}
2069
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002070static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002071 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002072 size_t *lenp, loff_t *ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002073 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2074 int write, void *data),
2075 void *data)
2076{
2077#define TMPBUFLEN 21
Sukanto Ghosh7338f292009-06-17 16:27:50 -07002078 int *i, vleft, first = 1, neg;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002079 unsigned long lval;
2080 size_t left, len;
2081
2082 char buf[TMPBUFLEN], *p;
2083 char __user *s = buffer;
2084
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002085 if (!tbl_data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002086 (*ppos && !write)) {
2087 *lenp = 0;
2088 return 0;
2089 }
2090
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002091 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002092 vleft = table->maxlen / sizeof(*i);
2093 left = *lenp;
2094
2095 if (!conv)
2096 conv = do_proc_dointvec_conv;
2097
2098 for (; left && vleft--; i++, first=0) {
2099 if (write) {
2100 while (left) {
2101 char c;
2102 if (get_user(c, s))
2103 return -EFAULT;
2104 if (!isspace(c))
2105 break;
2106 left--;
2107 s++;
2108 }
2109 if (!left)
2110 break;
2111 neg = 0;
2112 len = left;
2113 if (len > sizeof(buf) - 1)
2114 len = sizeof(buf) - 1;
2115 if (copy_from_user(buf, s, len))
2116 return -EFAULT;
2117 buf[len] = 0;
2118 p = buf;
2119 if (*p == '-' && left > 1) {
2120 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002121 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002122 }
2123 if (*p < '0' || *p > '9')
2124 break;
2125
2126 lval = simple_strtoul(p, &p, 0);
2127
2128 len = p-buf;
2129 if ((len < left) && *p && !isspace(*p))
2130 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002131 s += len;
2132 left -= len;
2133
2134 if (conv(&neg, &lval, i, 1, data))
2135 break;
2136 } else {
2137 p = buf;
2138 if (!first)
2139 *p++ = '\t';
2140
2141 if (conv(&neg, &lval, i, 0, data))
2142 break;
2143
2144 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2145 len = strlen(buf);
2146 if (len > left)
2147 len = left;
2148 if(copy_to_user(s, buf, len))
2149 return -EFAULT;
2150 left -= len;
2151 s += len;
2152 }
2153 }
2154
2155 if (!write && !first && left) {
2156 if(put_user('\n', s))
2157 return -EFAULT;
2158 left--, s++;
2159 }
2160 if (write) {
2161 while (left) {
2162 char c;
2163 if (get_user(c, s++))
2164 return -EFAULT;
2165 if (!isspace(c))
2166 break;
2167 left--;
2168 }
2169 }
2170 if (write && first)
2171 return -EINVAL;
2172 *lenp -= left;
2173 *ppos += *lenp;
2174 return 0;
2175#undef TMPBUFLEN
2176}
2177
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002178static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002179 void __user *buffer, size_t *lenp, loff_t *ppos,
2180 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2181 int write, void *data),
2182 void *data)
2183{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002184 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002185 buffer, lenp, ppos, conv, data);
2186}
2187
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188/**
2189 * proc_dointvec - read a vector of integers
2190 * @table: the sysctl table
2191 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002192 * @buffer: the user buffer
2193 * @lenp: the size of the user buffer
2194 * @ppos: file position
2195 *
2196 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2197 * values from/to the user buffer, treated as an ASCII string.
2198 *
2199 * Returns 0 on success.
2200 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002201int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002202 void __user *buffer, size_t *lenp, loff_t *ppos)
2203{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002204 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002205 NULL,NULL);
2206}
2207
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002208/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002209 * Taint values can only be increased
2210 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002211 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002212static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002213 void __user *buffer, size_t *lenp, loff_t *ppos)
2214{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002215 struct ctl_table t;
2216 unsigned long tmptaint = get_taint();
2217 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002218
Bastian Blank91fcd412007-04-23 14:41:14 -07002219 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002220 return -EPERM;
2221
Andi Kleen25ddbb12008-10-15 22:01:41 -07002222 t = *table;
2223 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002224 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002225 if (err < 0)
2226 return err;
2227
2228 if (write) {
2229 /*
2230 * Poor man's atomic or. Not worth adding a primitive
2231 * to everyone's atomic.h for this
2232 */
2233 int i;
2234 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2235 if ((tmptaint >> i) & 1)
2236 add_taint(i);
2237 }
2238 }
2239
2240 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002241}
2242
Linus Torvalds1da177e2005-04-16 15:20:36 -07002243struct do_proc_dointvec_minmax_conv_param {
2244 int *min;
2245 int *max;
2246};
2247
2248static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2249 int *valp,
2250 int write, void *data)
2251{
2252 struct do_proc_dointvec_minmax_conv_param *param = data;
2253 if (write) {
2254 int val = *negp ? -*lvalp : *lvalp;
2255 if ((param->min && *param->min > val) ||
2256 (param->max && *param->max < val))
2257 return -EINVAL;
2258 *valp = val;
2259 } else {
2260 int val = *valp;
2261 if (val < 0) {
2262 *negp = -1;
2263 *lvalp = (unsigned long)-val;
2264 } else {
2265 *negp = 0;
2266 *lvalp = (unsigned long)val;
2267 }
2268 }
2269 return 0;
2270}
2271
2272/**
2273 * proc_dointvec_minmax - read a vector of integers with min/max values
2274 * @table: the sysctl table
2275 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002276 * @buffer: the user buffer
2277 * @lenp: the size of the user buffer
2278 * @ppos: file position
2279 *
2280 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2281 * values from/to the user buffer, treated as an ASCII string.
2282 *
2283 * This routine will ensure the values are within the range specified by
2284 * table->extra1 (min) and table->extra2 (max).
2285 *
2286 * Returns 0 on success.
2287 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002288int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002289 void __user *buffer, size_t *lenp, loff_t *ppos)
2290{
2291 struct do_proc_dointvec_minmax_conv_param param = {
2292 .min = (int *) table->extra1,
2293 .max = (int *) table->extra2,
2294 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002295 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002296 do_proc_dointvec_minmax_conv, &param);
2297}
2298
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002299static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002300 void __user *buffer,
2301 size_t *lenp, loff_t *ppos,
2302 unsigned long convmul,
2303 unsigned long convdiv)
2304{
2305#define TMPBUFLEN 21
2306 unsigned long *i, *min, *max, val;
2307 int vleft, first=1, neg;
2308 size_t len, left;
2309 char buf[TMPBUFLEN], *p;
2310 char __user *s = buffer;
2311
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002312 if (!data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002313 (*ppos && !write)) {
2314 *lenp = 0;
2315 return 0;
2316 }
2317
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002318 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319 min = (unsigned long *) table->extra1;
2320 max = (unsigned long *) table->extra2;
2321 vleft = table->maxlen / sizeof(unsigned long);
2322 left = *lenp;
2323
2324 for (; left && vleft--; i++, min++, max++, first=0) {
2325 if (write) {
2326 while (left) {
2327 char c;
2328 if (get_user(c, s))
2329 return -EFAULT;
2330 if (!isspace(c))
2331 break;
2332 left--;
2333 s++;
2334 }
2335 if (!left)
2336 break;
2337 neg = 0;
2338 len = left;
2339 if (len > TMPBUFLEN-1)
2340 len = TMPBUFLEN-1;
2341 if (copy_from_user(buf, s, len))
2342 return -EFAULT;
2343 buf[len] = 0;
2344 p = buf;
2345 if (*p == '-' && left > 1) {
2346 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002347 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002348 }
2349 if (*p < '0' || *p > '9')
2350 break;
2351 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2352 len = p-buf;
2353 if ((len < left) && *p && !isspace(*p))
2354 break;
2355 if (neg)
2356 val = -val;
2357 s += len;
2358 left -= len;
2359
2360 if(neg)
2361 continue;
2362 if ((min && val < *min) || (max && val > *max))
2363 continue;
2364 *i = val;
2365 } else {
2366 p = buf;
2367 if (!first)
2368 *p++ = '\t';
2369 sprintf(p, "%lu", convdiv * (*i) / convmul);
2370 len = strlen(buf);
2371 if (len > left)
2372 len = left;
2373 if(copy_to_user(s, buf, len))
2374 return -EFAULT;
2375 left -= len;
2376 s += len;
2377 }
2378 }
2379
2380 if (!write && !first && left) {
2381 if(put_user('\n', s))
2382 return -EFAULT;
2383 left--, s++;
2384 }
2385 if (write) {
2386 while (left) {
2387 char c;
2388 if (get_user(c, s++))
2389 return -EFAULT;
2390 if (!isspace(c))
2391 break;
2392 left--;
2393 }
2394 }
2395 if (write && first)
2396 return -EINVAL;
2397 *lenp -= left;
2398 *ppos += *lenp;
2399 return 0;
2400#undef TMPBUFLEN
2401}
2402
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002403static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002404 void __user *buffer,
2405 size_t *lenp, loff_t *ppos,
2406 unsigned long convmul,
2407 unsigned long convdiv)
2408{
2409 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002410 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002411}
2412
Linus Torvalds1da177e2005-04-16 15:20:36 -07002413/**
2414 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2415 * @table: the sysctl table
2416 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002417 * @buffer: the user buffer
2418 * @lenp: the size of the user buffer
2419 * @ppos: file position
2420 *
2421 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2422 * values from/to the user buffer, treated as an ASCII string.
2423 *
2424 * This routine will ensure the values are within the range specified by
2425 * table->extra1 (min) and table->extra2 (max).
2426 *
2427 * Returns 0 on success.
2428 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002429int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002430 void __user *buffer, size_t *lenp, loff_t *ppos)
2431{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002432 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002433}
2434
2435/**
2436 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2437 * @table: the sysctl table
2438 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 * @buffer: the user buffer
2440 * @lenp: the size of the user buffer
2441 * @ppos: file position
2442 *
2443 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2444 * values from/to the user buffer, treated as an ASCII string. The values
2445 * are treated as milliseconds, and converted to jiffies when they are stored.
2446 *
2447 * This routine will ensure the values are within the range specified by
2448 * table->extra1 (min) and table->extra2 (max).
2449 *
2450 * Returns 0 on success.
2451 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002452int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453 void __user *buffer,
2454 size_t *lenp, loff_t *ppos)
2455{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002456 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002457 lenp, ppos, HZ, 1000l);
2458}
2459
2460
2461static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2462 int *valp,
2463 int write, void *data)
2464{
2465 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002466 if (*lvalp > LONG_MAX / HZ)
2467 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002468 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2469 } else {
2470 int val = *valp;
2471 unsigned long lval;
2472 if (val < 0) {
2473 *negp = -1;
2474 lval = (unsigned long)-val;
2475 } else {
2476 *negp = 0;
2477 lval = (unsigned long)val;
2478 }
2479 *lvalp = lval / HZ;
2480 }
2481 return 0;
2482}
2483
2484static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2485 int *valp,
2486 int write, void *data)
2487{
2488 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002489 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2490 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002491 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2492 } else {
2493 int val = *valp;
2494 unsigned long lval;
2495 if (val < 0) {
2496 *negp = -1;
2497 lval = (unsigned long)-val;
2498 } else {
2499 *negp = 0;
2500 lval = (unsigned long)val;
2501 }
2502 *lvalp = jiffies_to_clock_t(lval);
2503 }
2504 return 0;
2505}
2506
2507static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2508 int *valp,
2509 int write, void *data)
2510{
2511 if (write) {
2512 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2513 } else {
2514 int val = *valp;
2515 unsigned long lval;
2516 if (val < 0) {
2517 *negp = -1;
2518 lval = (unsigned long)-val;
2519 } else {
2520 *negp = 0;
2521 lval = (unsigned long)val;
2522 }
2523 *lvalp = jiffies_to_msecs(lval);
2524 }
2525 return 0;
2526}
2527
2528/**
2529 * proc_dointvec_jiffies - read a vector of integers as seconds
2530 * @table: the sysctl table
2531 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002532 * @buffer: the user buffer
2533 * @lenp: the size of the user buffer
2534 * @ppos: file position
2535 *
2536 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2537 * values from/to the user buffer, treated as an ASCII string.
2538 * The values read are assumed to be in seconds, and are converted into
2539 * jiffies.
2540 *
2541 * Returns 0 on success.
2542 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002543int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544 void __user *buffer, size_t *lenp, loff_t *ppos)
2545{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002546 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002547 do_proc_dointvec_jiffies_conv,NULL);
2548}
2549
2550/**
2551 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2552 * @table: the sysctl table
2553 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002554 * @buffer: the user buffer
2555 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002556 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002557 *
2558 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2559 * values from/to the user buffer, treated as an ASCII string.
2560 * The values read are assumed to be in 1/USER_HZ seconds, and
2561 * are converted into jiffies.
2562 *
2563 * Returns 0 on success.
2564 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002565int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002566 void __user *buffer, size_t *lenp, loff_t *ppos)
2567{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002568 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002569 do_proc_dointvec_userhz_jiffies_conv,NULL);
2570}
2571
2572/**
2573 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2574 * @table: the sysctl table
2575 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002576 * @buffer: the user buffer
2577 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002578 * @ppos: file position
2579 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002580 *
2581 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2582 * values from/to the user buffer, treated as an ASCII string.
2583 * The values read are assumed to be in 1/1000 seconds, and
2584 * are converted into jiffies.
2585 *
2586 * Returns 0 on success.
2587 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002588int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002589 void __user *buffer, size_t *lenp, loff_t *ppos)
2590{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002591 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002592 do_proc_dointvec_ms_jiffies_conv, NULL);
2593}
2594
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002595static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002596 void __user *buffer, size_t *lenp, loff_t *ppos)
2597{
2598 struct pid *new_pid;
2599 pid_t tmp;
2600 int r;
2601
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002602 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002603
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002604 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002605 lenp, ppos, NULL, NULL);
2606 if (r || !write)
2607 return r;
2608
2609 new_pid = find_get_pid(tmp);
2610 if (!new_pid)
2611 return -ESRCH;
2612
2613 put_pid(xchg(&cad_pid, new_pid));
2614 return 0;
2615}
2616
Linus Torvalds1da177e2005-04-16 15:20:36 -07002617#else /* CONFIG_PROC_FS */
2618
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002619int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620 void __user *buffer, size_t *lenp, loff_t *ppos)
2621{
2622 return -ENOSYS;
2623}
2624
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002625int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002626 void __user *buffer, size_t *lenp, loff_t *ppos)
2627{
2628 return -ENOSYS;
2629}
2630
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002631int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002632 void __user *buffer, size_t *lenp, loff_t *ppos)
2633{
2634 return -ENOSYS;
2635}
2636
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002637int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002638 void __user *buffer, size_t *lenp, loff_t *ppos)
2639{
2640 return -ENOSYS;
2641}
2642
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002643int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002644 void __user *buffer, size_t *lenp, loff_t *ppos)
2645{
2646 return -ENOSYS;
2647}
2648
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002649int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002650 void __user *buffer, size_t *lenp, loff_t *ppos)
2651{
2652 return -ENOSYS;
2653}
2654
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002655int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002656 void __user *buffer, size_t *lenp, loff_t *ppos)
2657{
2658 return -ENOSYS;
2659}
2660
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002661int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002662 void __user *buffer,
2663 size_t *lenp, loff_t *ppos)
2664{
2665 return -ENOSYS;
2666}
2667
2668
2669#endif /* CONFIG_PROC_FS */
2670
Linus Torvalds1da177e2005-04-16 15:20:36 -07002671/*
2672 * No sense putting this after each symbol definition, twice,
2673 * exception granted :-)
2674 */
2675EXPORT_SYMBOL(proc_dointvec);
2676EXPORT_SYMBOL(proc_dointvec_jiffies);
2677EXPORT_SYMBOL(proc_dointvec_minmax);
2678EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2679EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2680EXPORT_SYMBOL(proc_dostring);
2681EXPORT_SYMBOL(proc_doulongvec_minmax);
2682EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2683EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002684EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002685EXPORT_SYMBOL(unregister_sysctl_table);