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