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