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