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