blob: b125e3387568cc1c9c59b1cce982302a7693a40f [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>
David Howells12e22c52009-04-03 16:42:35 +010051#include <linux/slow-work.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53#include <asm/uaccess.h>
54#include <asm/processor.h>
55
Andi Kleen29cbc782006-09-30 01:47:55 +020056#ifdef CONFIG_X86
57#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010058#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010059#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020060#endif
61
Eric W. Biederman7058cb02007-10-18 03:05:58 -070062static int deprecated_sysctl_warning(struct __sysctl_args *args);
63
Linus Torvalds1da177e2005-04-16 15:20:36 -070064#if defined(CONFIG_SYSCTL)
65
66/* External variables not in a header file. */
67extern int C_A_D;
Ingo Molnar45807a12007-07-15 23:40:10 -070068extern int print_fatal_signals;
Linus Torvalds1da177e2005-04-16 15:20:36 -070069extern int sysctl_overcommit_memory;
70extern int sysctl_overcommit_ratio;
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -070071extern int sysctl_panic_on_oom;
David Rientjesfe071d72007-10-16 23:25:56 -070072extern int sysctl_oom_kill_allocating_task;
David Rientjesfef1bdd2008-02-07 00:14:07 -080073extern int sysctl_oom_dump_tasks;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070076extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070077extern char core_pattern[];
Linus Torvalds1da177e2005-04-16 15:20:36 -070078extern int pid_max;
79extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -070080extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -080081extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -080082extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +020083extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +010084extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -040085extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +000086#ifndef CONFIG_MMU
87extern int sysctl_nr_trim_pages;
88#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -070089#ifdef CONFIG_RCU_TORTURE_TEST
90extern int rcutorture_runnable;
91#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070093/* Constants used for minimum and maximum */
Bron Gondwana195cf452008-02-04 22:29:20 -080094#ifdef CONFIG_DETECT_SOFTLOCKUP
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070095static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +020096static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070097#endif
98
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070099static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700100static int __maybe_unused one = 1;
101static int __maybe_unused two = 2;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800102static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700103static int one_hundred = 100;
104
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
106static int maxolduid = 65535;
107static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800108static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109
110static int ngroups_max = NGROUPS_MAX;
111
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200112#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113extern char modprobe_path[];
114#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115#ifdef CONFIG_CHR_DEV_SG
116extern int sg_big_buff;
117#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
David S. Miller72c57ed2008-09-11 23:29:54 -0700119#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700120#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121#endif
122
David S. Miller08714202008-11-16 23:49:24 -0800123#ifdef CONFIG_SPARC64
124extern int sysctl_tsb_ratio;
125#endif
126
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127#ifdef __hppa__
128extern int pwrsw_enabled;
129extern int unaligned_enabled;
130#endif
131
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800132#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700133#ifdef CONFIG_MATHEMU
134extern int sysctl_ieee_emulation_warnings;
135#endif
136extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700137extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138#endif
139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140#ifdef CONFIG_BSD_PROCESS_ACCT
141extern int acct_parm[];
142#endif
143
Jes Sorensend2b176e2006-02-28 09:42:23 -0800144#ifdef CONFIG_IA64
145extern int no_unaligned_warning;
Doug Chapman88fc2412009-01-15 10:38:56 -0800146extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800147#endif
148
Ingo Molnar23f78d4a2006-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 Zickus8da5add2006-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 },
Doug Chapman88fc2412009-01-15 10:38:56 -0800784 {
785 .ctl_name = CTL_UNNUMBERED,
786 .procname = "unaligned-dump-stack",
787 .data = &unaligned_dump_stack,
788 .maxlen = sizeof (int),
789 .mode = 0644,
790 .proc_handler = &proc_dointvec,
791 },
Jes Sorensend2b176e2006-02-28 09:42:23 -0800792#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700793#ifdef CONFIG_DETECT_SOFTLOCKUP
794 {
795 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200796 .procname = "softlockup_panic",
797 .data = &softlockup_panic,
798 .maxlen = sizeof(int),
799 .mode = 0644,
Hiroshi Shimamoto4dca10a2008-07-07 18:37:04 -0700800 .proc_handler = &proc_dointvec_minmax,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200801 .strategy = &sysctl_intvec,
802 .extra1 = &zero,
803 .extra2 = &one,
804 },
805 {
806 .ctl_name = CTL_UNNUMBERED,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700807 .procname = "softlockup_thresh",
808 .data = &softlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200809 .maxlen = sizeof(int),
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700810 .mode = 0644,
Mandeep Singh Bainesbaf48f62009-01-12 21:15:17 -0800811 .proc_handler = &proc_dosoftlockup_thresh,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700812 .strategy = &sysctl_intvec,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200813 .extra1 = &neg_one,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700814 .extra2 = &sixty,
815 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100816 {
817 .ctl_name = CTL_UNNUMBERED,
818 .procname = "hung_task_check_count",
819 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100820 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100821 .mode = 0644,
Ingo Molnar90739082008-01-25 21:08:34 +0100822 .proc_handler = &proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100823 .strategy = &sysctl_intvec,
824 },
825 {
826 .ctl_name = CTL_UNNUMBERED,
827 .procname = "hung_task_timeout_secs",
828 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100829 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100830 .mode = 0644,
Ingo Molnar90739082008-01-25 21:08:34 +0100831 .proc_handler = &proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100832 .strategy = &sysctl_intvec,
833 },
834 {
835 .ctl_name = CTL_UNNUMBERED,
836 .procname = "hung_task_warnings",
837 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100838 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100839 .mode = 0644,
Ingo Molnar90739082008-01-25 21:08:34 +0100840 .proc_handler = &proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100841 .strategy = &sysctl_intvec,
842 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700843#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200844#ifdef CONFIG_COMPAT
845 {
846 .ctl_name = KERN_COMPAT_LOG,
847 .procname = "compat-log",
848 .data = &compat_log,
849 .maxlen = sizeof (int),
850 .mode = 0644,
851 .proc_handler = &proc_dointvec,
852 },
853#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700854#ifdef CONFIG_RT_MUTEXES
855 {
856 .ctl_name = KERN_MAX_LOCK_DEPTH,
857 .procname = "max_lock_depth",
858 .data = &max_lock_depth,
859 .maxlen = sizeof(int),
860 .mode = 0644,
861 .proc_handler = &proc_dointvec,
862 },
863#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700864 {
865 .ctl_name = CTL_UNNUMBERED,
866 .procname = "poweroff_cmd",
867 .data = &poweroff_cmd,
868 .maxlen = POWEROFF_CMD_PATH_LEN,
869 .mode = 0644,
870 .proc_handler = &proc_dostring,
871 .strategy = &sysctl_string,
872 },
David Howells0b77f5b2008-04-29 01:01:32 -0700873#ifdef CONFIG_KEYS
874 {
875 .ctl_name = CTL_UNNUMBERED,
876 .procname = "keys",
877 .mode = 0555,
878 .child = key_sysctls,
879 },
880#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700881#ifdef CONFIG_RCU_TORTURE_TEST
882 {
883 .ctl_name = CTL_UNNUMBERED,
884 .procname = "rcutorture_runnable",
885 .data = &rcutorture_runnable,
886 .maxlen = sizeof(int),
887 .mode = 0644,
888 .proc_handler = &proc_dointvec,
889 },
890#endif
Lee Schermerhornaf936a12008-10-18 20:26:53 -0700891#ifdef CONFIG_UNEVICTABLE_LRU
892 {
893 .ctl_name = CTL_UNNUMBERED,
894 .procname = "scan_unevictable_pages",
895 .data = &scan_unevictable_pages,
896 .maxlen = sizeof(scan_unevictable_pages),
897 .mode = 0644,
898 .proc_handler = &scan_unevictable_handler,
899 },
900#endif
David Howells12e22c52009-04-03 16:42:35 +0100901#ifdef CONFIG_SLOW_WORK
902 {
903 .ctl_name = CTL_UNNUMBERED,
904 .procname = "slow-work",
905 .mode = 0555,
906 .child = slow_work_sysctls,
907 },
908#endif
Andrew Mortoned2c12f2007-07-19 01:50:35 -0700909/*
910 * NOTE: do not add new entries to this table unless you have read
911 * Documentation/sysctl/ctl_unnumbered.txt
912 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913 { .ctl_name = 0 }
914};
915
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700916static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917 {
918 .ctl_name = VM_OVERCOMMIT_MEMORY,
919 .procname = "overcommit_memory",
920 .data = &sysctl_overcommit_memory,
921 .maxlen = sizeof(sysctl_overcommit_memory),
922 .mode = 0644,
923 .proc_handler = &proc_dointvec,
924 },
925 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700926 .ctl_name = VM_PANIC_ON_OOM,
927 .procname = "panic_on_oom",
928 .data = &sysctl_panic_on_oom,
929 .maxlen = sizeof(sysctl_panic_on_oom),
930 .mode = 0644,
931 .proc_handler = &proc_dointvec,
932 },
933 {
David Rientjesfe071d72007-10-16 23:25:56 -0700934 .ctl_name = CTL_UNNUMBERED,
935 .procname = "oom_kill_allocating_task",
936 .data = &sysctl_oom_kill_allocating_task,
937 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
938 .mode = 0644,
939 .proc_handler = &proc_dointvec,
940 },
941 {
David Rientjesfef1bdd2008-02-07 00:14:07 -0800942 .ctl_name = CTL_UNNUMBERED,
943 .procname = "oom_dump_tasks",
944 .data = &sysctl_oom_dump_tasks,
945 .maxlen = sizeof(sysctl_oom_dump_tasks),
946 .mode = 0644,
947 .proc_handler = &proc_dointvec,
948 },
949 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950 .ctl_name = VM_OVERCOMMIT_RATIO,
951 .procname = "overcommit_ratio",
952 .data = &sysctl_overcommit_ratio,
953 .maxlen = sizeof(sysctl_overcommit_ratio),
954 .mode = 0644,
955 .proc_handler = &proc_dointvec,
956 },
957 {
958 .ctl_name = VM_PAGE_CLUSTER,
959 .procname = "page-cluster",
960 .data = &page_cluster,
961 .maxlen = sizeof(int),
962 .mode = 0644,
963 .proc_handler = &proc_dointvec,
964 },
965 {
966 .ctl_name = VM_DIRTY_BACKGROUND,
967 .procname = "dirty_background_ratio",
968 .data = &dirty_background_ratio,
969 .maxlen = sizeof(dirty_background_ratio),
970 .mode = 0644,
David Rientjes2da02992009-01-06 14:39:31 -0800971 .proc_handler = &dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700972 .strategy = &sysctl_intvec,
973 .extra1 = &zero,
974 .extra2 = &one_hundred,
975 },
976 {
David Rientjes2da02992009-01-06 14:39:31 -0800977 .ctl_name = CTL_UNNUMBERED,
978 .procname = "dirty_background_bytes",
979 .data = &dirty_background_bytes,
980 .maxlen = sizeof(dirty_background_bytes),
981 .mode = 0644,
982 .proc_handler = &dirty_background_bytes_handler,
983 .strategy = &sysctl_intvec,
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800984 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -0800985 },
986 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 .ctl_name = VM_DIRTY_RATIO,
988 .procname = "dirty_ratio",
989 .data = &vm_dirty_ratio,
990 .maxlen = sizeof(vm_dirty_ratio),
991 .mode = 0644,
Peter Zijlstra04fbfdc2007-10-16 23:25:50 -0700992 .proc_handler = &dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993 .strategy = &sysctl_intvec,
994 .extra1 = &zero,
995 .extra2 = &one_hundred,
996 },
997 {
David Rientjes2da02992009-01-06 14:39:31 -0800998 .ctl_name = CTL_UNNUMBERED,
999 .procname = "dirty_bytes",
1000 .data = &vm_dirty_bytes,
1001 .maxlen = sizeof(vm_dirty_bytes),
1002 .mode = 0644,
1003 .proc_handler = &dirty_bytes_handler,
1004 .strategy = &sysctl_intvec,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001005 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001006 },
1007 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001008 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001009 .data = &dirty_writeback_interval,
1010 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011 .mode = 0644,
1012 .proc_handler = &dirty_writeback_centisecs_handler,
1013 },
1014 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001016 .data = &dirty_expire_interval,
1017 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001018 .mode = 0644,
Alexey Dobriyan704503d2009-03-31 15:23:18 -07001019 .proc_handler = &proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001020 },
1021 {
1022 .ctl_name = VM_NR_PDFLUSH_THREADS,
1023 .procname = "nr_pdflush_threads",
1024 .data = &nr_pdflush_threads,
1025 .maxlen = sizeof nr_pdflush_threads,
1026 .mode = 0444 /* read-only*/,
1027 .proc_handler = &proc_dointvec,
1028 },
1029 {
1030 .ctl_name = VM_SWAPPINESS,
1031 .procname = "swappiness",
1032 .data = &vm_swappiness,
1033 .maxlen = sizeof(vm_swappiness),
1034 .mode = 0644,
1035 .proc_handler = &proc_dointvec_minmax,
1036 .strategy = &sysctl_intvec,
1037 .extra1 = &zero,
1038 .extra2 = &one_hundred,
1039 },
1040#ifdef CONFIG_HUGETLB_PAGE
1041 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001042 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001043 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001044 .maxlen = sizeof(unsigned long),
1045 .mode = 0644,
1046 .proc_handler = &hugetlb_sysctl_handler,
1047 .extra1 = (void *)&hugetlb_zero,
1048 .extra2 = (void *)&hugetlb_infinity,
1049 },
1050 {
1051 .ctl_name = VM_HUGETLB_GROUP,
1052 .procname = "hugetlb_shm_group",
1053 .data = &sysctl_hugetlb_shm_group,
1054 .maxlen = sizeof(gid_t),
1055 .mode = 0644,
1056 .proc_handler = &proc_dointvec,
1057 },
Mel Gorman396faf02007-07-17 04:03:13 -07001058 {
1059 .ctl_name = CTL_UNNUMBERED,
1060 .procname = "hugepages_treat_as_movable",
1061 .data = &hugepages_treat_as_movable,
1062 .maxlen = sizeof(int),
1063 .mode = 0644,
1064 .proc_handler = &hugetlb_treat_movable_handler,
1065 },
Adam Litke54f9f802007-10-16 01:26:20 -07001066 {
1067 .ctl_name = CTL_UNNUMBERED,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001068 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001069 .data = NULL,
1070 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001071 .mode = 0644,
Nishanth Aravamudana3d0c6a2008-02-08 04:18:18 -08001072 .proc_handler = &hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001073 .extra1 = (void *)&hugetlb_zero,
1074 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001075 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001076#endif
1077 {
1078 .ctl_name = VM_LOWMEM_RESERVE_RATIO,
1079 .procname = "lowmem_reserve_ratio",
1080 .data = &sysctl_lowmem_reserve_ratio,
1081 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1082 .mode = 0644,
1083 .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
1084 .strategy = &sysctl_intvec,
1085 },
1086 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001087 .ctl_name = VM_DROP_PAGECACHE,
1088 .procname = "drop_caches",
1089 .data = &sysctl_drop_caches,
1090 .maxlen = sizeof(int),
1091 .mode = 0644,
1092 .proc_handler = drop_caches_sysctl_handler,
1093 .strategy = &sysctl_intvec,
1094 },
1095 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001096 .ctl_name = VM_MIN_FREE_KBYTES,
1097 .procname = "min_free_kbytes",
1098 .data = &min_free_kbytes,
1099 .maxlen = sizeof(min_free_kbytes),
1100 .mode = 0644,
1101 .proc_handler = &min_free_kbytes_sysctl_handler,
1102 .strategy = &sysctl_intvec,
1103 .extra1 = &zero,
1104 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001105 {
1106 .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
1107 .procname = "percpu_pagelist_fraction",
1108 .data = &percpu_pagelist_fraction,
1109 .maxlen = sizeof(percpu_pagelist_fraction),
1110 .mode = 0644,
1111 .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
1112 .strategy = &sysctl_intvec,
1113 .extra1 = &min_percpu_pagelist_fract,
1114 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115#ifdef CONFIG_MMU
1116 {
1117 .ctl_name = VM_MAX_MAP_COUNT,
1118 .procname = "max_map_count",
1119 .data = &sysctl_max_map_count,
1120 .maxlen = sizeof(sysctl_max_map_count),
1121 .mode = 0644,
1122 .proc_handler = &proc_dointvec
1123 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001124#else
1125 {
1126 .ctl_name = CTL_UNNUMBERED,
1127 .procname = "nr_trim_pages",
1128 .data = &sysctl_nr_trim_pages,
1129 .maxlen = sizeof(sysctl_nr_trim_pages),
1130 .mode = 0644,
1131 .proc_handler = &proc_dointvec_minmax,
1132 .strategy = &sysctl_intvec,
1133 .extra1 = &zero,
1134 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135#endif
1136 {
1137 .ctl_name = VM_LAPTOP_MODE,
1138 .procname = "laptop_mode",
1139 .data = &laptop_mode,
1140 .maxlen = sizeof(laptop_mode),
1141 .mode = 0644,
Bart Samweled5b43f2006-03-24 03:15:49 -08001142 .proc_handler = &proc_dointvec_jiffies,
1143 .strategy = &sysctl_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 },
1145 {
1146 .ctl_name = VM_BLOCK_DUMP,
1147 .procname = "block_dump",
1148 .data = &block_dump,
1149 .maxlen = sizeof(block_dump),
1150 .mode = 0644,
1151 .proc_handler = &proc_dointvec,
1152 .strategy = &sysctl_intvec,
1153 .extra1 = &zero,
1154 },
1155 {
1156 .ctl_name = VM_VFS_CACHE_PRESSURE,
1157 .procname = "vfs_cache_pressure",
1158 .data = &sysctl_vfs_cache_pressure,
1159 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1160 .mode = 0644,
1161 .proc_handler = &proc_dointvec,
1162 .strategy = &sysctl_intvec,
1163 .extra1 = &zero,
1164 },
1165#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1166 {
1167 .ctl_name = VM_LEGACY_VA_LAYOUT,
1168 .procname = "legacy_va_layout",
1169 .data = &sysctl_legacy_va_layout,
1170 .maxlen = sizeof(sysctl_legacy_va_layout),
1171 .mode = 0644,
1172 .proc_handler = &proc_dointvec,
1173 .strategy = &sysctl_intvec,
1174 .extra1 = &zero,
1175 },
1176#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001177#ifdef CONFIG_NUMA
1178 {
1179 .ctl_name = VM_ZONE_RECLAIM_MODE,
1180 .procname = "zone_reclaim_mode",
1181 .data = &zone_reclaim_mode,
1182 .maxlen = sizeof(zone_reclaim_mode),
1183 .mode = 0644,
1184 .proc_handler = &proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001185 .strategy = &sysctl_intvec,
1186 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001187 },
Christoph Lameter96146342006-07-03 00:24:13 -07001188 {
1189 .ctl_name = VM_MIN_UNMAPPED,
1190 .procname = "min_unmapped_ratio",
1191 .data = &sysctl_min_unmapped_ratio,
1192 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1193 .mode = 0644,
1194 .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
1195 .strategy = &sysctl_intvec,
1196 .extra1 = &zero,
1197 .extra2 = &one_hundred,
1198 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001199 {
1200 .ctl_name = VM_MIN_SLAB,
1201 .procname = "min_slab_ratio",
1202 .data = &sysctl_min_slab_ratio,
1203 .maxlen = sizeof(sysctl_min_slab_ratio),
1204 .mode = 0644,
1205 .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
1206 .strategy = &sysctl_intvec,
1207 .extra1 = &zero,
1208 .extra2 = &one_hundred,
1209 },
Christoph Lameter17436602006-01-18 17:42:32 -08001210#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001211#ifdef CONFIG_SMP
1212 {
1213 .ctl_name = CTL_UNNUMBERED,
1214 .procname = "stat_interval",
1215 .data = &sysctl_stat_interval,
1216 .maxlen = sizeof(sysctl_stat_interval),
1217 .mode = 0644,
1218 .proc_handler = &proc_dointvec_jiffies,
1219 .strategy = &sysctl_jiffies,
1220 },
1221#endif
Eric Parised032182007-06-28 15:55:21 -04001222#ifdef CONFIG_SECURITY
1223 {
1224 .ctl_name = CTL_UNNUMBERED,
1225 .procname = "mmap_min_addr",
1226 .data = &mmap_min_addr,
1227 .maxlen = sizeof(unsigned long),
1228 .mode = 0644,
1229 .proc_handler = &proc_doulongvec_minmax,
1230 },
Lee Schermerhorn8daec962007-08-10 13:00:51 -07001231#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001232#ifdef CONFIG_NUMA
1233 {
1234 .ctl_name = CTL_UNNUMBERED,
1235 .procname = "numa_zonelist_order",
1236 .data = &numa_zonelist_order,
1237 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1238 .mode = 0644,
1239 .proc_handler = &numa_zonelist_order_handler,
1240 .strategy = &sysctl_string,
1241 },
1242#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001243#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001244 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001245 {
1246 .ctl_name = VM_VDSO_ENABLED,
1247 .procname = "vdso_enabled",
1248 .data = &vdso_enabled,
1249 .maxlen = sizeof(vdso_enabled),
1250 .mode = 0644,
1251 .proc_handler = &proc_dointvec,
1252 .strategy = &sysctl_intvec,
1253 .extra1 = &zero,
1254 },
1255#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001256#ifdef CONFIG_HIGHMEM
1257 {
1258 .ctl_name = CTL_UNNUMBERED,
1259 .procname = "highmem_is_dirtyable",
1260 .data = &vm_highmem_is_dirtyable,
1261 .maxlen = sizeof(vm_highmem_is_dirtyable),
1262 .mode = 0644,
1263 .proc_handler = &proc_dointvec_minmax,
1264 .strategy = &sysctl_intvec,
1265 .extra1 = &zero,
1266 .extra2 = &one,
1267 },
1268#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001269/*
1270 * NOTE: do not add new entries to this table unless you have read
1271 * Documentation/sysctl/ctl_unnumbered.txt
1272 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001273 { .ctl_name = 0 }
1274};
1275
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001276#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001277static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001278 { .ctl_name = 0 }
1279};
1280#endif
1281
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001282static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001283 {
1284 .ctl_name = FS_NRINODE,
1285 .procname = "inode-nr",
1286 .data = &inodes_stat,
1287 .maxlen = 2*sizeof(int),
1288 .mode = 0444,
1289 .proc_handler = &proc_dointvec,
1290 },
1291 {
1292 .ctl_name = FS_STATINODE,
1293 .procname = "inode-state",
1294 .data = &inodes_stat,
1295 .maxlen = 7*sizeof(int),
1296 .mode = 0444,
1297 .proc_handler = &proc_dointvec,
1298 },
1299 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300 .procname = "file-nr",
1301 .data = &files_stat,
1302 .maxlen = 3*sizeof(int),
1303 .mode = 0444,
Dipankar Sarma529bf6b2006-03-07 21:55:35 -08001304 .proc_handler = &proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001305 },
1306 {
1307 .ctl_name = FS_MAXFILE,
1308 .procname = "file-max",
1309 .data = &files_stat.max_files,
1310 .maxlen = sizeof(int),
1311 .mode = 0644,
1312 .proc_handler = &proc_dointvec,
1313 },
1314 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001315 .ctl_name = CTL_UNNUMBERED,
1316 .procname = "nr_open",
1317 .data = &sysctl_nr_open,
1318 .maxlen = sizeof(int),
1319 .mode = 0644,
Al Viroeceea0b2008-05-10 10:08:32 -04001320 .proc_handler = &proc_dointvec_minmax,
1321 .extra1 = &sysctl_nr_open_min,
1322 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001323 },
1324 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 .ctl_name = FS_DENTRY,
1326 .procname = "dentry-state",
1327 .data = &dentry_stat,
1328 .maxlen = 6*sizeof(int),
1329 .mode = 0444,
1330 .proc_handler = &proc_dointvec,
1331 },
1332 {
1333 .ctl_name = FS_OVERFLOWUID,
1334 .procname = "overflowuid",
1335 .data = &fs_overflowuid,
1336 .maxlen = sizeof(int),
1337 .mode = 0644,
1338 .proc_handler = &proc_dointvec_minmax,
1339 .strategy = &sysctl_intvec,
1340 .extra1 = &minolduid,
1341 .extra2 = &maxolduid,
1342 },
1343 {
1344 .ctl_name = FS_OVERFLOWGID,
1345 .procname = "overflowgid",
1346 .data = &fs_overflowgid,
1347 .maxlen = sizeof(int),
1348 .mode = 0644,
1349 .proc_handler = &proc_dointvec_minmax,
1350 .strategy = &sysctl_intvec,
1351 .extra1 = &minolduid,
1352 .extra2 = &maxolduid,
1353 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001354#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355 {
1356 .ctl_name = FS_LEASES,
1357 .procname = "leases-enable",
1358 .data = &leases_enable,
1359 .maxlen = sizeof(int),
1360 .mode = 0644,
1361 .proc_handler = &proc_dointvec,
1362 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001363#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001364#ifdef CONFIG_DNOTIFY
1365 {
1366 .ctl_name = FS_DIR_NOTIFY,
1367 .procname = "dir-notify-enable",
1368 .data = &dir_notify_enable,
1369 .maxlen = sizeof(int),
1370 .mode = 0644,
1371 .proc_handler = &proc_dointvec,
1372 },
1373#endif
1374#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001375#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001376 {
1377 .ctl_name = FS_LEASE_TIME,
1378 .procname = "lease-break-time",
1379 .data = &lease_break_time,
1380 .maxlen = sizeof(int),
1381 .mode = 0644,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001382 .proc_handler = &proc_dointvec,
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,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001423 .proc_handler = &proc_dointvec_minmax,
1424 .strategy = &sysctl_intvec,
1425 .extra1 = &zero,
1426 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001427 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001428#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1429 {
1430 .ctl_name = CTL_UNNUMBERED,
1431 .procname = "binfmt_misc",
1432 .mode = 0555,
1433 .child = binfmt_misc_table,
1434 },
1435#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001436/*
1437 * NOTE: do not add new entries to this table unless you have read
1438 * Documentation/sysctl/ctl_unnumbered.txt
1439 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001440 { .ctl_name = 0 }
1441};
1442
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001443static struct ctl_table debug_table[] = {
Olof Johanssond0c3d532007-10-12 10:20:07 +10001444#if defined(CONFIG_X86) || defined(CONFIG_PPC)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001445 {
1446 .ctl_name = CTL_UNNUMBERED,
1447 .procname = "exception-trace",
1448 .data = &show_unhandled_signals,
1449 .maxlen = sizeof(int),
1450 .mode = 0644,
1451 .proc_handler = proc_dointvec
1452 },
1453#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001454 { .ctl_name = 0 }
1455};
1456
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001457static struct ctl_table dev_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001458 { .ctl_name = 0 }
Robert Love0eeca282005-07-12 17:06:03 -04001459};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001460
Al Viro330d57f2005-11-04 10:18:40 +00001461static DEFINE_SPINLOCK(sysctl_lock);
1462
1463/* called under sysctl_lock */
1464static int use_table(struct ctl_table_header *p)
1465{
1466 if (unlikely(p->unregistering))
1467 return 0;
1468 p->used++;
1469 return 1;
1470}
1471
1472/* called under sysctl_lock */
1473static void unuse_table(struct ctl_table_header *p)
1474{
1475 if (!--p->used)
1476 if (unlikely(p->unregistering))
1477 complete(p->unregistering);
1478}
1479
1480/* called under sysctl_lock, will reacquire if has to wait */
1481static void start_unregistering(struct ctl_table_header *p)
1482{
1483 /*
1484 * if p->used is 0, nobody will ever touch that entry again;
1485 * we'll eliminate all paths to it before dropping sysctl_lock
1486 */
1487 if (unlikely(p->used)) {
1488 struct completion wait;
1489 init_completion(&wait);
1490 p->unregistering = &wait;
1491 spin_unlock(&sysctl_lock);
1492 wait_for_completion(&wait);
1493 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001494 } else {
1495 /* anything non-NULL; we'll never dereference it */
1496 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001497 }
1498 /*
1499 * do not remove from the list until nobody holds it; walking the
1500 * list in do_sysctl() relies on that.
1501 */
1502 list_del_init(&p->ctl_entry);
1503}
1504
Al Virof7e6ced2008-07-15 01:44:23 -04001505void sysctl_head_get(struct ctl_table_header *head)
1506{
1507 spin_lock(&sysctl_lock);
1508 head->count++;
1509 spin_unlock(&sysctl_lock);
1510}
1511
1512void sysctl_head_put(struct ctl_table_header *head)
1513{
1514 spin_lock(&sysctl_lock);
1515 if (!--head->count)
1516 kfree(head);
1517 spin_unlock(&sysctl_lock);
1518}
1519
1520struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1521{
1522 if (!head)
1523 BUG();
1524 spin_lock(&sysctl_lock);
1525 if (!use_table(head))
1526 head = ERR_PTR(-ENOENT);
1527 spin_unlock(&sysctl_lock);
1528 return head;
1529}
1530
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001531void sysctl_head_finish(struct ctl_table_header *head)
1532{
1533 if (!head)
1534 return;
1535 spin_lock(&sysctl_lock);
1536 unuse_table(head);
1537 spin_unlock(&sysctl_lock);
1538}
1539
Al Viro73455092008-07-14 21:22:20 -04001540static struct ctl_table_set *
1541lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1542{
1543 struct ctl_table_set *set = &root->default_set;
1544 if (root->lookup)
1545 set = root->lookup(root, namespaces);
1546 return set;
1547}
1548
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001549static struct list_head *
1550lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001551{
Al Viro73455092008-07-14 21:22:20 -04001552 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1553 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001554}
1555
1556struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1557 struct ctl_table_header *prev)
1558{
1559 struct ctl_table_root *root;
1560 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001561 struct ctl_table_header *head;
1562 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001563
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001564 spin_lock(&sysctl_lock);
1565 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001566 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001567 tmp = &prev->ctl_entry;
1568 unuse_table(prev);
1569 goto next;
1570 }
1571 tmp = &root_table_header.ctl_entry;
1572 for (;;) {
1573 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1574
1575 if (!use_table(head))
1576 goto next;
1577 spin_unlock(&sysctl_lock);
1578 return head;
1579 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001580 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001581 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001582 header_list = lookup_header_list(root, namespaces);
1583 if (tmp != header_list)
1584 continue;
1585
1586 do {
1587 root = list_entry(root->root_list.next,
1588 struct ctl_table_root, root_list);
1589 if (root == &sysctl_table_root)
1590 goto out;
1591 header_list = lookup_header_list(root, namespaces);
1592 } while (list_empty(header_list));
1593 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001594 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001595out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001596 spin_unlock(&sysctl_lock);
1597 return NULL;
1598}
1599
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001600struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1601{
1602 return __sysctl_head_next(current->nsproxy, prev);
1603}
1604
1605void register_sysctl_root(struct ctl_table_root *root)
1606{
1607 spin_lock(&sysctl_lock);
1608 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1609 spin_unlock(&sysctl_lock);
1610}
1611
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001612#ifdef CONFIG_SYSCTL_SYSCALL
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001613/* Perform the actual read/write of a sysctl table entry. */
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001614static int do_sysctl_strategy(struct ctl_table_root *root,
1615 struct ctl_table *table,
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001616 void __user *oldval, size_t __user *oldlenp,
1617 void __user *newval, size_t newlen)
1618{
1619 int op = 0, rc;
1620
1621 if (oldval)
Al Viroe6305c42008-07-15 21:03:57 -04001622 op |= MAY_READ;
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001623 if (newval)
Al Viroe6305c42008-07-15 21:03:57 -04001624 op |= MAY_WRITE;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001625 if (sysctl_perm(root, table, op))
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001626 return -EPERM;
1627
1628 if (table->strategy) {
Alexey Dobriyanf221e722008-10-15 22:04:23 -07001629 rc = table->strategy(table, oldval, oldlenp, newval, newlen);
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001630 if (rc < 0)
1631 return rc;
1632 if (rc > 0)
1633 return 0;
1634 }
1635
1636 /* If there is no strategy routine, or if the strategy returns
1637 * zero, proceed with automatic r/w */
1638 if (table->data && table->maxlen) {
Alexey Dobriyanf221e722008-10-15 22:04:23 -07001639 rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001640 if (rc < 0)
1641 return rc;
1642 }
1643 return 0;
1644}
1645
1646static int parse_table(int __user *name, int nlen,
1647 void __user *oldval, size_t __user *oldlenp,
1648 void __user *newval, size_t newlen,
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001649 struct ctl_table_root *root,
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001650 struct ctl_table *table)
1651{
1652 int n;
1653repeat:
1654 if (!nlen)
1655 return -ENOTDIR;
1656 if (get_user(n, name))
1657 return -EFAULT;
1658 for ( ; table->ctl_name || table->procname; table++) {
1659 if (!table->ctl_name)
1660 continue;
1661 if (n == table->ctl_name) {
1662 int error;
1663 if (table->child) {
Al Viroe6305c42008-07-15 21:03:57 -04001664 if (sysctl_perm(root, table, MAY_EXEC))
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001665 return -EPERM;
1666 name++;
1667 nlen--;
1668 table = table->child;
1669 goto repeat;
1670 }
Alexey Dobriyanf221e722008-10-15 22:04:23 -07001671 error = do_sysctl_strategy(root, table,
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001672 oldval, oldlenp,
1673 newval, newlen);
1674 return error;
1675 }
1676 }
1677 return -ENOTDIR;
1678}
1679
Linus Torvalds1da177e2005-04-16 15:20:36 -07001680int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1681 void __user *newval, size_t newlen)
1682{
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001683 struct ctl_table_header *head;
Al Viro330d57f2005-11-04 10:18:40 +00001684 int error = -ENOTDIR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685
1686 if (nlen <= 0 || nlen >= CTL_MAXNAME)
1687 return -ENOTDIR;
1688 if (oldval) {
1689 int old_len;
1690 if (!oldlenp || get_user(old_len, oldlenp))
1691 return -EFAULT;
1692 }
Al Viro330d57f2005-11-04 10:18:40 +00001693
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001694 for (head = sysctl_head_next(NULL); head;
1695 head = sysctl_head_next(head)) {
Al Viro330d57f2005-11-04 10:18:40 +00001696 error = parse_table(name, nlen, oldval, oldlenp,
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001697 newval, newlen,
1698 head->root, head->ctl_table);
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001699 if (error != -ENOTDIR) {
1700 sysctl_head_finish(head);
Al Viro330d57f2005-11-04 10:18:40 +00001701 break;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001702 }
1703 }
Al Viro330d57f2005-11-04 10:18:40 +00001704 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001705}
1706
Heiko Carstens1e7bfb22009-01-14 14:14:29 +01001707SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001708{
1709 struct __sysctl_args tmp;
1710 int error;
1711
1712 if (copy_from_user(&tmp, args, sizeof(tmp)))
1713 return -EFAULT;
1714
Eric W. Biederman7058cb02007-10-18 03:05:58 -07001715 error = deprecated_sysctl_warning(&tmp);
1716 if (error)
1717 goto out;
1718
Linus Torvalds1da177e2005-04-16 15:20:36 -07001719 lock_kernel();
1720 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1721 tmp.newval, tmp.newlen);
1722 unlock_kernel();
Eric W. Biederman7058cb02007-10-18 03:05:58 -07001723out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001724 return error;
1725}
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001726#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001727
1728/*
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001729 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001730 * some sysctl variables are readonly even to root.
1731 */
1732
1733static int test_perm(int mode, int op)
1734{
David Howells76aac0e2008-11-14 10:39:12 +11001735 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736 mode >>= 6;
1737 else if (in_egroup_p(0))
1738 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001739 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740 return 0;
1741 return -EACCES;
1742}
1743
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001744int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001745{
1746 int error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001747 int mode;
1748
Al Viroe6305c42008-07-15 21:03:57 -04001749 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750 if (error)
1751 return error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001752
1753 if (root->permissions)
1754 mode = root->permissions(root, current->nsproxy, table);
1755 else
1756 mode = table->mode;
1757
1758 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001759}
1760
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001761static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1762{
1763 for (; table->ctl_name || table->procname; table++) {
1764 table->parent = parent;
1765 if (table->child)
1766 sysctl_set_parent(table, table->child);
1767 }
1768}
1769
1770static __init int sysctl_init(void)
1771{
1772 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001773#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1774 {
1775 int err;
1776 err = sysctl_check_table(current->nsproxy, root_table);
1777 }
1778#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001779 return 0;
1780}
1781
1782core_initcall(sysctl_init);
1783
Al Virobfbcf032008-07-27 06:31:22 +01001784static struct ctl_table *is_branch_in(struct ctl_table *branch,
1785 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001786{
1787 struct ctl_table *p;
1788 const char *s = branch->procname;
1789
1790 /* branch should have named subdirectory as its first element */
1791 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001792 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001793
1794 /* ... and nothing else */
1795 if (branch[1].procname || branch[1].ctl_name)
Al Virobfbcf032008-07-27 06:31:22 +01001796 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001797
1798 /* table should contain subdirectory with the same name */
1799 for (p = table; p->procname || p->ctl_name; p++) {
1800 if (!p->child)
1801 continue;
1802 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001803 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001804 }
Al Virobfbcf032008-07-27 06:31:22 +01001805 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001806}
1807
1808/* see if attaching q to p would be an improvement */
1809static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1810{
1811 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001812 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001813 int is_better = 0;
1814 int not_in_parent = !p->attached_by;
1815
Al Virobfbcf032008-07-27 06:31:22 +01001816 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001817 if (by == q->attached_by)
1818 is_better = 1;
1819 if (to == p->attached_by)
1820 not_in_parent = 1;
1821 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001822 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001823 }
1824
1825 if (is_better && not_in_parent) {
1826 q->attached_by = by;
1827 q->attached_to = to;
1828 q->parent = p;
1829 }
1830}
1831
Linus Torvalds1da177e2005-04-16 15:20:36 -07001832/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001833 * __register_sysctl_paths - register a sysctl hierarchy
1834 * @root: List of sysctl headers to register on
1835 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001836 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001837 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001838 *
1839 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001840 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001841 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001842 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001843 *
1844 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1845 * must be unique within that level of sysctl
1846 *
1847 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1848 * enter a sysctl file
1849 *
1850 * data - a pointer to data for use by proc_handler
1851 *
1852 * maxlen - the maximum size in bytes of the data
1853 *
1854 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1855 *
1856 * child - a pointer to the child sysctl table if this entry is a directory, or
1857 * %NULL.
1858 *
1859 * proc_handler - the text handler routine (described below)
1860 *
1861 * strategy - the strategy routine (described below)
1862 *
1863 * de - for internal use by the sysctl routines
1864 *
1865 * extra1, extra2 - extra pointers usable by the proc handler routines
1866 *
1867 * Leaf nodes in the sysctl tree will be represented by a single file
1868 * under /proc; non-leaf nodes will be represented by directories.
1869 *
1870 * sysctl(2) can automatically manage read and write requests through
1871 * the sysctl table. The data and maxlen fields of the ctl_table
1872 * struct enable minimal validation of the values being written to be
1873 * performed, and the mode field allows minimal authentication.
1874 *
1875 * More sophisticated management can be enabled by the provision of a
1876 * strategy routine with the table entry. This will be called before
1877 * any automatic read or write of the data is performed.
1878 *
1879 * The strategy routine may return
1880 *
1881 * < 0 - Error occurred (error is passed to user process)
1882 *
1883 * 0 - OK - proceed with automatic read or write.
1884 *
1885 * > 0 - OK - read or write has been done by the strategy routine, so
1886 * return immediately.
1887 *
1888 * There must be a proc_handler routine for any terminal nodes
1889 * mirrored under /proc/sys (non-terminals are handled by a built-in
1890 * directory handler). Several default handlers are available to
1891 * cover common cases -
1892 *
1893 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1894 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1895 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1896 *
1897 * It is the handler's job to read the input buffer from user memory
1898 * and process it. The handler should return 0 on success.
1899 *
1900 * This routine returns %NULL on a failure to register, and a pointer
1901 * to the table header on success.
1902 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001903struct ctl_table_header *__register_sysctl_paths(
1904 struct ctl_table_root *root,
1905 struct nsproxy *namespaces,
1906 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001907{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001908 struct ctl_table_header *header;
1909 struct ctl_table *new, **prevp;
1910 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001911 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001912
1913 /* Count the path components */
1914 for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
1915 ;
1916
1917 /*
1918 * For each path component, allocate a 2-element ctl_table array.
1919 * The first array element will be filled with the sysctl entry
1920 * for this, the second will be the sentinel (ctl_name == 0).
1921 *
1922 * We allocate everything in one go so that we don't have to
1923 * worry about freeing additional memory in unregister_sysctl_table.
1924 */
1925 header = kzalloc(sizeof(struct ctl_table_header) +
1926 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1927 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001928 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001929
1930 new = (struct ctl_table *) (header + 1);
1931
1932 /* Now connect the dots */
1933 prevp = &header->ctl_table;
1934 for (n = 0; n < npath; ++n, ++path) {
1935 /* Copy the procname */
1936 new->procname = path->procname;
1937 new->ctl_name = path->ctl_name;
1938 new->mode = 0555;
1939
1940 *prevp = new;
1941 prevp = &new->child;
1942
1943 new += 2;
1944 }
1945 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001946 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001947
1948 INIT_LIST_HEAD(&header->ctl_entry);
1949 header->used = 0;
1950 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001951 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001952 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001953 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001954#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001955 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001956 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001957 return NULL;
1958 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001959#endif
Al Viro330d57f2005-11-04 10:18:40 +00001960 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001961 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001962 header->attached_by = header->ctl_table;
1963 header->attached_to = root_table;
1964 header->parent = &root_table_header;
1965 for (set = header->set; set; set = set->parent) {
1966 struct ctl_table_header *p;
1967 list_for_each_entry(p, &set->list, ctl_entry) {
1968 if (p->unregistering)
1969 continue;
1970 try_attach(p, header);
1971 }
1972 }
1973 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001974 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001975 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001976
1977 return header;
1978}
1979
1980/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001981 * register_sysctl_table_path - register a sysctl table hierarchy
1982 * @path: The path to the directory the sysctl table is in.
1983 * @table: the top-level table structure
1984 *
1985 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1986 * array. A completely 0 filled entry terminates the table.
1987 *
1988 * See __register_sysctl_paths for more details.
1989 */
1990struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1991 struct ctl_table *table)
1992{
1993 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1994 path, table);
1995}
1996
1997/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001998 * register_sysctl_table - register a sysctl table hierarchy
1999 * @table: the top-level table structure
2000 *
2001 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
2002 * array. A completely 0 filled entry terminates the table.
2003 *
2004 * See register_sysctl_paths for more details.
2005 */
2006struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
2007{
2008 static const struct ctl_path null_path[] = { {} };
2009
2010 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002011}
2012
2013/**
2014 * unregister_sysctl_table - unregister a sysctl table hierarchy
2015 * @header: the header returned from register_sysctl_table
2016 *
2017 * Unregisters the sysctl table and all children. proc entries may not
2018 * actually be removed until they are no longer used by anyone.
2019 */
2020void unregister_sysctl_table(struct ctl_table_header * header)
2021{
Al Viro330d57f2005-11-04 10:18:40 +00002022 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08002023
2024 if (header == NULL)
2025 return;
2026
Al Viro330d57f2005-11-04 10:18:40 +00002027 spin_lock(&sysctl_lock);
2028 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04002029 if (!--header->parent->count) {
2030 WARN_ON(1);
2031 kfree(header->parent);
2032 }
Al Virof7e6ced2008-07-15 01:44:23 -04002033 if (!--header->count)
2034 kfree(header);
Al Viro330d57f2005-11-04 10:18:40 +00002035 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002036}
2037
Al Viro90434762008-07-15 08:54:06 -04002038int sysctl_is_seen(struct ctl_table_header *p)
2039{
2040 struct ctl_table_set *set = p->set;
2041 int res;
2042 spin_lock(&sysctl_lock);
2043 if (p->unregistering)
2044 res = 0;
2045 else if (!set->is_seen)
2046 res = 1;
2047 else
2048 res = set->is_seen(set);
2049 spin_unlock(&sysctl_lock);
2050 return res;
2051}
2052
Al Viro73455092008-07-14 21:22:20 -04002053void setup_sysctl_set(struct ctl_table_set *p,
2054 struct ctl_table_set *parent,
2055 int (*is_seen)(struct ctl_table_set *))
2056{
2057 INIT_LIST_HEAD(&p->list);
2058 p->parent = parent ? parent : &sysctl_table_root.default_set;
2059 p->is_seen = is_seen;
2060}
2061
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002062#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002063struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002064{
2065 return NULL;
2066}
2067
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002068struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2069 struct ctl_table *table)
2070{
2071 return NULL;
2072}
2073
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002074void unregister_sysctl_table(struct ctl_table_header * table)
2075{
2076}
2077
Al Viro73455092008-07-14 21:22:20 -04002078void setup_sysctl_set(struct ctl_table_set *p,
2079 struct ctl_table_set *parent,
2080 int (*is_seen)(struct ctl_table_set *))
2081{
2082}
2083
Al Virof7e6ced2008-07-15 01:44:23 -04002084void sysctl_head_put(struct ctl_table_header *head)
2085{
2086}
2087
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002088#endif /* CONFIG_SYSCTL */
2089
Linus Torvalds1da177e2005-04-16 15:20:36 -07002090/*
2091 * /proc/sys support
2092 */
2093
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002094#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002095
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002096static int _proc_do_string(void* data, int maxlen, int write,
2097 struct file *filp, void __user *buffer,
2098 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002099{
2100 size_t len;
2101 char __user *p;
2102 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002103
2104 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002105 *lenp = 0;
2106 return 0;
2107 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002108
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002109 if (write) {
2110 len = 0;
2111 p = buffer;
2112 while (len < *lenp) {
2113 if (get_user(c, p++))
2114 return -EFAULT;
2115 if (c == 0 || c == '\n')
2116 break;
2117 len++;
2118 }
2119 if (len >= maxlen)
2120 len = maxlen-1;
2121 if(copy_from_user(data, buffer, len))
2122 return -EFAULT;
2123 ((char *) data)[len] = 0;
2124 *ppos += *lenp;
2125 } else {
2126 len = strlen(data);
2127 if (len > maxlen)
2128 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002129
2130 if (*ppos > len) {
2131 *lenp = 0;
2132 return 0;
2133 }
2134
2135 data += *ppos;
2136 len -= *ppos;
2137
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002138 if (len > *lenp)
2139 len = *lenp;
2140 if (len)
2141 if(copy_to_user(buffer, data, len))
2142 return -EFAULT;
2143 if (len < *lenp) {
2144 if(put_user('\n', ((char __user *) buffer) + len))
2145 return -EFAULT;
2146 len++;
2147 }
2148 *lenp = len;
2149 *ppos += len;
2150 }
2151 return 0;
2152}
2153
Linus Torvalds1da177e2005-04-16 15:20:36 -07002154/**
2155 * proc_dostring - read a string sysctl
2156 * @table: the sysctl table
2157 * @write: %TRUE if this is a write to the sysctl file
2158 * @filp: the file structure
2159 * @buffer: the user buffer
2160 * @lenp: the size of the user buffer
2161 * @ppos: file position
2162 *
2163 * Reads/writes a string from/to the user buffer. If the kernel
2164 * buffer provided is not large enough to hold the string, the
2165 * string is truncated. The copied string is %NULL-terminated.
2166 * If the string is being read by the user process, it is copied
2167 * and a newline '\n' is added. It is truncated if the buffer is
2168 * not large enough.
2169 *
2170 * Returns 0 on success.
2171 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002172int proc_dostring(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002173 void __user *buffer, size_t *lenp, loff_t *ppos)
2174{
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002175 return _proc_do_string(table->data, table->maxlen, write, filp,
2176 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002177}
2178
Linus Torvalds1da177e2005-04-16 15:20:36 -07002179
2180static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2181 int *valp,
2182 int write, void *data)
2183{
2184 if (write) {
2185 *valp = *negp ? -*lvalp : *lvalp;
2186 } else {
2187 int val = *valp;
2188 if (val < 0) {
2189 *negp = -1;
2190 *lvalp = (unsigned long)-val;
2191 } else {
2192 *negp = 0;
2193 *lvalp = (unsigned long)val;
2194 }
2195 }
2196 return 0;
2197}
2198
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002199static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002200 int write, struct file *filp, void __user *buffer,
2201 size_t *lenp, loff_t *ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002202 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2203 int write, void *data),
2204 void *data)
2205{
2206#define TMPBUFLEN 21
2207 int *i, vleft, first=1, neg, val;
2208 unsigned long lval;
2209 size_t left, len;
2210
2211 char buf[TMPBUFLEN], *p;
2212 char __user *s = buffer;
2213
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002214 if (!tbl_data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002215 (*ppos && !write)) {
2216 *lenp = 0;
2217 return 0;
2218 }
2219
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002220 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221 vleft = table->maxlen / sizeof(*i);
2222 left = *lenp;
2223
2224 if (!conv)
2225 conv = do_proc_dointvec_conv;
2226
2227 for (; left && vleft--; i++, first=0) {
2228 if (write) {
2229 while (left) {
2230 char c;
2231 if (get_user(c, s))
2232 return -EFAULT;
2233 if (!isspace(c))
2234 break;
2235 left--;
2236 s++;
2237 }
2238 if (!left)
2239 break;
2240 neg = 0;
2241 len = left;
2242 if (len > sizeof(buf) - 1)
2243 len = sizeof(buf) - 1;
2244 if (copy_from_user(buf, s, len))
2245 return -EFAULT;
2246 buf[len] = 0;
2247 p = buf;
2248 if (*p == '-' && left > 1) {
2249 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002250 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002251 }
2252 if (*p < '0' || *p > '9')
2253 break;
2254
2255 lval = simple_strtoul(p, &p, 0);
2256
2257 len = p-buf;
2258 if ((len < left) && *p && !isspace(*p))
2259 break;
2260 if (neg)
2261 val = -val;
2262 s += len;
2263 left -= len;
2264
2265 if (conv(&neg, &lval, i, 1, data))
2266 break;
2267 } else {
2268 p = buf;
2269 if (!first)
2270 *p++ = '\t';
2271
2272 if (conv(&neg, &lval, i, 0, data))
2273 break;
2274
2275 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2276 len = strlen(buf);
2277 if (len > left)
2278 len = left;
2279 if(copy_to_user(s, buf, len))
2280 return -EFAULT;
2281 left -= len;
2282 s += len;
2283 }
2284 }
2285
2286 if (!write && !first && left) {
2287 if(put_user('\n', s))
2288 return -EFAULT;
2289 left--, s++;
2290 }
2291 if (write) {
2292 while (left) {
2293 char c;
2294 if (get_user(c, s++))
2295 return -EFAULT;
2296 if (!isspace(c))
2297 break;
2298 left--;
2299 }
2300 }
2301 if (write && first)
2302 return -EINVAL;
2303 *lenp -= left;
2304 *ppos += *lenp;
2305 return 0;
2306#undef TMPBUFLEN
2307}
2308
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002309static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002310 void __user *buffer, size_t *lenp, loff_t *ppos,
2311 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2312 int write, void *data),
2313 void *data)
2314{
2315 return __do_proc_dointvec(table->data, table, write, filp,
2316 buffer, lenp, ppos, conv, data);
2317}
2318
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319/**
2320 * proc_dointvec - read a vector of integers
2321 * @table: the sysctl table
2322 * @write: %TRUE if this is a write to the sysctl file
2323 * @filp: the file structure
2324 * @buffer: the user buffer
2325 * @lenp: the size of the user buffer
2326 * @ppos: file position
2327 *
2328 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2329 * values from/to the user buffer, treated as an ASCII string.
2330 *
2331 * Returns 0 on success.
2332 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002333int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002334 void __user *buffer, size_t *lenp, loff_t *ppos)
2335{
2336 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2337 NULL,NULL);
2338}
2339
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002340/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002341 * Taint values can only be increased
2342 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002343 */
Andi Kleen25ddbb12008-10-15 22:01:41 -07002344static int proc_taint(struct ctl_table *table, int write, struct file *filp,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002345 void __user *buffer, size_t *lenp, loff_t *ppos)
2346{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002347 struct ctl_table t;
2348 unsigned long tmptaint = get_taint();
2349 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002350
Bastian Blank91fcd412007-04-23 14:41:14 -07002351 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002352 return -EPERM;
2353
Andi Kleen25ddbb12008-10-15 22:01:41 -07002354 t = *table;
2355 t.data = &tmptaint;
2356 err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos);
2357 if (err < 0)
2358 return err;
2359
2360 if (write) {
2361 /*
2362 * Poor man's atomic or. Not worth adding a primitive
2363 * to everyone's atomic.h for this
2364 */
2365 int i;
2366 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2367 if ((tmptaint >> i) & 1)
2368 add_taint(i);
2369 }
2370 }
2371
2372 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002373}
2374
Linus Torvalds1da177e2005-04-16 15:20:36 -07002375struct do_proc_dointvec_minmax_conv_param {
2376 int *min;
2377 int *max;
2378};
2379
2380static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2381 int *valp,
2382 int write, void *data)
2383{
2384 struct do_proc_dointvec_minmax_conv_param *param = data;
2385 if (write) {
2386 int val = *negp ? -*lvalp : *lvalp;
2387 if ((param->min && *param->min > val) ||
2388 (param->max && *param->max < val))
2389 return -EINVAL;
2390 *valp = val;
2391 } else {
2392 int val = *valp;
2393 if (val < 0) {
2394 *negp = -1;
2395 *lvalp = (unsigned long)-val;
2396 } else {
2397 *negp = 0;
2398 *lvalp = (unsigned long)val;
2399 }
2400 }
2401 return 0;
2402}
2403
2404/**
2405 * proc_dointvec_minmax - read a vector of integers with min/max values
2406 * @table: the sysctl table
2407 * @write: %TRUE if this is a write to the sysctl file
2408 * @filp: the file structure
2409 * @buffer: the user buffer
2410 * @lenp: the size of the user buffer
2411 * @ppos: file position
2412 *
2413 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2414 * values from/to the user buffer, treated as an ASCII string.
2415 *
2416 * This routine will ensure the values are within the range specified by
2417 * table->extra1 (min) and table->extra2 (max).
2418 *
2419 * Returns 0 on success.
2420 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002421int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002422 void __user *buffer, size_t *lenp, loff_t *ppos)
2423{
2424 struct do_proc_dointvec_minmax_conv_param param = {
2425 .min = (int *) table->extra1,
2426 .max = (int *) table->extra2,
2427 };
2428 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2429 do_proc_dointvec_minmax_conv, &param);
2430}
2431
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002432static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002433 struct file *filp,
2434 void __user *buffer,
2435 size_t *lenp, loff_t *ppos,
2436 unsigned long convmul,
2437 unsigned long convdiv)
2438{
2439#define TMPBUFLEN 21
2440 unsigned long *i, *min, *max, val;
2441 int vleft, first=1, neg;
2442 size_t len, left;
2443 char buf[TMPBUFLEN], *p;
2444 char __user *s = buffer;
2445
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002446 if (!data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002447 (*ppos && !write)) {
2448 *lenp = 0;
2449 return 0;
2450 }
2451
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002452 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453 min = (unsigned long *) table->extra1;
2454 max = (unsigned long *) table->extra2;
2455 vleft = table->maxlen / sizeof(unsigned long);
2456 left = *lenp;
2457
2458 for (; left && vleft--; i++, min++, max++, first=0) {
2459 if (write) {
2460 while (left) {
2461 char c;
2462 if (get_user(c, s))
2463 return -EFAULT;
2464 if (!isspace(c))
2465 break;
2466 left--;
2467 s++;
2468 }
2469 if (!left)
2470 break;
2471 neg = 0;
2472 len = left;
2473 if (len > TMPBUFLEN-1)
2474 len = TMPBUFLEN-1;
2475 if (copy_from_user(buf, s, len))
2476 return -EFAULT;
2477 buf[len] = 0;
2478 p = buf;
2479 if (*p == '-' && left > 1) {
2480 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002481 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002482 }
2483 if (*p < '0' || *p > '9')
2484 break;
2485 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2486 len = p-buf;
2487 if ((len < left) && *p && !isspace(*p))
2488 break;
2489 if (neg)
2490 val = -val;
2491 s += len;
2492 left -= len;
2493
2494 if(neg)
2495 continue;
2496 if ((min && val < *min) || (max && val > *max))
2497 continue;
2498 *i = val;
2499 } else {
2500 p = buf;
2501 if (!first)
2502 *p++ = '\t';
2503 sprintf(p, "%lu", convdiv * (*i) / convmul);
2504 len = strlen(buf);
2505 if (len > left)
2506 len = left;
2507 if(copy_to_user(s, buf, len))
2508 return -EFAULT;
2509 left -= len;
2510 s += len;
2511 }
2512 }
2513
2514 if (!write && !first && left) {
2515 if(put_user('\n', s))
2516 return -EFAULT;
2517 left--, s++;
2518 }
2519 if (write) {
2520 while (left) {
2521 char c;
2522 if (get_user(c, s++))
2523 return -EFAULT;
2524 if (!isspace(c))
2525 break;
2526 left--;
2527 }
2528 }
2529 if (write && first)
2530 return -EINVAL;
2531 *lenp -= left;
2532 *ppos += *lenp;
2533 return 0;
2534#undef TMPBUFLEN
2535}
2536
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002537static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002538 struct file *filp,
2539 void __user *buffer,
2540 size_t *lenp, loff_t *ppos,
2541 unsigned long convmul,
2542 unsigned long convdiv)
2543{
2544 return __do_proc_doulongvec_minmax(table->data, table, write,
2545 filp, buffer, lenp, ppos, convmul, convdiv);
2546}
2547
Linus Torvalds1da177e2005-04-16 15:20:36 -07002548/**
2549 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2550 * @table: the sysctl table
2551 * @write: %TRUE if this is a write to the sysctl file
2552 * @filp: the file structure
2553 * @buffer: the user buffer
2554 * @lenp: the size of the user buffer
2555 * @ppos: file position
2556 *
2557 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2558 * values from/to the user buffer, treated as an ASCII string.
2559 *
2560 * This routine will ensure the values are within the range specified by
2561 * table->extra1 (min) and table->extra2 (max).
2562 *
2563 * Returns 0 on success.
2564 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002565int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002566 void __user *buffer, size_t *lenp, loff_t *ppos)
2567{
2568 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
2569}
2570
2571/**
2572 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2573 * @table: the sysctl table
2574 * @write: %TRUE if this is a write to the sysctl file
2575 * @filp: the file structure
2576 * @buffer: the user buffer
2577 * @lenp: the size of the user buffer
2578 * @ppos: file position
2579 *
2580 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2581 * values from/to the user buffer, treated as an ASCII string. The values
2582 * are treated as milliseconds, and converted to jiffies when they are stored.
2583 *
2584 * This routine will ensure the values are within the range specified by
2585 * table->extra1 (min) and table->extra2 (max).
2586 *
2587 * Returns 0 on success.
2588 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002589int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002590 struct file *filp,
2591 void __user *buffer,
2592 size_t *lenp, loff_t *ppos)
2593{
2594 return do_proc_doulongvec_minmax(table, write, filp, buffer,
2595 lenp, ppos, HZ, 1000l);
2596}
2597
2598
2599static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2600 int *valp,
2601 int write, void *data)
2602{
2603 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002604 if (*lvalp > LONG_MAX / HZ)
2605 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002606 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2607 } else {
2608 int val = *valp;
2609 unsigned long lval;
2610 if (val < 0) {
2611 *negp = -1;
2612 lval = (unsigned long)-val;
2613 } else {
2614 *negp = 0;
2615 lval = (unsigned long)val;
2616 }
2617 *lvalp = lval / HZ;
2618 }
2619 return 0;
2620}
2621
2622static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2623 int *valp,
2624 int write, void *data)
2625{
2626 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002627 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2628 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2630 } else {
2631 int val = *valp;
2632 unsigned long lval;
2633 if (val < 0) {
2634 *negp = -1;
2635 lval = (unsigned long)-val;
2636 } else {
2637 *negp = 0;
2638 lval = (unsigned long)val;
2639 }
2640 *lvalp = jiffies_to_clock_t(lval);
2641 }
2642 return 0;
2643}
2644
2645static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2646 int *valp,
2647 int write, void *data)
2648{
2649 if (write) {
2650 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2651 } else {
2652 int val = *valp;
2653 unsigned long lval;
2654 if (val < 0) {
2655 *negp = -1;
2656 lval = (unsigned long)-val;
2657 } else {
2658 *negp = 0;
2659 lval = (unsigned long)val;
2660 }
2661 *lvalp = jiffies_to_msecs(lval);
2662 }
2663 return 0;
2664}
2665
2666/**
2667 * proc_dointvec_jiffies - read a vector of integers as seconds
2668 * @table: the sysctl table
2669 * @write: %TRUE if this is a write to the sysctl file
2670 * @filp: the file structure
2671 * @buffer: the user buffer
2672 * @lenp: the size of the user buffer
2673 * @ppos: file position
2674 *
2675 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2676 * values from/to the user buffer, treated as an ASCII string.
2677 * The values read are assumed to be in seconds, and are converted into
2678 * jiffies.
2679 *
2680 * Returns 0 on success.
2681 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002682int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002683 void __user *buffer, size_t *lenp, loff_t *ppos)
2684{
2685 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2686 do_proc_dointvec_jiffies_conv,NULL);
2687}
2688
2689/**
2690 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2691 * @table: the sysctl table
2692 * @write: %TRUE if this is a write to the sysctl file
2693 * @filp: the file structure
2694 * @buffer: the user buffer
2695 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002696 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002697 *
2698 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2699 * values from/to the user buffer, treated as an ASCII string.
2700 * The values read are assumed to be in 1/USER_HZ seconds, and
2701 * are converted into jiffies.
2702 *
2703 * Returns 0 on success.
2704 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002705int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002706 void __user *buffer, size_t *lenp, loff_t *ppos)
2707{
2708 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2709 do_proc_dointvec_userhz_jiffies_conv,NULL);
2710}
2711
2712/**
2713 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2714 * @table: the sysctl table
2715 * @write: %TRUE if this is a write to the sysctl file
2716 * @filp: the file structure
2717 * @buffer: the user buffer
2718 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002719 * @ppos: file position
2720 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002721 *
2722 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2723 * values from/to the user buffer, treated as an ASCII string.
2724 * The values read are assumed to be in 1/1000 seconds, and
2725 * are converted into jiffies.
2726 *
2727 * Returns 0 on success.
2728 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002729int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002730 void __user *buffer, size_t *lenp, loff_t *ppos)
2731{
2732 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2733 do_proc_dointvec_ms_jiffies_conv, NULL);
2734}
2735
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002736static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002737 void __user *buffer, size_t *lenp, loff_t *ppos)
2738{
2739 struct pid *new_pid;
2740 pid_t tmp;
2741 int r;
2742
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002743 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002744
2745 r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
2746 lenp, ppos, NULL, NULL);
2747 if (r || !write)
2748 return r;
2749
2750 new_pid = find_get_pid(tmp);
2751 if (!new_pid)
2752 return -ESRCH;
2753
2754 put_pid(xchg(&cad_pid, new_pid));
2755 return 0;
2756}
2757
Linus Torvalds1da177e2005-04-16 15:20:36 -07002758#else /* CONFIG_PROC_FS */
2759
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002760int proc_dostring(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002761 void __user *buffer, size_t *lenp, loff_t *ppos)
2762{
2763 return -ENOSYS;
2764}
2765
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002766int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002767 void __user *buffer, size_t *lenp, loff_t *ppos)
2768{
2769 return -ENOSYS;
2770}
2771
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002772int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002773 void __user *buffer, size_t *lenp, loff_t *ppos)
2774{
2775 return -ENOSYS;
2776}
2777
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002778int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002779 void __user *buffer, size_t *lenp, loff_t *ppos)
2780{
2781 return -ENOSYS;
2782}
2783
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002784int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002785 void __user *buffer, size_t *lenp, loff_t *ppos)
2786{
2787 return -ENOSYS;
2788}
2789
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002790int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002791 void __user *buffer, size_t *lenp, loff_t *ppos)
2792{
2793 return -ENOSYS;
2794}
2795
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002796int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002797 void __user *buffer, size_t *lenp, loff_t *ppos)
2798{
2799 return -ENOSYS;
2800}
2801
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002802int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002803 struct file *filp,
2804 void __user *buffer,
2805 size_t *lenp, loff_t *ppos)
2806{
2807 return -ENOSYS;
2808}
2809
2810
2811#endif /* CONFIG_PROC_FS */
2812
2813
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002814#ifdef CONFIG_SYSCTL_SYSCALL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002815/*
2816 * General sysctl support routines
2817 */
2818
Eric W. Biederman49a0c452007-10-18 03:05:23 -07002819/* The generic sysctl data routine (used if no strategy routine supplied) */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002820int sysctl_data(struct ctl_table *table,
Eric W. Biederman49a0c452007-10-18 03:05:23 -07002821 void __user *oldval, size_t __user *oldlenp,
2822 void __user *newval, size_t newlen)
2823{
2824 size_t len;
2825
2826 /* Get out of I don't have a variable */
2827 if (!table->data || !table->maxlen)
2828 return -ENOTDIR;
2829
2830 if (oldval && oldlenp) {
2831 if (get_user(len, oldlenp))
2832 return -EFAULT;
2833 if (len) {
2834 if (len > table->maxlen)
2835 len = table->maxlen;
2836 if (copy_to_user(oldval, table->data, len))
2837 return -EFAULT;
2838 if (put_user(len, oldlenp))
2839 return -EFAULT;
2840 }
2841 }
2842
2843 if (newval && newlen) {
2844 if (newlen > table->maxlen)
2845 newlen = table->maxlen;
2846
2847 if (copy_from_user(table->data, newval, newlen))
2848 return -EFAULT;
2849 }
2850 return 1;
2851}
2852
Linus Torvalds1da177e2005-04-16 15:20:36 -07002853/* The generic string strategy routine: */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002854int sysctl_string(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002855 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002856 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002857{
Linus Torvalds1da177e2005-04-16 15:20:36 -07002858 if (!table->data || !table->maxlen)
2859 return -ENOTDIR;
2860
2861 if (oldval && oldlenp) {
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002862 size_t bufsize;
2863 if (get_user(bufsize, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002864 return -EFAULT;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002865 if (bufsize) {
2866 size_t len = strlen(table->data), copied;
2867
2868 /* This shouldn't trigger for a well-formed sysctl */
2869 if (len > table->maxlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002870 len = table->maxlen;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002871
2872 /* Copy up to a max of bufsize-1 bytes of the string */
2873 copied = (len >= bufsize) ? bufsize - 1 : len;
2874
2875 if (copy_to_user(oldval, table->data, copied) ||
2876 put_user(0, (char __user *)(oldval + copied)))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002877 return -EFAULT;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002878 if (put_user(len, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002879 return -EFAULT;
2880 }
2881 }
2882 if (newval && newlen) {
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002883 size_t len = newlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002884 if (len > table->maxlen)
2885 len = table->maxlen;
2886 if(copy_from_user(table->data, newval, len))
2887 return -EFAULT;
2888 if (len == table->maxlen)
2889 len--;
2890 ((char *) table->data)[len] = 0;
2891 }
Yi Yang82c9df82005-12-30 16:37:10 +08002892 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002893}
2894
2895/*
2896 * This function makes sure that all of the integers in the vector
2897 * are between the minimum and maximum values given in the arrays
2898 * table->extra1 and table->extra2, respectively.
2899 */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002900int sysctl_intvec(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002901 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002902 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002903{
2904
2905 if (newval && newlen) {
2906 int __user *vec = (int __user *) newval;
2907 int *min = (int *) table->extra1;
2908 int *max = (int *) table->extra2;
2909 size_t length;
2910 int i;
2911
2912 if (newlen % sizeof(int) != 0)
2913 return -EINVAL;
2914
2915 if (!table->extra1 && !table->extra2)
2916 return 0;
2917
2918 if (newlen > table->maxlen)
2919 newlen = table->maxlen;
2920 length = newlen / sizeof(int);
2921
2922 for (i = 0; i < length; i++) {
2923 int value;
2924 if (get_user(value, vec + i))
2925 return -EFAULT;
2926 if (min && value < min[i])
2927 return -EINVAL;
2928 if (max && value > max[i])
2929 return -EINVAL;
2930 }
2931 }
2932 return 0;
2933}
2934
2935/* Strategy function to convert jiffies to seconds */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002936int sysctl_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002937 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002938 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002939{
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002940 if (oldval && oldlenp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002941 size_t olen;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002942
2943 if (get_user(olen, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002944 return -EFAULT;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002945 if (olen) {
2946 int val;
2947
2948 if (olen < sizeof(int))
2949 return -EINVAL;
2950
2951 val = *(int *)(table->data) / HZ;
2952 if (put_user(val, (int __user *)oldval))
2953 return -EFAULT;
2954 if (put_user(sizeof(int), oldlenp))
2955 return -EFAULT;
2956 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002957 }
2958 if (newval && newlen) {
2959 int new;
2960 if (newlen != sizeof(int))
2961 return -EINVAL;
2962 if (get_user(new, (int __user *)newval))
2963 return -EFAULT;
2964 *(int *)(table->data) = new*HZ;
2965 }
2966 return 1;
2967}
2968
2969/* Strategy function to convert jiffies to seconds */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002970int sysctl_ms_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002971 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002972 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002973{
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002974 if (oldval && oldlenp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002975 size_t olen;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002976
2977 if (get_user(olen, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002978 return -EFAULT;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002979 if (olen) {
2980 int val;
2981
2982 if (olen < sizeof(int))
2983 return -EINVAL;
2984
2985 val = jiffies_to_msecs(*(int *)(table->data));
2986 if (put_user(val, (int __user *)oldval))
2987 return -EFAULT;
2988 if (put_user(sizeof(int), oldlenp))
2989 return -EFAULT;
2990 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002991 }
2992 if (newval && newlen) {
2993 int new;
2994 if (newlen != sizeof(int))
2995 return -EINVAL;
2996 if (get_user(new, (int __user *)newval))
2997 return -EFAULT;
2998 *(int *)(table->data) = msecs_to_jiffies(new);
2999 }
3000 return 1;
3001}
3002
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08003003
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08003004
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07003005#else /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003006
3007
Heiko Carstens1e7bfb22009-01-14 14:14:29 +01003008SYSCALL_DEFINE1(sysctl, struct __sysctl_args __user *, args)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003009{
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003010 struct __sysctl_args tmp;
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003011 int error;
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003012
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003013 if (copy_from_user(&tmp, args, sizeof(tmp)))
3014 return -EFAULT;
Eric W. Biederman0e009be2006-11-05 23:52:11 -08003015
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003016 error = deprecated_sysctl_warning(&tmp);
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07003017
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003018 /* If no error reading the parameters then just -ENOSYS ... */
3019 if (!error)
3020 error = -ENOSYS;
3021
3022 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003023}
3024
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003025int sysctl_data(struct ctl_table *table,
Eric W. Biederman49a0c452007-10-18 03:05:23 -07003026 void __user *oldval, size_t __user *oldlenp,
3027 void __user *newval, size_t newlen)
3028{
3029 return -ENOSYS;
3030}
3031
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003032int sysctl_string(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003033 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003034 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003035{
3036 return -ENOSYS;
3037}
3038
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003039int sysctl_intvec(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003040 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003041 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003042{
3043 return -ENOSYS;
3044}
3045
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003046int sysctl_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003047 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003048 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003049{
3050 return -ENOSYS;
3051}
3052
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003053int sysctl_ms_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003054 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003055 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003056{
3057 return -ENOSYS;
3058}
3059
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07003060#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003061
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003062static int deprecated_sysctl_warning(struct __sysctl_args *args)
3063{
3064 static int msg_count;
3065 int name[CTL_MAXNAME];
3066 int i;
3067
Tetsuo Handa6fc48af2007-11-14 16:58:38 -08003068 /* Check args->nlen. */
3069 if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
3070 return -ENOTDIR;
3071
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003072 /* Read in the sysctl name for better debug message logging */
3073 for (i = 0; i < args->nlen; i++)
3074 if (get_user(name[i], args->name + i))
3075 return -EFAULT;
3076
3077 /* Ignore accesses to kernel.version */
3078 if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
3079 return 0;
3080
3081 if (msg_count < 5) {
3082 msg_count++;
3083 printk(KERN_INFO
3084 "warning: process `%s' used the deprecated sysctl "
3085 "system call with ", current->comm);
3086 for (i = 0; i < args->nlen; i++)
3087 printk("%d.", name[i]);
3088 printk("\n");
3089 }
3090 return 0;
3091}
3092
Linus Torvalds1da177e2005-04-16 15:20:36 -07003093/*
3094 * No sense putting this after each symbol definition, twice,
3095 * exception granted :-)
3096 */
3097EXPORT_SYMBOL(proc_dointvec);
3098EXPORT_SYMBOL(proc_dointvec_jiffies);
3099EXPORT_SYMBOL(proc_dointvec_minmax);
3100EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3101EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3102EXPORT_SYMBOL(proc_dostring);
3103EXPORT_SYMBOL(proc_doulongvec_minmax);
3104EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3105EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11003106EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003107EXPORT_SYMBOL(sysctl_intvec);
3108EXPORT_SYMBOL(sysctl_jiffies);
3109EXPORT_SYMBOL(sysctl_ms_jiffies);
3110EXPORT_SYMBOL(sysctl_string);
Eric W. Biederman49a0c452007-10-18 03:05:23 -07003111EXPORT_SYMBOL(sysctl_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003112EXPORT_SYMBOL(unregister_sysctl_table);