blob: 2481ed30d2b5097e63b5c34aea381f1722726106 [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 Gondwana195cf452008-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;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700104static int one_hundred = 100;
105
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
107static int maxolduid = 65535;
108static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800109static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110
111static int ngroups_max = NGROUPS_MAX;
112
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200113#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114extern char modprobe_path[];
115#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116#ifdef CONFIG_CHR_DEV_SG
117extern int sg_big_buff;
118#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119
David S. Miller72c57ed2008-09-11 23:29:54 -0700120#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700121#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122#endif
123
David S. Miller08714202008-11-16 23:49:24 -0800124#ifdef CONFIG_SPARC64
125extern int sysctl_tsb_ratio;
126#endif
127
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128#ifdef __hppa__
129extern int pwrsw_enabled;
130extern int unaligned_enabled;
131#endif
132
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800133#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700134#ifdef CONFIG_MATHEMU
135extern int sysctl_ieee_emulation_warnings;
136#endif
137extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700138extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139#endif
140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141#ifdef CONFIG_BSD_PROCESS_ACCT
142extern int acct_parm[];
143#endif
144
Jes Sorensend2b176e2006-02-28 09:42:23 -0800145#ifdef CONFIG_IA64
146extern int no_unaligned_warning;
147#endif
148
Ingo Molnar23f78d42006-06-27 02:54:53 -0700149#ifdef CONFIG_RT_MUTEXES
150extern int max_lock_depth;
151#endif
152
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700153#ifdef CONFIG_PROC_SYSCTL
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700154static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700155 void __user *buffer, size_t *lenp, loff_t *ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -0700156static int proc_taint(struct ctl_table *table, int write, struct file *filp,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800157 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700158#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700159
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700160static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100161static struct ctl_table_root sysctl_table_root;
162static struct ctl_table_header root_table_header = {
Al Virob380b0d2008-09-04 17:05:57 +0100163 .count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100164 .ctl_table = root_table,
Al Viro73455092008-07-14 21:22:20 -0400165 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100166 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400167 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100168};
169static struct ctl_table_root sysctl_table_root = {
170 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400171 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100172};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700174static struct ctl_table kern_table[];
175static struct ctl_table vm_table[];
176static struct ctl_table fs_table[];
177static struct ctl_table debug_table[];
178static struct ctl_table dev_table[];
179extern struct ctl_table random_table[];
Amy Griffis2d9048e2006-06-01 13:10:59 -0700180#ifdef CONFIG_INOTIFY_USER
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700181extern struct ctl_table inotify_table[];
Robert Love0399cb02005-07-13 12:38:18 -0400182#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -0800183#ifdef CONFIG_EPOLL
184extern struct ctl_table epoll_table[];
185#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186
187#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
188int sysctl_legacy_va_layout;
189#endif
190
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700191extern int prove_locking;
192extern int lock_stat;
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800193
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194/* The default sysctl tables: */
195
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700196static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 {
198 .ctl_name = CTL_KERN,
199 .procname = "kernel",
200 .mode = 0555,
201 .child = kern_table,
202 },
203 {
204 .ctl_name = CTL_VM,
205 .procname = "vm",
206 .mode = 0555,
207 .child = vm_table,
208 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 .ctl_name = CTL_FS,
211 .procname = "fs",
212 .mode = 0555,
213 .child = fs_table,
214 },
215 {
216 .ctl_name = CTL_DEBUG,
217 .procname = "debug",
218 .mode = 0555,
219 .child = debug_table,
220 },
221 {
222 .ctl_name = CTL_DEV,
223 .procname = "dev",
224 .mode = 0555,
225 .child = dev_table,
226 },
Andrew Morton2be7fe02007-07-15 23:41:21 -0700227/*
228 * NOTE: do not add new entries to this table unless you have read
229 * Documentation/sysctl/ctl_unnumbered.txt
230 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 { .ctl_name = 0 }
232};
233
Ingo Molnar77e54a12007-07-09 18:52:00 +0200234#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100235static int min_sched_granularity_ns = 100000; /* 100 usecs */
236static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
237static int min_wakeup_granularity_ns; /* 0 usecs */
238static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200239#endif
240
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700241static struct ctl_table kern_table[] = {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200242#ifdef CONFIG_SCHED_DEBUG
243 {
244 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100245 .procname = "sched_min_granularity_ns",
246 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200247 .maxlen = sizeof(unsigned int),
248 .mode = 0644,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100249 .proc_handler = &sched_nr_latency_handler,
250 .strategy = &sysctl_intvec,
251 .extra1 = &min_sched_granularity_ns,
252 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200253 },
254 {
255 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra21805082007-08-25 18:41:53 +0200256 .procname = "sched_latency_ns",
257 .data = &sysctl_sched_latency,
258 .maxlen = sizeof(unsigned int),
259 .mode = 0644,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100260 .proc_handler = &sched_nr_latency_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200261 .strategy = &sysctl_intvec,
262 .extra1 = &min_sched_granularity_ns,
263 .extra2 = &max_sched_granularity_ns,
264 },
265 {
266 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200267 .procname = "sched_wakeup_granularity_ns",
268 .data = &sysctl_sched_wakeup_granularity,
269 .maxlen = sizeof(unsigned int),
270 .mode = 0644,
271 .proc_handler = &proc_dointvec_minmax,
272 .strategy = &sysctl_intvec,
273 .extra1 = &min_wakeup_granularity_ns,
274 .extra2 = &max_wakeup_granularity_ns,
275 },
276 {
277 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200278 .procname = "sched_shares_ratelimit",
279 .data = &sysctl_sched_shares_ratelimit,
280 .maxlen = sizeof(unsigned int),
281 .mode = 0644,
282 .proc_handler = &proc_dointvec,
283 },
284 {
285 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200286 .procname = "sched_shares_thresh",
287 .data = &sysctl_sched_shares_thresh,
288 .maxlen = sizeof(unsigned int),
289 .mode = 0644,
290 .proc_handler = &proc_dointvec_minmax,
291 .strategy = &sysctl_intvec,
292 .extra1 = &zero,
293 },
294 {
295 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200296 .procname = "sched_child_runs_first",
297 .data = &sysctl_sched_child_runs_first,
298 .maxlen = sizeof(unsigned int),
299 .mode = 0644,
300 .proc_handler = &proc_dointvec,
301 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200302 {
303 .ctl_name = CTL_UNNUMBERED,
304 .procname = "sched_features",
305 .data = &sysctl_sched_features,
306 .maxlen = sizeof(unsigned int),
307 .mode = 0644,
308 .proc_handler = &proc_dointvec,
309 },
Ingo Molnarda84d962007-10-15 17:00:18 +0200310 {
311 .ctl_name = CTL_UNNUMBERED,
312 .procname = "sched_migration_cost",
313 .data = &sysctl_sched_migration_cost,
314 .maxlen = sizeof(unsigned int),
315 .mode = 0644,
316 .proc_handler = &proc_dointvec,
317 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100318 {
319 .ctl_name = CTL_UNNUMBERED,
320 .procname = "sched_nr_migrate",
321 .data = &sysctl_sched_nr_migrate,
322 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100323 .mode = 0644,
324 .proc_handler = &proc_dointvec,
325 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200326#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200327 {
328 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100329 .procname = "sched_rt_period_us",
330 .data = &sysctl_sched_rt_period,
331 .maxlen = sizeof(unsigned int),
332 .mode = 0644,
Peter Zijlstrad0b27fa2008-04-19 19:44:57 +0200333 .proc_handler = &sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100334 },
335 {
336 .ctl_name = CTL_UNNUMBERED,
337 .procname = "sched_rt_runtime_us",
338 .data = &sysctl_sched_rt_runtime,
339 .maxlen = sizeof(int),
340 .mode = 0644,
Peter Zijlstrad0b27fa2008-04-19 19:44:57 +0200341 .proc_handler = &sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100342 },
343 {
344 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar1799e352007-09-19 23:34:46 +0200345 .procname = "sched_compat_yield",
346 .data = &sysctl_sched_compat_yield,
347 .maxlen = sizeof(unsigned int),
348 .mode = 0644,
349 .proc_handler = &proc_dointvec,
350 },
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700351#ifdef CONFIG_PROVE_LOCKING
352 {
353 .ctl_name = CTL_UNNUMBERED,
354 .procname = "prove_locking",
355 .data = &prove_locking,
356 .maxlen = sizeof(int),
357 .mode = 0644,
358 .proc_handler = &proc_dointvec,
359 },
360#endif
361#ifdef CONFIG_LOCK_STAT
362 {
363 .ctl_name = CTL_UNNUMBERED,
364 .procname = "lock_stat",
365 .data = &lock_stat,
366 .maxlen = sizeof(int),
367 .mode = 0644,
368 .proc_handler = &proc_dointvec,
369 },
370#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200371 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 .ctl_name = KERN_PANIC,
373 .procname = "panic",
374 .data = &panic_timeout,
375 .maxlen = sizeof(int),
376 .mode = 0644,
377 .proc_handler = &proc_dointvec,
378 },
379 {
380 .ctl_name = KERN_CORE_USES_PID,
381 .procname = "core_uses_pid",
382 .data = &core_uses_pid,
383 .maxlen = sizeof(int),
384 .mode = 0644,
385 .proc_handler = &proc_dointvec,
386 },
387 {
388 .ctl_name = KERN_CORE_PATTERN,
389 .procname = "core_pattern",
390 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700391 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 .mode = 0644,
393 .proc_handler = &proc_dostring,
394 .strategy = &sysctl_string,
395 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800396#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700399 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800400 .mode = 0644,
Andi Kleen25ddbb12008-10-15 22:01:41 -0700401 .proc_handler = &proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800403#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100404#ifdef CONFIG_LATENCYTOP
405 {
406 .procname = "latencytop",
407 .data = &latencytop_enabled,
408 .maxlen = sizeof(int),
409 .mode = 0644,
410 .proc_handler = &proc_dointvec,
411 },
412#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413#ifdef CONFIG_BLK_DEV_INITRD
414 {
415 .ctl_name = KERN_REALROOTDEV,
416 .procname = "real-root-dev",
417 .data = &real_root_dev,
418 .maxlen = sizeof(int),
419 .mode = 0644,
420 .proc_handler = &proc_dointvec,
421 },
422#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700423 {
424 .ctl_name = CTL_UNNUMBERED,
425 .procname = "print-fatal-signals",
426 .data = &print_fatal_signals,
427 .maxlen = sizeof(int),
428 .mode = 0644,
429 .proc_handler = &proc_dointvec,
430 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700431#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 {
433 .ctl_name = KERN_SPARC_REBOOT,
434 .procname = "reboot-cmd",
435 .data = reboot_command,
436 .maxlen = 256,
437 .mode = 0644,
438 .proc_handler = &proc_dostring,
439 .strategy = &sysctl_string,
440 },
441 {
442 .ctl_name = KERN_SPARC_STOP_A,
443 .procname = "stop-a",
444 .data = &stop_a_enabled,
445 .maxlen = sizeof (int),
446 .mode = 0644,
447 .proc_handler = &proc_dointvec,
448 },
449 {
450 .ctl_name = KERN_SPARC_SCONS_PWROFF,
451 .procname = "scons-poweroff",
452 .data = &scons_pwroff,
453 .maxlen = sizeof (int),
454 .mode = 0644,
455 .proc_handler = &proc_dointvec,
456 },
457#endif
David S. Miller08714202008-11-16 23:49:24 -0800458#ifdef CONFIG_SPARC64
459 {
460 .ctl_name = CTL_UNNUMBERED,
461 .procname = "tsb-ratio",
462 .data = &sysctl_tsb_ratio,
463 .maxlen = sizeof (int),
464 .mode = 0644,
465 .proc_handler = &proc_dointvec,
466 },
467#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468#ifdef __hppa__
469 {
470 .ctl_name = KERN_HPPA_PWRSW,
471 .procname = "soft-power",
472 .data = &pwrsw_enabled,
473 .maxlen = sizeof (int),
474 .mode = 0644,
475 .proc_handler = &proc_dointvec,
476 },
477 {
478 .ctl_name = KERN_HPPA_UNALIGNED,
479 .procname = "unaligned-trap",
480 .data = &unaligned_enabled,
481 .maxlen = sizeof (int),
482 .mode = 0644,
483 .proc_handler = &proc_dointvec,
484 },
485#endif
486 {
487 .ctl_name = KERN_CTLALTDEL,
488 .procname = "ctrl-alt-del",
489 .data = &C_A_D,
490 .maxlen = sizeof(int),
491 .mode = 0644,
492 .proc_handler = &proc_dointvec,
493 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400494#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200495 {
496 .ctl_name = CTL_UNNUMBERED,
497 .procname = "ftrace_enabled",
498 .data = &ftrace_enabled,
499 .maxlen = sizeof(int),
500 .mode = 0644,
501 .proc_handler = &ftrace_enable_sysctl,
502 },
503#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500504#ifdef CONFIG_STACK_TRACER
505 {
506 .ctl_name = CTL_UNNUMBERED,
507 .procname = "stack_tracer_enabled",
508 .data = &stack_tracer_enabled,
509 .maxlen = sizeof(int),
510 .mode = 0644,
511 .proc_handler = &stack_trace_sysctl,
512 },
513#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400514#ifdef CONFIG_TRACING
515 {
516 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100517 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400518 .data = &ftrace_dump_on_oops,
519 .maxlen = sizeof(int),
520 .mode = 0644,
521 .proc_handler = &proc_dointvec,
522 },
523#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200524#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 {
526 .ctl_name = KERN_MODPROBE,
527 .procname = "modprobe",
528 .data = &modprobe_path,
529 .maxlen = KMOD_PATH_LEN,
530 .mode = 0644,
531 .proc_handler = &proc_dostring,
532 .strategy = &sysctl_string,
533 },
534#endif
Andrew Morton57ae2502006-06-23 02:05:47 -0700535#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 {
537 .ctl_name = KERN_HOTPLUG,
538 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100539 .data = &uevent_helper,
540 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 .mode = 0644,
542 .proc_handler = &proc_dostring,
543 .strategy = &sysctl_string,
544 },
545#endif
546#ifdef CONFIG_CHR_DEV_SG
547 {
548 .ctl_name = KERN_SG_BIG_BUFF,
549 .procname = "sg-big-buff",
550 .data = &sg_big_buff,
551 .maxlen = sizeof (int),
552 .mode = 0444,
553 .proc_handler = &proc_dointvec,
554 },
555#endif
556#ifdef CONFIG_BSD_PROCESS_ACCT
557 {
558 .ctl_name = KERN_ACCT,
559 .procname = "acct",
560 .data = &acct_parm,
561 .maxlen = 3*sizeof(int),
562 .mode = 0644,
563 .proc_handler = &proc_dointvec,
564 },
565#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566#ifdef CONFIG_MAGIC_SYSRQ
567 {
568 .ctl_name = KERN_SYSRQ,
569 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800570 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 .maxlen = sizeof (int),
572 .mode = 0644,
573 .proc_handler = &proc_dointvec,
574 },
575#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700576#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700579 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 .maxlen = sizeof (int),
581 .mode = 0600,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700582 .proc_handler = &proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700584#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 {
586 .ctl_name = KERN_MAX_THREADS,
587 .procname = "threads-max",
588 .data = &max_threads,
589 .maxlen = sizeof(int),
590 .mode = 0644,
591 .proc_handler = &proc_dointvec,
592 },
593 {
594 .ctl_name = KERN_RANDOM,
595 .procname = "random",
596 .mode = 0555,
597 .child = random_table,
598 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 {
600 .ctl_name = KERN_OVERFLOWUID,
601 .procname = "overflowuid",
602 .data = &overflowuid,
603 .maxlen = sizeof(int),
604 .mode = 0644,
605 .proc_handler = &proc_dointvec_minmax,
606 .strategy = &sysctl_intvec,
607 .extra1 = &minolduid,
608 .extra2 = &maxolduid,
609 },
610 {
611 .ctl_name = KERN_OVERFLOWGID,
612 .procname = "overflowgid",
613 .data = &overflowgid,
614 .maxlen = sizeof(int),
615 .mode = 0644,
616 .proc_handler = &proc_dointvec_minmax,
617 .strategy = &sysctl_intvec,
618 .extra1 = &minolduid,
619 .extra2 = &maxolduid,
620 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800621#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622#ifdef CONFIG_MATHEMU
623 {
624 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
625 .procname = "ieee_emulation_warnings",
626 .data = &sysctl_ieee_emulation_warnings,
627 .maxlen = sizeof(int),
628 .mode = 0644,
629 .proc_handler = &proc_dointvec,
630 },
631#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 {
633 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
634 .procname = "userprocess_debug",
635 .data = &sysctl_userprocess_debug,
636 .maxlen = sizeof(int),
637 .mode = 0644,
638 .proc_handler = &proc_dointvec,
639 },
640#endif
641 {
642 .ctl_name = KERN_PIDMAX,
643 .procname = "pid_max",
644 .data = &pid_max,
645 .maxlen = sizeof (int),
646 .mode = 0644,
647 .proc_handler = &proc_dointvec_minmax,
648 .strategy = sysctl_intvec,
649 .extra1 = &pid_max_min,
650 .extra2 = &pid_max_max,
651 },
652 {
653 .ctl_name = KERN_PANIC_ON_OOPS,
654 .procname = "panic_on_oops",
655 .data = &panic_on_oops,
656 .maxlen = sizeof(int),
657 .mode = 0644,
658 .proc_handler = &proc_dointvec,
659 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800660#if defined CONFIG_PRINTK
661 {
662 .ctl_name = KERN_PRINTK,
663 .procname = "printk",
664 .data = &console_loglevel,
665 .maxlen = 4*sizeof(int),
666 .mode = 0644,
667 .proc_handler = &proc_dointvec,
668 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 {
670 .ctl_name = KERN_PRINTK_RATELIMIT,
671 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700672 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 .maxlen = sizeof(int),
674 .mode = 0644,
675 .proc_handler = &proc_dointvec_jiffies,
676 .strategy = &sysctl_jiffies,
677 },
678 {
679 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
680 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700681 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 .maxlen = sizeof(int),
683 .mode = 0644,
684 .proc_handler = &proc_dointvec,
685 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800686#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 {
688 .ctl_name = KERN_NGROUPS_MAX,
689 .procname = "ngroups_max",
690 .data = &ngroups_max,
691 .maxlen = sizeof (int),
692 .mode = 0444,
693 .proc_handler = &proc_dointvec,
694 },
695#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
696 {
697 .ctl_name = KERN_UNKNOWN_NMI_PANIC,
698 .procname = "unknown_nmi_panic",
699 .data = &unknown_nmi_panic,
700 .maxlen = sizeof (int),
701 .mode = 0644,
Don Zickus2fbe7b22006-09-26 10:52:27 +0200702 .proc_handler = &proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 },
Don Zickus407984f2006-09-26 10:52:27 +0200704 {
Don Zickus407984f2006-09-26 10:52:27 +0200705 .procname = "nmi_watchdog",
706 .data = &nmi_watchdog_enabled,
707 .maxlen = sizeof (int),
708 .mode = 0644,
709 .proc_handler = &proc_nmi_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 },
711#endif
712#if defined(CONFIG_X86)
713 {
Don Zickus8da5adda2006-09-26 10:52:27 +0200714 .ctl_name = KERN_PANIC_ON_NMI,
715 .procname = "panic_on_unrecovered_nmi",
716 .data = &panic_on_unrecovered_nmi,
717 .maxlen = sizeof(int),
718 .mode = 0644,
719 .proc_handler = &proc_dointvec,
720 },
721 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 .ctl_name = KERN_BOOTLOADER_TYPE,
723 .procname = "bootloader_type",
724 .data = &bootloader_type,
725 .maxlen = sizeof (int),
726 .mode = 0444,
727 .proc_handler = &proc_dointvec,
728 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100729 {
730 .ctl_name = CTL_UNNUMBERED,
731 .procname = "kstack_depth_to_print",
732 .data = &kstack_depth_to_print,
733 .maxlen = sizeof(int),
734 .mode = 0644,
735 .proc_handler = &proc_dointvec,
736 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100737 {
738 .ctl_name = CTL_UNNUMBERED,
739 .procname = "io_delay_type",
740 .data = &io_delay_type,
741 .maxlen = sizeof(int),
742 .mode = 0644,
743 .proc_handler = &proc_dointvec,
744 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800746#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 {
748 .ctl_name = KERN_RANDOMIZE,
749 .procname = "randomize_va_space",
750 .data = &randomize_va_space,
751 .maxlen = sizeof(int),
752 .mode = 0644,
753 .proc_handler = &proc_dointvec,
754 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800755#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800756#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700757 {
758 .ctl_name = KERN_SPIN_RETRY,
759 .procname = "spin_retry",
760 .data = &spin_retry,
761 .maxlen = sizeof (int),
762 .mode = 0644,
763 .proc_handler = &proc_dointvec,
764 },
765#endif
Len Brown673d5b42007-07-28 03:33:16 -0400766#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800767 {
Pavel Machekc255d842006-02-20 18:27:58 -0800768 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700769 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800770 .maxlen = sizeof (unsigned long),
771 .mode = 0644,
Stefan Seyfried7f99f062006-03-02 02:54:34 -0800772 .proc_handler = &proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800773 },
774#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800775#ifdef CONFIG_IA64
776 {
777 .ctl_name = KERN_IA64_UNALIGNED,
778 .procname = "ignore-unaligned-usertrap",
779 .data = &no_unaligned_warning,
780 .maxlen = sizeof (int),
781 .mode = 0644,
782 .proc_handler = &proc_dointvec,
783 },
784#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700785#ifdef CONFIG_DETECT_SOFTLOCKUP
786 {
787 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200788 .procname = "softlockup_panic",
789 .data = &softlockup_panic,
790 .maxlen = sizeof(int),
791 .mode = 0644,
Hiroshi Shimamoto4dca10a2008-07-07 18:37:04 -0700792 .proc_handler = &proc_dointvec_minmax,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200793 .strategy = &sysctl_intvec,
794 .extra1 = &zero,
795 .extra2 = &one,
796 },
797 {
798 .ctl_name = CTL_UNNUMBERED,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700799 .procname = "softlockup_thresh",
800 .data = &softlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200801 .maxlen = sizeof(int),
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700802 .mode = 0644,
Mandeep Singh Bainesbaf48f62009-01-12 21:15:17 -0800803 .proc_handler = &proc_dosoftlockup_thresh,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700804 .strategy = &sysctl_intvec,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200805 .extra1 = &neg_one,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700806 .extra2 = &sixty,
807 },
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800808#endif
809#ifdef CONFIG_DETECT_HUNG_TASK
810 {
811 .ctl_name = CTL_UNNUMBERED,
812 .procname = "hung_task_panic",
813 .data = &sysctl_hung_task_panic,
814 .maxlen = sizeof(int),
815 .mode = 0644,
816 .proc_handler = &proc_dointvec_minmax,
817 .strategy = &sysctl_intvec,
818 .extra1 = &zero,
819 .extra2 = &one,
820 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100821 {
822 .ctl_name = CTL_UNNUMBERED,
823 .procname = "hung_task_check_count",
824 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100825 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100826 .mode = 0644,
Ingo Molnar90739082008-01-25 21:08:34 +0100827 .proc_handler = &proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100828 .strategy = &sysctl_intvec,
829 },
830 {
831 .ctl_name = CTL_UNNUMBERED,
832 .procname = "hung_task_timeout_secs",
833 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100834 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100835 .mode = 0644,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -0800836 .proc_handler = &proc_dohung_task_timeout_secs,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100837 .strategy = &sysctl_intvec,
838 },
839 {
840 .ctl_name = CTL_UNNUMBERED,
841 .procname = "hung_task_warnings",
842 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100843 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100844 .mode = 0644,
Ingo Molnar90739082008-01-25 21:08:34 +0100845 .proc_handler = &proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100846 .strategy = &sysctl_intvec,
847 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700848#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200849#ifdef CONFIG_COMPAT
850 {
851 .ctl_name = KERN_COMPAT_LOG,
852 .procname = "compat-log",
853 .data = &compat_log,
854 .maxlen = sizeof (int),
855 .mode = 0644,
856 .proc_handler = &proc_dointvec,
857 },
858#endif
Ingo Molnar23f78d42006-06-27 02:54:53 -0700859#ifdef CONFIG_RT_MUTEXES
860 {
861 .ctl_name = KERN_MAX_LOCK_DEPTH,
862 .procname = "max_lock_depth",
863 .data = &max_lock_depth,
864 .maxlen = sizeof(int),
865 .mode = 0644,
866 .proc_handler = &proc_dointvec,
867 },
868#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700869 {
870 .ctl_name = CTL_UNNUMBERED,
871 .procname = "poweroff_cmd",
872 .data = &poweroff_cmd,
873 .maxlen = POWEROFF_CMD_PATH_LEN,
874 .mode = 0644,
875 .proc_handler = &proc_dostring,
876 .strategy = &sysctl_string,
877 },
David Howells0b77f5b2008-04-29 01:01:32 -0700878#ifdef CONFIG_KEYS
879 {
880 .ctl_name = CTL_UNNUMBERED,
881 .procname = "keys",
882 .mode = 0555,
883 .child = key_sysctls,
884 },
885#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700886#ifdef CONFIG_RCU_TORTURE_TEST
887 {
888 .ctl_name = CTL_UNNUMBERED,
889 .procname = "rcutorture_runnable",
890 .data = &rcutorture_runnable,
891 .maxlen = sizeof(int),
892 .mode = 0644,
893 .proc_handler = &proc_dointvec,
894 },
895#endif
Lee Schermerhornaf936a12008-10-18 20:26:53 -0700896#ifdef CONFIG_UNEVICTABLE_LRU
897 {
898 .ctl_name = CTL_UNNUMBERED,
899 .procname = "scan_unevictable_pages",
900 .data = &scan_unevictable_pages,
901 .maxlen = sizeof(scan_unevictable_pages),
902 .mode = 0644,
903 .proc_handler = &scan_unevictable_handler,
904 },
905#endif
Andrew Mortoned2c12f2007-07-19 01:50:35 -0700906/*
907 * NOTE: do not add new entries to this table unless you have read
908 * Documentation/sysctl/ctl_unnumbered.txt
909 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910 { .ctl_name = 0 }
911};
912
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700913static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 {
915 .ctl_name = VM_OVERCOMMIT_MEMORY,
916 .procname = "overcommit_memory",
917 .data = &sysctl_overcommit_memory,
918 .maxlen = sizeof(sysctl_overcommit_memory),
919 .mode = 0644,
920 .proc_handler = &proc_dointvec,
921 },
922 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700923 .ctl_name = VM_PANIC_ON_OOM,
924 .procname = "panic_on_oom",
925 .data = &sysctl_panic_on_oom,
926 .maxlen = sizeof(sysctl_panic_on_oom),
927 .mode = 0644,
928 .proc_handler = &proc_dointvec,
929 },
930 {
David Rientjesfe071d72007-10-16 23:25:56 -0700931 .ctl_name = CTL_UNNUMBERED,
932 .procname = "oom_kill_allocating_task",
933 .data = &sysctl_oom_kill_allocating_task,
934 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
935 .mode = 0644,
936 .proc_handler = &proc_dointvec,
937 },
938 {
David Rientjesfef1bdd2008-02-07 00:14:07 -0800939 .ctl_name = CTL_UNNUMBERED,
940 .procname = "oom_dump_tasks",
941 .data = &sysctl_oom_dump_tasks,
942 .maxlen = sizeof(sysctl_oom_dump_tasks),
943 .mode = 0644,
944 .proc_handler = &proc_dointvec,
945 },
946 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947 .ctl_name = VM_OVERCOMMIT_RATIO,
948 .procname = "overcommit_ratio",
949 .data = &sysctl_overcommit_ratio,
950 .maxlen = sizeof(sysctl_overcommit_ratio),
951 .mode = 0644,
952 .proc_handler = &proc_dointvec,
953 },
954 {
955 .ctl_name = VM_PAGE_CLUSTER,
956 .procname = "page-cluster",
957 .data = &page_cluster,
958 .maxlen = sizeof(int),
959 .mode = 0644,
960 .proc_handler = &proc_dointvec,
961 },
962 {
963 .ctl_name = VM_DIRTY_BACKGROUND,
964 .procname = "dirty_background_ratio",
965 .data = &dirty_background_ratio,
966 .maxlen = sizeof(dirty_background_ratio),
967 .mode = 0644,
David Rientjes2da02992009-01-06 14:39:31 -0800968 .proc_handler = &dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969 .strategy = &sysctl_intvec,
970 .extra1 = &zero,
971 .extra2 = &one_hundred,
972 },
973 {
David Rientjes2da02992009-01-06 14:39:31 -0800974 .ctl_name = CTL_UNNUMBERED,
975 .procname = "dirty_background_bytes",
976 .data = &dirty_background_bytes,
977 .maxlen = sizeof(dirty_background_bytes),
978 .mode = 0644,
979 .proc_handler = &dirty_background_bytes_handler,
980 .strategy = &sysctl_intvec,
981 .extra1 = &one,
982 },
983 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984 .ctl_name = VM_DIRTY_RATIO,
985 .procname = "dirty_ratio",
986 .data = &vm_dirty_ratio,
987 .maxlen = sizeof(vm_dirty_ratio),
988 .mode = 0644,
Peter Zijlstra04fbfdc2007-10-16 23:25:50 -0700989 .proc_handler = &dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990 .strategy = &sysctl_intvec,
991 .extra1 = &zero,
992 .extra2 = &one_hundred,
993 },
994 {
David Rientjes2da02992009-01-06 14:39:31 -0800995 .ctl_name = CTL_UNNUMBERED,
996 .procname = "dirty_bytes",
997 .data = &vm_dirty_bytes,
998 .maxlen = sizeof(vm_dirty_bytes),
999 .mode = 0644,
1000 .proc_handler = &dirty_bytes_handler,
1001 .strategy = &sysctl_intvec,
1002 .extra1 = &one,
1003 },
1004 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001006 .data = &dirty_writeback_interval,
1007 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001008 .mode = 0644,
1009 .proc_handler = &dirty_writeback_centisecs_handler,
1010 },
1011 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001013 .data = &dirty_expire_interval,
1014 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 .mode = 0644,
Bart Samwelf6ef9432006-03-24 03:15:48 -08001016 .proc_handler = &proc_dointvec_userhz_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001017 },
1018 {
1019 .ctl_name = VM_NR_PDFLUSH_THREADS,
1020 .procname = "nr_pdflush_threads",
1021 .data = &nr_pdflush_threads,
1022 .maxlen = sizeof nr_pdflush_threads,
1023 .mode = 0444 /* read-only*/,
1024 .proc_handler = &proc_dointvec,
1025 },
1026 {
1027 .ctl_name = VM_SWAPPINESS,
1028 .procname = "swappiness",
1029 .data = &vm_swappiness,
1030 .maxlen = sizeof(vm_swappiness),
1031 .mode = 0644,
1032 .proc_handler = &proc_dointvec_minmax,
1033 .strategy = &sysctl_intvec,
1034 .extra1 = &zero,
1035 .extra2 = &one_hundred,
1036 },
1037#ifdef CONFIG_HUGETLB_PAGE
1038 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001039 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001040 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001041 .maxlen = sizeof(unsigned long),
1042 .mode = 0644,
1043 .proc_handler = &hugetlb_sysctl_handler,
1044 .extra1 = (void *)&hugetlb_zero,
1045 .extra2 = (void *)&hugetlb_infinity,
1046 },
1047 {
1048 .ctl_name = VM_HUGETLB_GROUP,
1049 .procname = "hugetlb_shm_group",
1050 .data = &sysctl_hugetlb_shm_group,
1051 .maxlen = sizeof(gid_t),
1052 .mode = 0644,
1053 .proc_handler = &proc_dointvec,
1054 },
Mel Gorman396faf02007-07-17 04:03:13 -07001055 {
1056 .ctl_name = CTL_UNNUMBERED,
1057 .procname = "hugepages_treat_as_movable",
1058 .data = &hugepages_treat_as_movable,
1059 .maxlen = sizeof(int),
1060 .mode = 0644,
1061 .proc_handler = &hugetlb_treat_movable_handler,
1062 },
Adam Litke54f9f802007-10-16 01:26:20 -07001063 {
1064 .ctl_name = CTL_UNNUMBERED,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001065 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001066 .data = NULL,
1067 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001068 .mode = 0644,
Nishanth Aravamudana3d0c6a2008-02-08 04:18:18 -08001069 .proc_handler = &hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001070 .extra1 = (void *)&hugetlb_zero,
1071 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001072 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073#endif
1074 {
1075 .ctl_name = VM_LOWMEM_RESERVE_RATIO,
1076 .procname = "lowmem_reserve_ratio",
1077 .data = &sysctl_lowmem_reserve_ratio,
1078 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1079 .mode = 0644,
1080 .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
1081 .strategy = &sysctl_intvec,
1082 },
1083 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001084 .ctl_name = VM_DROP_PAGECACHE,
1085 .procname = "drop_caches",
1086 .data = &sysctl_drop_caches,
1087 .maxlen = sizeof(int),
1088 .mode = 0644,
1089 .proc_handler = drop_caches_sysctl_handler,
1090 .strategy = &sysctl_intvec,
1091 },
1092 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093 .ctl_name = VM_MIN_FREE_KBYTES,
1094 .procname = "min_free_kbytes",
1095 .data = &min_free_kbytes,
1096 .maxlen = sizeof(min_free_kbytes),
1097 .mode = 0644,
1098 .proc_handler = &min_free_kbytes_sysctl_handler,
1099 .strategy = &sysctl_intvec,
1100 .extra1 = &zero,
1101 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001102 {
1103 .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
1104 .procname = "percpu_pagelist_fraction",
1105 .data = &percpu_pagelist_fraction,
1106 .maxlen = sizeof(percpu_pagelist_fraction),
1107 .mode = 0644,
1108 .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
1109 .strategy = &sysctl_intvec,
1110 .extra1 = &min_percpu_pagelist_fract,
1111 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001112#ifdef CONFIG_MMU
1113 {
1114 .ctl_name = VM_MAX_MAP_COUNT,
1115 .procname = "max_map_count",
1116 .data = &sysctl_max_map_count,
1117 .maxlen = sizeof(sysctl_max_map_count),
1118 .mode = 0644,
1119 .proc_handler = &proc_dointvec
1120 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001121#else
1122 {
1123 .ctl_name = CTL_UNNUMBERED,
1124 .procname = "nr_trim_pages",
1125 .data = &sysctl_nr_trim_pages,
1126 .maxlen = sizeof(sysctl_nr_trim_pages),
1127 .mode = 0644,
1128 .proc_handler = &proc_dointvec_minmax,
1129 .strategy = &sysctl_intvec,
1130 .extra1 = &zero,
1131 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132#endif
1133 {
1134 .ctl_name = VM_LAPTOP_MODE,
1135 .procname = "laptop_mode",
1136 .data = &laptop_mode,
1137 .maxlen = sizeof(laptop_mode),
1138 .mode = 0644,
Bart Samweled5b43f2006-03-24 03:15:49 -08001139 .proc_handler = &proc_dointvec_jiffies,
1140 .strategy = &sysctl_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141 },
1142 {
1143 .ctl_name = VM_BLOCK_DUMP,
1144 .procname = "block_dump",
1145 .data = &block_dump,
1146 .maxlen = sizeof(block_dump),
1147 .mode = 0644,
1148 .proc_handler = &proc_dointvec,
1149 .strategy = &sysctl_intvec,
1150 .extra1 = &zero,
1151 },
1152 {
1153 .ctl_name = VM_VFS_CACHE_PRESSURE,
1154 .procname = "vfs_cache_pressure",
1155 .data = &sysctl_vfs_cache_pressure,
1156 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1157 .mode = 0644,
1158 .proc_handler = &proc_dointvec,
1159 .strategy = &sysctl_intvec,
1160 .extra1 = &zero,
1161 },
1162#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1163 {
1164 .ctl_name = VM_LEGACY_VA_LAYOUT,
1165 .procname = "legacy_va_layout",
1166 .data = &sysctl_legacy_va_layout,
1167 .maxlen = sizeof(sysctl_legacy_va_layout),
1168 .mode = 0644,
1169 .proc_handler = &proc_dointvec,
1170 .strategy = &sysctl_intvec,
1171 .extra1 = &zero,
1172 },
1173#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001174#ifdef CONFIG_NUMA
1175 {
1176 .ctl_name = VM_ZONE_RECLAIM_MODE,
1177 .procname = "zone_reclaim_mode",
1178 .data = &zone_reclaim_mode,
1179 .maxlen = sizeof(zone_reclaim_mode),
1180 .mode = 0644,
1181 .proc_handler = &proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001182 .strategy = &sysctl_intvec,
1183 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001184 },
Christoph Lameter96146342006-07-03 00:24:13 -07001185 {
1186 .ctl_name = VM_MIN_UNMAPPED,
1187 .procname = "min_unmapped_ratio",
1188 .data = &sysctl_min_unmapped_ratio,
1189 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1190 .mode = 0644,
1191 .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
1192 .strategy = &sysctl_intvec,
1193 .extra1 = &zero,
1194 .extra2 = &one_hundred,
1195 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001196 {
1197 .ctl_name = VM_MIN_SLAB,
1198 .procname = "min_slab_ratio",
1199 .data = &sysctl_min_slab_ratio,
1200 .maxlen = sizeof(sysctl_min_slab_ratio),
1201 .mode = 0644,
1202 .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
1203 .strategy = &sysctl_intvec,
1204 .extra1 = &zero,
1205 .extra2 = &one_hundred,
1206 },
Christoph Lameter17436602006-01-18 17:42:32 -08001207#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001208#ifdef CONFIG_SMP
1209 {
1210 .ctl_name = CTL_UNNUMBERED,
1211 .procname = "stat_interval",
1212 .data = &sysctl_stat_interval,
1213 .maxlen = sizeof(sysctl_stat_interval),
1214 .mode = 0644,
1215 .proc_handler = &proc_dointvec_jiffies,
1216 .strategy = &sysctl_jiffies,
1217 },
1218#endif
Eric Parised032182007-06-28 15:55:21 -04001219#ifdef CONFIG_SECURITY
1220 {
1221 .ctl_name = CTL_UNNUMBERED,
1222 .procname = "mmap_min_addr",
1223 .data = &mmap_min_addr,
1224 .maxlen = sizeof(unsigned long),
1225 .mode = 0644,
1226 .proc_handler = &proc_doulongvec_minmax,
1227 },
Lee Schermerhorn8daec962007-08-10 13:00:51 -07001228#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001229#ifdef CONFIG_NUMA
1230 {
1231 .ctl_name = CTL_UNNUMBERED,
1232 .procname = "numa_zonelist_order",
1233 .data = &numa_zonelist_order,
1234 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1235 .mode = 0644,
1236 .proc_handler = &numa_zonelist_order_handler,
1237 .strategy = &sysctl_string,
1238 },
1239#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001240#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001241 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001242 {
1243 .ctl_name = VM_VDSO_ENABLED,
1244 .procname = "vdso_enabled",
1245 .data = &vdso_enabled,
1246 .maxlen = sizeof(vdso_enabled),
1247 .mode = 0644,
1248 .proc_handler = &proc_dointvec,
1249 .strategy = &sysctl_intvec,
1250 .extra1 = &zero,
1251 },
1252#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001253#ifdef CONFIG_HIGHMEM
1254 {
1255 .ctl_name = CTL_UNNUMBERED,
1256 .procname = "highmem_is_dirtyable",
1257 .data = &vm_highmem_is_dirtyable,
1258 .maxlen = sizeof(vm_highmem_is_dirtyable),
1259 .mode = 0644,
1260 .proc_handler = &proc_dointvec_minmax,
1261 .strategy = &sysctl_intvec,
1262 .extra1 = &zero,
1263 .extra2 = &one,
1264 },
1265#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001266/*
1267 * NOTE: do not add new entries to this table unless you have read
1268 * Documentation/sysctl/ctl_unnumbered.txt
1269 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001270 { .ctl_name = 0 }
1271};
1272
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001273#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001274static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001275 { .ctl_name = 0 }
1276};
1277#endif
1278
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001279static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 {
1281 .ctl_name = FS_NRINODE,
1282 .procname = "inode-nr",
1283 .data = &inodes_stat,
1284 .maxlen = 2*sizeof(int),
1285 .mode = 0444,
1286 .proc_handler = &proc_dointvec,
1287 },
1288 {
1289 .ctl_name = FS_STATINODE,
1290 .procname = "inode-state",
1291 .data = &inodes_stat,
1292 .maxlen = 7*sizeof(int),
1293 .mode = 0444,
1294 .proc_handler = &proc_dointvec,
1295 },
1296 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297 .procname = "file-nr",
1298 .data = &files_stat,
1299 .maxlen = 3*sizeof(int),
1300 .mode = 0444,
Dipankar Sarma529bf6b2006-03-07 21:55:35 -08001301 .proc_handler = &proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001302 },
1303 {
1304 .ctl_name = FS_MAXFILE,
1305 .procname = "file-max",
1306 .data = &files_stat.max_files,
1307 .maxlen = sizeof(int),
1308 .mode = 0644,
1309 .proc_handler = &proc_dointvec,
1310 },
1311 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001312 .ctl_name = CTL_UNNUMBERED,
1313 .procname = "nr_open",
1314 .data = &sysctl_nr_open,
1315 .maxlen = sizeof(int),
1316 .mode = 0644,
Al Viroeceea0b2008-05-10 10:08:32 -04001317 .proc_handler = &proc_dointvec_minmax,
1318 .extra1 = &sysctl_nr_open_min,
1319 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001320 },
1321 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001322 .ctl_name = FS_DENTRY,
1323 .procname = "dentry-state",
1324 .data = &dentry_stat,
1325 .maxlen = 6*sizeof(int),
1326 .mode = 0444,
1327 .proc_handler = &proc_dointvec,
1328 },
1329 {
1330 .ctl_name = FS_OVERFLOWUID,
1331 .procname = "overflowuid",
1332 .data = &fs_overflowuid,
1333 .maxlen = sizeof(int),
1334 .mode = 0644,
1335 .proc_handler = &proc_dointvec_minmax,
1336 .strategy = &sysctl_intvec,
1337 .extra1 = &minolduid,
1338 .extra2 = &maxolduid,
1339 },
1340 {
1341 .ctl_name = FS_OVERFLOWGID,
1342 .procname = "overflowgid",
1343 .data = &fs_overflowgid,
1344 .maxlen = sizeof(int),
1345 .mode = 0644,
1346 .proc_handler = &proc_dointvec_minmax,
1347 .strategy = &sysctl_intvec,
1348 .extra1 = &minolduid,
1349 .extra2 = &maxolduid,
1350 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001351#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001352 {
1353 .ctl_name = FS_LEASES,
1354 .procname = "leases-enable",
1355 .data = &leases_enable,
1356 .maxlen = sizeof(int),
1357 .mode = 0644,
1358 .proc_handler = &proc_dointvec,
1359 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001360#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001361#ifdef CONFIG_DNOTIFY
1362 {
1363 .ctl_name = FS_DIR_NOTIFY,
1364 .procname = "dir-notify-enable",
1365 .data = &dir_notify_enable,
1366 .maxlen = sizeof(int),
1367 .mode = 0644,
1368 .proc_handler = &proc_dointvec,
1369 },
1370#endif
1371#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001372#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001373 {
1374 .ctl_name = FS_LEASE_TIME,
1375 .procname = "lease-break-time",
1376 .data = &lease_break_time,
1377 .maxlen = sizeof(int),
1378 .mode = 0644,
Kawai, Hidehiro76fdbb22007-07-19 01:48:26 -07001379 .proc_handler = &proc_dointvec_minmax,
1380 .strategy = &sysctl_intvec,
1381 .extra1 = &zero,
1382 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001383 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001384#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001385#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001386 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001387 .procname = "aio-nr",
1388 .data = &aio_nr,
1389 .maxlen = sizeof(aio_nr),
1390 .mode = 0444,
Zach Brownd55b5fd2005-11-07 00:59:31 -08001391 .proc_handler = &proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392 },
1393 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001394 .procname = "aio-max-nr",
1395 .data = &aio_max_nr,
1396 .maxlen = sizeof(aio_max_nr),
1397 .mode = 0644,
Zach Brownd55b5fd2005-11-07 00:59:31 -08001398 .proc_handler = &proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001399 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001400#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001401#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001402 {
1403 .ctl_name = FS_INOTIFY,
1404 .procname = "inotify",
1405 .mode = 0555,
1406 .child = inotify_table,
1407 },
1408#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001409#ifdef CONFIG_EPOLL
1410 {
1411 .procname = "epoll",
1412 .mode = 0555,
1413 .child = epoll_table,
1414 },
1415#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001416#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001417 {
1418 .ctl_name = KERN_SETUID_DUMPABLE,
1419 .procname = "suid_dumpable",
1420 .data = &suid_dumpable,
1421 .maxlen = sizeof(int),
1422 .mode = 0644,
1423 .proc_handler = &proc_dointvec,
1424 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001425#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1426 {
1427 .ctl_name = CTL_UNNUMBERED,
1428 .procname = "binfmt_misc",
1429 .mode = 0555,
1430 .child = binfmt_misc_table,
1431 },
1432#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001433/*
1434 * NOTE: do not add new entries to this table unless you have read
1435 * Documentation/sysctl/ctl_unnumbered.txt
1436 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001437 { .ctl_name = 0 }
1438};
1439
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001440static struct ctl_table debug_table[] = {
Olof Johanssond0c3d532007-10-12 10:20:07 +10001441#if defined(CONFIG_X86) || defined(CONFIG_PPC)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001442 {
1443 .ctl_name = CTL_UNNUMBERED,
1444 .procname = "exception-trace",
1445 .data = &show_unhandled_signals,
1446 .maxlen = sizeof(int),
1447 .mode = 0644,
1448 .proc_handler = proc_dointvec
1449 },
1450#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001451 { .ctl_name = 0 }
1452};
1453
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001454static struct ctl_table dev_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 { .ctl_name = 0 }
Robert Love0eeca282005-07-12 17:06:03 -04001456};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457
Al Viro330d57f2005-11-04 10:18:40 +00001458static DEFINE_SPINLOCK(sysctl_lock);
1459
1460/* called under sysctl_lock */
1461static int use_table(struct ctl_table_header *p)
1462{
1463 if (unlikely(p->unregistering))
1464 return 0;
1465 p->used++;
1466 return 1;
1467}
1468
1469/* called under sysctl_lock */
1470static void unuse_table(struct ctl_table_header *p)
1471{
1472 if (!--p->used)
1473 if (unlikely(p->unregistering))
1474 complete(p->unregistering);
1475}
1476
1477/* called under sysctl_lock, will reacquire if has to wait */
1478static void start_unregistering(struct ctl_table_header *p)
1479{
1480 /*
1481 * if p->used is 0, nobody will ever touch that entry again;
1482 * we'll eliminate all paths to it before dropping sysctl_lock
1483 */
1484 if (unlikely(p->used)) {
1485 struct completion wait;
1486 init_completion(&wait);
1487 p->unregistering = &wait;
1488 spin_unlock(&sysctl_lock);
1489 wait_for_completion(&wait);
1490 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001491 } else {
1492 /* anything non-NULL; we'll never dereference it */
1493 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001494 }
1495 /*
1496 * do not remove from the list until nobody holds it; walking the
1497 * list in do_sysctl() relies on that.
1498 */
1499 list_del_init(&p->ctl_entry);
1500}
1501
Al Virof7e6ced2008-07-15 01:44:23 -04001502void sysctl_head_get(struct ctl_table_header *head)
1503{
1504 spin_lock(&sysctl_lock);
1505 head->count++;
1506 spin_unlock(&sysctl_lock);
1507}
1508
1509void sysctl_head_put(struct ctl_table_header *head)
1510{
1511 spin_lock(&sysctl_lock);
1512 if (!--head->count)
1513 kfree(head);
1514 spin_unlock(&sysctl_lock);
1515}
1516
1517struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1518{
1519 if (!head)
1520 BUG();
1521 spin_lock(&sysctl_lock);
1522 if (!use_table(head))
1523 head = ERR_PTR(-ENOENT);
1524 spin_unlock(&sysctl_lock);
1525 return head;
1526}
1527
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001528void sysctl_head_finish(struct ctl_table_header *head)
1529{
1530 if (!head)
1531 return;
1532 spin_lock(&sysctl_lock);
1533 unuse_table(head);
1534 spin_unlock(&sysctl_lock);
1535}
1536
Al Viro73455092008-07-14 21:22:20 -04001537static struct ctl_table_set *
1538lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1539{
1540 struct ctl_table_set *set = &root->default_set;
1541 if (root->lookup)
1542 set = root->lookup(root, namespaces);
1543 return set;
1544}
1545
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001546static struct list_head *
1547lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001548{
Al Viro73455092008-07-14 21:22:20 -04001549 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1550 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001551}
1552
1553struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1554 struct ctl_table_header *prev)
1555{
1556 struct ctl_table_root *root;
1557 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001558 struct ctl_table_header *head;
1559 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001560
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001561 spin_lock(&sysctl_lock);
1562 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001563 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001564 tmp = &prev->ctl_entry;
1565 unuse_table(prev);
1566 goto next;
1567 }
1568 tmp = &root_table_header.ctl_entry;
1569 for (;;) {
1570 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1571
1572 if (!use_table(head))
1573 goto next;
1574 spin_unlock(&sysctl_lock);
1575 return head;
1576 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001577 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001578 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001579 header_list = lookup_header_list(root, namespaces);
1580 if (tmp != header_list)
1581 continue;
1582
1583 do {
1584 root = list_entry(root->root_list.next,
1585 struct ctl_table_root, root_list);
1586 if (root == &sysctl_table_root)
1587 goto out;
1588 header_list = lookup_header_list(root, namespaces);
1589 } while (list_empty(header_list));
1590 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001591 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001592out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001593 spin_unlock(&sysctl_lock);
1594 return NULL;
1595}
1596
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001597struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1598{
1599 return __sysctl_head_next(current->nsproxy, prev);
1600}
1601
1602void register_sysctl_root(struct ctl_table_root *root)
1603{
1604 spin_lock(&sysctl_lock);
1605 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1606 spin_unlock(&sysctl_lock);
1607}
1608
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001609#ifdef CONFIG_SYSCTL_SYSCALL
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001610/* Perform the actual read/write of a sysctl table entry. */
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001611static int do_sysctl_strategy(struct ctl_table_root *root,
1612 struct ctl_table *table,
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001613 void __user *oldval, size_t __user *oldlenp,
1614 void __user *newval, size_t newlen)
1615{
1616 int op = 0, rc;
1617
1618 if (oldval)
Al Viroe6305c42008-07-15 21:03:57 -04001619 op |= MAY_READ;
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001620 if (newval)
Al Viroe6305c42008-07-15 21:03:57 -04001621 op |= MAY_WRITE;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001622 if (sysctl_perm(root, table, op))
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001623 return -EPERM;
1624
1625 if (table->strategy) {
Alexey Dobriyanf221e722008-10-15 22:04:23 -07001626 rc = table->strategy(table, oldval, oldlenp, newval, newlen);
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001627 if (rc < 0)
1628 return rc;
1629 if (rc > 0)
1630 return 0;
1631 }
1632
1633 /* If there is no strategy routine, or if the strategy returns
1634 * zero, proceed with automatic r/w */
1635 if (table->data && table->maxlen) {
Alexey Dobriyanf221e722008-10-15 22:04:23 -07001636 rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001637 if (rc < 0)
1638 return rc;
1639 }
1640 return 0;
1641}
1642
1643static int parse_table(int __user *name, int nlen,
1644 void __user *oldval, size_t __user *oldlenp,
1645 void __user *newval, size_t newlen,
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001646 struct ctl_table_root *root,
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001647 struct ctl_table *table)
1648{
1649 int n;
1650repeat:
1651 if (!nlen)
1652 return -ENOTDIR;
1653 if (get_user(n, name))
1654 return -EFAULT;
1655 for ( ; table->ctl_name || table->procname; table++) {
1656 if (!table->ctl_name)
1657 continue;
1658 if (n == table->ctl_name) {
1659 int error;
1660 if (table->child) {
Al Viroe6305c42008-07-15 21:03:57 -04001661 if (sysctl_perm(root, table, MAY_EXEC))
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001662 return -EPERM;
1663 name++;
1664 nlen--;
1665 table = table->child;
1666 goto repeat;
1667 }
Alexey Dobriyanf221e722008-10-15 22:04:23 -07001668 error = do_sysctl_strategy(root, table,
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001669 oldval, oldlenp,
1670 newval, newlen);
1671 return error;
1672 }
1673 }
1674 return -ENOTDIR;
1675}
1676
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1678 void __user *newval, size_t newlen)
1679{
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001680 struct ctl_table_header *head;
Al Viro330d57f2005-11-04 10:18:40 +00001681 int error = -ENOTDIR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001682
1683 if (nlen <= 0 || nlen >= CTL_MAXNAME)
1684 return -ENOTDIR;
1685 if (oldval) {
1686 int old_len;
1687 if (!oldlenp || get_user(old_len, oldlenp))
1688 return -EFAULT;
1689 }
Al Viro330d57f2005-11-04 10:18:40 +00001690
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001691 for (head = sysctl_head_next(NULL); head;
1692 head = sysctl_head_next(head)) {
Al Viro330d57f2005-11-04 10:18:40 +00001693 error = parse_table(name, nlen, oldval, oldlenp,
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001694 newval, newlen,
1695 head->root, head->ctl_table);
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001696 if (error != -ENOTDIR) {
1697 sysctl_head_finish(head);
Al Viro330d57f2005-11-04 10:18:40 +00001698 break;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001699 }
1700 }
Al Viro330d57f2005-11-04 10:18:40 +00001701 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001702}
1703
1704asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1705{
1706 struct __sysctl_args tmp;
1707 int error;
1708
1709 if (copy_from_user(&tmp, args, sizeof(tmp)))
1710 return -EFAULT;
1711
Eric W. Biederman7058cb02007-10-18 03:05:58 -07001712 error = deprecated_sysctl_warning(&tmp);
1713 if (error)
1714 goto out;
1715
Linus Torvalds1da177e2005-04-16 15:20:36 -07001716 lock_kernel();
1717 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1718 tmp.newval, tmp.newlen);
1719 unlock_kernel();
Eric W. Biederman7058cb02007-10-18 03:05:58 -07001720out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001721 return error;
1722}
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001723#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001724
1725/*
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001726 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001727 * some sysctl variables are readonly even to root.
1728 */
1729
1730static int test_perm(int mode, int op)
1731{
David Howells76aac0e2008-11-14 10:39:12 +11001732 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001733 mode >>= 6;
1734 else if (in_egroup_p(0))
1735 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001736 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001737 return 0;
1738 return -EACCES;
1739}
1740
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001741int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001742{
1743 int error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001744 int mode;
1745
Al Viroe6305c42008-07-15 21:03:57 -04001746 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001747 if (error)
1748 return error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001749
1750 if (root->permissions)
1751 mode = root->permissions(root, current->nsproxy, table);
1752 else
1753 mode = table->mode;
1754
1755 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001756}
1757
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001758static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1759{
1760 for (; table->ctl_name || table->procname; table++) {
1761 table->parent = parent;
1762 if (table->child)
1763 sysctl_set_parent(table, table->child);
1764 }
1765}
1766
1767static __init int sysctl_init(void)
1768{
1769 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001770#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1771 {
1772 int err;
1773 err = sysctl_check_table(current->nsproxy, root_table);
1774 }
1775#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001776 return 0;
1777}
1778
1779core_initcall(sysctl_init);
1780
Al Virobfbcf032008-07-27 06:31:22 +01001781static struct ctl_table *is_branch_in(struct ctl_table *branch,
1782 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001783{
1784 struct ctl_table *p;
1785 const char *s = branch->procname;
1786
1787 /* branch should have named subdirectory as its first element */
1788 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001789 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001790
1791 /* ... and nothing else */
1792 if (branch[1].procname || branch[1].ctl_name)
Al Virobfbcf032008-07-27 06:31:22 +01001793 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001794
1795 /* table should contain subdirectory with the same name */
1796 for (p = table; p->procname || p->ctl_name; p++) {
1797 if (!p->child)
1798 continue;
1799 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001800 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001801 }
Al Virobfbcf032008-07-27 06:31:22 +01001802 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001803}
1804
1805/* see if attaching q to p would be an improvement */
1806static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1807{
1808 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001809 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001810 int is_better = 0;
1811 int not_in_parent = !p->attached_by;
1812
Al Virobfbcf032008-07-27 06:31:22 +01001813 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001814 if (by == q->attached_by)
1815 is_better = 1;
1816 if (to == p->attached_by)
1817 not_in_parent = 1;
1818 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001819 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001820 }
1821
1822 if (is_better && not_in_parent) {
1823 q->attached_by = by;
1824 q->attached_to = to;
1825 q->parent = p;
1826 }
1827}
1828
Linus Torvalds1da177e2005-04-16 15:20:36 -07001829/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001830 * __register_sysctl_paths - register a sysctl hierarchy
1831 * @root: List of sysctl headers to register on
1832 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001833 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001834 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001835 *
1836 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001837 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001838 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001839 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001840 *
1841 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1842 * must be unique within that level of sysctl
1843 *
1844 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1845 * enter a sysctl file
1846 *
1847 * data - a pointer to data for use by proc_handler
1848 *
1849 * maxlen - the maximum size in bytes of the data
1850 *
1851 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1852 *
1853 * child - a pointer to the child sysctl table if this entry is a directory, or
1854 * %NULL.
1855 *
1856 * proc_handler - the text handler routine (described below)
1857 *
1858 * strategy - the strategy routine (described below)
1859 *
1860 * de - for internal use by the sysctl routines
1861 *
1862 * extra1, extra2 - extra pointers usable by the proc handler routines
1863 *
1864 * Leaf nodes in the sysctl tree will be represented by a single file
1865 * under /proc; non-leaf nodes will be represented by directories.
1866 *
1867 * sysctl(2) can automatically manage read and write requests through
1868 * the sysctl table. The data and maxlen fields of the ctl_table
1869 * struct enable minimal validation of the values being written to be
1870 * performed, and the mode field allows minimal authentication.
1871 *
1872 * More sophisticated management can be enabled by the provision of a
1873 * strategy routine with the table entry. This will be called before
1874 * any automatic read or write of the data is performed.
1875 *
1876 * The strategy routine may return
1877 *
1878 * < 0 - Error occurred (error is passed to user process)
1879 *
1880 * 0 - OK - proceed with automatic read or write.
1881 *
1882 * > 0 - OK - read or write has been done by the strategy routine, so
1883 * return immediately.
1884 *
1885 * There must be a proc_handler routine for any terminal nodes
1886 * mirrored under /proc/sys (non-terminals are handled by a built-in
1887 * directory handler). Several default handlers are available to
1888 * cover common cases -
1889 *
1890 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1891 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1892 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1893 *
1894 * It is the handler's job to read the input buffer from user memory
1895 * and process it. The handler should return 0 on success.
1896 *
1897 * This routine returns %NULL on a failure to register, and a pointer
1898 * to the table header on success.
1899 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001900struct ctl_table_header *__register_sysctl_paths(
1901 struct ctl_table_root *root,
1902 struct nsproxy *namespaces,
1903 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001904{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001905 struct ctl_table_header *header;
1906 struct ctl_table *new, **prevp;
1907 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001908 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001909
1910 /* Count the path components */
1911 for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
1912 ;
1913
1914 /*
1915 * For each path component, allocate a 2-element ctl_table array.
1916 * The first array element will be filled with the sysctl entry
1917 * for this, the second will be the sentinel (ctl_name == 0).
1918 *
1919 * We allocate everything in one go so that we don't have to
1920 * worry about freeing additional memory in unregister_sysctl_table.
1921 */
1922 header = kzalloc(sizeof(struct ctl_table_header) +
1923 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1924 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001925 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001926
1927 new = (struct ctl_table *) (header + 1);
1928
1929 /* Now connect the dots */
1930 prevp = &header->ctl_table;
1931 for (n = 0; n < npath; ++n, ++path) {
1932 /* Copy the procname */
1933 new->procname = path->procname;
1934 new->ctl_name = path->ctl_name;
1935 new->mode = 0555;
1936
1937 *prevp = new;
1938 prevp = &new->child;
1939
1940 new += 2;
1941 }
1942 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001943 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001944
1945 INIT_LIST_HEAD(&header->ctl_entry);
1946 header->used = 0;
1947 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001948 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001949 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001950 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001951#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001952 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001953 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001954 return NULL;
1955 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001956#endif
Al Viro330d57f2005-11-04 10:18:40 +00001957 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001958 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001959 header->attached_by = header->ctl_table;
1960 header->attached_to = root_table;
1961 header->parent = &root_table_header;
1962 for (set = header->set; set; set = set->parent) {
1963 struct ctl_table_header *p;
1964 list_for_each_entry(p, &set->list, ctl_entry) {
1965 if (p->unregistering)
1966 continue;
1967 try_attach(p, header);
1968 }
1969 }
1970 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001971 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001972 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001973
1974 return header;
1975}
1976
1977/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001978 * register_sysctl_table_path - register a sysctl table hierarchy
1979 * @path: The path to the directory the sysctl table is in.
1980 * @table: the top-level table structure
1981 *
1982 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1983 * array. A completely 0 filled entry terminates the table.
1984 *
1985 * See __register_sysctl_paths for more details.
1986 */
1987struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1988 struct ctl_table *table)
1989{
1990 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1991 path, table);
1992}
1993
1994/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001995 * register_sysctl_table - register a sysctl table hierarchy
1996 * @table: the top-level table structure
1997 *
1998 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1999 * array. A completely 0 filled entry terminates the table.
2000 *
2001 * See register_sysctl_paths for more details.
2002 */
2003struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
2004{
2005 static const struct ctl_path null_path[] = { {} };
2006
2007 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002008}
2009
2010/**
2011 * unregister_sysctl_table - unregister a sysctl table hierarchy
2012 * @header: the header returned from register_sysctl_table
2013 *
2014 * Unregisters the sysctl table and all children. proc entries may not
2015 * actually be removed until they are no longer used by anyone.
2016 */
2017void unregister_sysctl_table(struct ctl_table_header * header)
2018{
Al Viro330d57f2005-11-04 10:18:40 +00002019 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08002020
2021 if (header == NULL)
2022 return;
2023
Al Viro330d57f2005-11-04 10:18:40 +00002024 spin_lock(&sysctl_lock);
2025 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04002026 if (!--header->parent->count) {
2027 WARN_ON(1);
2028 kfree(header->parent);
2029 }
Al Virof7e6ced2008-07-15 01:44:23 -04002030 if (!--header->count)
2031 kfree(header);
Al Viro330d57f2005-11-04 10:18:40 +00002032 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002033}
2034
Al Viro90434762008-07-15 08:54:06 -04002035int sysctl_is_seen(struct ctl_table_header *p)
2036{
2037 struct ctl_table_set *set = p->set;
2038 int res;
2039 spin_lock(&sysctl_lock);
2040 if (p->unregistering)
2041 res = 0;
2042 else if (!set->is_seen)
2043 res = 1;
2044 else
2045 res = set->is_seen(set);
2046 spin_unlock(&sysctl_lock);
2047 return res;
2048}
2049
Al Viro73455092008-07-14 21:22:20 -04002050void setup_sysctl_set(struct ctl_table_set *p,
2051 struct ctl_table_set *parent,
2052 int (*is_seen)(struct ctl_table_set *))
2053{
2054 INIT_LIST_HEAD(&p->list);
2055 p->parent = parent ? parent : &sysctl_table_root.default_set;
2056 p->is_seen = is_seen;
2057}
2058
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002059#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002060struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002061{
2062 return NULL;
2063}
2064
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002065struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2066 struct ctl_table *table)
2067{
2068 return NULL;
2069}
2070
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002071void unregister_sysctl_table(struct ctl_table_header * table)
2072{
2073}
2074
Al Viro73455092008-07-14 21:22:20 -04002075void setup_sysctl_set(struct ctl_table_set *p,
2076 struct ctl_table_set *parent,
2077 int (*is_seen)(struct ctl_table_set *))
2078{
2079}
2080
Al Virof7e6ced2008-07-15 01:44:23 -04002081void sysctl_head_put(struct ctl_table_header *head)
2082{
2083}
2084
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002085#endif /* CONFIG_SYSCTL */
2086
Linus Torvalds1da177e2005-04-16 15:20:36 -07002087/*
2088 * /proc/sys support
2089 */
2090
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002091#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002092
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002093static int _proc_do_string(void* data, int maxlen, int write,
2094 struct file *filp, void __user *buffer,
2095 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002096{
2097 size_t len;
2098 char __user *p;
2099 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002100
2101 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002102 *lenp = 0;
2103 return 0;
2104 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002105
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002106 if (write) {
2107 len = 0;
2108 p = buffer;
2109 while (len < *lenp) {
2110 if (get_user(c, p++))
2111 return -EFAULT;
2112 if (c == 0 || c == '\n')
2113 break;
2114 len++;
2115 }
2116 if (len >= maxlen)
2117 len = maxlen-1;
2118 if(copy_from_user(data, buffer, len))
2119 return -EFAULT;
2120 ((char *) data)[len] = 0;
2121 *ppos += *lenp;
2122 } else {
2123 len = strlen(data);
2124 if (len > maxlen)
2125 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002126
2127 if (*ppos > len) {
2128 *lenp = 0;
2129 return 0;
2130 }
2131
2132 data += *ppos;
2133 len -= *ppos;
2134
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002135 if (len > *lenp)
2136 len = *lenp;
2137 if (len)
2138 if(copy_to_user(buffer, data, len))
2139 return -EFAULT;
2140 if (len < *lenp) {
2141 if(put_user('\n', ((char __user *) buffer) + len))
2142 return -EFAULT;
2143 len++;
2144 }
2145 *lenp = len;
2146 *ppos += len;
2147 }
2148 return 0;
2149}
2150
Linus Torvalds1da177e2005-04-16 15:20:36 -07002151/**
2152 * proc_dostring - read a string sysctl
2153 * @table: the sysctl table
2154 * @write: %TRUE if this is a write to the sysctl file
2155 * @filp: the file structure
2156 * @buffer: the user buffer
2157 * @lenp: the size of the user buffer
2158 * @ppos: file position
2159 *
2160 * Reads/writes a string from/to the user buffer. If the kernel
2161 * buffer provided is not large enough to hold the string, the
2162 * string is truncated. The copied string is %NULL-terminated.
2163 * If the string is being read by the user process, it is copied
2164 * and a newline '\n' is added. It is truncated if the buffer is
2165 * not large enough.
2166 *
2167 * Returns 0 on success.
2168 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002169int proc_dostring(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002170 void __user *buffer, size_t *lenp, loff_t *ppos)
2171{
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002172 return _proc_do_string(table->data, table->maxlen, write, filp,
2173 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174}
2175
Linus Torvalds1da177e2005-04-16 15:20:36 -07002176
2177static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2178 int *valp,
2179 int write, void *data)
2180{
2181 if (write) {
2182 *valp = *negp ? -*lvalp : *lvalp;
2183 } else {
2184 int val = *valp;
2185 if (val < 0) {
2186 *negp = -1;
2187 *lvalp = (unsigned long)-val;
2188 } else {
2189 *negp = 0;
2190 *lvalp = (unsigned long)val;
2191 }
2192 }
2193 return 0;
2194}
2195
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002196static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002197 int write, struct file *filp, void __user *buffer,
2198 size_t *lenp, loff_t *ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002199 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2200 int write, void *data),
2201 void *data)
2202{
2203#define TMPBUFLEN 21
2204 int *i, vleft, first=1, neg, val;
2205 unsigned long lval;
2206 size_t left, len;
2207
2208 char buf[TMPBUFLEN], *p;
2209 char __user *s = buffer;
2210
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002211 if (!tbl_data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002212 (*ppos && !write)) {
2213 *lenp = 0;
2214 return 0;
2215 }
2216
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002217 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002218 vleft = table->maxlen / sizeof(*i);
2219 left = *lenp;
2220
2221 if (!conv)
2222 conv = do_proc_dointvec_conv;
2223
2224 for (; left && vleft--; i++, first=0) {
2225 if (write) {
2226 while (left) {
2227 char c;
2228 if (get_user(c, s))
2229 return -EFAULT;
2230 if (!isspace(c))
2231 break;
2232 left--;
2233 s++;
2234 }
2235 if (!left)
2236 break;
2237 neg = 0;
2238 len = left;
2239 if (len > sizeof(buf) - 1)
2240 len = sizeof(buf) - 1;
2241 if (copy_from_user(buf, s, len))
2242 return -EFAULT;
2243 buf[len] = 0;
2244 p = buf;
2245 if (*p == '-' && left > 1) {
2246 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002247 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002248 }
2249 if (*p < '0' || *p > '9')
2250 break;
2251
2252 lval = simple_strtoul(p, &p, 0);
2253
2254 len = p-buf;
2255 if ((len < left) && *p && !isspace(*p))
2256 break;
2257 if (neg)
2258 val = -val;
2259 s += len;
2260 left -= len;
2261
2262 if (conv(&neg, &lval, i, 1, data))
2263 break;
2264 } else {
2265 p = buf;
2266 if (!first)
2267 *p++ = '\t';
2268
2269 if (conv(&neg, &lval, i, 0, data))
2270 break;
2271
2272 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2273 len = strlen(buf);
2274 if (len > left)
2275 len = left;
2276 if(copy_to_user(s, buf, len))
2277 return -EFAULT;
2278 left -= len;
2279 s += len;
2280 }
2281 }
2282
2283 if (!write && !first && left) {
2284 if(put_user('\n', s))
2285 return -EFAULT;
2286 left--, s++;
2287 }
2288 if (write) {
2289 while (left) {
2290 char c;
2291 if (get_user(c, s++))
2292 return -EFAULT;
2293 if (!isspace(c))
2294 break;
2295 left--;
2296 }
2297 }
2298 if (write && first)
2299 return -EINVAL;
2300 *lenp -= left;
2301 *ppos += *lenp;
2302 return 0;
2303#undef TMPBUFLEN
2304}
2305
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002306static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002307 void __user *buffer, size_t *lenp, loff_t *ppos,
2308 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2309 int write, void *data),
2310 void *data)
2311{
2312 return __do_proc_dointvec(table->data, table, write, filp,
2313 buffer, lenp, ppos, conv, data);
2314}
2315
Linus Torvalds1da177e2005-04-16 15:20:36 -07002316/**
2317 * proc_dointvec - read a vector of integers
2318 * @table: the sysctl table
2319 * @write: %TRUE if this is a write to the sysctl file
2320 * @filp: the file structure
2321 * @buffer: the user buffer
2322 * @lenp: the size of the user buffer
2323 * @ppos: file position
2324 *
2325 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2326 * values from/to the user buffer, treated as an ASCII string.
2327 *
2328 * Returns 0 on success.
2329 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002330int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002331 void __user *buffer, size_t *lenp, loff_t *ppos)
2332{
2333 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2334 NULL,NULL);
2335}
2336
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002337/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002338 * Taint values can only be increased
2339 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002340 */
Andi Kleen25ddbb12008-10-15 22:01:41 -07002341static int proc_taint(struct ctl_table *table, int write, struct file *filp,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002342 void __user *buffer, size_t *lenp, loff_t *ppos)
2343{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002344 struct ctl_table t;
2345 unsigned long tmptaint = get_taint();
2346 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002347
Bastian Blank91fcd412007-04-23 14:41:14 -07002348 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002349 return -EPERM;
2350
Andi Kleen25ddbb12008-10-15 22:01:41 -07002351 t = *table;
2352 t.data = &tmptaint;
2353 err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos);
2354 if (err < 0)
2355 return err;
2356
2357 if (write) {
2358 /*
2359 * Poor man's atomic or. Not worth adding a primitive
2360 * to everyone's atomic.h for this
2361 */
2362 int i;
2363 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2364 if ((tmptaint >> i) & 1)
2365 add_taint(i);
2366 }
2367 }
2368
2369 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002370}
2371
Linus Torvalds1da177e2005-04-16 15:20:36 -07002372struct do_proc_dointvec_minmax_conv_param {
2373 int *min;
2374 int *max;
2375};
2376
2377static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2378 int *valp,
2379 int write, void *data)
2380{
2381 struct do_proc_dointvec_minmax_conv_param *param = data;
2382 if (write) {
2383 int val = *negp ? -*lvalp : *lvalp;
2384 if ((param->min && *param->min > val) ||
2385 (param->max && *param->max < val))
2386 return -EINVAL;
2387 *valp = val;
2388 } else {
2389 int val = *valp;
2390 if (val < 0) {
2391 *negp = -1;
2392 *lvalp = (unsigned long)-val;
2393 } else {
2394 *negp = 0;
2395 *lvalp = (unsigned long)val;
2396 }
2397 }
2398 return 0;
2399}
2400
2401/**
2402 * proc_dointvec_minmax - read a vector of integers with min/max values
2403 * @table: the sysctl table
2404 * @write: %TRUE if this is a write to the sysctl file
2405 * @filp: the file structure
2406 * @buffer: the user buffer
2407 * @lenp: the size of the user buffer
2408 * @ppos: file position
2409 *
2410 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2411 * values from/to the user buffer, treated as an ASCII string.
2412 *
2413 * This routine will ensure the values are within the range specified by
2414 * table->extra1 (min) and table->extra2 (max).
2415 *
2416 * Returns 0 on success.
2417 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002418int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002419 void __user *buffer, size_t *lenp, loff_t *ppos)
2420{
2421 struct do_proc_dointvec_minmax_conv_param param = {
2422 .min = (int *) table->extra1,
2423 .max = (int *) table->extra2,
2424 };
2425 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2426 do_proc_dointvec_minmax_conv, &param);
2427}
2428
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002429static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002430 struct file *filp,
2431 void __user *buffer,
2432 size_t *lenp, loff_t *ppos,
2433 unsigned long convmul,
2434 unsigned long convdiv)
2435{
2436#define TMPBUFLEN 21
2437 unsigned long *i, *min, *max, val;
2438 int vleft, first=1, neg;
2439 size_t len, left;
2440 char buf[TMPBUFLEN], *p;
2441 char __user *s = buffer;
2442
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002443 if (!data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002444 (*ppos && !write)) {
2445 *lenp = 0;
2446 return 0;
2447 }
2448
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002449 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002450 min = (unsigned long *) table->extra1;
2451 max = (unsigned long *) table->extra2;
2452 vleft = table->maxlen / sizeof(unsigned long);
2453 left = *lenp;
2454
2455 for (; left && vleft--; i++, min++, max++, first=0) {
2456 if (write) {
2457 while (left) {
2458 char c;
2459 if (get_user(c, s))
2460 return -EFAULT;
2461 if (!isspace(c))
2462 break;
2463 left--;
2464 s++;
2465 }
2466 if (!left)
2467 break;
2468 neg = 0;
2469 len = left;
2470 if (len > TMPBUFLEN-1)
2471 len = TMPBUFLEN-1;
2472 if (copy_from_user(buf, s, len))
2473 return -EFAULT;
2474 buf[len] = 0;
2475 p = buf;
2476 if (*p == '-' && left > 1) {
2477 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002478 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002479 }
2480 if (*p < '0' || *p > '9')
2481 break;
2482 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2483 len = p-buf;
2484 if ((len < left) && *p && !isspace(*p))
2485 break;
2486 if (neg)
2487 val = -val;
2488 s += len;
2489 left -= len;
2490
2491 if(neg)
2492 continue;
2493 if ((min && val < *min) || (max && val > *max))
2494 continue;
2495 *i = val;
2496 } else {
2497 p = buf;
2498 if (!first)
2499 *p++ = '\t';
2500 sprintf(p, "%lu", convdiv * (*i) / convmul);
2501 len = strlen(buf);
2502 if (len > left)
2503 len = left;
2504 if(copy_to_user(s, buf, len))
2505 return -EFAULT;
2506 left -= len;
2507 s += len;
2508 }
2509 }
2510
2511 if (!write && !first && left) {
2512 if(put_user('\n', s))
2513 return -EFAULT;
2514 left--, s++;
2515 }
2516 if (write) {
2517 while (left) {
2518 char c;
2519 if (get_user(c, s++))
2520 return -EFAULT;
2521 if (!isspace(c))
2522 break;
2523 left--;
2524 }
2525 }
2526 if (write && first)
2527 return -EINVAL;
2528 *lenp -= left;
2529 *ppos += *lenp;
2530 return 0;
2531#undef TMPBUFLEN
2532}
2533
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002534static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002535 struct file *filp,
2536 void __user *buffer,
2537 size_t *lenp, loff_t *ppos,
2538 unsigned long convmul,
2539 unsigned long convdiv)
2540{
2541 return __do_proc_doulongvec_minmax(table->data, table, write,
2542 filp, buffer, lenp, ppos, convmul, convdiv);
2543}
2544
Linus Torvalds1da177e2005-04-16 15:20:36 -07002545/**
2546 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2547 * @table: the sysctl table
2548 * @write: %TRUE if this is a write to the sysctl file
2549 * @filp: the file structure
2550 * @buffer: the user buffer
2551 * @lenp: the size of the user buffer
2552 * @ppos: file position
2553 *
2554 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2555 * values from/to the user buffer, treated as an ASCII string.
2556 *
2557 * This routine will ensure the values are within the range specified by
2558 * table->extra1 (min) and table->extra2 (max).
2559 *
2560 * Returns 0 on success.
2561 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002562int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002563 void __user *buffer, size_t *lenp, loff_t *ppos)
2564{
2565 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
2566}
2567
2568/**
2569 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2570 * @table: the sysctl table
2571 * @write: %TRUE if this is a write to the sysctl file
2572 * @filp: the file structure
2573 * @buffer: the user buffer
2574 * @lenp: the size of the user buffer
2575 * @ppos: file position
2576 *
2577 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2578 * values from/to the user buffer, treated as an ASCII string. The values
2579 * are treated as milliseconds, and converted to jiffies when they are stored.
2580 *
2581 * This routine will ensure the values are within the range specified by
2582 * table->extra1 (min) and table->extra2 (max).
2583 *
2584 * Returns 0 on success.
2585 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002586int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002587 struct file *filp,
2588 void __user *buffer,
2589 size_t *lenp, loff_t *ppos)
2590{
2591 return do_proc_doulongvec_minmax(table, write, filp, buffer,
2592 lenp, ppos, HZ, 1000l);
2593}
2594
2595
2596static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2597 int *valp,
2598 int write, void *data)
2599{
2600 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002601 if (*lvalp > LONG_MAX / HZ)
2602 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002603 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2604 } else {
2605 int val = *valp;
2606 unsigned long lval;
2607 if (val < 0) {
2608 *negp = -1;
2609 lval = (unsigned long)-val;
2610 } else {
2611 *negp = 0;
2612 lval = (unsigned long)val;
2613 }
2614 *lvalp = lval / HZ;
2615 }
2616 return 0;
2617}
2618
2619static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2620 int *valp,
2621 int write, void *data)
2622{
2623 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002624 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2625 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002626 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2627 } else {
2628 int val = *valp;
2629 unsigned long lval;
2630 if (val < 0) {
2631 *negp = -1;
2632 lval = (unsigned long)-val;
2633 } else {
2634 *negp = 0;
2635 lval = (unsigned long)val;
2636 }
2637 *lvalp = jiffies_to_clock_t(lval);
2638 }
2639 return 0;
2640}
2641
2642static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2643 int *valp,
2644 int write, void *data)
2645{
2646 if (write) {
2647 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2648 } else {
2649 int val = *valp;
2650 unsigned long lval;
2651 if (val < 0) {
2652 *negp = -1;
2653 lval = (unsigned long)-val;
2654 } else {
2655 *negp = 0;
2656 lval = (unsigned long)val;
2657 }
2658 *lvalp = jiffies_to_msecs(lval);
2659 }
2660 return 0;
2661}
2662
2663/**
2664 * proc_dointvec_jiffies - read a vector of integers as seconds
2665 * @table: the sysctl table
2666 * @write: %TRUE if this is a write to the sysctl file
2667 * @filp: the file structure
2668 * @buffer: the user buffer
2669 * @lenp: the size of the user buffer
2670 * @ppos: file position
2671 *
2672 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2673 * values from/to the user buffer, treated as an ASCII string.
2674 * The values read are assumed to be in seconds, and are converted into
2675 * jiffies.
2676 *
2677 * Returns 0 on success.
2678 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002679int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002680 void __user *buffer, size_t *lenp, loff_t *ppos)
2681{
2682 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2683 do_proc_dointvec_jiffies_conv,NULL);
2684}
2685
2686/**
2687 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2688 * @table: the sysctl table
2689 * @write: %TRUE if this is a write to the sysctl file
2690 * @filp: the file structure
2691 * @buffer: the user buffer
2692 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002693 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002694 *
2695 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2696 * values from/to the user buffer, treated as an ASCII string.
2697 * The values read are assumed to be in 1/USER_HZ seconds, and
2698 * are converted into jiffies.
2699 *
2700 * Returns 0 on success.
2701 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002702int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002703 void __user *buffer, size_t *lenp, loff_t *ppos)
2704{
2705 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2706 do_proc_dointvec_userhz_jiffies_conv,NULL);
2707}
2708
2709/**
2710 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2711 * @table: the sysctl table
2712 * @write: %TRUE if this is a write to the sysctl file
2713 * @filp: the file structure
2714 * @buffer: the user buffer
2715 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002716 * @ppos: file position
2717 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002718 *
2719 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2720 * values from/to the user buffer, treated as an ASCII string.
2721 * The values read are assumed to be in 1/1000 seconds, and
2722 * are converted into jiffies.
2723 *
2724 * Returns 0 on success.
2725 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002726int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002727 void __user *buffer, size_t *lenp, loff_t *ppos)
2728{
2729 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2730 do_proc_dointvec_ms_jiffies_conv, NULL);
2731}
2732
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002733static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002734 void __user *buffer, size_t *lenp, loff_t *ppos)
2735{
2736 struct pid *new_pid;
2737 pid_t tmp;
2738 int r;
2739
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002740 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002741
2742 r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
2743 lenp, ppos, NULL, NULL);
2744 if (r || !write)
2745 return r;
2746
2747 new_pid = find_get_pid(tmp);
2748 if (!new_pid)
2749 return -ESRCH;
2750
2751 put_pid(xchg(&cad_pid, new_pid));
2752 return 0;
2753}
2754
Linus Torvalds1da177e2005-04-16 15:20:36 -07002755#else /* CONFIG_PROC_FS */
2756
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002757int proc_dostring(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002758 void __user *buffer, size_t *lenp, loff_t *ppos)
2759{
2760 return -ENOSYS;
2761}
2762
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002763int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002764 void __user *buffer, size_t *lenp, loff_t *ppos)
2765{
2766 return -ENOSYS;
2767}
2768
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002769int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002770 void __user *buffer, size_t *lenp, loff_t *ppos)
2771{
2772 return -ENOSYS;
2773}
2774
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002775int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002776 void __user *buffer, size_t *lenp, loff_t *ppos)
2777{
2778 return -ENOSYS;
2779}
2780
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002781int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002782 void __user *buffer, size_t *lenp, loff_t *ppos)
2783{
2784 return -ENOSYS;
2785}
2786
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002787int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002788 void __user *buffer, size_t *lenp, loff_t *ppos)
2789{
2790 return -ENOSYS;
2791}
2792
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002793int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002794 void __user *buffer, size_t *lenp, loff_t *ppos)
2795{
2796 return -ENOSYS;
2797}
2798
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002799int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002800 struct file *filp,
2801 void __user *buffer,
2802 size_t *lenp, loff_t *ppos)
2803{
2804 return -ENOSYS;
2805}
2806
2807
2808#endif /* CONFIG_PROC_FS */
2809
2810
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002811#ifdef CONFIG_SYSCTL_SYSCALL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002812/*
2813 * General sysctl support routines
2814 */
2815
Eric W. Biederman49a0c452007-10-18 03:05:23 -07002816/* The generic sysctl data routine (used if no strategy routine supplied) */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002817int sysctl_data(struct ctl_table *table,
Eric W. Biederman49a0c452007-10-18 03:05:23 -07002818 void __user *oldval, size_t __user *oldlenp,
2819 void __user *newval, size_t newlen)
2820{
2821 size_t len;
2822
2823 /* Get out of I don't have a variable */
2824 if (!table->data || !table->maxlen)
2825 return -ENOTDIR;
2826
2827 if (oldval && oldlenp) {
2828 if (get_user(len, oldlenp))
2829 return -EFAULT;
2830 if (len) {
2831 if (len > table->maxlen)
2832 len = table->maxlen;
2833 if (copy_to_user(oldval, table->data, len))
2834 return -EFAULT;
2835 if (put_user(len, oldlenp))
2836 return -EFAULT;
2837 }
2838 }
2839
2840 if (newval && newlen) {
2841 if (newlen > table->maxlen)
2842 newlen = table->maxlen;
2843
2844 if (copy_from_user(table->data, newval, newlen))
2845 return -EFAULT;
2846 }
2847 return 1;
2848}
2849
Linus Torvalds1da177e2005-04-16 15:20:36 -07002850/* The generic string strategy routine: */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002851int sysctl_string(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002852 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002853 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002854{
Linus Torvalds1da177e2005-04-16 15:20:36 -07002855 if (!table->data || !table->maxlen)
2856 return -ENOTDIR;
2857
2858 if (oldval && oldlenp) {
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002859 size_t bufsize;
2860 if (get_user(bufsize, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002861 return -EFAULT;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002862 if (bufsize) {
2863 size_t len = strlen(table->data), copied;
2864
2865 /* This shouldn't trigger for a well-formed sysctl */
2866 if (len > table->maxlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002867 len = table->maxlen;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002868
2869 /* Copy up to a max of bufsize-1 bytes of the string */
2870 copied = (len >= bufsize) ? bufsize - 1 : len;
2871
2872 if (copy_to_user(oldval, table->data, copied) ||
2873 put_user(0, (char __user *)(oldval + copied)))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002874 return -EFAULT;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002875 if (put_user(len, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002876 return -EFAULT;
2877 }
2878 }
2879 if (newval && newlen) {
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002880 size_t len = newlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002881 if (len > table->maxlen)
2882 len = table->maxlen;
2883 if(copy_from_user(table->data, newval, len))
2884 return -EFAULT;
2885 if (len == table->maxlen)
2886 len--;
2887 ((char *) table->data)[len] = 0;
2888 }
Yi Yang82c9df82005-12-30 16:37:10 +08002889 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002890}
2891
2892/*
2893 * This function makes sure that all of the integers in the vector
2894 * are between the minimum and maximum values given in the arrays
2895 * table->extra1 and table->extra2, respectively.
2896 */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002897int sysctl_intvec(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002898 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002899 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002900{
2901
2902 if (newval && newlen) {
2903 int __user *vec = (int __user *) newval;
2904 int *min = (int *) table->extra1;
2905 int *max = (int *) table->extra2;
2906 size_t length;
2907 int i;
2908
2909 if (newlen % sizeof(int) != 0)
2910 return -EINVAL;
2911
2912 if (!table->extra1 && !table->extra2)
2913 return 0;
2914
2915 if (newlen > table->maxlen)
2916 newlen = table->maxlen;
2917 length = newlen / sizeof(int);
2918
2919 for (i = 0; i < length; i++) {
2920 int value;
2921 if (get_user(value, vec + i))
2922 return -EFAULT;
2923 if (min && value < min[i])
2924 return -EINVAL;
2925 if (max && value > max[i])
2926 return -EINVAL;
2927 }
2928 }
2929 return 0;
2930}
2931
2932/* Strategy function to convert jiffies to seconds */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002933int sysctl_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002934 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002935 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002936{
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002937 if (oldval && oldlenp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002938 size_t olen;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002939
2940 if (get_user(olen, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002941 return -EFAULT;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002942 if (olen) {
2943 int val;
2944
2945 if (olen < sizeof(int))
2946 return -EINVAL;
2947
2948 val = *(int *)(table->data) / HZ;
2949 if (put_user(val, (int __user *)oldval))
2950 return -EFAULT;
2951 if (put_user(sizeof(int), oldlenp))
2952 return -EFAULT;
2953 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002954 }
2955 if (newval && newlen) {
2956 int new;
2957 if (newlen != sizeof(int))
2958 return -EINVAL;
2959 if (get_user(new, (int __user *)newval))
2960 return -EFAULT;
2961 *(int *)(table->data) = new*HZ;
2962 }
2963 return 1;
2964}
2965
2966/* Strategy function to convert jiffies to seconds */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002967int sysctl_ms_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002968 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002969 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002970{
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002971 if (oldval && oldlenp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002972 size_t olen;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002973
2974 if (get_user(olen, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002975 return -EFAULT;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002976 if (olen) {
2977 int val;
2978
2979 if (olen < sizeof(int))
2980 return -EINVAL;
2981
2982 val = jiffies_to_msecs(*(int *)(table->data));
2983 if (put_user(val, (int __user *)oldval))
2984 return -EFAULT;
2985 if (put_user(sizeof(int), oldlenp))
2986 return -EFAULT;
2987 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002988 }
2989 if (newval && newlen) {
2990 int new;
2991 if (newlen != sizeof(int))
2992 return -EINVAL;
2993 if (get_user(new, (int __user *)newval))
2994 return -EFAULT;
2995 *(int *)(table->data) = msecs_to_jiffies(new);
2996 }
2997 return 1;
2998}
2999
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08003000
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08003001
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07003002#else /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003003
3004
3005asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
3006{
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003007 struct __sysctl_args tmp;
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003008 int error;
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003009
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003010 if (copy_from_user(&tmp, args, sizeof(tmp)))
3011 return -EFAULT;
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003012
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003013 error = deprecated_sysctl_warning(&tmp);
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07003014
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003015 /* If no error reading the parameters then just -ENOSYS ... */
3016 if (!error)
3017 error = -ENOSYS;
3018
3019 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003020}
3021
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003022int sysctl_data(struct ctl_table *table,
Eric W. Biederman49a0c452007-10-18 03:05:23 -07003023 void __user *oldval, size_t __user *oldlenp,
3024 void __user *newval, size_t newlen)
3025{
3026 return -ENOSYS;
3027}
3028
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003029int sysctl_string(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003030 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003031 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003032{
3033 return -ENOSYS;
3034}
3035
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003036int sysctl_intvec(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003037 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003038 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003039{
3040 return -ENOSYS;
3041}
3042
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003043int sysctl_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003044 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003045 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003046{
3047 return -ENOSYS;
3048}
3049
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003050int sysctl_ms_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003051 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003052 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003053{
3054 return -ENOSYS;
3055}
3056
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07003057#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003058
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003059static int deprecated_sysctl_warning(struct __sysctl_args *args)
3060{
3061 static int msg_count;
3062 int name[CTL_MAXNAME];
3063 int i;
3064
Tetsuo Handa6fc48af2007-11-14 16:58:38 -08003065 /* Check args->nlen. */
3066 if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
3067 return -ENOTDIR;
3068
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003069 /* Read in the sysctl name for better debug message logging */
3070 for (i = 0; i < args->nlen; i++)
3071 if (get_user(name[i], args->name + i))
3072 return -EFAULT;
3073
3074 /* Ignore accesses to kernel.version */
3075 if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
3076 return 0;
3077
3078 if (msg_count < 5) {
3079 msg_count++;
3080 printk(KERN_INFO
3081 "warning: process `%s' used the deprecated sysctl "
3082 "system call with ", current->comm);
3083 for (i = 0; i < args->nlen; i++)
3084 printk("%d.", name[i]);
3085 printk("\n");
3086 }
3087 return 0;
3088}
3089
Linus Torvalds1da177e2005-04-16 15:20:36 -07003090/*
3091 * No sense putting this after each symbol definition, twice,
3092 * exception granted :-)
3093 */
3094EXPORT_SYMBOL(proc_dointvec);
3095EXPORT_SYMBOL(proc_dointvec_jiffies);
3096EXPORT_SYMBOL(proc_dointvec_minmax);
3097EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3098EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3099EXPORT_SYMBOL(proc_dostring);
3100EXPORT_SYMBOL(proc_doulongvec_minmax);
3101EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3102EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11003103EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003104EXPORT_SYMBOL(sysctl_intvec);
3105EXPORT_SYMBOL(sysctl_jiffies);
3106EXPORT_SYMBOL(sysctl_ms_jiffies);
3107EXPORT_SYMBOL(sysctl_string);
Eric W. Biederman49a0c452007-10-18 03:05:23 -07003108EXPORT_SYMBOL(sysctl_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003109EXPORT_SYMBOL(unregister_sysctl_table);