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