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