blob: 2fb4246d27ded21901cfd482643af84036c217aa [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
22#include <linux/mm.h>
23#include <linux/swap.h>
24#include <linux/slab.h>
25#include <linux/sysctl.h>
26#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070027#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <linux/ctype.h>
29#include <linux/utsname.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/smp_lock.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>
39#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070041#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#include <linux/times.h>
43#include <linux/limits.h>
44#include <linux/dcache.h>
45#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070046#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080047#include <linux/nfs_fs.h>
48#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070049#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020050#include <linux/ftrace.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52#include <asm/uaccess.h>
53#include <asm/processor.h>
54
Andi Kleen29cbc782006-09-30 01:47:55 +020055#ifdef CONFIG_X86
56#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010057#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010058#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020059#endif
60
Eric W. Biederman7058cb02007-10-18 03:05:58 -070061static int deprecated_sysctl_warning(struct __sysctl_args *args);
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#if defined(CONFIG_SYSCTL)
64
65/* External variables not in a header file. */
66extern int C_A_D;
Ingo Molnar45807a12007-07-15 23:40:10 -070067extern int print_fatal_signals;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068extern int sysctl_overcommit_memory;
69extern int sysctl_overcommit_ratio;
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -070070extern int sysctl_panic_on_oom;
David Rientjesfe071d72007-10-16 23:25:56 -070071extern int sysctl_oom_kill_allocating_task;
David Rientjesfef1bdd2008-02-07 00:14:07 -080072extern int sysctl_oom_dump_tasks;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070075extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076extern char core_pattern[];
Linus Torvalds1da177e2005-04-16 15:20:36 -070077extern int pid_max;
78extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -080080extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -080081extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +020082extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +010083extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -040084extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +000085#ifndef CONFIG_MMU
86extern int sysctl_nr_trim_pages;
87#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -070088#ifdef CONFIG_RCU_TORTURE_TEST
89extern int rcutorture_runnable;
90#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
Linus Torvalds1da177e2005-04-16 15:20:36 -070091
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070092/* Constants used for minimum and maximum */
Bron Gondwana195cf4532008-02-04 22:29:20 -080093#ifdef CONFIG_DETECT_SOFTLOCKUP
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070094static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +020095static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070096#endif
97
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +020098#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING)
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070099static int two = 2;
100#endif
101
102static int zero;
David Rientjes2da02992009-01-06 14:39:31 -0800103static int one = 1;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800104static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700105static int one_hundred = 100;
106
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
108static int maxolduid = 65535;
109static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800110static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
112static int ngroups_max = NGROUPS_MAX;
113
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200114#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115extern char modprobe_path[];
Kees Cook3d433212009-04-02 15:49:29 -0700116extern int modules_disabled;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118#ifdef CONFIG_CHR_DEV_SG
119extern int sg_big_buff;
120#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
David S. Miller72c57ed2008-09-11 23:29:54 -0700122#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700123#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124#endif
125
David S. Miller08714202008-11-16 23:49:24 -0800126#ifdef CONFIG_SPARC64
127extern int sysctl_tsb_ratio;
128#endif
129
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130#ifdef __hppa__
131extern int pwrsw_enabled;
132extern int unaligned_enabled;
133#endif
134
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800135#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136#ifdef CONFIG_MATHEMU
137extern int sysctl_ieee_emulation_warnings;
138#endif
139extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700140extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141#endif
142
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143#ifdef CONFIG_BSD_PROCESS_ACCT
144extern int acct_parm[];
145#endif
146
Jes Sorensend2b176e2006-02-28 09:42:23 -0800147#ifdef CONFIG_IA64
148extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800149extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800150#endif
151
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700152#ifdef CONFIG_RT_MUTEXES
153extern int max_lock_depth;
154#endif
155
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700156#ifdef CONFIG_PROC_SYSCTL
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700157static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700158 void __user *buffer, size_t *lenp, loff_t *ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -0700159static int proc_taint(struct ctl_table *table, int write, struct file *filp,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800160 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700161#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700162
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700163static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100164static struct ctl_table_root sysctl_table_root;
165static struct ctl_table_header root_table_header = {
Al Virob380b0d2008-09-04 17:05:57 +0100166 .count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100167 .ctl_table = root_table,
Al Viro73455092008-07-14 21:22:20 -0400168 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100169 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400170 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100171};
172static struct ctl_table_root sysctl_table_root = {
173 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400174 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100175};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700177static struct ctl_table kern_table[];
178static struct ctl_table vm_table[];
179static struct ctl_table fs_table[];
180static struct ctl_table debug_table[];
181static struct ctl_table dev_table[];
182extern struct ctl_table random_table[];
Amy Griffis2d9048e2006-06-01 13:10:59 -0700183#ifdef CONFIG_INOTIFY_USER
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700184extern struct ctl_table inotify_table[];
Robert Love0399cb02005-07-13 12:38:18 -0400185#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -0800186#ifdef CONFIG_EPOLL
187extern struct ctl_table epoll_table[];
188#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189
190#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
191int sysctl_legacy_va_layout;
192#endif
193
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700194extern int prove_locking;
195extern int lock_stat;
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800196
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197/* The default sysctl tables: */
198
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700199static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 {
201 .ctl_name = CTL_KERN,
202 .procname = "kernel",
203 .mode = 0555,
204 .child = kern_table,
205 },
206 {
207 .ctl_name = CTL_VM,
208 .procname = "vm",
209 .mode = 0555,
210 .child = vm_table,
211 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 .ctl_name = CTL_FS,
214 .procname = "fs",
215 .mode = 0555,
216 .child = fs_table,
217 },
218 {
219 .ctl_name = CTL_DEBUG,
220 .procname = "debug",
221 .mode = 0555,
222 .child = debug_table,
223 },
224 {
225 .ctl_name = CTL_DEV,
226 .procname = "dev",
227 .mode = 0555,
228 .child = dev_table,
229 },
Andrew Morton2be7fe02007-07-15 23:41:21 -0700230/*
231 * NOTE: do not add new entries to this table unless you have read
232 * Documentation/sysctl/ctl_unnumbered.txt
233 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 { .ctl_name = 0 }
235};
236
Ingo Molnar77e54a12007-07-09 18:52:00 +0200237#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100238static int min_sched_granularity_ns = 100000; /* 100 usecs */
239static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
240static int min_wakeup_granularity_ns; /* 0 usecs */
241static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200242#endif
243
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700244static struct ctl_table kern_table[] = {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200245#ifdef CONFIG_SCHED_DEBUG
246 {
247 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100248 .procname = "sched_min_granularity_ns",
249 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200250 .maxlen = sizeof(unsigned int),
251 .mode = 0644,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100252 .proc_handler = &sched_nr_latency_handler,
253 .strategy = &sysctl_intvec,
254 .extra1 = &min_sched_granularity_ns,
255 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200256 },
257 {
258 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra21805082007-08-25 18:41:53 +0200259 .procname = "sched_latency_ns",
260 .data = &sysctl_sched_latency,
261 .maxlen = sizeof(unsigned int),
262 .mode = 0644,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100263 .proc_handler = &sched_nr_latency_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200264 .strategy = &sysctl_intvec,
265 .extra1 = &min_sched_granularity_ns,
266 .extra2 = &max_sched_granularity_ns,
267 },
268 {
269 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200270 .procname = "sched_wakeup_granularity_ns",
271 .data = &sysctl_sched_wakeup_granularity,
272 .maxlen = sizeof(unsigned int),
273 .mode = 0644,
274 .proc_handler = &proc_dointvec_minmax,
275 .strategy = &sysctl_intvec,
276 .extra1 = &min_wakeup_granularity_ns,
277 .extra2 = &max_wakeup_granularity_ns,
278 },
279 {
280 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200281 .procname = "sched_shares_ratelimit",
282 .data = &sysctl_sched_shares_ratelimit,
283 .maxlen = sizeof(unsigned int),
284 .mode = 0644,
285 .proc_handler = &proc_dointvec,
286 },
287 {
288 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200289 .procname = "sched_shares_thresh",
290 .data = &sysctl_sched_shares_thresh,
291 .maxlen = sizeof(unsigned int),
292 .mode = 0644,
293 .proc_handler = &proc_dointvec_minmax,
294 .strategy = &sysctl_intvec,
295 .extra1 = &zero,
296 },
297 {
298 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200299 .procname = "sched_child_runs_first",
300 .data = &sysctl_sched_child_runs_first,
301 .maxlen = sizeof(unsigned int),
302 .mode = 0644,
303 .proc_handler = &proc_dointvec,
304 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200305 {
306 .ctl_name = CTL_UNNUMBERED,
307 .procname = "sched_features",
308 .data = &sysctl_sched_features,
309 .maxlen = sizeof(unsigned int),
310 .mode = 0644,
311 .proc_handler = &proc_dointvec,
312 },
Ingo Molnarda84d962007-10-15 17:00:18 +0200313 {
314 .ctl_name = CTL_UNNUMBERED,
315 .procname = "sched_migration_cost",
316 .data = &sysctl_sched_migration_cost,
317 .maxlen = sizeof(unsigned int),
318 .mode = 0644,
319 .proc_handler = &proc_dointvec,
320 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100321 {
322 .ctl_name = CTL_UNNUMBERED,
323 .procname = "sched_nr_migrate",
324 .data = &sysctl_sched_nr_migrate,
325 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100326 .mode = 0644,
327 .proc_handler = &proc_dointvec,
328 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200329#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200330 {
331 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100332 .procname = "sched_rt_period_us",
333 .data = &sysctl_sched_rt_period,
334 .maxlen = sizeof(unsigned int),
335 .mode = 0644,
Peter Zijlstrad0b27fa2008-04-19 19:44:57 +0200336 .proc_handler = &sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100337 },
338 {
339 .ctl_name = CTL_UNNUMBERED,
340 .procname = "sched_rt_runtime_us",
341 .data = &sysctl_sched_rt_runtime,
342 .maxlen = sizeof(int),
343 .mode = 0644,
Peter Zijlstrad0b27fa2008-04-19 19:44:57 +0200344 .proc_handler = &sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100345 },
346 {
347 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar1799e352007-09-19 23:34:46 +0200348 .procname = "sched_compat_yield",
349 .data = &sysctl_sched_compat_yield,
350 .maxlen = sizeof(unsigned int),
351 .mode = 0644,
352 .proc_handler = &proc_dointvec,
353 },
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700354#ifdef CONFIG_PROVE_LOCKING
355 {
356 .ctl_name = CTL_UNNUMBERED,
357 .procname = "prove_locking",
358 .data = &prove_locking,
359 .maxlen = sizeof(int),
360 .mode = 0644,
361 .proc_handler = &proc_dointvec,
362 },
363#endif
364#ifdef CONFIG_LOCK_STAT
365 {
366 .ctl_name = CTL_UNNUMBERED,
367 .procname = "lock_stat",
368 .data = &lock_stat,
369 .maxlen = sizeof(int),
370 .mode = 0644,
371 .proc_handler = &proc_dointvec,
372 },
373#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200374 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 .ctl_name = KERN_PANIC,
376 .procname = "panic",
377 .data = &panic_timeout,
378 .maxlen = sizeof(int),
379 .mode = 0644,
380 .proc_handler = &proc_dointvec,
381 },
382 {
383 .ctl_name = KERN_CORE_USES_PID,
384 .procname = "core_uses_pid",
385 .data = &core_uses_pid,
386 .maxlen = sizeof(int),
387 .mode = 0644,
388 .proc_handler = &proc_dointvec,
389 },
390 {
391 .ctl_name = KERN_CORE_PATTERN,
392 .procname = "core_pattern",
393 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700394 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 .mode = 0644,
396 .proc_handler = &proc_dostring,
397 .strategy = &sysctl_string,
398 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800399#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700402 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800403 .mode = 0644,
Andi Kleen25ddbb12008-10-15 22:01:41 -0700404 .proc_handler = &proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800406#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100407#ifdef CONFIG_LATENCYTOP
408 {
409 .procname = "latencytop",
410 .data = &latencytop_enabled,
411 .maxlen = sizeof(int),
412 .mode = 0644,
413 .proc_handler = &proc_dointvec,
414 },
415#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416#ifdef CONFIG_BLK_DEV_INITRD
417 {
418 .ctl_name = KERN_REALROOTDEV,
419 .procname = "real-root-dev",
420 .data = &real_root_dev,
421 .maxlen = sizeof(int),
422 .mode = 0644,
423 .proc_handler = &proc_dointvec,
424 },
425#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700426 {
427 .ctl_name = CTL_UNNUMBERED,
428 .procname = "print-fatal-signals",
429 .data = &print_fatal_signals,
430 .maxlen = sizeof(int),
431 .mode = 0644,
432 .proc_handler = &proc_dointvec,
433 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700434#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 {
436 .ctl_name = KERN_SPARC_REBOOT,
437 .procname = "reboot-cmd",
438 .data = reboot_command,
439 .maxlen = 256,
440 .mode = 0644,
441 .proc_handler = &proc_dostring,
442 .strategy = &sysctl_string,
443 },
444 {
445 .ctl_name = KERN_SPARC_STOP_A,
446 .procname = "stop-a",
447 .data = &stop_a_enabled,
448 .maxlen = sizeof (int),
449 .mode = 0644,
450 .proc_handler = &proc_dointvec,
451 },
452 {
453 .ctl_name = KERN_SPARC_SCONS_PWROFF,
454 .procname = "scons-poweroff",
455 .data = &scons_pwroff,
456 .maxlen = sizeof (int),
457 .mode = 0644,
458 .proc_handler = &proc_dointvec,
459 },
460#endif
David S. Miller08714202008-11-16 23:49:24 -0800461#ifdef CONFIG_SPARC64
462 {
463 .ctl_name = CTL_UNNUMBERED,
464 .procname = "tsb-ratio",
465 .data = &sysctl_tsb_ratio,
466 .maxlen = sizeof (int),
467 .mode = 0644,
468 .proc_handler = &proc_dointvec,
469 },
470#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471#ifdef __hppa__
472 {
473 .ctl_name = KERN_HPPA_PWRSW,
474 .procname = "soft-power",
475 .data = &pwrsw_enabled,
476 .maxlen = sizeof (int),
477 .mode = 0644,
478 .proc_handler = &proc_dointvec,
479 },
480 {
481 .ctl_name = KERN_HPPA_UNALIGNED,
482 .procname = "unaligned-trap",
483 .data = &unaligned_enabled,
484 .maxlen = sizeof (int),
485 .mode = 0644,
486 .proc_handler = &proc_dointvec,
487 },
488#endif
489 {
490 .ctl_name = KERN_CTLALTDEL,
491 .procname = "ctrl-alt-del",
492 .data = &C_A_D,
493 .maxlen = sizeof(int),
494 .mode = 0644,
495 .proc_handler = &proc_dointvec,
496 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400497#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200498 {
499 .ctl_name = CTL_UNNUMBERED,
500 .procname = "ftrace_enabled",
501 .data = &ftrace_enabled,
502 .maxlen = sizeof(int),
503 .mode = 0644,
504 .proc_handler = &ftrace_enable_sysctl,
505 },
506#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500507#ifdef CONFIG_STACK_TRACER
508 {
509 .ctl_name = CTL_UNNUMBERED,
510 .procname = "stack_tracer_enabled",
511 .data = &stack_tracer_enabled,
512 .maxlen = sizeof(int),
513 .mode = 0644,
514 .proc_handler = &stack_trace_sysctl,
515 },
516#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400517#ifdef CONFIG_TRACING
518 {
519 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100520 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400521 .data = &ftrace_dump_on_oops,
522 .maxlen = sizeof(int),
523 .mode = 0644,
524 .proc_handler = &proc_dointvec,
525 },
526#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200527#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 {
529 .ctl_name = KERN_MODPROBE,
530 .procname = "modprobe",
531 .data = &modprobe_path,
532 .maxlen = KMOD_PATH_LEN,
533 .mode = 0644,
534 .proc_handler = &proc_dostring,
535 .strategy = &sysctl_string,
536 },
Kees Cook3d433212009-04-02 15:49:29 -0700537 {
538 .ctl_name = CTL_UNNUMBERED,
539 .procname = "modules_disabled",
540 .data = &modules_disabled,
541 .maxlen = sizeof(int),
542 .mode = 0644,
543 /* only handle a transition from default "0" to "1" */
544 .proc_handler = &proc_dointvec_minmax,
545 .extra1 = &one,
546 .extra2 = &one,
547 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548#endif
Andrew Morton57ae2502006-06-23 02:05:47 -0700549#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 {
551 .ctl_name = KERN_HOTPLUG,
552 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100553 .data = &uevent_helper,
554 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 .mode = 0644,
556 .proc_handler = &proc_dostring,
557 .strategy = &sysctl_string,
558 },
559#endif
560#ifdef CONFIG_CHR_DEV_SG
561 {
562 .ctl_name = KERN_SG_BIG_BUFF,
563 .procname = "sg-big-buff",
564 .data = &sg_big_buff,
565 .maxlen = sizeof (int),
566 .mode = 0444,
567 .proc_handler = &proc_dointvec,
568 },
569#endif
570#ifdef CONFIG_BSD_PROCESS_ACCT
571 {
572 .ctl_name = KERN_ACCT,
573 .procname = "acct",
574 .data = &acct_parm,
575 .maxlen = 3*sizeof(int),
576 .mode = 0644,
577 .proc_handler = &proc_dointvec,
578 },
579#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580#ifdef CONFIG_MAGIC_SYSRQ
581 {
582 .ctl_name = KERN_SYSRQ,
583 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800584 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 .maxlen = sizeof (int),
586 .mode = 0644,
587 .proc_handler = &proc_dointvec,
588 },
589#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700590#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700593 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 .maxlen = sizeof (int),
595 .mode = 0600,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700596 .proc_handler = &proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700598#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 {
600 .ctl_name = KERN_MAX_THREADS,
601 .procname = "threads-max",
602 .data = &max_threads,
603 .maxlen = sizeof(int),
604 .mode = 0644,
605 .proc_handler = &proc_dointvec,
606 },
607 {
608 .ctl_name = KERN_RANDOM,
609 .procname = "random",
610 .mode = 0555,
611 .child = random_table,
612 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 {
614 .ctl_name = KERN_OVERFLOWUID,
615 .procname = "overflowuid",
616 .data = &overflowuid,
617 .maxlen = sizeof(int),
618 .mode = 0644,
619 .proc_handler = &proc_dointvec_minmax,
620 .strategy = &sysctl_intvec,
621 .extra1 = &minolduid,
622 .extra2 = &maxolduid,
623 },
624 {
625 .ctl_name = KERN_OVERFLOWGID,
626 .procname = "overflowgid",
627 .data = &overflowgid,
628 .maxlen = sizeof(int),
629 .mode = 0644,
630 .proc_handler = &proc_dointvec_minmax,
631 .strategy = &sysctl_intvec,
632 .extra1 = &minolduid,
633 .extra2 = &maxolduid,
634 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800635#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636#ifdef CONFIG_MATHEMU
637 {
638 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
639 .procname = "ieee_emulation_warnings",
640 .data = &sysctl_ieee_emulation_warnings,
641 .maxlen = sizeof(int),
642 .mode = 0644,
643 .proc_handler = &proc_dointvec,
644 },
645#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 {
647 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
648 .procname = "userprocess_debug",
649 .data = &sysctl_userprocess_debug,
650 .maxlen = sizeof(int),
651 .mode = 0644,
652 .proc_handler = &proc_dointvec,
653 },
654#endif
655 {
656 .ctl_name = KERN_PIDMAX,
657 .procname = "pid_max",
658 .data = &pid_max,
659 .maxlen = sizeof (int),
660 .mode = 0644,
661 .proc_handler = &proc_dointvec_minmax,
662 .strategy = sysctl_intvec,
663 .extra1 = &pid_max_min,
664 .extra2 = &pid_max_max,
665 },
666 {
667 .ctl_name = KERN_PANIC_ON_OOPS,
668 .procname = "panic_on_oops",
669 .data = &panic_on_oops,
670 .maxlen = sizeof(int),
671 .mode = 0644,
672 .proc_handler = &proc_dointvec,
673 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800674#if defined CONFIG_PRINTK
675 {
676 .ctl_name = KERN_PRINTK,
677 .procname = "printk",
678 .data = &console_loglevel,
679 .maxlen = 4*sizeof(int),
680 .mode = 0644,
681 .proc_handler = &proc_dointvec,
682 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 {
684 .ctl_name = KERN_PRINTK_RATELIMIT,
685 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700686 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 .maxlen = sizeof(int),
688 .mode = 0644,
689 .proc_handler = &proc_dointvec_jiffies,
690 .strategy = &sysctl_jiffies,
691 },
692 {
693 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
694 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700695 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 .maxlen = sizeof(int),
697 .mode = 0644,
698 .proc_handler = &proc_dointvec,
699 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800700#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 {
702 .ctl_name = KERN_NGROUPS_MAX,
703 .procname = "ngroups_max",
704 .data = &ngroups_max,
705 .maxlen = sizeof (int),
706 .mode = 0444,
707 .proc_handler = &proc_dointvec,
708 },
709#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
710 {
711 .ctl_name = KERN_UNKNOWN_NMI_PANIC,
712 .procname = "unknown_nmi_panic",
713 .data = &unknown_nmi_panic,
714 .maxlen = sizeof (int),
715 .mode = 0644,
Don Zickus2fbe7b22006-09-26 10:52:27 +0200716 .proc_handler = &proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 },
Don Zickus407984f2006-09-26 10:52:27 +0200718 {
Don Zickus407984f2006-09-26 10:52:27 +0200719 .procname = "nmi_watchdog",
720 .data = &nmi_watchdog_enabled,
721 .maxlen = sizeof (int),
722 .mode = 0644,
723 .proc_handler = &proc_nmi_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 },
725#endif
726#if defined(CONFIG_X86)
727 {
Don Zickus8da5add2006-09-26 10:52:27 +0200728 .ctl_name = KERN_PANIC_ON_NMI,
729 .procname = "panic_on_unrecovered_nmi",
730 .data = &panic_on_unrecovered_nmi,
731 .maxlen = sizeof(int),
732 .mode = 0644,
733 .proc_handler = &proc_dointvec,
734 },
735 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 .ctl_name = KERN_BOOTLOADER_TYPE,
737 .procname = "bootloader_type",
738 .data = &bootloader_type,
739 .maxlen = sizeof (int),
740 .mode = 0444,
741 .proc_handler = &proc_dointvec,
742 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100743 {
744 .ctl_name = CTL_UNNUMBERED,
745 .procname = "kstack_depth_to_print",
746 .data = &kstack_depth_to_print,
747 .maxlen = sizeof(int),
748 .mode = 0644,
749 .proc_handler = &proc_dointvec,
750 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100751 {
752 .ctl_name = CTL_UNNUMBERED,
753 .procname = "io_delay_type",
754 .data = &io_delay_type,
755 .maxlen = sizeof(int),
756 .mode = 0644,
757 .proc_handler = &proc_dointvec,
758 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800760#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 {
762 .ctl_name = KERN_RANDOMIZE,
763 .procname = "randomize_va_space",
764 .data = &randomize_va_space,
765 .maxlen = sizeof(int),
766 .mode = 0644,
767 .proc_handler = &proc_dointvec,
768 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800769#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800770#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700771 {
772 .ctl_name = KERN_SPIN_RETRY,
773 .procname = "spin_retry",
774 .data = &spin_retry,
775 .maxlen = sizeof (int),
776 .mode = 0644,
777 .proc_handler = &proc_dointvec,
778 },
779#endif
Len Brown673d5b42007-07-28 03:33:16 -0400780#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800781 {
Pavel Machekc255d842006-02-20 18:27:58 -0800782 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700783 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800784 .maxlen = sizeof (unsigned long),
785 .mode = 0644,
Stefan Seyfried7f99f062006-03-02 02:54:34 -0800786 .proc_handler = &proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800787 },
788#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800789#ifdef CONFIG_IA64
790 {
791 .ctl_name = KERN_IA64_UNALIGNED,
792 .procname = "ignore-unaligned-usertrap",
793 .data = &no_unaligned_warning,
794 .maxlen = sizeof (int),
795 .mode = 0644,
796 .proc_handler = &proc_dointvec,
797 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800798 {
799 .ctl_name = CTL_UNNUMBERED,
800 .procname = "unaligned-dump-stack",
801 .data = &unaligned_dump_stack,
802 .maxlen = sizeof (int),
803 .mode = 0644,
804 .proc_handler = &proc_dointvec,
805 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800806#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700807#ifdef CONFIG_DETECT_SOFTLOCKUP
808 {
809 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200810 .procname = "softlockup_panic",
811 .data = &softlockup_panic,
812 .maxlen = sizeof(int),
813 .mode = 0644,
Hiroshi Shimamoto4dca10a2008-07-07 18:37:04 -0700814 .proc_handler = &proc_dointvec_minmax,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200815 .strategy = &sysctl_intvec,
816 .extra1 = &zero,
817 .extra2 = &one,
818 },
819 {
820 .ctl_name = CTL_UNNUMBERED,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700821 .procname = "softlockup_thresh",
822 .data = &softlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200823 .maxlen = sizeof(int),
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700824 .mode = 0644,
Mandeep Singh Bainesbaf48f62009-01-12 21:15:17 -0800825 .proc_handler = &proc_dosoftlockup_thresh,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700826 .strategy = &sysctl_intvec,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200827 .extra1 = &neg_one,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700828 .extra2 = &sixty,
829 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100830 {
831 .ctl_name = CTL_UNNUMBERED,
832 .procname = "hung_task_check_count",
833 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100834 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100835 .mode = 0644,
Ingo Molnar90739082008-01-25 21:08:34 +0100836 .proc_handler = &proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100837 .strategy = &sysctl_intvec,
838 },
839 {
840 .ctl_name = CTL_UNNUMBERED,
841 .procname = "hung_task_timeout_secs",
842 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100843 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100844 .mode = 0644,
Ingo Molnar90739082008-01-25 21:08:34 +0100845 .proc_handler = &proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100846 .strategy = &sysctl_intvec,
847 },
848 {
849 .ctl_name = CTL_UNNUMBERED,
850 .procname = "hung_task_warnings",
851 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100852 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100853 .mode = 0644,
Ingo Molnar90739082008-01-25 21:08:34 +0100854 .proc_handler = &proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100855 .strategy = &sysctl_intvec,
856 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700857#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200858#ifdef CONFIG_COMPAT
859 {
860 .ctl_name = KERN_COMPAT_LOG,
861 .procname = "compat-log",
862 .data = &compat_log,
863 .maxlen = sizeof (int),
864 .mode = 0644,
865 .proc_handler = &proc_dointvec,
866 },
867#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700868#ifdef CONFIG_RT_MUTEXES
869 {
870 .ctl_name = KERN_MAX_LOCK_DEPTH,
871 .procname = "max_lock_depth",
872 .data = &max_lock_depth,
873 .maxlen = sizeof(int),
874 .mode = 0644,
875 .proc_handler = &proc_dointvec,
876 },
877#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700878 {
879 .ctl_name = CTL_UNNUMBERED,
880 .procname = "poweroff_cmd",
881 .data = &poweroff_cmd,
882 .maxlen = POWEROFF_CMD_PATH_LEN,
883 .mode = 0644,
884 .proc_handler = &proc_dostring,
885 .strategy = &sysctl_string,
886 },
David Howells0b77f5b2008-04-29 01:01:32 -0700887#ifdef CONFIG_KEYS
888 {
889 .ctl_name = CTL_UNNUMBERED,
890 .procname = "keys",
891 .mode = 0555,
892 .child = key_sysctls,
893 },
894#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700895#ifdef CONFIG_RCU_TORTURE_TEST
896 {
897 .ctl_name = CTL_UNNUMBERED,
898 .procname = "rcutorture_runnable",
899 .data = &rcutorture_runnable,
900 .maxlen = sizeof(int),
901 .mode = 0644,
902 .proc_handler = &proc_dointvec,
903 },
904#endif
Lee Schermerhornaf936a12008-10-18 20:26:53 -0700905#ifdef CONFIG_UNEVICTABLE_LRU
906 {
907 .ctl_name = CTL_UNNUMBERED,
908 .procname = "scan_unevictable_pages",
909 .data = &scan_unevictable_pages,
910 .maxlen = sizeof(scan_unevictable_pages),
911 .mode = 0644,
912 .proc_handler = &scan_unevictable_handler,
913 },
914#endif
Andrew Mortoned2c12f2007-07-19 01:50:35 -0700915/*
916 * NOTE: do not add new entries to this table unless you have read
917 * Documentation/sysctl/ctl_unnumbered.txt
918 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919 { .ctl_name = 0 }
920};
921
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700922static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700923 {
924 .ctl_name = VM_OVERCOMMIT_MEMORY,
925 .procname = "overcommit_memory",
926 .data = &sysctl_overcommit_memory,
927 .maxlen = sizeof(sysctl_overcommit_memory),
928 .mode = 0644,
929 .proc_handler = &proc_dointvec,
930 },
931 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700932 .ctl_name = VM_PANIC_ON_OOM,
933 .procname = "panic_on_oom",
934 .data = &sysctl_panic_on_oom,
935 .maxlen = sizeof(sysctl_panic_on_oom),
936 .mode = 0644,
937 .proc_handler = &proc_dointvec,
938 },
939 {
David Rientjesfe071d72007-10-16 23:25:56 -0700940 .ctl_name = CTL_UNNUMBERED,
941 .procname = "oom_kill_allocating_task",
942 .data = &sysctl_oom_kill_allocating_task,
943 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
944 .mode = 0644,
945 .proc_handler = &proc_dointvec,
946 },
947 {
David Rientjesfef1bdd2008-02-07 00:14:07 -0800948 .ctl_name = CTL_UNNUMBERED,
949 .procname = "oom_dump_tasks",
950 .data = &sysctl_oom_dump_tasks,
951 .maxlen = sizeof(sysctl_oom_dump_tasks),
952 .mode = 0644,
953 .proc_handler = &proc_dointvec,
954 },
955 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956 .ctl_name = VM_OVERCOMMIT_RATIO,
957 .procname = "overcommit_ratio",
958 .data = &sysctl_overcommit_ratio,
959 .maxlen = sizeof(sysctl_overcommit_ratio),
960 .mode = 0644,
961 .proc_handler = &proc_dointvec,
962 },
963 {
964 .ctl_name = VM_PAGE_CLUSTER,
965 .procname = "page-cluster",
966 .data = &page_cluster,
967 .maxlen = sizeof(int),
968 .mode = 0644,
969 .proc_handler = &proc_dointvec,
970 },
971 {
972 .ctl_name = VM_DIRTY_BACKGROUND,
973 .procname = "dirty_background_ratio",
974 .data = &dirty_background_ratio,
975 .maxlen = sizeof(dirty_background_ratio),
976 .mode = 0644,
David Rientjes2da02992009-01-06 14:39:31 -0800977 .proc_handler = &dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700978 .strategy = &sysctl_intvec,
979 .extra1 = &zero,
980 .extra2 = &one_hundred,
981 },
982 {
David Rientjes2da02992009-01-06 14:39:31 -0800983 .ctl_name = CTL_UNNUMBERED,
984 .procname = "dirty_background_bytes",
985 .data = &dirty_background_bytes,
986 .maxlen = sizeof(dirty_background_bytes),
987 .mode = 0644,
988 .proc_handler = &dirty_background_bytes_handler,
989 .strategy = &sysctl_intvec,
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800990 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -0800991 },
992 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993 .ctl_name = VM_DIRTY_RATIO,
994 .procname = "dirty_ratio",
995 .data = &vm_dirty_ratio,
996 .maxlen = sizeof(vm_dirty_ratio),
997 .mode = 0644,
Peter Zijlstra04fbfdc2007-10-16 23:25:50 -0700998 .proc_handler = &dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700999 .strategy = &sysctl_intvec,
1000 .extra1 = &zero,
1001 .extra2 = &one_hundred,
1002 },
1003 {
David Rientjes2da02992009-01-06 14:39:31 -08001004 .ctl_name = CTL_UNNUMBERED,
1005 .procname = "dirty_bytes",
1006 .data = &vm_dirty_bytes,
1007 .maxlen = sizeof(vm_dirty_bytes),
1008 .mode = 0644,
1009 .proc_handler = &dirty_bytes_handler,
1010 .strategy = &sysctl_intvec,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001011 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001012 },
1013 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001014 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001015 .data = &dirty_writeback_interval,
1016 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001017 .mode = 0644,
1018 .proc_handler = &dirty_writeback_centisecs_handler,
1019 },
1020 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001021 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001022 .data = &dirty_expire_interval,
1023 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001024 .mode = 0644,
Bart Samwelf6ef9432006-03-24 03:15:48 -08001025 .proc_handler = &proc_dointvec_userhz_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026 },
1027 {
1028 .ctl_name = VM_NR_PDFLUSH_THREADS,
1029 .procname = "nr_pdflush_threads",
1030 .data = &nr_pdflush_threads,
1031 .maxlen = sizeof nr_pdflush_threads,
1032 .mode = 0444 /* read-only*/,
1033 .proc_handler = &proc_dointvec,
1034 },
1035 {
1036 .ctl_name = VM_SWAPPINESS,
1037 .procname = "swappiness",
1038 .data = &vm_swappiness,
1039 .maxlen = sizeof(vm_swappiness),
1040 .mode = 0644,
1041 .proc_handler = &proc_dointvec_minmax,
1042 .strategy = &sysctl_intvec,
1043 .extra1 = &zero,
1044 .extra2 = &one_hundred,
1045 },
1046#ifdef CONFIG_HUGETLB_PAGE
1047 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001049 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001050 .maxlen = sizeof(unsigned long),
1051 .mode = 0644,
1052 .proc_handler = &hugetlb_sysctl_handler,
1053 .extra1 = (void *)&hugetlb_zero,
1054 .extra2 = (void *)&hugetlb_infinity,
1055 },
1056 {
1057 .ctl_name = VM_HUGETLB_GROUP,
1058 .procname = "hugetlb_shm_group",
1059 .data = &sysctl_hugetlb_shm_group,
1060 .maxlen = sizeof(gid_t),
1061 .mode = 0644,
1062 .proc_handler = &proc_dointvec,
1063 },
Mel Gorman396faf02007-07-17 04:03:13 -07001064 {
1065 .ctl_name = CTL_UNNUMBERED,
1066 .procname = "hugepages_treat_as_movable",
1067 .data = &hugepages_treat_as_movable,
1068 .maxlen = sizeof(int),
1069 .mode = 0644,
1070 .proc_handler = &hugetlb_treat_movable_handler,
1071 },
Adam Litke54f9f802007-10-16 01:26:20 -07001072 {
1073 .ctl_name = CTL_UNNUMBERED,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001074 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001075 .data = NULL,
1076 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001077 .mode = 0644,
Nishanth Aravamudana3d0c6a2008-02-08 04:18:18 -08001078 .proc_handler = &hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001079 .extra1 = (void *)&hugetlb_zero,
1080 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001081 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082#endif
1083 {
1084 .ctl_name = VM_LOWMEM_RESERVE_RATIO,
1085 .procname = "lowmem_reserve_ratio",
1086 .data = &sysctl_lowmem_reserve_ratio,
1087 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1088 .mode = 0644,
1089 .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
1090 .strategy = &sysctl_intvec,
1091 },
1092 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001093 .ctl_name = VM_DROP_PAGECACHE,
1094 .procname = "drop_caches",
1095 .data = &sysctl_drop_caches,
1096 .maxlen = sizeof(int),
1097 .mode = 0644,
1098 .proc_handler = drop_caches_sysctl_handler,
1099 .strategy = &sysctl_intvec,
1100 },
1101 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102 .ctl_name = VM_MIN_FREE_KBYTES,
1103 .procname = "min_free_kbytes",
1104 .data = &min_free_kbytes,
1105 .maxlen = sizeof(min_free_kbytes),
1106 .mode = 0644,
1107 .proc_handler = &min_free_kbytes_sysctl_handler,
1108 .strategy = &sysctl_intvec,
1109 .extra1 = &zero,
1110 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001111 {
1112 .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
1113 .procname = "percpu_pagelist_fraction",
1114 .data = &percpu_pagelist_fraction,
1115 .maxlen = sizeof(percpu_pagelist_fraction),
1116 .mode = 0644,
1117 .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
1118 .strategy = &sysctl_intvec,
1119 .extra1 = &min_percpu_pagelist_fract,
1120 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121#ifdef CONFIG_MMU
1122 {
1123 .ctl_name = VM_MAX_MAP_COUNT,
1124 .procname = "max_map_count",
1125 .data = &sysctl_max_map_count,
1126 .maxlen = sizeof(sysctl_max_map_count),
1127 .mode = 0644,
1128 .proc_handler = &proc_dointvec
1129 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001130#else
1131 {
1132 .ctl_name = CTL_UNNUMBERED,
1133 .procname = "nr_trim_pages",
1134 .data = &sysctl_nr_trim_pages,
1135 .maxlen = sizeof(sysctl_nr_trim_pages),
1136 .mode = 0644,
1137 .proc_handler = &proc_dointvec_minmax,
1138 .strategy = &sysctl_intvec,
1139 .extra1 = &zero,
1140 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141#endif
1142 {
1143 .ctl_name = VM_LAPTOP_MODE,
1144 .procname = "laptop_mode",
1145 .data = &laptop_mode,
1146 .maxlen = sizeof(laptop_mode),
1147 .mode = 0644,
Bart Samweled5b43f2006-03-24 03:15:49 -08001148 .proc_handler = &proc_dointvec_jiffies,
1149 .strategy = &sysctl_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001150 },
1151 {
1152 .ctl_name = VM_BLOCK_DUMP,
1153 .procname = "block_dump",
1154 .data = &block_dump,
1155 .maxlen = sizeof(block_dump),
1156 .mode = 0644,
1157 .proc_handler = &proc_dointvec,
1158 .strategy = &sysctl_intvec,
1159 .extra1 = &zero,
1160 },
1161 {
1162 .ctl_name = VM_VFS_CACHE_PRESSURE,
1163 .procname = "vfs_cache_pressure",
1164 .data = &sysctl_vfs_cache_pressure,
1165 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1166 .mode = 0644,
1167 .proc_handler = &proc_dointvec,
1168 .strategy = &sysctl_intvec,
1169 .extra1 = &zero,
1170 },
1171#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1172 {
1173 .ctl_name = VM_LEGACY_VA_LAYOUT,
1174 .procname = "legacy_va_layout",
1175 .data = &sysctl_legacy_va_layout,
1176 .maxlen = sizeof(sysctl_legacy_va_layout),
1177 .mode = 0644,
1178 .proc_handler = &proc_dointvec,
1179 .strategy = &sysctl_intvec,
1180 .extra1 = &zero,
1181 },
1182#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001183#ifdef CONFIG_NUMA
1184 {
1185 .ctl_name = VM_ZONE_RECLAIM_MODE,
1186 .procname = "zone_reclaim_mode",
1187 .data = &zone_reclaim_mode,
1188 .maxlen = sizeof(zone_reclaim_mode),
1189 .mode = 0644,
1190 .proc_handler = &proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001191 .strategy = &sysctl_intvec,
1192 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001193 },
Christoph Lameter96146342006-07-03 00:24:13 -07001194 {
1195 .ctl_name = VM_MIN_UNMAPPED,
1196 .procname = "min_unmapped_ratio",
1197 .data = &sysctl_min_unmapped_ratio,
1198 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1199 .mode = 0644,
1200 .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
1201 .strategy = &sysctl_intvec,
1202 .extra1 = &zero,
1203 .extra2 = &one_hundred,
1204 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001205 {
1206 .ctl_name = VM_MIN_SLAB,
1207 .procname = "min_slab_ratio",
1208 .data = &sysctl_min_slab_ratio,
1209 .maxlen = sizeof(sysctl_min_slab_ratio),
1210 .mode = 0644,
1211 .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
1212 .strategy = &sysctl_intvec,
1213 .extra1 = &zero,
1214 .extra2 = &one_hundred,
1215 },
Christoph Lameter17436602006-01-18 17:42:32 -08001216#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001217#ifdef CONFIG_SMP
1218 {
1219 .ctl_name = CTL_UNNUMBERED,
1220 .procname = "stat_interval",
1221 .data = &sysctl_stat_interval,
1222 .maxlen = sizeof(sysctl_stat_interval),
1223 .mode = 0644,
1224 .proc_handler = &proc_dointvec_jiffies,
1225 .strategy = &sysctl_jiffies,
1226 },
1227#endif
Eric Parised032182007-06-28 15:55:21 -04001228#ifdef CONFIG_SECURITY
1229 {
1230 .ctl_name = CTL_UNNUMBERED,
1231 .procname = "mmap_min_addr",
1232 .data = &mmap_min_addr,
1233 .maxlen = sizeof(unsigned long),
1234 .mode = 0644,
1235 .proc_handler = &proc_doulongvec_minmax,
1236 },
Lee Schermerhorn8daec962007-08-10 13:00:51 -07001237#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001238#ifdef CONFIG_NUMA
1239 {
1240 .ctl_name = CTL_UNNUMBERED,
1241 .procname = "numa_zonelist_order",
1242 .data = &numa_zonelist_order,
1243 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1244 .mode = 0644,
1245 .proc_handler = &numa_zonelist_order_handler,
1246 .strategy = &sysctl_string,
1247 },
1248#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001249#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001250 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001251 {
1252 .ctl_name = VM_VDSO_ENABLED,
1253 .procname = "vdso_enabled",
1254 .data = &vdso_enabled,
1255 .maxlen = sizeof(vdso_enabled),
1256 .mode = 0644,
1257 .proc_handler = &proc_dointvec,
1258 .strategy = &sysctl_intvec,
1259 .extra1 = &zero,
1260 },
1261#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001262#ifdef CONFIG_HIGHMEM
1263 {
1264 .ctl_name = CTL_UNNUMBERED,
1265 .procname = "highmem_is_dirtyable",
1266 .data = &vm_highmem_is_dirtyable,
1267 .maxlen = sizeof(vm_highmem_is_dirtyable),
1268 .mode = 0644,
1269 .proc_handler = &proc_dointvec_minmax,
1270 .strategy = &sysctl_intvec,
1271 .extra1 = &zero,
1272 .extra2 = &one,
1273 },
1274#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001275/*
1276 * NOTE: do not add new entries to this table unless you have read
1277 * Documentation/sysctl/ctl_unnumbered.txt
1278 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001279 { .ctl_name = 0 }
1280};
1281
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001282#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001283static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001284 { .ctl_name = 0 }
1285};
1286#endif
1287
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001288static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001289 {
1290 .ctl_name = FS_NRINODE,
1291 .procname = "inode-nr",
1292 .data = &inodes_stat,
1293 .maxlen = 2*sizeof(int),
1294 .mode = 0444,
1295 .proc_handler = &proc_dointvec,
1296 },
1297 {
1298 .ctl_name = FS_STATINODE,
1299 .procname = "inode-state",
1300 .data = &inodes_stat,
1301 .maxlen = 7*sizeof(int),
1302 .mode = 0444,
1303 .proc_handler = &proc_dointvec,
1304 },
1305 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001306 .procname = "file-nr",
1307 .data = &files_stat,
1308 .maxlen = 3*sizeof(int),
1309 .mode = 0444,
Dipankar Sarma529bf6b2006-03-07 21:55:35 -08001310 .proc_handler = &proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311 },
1312 {
1313 .ctl_name = FS_MAXFILE,
1314 .procname = "file-max",
1315 .data = &files_stat.max_files,
1316 .maxlen = sizeof(int),
1317 .mode = 0644,
1318 .proc_handler = &proc_dointvec,
1319 },
1320 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001321 .ctl_name = CTL_UNNUMBERED,
1322 .procname = "nr_open",
1323 .data = &sysctl_nr_open,
1324 .maxlen = sizeof(int),
1325 .mode = 0644,
Al Viroeceea0b2008-05-10 10:08:32 -04001326 .proc_handler = &proc_dointvec_minmax,
1327 .extra1 = &sysctl_nr_open_min,
1328 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001329 },
1330 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001331 .ctl_name = FS_DENTRY,
1332 .procname = "dentry-state",
1333 .data = &dentry_stat,
1334 .maxlen = 6*sizeof(int),
1335 .mode = 0444,
1336 .proc_handler = &proc_dointvec,
1337 },
1338 {
1339 .ctl_name = FS_OVERFLOWUID,
1340 .procname = "overflowuid",
1341 .data = &fs_overflowuid,
1342 .maxlen = sizeof(int),
1343 .mode = 0644,
1344 .proc_handler = &proc_dointvec_minmax,
1345 .strategy = &sysctl_intvec,
1346 .extra1 = &minolduid,
1347 .extra2 = &maxolduid,
1348 },
1349 {
1350 .ctl_name = FS_OVERFLOWGID,
1351 .procname = "overflowgid",
1352 .data = &fs_overflowgid,
1353 .maxlen = sizeof(int),
1354 .mode = 0644,
1355 .proc_handler = &proc_dointvec_minmax,
1356 .strategy = &sysctl_intvec,
1357 .extra1 = &minolduid,
1358 .extra2 = &maxolduid,
1359 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001360#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001361 {
1362 .ctl_name = FS_LEASES,
1363 .procname = "leases-enable",
1364 .data = &leases_enable,
1365 .maxlen = sizeof(int),
1366 .mode = 0644,
1367 .proc_handler = &proc_dointvec,
1368 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001369#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001370#ifdef CONFIG_DNOTIFY
1371 {
1372 .ctl_name = FS_DIR_NOTIFY,
1373 .procname = "dir-notify-enable",
1374 .data = &dir_notify_enable,
1375 .maxlen = sizeof(int),
1376 .mode = 0644,
1377 .proc_handler = &proc_dointvec,
1378 },
1379#endif
1380#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001381#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001382 {
1383 .ctl_name = FS_LEASE_TIME,
1384 .procname = "lease-break-time",
1385 .data = &lease_break_time,
1386 .maxlen = sizeof(int),
1387 .mode = 0644,
Kawai, Hidehiro76fdbb22007-07-19 01:48:26 -07001388 .proc_handler = &proc_dointvec_minmax,
1389 .strategy = &sysctl_intvec,
1390 .extra1 = &zero,
1391 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001393#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001394#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001395 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001396 .procname = "aio-nr",
1397 .data = &aio_nr,
1398 .maxlen = sizeof(aio_nr),
1399 .mode = 0444,
Zach Brownd55b5fd2005-11-07 00:59:31 -08001400 .proc_handler = &proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401 },
1402 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001403 .procname = "aio-max-nr",
1404 .data = &aio_max_nr,
1405 .maxlen = sizeof(aio_max_nr),
1406 .mode = 0644,
Zach Brownd55b5fd2005-11-07 00:59:31 -08001407 .proc_handler = &proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001409#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001410#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001411 {
1412 .ctl_name = FS_INOTIFY,
1413 .procname = "inotify",
1414 .mode = 0555,
1415 .child = inotify_table,
1416 },
1417#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001418#ifdef CONFIG_EPOLL
1419 {
1420 .procname = "epoll",
1421 .mode = 0555,
1422 .child = epoll_table,
1423 },
1424#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001425#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001426 {
1427 .ctl_name = KERN_SETUID_DUMPABLE,
1428 .procname = "suid_dumpable",
1429 .data = &suid_dumpable,
1430 .maxlen = sizeof(int),
1431 .mode = 0644,
1432 .proc_handler = &proc_dointvec,
1433 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001434#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1435 {
1436 .ctl_name = CTL_UNNUMBERED,
1437 .procname = "binfmt_misc",
1438 .mode = 0555,
1439 .child = binfmt_misc_table,
1440 },
1441#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001442/*
1443 * NOTE: do not add new entries to this table unless you have read
1444 * Documentation/sysctl/ctl_unnumbered.txt
1445 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001446 { .ctl_name = 0 }
1447};
1448
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001449static struct ctl_table debug_table[] = {
Olof Johanssond0c3d532007-10-12 10:20:07 +10001450#if defined(CONFIG_X86) || defined(CONFIG_PPC)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001451 {
1452 .ctl_name = CTL_UNNUMBERED,
1453 .procname = "exception-trace",
1454 .data = &show_unhandled_signals,
1455 .maxlen = sizeof(int),
1456 .mode = 0644,
1457 .proc_handler = proc_dointvec
1458 },
1459#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001460 { .ctl_name = 0 }
1461};
1462
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001463static struct ctl_table dev_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 { .ctl_name = 0 }
Robert Love0eeca282005-07-12 17:06:03 -04001465};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001466
Al Viro330d57f2005-11-04 10:18:40 +00001467static DEFINE_SPINLOCK(sysctl_lock);
1468
1469/* called under sysctl_lock */
1470static int use_table(struct ctl_table_header *p)
1471{
1472 if (unlikely(p->unregistering))
1473 return 0;
1474 p->used++;
1475 return 1;
1476}
1477
1478/* called under sysctl_lock */
1479static void unuse_table(struct ctl_table_header *p)
1480{
1481 if (!--p->used)
1482 if (unlikely(p->unregistering))
1483 complete(p->unregistering);
1484}
1485
1486/* called under sysctl_lock, will reacquire if has to wait */
1487static void start_unregistering(struct ctl_table_header *p)
1488{
1489 /*
1490 * if p->used is 0, nobody will ever touch that entry again;
1491 * we'll eliminate all paths to it before dropping sysctl_lock
1492 */
1493 if (unlikely(p->used)) {
1494 struct completion wait;
1495 init_completion(&wait);
1496 p->unregistering = &wait;
1497 spin_unlock(&sysctl_lock);
1498 wait_for_completion(&wait);
1499 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001500 } else {
1501 /* anything non-NULL; we'll never dereference it */
1502 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001503 }
1504 /*
1505 * do not remove from the list until nobody holds it; walking the
1506 * list in do_sysctl() relies on that.
1507 */
1508 list_del_init(&p->ctl_entry);
1509}
1510
Al Virof7e6ced2008-07-15 01:44:23 -04001511void sysctl_head_get(struct ctl_table_header *head)
1512{
1513 spin_lock(&sysctl_lock);
1514 head->count++;
1515 spin_unlock(&sysctl_lock);
1516}
1517
1518void sysctl_head_put(struct ctl_table_header *head)
1519{
1520 spin_lock(&sysctl_lock);
1521 if (!--head->count)
1522 kfree(head);
1523 spin_unlock(&sysctl_lock);
1524}
1525
1526struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1527{
1528 if (!head)
1529 BUG();
1530 spin_lock(&sysctl_lock);
1531 if (!use_table(head))
1532 head = ERR_PTR(-ENOENT);
1533 spin_unlock(&sysctl_lock);
1534 return head;
1535}
1536
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001537void sysctl_head_finish(struct ctl_table_header *head)
1538{
1539 if (!head)
1540 return;
1541 spin_lock(&sysctl_lock);
1542 unuse_table(head);
1543 spin_unlock(&sysctl_lock);
1544}
1545
Al Viro73455092008-07-14 21:22:20 -04001546static struct ctl_table_set *
1547lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1548{
1549 struct ctl_table_set *set = &root->default_set;
1550 if (root->lookup)
1551 set = root->lookup(root, namespaces);
1552 return set;
1553}
1554
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001555static struct list_head *
1556lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001557{
Al Viro73455092008-07-14 21:22:20 -04001558 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1559 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001560}
1561
1562struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1563 struct ctl_table_header *prev)
1564{
1565 struct ctl_table_root *root;
1566 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001567 struct ctl_table_header *head;
1568 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001569
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001570 spin_lock(&sysctl_lock);
1571 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001572 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001573 tmp = &prev->ctl_entry;
1574 unuse_table(prev);
1575 goto next;
1576 }
1577 tmp = &root_table_header.ctl_entry;
1578 for (;;) {
1579 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1580
1581 if (!use_table(head))
1582 goto next;
1583 spin_unlock(&sysctl_lock);
1584 return head;
1585 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001586 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001587 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001588 header_list = lookup_header_list(root, namespaces);
1589 if (tmp != header_list)
1590 continue;
1591
1592 do {
1593 root = list_entry(root->root_list.next,
1594 struct ctl_table_root, root_list);
1595 if (root == &sysctl_table_root)
1596 goto out;
1597 header_list = lookup_header_list(root, namespaces);
1598 } while (list_empty(header_list));
1599 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001600 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001601out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001602 spin_unlock(&sysctl_lock);
1603 return NULL;
1604}
1605
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001606struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1607{
1608 return __sysctl_head_next(current->nsproxy, prev);
1609}
1610
1611void register_sysctl_root(struct ctl_table_root *root)
1612{
1613 spin_lock(&sysctl_lock);
1614 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1615 spin_unlock(&sysctl_lock);
1616}
1617
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001618#ifdef CONFIG_SYSCTL_SYSCALL
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001619/* Perform the actual read/write of a sysctl table entry. */
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001620static int do_sysctl_strategy(struct ctl_table_root *root,
1621 struct ctl_table *table,
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001622 void __user *oldval, size_t __user *oldlenp,
1623 void __user *newval, size_t newlen)
1624{
1625 int op = 0, rc;
1626
1627 if (oldval)
Al Viroe6305c42008-07-15 21:03:57 -04001628 op |= MAY_READ;
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001629 if (newval)
Al Viroe6305c42008-07-15 21:03:57 -04001630 op |= MAY_WRITE;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001631 if (sysctl_perm(root, table, op))
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001632 return -EPERM;
1633
1634 if (table->strategy) {
Alexey Dobriyanf221e722008-10-15 22:04:23 -07001635 rc = table->strategy(table, oldval, oldlenp, newval, newlen);
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001636 if (rc < 0)
1637 return rc;
1638 if (rc > 0)
1639 return 0;
1640 }
1641
1642 /* If there is no strategy routine, or if the strategy returns
1643 * zero, proceed with automatic r/w */
1644 if (table->data && table->maxlen) {
Alexey Dobriyanf221e722008-10-15 22:04:23 -07001645 rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001646 if (rc < 0)
1647 return rc;
1648 }
1649 return 0;
1650}
1651
1652static int parse_table(int __user *name, int nlen,
1653 void __user *oldval, size_t __user *oldlenp,
1654 void __user *newval, size_t newlen,
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001655 struct ctl_table_root *root,
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001656 struct ctl_table *table)
1657{
1658 int n;
1659repeat:
1660 if (!nlen)
1661 return -ENOTDIR;
1662 if (get_user(n, name))
1663 return -EFAULT;
1664 for ( ; table->ctl_name || table->procname; table++) {
1665 if (!table->ctl_name)
1666 continue;
1667 if (n == table->ctl_name) {
1668 int error;
1669 if (table->child) {
Al Viroe6305c42008-07-15 21:03:57 -04001670 if (sysctl_perm(root, table, MAY_EXEC))
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001671 return -EPERM;
1672 name++;
1673 nlen--;
1674 table = table->child;
1675 goto repeat;
1676 }
Alexey Dobriyanf221e722008-10-15 22:04:23 -07001677 error = do_sysctl_strategy(root, table,
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001678 oldval, oldlenp,
1679 newval, newlen);
1680 return error;
1681 }
1682 }
1683 return -ENOTDIR;
1684}
1685
Linus Torvalds1da177e2005-04-16 15:20:36 -07001686int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1687 void __user *newval, size_t newlen)
1688{
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001689 struct ctl_table_header *head;
Al Viro330d57f2005-11-04 10:18:40 +00001690 int error = -ENOTDIR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001691
1692 if (nlen <= 0 || nlen >= CTL_MAXNAME)
1693 return -ENOTDIR;
1694 if (oldval) {
1695 int old_len;
1696 if (!oldlenp || get_user(old_len, oldlenp))
1697 return -EFAULT;
1698 }
Al Viro330d57f2005-11-04 10:18:40 +00001699
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001700 for (head = sysctl_head_next(NULL); head;
1701 head = sysctl_head_next(head)) {
Al Viro330d57f2005-11-04 10:18:40 +00001702 error = parse_table(name, nlen, oldval, oldlenp,
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001703 newval, newlen,
1704 head->root, head->ctl_table);
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001705 if (error != -ENOTDIR) {
1706 sysctl_head_finish(head);
Al Viro330d57f2005-11-04 10:18:40 +00001707 break;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001708 }
1709 }
Al Viro330d57f2005-11-04 10:18:40 +00001710 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001711}
1712
Heiko Carstens1e7bfb22009-01-14 14:14:29 +01001713SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001714{
1715 struct __sysctl_args tmp;
1716 int error;
1717
1718 if (copy_from_user(&tmp, args, sizeof(tmp)))
1719 return -EFAULT;
1720
Eric W. Biederman7058cb02007-10-18 03:05:58 -07001721 error = deprecated_sysctl_warning(&tmp);
1722 if (error)
1723 goto out;
1724
Linus Torvalds1da177e2005-04-16 15:20:36 -07001725 lock_kernel();
1726 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1727 tmp.newval, tmp.newlen);
1728 unlock_kernel();
Eric W. Biederman7058cb02007-10-18 03:05:58 -07001729out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001730 return error;
1731}
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001732#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001733
1734/*
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001735 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736 * some sysctl variables are readonly even to root.
1737 */
1738
1739static int test_perm(int mode, int op)
1740{
David Howells76aac0e2008-11-14 10:39:12 +11001741 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001742 mode >>= 6;
1743 else if (in_egroup_p(0))
1744 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001745 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001746 return 0;
1747 return -EACCES;
1748}
1749
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001750int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001751{
1752 int error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001753 int mode;
1754
Al Viroe6305c42008-07-15 21:03:57 -04001755 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001756 if (error)
1757 return error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001758
1759 if (root->permissions)
1760 mode = root->permissions(root, current->nsproxy, table);
1761 else
1762 mode = table->mode;
1763
1764 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001765}
1766
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001767static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1768{
1769 for (; table->ctl_name || table->procname; table++) {
1770 table->parent = parent;
1771 if (table->child)
1772 sysctl_set_parent(table, table->child);
1773 }
1774}
1775
1776static __init int sysctl_init(void)
1777{
1778 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001779#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1780 {
1781 int err;
1782 err = sysctl_check_table(current->nsproxy, root_table);
1783 }
1784#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001785 return 0;
1786}
1787
1788core_initcall(sysctl_init);
1789
Al Virobfbcf032008-07-27 06:31:22 +01001790static struct ctl_table *is_branch_in(struct ctl_table *branch,
1791 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001792{
1793 struct ctl_table *p;
1794 const char *s = branch->procname;
1795
1796 /* branch should have named subdirectory as its first element */
1797 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001798 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001799
1800 /* ... and nothing else */
1801 if (branch[1].procname || branch[1].ctl_name)
Al Virobfbcf032008-07-27 06:31:22 +01001802 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001803
1804 /* table should contain subdirectory with the same name */
1805 for (p = table; p->procname || p->ctl_name; p++) {
1806 if (!p->child)
1807 continue;
1808 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001809 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001810 }
Al Virobfbcf032008-07-27 06:31:22 +01001811 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001812}
1813
1814/* see if attaching q to p would be an improvement */
1815static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1816{
1817 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001818 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001819 int is_better = 0;
1820 int not_in_parent = !p->attached_by;
1821
Al Virobfbcf032008-07-27 06:31:22 +01001822 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001823 if (by == q->attached_by)
1824 is_better = 1;
1825 if (to == p->attached_by)
1826 not_in_parent = 1;
1827 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001828 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001829 }
1830
1831 if (is_better && not_in_parent) {
1832 q->attached_by = by;
1833 q->attached_to = to;
1834 q->parent = p;
1835 }
1836}
1837
Linus Torvalds1da177e2005-04-16 15:20:36 -07001838/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001839 * __register_sysctl_paths - register a sysctl hierarchy
1840 * @root: List of sysctl headers to register on
1841 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001842 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001843 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001844 *
1845 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001846 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001847 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001848 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001849 *
1850 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1851 * must be unique within that level of sysctl
1852 *
1853 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1854 * enter a sysctl file
1855 *
1856 * data - a pointer to data for use by proc_handler
1857 *
1858 * maxlen - the maximum size in bytes of the data
1859 *
1860 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1861 *
1862 * child - a pointer to the child sysctl table if this entry is a directory, or
1863 * %NULL.
1864 *
1865 * proc_handler - the text handler routine (described below)
1866 *
1867 * strategy - the strategy routine (described below)
1868 *
1869 * de - for internal use by the sysctl routines
1870 *
1871 * extra1, extra2 - extra pointers usable by the proc handler routines
1872 *
1873 * Leaf nodes in the sysctl tree will be represented by a single file
1874 * under /proc; non-leaf nodes will be represented by directories.
1875 *
1876 * sysctl(2) can automatically manage read and write requests through
1877 * the sysctl table. The data and maxlen fields of the ctl_table
1878 * struct enable minimal validation of the values being written to be
1879 * performed, and the mode field allows minimal authentication.
1880 *
1881 * More sophisticated management can be enabled by the provision of a
1882 * strategy routine with the table entry. This will be called before
1883 * any automatic read or write of the data is performed.
1884 *
1885 * The strategy routine may return
1886 *
1887 * < 0 - Error occurred (error is passed to user process)
1888 *
1889 * 0 - OK - proceed with automatic read or write.
1890 *
1891 * > 0 - OK - read or write has been done by the strategy routine, so
1892 * return immediately.
1893 *
1894 * There must be a proc_handler routine for any terminal nodes
1895 * mirrored under /proc/sys (non-terminals are handled by a built-in
1896 * directory handler). Several default handlers are available to
1897 * cover common cases -
1898 *
1899 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1900 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1901 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1902 *
1903 * It is the handler's job to read the input buffer from user memory
1904 * and process it. The handler should return 0 on success.
1905 *
1906 * This routine returns %NULL on a failure to register, and a pointer
1907 * to the table header on success.
1908 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001909struct ctl_table_header *__register_sysctl_paths(
1910 struct ctl_table_root *root,
1911 struct nsproxy *namespaces,
1912 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001913{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001914 struct ctl_table_header *header;
1915 struct ctl_table *new, **prevp;
1916 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001917 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001918
1919 /* Count the path components */
1920 for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
1921 ;
1922
1923 /*
1924 * For each path component, allocate a 2-element ctl_table array.
1925 * The first array element will be filled with the sysctl entry
1926 * for this, the second will be the sentinel (ctl_name == 0).
1927 *
1928 * We allocate everything in one go so that we don't have to
1929 * worry about freeing additional memory in unregister_sysctl_table.
1930 */
1931 header = kzalloc(sizeof(struct ctl_table_header) +
1932 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1933 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001934 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001935
1936 new = (struct ctl_table *) (header + 1);
1937
1938 /* Now connect the dots */
1939 prevp = &header->ctl_table;
1940 for (n = 0; n < npath; ++n, ++path) {
1941 /* Copy the procname */
1942 new->procname = path->procname;
1943 new->ctl_name = path->ctl_name;
1944 new->mode = 0555;
1945
1946 *prevp = new;
1947 prevp = &new->child;
1948
1949 new += 2;
1950 }
1951 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001952 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001953
1954 INIT_LIST_HEAD(&header->ctl_entry);
1955 header->used = 0;
1956 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001957 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001958 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001959 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001960#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001961 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001962 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001963 return NULL;
1964 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001965#endif
Al Viro330d57f2005-11-04 10:18:40 +00001966 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001967 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001968 header->attached_by = header->ctl_table;
1969 header->attached_to = root_table;
1970 header->parent = &root_table_header;
1971 for (set = header->set; set; set = set->parent) {
1972 struct ctl_table_header *p;
1973 list_for_each_entry(p, &set->list, ctl_entry) {
1974 if (p->unregistering)
1975 continue;
1976 try_attach(p, header);
1977 }
1978 }
1979 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001980 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001981 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001982
1983 return header;
1984}
1985
1986/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001987 * register_sysctl_table_path - register a sysctl table hierarchy
1988 * @path: The path to the directory the sysctl table is in.
1989 * @table: the top-level table structure
1990 *
1991 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1992 * array. A completely 0 filled entry terminates the table.
1993 *
1994 * See __register_sysctl_paths for more details.
1995 */
1996struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1997 struct ctl_table *table)
1998{
1999 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
2000 path, table);
2001}
2002
2003/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002004 * register_sysctl_table - register a sysctl table hierarchy
2005 * @table: the top-level table structure
2006 *
2007 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2008 * array. A completely 0 filled entry terminates the table.
2009 *
2010 * See register_sysctl_paths for more details.
2011 */
2012struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
2013{
2014 static const struct ctl_path null_path[] = { {} };
2015
2016 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002017}
2018
2019/**
2020 * unregister_sysctl_table - unregister a sysctl table hierarchy
2021 * @header: the header returned from register_sysctl_table
2022 *
2023 * Unregisters the sysctl table and all children. proc entries may not
2024 * actually be removed until they are no longer used by anyone.
2025 */
2026void unregister_sysctl_table(struct ctl_table_header * header)
2027{
Al Viro330d57f2005-11-04 10:18:40 +00002028 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08002029
2030 if (header == NULL)
2031 return;
2032
Al Viro330d57f2005-11-04 10:18:40 +00002033 spin_lock(&sysctl_lock);
2034 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04002035 if (!--header->parent->count) {
2036 WARN_ON(1);
2037 kfree(header->parent);
2038 }
Al Virof7e6ced2008-07-15 01:44:23 -04002039 if (!--header->count)
2040 kfree(header);
Al Viro330d57f2005-11-04 10:18:40 +00002041 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002042}
2043
Al Viro9043476f2008-07-15 08:54:06 -04002044int sysctl_is_seen(struct ctl_table_header *p)
2045{
2046 struct ctl_table_set *set = p->set;
2047 int res;
2048 spin_lock(&sysctl_lock);
2049 if (p->unregistering)
2050 res = 0;
2051 else if (!set->is_seen)
2052 res = 1;
2053 else
2054 res = set->is_seen(set);
2055 spin_unlock(&sysctl_lock);
2056 return res;
2057}
2058
Al Viro73455092008-07-14 21:22:20 -04002059void setup_sysctl_set(struct ctl_table_set *p,
2060 struct ctl_table_set *parent,
2061 int (*is_seen)(struct ctl_table_set *))
2062{
2063 INIT_LIST_HEAD(&p->list);
2064 p->parent = parent ? parent : &sysctl_table_root.default_set;
2065 p->is_seen = is_seen;
2066}
2067
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002068#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002069struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002070{
2071 return NULL;
2072}
2073
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002074struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2075 struct ctl_table *table)
2076{
2077 return NULL;
2078}
2079
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002080void unregister_sysctl_table(struct ctl_table_header * table)
2081{
2082}
2083
Al Viro73455092008-07-14 21:22:20 -04002084void setup_sysctl_set(struct ctl_table_set *p,
2085 struct ctl_table_set *parent,
2086 int (*is_seen)(struct ctl_table_set *))
2087{
2088}
2089
Al Virof7e6ced2008-07-15 01:44:23 -04002090void sysctl_head_put(struct ctl_table_header *head)
2091{
2092}
2093
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002094#endif /* CONFIG_SYSCTL */
2095
Linus Torvalds1da177e2005-04-16 15:20:36 -07002096/*
2097 * /proc/sys support
2098 */
2099
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002100#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002101
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002102static int _proc_do_string(void* data, int maxlen, int write,
2103 struct file *filp, void __user *buffer,
2104 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002105{
2106 size_t len;
2107 char __user *p;
2108 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002109
2110 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002111 *lenp = 0;
2112 return 0;
2113 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002114
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002115 if (write) {
2116 len = 0;
2117 p = buffer;
2118 while (len < *lenp) {
2119 if (get_user(c, p++))
2120 return -EFAULT;
2121 if (c == 0 || c == '\n')
2122 break;
2123 len++;
2124 }
2125 if (len >= maxlen)
2126 len = maxlen-1;
2127 if(copy_from_user(data, buffer, len))
2128 return -EFAULT;
2129 ((char *) data)[len] = 0;
2130 *ppos += *lenp;
2131 } else {
2132 len = strlen(data);
2133 if (len > maxlen)
2134 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002135
2136 if (*ppos > len) {
2137 *lenp = 0;
2138 return 0;
2139 }
2140
2141 data += *ppos;
2142 len -= *ppos;
2143
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002144 if (len > *lenp)
2145 len = *lenp;
2146 if (len)
2147 if(copy_to_user(buffer, data, len))
2148 return -EFAULT;
2149 if (len < *lenp) {
2150 if(put_user('\n', ((char __user *) buffer) + len))
2151 return -EFAULT;
2152 len++;
2153 }
2154 *lenp = len;
2155 *ppos += len;
2156 }
2157 return 0;
2158}
2159
Linus Torvalds1da177e2005-04-16 15:20:36 -07002160/**
2161 * proc_dostring - read a string sysctl
2162 * @table: the sysctl table
2163 * @write: %TRUE if this is a write to the sysctl file
2164 * @filp: the file structure
2165 * @buffer: the user buffer
2166 * @lenp: the size of the user buffer
2167 * @ppos: file position
2168 *
2169 * Reads/writes a string from/to the user buffer. If the kernel
2170 * buffer provided is not large enough to hold the string, the
2171 * string is truncated. The copied string is %NULL-terminated.
2172 * If the string is being read by the user process, it is copied
2173 * and a newline '\n' is added. It is truncated if the buffer is
2174 * not large enough.
2175 *
2176 * Returns 0 on success.
2177 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002178int proc_dostring(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002179 void __user *buffer, size_t *lenp, loff_t *ppos)
2180{
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002181 return _proc_do_string(table->data, table->maxlen, write, filp,
2182 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002183}
2184
Linus Torvalds1da177e2005-04-16 15:20:36 -07002185
2186static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2187 int *valp,
2188 int write, void *data)
2189{
2190 if (write) {
2191 *valp = *negp ? -*lvalp : *lvalp;
2192 } else {
2193 int val = *valp;
2194 if (val < 0) {
2195 *negp = -1;
2196 *lvalp = (unsigned long)-val;
2197 } else {
2198 *negp = 0;
2199 *lvalp = (unsigned long)val;
2200 }
2201 }
2202 return 0;
2203}
2204
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002205static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002206 int write, struct file *filp, void __user *buffer,
2207 size_t *lenp, loff_t *ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002208 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2209 int write, void *data),
2210 void *data)
2211{
2212#define TMPBUFLEN 21
2213 int *i, vleft, first=1, neg, val;
2214 unsigned long lval;
2215 size_t left, len;
2216
2217 char buf[TMPBUFLEN], *p;
2218 char __user *s = buffer;
2219
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002220 if (!tbl_data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221 (*ppos && !write)) {
2222 *lenp = 0;
2223 return 0;
2224 }
2225
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002226 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002227 vleft = table->maxlen / sizeof(*i);
2228 left = *lenp;
2229
2230 if (!conv)
2231 conv = do_proc_dointvec_conv;
2232
2233 for (; left && vleft--; i++, first=0) {
2234 if (write) {
2235 while (left) {
2236 char c;
2237 if (get_user(c, s))
2238 return -EFAULT;
2239 if (!isspace(c))
2240 break;
2241 left--;
2242 s++;
2243 }
2244 if (!left)
2245 break;
2246 neg = 0;
2247 len = left;
2248 if (len > sizeof(buf) - 1)
2249 len = sizeof(buf) - 1;
2250 if (copy_from_user(buf, s, len))
2251 return -EFAULT;
2252 buf[len] = 0;
2253 p = buf;
2254 if (*p == '-' && left > 1) {
2255 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002256 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002257 }
2258 if (*p < '0' || *p > '9')
2259 break;
2260
2261 lval = simple_strtoul(p, &p, 0);
2262
2263 len = p-buf;
2264 if ((len < left) && *p && !isspace(*p))
2265 break;
2266 if (neg)
2267 val = -val;
2268 s += len;
2269 left -= len;
2270
2271 if (conv(&neg, &lval, i, 1, data))
2272 break;
2273 } else {
2274 p = buf;
2275 if (!first)
2276 *p++ = '\t';
2277
2278 if (conv(&neg, &lval, i, 0, data))
2279 break;
2280
2281 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2282 len = strlen(buf);
2283 if (len > left)
2284 len = left;
2285 if(copy_to_user(s, buf, len))
2286 return -EFAULT;
2287 left -= len;
2288 s += len;
2289 }
2290 }
2291
2292 if (!write && !first && left) {
2293 if(put_user('\n', s))
2294 return -EFAULT;
2295 left--, s++;
2296 }
2297 if (write) {
2298 while (left) {
2299 char c;
2300 if (get_user(c, s++))
2301 return -EFAULT;
2302 if (!isspace(c))
2303 break;
2304 left--;
2305 }
2306 }
2307 if (write && first)
2308 return -EINVAL;
2309 *lenp -= left;
2310 *ppos += *lenp;
2311 return 0;
2312#undef TMPBUFLEN
2313}
2314
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002315static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002316 void __user *buffer, size_t *lenp, loff_t *ppos,
2317 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2318 int write, void *data),
2319 void *data)
2320{
2321 return __do_proc_dointvec(table->data, table, write, filp,
2322 buffer, lenp, ppos, conv, data);
2323}
2324
Linus Torvalds1da177e2005-04-16 15:20:36 -07002325/**
2326 * proc_dointvec - read a vector of integers
2327 * @table: the sysctl table
2328 * @write: %TRUE if this is a write to the sysctl file
2329 * @filp: the file structure
2330 * @buffer: the user buffer
2331 * @lenp: the size of the user buffer
2332 * @ppos: file position
2333 *
2334 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2335 * values from/to the user buffer, treated as an ASCII string.
2336 *
2337 * Returns 0 on success.
2338 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002339int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002340 void __user *buffer, size_t *lenp, loff_t *ppos)
2341{
2342 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2343 NULL,NULL);
2344}
2345
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002346/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002347 * Taint values can only be increased
2348 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002349 */
Andi Kleen25ddbb12008-10-15 22:01:41 -07002350static int proc_taint(struct ctl_table *table, int write, struct file *filp,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002351 void __user *buffer, size_t *lenp, loff_t *ppos)
2352{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002353 struct ctl_table t;
2354 unsigned long tmptaint = get_taint();
2355 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002356
Bastian Blank91fcd412007-04-23 14:41:14 -07002357 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002358 return -EPERM;
2359
Andi Kleen25ddbb12008-10-15 22:01:41 -07002360 t = *table;
2361 t.data = &tmptaint;
2362 err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos);
2363 if (err < 0)
2364 return err;
2365
2366 if (write) {
2367 /*
2368 * Poor man's atomic or. Not worth adding a primitive
2369 * to everyone's atomic.h for this
2370 */
2371 int i;
2372 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2373 if ((tmptaint >> i) & 1)
2374 add_taint(i);
2375 }
2376 }
2377
2378 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002379}
2380
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381struct do_proc_dointvec_minmax_conv_param {
2382 int *min;
2383 int *max;
2384};
2385
2386static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2387 int *valp,
2388 int write, void *data)
2389{
2390 struct do_proc_dointvec_minmax_conv_param *param = data;
2391 if (write) {
2392 int val = *negp ? -*lvalp : *lvalp;
2393 if ((param->min && *param->min > val) ||
2394 (param->max && *param->max < val))
2395 return -EINVAL;
2396 *valp = val;
2397 } else {
2398 int val = *valp;
2399 if (val < 0) {
2400 *negp = -1;
2401 *lvalp = (unsigned long)-val;
2402 } else {
2403 *negp = 0;
2404 *lvalp = (unsigned long)val;
2405 }
2406 }
2407 return 0;
2408}
2409
2410/**
2411 * proc_dointvec_minmax - read a vector of integers with min/max values
2412 * @table: the sysctl table
2413 * @write: %TRUE if this is a write to the sysctl file
2414 * @filp: the file structure
2415 * @buffer: the user buffer
2416 * @lenp: the size of the user buffer
2417 * @ppos: file position
2418 *
2419 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2420 * values from/to the user buffer, treated as an ASCII string.
2421 *
2422 * This routine will ensure the values are within the range specified by
2423 * table->extra1 (min) and table->extra2 (max).
2424 *
2425 * Returns 0 on success.
2426 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002427int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002428 void __user *buffer, size_t *lenp, loff_t *ppos)
2429{
2430 struct do_proc_dointvec_minmax_conv_param param = {
2431 .min = (int *) table->extra1,
2432 .max = (int *) table->extra2,
2433 };
2434 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2435 do_proc_dointvec_minmax_conv, &param);
2436}
2437
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002438static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 struct file *filp,
2440 void __user *buffer,
2441 size_t *lenp, loff_t *ppos,
2442 unsigned long convmul,
2443 unsigned long convdiv)
2444{
2445#define TMPBUFLEN 21
2446 unsigned long *i, *min, *max, val;
2447 int vleft, first=1, neg;
2448 size_t len, left;
2449 char buf[TMPBUFLEN], *p;
2450 char __user *s = buffer;
2451
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002452 if (!data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453 (*ppos && !write)) {
2454 *lenp = 0;
2455 return 0;
2456 }
2457
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002458 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002459 min = (unsigned long *) table->extra1;
2460 max = (unsigned long *) table->extra2;
2461 vleft = table->maxlen / sizeof(unsigned long);
2462 left = *lenp;
2463
2464 for (; left && vleft--; i++, min++, max++, first=0) {
2465 if (write) {
2466 while (left) {
2467 char c;
2468 if (get_user(c, s))
2469 return -EFAULT;
2470 if (!isspace(c))
2471 break;
2472 left--;
2473 s++;
2474 }
2475 if (!left)
2476 break;
2477 neg = 0;
2478 len = left;
2479 if (len > TMPBUFLEN-1)
2480 len = TMPBUFLEN-1;
2481 if (copy_from_user(buf, s, len))
2482 return -EFAULT;
2483 buf[len] = 0;
2484 p = buf;
2485 if (*p == '-' && left > 1) {
2486 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002487 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002488 }
2489 if (*p < '0' || *p > '9')
2490 break;
2491 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2492 len = p-buf;
2493 if ((len < left) && *p && !isspace(*p))
2494 break;
2495 if (neg)
2496 val = -val;
2497 s += len;
2498 left -= len;
2499
2500 if(neg)
2501 continue;
2502 if ((min && val < *min) || (max && val > *max))
2503 continue;
2504 *i = val;
2505 } else {
2506 p = buf;
2507 if (!first)
2508 *p++ = '\t';
2509 sprintf(p, "%lu", convdiv * (*i) / convmul);
2510 len = strlen(buf);
2511 if (len > left)
2512 len = left;
2513 if(copy_to_user(s, buf, len))
2514 return -EFAULT;
2515 left -= len;
2516 s += len;
2517 }
2518 }
2519
2520 if (!write && !first && left) {
2521 if(put_user('\n', s))
2522 return -EFAULT;
2523 left--, s++;
2524 }
2525 if (write) {
2526 while (left) {
2527 char c;
2528 if (get_user(c, s++))
2529 return -EFAULT;
2530 if (!isspace(c))
2531 break;
2532 left--;
2533 }
2534 }
2535 if (write && first)
2536 return -EINVAL;
2537 *lenp -= left;
2538 *ppos += *lenp;
2539 return 0;
2540#undef TMPBUFLEN
2541}
2542
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002543static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002544 struct file *filp,
2545 void __user *buffer,
2546 size_t *lenp, loff_t *ppos,
2547 unsigned long convmul,
2548 unsigned long convdiv)
2549{
2550 return __do_proc_doulongvec_minmax(table->data, table, write,
2551 filp, buffer, lenp, ppos, convmul, convdiv);
2552}
2553
Linus Torvalds1da177e2005-04-16 15:20:36 -07002554/**
2555 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2556 * @table: the sysctl table
2557 * @write: %TRUE if this is a write to the sysctl file
2558 * @filp: the file structure
2559 * @buffer: the user buffer
2560 * @lenp: the size of the user buffer
2561 * @ppos: file position
2562 *
2563 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2564 * values from/to the user buffer, treated as an ASCII string.
2565 *
2566 * This routine will ensure the values are within the range specified by
2567 * table->extra1 (min) and table->extra2 (max).
2568 *
2569 * Returns 0 on success.
2570 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002571int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002572 void __user *buffer, size_t *lenp, loff_t *ppos)
2573{
2574 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
2575}
2576
2577/**
2578 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2579 * @table: the sysctl table
2580 * @write: %TRUE if this is a write to the sysctl file
2581 * @filp: the file structure
2582 * @buffer: the user buffer
2583 * @lenp: the size of the user buffer
2584 * @ppos: file position
2585 *
2586 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2587 * values from/to the user buffer, treated as an ASCII string. The values
2588 * are treated as milliseconds, and converted to jiffies when they are stored.
2589 *
2590 * This routine will ensure the values are within the range specified by
2591 * table->extra1 (min) and table->extra2 (max).
2592 *
2593 * Returns 0 on success.
2594 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002595int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002596 struct file *filp,
2597 void __user *buffer,
2598 size_t *lenp, loff_t *ppos)
2599{
2600 return do_proc_doulongvec_minmax(table, write, filp, buffer,
2601 lenp, ppos, HZ, 1000l);
2602}
2603
2604
2605static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2606 int *valp,
2607 int write, void *data)
2608{
2609 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002610 if (*lvalp > LONG_MAX / HZ)
2611 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002612 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2613 } else {
2614 int val = *valp;
2615 unsigned long lval;
2616 if (val < 0) {
2617 *negp = -1;
2618 lval = (unsigned long)-val;
2619 } else {
2620 *negp = 0;
2621 lval = (unsigned long)val;
2622 }
2623 *lvalp = lval / HZ;
2624 }
2625 return 0;
2626}
2627
2628static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2629 int *valp,
2630 int write, void *data)
2631{
2632 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002633 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2634 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002635 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2636 } else {
2637 int val = *valp;
2638 unsigned long lval;
2639 if (val < 0) {
2640 *negp = -1;
2641 lval = (unsigned long)-val;
2642 } else {
2643 *negp = 0;
2644 lval = (unsigned long)val;
2645 }
2646 *lvalp = jiffies_to_clock_t(lval);
2647 }
2648 return 0;
2649}
2650
2651static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2652 int *valp,
2653 int write, void *data)
2654{
2655 if (write) {
2656 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2657 } else {
2658 int val = *valp;
2659 unsigned long lval;
2660 if (val < 0) {
2661 *negp = -1;
2662 lval = (unsigned long)-val;
2663 } else {
2664 *negp = 0;
2665 lval = (unsigned long)val;
2666 }
2667 *lvalp = jiffies_to_msecs(lval);
2668 }
2669 return 0;
2670}
2671
2672/**
2673 * proc_dointvec_jiffies - read a vector of integers as seconds
2674 * @table: the sysctl table
2675 * @write: %TRUE if this is a write to the sysctl file
2676 * @filp: the file structure
2677 * @buffer: the user buffer
2678 * @lenp: the size of the user buffer
2679 * @ppos: file position
2680 *
2681 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2682 * values from/to the user buffer, treated as an ASCII string.
2683 * The values read are assumed to be in seconds, and are converted into
2684 * jiffies.
2685 *
2686 * Returns 0 on success.
2687 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002688int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002689 void __user *buffer, size_t *lenp, loff_t *ppos)
2690{
2691 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2692 do_proc_dointvec_jiffies_conv,NULL);
2693}
2694
2695/**
2696 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2697 * @table: the sysctl table
2698 * @write: %TRUE if this is a write to the sysctl file
2699 * @filp: the file structure
2700 * @buffer: the user buffer
2701 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002702 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002703 *
2704 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2705 * values from/to the user buffer, treated as an ASCII string.
2706 * The values read are assumed to be in 1/USER_HZ seconds, and
2707 * are converted into jiffies.
2708 *
2709 * Returns 0 on success.
2710 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002711int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002712 void __user *buffer, size_t *lenp, loff_t *ppos)
2713{
2714 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2715 do_proc_dointvec_userhz_jiffies_conv,NULL);
2716}
2717
2718/**
2719 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2720 * @table: the sysctl table
2721 * @write: %TRUE if this is a write to the sysctl file
2722 * @filp: the file structure
2723 * @buffer: the user buffer
2724 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002725 * @ppos: file position
2726 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002727 *
2728 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2729 * values from/to the user buffer, treated as an ASCII string.
2730 * The values read are assumed to be in 1/1000 seconds, and
2731 * are converted into jiffies.
2732 *
2733 * Returns 0 on success.
2734 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002735int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002736 void __user *buffer, size_t *lenp, loff_t *ppos)
2737{
2738 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2739 do_proc_dointvec_ms_jiffies_conv, NULL);
2740}
2741
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002742static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002743 void __user *buffer, size_t *lenp, loff_t *ppos)
2744{
2745 struct pid *new_pid;
2746 pid_t tmp;
2747 int r;
2748
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002749 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002750
2751 r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
2752 lenp, ppos, NULL, NULL);
2753 if (r || !write)
2754 return r;
2755
2756 new_pid = find_get_pid(tmp);
2757 if (!new_pid)
2758 return -ESRCH;
2759
2760 put_pid(xchg(&cad_pid, new_pid));
2761 return 0;
2762}
2763
Linus Torvalds1da177e2005-04-16 15:20:36 -07002764#else /* CONFIG_PROC_FS */
2765
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002766int proc_dostring(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002767 void __user *buffer, size_t *lenp, loff_t *ppos)
2768{
2769 return -ENOSYS;
2770}
2771
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002772int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002773 void __user *buffer, size_t *lenp, loff_t *ppos)
2774{
2775 return -ENOSYS;
2776}
2777
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002778int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002779 void __user *buffer, size_t *lenp, loff_t *ppos)
2780{
2781 return -ENOSYS;
2782}
2783
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002784int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002785 void __user *buffer, size_t *lenp, loff_t *ppos)
2786{
2787 return -ENOSYS;
2788}
2789
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002790int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002791 void __user *buffer, size_t *lenp, loff_t *ppos)
2792{
2793 return -ENOSYS;
2794}
2795
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002796int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002797 void __user *buffer, size_t *lenp, loff_t *ppos)
2798{
2799 return -ENOSYS;
2800}
2801
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002802int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002803 void __user *buffer, size_t *lenp, loff_t *ppos)
2804{
2805 return -ENOSYS;
2806}
2807
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002808int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002809 struct file *filp,
2810 void __user *buffer,
2811 size_t *lenp, loff_t *ppos)
2812{
2813 return -ENOSYS;
2814}
2815
2816
2817#endif /* CONFIG_PROC_FS */
2818
2819
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002820#ifdef CONFIG_SYSCTL_SYSCALL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002821/*
2822 * General sysctl support routines
2823 */
2824
Eric W. Biederman49a0c452007-10-18 03:05:23 -07002825/* The generic sysctl data routine (used if no strategy routine supplied) */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002826int sysctl_data(struct ctl_table *table,
Eric W. Biederman49a0c452007-10-18 03:05:23 -07002827 void __user *oldval, size_t __user *oldlenp,
2828 void __user *newval, size_t newlen)
2829{
2830 size_t len;
2831
2832 /* Get out of I don't have a variable */
2833 if (!table->data || !table->maxlen)
2834 return -ENOTDIR;
2835
2836 if (oldval && oldlenp) {
2837 if (get_user(len, oldlenp))
2838 return -EFAULT;
2839 if (len) {
2840 if (len > table->maxlen)
2841 len = table->maxlen;
2842 if (copy_to_user(oldval, table->data, len))
2843 return -EFAULT;
2844 if (put_user(len, oldlenp))
2845 return -EFAULT;
2846 }
2847 }
2848
2849 if (newval && newlen) {
2850 if (newlen > table->maxlen)
2851 newlen = table->maxlen;
2852
2853 if (copy_from_user(table->data, newval, newlen))
2854 return -EFAULT;
2855 }
2856 return 1;
2857}
2858
Linus Torvalds1da177e2005-04-16 15:20:36 -07002859/* The generic string strategy routine: */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002860int sysctl_string(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002861 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002862 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002863{
Linus Torvalds1da177e2005-04-16 15:20:36 -07002864 if (!table->data || !table->maxlen)
2865 return -ENOTDIR;
2866
2867 if (oldval && oldlenp) {
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002868 size_t bufsize;
2869 if (get_user(bufsize, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002870 return -EFAULT;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002871 if (bufsize) {
2872 size_t len = strlen(table->data), copied;
2873
2874 /* This shouldn't trigger for a well-formed sysctl */
2875 if (len > table->maxlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002876 len = table->maxlen;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002877
2878 /* Copy up to a max of bufsize-1 bytes of the string */
2879 copied = (len >= bufsize) ? bufsize - 1 : len;
2880
2881 if (copy_to_user(oldval, table->data, copied) ||
2882 put_user(0, (char __user *)(oldval + copied)))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002883 return -EFAULT;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002884 if (put_user(len, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002885 return -EFAULT;
2886 }
2887 }
2888 if (newval && newlen) {
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002889 size_t len = newlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002890 if (len > table->maxlen)
2891 len = table->maxlen;
2892 if(copy_from_user(table->data, newval, len))
2893 return -EFAULT;
2894 if (len == table->maxlen)
2895 len--;
2896 ((char *) table->data)[len] = 0;
2897 }
Yi Yang82c9df82005-12-30 16:37:10 +08002898 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002899}
2900
2901/*
2902 * This function makes sure that all of the integers in the vector
2903 * are between the minimum and maximum values given in the arrays
2904 * table->extra1 and table->extra2, respectively.
2905 */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002906int sysctl_intvec(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002907 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002908 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002909{
2910
2911 if (newval && newlen) {
2912 int __user *vec = (int __user *) newval;
2913 int *min = (int *) table->extra1;
2914 int *max = (int *) table->extra2;
2915 size_t length;
2916 int i;
2917
2918 if (newlen % sizeof(int) != 0)
2919 return -EINVAL;
2920
2921 if (!table->extra1 && !table->extra2)
2922 return 0;
2923
2924 if (newlen > table->maxlen)
2925 newlen = table->maxlen;
2926 length = newlen / sizeof(int);
2927
2928 for (i = 0; i < length; i++) {
2929 int value;
2930 if (get_user(value, vec + i))
2931 return -EFAULT;
2932 if (min && value < min[i])
2933 return -EINVAL;
2934 if (max && value > max[i])
2935 return -EINVAL;
2936 }
2937 }
2938 return 0;
2939}
2940
2941/* Strategy function to convert jiffies to seconds */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002942int sysctl_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002943 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002944 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002945{
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002946 if (oldval && oldlenp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002947 size_t olen;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002948
2949 if (get_user(olen, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002950 return -EFAULT;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002951 if (olen) {
2952 int val;
2953
2954 if (olen < sizeof(int))
2955 return -EINVAL;
2956
2957 val = *(int *)(table->data) / HZ;
2958 if (put_user(val, (int __user *)oldval))
2959 return -EFAULT;
2960 if (put_user(sizeof(int), oldlenp))
2961 return -EFAULT;
2962 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002963 }
2964 if (newval && newlen) {
2965 int new;
2966 if (newlen != sizeof(int))
2967 return -EINVAL;
2968 if (get_user(new, (int __user *)newval))
2969 return -EFAULT;
2970 *(int *)(table->data) = new*HZ;
2971 }
2972 return 1;
2973}
2974
2975/* Strategy function to convert jiffies to seconds */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002976int sysctl_ms_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002977 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002978 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002979{
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002980 if (oldval && oldlenp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002981 size_t olen;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002982
2983 if (get_user(olen, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002984 return -EFAULT;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002985 if (olen) {
2986 int val;
2987
2988 if (olen < sizeof(int))
2989 return -EINVAL;
2990
2991 val = jiffies_to_msecs(*(int *)(table->data));
2992 if (put_user(val, (int __user *)oldval))
2993 return -EFAULT;
2994 if (put_user(sizeof(int), oldlenp))
2995 return -EFAULT;
2996 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002997 }
2998 if (newval && newlen) {
2999 int new;
3000 if (newlen != sizeof(int))
3001 return -EINVAL;
3002 if (get_user(new, (int __user *)newval))
3003 return -EFAULT;
3004 *(int *)(table->data) = msecs_to_jiffies(new);
3005 }
3006 return 1;
3007}
3008
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08003009
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08003010
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07003011#else /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003012
3013
Heiko Carstens1e7bfb22009-01-14 14:14:29 +01003014SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003015{
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003016 struct __sysctl_args tmp;
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003017 int error;
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003018
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003019 if (copy_from_user(&tmp, args, sizeof(tmp)))
3020 return -EFAULT;
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003021
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003022 error = deprecated_sysctl_warning(&tmp);
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07003023
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003024 /* If no error reading the parameters then just -ENOSYS ... */
3025 if (!error)
3026 error = -ENOSYS;
3027
3028 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003029}
3030
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003031int sysctl_data(struct ctl_table *table,
Eric W. Biederman49a0c452007-10-18 03:05:23 -07003032 void __user *oldval, size_t __user *oldlenp,
3033 void __user *newval, size_t newlen)
3034{
3035 return -ENOSYS;
3036}
3037
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003038int sysctl_string(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003039 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003040 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003041{
3042 return -ENOSYS;
3043}
3044
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003045int sysctl_intvec(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003046 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003047 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003048{
3049 return -ENOSYS;
3050}
3051
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003052int sysctl_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003053 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003054 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003055{
3056 return -ENOSYS;
3057}
3058
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003059int sysctl_ms_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003060 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003061 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003062{
3063 return -ENOSYS;
3064}
3065
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07003066#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003067
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003068static int deprecated_sysctl_warning(struct __sysctl_args *args)
3069{
3070 static int msg_count;
3071 int name[CTL_MAXNAME];
3072 int i;
3073
Tetsuo Handa6fc48af2007-11-14 16:58:38 -08003074 /* Check args->nlen. */
3075 if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
3076 return -ENOTDIR;
3077
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003078 /* Read in the sysctl name for better debug message logging */
3079 for (i = 0; i < args->nlen; i++)
3080 if (get_user(name[i], args->name + i))
3081 return -EFAULT;
3082
3083 /* Ignore accesses to kernel.version */
3084 if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
3085 return 0;
3086
3087 if (msg_count < 5) {
3088 msg_count++;
3089 printk(KERN_INFO
3090 "warning: process `%s' used the deprecated sysctl "
3091 "system call with ", current->comm);
3092 for (i = 0; i < args->nlen; i++)
3093 printk("%d.", name[i]);
3094 printk("\n");
3095 }
3096 return 0;
3097}
3098
Linus Torvalds1da177e2005-04-16 15:20:36 -07003099/*
3100 * No sense putting this after each symbol definition, twice,
3101 * exception granted :-)
3102 */
3103EXPORT_SYMBOL(proc_dointvec);
3104EXPORT_SYMBOL(proc_dointvec_jiffies);
3105EXPORT_SYMBOL(proc_dointvec_minmax);
3106EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3107EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3108EXPORT_SYMBOL(proc_dostring);
3109EXPORT_SYMBOL(proc_doulongvec_minmax);
3110EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3111EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11003112EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003113EXPORT_SYMBOL(sysctl_intvec);
3114EXPORT_SYMBOL(sysctl_jiffies);
3115EXPORT_SYMBOL(sysctl_ms_jiffies);
3116EXPORT_SYMBOL(sysctl_string);
Eric W. Biederman49a0c452007-10-18 03:05:23 -07003117EXPORT_SYMBOL(sysctl_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003118EXPORT_SYMBOL(unregister_sysctl_table);