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