blob: 8ac51714b08ca7ec4261b8544fc62524dad8a3e4 [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>
40#include <linux/security.h>
41#include <linux/initrd.h>
42#include <linux/times.h>
43#include <linux/limits.h>
44#include <linux/dcache.h>
45#include <linux/syscalls.h>
Pavel Machekc255d842006-02-20 18:27:58 -080046#include <linux/nfs_fs.h>
47#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070048#include <linux/reboot.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070049
50#include <asm/uaccess.h>
51#include <asm/processor.h>
52
Andi Kleen29cbc782006-09-30 01:47:55 +020053#ifdef CONFIG_X86
54#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010055#include <asm/stacktrace.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020056#endif
57
Eric W. Biederman7058cb02007-10-18 03:05:58 -070058static int deprecated_sysctl_warning(struct __sysctl_args *args);
59
Linus Torvalds1da177e2005-04-16 15:20:36 -070060#if defined(CONFIG_SYSCTL)
61
62/* External variables not in a header file. */
63extern int C_A_D;
Ingo Molnar45807a12007-07-15 23:40:10 -070064extern int print_fatal_signals;
Linus Torvalds1da177e2005-04-16 15:20:36 -070065extern int sysctl_overcommit_memory;
66extern int sysctl_overcommit_ratio;
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -070067extern int sysctl_panic_on_oom;
David Rientjesfe071d72007-10-16 23:25:56 -070068extern int sysctl_oom_kill_allocating_task;
Linus Torvalds1da177e2005-04-16 15:20:36 -070069extern int max_threads;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070extern int core_uses_pid;
Alan Coxd6e71142005-06-23 00:09:43 -070071extern int suid_dumpable;
Linus Torvalds1da177e2005-04-16 15:20:36 -070072extern char core_pattern[];
Linus Torvalds1da177e2005-04-16 15:20:36 -070073extern int pid_max;
74extern int min_free_kbytes;
75extern int printk_ratelimit_jiffies;
76extern int printk_ratelimit_burst;
77extern int pid_max_min, pid_max_max;
Andrew Morton9d0243b2006-01-08 01:00:39 -080078extern int sysctl_drop_caches;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -080079extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +020080extern int compat_log;
Kees Cook5096add2007-05-08 00:26:04 -070081extern int maps_protect;
Christoph Lameter77461ab2007-05-09 02:35:13 -070082extern int sysctl_stat_interval;
Peter Zijlstrabdf4c482007-07-19 01:48:15 -070083extern int audit_argv_kb;
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -070085/* Constants used for minimum and maximum */
86#ifdef CONFIG_DETECT_SOFTLOCKUP
87static int one = 1;
88static int sixty = 60;
89#endif
90
91#ifdef CONFIG_MMU
92static int two = 2;
93#endif
94
95static int zero;
96static int one_hundred = 100;
97
Linus Torvalds1da177e2005-04-16 15:20:36 -070098/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
99static int maxolduid = 65535;
100static int minolduid;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800101static int min_percpu_pagelist_fract = 8;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102
103static int ngroups_max = NGROUPS_MAX;
104
105#ifdef CONFIG_KMOD
106extern char modprobe_path[];
107#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108#ifdef CONFIG_CHR_DEV_SG
109extern int sg_big_buff;
110#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111
112#ifdef __sparc__
113extern char reboot_command [];
114extern int stop_a_enabled;
115extern int scons_pwroff;
116#endif
117
118#ifdef __hppa__
119extern int pwrsw_enabled;
120extern int unaligned_enabled;
121#endif
122
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800123#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124#ifdef CONFIG_MATHEMU
125extern int sysctl_ieee_emulation_warnings;
126#endif
127extern int sysctl_userprocess_debug;
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700128extern int spin_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129#endif
130
131extern int sysctl_hz_timer;
132
133#ifdef CONFIG_BSD_PROCESS_ACCT
134extern int acct_parm[];
135#endif
136
Jes Sorensend2b176e2006-02-28 09:42:23 -0800137#ifdef CONFIG_IA64
138extern int no_unaligned_warning;
139#endif
140
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700141#ifdef CONFIG_RT_MUTEXES
142extern int max_lock_depth;
143#endif
144
Eric W. Biedermanb89a8172006-09-27 01:51:04 -0700145#ifdef CONFIG_SYSCTL_SYSCALL
146static int parse_table(int __user *, int, void __user *, size_t __user *,
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700147 void __user *, size_t, struct ctl_table *);
Eric W. Biedermanb89a8172006-09-27 01:51:04 -0700148#endif
149
Eric W. Biederman6b49a252006-12-08 02:39:57 -0800150
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700151#ifdef CONFIG_PROC_SYSCTL
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700152static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700153 void __user *buffer, size_t *lenp, loff_t *ppos);
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700154static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800155 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700156#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700157
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700158static struct ctl_table root_table[];
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159static struct ctl_table_header root_table_header =
160 { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
161
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700162static struct ctl_table kern_table[];
163static struct ctl_table vm_table[];
164static struct ctl_table fs_table[];
165static struct ctl_table debug_table[];
166static struct ctl_table dev_table[];
167extern struct ctl_table random_table[];
Amy Griffis2d9048e2006-06-01 13:10:59 -0700168#ifdef CONFIG_INOTIFY_USER
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700169extern struct ctl_table inotify_table[];
Robert Love0399cb02005-07-13 12:38:18 -0400170#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171
172#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
173int sysctl_legacy_va_layout;
174#endif
175
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700176extern int prove_locking;
177extern int lock_stat;
Eric W. Biederman9bc9a6b2006-12-08 02:39:56 -0800178
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179/* The default sysctl tables: */
180
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700181static struct ctl_table root_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 {
183 .ctl_name = CTL_KERN,
184 .procname = "kernel",
185 .mode = 0555,
186 .child = kern_table,
187 },
188 {
189 .ctl_name = CTL_VM,
190 .procname = "vm",
191 .mode = 0555,
192 .child = vm_table,
193 },
194#ifdef CONFIG_NET
195 {
196 .ctl_name = CTL_NET,
197 .procname = "net",
198 .mode = 0555,
199 .child = net_table,
200 },
201#endif
202 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 .ctl_name = CTL_FS,
204 .procname = "fs",
205 .mode = 0555,
206 .child = fs_table,
207 },
208 {
209 .ctl_name = CTL_DEBUG,
210 .procname = "debug",
211 .mode = 0555,
212 .child = debug_table,
213 },
214 {
215 .ctl_name = CTL_DEV,
216 .procname = "dev",
217 .mode = 0555,
218 .child = dev_table,
219 },
Andrew Morton2be7fe02007-07-15 23:41:21 -0700220/*
221 * NOTE: do not add new entries to this table unless you have read
222 * Documentation/sysctl/ctl_unnumbered.txt
223 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 { .ctl_name = 0 }
225};
226
Ingo Molnar77e54a12007-07-09 18:52:00 +0200227#ifdef CONFIG_SCHED_DEBUG
228static unsigned long min_sched_granularity_ns = 100000; /* 100 usecs */
Eric Dumazetd6322fa2007-11-09 22:39:38 +0100229static unsigned long max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200230static unsigned long min_wakeup_granularity_ns; /* 0 usecs */
Eric Dumazetd6322fa2007-11-09 22:39:38 +0100231static unsigned long max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200232#endif
233
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700234static struct ctl_table kern_table[] = {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200235#ifdef CONFIG_SCHED_DEBUG
236 {
237 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100238 .procname = "sched_min_granularity_ns",
239 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200240 .maxlen = sizeof(unsigned int),
241 .mode = 0644,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100242 .proc_handler = &sched_nr_latency_handler,
243 .strategy = &sysctl_intvec,
244 .extra1 = &min_sched_granularity_ns,
245 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200246 },
247 {
248 .ctl_name = CTL_UNNUMBERED,
Peter Zijlstra21805082007-08-25 18:41:53 +0200249 .procname = "sched_latency_ns",
250 .data = &sysctl_sched_latency,
251 .maxlen = sizeof(unsigned int),
252 .mode = 0644,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100253 .proc_handler = &sched_nr_latency_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200254 .strategy = &sysctl_intvec,
255 .extra1 = &min_sched_granularity_ns,
256 .extra2 = &max_sched_granularity_ns,
257 },
258 {
259 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200260 .procname = "sched_wakeup_granularity_ns",
261 .data = &sysctl_sched_wakeup_granularity,
262 .maxlen = sizeof(unsigned int),
263 .mode = 0644,
264 .proc_handler = &proc_dointvec_minmax,
265 .strategy = &sysctl_intvec,
266 .extra1 = &min_wakeup_granularity_ns,
267 .extra2 = &max_wakeup_granularity_ns,
268 },
269 {
270 .ctl_name = CTL_UNNUMBERED,
271 .procname = "sched_batch_wakeup_granularity_ns",
272 .data = &sysctl_sched_batch_wakeup_granularity,
273 .maxlen = sizeof(unsigned int),
274 .mode = 0644,
275 .proc_handler = &proc_dointvec_minmax,
276 .strategy = &sysctl_intvec,
277 .extra1 = &min_wakeup_granularity_ns,
278 .extra2 = &max_wakeup_granularity_ns,
279 },
280 {
281 .ctl_name = CTL_UNNUMBERED,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200282 .procname = "sched_child_runs_first",
283 .data = &sysctl_sched_child_runs_first,
284 .maxlen = sizeof(unsigned int),
285 .mode = 0644,
286 .proc_handler = &proc_dointvec,
287 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200288 {
289 .ctl_name = CTL_UNNUMBERED,
290 .procname = "sched_features",
291 .data = &sysctl_sched_features,
292 .maxlen = sizeof(unsigned int),
293 .mode = 0644,
294 .proc_handler = &proc_dointvec,
295 },
Ingo Molnarda84d962007-10-15 17:00:18 +0200296 {
297 .ctl_name = CTL_UNNUMBERED,
298 .procname = "sched_migration_cost",
299 .data = &sysctl_sched_migration_cost,
300 .maxlen = sizeof(unsigned int),
301 .mode = 0644,
302 .proc_handler = &proc_dointvec,
303 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100304 {
305 .ctl_name = CTL_UNNUMBERED,
306 .procname = "sched_nr_migrate",
307 .data = &sysctl_sched_nr_migrate,
308 .maxlen = sizeof(unsigned int),
309 .mode = 644,
310 .proc_handler = &proc_dointvec,
311 },
Peter Zijlstra1fc84aa2007-08-25 18:41:52 +0200312#endif
Ingo Molnar1799e352007-09-19 23:34:46 +0200313 {
314 .ctl_name = CTL_UNNUMBERED,
315 .procname = "sched_compat_yield",
316 .data = &sysctl_sched_compat_yield,
317 .maxlen = sizeof(unsigned int),
318 .mode = 0644,
319 .proc_handler = &proc_dointvec,
320 },
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700321#ifdef CONFIG_PROVE_LOCKING
322 {
323 .ctl_name = CTL_UNNUMBERED,
324 .procname = "prove_locking",
325 .data = &prove_locking,
326 .maxlen = sizeof(int),
327 .mode = 0644,
328 .proc_handler = &proc_dointvec,
329 },
330#endif
331#ifdef CONFIG_LOCK_STAT
332 {
333 .ctl_name = CTL_UNNUMBERED,
334 .procname = "lock_stat",
335 .data = &lock_stat,
336 .maxlen = sizeof(int),
337 .mode = 0644,
338 .proc_handler = &proc_dointvec,
339 },
340#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200341 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 .ctl_name = KERN_PANIC,
343 .procname = "panic",
344 .data = &panic_timeout,
345 .maxlen = sizeof(int),
346 .mode = 0644,
347 .proc_handler = &proc_dointvec,
348 },
349 {
350 .ctl_name = KERN_CORE_USES_PID,
351 .procname = "core_uses_pid",
352 .data = &core_uses_pid,
353 .maxlen = sizeof(int),
354 .mode = 0644,
355 .proc_handler = &proc_dointvec,
356 },
Peter Zijlstrabdf4c482007-07-19 01:48:15 -0700357#ifdef CONFIG_AUDITSYSCALL
358 {
359 .ctl_name = CTL_UNNUMBERED,
360 .procname = "audit_argv_kb",
361 .data = &audit_argv_kb,
362 .maxlen = sizeof(int),
363 .mode = 0644,
364 .proc_handler = &proc_dointvec,
365 },
366#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 {
368 .ctl_name = KERN_CORE_PATTERN,
369 .procname = "core_pattern",
370 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700371 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 .mode = 0644,
373 .proc_handler = &proc_dostring,
374 .strategy = &sysctl_string,
375 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800376#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378 .procname = "tainted",
379 .data = &tainted,
380 .maxlen = sizeof(int),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800381 .mode = 0644,
382 .proc_handler = &proc_dointvec_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800384#endif
Andrew Morgan72c2d582007-10-18 03:05:59 -0700385#ifdef CONFIG_SECURITY_CAPABILITIES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 .procname = "cap-bound",
388 .data = &cap_bset,
389 .maxlen = sizeof(kernel_cap_t),
390 .mode = 0600,
391 .proc_handler = &proc_dointvec_bset,
392 },
Andrew Morgan72c2d582007-10-18 03:05:59 -0700393#endif /* def CONFIG_SECURITY_CAPABILITIES */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394#ifdef CONFIG_BLK_DEV_INITRD
395 {
396 .ctl_name = KERN_REALROOTDEV,
397 .procname = "real-root-dev",
398 .data = &real_root_dev,
399 .maxlen = sizeof(int),
400 .mode = 0644,
401 .proc_handler = &proc_dointvec,
402 },
403#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700404 {
405 .ctl_name = CTL_UNNUMBERED,
406 .procname = "print-fatal-signals",
407 .data = &print_fatal_signals,
408 .maxlen = sizeof(int),
409 .mode = 0644,
410 .proc_handler = &proc_dointvec,
411 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412#ifdef __sparc__
413 {
414 .ctl_name = KERN_SPARC_REBOOT,
415 .procname = "reboot-cmd",
416 .data = reboot_command,
417 .maxlen = 256,
418 .mode = 0644,
419 .proc_handler = &proc_dostring,
420 .strategy = &sysctl_string,
421 },
422 {
423 .ctl_name = KERN_SPARC_STOP_A,
424 .procname = "stop-a",
425 .data = &stop_a_enabled,
426 .maxlen = sizeof (int),
427 .mode = 0644,
428 .proc_handler = &proc_dointvec,
429 },
430 {
431 .ctl_name = KERN_SPARC_SCONS_PWROFF,
432 .procname = "scons-poweroff",
433 .data = &scons_pwroff,
434 .maxlen = sizeof (int),
435 .mode = 0644,
436 .proc_handler = &proc_dointvec,
437 },
438#endif
439#ifdef __hppa__
440 {
441 .ctl_name = KERN_HPPA_PWRSW,
442 .procname = "soft-power",
443 .data = &pwrsw_enabled,
444 .maxlen = sizeof (int),
445 .mode = 0644,
446 .proc_handler = &proc_dointvec,
447 },
448 {
449 .ctl_name = KERN_HPPA_UNALIGNED,
450 .procname = "unaligned-trap",
451 .data = &unaligned_enabled,
452 .maxlen = sizeof (int),
453 .mode = 0644,
454 .proc_handler = &proc_dointvec,
455 },
456#endif
457 {
458 .ctl_name = KERN_CTLALTDEL,
459 .procname = "ctrl-alt-del",
460 .data = &C_A_D,
461 .maxlen = sizeof(int),
462 .mode = 0644,
463 .proc_handler = &proc_dointvec,
464 },
465 {
466 .ctl_name = KERN_PRINTK,
467 .procname = "printk",
468 .data = &console_loglevel,
469 .maxlen = 4*sizeof(int),
470 .mode = 0644,
471 .proc_handler = &proc_dointvec,
472 },
473#ifdef CONFIG_KMOD
474 {
475 .ctl_name = KERN_MODPROBE,
476 .procname = "modprobe",
477 .data = &modprobe_path,
478 .maxlen = KMOD_PATH_LEN,
479 .mode = 0644,
480 .proc_handler = &proc_dostring,
481 .strategy = &sysctl_string,
482 },
483#endif
Andrew Morton57ae2502006-06-23 02:05:47 -0700484#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 {
486 .ctl_name = KERN_HOTPLUG,
487 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100488 .data = &uevent_helper,
489 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 .mode = 0644,
491 .proc_handler = &proc_dostring,
492 .strategy = &sysctl_string,
493 },
494#endif
495#ifdef CONFIG_CHR_DEV_SG
496 {
497 .ctl_name = KERN_SG_BIG_BUFF,
498 .procname = "sg-big-buff",
499 .data = &sg_big_buff,
500 .maxlen = sizeof (int),
501 .mode = 0444,
502 .proc_handler = &proc_dointvec,
503 },
504#endif
505#ifdef CONFIG_BSD_PROCESS_ACCT
506 {
507 .ctl_name = KERN_ACCT,
508 .procname = "acct",
509 .data = &acct_parm,
510 .maxlen = 3*sizeof(int),
511 .mode = 0644,
512 .proc_handler = &proc_dointvec,
513 },
514#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515#ifdef CONFIG_MAGIC_SYSRQ
516 {
517 .ctl_name = KERN_SYSRQ,
518 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800519 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 .maxlen = sizeof (int),
521 .mode = 0644,
522 .proc_handler = &proc_dointvec,
523 },
524#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700525#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700528 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 .maxlen = sizeof (int),
530 .mode = 0600,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700531 .proc_handler = &proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700533#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 {
535 .ctl_name = KERN_MAX_THREADS,
536 .procname = "threads-max",
537 .data = &max_threads,
538 .maxlen = sizeof(int),
539 .mode = 0644,
540 .proc_handler = &proc_dointvec,
541 },
542 {
543 .ctl_name = KERN_RANDOM,
544 .procname = "random",
545 .mode = 0555,
546 .child = random_table,
547 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 {
549 .ctl_name = KERN_OVERFLOWUID,
550 .procname = "overflowuid",
551 .data = &overflowuid,
552 .maxlen = sizeof(int),
553 .mode = 0644,
554 .proc_handler = &proc_dointvec_minmax,
555 .strategy = &sysctl_intvec,
556 .extra1 = &minolduid,
557 .extra2 = &maxolduid,
558 },
559 {
560 .ctl_name = KERN_OVERFLOWGID,
561 .procname = "overflowgid",
562 .data = &overflowgid,
563 .maxlen = sizeof(int),
564 .mode = 0644,
565 .proc_handler = &proc_dointvec_minmax,
566 .strategy = &sysctl_intvec,
567 .extra1 = &minolduid,
568 .extra2 = &maxolduid,
569 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800570#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571#ifdef CONFIG_MATHEMU
572 {
573 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
574 .procname = "ieee_emulation_warnings",
575 .data = &sysctl_ieee_emulation_warnings,
576 .maxlen = sizeof(int),
577 .mode = 0644,
578 .proc_handler = &proc_dointvec,
579 },
580#endif
581#ifdef CONFIG_NO_IDLE_HZ
582 {
583 .ctl_name = KERN_HZ_TIMER,
584 .procname = "hz_timer",
585 .data = &sysctl_hz_timer,
586 .maxlen = sizeof(int),
587 .mode = 0644,
588 .proc_handler = &proc_dointvec,
589 },
590#endif
591 {
592 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
593 .procname = "userprocess_debug",
594 .data = &sysctl_userprocess_debug,
595 .maxlen = sizeof(int),
596 .mode = 0644,
597 .proc_handler = &proc_dointvec,
598 },
599#endif
600 {
601 .ctl_name = KERN_PIDMAX,
602 .procname = "pid_max",
603 .data = &pid_max,
604 .maxlen = sizeof (int),
605 .mode = 0644,
606 .proc_handler = &proc_dointvec_minmax,
607 .strategy = sysctl_intvec,
608 .extra1 = &pid_max_min,
609 .extra2 = &pid_max_max,
610 },
611 {
612 .ctl_name = KERN_PANIC_ON_OOPS,
613 .procname = "panic_on_oops",
614 .data = &panic_on_oops,
615 .maxlen = sizeof(int),
616 .mode = 0644,
617 .proc_handler = &proc_dointvec,
618 },
619 {
620 .ctl_name = KERN_PRINTK_RATELIMIT,
621 .procname = "printk_ratelimit",
622 .data = &printk_ratelimit_jiffies,
623 .maxlen = sizeof(int),
624 .mode = 0644,
625 .proc_handler = &proc_dointvec_jiffies,
626 .strategy = &sysctl_jiffies,
627 },
628 {
629 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
630 .procname = "printk_ratelimit_burst",
631 .data = &printk_ratelimit_burst,
632 .maxlen = sizeof(int),
633 .mode = 0644,
634 .proc_handler = &proc_dointvec,
635 },
636 {
637 .ctl_name = KERN_NGROUPS_MAX,
638 .procname = "ngroups_max",
639 .data = &ngroups_max,
640 .maxlen = sizeof (int),
641 .mode = 0444,
642 .proc_handler = &proc_dointvec,
643 },
644#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
645 {
646 .ctl_name = KERN_UNKNOWN_NMI_PANIC,
647 .procname = "unknown_nmi_panic",
648 .data = &unknown_nmi_panic,
649 .maxlen = sizeof (int),
650 .mode = 0644,
Don Zickus2fbe7b22006-09-26 10:52:27 +0200651 .proc_handler = &proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 },
Don Zickus407984f2006-09-26 10:52:27 +0200653 {
Don Zickus407984f2006-09-26 10:52:27 +0200654 .procname = "nmi_watchdog",
655 .data = &nmi_watchdog_enabled,
656 .maxlen = sizeof (int),
657 .mode = 0644,
658 .proc_handler = &proc_nmi_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 },
660#endif
661#if defined(CONFIG_X86)
662 {
Don Zickus8da5add2006-09-26 10:52:27 +0200663 .ctl_name = KERN_PANIC_ON_NMI,
664 .procname = "panic_on_unrecovered_nmi",
665 .data = &panic_on_unrecovered_nmi,
666 .maxlen = sizeof(int),
667 .mode = 0644,
668 .proc_handler = &proc_dointvec,
669 },
670 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 .ctl_name = KERN_BOOTLOADER_TYPE,
672 .procname = "bootloader_type",
673 .data = &bootloader_type,
674 .maxlen = sizeof (int),
675 .mode = 0444,
676 .proc_handler = &proc_dointvec,
677 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100678 {
679 .ctl_name = CTL_UNNUMBERED,
680 .procname = "kstack_depth_to_print",
681 .data = &kstack_depth_to_print,
682 .maxlen = sizeof(int),
683 .mode = 0644,
684 .proc_handler = &proc_dointvec,
685 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800687#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 {
689 .ctl_name = KERN_RANDOMIZE,
690 .procname = "randomize_va_space",
691 .data = &randomize_va_space,
692 .maxlen = sizeof(int),
693 .mode = 0644,
694 .proc_handler = &proc_dointvec,
695 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800696#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800697#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700698 {
699 .ctl_name = KERN_SPIN_RETRY,
700 .procname = "spin_retry",
701 .data = &spin_retry,
702 .maxlen = sizeof (int),
703 .mode = 0644,
704 .proc_handler = &proc_dointvec,
705 },
706#endif
Len Brown673d5b42007-07-28 03:33:16 -0400707#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800708 {
Pavel Machekc255d842006-02-20 18:27:58 -0800709 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700710 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800711 .maxlen = sizeof (unsigned long),
712 .mode = 0644,
Stefan Seyfried7f99f062006-03-02 02:54:34 -0800713 .proc_handler = &proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800714 },
715#endif
Jes Sorensend2b176e2006-02-28 09:42:23 -0800716#ifdef CONFIG_IA64
717 {
718 .ctl_name = KERN_IA64_UNALIGNED,
719 .procname = "ignore-unaligned-usertrap",
720 .data = &no_unaligned_warning,
721 .maxlen = sizeof (int),
722 .mode = 0644,
723 .proc_handler = &proc_dointvec,
724 },
725#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700726#ifdef CONFIG_DETECT_SOFTLOCKUP
727 {
728 .ctl_name = CTL_UNNUMBERED,
729 .procname = "softlockup_thresh",
730 .data = &softlockup_thresh,
731 .maxlen = sizeof(int),
732 .mode = 0644,
733 .proc_handler = &proc_dointvec_minmax,
734 .strategy = &sysctl_intvec,
735 .extra1 = &one,
736 .extra2 = &sixty,
737 },
738#endif
Andi Kleenbebfa102006-06-26 13:56:52 +0200739#ifdef CONFIG_COMPAT
740 {
741 .ctl_name = KERN_COMPAT_LOG,
742 .procname = "compat-log",
743 .data = &compat_log,
744 .maxlen = sizeof (int),
745 .mode = 0644,
746 .proc_handler = &proc_dointvec,
747 },
748#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -0700749#ifdef CONFIG_RT_MUTEXES
750 {
751 .ctl_name = KERN_MAX_LOCK_DEPTH,
752 .procname = "max_lock_depth",
753 .data = &max_lock_depth,
754 .maxlen = sizeof(int),
755 .mode = 0644,
756 .proc_handler = &proc_dointvec,
757 },
758#endif
Kees Cook5096add2007-05-08 00:26:04 -0700759#ifdef CONFIG_PROC_FS
760 {
761 .ctl_name = CTL_UNNUMBERED,
762 .procname = "maps_protect",
763 .data = &maps_protect,
764 .maxlen = sizeof(int),
765 .mode = 0644,
766 .proc_handler = &proc_dointvec,
767 },
768#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -0700769 {
770 .ctl_name = CTL_UNNUMBERED,
771 .procname = "poweroff_cmd",
772 .data = &poweroff_cmd,
773 .maxlen = POWEROFF_CMD_PATH_LEN,
774 .mode = 0644,
775 .proc_handler = &proc_dostring,
776 .strategy = &sysctl_string,
777 },
Andrew Mortoned2c12f2007-07-19 01:50:35 -0700778/*
779 * NOTE: do not add new entries to this table unless you have read
780 * Documentation/sysctl/ctl_unnumbered.txt
781 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 { .ctl_name = 0 }
783};
784
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700785static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 {
787 .ctl_name = VM_OVERCOMMIT_MEMORY,
788 .procname = "overcommit_memory",
789 .data = &sysctl_overcommit_memory,
790 .maxlen = sizeof(sysctl_overcommit_memory),
791 .mode = 0644,
792 .proc_handler = &proc_dointvec,
793 },
794 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -0700795 .ctl_name = VM_PANIC_ON_OOM,
796 .procname = "panic_on_oom",
797 .data = &sysctl_panic_on_oom,
798 .maxlen = sizeof(sysctl_panic_on_oom),
799 .mode = 0644,
800 .proc_handler = &proc_dointvec,
801 },
802 {
David Rientjesfe071d72007-10-16 23:25:56 -0700803 .ctl_name = CTL_UNNUMBERED,
804 .procname = "oom_kill_allocating_task",
805 .data = &sysctl_oom_kill_allocating_task,
806 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
807 .mode = 0644,
808 .proc_handler = &proc_dointvec,
809 },
810 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 .ctl_name = VM_OVERCOMMIT_RATIO,
812 .procname = "overcommit_ratio",
813 .data = &sysctl_overcommit_ratio,
814 .maxlen = sizeof(sysctl_overcommit_ratio),
815 .mode = 0644,
816 .proc_handler = &proc_dointvec,
817 },
818 {
819 .ctl_name = VM_PAGE_CLUSTER,
820 .procname = "page-cluster",
821 .data = &page_cluster,
822 .maxlen = sizeof(int),
823 .mode = 0644,
824 .proc_handler = &proc_dointvec,
825 },
826 {
827 .ctl_name = VM_DIRTY_BACKGROUND,
828 .procname = "dirty_background_ratio",
829 .data = &dirty_background_ratio,
830 .maxlen = sizeof(dirty_background_ratio),
831 .mode = 0644,
832 .proc_handler = &proc_dointvec_minmax,
833 .strategy = &sysctl_intvec,
834 .extra1 = &zero,
835 .extra2 = &one_hundred,
836 },
837 {
838 .ctl_name = VM_DIRTY_RATIO,
839 .procname = "dirty_ratio",
840 .data = &vm_dirty_ratio,
841 .maxlen = sizeof(vm_dirty_ratio),
842 .mode = 0644,
Peter Zijlstra04fbfdc2007-10-16 23:25:50 -0700843 .proc_handler = &dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 .strategy = &sysctl_intvec,
845 .extra1 = &zero,
846 .extra2 = &one_hundred,
847 },
848 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -0800850 .data = &dirty_writeback_interval,
851 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 .mode = 0644,
853 .proc_handler = &dirty_writeback_centisecs_handler,
854 },
855 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -0800857 .data = &dirty_expire_interval,
858 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859 .mode = 0644,
Bart Samwelf6ef9432006-03-24 03:15:48 -0800860 .proc_handler = &proc_dointvec_userhz_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700861 },
862 {
863 .ctl_name = VM_NR_PDFLUSH_THREADS,
864 .procname = "nr_pdflush_threads",
865 .data = &nr_pdflush_threads,
866 .maxlen = sizeof nr_pdflush_threads,
867 .mode = 0444 /* read-only*/,
868 .proc_handler = &proc_dointvec,
869 },
870 {
871 .ctl_name = VM_SWAPPINESS,
872 .procname = "swappiness",
873 .data = &vm_swappiness,
874 .maxlen = sizeof(vm_swappiness),
875 .mode = 0644,
876 .proc_handler = &proc_dointvec_minmax,
877 .strategy = &sysctl_intvec,
878 .extra1 = &zero,
879 .extra2 = &one_hundred,
880 },
881#ifdef CONFIG_HUGETLB_PAGE
882 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883 .procname = "nr_hugepages",
884 .data = &max_huge_pages,
885 .maxlen = sizeof(unsigned long),
886 .mode = 0644,
887 .proc_handler = &hugetlb_sysctl_handler,
888 .extra1 = (void *)&hugetlb_zero,
889 .extra2 = (void *)&hugetlb_infinity,
890 },
891 {
892 .ctl_name = VM_HUGETLB_GROUP,
893 .procname = "hugetlb_shm_group",
894 .data = &sysctl_hugetlb_shm_group,
895 .maxlen = sizeof(gid_t),
896 .mode = 0644,
897 .proc_handler = &proc_dointvec,
898 },
Mel Gorman396faf02007-07-17 04:03:13 -0700899 {
900 .ctl_name = CTL_UNNUMBERED,
901 .procname = "hugepages_treat_as_movable",
902 .data = &hugepages_treat_as_movable,
903 .maxlen = sizeof(int),
904 .mode = 0644,
905 .proc_handler = &hugetlb_treat_movable_handler,
906 },
Adam Litke54f9f802007-10-16 01:26:20 -0700907 {
908 .ctl_name = CTL_UNNUMBERED,
909 .procname = "hugetlb_dynamic_pool",
910 .data = &hugetlb_dynamic_pool,
911 .maxlen = sizeof(hugetlb_dynamic_pool),
912 .mode = 0644,
913 .proc_handler = &proc_dointvec,
914 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915#endif
916 {
917 .ctl_name = VM_LOWMEM_RESERVE_RATIO,
918 .procname = "lowmem_reserve_ratio",
919 .data = &sysctl_lowmem_reserve_ratio,
920 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
921 .mode = 0644,
922 .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
923 .strategy = &sysctl_intvec,
924 },
925 {
Andrew Morton9d0243b2006-01-08 01:00:39 -0800926 .ctl_name = VM_DROP_PAGECACHE,
927 .procname = "drop_caches",
928 .data = &sysctl_drop_caches,
929 .maxlen = sizeof(int),
930 .mode = 0644,
931 .proc_handler = drop_caches_sysctl_handler,
932 .strategy = &sysctl_intvec,
933 },
934 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700935 .ctl_name = VM_MIN_FREE_KBYTES,
936 .procname = "min_free_kbytes",
937 .data = &min_free_kbytes,
938 .maxlen = sizeof(min_free_kbytes),
939 .mode = 0644,
940 .proc_handler = &min_free_kbytes_sysctl_handler,
941 .strategy = &sysctl_intvec,
942 .extra1 = &zero,
943 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800944 {
945 .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
946 .procname = "percpu_pagelist_fraction",
947 .data = &percpu_pagelist_fraction,
948 .maxlen = sizeof(percpu_pagelist_fraction),
949 .mode = 0644,
950 .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
951 .strategy = &sysctl_intvec,
952 .extra1 = &min_percpu_pagelist_fract,
953 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700954#ifdef CONFIG_MMU
955 {
956 .ctl_name = VM_MAX_MAP_COUNT,
957 .procname = "max_map_count",
958 .data = &sysctl_max_map_count,
959 .maxlen = sizeof(sysctl_max_map_count),
960 .mode = 0644,
961 .proc_handler = &proc_dointvec
962 },
963#endif
964 {
965 .ctl_name = VM_LAPTOP_MODE,
966 .procname = "laptop_mode",
967 .data = &laptop_mode,
968 .maxlen = sizeof(laptop_mode),
969 .mode = 0644,
Bart Samweled5b43f2006-03-24 03:15:49 -0800970 .proc_handler = &proc_dointvec_jiffies,
971 .strategy = &sysctl_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700972 },
973 {
974 .ctl_name = VM_BLOCK_DUMP,
975 .procname = "block_dump",
976 .data = &block_dump,
977 .maxlen = sizeof(block_dump),
978 .mode = 0644,
979 .proc_handler = &proc_dointvec,
980 .strategy = &sysctl_intvec,
981 .extra1 = &zero,
982 },
983 {
984 .ctl_name = VM_VFS_CACHE_PRESSURE,
985 .procname = "vfs_cache_pressure",
986 .data = &sysctl_vfs_cache_pressure,
987 .maxlen = sizeof(sysctl_vfs_cache_pressure),
988 .mode = 0644,
989 .proc_handler = &proc_dointvec,
990 .strategy = &sysctl_intvec,
991 .extra1 = &zero,
992 },
993#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
994 {
995 .ctl_name = VM_LEGACY_VA_LAYOUT,
996 .procname = "legacy_va_layout",
997 .data = &sysctl_legacy_va_layout,
998 .maxlen = sizeof(sysctl_legacy_va_layout),
999 .mode = 0644,
1000 .proc_handler = &proc_dointvec,
1001 .strategy = &sysctl_intvec,
1002 .extra1 = &zero,
1003 },
1004#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001005#ifdef CONFIG_NUMA
1006 {
1007 .ctl_name = VM_ZONE_RECLAIM_MODE,
1008 .procname = "zone_reclaim_mode",
1009 .data = &zone_reclaim_mode,
1010 .maxlen = sizeof(zone_reclaim_mode),
1011 .mode = 0644,
1012 .proc_handler = &proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001013 .strategy = &sysctl_intvec,
1014 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001015 },
Christoph Lameter96146342006-07-03 00:24:13 -07001016 {
1017 .ctl_name = VM_MIN_UNMAPPED,
1018 .procname = "min_unmapped_ratio",
1019 .data = &sysctl_min_unmapped_ratio,
1020 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1021 .mode = 0644,
1022 .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
1023 .strategy = &sysctl_intvec,
1024 .extra1 = &zero,
1025 .extra2 = &one_hundred,
1026 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001027 {
1028 .ctl_name = VM_MIN_SLAB,
1029 .procname = "min_slab_ratio",
1030 .data = &sysctl_min_slab_ratio,
1031 .maxlen = sizeof(sysctl_min_slab_ratio),
1032 .mode = 0644,
1033 .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
1034 .strategy = &sysctl_intvec,
1035 .extra1 = &zero,
1036 .extra2 = &one_hundred,
1037 },
Christoph Lameter17436602006-01-18 17:42:32 -08001038#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001039#ifdef CONFIG_SMP
1040 {
1041 .ctl_name = CTL_UNNUMBERED,
1042 .procname = "stat_interval",
1043 .data = &sysctl_stat_interval,
1044 .maxlen = sizeof(sysctl_stat_interval),
1045 .mode = 0644,
1046 .proc_handler = &proc_dointvec_jiffies,
1047 .strategy = &sysctl_jiffies,
1048 },
1049#endif
Eric Parised032182007-06-28 15:55:21 -04001050#ifdef CONFIG_SECURITY
1051 {
1052 .ctl_name = CTL_UNNUMBERED,
1053 .procname = "mmap_min_addr",
1054 .data = &mmap_min_addr,
1055 .maxlen = sizeof(unsigned long),
1056 .mode = 0644,
1057 .proc_handler = &proc_doulongvec_minmax,
1058 },
Lee Schermerhorn8daec962007-08-10 13:00:51 -07001059#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001060#ifdef CONFIG_NUMA
1061 {
1062 .ctl_name = CTL_UNNUMBERED,
1063 .procname = "numa_zonelist_order",
1064 .data = &numa_zonelist_order,
1065 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1066 .mode = 0644,
1067 .proc_handler = &numa_zonelist_order_handler,
1068 .strategy = &sysctl_string,
1069 },
1070#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001071#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001072 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001073 {
1074 .ctl_name = VM_VDSO_ENABLED,
1075 .procname = "vdso_enabled",
1076 .data = &vdso_enabled,
1077 .maxlen = sizeof(vdso_enabled),
1078 .mode = 0644,
1079 .proc_handler = &proc_dointvec,
1080 .strategy = &sysctl_intvec,
1081 .extra1 = &zero,
1082 },
1083#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001084/*
1085 * NOTE: do not add new entries to this table unless you have read
1086 * Documentation/sysctl/ctl_unnumbered.txt
1087 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088 { .ctl_name = 0 }
1089};
1090
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001091#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001092static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001093 { .ctl_name = 0 }
1094};
1095#endif
1096
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001097static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001098 {
1099 .ctl_name = FS_NRINODE,
1100 .procname = "inode-nr",
1101 .data = &inodes_stat,
1102 .maxlen = 2*sizeof(int),
1103 .mode = 0444,
1104 .proc_handler = &proc_dointvec,
1105 },
1106 {
1107 .ctl_name = FS_STATINODE,
1108 .procname = "inode-state",
1109 .data = &inodes_stat,
1110 .maxlen = 7*sizeof(int),
1111 .mode = 0444,
1112 .proc_handler = &proc_dointvec,
1113 },
1114 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001115 .procname = "file-nr",
1116 .data = &files_stat,
1117 .maxlen = 3*sizeof(int),
1118 .mode = 0444,
Dipankar Sarma529bf6b2006-03-07 21:55:35 -08001119 .proc_handler = &proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120 },
1121 {
1122 .ctl_name = FS_MAXFILE,
1123 .procname = "file-max",
1124 .data = &files_stat.max_files,
1125 .maxlen = sizeof(int),
1126 .mode = 0644,
1127 .proc_handler = &proc_dointvec,
1128 },
1129 {
1130 .ctl_name = FS_DENTRY,
1131 .procname = "dentry-state",
1132 .data = &dentry_stat,
1133 .maxlen = 6*sizeof(int),
1134 .mode = 0444,
1135 .proc_handler = &proc_dointvec,
1136 },
1137 {
1138 .ctl_name = FS_OVERFLOWUID,
1139 .procname = "overflowuid",
1140 .data = &fs_overflowuid,
1141 .maxlen = sizeof(int),
1142 .mode = 0644,
1143 .proc_handler = &proc_dointvec_minmax,
1144 .strategy = &sysctl_intvec,
1145 .extra1 = &minolduid,
1146 .extra2 = &maxolduid,
1147 },
1148 {
1149 .ctl_name = FS_OVERFLOWGID,
1150 .procname = "overflowgid",
1151 .data = &fs_overflowgid,
1152 .maxlen = sizeof(int),
1153 .mode = 0644,
1154 .proc_handler = &proc_dointvec_minmax,
1155 .strategy = &sysctl_intvec,
1156 .extra1 = &minolduid,
1157 .extra2 = &maxolduid,
1158 },
1159 {
1160 .ctl_name = FS_LEASES,
1161 .procname = "leases-enable",
1162 .data = &leases_enable,
1163 .maxlen = sizeof(int),
1164 .mode = 0644,
1165 .proc_handler = &proc_dointvec,
1166 },
1167#ifdef CONFIG_DNOTIFY
1168 {
1169 .ctl_name = FS_DIR_NOTIFY,
1170 .procname = "dir-notify-enable",
1171 .data = &dir_notify_enable,
1172 .maxlen = sizeof(int),
1173 .mode = 0644,
1174 .proc_handler = &proc_dointvec,
1175 },
1176#endif
1177#ifdef CONFIG_MMU
1178 {
1179 .ctl_name = FS_LEASE_TIME,
1180 .procname = "lease-break-time",
1181 .data = &lease_break_time,
1182 .maxlen = sizeof(int),
1183 .mode = 0644,
Kawai, Hidehiro76fdbb22007-07-19 01:48:26 -07001184 .proc_handler = &proc_dointvec_minmax,
1185 .strategy = &sysctl_intvec,
1186 .extra1 = &zero,
1187 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 },
1189 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 .procname = "aio-nr",
1191 .data = &aio_nr,
1192 .maxlen = sizeof(aio_nr),
1193 .mode = 0444,
Zach Brownd55b5fd2005-11-07 00:59:31 -08001194 .proc_handler = &proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195 },
1196 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001197 .procname = "aio-max-nr",
1198 .data = &aio_max_nr,
1199 .maxlen = sizeof(aio_max_nr),
1200 .mode = 0644,
Zach Brownd55b5fd2005-11-07 00:59:31 -08001201 .proc_handler = &proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202 },
Amy Griffis2d9048e2006-06-01 13:10:59 -07001203#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001204 {
1205 .ctl_name = FS_INOTIFY,
1206 .procname = "inotify",
1207 .mode = 0555,
1208 .child = inotify_table,
1209 },
1210#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001211#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001212 {
1213 .ctl_name = KERN_SETUID_DUMPABLE,
1214 .procname = "suid_dumpable",
1215 .data = &suid_dumpable,
1216 .maxlen = sizeof(int),
1217 .mode = 0644,
1218 .proc_handler = &proc_dointvec,
1219 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001220#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1221 {
1222 .ctl_name = CTL_UNNUMBERED,
1223 .procname = "binfmt_misc",
1224 .mode = 0555,
1225 .child = binfmt_misc_table,
1226 },
1227#endif
Andrew Morton2be7fe02007-07-15 23:41:21 -07001228/*
1229 * NOTE: do not add new entries to this table unless you have read
1230 * Documentation/sysctl/ctl_unnumbered.txt
1231 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232 { .ctl_name = 0 }
1233};
1234
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001235static struct ctl_table debug_table[] = {
Olof Johanssond0c3d532007-10-12 10:20:07 +10001236#if defined(CONFIG_X86) || defined(CONFIG_PPC)
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001237 {
1238 .ctl_name = CTL_UNNUMBERED,
1239 .procname = "exception-trace",
1240 .data = &show_unhandled_signals,
1241 .maxlen = sizeof(int),
1242 .mode = 0644,
1243 .proc_handler = proc_dointvec
1244 },
1245#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001246 { .ctl_name = 0 }
1247};
1248
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001249static struct ctl_table dev_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001250 { .ctl_name = 0 }
Robert Love0eeca282005-07-12 17:06:03 -04001251};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001252
Al Viro330d57f2005-11-04 10:18:40 +00001253static DEFINE_SPINLOCK(sysctl_lock);
1254
1255/* called under sysctl_lock */
1256static int use_table(struct ctl_table_header *p)
1257{
1258 if (unlikely(p->unregistering))
1259 return 0;
1260 p->used++;
1261 return 1;
1262}
1263
1264/* called under sysctl_lock */
1265static void unuse_table(struct ctl_table_header *p)
1266{
1267 if (!--p->used)
1268 if (unlikely(p->unregistering))
1269 complete(p->unregistering);
1270}
1271
1272/* called under sysctl_lock, will reacquire if has to wait */
1273static void start_unregistering(struct ctl_table_header *p)
1274{
1275 /*
1276 * if p->used is 0, nobody will ever touch that entry again;
1277 * we'll eliminate all paths to it before dropping sysctl_lock
1278 */
1279 if (unlikely(p->used)) {
1280 struct completion wait;
1281 init_completion(&wait);
1282 p->unregistering = &wait;
1283 spin_unlock(&sysctl_lock);
1284 wait_for_completion(&wait);
1285 spin_lock(&sysctl_lock);
1286 }
1287 /*
1288 * do not remove from the list until nobody holds it; walking the
1289 * list in do_sysctl() relies on that.
1290 */
1291 list_del_init(&p->ctl_entry);
1292}
1293
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001294void sysctl_head_finish(struct ctl_table_header *head)
1295{
1296 if (!head)
1297 return;
1298 spin_lock(&sysctl_lock);
1299 unuse_table(head);
1300 spin_unlock(&sysctl_lock);
1301}
1302
1303struct ctl_table_header *sysctl_head_next(struct ctl_table_header *prev)
1304{
1305 struct ctl_table_header *head;
1306 struct list_head *tmp;
1307 spin_lock(&sysctl_lock);
1308 if (prev) {
1309 tmp = &prev->ctl_entry;
1310 unuse_table(prev);
1311 goto next;
1312 }
1313 tmp = &root_table_header.ctl_entry;
1314 for (;;) {
1315 head = list_entry(tmp, struct ctl_table_header, ctl_entry);
1316
1317 if (!use_table(head))
1318 goto next;
1319 spin_unlock(&sysctl_lock);
1320 return head;
1321 next:
1322 tmp = tmp->next;
1323 if (tmp == &root_table_header.ctl_entry)
1324 break;
1325 }
1326 spin_unlock(&sysctl_lock);
1327 return NULL;
1328}
1329
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001330#ifdef CONFIG_SYSCTL_SYSCALL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001331int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1332 void __user *newval, size_t newlen)
1333{
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001334 struct ctl_table_header *head;
Al Viro330d57f2005-11-04 10:18:40 +00001335 int error = -ENOTDIR;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001336
1337 if (nlen <= 0 || nlen >= CTL_MAXNAME)
1338 return -ENOTDIR;
1339 if (oldval) {
1340 int old_len;
1341 if (!oldlenp || get_user(old_len, oldlenp))
1342 return -EFAULT;
1343 }
Al Viro330d57f2005-11-04 10:18:40 +00001344
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001345 for (head = sysctl_head_next(NULL); head;
1346 head = sysctl_head_next(head)) {
Al Viro330d57f2005-11-04 10:18:40 +00001347 error = parse_table(name, nlen, oldval, oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08001348 newval, newlen, head->ctl_table);
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001349 if (error != -ENOTDIR) {
1350 sysctl_head_finish(head);
Al Viro330d57f2005-11-04 10:18:40 +00001351 break;
Eric W. Biederman805b5d52007-02-14 00:34:11 -08001352 }
1353 }
Al Viro330d57f2005-11-04 10:18:40 +00001354 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355}
1356
1357asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1358{
1359 struct __sysctl_args tmp;
1360 int error;
1361
1362 if (copy_from_user(&tmp, args, sizeof(tmp)))
1363 return -EFAULT;
1364
Eric W. Biederman7058cb02007-10-18 03:05:58 -07001365 error = deprecated_sysctl_warning(&tmp);
1366 if (error)
1367 goto out;
1368
Linus Torvalds1da177e2005-04-16 15:20:36 -07001369 lock_kernel();
1370 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1371 tmp.newval, tmp.newlen);
1372 unlock_kernel();
Eric W. Biederman7058cb02007-10-18 03:05:58 -07001373out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001374 return error;
1375}
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001376#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001377
1378/*
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001379 * sysctl_perm does NOT grant the superuser all rights automatically, because
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380 * some sysctl variables are readonly even to root.
1381 */
1382
1383static int test_perm(int mode, int op)
1384{
1385 if (!current->euid)
1386 mode >>= 6;
1387 else if (in_egroup_p(0))
1388 mode >>= 3;
1389 if ((mode & op & 0007) == op)
1390 return 0;
1391 return -EACCES;
1392}
1393
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001394int sysctl_perm(struct ctl_table *table, int op)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001395{
1396 int error;
1397 error = security_sysctl(table, op);
1398 if (error)
1399 return error;
1400 return test_perm(table->mode, op);
1401}
1402
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001403#ifdef CONFIG_SYSCTL_SYSCALL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001404static int parse_table(int __user *name, int nlen,
1405 void __user *oldval, size_t __user *oldlenp,
1406 void __user *newval, size_t newlen,
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001407 struct ctl_table *table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408{
1409 int n;
1410repeat:
1411 if (!nlen)
1412 return -ENOTDIR;
1413 if (get_user(n, name))
1414 return -EFAULT;
Eric W. Biedermand99f1602006-11-05 23:52:12 -08001415 for ( ; table->ctl_name || table->procname; table++) {
1416 if (!table->ctl_name)
1417 continue;
Eric W. Biederman6703ddf2007-02-14 00:34:07 -08001418 if (n == table->ctl_name) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001419 int error;
1420 if (table->child) {
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001421 if (sysctl_perm(table, 001))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001422 return -EPERM;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001423 name++;
1424 nlen--;
1425 table = table->child;
1426 goto repeat;
1427 }
1428 error = do_sysctl_strategy(table, name, nlen,
1429 oldval, oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08001430 newval, newlen);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001431 return error;
1432 }
1433 }
1434 return -ENOTDIR;
1435}
1436
1437/* Perform the actual read/write of a sysctl table entry. */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001438int do_sysctl_strategy (struct ctl_table *table,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439 int __user *name, int nlen,
1440 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08001441 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001442{
1443 int op = 0, rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001444
1445 if (oldval)
1446 op |= 004;
1447 if (newval)
1448 op |= 002;
Eric W. Biederman1ff007e2007-02-14 00:34:11 -08001449 if (sysctl_perm(table, op))
Linus Torvalds1da177e2005-04-16 15:20:36 -07001450 return -EPERM;
1451
1452 if (table->strategy) {
1453 rc = table->strategy(table, name, nlen, oldval, oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08001454 newval, newlen);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 if (rc < 0)
1456 return rc;
1457 if (rc > 0)
1458 return 0;
1459 }
1460
1461 /* If there is no strategy routine, or if the strategy returns
1462 * zero, proceed with automatic r/w */
1463 if (table->data && table->maxlen) {
Eric W. Biederman49a0c452007-10-18 03:05:23 -07001464 rc = sysctl_data(table, name, nlen, oldval, oldlenp,
1465 newval, newlen);
1466 if (rc < 0)
1467 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001468 }
1469 return 0;
1470}
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001471#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001473static void sysctl_set_parent(struct ctl_table *parent, struct ctl_table *table)
1474{
1475 for (; table->ctl_name || table->procname; table++) {
1476 table->parent = parent;
1477 if (table->child)
1478 sysctl_set_parent(table, table->child);
1479 }
1480}
1481
1482static __init int sysctl_init(void)
1483{
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001484 int err;
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001485 sysctl_set_parent(NULL, root_table);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001486 err = sysctl_check_table(root_table);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001487 return 0;
1488}
1489
1490core_initcall(sysctl_init);
1491
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492/**
1493 * register_sysctl_table - register a sysctl hierarchy
1494 * @table: the top-level table structure
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 *
1496 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1497 * array. An entry with a ctl_name of 0 terminates the table.
1498 *
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001499 * The members of the &struct ctl_table structure are used as follows:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500 *
1501 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1502 * must be unique within that level of sysctl
1503 *
1504 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1505 * enter a sysctl file
1506 *
1507 * data - a pointer to data for use by proc_handler
1508 *
1509 * maxlen - the maximum size in bytes of the data
1510 *
1511 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1512 *
1513 * child - a pointer to the child sysctl table if this entry is a directory, or
1514 * %NULL.
1515 *
1516 * proc_handler - the text handler routine (described below)
1517 *
1518 * strategy - the strategy routine (described below)
1519 *
1520 * de - for internal use by the sysctl routines
1521 *
1522 * extra1, extra2 - extra pointers usable by the proc handler routines
1523 *
1524 * Leaf nodes in the sysctl tree will be represented by a single file
1525 * under /proc; non-leaf nodes will be represented by directories.
1526 *
1527 * sysctl(2) can automatically manage read and write requests through
1528 * the sysctl table. The data and maxlen fields of the ctl_table
1529 * struct enable minimal validation of the values being written to be
1530 * performed, and the mode field allows minimal authentication.
1531 *
1532 * More sophisticated management can be enabled by the provision of a
1533 * strategy routine with the table entry. This will be called before
1534 * any automatic read or write of the data is performed.
1535 *
1536 * The strategy routine may return
1537 *
1538 * < 0 - Error occurred (error is passed to user process)
1539 *
1540 * 0 - OK - proceed with automatic read or write.
1541 *
1542 * > 0 - OK - read or write has been done by the strategy routine, so
1543 * return immediately.
1544 *
1545 * There must be a proc_handler routine for any terminal nodes
1546 * mirrored under /proc/sys (non-terminals are handled by a built-in
1547 * directory handler). Several default handlers are available to
1548 * cover common cases -
1549 *
1550 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1551 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1552 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1553 *
1554 * It is the handler's job to read the input buffer from user memory
1555 * and process it. The handler should return 0 on success.
1556 *
1557 * This routine returns %NULL on a failure to register, and a pointer
1558 * to the table header on success.
1559 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001560struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001561{
1562 struct ctl_table_header *tmp;
1563 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1564 if (!tmp)
1565 return NULL;
1566 tmp->ctl_table = table;
1567 INIT_LIST_HEAD(&tmp->ctl_entry);
Al Viro330d57f2005-11-04 10:18:40 +00001568 tmp->used = 0;
1569 tmp->unregistering = NULL;
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001570 sysctl_set_parent(NULL, table);
Eric W. Biedermanfc6cd252007-10-18 03:05:54 -07001571 if (sysctl_check_table(tmp->ctl_table)) {
1572 kfree(tmp);
1573 return NULL;
1574 }
Al Viro330d57f2005-11-04 10:18:40 +00001575 spin_lock(&sysctl_lock);
Eric W. Biederman0b4d4142007-02-14 00:34:09 -08001576 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
Al Viro330d57f2005-11-04 10:18:40 +00001577 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001578 return tmp;
1579}
1580
1581/**
1582 * unregister_sysctl_table - unregister a sysctl table hierarchy
1583 * @header: the header returned from register_sysctl_table
1584 *
1585 * Unregisters the sysctl table and all children. proc entries may not
1586 * actually be removed until they are no longer used by anyone.
1587 */
1588void unregister_sysctl_table(struct ctl_table_header * header)
1589{
Al Viro330d57f2005-11-04 10:18:40 +00001590 might_sleep();
Pavel Emelyanovf1dad162007-12-04 23:45:24 -08001591
1592 if (header == NULL)
1593 return;
1594
Al Viro330d57f2005-11-04 10:18:40 +00001595 spin_lock(&sysctl_lock);
1596 start_unregistering(header);
Al Viro330d57f2005-11-04 10:18:40 +00001597 spin_unlock(&sysctl_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001598 kfree(header);
1599}
1600
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001601#else /* !CONFIG_SYSCTL */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001602struct ctl_table_header *register_sysctl_table(struct ctl_table * table)
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001603{
1604 return NULL;
1605}
1606
1607void unregister_sysctl_table(struct ctl_table_header * table)
1608{
1609}
1610
1611#endif /* CONFIG_SYSCTL */
1612
Linus Torvalds1da177e2005-04-16 15:20:36 -07001613/*
1614 * /proc/sys support
1615 */
1616
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001617#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001618
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001619static int _proc_do_string(void* data, int maxlen, int write,
1620 struct file *filp, void __user *buffer,
1621 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001622{
1623 size_t len;
1624 char __user *p;
1625 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001626
1627 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001628 *lenp = 0;
1629 return 0;
1630 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001631
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001632 if (write) {
1633 len = 0;
1634 p = buffer;
1635 while (len < *lenp) {
1636 if (get_user(c, p++))
1637 return -EFAULT;
1638 if (c == 0 || c == '\n')
1639 break;
1640 len++;
1641 }
1642 if (len >= maxlen)
1643 len = maxlen-1;
1644 if(copy_from_user(data, buffer, len))
1645 return -EFAULT;
1646 ((char *) data)[len] = 0;
1647 *ppos += *lenp;
1648 } else {
1649 len = strlen(data);
1650 if (len > maxlen)
1651 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001652
1653 if (*ppos > len) {
1654 *lenp = 0;
1655 return 0;
1656 }
1657
1658 data += *ppos;
1659 len -= *ppos;
1660
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001661 if (len > *lenp)
1662 len = *lenp;
1663 if (len)
1664 if(copy_to_user(buffer, data, len))
1665 return -EFAULT;
1666 if (len < *lenp) {
1667 if(put_user('\n', ((char __user *) buffer) + len))
1668 return -EFAULT;
1669 len++;
1670 }
1671 *lenp = len;
1672 *ppos += len;
1673 }
1674 return 0;
1675}
1676
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677/**
1678 * proc_dostring - read a string sysctl
1679 * @table: the sysctl table
1680 * @write: %TRUE if this is a write to the sysctl file
1681 * @filp: the file structure
1682 * @buffer: the user buffer
1683 * @lenp: the size of the user buffer
1684 * @ppos: file position
1685 *
1686 * Reads/writes a string from/to the user buffer. If the kernel
1687 * buffer provided is not large enough to hold the string, the
1688 * string is truncated. The copied string is %NULL-terminated.
1689 * If the string is being read by the user process, it is copied
1690 * and a newline '\n' is added. It is truncated if the buffer is
1691 * not large enough.
1692 *
1693 * Returns 0 on success.
1694 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001695int proc_dostring(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696 void __user *buffer, size_t *lenp, loff_t *ppos)
1697{
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001698 return _proc_do_string(table->data, table->maxlen, write, filp,
1699 buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700}
1701
Linus Torvalds1da177e2005-04-16 15:20:36 -07001702
1703static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1704 int *valp,
1705 int write, void *data)
1706{
1707 if (write) {
1708 *valp = *negp ? -*lvalp : *lvalp;
1709 } else {
1710 int val = *valp;
1711 if (val < 0) {
1712 *negp = -1;
1713 *lvalp = (unsigned long)-val;
1714 } else {
1715 *negp = 0;
1716 *lvalp = (unsigned long)val;
1717 }
1718 }
1719 return 0;
1720}
1721
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001722static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001723 int write, struct file *filp, void __user *buffer,
1724 size_t *lenp, loff_t *ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001725 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1726 int write, void *data),
1727 void *data)
1728{
1729#define TMPBUFLEN 21
1730 int *i, vleft, first=1, neg, val;
1731 unsigned long lval;
1732 size_t left, len;
1733
1734 char buf[TMPBUFLEN], *p;
1735 char __user *s = buffer;
1736
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001737 if (!tbl_data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07001738 (*ppos && !write)) {
1739 *lenp = 0;
1740 return 0;
1741 }
1742
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001743 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001744 vleft = table->maxlen / sizeof(*i);
1745 left = *lenp;
1746
1747 if (!conv)
1748 conv = do_proc_dointvec_conv;
1749
1750 for (; left && vleft--; i++, first=0) {
1751 if (write) {
1752 while (left) {
1753 char c;
1754 if (get_user(c, s))
1755 return -EFAULT;
1756 if (!isspace(c))
1757 break;
1758 left--;
1759 s++;
1760 }
1761 if (!left)
1762 break;
1763 neg = 0;
1764 len = left;
1765 if (len > sizeof(buf) - 1)
1766 len = sizeof(buf) - 1;
1767 if (copy_from_user(buf, s, len))
1768 return -EFAULT;
1769 buf[len] = 0;
1770 p = buf;
1771 if (*p == '-' && left > 1) {
1772 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08001773 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001774 }
1775 if (*p < '0' || *p > '9')
1776 break;
1777
1778 lval = simple_strtoul(p, &p, 0);
1779
1780 len = p-buf;
1781 if ((len < left) && *p && !isspace(*p))
1782 break;
1783 if (neg)
1784 val = -val;
1785 s += len;
1786 left -= len;
1787
1788 if (conv(&neg, &lval, i, 1, data))
1789 break;
1790 } else {
1791 p = buf;
1792 if (!first)
1793 *p++ = '\t';
1794
1795 if (conv(&neg, &lval, i, 0, data))
1796 break;
1797
1798 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1799 len = strlen(buf);
1800 if (len > left)
1801 len = left;
1802 if(copy_to_user(s, buf, len))
1803 return -EFAULT;
1804 left -= len;
1805 s += len;
1806 }
1807 }
1808
1809 if (!write && !first && left) {
1810 if(put_user('\n', s))
1811 return -EFAULT;
1812 left--, s++;
1813 }
1814 if (write) {
1815 while (left) {
1816 char c;
1817 if (get_user(c, s++))
1818 return -EFAULT;
1819 if (!isspace(c))
1820 break;
1821 left--;
1822 }
1823 }
1824 if (write && first)
1825 return -EINVAL;
1826 *lenp -= left;
1827 *ppos += *lenp;
1828 return 0;
1829#undef TMPBUFLEN
1830}
1831
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001832static int do_proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001833 void __user *buffer, size_t *lenp, loff_t *ppos,
1834 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1835 int write, void *data),
1836 void *data)
1837{
1838 return __do_proc_dointvec(table->data, table, write, filp,
1839 buffer, lenp, ppos, conv, data);
1840}
1841
Linus Torvalds1da177e2005-04-16 15:20:36 -07001842/**
1843 * proc_dointvec - read a vector of integers
1844 * @table: the sysctl table
1845 * @write: %TRUE if this is a write to the sysctl file
1846 * @filp: the file structure
1847 * @buffer: the user buffer
1848 * @lenp: the size of the user buffer
1849 * @ppos: file position
1850 *
1851 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1852 * values from/to the user buffer, treated as an ASCII string.
1853 *
1854 * Returns 0 on success.
1855 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001856int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001857 void __user *buffer, size_t *lenp, loff_t *ppos)
1858{
1859 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1860 NULL,NULL);
1861}
1862
1863#define OP_SET 0
1864#define OP_AND 1
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001865#define OP_OR 2
Linus Torvalds1da177e2005-04-16 15:20:36 -07001866
1867static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1868 int *valp,
1869 int write, void *data)
1870{
1871 int op = *(int *)data;
1872 if (write) {
1873 int val = *negp ? -*lvalp : *lvalp;
1874 switch(op) {
1875 case OP_SET: *valp = val; break;
1876 case OP_AND: *valp &= val; break;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001877 case OP_OR: *valp |= val; break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001878 }
1879 } else {
1880 int val = *valp;
1881 if (val < 0) {
1882 *negp = -1;
1883 *lvalp = (unsigned long)-val;
1884 } else {
1885 *negp = 0;
1886 *lvalp = (unsigned long)val;
1887 }
1888 }
1889 return 0;
1890}
1891
Andrew Morgan72c2d582007-10-18 03:05:59 -07001892#ifdef CONFIG_SECURITY_CAPABILITIES
Linus Torvalds1da177e2005-04-16 15:20:36 -07001893/*
1894 * init may raise the set.
1895 */
Andrew Morgan72c2d582007-10-18 03:05:59 -07001896
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001897int proc_dointvec_bset(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001898 void __user *buffer, size_t *lenp, loff_t *ppos)
1899{
1900 int op;
1901
Eric Paris6ff1b442007-02-10 01:43:19 -08001902 if (write && !capable(CAP_SYS_MODULE)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001903 return -EPERM;
1904 }
1905
Serge E. Hallynb460cbc2007-10-18 23:39:52 -07001906 op = is_global_init(current) ? OP_SET : OP_AND;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001907 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1908 do_proc_dointvec_bset_conv,&op);
1909}
Andrew Morgan72c2d582007-10-18 03:05:59 -07001910#endif /* def CONFIG_SECURITY_CAPABILITIES */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001911
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001912/*
1913 * Taint values can only be increased
1914 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001915static int proc_dointvec_taint(struct ctl_table *table, int write, struct file *filp,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001916 void __user *buffer, size_t *lenp, loff_t *ppos)
1917{
1918 int op;
1919
Bastian Blank91fcd412007-04-23 14:41:14 -07001920 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08001921 return -EPERM;
1922
1923 op = OP_OR;
1924 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1925 do_proc_dointvec_bset_conv,&op);
1926}
1927
Linus Torvalds1da177e2005-04-16 15:20:36 -07001928struct do_proc_dointvec_minmax_conv_param {
1929 int *min;
1930 int *max;
1931};
1932
1933static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1934 int *valp,
1935 int write, void *data)
1936{
1937 struct do_proc_dointvec_minmax_conv_param *param = data;
1938 if (write) {
1939 int val = *negp ? -*lvalp : *lvalp;
1940 if ((param->min && *param->min > val) ||
1941 (param->max && *param->max < val))
1942 return -EINVAL;
1943 *valp = val;
1944 } else {
1945 int val = *valp;
1946 if (val < 0) {
1947 *negp = -1;
1948 *lvalp = (unsigned long)-val;
1949 } else {
1950 *negp = 0;
1951 *lvalp = (unsigned long)val;
1952 }
1953 }
1954 return 0;
1955}
1956
1957/**
1958 * proc_dointvec_minmax - read a vector of integers with min/max values
1959 * @table: the sysctl table
1960 * @write: %TRUE if this is a write to the sysctl file
1961 * @filp: the file structure
1962 * @buffer: the user buffer
1963 * @lenp: the size of the user buffer
1964 * @ppos: file position
1965 *
1966 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1967 * values from/to the user buffer, treated as an ASCII string.
1968 *
1969 * This routine will ensure the values are within the range specified by
1970 * table->extra1 (min) and table->extra2 (max).
1971 *
1972 * Returns 0 on success.
1973 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001974int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001975 void __user *buffer, size_t *lenp, loff_t *ppos)
1976{
1977 struct do_proc_dointvec_minmax_conv_param param = {
1978 .min = (int *) table->extra1,
1979 .max = (int *) table->extra2,
1980 };
1981 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
1982 do_proc_dointvec_minmax_conv, &param);
1983}
1984
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001985static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001986 struct file *filp,
1987 void __user *buffer,
1988 size_t *lenp, loff_t *ppos,
1989 unsigned long convmul,
1990 unsigned long convdiv)
1991{
1992#define TMPBUFLEN 21
1993 unsigned long *i, *min, *max, val;
1994 int vleft, first=1, neg;
1995 size_t len, left;
1996 char buf[TMPBUFLEN], *p;
1997 char __user *s = buffer;
1998
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07001999 if (!data || !table->maxlen || !*lenp ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002000 (*ppos && !write)) {
2001 *lenp = 0;
2002 return 0;
2003 }
2004
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002005 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002006 min = (unsigned long *) table->extra1;
2007 max = (unsigned long *) table->extra2;
2008 vleft = table->maxlen / sizeof(unsigned long);
2009 left = *lenp;
2010
2011 for (; left && vleft--; i++, min++, max++, first=0) {
2012 if (write) {
2013 while (left) {
2014 char c;
2015 if (get_user(c, s))
2016 return -EFAULT;
2017 if (!isspace(c))
2018 break;
2019 left--;
2020 s++;
2021 }
2022 if (!left)
2023 break;
2024 neg = 0;
2025 len = left;
2026 if (len > TMPBUFLEN-1)
2027 len = TMPBUFLEN-1;
2028 if (copy_from_user(buf, s, len))
2029 return -EFAULT;
2030 buf[len] = 0;
2031 p = buf;
2032 if (*p == '-' && left > 1) {
2033 neg = 1;
BP, Praveenbd9b0ba2006-12-06 20:39:09 -08002034 p++;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002035 }
2036 if (*p < '0' || *p > '9')
2037 break;
2038 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2039 len = p-buf;
2040 if ((len < left) && *p && !isspace(*p))
2041 break;
2042 if (neg)
2043 val = -val;
2044 s += len;
2045 left -= len;
2046
2047 if(neg)
2048 continue;
2049 if ((min && val < *min) || (max && val > *max))
2050 continue;
2051 *i = val;
2052 } else {
2053 p = buf;
2054 if (!first)
2055 *p++ = '\t';
2056 sprintf(p, "%lu", convdiv * (*i) / convmul);
2057 len = strlen(buf);
2058 if (len > left)
2059 len = left;
2060 if(copy_to_user(s, buf, len))
2061 return -EFAULT;
2062 left -= len;
2063 s += len;
2064 }
2065 }
2066
2067 if (!write && !first && left) {
2068 if(put_user('\n', s))
2069 return -EFAULT;
2070 left--, s++;
2071 }
2072 if (write) {
2073 while (left) {
2074 char c;
2075 if (get_user(c, s++))
2076 return -EFAULT;
2077 if (!isspace(c))
2078 break;
2079 left--;
2080 }
2081 }
2082 if (write && first)
2083 return -EINVAL;
2084 *lenp -= left;
2085 *ppos += *lenp;
2086 return 0;
2087#undef TMPBUFLEN
2088}
2089
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002090static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002091 struct file *filp,
2092 void __user *buffer,
2093 size_t *lenp, loff_t *ppos,
2094 unsigned long convmul,
2095 unsigned long convdiv)
2096{
2097 return __do_proc_doulongvec_minmax(table->data, table, write,
2098 filp, buffer, lenp, ppos, convmul, convdiv);
2099}
2100
Linus Torvalds1da177e2005-04-16 15:20:36 -07002101/**
2102 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2103 * @table: the sysctl table
2104 * @write: %TRUE if this is a write to the sysctl file
2105 * @filp: the file structure
2106 * @buffer: the user buffer
2107 * @lenp: the size of the user buffer
2108 * @ppos: file position
2109 *
2110 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2111 * values from/to the user buffer, treated as an ASCII string.
2112 *
2113 * This routine will ensure the values are within the range specified by
2114 * table->extra1 (min) and table->extra2 (max).
2115 *
2116 * Returns 0 on success.
2117 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002118int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002119 void __user *buffer, size_t *lenp, loff_t *ppos)
2120{
2121 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
2122}
2123
2124/**
2125 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
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 up to table->maxlen/sizeof(unsigned long) unsigned long
2134 * values from/to the user buffer, treated as an ASCII string. The values
2135 * are treated as milliseconds, and converted to jiffies when they are stored.
2136 *
2137 * This routine will ensure the values are within the range specified by
2138 * table->extra1 (min) and table->extra2 (max).
2139 *
2140 * Returns 0 on success.
2141 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002142int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002143 struct file *filp,
2144 void __user *buffer,
2145 size_t *lenp, loff_t *ppos)
2146{
2147 return do_proc_doulongvec_minmax(table, write, filp, buffer,
2148 lenp, ppos, HZ, 1000l);
2149}
2150
2151
2152static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2153 int *valp,
2154 int write, void *data)
2155{
2156 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002157 if (*lvalp > LONG_MAX / HZ)
2158 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002159 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2160 } else {
2161 int val = *valp;
2162 unsigned long lval;
2163 if (val < 0) {
2164 *negp = -1;
2165 lval = (unsigned long)-val;
2166 } else {
2167 *negp = 0;
2168 lval = (unsigned long)val;
2169 }
2170 *lvalp = lval / HZ;
2171 }
2172 return 0;
2173}
2174
2175static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2176 int *valp,
2177 int write, void *data)
2178{
2179 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002180 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2181 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002182 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2183 } else {
2184 int val = *valp;
2185 unsigned long lval;
2186 if (val < 0) {
2187 *negp = -1;
2188 lval = (unsigned long)-val;
2189 } else {
2190 *negp = 0;
2191 lval = (unsigned long)val;
2192 }
2193 *lvalp = jiffies_to_clock_t(lval);
2194 }
2195 return 0;
2196}
2197
2198static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2199 int *valp,
2200 int write, void *data)
2201{
2202 if (write) {
2203 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2204 } else {
2205 int val = *valp;
2206 unsigned long lval;
2207 if (val < 0) {
2208 *negp = -1;
2209 lval = (unsigned long)-val;
2210 } else {
2211 *negp = 0;
2212 lval = (unsigned long)val;
2213 }
2214 *lvalp = jiffies_to_msecs(lval);
2215 }
2216 return 0;
2217}
2218
2219/**
2220 * proc_dointvec_jiffies - read a vector of integers as seconds
2221 * @table: the sysctl table
2222 * @write: %TRUE if this is a write to the sysctl file
2223 * @filp: the file structure
2224 * @buffer: the user buffer
2225 * @lenp: the size of the user buffer
2226 * @ppos: file position
2227 *
2228 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2229 * values from/to the user buffer, treated as an ASCII string.
2230 * The values read are assumed to be in seconds, and are converted into
2231 * jiffies.
2232 *
2233 * Returns 0 on success.
2234 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002235int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002236 void __user *buffer, size_t *lenp, loff_t *ppos)
2237{
2238 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2239 do_proc_dointvec_jiffies_conv,NULL);
2240}
2241
2242/**
2243 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2244 * @table: the sysctl table
2245 * @write: %TRUE if this is a write to the sysctl file
2246 * @filp: the file structure
2247 * @buffer: the user buffer
2248 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002249 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002250 *
2251 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2252 * values from/to the user buffer, treated as an ASCII string.
2253 * The values read are assumed to be in 1/USER_HZ seconds, and
2254 * are converted into jiffies.
2255 *
2256 * Returns 0 on success.
2257 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002258int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002259 void __user *buffer, size_t *lenp, loff_t *ppos)
2260{
2261 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2262 do_proc_dointvec_userhz_jiffies_conv,NULL);
2263}
2264
2265/**
2266 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2267 * @table: the sysctl table
2268 * @write: %TRUE if this is a write to the sysctl file
2269 * @filp: the file structure
2270 * @buffer: the user buffer
2271 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002272 * @ppos: file position
2273 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002274 *
2275 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2276 * values from/to the user buffer, treated as an ASCII string.
2277 * The values read are assumed to be in 1/1000 seconds, and
2278 * are converted into jiffies.
2279 *
2280 * Returns 0 on success.
2281 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002282int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002283 void __user *buffer, size_t *lenp, loff_t *ppos)
2284{
2285 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2286 do_proc_dointvec_ms_jiffies_conv, NULL);
2287}
2288
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002289static int proc_do_cad_pid(struct ctl_table *table, int write, struct file *filp,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002290 void __user *buffer, size_t *lenp, loff_t *ppos)
2291{
2292 struct pid *new_pid;
2293 pid_t tmp;
2294 int r;
2295
Pavel Emelyanovb4888932007-10-18 23:40:14 -07002296 tmp = pid_nr_ns(cad_pid, current->nsproxy->pid_ns);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002297
2298 r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
2299 lenp, ppos, NULL, NULL);
2300 if (r || !write)
2301 return r;
2302
2303 new_pid = find_get_pid(tmp);
2304 if (!new_pid)
2305 return -ESRCH;
2306
2307 put_pid(xchg(&cad_pid, new_pid));
2308 return 0;
2309}
2310
Linus Torvalds1da177e2005-04-16 15:20:36 -07002311#else /* CONFIG_PROC_FS */
2312
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002313int proc_dostring(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002314 void __user *buffer, size_t *lenp, loff_t *ppos)
2315{
2316 return -ENOSYS;
2317}
2318
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002319int proc_dointvec(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002320 void __user *buffer, size_t *lenp, loff_t *ppos)
2321{
2322 return -ENOSYS;
2323}
2324
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002325int proc_dointvec_bset(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002326 void __user *buffer, size_t *lenp, loff_t *ppos)
2327{
2328 return -ENOSYS;
2329}
2330
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002331int proc_dointvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002332 void __user *buffer, size_t *lenp, loff_t *ppos)
2333{
2334 return -ENOSYS;
2335}
2336
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002337int proc_dointvec_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002338 void __user *buffer, size_t *lenp, loff_t *ppos)
2339{
2340 return -ENOSYS;
2341}
2342
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002343int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002344 void __user *buffer, size_t *lenp, loff_t *ppos)
2345{
2346 return -ENOSYS;
2347}
2348
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002349int proc_dointvec_ms_jiffies(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002350 void __user *buffer, size_t *lenp, loff_t *ppos)
2351{
2352 return -ENOSYS;
2353}
2354
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002355int proc_doulongvec_minmax(struct ctl_table *table, int write, struct file *filp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356 void __user *buffer, size_t *lenp, loff_t *ppos)
2357{
2358 return -ENOSYS;
2359}
2360
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002361int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362 struct file *filp,
2363 void __user *buffer,
2364 size_t *lenp, loff_t *ppos)
2365{
2366 return -ENOSYS;
2367}
2368
2369
2370#endif /* CONFIG_PROC_FS */
2371
2372
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002373#ifdef CONFIG_SYSCTL_SYSCALL
Linus Torvalds1da177e2005-04-16 15:20:36 -07002374/*
2375 * General sysctl support routines
2376 */
2377
Eric W. Biederman49a0c452007-10-18 03:05:23 -07002378/* The generic sysctl data routine (used if no strategy routine supplied) */
2379int sysctl_data(struct ctl_table *table, int __user *name, int nlen,
2380 void __user *oldval, size_t __user *oldlenp,
2381 void __user *newval, size_t newlen)
2382{
2383 size_t len;
2384
2385 /* Get out of I don't have a variable */
2386 if (!table->data || !table->maxlen)
2387 return -ENOTDIR;
2388
2389 if (oldval && oldlenp) {
2390 if (get_user(len, oldlenp))
2391 return -EFAULT;
2392 if (len) {
2393 if (len > table->maxlen)
2394 len = table->maxlen;
2395 if (copy_to_user(oldval, table->data, len))
2396 return -EFAULT;
2397 if (put_user(len, oldlenp))
2398 return -EFAULT;
2399 }
2400 }
2401
2402 if (newval && newlen) {
2403 if (newlen > table->maxlen)
2404 newlen = table->maxlen;
2405
2406 if (copy_from_user(table->data, newval, newlen))
2407 return -EFAULT;
2408 }
2409 return 1;
2410}
2411
Linus Torvalds1da177e2005-04-16 15:20:36 -07002412/* The generic string strategy routine: */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002413int sysctl_string(struct ctl_table *table, int __user *name, int nlen,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002414 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002415 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002416{
Linus Torvalds1da177e2005-04-16 15:20:36 -07002417 if (!table->data || !table->maxlen)
2418 return -ENOTDIR;
2419
2420 if (oldval && oldlenp) {
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002421 size_t bufsize;
2422 if (get_user(bufsize, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002423 return -EFAULT;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002424 if (bufsize) {
2425 size_t len = strlen(table->data), copied;
2426
2427 /* This shouldn't trigger for a well-formed sysctl */
2428 if (len > table->maxlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002429 len = table->maxlen;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002430
2431 /* Copy up to a max of bufsize-1 bytes of the string */
2432 copied = (len >= bufsize) ? bufsize - 1 : len;
2433
2434 if (copy_to_user(oldval, table->data, copied) ||
2435 put_user(0, (char __user *)(oldval + copied)))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436 return -EFAULT;
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002437 if (put_user(len, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002438 return -EFAULT;
2439 }
2440 }
2441 if (newval && newlen) {
Linus Torvaldsde9e0072005-12-31 17:00:29 -08002442 size_t len = newlen;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002443 if (len > table->maxlen)
2444 len = table->maxlen;
2445 if(copy_from_user(table->data, newval, len))
2446 return -EFAULT;
2447 if (len == table->maxlen)
2448 len--;
2449 ((char *) table->data)[len] = 0;
2450 }
Yi Yang82c9df82005-12-30 16:37:10 +08002451 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002452}
2453
2454/*
2455 * This function makes sure that all of the integers in the vector
2456 * are between the minimum and maximum values given in the arrays
2457 * table->extra1 and table->extra2, respectively.
2458 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002459int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002460 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002461 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002462{
2463
2464 if (newval && newlen) {
2465 int __user *vec = (int __user *) newval;
2466 int *min = (int *) table->extra1;
2467 int *max = (int *) table->extra2;
2468 size_t length;
2469 int i;
2470
2471 if (newlen % sizeof(int) != 0)
2472 return -EINVAL;
2473
2474 if (!table->extra1 && !table->extra2)
2475 return 0;
2476
2477 if (newlen > table->maxlen)
2478 newlen = table->maxlen;
2479 length = newlen / sizeof(int);
2480
2481 for (i = 0; i < length; i++) {
2482 int value;
2483 if (get_user(value, vec + i))
2484 return -EFAULT;
2485 if (min && value < min[i])
2486 return -EINVAL;
2487 if (max && value > max[i])
2488 return -EINVAL;
2489 }
2490 }
2491 return 0;
2492}
2493
2494/* Strategy function to convert jiffies to seconds */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002495int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002496 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002497 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002498{
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002499 if (oldval && oldlenp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002500 size_t olen;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002501
2502 if (get_user(olen, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002503 return -EFAULT;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002504 if (olen) {
2505 int val;
2506
2507 if (olen < sizeof(int))
2508 return -EINVAL;
2509
2510 val = *(int *)(table->data) / HZ;
2511 if (put_user(val, (int __user *)oldval))
2512 return -EFAULT;
2513 if (put_user(sizeof(int), oldlenp))
2514 return -EFAULT;
2515 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002516 }
2517 if (newval && newlen) {
2518 int new;
2519 if (newlen != sizeof(int))
2520 return -EINVAL;
2521 if (get_user(new, (int __user *)newval))
2522 return -EFAULT;
2523 *(int *)(table->data) = new*HZ;
2524 }
2525 return 1;
2526}
2527
2528/* Strategy function to convert jiffies to seconds */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002529int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002530 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002531 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002532{
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002533 if (oldval && oldlenp) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002534 size_t olen;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002535
2536 if (get_user(olen, oldlenp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002537 return -EFAULT;
Alexey Dobriyan3ee75ac2007-02-10 01:44:39 -08002538 if (olen) {
2539 int val;
2540
2541 if (olen < sizeof(int))
2542 return -EINVAL;
2543
2544 val = jiffies_to_msecs(*(int *)(table->data));
2545 if (put_user(val, (int __user *)oldval))
2546 return -EFAULT;
2547 if (put_user(sizeof(int), oldlenp))
2548 return -EFAULT;
2549 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550 }
2551 if (newval && newlen) {
2552 int new;
2553 if (newlen != sizeof(int))
2554 return -EINVAL;
2555 if (get_user(new, (int __user *)newval))
2556 return -EFAULT;
2557 *(int *)(table->data) = msecs_to_jiffies(new);
2558 }
2559 return 1;
2560}
2561
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08002562
Eric W. Biedermanc4b8b762006-12-08 02:39:55 -08002563
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002564#else /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002565
2566
2567asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2568{
Eric W. Biederman0e009be2006-11-05 23:52:11 -08002569 struct __sysctl_args tmp;
Eric W. Biederman7058cb02007-10-18 03:05:58 -07002570 int error;
Eric W. Biederman0e009be2006-11-05 23:52:11 -08002571
Eric W. Biederman0e009be2006-11-05 23:52:11 -08002572 if (copy_from_user(&tmp, args, sizeof(tmp)))
2573 return -EFAULT;
Eric W. Biederman0e009be2006-11-05 23:52:11 -08002574
Eric W. Biederman7058cb02007-10-18 03:05:58 -07002575 error = deprecated_sysctl_warning(&tmp);
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002576
Eric W. Biederman7058cb02007-10-18 03:05:58 -07002577 /* If no error reading the parameters then just -ENOSYS ... */
2578 if (!error)
2579 error = -ENOSYS;
2580
2581 return error;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002582}
2583
Eric W. Biederman49a0c452007-10-18 03:05:23 -07002584int sysctl_data(struct ctl_table *table, int __user *name, int nlen,
2585 void __user *oldval, size_t __user *oldlenp,
2586 void __user *newval, size_t newlen)
2587{
2588 return -ENOSYS;
2589}
2590
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002591int sysctl_string(struct ctl_table *table, int __user *name, int nlen,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002592 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002593 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002594{
2595 return -ENOSYS;
2596}
2597
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002598int sysctl_intvec(struct ctl_table *table, int __user *name, int nlen,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002599 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002600 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002601{
2602 return -ENOSYS;
2603}
2604
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002605int sysctl_jiffies(struct ctl_table *table, int __user *name, int nlen,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002606 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002607 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002608{
2609 return -ENOSYS;
2610}
2611
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002612int sysctl_ms_jiffies(struct ctl_table *table, int __user *name, int nlen,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002613 void __user *oldval, size_t __user *oldlenp,
Alexey Dobriyan1f29bcd2006-12-10 02:19:10 -08002614 void __user *newval, size_t newlen)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002615{
2616 return -ENOSYS;
2617}
2618
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07002619#endif /* CONFIG_SYSCTL_SYSCALL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620
Eric W. Biederman7058cb02007-10-18 03:05:58 -07002621static int deprecated_sysctl_warning(struct __sysctl_args *args)
2622{
2623 static int msg_count;
2624 int name[CTL_MAXNAME];
2625 int i;
2626
Tetsuo Handa6fc48af2007-11-14 16:58:38 -08002627 /* Check args->nlen. */
2628 if (args->nlen < 0 || args->nlen > CTL_MAXNAME)
2629 return -ENOTDIR;
2630
Eric W. Biederman7058cb02007-10-18 03:05:58 -07002631 /* Read in the sysctl name for better debug message logging */
2632 for (i = 0; i < args->nlen; i++)
2633 if (get_user(name[i], args->name + i))
2634 return -EFAULT;
2635
2636 /* Ignore accesses to kernel.version */
2637 if ((args->nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
2638 return 0;
2639
2640 if (msg_count < 5) {
2641 msg_count++;
2642 printk(KERN_INFO
2643 "warning: process `%s' used the deprecated sysctl "
2644 "system call with ", current->comm);
2645 for (i = 0; i < args->nlen; i++)
2646 printk("%d.", name[i]);
2647 printk("\n");
2648 }
2649 return 0;
2650}
2651
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652/*
2653 * No sense putting this after each symbol definition, twice,
2654 * exception granted :-)
2655 */
2656EXPORT_SYMBOL(proc_dointvec);
2657EXPORT_SYMBOL(proc_dointvec_jiffies);
2658EXPORT_SYMBOL(proc_dointvec_minmax);
2659EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2660EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2661EXPORT_SYMBOL(proc_dostring);
2662EXPORT_SYMBOL(proc_doulongvec_minmax);
2663EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2664EXPORT_SYMBOL(register_sysctl_table);
2665EXPORT_SYMBOL(sysctl_intvec);
2666EXPORT_SYMBOL(sysctl_jiffies);
2667EXPORT_SYMBOL(sysctl_ms_jiffies);
2668EXPORT_SYMBOL(sysctl_string);
Eric W. Biederman49a0c452007-10-18 03:05:23 -07002669EXPORT_SYMBOL(sysctl_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002670EXPORT_SYMBOL(unregister_sysctl_table);