blob: 92f6e5bc3c24f2700b88e31a689f642a83a29a4b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
22#include <linux/mm.h>
23#include <linux/swap.h>
24#include <linux/slab.h>
25#include <linux/sysctl.h>
26#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070027#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#include <linux/ctype.h>
29#include <linux/utsname.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/smp_lock.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070031#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/init.h>
33#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010034#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030035#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/sysrq.h>
37#include <linux/highuid.h>
38#include <linux/writeback.h>
39#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070041#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070042#include <linux/times.h>
43#include <linux/limits.h>
44#include <linux/dcache.h>
45#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070046#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080047#include <linux/nfs_fs.h>
48#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070049#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020050#include <linux/ftrace.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
52#include <asm/uaccess.h>
53#include <asm/processor.h>
54
Andi Kleen29cbc782006-09-30 01:47:55 +020055#ifdef CONFIG_X86
56#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010057#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010058#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020059#endif
60
Eric W. Biederman7058cb02007-10-18 03:05:58 -070061static int deprecated_sysctl_warning(struct __sysctl_args *args);
62
Linus Torvalds1da177e2005-04-16 15:20:36 -070063#if defined(CONFIG_SYSCTL)
64
65/* External variables not in a header file. */
66extern int C_A_D;
Ingo Molnar45807a12007-07-15 23:40:10 -070067extern int print_fatal_signals;
Linus Torvalds1da177e2005-04-16 15:20:36 -070068extern int sysctl_overcommit_memory;
69extern int sysctl_overcommit_ratio;
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -070070extern int sysctl_panic_on_oom;
David Rientjesfe071d72007-10-16 23:25:56 -070071extern int sysctl_oom_kill_allocating_task;
David Rientjesfef1bdd2008-02-07 00:14:07 -080072extern int sysctl_oom_dump_tasks;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070074extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070075extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070076extern char core_pattern[];
Linus Torvalds1da177e2005-04-16 15:20:36 -070077extern int pid_max;
78extern int min_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -070079extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -080080extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -080081extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +020082extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +010083extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -040084extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul E. McKenney31a72bc2008-06-18 09:26:49 -070085#ifdef CONFIG_RCU_TORTURE_TEST
86extern int rcutorture_runnable;
87#endif /* #ifdef CONFIG_RCU_TORTURE_TEST */
Linus Torvalds1da177e2005-04-16 15:20:36 -070088
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070089/* Constants used for minimum and maximum */
Bron Gondwana195cf4532008-02-04 22:29:20 -080090#ifdef CONFIG_DETECT_SOFTLOCKUP
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070091static int sixty = 60;
Dimitri Sivanich9383d962008-05-12 21:21:14 +020092static int neg_one = -1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070093#endif
94
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +020095#if defined(CONFIG_MMU) && defined(CONFIG_FILE_LOCKING)
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070096static int two = 2;
97#endif
98
99static int zero;
David Rientjes2da02992009-01-06 14:39:31 -0800100static int one = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700101static int one_hundred = 100;
102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
104static int maxolduid = 65535;
105static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800106static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
108static int ngroups_max = NGROUPS_MAX;
109
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200110#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111extern char modprobe_path[];
112#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113#ifdef CONFIG_CHR_DEV_SG
114extern int sg_big_buff;
115#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
David S. Miller72c57ed2008-09-11 23:29:54 -0700117#ifdef CONFIG_SPARC
David S. Miller17f04fb2008-09-11 23:33:53 -0700118#include <asm/system.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119#endif
120
David S. Miller08714202008-11-16 23:49:24 -0800121#ifdef CONFIG_SPARC64
122extern int sysctl_tsb_ratio;
123#endif
124
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125#ifdef __hppa__
126extern int pwrsw_enabled;
127extern int unaligned_enabled;
128#endif
129
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800130#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131#ifdef CONFIG_MATHEMU
132extern int sysctl_ieee_emulation_warnings;
133#endif
134extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700135extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136#endif
137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138#ifdef CONFIG_BSD_PROCESS_ACCT
139extern int acct_parm[];
140#endif
141
Jes Sorensend2b176e2006-02-28 09:42:23 -0800142#ifdef CONFIG_IA64
143extern int no_unaligned_warning;
144#endif
145
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700146#ifdef CONFIG_RT_MUTEXES
147extern int max_lock_depth;
148#endif
149
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700150#ifdef CONFIG_PROC_SYSCTL
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700151static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700152 void __user *buffer, size_t *lenp, loff_t *ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -0700153static int proc_taint(struct ctl_table *table, int write, struct file *filp,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800154 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700155#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700156
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700157static struct ctl_table root_table[];
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100158static struct ctl_table_root sysctl_table_root;
159static struct ctl_table_header root_table_header = {
Al Virob380b0d2008-09-04 17:05:57 +0100160 .count = 1,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100161 .ctl_table = root_table,
Al Viro73455092008-07-14 21:22:20 -0400162 .ctl_entry = LIST_HEAD_INIT(sysctl_table_root.default_set.list),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100163 .root = &sysctl_table_root,
Al Viro73455092008-07-14 21:22:20 -0400164 .set = &sysctl_table_root.default_set,
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100165};
166static struct ctl_table_root sysctl_table_root = {
167 .root_list = LIST_HEAD_INIT(sysctl_table_root.root_list),
Al Viro73455092008-07-14 21:22:20 -0400168 .default_set.list = LIST_HEAD_INIT(root_table_header.ctl_entry),
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +1100169};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700171static struct ctl_table kern_table[];
172static struct ctl_table vm_table[];
173static struct ctl_table fs_table[];
174static struct ctl_table debug_table[];
175static struct ctl_table dev_table[];
176extern struct ctl_table random_table[];
Amy Griffis2d9048e2006-06-01 13:10:59 -0700177#ifdef CONFIG_INOTIFY_USER
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700178extern struct ctl_table inotify_table[];
Robert Love0399cb02005-07-13 12:38:18 -0400179#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -0800180#ifdef CONFIG_EPOLL
181extern struct ctl_table epoll_table[];
182#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183
184#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
185int sysctl_legacy_va_layout;
186#endif
187
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700188extern int prove_locking;
189extern int lock_stat;
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800190
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191/* The default sysctl tables: */
192
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700193static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 {
195 .ctl_name = CTL_KERN,
196 .procname = "kernel",
197 .mode = 0555,
198 .child = kern_table,
199 },
200 {
201 .ctl_name = CTL_VM,
202 .procname = "vm",
203 .mode = 0555,
204 .child = vm_table,
205 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 .ctl_name = CTL_FS,
208 .procname = "fs",
209 .mode = 0555,
210 .child = fs_table,
211 },
212 {
213 .ctl_name = CTL_DEBUG,
214 .procname = "debug",
215 .mode = 0555,
216 .child = debug_table,
217 },
218 {
219 .ctl_name = CTL_DEV,
220 .procname = "dev",
221 .mode = 0555,
222 .child = dev_table,
223 },
Andrew Morton2be7fe02007-07-15 23:41:21 -0700224/*
225 * NOTE: do not add new entries to this table unless you have read
226 * Documentation/sysctl/ctl_unnumbered.txt
227 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 { .ctl_name = 0 }
229};
230
Ingo Molnar77e54a12007-07-09 18:52:00 +0200231#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100232static int min_sched_granularity_ns = 100000; /* 100 usecs */
233static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
234static int min_wakeup_granularity_ns; /* 0 usecs */
235static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200236#endif
237
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700238static struct ctl_table kern_table[] = {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200239#ifdef CONFIG_SCHED_DEBUG
240 {
241 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100242 .procname = "sched_min_granularity_ns",
243 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200244 .maxlen = sizeof(unsigned int),
245 .mode = 0644,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100246 .proc_handler = &sched_nr_latency_handler,
247 .strategy = &sysctl_intvec,
248 .extra1 = &min_sched_granularity_ns,
249 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200250 },
251 {
252 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra21805082007-08-25 18:41:53 +0200253 .procname = "sched_latency_ns",
254 .data = &sysctl_sched_latency,
255 .maxlen = sizeof(unsigned int),
256 .mode = 0644,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100257 .proc_handler = &sched_nr_latency_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200258 .strategy = &sysctl_intvec,
259 .extra1 = &min_sched_granularity_ns,
260 .extra2 = &max_sched_granularity_ns,
261 },
262 {
263 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200264 .procname = "sched_wakeup_granularity_ns",
265 .data = &sysctl_sched_wakeup_granularity,
266 .maxlen = sizeof(unsigned int),
267 .mode = 0644,
268 .proc_handler = &proc_dointvec_minmax,
269 .strategy = &sysctl_intvec,
270 .extra1 = &min_wakeup_granularity_ns,
271 .extra2 = &max_wakeup_granularity_ns,
272 },
273 {
274 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200275 .procname = "sched_shares_ratelimit",
276 .data = &sysctl_sched_shares_ratelimit,
277 .maxlen = sizeof(unsigned int),
278 .mode = 0644,
279 .proc_handler = &proc_dointvec,
280 },
281 {
282 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstraffda12a2008-10-17 19:27:02 +0200283 .procname = "sched_shares_thresh",
284 .data = &sysctl_sched_shares_thresh,
285 .maxlen = sizeof(unsigned int),
286 .mode = 0644,
287 .proc_handler = &proc_dointvec_minmax,
288 .strategy = &sysctl_intvec,
289 .extra1 = &zero,
290 },
291 {
292 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200293 .procname = "sched_child_runs_first",
294 .data = &sysctl_sched_child_runs_first,
295 .maxlen = sizeof(unsigned int),
296 .mode = 0644,
297 .proc_handler = &proc_dointvec,
298 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200299 {
300 .ctl_name = CTL_UNNUMBERED,
301 .procname = "sched_features",
302 .data = &sysctl_sched_features,
303 .maxlen = sizeof(unsigned int),
304 .mode = 0644,
305 .proc_handler = &proc_dointvec,
306 },
Ingo Molnarda84d962007-10-15 17:00:18 +0200307 {
308 .ctl_name = CTL_UNNUMBERED,
309 .procname = "sched_migration_cost",
310 .data = &sysctl_sched_migration_cost,
311 .maxlen = sizeof(unsigned int),
312 .mode = 0644,
313 .proc_handler = &proc_dointvec,
314 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100315 {
316 .ctl_name = CTL_UNNUMBERED,
317 .procname = "sched_nr_migrate",
318 .data = &sysctl_sched_nr_migrate,
319 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100320 .mode = 0644,
321 .proc_handler = &proc_dointvec,
322 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200323#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200324 {
325 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100326 .procname = "sched_rt_period_us",
327 .data = &sysctl_sched_rt_period,
328 .maxlen = sizeof(unsigned int),
329 .mode = 0644,
Peter Zijlstrad0b27fa2008-04-19 19:44:57 +0200330 .proc_handler = &sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100331 },
332 {
333 .ctl_name = CTL_UNNUMBERED,
334 .procname = "sched_rt_runtime_us",
335 .data = &sysctl_sched_rt_runtime,
336 .maxlen = sizeof(int),
337 .mode = 0644,
Peter Zijlstrad0b27fa2008-04-19 19:44:57 +0200338 .proc_handler = &sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100339 },
340 {
341 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar1799e352007-09-19 23:34:46 +0200342 .procname = "sched_compat_yield",
343 .data = &sysctl_sched_compat_yield,
344 .maxlen = sizeof(unsigned int),
345 .mode = 0644,
346 .proc_handler = &proc_dointvec,
347 },
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700348#ifdef CONFIG_PROVE_LOCKING
349 {
350 .ctl_name = CTL_UNNUMBERED,
351 .procname = "prove_locking",
352 .data = &prove_locking,
353 .maxlen = sizeof(int),
354 .mode = 0644,
355 .proc_handler = &proc_dointvec,
356 },
357#endif
358#ifdef CONFIG_LOCK_STAT
359 {
360 .ctl_name = CTL_UNNUMBERED,
361 .procname = "lock_stat",
362 .data = &lock_stat,
363 .maxlen = sizeof(int),
364 .mode = 0644,
365 .proc_handler = &proc_dointvec,
366 },
367#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200368 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 .ctl_name = KERN_PANIC,
370 .procname = "panic",
371 .data = &panic_timeout,
372 .maxlen = sizeof(int),
373 .mode = 0644,
374 .proc_handler = &proc_dointvec,
375 },
376 {
377 .ctl_name = KERN_CORE_USES_PID,
378 .procname = "core_uses_pid",
379 .data = &core_uses_pid,
380 .maxlen = sizeof(int),
381 .mode = 0644,
382 .proc_handler = &proc_dointvec,
383 },
384 {
385 .ctl_name = KERN_CORE_PATTERN,
386 .procname = "core_pattern",
387 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700388 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 .mode = 0644,
390 .proc_handler = &proc_dostring,
391 .strategy = &sysctl_string,
392 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800393#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700396 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800397 .mode = 0644,
Andi Kleen25ddbb12008-10-15 22:01:41 -0700398 .proc_handler = &proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800400#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100401#ifdef CONFIG_LATENCYTOP
402 {
403 .procname = "latencytop",
404 .data = &latencytop_enabled,
405 .maxlen = sizeof(int),
406 .mode = 0644,
407 .proc_handler = &proc_dointvec,
408 },
409#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410#ifdef CONFIG_BLK_DEV_INITRD
411 {
412 .ctl_name = KERN_REALROOTDEV,
413 .procname = "real-root-dev",
414 .data = &real_root_dev,
415 .maxlen = sizeof(int),
416 .mode = 0644,
417 .proc_handler = &proc_dointvec,
418 },
419#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700420 {
421 .ctl_name = CTL_UNNUMBERED,
422 .procname = "print-fatal-signals",
423 .data = &print_fatal_signals,
424 .maxlen = sizeof(int),
425 .mode = 0644,
426 .proc_handler = &proc_dointvec,
427 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700428#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 {
430 .ctl_name = KERN_SPARC_REBOOT,
431 .procname = "reboot-cmd",
432 .data = reboot_command,
433 .maxlen = 256,
434 .mode = 0644,
435 .proc_handler = &proc_dostring,
436 .strategy = &sysctl_string,
437 },
438 {
439 .ctl_name = KERN_SPARC_STOP_A,
440 .procname = "stop-a",
441 .data = &stop_a_enabled,
442 .maxlen = sizeof (int),
443 .mode = 0644,
444 .proc_handler = &proc_dointvec,
445 },
446 {
447 .ctl_name = KERN_SPARC_SCONS_PWROFF,
448 .procname = "scons-poweroff",
449 .data = &scons_pwroff,
450 .maxlen = sizeof (int),
451 .mode = 0644,
452 .proc_handler = &proc_dointvec,
453 },
454#endif
David S. Miller08714202008-11-16 23:49:24 -0800455#ifdef CONFIG_SPARC64
456 {
457 .ctl_name = CTL_UNNUMBERED,
458 .procname = "tsb-ratio",
459 .data = &sysctl_tsb_ratio,
460 .maxlen = sizeof (int),
461 .mode = 0644,
462 .proc_handler = &proc_dointvec,
463 },
464#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465#ifdef __hppa__
466 {
467 .ctl_name = KERN_HPPA_PWRSW,
468 .procname = "soft-power",
469 .data = &pwrsw_enabled,
470 .maxlen = sizeof (int),
471 .mode = 0644,
472 .proc_handler = &proc_dointvec,
473 },
474 {
475 .ctl_name = KERN_HPPA_UNALIGNED,
476 .procname = "unaligned-trap",
477 .data = &unaligned_enabled,
478 .maxlen = sizeof (int),
479 .mode = 0644,
480 .proc_handler = &proc_dointvec,
481 },
482#endif
483 {
484 .ctl_name = KERN_CTLALTDEL,
485 .procname = "ctrl-alt-del",
486 .data = &C_A_D,
487 .maxlen = sizeof(int),
488 .mode = 0644,
489 .proc_handler = &proc_dointvec,
490 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400491#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200492 {
493 .ctl_name = CTL_UNNUMBERED,
494 .procname = "ftrace_enabled",
495 .data = &ftrace_enabled,
496 .maxlen = sizeof(int),
497 .mode = 0644,
498 .proc_handler = &ftrace_enable_sysctl,
499 },
500#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500501#ifdef CONFIG_STACK_TRACER
502 {
503 .ctl_name = CTL_UNNUMBERED,
504 .procname = "stack_tracer_enabled",
505 .data = &stack_tracer_enabled,
506 .maxlen = sizeof(int),
507 .mode = 0644,
508 .proc_handler = &stack_trace_sysctl,
509 },
510#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400511#ifdef CONFIG_TRACING
512 {
513 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100514 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400515 .data = &ftrace_dump_on_oops,
516 .maxlen = sizeof(int),
517 .mode = 0644,
518 .proc_handler = &proc_dointvec,
519 },
520#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200521#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 {
523 .ctl_name = KERN_MODPROBE,
524 .procname = "modprobe",
525 .data = &modprobe_path,
526 .maxlen = KMOD_PATH_LEN,
527 .mode = 0644,
528 .proc_handler = &proc_dostring,
529 .strategy = &sysctl_string,
530 },
531#endif
Andrew Morton57ae2502006-06-23 02:05:47 -0700532#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 {
534 .ctl_name = KERN_HOTPLUG,
535 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100536 .data = &uevent_helper,
537 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 .mode = 0644,
539 .proc_handler = &proc_dostring,
540 .strategy = &sysctl_string,
541 },
542#endif
543#ifdef CONFIG_CHR_DEV_SG
544 {
545 .ctl_name = KERN_SG_BIG_BUFF,
546 .procname = "sg-big-buff",
547 .data = &sg_big_buff,
548 .maxlen = sizeof (int),
549 .mode = 0444,
550 .proc_handler = &proc_dointvec,
551 },
552#endif
553#ifdef CONFIG_BSD_PROCESS_ACCT
554 {
555 .ctl_name = KERN_ACCT,
556 .procname = "acct",
557 .data = &acct_parm,
558 .maxlen = 3*sizeof(int),
559 .mode = 0644,
560 .proc_handler = &proc_dointvec,
561 },
562#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563#ifdef CONFIG_MAGIC_SYSRQ
564 {
565 .ctl_name = KERN_SYSRQ,
566 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800567 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 .maxlen = sizeof (int),
569 .mode = 0644,
570 .proc_handler = &proc_dointvec,
571 },
572#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700573#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700576 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 .maxlen = sizeof (int),
578 .mode = 0600,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700579 .proc_handler = &proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700581#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 {
583 .ctl_name = KERN_MAX_THREADS,
584 .procname = "threads-max",
585 .data = &max_threads,
586 .maxlen = sizeof(int),
587 .mode = 0644,
588 .proc_handler = &proc_dointvec,
589 },
590 {
591 .ctl_name = KERN_RANDOM,
592 .procname = "random",
593 .mode = 0555,
594 .child = random_table,
595 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 {
597 .ctl_name = KERN_OVERFLOWUID,
598 .procname = "overflowuid",
599 .data = &overflowuid,
600 .maxlen = sizeof(int),
601 .mode = 0644,
602 .proc_handler = &proc_dointvec_minmax,
603 .strategy = &sysctl_intvec,
604 .extra1 = &minolduid,
605 .extra2 = &maxolduid,
606 },
607 {
608 .ctl_name = KERN_OVERFLOWGID,
609 .procname = "overflowgid",
610 .data = &overflowgid,
611 .maxlen = sizeof(int),
612 .mode = 0644,
613 .proc_handler = &proc_dointvec_minmax,
614 .strategy = &sysctl_intvec,
615 .extra1 = &minolduid,
616 .extra2 = &maxolduid,
617 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800618#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619#ifdef CONFIG_MATHEMU
620 {
621 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
622 .procname = "ieee_emulation_warnings",
623 .data = &sysctl_ieee_emulation_warnings,
624 .maxlen = sizeof(int),
625 .mode = 0644,
626 .proc_handler = &proc_dointvec,
627 },
628#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 {
630 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
631 .procname = "userprocess_debug",
632 .data = &sysctl_userprocess_debug,
633 .maxlen = sizeof(int),
634 .mode = 0644,
635 .proc_handler = &proc_dointvec,
636 },
637#endif
638 {
639 .ctl_name = KERN_PIDMAX,
640 .procname = "pid_max",
641 .data = &pid_max,
642 .maxlen = sizeof (int),
643 .mode = 0644,
644 .proc_handler = &proc_dointvec_minmax,
645 .strategy = sysctl_intvec,
646 .extra1 = &pid_max_min,
647 .extra2 = &pid_max_max,
648 },
649 {
650 .ctl_name = KERN_PANIC_ON_OOPS,
651 .procname = "panic_on_oops",
652 .data = &panic_on_oops,
653 .maxlen = sizeof(int),
654 .mode = 0644,
655 .proc_handler = &proc_dointvec,
656 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800657#if defined CONFIG_PRINTK
658 {
659 .ctl_name = KERN_PRINTK,
660 .procname = "printk",
661 .data = &console_loglevel,
662 .maxlen = 4*sizeof(int),
663 .mode = 0644,
664 .proc_handler = &proc_dointvec,
665 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 {
667 .ctl_name = KERN_PRINTK_RATELIMIT,
668 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700669 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 .maxlen = sizeof(int),
671 .mode = 0644,
672 .proc_handler = &proc_dointvec_jiffies,
673 .strategy = &sysctl_jiffies,
674 },
675 {
676 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
677 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700678 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 .maxlen = sizeof(int),
680 .mode = 0644,
681 .proc_handler = &proc_dointvec,
682 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800683#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 {
685 .ctl_name = KERN_NGROUPS_MAX,
686 .procname = "ngroups_max",
687 .data = &ngroups_max,
688 .maxlen = sizeof (int),
689 .mode = 0444,
690 .proc_handler = &proc_dointvec,
691 },
692#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
693 {
694 .ctl_name = KERN_UNKNOWN_NMI_PANIC,
695 .procname = "unknown_nmi_panic",
696 .data = &unknown_nmi_panic,
697 .maxlen = sizeof (int),
698 .mode = 0644,
Don Zickus2fbe7b22006-09-26 10:52:27 +0200699 .proc_handler = &proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 },
Don Zickus407984f2006-09-26 10:52:27 +0200701 {
Don Zickus407984f2006-09-26 10:52:27 +0200702 .procname = "nmi_watchdog",
703 .data = &nmi_watchdog_enabled,
704 .maxlen = sizeof (int),
705 .mode = 0644,
706 .proc_handler = &proc_nmi_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 },
708#endif
709#if defined(CONFIG_X86)
710 {
Don Zickus8da5add2006-09-26 10:52:27 +0200711 .ctl_name = KERN_PANIC_ON_NMI,
712 .procname = "panic_on_unrecovered_nmi",
713 .data = &panic_on_unrecovered_nmi,
714 .maxlen = sizeof(int),
715 .mode = 0644,
716 .proc_handler = &proc_dointvec,
717 },
718 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 .ctl_name = KERN_BOOTLOADER_TYPE,
720 .procname = "bootloader_type",
721 .data = &bootloader_type,
722 .maxlen = sizeof (int),
723 .mode = 0444,
724 .proc_handler = &proc_dointvec,
725 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100726 {
727 .ctl_name = CTL_UNNUMBERED,
728 .procname = "kstack_depth_to_print",
729 .data = &kstack_depth_to_print,
730 .maxlen = sizeof(int),
731 .mode = 0644,
732 .proc_handler = &proc_dointvec,
733 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100734 {
735 .ctl_name = CTL_UNNUMBERED,
736 .procname = "io_delay_type",
737 .data = &io_delay_type,
738 .maxlen = sizeof(int),
739 .mode = 0644,
740 .proc_handler = &proc_dointvec,
741 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800743#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 {
745 .ctl_name = KERN_RANDOMIZE,
746 .procname = "randomize_va_space",
747 .data = &randomize_va_space,
748 .maxlen = sizeof(int),
749 .mode = 0644,
750 .proc_handler = &proc_dointvec,
751 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800752#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800753#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700754 {
755 .ctl_name = KERN_SPIN_RETRY,
756 .procname = "spin_retry",
757 .data = &spin_retry,
758 .maxlen = sizeof (int),
759 .mode = 0644,
760 .proc_handler = &proc_dointvec,
761 },
762#endif
Len Brown673d5b42007-07-28 03:33:16 -0400763#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800764 {
Pavel Machekc255d842006-02-20 18:27:58 -0800765 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700766 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800767 .maxlen = sizeof (unsigned long),
768 .mode = 0644,
Stefan Seyfried7f99f062006-03-02 02:54:34 -0800769 .proc_handler = &proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800770 },
771#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800772#ifdef CONFIG_IA64
773 {
774 .ctl_name = KERN_IA64_UNALIGNED,
775 .procname = "ignore-unaligned-usertrap",
776 .data = &no_unaligned_warning,
777 .maxlen = sizeof (int),
778 .mode = 0644,
779 .proc_handler = &proc_dointvec,
780 },
781#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700782#ifdef CONFIG_DETECT_SOFTLOCKUP
783 {
784 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200785 .procname = "softlockup_panic",
786 .data = &softlockup_panic,
787 .maxlen = sizeof(int),
788 .mode = 0644,
Hiroshi Shimamoto4dca10a2008-07-07 18:37:04 -0700789 .proc_handler = &proc_dointvec_minmax,
Ingo Molnar9c44bc02008-05-12 21:21:04 +0200790 .strategy = &sysctl_intvec,
791 .extra1 = &zero,
792 .extra2 = &one,
793 },
794 {
795 .ctl_name = CTL_UNNUMBERED,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700796 .procname = "softlockup_thresh",
797 .data = &softlockup_thresh,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200798 .maxlen = sizeof(int),
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700799 .mode = 0644,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200800 .proc_handler = &proc_dointvec_minmax,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700801 .strategy = &sysctl_intvec,
Dimitri Sivanich9383d962008-05-12 21:21:14 +0200802 .extra1 = &neg_one,
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700803 .extra2 = &sixty,
804 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100805 {
806 .ctl_name = CTL_UNNUMBERED,
807 .procname = "hung_task_check_count",
808 .data = &sysctl_hung_task_check_count,
Ingo Molnar90739082008-01-25 21:08:34 +0100809 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100810 .mode = 0644,
Ingo Molnar90739082008-01-25 21:08:34 +0100811 .proc_handler = &proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100812 .strategy = &sysctl_intvec,
813 },
814 {
815 .ctl_name = CTL_UNNUMBERED,
816 .procname = "hung_task_timeout_secs",
817 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +0100818 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100819 .mode = 0644,
Ingo Molnar90739082008-01-25 21:08:34 +0100820 .proc_handler = &proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100821 .strategy = &sysctl_intvec,
822 },
823 {
824 .ctl_name = CTL_UNNUMBERED,
825 .procname = "hung_task_warnings",
826 .data = &sysctl_hung_task_warnings,
Ingo Molnar90739082008-01-25 21:08:34 +0100827 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100828 .mode = 0644,
Ingo Molnar90739082008-01-25 21:08:34 +0100829 .proc_handler = &proc_doulongvec_minmax,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +0100830 .strategy = &sysctl_intvec,
831 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700832#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200833#ifdef CONFIG_COMPAT
834 {
835 .ctl_name = KERN_COMPAT_LOG,
836 .procname = "compat-log",
837 .data = &compat_log,
838 .maxlen = sizeof (int),
839 .mode = 0644,
840 .proc_handler = &proc_dointvec,
841 },
842#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700843#ifdef CONFIG_RT_MUTEXES
844 {
845 .ctl_name = KERN_MAX_LOCK_DEPTH,
846 .procname = "max_lock_depth",
847 .data = &max_lock_depth,
848 .maxlen = sizeof(int),
849 .mode = 0644,
850 .proc_handler = &proc_dointvec,
851 },
852#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700853 {
854 .ctl_name = CTL_UNNUMBERED,
855 .procname = "poweroff_cmd",
856 .data = &poweroff_cmd,
857 .maxlen = POWEROFF_CMD_PATH_LEN,
858 .mode = 0644,
859 .proc_handler = &proc_dostring,
860 .strategy = &sysctl_string,
861 },
David Howells0b77f5b2008-04-29 01:01:32 -0700862#ifdef CONFIG_KEYS
863 {
864 .ctl_name = CTL_UNNUMBERED,
865 .procname = "keys",
866 .mode = 0555,
867 .child = key_sysctls,
868 },
869#endif
Paul E. McKenney31a72bc2008-06-18 09:26:49 -0700870#ifdef CONFIG_RCU_TORTURE_TEST
871 {
872 .ctl_name = CTL_UNNUMBERED,
873 .procname = "rcutorture_runnable",
874 .data = &rcutorture_runnable,
875 .maxlen = sizeof(int),
876 .mode = 0644,
877 .proc_handler = &proc_dointvec,
878 },
879#endif
Lee Schermerhornaf936a12008-10-18 20:26:53 -0700880#ifdef CONFIG_UNEVICTABLE_LRU
881 {
882 .ctl_name = CTL_UNNUMBERED,
883 .procname = "scan_unevictable_pages",
884 .data = &scan_unevictable_pages,
885 .maxlen = sizeof(scan_unevictable_pages),
886 .mode = 0644,
887 .proc_handler = &scan_unevictable_handler,
888 },
889#endif
Andrew Mortoned2c12f2007-07-19 01:50:35 -0700890/*
891 * NOTE: do not add new entries to this table unless you have read
892 * Documentation/sysctl/ctl_unnumbered.txt
893 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894 { .ctl_name = 0 }
895};
896
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700897static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898 {
899 .ctl_name = VM_OVERCOMMIT_MEMORY,
900 .procname = "overcommit_memory",
901 .data = &sysctl_overcommit_memory,
902 .maxlen = sizeof(sysctl_overcommit_memory),
903 .mode = 0644,
904 .proc_handler = &proc_dointvec,
905 },
906 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700907 .ctl_name = VM_PANIC_ON_OOM,
908 .procname = "panic_on_oom",
909 .data = &sysctl_panic_on_oom,
910 .maxlen = sizeof(sysctl_panic_on_oom),
911 .mode = 0644,
912 .proc_handler = &proc_dointvec,
913 },
914 {
David Rientjesfe071d72007-10-16 23:25:56 -0700915 .ctl_name = CTL_UNNUMBERED,
916 .procname = "oom_kill_allocating_task",
917 .data = &sysctl_oom_kill_allocating_task,
918 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
919 .mode = 0644,
920 .proc_handler = &proc_dointvec,
921 },
922 {
David Rientjesfef1bdd2008-02-07 00:14:07 -0800923 .ctl_name = CTL_UNNUMBERED,
924 .procname = "oom_dump_tasks",
925 .data = &sysctl_oom_dump_tasks,
926 .maxlen = sizeof(sysctl_oom_dump_tasks),
927 .mode = 0644,
928 .proc_handler = &proc_dointvec,
929 },
930 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700931 .ctl_name = VM_OVERCOMMIT_RATIO,
932 .procname = "overcommit_ratio",
933 .data = &sysctl_overcommit_ratio,
934 .maxlen = sizeof(sysctl_overcommit_ratio),
935 .mode = 0644,
936 .proc_handler = &proc_dointvec,
937 },
938 {
939 .ctl_name = VM_PAGE_CLUSTER,
940 .procname = "page-cluster",
941 .data = &page_cluster,
942 .maxlen = sizeof(int),
943 .mode = 0644,
944 .proc_handler = &proc_dointvec,
945 },
946 {
947 .ctl_name = VM_DIRTY_BACKGROUND,
948 .procname = "dirty_background_ratio",
949 .data = &dirty_background_ratio,
950 .maxlen = sizeof(dirty_background_ratio),
951 .mode = 0644,
David Rientjes2da02992009-01-06 14:39:31 -0800952 .proc_handler = &dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953 .strategy = &sysctl_intvec,
954 .extra1 = &zero,
955 .extra2 = &one_hundred,
956 },
957 {
David Rientjes2da02992009-01-06 14:39:31 -0800958 .ctl_name = CTL_UNNUMBERED,
959 .procname = "dirty_background_bytes",
960 .data = &dirty_background_bytes,
961 .maxlen = sizeof(dirty_background_bytes),
962 .mode = 0644,
963 .proc_handler = &dirty_background_bytes_handler,
964 .strategy = &sysctl_intvec,
965 .extra1 = &one,
966 },
967 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968 .ctl_name = VM_DIRTY_RATIO,
969 .procname = "dirty_ratio",
970 .data = &vm_dirty_ratio,
971 .maxlen = sizeof(vm_dirty_ratio),
972 .mode = 0644,
Peter Zijlstra04fbfdc2007-10-16 23:25:50 -0700973 .proc_handler = &dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700974 .strategy = &sysctl_intvec,
975 .extra1 = &zero,
976 .extra2 = &one_hundred,
977 },
978 {
David Rientjes2da02992009-01-06 14:39:31 -0800979 .ctl_name = CTL_UNNUMBERED,
980 .procname = "dirty_bytes",
981 .data = &vm_dirty_bytes,
982 .maxlen = sizeof(vm_dirty_bytes),
983 .mode = 0644,
984 .proc_handler = &dirty_bytes_handler,
985 .strategy = &sysctl_intvec,
986 .extra1 = &one,
987 },
988 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700989 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -0800990 .data = &dirty_writeback_interval,
991 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700992 .mode = 0644,
993 .proc_handler = &dirty_writeback_centisecs_handler,
994 },
995 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -0800997 .data = &dirty_expire_interval,
998 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700999 .mode = 0644,
Bart Samwelf6ef9432006-03-24 03:15:48 -08001000 .proc_handler = &proc_dointvec_userhz_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001 },
1002 {
1003 .ctl_name = VM_NR_PDFLUSH_THREADS,
1004 .procname = "nr_pdflush_threads",
1005 .data = &nr_pdflush_threads,
1006 .maxlen = sizeof nr_pdflush_threads,
1007 .mode = 0444 /* read-only*/,
1008 .proc_handler = &proc_dointvec,
1009 },
1010 {
1011 .ctl_name = VM_SWAPPINESS,
1012 .procname = "swappiness",
1013 .data = &vm_swappiness,
1014 .maxlen = sizeof(vm_swappiness),
1015 .mode = 0644,
1016 .proc_handler = &proc_dointvec_minmax,
1017 .strategy = &sysctl_intvec,
1018 .extra1 = &zero,
1019 .extra2 = &one_hundred,
1020 },
1021#ifdef CONFIG_HUGETLB_PAGE
1022 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001023 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001024 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001025 .maxlen = sizeof(unsigned long),
1026 .mode = 0644,
1027 .proc_handler = &hugetlb_sysctl_handler,
1028 .extra1 = (void *)&hugetlb_zero,
1029 .extra2 = (void *)&hugetlb_infinity,
1030 },
1031 {
1032 .ctl_name = VM_HUGETLB_GROUP,
1033 .procname = "hugetlb_shm_group",
1034 .data = &sysctl_hugetlb_shm_group,
1035 .maxlen = sizeof(gid_t),
1036 .mode = 0644,
1037 .proc_handler = &proc_dointvec,
1038 },
Mel Gorman396faf02007-07-17 04:03:13 -07001039 {
1040 .ctl_name = CTL_UNNUMBERED,
1041 .procname = "hugepages_treat_as_movable",
1042 .data = &hugepages_treat_as_movable,
1043 .maxlen = sizeof(int),
1044 .mode = 0644,
1045 .proc_handler = &hugetlb_treat_movable_handler,
1046 },
Adam Litke54f9f802007-10-16 01:26:20 -07001047 {
1048 .ctl_name = CTL_UNNUMBERED,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001049 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001050 .data = NULL,
1051 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001052 .mode = 0644,
Nishanth Aravamudana3d0c6a2008-02-08 04:18:18 -08001053 .proc_handler = &hugetlb_overcommit_handler,
Andi Kleene5ff2152008-07-23 21:27:42 -07001054 .extra1 = (void *)&hugetlb_zero,
1055 .extra2 = (void *)&hugetlb_infinity,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001056 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001057#endif
1058 {
1059 .ctl_name = VM_LOWMEM_RESERVE_RATIO,
1060 .procname = "lowmem_reserve_ratio",
1061 .data = &sysctl_lowmem_reserve_ratio,
1062 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1063 .mode = 0644,
1064 .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
1065 .strategy = &sysctl_intvec,
1066 },
1067 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001068 .ctl_name = VM_DROP_PAGECACHE,
1069 .procname = "drop_caches",
1070 .data = &sysctl_drop_caches,
1071 .maxlen = sizeof(int),
1072 .mode = 0644,
1073 .proc_handler = drop_caches_sysctl_handler,
1074 .strategy = &sysctl_intvec,
1075 },
1076 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001077 .ctl_name = VM_MIN_FREE_KBYTES,
1078 .procname = "min_free_kbytes",
1079 .data = &min_free_kbytes,
1080 .maxlen = sizeof(min_free_kbytes),
1081 .mode = 0644,
1082 .proc_handler = &min_free_kbytes_sysctl_handler,
1083 .strategy = &sysctl_intvec,
1084 .extra1 = &zero,
1085 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001086 {
1087 .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
1088 .procname = "percpu_pagelist_fraction",
1089 .data = &percpu_pagelist_fraction,
1090 .maxlen = sizeof(percpu_pagelist_fraction),
1091 .mode = 0644,
1092 .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
1093 .strategy = &sysctl_intvec,
1094 .extra1 = &min_percpu_pagelist_fract,
1095 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001096#ifdef CONFIG_MMU
1097 {
1098 .ctl_name = VM_MAX_MAP_COUNT,
1099 .procname = "max_map_count",
1100 .data = &sysctl_max_map_count,
1101 .maxlen = sizeof(sysctl_max_map_count),
1102 .mode = 0644,
1103 .proc_handler = &proc_dointvec
1104 },
1105#endif
1106 {
1107 .ctl_name = VM_LAPTOP_MODE,
1108 .procname = "laptop_mode",
1109 .data = &laptop_mode,
1110 .maxlen = sizeof(laptop_mode),
1111 .mode = 0644,
Bart Samweled5b43f2006-03-24 03:15:49 -08001112 .proc_handler = &proc_dointvec_jiffies,
1113 .strategy = &sysctl_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001114 },
1115 {
1116 .ctl_name = VM_BLOCK_DUMP,
1117 .procname = "block_dump",
1118 .data = &block_dump,
1119 .maxlen = sizeof(block_dump),
1120 .mode = 0644,
1121 .proc_handler = &proc_dointvec,
1122 .strategy = &sysctl_intvec,
1123 .extra1 = &zero,
1124 },
1125 {
1126 .ctl_name = VM_VFS_CACHE_PRESSURE,
1127 .procname = "vfs_cache_pressure",
1128 .data = &sysctl_vfs_cache_pressure,
1129 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1130 .mode = 0644,
1131 .proc_handler = &proc_dointvec,
1132 .strategy = &sysctl_intvec,
1133 .extra1 = &zero,
1134 },
1135#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1136 {
1137 .ctl_name = VM_LEGACY_VA_LAYOUT,
1138 .procname = "legacy_va_layout",
1139 .data = &sysctl_legacy_va_layout,
1140 .maxlen = sizeof(sysctl_legacy_va_layout),
1141 .mode = 0644,
1142 .proc_handler = &proc_dointvec,
1143 .strategy = &sysctl_intvec,
1144 .extra1 = &zero,
1145 },
1146#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001147#ifdef CONFIG_NUMA
1148 {
1149 .ctl_name = VM_ZONE_RECLAIM_MODE,
1150 .procname = "zone_reclaim_mode",
1151 .data = &zone_reclaim_mode,
1152 .maxlen = sizeof(zone_reclaim_mode),
1153 .mode = 0644,
1154 .proc_handler = &proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001155 .strategy = &sysctl_intvec,
1156 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001157 },
Christoph Lameter96146342006-07-03 00:24:13 -07001158 {
1159 .ctl_name = VM_MIN_UNMAPPED,
1160 .procname = "min_unmapped_ratio",
1161 .data = &sysctl_min_unmapped_ratio,
1162 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1163 .mode = 0644,
1164 .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
1165 .strategy = &sysctl_intvec,
1166 .extra1 = &zero,
1167 .extra2 = &one_hundred,
1168 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001169 {
1170 .ctl_name = VM_MIN_SLAB,
1171 .procname = "min_slab_ratio",
1172 .data = &sysctl_min_slab_ratio,
1173 .maxlen = sizeof(sysctl_min_slab_ratio),
1174 .mode = 0644,
1175 .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
1176 .strategy = &sysctl_intvec,
1177 .extra1 = &zero,
1178 .extra2 = &one_hundred,
1179 },
Christoph Lameter17436602006-01-18 17:42:32 -08001180#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001181#ifdef CONFIG_SMP
1182 {
1183 .ctl_name = CTL_UNNUMBERED,
1184 .procname = "stat_interval",
1185 .data = &sysctl_stat_interval,
1186 .maxlen = sizeof(sysctl_stat_interval),
1187 .mode = 0644,
1188 .proc_handler = &proc_dointvec_jiffies,
1189 .strategy = &sysctl_jiffies,
1190 },
1191#endif
Eric Parised032182007-06-28 15:55:21 -04001192#ifdef CONFIG_SECURITY
1193 {
1194 .ctl_name = CTL_UNNUMBERED,
1195 .procname = "mmap_min_addr",
1196 .data = &mmap_min_addr,
1197 .maxlen = sizeof(unsigned long),
1198 .mode = 0644,
1199 .proc_handler = &proc_doulongvec_minmax,
1200 },
Lee Schermerhorn8daec962007-08-10 13:00:51 -07001201#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001202#ifdef CONFIG_NUMA
1203 {
1204 .ctl_name = CTL_UNNUMBERED,
1205 .procname = "numa_zonelist_order",
1206 .data = &numa_zonelist_order,
1207 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1208 .mode = 0644,
1209 .proc_handler = &numa_zonelist_order_handler,
1210 .strategy = &sysctl_string,
1211 },
1212#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001213#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001214 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001215 {
1216 .ctl_name = VM_VDSO_ENABLED,
1217 .procname = "vdso_enabled",
1218 .data = &vdso_enabled,
1219 .maxlen = sizeof(vdso_enabled),
1220 .mode = 0644,
1221 .proc_handler = &proc_dointvec,
1222 .strategy = &sysctl_intvec,
1223 .extra1 = &zero,
1224 },
1225#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001226#ifdef CONFIG_HIGHMEM
1227 {
1228 .ctl_name = CTL_UNNUMBERED,
1229 .procname = "highmem_is_dirtyable",
1230 .data = &vm_highmem_is_dirtyable,
1231 .maxlen = sizeof(vm_highmem_is_dirtyable),
1232 .mode = 0644,
1233 .proc_handler = &proc_dointvec_minmax,
1234 .strategy = &sysctl_intvec,
1235 .extra1 = &zero,
1236 .extra2 = &one,
1237 },
1238#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001239/*
1240 * NOTE: do not add new entries to this table unless you have read
1241 * Documentation/sysctl/ctl_unnumbered.txt
1242 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243 { .ctl_name = 0 }
1244};
1245
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001246#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001247static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001248 { .ctl_name = 0 }
1249};
1250#endif
1251
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001252static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001253 {
1254 .ctl_name = FS_NRINODE,
1255 .procname = "inode-nr",
1256 .data = &inodes_stat,
1257 .maxlen = 2*sizeof(int),
1258 .mode = 0444,
1259 .proc_handler = &proc_dointvec,
1260 },
1261 {
1262 .ctl_name = FS_STATINODE,
1263 .procname = "inode-state",
1264 .data = &inodes_stat,
1265 .maxlen = 7*sizeof(int),
1266 .mode = 0444,
1267 .proc_handler = &proc_dointvec,
1268 },
1269 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001270 .procname = "file-nr",
1271 .data = &files_stat,
1272 .maxlen = 3*sizeof(int),
1273 .mode = 0444,
Dipankar Sarma529bf6b2006-03-07 21:55:35 -08001274 .proc_handler = &proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001275 },
1276 {
1277 .ctl_name = FS_MAXFILE,
1278 .procname = "file-max",
1279 .data = &files_stat.max_files,
1280 .maxlen = sizeof(int),
1281 .mode = 0644,
1282 .proc_handler = &proc_dointvec,
1283 },
1284 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001285 .ctl_name = CTL_UNNUMBERED,
1286 .procname = "nr_open",
1287 .data = &sysctl_nr_open,
1288 .maxlen = sizeof(int),
1289 .mode = 0644,
Al Viroeceea0b2008-05-10 10:08:32 -04001290 .proc_handler = &proc_dointvec_minmax,
1291 .extra1 = &sysctl_nr_open_min,
1292 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001293 },
1294 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001295 .ctl_name = FS_DENTRY,
1296 .procname = "dentry-state",
1297 .data = &dentry_stat,
1298 .maxlen = 6*sizeof(int),
1299 .mode = 0444,
1300 .proc_handler = &proc_dointvec,
1301 },
1302 {
1303 .ctl_name = FS_OVERFLOWUID,
1304 .procname = "overflowuid",
1305 .data = &fs_overflowuid,
1306 .maxlen = sizeof(int),
1307 .mode = 0644,
1308 .proc_handler = &proc_dointvec_minmax,
1309 .strategy = &sysctl_intvec,
1310 .extra1 = &minolduid,
1311 .extra2 = &maxolduid,
1312 },
1313 {
1314 .ctl_name = FS_OVERFLOWGID,
1315 .procname = "overflowgid",
1316 .data = &fs_overflowgid,
1317 .maxlen = sizeof(int),
1318 .mode = 0644,
1319 .proc_handler = &proc_dointvec_minmax,
1320 .strategy = &sysctl_intvec,
1321 .extra1 = &minolduid,
1322 .extra2 = &maxolduid,
1323 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001324#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 {
1326 .ctl_name = FS_LEASES,
1327 .procname = "leases-enable",
1328 .data = &leases_enable,
1329 .maxlen = sizeof(int),
1330 .mode = 0644,
1331 .proc_handler = &proc_dointvec,
1332 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001333#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001334#ifdef CONFIG_DNOTIFY
1335 {
1336 .ctl_name = FS_DIR_NOTIFY,
1337 .procname = "dir-notify-enable",
1338 .data = &dir_notify_enable,
1339 .maxlen = sizeof(int),
1340 .mode = 0644,
1341 .proc_handler = &proc_dointvec,
1342 },
1343#endif
1344#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001345#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001346 {
1347 .ctl_name = FS_LEASE_TIME,
1348 .procname = "lease-break-time",
1349 .data = &lease_break_time,
1350 .maxlen = sizeof(int),
1351 .mode = 0644,
Kawai, Hidehiro76fdbb22007-07-19 01:48:26 -07001352 .proc_handler = &proc_dointvec_minmax,
1353 .strategy = &sysctl_intvec,
1354 .extra1 = &zero,
1355 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001356 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001357#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001358#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001359 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001360 .procname = "aio-nr",
1361 .data = &aio_nr,
1362 .maxlen = sizeof(aio_nr),
1363 .mode = 0444,
Zach Brownd55b5fd2005-11-07 00:59:31 -08001364 .proc_handler = &proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001365 },
1366 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001367 .procname = "aio-max-nr",
1368 .data = &aio_max_nr,
1369 .maxlen = sizeof(aio_max_nr),
1370 .mode = 0644,
Zach Brownd55b5fd2005-11-07 00:59:31 -08001371 .proc_handler = &proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001373#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001374#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001375 {
1376 .ctl_name = FS_INOTIFY,
1377 .procname = "inotify",
1378 .mode = 0555,
1379 .child = inotify_table,
1380 },
1381#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001382#ifdef CONFIG_EPOLL
1383 {
1384 .procname = "epoll",
1385 .mode = 0555,
1386 .child = epoll_table,
1387 },
1388#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001390 {
1391 .ctl_name = KERN_SETUID_DUMPABLE,
1392 .procname = "suid_dumpable",
1393 .data = &suid_dumpable,
1394 .maxlen = sizeof(int),
1395 .mode = 0644,
1396 .proc_handler = &proc_dointvec,
1397 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001398#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1399 {
1400 .ctl_name = CTL_UNNUMBERED,
1401 .procname = "binfmt_misc",
1402 .mode = 0555,
1403 .child = binfmt_misc_table,
1404 },
1405#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001406/*
1407 * NOTE: do not add new entries to this table unless you have read
1408 * Documentation/sysctl/ctl_unnumbered.txt
1409 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001410 { .ctl_name = 0 }
1411};
1412
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001413static struct ctl_table debug_table[] = {
Olof Johanssond0c3d532007-10-12 10:20:07 +10001414#if defined(CONFIG_X86) || defined(CONFIG_PPC)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001415 {
1416 .ctl_name = CTL_UNNUMBERED,
1417 .procname = "exception-trace",
1418 .data = &show_unhandled_signals,
1419 .maxlen = sizeof(int),
1420 .mode = 0644,
1421 .proc_handler = proc_dointvec
1422 },
1423#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001424 { .ctl_name = 0 }
1425};
1426
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001427static struct ctl_table dev_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001428 { .ctl_name = 0 }
Robert Love0eeca282005-07-12 17:06:03 -04001429};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001430
Al Viro330d57f2005-11-04 10:18:40 +00001431static DEFINE_SPINLOCK(sysctl_lock);
1432
1433/* called under sysctl_lock */
1434static int use_table(struct ctl_table_header *p)
1435{
1436 if (unlikely(p->unregistering))
1437 return 0;
1438 p->used++;
1439 return 1;
1440}
1441
1442/* called under sysctl_lock */
1443static void unuse_table(struct ctl_table_header *p)
1444{
1445 if (!--p->used)
1446 if (unlikely(p->unregistering))
1447 complete(p->unregistering);
1448}
1449
1450/* called under sysctl_lock, will reacquire if has to wait */
1451static void start_unregistering(struct ctl_table_header *p)
1452{
1453 /*
1454 * if p->used is 0, nobody will ever touch that entry again;
1455 * we'll eliminate all paths to it before dropping sysctl_lock
1456 */
1457 if (unlikely(p->used)) {
1458 struct completion wait;
1459 init_completion(&wait);
1460 p->unregistering = &wait;
1461 spin_unlock(&sysctl_lock);
1462 wait_for_completion(&wait);
1463 spin_lock(&sysctl_lock);
Al Virof7e6ced2008-07-15 01:44:23 -04001464 } else {
1465 /* anything non-NULL; we'll never dereference it */
1466 p->unregistering = ERR_PTR(-EINVAL);
Al Viro330d57f2005-11-04 10:18:40 +00001467 }
1468 /*
1469 * do not remove from the list until nobody holds it; walking the
1470 * list in do_sysctl() relies on that.
1471 */
1472 list_del_init(&p->ctl_entry);
1473}
1474
Al Virof7e6ced2008-07-15 01:44:23 -04001475void sysctl_head_get(struct ctl_table_header *head)
1476{
1477 spin_lock(&sysctl_lock);
1478 head->count++;
1479 spin_unlock(&sysctl_lock);
1480}
1481
1482void sysctl_head_put(struct ctl_table_header *head)
1483{
1484 spin_lock(&sysctl_lock);
1485 if (!--head->count)
1486 kfree(head);
1487 spin_unlock(&sysctl_lock);
1488}
1489
1490struct ctl_table_header *sysctl_head_grab(struct ctl_table_header *head)
1491{
1492 if (!head)
1493 BUG();
1494 spin_lock(&sysctl_lock);
1495 if (!use_table(head))
1496 head = ERR_PTR(-ENOENT);
1497 spin_unlock(&sysctl_lock);
1498 return head;
1499}
1500
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001501void sysctl_head_finish(struct ctl_table_header *head)
1502{
1503 if (!head)
1504 return;
1505 spin_lock(&sysctl_lock);
1506 unuse_table(head);
1507 spin_unlock(&sysctl_lock);
1508}
1509
Al Viro73455092008-07-14 21:22:20 -04001510static struct ctl_table_set *
1511lookup_header_set(struct ctl_table_root *root, struct nsproxy *namespaces)
1512{
1513 struct ctl_table_set *set = &root->default_set;
1514 if (root->lookup)
1515 set = root->lookup(root, namespaces);
1516 return set;
1517}
1518
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001519static struct list_head *
1520lookup_header_list(struct ctl_table_root *root, struct nsproxy *namespaces)
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001521{
Al Viro73455092008-07-14 21:22:20 -04001522 struct ctl_table_set *set = lookup_header_set(root, namespaces);
1523 return &set->list;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001524}
1525
1526struct ctl_table_header *__sysctl_head_next(struct nsproxy *namespaces,
1527 struct ctl_table_header *prev)
1528{
1529 struct ctl_table_root *root;
1530 struct list_head *header_list;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001531 struct ctl_table_header *head;
1532 struct list_head *tmp;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001533
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001534 spin_lock(&sysctl_lock);
1535 if (prev) {
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001536 head = prev;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001537 tmp = &prev->ctl_entry;
1538 unuse_table(prev);
1539 goto next;
1540 }
1541 tmp = &root_table_header.ctl_entry;
1542 for (;;) {
1543 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1544
1545 if (!use_table(head))
1546 goto next;
1547 spin_unlock(&sysctl_lock);
1548 return head;
1549 next:
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001550 root = head->root;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001551 tmp = tmp->next;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001552 header_list = lookup_header_list(root, namespaces);
1553 if (tmp != header_list)
1554 continue;
1555
1556 do {
1557 root = list_entry(root->root_list.next,
1558 struct ctl_table_root, root_list);
1559 if (root == &sysctl_table_root)
1560 goto out;
1561 header_list = lookup_header_list(root, namespaces);
1562 } while (list_empty(header_list));
1563 tmp = header_list->next;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001564 }
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001565out:
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001566 spin_unlock(&sysctl_lock);
1567 return NULL;
1568}
1569
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001570struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1571{
1572 return __sysctl_head_next(current->nsproxy, prev);
1573}
1574
1575void register_sysctl_root(struct ctl_table_root *root)
1576{
1577 spin_lock(&sysctl_lock);
1578 list_add_tail(&root->root_list, &sysctl_table_root.root_list);
1579 spin_unlock(&sysctl_lock);
1580}
1581
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001582#ifdef CONFIG_SYSCTL_SYSCALL
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001583/* Perform the actual read/write of a sysctl table entry. */
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001584static int do_sysctl_strategy(struct ctl_table_root *root,
1585 struct ctl_table *table,
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001586 void __user *oldval, size_t __user *oldlenp,
1587 void __user *newval, size_t newlen)
1588{
1589 int op = 0, rc;
1590
1591 if (oldval)
Al Viroe6305c42008-07-15 21:03:57 -04001592 op |= MAY_READ;
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001593 if (newval)
Al Viroe6305c42008-07-15 21:03:57 -04001594 op |= MAY_WRITE;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001595 if (sysctl_perm(root, table, op))
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001596 return -EPERM;
1597
1598 if (table->strategy) {
Alexey Dobriyanf221e722008-10-15 22:04:23 -07001599 rc = table->strategy(table, oldval, oldlenp, newval, newlen);
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001600 if (rc < 0)
1601 return rc;
1602 if (rc > 0)
1603 return 0;
1604 }
1605
1606 /* If there is no strategy routine, or if the strategy returns
1607 * zero, proceed with automatic r/w */
1608 if (table->data && table->maxlen) {
Alexey Dobriyanf221e722008-10-15 22:04:23 -07001609 rc = sysctl_data(table, oldval, oldlenp, newval, newlen);
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001610 if (rc < 0)
1611 return rc;
1612 }
1613 return 0;
1614}
1615
1616static int parse_table(int __user *name, int nlen,
1617 void __user *oldval, size_t __user *oldlenp,
1618 void __user *newval, size_t newlen,
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001619 struct ctl_table_root *root,
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001620 struct ctl_table *table)
1621{
1622 int n;
1623repeat:
1624 if (!nlen)
1625 return -ENOTDIR;
1626 if (get_user(n, name))
1627 return -EFAULT;
1628 for ( ; table->ctl_name || table->procname; table++) {
1629 if (!table->ctl_name)
1630 continue;
1631 if (n == table->ctl_name) {
1632 int error;
1633 if (table->child) {
Al Viroe6305c42008-07-15 21:03:57 -04001634 if (sysctl_perm(root, table, MAY_EXEC))
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001635 return -EPERM;
1636 name++;
1637 nlen--;
1638 table = table->child;
1639 goto repeat;
1640 }
Alexey Dobriyanf221e722008-10-15 22:04:23 -07001641 error = do_sysctl_strategy(root, table,
Pavel Emelyanov2c4c7152008-04-29 01:02:41 -07001642 oldval, oldlenp,
1643 newval, newlen);
1644 return error;
1645 }
1646 }
1647 return -ENOTDIR;
1648}
1649
Linus Torvalds1da177e2005-04-16 15:20:36 -07001650int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1651 void __user *newval, size_t newlen)
1652{
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001653 struct ctl_table_header *head;
Al Viro330d57f2005-11-04 10:18:40 +00001654 int error = -ENOTDIR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655
1656 if (nlen <= 0 || nlen >= CTL_MAXNAME)
1657 return -ENOTDIR;
1658 if (oldval) {
1659 int old_len;
1660 if (!oldlenp || get_user(old_len, oldlenp))
1661 return -EFAULT;
1662 }
Al Viro330d57f2005-11-04 10:18:40 +00001663
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001664 for (head = sysctl_head_next(NULL); head;
1665 head = sysctl_head_next(head)) {
Al Viro330d57f2005-11-04 10:18:40 +00001666 error = parse_table(name, nlen, oldval, oldlenp,
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001667 newval, newlen,
1668 head->root, head->ctl_table);
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001669 if (error != -ENOTDIR) {
1670 sysctl_head_finish(head);
Al Viro330d57f2005-11-04 10:18:40 +00001671 break;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001672 }
1673 }
Al Viro330d57f2005-11-04 10:18:40 +00001674 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001675}
1676
1677asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1678{
1679 struct __sysctl_args tmp;
1680 int error;
1681
1682 if (copy_from_user(&tmp, args, sizeof(tmp)))
1683 return -EFAULT;
1684
Eric W. Biederman7058cb02007-10-18 03:05:58 -07001685 error = deprecated_sysctl_warning(&tmp);
1686 if (error)
1687 goto out;
1688
Linus Torvalds1da177e2005-04-16 15:20:36 -07001689 lock_kernel();
1690 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1691 tmp.newval, tmp.newlen);
1692 unlock_kernel();
Eric W. Biederman7058cb02007-10-18 03:05:58 -07001693out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001694 return error;
1695}
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001696#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001697
1698/*
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001699 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700 * some sysctl variables are readonly even to root.
1701 */
1702
1703static int test_perm(int mode, int op)
1704{
David Howells76aac0e2008-11-14 10:39:12 +11001705 if (!current_euid())
Linus Torvalds1da177e2005-04-16 15:20:36 -07001706 mode >>= 6;
1707 else if (in_egroup_p(0))
1708 mode >>= 3;
Al Viroe6305c42008-07-15 21:03:57 -04001709 if ((op & ~mode & (MAY_READ|MAY_WRITE|MAY_EXEC)) == 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001710 return 0;
1711 return -EACCES;
1712}
1713
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001714int sysctl_perm(struct ctl_table_root *root, struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001715{
1716 int error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001717 int mode;
1718
Al Viroe6305c42008-07-15 21:03:57 -04001719 error = security_sysctl(table, op & (MAY_READ | MAY_WRITE | MAY_EXEC));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001720 if (error)
1721 return error;
Pavel Emelyanovd7321cd2008-04-29 01:02:44 -07001722
1723 if (root->permissions)
1724 mode = root->permissions(root, current->nsproxy, table);
1725 else
1726 mode = table->mode;
1727
1728 return test_perm(mode, op);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729}
1730
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001731static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1732{
1733 for (; table->ctl_name || table->procname; table++) {
1734 table->parent = parent;
1735 if (table->child)
1736 sysctl_set_parent(table, table->child);
1737 }
1738}
1739
1740static __init int sysctl_init(void)
1741{
1742 sysctl_set_parent(NULL, root_table);
Holger Schurig88f458e2008-04-29 01:02:36 -07001743#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
1744 {
1745 int err;
1746 err = sysctl_check_table(current->nsproxy, root_table);
1747 }
1748#endif
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001749 return 0;
1750}
1751
1752core_initcall(sysctl_init);
1753
Al Virobfbcf032008-07-27 06:31:22 +01001754static struct ctl_table *is_branch_in(struct ctl_table *branch,
1755 struct ctl_table *table)
Al Viroae7edec2008-07-15 06:33:31 -04001756{
1757 struct ctl_table *p;
1758 const char *s = branch->procname;
1759
1760 /* branch should have named subdirectory as its first element */
1761 if (!s || !branch->child)
Al Virobfbcf032008-07-27 06:31:22 +01001762 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001763
1764 /* ... and nothing else */
1765 if (branch[1].procname || branch[1].ctl_name)
Al Virobfbcf032008-07-27 06:31:22 +01001766 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001767
1768 /* table should contain subdirectory with the same name */
1769 for (p = table; p->procname || p->ctl_name; p++) {
1770 if (!p->child)
1771 continue;
1772 if (p->procname && strcmp(p->procname, s) == 0)
Al Virobfbcf032008-07-27 06:31:22 +01001773 return p;
Al Viroae7edec2008-07-15 06:33:31 -04001774 }
Al Virobfbcf032008-07-27 06:31:22 +01001775 return NULL;
Al Viroae7edec2008-07-15 06:33:31 -04001776}
1777
1778/* see if attaching q to p would be an improvement */
1779static void try_attach(struct ctl_table_header *p, struct ctl_table_header *q)
1780{
1781 struct ctl_table *to = p->ctl_table, *by = q->ctl_table;
Al Virobfbcf032008-07-27 06:31:22 +01001782 struct ctl_table *next;
Al Viroae7edec2008-07-15 06:33:31 -04001783 int is_better = 0;
1784 int not_in_parent = !p->attached_by;
1785
Al Virobfbcf032008-07-27 06:31:22 +01001786 while ((next = is_branch_in(by, to)) != NULL) {
Al Viroae7edec2008-07-15 06:33:31 -04001787 if (by == q->attached_by)
1788 is_better = 1;
1789 if (to == p->attached_by)
1790 not_in_parent = 1;
1791 by = by->child;
Al Virobfbcf032008-07-27 06:31:22 +01001792 to = next->child;
Al Viroae7edec2008-07-15 06:33:31 -04001793 }
1794
1795 if (is_better && not_in_parent) {
1796 q->attached_by = by;
1797 q->attached_to = to;
1798 q->parent = p;
1799 }
1800}
1801
Linus Torvalds1da177e2005-04-16 15:20:36 -07001802/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001803 * __register_sysctl_paths - register a sysctl hierarchy
1804 * @root: List of sysctl headers to register on
1805 * @namespaces: Data to compute which lists of sysctl entries are visible
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001806 * @path: The path to the directory the sysctl table is in.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001807 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001808 *
1809 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001810 * array. A completely 0 filled entry terminates the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -07001811 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001812 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001813 *
1814 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1815 * must be unique within that level of sysctl
1816 *
1817 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1818 * enter a sysctl file
1819 *
1820 * data - a pointer to data for use by proc_handler
1821 *
1822 * maxlen - the maximum size in bytes of the data
1823 *
1824 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1825 *
1826 * child - a pointer to the child sysctl table if this entry is a directory, or
1827 * %NULL.
1828 *
1829 * proc_handler - the text handler routine (described below)
1830 *
1831 * strategy - the strategy routine (described below)
1832 *
1833 * de - for internal use by the sysctl routines
1834 *
1835 * extra1, extra2 - extra pointers usable by the proc handler routines
1836 *
1837 * Leaf nodes in the sysctl tree will be represented by a single file
1838 * under /proc; non-leaf nodes will be represented by directories.
1839 *
1840 * sysctl(2) can automatically manage read and write requests through
1841 * the sysctl table. The data and maxlen fields of the ctl_table
1842 * struct enable minimal validation of the values being written to be
1843 * performed, and the mode field allows minimal authentication.
1844 *
1845 * More sophisticated management can be enabled by the provision of a
1846 * strategy routine with the table entry. This will be called before
1847 * any automatic read or write of the data is performed.
1848 *
1849 * The strategy routine may return
1850 *
1851 * < 0 - Error occurred (error is passed to user process)
1852 *
1853 * 0 - OK - proceed with automatic read or write.
1854 *
1855 * > 0 - OK - read or write has been done by the strategy routine, so
1856 * return immediately.
1857 *
1858 * There must be a proc_handler routine for any terminal nodes
1859 * mirrored under /proc/sys (non-terminals are handled by a built-in
1860 * directory handler). Several default handlers are available to
1861 * cover common cases -
1862 *
1863 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1864 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1865 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1866 *
1867 * It is the handler's job to read the input buffer from user memory
1868 * and process it. The handler should return 0 on success.
1869 *
1870 * This routine returns %NULL on a failure to register, and a pointer
1871 * to the table header on success.
1872 */
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001873struct ctl_table_header *__register_sysctl_paths(
1874 struct ctl_table_root *root,
1875 struct nsproxy *namespaces,
1876 const struct ctl_path *path, struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001877{
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001878 struct ctl_table_header *header;
1879 struct ctl_table *new, **prevp;
1880 unsigned int n, npath;
Al Viroae7edec2008-07-15 06:33:31 -04001881 struct ctl_table_set *set;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001882
1883 /* Count the path components */
1884 for (npath = 0; path[npath].ctl_name || path[npath].procname; ++npath)
1885 ;
1886
1887 /*
1888 * For each path component, allocate a 2-element ctl_table array.
1889 * The first array element will be filled with the sysctl entry
1890 * for this, the second will be the sentinel (ctl_name == 0).
1891 *
1892 * We allocate everything in one go so that we don't have to
1893 * worry about freeing additional memory in unregister_sysctl_table.
1894 */
1895 header = kzalloc(sizeof(struct ctl_table_header) +
1896 (2 * npath * sizeof(struct ctl_table)), GFP_KERNEL);
1897 if (!header)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001898 return NULL;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001899
1900 new = (struct ctl_table *) (header + 1);
1901
1902 /* Now connect the dots */
1903 prevp = &header->ctl_table;
1904 for (n = 0; n < npath; ++n, ++path) {
1905 /* Copy the procname */
1906 new->procname = path->procname;
1907 new->ctl_name = path->ctl_name;
1908 new->mode = 0555;
1909
1910 *prevp = new;
1911 prevp = &new->child;
1912
1913 new += 2;
1914 }
1915 *prevp = table;
Eric W. Biederman23eb06d2007-11-30 23:52:10 +11001916 header->ctl_table_arg = table;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001917
1918 INIT_LIST_HEAD(&header->ctl_entry);
1919 header->used = 0;
1920 header->unregistering = NULL;
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001921 header->root = root;
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001922 sysctl_set_parent(NULL, header->ctl_table);
Al Virof7e6ced2008-07-15 01:44:23 -04001923 header->count = 1;
Holger Schurig88f458e2008-04-29 01:02:36 -07001924#ifdef CONFIG_SYSCTL_SYSCALL_CHECK
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001925 if (sysctl_check_table(namespaces, header->ctl_table)) {
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001926 kfree(header);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001927 return NULL;
1928 }
Holger Schurig88f458e2008-04-29 01:02:36 -07001929#endif
Al Viro330d57f2005-11-04 10:18:40 +00001930 spin_lock(&sysctl_lock);
Al Viro73455092008-07-14 21:22:20 -04001931 header->set = lookup_header_set(root, namespaces);
Al Viroae7edec2008-07-15 06:33:31 -04001932 header->attached_by = header->ctl_table;
1933 header->attached_to = root_table;
1934 header->parent = &root_table_header;
1935 for (set = header->set; set; set = set->parent) {
1936 struct ctl_table_header *p;
1937 list_for_each_entry(p, &set->list, ctl_entry) {
1938 if (p->unregistering)
1939 continue;
1940 try_attach(p, header);
1941 }
1942 }
1943 header->parent->count++;
Al Viro73455092008-07-14 21:22:20 -04001944 list_add_tail(&header->ctl_entry, &header->set->list);
Al Viro330d57f2005-11-04 10:18:40 +00001945 spin_unlock(&sysctl_lock);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001946
1947 return header;
1948}
1949
1950/**
Eric W. Biedermane51b6ba2007-11-30 23:54:00 +11001951 * register_sysctl_table_path - register a sysctl table hierarchy
1952 * @path: The path to the directory the sysctl table is in.
1953 * @table: the top-level table structure
1954 *
1955 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1956 * array. A completely 0 filled entry terminates the table.
1957 *
1958 * See __register_sysctl_paths for more details.
1959 */
1960struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
1961 struct ctl_table *table)
1962{
1963 return __register_sysctl_paths(&sysctl_table_root, current->nsproxy,
1964 path, table);
1965}
1966
1967/**
Eric W. Biederman29e796f2007-11-30 23:50:18 +11001968 * register_sysctl_table - register a sysctl table hierarchy
1969 * @table: the top-level table structure
1970 *
1971 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1972 * array. A completely 0 filled entry terminates the table.
1973 *
1974 * See register_sysctl_paths for more details.
1975 */
1976struct ctl_table_header *register_sysctl_table(struct ctl_table *table)
1977{
1978 static const struct ctl_path null_path[] = { {} };
1979
1980 return register_sysctl_paths(null_path, table);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001981}
1982
1983/**
1984 * unregister_sysctl_table - unregister a sysctl table hierarchy
1985 * @header: the header returned from register_sysctl_table
1986 *
1987 * Unregisters the sysctl table and all children. proc entries may not
1988 * actually be removed until they are no longer used by anyone.
1989 */
1990void unregister_sysctl_table(struct ctl_table_header * header)
1991{
Al Viro330d57f2005-11-04 10:18:40 +00001992 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08001993
1994 if (header == NULL)
1995 return;
1996
Al Viro330d57f2005-11-04 10:18:40 +00001997 spin_lock(&sysctl_lock);
1998 start_unregistering(header);
Al Viroae7edec2008-07-15 06:33:31 -04001999 if (!--header->parent->count) {
2000 WARN_ON(1);
2001 kfree(header->parent);
2002 }
Al Virof7e6ced2008-07-15 01:44:23 -04002003 if (!--header->count)
2004 kfree(header);
Al Viro330d57f2005-11-04 10:18:40 +00002005 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002006}
2007
Al Viro9043476f2008-07-15 08:54:06 -04002008int sysctl_is_seen(struct ctl_table_header *p)
2009{
2010 struct ctl_table_set *set = p->set;
2011 int res;
2012 spin_lock(&sysctl_lock);
2013 if (p->unregistering)
2014 res = 0;
2015 else if (!set->is_seen)
2016 res = 1;
2017 else
2018 res = set->is_seen(set);
2019 spin_unlock(&sysctl_lock);
2020 return res;
2021}
2022
Al Viro73455092008-07-14 21:22:20 -04002023void setup_sysctl_set(struct ctl_table_set *p,
2024 struct ctl_table_set *parent,
2025 int (*is_seen)(struct ctl_table_set *))
2026{
2027 INIT_LIST_HEAD(&p->list);
2028 p->parent = parent ? parent : &sysctl_table_root.default_set;
2029 p->is_seen = is_seen;
2030}
2031
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002032#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002033struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002034{
2035 return NULL;
2036}
2037
Eric W. Biederman29e796f2007-11-30 23:50:18 +11002038struct ctl_table_header *register_sysctl_paths(const struct ctl_path *path,
2039 struct ctl_table *table)
2040{
2041 return NULL;
2042}
2043
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002044void unregister_sysctl_table(struct ctl_table_header * table)
2045{
2046}
2047
Al Viro73455092008-07-14 21:22:20 -04002048void setup_sysctl_set(struct ctl_table_set *p,
2049 struct ctl_table_set *parent,
2050 int (*is_seen)(struct ctl_table_set *))
2051{
2052}
2053
Al Virof7e6ced2008-07-15 01:44:23 -04002054void sysctl_head_put(struct ctl_table_header *head)
2055{
2056}
2057
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002058#endif /* CONFIG_SYSCTL */
2059
Linus Torvalds1da177e2005-04-16 15:20:36 -07002060/*
2061 * /proc/sys support
2062 */
2063
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002064#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002065
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07002066static int _proc_do_string(void* data, int maxlen, int write,
2067 struct file *filp, void __user *buffer,
2068 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002069{
2070 size_t len;
2071 char __user *p;
2072 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002073
2074 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002075 *lenp = 0;
2076 return 0;
2077 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002078
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002079 if (write) {
2080 len = 0;
2081 p = buffer;
2082 while (len < *lenp) {
2083 if (get_user(c, p++))
2084 return -EFAULT;
2085 if (c == 0 || c == '\n')
2086 break;
2087 len++;
2088 }
2089 if (len >= maxlen)
2090 len = maxlen-1;
2091 if(copy_from_user(data, buffer, len))
2092 return -EFAULT;
2093 ((char *) data)[len] = 0;
2094 *ppos += *lenp;
2095 } else {
2096 len = strlen(data);
2097 if (len > maxlen)
2098 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002099
2100 if (*ppos > len) {
2101 *lenp = 0;
2102 return 0;
2103 }
2104
2105 data += *ppos;
2106 len -= *ppos;
2107
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002108 if (len > *lenp)
2109 len = *lenp;
2110 if (len)
2111 if(copy_to_user(buffer, data, len))
2112 return -EFAULT;
2113 if (len < *lenp) {
2114 if(put_user('\n', ((char __user *) buffer) + len))
2115 return -EFAULT;
2116 len++;
2117 }
2118 *lenp = len;
2119 *ppos += len;
2120 }
2121 return 0;
2122}
2123
Linus Torvalds1da177e2005-04-16 15:20:36 -07002124/**
2125 * proc_dostring - read a string sysctl
2126 * @table: the sysctl table
2127 * @write: %TRUE if this is a write to the sysctl file
2128 * @filp: the file structure
2129 * @buffer: the user buffer
2130 * @lenp: the size of the user buffer
2131 * @ppos: file position
2132 *
2133 * Reads/writes a string from/to the user buffer. If the kernel
2134 * buffer provided is not large enough to hold the string, the
2135 * string is truncated. The copied string is %NULL-terminated.
2136 * If the string is being read by the user process, it is copied
2137 * and a newline '\n' is added. It is truncated if the buffer is
2138 * not large enough.
2139 *
2140 * Returns 0 on success.
2141 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002142int proc_dostring(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002143 void __user *buffer, size_t *lenp, loff_t *ppos)
2144{
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002145 return _proc_do_string(table->data, table->maxlen, write, filp,
2146 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002147}
2148
Linus Torvalds1da177e2005-04-16 15:20:36 -07002149
2150static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
2151 int *valp,
2152 int write, void *data)
2153{
2154 if (write) {
2155 *valp = *negp ? -*lvalp : *lvalp;
2156 } else {
2157 int val = *valp;
2158 if (val < 0) {
2159 *negp = -1;
2160 *lvalp = (unsigned long)-val;
2161 } else {
2162 *negp = 0;
2163 *lvalp = (unsigned long)val;
2164 }
2165 }
2166 return 0;
2167}
2168
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002169static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002170 int write, struct file *filp, void __user *buffer,
2171 size_t *lenp, loff_t *ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002172 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2173 int write, void *data),
2174 void *data)
2175{
2176#define TMPBUFLEN 21
2177 int *i, vleft, first=1, neg, val;
2178 unsigned long lval;
2179 size_t left, len;
2180
2181 char buf[TMPBUFLEN], *p;
2182 char __user *s = buffer;
2183
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002184 if (!tbl_data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002185 (*ppos && !write)) {
2186 *lenp = 0;
2187 return 0;
2188 }
2189
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002190 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002191 vleft = table->maxlen / sizeof(*i);
2192 left = *lenp;
2193
2194 if (!conv)
2195 conv = do_proc_dointvec_conv;
2196
2197 for (; left && vleft--; i++, first=0) {
2198 if (write) {
2199 while (left) {
2200 char c;
2201 if (get_user(c, s))
2202 return -EFAULT;
2203 if (!isspace(c))
2204 break;
2205 left--;
2206 s++;
2207 }
2208 if (!left)
2209 break;
2210 neg = 0;
2211 len = left;
2212 if (len > sizeof(buf) - 1)
2213 len = sizeof(buf) - 1;
2214 if (copy_from_user(buf, s, len))
2215 return -EFAULT;
2216 buf[len] = 0;
2217 p = buf;
2218 if (*p == '-' && left > 1) {
2219 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002220 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221 }
2222 if (*p < '0' || *p > '9')
2223 break;
2224
2225 lval = simple_strtoul(p, &p, 0);
2226
2227 len = p-buf;
2228 if ((len < left) && *p && !isspace(*p))
2229 break;
2230 if (neg)
2231 val = -val;
2232 s += len;
2233 left -= len;
2234
2235 if (conv(&neg, &lval, i, 1, data))
2236 break;
2237 } else {
2238 p = buf;
2239 if (!first)
2240 *p++ = '\t';
2241
2242 if (conv(&neg, &lval, i, 0, data))
2243 break;
2244
2245 sprintf(p, "%s%lu", neg ? "-" : "", lval);
2246 len = strlen(buf);
2247 if (len > left)
2248 len = left;
2249 if(copy_to_user(s, buf, len))
2250 return -EFAULT;
2251 left -= len;
2252 s += len;
2253 }
2254 }
2255
2256 if (!write && !first && left) {
2257 if(put_user('\n', s))
2258 return -EFAULT;
2259 left--, s++;
2260 }
2261 if (write) {
2262 while (left) {
2263 char c;
2264 if (get_user(c, s++))
2265 return -EFAULT;
2266 if (!isspace(c))
2267 break;
2268 left--;
2269 }
2270 }
2271 if (write && first)
2272 return -EINVAL;
2273 *lenp -= left;
2274 *ppos += *lenp;
2275 return 0;
2276#undef TMPBUFLEN
2277}
2278
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002279static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002280 void __user *buffer, size_t *lenp, loff_t *ppos,
2281 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
2282 int write, void *data),
2283 void *data)
2284{
2285 return __do_proc_dointvec(table->data, table, write, filp,
2286 buffer, lenp, ppos, conv, data);
2287}
2288
Linus Torvalds1da177e2005-04-16 15:20:36 -07002289/**
2290 * proc_dointvec - read a vector of integers
2291 * @table: the sysctl table
2292 * @write: %TRUE if this is a write to the sysctl file
2293 * @filp: the file structure
2294 * @buffer: the user buffer
2295 * @lenp: the size of the user buffer
2296 * @ppos: file position
2297 *
2298 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2299 * values from/to the user buffer, treated as an ASCII string.
2300 *
2301 * Returns 0 on success.
2302 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002303int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002304 void __user *buffer, size_t *lenp, loff_t *ppos)
2305{
2306 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2307 NULL,NULL);
2308}
2309
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002310/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002311 * Taint values can only be increased
2312 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002313 */
Andi Kleen25ddbb12008-10-15 22:01:41 -07002314static int proc_taint(struct ctl_table *table, int write, struct file *filp,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002315 void __user *buffer, size_t *lenp, loff_t *ppos)
2316{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002317 struct ctl_table t;
2318 unsigned long tmptaint = get_taint();
2319 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002320
Bastian Blank91fcd412007-04-23 14:41:14 -07002321 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002322 return -EPERM;
2323
Andi Kleen25ddbb12008-10-15 22:01:41 -07002324 t = *table;
2325 t.data = &tmptaint;
2326 err = proc_doulongvec_minmax(&t, write, filp, buffer, lenp, ppos);
2327 if (err < 0)
2328 return err;
2329
2330 if (write) {
2331 /*
2332 * Poor man's atomic or. Not worth adding a primitive
2333 * to everyone's atomic.h for this
2334 */
2335 int i;
2336 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2337 if ((tmptaint >> i) & 1)
2338 add_taint(i);
2339 }
2340 }
2341
2342 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002343}
2344
Linus Torvalds1da177e2005-04-16 15:20:36 -07002345struct do_proc_dointvec_minmax_conv_param {
2346 int *min;
2347 int *max;
2348};
2349
2350static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
2351 int *valp,
2352 int write, void *data)
2353{
2354 struct do_proc_dointvec_minmax_conv_param *param = data;
2355 if (write) {
2356 int val = *negp ? -*lvalp : *lvalp;
2357 if ((param->min && *param->min > val) ||
2358 (param->max && *param->max < val))
2359 return -EINVAL;
2360 *valp = val;
2361 } else {
2362 int val = *valp;
2363 if (val < 0) {
2364 *negp = -1;
2365 *lvalp = (unsigned long)-val;
2366 } else {
2367 *negp = 0;
2368 *lvalp = (unsigned long)val;
2369 }
2370 }
2371 return 0;
2372}
2373
2374/**
2375 * proc_dointvec_minmax - read a vector of integers with min/max values
2376 * @table: the sysctl table
2377 * @write: %TRUE if this is a write to the sysctl file
2378 * @filp: the file structure
2379 * @buffer: the user buffer
2380 * @lenp: the size of the user buffer
2381 * @ppos: file position
2382 *
2383 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2384 * values from/to the user buffer, treated as an ASCII string.
2385 *
2386 * This routine will ensure the values are within the range specified by
2387 * table->extra1 (min) and table->extra2 (max).
2388 *
2389 * Returns 0 on success.
2390 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002391int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002392 void __user *buffer, size_t *lenp, loff_t *ppos)
2393{
2394 struct do_proc_dointvec_minmax_conv_param param = {
2395 .min = (int *) table->extra1,
2396 .max = (int *) table->extra2,
2397 };
2398 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2399 do_proc_dointvec_minmax_conv, &param);
2400}
2401
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002402static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002403 struct file *filp,
2404 void __user *buffer,
2405 size_t *lenp, loff_t *ppos,
2406 unsigned long convmul,
2407 unsigned long convdiv)
2408{
2409#define TMPBUFLEN 21
2410 unsigned long *i, *min, *max, val;
2411 int vleft, first=1, neg;
2412 size_t len, left;
2413 char buf[TMPBUFLEN], *p;
2414 char __user *s = buffer;
2415
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002416 if (!data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002417 (*ppos && !write)) {
2418 *lenp = 0;
2419 return 0;
2420 }
2421
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002422 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002423 min = (unsigned long *) table->extra1;
2424 max = (unsigned long *) table->extra2;
2425 vleft = table->maxlen / sizeof(unsigned long);
2426 left = *lenp;
2427
2428 for (; left && vleft--; i++, min++, max++, first=0) {
2429 if (write) {
2430 while (left) {
2431 char c;
2432 if (get_user(c, s))
2433 return -EFAULT;
2434 if (!isspace(c))
2435 break;
2436 left--;
2437 s++;
2438 }
2439 if (!left)
2440 break;
2441 neg = 0;
2442 len = left;
2443 if (len > TMPBUFLEN-1)
2444 len = TMPBUFLEN-1;
2445 if (copy_from_user(buf, s, len))
2446 return -EFAULT;
2447 buf[len] = 0;
2448 p = buf;
2449 if (*p == '-' && left > 1) {
2450 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002451 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002452 }
2453 if (*p < '0' || *p > '9')
2454 break;
2455 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2456 len = p-buf;
2457 if ((len < left) && *p && !isspace(*p))
2458 break;
2459 if (neg)
2460 val = -val;
2461 s += len;
2462 left -= len;
2463
2464 if(neg)
2465 continue;
2466 if ((min && val < *min) || (max && val > *max))
2467 continue;
2468 *i = val;
2469 } else {
2470 p = buf;
2471 if (!first)
2472 *p++ = '\t';
2473 sprintf(p, "%lu", convdiv * (*i) / convmul);
2474 len = strlen(buf);
2475 if (len > left)
2476 len = left;
2477 if(copy_to_user(s, buf, len))
2478 return -EFAULT;
2479 left -= len;
2480 s += len;
2481 }
2482 }
2483
2484 if (!write && !first && left) {
2485 if(put_user('\n', s))
2486 return -EFAULT;
2487 left--, s++;
2488 }
2489 if (write) {
2490 while (left) {
2491 char c;
2492 if (get_user(c, s++))
2493 return -EFAULT;
2494 if (!isspace(c))
2495 break;
2496 left--;
2497 }
2498 }
2499 if (write && first)
2500 return -EINVAL;
2501 *lenp -= left;
2502 *ppos += *lenp;
2503 return 0;
2504#undef TMPBUFLEN
2505}
2506
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002507static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002508 struct file *filp,
2509 void __user *buffer,
2510 size_t *lenp, loff_t *ppos,
2511 unsigned long convmul,
2512 unsigned long convdiv)
2513{
2514 return __do_proc_doulongvec_minmax(table->data, table, write,
2515 filp, buffer, lenp, ppos, convmul, convdiv);
2516}
2517
Linus Torvalds1da177e2005-04-16 15:20:36 -07002518/**
2519 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2520 * @table: the sysctl table
2521 * @write: %TRUE if this is a write to the sysctl file
2522 * @filp: the file structure
2523 * @buffer: the user buffer
2524 * @lenp: the size of the user buffer
2525 * @ppos: file position
2526 *
2527 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2528 * values from/to the user buffer, treated as an ASCII string.
2529 *
2530 * This routine will ensure the values are within the range specified by
2531 * table->extra1 (min) and table->extra2 (max).
2532 *
2533 * Returns 0 on success.
2534 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002535int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002536 void __user *buffer, size_t *lenp, loff_t *ppos)
2537{
2538 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
2539}
2540
2541/**
2542 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2543 * @table: the sysctl table
2544 * @write: %TRUE if this is a write to the sysctl file
2545 * @filp: the file structure
2546 * @buffer: the user buffer
2547 * @lenp: the size of the user buffer
2548 * @ppos: file position
2549 *
2550 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2551 * values from/to the user buffer, treated as an ASCII string. The values
2552 * are treated as milliseconds, and converted to jiffies when they are stored.
2553 *
2554 * This routine will ensure the values are within the range specified by
2555 * table->extra1 (min) and table->extra2 (max).
2556 *
2557 * Returns 0 on success.
2558 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002559int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002560 struct file *filp,
2561 void __user *buffer,
2562 size_t *lenp, loff_t *ppos)
2563{
2564 return do_proc_doulongvec_minmax(table, write, filp, buffer,
2565 lenp, ppos, HZ, 1000l);
2566}
2567
2568
2569static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2570 int *valp,
2571 int write, void *data)
2572{
2573 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002574 if (*lvalp > LONG_MAX / HZ)
2575 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002576 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2577 } else {
2578 int val = *valp;
2579 unsigned long lval;
2580 if (val < 0) {
2581 *negp = -1;
2582 lval = (unsigned long)-val;
2583 } else {
2584 *negp = 0;
2585 lval = (unsigned long)val;
2586 }
2587 *lvalp = lval / HZ;
2588 }
2589 return 0;
2590}
2591
2592static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2593 int *valp,
2594 int write, void *data)
2595{
2596 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002597 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2598 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002599 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2600 } else {
2601 int val = *valp;
2602 unsigned long lval;
2603 if (val < 0) {
2604 *negp = -1;
2605 lval = (unsigned long)-val;
2606 } else {
2607 *negp = 0;
2608 lval = (unsigned long)val;
2609 }
2610 *lvalp = jiffies_to_clock_t(lval);
2611 }
2612 return 0;
2613}
2614
2615static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2616 int *valp,
2617 int write, void *data)
2618{
2619 if (write) {
2620 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2621 } else {
2622 int val = *valp;
2623 unsigned long lval;
2624 if (val < 0) {
2625 *negp = -1;
2626 lval = (unsigned long)-val;
2627 } else {
2628 *negp = 0;
2629 lval = (unsigned long)val;
2630 }
2631 *lvalp = jiffies_to_msecs(lval);
2632 }
2633 return 0;
2634}
2635
2636/**
2637 * proc_dointvec_jiffies - read a vector of integers as seconds
2638 * @table: the sysctl table
2639 * @write: %TRUE if this is a write to the sysctl file
2640 * @filp: the file structure
2641 * @buffer: the user buffer
2642 * @lenp: the size of the user buffer
2643 * @ppos: file position
2644 *
2645 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2646 * values from/to the user buffer, treated as an ASCII string.
2647 * The values read are assumed to be in seconds, and are converted into
2648 * jiffies.
2649 *
2650 * Returns 0 on success.
2651 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002652int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002653 void __user *buffer, size_t *lenp, loff_t *ppos)
2654{
2655 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2656 do_proc_dointvec_jiffies_conv,NULL);
2657}
2658
2659/**
2660 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2661 * @table: the sysctl table
2662 * @write: %TRUE if this is a write to the sysctl file
2663 * @filp: the file structure
2664 * @buffer: the user buffer
2665 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002666 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667 *
2668 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2669 * values from/to the user buffer, treated as an ASCII string.
2670 * The values read are assumed to be in 1/USER_HZ seconds, and
2671 * are converted into jiffies.
2672 *
2673 * Returns 0 on success.
2674 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002675int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002676 void __user *buffer, size_t *lenp, loff_t *ppos)
2677{
2678 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2679 do_proc_dointvec_userhz_jiffies_conv,NULL);
2680}
2681
2682/**
2683 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2684 * @table: the sysctl table
2685 * @write: %TRUE if this is a write to the sysctl file
2686 * @filp: the file structure
2687 * @buffer: the user buffer
2688 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002689 * @ppos: file position
2690 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002691 *
2692 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2693 * values from/to the user buffer, treated as an ASCII string.
2694 * The values read are assumed to be in 1/1000 seconds, and
2695 * are converted into jiffies.
2696 *
2697 * Returns 0 on success.
2698 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002699int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002700 void __user *buffer, size_t *lenp, loff_t *ppos)
2701{
2702 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2703 do_proc_dointvec_ms_jiffies_conv, NULL);
2704}
2705
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002706static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002707 void __user *buffer, size_t *lenp, loff_t *ppos)
2708{
2709 struct pid *new_pid;
2710 pid_t tmp;
2711 int r;
2712
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002713 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002714
2715 r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
2716 lenp, ppos, NULL, NULL);
2717 if (r || !write)
2718 return r;
2719
2720 new_pid = find_get_pid(tmp);
2721 if (!new_pid)
2722 return -ESRCH;
2723
2724 put_pid(xchg(&cad_pid, new_pid));
2725 return 0;
2726}
2727
Linus Torvalds1da177e2005-04-16 15:20:36 -07002728#else /* CONFIG_PROC_FS */
2729
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002730int proc_dostring(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002731 void __user *buffer, size_t *lenp, loff_t *ppos)
2732{
2733 return -ENOSYS;
2734}
2735
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002736int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002737 void __user *buffer, size_t *lenp, loff_t *ppos)
2738{
2739 return -ENOSYS;
2740}
2741
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002742int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002743 void __user *buffer, size_t *lenp, loff_t *ppos)
2744{
2745 return -ENOSYS;
2746}
2747
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002748int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002749 void __user *buffer, size_t *lenp, loff_t *ppos)
2750{
2751 return -ENOSYS;
2752}
2753
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002754int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002755 void __user *buffer, size_t *lenp, loff_t *ppos)
2756{
2757 return -ENOSYS;
2758}
2759
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002760int proc_dointvec_ms_jiffies(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_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002767 void __user *buffer, size_t *lenp, loff_t *ppos)
2768{
2769 return -ENOSYS;
2770}
2771
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002772int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002773 struct file *filp,
2774 void __user *buffer,
2775 size_t *lenp, loff_t *ppos)
2776{
2777 return -ENOSYS;
2778}
2779
2780
2781#endif /* CONFIG_PROC_FS */
2782
2783
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002784#ifdef CONFIG_SYSCTL_SYSCALL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002785/*
2786 * General sysctl support routines
2787 */
2788
Eric W. Biederman49a0c452007-10-18 03:05:23 -07002789/* The generic sysctl data routine (used if no strategy routine supplied) */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002790int sysctl_data(struct ctl_table *table,
Eric W. Biederman49a0c452007-10-18 03:05:23 -07002791 void __user *oldval, size_t __user *oldlenp,
2792 void __user *newval, size_t newlen)
2793{
2794 size_t len;
2795
2796 /* Get out of I don't have a variable */
2797 if (!table->data || !table->maxlen)
2798 return -ENOTDIR;
2799
2800 if (oldval && oldlenp) {
2801 if (get_user(len, oldlenp))
2802 return -EFAULT;
2803 if (len) {
2804 if (len > table->maxlen)
2805 len = table->maxlen;
2806 if (copy_to_user(oldval, table->data, len))
2807 return -EFAULT;
2808 if (put_user(len, oldlenp))
2809 return -EFAULT;
2810 }
2811 }
2812
2813 if (newval && newlen) {
2814 if (newlen > table->maxlen)
2815 newlen = table->maxlen;
2816
2817 if (copy_from_user(table->data, newval, newlen))
2818 return -EFAULT;
2819 }
2820 return 1;
2821}
2822
Linus Torvalds1da177e2005-04-16 15:20:36 -07002823/* The generic string strategy routine: */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002824int sysctl_string(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002825 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002826 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002827{
Linus Torvalds1da177e2005-04-16 15:20:36 -07002828 if (!table->data || !table->maxlen)
2829 return -ENOTDIR;
2830
2831 if (oldval && oldlenp) {
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002832 size_t bufsize;
2833 if (get_user(bufsize, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002834 return -EFAULT;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002835 if (bufsize) {
2836 size_t len = strlen(table->data), copied;
2837
2838 /* This shouldn't trigger for a well-formed sysctl */
2839 if (len > table->maxlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002840 len = table->maxlen;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002841
2842 /* Copy up to a max of bufsize-1 bytes of the string */
2843 copied = (len >= bufsize) ? bufsize - 1 : len;
2844
2845 if (copy_to_user(oldval, table->data, copied) ||
2846 put_user(0, (char __user *)(oldval + copied)))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002847 return -EFAULT;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002848 if (put_user(len, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002849 return -EFAULT;
2850 }
2851 }
2852 if (newval && newlen) {
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002853 size_t len = newlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002854 if (len > table->maxlen)
2855 len = table->maxlen;
2856 if(copy_from_user(table->data, newval, len))
2857 return -EFAULT;
2858 if (len == table->maxlen)
2859 len--;
2860 ((char *) table->data)[len] = 0;
2861 }
Yi Yang82c9df82005-12-30 16:37:10 +08002862 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002863}
2864
2865/*
2866 * This function makes sure that all of the integers in the vector
2867 * are between the minimum and maximum values given in the arrays
2868 * table->extra1 and table->extra2, respectively.
2869 */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002870int sysctl_intvec(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002871 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002872 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002873{
2874
2875 if (newval && newlen) {
2876 int __user *vec = (int __user *) newval;
2877 int *min = (int *) table->extra1;
2878 int *max = (int *) table->extra2;
2879 size_t length;
2880 int i;
2881
2882 if (newlen % sizeof(int) != 0)
2883 return -EINVAL;
2884
2885 if (!table->extra1 && !table->extra2)
2886 return 0;
2887
2888 if (newlen > table->maxlen)
2889 newlen = table->maxlen;
2890 length = newlen / sizeof(int);
2891
2892 for (i = 0; i < length; i++) {
2893 int value;
2894 if (get_user(value, vec + i))
2895 return -EFAULT;
2896 if (min && value < min[i])
2897 return -EINVAL;
2898 if (max && value > max[i])
2899 return -EINVAL;
2900 }
2901 }
2902 return 0;
2903}
2904
2905/* Strategy function to convert jiffies to seconds */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002906int sysctl_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002907 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002908 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002909{
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002910 if (oldval && oldlenp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002911 size_t olen;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002912
2913 if (get_user(olen, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002914 return -EFAULT;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002915 if (olen) {
2916 int val;
2917
2918 if (olen < sizeof(int))
2919 return -EINVAL;
2920
2921 val = *(int *)(table->data) / HZ;
2922 if (put_user(val, (int __user *)oldval))
2923 return -EFAULT;
2924 if (put_user(sizeof(int), oldlenp))
2925 return -EFAULT;
2926 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002927 }
2928 if (newval && newlen) {
2929 int new;
2930 if (newlen != sizeof(int))
2931 return -EINVAL;
2932 if (get_user(new, (int __user *)newval))
2933 return -EFAULT;
2934 *(int *)(table->data) = new*HZ;
2935 }
2936 return 1;
2937}
2938
2939/* Strategy function to convert jiffies to seconds */
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002940int sysctl_ms_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002941 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002942 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002943{
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002944 if (oldval && oldlenp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002945 size_t olen;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002946
2947 if (get_user(olen, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002948 return -EFAULT;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002949 if (olen) {
2950 int val;
2951
2952 if (olen < sizeof(int))
2953 return -EINVAL;
2954
2955 val = jiffies_to_msecs(*(int *)(table->data));
2956 if (put_user(val, (int __user *)oldval))
2957 return -EFAULT;
2958 if (put_user(sizeof(int), oldlenp))
2959 return -EFAULT;
2960 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002961 }
2962 if (newval && newlen) {
2963 int new;
2964 if (newlen != sizeof(int))
2965 return -EINVAL;
2966 if (get_user(new, (int __user *)newval))
2967 return -EFAULT;
2968 *(int *)(table->data) = msecs_to_jiffies(new);
2969 }
2970 return 1;
2971}
2972
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08002973
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08002974
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002975#else /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002976
2977
2978asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2979{
Eric W. Biederman0e009be2006-11-05 23:52:11 -08002980 struct __sysctl_args tmp;
Eric W. Biederman7058cb02007-10-18 03:05:58 -07002981 int error;
Eric W. Biederman0e009be2006-11-05 23:52:11 -08002982
Eric W. Biederman0e009be2006-11-05 23:52:11 -08002983 if (copy_from_user(&tmp, args, sizeof(tmp)))
2984 return -EFAULT;
Eric W. Biederman0e009be2006-11-05 23:52:11 -08002985
Eric W. Biederman7058cb02007-10-18 03:05:58 -07002986 error = deprecated_sysctl_warning(&tmp);
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002987
Eric W. Biederman7058cb02007-10-18 03:05:58 -07002988 /* If no error reading the parameters then just -ENOSYS ... */
2989 if (!error)
2990 error = -ENOSYS;
2991
2992 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002993}
2994
Alexey Dobriyanf221e722008-10-15 22:04:23 -07002995int sysctl_data(struct ctl_table *table,
Eric W. Biederman49a0c452007-10-18 03:05:23 -07002996 void __user *oldval, size_t __user *oldlenp,
2997 void __user *newval, size_t newlen)
2998{
2999 return -ENOSYS;
3000}
3001
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003002int sysctl_string(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003003 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003004 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003005{
3006 return -ENOSYS;
3007}
3008
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003009int sysctl_intvec(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003010 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003011 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003012{
3013 return -ENOSYS;
3014}
3015
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003016int sysctl_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003017 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003018 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003019{
3020 return -ENOSYS;
3021}
3022
Alexey Dobriyanf221e722008-10-15 22:04:23 -07003023int sysctl_ms_jiffies(struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003024 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08003025 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003026{
3027 return -ENOSYS;
3028}
3029
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07003030#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003031
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003032static int deprecated_sysctl_warning(struct __sysctl_args *args)
3033{
3034 static int msg_count;
3035 int name[CTL_MAXNAME];
3036 int i;
3037
Tetsuo Handa6fc48af2007-11-14 16:58:38 -08003038 /* Check args->nlen. */
3039 if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
3040 return -ENOTDIR;
3041
Eric W. Biederman7058cb02007-10-18 03:05:58 -07003042 /* Read in the sysctl name for better debug message logging */
3043 for (i = 0; i < args->nlen; i++)
3044 if (get_user(name[i], args->name + i))
3045 return -EFAULT;
3046
3047 /* Ignore accesses to kernel.version */
3048 if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
3049 return 0;
3050
3051 if (msg_count < 5) {
3052 msg_count++;
3053 printk(KERN_INFO
3054 "warning: process `%s' used the deprecated sysctl "
3055 "system call with ", current->comm);
3056 for (i = 0; i < args->nlen; i++)
3057 printk("%d.", name[i]);
3058 printk("\n");
3059 }
3060 return 0;
3061}
3062
Linus Torvalds1da177e2005-04-16 15:20:36 -07003063/*
3064 * No sense putting this after each symbol definition, twice,
3065 * exception granted :-)
3066 */
3067EXPORT_SYMBOL(proc_dointvec);
3068EXPORT_SYMBOL(proc_dointvec_jiffies);
3069EXPORT_SYMBOL(proc_dointvec_minmax);
3070EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3071EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3072EXPORT_SYMBOL(proc_dostring);
3073EXPORT_SYMBOL(proc_doulongvec_minmax);
3074EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
3075EXPORT_SYMBOL(register_sysctl_table);
Eric W. Biederman29e796f2007-11-30 23:50:18 +11003076EXPORT_SYMBOL(register_sysctl_paths);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003077EXPORT_SYMBOL(sysctl_intvec);
3078EXPORT_SYMBOL(sysctl_jiffies);
3079EXPORT_SYMBOL(sysctl_ms_jiffies);
3080EXPORT_SYMBOL(sysctl_string);
Eric W. Biederman49a0c452007-10-18 03:05:23 -07003081EXPORT_SYMBOL(sysctl_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003082EXPORT_SYMBOL(unregister_sysctl_table);