]> git.proxmox.com Git - mirror_ubuntu-kernels.git/blame - kernel/sysctl.c
[PATCH] sysctl: remove some OPs
[mirror_ubuntu-kernels.git] / kernel / sysctl.c
CommitLineData
1da177e4
LT
1/*
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
1da177e4
LT
21#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>
c59ede7b 27#include <linux/capability.h>
1da177e4
LT
28#include <linux/ctype.h>
29#include <linux/utsname.h>
30#include <linux/capability.h>
31#include <linux/smp_lock.h>
32#include <linux/init.h>
33#include <linux/kernel.h>
0296b228 34#include <linux/kobject.h>
20380731 35#include <linux/net.h>
1da177e4
LT
36#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>
c255d844
PM
46#include <linux/nfs_fs.h>
47#include <linux/acpi.h>
1da177e4
LT
48
49#include <asm/uaccess.h>
50#include <asm/processor.h>
51
529bf6be
DS
52extern int proc_nr_files(ctl_table *table, int write, struct file *filp,
53 void __user *buffer, size_t *lenp, loff_t *ppos);
54
29cbc78b
AK
55#ifdef CONFIG_X86
56#include <asm/nmi.h>
0741f4d2 57#include <asm/stacktrace.h>
29cbc78b
AK
58#endif
59
1da177e4
LT
60#if defined(CONFIG_SYSCTL)
61
62/* External variables not in a header file. */
63extern int C_A_D;
64extern int sysctl_overcommit_memory;
65extern int sysctl_overcommit_ratio;
fadd8fbd 66extern int sysctl_panic_on_oom;
1da177e4
LT
67extern int max_threads;
68extern int sysrq_enabled;
69extern int core_uses_pid;
d6e71144 70extern int suid_dumpable;
1da177e4 71extern char core_pattern[];
1da177e4
LT
72extern int pid_max;
73extern int min_free_kbytes;
74extern int printk_ratelimit_jiffies;
75extern int printk_ratelimit_burst;
76extern int pid_max_min, pid_max_max;
9d0243bc 77extern int sysctl_drop_caches;
8ad4b1fb 78extern int percpu_pagelist_fraction;
bebfa101 79extern int compat_log;
1da177e4 80
1da177e4
LT
81/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
82static int maxolduid = 65535;
83static int minolduid;
8ad4b1fb 84static int min_percpu_pagelist_fract = 8;
1da177e4
LT
85
86static int ngroups_max = NGROUPS_MAX;
87
88#ifdef CONFIG_KMOD
89extern char modprobe_path[];
90#endif
1da177e4
LT
91#ifdef CONFIG_CHR_DEV_SG
92extern int sg_big_buff;
93#endif
94#ifdef CONFIG_SYSVIPC
9bc9a6bd
EB
95static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
96 void __user *buffer, size_t *lenp, loff_t *ppos);
97static int proc_ipc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
fcfbd547 98 void __user *buffer, size_t *lenp, loff_t *ppos);
1da177e4
LT
99#endif
100
101#ifdef __sparc__
102extern char reboot_command [];
103extern int stop_a_enabled;
104extern int scons_pwroff;
105#endif
106
107#ifdef __hppa__
108extern int pwrsw_enabled;
109extern int unaligned_enabled;
110#endif
111
347a8dc3 112#ifdef CONFIG_S390
1da177e4
LT
113#ifdef CONFIG_MATHEMU
114extern int sysctl_ieee_emulation_warnings;
115#endif
116extern int sysctl_userprocess_debug;
951f22d5 117extern int spin_retry;
1da177e4
LT
118#endif
119
120extern int sysctl_hz_timer;
121
122#ifdef CONFIG_BSD_PROCESS_ACCT
123extern int acct_parm[];
124#endif
125
d2b176ed
JS
126#ifdef CONFIG_IA64
127extern int no_unaligned_warning;
128#endif
129
23f78d4a
IM
130#ifdef CONFIG_RT_MUTEXES
131extern int max_lock_depth;
132#endif
133
b89a8171
EB
134#ifdef CONFIG_SYSCTL_SYSCALL
135static int parse_table(int __user *, int, void __user *, size_t __user *,
136 void __user *, size_t, ctl_table *, void **);
137#endif
138
8218c74c 139static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
1da177e4
LT
140 void __user *buffer, size_t *lenp, loff_t *ppos);
141
c4b8b769
EB
142static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
143 void __user *oldval, size_t __user *oldlenp,
144 void __user *newval, size_t newlen, void **context);
145
6b49a257
EB
146#ifdef CONFIG_SYSVIPC
147static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
148 void __user *oldval, size_t __user *oldlenp,
149 void __user *newval, size_t newlen, void **context);
150#endif
151
d6f8ff73 152#ifdef CONFIG_PROC_SYSCTL
9ec52099
CLG
153static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
154 void __user *buffer, size_t *lenp, loff_t *ppos);
d6f8ff73 155#endif
9ec52099 156
1da177e4
LT
157static ctl_table root_table[];
158static struct ctl_table_header root_table_header =
159 { root_table, LIST_HEAD_INIT(root_table_header.ctl_entry) };
160
161static ctl_table kern_table[];
162static ctl_table vm_table[];
1da177e4
LT
163static ctl_table fs_table[];
164static ctl_table debug_table[];
165static ctl_table dev_table[];
166extern ctl_table random_table[];
167#ifdef CONFIG_UNIX98_PTYS
168extern ctl_table pty_table[];
169#endif
2d9048e2 170#ifdef CONFIG_INOTIFY_USER
0399cb08
RL
171extern ctl_table inotify_table[];
172#endif
1da177e4
LT
173
174#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
175int sysctl_legacy_va_layout;
176#endif
177
cf9f151c
EB
178static void *get_uts(ctl_table *table, int write)
179{
180 char *which = table->data;
181#ifdef CONFIG_UTS_NS
182 struct uts_namespace *uts_ns = current->nsproxy->uts_ns;
183 which = (which - (char *)&init_uts_ns) + (char *)uts_ns;
184#endif
185 if (!write)
186 down_read(&uts_sem);
187 else
188 down_write(&uts_sem);
189 return which;
190}
191
192static void put_uts(ctl_table *table, int write, void *which)
193{
194 if (!write)
195 up_read(&uts_sem);
196 else
197 up_write(&uts_sem);
198}
199
9bc9a6bd
EB
200#ifdef CONFIG_SYSVIPC
201static void *get_ipc(ctl_table *table, int write)
202{
203 char *which = table->data;
204 struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
205 which = (which - (char *)&init_ipc_ns) + (char *)ipc_ns;
206 return which;
207}
208#else
209#define get_ipc(T,W) ((T)->data)
210#endif
211
1da177e4
LT
212/* /proc declarations: */
213
b89a8171 214#ifdef CONFIG_PROC_SYSCTL
1da177e4
LT
215
216static ssize_t proc_readsys(struct file *, char __user *, size_t, loff_t *);
217static ssize_t proc_writesys(struct file *, const char __user *, size_t, loff_t *);
218static int proc_opensys(struct inode *, struct file *);
219
15ad7cdc 220const struct file_operations proc_sys_file_operations = {
1da177e4
LT
221 .open = proc_opensys,
222 .read = proc_readsys,
223 .write = proc_writesys,
224};
225
226extern struct proc_dir_entry *proc_sys_root;
227
330d57fb 228static void register_proc_table(ctl_table *, struct proc_dir_entry *, void *);
1da177e4
LT
229static void unregister_proc_table(ctl_table *, struct proc_dir_entry *);
230#endif
231
232/* The default sysctl tables: */
233
234static ctl_table root_table[] = {
235 {
236 .ctl_name = CTL_KERN,
237 .procname = "kernel",
238 .mode = 0555,
239 .child = kern_table,
240 },
241 {
242 .ctl_name = CTL_VM,
243 .procname = "vm",
244 .mode = 0555,
245 .child = vm_table,
246 },
247#ifdef CONFIG_NET
248 {
249 .ctl_name = CTL_NET,
250 .procname = "net",
251 .mode = 0555,
252 .child = net_table,
253 },
254#endif
1da177e4
LT
255 {
256 .ctl_name = CTL_FS,
257 .procname = "fs",
258 .mode = 0555,
259 .child = fs_table,
260 },
261 {
262 .ctl_name = CTL_DEBUG,
263 .procname = "debug",
264 .mode = 0555,
265 .child = debug_table,
266 },
267 {
268 .ctl_name = CTL_DEV,
269 .procname = "dev",
270 .mode = 0555,
271 .child = dev_table,
272 },
0eeca283 273
1da177e4
LT
274 { .ctl_name = 0 }
275};
276
277static ctl_table kern_table[] = {
278 {
279 .ctl_name = KERN_OSTYPE,
280 .procname = "ostype",
8218c74c
SH
281 .data = init_uts_ns.name.sysname,
282 .maxlen = sizeof(init_uts_ns.name.sysname),
1da177e4 283 .mode = 0444,
8218c74c 284 .proc_handler = &proc_do_uts_string,
c4b8b769 285 .strategy = &sysctl_uts_string,
1da177e4
LT
286 },
287 {
288 .ctl_name = KERN_OSRELEASE,
289 .procname = "osrelease",
8218c74c
SH
290 .data = init_uts_ns.name.release,
291 .maxlen = sizeof(init_uts_ns.name.release),
1da177e4 292 .mode = 0444,
8218c74c 293 .proc_handler = &proc_do_uts_string,
c4b8b769 294 .strategy = &sysctl_uts_string,
1da177e4
LT
295 },
296 {
297 .ctl_name = KERN_VERSION,
298 .procname = "version",
8218c74c
SH
299 .data = init_uts_ns.name.version,
300 .maxlen = sizeof(init_uts_ns.name.version),
1da177e4 301 .mode = 0444,
8218c74c 302 .proc_handler = &proc_do_uts_string,
c4b8b769 303 .strategy = &sysctl_uts_string,
1da177e4
LT
304 },
305 {
306 .ctl_name = KERN_NODENAME,
307 .procname = "hostname",
8218c74c
SH
308 .data = init_uts_ns.name.nodename,
309 .maxlen = sizeof(init_uts_ns.name.nodename),
1da177e4 310 .mode = 0644,
8218c74c 311 .proc_handler = &proc_do_uts_string,
c4b8b769 312 .strategy = &sysctl_uts_string,
1da177e4
LT
313 },
314 {
315 .ctl_name = KERN_DOMAINNAME,
316 .procname = "domainname",
8218c74c
SH
317 .data = init_uts_ns.name.domainname,
318 .maxlen = sizeof(init_uts_ns.name.domainname),
1da177e4 319 .mode = 0644,
8218c74c 320 .proc_handler = &proc_do_uts_string,
c4b8b769 321 .strategy = &sysctl_uts_string,
1da177e4
LT
322 },
323 {
324 .ctl_name = KERN_PANIC,
325 .procname = "panic",
326 .data = &panic_timeout,
327 .maxlen = sizeof(int),
328 .mode = 0644,
329 .proc_handler = &proc_dointvec,
330 },
331 {
332 .ctl_name = KERN_CORE_USES_PID,
333 .procname = "core_uses_pid",
334 .data = &core_uses_pid,
335 .maxlen = sizeof(int),
336 .mode = 0644,
337 .proc_handler = &proc_dointvec,
338 },
339 {
340 .ctl_name = KERN_CORE_PATTERN,
341 .procname = "core_pattern",
342 .data = core_pattern,
d025c9db 343 .maxlen = 128,
1da177e4
LT
344 .mode = 0644,
345 .proc_handler = &proc_dostring,
346 .strategy = &sysctl_string,
347 },
348 {
349 .ctl_name = KERN_TAINTED,
350 .procname = "tainted",
351 .data = &tainted,
352 .maxlen = sizeof(int),
353 .mode = 0444,
354 .proc_handler = &proc_dointvec,
355 },
356 {
357 .ctl_name = KERN_CAP_BSET,
358 .procname = "cap-bound",
359 .data = &cap_bset,
360 .maxlen = sizeof(kernel_cap_t),
361 .mode = 0600,
362 .proc_handler = &proc_dointvec_bset,
363 },
364#ifdef CONFIG_BLK_DEV_INITRD
365 {
366 .ctl_name = KERN_REALROOTDEV,
367 .procname = "real-root-dev",
368 .data = &real_root_dev,
369 .maxlen = sizeof(int),
370 .mode = 0644,
371 .proc_handler = &proc_dointvec,
372 },
373#endif
374#ifdef __sparc__
375 {
376 .ctl_name = KERN_SPARC_REBOOT,
377 .procname = "reboot-cmd",
378 .data = reboot_command,
379 .maxlen = 256,
380 .mode = 0644,
381 .proc_handler = &proc_dostring,
382 .strategy = &sysctl_string,
383 },
384 {
385 .ctl_name = KERN_SPARC_STOP_A,
386 .procname = "stop-a",
387 .data = &stop_a_enabled,
388 .maxlen = sizeof (int),
389 .mode = 0644,
390 .proc_handler = &proc_dointvec,
391 },
392 {
393 .ctl_name = KERN_SPARC_SCONS_PWROFF,
394 .procname = "scons-poweroff",
395 .data = &scons_pwroff,
396 .maxlen = sizeof (int),
397 .mode = 0644,
398 .proc_handler = &proc_dointvec,
399 },
400#endif
401#ifdef __hppa__
402 {
403 .ctl_name = KERN_HPPA_PWRSW,
404 .procname = "soft-power",
405 .data = &pwrsw_enabled,
406 .maxlen = sizeof (int),
407 .mode = 0644,
408 .proc_handler = &proc_dointvec,
409 },
410 {
411 .ctl_name = KERN_HPPA_UNALIGNED,
412 .procname = "unaligned-trap",
413 .data = &unaligned_enabled,
414 .maxlen = sizeof (int),
415 .mode = 0644,
416 .proc_handler = &proc_dointvec,
417 },
418#endif
419 {
420 .ctl_name = KERN_CTLALTDEL,
421 .procname = "ctrl-alt-del",
422 .data = &C_A_D,
423 .maxlen = sizeof(int),
424 .mode = 0644,
425 .proc_handler = &proc_dointvec,
426 },
427 {
428 .ctl_name = KERN_PRINTK,
429 .procname = "printk",
430 .data = &console_loglevel,
431 .maxlen = 4*sizeof(int),
432 .mode = 0644,
433 .proc_handler = &proc_dointvec,
434 },
435#ifdef CONFIG_KMOD
436 {
437 .ctl_name = KERN_MODPROBE,
438 .procname = "modprobe",
439 .data = &modprobe_path,
440 .maxlen = KMOD_PATH_LEN,
441 .mode = 0644,
442 .proc_handler = &proc_dostring,
443 .strategy = &sysctl_string,
444 },
445#endif
57ae2508 446#if defined(CONFIG_HOTPLUG) && defined(CONFIG_NET)
1da177e4
LT
447 {
448 .ctl_name = KERN_HOTPLUG,
449 .procname = "hotplug",
312c004d
KS
450 .data = &uevent_helper,
451 .maxlen = UEVENT_HELPER_PATH_LEN,
1da177e4
LT
452 .mode = 0644,
453 .proc_handler = &proc_dostring,
454 .strategy = &sysctl_string,
455 },
456#endif
457#ifdef CONFIG_CHR_DEV_SG
458 {
459 .ctl_name = KERN_SG_BIG_BUFF,
460 .procname = "sg-big-buff",
461 .data = &sg_big_buff,
462 .maxlen = sizeof (int),
463 .mode = 0444,
464 .proc_handler = &proc_dointvec,
465 },
466#endif
467#ifdef CONFIG_BSD_PROCESS_ACCT
468 {
469 .ctl_name = KERN_ACCT,
470 .procname = "acct",
471 .data = &acct_parm,
472 .maxlen = 3*sizeof(int),
473 .mode = 0644,
474 .proc_handler = &proc_dointvec,
475 },
476#endif
477#ifdef CONFIG_SYSVIPC
478 {
479 .ctl_name = KERN_SHMMAX,
480 .procname = "shmmax",
9bc9a6bd
EB
481 .data = &init_ipc_ns.shm_ctlmax,
482 .maxlen = sizeof (init_ipc_ns.shm_ctlmax),
1da177e4 483 .mode = 0644,
9bc9a6bd 484 .proc_handler = &proc_ipc_doulongvec_minmax,
6b49a257 485 .strategy = sysctl_ipc_data,
1da177e4
LT
486 },
487 {
488 .ctl_name = KERN_SHMALL,
489 .procname = "shmall",
9bc9a6bd
EB
490 .data = &init_ipc_ns.shm_ctlall,
491 .maxlen = sizeof (init_ipc_ns.shm_ctlall),
1da177e4 492 .mode = 0644,
9bc9a6bd 493 .proc_handler = &proc_ipc_doulongvec_minmax,
6b49a257 494 .strategy = sysctl_ipc_data,
1da177e4
LT
495 },
496 {
497 .ctl_name = KERN_SHMMNI,
498 .procname = "shmmni",
9bc9a6bd
EB
499 .data = &init_ipc_ns.shm_ctlmni,
500 .maxlen = sizeof (init_ipc_ns.shm_ctlmni),
1da177e4 501 .mode = 0644,
9bc9a6bd 502 .proc_handler = &proc_ipc_dointvec,
6b49a257 503 .strategy = sysctl_ipc_data,
1da177e4
LT
504 },
505 {
506 .ctl_name = KERN_MSGMAX,
507 .procname = "msgmax",
9bc9a6bd
EB
508 .data = &init_ipc_ns.msg_ctlmax,
509 .maxlen = sizeof (init_ipc_ns.msg_ctlmax),
1da177e4 510 .mode = 0644,
9bc9a6bd 511 .proc_handler = &proc_ipc_dointvec,
6b49a257 512 .strategy = sysctl_ipc_data,
1da177e4
LT
513 },
514 {
515 .ctl_name = KERN_MSGMNI,
516 .procname = "msgmni",
9bc9a6bd
EB
517 .data = &init_ipc_ns.msg_ctlmni,
518 .maxlen = sizeof (init_ipc_ns.msg_ctlmni),
1da177e4 519 .mode = 0644,
9bc9a6bd 520 .proc_handler = &proc_ipc_dointvec,
6b49a257 521 .strategy = sysctl_ipc_data,
1da177e4
LT
522 },
523 {
524 .ctl_name = KERN_MSGMNB,
525 .procname = "msgmnb",
9bc9a6bd
EB
526 .data = &init_ipc_ns.msg_ctlmnb,
527 .maxlen = sizeof (init_ipc_ns.msg_ctlmnb),
1da177e4 528 .mode = 0644,
9bc9a6bd 529 .proc_handler = &proc_ipc_dointvec,
6b49a257 530 .strategy = sysctl_ipc_data,
1da177e4
LT
531 },
532 {
533 .ctl_name = KERN_SEM,
534 .procname = "sem",
9bc9a6bd 535 .data = &init_ipc_ns.sem_ctls,
1da177e4
LT
536 .maxlen = 4*sizeof (int),
537 .mode = 0644,
9bc9a6bd 538 .proc_handler = &proc_ipc_dointvec,
6b49a257 539 .strategy = sysctl_ipc_data,
1da177e4
LT
540 },
541#endif
542#ifdef CONFIG_MAGIC_SYSRQ
543 {
544 .ctl_name = KERN_SYSRQ,
545 .procname = "sysrq",
546 .data = &sysrq_enabled,
547 .maxlen = sizeof (int),
548 .mode = 0644,
549 .proc_handler = &proc_dointvec,
550 },
551#endif
d6f8ff73 552#ifdef CONFIG_PROC_SYSCTL
1da177e4
LT
553 {
554 .ctl_name = KERN_CADPID,
555 .procname = "cad_pid",
9ec52099 556 .data = NULL,
1da177e4
LT
557 .maxlen = sizeof (int),
558 .mode = 0600,
9ec52099 559 .proc_handler = &proc_do_cad_pid,
1da177e4 560 },
d6f8ff73 561#endif
1da177e4
LT
562 {
563 .ctl_name = KERN_MAX_THREADS,
564 .procname = "threads-max",
565 .data = &max_threads,
566 .maxlen = sizeof(int),
567 .mode = 0644,
568 .proc_handler = &proc_dointvec,
569 },
570 {
571 .ctl_name = KERN_RANDOM,
572 .procname = "random",
573 .mode = 0555,
574 .child = random_table,
575 },
576#ifdef CONFIG_UNIX98_PTYS
577 {
578 .ctl_name = KERN_PTY,
579 .procname = "pty",
580 .mode = 0555,
581 .child = pty_table,
582 },
583#endif
584 {
585 .ctl_name = KERN_OVERFLOWUID,
586 .procname = "overflowuid",
587 .data = &overflowuid,
588 .maxlen = sizeof(int),
589 .mode = 0644,
590 .proc_handler = &proc_dointvec_minmax,
591 .strategy = &sysctl_intvec,
592 .extra1 = &minolduid,
593 .extra2 = &maxolduid,
594 },
595 {
596 .ctl_name = KERN_OVERFLOWGID,
597 .procname = "overflowgid",
598 .data = &overflowgid,
599 .maxlen = sizeof(int),
600 .mode = 0644,
601 .proc_handler = &proc_dointvec_minmax,
602 .strategy = &sysctl_intvec,
603 .extra1 = &minolduid,
604 .extra2 = &maxolduid,
605 },
347a8dc3 606#ifdef CONFIG_S390
1da177e4
LT
607#ifdef CONFIG_MATHEMU
608 {
609 .ctl_name = KERN_IEEE_EMULATION_WARNINGS,
610 .procname = "ieee_emulation_warnings",
611 .data = &sysctl_ieee_emulation_warnings,
612 .maxlen = sizeof(int),
613 .mode = 0644,
614 .proc_handler = &proc_dointvec,
615 },
616#endif
617#ifdef CONFIG_NO_IDLE_HZ
618 {
619 .ctl_name = KERN_HZ_TIMER,
620 .procname = "hz_timer",
621 .data = &sysctl_hz_timer,
622 .maxlen = sizeof(int),
623 .mode = 0644,
624 .proc_handler = &proc_dointvec,
625 },
626#endif
627 {
628 .ctl_name = KERN_S390_USER_DEBUG_LOGGING,
629 .procname = "userprocess_debug",
630 .data = &sysctl_userprocess_debug,
631 .maxlen = sizeof(int),
632 .mode = 0644,
633 .proc_handler = &proc_dointvec,
634 },
635#endif
636 {
637 .ctl_name = KERN_PIDMAX,
638 .procname = "pid_max",
639 .data = &pid_max,
640 .maxlen = sizeof (int),
641 .mode = 0644,
642 .proc_handler = &proc_dointvec_minmax,
643 .strategy = sysctl_intvec,
644 .extra1 = &pid_max_min,
645 .extra2 = &pid_max_max,
646 },
647 {
648 .ctl_name = KERN_PANIC_ON_OOPS,
649 .procname = "panic_on_oops",
650 .data = &panic_on_oops,
651 .maxlen = sizeof(int),
652 .mode = 0644,
653 .proc_handler = &proc_dointvec,
654 },
655 {
656 .ctl_name = KERN_PRINTK_RATELIMIT,
657 .procname = "printk_ratelimit",
658 .data = &printk_ratelimit_jiffies,
659 .maxlen = sizeof(int),
660 .mode = 0644,
661 .proc_handler = &proc_dointvec_jiffies,
662 .strategy = &sysctl_jiffies,
663 },
664 {
665 .ctl_name = KERN_PRINTK_RATELIMIT_BURST,
666 .procname = "printk_ratelimit_burst",
667 .data = &printk_ratelimit_burst,
668 .maxlen = sizeof(int),
669 .mode = 0644,
670 .proc_handler = &proc_dointvec,
671 },
672 {
673 .ctl_name = KERN_NGROUPS_MAX,
674 .procname = "ngroups_max",
675 .data = &ngroups_max,
676 .maxlen = sizeof (int),
677 .mode = 0444,
678 .proc_handler = &proc_dointvec,
679 },
680#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
681 {
682 .ctl_name = KERN_UNKNOWN_NMI_PANIC,
683 .procname = "unknown_nmi_panic",
684 .data = &unknown_nmi_panic,
685 .maxlen = sizeof (int),
686 .mode = 0644,
2fbe7b25 687 .proc_handler = &proc_dointvec,
1da177e4 688 },
407984f1
DZ
689 {
690 .ctl_name = KERN_NMI_WATCHDOG,
691 .procname = "nmi_watchdog",
692 .data = &nmi_watchdog_enabled,
693 .maxlen = sizeof (int),
694 .mode = 0644,
695 .proc_handler = &proc_nmi_enabled,
1da177e4
LT
696 },
697#endif
698#if defined(CONFIG_X86)
8da5adda
DZ
699 {
700 .ctl_name = KERN_PANIC_ON_NMI,
701 .procname = "panic_on_unrecovered_nmi",
702 .data = &panic_on_unrecovered_nmi,
703 .maxlen = sizeof(int),
704 .mode = 0644,
705 .proc_handler = &proc_dointvec,
706 },
1da177e4
LT
707 {
708 .ctl_name = KERN_BOOTLOADER_TYPE,
709 .procname = "bootloader_type",
710 .data = &bootloader_type,
711 .maxlen = sizeof (int),
712 .mode = 0444,
713 .proc_handler = &proc_dointvec,
714 },
0741f4d2
CE
715 {
716 .ctl_name = CTL_UNNUMBERED,
717 .procname = "kstack_depth_to_print",
718 .data = &kstack_depth_to_print,
719 .maxlen = sizeof(int),
720 .mode = 0644,
721 .proc_handler = &proc_dointvec,
722 },
1da177e4 723#endif
7a9166e3 724#if defined(CONFIG_MMU)
1da177e4
LT
725 {
726 .ctl_name = KERN_RANDOMIZE,
727 .procname = "randomize_va_space",
728 .data = &randomize_va_space,
729 .maxlen = sizeof(int),
730 .mode = 0644,
731 .proc_handler = &proc_dointvec,
732 },
7a9166e3 733#endif
0152fb37 734#if defined(CONFIG_S390) && defined(CONFIG_SMP)
951f22d5
MS
735 {
736 .ctl_name = KERN_SPIN_RETRY,
737 .procname = "spin_retry",
738 .data = &spin_retry,
739 .maxlen = sizeof (int),
740 .mode = 0644,
741 .proc_handler = &proc_dointvec,
742 },
c255d844
PM
743#endif
744#ifdef CONFIG_ACPI_SLEEP
745 {
746 .ctl_name = KERN_ACPI_VIDEO_FLAGS,
747 .procname = "acpi_video_flags",
748 .data = &acpi_video_flags,
749 .maxlen = sizeof (unsigned long),
750 .mode = 0644,
7f99f06f 751 .proc_handler = &proc_doulongvec_minmax,
c255d844 752 },
d2b176ed
JS
753#endif
754#ifdef CONFIG_IA64
755 {
756 .ctl_name = KERN_IA64_UNALIGNED,
757 .procname = "ignore-unaligned-usertrap",
758 .data = &no_unaligned_warning,
759 .maxlen = sizeof (int),
760 .mode = 0644,
761 .proc_handler = &proc_dointvec,
762 },
bebfa101
AK
763#endif
764#ifdef CONFIG_COMPAT
765 {
766 .ctl_name = KERN_COMPAT_LOG,
767 .procname = "compat-log",
768 .data = &compat_log,
769 .maxlen = sizeof (int),
770 .mode = 0644,
771 .proc_handler = &proc_dointvec,
772 },
951f22d5 773#endif
23f78d4a
IM
774#ifdef CONFIG_RT_MUTEXES
775 {
776 .ctl_name = KERN_MAX_LOCK_DEPTH,
777 .procname = "max_lock_depth",
778 .data = &max_lock_depth,
779 .maxlen = sizeof(int),
780 .mode = 0644,
781 .proc_handler = &proc_dointvec,
782 },
783#endif
784
1da177e4
LT
785 { .ctl_name = 0 }
786};
787
788/* Constants for minimum and maximum testing in vm_table.
789 We use these as one-element integer vectors. */
790static int zero;
791static int one_hundred = 100;
792
793
794static ctl_table vm_table[] = {
795 {
796 .ctl_name = VM_OVERCOMMIT_MEMORY,
797 .procname = "overcommit_memory",
798 .data = &sysctl_overcommit_memory,
799 .maxlen = sizeof(sysctl_overcommit_memory),
800 .mode = 0644,
801 .proc_handler = &proc_dointvec,
802 },
fadd8fbd
KH
803 {
804 .ctl_name = VM_PANIC_ON_OOM,
805 .procname = "panic_on_oom",
806 .data = &sysctl_panic_on_oom,
807 .maxlen = sizeof(sysctl_panic_on_oom),
808 .mode = 0644,
809 .proc_handler = &proc_dointvec,
810 },
1da177e4
LT
811 {
812 .ctl_name = VM_OVERCOMMIT_RATIO,
813 .procname = "overcommit_ratio",
814 .data = &sysctl_overcommit_ratio,
815 .maxlen = sizeof(sysctl_overcommit_ratio),
816 .mode = 0644,
817 .proc_handler = &proc_dointvec,
818 },
819 {
820 .ctl_name = VM_PAGE_CLUSTER,
821 .procname = "page-cluster",
822 .data = &page_cluster,
823 .maxlen = sizeof(int),
824 .mode = 0644,
825 .proc_handler = &proc_dointvec,
826 },
827 {
828 .ctl_name = VM_DIRTY_BACKGROUND,
829 .procname = "dirty_background_ratio",
830 .data = &dirty_background_ratio,
831 .maxlen = sizeof(dirty_background_ratio),
832 .mode = 0644,
833 .proc_handler = &proc_dointvec_minmax,
834 .strategy = &sysctl_intvec,
835 .extra1 = &zero,
836 .extra2 = &one_hundred,
837 },
838 {
839 .ctl_name = VM_DIRTY_RATIO,
840 .procname = "dirty_ratio",
841 .data = &vm_dirty_ratio,
842 .maxlen = sizeof(vm_dirty_ratio),
843 .mode = 0644,
844 .proc_handler = &proc_dointvec_minmax,
845 .strategy = &sysctl_intvec,
846 .extra1 = &zero,
847 .extra2 = &one_hundred,
848 },
849 {
850 .ctl_name = VM_DIRTY_WB_CS,
851 .procname = "dirty_writeback_centisecs",
f6ef9438
BS
852 .data = &dirty_writeback_interval,
853 .maxlen = sizeof(dirty_writeback_interval),
1da177e4
LT
854 .mode = 0644,
855 .proc_handler = &dirty_writeback_centisecs_handler,
856 },
857 {
858 .ctl_name = VM_DIRTY_EXPIRE_CS,
859 .procname = "dirty_expire_centisecs",
f6ef9438
BS
860 .data = &dirty_expire_interval,
861 .maxlen = sizeof(dirty_expire_interval),
1da177e4 862 .mode = 0644,
f6ef9438 863 .proc_handler = &proc_dointvec_userhz_jiffies,
1da177e4
LT
864 },
865 {
866 .ctl_name = VM_NR_PDFLUSH_THREADS,
867 .procname = "nr_pdflush_threads",
868 .data = &nr_pdflush_threads,
869 .maxlen = sizeof nr_pdflush_threads,
870 .mode = 0444 /* read-only*/,
871 .proc_handler = &proc_dointvec,
872 },
873 {
874 .ctl_name = VM_SWAPPINESS,
875 .procname = "swappiness",
876 .data = &vm_swappiness,
877 .maxlen = sizeof(vm_swappiness),
878 .mode = 0644,
879 .proc_handler = &proc_dointvec_minmax,
880 .strategy = &sysctl_intvec,
881 .extra1 = &zero,
882 .extra2 = &one_hundred,
883 },
884#ifdef CONFIG_HUGETLB_PAGE
885 {
886 .ctl_name = VM_HUGETLB_PAGES,
887 .procname = "nr_hugepages",
888 .data = &max_huge_pages,
889 .maxlen = sizeof(unsigned long),
890 .mode = 0644,
891 .proc_handler = &hugetlb_sysctl_handler,
892 .extra1 = (void *)&hugetlb_zero,
893 .extra2 = (void *)&hugetlb_infinity,
894 },
895 {
896 .ctl_name = VM_HUGETLB_GROUP,
897 .procname = "hugetlb_shm_group",
898 .data = &sysctl_hugetlb_shm_group,
899 .maxlen = sizeof(gid_t),
900 .mode = 0644,
901 .proc_handler = &proc_dointvec,
902 },
903#endif
904 {
905 .ctl_name = VM_LOWMEM_RESERVE_RATIO,
906 .procname = "lowmem_reserve_ratio",
907 .data = &sysctl_lowmem_reserve_ratio,
908 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
909 .mode = 0644,
910 .proc_handler = &lowmem_reserve_ratio_sysctl_handler,
911 .strategy = &sysctl_intvec,
912 },
9d0243bc
AM
913 {
914 .ctl_name = VM_DROP_PAGECACHE,
915 .procname = "drop_caches",
916 .data = &sysctl_drop_caches,
917 .maxlen = sizeof(int),
918 .mode = 0644,
919 .proc_handler = drop_caches_sysctl_handler,
920 .strategy = &sysctl_intvec,
921 },
1da177e4
LT
922 {
923 .ctl_name = VM_MIN_FREE_KBYTES,
924 .procname = "min_free_kbytes",
925 .data = &min_free_kbytes,
926 .maxlen = sizeof(min_free_kbytes),
927 .mode = 0644,
928 .proc_handler = &min_free_kbytes_sysctl_handler,
929 .strategy = &sysctl_intvec,
930 .extra1 = &zero,
931 },
8ad4b1fb
RS
932 {
933 .ctl_name = VM_PERCPU_PAGELIST_FRACTION,
934 .procname = "percpu_pagelist_fraction",
935 .data = &percpu_pagelist_fraction,
936 .maxlen = sizeof(percpu_pagelist_fraction),
937 .mode = 0644,
938 .proc_handler = &percpu_pagelist_fraction_sysctl_handler,
939 .strategy = &sysctl_intvec,
940 .extra1 = &min_percpu_pagelist_fract,
941 },
1da177e4
LT
942#ifdef CONFIG_MMU
943 {
944 .ctl_name = VM_MAX_MAP_COUNT,
945 .procname = "max_map_count",
946 .data = &sysctl_max_map_count,
947 .maxlen = sizeof(sysctl_max_map_count),
948 .mode = 0644,
949 .proc_handler = &proc_dointvec
950 },
951#endif
952 {
953 .ctl_name = VM_LAPTOP_MODE,
954 .procname = "laptop_mode",
955 .data = &laptop_mode,
956 .maxlen = sizeof(laptop_mode),
957 .mode = 0644,
ed5b43f1
BS
958 .proc_handler = &proc_dointvec_jiffies,
959 .strategy = &sysctl_jiffies,
1da177e4
LT
960 },
961 {
962 .ctl_name = VM_BLOCK_DUMP,
963 .procname = "block_dump",
964 .data = &block_dump,
965 .maxlen = sizeof(block_dump),
966 .mode = 0644,
967 .proc_handler = &proc_dointvec,
968 .strategy = &sysctl_intvec,
969 .extra1 = &zero,
970 },
971 {
972 .ctl_name = VM_VFS_CACHE_PRESSURE,
973 .procname = "vfs_cache_pressure",
974 .data = &sysctl_vfs_cache_pressure,
975 .maxlen = sizeof(sysctl_vfs_cache_pressure),
976 .mode = 0644,
977 .proc_handler = &proc_dointvec,
978 .strategy = &sysctl_intvec,
979 .extra1 = &zero,
980 },
981#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
982 {
983 .ctl_name = VM_LEGACY_VA_LAYOUT,
984 .procname = "legacy_va_layout",
985 .data = &sysctl_legacy_va_layout,
986 .maxlen = sizeof(sysctl_legacy_va_layout),
987 .mode = 0644,
988 .proc_handler = &proc_dointvec,
989 .strategy = &sysctl_intvec,
990 .extra1 = &zero,
991 },
992#endif
1743660b
CL
993#ifdef CONFIG_NUMA
994 {
995 .ctl_name = VM_ZONE_RECLAIM_MODE,
996 .procname = "zone_reclaim_mode",
997 .data = &zone_reclaim_mode,
998 .maxlen = sizeof(zone_reclaim_mode),
999 .mode = 0644,
1000 .proc_handler = &proc_dointvec,
c84db23c
CL
1001 .strategy = &sysctl_intvec,
1002 .extra1 = &zero,
1743660b 1003 },
9614634f
CL
1004 {
1005 .ctl_name = VM_MIN_UNMAPPED,
1006 .procname = "min_unmapped_ratio",
1007 .data = &sysctl_min_unmapped_ratio,
1008 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1009 .mode = 0644,
1010 .proc_handler = &sysctl_min_unmapped_ratio_sysctl_handler,
1011 .strategy = &sysctl_intvec,
1012 .extra1 = &zero,
1013 .extra2 = &one_hundred,
1014 },
0ff38490
CL
1015 {
1016 .ctl_name = VM_MIN_SLAB,
1017 .procname = "min_slab_ratio",
1018 .data = &sysctl_min_slab_ratio,
1019 .maxlen = sizeof(sysctl_min_slab_ratio),
1020 .mode = 0644,
1021 .proc_handler = &sysctl_min_slab_ratio_sysctl_handler,
1022 .strategy = &sysctl_intvec,
1023 .extra1 = &zero,
1024 .extra2 = &one_hundred,
1025 },
e6e5494c
IM
1026#endif
1027#ifdef CONFIG_X86_32
1028 {
1029 .ctl_name = VM_VDSO_ENABLED,
1030 .procname = "vdso_enabled",
1031 .data = &vdso_enabled,
1032 .maxlen = sizeof(vdso_enabled),
1033 .mode = 0644,
1034 .proc_handler = &proc_dointvec,
1035 .strategy = &sysctl_intvec,
1036 .extra1 = &zero,
1037 },
1da177e4
LT
1038#endif
1039 { .ctl_name = 0 }
1040};
1041
1da177e4
LT
1042static ctl_table fs_table[] = {
1043 {
1044 .ctl_name = FS_NRINODE,
1045 .procname = "inode-nr",
1046 .data = &inodes_stat,
1047 .maxlen = 2*sizeof(int),
1048 .mode = 0444,
1049 .proc_handler = &proc_dointvec,
1050 },
1051 {
1052 .ctl_name = FS_STATINODE,
1053 .procname = "inode-state",
1054 .data = &inodes_stat,
1055 .maxlen = 7*sizeof(int),
1056 .mode = 0444,
1057 .proc_handler = &proc_dointvec,
1058 },
1059 {
1060 .ctl_name = FS_NRFILE,
1061 .procname = "file-nr",
1062 .data = &files_stat,
1063 .maxlen = 3*sizeof(int),
1064 .mode = 0444,
529bf6be 1065 .proc_handler = &proc_nr_files,
1da177e4
LT
1066 },
1067 {
1068 .ctl_name = FS_MAXFILE,
1069 .procname = "file-max",
1070 .data = &files_stat.max_files,
1071 .maxlen = sizeof(int),
1072 .mode = 0644,
1073 .proc_handler = &proc_dointvec,
1074 },
1075 {
1076 .ctl_name = FS_DENTRY,
1077 .procname = "dentry-state",
1078 .data = &dentry_stat,
1079 .maxlen = 6*sizeof(int),
1080 .mode = 0444,
1081 .proc_handler = &proc_dointvec,
1082 },
1083 {
1084 .ctl_name = FS_OVERFLOWUID,
1085 .procname = "overflowuid",
1086 .data = &fs_overflowuid,
1087 .maxlen = sizeof(int),
1088 .mode = 0644,
1089 .proc_handler = &proc_dointvec_minmax,
1090 .strategy = &sysctl_intvec,
1091 .extra1 = &minolduid,
1092 .extra2 = &maxolduid,
1093 },
1094 {
1095 .ctl_name = FS_OVERFLOWGID,
1096 .procname = "overflowgid",
1097 .data = &fs_overflowgid,
1098 .maxlen = sizeof(int),
1099 .mode = 0644,
1100 .proc_handler = &proc_dointvec_minmax,
1101 .strategy = &sysctl_intvec,
1102 .extra1 = &minolduid,
1103 .extra2 = &maxolduid,
1104 },
1105 {
1106 .ctl_name = FS_LEASES,
1107 .procname = "leases-enable",
1108 .data = &leases_enable,
1109 .maxlen = sizeof(int),
1110 .mode = 0644,
1111 .proc_handler = &proc_dointvec,
1112 },
1113#ifdef CONFIG_DNOTIFY
1114 {
1115 .ctl_name = FS_DIR_NOTIFY,
1116 .procname = "dir-notify-enable",
1117 .data = &dir_notify_enable,
1118 .maxlen = sizeof(int),
1119 .mode = 0644,
1120 .proc_handler = &proc_dointvec,
1121 },
1122#endif
1123#ifdef CONFIG_MMU
1124 {
1125 .ctl_name = FS_LEASE_TIME,
1126 .procname = "lease-break-time",
1127 .data = &lease_break_time,
1128 .maxlen = sizeof(int),
1129 .mode = 0644,
1130 .proc_handler = &proc_dointvec,
1131 },
1132 {
1133 .ctl_name = FS_AIO_NR,
1134 .procname = "aio-nr",
1135 .data = &aio_nr,
1136 .maxlen = sizeof(aio_nr),
1137 .mode = 0444,
d55b5fda 1138 .proc_handler = &proc_doulongvec_minmax,
1da177e4
LT
1139 },
1140 {
1141 .ctl_name = FS_AIO_MAX_NR,
1142 .procname = "aio-max-nr",
1143 .data = &aio_max_nr,
1144 .maxlen = sizeof(aio_max_nr),
1145 .mode = 0644,
d55b5fda 1146 .proc_handler = &proc_doulongvec_minmax,
1da177e4 1147 },
2d9048e2 1148#ifdef CONFIG_INOTIFY_USER
0399cb08
RL
1149 {
1150 .ctl_name = FS_INOTIFY,
1151 .procname = "inotify",
1152 .mode = 0555,
1153 .child = inotify_table,
1154 },
1155#endif
1da177e4 1156#endif
d6e71144
AC
1157 {
1158 .ctl_name = KERN_SETUID_DUMPABLE,
1159 .procname = "suid_dumpable",
1160 .data = &suid_dumpable,
1161 .maxlen = sizeof(int),
1162 .mode = 0644,
1163 .proc_handler = &proc_dointvec,
1164 },
1da177e4
LT
1165 { .ctl_name = 0 }
1166};
1167
1168static ctl_table debug_table[] = {
1169 { .ctl_name = 0 }
1170};
1171
1172static ctl_table dev_table[] = {
1173 { .ctl_name = 0 }
0eeca283 1174};
1da177e4
LT
1175
1176extern void init_irq_proc (void);
1177
330d57fb
AV
1178static DEFINE_SPINLOCK(sysctl_lock);
1179
1180/* called under sysctl_lock */
1181static int use_table(struct ctl_table_header *p)
1182{
1183 if (unlikely(p->unregistering))
1184 return 0;
1185 p->used++;
1186 return 1;
1187}
1188
1189/* called under sysctl_lock */
1190static void unuse_table(struct ctl_table_header *p)
1191{
1192 if (!--p->used)
1193 if (unlikely(p->unregistering))
1194 complete(p->unregistering);
1195}
1196
1197/* called under sysctl_lock, will reacquire if has to wait */
1198static void start_unregistering(struct ctl_table_header *p)
1199{
1200 /*
1201 * if p->used is 0, nobody will ever touch that entry again;
1202 * we'll eliminate all paths to it before dropping sysctl_lock
1203 */
1204 if (unlikely(p->used)) {
1205 struct completion wait;
1206 init_completion(&wait);
1207 p->unregistering = &wait;
1208 spin_unlock(&sysctl_lock);
1209 wait_for_completion(&wait);
1210 spin_lock(&sysctl_lock);
1211 }
1212 /*
1213 * do not remove from the list until nobody holds it; walking the
1214 * list in do_sysctl() relies on that.
1215 */
1216 list_del_init(&p->ctl_entry);
1217}
1218
1da177e4
LT
1219void __init sysctl_init(void)
1220{
b89a8171 1221#ifdef CONFIG_PROC_SYSCTL
330d57fb 1222 register_proc_table(root_table, proc_sys_root, &root_table_header);
1da177e4
LT
1223 init_irq_proc();
1224#endif
1225}
1226
b89a8171 1227#ifdef CONFIG_SYSCTL_SYSCALL
1da177e4
LT
1228int do_sysctl(int __user *name, int nlen, void __user *oldval, size_t __user *oldlenp,
1229 void __user *newval, size_t newlen)
1230{
1231 struct list_head *tmp;
330d57fb 1232 int error = -ENOTDIR;
1da177e4
LT
1233
1234 if (nlen <= 0 || nlen >= CTL_MAXNAME)
1235 return -ENOTDIR;
1236 if (oldval) {
1237 int old_len;
1238 if (!oldlenp || get_user(old_len, oldlenp))
1239 return -EFAULT;
1240 }
330d57fb 1241 spin_lock(&sysctl_lock);
1da177e4
LT
1242 tmp = &root_table_header.ctl_entry;
1243 do {
1244 struct ctl_table_header *head =
1245 list_entry(tmp, struct ctl_table_header, ctl_entry);
1246 void *context = NULL;
330d57fb
AV
1247
1248 if (!use_table(head))
1249 continue;
1250
1251 spin_unlock(&sysctl_lock);
1252
1253 error = parse_table(name, nlen, oldval, oldlenp,
1da177e4
LT
1254 newval, newlen, head->ctl_table,
1255 &context);
5a6b454f 1256 kfree(context);
330d57fb
AV
1257
1258 spin_lock(&sysctl_lock);
1259 unuse_table(head);
1da177e4 1260 if (error != -ENOTDIR)
330d57fb
AV
1261 break;
1262 } while ((tmp = tmp->next) != &root_table_header.ctl_entry);
1263 spin_unlock(&sysctl_lock);
1264 return error;
1da177e4
LT
1265}
1266
1267asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
1268{
1269 struct __sysctl_args tmp;
1270 int error;
1271
1272 if (copy_from_user(&tmp, args, sizeof(tmp)))
1273 return -EFAULT;
1274
1275 lock_kernel();
1276 error = do_sysctl(tmp.name, tmp.nlen, tmp.oldval, tmp.oldlenp,
1277 tmp.newval, tmp.newlen);
1278 unlock_kernel();
1279 return error;
1280}
b89a8171 1281#endif /* CONFIG_SYSCTL_SYSCALL */
1da177e4
LT
1282
1283/*
1284 * ctl_perm does NOT grant the superuser all rights automatically, because
1285 * some sysctl variables are readonly even to root.
1286 */
1287
1288static int test_perm(int mode, int op)
1289{
1290 if (!current->euid)
1291 mode >>= 6;
1292 else if (in_egroup_p(0))
1293 mode >>= 3;
1294 if ((mode & op & 0007) == op)
1295 return 0;
1296 return -EACCES;
1297}
1298
1299static inline int ctl_perm(ctl_table *table, int op)
1300{
1301 int error;
1302 error = security_sysctl(table, op);
1303 if (error)
1304 return error;
1305 return test_perm(table->mode, op);
1306}
1307
b89a8171 1308#ifdef CONFIG_SYSCTL_SYSCALL
1da177e4
LT
1309static int parse_table(int __user *name, int nlen,
1310 void __user *oldval, size_t __user *oldlenp,
1311 void __user *newval, size_t newlen,
1312 ctl_table *table, void **context)
1313{
1314 int n;
1315repeat:
1316 if (!nlen)
1317 return -ENOTDIR;
1318 if (get_user(n, name))
1319 return -EFAULT;
d99f160a
EB
1320 for ( ; table->ctl_name || table->procname; table++) {
1321 if (!table->ctl_name)
1322 continue;
1da177e4
LT
1323 if (n == table->ctl_name || table->ctl_name == CTL_ANY) {
1324 int error;
1325 if (table->child) {
1326 if (ctl_perm(table, 001))
1327 return -EPERM;
1328 if (table->strategy) {
1329 error = table->strategy(
1330 table, name, nlen,
1331 oldval, oldlenp,
1332 newval, newlen, context);
1333 if (error)
1334 return error;
1335 }
1336 name++;
1337 nlen--;
1338 table = table->child;
1339 goto repeat;
1340 }
1341 error = do_sysctl_strategy(table, name, nlen,
1342 oldval, oldlenp,
1343 newval, newlen, context);
1344 return error;
1345 }
1346 }
1347 return -ENOTDIR;
1348}
1349
1350/* Perform the actual read/write of a sysctl table entry. */
1351int do_sysctl_strategy (ctl_table *table,
1352 int __user *name, int nlen,
1353 void __user *oldval, size_t __user *oldlenp,
1354 void __user *newval, size_t newlen, void **context)
1355{
1356 int op = 0, rc;
1357 size_t len;
1358
1359 if (oldval)
1360 op |= 004;
1361 if (newval)
1362 op |= 002;
1363 if (ctl_perm(table, op))
1364 return -EPERM;
1365
1366 if (table->strategy) {
1367 rc = table->strategy(table, name, nlen, oldval, oldlenp,
1368 newval, newlen, context);
1369 if (rc < 0)
1370 return rc;
1371 if (rc > 0)
1372 return 0;
1373 }
1374
1375 /* If there is no strategy routine, or if the strategy returns
1376 * zero, proceed with automatic r/w */
1377 if (table->data && table->maxlen) {
1378 if (oldval && oldlenp) {
1379 if (get_user(len, oldlenp))
1380 return -EFAULT;
1381 if (len) {
1382 if (len > table->maxlen)
1383 len = table->maxlen;
1384 if(copy_to_user(oldval, table->data, len))
1385 return -EFAULT;
1386 if(put_user(len, oldlenp))
1387 return -EFAULT;
1388 }
1389 }
1390 if (newval && newlen) {
1391 len = newlen;
1392 if (len > table->maxlen)
1393 len = table->maxlen;
1394 if(copy_from_user(table->data, newval, len))
1395 return -EFAULT;
1396 }
1397 }
1398 return 0;
1399}
b89a8171 1400#endif /* CONFIG_SYSCTL_SYSCALL */
1da177e4
LT
1401
1402/**
1403 * register_sysctl_table - register a sysctl hierarchy
1404 * @table: the top-level table structure
1405 * @insert_at_head: whether the entry should be inserted in front or at the end
1406 *
1407 * Register a sysctl table hierarchy. @table should be a filled in ctl_table
1408 * array. An entry with a ctl_name of 0 terminates the table.
1409 *
1410 * The members of the &ctl_table structure are used as follows:
1411 *
1412 * ctl_name - This is the numeric sysctl value used by sysctl(2). The number
1413 * must be unique within that level of sysctl
1414 *
1415 * procname - the name of the sysctl file under /proc/sys. Set to %NULL to not
1416 * enter a sysctl file
1417 *
1418 * data - a pointer to data for use by proc_handler
1419 *
1420 * maxlen - the maximum size in bytes of the data
1421 *
1422 * mode - the file permissions for the /proc/sys file, and for sysctl(2)
1423 *
1424 * child - a pointer to the child sysctl table if this entry is a directory, or
1425 * %NULL.
1426 *
1427 * proc_handler - the text handler routine (described below)
1428 *
1429 * strategy - the strategy routine (described below)
1430 *
1431 * de - for internal use by the sysctl routines
1432 *
1433 * extra1, extra2 - extra pointers usable by the proc handler routines
1434 *
1435 * Leaf nodes in the sysctl tree will be represented by a single file
1436 * under /proc; non-leaf nodes will be represented by directories.
1437 *
1438 * sysctl(2) can automatically manage read and write requests through
1439 * the sysctl table. The data and maxlen fields of the ctl_table
1440 * struct enable minimal validation of the values being written to be
1441 * performed, and the mode field allows minimal authentication.
1442 *
1443 * More sophisticated management can be enabled by the provision of a
1444 * strategy routine with the table entry. This will be called before
1445 * any automatic read or write of the data is performed.
1446 *
1447 * The strategy routine may return
1448 *
1449 * < 0 - Error occurred (error is passed to user process)
1450 *
1451 * 0 - OK - proceed with automatic read or write.
1452 *
1453 * > 0 - OK - read or write has been done by the strategy routine, so
1454 * return immediately.
1455 *
1456 * There must be a proc_handler routine for any terminal nodes
1457 * mirrored under /proc/sys (non-terminals are handled by a built-in
1458 * directory handler). Several default handlers are available to
1459 * cover common cases -
1460 *
1461 * proc_dostring(), proc_dointvec(), proc_dointvec_jiffies(),
1462 * proc_dointvec_userhz_jiffies(), proc_dointvec_minmax(),
1463 * proc_doulongvec_ms_jiffies_minmax(), proc_doulongvec_minmax()
1464 *
1465 * It is the handler's job to read the input buffer from user memory
1466 * and process it. The handler should return 0 on success.
1467 *
1468 * This routine returns %NULL on a failure to register, and a pointer
1469 * to the table header on success.
1470 */
1471struct ctl_table_header *register_sysctl_table(ctl_table * table,
1472 int insert_at_head)
1473{
1474 struct ctl_table_header *tmp;
1475 tmp = kmalloc(sizeof(struct ctl_table_header), GFP_KERNEL);
1476 if (!tmp)
1477 return NULL;
1478 tmp->ctl_table = table;
1479 INIT_LIST_HEAD(&tmp->ctl_entry);
330d57fb
AV
1480 tmp->used = 0;
1481 tmp->unregistering = NULL;
1482 spin_lock(&sysctl_lock);
1da177e4
LT
1483 if (insert_at_head)
1484 list_add(&tmp->ctl_entry, &root_table_header.ctl_entry);
1485 else
1486 list_add_tail(&tmp->ctl_entry, &root_table_header.ctl_entry);
330d57fb 1487 spin_unlock(&sysctl_lock);
b89a8171 1488#ifdef CONFIG_PROC_SYSCTL
330d57fb 1489 register_proc_table(table, proc_sys_root, tmp);
1da177e4
LT
1490#endif
1491 return tmp;
1492}
1493
1494/**
1495 * unregister_sysctl_table - unregister a sysctl table hierarchy
1496 * @header: the header returned from register_sysctl_table
1497 *
1498 * Unregisters the sysctl table and all children. proc entries may not
1499 * actually be removed until they are no longer used by anyone.
1500 */
1501void unregister_sysctl_table(struct ctl_table_header * header)
1502{
330d57fb
AV
1503 might_sleep();
1504 spin_lock(&sysctl_lock);
1505 start_unregistering(header);
b89a8171 1506#ifdef CONFIG_PROC_SYSCTL
1da177e4
LT
1507 unregister_proc_table(header->ctl_table, proc_sys_root);
1508#endif
330d57fb 1509 spin_unlock(&sysctl_lock);
1da177e4
LT
1510 kfree(header);
1511}
1512
b89a8171
EB
1513#else /* !CONFIG_SYSCTL */
1514struct ctl_table_header * register_sysctl_table(ctl_table * table,
1515 int insert_at_head)
1516{
1517 return NULL;
1518}
1519
1520void unregister_sysctl_table(struct ctl_table_header * table)
1521{
1522}
1523
1524#endif /* CONFIG_SYSCTL */
1525
1da177e4
LT
1526/*
1527 * /proc/sys support
1528 */
1529
b89a8171 1530#ifdef CONFIG_PROC_SYSCTL
1da177e4
LT
1531
1532/* Scan the sysctl entries in table and add them all into /proc */
330d57fb 1533static void register_proc_table(ctl_table * table, struct proc_dir_entry *root, void *set)
1da177e4
LT
1534{
1535 struct proc_dir_entry *de;
1536 int len;
1537 mode_t mode;
1538
d99f160a 1539 for (; table->ctl_name || table->procname; table++) {
1da177e4
LT
1540 /* Can't do anything without a proc name. */
1541 if (!table->procname)
1542 continue;
1543 /* Maybe we can't do anything with it... */
1544 if (!table->proc_handler && !table->child) {
1545 printk(KERN_WARNING "SYSCTL: Can't register %s\n",
1546 table->procname);
1547 continue;
1548 }
1549
1550 len = strlen(table->procname);
1551 mode = table->mode;
1552
1553 de = NULL;
1554 if (table->proc_handler)
1555 mode |= S_IFREG;
1556 else {
1557 mode |= S_IFDIR;
1558 for (de = root->subdir; de; de = de->next) {
1559 if (proc_match(len, table->procname, de))
1560 break;
1561 }
1562 /* If the subdir exists already, de is non-NULL */
1563 }
1564
1565 if (!de) {
1566 de = create_proc_entry(table->procname, mode, root);
1567 if (!de)
1568 continue;
330d57fb 1569 de->set = set;
1da177e4
LT
1570 de->data = (void *) table;
1571 if (table->proc_handler)
1572 de->proc_fops = &proc_sys_file_operations;
1573 }
1574 table->de = de;
1575 if (de->mode & S_IFDIR)
330d57fb 1576 register_proc_table(table->child, de, set);
1da177e4
LT
1577 }
1578}
1579
1580/*
1581 * Unregister a /proc sysctl table and any subdirectories.
1582 */
1583static void unregister_proc_table(ctl_table * table, struct proc_dir_entry *root)
1584{
1585 struct proc_dir_entry *de;
d99f160a 1586 for (; table->ctl_name || table->procname; table++) {
1da177e4
LT
1587 if (!(de = table->de))
1588 continue;
1589 if (de->mode & S_IFDIR) {
1590 if (!table->child) {
1591 printk (KERN_ALERT "Help - malformed sysctl tree on free\n");
1592 continue;
1593 }
1594 unregister_proc_table(table->child, de);
1595
1596 /* Don't unregister directories which still have entries.. */
1597 if (de->subdir)
1598 continue;
1599 }
1600
330d57fb
AV
1601 /*
1602 * In any case, mark the entry as goner; we'll keep it
1603 * around if it's busy, but we'll know to do nothing with
1604 * its fields. We are under sysctl_lock here.
1605 */
1606 de->data = NULL;
1607
1da177e4
LT
1608 /* Don't unregister proc entries that are still being used.. */
1609 if (atomic_read(&de->count))
1610 continue;
1611
1612 table->de = NULL;
1613 remove_proc_entry(table->procname, root);
1614 }
1615}
1616
1617static ssize_t do_rw_proc(int write, struct file * file, char __user * buf,
1618 size_t count, loff_t *ppos)
1619{
1620 int op;
f3a43f3f 1621 struct proc_dir_entry *de = PDE(file->f_path.dentry->d_inode);
1da177e4
LT
1622 struct ctl_table *table;
1623 size_t res;
330d57fb 1624 ssize_t error = -ENOTDIR;
1da177e4 1625
330d57fb
AV
1626 spin_lock(&sysctl_lock);
1627 if (de && de->data && use_table(de->set)) {
1628 /*
1629 * at that point we know that sysctl was not unregistered
1630 * and won't be until we finish
1631 */
1632 spin_unlock(&sysctl_lock);
1633 table = (struct ctl_table *) de->data;
1634 if (!table || !table->proc_handler)
1635 goto out;
1636 error = -EPERM;
1637 op = (write ? 002 : 004);
1638 if (ctl_perm(table, op))
1639 goto out;
1640
1641 /* careful: calling conventions are nasty here */
1642 res = count;
1643 error = (*table->proc_handler)(table, write, file,
1644 buf, &res, ppos);
1645 if (!error)
1646 error = res;
1647 out:
1648 spin_lock(&sysctl_lock);
1649 unuse_table(de->set);
1650 }
1651 spin_unlock(&sysctl_lock);
1652 return error;
1da177e4
LT
1653}
1654
1655static int proc_opensys(struct inode *inode, struct file *file)
1656{
1657 if (file->f_mode & FMODE_WRITE) {
1658 /*
1659 * sysctl entries that are not writable,
1660 * are _NOT_ writable, capabilities or not.
1661 */
1662 if (!(inode->i_mode & S_IWUSR))
1663 return -EPERM;
1664 }
1665
1666 return 0;
1667}
1668
1669static ssize_t proc_readsys(struct file * file, char __user * buf,
1670 size_t count, loff_t *ppos)
1671{
1672 return do_rw_proc(0, file, buf, count, ppos);
1673}
1674
1675static ssize_t proc_writesys(struct file * file, const char __user * buf,
1676 size_t count, loff_t *ppos)
1677{
1678 return do_rw_proc(1, file, (char __user *) buf, count, ppos);
1679}
1680
b1ba4ddd
AB
1681static int _proc_do_string(void* data, int maxlen, int write,
1682 struct file *filp, void __user *buffer,
1683 size_t *lenp, loff_t *ppos)
1da177e4
LT
1684{
1685 size_t len;
1686 char __user *p;
1687 char c;
1688
f5dd3d6f 1689 if (!data || !maxlen || !*lenp ||
1da177e4
LT
1690 (*ppos && !write)) {
1691 *lenp = 0;
1692 return 0;
1693 }
1694
1695 if (write) {
1696 len = 0;
1697 p = buffer;
1698 while (len < *lenp) {
1699 if (get_user(c, p++))
1700 return -EFAULT;
1701 if (c == 0 || c == '\n')
1702 break;
1703 len++;
1704 }
f5dd3d6f
SV
1705 if (len >= maxlen)
1706 len = maxlen-1;
1707 if(copy_from_user(data, buffer, len))
1da177e4 1708 return -EFAULT;
f5dd3d6f 1709 ((char *) data)[len] = 0;
1da177e4
LT
1710 *ppos += *lenp;
1711 } else {
f5dd3d6f
SV
1712 len = strlen(data);
1713 if (len > maxlen)
1714 len = maxlen;
1da177e4
LT
1715 if (len > *lenp)
1716 len = *lenp;
1717 if (len)
f5dd3d6f 1718 if(copy_to_user(buffer, data, len))
1da177e4
LT
1719 return -EFAULT;
1720 if (len < *lenp) {
1721 if(put_user('\n', ((char __user *) buffer) + len))
1722 return -EFAULT;
1723 len++;
1724 }
1725 *lenp = len;
1726 *ppos += len;
1727 }
1728 return 0;
1729}
1730
f5dd3d6f
SV
1731/**
1732 * proc_dostring - read a string sysctl
1733 * @table: the sysctl table
1734 * @write: %TRUE if this is a write to the sysctl file
1735 * @filp: the file structure
1736 * @buffer: the user buffer
1737 * @lenp: the size of the user buffer
1738 * @ppos: file position
1739 *
1740 * Reads/writes a string from/to the user buffer. If the kernel
1741 * buffer provided is not large enough to hold the string, the
1742 * string is truncated. The copied string is %NULL-terminated.
1743 * If the string is being read by the user process, it is copied
1744 * and a newline '\n' is added. It is truncated if the buffer is
1745 * not large enough.
1746 *
1747 * Returns 0 on success.
1748 */
1749int proc_dostring(ctl_table *table, int write, struct file *filp,
1750 void __user *buffer, size_t *lenp, loff_t *ppos)
1751{
1752 return _proc_do_string(table->data, table->maxlen, write, filp,
1753 buffer, lenp, ppos);
1754}
1755
1da177e4
LT
1756/*
1757 * Special case of dostring for the UTS structure. This has locks
1758 * to observe. Should this be in kernel/sys.c ????
1759 */
1da177e4 1760
8218c74c
SH
1761static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
1762 void __user *buffer, size_t *lenp, loff_t *ppos)
1763{
1764 int r;
cf9f151c
EB
1765 void *which;
1766 which = get_uts(table, write);
1767 r = _proc_do_string(which, table->maxlen,write,filp,buffer,lenp, ppos);
1768 put_uts(table, write, which);
8218c74c
SH
1769 return r;
1770}
1da177e4
LT
1771
1772static int do_proc_dointvec_conv(int *negp, unsigned long *lvalp,
1773 int *valp,
1774 int write, void *data)
1775{
1776 if (write) {
1777 *valp = *negp ? -*lvalp : *lvalp;
1778 } else {
1779 int val = *valp;
1780 if (val < 0) {
1781 *negp = -1;
1782 *lvalp = (unsigned long)-val;
1783 } else {
1784 *negp = 0;
1785 *lvalp = (unsigned long)val;
1786 }
1787 }
1788 return 0;
1789}
1790
fcfbd547
KK
1791static int __do_proc_dointvec(void *tbl_data, ctl_table *table,
1792 int write, struct file *filp, void __user *buffer,
1793 size_t *lenp, loff_t *ppos,
1da177e4
LT
1794 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1795 int write, void *data),
1796 void *data)
1797{
1798#define TMPBUFLEN 21
1799 int *i, vleft, first=1, neg, val;
1800 unsigned long lval;
1801 size_t left, len;
1802
1803 char buf[TMPBUFLEN], *p;
1804 char __user *s = buffer;
1805
fcfbd547 1806 if (!tbl_data || !table->maxlen || !*lenp ||
1da177e4
LT
1807 (*ppos && !write)) {
1808 *lenp = 0;
1809 return 0;
1810 }
1811
fcfbd547 1812 i = (int *) tbl_data;
1da177e4
LT
1813 vleft = table->maxlen / sizeof(*i);
1814 left = *lenp;
1815
1816 if (!conv)
1817 conv = do_proc_dointvec_conv;
1818
1819 for (; left && vleft--; i++, first=0) {
1820 if (write) {
1821 while (left) {
1822 char c;
1823 if (get_user(c, s))
1824 return -EFAULT;
1825 if (!isspace(c))
1826 break;
1827 left--;
1828 s++;
1829 }
1830 if (!left)
1831 break;
1832 neg = 0;
1833 len = left;
1834 if (len > sizeof(buf) - 1)
1835 len = sizeof(buf) - 1;
1836 if (copy_from_user(buf, s, len))
1837 return -EFAULT;
1838 buf[len] = 0;
1839 p = buf;
1840 if (*p == '-' && left > 1) {
1841 neg = 1;
bd9b0bac 1842 p++;
1da177e4
LT
1843 }
1844 if (*p < '0' || *p > '9')
1845 break;
1846
1847 lval = simple_strtoul(p, &p, 0);
1848
1849 len = p-buf;
1850 if ((len < left) && *p && !isspace(*p))
1851 break;
1852 if (neg)
1853 val = -val;
1854 s += len;
1855 left -= len;
1856
1857 if (conv(&neg, &lval, i, 1, data))
1858 break;
1859 } else {
1860 p = buf;
1861 if (!first)
1862 *p++ = '\t';
1863
1864 if (conv(&neg, &lval, i, 0, data))
1865 break;
1866
1867 sprintf(p, "%s%lu", neg ? "-" : "", lval);
1868 len = strlen(buf);
1869 if (len > left)
1870 len = left;
1871 if(copy_to_user(s, buf, len))
1872 return -EFAULT;
1873 left -= len;
1874 s += len;
1875 }
1876 }
1877
1878 if (!write && !first && left) {
1879 if(put_user('\n', s))
1880 return -EFAULT;
1881 left--, s++;
1882 }
1883 if (write) {
1884 while (left) {
1885 char c;
1886 if (get_user(c, s++))
1887 return -EFAULT;
1888 if (!isspace(c))
1889 break;
1890 left--;
1891 }
1892 }
1893 if (write && first)
1894 return -EINVAL;
1895 *lenp -= left;
1896 *ppos += *lenp;
1897 return 0;
1898#undef TMPBUFLEN
1899}
1900
fcfbd547
KK
1901static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
1902 void __user *buffer, size_t *lenp, loff_t *ppos,
1903 int (*conv)(int *negp, unsigned long *lvalp, int *valp,
1904 int write, void *data),
1905 void *data)
1906{
1907 return __do_proc_dointvec(table->data, table, write, filp,
1908 buffer, lenp, ppos, conv, data);
1909}
1910
1da177e4
LT
1911/**
1912 * proc_dointvec - read a vector of integers
1913 * @table: the sysctl table
1914 * @write: %TRUE if this is a write to the sysctl file
1915 * @filp: the file structure
1916 * @buffer: the user buffer
1917 * @lenp: the size of the user buffer
1918 * @ppos: file position
1919 *
1920 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
1921 * values from/to the user buffer, treated as an ASCII string.
1922 *
1923 * Returns 0 on success.
1924 */
1925int proc_dointvec(ctl_table *table, int write, struct file *filp,
1926 void __user *buffer, size_t *lenp, loff_t *ppos)
1927{
1928 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1929 NULL,NULL);
1930}
1931
1932#define OP_SET 0
1933#define OP_AND 1
1da177e4
LT
1934
1935static int do_proc_dointvec_bset_conv(int *negp, unsigned long *lvalp,
1936 int *valp,
1937 int write, void *data)
1938{
1939 int op = *(int *)data;
1940 if (write) {
1941 int val = *negp ? -*lvalp : *lvalp;
1942 switch(op) {
1943 case OP_SET: *valp = val; break;
1944 case OP_AND: *valp &= val; break;
1da177e4
LT
1945 }
1946 } else {
1947 int val = *valp;
1948 if (val < 0) {
1949 *negp = -1;
1950 *lvalp = (unsigned long)-val;
1951 } else {
1952 *negp = 0;
1953 *lvalp = (unsigned long)val;
1954 }
1955 }
1956 return 0;
1957}
1958
1959/*
1960 * init may raise the set.
1961 */
1962
1963int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
1964 void __user *buffer, size_t *lenp, loff_t *ppos)
1965{
1966 int op;
1967
1968 if (!capable(CAP_SYS_MODULE)) {
1969 return -EPERM;
1970 }
1971
f400e198 1972 op = is_init(current) ? OP_SET : OP_AND;
1da177e4
LT
1973 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
1974 do_proc_dointvec_bset_conv,&op);
1975}
1976
1977struct do_proc_dointvec_minmax_conv_param {
1978 int *min;
1979 int *max;
1980};
1981
1982static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp,
1983 int *valp,
1984 int write, void *data)
1985{
1986 struct do_proc_dointvec_minmax_conv_param *param = data;
1987 if (write) {
1988 int val = *negp ? -*lvalp : *lvalp;
1989 if ((param->min && *param->min > val) ||
1990 (param->max && *param->max < val))
1991 return -EINVAL;
1992 *valp = val;
1993 } else {
1994 int val = *valp;
1995 if (val < 0) {
1996 *negp = -1;
1997 *lvalp = (unsigned long)-val;
1998 } else {
1999 *negp = 0;
2000 *lvalp = (unsigned long)val;
2001 }
2002 }
2003 return 0;
2004}
2005
2006/**
2007 * proc_dointvec_minmax - read a vector of integers with min/max values
2008 * @table: the sysctl table
2009 * @write: %TRUE if this is a write to the sysctl file
2010 * @filp: the file structure
2011 * @buffer: the user buffer
2012 * @lenp: the size of the user buffer
2013 * @ppos: file position
2014 *
2015 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2016 * values from/to the user buffer, treated as an ASCII string.
2017 *
2018 * This routine will ensure the values are within the range specified by
2019 * table->extra1 (min) and table->extra2 (max).
2020 *
2021 * Returns 0 on success.
2022 */
2023int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2024 void __user *buffer, size_t *lenp, loff_t *ppos)
2025{
2026 struct do_proc_dointvec_minmax_conv_param param = {
2027 .min = (int *) table->extra1,
2028 .max = (int *) table->extra2,
2029 };
2030 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2031 do_proc_dointvec_minmax_conv, &param);
2032}
2033
fcfbd547 2034static int __do_proc_doulongvec_minmax(void *data, ctl_table *table, int write,
1da177e4
LT
2035 struct file *filp,
2036 void __user *buffer,
2037 size_t *lenp, loff_t *ppos,
2038 unsigned long convmul,
2039 unsigned long convdiv)
2040{
2041#define TMPBUFLEN 21
2042 unsigned long *i, *min, *max, val;
2043 int vleft, first=1, neg;
2044 size_t len, left;
2045 char buf[TMPBUFLEN], *p;
2046 char __user *s = buffer;
2047
fcfbd547 2048 if (!data || !table->maxlen || !*lenp ||
1da177e4
LT
2049 (*ppos && !write)) {
2050 *lenp = 0;
2051 return 0;
2052 }
2053
fcfbd547 2054 i = (unsigned long *) data;
1da177e4
LT
2055 min = (unsigned long *) table->extra1;
2056 max = (unsigned long *) table->extra2;
2057 vleft = table->maxlen / sizeof(unsigned long);
2058 left = *lenp;
2059
2060 for (; left && vleft--; i++, min++, max++, first=0) {
2061 if (write) {
2062 while (left) {
2063 char c;
2064 if (get_user(c, s))
2065 return -EFAULT;
2066 if (!isspace(c))
2067 break;
2068 left--;
2069 s++;
2070 }
2071 if (!left)
2072 break;
2073 neg = 0;
2074 len = left;
2075 if (len > TMPBUFLEN-1)
2076 len = TMPBUFLEN-1;
2077 if (copy_from_user(buf, s, len))
2078 return -EFAULT;
2079 buf[len] = 0;
2080 p = buf;
2081 if (*p == '-' && left > 1) {
2082 neg = 1;
bd9b0bac 2083 p++;
1da177e4
LT
2084 }
2085 if (*p < '0' || *p > '9')
2086 break;
2087 val = simple_strtoul(p, &p, 0) * convmul / convdiv ;
2088 len = p-buf;
2089 if ((len < left) && *p && !isspace(*p))
2090 break;
2091 if (neg)
2092 val = -val;
2093 s += len;
2094 left -= len;
2095
2096 if(neg)
2097 continue;
2098 if ((min && val < *min) || (max && val > *max))
2099 continue;
2100 *i = val;
2101 } else {
2102 p = buf;
2103 if (!first)
2104 *p++ = '\t';
2105 sprintf(p, "%lu", convdiv * (*i) / convmul);
2106 len = strlen(buf);
2107 if (len > left)
2108 len = left;
2109 if(copy_to_user(s, buf, len))
2110 return -EFAULT;
2111 left -= len;
2112 s += len;
2113 }
2114 }
2115
2116 if (!write && !first && left) {
2117 if(put_user('\n', s))
2118 return -EFAULT;
2119 left--, s++;
2120 }
2121 if (write) {
2122 while (left) {
2123 char c;
2124 if (get_user(c, s++))
2125 return -EFAULT;
2126 if (!isspace(c))
2127 break;
2128 left--;
2129 }
2130 }
2131 if (write && first)
2132 return -EINVAL;
2133 *lenp -= left;
2134 *ppos += *lenp;
2135 return 0;
2136#undef TMPBUFLEN
2137}
2138
fcfbd547
KK
2139static int do_proc_doulongvec_minmax(ctl_table *table, int write,
2140 struct file *filp,
2141 void __user *buffer,
2142 size_t *lenp, loff_t *ppos,
2143 unsigned long convmul,
2144 unsigned long convdiv)
2145{
2146 return __do_proc_doulongvec_minmax(table->data, table, write,
2147 filp, buffer, lenp, ppos, convmul, convdiv);
2148}
2149
1da177e4
LT
2150/**
2151 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2152 * @table: the sysctl table
2153 * @write: %TRUE if this is a write to the sysctl file
2154 * @filp: the file structure
2155 * @buffer: the user buffer
2156 * @lenp: the size of the user buffer
2157 * @ppos: file position
2158 *
2159 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2160 * values from/to the user buffer, treated as an ASCII string.
2161 *
2162 * This routine will ensure the values are within the range specified by
2163 * table->extra1 (min) and table->extra2 (max).
2164 *
2165 * Returns 0 on success.
2166 */
2167int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2168 void __user *buffer, size_t *lenp, loff_t *ppos)
2169{
2170 return do_proc_doulongvec_minmax(table, write, filp, buffer, lenp, ppos, 1l, 1l);
2171}
2172
2173/**
2174 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2175 * @table: the sysctl table
2176 * @write: %TRUE if this is a write to the sysctl file
2177 * @filp: the file structure
2178 * @buffer: the user buffer
2179 * @lenp: the size of the user buffer
2180 * @ppos: file position
2181 *
2182 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2183 * values from/to the user buffer, treated as an ASCII string. The values
2184 * are treated as milliseconds, and converted to jiffies when they are stored.
2185 *
2186 * This routine will ensure the values are within the range specified by
2187 * table->extra1 (min) and table->extra2 (max).
2188 *
2189 * Returns 0 on success.
2190 */
2191int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2192 struct file *filp,
2193 void __user *buffer,
2194 size_t *lenp, loff_t *ppos)
2195{
2196 return do_proc_doulongvec_minmax(table, write, filp, buffer,
2197 lenp, ppos, HZ, 1000l);
2198}
2199
2200
2201static int do_proc_dointvec_jiffies_conv(int *negp, unsigned long *lvalp,
2202 int *valp,
2203 int write, void *data)
2204{
2205 if (write) {
cba9f33d
BS
2206 if (*lvalp > LONG_MAX / HZ)
2207 return 1;
1da177e4
LT
2208 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2209 } else {
2210 int val = *valp;
2211 unsigned long lval;
2212 if (val < 0) {
2213 *negp = -1;
2214 lval = (unsigned long)-val;
2215 } else {
2216 *negp = 0;
2217 lval = (unsigned long)val;
2218 }
2219 *lvalp = lval / HZ;
2220 }
2221 return 0;
2222}
2223
2224static int do_proc_dointvec_userhz_jiffies_conv(int *negp, unsigned long *lvalp,
2225 int *valp,
2226 int write, void *data)
2227{
2228 if (write) {
cba9f33d
BS
2229 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2230 return 1;
1da177e4
LT
2231 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2232 } else {
2233 int val = *valp;
2234 unsigned long lval;
2235 if (val < 0) {
2236 *negp = -1;
2237 lval = (unsigned long)-val;
2238 } else {
2239 *negp = 0;
2240 lval = (unsigned long)val;
2241 }
2242 *lvalp = jiffies_to_clock_t(lval);
2243 }
2244 return 0;
2245}
2246
2247static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp,
2248 int *valp,
2249 int write, void *data)
2250{
2251 if (write) {
2252 *valp = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2253 } else {
2254 int val = *valp;
2255 unsigned long lval;
2256 if (val < 0) {
2257 *negp = -1;
2258 lval = (unsigned long)-val;
2259 } else {
2260 *negp = 0;
2261 lval = (unsigned long)val;
2262 }
2263 *lvalp = jiffies_to_msecs(lval);
2264 }
2265 return 0;
2266}
2267
2268/**
2269 * proc_dointvec_jiffies - read a vector of integers as seconds
2270 * @table: the sysctl table
2271 * @write: %TRUE if this is a write to the sysctl file
2272 * @filp: the file structure
2273 * @buffer: the user buffer
2274 * @lenp: the size of the user buffer
2275 * @ppos: file position
2276 *
2277 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2278 * values from/to the user buffer, treated as an ASCII string.
2279 * The values read are assumed to be in seconds, and are converted into
2280 * jiffies.
2281 *
2282 * Returns 0 on success.
2283 */
2284int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2285 void __user *buffer, size_t *lenp, loff_t *ppos)
2286{
2287 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2288 do_proc_dointvec_jiffies_conv,NULL);
2289}
2290
2291/**
2292 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2293 * @table: the sysctl table
2294 * @write: %TRUE if this is a write to the sysctl file
2295 * @filp: the file structure
2296 * @buffer: the user buffer
2297 * @lenp: the size of the user buffer
1e5d5331 2298 * @ppos: pointer to the file position
1da177e4
LT
2299 *
2300 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2301 * values from/to the user buffer, treated as an ASCII string.
2302 * The values read are assumed to be in 1/USER_HZ seconds, and
2303 * are converted into jiffies.
2304 *
2305 * Returns 0 on success.
2306 */
2307int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2308 void __user *buffer, size_t *lenp, loff_t *ppos)
2309{
2310 return do_proc_dointvec(table,write,filp,buffer,lenp,ppos,
2311 do_proc_dointvec_userhz_jiffies_conv,NULL);
2312}
2313
2314/**
2315 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2316 * @table: the sysctl table
2317 * @write: %TRUE if this is a write to the sysctl file
2318 * @filp: the file structure
2319 * @buffer: the user buffer
2320 * @lenp: the size of the user buffer
67be2dd1
MW
2321 * @ppos: file position
2322 * @ppos: the current position in the file
1da177e4
LT
2323 *
2324 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2325 * values from/to the user buffer, treated as an ASCII string.
2326 * The values read are assumed to be in 1/1000 seconds, and
2327 * are converted into jiffies.
2328 *
2329 * Returns 0 on success.
2330 */
2331int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2332 void __user *buffer, size_t *lenp, loff_t *ppos)
2333{
2334 return do_proc_dointvec(table, write, filp, buffer, lenp, ppos,
2335 do_proc_dointvec_ms_jiffies_conv, NULL);
2336}
2337
fcfbd547 2338#ifdef CONFIG_SYSVIPC
9bc9a6bd
EB
2339static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
2340 void __user *buffer, size_t *lenp, loff_t *ppos)
fcfbd547 2341{
9bc9a6bd
EB
2342 void *which;
2343 which = get_ipc(table, write);
2344 return __do_proc_dointvec(which, table, write, filp, buffer,
fcfbd547 2345 lenp, ppos, NULL, NULL);
9bc9a6bd
EB
2346}
2347
2348static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
2349 struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
2350{
2351 void *which;
2352 which = get_ipc(table, write);
2353 return __do_proc_doulongvec_minmax(which, table, write, filp, buffer,
fcfbd547
KK
2354 lenp, ppos, 1l, 1l);
2355}
9bc9a6bd 2356
fcfbd547
KK
2357#endif
2358
9ec52099
CLG
2359static int proc_do_cad_pid(ctl_table *table, int write, struct file *filp,
2360 void __user *buffer, size_t *lenp, loff_t *ppos)
2361{
2362 struct pid *new_pid;
2363 pid_t tmp;
2364 int r;
2365
2366 tmp = pid_nr(cad_pid);
2367
2368 r = __do_proc_dointvec(&tmp, table, write, filp, buffer,
2369 lenp, ppos, NULL, NULL);
2370 if (r || !write)
2371 return r;
2372
2373 new_pid = find_get_pid(tmp);
2374 if (!new_pid)
2375 return -ESRCH;
2376
2377 put_pid(xchg(&cad_pid, new_pid));
2378 return 0;
2379}
2380
1da177e4
LT
2381#else /* CONFIG_PROC_FS */
2382
2383int proc_dostring(ctl_table *table, int write, struct file *filp,
2384 void __user *buffer, size_t *lenp, loff_t *ppos)
2385{
2386 return -ENOSYS;
2387}
2388
8218c74c
SH
2389static int proc_do_uts_string(ctl_table *table, int write, struct file *filp,
2390 void __user *buffer, size_t *lenp, loff_t *ppos)
1da177e4
LT
2391{
2392 return -ENOSYS;
2393}
2394
8218c74c
SH
2395#ifdef CONFIG_SYSVIPC
2396static int proc_do_ipc_string(ctl_table *table, int write, struct file *filp,
2397 void __user *buffer, size_t *lenp, loff_t *ppos)
2398{
2399 return -ENOSYS;
2400}
d53ef07a
RD
2401static int proc_ipc_dointvec(ctl_table *table, int write, struct file *filp,
2402 void __user *buffer, size_t *lenp, loff_t *ppos)
2403{
2404 return -ENOSYS;
2405}
2406static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
2407 struct file *filp, void __user *buffer,
2408 size_t *lenp, loff_t *ppos)
2409{
2410 return -ENOSYS;
2411}
8218c74c
SH
2412#endif
2413
1da177e4
LT
2414int proc_dointvec(ctl_table *table, int write, struct file *filp,
2415 void __user *buffer, size_t *lenp, loff_t *ppos)
2416{
2417 return -ENOSYS;
2418}
2419
2420int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
2421 void __user *buffer, size_t *lenp, loff_t *ppos)
2422{
2423 return -ENOSYS;
2424}
2425
2426int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
2427 void __user *buffer, size_t *lenp, loff_t *ppos)
2428{
2429 return -ENOSYS;
2430}
2431
2432int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
2433 void __user *buffer, size_t *lenp, loff_t *ppos)
2434{
2435 return -ENOSYS;
2436}
2437
2438int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp,
2439 void __user *buffer, size_t *lenp, loff_t *ppos)
2440{
2441 return -ENOSYS;
2442}
2443
2444int proc_dointvec_ms_jiffies(ctl_table *table, int write, struct file *filp,
2445 void __user *buffer, size_t *lenp, loff_t *ppos)
2446{
2447 return -ENOSYS;
2448}
2449
2450int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp,
2451 void __user *buffer, size_t *lenp, loff_t *ppos)
2452{
2453 return -ENOSYS;
2454}
2455
2456int proc_doulongvec_ms_jiffies_minmax(ctl_table *table, int write,
2457 struct file *filp,
2458 void __user *buffer,
2459 size_t *lenp, loff_t *ppos)
2460{
2461 return -ENOSYS;
2462}
2463
2464
2465#endif /* CONFIG_PROC_FS */
2466
2467
b89a8171 2468#ifdef CONFIG_SYSCTL_SYSCALL
1da177e4
LT
2469/*
2470 * General sysctl support routines
2471 */
2472
2473/* The generic string strategy routine: */
2474int sysctl_string(ctl_table *table, int __user *name, int nlen,
2475 void __user *oldval, size_t __user *oldlenp,
2476 void __user *newval, size_t newlen, void **context)
2477{
1da177e4
LT
2478 if (!table->data || !table->maxlen)
2479 return -ENOTDIR;
2480
2481 if (oldval && oldlenp) {
de9e007d
LT
2482 size_t bufsize;
2483 if (get_user(bufsize, oldlenp))
1da177e4 2484 return -EFAULT;
de9e007d
LT
2485 if (bufsize) {
2486 size_t len = strlen(table->data), copied;
2487
2488 /* This shouldn't trigger for a well-formed sysctl */
2489 if (len > table->maxlen)
1da177e4 2490 len = table->maxlen;
de9e007d
LT
2491
2492 /* Copy up to a max of bufsize-1 bytes of the string */
2493 copied = (len >= bufsize) ? bufsize - 1 : len;
2494
2495 if (copy_to_user(oldval, table->data, copied) ||
2496 put_user(0, (char __user *)(oldval + copied)))
1da177e4 2497 return -EFAULT;
de9e007d 2498 if (put_user(len, oldlenp))
1da177e4
LT
2499 return -EFAULT;
2500 }
2501 }
2502 if (newval && newlen) {
de9e007d 2503 size_t len = newlen;
1da177e4
LT
2504 if (len > table->maxlen)
2505 len = table->maxlen;
2506 if(copy_from_user(table->data, newval, len))
2507 return -EFAULT;
2508 if (len == table->maxlen)
2509 len--;
2510 ((char *) table->data)[len] = 0;
2511 }
82c9df82 2512 return 1;
1da177e4
LT
2513}
2514
2515/*
2516 * This function makes sure that all of the integers in the vector
2517 * are between the minimum and maximum values given in the arrays
2518 * table->extra1 and table->extra2, respectively.
2519 */
2520int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2521 void __user *oldval, size_t __user *oldlenp,
2522 void __user *newval, size_t newlen, void **context)
2523{
2524
2525 if (newval && newlen) {
2526 int __user *vec = (int __user *) newval;
2527 int *min = (int *) table->extra1;
2528 int *max = (int *) table->extra2;
2529 size_t length;
2530 int i;
2531
2532 if (newlen % sizeof(int) != 0)
2533 return -EINVAL;
2534
2535 if (!table->extra1 && !table->extra2)
2536 return 0;
2537
2538 if (newlen > table->maxlen)
2539 newlen = table->maxlen;
2540 length = newlen / sizeof(int);
2541
2542 for (i = 0; i < length; i++) {
2543 int value;
2544 if (get_user(value, vec + i))
2545 return -EFAULT;
2546 if (min && value < min[i])
2547 return -EINVAL;
2548 if (max && value > max[i])
2549 return -EINVAL;
2550 }
2551 }
2552 return 0;
2553}
2554
2555/* Strategy function to convert jiffies to seconds */
2556int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2557 void __user *oldval, size_t __user *oldlenp,
2558 void __user *newval, size_t newlen, void **context)
2559{
2560 if (oldval) {
2561 size_t olen;
2562 if (oldlenp) {
2563 if (get_user(olen, oldlenp))
2564 return -EFAULT;
2565 if (olen!=sizeof(int))
2566 return -EINVAL;
2567 }
2568 if (put_user(*(int *)(table->data)/HZ, (int __user *)oldval) ||
2569 (oldlenp && put_user(sizeof(int),oldlenp)))
2570 return -EFAULT;
2571 }
2572 if (newval && newlen) {
2573 int new;
2574 if (newlen != sizeof(int))
2575 return -EINVAL;
2576 if (get_user(new, (int __user *)newval))
2577 return -EFAULT;
2578 *(int *)(table->data) = new*HZ;
2579 }
2580 return 1;
2581}
2582
2583/* Strategy function to convert jiffies to seconds */
2584int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2585 void __user *oldval, size_t __user *oldlenp,
2586 void __user *newval, size_t newlen, void **context)
2587{
2588 if (oldval) {
2589 size_t olen;
2590 if (oldlenp) {
2591 if (get_user(olen, oldlenp))
2592 return -EFAULT;
2593 if (olen!=sizeof(int))
2594 return -EINVAL;
2595 }
2596 if (put_user(jiffies_to_msecs(*(int *)(table->data)), (int __user *)oldval) ||
2597 (oldlenp && put_user(sizeof(int),oldlenp)))
2598 return -EFAULT;
2599 }
2600 if (newval && newlen) {
2601 int new;
2602 if (newlen != sizeof(int))
2603 return -EINVAL;
2604 if (get_user(new, (int __user *)newval))
2605 return -EFAULT;
2606 *(int *)(table->data) = msecs_to_jiffies(new);
2607 }
2608 return 1;
2609}
2610
c4b8b769
EB
2611
2612/* The generic string strategy routine: */
2613static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
2614 void __user *oldval, size_t __user *oldlenp,
2615 void __user *newval, size_t newlen, void **context)
2616{
2617 struct ctl_table uts_table;
2618 int r, write;
2619 write = newval && newlen;
2620 memcpy(&uts_table, table, sizeof(uts_table));
2621 uts_table.data = get_uts(table, write);
2622 r = sysctl_string(&uts_table, name, nlen,
2623 oldval, oldlenp, newval, newlen, context);
2624 put_uts(table, write, uts_table.data);
2625 return r;
2626}
2627
6b49a257
EB
2628#ifdef CONFIG_SYSVIPC
2629/* The generic sysctl ipc data routine. */
2630static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
2631 void __user *oldval, size_t __user *oldlenp,
2632 void __user *newval, size_t newlen, void **context)
2633{
2634 size_t len;
2635 void *data;
2636
2637 /* Get out of I don't have a variable */
2638 if (!table->data || !table->maxlen)
2639 return -ENOTDIR;
2640
2641 data = get_ipc(table, 1);
2642 if (!data)
2643 return -ENOTDIR;
2644
2645 if (oldval && oldlenp) {
2646 if (get_user(len, oldlenp))
2647 return -EFAULT;
2648 if (len) {
2649 if (len > table->maxlen)
2650 len = table->maxlen;
2651 if (copy_to_user(oldval, data, len))
2652 return -EFAULT;
2653 if (put_user(len, oldlenp))
2654 return -EFAULT;
2655 }
2656 }
2657
2658 if (newval && newlen) {
2659 if (newlen > table->maxlen)
2660 newlen = table->maxlen;
2661
2662 if (copy_from_user(data, newval, newlen))
2663 return -EFAULT;
2664 }
2665 return 1;
2666}
2667#endif
2668
b89a8171 2669#else /* CONFIG_SYSCTL_SYSCALL */
1da177e4
LT
2670
2671
2672asmlinkage long sys_sysctl(struct __sysctl_args __user *args)
2673{
b89a8171 2674 static int msg_count;
0e009be8
EB
2675 struct __sysctl_args tmp;
2676 int name[CTL_MAXNAME];
2677 int i;
2678
2679 /* Read in the sysctl name for better debug message logging */
2680 if (copy_from_user(&tmp, args, sizeof(tmp)))
2681 return -EFAULT;
2682 if (tmp.nlen <= 0 || tmp.nlen >= CTL_MAXNAME)
2683 return -ENOTDIR;
2684 for (i = 0; i < tmp.nlen; i++)
2685 if (get_user(name[i], tmp.name + i))
2686 return -EFAULT;
2687
2688 /* Ignore accesses to kernel.version */
2689 if ((tmp.nlen == 2) && (name[0] == CTL_KERN) && (name[1] == KERN_VERSION))
2690 goto out;
b89a8171
EB
2691
2692 if (msg_count < 5) {
2693 msg_count++;
2694 printk(KERN_INFO
2695 "warning: process `%s' used the removed sysctl "
0e009be8
EB
2696 "system call with ", current->comm);
2697 for (i = 0; i < tmp.nlen; i++)
2698 printk("%d.", name[i]);
2699 printk("\n");
b89a8171 2700 }
0e009be8 2701out:
1da177e4
LT
2702 return -ENOSYS;
2703}
2704
2705int sysctl_string(ctl_table *table, int __user *name, int nlen,
2706 void __user *oldval, size_t __user *oldlenp,
2707 void __user *newval, size_t newlen, void **context)
2708{
2709 return -ENOSYS;
2710}
2711
2712int sysctl_intvec(ctl_table *table, int __user *name, int nlen,
2713 void __user *oldval, size_t __user *oldlenp,
2714 void __user *newval, size_t newlen, void **context)
2715{
2716 return -ENOSYS;
2717}
2718
2719int sysctl_jiffies(ctl_table *table, int __user *name, int nlen,
2720 void __user *oldval, size_t __user *oldlenp,
2721 void __user *newval, size_t newlen, void **context)
2722{
2723 return -ENOSYS;
2724}
2725
2726int sysctl_ms_jiffies(ctl_table *table, int __user *name, int nlen,
2727 void __user *oldval, size_t __user *oldlenp,
2728 void __user *newval, size_t newlen, void **context)
2729{
2730 return -ENOSYS;
2731}
2732
c4b8b769
EB
2733static int sysctl_uts_string(ctl_table *table, int __user *name, int nlen,
2734 void __user *oldval, size_t __user *oldlenp,
2735 void __user *newval, size_t newlen, void **context)
2736{
2737 return -ENOSYS;
2738}
6b49a257
EB
2739static int sysctl_ipc_data(ctl_table *table, int __user *name, int nlen,
2740 void __user *oldval, size_t __user *oldlenp,
2741 void __user *newval, size_t newlen, void **context)
2742{
2743 return -ENOSYS;
2744}
b89a8171 2745#endif /* CONFIG_SYSCTL_SYSCALL */
1da177e4
LT
2746
2747/*
2748 * No sense putting this after each symbol definition, twice,
2749 * exception granted :-)
2750 */
2751EXPORT_SYMBOL(proc_dointvec);
2752EXPORT_SYMBOL(proc_dointvec_jiffies);
2753EXPORT_SYMBOL(proc_dointvec_minmax);
2754EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2755EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2756EXPORT_SYMBOL(proc_dostring);
2757EXPORT_SYMBOL(proc_doulongvec_minmax);
2758EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
2759EXPORT_SYMBOL(register_sysctl_table);
2760EXPORT_SYMBOL(sysctl_intvec);
2761EXPORT_SYMBOL(sysctl_jiffies);
2762EXPORT_SYMBOL(sysctl_ms_jiffies);
2763EXPORT_SYMBOL(sysctl_string);
2764EXPORT_SYMBOL(unregister_sysctl_table);