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