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