blob: c5ef44ff850f5af111943d76a5484318d6a5bc35 [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[];
116#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117#ifdef CONFIG_CHR_DEV_SG
118extern int sg_big_buff;
119#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
David S. Miller72c57ed2008-09-11 23:29:54 -0700121#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700122#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123#endif
124
David S. Miller08714202008-11-16 23:49:24 -0800125#ifdef CONFIG_SPARC64
126extern int sysctl_tsb_ratio;
127#endif
128
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129#ifdef __hppa__
130extern int pwrsw_enabled;
131extern int unaligned_enabled;
132#endif
133
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800134#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135#ifdef CONFIG_MATHEMU
136extern int sysctl_ieee_emulation_warnings;
137#endif
138extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700139extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140#endif
141
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142#ifdef CONFIG_BSD_PROCESS_ACCT
143extern int acct_parm[];
144#endif
145
Jes Sorensend2b176e2006-02-28 09:42:23 -0800146#ifdef CONFIG_IA64
147extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800148extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800149#endif
150
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700151#ifdef CONFIG_RT_MUTEXES
152extern int max_lock_depth;
153#endif
154
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700155#ifdef CONFIG_PROC_SYSCTL
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700156static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700157 void __user *buffer, size_t *lenp, loff_t *ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -0700158static int proc_taint(struct ctl_table *table, int write, struct file *filp,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800159 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700160#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700161
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700162static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100163static struct ctl_table_root sysctl_table_root;
164static struct ctl_table_header root_table_header = {
Al Virob380b0d2008-09-04 17:05:57 +0100165 .count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100166 .ctl_table = root_table,
Al Viro73455092008-07-14 21:22:20 -0400167 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100168 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400169 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100170};
171static struct ctl_table_root sysctl_table_root = {
172 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400173 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100174};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700176static struct ctl_table kern_table[];
177static struct ctl_table vm_table[];
178static struct ctl_table fs_table[];
179static struct ctl_table debug_table[];
180static struct ctl_table dev_table[];
181extern struct ctl_table random_table[];
Amy Griffis2d9048e2006-06-01 13:10:59 -0700182#ifdef CONFIG_INOTIFY_USER
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700183extern struct ctl_table inotify_table[];
Robert Love0399cb02005-07-13 12:38:18 -0400184#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -0800185#ifdef CONFIG_EPOLL
186extern struct ctl_table epoll_table[];
187#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
189#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
190int sysctl_legacy_va_layout;
191#endif
192
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700193extern int prove_locking;
194extern int lock_stat;
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800195
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196/* The default sysctl tables: */
197
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700198static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199 {
200 .ctl_name = CTL_KERN,
201 .procname = "kernel",
202 .mode = 0555,
203 .child = kern_table,
204 },
205 {
206 .ctl_name = CTL_VM,
207 .procname = "vm",
208 .mode = 0555,
209 .child = vm_table,
210 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 .ctl_name = CTL_FS,
213 .procname = "fs",
214 .mode = 0555,
215 .child = fs_table,
216 },
217 {
218 .ctl_name = CTL_DEBUG,
219 .procname = "debug",
220 .mode = 0555,
221 .child = debug_table,
222 },
223 {
224 .ctl_name = CTL_DEV,
225 .procname = "dev",
226 .mode = 0555,
227 .child = dev_table,
228 },
Andrew Morton2be7fe02007-07-15 23:41:21 -0700229/*
230 * NOTE: do not add new entries to this table unless you have read
231 * Documentation/sysctl/ctl_unnumbered.txt
232 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 { .ctl_name = 0 }
234};
235
Ingo Molnar77e54a12007-07-09 18:52:00 +0200236#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100237static int min_sched_granularity_ns = 100000; /* 100 usecs */
238static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
239static int min_wakeup_granularity_ns; /* 0 usecs */
240static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200241#endif
242
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700243static struct ctl_table kern_table[] = {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200244#ifdef CONFIG_SCHED_DEBUG
245 {
246 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100247 .procname = "sched_min_granularity_ns",
248 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200249 .maxlen = sizeof(unsigned int),
250 .mode = 0644,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100251 .proc_handler = &sched_nr_latency_handler,
252 .strategy = &sysctl_intvec,
253 .extra1 = &min_sched_granularity_ns,
254 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200255 },
256 {
257 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra21805082007-08-25 18:41:53 +0200258 .procname = "sched_latency_ns",
259 .data = &sysctl_sched_latency,
260 .maxlen = sizeof(unsigned int),
261 .mode = 0644,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100262 .proc_handler = &sched_nr_latency_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200263 .strategy = &sysctl_intvec,
264 .extra1 = &min_sched_granularity_ns,
265 .extra2 = &max_sched_granularity_ns,
266 },
267 {
268 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200269 .procname = "sched_wakeup_granularity_ns",
270 .data = &sysctl_sched_wakeup_granularity,
271 .maxlen = sizeof(unsigned int),
272 .mode = 0644,
273 .proc_handler = &proc_dointvec_minmax,
274 .strategy = &sysctl_intvec,
275 .extra1 = &min_wakeup_granularity_ns,
276 .extra2 = &max_wakeup_granularity_ns,
277 },
278 {
279 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200280 .procname = "sched_shares_ratelimit",
281 .data = &sysctl_sched_shares_ratelimit,
282 .maxlen = sizeof(unsigned int),
283 .mode = 0644,
284 .proc_handler = &proc_dointvec,
285 },
286 {
287 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200288 .procname = "sched_shares_thresh",
289 .data = &sysctl_sched_shares_thresh,
290 .maxlen = sizeof(unsigned int),
291 .mode = 0644,
292 .proc_handler = &proc_dointvec_minmax,
293 .strategy = &sysctl_intvec,
294 .extra1 = &zero,
295 },
296 {
297 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200298 .procname = "sched_child_runs_first",
299 .data = &sysctl_sched_child_runs_first,
300 .maxlen = sizeof(unsigned int),
301 .mode = 0644,
302 .proc_handler = &proc_dointvec,
303 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200304 {
305 .ctl_name = CTL_UNNUMBERED,
306 .procname = "sched_features",
307 .data = &sysctl_sched_features,
308 .maxlen = sizeof(unsigned int),
309 .mode = 0644,
310 .proc_handler = &proc_dointvec,
311 },
Ingo Molnarda84d962007-10-15 17:00:18 +0200312 {
313 .ctl_name = CTL_UNNUMBERED,
314 .procname = "sched_migration_cost",
315 .data = &sysctl_sched_migration_cost,
316 .maxlen = sizeof(unsigned int),
317 .mode = 0644,
318 .proc_handler = &proc_dointvec,
319 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100320 {
321 .ctl_name = CTL_UNNUMBERED,
322 .procname = "sched_nr_migrate",
323 .data = &sysctl_sched_nr_migrate,
324 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100325 .mode = 0644,
326 .proc_handler = &proc_dointvec,
327 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200328#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200329 {
330 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100331 .procname = "sched_rt_period_us",
332 .data = &sysctl_sched_rt_period,
333 .maxlen = sizeof(unsigned int),
334 .mode = 0644,
Peter Zijlstrad0b27fa2008-04-19 19:44:57 +0200335 .proc_handler = &sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100336 },
337 {
338 .ctl_name = CTL_UNNUMBERED,
339 .procname = "sched_rt_runtime_us",
340 .data = &sysctl_sched_rt_runtime,
341 .maxlen = sizeof(int),
342 .mode = 0644,
Peter Zijlstrad0b27fa2008-04-19 19:44:57 +0200343 .proc_handler = &sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100344 },
345 {
346 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar1799e352007-09-19 23:34:46 +0200347 .procname = "sched_compat_yield",
348 .data = &sysctl_sched_compat_yield,
349 .maxlen = sizeof(unsigned int),
350 .mode = 0644,
351 .proc_handler = &proc_dointvec,
352 },
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700353#ifdef CONFIG_PROVE_LOCKING
354 {
355 .ctl_name = CTL_UNNUMBERED,
356 .procname = "prove_locking",
357 .data = &prove_locking,
358 .maxlen = sizeof(int),
359 .mode = 0644,
360 .proc_handler = &proc_dointvec,
361 },
362#endif
363#ifdef CONFIG_LOCK_STAT
364 {
365 .ctl_name = CTL_UNNUMBERED,
366 .procname = "lock_stat",
367 .data = &lock_stat,
368 .maxlen = sizeof(int),
369 .mode = 0644,
370 .proc_handler = &proc_dointvec,
371 },
372#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200373 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 .ctl_name = KERN_PANIC,
375 .procname = "panic",
376 .data = &panic_timeout,
377 .maxlen = sizeof(int),
378 .mode = 0644,
379 .proc_handler = &proc_dointvec,
380 },
381 {
382 .ctl_name = KERN_CORE_USES_PID,
383 .procname = "core_uses_pid",
384 .data = &core_uses_pid,
385 .maxlen = sizeof(int),
386 .mode = 0644,
387 .proc_handler = &proc_dointvec,
388 },
389 {
390 .ctl_name = KERN_CORE_PATTERN,
391 .procname = "core_pattern",
392 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700393 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 .mode = 0644,
395 .proc_handler = &proc_dostring,
396 .strategy = &sysctl_string,
397 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800398#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700401 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800402 .mode = 0644,
Andi Kleen25ddbb12008-10-15 22:01:41 -0700403 .proc_handler = &proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800405#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100406#ifdef CONFIG_LATENCYTOP
407 {
408 .procname = "latencytop",
409 .data = &latencytop_enabled,
410 .maxlen = sizeof(int),
411 .mode = 0644,
412 .proc_handler = &proc_dointvec,
413 },
414#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415#ifdef CONFIG_BLK_DEV_INITRD
416 {
417 .ctl_name = KERN_REALROOTDEV,
418 .procname = "real-root-dev",
419 .data = &real_root_dev,
420 .maxlen = sizeof(int),
421 .mode = 0644,
422 .proc_handler = &proc_dointvec,
423 },
424#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700425 {
426 .ctl_name = CTL_UNNUMBERED,
427 .procname = "print-fatal-signals",
428 .data = &print_fatal_signals,
429 .maxlen = sizeof(int),
430 .mode = 0644,
431 .proc_handler = &proc_dointvec,
432 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700433#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 {
435 .ctl_name = KERN_SPARC_REBOOT,
436 .procname = "reboot-cmd",
437 .data = reboot_command,
438 .maxlen = 256,
439 .mode = 0644,
440 .proc_handler = &proc_dostring,
441 .strategy = &sysctl_string,
442 },
443 {
444 .ctl_name = KERN_SPARC_STOP_A,
445 .procname = "stop-a",
446 .data = &stop_a_enabled,
447 .maxlen = sizeof (int),
448 .mode = 0644,
449 .proc_handler = &proc_dointvec,
450 },
451 {
452 .ctl_name = KERN_SPARC_SCONS_PWROFF,
453 .procname = "scons-poweroff",
454 .data = &scons_pwroff,
455 .maxlen = sizeof (int),
456 .mode = 0644,
457 .proc_handler = &proc_dointvec,
458 },
459#endif
David S. Miller08714202008-11-16 23:49:24 -0800460#ifdef CONFIG_SPARC64
461 {
462 .ctl_name = CTL_UNNUMBERED,
463 .procname = "tsb-ratio",
464 .data = &sysctl_tsb_ratio,
465 .maxlen = sizeof (int),
466 .mode = 0644,
467 .proc_handler = &proc_dointvec,
468 },
469#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470#ifdef __hppa__
471 {
472 .ctl_name = KERN_HPPA_PWRSW,
473 .procname = "soft-power",
474 .data = &pwrsw_enabled,
475 .maxlen = sizeof (int),
476 .mode = 0644,
477 .proc_handler = &proc_dointvec,
478 },
479 {
480 .ctl_name = KERN_HPPA_UNALIGNED,
481 .procname = "unaligned-trap",
482 .data = &unaligned_enabled,
483 .maxlen = sizeof (int),
484 .mode = 0644,
485 .proc_handler = &proc_dointvec,
486 },
487#endif
488 {
489 .ctl_name = KERN_CTLALTDEL,
490 .procname = "ctrl-alt-del",
491 .data = &C_A_D,
492 .maxlen = sizeof(int),
493 .mode = 0644,
494 .proc_handler = &proc_dointvec,
495 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400496#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200497 {
498 .ctl_name = CTL_UNNUMBERED,
499 .procname = "ftrace_enabled",
500 .data = &ftrace_enabled,
501 .maxlen = sizeof(int),
502 .mode = 0644,
503 .proc_handler = &ftrace_enable_sysctl,
504 },
505#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500506#ifdef CONFIG_STACK_TRACER
507 {
508 .ctl_name = CTL_UNNUMBERED,
509 .procname = "stack_tracer_enabled",
510 .data = &stack_tracer_enabled,
511 .maxlen = sizeof(int),
512 .mode = 0644,
513 .proc_handler = &stack_trace_sysctl,
514 },
515#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400516#ifdef CONFIG_TRACING
517 {
518 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100519 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400520 .data = &ftrace_dump_on_oops,
521 .maxlen = sizeof(int),
522 .mode = 0644,
523 .proc_handler = &proc_dointvec,
524 },
525#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200526#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 {
528 .ctl_name = KERN_MODPROBE,
529 .procname = "modprobe",
530 .data = &modprobe_path,
531 .maxlen = KMOD_PATH_LEN,
532 .mode = 0644,
533 .proc_handler = &proc_dostring,
534 .strategy = &sysctl_string,
535 },
536#endif
Andrew Morton57ae2502006-06-23 02:05:47 -0700537#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 {
539 .ctl_name = KERN_HOTPLUG,
540 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100541 .data = &uevent_helper,
542 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 .mode = 0644,
544 .proc_handler = &proc_dostring,
545 .strategy = &sysctl_string,
546 },
547#endif
548#ifdef CONFIG_CHR_DEV_SG
549 {
550 .ctl_name = KERN_SG_BIG_BUFF,
551 .procname = "sg-big-buff",
552 .data = &sg_big_buff,
553 .maxlen = sizeof (int),
554 .mode = 0444,
555 .proc_handler = &proc_dointvec,
556 },
557#endif
558#ifdef CONFIG_BSD_PROCESS_ACCT
559 {
560 .ctl_name = KERN_ACCT,
561 .procname = "acct",
562 .data = &acct_parm,
563 .maxlen = 3*sizeof(int),
564 .mode = 0644,
565 .proc_handler = &proc_dointvec,
566 },
567#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568#ifdef CONFIG_MAGIC_SYSRQ
569 {
570 .ctl_name = KERN_SYSRQ,
571 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800572 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 .maxlen = sizeof (int),
574 .mode = 0644,
575 .proc_handler = &proc_dointvec,
576 },
577#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700578#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700581 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 .maxlen = sizeof (int),
583 .mode = 0600,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700584 .proc_handler = &proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700586#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 {
588 .ctl_name = KERN_MAX_THREADS,
589 .procname = "threads-max",
590 .data = &max_threads,
591 .maxlen = sizeof(int),
592 .mode = 0644,
593 .proc_handler = &proc_dointvec,
594 },
595 {
596 .ctl_name = KERN_RANDOM,
597 .procname = "random",
598 .mode = 0555,
599 .child = random_table,
600 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 {
602 .ctl_name = KERN_OVERFLOWUID,
603 .procname = "overflowuid",
604 .data = &overflowuid,
605 .maxlen = sizeof(int),
606 .mode = 0644,
607 .proc_handler = &proc_dointvec_minmax,
608 .strategy = &sysctl_intvec,
609 .extra1 = &minolduid,
610 .extra2 = &maxolduid,
611 },
612 {
613 .ctl_name = KERN_OVERFLOWGID,
614 .procname = "overflowgid",
615 .data = &overflowgid,
616 .maxlen = sizeof(int),
617 .mode = 0644,
618 .proc_handler = &proc_dointvec_minmax,
619 .strategy = &sysctl_intvec,
620 .extra1 = &minolduid,
621 .extra2 = &maxolduid,
622 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800623#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624#ifdef CONFIG_MATHEMU
625 {
626 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
627 .procname = "ieee_emulation_warnings",
628 .data = &sysctl_ieee_emulation_warnings,
629 .maxlen = sizeof(int),
630 .mode = 0644,
631 .proc_handler = &proc_dointvec,
632 },
633#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 {
635 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
636 .procname = "userprocess_debug",
637 .data = &sysctl_userprocess_debug,
638 .maxlen = sizeof(int),
639 .mode = 0644,
640 .proc_handler = &proc_dointvec,
641 },
642#endif
643 {
644 .ctl_name = KERN_PIDMAX,
645 .procname = "pid_max",
646 .data = &pid_max,
647 .maxlen = sizeof (int),
648 .mode = 0644,
649 .proc_handler = &proc_dointvec_minmax,
650 .strategy = sysctl_intvec,
651 .extra1 = &pid_max_min,
652 .extra2 = &pid_max_max,
653 },
654 {
655 .ctl_name = KERN_PANIC_ON_OOPS,
656 .procname = "panic_on_oops",
657 .data = &panic_on_oops,
658 .maxlen = sizeof(int),
659 .mode = 0644,
660 .proc_handler = &proc_dointvec,
661 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800662#if defined CONFIG_PRINTK
663 {
664 .ctl_name = KERN_PRINTK,
665 .procname = "printk",
666 .data = &console_loglevel,
667 .maxlen = 4*sizeof(int),
668 .mode = 0644,
669 .proc_handler = &proc_dointvec,
670 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 {
672 .ctl_name = KERN_PRINTK_RATELIMIT,
673 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700674 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 .maxlen = sizeof(int),
676 .mode = 0644,
677 .proc_handler = &proc_dointvec_jiffies,
678 .strategy = &sysctl_jiffies,
679 },
680 {
681 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
682 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700683 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 .maxlen = sizeof(int),
685 .mode = 0644,
686 .proc_handler = &proc_dointvec,
687 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800688#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 {
690 .ctl_name = KERN_NGROUPS_MAX,
691 .procname = "ngroups_max",
692 .data = &ngroups_max,
693 .maxlen = sizeof (int),
694 .mode = 0444,
695 .proc_handler = &proc_dointvec,
696 },
697#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
698 {
699 .ctl_name = KERN_UNKNOWN_NMI_PANIC,
700 .procname = "unknown_nmi_panic",
701 .data = &unknown_nmi_panic,
702 .maxlen = sizeof (int),
703 .mode = 0644,
Don Zickus2fbe7b22006-09-26 10:52:27 +0200704 .proc_handler = &proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 },
Don Zickus407984f2006-09-26 10:52:27 +0200706 {
Don Zickus407984f2006-09-26 10:52:27 +0200707 .procname = "nmi_watchdog",
708 .data = &nmi_watchdog_enabled,
709 .maxlen = sizeof (int),
710 .mode = 0644,
711 .proc_handler = &proc_nmi_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 },
713#endif
714#if defined(CONFIG_X86)
715 {
Don Zickus8da5add2006-09-26 10:52:27 +0200716 .ctl_name = KERN_PANIC_ON_NMI,
717 .procname = "panic_on_unrecovered_nmi",
718 .data = &panic_on_unrecovered_nmi,
719 .maxlen = sizeof(int),
720 .mode = 0644,
721 .proc_handler = &proc_dointvec,
722 },
723 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 .ctl_name = KERN_BOOTLOADER_TYPE,
725 .procname = "bootloader_type",
726 .data = &bootloader_type,
727 .maxlen = sizeof (int),
728 .mode = 0444,
729 .proc_handler = &proc_dointvec,
730 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100731 {
732 .ctl_name = CTL_UNNUMBERED,
733 .procname = "kstack_depth_to_print",
734 .data = &kstack_depth_to_print,
735 .maxlen = sizeof(int),
736 .mode = 0644,
737 .proc_handler = &proc_dointvec,
738 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100739 {
740 .ctl_name = CTL_UNNUMBERED,
741 .procname = "io_delay_type",
742 .data = &io_delay_type,
743 .maxlen = sizeof(int),
744 .mode = 0644,
745 .proc_handler = &proc_dointvec,
746 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800748#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 {
750 .ctl_name = KERN_RANDOMIZE,
751 .procname = "randomize_va_space",
752 .data = &randomize_va_space,
753 .maxlen = sizeof(int),
754 .mode = 0644,
755 .proc_handler = &proc_dointvec,
756 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800757#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800758#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700759 {
760 .ctl_name = KERN_SPIN_RETRY,
761 .procname = "spin_retry",
762 .data = &spin_retry,
763 .maxlen = sizeof (int),
764 .mode = 0644,
765 .proc_handler = &proc_dointvec,
766 },
767#endif
Len Brown673d5b42007-07-28 03:33:16 -0400768#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800769 {
Pavel Machekc255d842006-02-20 18:27:58 -0800770 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700771 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800772 .maxlen = sizeof (unsigned long),
773 .mode = 0644,
Stefan Seyfried7f99f062006-03-02 02:54:34 -0800774 .proc_handler = &proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800775 },
776#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800777#ifdef CONFIG_IA64
778 {
779 .ctl_name = KERN_IA64_UNALIGNED,
780 .procname = "ignore-unaligned-usertrap",
781 .data = &no_unaligned_warning,
782 .maxlen = sizeof (int),
783 .mode = 0644,
784 .proc_handler = &proc_dointvec,
785 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800786 {
787 .ctl_name = CTL_UNNUMBERED,
788 .procname = "unaligned-dump-stack",
789 .data = &unaligned_dump_stack,
790 .maxlen = sizeof (int),
791 .mode = 0644,
792 .proc_handler = &proc_dointvec,
793 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800794#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700795#ifdef CONFIG_DETECT_SOFTLOCKUP
796 {
797 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200798 .procname = "softlockup_panic",
799 .data = &softlockup_panic,
800 .maxlen = sizeof(int),
801 .mode = 0644,
Hiroshi Shimamoto4dca10a2008-07-07 18:37:04 -0700802 .proc_handler = &proc_dointvec_minmax,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200803 .strategy = &sysctl_intvec,
804 .extra1 = &zero,
805 .extra2 = &one,
806 },
807 {
808 .ctl_name = CTL_UNNUMBERED,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700809 .procname = "softlockup_thresh",
810 .data = &softlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200811 .maxlen = sizeof(int),
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700812 .mode = 0644,
Mandeep Singh Bainesbaf48f62009-01-12 21:15:17 -0800813 .proc_handler = &proc_dosoftlockup_thresh,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700814 .strategy = &sysctl_intvec,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200815 .extra1 = &neg_one,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700816 .extra2 = &sixty,
817 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100818 {
819 .ctl_name = CTL_UNNUMBERED,
820 .procname = "hung_task_check_count",
821 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100822 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100823 .mode = 0644,
Ingo Molnar90739082008-01-25 21:08:34 +0100824 .proc_handler = &proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100825 .strategy = &sysctl_intvec,
826 },
827 {
828 .ctl_name = CTL_UNNUMBERED,
829 .procname = "hung_task_timeout_secs",
830 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100831 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100832 .mode = 0644,
Ingo Molnar90739082008-01-25 21:08:34 +0100833 .proc_handler = &proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100834 .strategy = &sysctl_intvec,
835 },
836 {
837 .ctl_name = CTL_UNNUMBERED,
838 .procname = "hung_task_warnings",
839 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100840 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100841 .mode = 0644,
Ingo Molnar90739082008-01-25 21:08:34 +0100842 .proc_handler = &proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100843 .strategy = &sysctl_intvec,
844 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700845#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200846#ifdef CONFIG_COMPAT
847 {
848 .ctl_name = KERN_COMPAT_LOG,
849 .procname = "compat-log",
850 .data = &compat_log,
851 .maxlen = sizeof (int),
852 .mode = 0644,
853 .proc_handler = &proc_dointvec,
854 },
855#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700856#ifdef CONFIG_RT_MUTEXES
857 {
858 .ctl_name = KERN_MAX_LOCK_DEPTH,
859 .procname = "max_lock_depth",
860 .data = &max_lock_depth,
861 .maxlen = sizeof(int),
862 .mode = 0644,
863 .proc_handler = &proc_dointvec,
864 },
865#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700866 {
867 .ctl_name = CTL_UNNUMBERED,
868 .procname = "poweroff_cmd",
869 .data = &poweroff_cmd,
870 .maxlen = POWEROFF_CMD_PATH_LEN,
871 .mode = 0644,
872 .proc_handler = &proc_dostring,
873 .strategy = &sysctl_string,
874 },
David Howells0b77f5b2008-04-29 01:01:32 -0700875#ifdef CONFIG_KEYS
876 {
877 .ctl_name = CTL_UNNUMBERED,
878 .procname = "keys",
879 .mode = 0555,
880 .child = key_sysctls,
881 },
882#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700883#ifdef CONFIG_RCU_TORTURE_TEST
884 {
885 .ctl_name = CTL_UNNUMBERED,
886 .procname = "rcutorture_runnable",
887 .data = &rcutorture_runnable,
888 .maxlen = sizeof(int),
889 .mode = 0644,
890 .proc_handler = &proc_dointvec,
891 },
892#endif
Lee Schermerhornaf936a12008-10-18 20:26:53 -0700893#ifdef CONFIG_UNEVICTABLE_LRU
894 {
895 .ctl_name = CTL_UNNUMBERED,
896 .procname = "scan_unevictable_pages",
897 .data = &scan_unevictable_pages,
898 .maxlen = sizeof(scan_unevictable_pages),
899 .mode = 0644,
900 .proc_handler = &scan_unevictable_handler,
901 },
902#endif
Andrew Mortoned2c12f2007-07-19 01:50:35 -0700903/*
904 * NOTE: do not add new entries to this table unless you have read
905 * Documentation/sysctl/ctl_unnumbered.txt
906 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907 { .ctl_name = 0 }
908};
909
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700910static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911 {
912 .ctl_name = VM_OVERCOMMIT_MEMORY,
913 .procname = "overcommit_memory",
914 .data = &sysctl_overcommit_memory,
915 .maxlen = sizeof(sysctl_overcommit_memory),
916 .mode = 0644,
917 .proc_handler = &proc_dointvec,
918 },
919 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700920 .ctl_name = VM_PANIC_ON_OOM,
921 .procname = "panic_on_oom",
922 .data = &sysctl_panic_on_oom,
923 .maxlen = sizeof(sysctl_panic_on_oom),
924 .mode = 0644,
925 .proc_handler = &proc_dointvec,
926 },
927 {
David Rientjesfe071d72007-10-16 23:25:56 -0700928 .ctl_name = CTL_UNNUMBERED,
929 .procname = "oom_kill_allocating_task",
930 .data = &sysctl_oom_kill_allocating_task,
931 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
932 .mode = 0644,
933 .proc_handler = &proc_dointvec,
934 },
935 {
David Rientjesfef1bdd2008-02-07 00:14:07 -0800936 .ctl_name = CTL_UNNUMBERED,
937 .procname = "oom_dump_tasks",
938 .data = &sysctl_oom_dump_tasks,
939 .maxlen = sizeof(sysctl_oom_dump_tasks),
940 .mode = 0644,
941 .proc_handler = &proc_dointvec,
942 },
943 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944 .ctl_name = VM_OVERCOMMIT_RATIO,
945 .procname = "overcommit_ratio",
946 .data = &sysctl_overcommit_ratio,
947 .maxlen = sizeof(sysctl_overcommit_ratio),
948 .mode = 0644,
949 .proc_handler = &proc_dointvec,
950 },
951 {
952 .ctl_name = VM_PAGE_CLUSTER,
953 .procname = "page-cluster",
954 .data = &page_cluster,
955 .maxlen = sizeof(int),
956 .mode = 0644,
957 .proc_handler = &proc_dointvec,
958 },
959 {
960 .ctl_name = VM_DIRTY_BACKGROUND,
961 .procname = "dirty_background_ratio",
962 .data = &dirty_background_ratio,
963 .maxlen = sizeof(dirty_background_ratio),
964 .mode = 0644,
David Rientjes2da02992009-01-06 14:39:31 -0800965 .proc_handler = &dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966 .strategy = &sysctl_intvec,
967 .extra1 = &zero,
968 .extra2 = &one_hundred,
969 },
970 {
David Rientjes2da02992009-01-06 14:39:31 -0800971 .ctl_name = CTL_UNNUMBERED,
972 .procname = "dirty_background_bytes",
973 .data = &dirty_background_bytes,
974 .maxlen = sizeof(dirty_background_bytes),
975 .mode = 0644,
976 .proc_handler = &dirty_background_bytes_handler,
977 .strategy = &sysctl_intvec,
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800978 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -0800979 },
980 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700981 .ctl_name = VM_DIRTY_RATIO,
982 .procname = "dirty_ratio",
983 .data = &vm_dirty_ratio,
984 .maxlen = sizeof(vm_dirty_ratio),
985 .mode = 0644,
Peter Zijlstra04fbfdc2007-10-16 23:25:50 -0700986 .proc_handler = &dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 .strategy = &sysctl_intvec,
988 .extra1 = &zero,
989 .extra2 = &one_hundred,
990 },
991 {
David Rientjes2da02992009-01-06 14:39:31 -0800992 .ctl_name = CTL_UNNUMBERED,
993 .procname = "dirty_bytes",
994 .data = &vm_dirty_bytes,
995 .maxlen = sizeof(vm_dirty_bytes),
996 .mode = 0644,
997 .proc_handler = &dirty_bytes_handler,
998 .strategy = &sysctl_intvec,
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800999 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001000 },
1001 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001003 .data = &dirty_writeback_interval,
1004 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005 .mode = 0644,
1006 .proc_handler = &dirty_writeback_centisecs_handler,
1007 },
1008 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001009 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001010 .data = &dirty_expire_interval,
1011 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012 .mode = 0644,
Bart Samwelf6ef9432006-03-24 03:15:48 -08001013 .proc_handler = &proc_dointvec_userhz_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001014 },
1015 {
1016 .ctl_name = VM_NR_PDFLUSH_THREADS,
1017 .procname = "nr_pdflush_threads",
1018 .data = &nr_pdflush_threads,
1019 .maxlen = sizeof nr_pdflush_threads,
1020 .mode = 0444 /* read-only*/,
1021 .proc_handler = &proc_dointvec,
1022 },
1023 {
1024 .ctl_name = VM_SWAPPINESS,
1025 .procname = "swappiness",
1026 .data = &vm_swappiness,
1027 .maxlen = sizeof(vm_swappiness),
1028 .mode = 0644,
1029 .proc_handler = &proc_dointvec_minmax,
1030 .strategy = &sysctl_intvec,
1031 .extra1 = &zero,
1032 .extra2 = &one_hundred,
1033 },
1034#ifdef CONFIG_HUGETLB_PAGE
1035 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001036 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001037 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038 .maxlen = sizeof(unsigned long),
1039 .mode = 0644,
1040 .proc_handler = &hugetlb_sysctl_handler,
1041 .extra1 = (void *)&hugetlb_zero,
1042 .extra2 = (void *)&hugetlb_infinity,
1043 },
1044 {
1045 .ctl_name = VM_HUGETLB_GROUP,
1046 .procname = "hugetlb_shm_group",
1047 .data = &sysctl_hugetlb_shm_group,
1048 .maxlen = sizeof(gid_t),
1049 .mode = 0644,
1050 .proc_handler = &proc_dointvec,
1051 },
Mel Gorman396faf02007-07-17 04:03:13 -07001052 {
1053 .ctl_name = CTL_UNNUMBERED,
1054 .procname = "hugepages_treat_as_movable",
1055 .data = &hugepages_treat_as_movable,
1056 .maxlen = sizeof(int),
1057 .mode = 0644,
1058 .proc_handler = &hugetlb_treat_movable_handler,
1059 },
Adam Litke54f9f802007-10-16 01:26:20 -07001060 {
1061 .ctl_name = CTL_UNNUMBERED,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001062 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001063 .data = NULL,
1064 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001065 .mode = 0644,
Nishanth Aravamudana3d0c6a2008-02-08 04:18:18 -08001066 .proc_handler = &hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001067 .extra1 = (void *)&hugetlb_zero,
1068 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001069 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070#endif
1071 {
1072 .ctl_name = VM_LOWMEM_RESERVE_RATIO,
1073 .procname = "lowmem_reserve_ratio",
1074 .data = &sysctl_lowmem_reserve_ratio,
1075 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1076 .mode = 0644,
1077 .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
1078 .strategy = &sysctl_intvec,
1079 },
1080 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001081 .ctl_name = VM_DROP_PAGECACHE,
1082 .procname = "drop_caches",
1083 .data = &sysctl_drop_caches,
1084 .maxlen = sizeof(int),
1085 .mode = 0644,
1086 .proc_handler = drop_caches_sysctl_handler,
1087 .strategy = &sysctl_intvec,
1088 },
1089 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001090 .ctl_name = VM_MIN_FREE_KBYTES,
1091 .procname = "min_free_kbytes",
1092 .data = &min_free_kbytes,
1093 .maxlen = sizeof(min_free_kbytes),
1094 .mode = 0644,
1095 .proc_handler = &min_free_kbytes_sysctl_handler,
1096 .strategy = &sysctl_intvec,
1097 .extra1 = &zero,
1098 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001099 {
1100 .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
1101 .procname = "percpu_pagelist_fraction",
1102 .data = &percpu_pagelist_fraction,
1103 .maxlen = sizeof(percpu_pagelist_fraction),
1104 .mode = 0644,
1105 .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
1106 .strategy = &sysctl_intvec,
1107 .extra1 = &min_percpu_pagelist_fract,
1108 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001109#ifdef CONFIG_MMU
1110 {
1111 .ctl_name = VM_MAX_MAP_COUNT,
1112 .procname = "max_map_count",
1113 .data = &sysctl_max_map_count,
1114 .maxlen = sizeof(sysctl_max_map_count),
1115 .mode = 0644,
1116 .proc_handler = &proc_dointvec
1117 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001118#else
1119 {
1120 .ctl_name = CTL_UNNUMBERED,
1121 .procname = "nr_trim_pages",
1122 .data = &sysctl_nr_trim_pages,
1123 .maxlen = sizeof(sysctl_nr_trim_pages),
1124 .mode = 0644,
1125 .proc_handler = &proc_dointvec_minmax,
1126 .strategy = &sysctl_intvec,
1127 .extra1 = &zero,
1128 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001129#endif
1130 {
1131 .ctl_name = VM_LAPTOP_MODE,
1132 .procname = "laptop_mode",
1133 .data = &laptop_mode,
1134 .maxlen = sizeof(laptop_mode),
1135 .mode = 0644,
Bart Samweled5b43f2006-03-24 03:15:49 -08001136 .proc_handler = &proc_dointvec_jiffies,
1137 .strategy = &sysctl_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138 },
1139 {
1140 .ctl_name = VM_BLOCK_DUMP,
1141 .procname = "block_dump",
1142 .data = &block_dump,
1143 .maxlen = sizeof(block_dump),
1144 .mode = 0644,
1145 .proc_handler = &proc_dointvec,
1146 .strategy = &sysctl_intvec,
1147 .extra1 = &zero,
1148 },
1149 {
1150 .ctl_name = VM_VFS_CACHE_PRESSURE,
1151 .procname = "vfs_cache_pressure",
1152 .data = &sysctl_vfs_cache_pressure,
1153 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1154 .mode = 0644,
1155 .proc_handler = &proc_dointvec,
1156 .strategy = &sysctl_intvec,
1157 .extra1 = &zero,
1158 },
1159#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1160 {
1161 .ctl_name = VM_LEGACY_VA_LAYOUT,
1162 .procname = "legacy_va_layout",
1163 .data = &sysctl_legacy_va_layout,
1164 .maxlen = sizeof(sysctl_legacy_va_layout),
1165 .mode = 0644,
1166 .proc_handler = &proc_dointvec,
1167 .strategy = &sysctl_intvec,
1168 .extra1 = &zero,
1169 },
1170#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001171#ifdef CONFIG_NUMA
1172 {
1173 .ctl_name = VM_ZONE_RECLAIM_MODE,
1174 .procname = "zone_reclaim_mode",
1175 .data = &zone_reclaim_mode,
1176 .maxlen = sizeof(zone_reclaim_mode),
1177 .mode = 0644,
1178 .proc_handler = &proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001179 .strategy = &sysctl_intvec,
1180 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001181 },
Christoph Lameter96146342006-07-03 00:24:13 -07001182 {
1183 .ctl_name = VM_MIN_UNMAPPED,
1184 .procname = "min_unmapped_ratio",
1185 .data = &sysctl_min_unmapped_ratio,
1186 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1187 .mode = 0644,
1188 .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
1189 .strategy = &sysctl_intvec,
1190 .extra1 = &zero,
1191 .extra2 = &one_hundred,
1192 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001193 {
1194 .ctl_name = VM_MIN_SLAB,
1195 .procname = "min_slab_ratio",
1196 .data = &sysctl_min_slab_ratio,
1197 .maxlen = sizeof(sysctl_min_slab_ratio),
1198 .mode = 0644,
1199 .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
1200 .strategy = &sysctl_intvec,
1201 .extra1 = &zero,
1202 .extra2 = &one_hundred,
1203 },
Christoph Lameter17436602006-01-18 17:42:32 -08001204#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001205#ifdef CONFIG_SMP
1206 {
1207 .ctl_name = CTL_UNNUMBERED,
1208 .procname = "stat_interval",
1209 .data = &sysctl_stat_interval,
1210 .maxlen = sizeof(sysctl_stat_interval),
1211 .mode = 0644,
1212 .proc_handler = &proc_dointvec_jiffies,
1213 .strategy = &sysctl_jiffies,
1214 },
1215#endif
Eric Parised032182007-06-28 15:55:21 -04001216#ifdef CONFIG_SECURITY
1217 {
1218 .ctl_name = CTL_UNNUMBERED,
1219 .procname = "mmap_min_addr",
1220 .data = &mmap_min_addr,
1221 .maxlen = sizeof(unsigned long),
1222 .mode = 0644,
1223 .proc_handler = &proc_doulongvec_minmax,
1224 },
Lee Schermerhorn8daec962007-08-10 13:00:51 -07001225#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001226#ifdef CONFIG_NUMA
1227 {
1228 .ctl_name = CTL_UNNUMBERED,
1229 .procname = "numa_zonelist_order",
1230 .data = &numa_zonelist_order,
1231 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1232 .mode = 0644,
1233 .proc_handler = &numa_zonelist_order_handler,
1234 .strategy = &sysctl_string,
1235 },
1236#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001237#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001238 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001239 {
1240 .ctl_name = VM_VDSO_ENABLED,
1241 .procname = "vdso_enabled",
1242 .data = &vdso_enabled,
1243 .maxlen = sizeof(vdso_enabled),
1244 .mode = 0644,
1245 .proc_handler = &proc_dointvec,
1246 .strategy = &sysctl_intvec,
1247 .extra1 = &zero,
1248 },
1249#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001250#ifdef CONFIG_HIGHMEM
1251 {
1252 .ctl_name = CTL_UNNUMBERED,
1253 .procname = "highmem_is_dirtyable",
1254 .data = &vm_highmem_is_dirtyable,
1255 .maxlen = sizeof(vm_highmem_is_dirtyable),
1256 .mode = 0644,
1257 .proc_handler = &proc_dointvec_minmax,
1258 .strategy = &sysctl_intvec,
1259 .extra1 = &zero,
1260 .extra2 = &one,
1261 },
1262#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001263/*
1264 * NOTE: do not add new entries to this table unless you have read
1265 * Documentation/sysctl/ctl_unnumbered.txt
1266 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001267 { .ctl_name = 0 }
1268};
1269
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001270#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001271static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001272 { .ctl_name = 0 }
1273};
1274#endif
1275
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001276static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001277 {
1278 .ctl_name = FS_NRINODE,
1279 .procname = "inode-nr",
1280 .data = &inodes_stat,
1281 .maxlen = 2*sizeof(int),
1282 .mode = 0444,
1283 .proc_handler = &proc_dointvec,
1284 },
1285 {
1286 .ctl_name = FS_STATINODE,
1287 .procname = "inode-state",
1288 .data = &inodes_stat,
1289 .maxlen = 7*sizeof(int),
1290 .mode = 0444,
1291 .proc_handler = &proc_dointvec,
1292 },
1293 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294 .procname = "file-nr",
1295 .data = &files_stat,
1296 .maxlen = 3*sizeof(int),
1297 .mode = 0444,
Dipankar Sarma529bf6b2006-03-07 21:55:35 -08001298 .proc_handler = &proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001299 },
1300 {
1301 .ctl_name = FS_MAXFILE,
1302 .procname = "file-max",
1303 .data = &files_stat.max_files,
1304 .maxlen = sizeof(int),
1305 .mode = 0644,
1306 .proc_handler = &proc_dointvec,
1307 },
1308 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001309 .ctl_name = CTL_UNNUMBERED,
1310 .procname = "nr_open",
1311 .data = &sysctl_nr_open,
1312 .maxlen = sizeof(int),
1313 .mode = 0644,
Al Viroeceea0b2008-05-10 10:08:32 -04001314 .proc_handler = &proc_dointvec_minmax,
1315 .extra1 = &sysctl_nr_open_min,
1316 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001317 },
1318 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001319 .ctl_name = FS_DENTRY,
1320 .procname = "dentry-state",
1321 .data = &dentry_stat,
1322 .maxlen = 6*sizeof(int),
1323 .mode = 0444,
1324 .proc_handler = &proc_dointvec,
1325 },
1326 {
1327 .ctl_name = FS_OVERFLOWUID,
1328 .procname = "overflowuid",
1329 .data = &fs_overflowuid,
1330 .maxlen = sizeof(int),
1331 .mode = 0644,
1332 .proc_handler = &proc_dointvec_minmax,
1333 .strategy = &sysctl_intvec,
1334 .extra1 = &minolduid,
1335 .extra2 = &maxolduid,
1336 },
1337 {
1338 .ctl_name = FS_OVERFLOWGID,
1339 .procname = "overflowgid",
1340 .data = &fs_overflowgid,
1341 .maxlen = sizeof(int),
1342 .mode = 0644,
1343 .proc_handler = &proc_dointvec_minmax,
1344 .strategy = &sysctl_intvec,
1345 .extra1 = &minolduid,
1346 .extra2 = &maxolduid,
1347 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001348#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001349 {
1350 .ctl_name = FS_LEASES,
1351 .procname = "leases-enable",
1352 .data = &leases_enable,
1353 .maxlen = sizeof(int),
1354 .mode = 0644,
1355 .proc_handler = &proc_dointvec,
1356 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001357#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001358#ifdef CONFIG_DNOTIFY
1359 {
1360 .ctl_name = FS_DIR_NOTIFY,
1361 .procname = "dir-notify-enable",
1362 .data = &dir_notify_enable,
1363 .maxlen = sizeof(int),
1364 .mode = 0644,
1365 .proc_handler = &proc_dointvec,
1366 },
1367#endif
1368#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001369#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001370 {
1371 .ctl_name = FS_LEASE_TIME,
1372 .procname = "lease-break-time",
1373 .data = &lease_break_time,
1374 .maxlen = sizeof(int),
1375 .mode = 0644,
Kawai, Hidehiro76fdbb22007-07-19 01:48:26 -07001376 .proc_handler = &proc_dointvec_minmax,
1377 .strategy = &sysctl_intvec,
1378 .extra1 = &zero,
1379 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001381#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001382#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001383 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384 .procname = "aio-nr",
1385 .data = &aio_nr,
1386 .maxlen = sizeof(aio_nr),
1387 .mode = 0444,
Zach Brownd55b5fd2005-11-07 00:59:31 -08001388 .proc_handler = &proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389 },
1390 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391 .procname = "aio-max-nr",
1392 .data = &aio_max_nr,
1393 .maxlen = sizeof(aio_max_nr),
1394 .mode = 0644,
Zach Brownd55b5fd2005-11-07 00:59:31 -08001395 .proc_handler = &proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001396 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001397#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001398#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001399 {
1400 .ctl_name = FS_INOTIFY,
1401 .procname = "inotify",
1402 .mode = 0555,
1403 .child = inotify_table,
1404 },
1405#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001406#ifdef CONFIG_EPOLL
1407 {
1408 .procname = "epoll",
1409 .mode = 0555,
1410 .child = epoll_table,
1411 },
1412#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001414 {
1415 .ctl_name = KERN_SETUID_DUMPABLE,
1416 .procname = "suid_dumpable",
1417 .data = &suid_dumpable,
1418 .maxlen = sizeof(int),
1419 .mode = 0644,
1420 .proc_handler = &proc_dointvec,
1421 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001422#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1423 {
1424 .ctl_name = CTL_UNNUMBERED,
1425 .procname = "binfmt_misc",
1426 .mode = 0555,
1427 .child = binfmt_misc_table,
1428 },
1429#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001430/*
1431 * NOTE: do not add new entries to this table unless you have read
1432 * Documentation/sysctl/ctl_unnumbered.txt
1433 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001434 { .ctl_name = 0 }
1435};
1436
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001437static struct ctl_table debug_table[] = {
Olof Johanssond0c3d532007-10-12 10:20:07 +10001438#if defined(CONFIG_X86) || defined(CONFIG_PPC)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001439 {
1440 .ctl_name = CTL_UNNUMBERED,
1441 .procname = "exception-trace",
1442 .data = &show_unhandled_signals,
1443 .maxlen = sizeof(int),
1444 .mode = 0644,
1445 .proc_handler = proc_dointvec
1446 },
1447#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001448 { .ctl_name = 0 }
1449};
1450
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001451static struct ctl_table dev_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001452 { .ctl_name = 0 }
Robert Love0eeca282005-07-12 17:06:03 -04001453};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001454
Al Viro330d57f2005-11-04 10:18:40 +00001455static DEFINE_SPINLOCK(sysctl_lock);
1456
1457/* called under sysctl_lock */
1458static int use_table(struct ctl_table_header *p)
1459{
1460 if (unlikely(p->unregistering))
1461 return 0;
1462 p->used++;
1463 return 1;
1464}
1465
1466/* called under sysctl_lock */
1467static void unuse_table(struct ctl_table_header *p)
1468{
1469 if (!--p->used)
1470 if (unlikely(p->unregistering))
1471 complete(p->unregistering);
1472}
1473
1474/* called under sysctl_lock, will reacquire if has to wait */
1475static void start_unregistering(struct ctl_table_header *p)
1476{
1477 /*
1478 * if p->used is 0, nobody will ever touch that entry again;
1479 * we'll eliminate all paths to it before dropping sysctl_lock
1480 */
1481 if (unlikely(p->used)) {
1482 struct completion wait;
1483 init_completion(&wait);
1484 p->unregistering = &wait;
1485 spin_unlock(&sysctl_lock);
1486 wait_for_completion(&wait);
1487 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001488 } else {
1489 /* anything non-NULL; we'll never dereference it */
1490 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001491 }
1492 /*
1493 * do not remove from the list until nobody holds it; walking the
1494 * list in do_sysctl() relies on that.
1495 */
1496 list_del_init(&p->ctl_entry);
1497}
1498
Al Virof7e6ced2008-07-15 01:44:23 -04001499void sysctl_head_get(struct ctl_table_header *head)
1500{
1501 spin_lock(&sysctl_lock);
1502 head->count++;
1503 spin_unlock(&sysctl_lock);
1504}
1505
1506void sysctl_head_put(struct ctl_table_header *head)
1507{
1508 spin_lock(&sysctl_lock);
1509 if (!--head->count)
1510 kfree(head);
1511 spin_unlock(&sysctl_lock);
1512}
1513
1514struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1515{
1516 if (!head)
1517 BUG();
1518 spin_lock(&sysctl_lock);
1519 if (!use_table(head))
1520 head = ERR_PTR(-ENOENT);
1521 spin_unlock(&sysctl_lock);
1522 return head;
1523}
1524
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001525void sysctl_head_finish(struct ctl_table_header *head)
1526{
1527 if (!head)
1528 return;
1529 spin_lock(&sysctl_lock);
1530 unuse_table(head);
1531 spin_unlock(&sysctl_lock);
1532}
1533
Al Viro73455092008-07-14 21:22:20 -04001534static struct ctl_table_set *
1535lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1536{
1537 struct ctl_table_set *set = &root->default_set;
1538 if (root->lookup)
1539 set = root->lookup(root, namespaces);
1540 return set;
1541}
1542
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001543static struct list_head *
1544lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001545{
Al Viro73455092008-07-14 21:22:20 -04001546 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1547 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001548}
1549
1550struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1551 struct ctl_table_header *prev)
1552{
1553 struct ctl_table_root *root;
1554 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001555 struct ctl_table_header *head;
1556 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001557
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001558 spin_lock(&sysctl_lock);
1559 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001560 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001561 tmp = &prev->ctl_entry;
1562 unuse_table(prev);
1563 goto next;
1564 }
1565 tmp = &root_table_header.ctl_entry;
1566 for (;;) {
1567 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1568
1569 if (!use_table(head))
1570 goto next;
1571 spin_unlock(&sysctl_lock);
1572 return head;
1573 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001574 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001575 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001576 header_list = lookup_header_list(root, namespaces);
1577 if (tmp != header_list)
1578 continue;
1579
1580 do {
1581 root = list_entry(root->root_list.next,
1582 struct ctl_table_root, root_list);
1583 if (root == &sysctl_table_root)
1584 goto out;
1585 header_list = lookup_header_list(root, namespaces);
1586 } while (list_empty(header_list));
1587 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001588 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001589out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001590 spin_unlock(&sysctl_lock);
1591 return NULL;
1592}
1593
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001594struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1595{
1596 return __sysctl_head_next(current->nsproxy, prev);
1597}
1598
1599void register_sysctl_root(struct ctl_table_root *root)
1600{
1601 spin_lock(&sysctl_lock);
1602 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1603 spin_unlock(&sysctl_lock);
1604}
1605
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001606#ifdef CONFIG_SYSCTL_SYSCALL
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001607/* Perform the actual read/write of a sysctl table entry. */
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001608static int do_sysctl_strategy(struct ctl_table_root *root,
1609 struct ctl_table *table,
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001610 void __user *oldval, size_t __user *oldlenp,
1611 void __user *newval, size_t newlen)
1612{
1613 int op = 0, rc;
1614
1615 if (oldval)
Al Viroe6305c42008-07-15 21:03:57 -04001616 op |= MAY_READ;
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001617 if (newval)
Al Viroe6305c42008-07-15 21:03:57 -04001618 op |= MAY_WRITE;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001619 if (sysctl_perm(root, table, op))
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001620 return -EPERM;
1621
1622 if (table->strategy) {
Alexey Dobriyanf221e722008-10-15 22:04:23 -07001623 rc = table->strategy(table, oldval, oldlenp, newval, newlen);
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001624 if (rc < 0)
1625 return rc;
1626 if (rc > 0)
1627 return 0;
1628 }
1629
1630 /* If there is no strategy routine, or if the strategy returns
1631 * zero, proceed with automatic r/w */
1632 if (table->data && table->maxlen) {
Alexey Dobriyanf221e722008-10-15 22:04:23 -07001633 rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001634 if (rc < 0)
1635 return rc;
1636 }
1637 return 0;
1638}
1639
1640static int parse_table(int __user *name, int nlen,
1641 void __user *oldval, size_t __user *oldlenp,
1642 void __user *newval, size_t newlen,
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001643 struct ctl_table_root *root,
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001644 struct ctl_table *table)
1645{
1646 int n;
1647repeat:
1648 if (!nlen)
1649 return -ENOTDIR;
1650 if (get_user(n, name))
1651 return -EFAULT;
1652 for ( ; table->ctl_name || table->procname; table++) {
1653 if (!table->ctl_name)
1654 continue;
1655 if (n == table->ctl_name) {
1656 int error;
1657 if (table->child) {
Al Viroe6305c42008-07-15 21:03:57 -04001658 if (sysctl_perm(root, table, MAY_EXEC))
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001659 return -EPERM;
1660 name++;
1661 nlen--;
1662 table = table->child;
1663 goto repeat;
1664 }
Alexey Dobriyanf221e722008-10-15 22:04:23 -07001665 error = do_sysctl_strategy(root, table,
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001666 oldval, oldlenp,
1667 newval, newlen);
1668 return error;
1669 }
1670 }
1671 return -ENOTDIR;
1672}
1673
Linus Torvalds1da177e2005-04-16 15:20:36 -07001674int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1675 void __user *newval, size_t newlen)
1676{
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001677 struct ctl_table_header *head;
Al Viro330d57f2005-11-04 10:18:40 +00001678 int error = -ENOTDIR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001679
1680 if (nlen <= 0 || nlen >= CTL_MAXNAME)
1681 return -ENOTDIR;
1682 if (oldval) {
1683 int old_len;
1684 if (!oldlenp || get_user(old_len, oldlenp))
1685 return -EFAULT;
1686 }
Al Viro330d57f2005-11-04 10:18:40 +00001687
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001688 for (head = sysctl_head_next(NULL); head;
1689 head = sysctl_head_next(head)) {
Al Viro330d57f2005-11-04 10:18:40 +00001690 error = parse_table(name, nlen, oldval, oldlenp,
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001691 newval, newlen,
1692 head->root, head->ctl_table);
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001693 if (error != -ENOTDIR) {
1694 sysctl_head_finish(head);
Al Viro330d57f2005-11-04 10:18:40 +00001695 break;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001696 }
1697 }
Al Viro330d57f2005-11-04 10:18:40 +00001698 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001699}
1700
Heiko Carstens1e7bfb22009-01-14 14:14:29 +01001701SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001702{
1703 struct __sysctl_args tmp;
1704 int error;
1705
1706 if (copy_from_user(&tmp, args, sizeof(tmp)))
1707 return -EFAULT;
1708
Eric W. Biederman7058cb02007-10-18 03:05:58 -07001709 error = deprecated_sysctl_warning(&tmp);
1710 if (error)
1711 goto out;
1712
Linus Torvalds1da177e2005-04-16 15:20:36 -07001713 lock_kernel();
1714 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1715 tmp.newval, tmp.newlen);
1716 unlock_kernel();
Eric W. Biederman7058cb02007-10-18 03:05:58 -07001717out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001718 return error;
1719}
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001720#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001721
1722/*
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001723 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001724 * some sysctl variables are readonly even to root.
1725 */
1726
1727static int test_perm(int mode, int op)
1728{
David Howells76aac0e2008-11-14 10:39:12 +11001729 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001730 mode >>= 6;
1731 else if (in_egroup_p(0))
1732 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001733 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001734 return 0;
1735 return -EACCES;
1736}
1737
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001738int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001739{
1740 int error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001741 int mode;
1742
Al Viroe6305c42008-07-15 21:03:57 -04001743 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001744 if (error)
1745 return error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001746
1747 if (root->permissions)
1748 mode = root->permissions(root, current->nsproxy, table);
1749 else
1750 mode = table->mode;
1751
1752 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001753}
1754
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001755static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1756{
1757 for (; table->ctl_name || table->procname; table++) {
1758 table->parent = parent;
1759 if (table->child)
1760 sysctl_set_parent(table, table->child);
1761 }
1762}
1763
1764static __init int sysctl_init(void)
1765{
1766 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001767#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1768 {
1769 int err;
1770 err = sysctl_check_table(current->nsproxy, root_table);
1771 }
1772#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001773 return 0;
1774}
1775
1776core_initcall(sysctl_init);
1777
Al Virobfbcf032008-07-27 06:31:22 +01001778static struct ctl_table *is_branch_in(struct ctl_table *branch,
1779 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001780{
1781 struct ctl_table *p;
1782 const char *s = branch->procname;
1783
1784 /* branch should have named subdirectory as its first element */
1785 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001786 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001787
1788 /* ... and nothing else */
1789 if (branch[1].procname || branch[1].ctl_name)
Al Virobfbcf032008-07-27 06:31:22 +01001790 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001791
1792 /* table should contain subdirectory with the same name */
1793 for (p = table; p->procname || p->ctl_name; p++) {
1794 if (!p->child)
1795 continue;
1796 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001797 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001798 }
Al Virobfbcf032008-07-27 06:31:22 +01001799 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001800}
1801
1802/* see if attaching q to p would be an improvement */
1803static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1804{
1805 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001806 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001807 int is_better = 0;
1808 int not_in_parent = !p->attached_by;
1809
Al Virobfbcf032008-07-27 06:31:22 +01001810 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001811 if (by == q->attached_by)
1812 is_better = 1;
1813 if (to == p->attached_by)
1814 not_in_parent = 1;
1815 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001816 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001817 }
1818
1819 if (is_better && not_in_parent) {
1820 q->attached_by = by;
1821 q->attached_to = to;
1822 q->parent = p;
1823 }
1824}
1825
Linus Torvalds1da177e2005-04-16 15:20:36 -07001826/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001827 * __register_sysctl_paths - register a sysctl hierarchy
1828 * @root: List of sysctl headers to register on
1829 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001830 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001831 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001832 *
1833 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001834 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001835 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001836 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001837 *
1838 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1839 * must be unique within that level of sysctl
1840 *
1841 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1842 * enter a sysctl file
1843 *
1844 * data - a pointer to data for use by proc_handler
1845 *
1846 * maxlen - the maximum size in bytes of the data
1847 *
1848 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1849 *
1850 * child - a pointer to the child sysctl table if this entry is a directory, or
1851 * %NULL.
1852 *
1853 * proc_handler - the text handler routine (described below)
1854 *
1855 * strategy - the strategy routine (described below)
1856 *
1857 * de - for internal use by the sysctl routines
1858 *
1859 * extra1, extra2 - extra pointers usable by the proc handler routines
1860 *
1861 * Leaf nodes in the sysctl tree will be represented by a single file
1862 * under /proc; non-leaf nodes will be represented by directories.
1863 *
1864 * sysctl(2) can automatically manage read and write requests through
1865 * the sysctl table. The data and maxlen fields of the ctl_table
1866 * struct enable minimal validation of the values being written to be
1867 * performed, and the mode field allows minimal authentication.
1868 *
1869 * More sophisticated management can be enabled by the provision of a
1870 * strategy routine with the table entry. This will be called before
1871 * any automatic read or write of the data is performed.
1872 *
1873 * The strategy routine may return
1874 *
1875 * < 0 - Error occurred (error is passed to user process)
1876 *
1877 * 0 - OK - proceed with automatic read or write.
1878 *
1879 * > 0 - OK - read or write has been done by the strategy routine, so
1880 * return immediately.
1881 *
1882 * There must be a proc_handler routine for any terminal nodes
1883 * mirrored under /proc/sys (non-terminals are handled by a built-in
1884 * directory handler). Several default handlers are available to
1885 * cover common cases -
1886 *
1887 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1888 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1889 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1890 *
1891 * It is the handler's job to read the input buffer from user memory
1892 * and process it. The handler should return 0 on success.
1893 *
1894 * This routine returns %NULL on a failure to register, and a pointer
1895 * to the table header on success.
1896 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001897struct ctl_table_header *__register_sysctl_paths(
1898 struct ctl_table_root *root,
1899 struct nsproxy *namespaces,
1900 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001901{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001902 struct ctl_table_header *header;
1903 struct ctl_table *new, **prevp;
1904 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001905 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001906
1907 /* Count the path components */
1908 for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
1909 ;
1910
1911 /*
1912 * For each path component, allocate a 2-element ctl_table array.
1913 * The first array element will be filled with the sysctl entry
1914 * for this, the second will be the sentinel (ctl_name == 0).
1915 *
1916 * We allocate everything in one go so that we don't have to
1917 * worry about freeing additional memory in unregister_sysctl_table.
1918 */
1919 header = kzalloc(sizeof(struct ctl_table_header) +
1920 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1921 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001922 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001923
1924 new = (struct ctl_table *) (header + 1);
1925
1926 /* Now connect the dots */
1927 prevp = &header->ctl_table;
1928 for (n = 0; n < npath; ++n, ++path) {
1929 /* Copy the procname */
1930 new->procname = path->procname;
1931 new->ctl_name = path->ctl_name;
1932 new->mode = 0555;
1933
1934 *prevp = new;
1935 prevp = &new->child;
1936
1937 new += 2;
1938 }
1939 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001940 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001941
1942 INIT_LIST_HEAD(&header->ctl_entry);
1943 header->used = 0;
1944 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001945 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001946 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001947 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001948#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001949 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001950 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001951 return NULL;
1952 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001953#endif
Al Viro330d57f2005-11-04 10:18:40 +00001954 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001955 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001956 header->attached_by = header->ctl_table;
1957 header->attached_to = root_table;
1958 header->parent = &root_table_header;
1959 for (set = header->set; set; set = set->parent) {
1960 struct ctl_table_header *p;
1961 list_for_each_entry(p, &set->list, ctl_entry) {
1962 if (p->unregistering)
1963 continue;
1964 try_attach(p, header);
1965 }
1966 }
1967 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001968 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001969 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001970
1971 return header;
1972}
1973
1974/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001975 * register_sysctl_table_path - register a sysctl table hierarchy
1976 * @path: The path to the directory the sysctl table is in.
1977 * @table: the top-level table structure
1978 *
1979 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1980 * array. A completely 0 filled entry terminates the table.
1981 *
1982 * See __register_sysctl_paths for more details.
1983 */
1984struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1985 struct ctl_table *table)
1986{
1987 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1988 path, table);
1989}
1990
1991/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001992 * register_sysctl_table - register a sysctl table hierarchy
1993 * @table: the top-level table structure
1994 *
1995 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1996 * array. A completely 0 filled entry terminates the table.
1997 *
1998 * See register_sysctl_paths for more details.
1999 */
2000struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
2001{
2002 static const struct ctl_path null_path[] = { {} };
2003
2004 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002005}
2006
2007/**
2008 * unregister_sysctl_table - unregister a sysctl table hierarchy
2009 * @header: the header returned from register_sysctl_table
2010 *
2011 * Unregisters the sysctl table and all children. proc entries may not
2012 * actually be removed until they are no longer used by anyone.
2013 */
2014void unregister_sysctl_table(struct ctl_table_header * header)
2015{
Al Viro330d57f2005-11-04 10:18:40 +00002016 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08002017
2018 if (header == NULL)
2019 return;
2020
Al Viro330d57f2005-11-04 10:18:40 +00002021 spin_lock(&sysctl_lock);
2022 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04002023 if (!--header->parent->count) {
2024 WARN_ON(1);
2025 kfree(header->parent);
2026 }
Al Virof7e6ced2008-07-15 01:44:23 -04002027 if (!--header->count)
2028 kfree(header);
Al Viro330d57f2005-11-04 10:18:40 +00002029 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002030}
2031
Al Viro9043476f2008-07-15 08:54:06 -04002032int sysctl_is_seen(struct ctl_table_header *p)
2033{
2034 struct ctl_table_set *set = p->set;
2035 int res;
2036 spin_lock(&sysctl_lock);
2037 if (p->unregistering)
2038 res = 0;
2039 else if (!set->is_seen)
2040 res = 1;
2041 else
2042 res = set->is_seen(set);
2043 spin_unlock(&sysctl_lock);
2044 return res;
2045}
2046
Al Viro73455092008-07-14 21:22:20 -04002047void setup_sysctl_set(struct ctl_table_set *p,
2048 struct ctl_table_set *parent,
2049 int (*is_seen)(struct ctl_table_set *))
2050{
2051 INIT_LIST_HEAD(&p->list);
2052 p->parent = parent ? parent : &sysctl_table_root.default_set;
2053 p->is_seen = is_seen;
2054}
2055
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002056#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002057struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002058{
2059 return NULL;
2060}
2061
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002062struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2063 struct ctl_table *table)
2064{
2065 return NULL;
2066}
2067
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002068void unregister_sysctl_table(struct ctl_table_header * table)
2069{
2070}
2071
Al Viro73455092008-07-14 21:22:20 -04002072void setup_sysctl_set(struct ctl_table_set *p,
2073 struct ctl_table_set *parent,
2074 int (*is_seen)(struct ctl_table_set *))
2075{
2076}
2077
Al Virof7e6ced2008-07-15 01:44:23 -04002078void sysctl_head_put(struct ctl_table_header *head)
2079{
2080}
2081
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002082#endif /* CONFIG_SYSCTL */
2083
Linus Torvalds1da177e2005-04-16 15:20:36 -07002084/*
2085 * /proc/sys support
2086 */
2087
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002088#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002089
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002090static int _proc_do_string(void* data, int maxlen, int write,
2091 struct file *filp, void __user *buffer,
2092 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002093{
2094 size_t len;
2095 char __user *p;
2096 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002097
2098 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002099 *lenp = 0;
2100 return 0;
2101 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002102
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002103 if (write) {
2104 len = 0;
2105 p = buffer;
2106 while (len < *lenp) {
2107 if (get_user(c, p++))
2108 return -EFAULT;
2109 if (c == 0 || c == '\n')
2110 break;
2111 len++;
2112 }
2113 if (len >= maxlen)
2114 len = maxlen-1;
2115 if(copy_from_user(data, buffer, len))
2116 return -EFAULT;
2117 ((char *) data)[len] = 0;
2118 *ppos += *lenp;
2119 } else {
2120 len = strlen(data);
2121 if (len > maxlen)
2122 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002123
2124 if (*ppos > len) {
2125 *lenp = 0;
2126 return 0;
2127 }
2128
2129 data += *ppos;
2130 len -= *ppos;
2131
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002132 if (len > *lenp)
2133 len = *lenp;
2134 if (len)
2135 if(copy_to_user(buffer, data, len))
2136 return -EFAULT;
2137 if (len < *lenp) {
2138 if(put_user('\n', ((char __user *) buffer) + len))
2139 return -EFAULT;
2140 len++;
2141 }
2142 *lenp = len;
2143 *ppos += len;
2144 }
2145 return 0;
2146}
2147
Linus Torvalds1da177e2005-04-16 15:20:36 -07002148/**
2149 * proc_dostring - read a string sysctl
2150 * @table: the sysctl table
2151 * @write: %TRUE if this is a write to the sysctl file
2152 * @filp: the file structure
2153 * @buffer: the user buffer
2154 * @lenp: the size of the user buffer
2155 * @ppos: file position
2156 *
2157 * Reads/writes a string from/to the user buffer. If the kernel
2158 * buffer provided is not large enough to hold the string, the
2159 * string is truncated. The copied string is %NULL-terminated.
2160 * If the string is being read by the user process, it is copied
2161 * and a newline '\n' is added. It is truncated if the buffer is
2162 * not large enough.
2163 *
2164 * Returns 0 on success.
2165 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002166int proc_dostring(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002167 void __user *buffer, size_t *lenp, loff_t *ppos)
2168{
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002169 return _proc_do_string(table->data, table->maxlen, write, filp,
2170 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002171}
2172
Linus Torvalds1da177e2005-04-16 15:20:36 -07002173
2174static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2175 int *valp,
2176 int write, void *data)
2177{
2178 if (write) {
2179 *valp = *negp ? -*lvalp : *lvalp;
2180 } else {
2181 int val = *valp;
2182 if (val < 0) {
2183 *negp = -1;
2184 *lvalp = (unsigned long)-val;
2185 } else {
2186 *negp = 0;
2187 *lvalp = (unsigned long)val;
2188 }
2189 }
2190 return 0;
2191}
2192
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002193static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002194 int write, struct file *filp, void __user *buffer,
2195 size_t *lenp, loff_t *ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002196 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2197 int write, void *data),
2198 void *data)
2199{
2200#define TMPBUFLEN 21
2201 int *i, vleft, first=1, neg, val;
2202 unsigned long lval;
2203 size_t left, len;
2204
2205 char buf[TMPBUFLEN], *p;
2206 char __user *s = buffer;
2207
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002208 if (!tbl_data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002209 (*ppos && !write)) {
2210 *lenp = 0;
2211 return 0;
2212 }
2213
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002214 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002215 vleft = table->maxlen / sizeof(*i);
2216 left = *lenp;
2217
2218 if (!conv)
2219 conv = do_proc_dointvec_conv;
2220
2221 for (; left && vleft--; i++, first=0) {
2222 if (write) {
2223 while (left) {
2224 char c;
2225 if (get_user(c, s))
2226 return -EFAULT;
2227 if (!isspace(c))
2228 break;
2229 left--;
2230 s++;
2231 }
2232 if (!left)
2233 break;
2234 neg = 0;
2235 len = left;
2236 if (len > sizeof(buf) - 1)
2237 len = sizeof(buf) - 1;
2238 if (copy_from_user(buf, s, len))
2239 return -EFAULT;
2240 buf[len] = 0;
2241 p = buf;
2242 if (*p == '-' && left > 1) {
2243 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002244 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002245 }
2246 if (*p < '0' || *p > '9')
2247 break;
2248
2249 lval = simple_strtoul(p, &p, 0);
2250
2251 len = p-buf;
2252 if ((len < left) && *p && !isspace(*p))
2253 break;
2254 if (neg)
2255 val = -val;
2256 s += len;
2257 left -= len;
2258
2259 if (conv(&neg, &lval, i, 1, data))
2260 break;
2261 } else {
2262 p = buf;
2263 if (!first)
2264 *p++ = '\t';
2265
2266 if (conv(&neg, &lval, i, 0, data))
2267 break;
2268
2269 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2270 len = strlen(buf);
2271 if (len > left)
2272 len = left;
2273 if(copy_to_user(s, buf, len))
2274 return -EFAULT;
2275 left -= len;
2276 s += len;
2277 }
2278 }
2279
2280 if (!write && !first && left) {
2281 if(put_user('\n', s))
2282 return -EFAULT;
2283 left--, s++;
2284 }
2285 if (write) {
2286 while (left) {
2287 char c;
2288 if (get_user(c, s++))
2289 return -EFAULT;
2290 if (!isspace(c))
2291 break;
2292 left--;
2293 }
2294 }
2295 if (write && first)
2296 return -EINVAL;
2297 *lenp -= left;
2298 *ppos += *lenp;
2299 return 0;
2300#undef TMPBUFLEN
2301}
2302
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002303static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002304 void __user *buffer, size_t *lenp, loff_t *ppos,
2305 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2306 int write, void *data),
2307 void *data)
2308{
2309 return __do_proc_dointvec(table->data, table, write, filp,
2310 buffer, lenp, ppos, conv, data);
2311}
2312
Linus Torvalds1da177e2005-04-16 15:20:36 -07002313/**
2314 * proc_dointvec - read a vector of integers
2315 * @table: the sysctl table
2316 * @write: %TRUE if this is a write to the sysctl file
2317 * @filp: the file structure
2318 * @buffer: the user buffer
2319 * @lenp: the size of the user buffer
2320 * @ppos: file position
2321 *
2322 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2323 * values from/to the user buffer, treated as an ASCII string.
2324 *
2325 * Returns 0 on success.
2326 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002327int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002328 void __user *buffer, size_t *lenp, loff_t *ppos)
2329{
2330 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2331 NULL,NULL);
2332}
2333
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002334/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002335 * Taint values can only be increased
2336 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002337 */
Andi Kleen25ddbb12008-10-15 22:01:41 -07002338static int proc_taint(struct ctl_table *table, int write, struct file *filp,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002339 void __user *buffer, size_t *lenp, loff_t *ppos)
2340{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002341 struct ctl_table t;
2342 unsigned long tmptaint = get_taint();
2343 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002344
Bastian Blank91fcd412007-04-23 14:41:14 -07002345 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002346 return -EPERM;
2347
Andi Kleen25ddbb12008-10-15 22:01:41 -07002348 t = *table;
2349 t.data = &tmptaint;
2350 err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos);
2351 if (err < 0)
2352 return err;
2353
2354 if (write) {
2355 /*
2356 * Poor man's atomic or. Not worth adding a primitive
2357 * to everyone's atomic.h for this
2358 */
2359 int i;
2360 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2361 if ((tmptaint >> i) & 1)
2362 add_taint(i);
2363 }
2364 }
2365
2366 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002367}
2368
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369struct do_proc_dointvec_minmax_conv_param {
2370 int *min;
2371 int *max;
2372};
2373
2374static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2375 int *valp,
2376 int write, void *data)
2377{
2378 struct do_proc_dointvec_minmax_conv_param *param = data;
2379 if (write) {
2380 int val = *negp ? -*lvalp : *lvalp;
2381 if ((param->min && *param->min > val) ||
2382 (param->max && *param->max < val))
2383 return -EINVAL;
2384 *valp = val;
2385 } else {
2386 int val = *valp;
2387 if (val < 0) {
2388 *negp = -1;
2389 *lvalp = (unsigned long)-val;
2390 } else {
2391 *negp = 0;
2392 *lvalp = (unsigned long)val;
2393 }
2394 }
2395 return 0;
2396}
2397
2398/**
2399 * proc_dointvec_minmax - read a vector of integers with min/max values
2400 * @table: the sysctl table
2401 * @write: %TRUE if this is a write to the sysctl file
2402 * @filp: the file structure
2403 * @buffer: the user buffer
2404 * @lenp: the size of the user buffer
2405 * @ppos: file position
2406 *
2407 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2408 * values from/to the user buffer, treated as an ASCII string.
2409 *
2410 * This routine will ensure the values are within the range specified by
2411 * table->extra1 (min) and table->extra2 (max).
2412 *
2413 * Returns 0 on success.
2414 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002415int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002416 void __user *buffer, size_t *lenp, loff_t *ppos)
2417{
2418 struct do_proc_dointvec_minmax_conv_param param = {
2419 .min = (int *) table->extra1,
2420 .max = (int *) table->extra2,
2421 };
2422 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2423 do_proc_dointvec_minmax_conv, &param);
2424}
2425
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002426static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002427 struct file *filp,
2428 void __user *buffer,
2429 size_t *lenp, loff_t *ppos,
2430 unsigned long convmul,
2431 unsigned long convdiv)
2432{
2433#define TMPBUFLEN 21
2434 unsigned long *i, *min, *max, val;
2435 int vleft, first=1, neg;
2436 size_t len, left;
2437 char buf[TMPBUFLEN], *p;
2438 char __user *s = buffer;
2439
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002440 if (!data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002441 (*ppos && !write)) {
2442 *lenp = 0;
2443 return 0;
2444 }
2445
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002446 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002447 min = (unsigned long *) table->extra1;
2448 max = (unsigned long *) table->extra2;
2449 vleft = table->maxlen / sizeof(unsigned long);
2450 left = *lenp;
2451
2452 for (; left && vleft--; i++, min++, max++, first=0) {
2453 if (write) {
2454 while (left) {
2455 char c;
2456 if (get_user(c, s))
2457 return -EFAULT;
2458 if (!isspace(c))
2459 break;
2460 left--;
2461 s++;
2462 }
2463 if (!left)
2464 break;
2465 neg = 0;
2466 len = left;
2467 if (len > TMPBUFLEN-1)
2468 len = TMPBUFLEN-1;
2469 if (copy_from_user(buf, s, len))
2470 return -EFAULT;
2471 buf[len] = 0;
2472 p = buf;
2473 if (*p == '-' && left > 1) {
2474 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002475 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002476 }
2477 if (*p < '0' || *p > '9')
2478 break;
2479 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2480 len = p-buf;
2481 if ((len < left) && *p && !isspace(*p))
2482 break;
2483 if (neg)
2484 val = -val;
2485 s += len;
2486 left -= len;
2487
2488 if(neg)
2489 continue;
2490 if ((min && val < *min) || (max && val > *max))
2491 continue;
2492 *i = val;
2493 } else {
2494 p = buf;
2495 if (!first)
2496 *p++ = '\t';
2497 sprintf(p, "%lu", convdiv * (*i) / convmul);
2498 len = strlen(buf);
2499 if (len > left)
2500 len = left;
2501 if(copy_to_user(s, buf, len))
2502 return -EFAULT;
2503 left -= len;
2504 s += len;
2505 }
2506 }
2507
2508 if (!write && !first && left) {
2509 if(put_user('\n', s))
2510 return -EFAULT;
2511 left--, s++;
2512 }
2513 if (write) {
2514 while (left) {
2515 char c;
2516 if (get_user(c, s++))
2517 return -EFAULT;
2518 if (!isspace(c))
2519 break;
2520 left--;
2521 }
2522 }
2523 if (write && first)
2524 return -EINVAL;
2525 *lenp -= left;
2526 *ppos += *lenp;
2527 return 0;
2528#undef TMPBUFLEN
2529}
2530
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002531static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002532 struct file *filp,
2533 void __user *buffer,
2534 size_t *lenp, loff_t *ppos,
2535 unsigned long convmul,
2536 unsigned long convdiv)
2537{
2538 return __do_proc_doulongvec_minmax(table->data, table, write,
2539 filp, buffer, lenp, ppos, convmul, convdiv);
2540}
2541
Linus Torvalds1da177e2005-04-16 15:20:36 -07002542/**
2543 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2544 * @table: the sysctl table
2545 * @write: %TRUE if this is a write to the sysctl file
2546 * @filp: the file structure
2547 * @buffer: the user buffer
2548 * @lenp: the size of the user buffer
2549 * @ppos: file position
2550 *
2551 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2552 * values from/to the user buffer, treated as an ASCII string.
2553 *
2554 * This routine will ensure the values are within the range specified by
2555 * table->extra1 (min) and table->extra2 (max).
2556 *
2557 * Returns 0 on success.
2558 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002559int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002560 void __user *buffer, size_t *lenp, loff_t *ppos)
2561{
2562 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
2563}
2564
2565/**
2566 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2567 * @table: the sysctl table
2568 * @write: %TRUE if this is a write to the sysctl file
2569 * @filp: the file structure
2570 * @buffer: the user buffer
2571 * @lenp: the size of the user buffer
2572 * @ppos: file position
2573 *
2574 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2575 * values from/to the user buffer, treated as an ASCII string. The values
2576 * are treated as milliseconds, and converted to jiffies when they are stored.
2577 *
2578 * This routine will ensure the values are within the range specified by
2579 * table->extra1 (min) and table->extra2 (max).
2580 *
2581 * Returns 0 on success.
2582 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002583int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002584 struct file *filp,
2585 void __user *buffer,
2586 size_t *lenp, loff_t *ppos)
2587{
2588 return do_proc_doulongvec_minmax(table, write, filp, buffer,
2589 lenp, ppos, HZ, 1000l);
2590}
2591
2592
2593static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2594 int *valp,
2595 int write, void *data)
2596{
2597 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002598 if (*lvalp > LONG_MAX / HZ)
2599 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002600 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2601 } else {
2602 int val = *valp;
2603 unsigned long lval;
2604 if (val < 0) {
2605 *negp = -1;
2606 lval = (unsigned long)-val;
2607 } else {
2608 *negp = 0;
2609 lval = (unsigned long)val;
2610 }
2611 *lvalp = lval / HZ;
2612 }
2613 return 0;
2614}
2615
2616static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2617 int *valp,
2618 int write, void *data)
2619{
2620 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002621 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2622 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002623 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2624 } else {
2625 int val = *valp;
2626 unsigned long lval;
2627 if (val < 0) {
2628 *negp = -1;
2629 lval = (unsigned long)-val;
2630 } else {
2631 *negp = 0;
2632 lval = (unsigned long)val;
2633 }
2634 *lvalp = jiffies_to_clock_t(lval);
2635 }
2636 return 0;
2637}
2638
2639static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2640 int *valp,
2641 int write, void *data)
2642{
2643 if (write) {
2644 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2645 } else {
2646 int val = *valp;
2647 unsigned long lval;
2648 if (val < 0) {
2649 *negp = -1;
2650 lval = (unsigned long)-val;
2651 } else {
2652 *negp = 0;
2653 lval = (unsigned long)val;
2654 }
2655 *lvalp = jiffies_to_msecs(lval);
2656 }
2657 return 0;
2658}
2659
2660/**
2661 * proc_dointvec_jiffies - read a vector of integers as seconds
2662 * @table: the sysctl table
2663 * @write: %TRUE if this is a write to the sysctl file
2664 * @filp: the file structure
2665 * @buffer: the user buffer
2666 * @lenp: the size of the user buffer
2667 * @ppos: file position
2668 *
2669 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2670 * values from/to the user buffer, treated as an ASCII string.
2671 * The values read are assumed to be in seconds, and are converted into
2672 * jiffies.
2673 *
2674 * Returns 0 on success.
2675 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002676int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002677 void __user *buffer, size_t *lenp, loff_t *ppos)
2678{
2679 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2680 do_proc_dointvec_jiffies_conv,NULL);
2681}
2682
2683/**
2684 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2685 * @table: the sysctl table
2686 * @write: %TRUE if this is a write to the sysctl file
2687 * @filp: the file structure
2688 * @buffer: the user buffer
2689 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002690 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002691 *
2692 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2693 * values from/to the user buffer, treated as an ASCII string.
2694 * The values read are assumed to be in 1/USER_HZ seconds, and
2695 * are converted into jiffies.
2696 *
2697 * Returns 0 on success.
2698 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002699int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002700 void __user *buffer, size_t *lenp, loff_t *ppos)
2701{
2702 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2703 do_proc_dointvec_userhz_jiffies_conv,NULL);
2704}
2705
2706/**
2707 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2708 * @table: the sysctl table
2709 * @write: %TRUE if this is a write to the sysctl file
2710 * @filp: the file structure
2711 * @buffer: the user buffer
2712 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002713 * @ppos: file position
2714 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002715 *
2716 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2717 * values from/to the user buffer, treated as an ASCII string.
2718 * The values read are assumed to be in 1/1000 seconds, and
2719 * are converted into jiffies.
2720 *
2721 * Returns 0 on success.
2722 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002723int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002724 void __user *buffer, size_t *lenp, loff_t *ppos)
2725{
2726 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2727 do_proc_dointvec_ms_jiffies_conv, NULL);
2728}
2729
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002730static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002731 void __user *buffer, size_t *lenp, loff_t *ppos)
2732{
2733 struct pid *new_pid;
2734 pid_t tmp;
2735 int r;
2736
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002737 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002738
2739 r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
2740 lenp, ppos, NULL, NULL);
2741 if (r || !write)
2742 return r;
2743
2744 new_pid = find_get_pid(tmp);
2745 if (!new_pid)
2746 return -ESRCH;
2747
2748 put_pid(xchg(&cad_pid, new_pid));
2749 return 0;
2750}
2751
Linus Torvalds1da177e2005-04-16 15:20:36 -07002752#else /* CONFIG_PROC_FS */
2753
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002754int proc_dostring(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002755 void __user *buffer, size_t *lenp, loff_t *ppos)
2756{
2757 return -ENOSYS;
2758}
2759
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002760int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002761 void __user *buffer, size_t *lenp, loff_t *ppos)
2762{
2763 return -ENOSYS;
2764}
2765
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002766int proc_dointvec_minmax(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_jiffies(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_userhz_jiffies(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_ms_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_doulongvec_minmax(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_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002797 struct file *filp,
2798 void __user *buffer,
2799 size_t *lenp, loff_t *ppos)
2800{
2801 return -ENOSYS;
2802}
2803
2804
2805#endif /* CONFIG_PROC_FS */
2806
2807
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002808#ifdef CONFIG_SYSCTL_SYSCALL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002809/*
2810 * General sysctl support routines
2811 */
2812
Eric W. Biederman49a0c452007-10-18 03:05:23 -07002813/* The generic sysctl data routine (used if no strategy routine supplied) */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002814int sysctl_data(struct ctl_table *table,
Eric W. Biederman49a0c452007-10-18 03:05:23 -07002815 void __user *oldval, size_t __user *oldlenp,
2816 void __user *newval, size_t newlen)
2817{
2818 size_t len;
2819
2820 /* Get out of I don't have a variable */
2821 if (!table->data || !table->maxlen)
2822 return -ENOTDIR;
2823
2824 if (oldval && oldlenp) {
2825 if (get_user(len, oldlenp))
2826 return -EFAULT;
2827 if (len) {
2828 if (len > table->maxlen)
2829 len = table->maxlen;
2830 if (copy_to_user(oldval, table->data, len))
2831 return -EFAULT;
2832 if (put_user(len, oldlenp))
2833 return -EFAULT;
2834 }
2835 }
2836
2837 if (newval && newlen) {
2838 if (newlen > table->maxlen)
2839 newlen = table->maxlen;
2840
2841 if (copy_from_user(table->data, newval, newlen))
2842 return -EFAULT;
2843 }
2844 return 1;
2845}
2846
Linus Torvalds1da177e2005-04-16 15:20:36 -07002847/* The generic string strategy routine: */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002848int sysctl_string(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002849 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002850 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002851{
Linus Torvalds1da177e2005-04-16 15:20:36 -07002852 if (!table->data || !table->maxlen)
2853 return -ENOTDIR;
2854
2855 if (oldval && oldlenp) {
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002856 size_t bufsize;
2857 if (get_user(bufsize, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002858 return -EFAULT;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002859 if (bufsize) {
2860 size_t len = strlen(table->data), copied;
2861
2862 /* This shouldn't trigger for a well-formed sysctl */
2863 if (len > table->maxlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002864 len = table->maxlen;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002865
2866 /* Copy up to a max of bufsize-1 bytes of the string */
2867 copied = (len >= bufsize) ? bufsize - 1 : len;
2868
2869 if (copy_to_user(oldval, table->data, copied) ||
2870 put_user(0, (char __user *)(oldval + copied)))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002871 return -EFAULT;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002872 if (put_user(len, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002873 return -EFAULT;
2874 }
2875 }
2876 if (newval && newlen) {
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002877 size_t len = newlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002878 if (len > table->maxlen)
2879 len = table->maxlen;
2880 if(copy_from_user(table->data, newval, len))
2881 return -EFAULT;
2882 if (len == table->maxlen)
2883 len--;
2884 ((char *) table->data)[len] = 0;
2885 }
Yi Yang82c9df82005-12-30 16:37:10 +08002886 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002887}
2888
2889/*
2890 * This function makes sure that all of the integers in the vector
2891 * are between the minimum and maximum values given in the arrays
2892 * table->extra1 and table->extra2, respectively.
2893 */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002894int sysctl_intvec(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002895 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002896 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002897{
2898
2899 if (newval && newlen) {
2900 int __user *vec = (int __user *) newval;
2901 int *min = (int *) table->extra1;
2902 int *max = (int *) table->extra2;
2903 size_t length;
2904 int i;
2905
2906 if (newlen % sizeof(int) != 0)
2907 return -EINVAL;
2908
2909 if (!table->extra1 && !table->extra2)
2910 return 0;
2911
2912 if (newlen > table->maxlen)
2913 newlen = table->maxlen;
2914 length = newlen / sizeof(int);
2915
2916 for (i = 0; i < length; i++) {
2917 int value;
2918 if (get_user(value, vec + i))
2919 return -EFAULT;
2920 if (min && value < min[i])
2921 return -EINVAL;
2922 if (max && value > max[i])
2923 return -EINVAL;
2924 }
2925 }
2926 return 0;
2927}
2928
2929/* Strategy function to convert jiffies to seconds */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002930int sysctl_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002931 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002932 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002933{
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002934 if (oldval && oldlenp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002935 size_t olen;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002936
2937 if (get_user(olen, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002938 return -EFAULT;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002939 if (olen) {
2940 int val;
2941
2942 if (olen < sizeof(int))
2943 return -EINVAL;
2944
2945 val = *(int *)(table->data) / HZ;
2946 if (put_user(val, (int __user *)oldval))
2947 return -EFAULT;
2948 if (put_user(sizeof(int), oldlenp))
2949 return -EFAULT;
2950 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002951 }
2952 if (newval && newlen) {
2953 int new;
2954 if (newlen != sizeof(int))
2955 return -EINVAL;
2956 if (get_user(new, (int __user *)newval))
2957 return -EFAULT;
2958 *(int *)(table->data) = new*HZ;
2959 }
2960 return 1;
2961}
2962
2963/* Strategy function to convert jiffies to seconds */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002964int sysctl_ms_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002965 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002966 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002967{
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002968 if (oldval && oldlenp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002969 size_t olen;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002970
2971 if (get_user(olen, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002972 return -EFAULT;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002973 if (olen) {
2974 int val;
2975
2976 if (olen < sizeof(int))
2977 return -EINVAL;
2978
2979 val = jiffies_to_msecs(*(int *)(table->data));
2980 if (put_user(val, (int __user *)oldval))
2981 return -EFAULT;
2982 if (put_user(sizeof(int), oldlenp))
2983 return -EFAULT;
2984 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002985 }
2986 if (newval && newlen) {
2987 int new;
2988 if (newlen != sizeof(int))
2989 return -EINVAL;
2990 if (get_user(new, (int __user *)newval))
2991 return -EFAULT;
2992 *(int *)(table->data) = msecs_to_jiffies(new);
2993 }
2994 return 1;
2995}
2996
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08002997
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08002998
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002999#else /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003000
3001
Heiko Carstens1e7bfb22009-01-14 14:14:29 +01003002SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003003{
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003004 struct __sysctl_args tmp;
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003005 int error;
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003006
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003007 if (copy_from_user(&tmp, args, sizeof(tmp)))
3008 return -EFAULT;
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003009
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003010 error = deprecated_sysctl_warning(&tmp);
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07003011
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003012 /* If no error reading the parameters then just -ENOSYS ... */
3013 if (!error)
3014 error = -ENOSYS;
3015
3016 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003017}
3018
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003019int sysctl_data(struct ctl_table *table,
Eric W. Biederman49a0c452007-10-18 03:05:23 -07003020 void __user *oldval, size_t __user *oldlenp,
3021 void __user *newval, size_t newlen)
3022{
3023 return -ENOSYS;
3024}
3025
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003026int sysctl_string(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003027 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003028 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003029{
3030 return -ENOSYS;
3031}
3032
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003033int sysctl_intvec(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003034 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003035 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003036{
3037 return -ENOSYS;
3038}
3039
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003040int sysctl_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003041 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003042 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003043{
3044 return -ENOSYS;
3045}
3046
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003047int sysctl_ms_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003048 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003049 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003050{
3051 return -ENOSYS;
3052}
3053
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07003054#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003055
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003056static int deprecated_sysctl_warning(struct __sysctl_args *args)
3057{
3058 static int msg_count;
3059 int name[CTL_MAXNAME];
3060 int i;
3061
Tetsuo Handa6fc48af2007-11-14 16:58:38 -08003062 /* Check args->nlen. */
3063 if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
3064 return -ENOTDIR;
3065
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003066 /* Read in the sysctl name for better debug message logging */
3067 for (i = 0; i < args->nlen; i++)
3068 if (get_user(name[i], args->name + i))
3069 return -EFAULT;
3070
3071 /* Ignore accesses to kernel.version */
3072 if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
3073 return 0;
3074
3075 if (msg_count < 5) {
3076 msg_count++;
3077 printk(KERN_INFO
3078 "warning: process `%s' used the deprecated sysctl "
3079 "system call with ", current->comm);
3080 for (i = 0; i < args->nlen; i++)
3081 printk("%d.", name[i]);
3082 printk("\n");
3083 }
3084 return 0;
3085}
3086
Linus Torvalds1da177e2005-04-16 15:20:36 -07003087/*
3088 * No sense putting this after each symbol definition, twice,
3089 * exception granted :-)
3090 */
3091EXPORT_SYMBOL(proc_dointvec);
3092EXPORT_SYMBOL(proc_dointvec_jiffies);
3093EXPORT_SYMBOL(proc_dointvec_minmax);
3094EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3095EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3096EXPORT_SYMBOL(proc_dostring);
3097EXPORT_SYMBOL(proc_doulongvec_minmax);
3098EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3099EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11003100EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003101EXPORT_SYMBOL(sysctl_intvec);
3102EXPORT_SYMBOL(sysctl_jiffies);
3103EXPORT_SYMBOL(sysctl_ms_jiffies);
3104EXPORT_SYMBOL(sysctl_string);
Eric W. Biederman49a0c452007-10-18 03:05:23 -07003105EXPORT_SYMBOL(sysctl_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003106EXPORT_SYMBOL(unregister_sysctl_table);