tcp: add tcp_min_snd_mss sysctl
[linux-stable.git] / kernel / sysctl.c
blobcfc2c0d1369abc38c5added70a2040adef9504ed
1 /*
2 * sysctl.c: General linux system control interface
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
21 #include <linux/module.h>
22 #include <linux/aio.h>
23 #include <linux/mm.h>
24 #include <linux/swap.h>
25 #include <linux/slab.h>
26 #include <linux/sysctl.h>
27 #include <linux/bitmap.h>
28 #include <linux/signal.h>
29 #include <linux/printk.h>
30 #include <linux/proc_fs.h>
31 #include <linux/security.h>
32 #include <linux/ctype.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/sched/coredump.h>
66 #include <linux/kexec.h>
67 #include <linux/bpf.h>
68 #include <linux/mount.h>
70 #include <linux/uaccess.h>
71 #include <asm/processor.h>
73 #ifdef CONFIG_X86
74 #include <asm/nmi.h>
75 #include <asm/stacktrace.h>
76 #include <asm/io.h>
77 #endif
78 #ifdef CONFIG_SPARC
79 #include <asm/setup.h>
80 #endif
81 #ifdef CONFIG_BSD_PROCESS_ACCT
82 #include <linux/acct.h>
83 #endif
84 #ifdef CONFIG_RT_MUTEXES
85 #include <linux/rtmutex.h>
86 #endif
87 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
88 #include <linux/lockdep.h>
89 #endif
90 #ifdef CONFIG_CHR_DEV_SG
91 #include <scsi/sg.h>
92 #endif
94 #ifdef CONFIG_LOCKUP_DETECTOR
95 #include <linux/nmi.h>
96 #endif
98 #if defined(CONFIG_SYSCTL)
100 /* External variables not in a header file. */
101 extern int suid_dumpable;
102 #ifdef CONFIG_COREDUMP
103 extern int core_uses_pid;
104 extern char core_pattern[];
105 extern unsigned int core_pipe_limit;
106 #endif
107 extern int pid_max;
108 extern int pid_max_min, pid_max_max;
109 extern int percpu_pagelist_fraction;
110 extern int latencytop_enabled;
111 extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
112 #ifndef CONFIG_MMU
113 extern int sysctl_nr_trim_pages;
114 #endif
116 /* Constants used for minimum and maximum */
117 #ifdef CONFIG_LOCKUP_DETECTOR
118 static int sixty = 60;
119 #endif
121 static int __maybe_unused neg_one = -1;
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 zero_ul;
128 static unsigned long one_ul = 1;
129 static unsigned long long_max = LONG_MAX;
130 static int one_hundred = 100;
131 static int one_thousand = 1000;
132 #ifdef CONFIG_PRINTK
133 static int ten_thousand = 10000;
134 #endif
135 #ifdef CONFIG_PERF_EVENTS
136 static int six_hundred_forty_kb = 640 * 1024;
137 #endif
139 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
140 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
142 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
143 static int maxolduid = 65535;
144 static int minolduid;
146 static int ngroups_max = NGROUPS_MAX;
147 static const int cap_last_cap = CAP_LAST_CAP;
149 /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
150 #ifdef CONFIG_DETECT_HUNG_TASK
151 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
152 #endif
154 #ifdef CONFIG_INOTIFY_USER
155 #include <linux/inotify.h>
156 #endif
157 #ifdef CONFIG_SPARC
158 #endif
160 #ifdef __hppa__
161 extern int pwrsw_enabled;
162 #endif
164 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
165 extern int unaligned_enabled;
166 #endif
168 #ifdef CONFIG_IA64
169 extern int unaligned_dump_stack;
170 #endif
172 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
173 extern int no_unaligned_warning;
174 #endif
176 #ifdef CONFIG_PROC_SYSCTL
179 * enum sysctl_writes_mode - supported sysctl write modes
181 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
182 * to be written, and multiple writes on the same sysctl file descriptor
183 * will rewrite the sysctl value, regardless of file position. No warning
184 * is issued when the initial position is not 0.
185 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
186 * not 0.
187 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
188 * file position 0 and the value must be fully contained in the buffer
189 * sent to the write syscall. If dealing with strings respect the file
190 * position, but restrict this to the max length of the buffer, anything
191 * passed the max lenght will be ignored. Multiple writes will append
192 * to the buffer.
194 * These write modes control how current file position affects the behavior of
195 * updating sysctl values through the proc interface on each write.
197 enum sysctl_writes_mode {
198 SYSCTL_WRITES_LEGACY = -1,
199 SYSCTL_WRITES_WARN = 0,
200 SYSCTL_WRITES_STRICT = 1,
203 static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
205 static int proc_do_cad_pid(struct ctl_table *table, int write,
206 void __user *buffer, size_t *lenp, loff_t *ppos);
207 static int proc_taint(struct ctl_table *table, int write,
208 void __user *buffer, size_t *lenp, loff_t *ppos);
209 #endif
211 #ifdef CONFIG_PRINTK
212 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
213 void __user *buffer, size_t *lenp, loff_t *ppos);
214 #endif
216 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
217 void __user *buffer, size_t *lenp, loff_t *ppos);
218 #ifdef CONFIG_COREDUMP
219 static int proc_dostring_coredump(struct ctl_table *table, int write,
220 void __user *buffer, size_t *lenp, loff_t *ppos);
221 #endif
223 #ifdef CONFIG_MAGIC_SYSRQ
224 /* Note: sysrq code uses it's own private copy */
225 static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
227 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
228 void __user *buffer, size_t *lenp,
229 loff_t *ppos)
231 int error;
233 error = proc_dointvec(table, write, buffer, lenp, ppos);
234 if (error)
235 return error;
237 if (write)
238 sysrq_toggle_support(__sysrq_enabled);
240 return 0;
243 #endif
245 static struct ctl_table kern_table[];
246 static struct ctl_table vm_table[];
247 static struct ctl_table fs_table[];
248 static struct ctl_table debug_table[];
249 static struct ctl_table dev_table[];
250 extern struct ctl_table random_table[];
251 #ifdef CONFIG_EPOLL
252 extern struct ctl_table epoll_table[];
253 #endif
255 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
256 int sysctl_legacy_va_layout;
257 #endif
259 /* The default sysctl tables: */
261 static struct ctl_table sysctl_base_table[] = {
263 .procname = "kernel",
264 .mode = 0555,
265 .child = kern_table,
268 .procname = "vm",
269 .mode = 0555,
270 .child = vm_table,
273 .procname = "fs",
274 .mode = 0555,
275 .child = fs_table,
278 .procname = "debug",
279 .mode = 0555,
280 .child = debug_table,
283 .procname = "dev",
284 .mode = 0555,
285 .child = dev_table,
290 #ifdef CONFIG_SCHED_DEBUG
291 static int min_sched_granularity_ns = 100000; /* 100 usecs */
292 static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
293 static int min_wakeup_granularity_ns; /* 0 usecs */
294 static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
295 #ifdef CONFIG_SMP
296 static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
297 static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
298 #endif /* CONFIG_SMP */
299 #endif /* CONFIG_SCHED_DEBUG */
301 #ifdef CONFIG_COMPACTION
302 static int min_extfrag_threshold;
303 static int max_extfrag_threshold = 1000;
304 #endif
306 static struct ctl_table kern_table[] = {
308 .procname = "sched_child_runs_first",
309 .data = &sysctl_sched_child_runs_first,
310 .maxlen = sizeof(unsigned int),
311 .mode = 0644,
312 .proc_handler = proc_dointvec,
314 #ifdef CONFIG_SCHED_DEBUG
316 .procname = "sched_min_granularity_ns",
317 .data = &sysctl_sched_min_granularity,
318 .maxlen = sizeof(unsigned int),
319 .mode = 0644,
320 .proc_handler = sched_proc_update_handler,
321 .extra1 = &min_sched_granularity_ns,
322 .extra2 = &max_sched_granularity_ns,
325 .procname = "sched_latency_ns",
326 .data = &sysctl_sched_latency,
327 .maxlen = sizeof(unsigned int),
328 .mode = 0644,
329 .proc_handler = sched_proc_update_handler,
330 .extra1 = &min_sched_granularity_ns,
331 .extra2 = &max_sched_granularity_ns,
334 .procname = "sched_wakeup_granularity_ns",
335 .data = &sysctl_sched_wakeup_granularity,
336 .maxlen = sizeof(unsigned int),
337 .mode = 0644,
338 .proc_handler = sched_proc_update_handler,
339 .extra1 = &min_wakeup_granularity_ns,
340 .extra2 = &max_wakeup_granularity_ns,
342 #ifdef CONFIG_SMP
344 .procname = "sched_tunable_scaling",
345 .data = &sysctl_sched_tunable_scaling,
346 .maxlen = sizeof(enum sched_tunable_scaling),
347 .mode = 0644,
348 .proc_handler = sched_proc_update_handler,
349 .extra1 = &min_sched_tunable_scaling,
350 .extra2 = &max_sched_tunable_scaling,
353 .procname = "sched_migration_cost_ns",
354 .data = &sysctl_sched_migration_cost,
355 .maxlen = sizeof(unsigned int),
356 .mode = 0644,
357 .proc_handler = proc_dointvec,
360 .procname = "sched_nr_migrate",
361 .data = &sysctl_sched_nr_migrate,
362 .maxlen = sizeof(unsigned int),
363 .mode = 0644,
364 .proc_handler = proc_dointvec,
367 .procname = "sched_time_avg_ms",
368 .data = &sysctl_sched_time_avg,
369 .maxlen = sizeof(unsigned int),
370 .mode = 0644,
371 .proc_handler = proc_dointvec_minmax,
372 .extra1 = &one,
374 #ifdef CONFIG_SCHEDSTATS
376 .procname = "sched_schedstats",
377 .data = NULL,
378 .maxlen = sizeof(unsigned int),
379 .mode = 0644,
380 .proc_handler = sysctl_schedstats,
381 .extra1 = &zero,
382 .extra2 = &one,
384 #endif /* CONFIG_SCHEDSTATS */
385 #endif /* CONFIG_SMP */
386 #ifdef CONFIG_NUMA_BALANCING
388 .procname = "numa_balancing_scan_delay_ms",
389 .data = &sysctl_numa_balancing_scan_delay,
390 .maxlen = sizeof(unsigned int),
391 .mode = 0644,
392 .proc_handler = proc_dointvec,
395 .procname = "numa_balancing_scan_period_min_ms",
396 .data = &sysctl_numa_balancing_scan_period_min,
397 .maxlen = sizeof(unsigned int),
398 .mode = 0644,
399 .proc_handler = proc_dointvec,
402 .procname = "numa_balancing_scan_period_max_ms",
403 .data = &sysctl_numa_balancing_scan_period_max,
404 .maxlen = sizeof(unsigned int),
405 .mode = 0644,
406 .proc_handler = proc_dointvec,
409 .procname = "numa_balancing_scan_size_mb",
410 .data = &sysctl_numa_balancing_scan_size,
411 .maxlen = sizeof(unsigned int),
412 .mode = 0644,
413 .proc_handler = proc_dointvec_minmax,
414 .extra1 = &one,
417 .procname = "numa_balancing",
418 .data = NULL, /* filled in by handler */
419 .maxlen = sizeof(unsigned int),
420 .mode = 0644,
421 .proc_handler = sysctl_numa_balancing,
422 .extra1 = &zero,
423 .extra2 = &one,
425 #endif /* CONFIG_NUMA_BALANCING */
426 #endif /* CONFIG_SCHED_DEBUG */
428 .procname = "sched_rt_period_us",
429 .data = &sysctl_sched_rt_period,
430 .maxlen = sizeof(unsigned int),
431 .mode = 0644,
432 .proc_handler = sched_rt_handler,
435 .procname = "sched_rt_runtime_us",
436 .data = &sysctl_sched_rt_runtime,
437 .maxlen = sizeof(int),
438 .mode = 0644,
439 .proc_handler = sched_rt_handler,
442 .procname = "sched_rr_timeslice_ms",
443 .data = &sysctl_sched_rr_timeslice,
444 .maxlen = sizeof(int),
445 .mode = 0644,
446 .proc_handler = sched_rr_handler,
448 #ifdef CONFIG_SCHED_AUTOGROUP
450 .procname = "sched_autogroup_enabled",
451 .data = &sysctl_sched_autogroup_enabled,
452 .maxlen = sizeof(unsigned int),
453 .mode = 0644,
454 .proc_handler = proc_dointvec_minmax,
455 .extra1 = &zero,
456 .extra2 = &one,
458 #endif
459 #ifdef CONFIG_CFS_BANDWIDTH
461 .procname = "sched_cfs_bandwidth_slice_us",
462 .data = &sysctl_sched_cfs_bandwidth_slice,
463 .maxlen = sizeof(unsigned int),
464 .mode = 0644,
465 .proc_handler = proc_dointvec_minmax,
466 .extra1 = &one,
468 #endif
469 #ifdef CONFIG_PROVE_LOCKING
471 .procname = "prove_locking",
472 .data = &prove_locking,
473 .maxlen = sizeof(int),
474 .mode = 0644,
475 .proc_handler = proc_dointvec,
477 #endif
478 #ifdef CONFIG_LOCK_STAT
480 .procname = "lock_stat",
481 .data = &lock_stat,
482 .maxlen = sizeof(int),
483 .mode = 0644,
484 .proc_handler = proc_dointvec,
486 #endif
488 .procname = "panic",
489 .data = &panic_timeout,
490 .maxlen = sizeof(int),
491 .mode = 0644,
492 .proc_handler = proc_dointvec,
494 #ifdef CONFIG_COREDUMP
496 .procname = "core_uses_pid",
497 .data = &core_uses_pid,
498 .maxlen = sizeof(int),
499 .mode = 0644,
500 .proc_handler = proc_dointvec,
503 .procname = "core_pattern",
504 .data = core_pattern,
505 .maxlen = CORENAME_MAX_SIZE,
506 .mode = 0644,
507 .proc_handler = proc_dostring_coredump,
510 .procname = "core_pipe_limit",
511 .data = &core_pipe_limit,
512 .maxlen = sizeof(unsigned int),
513 .mode = 0644,
514 .proc_handler = proc_dointvec,
516 #endif
517 #ifdef CONFIG_PROC_SYSCTL
519 .procname = "tainted",
520 .maxlen = sizeof(long),
521 .mode = 0644,
522 .proc_handler = proc_taint,
525 .procname = "sysctl_writes_strict",
526 .data = &sysctl_writes_strict,
527 .maxlen = sizeof(int),
528 .mode = 0644,
529 .proc_handler = proc_dointvec_minmax,
530 .extra1 = &neg_one,
531 .extra2 = &one,
533 #endif
534 #ifdef CONFIG_LATENCYTOP
536 .procname = "latencytop",
537 .data = &latencytop_enabled,
538 .maxlen = sizeof(int),
539 .mode = 0644,
540 .proc_handler = sysctl_latencytop,
542 #endif
543 #ifdef CONFIG_BLK_DEV_INITRD
545 .procname = "real-root-dev",
546 .data = &real_root_dev,
547 .maxlen = sizeof(int),
548 .mode = 0644,
549 .proc_handler = proc_dointvec,
551 #endif
553 .procname = "print-fatal-signals",
554 .data = &print_fatal_signals,
555 .maxlen = sizeof(int),
556 .mode = 0644,
557 .proc_handler = proc_dointvec,
559 #ifdef CONFIG_SPARC
561 .procname = "reboot-cmd",
562 .data = reboot_command,
563 .maxlen = 256,
564 .mode = 0644,
565 .proc_handler = proc_dostring,
568 .procname = "stop-a",
569 .data = &stop_a_enabled,
570 .maxlen = sizeof (int),
571 .mode = 0644,
572 .proc_handler = proc_dointvec,
575 .procname = "scons-poweroff",
576 .data = &scons_pwroff,
577 .maxlen = sizeof (int),
578 .mode = 0644,
579 .proc_handler = proc_dointvec,
581 #endif
582 #ifdef CONFIG_SPARC64
584 .procname = "tsb-ratio",
585 .data = &sysctl_tsb_ratio,
586 .maxlen = sizeof (int),
587 .mode = 0644,
588 .proc_handler = proc_dointvec,
590 #endif
591 #ifdef __hppa__
593 .procname = "soft-power",
594 .data = &pwrsw_enabled,
595 .maxlen = sizeof (int),
596 .mode = 0644,
597 .proc_handler = proc_dointvec,
599 #endif
600 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
602 .procname = "unaligned-trap",
603 .data = &unaligned_enabled,
604 .maxlen = sizeof (int),
605 .mode = 0644,
606 .proc_handler = proc_dointvec,
608 #endif
610 .procname = "ctrl-alt-del",
611 .data = &C_A_D,
612 .maxlen = sizeof(int),
613 .mode = 0644,
614 .proc_handler = proc_dointvec,
616 #ifdef CONFIG_FUNCTION_TRACER
618 .procname = "ftrace_enabled",
619 .data = &ftrace_enabled,
620 .maxlen = sizeof(int),
621 .mode = 0644,
622 .proc_handler = ftrace_enable_sysctl,
624 #endif
625 #ifdef CONFIG_STACK_TRACER
627 .procname = "stack_tracer_enabled",
628 .data = &stack_tracer_enabled,
629 .maxlen = sizeof(int),
630 .mode = 0644,
631 .proc_handler = stack_trace_sysctl,
633 #endif
634 #ifdef CONFIG_TRACING
636 .procname = "ftrace_dump_on_oops",
637 .data = &ftrace_dump_on_oops,
638 .maxlen = sizeof(int),
639 .mode = 0644,
640 .proc_handler = proc_dointvec,
643 .procname = "traceoff_on_warning",
644 .data = &__disable_trace_on_warning,
645 .maxlen = sizeof(__disable_trace_on_warning),
646 .mode = 0644,
647 .proc_handler = proc_dointvec,
650 .procname = "tracepoint_printk",
651 .data = &tracepoint_printk,
652 .maxlen = sizeof(tracepoint_printk),
653 .mode = 0644,
654 .proc_handler = tracepoint_printk_sysctl,
656 #endif
657 #ifdef CONFIG_KEXEC_CORE
659 .procname = "kexec_load_disabled",
660 .data = &kexec_load_disabled,
661 .maxlen = sizeof(int),
662 .mode = 0644,
663 /* only handle a transition from default "0" to "1" */
664 .proc_handler = proc_dointvec_minmax,
665 .extra1 = &one,
666 .extra2 = &one,
668 #endif
669 #ifdef CONFIG_MODULES
671 .procname = "modprobe",
672 .data = &modprobe_path,
673 .maxlen = KMOD_PATH_LEN,
674 .mode = 0644,
675 .proc_handler = proc_dostring,
678 .procname = "modules_disabled",
679 .data = &modules_disabled,
680 .maxlen = sizeof(int),
681 .mode = 0644,
682 /* only handle a transition from default "0" to "1" */
683 .proc_handler = proc_dointvec_minmax,
684 .extra1 = &one,
685 .extra2 = &one,
687 #endif
688 #ifdef CONFIG_UEVENT_HELPER
690 .procname = "hotplug",
691 .data = &uevent_helper,
692 .maxlen = UEVENT_HELPER_PATH_LEN,
693 .mode = 0644,
694 .proc_handler = proc_dostring,
696 #endif
697 #ifdef CONFIG_CHR_DEV_SG
699 .procname = "sg-big-buff",
700 .data = &sg_big_buff,
701 .maxlen = sizeof (int),
702 .mode = 0444,
703 .proc_handler = proc_dointvec,
705 #endif
706 #ifdef CONFIG_BSD_PROCESS_ACCT
708 .procname = "acct",
709 .data = &acct_parm,
710 .maxlen = 3*sizeof(int),
711 .mode = 0644,
712 .proc_handler = proc_dointvec,
714 #endif
715 #ifdef CONFIG_MAGIC_SYSRQ
717 .procname = "sysrq",
718 .data = &__sysrq_enabled,
719 .maxlen = sizeof (int),
720 .mode = 0644,
721 .proc_handler = sysrq_sysctl_handler,
723 #endif
724 #ifdef CONFIG_PROC_SYSCTL
726 .procname = "cad_pid",
727 .data = NULL,
728 .maxlen = sizeof (int),
729 .mode = 0600,
730 .proc_handler = proc_do_cad_pid,
732 #endif
734 .procname = "threads-max",
735 .data = NULL,
736 .maxlen = sizeof(int),
737 .mode = 0644,
738 .proc_handler = sysctl_max_threads,
741 .procname = "random",
742 .mode = 0555,
743 .child = random_table,
746 .procname = "usermodehelper",
747 .mode = 0555,
748 .child = usermodehelper_table,
751 .procname = "overflowuid",
752 .data = &overflowuid,
753 .maxlen = sizeof(int),
754 .mode = 0644,
755 .proc_handler = proc_dointvec_minmax,
756 .extra1 = &minolduid,
757 .extra2 = &maxolduid,
760 .procname = "overflowgid",
761 .data = &overflowgid,
762 .maxlen = sizeof(int),
763 .mode = 0644,
764 .proc_handler = proc_dointvec_minmax,
765 .extra1 = &minolduid,
766 .extra2 = &maxolduid,
768 #ifdef CONFIG_S390
769 #ifdef CONFIG_MATHEMU
771 .procname = "ieee_emulation_warnings",
772 .data = &sysctl_ieee_emulation_warnings,
773 .maxlen = sizeof(int),
774 .mode = 0644,
775 .proc_handler = proc_dointvec,
777 #endif
779 .procname = "userprocess_debug",
780 .data = &show_unhandled_signals,
781 .maxlen = sizeof(int),
782 .mode = 0644,
783 .proc_handler = proc_dointvec,
785 #endif
787 .procname = "pid_max",
788 .data = &pid_max,
789 .maxlen = sizeof (int),
790 .mode = 0644,
791 .proc_handler = proc_dointvec_minmax,
792 .extra1 = &pid_max_min,
793 .extra2 = &pid_max_max,
796 .procname = "panic_on_oops",
797 .data = &panic_on_oops,
798 .maxlen = sizeof(int),
799 .mode = 0644,
800 .proc_handler = proc_dointvec,
802 #if defined CONFIG_PRINTK
804 .procname = "printk",
805 .data = &console_loglevel,
806 .maxlen = 4*sizeof(int),
807 .mode = 0644,
808 .proc_handler = proc_dointvec,
811 .procname = "printk_ratelimit",
812 .data = &printk_ratelimit_state.interval,
813 .maxlen = sizeof(int),
814 .mode = 0644,
815 .proc_handler = proc_dointvec_jiffies,
818 .procname = "printk_ratelimit_burst",
819 .data = &printk_ratelimit_state.burst,
820 .maxlen = sizeof(int),
821 .mode = 0644,
822 .proc_handler = proc_dointvec,
825 .procname = "printk_delay",
826 .data = &printk_delay_msec,
827 .maxlen = sizeof(int),
828 .mode = 0644,
829 .proc_handler = proc_dointvec_minmax,
830 .extra1 = &zero,
831 .extra2 = &ten_thousand,
834 .procname = "printk_devkmsg",
835 .data = devkmsg_log_str,
836 .maxlen = DEVKMSG_STR_MAX_SIZE,
837 .mode = 0644,
838 .proc_handler = devkmsg_sysctl_set_loglvl,
841 .procname = "dmesg_restrict",
842 .data = &dmesg_restrict,
843 .maxlen = sizeof(int),
844 .mode = 0644,
845 .proc_handler = proc_dointvec_minmax_sysadmin,
846 .extra1 = &zero,
847 .extra2 = &one,
850 .procname = "kptr_restrict",
851 .data = &kptr_restrict,
852 .maxlen = sizeof(int),
853 .mode = 0644,
854 .proc_handler = proc_dointvec_minmax_sysadmin,
855 .extra1 = &zero,
856 .extra2 = &two,
858 #endif
860 .procname = "ngroups_max",
861 .data = &ngroups_max,
862 .maxlen = sizeof (int),
863 .mode = 0444,
864 .proc_handler = proc_dointvec,
867 .procname = "cap_last_cap",
868 .data = (void *)&cap_last_cap,
869 .maxlen = sizeof(int),
870 .mode = 0444,
871 .proc_handler = proc_dointvec,
873 #if defined(CONFIG_LOCKUP_DETECTOR)
875 .procname = "watchdog",
876 .data = &watchdog_user_enabled,
877 .maxlen = sizeof(int),
878 .mode = 0644,
879 .proc_handler = proc_watchdog,
880 .extra1 = &zero,
881 .extra2 = &one,
884 .procname = "watchdog_thresh",
885 .data = &watchdog_thresh,
886 .maxlen = sizeof(int),
887 .mode = 0644,
888 .proc_handler = proc_watchdog_thresh,
889 .extra1 = &zero,
890 .extra2 = &sixty,
893 .procname = "nmi_watchdog",
894 .data = &nmi_watchdog_user_enabled,
895 .maxlen = sizeof(int),
896 .mode = NMI_WATCHDOG_SYSCTL_PERM,
897 .proc_handler = proc_nmi_watchdog,
898 .extra1 = &zero,
899 .extra2 = &one,
902 .procname = "watchdog_cpumask",
903 .data = &watchdog_cpumask_bits,
904 .maxlen = NR_CPUS,
905 .mode = 0644,
906 .proc_handler = proc_watchdog_cpumask,
908 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
910 .procname = "soft_watchdog",
911 .data = &soft_watchdog_user_enabled,
912 .maxlen = sizeof(int),
913 .mode = 0644,
914 .proc_handler = proc_soft_watchdog,
915 .extra1 = &zero,
916 .extra2 = &one,
919 .procname = "softlockup_panic",
920 .data = &softlockup_panic,
921 .maxlen = sizeof(int),
922 .mode = 0644,
923 .proc_handler = proc_dointvec_minmax,
924 .extra1 = &zero,
925 .extra2 = &one,
927 #ifdef CONFIG_SMP
929 .procname = "softlockup_all_cpu_backtrace",
930 .data = &sysctl_softlockup_all_cpu_backtrace,
931 .maxlen = sizeof(int),
932 .mode = 0644,
933 .proc_handler = proc_dointvec_minmax,
934 .extra1 = &zero,
935 .extra2 = &one,
937 #endif /* CONFIG_SMP */
938 #endif
939 #ifdef CONFIG_HARDLOCKUP_DETECTOR
941 .procname = "hardlockup_panic",
942 .data = &hardlockup_panic,
943 .maxlen = sizeof(int),
944 .mode = 0644,
945 .proc_handler = proc_dointvec_minmax,
946 .extra1 = &zero,
947 .extra2 = &one,
949 #ifdef CONFIG_SMP
951 .procname = "hardlockup_all_cpu_backtrace",
952 .data = &sysctl_hardlockup_all_cpu_backtrace,
953 .maxlen = sizeof(int),
954 .mode = 0644,
955 .proc_handler = proc_dointvec_minmax,
956 .extra1 = &zero,
957 .extra2 = &one,
959 #endif /* CONFIG_SMP */
960 #endif
961 #endif
963 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
965 .procname = "unknown_nmi_panic",
966 .data = &unknown_nmi_panic,
967 .maxlen = sizeof (int),
968 .mode = 0644,
969 .proc_handler = proc_dointvec,
971 #endif
972 #if defined(CONFIG_X86)
974 .procname = "panic_on_unrecovered_nmi",
975 .data = &panic_on_unrecovered_nmi,
976 .maxlen = sizeof(int),
977 .mode = 0644,
978 .proc_handler = proc_dointvec,
981 .procname = "panic_on_io_nmi",
982 .data = &panic_on_io_nmi,
983 .maxlen = sizeof(int),
984 .mode = 0644,
985 .proc_handler = proc_dointvec,
987 #ifdef CONFIG_DEBUG_STACKOVERFLOW
989 .procname = "panic_on_stackoverflow",
990 .data = &sysctl_panic_on_stackoverflow,
991 .maxlen = sizeof(int),
992 .mode = 0644,
993 .proc_handler = proc_dointvec,
995 #endif
997 .procname = "bootloader_type",
998 .data = &bootloader_type,
999 .maxlen = sizeof (int),
1000 .mode = 0444,
1001 .proc_handler = proc_dointvec,
1004 .procname = "bootloader_version",
1005 .data = &bootloader_version,
1006 .maxlen = sizeof (int),
1007 .mode = 0444,
1008 .proc_handler = proc_dointvec,
1011 .procname = "io_delay_type",
1012 .data = &io_delay_type,
1013 .maxlen = sizeof(int),
1014 .mode = 0644,
1015 .proc_handler = proc_dointvec,
1017 #endif
1018 #if defined(CONFIG_MMU)
1020 .procname = "randomize_va_space",
1021 .data = &randomize_va_space,
1022 .maxlen = sizeof(int),
1023 .mode = 0644,
1024 .proc_handler = proc_dointvec,
1026 #endif
1027 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1029 .procname = "spin_retry",
1030 .data = &spin_retry,
1031 .maxlen = sizeof (int),
1032 .mode = 0644,
1033 .proc_handler = proc_dointvec,
1035 #endif
1036 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1038 .procname = "acpi_video_flags",
1039 .data = &acpi_realmode_flags,
1040 .maxlen = sizeof (unsigned long),
1041 .mode = 0644,
1042 .proc_handler = proc_doulongvec_minmax,
1044 #endif
1045 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1047 .procname = "ignore-unaligned-usertrap",
1048 .data = &no_unaligned_warning,
1049 .maxlen = sizeof (int),
1050 .mode = 0644,
1051 .proc_handler = proc_dointvec,
1053 #endif
1054 #ifdef CONFIG_IA64
1056 .procname = "unaligned-dump-stack",
1057 .data = &unaligned_dump_stack,
1058 .maxlen = sizeof (int),
1059 .mode = 0644,
1060 .proc_handler = proc_dointvec,
1062 #endif
1063 #ifdef CONFIG_DETECT_HUNG_TASK
1065 .procname = "hung_task_panic",
1066 .data = &sysctl_hung_task_panic,
1067 .maxlen = sizeof(int),
1068 .mode = 0644,
1069 .proc_handler = proc_dointvec_minmax,
1070 .extra1 = &zero,
1071 .extra2 = &one,
1074 .procname = "hung_task_check_count",
1075 .data = &sysctl_hung_task_check_count,
1076 .maxlen = sizeof(int),
1077 .mode = 0644,
1078 .proc_handler = proc_dointvec_minmax,
1079 .extra1 = &zero,
1082 .procname = "hung_task_timeout_secs",
1083 .data = &sysctl_hung_task_timeout_secs,
1084 .maxlen = sizeof(unsigned long),
1085 .mode = 0644,
1086 .proc_handler = proc_dohung_task_timeout_secs,
1087 .extra2 = &hung_task_timeout_max,
1090 .procname = "hung_task_warnings",
1091 .data = &sysctl_hung_task_warnings,
1092 .maxlen = sizeof(int),
1093 .mode = 0644,
1094 .proc_handler = proc_dointvec_minmax,
1095 .extra1 = &neg_one,
1097 #endif
1098 #ifdef CONFIG_RT_MUTEXES
1100 .procname = "max_lock_depth",
1101 .data = &max_lock_depth,
1102 .maxlen = sizeof(int),
1103 .mode = 0644,
1104 .proc_handler = proc_dointvec,
1106 #endif
1108 .procname = "poweroff_cmd",
1109 .data = &poweroff_cmd,
1110 .maxlen = POWEROFF_CMD_PATH_LEN,
1111 .mode = 0644,
1112 .proc_handler = proc_dostring,
1114 #ifdef CONFIG_KEYS
1116 .procname = "keys",
1117 .mode = 0555,
1118 .child = key_sysctls,
1120 #endif
1121 #ifdef CONFIG_PERF_EVENTS
1123 * User-space scripts rely on the existence of this file
1124 * as a feature check for perf_events being enabled.
1126 * So it's an ABI, do not remove!
1129 .procname = "perf_event_paranoid",
1130 .data = &sysctl_perf_event_paranoid,
1131 .maxlen = sizeof(sysctl_perf_event_paranoid),
1132 .mode = 0644,
1133 .proc_handler = proc_dointvec,
1136 .procname = "perf_event_mlock_kb",
1137 .data = &sysctl_perf_event_mlock,
1138 .maxlen = sizeof(sysctl_perf_event_mlock),
1139 .mode = 0644,
1140 .proc_handler = proc_dointvec,
1143 .procname = "perf_event_max_sample_rate",
1144 .data = &sysctl_perf_event_sample_rate,
1145 .maxlen = sizeof(sysctl_perf_event_sample_rate),
1146 .mode = 0644,
1147 .proc_handler = perf_proc_update_handler,
1148 .extra1 = &one,
1151 .procname = "perf_cpu_time_max_percent",
1152 .data = &sysctl_perf_cpu_time_max_percent,
1153 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1154 .mode = 0644,
1155 .proc_handler = perf_cpu_time_max_percent_handler,
1156 .extra1 = &zero,
1157 .extra2 = &one_hundred,
1160 .procname = "perf_event_max_stack",
1161 .data = &sysctl_perf_event_max_stack,
1162 .maxlen = sizeof(sysctl_perf_event_max_stack),
1163 .mode = 0644,
1164 .proc_handler = perf_event_max_stack_handler,
1165 .extra1 = &zero,
1166 .extra2 = &six_hundred_forty_kb,
1169 .procname = "perf_event_max_contexts_per_stack",
1170 .data = &sysctl_perf_event_max_contexts_per_stack,
1171 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1172 .mode = 0644,
1173 .proc_handler = perf_event_max_stack_handler,
1174 .extra1 = &zero,
1175 .extra2 = &one_thousand,
1177 #endif
1179 .procname = "panic_on_warn",
1180 .data = &panic_on_warn,
1181 .maxlen = sizeof(int),
1182 .mode = 0644,
1183 .proc_handler = proc_dointvec_minmax,
1184 .extra1 = &zero,
1185 .extra2 = &one,
1187 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1189 .procname = "timer_migration",
1190 .data = &sysctl_timer_migration,
1191 .maxlen = sizeof(unsigned int),
1192 .mode = 0644,
1193 .proc_handler = timer_migration_handler,
1194 .extra1 = &zero,
1195 .extra2 = &one,
1197 #endif
1198 #ifdef CONFIG_BPF_SYSCALL
1200 .procname = "unprivileged_bpf_disabled",
1201 .data = &sysctl_unprivileged_bpf_disabled,
1202 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1203 .mode = 0644,
1204 /* only handle a transition from default "0" to "1" */
1205 .proc_handler = proc_dointvec_minmax,
1206 .extra1 = &one,
1207 .extra2 = &one,
1209 #endif
1210 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1212 .procname = "panic_on_rcu_stall",
1213 .data = &sysctl_panic_on_rcu_stall,
1214 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1215 .mode = 0644,
1216 .proc_handler = proc_dointvec_minmax,
1217 .extra1 = &zero,
1218 .extra2 = &one,
1220 #endif
1224 static struct ctl_table vm_table[] = {
1226 .procname = "overcommit_memory",
1227 .data = &sysctl_overcommit_memory,
1228 .maxlen = sizeof(sysctl_overcommit_memory),
1229 .mode = 0644,
1230 .proc_handler = proc_dointvec_minmax,
1231 .extra1 = &zero,
1232 .extra2 = &two,
1235 .procname = "panic_on_oom",
1236 .data = &sysctl_panic_on_oom,
1237 .maxlen = sizeof(sysctl_panic_on_oom),
1238 .mode = 0644,
1239 .proc_handler = proc_dointvec_minmax,
1240 .extra1 = &zero,
1241 .extra2 = &two,
1244 .procname = "oom_kill_allocating_task",
1245 .data = &sysctl_oom_kill_allocating_task,
1246 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1247 .mode = 0644,
1248 .proc_handler = proc_dointvec,
1251 .procname = "oom_dump_tasks",
1252 .data = &sysctl_oom_dump_tasks,
1253 .maxlen = sizeof(sysctl_oom_dump_tasks),
1254 .mode = 0644,
1255 .proc_handler = proc_dointvec,
1258 .procname = "overcommit_ratio",
1259 .data = &sysctl_overcommit_ratio,
1260 .maxlen = sizeof(sysctl_overcommit_ratio),
1261 .mode = 0644,
1262 .proc_handler = overcommit_ratio_handler,
1265 .procname = "overcommit_kbytes",
1266 .data = &sysctl_overcommit_kbytes,
1267 .maxlen = sizeof(sysctl_overcommit_kbytes),
1268 .mode = 0644,
1269 .proc_handler = overcommit_kbytes_handler,
1272 .procname = "page-cluster",
1273 .data = &page_cluster,
1274 .maxlen = sizeof(int),
1275 .mode = 0644,
1276 .proc_handler = proc_dointvec_minmax,
1277 .extra1 = &zero,
1280 .procname = "dirty_background_ratio",
1281 .data = &dirty_background_ratio,
1282 .maxlen = sizeof(dirty_background_ratio),
1283 .mode = 0644,
1284 .proc_handler = dirty_background_ratio_handler,
1285 .extra1 = &zero,
1286 .extra2 = &one_hundred,
1289 .procname = "dirty_background_bytes",
1290 .data = &dirty_background_bytes,
1291 .maxlen = sizeof(dirty_background_bytes),
1292 .mode = 0644,
1293 .proc_handler = dirty_background_bytes_handler,
1294 .extra1 = &one_ul,
1297 .procname = "dirty_ratio",
1298 .data = &vm_dirty_ratio,
1299 .maxlen = sizeof(vm_dirty_ratio),
1300 .mode = 0644,
1301 .proc_handler = dirty_ratio_handler,
1302 .extra1 = &zero,
1303 .extra2 = &one_hundred,
1306 .procname = "dirty_bytes",
1307 .data = &vm_dirty_bytes,
1308 .maxlen = sizeof(vm_dirty_bytes),
1309 .mode = 0644,
1310 .proc_handler = dirty_bytes_handler,
1311 .extra1 = &dirty_bytes_min,
1314 .procname = "dirty_writeback_centisecs",
1315 .data = &dirty_writeback_interval,
1316 .maxlen = sizeof(dirty_writeback_interval),
1317 .mode = 0644,
1318 .proc_handler = dirty_writeback_centisecs_handler,
1321 .procname = "dirty_expire_centisecs",
1322 .data = &dirty_expire_interval,
1323 .maxlen = sizeof(dirty_expire_interval),
1324 .mode = 0644,
1325 .proc_handler = proc_dointvec_minmax,
1326 .extra1 = &zero,
1329 .procname = "dirtytime_expire_seconds",
1330 .data = &dirtytime_expire_interval,
1331 .maxlen = sizeof(dirty_expire_interval),
1332 .mode = 0644,
1333 .proc_handler = dirtytime_interval_handler,
1334 .extra1 = &zero,
1337 .procname = "nr_pdflush_threads",
1338 .mode = 0444 /* read-only */,
1339 .proc_handler = pdflush_proc_obsolete,
1342 .procname = "swappiness",
1343 .data = &vm_swappiness,
1344 .maxlen = sizeof(vm_swappiness),
1345 .mode = 0644,
1346 .proc_handler = proc_dointvec_minmax,
1347 .extra1 = &zero,
1348 .extra2 = &one_hundred,
1350 #ifdef CONFIG_HUGETLB_PAGE
1352 .procname = "nr_hugepages",
1353 .data = NULL,
1354 .maxlen = sizeof(unsigned long),
1355 .mode = 0644,
1356 .proc_handler = hugetlb_sysctl_handler,
1358 #ifdef CONFIG_NUMA
1360 .procname = "nr_hugepages_mempolicy",
1361 .data = NULL,
1362 .maxlen = sizeof(unsigned long),
1363 .mode = 0644,
1364 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1366 #endif
1368 .procname = "hugetlb_shm_group",
1369 .data = &sysctl_hugetlb_shm_group,
1370 .maxlen = sizeof(gid_t),
1371 .mode = 0644,
1372 .proc_handler = proc_dointvec,
1375 .procname = "hugepages_treat_as_movable",
1376 .data = &hugepages_treat_as_movable,
1377 .maxlen = sizeof(int),
1378 .mode = 0644,
1379 .proc_handler = proc_dointvec,
1382 .procname = "nr_overcommit_hugepages",
1383 .data = NULL,
1384 .maxlen = sizeof(unsigned long),
1385 .mode = 0644,
1386 .proc_handler = hugetlb_overcommit_handler,
1388 #endif
1390 .procname = "lowmem_reserve_ratio",
1391 .data = &sysctl_lowmem_reserve_ratio,
1392 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1393 .mode = 0644,
1394 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
1397 .procname = "drop_caches",
1398 .data = &sysctl_drop_caches,
1399 .maxlen = sizeof(int),
1400 .mode = 0644,
1401 .proc_handler = drop_caches_sysctl_handler,
1402 .extra1 = &one,
1403 .extra2 = &four,
1405 #ifdef CONFIG_COMPACTION
1407 .procname = "compact_memory",
1408 .data = &sysctl_compact_memory,
1409 .maxlen = sizeof(int),
1410 .mode = 0200,
1411 .proc_handler = sysctl_compaction_handler,
1414 .procname = "extfrag_threshold",
1415 .data = &sysctl_extfrag_threshold,
1416 .maxlen = sizeof(int),
1417 .mode = 0644,
1418 .proc_handler = sysctl_extfrag_handler,
1419 .extra1 = &min_extfrag_threshold,
1420 .extra2 = &max_extfrag_threshold,
1423 .procname = "compact_unevictable_allowed",
1424 .data = &sysctl_compact_unevictable_allowed,
1425 .maxlen = sizeof(int),
1426 .mode = 0644,
1427 .proc_handler = proc_dointvec,
1428 .extra1 = &zero,
1429 .extra2 = &one,
1432 #endif /* CONFIG_COMPACTION */
1434 .procname = "min_free_kbytes",
1435 .data = &min_free_kbytes,
1436 .maxlen = sizeof(min_free_kbytes),
1437 .mode = 0644,
1438 .proc_handler = min_free_kbytes_sysctl_handler,
1439 .extra1 = &zero,
1442 .procname = "watermark_scale_factor",
1443 .data = &watermark_scale_factor,
1444 .maxlen = sizeof(watermark_scale_factor),
1445 .mode = 0644,
1446 .proc_handler = watermark_scale_factor_sysctl_handler,
1447 .extra1 = &one,
1448 .extra2 = &one_thousand,
1451 .procname = "percpu_pagelist_fraction",
1452 .data = &percpu_pagelist_fraction,
1453 .maxlen = sizeof(percpu_pagelist_fraction),
1454 .mode = 0644,
1455 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
1456 .extra1 = &zero,
1458 #ifdef CONFIG_MMU
1460 .procname = "max_map_count",
1461 .data = &sysctl_max_map_count,
1462 .maxlen = sizeof(sysctl_max_map_count),
1463 .mode = 0644,
1464 .proc_handler = proc_dointvec_minmax,
1465 .extra1 = &zero,
1467 #else
1469 .procname = "nr_trim_pages",
1470 .data = &sysctl_nr_trim_pages,
1471 .maxlen = sizeof(sysctl_nr_trim_pages),
1472 .mode = 0644,
1473 .proc_handler = proc_dointvec_minmax,
1474 .extra1 = &zero,
1476 #endif
1478 .procname = "laptop_mode",
1479 .data = &laptop_mode,
1480 .maxlen = sizeof(laptop_mode),
1481 .mode = 0644,
1482 .proc_handler = proc_dointvec_jiffies,
1485 .procname = "block_dump",
1486 .data = &block_dump,
1487 .maxlen = sizeof(block_dump),
1488 .mode = 0644,
1489 .proc_handler = proc_dointvec,
1490 .extra1 = &zero,
1493 .procname = "vfs_cache_pressure",
1494 .data = &sysctl_vfs_cache_pressure,
1495 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1496 .mode = 0644,
1497 .proc_handler = proc_dointvec,
1498 .extra1 = &zero,
1500 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1502 .procname = "legacy_va_layout",
1503 .data = &sysctl_legacy_va_layout,
1504 .maxlen = sizeof(sysctl_legacy_va_layout),
1505 .mode = 0644,
1506 .proc_handler = proc_dointvec,
1507 .extra1 = &zero,
1509 #endif
1510 #ifdef CONFIG_NUMA
1512 .procname = "zone_reclaim_mode",
1513 .data = &node_reclaim_mode,
1514 .maxlen = sizeof(node_reclaim_mode),
1515 .mode = 0644,
1516 .proc_handler = proc_dointvec,
1517 .extra1 = &zero,
1520 .procname = "min_unmapped_ratio",
1521 .data = &sysctl_min_unmapped_ratio,
1522 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1523 .mode = 0644,
1524 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
1525 .extra1 = &zero,
1526 .extra2 = &one_hundred,
1529 .procname = "min_slab_ratio",
1530 .data = &sysctl_min_slab_ratio,
1531 .maxlen = sizeof(sysctl_min_slab_ratio),
1532 .mode = 0644,
1533 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
1534 .extra1 = &zero,
1535 .extra2 = &one_hundred,
1537 #endif
1538 #ifdef CONFIG_SMP
1540 .procname = "stat_interval",
1541 .data = &sysctl_stat_interval,
1542 .maxlen = sizeof(sysctl_stat_interval),
1543 .mode = 0644,
1544 .proc_handler = proc_dointvec_jiffies,
1547 .procname = "stat_refresh",
1548 .data = NULL,
1549 .maxlen = 0,
1550 .mode = 0600,
1551 .proc_handler = vmstat_refresh,
1553 #endif
1554 #ifdef CONFIG_MMU
1556 .procname = "mmap_min_addr",
1557 .data = &dac_mmap_min_addr,
1558 .maxlen = sizeof(unsigned long),
1559 .mode = 0644,
1560 .proc_handler = mmap_min_addr_handler,
1562 #endif
1563 #ifdef CONFIG_NUMA
1565 .procname = "numa_zonelist_order",
1566 .data = &numa_zonelist_order,
1567 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1568 .mode = 0644,
1569 .proc_handler = numa_zonelist_order_handler,
1571 #endif
1572 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1573 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1575 .procname = "vdso_enabled",
1576 #ifdef CONFIG_X86_32
1577 .data = &vdso32_enabled,
1578 .maxlen = sizeof(vdso32_enabled),
1579 #else
1580 .data = &vdso_enabled,
1581 .maxlen = sizeof(vdso_enabled),
1582 #endif
1583 .mode = 0644,
1584 .proc_handler = proc_dointvec,
1585 .extra1 = &zero,
1587 #endif
1588 #ifdef CONFIG_HIGHMEM
1590 .procname = "highmem_is_dirtyable",
1591 .data = &vm_highmem_is_dirtyable,
1592 .maxlen = sizeof(vm_highmem_is_dirtyable),
1593 .mode = 0644,
1594 .proc_handler = proc_dointvec_minmax,
1595 .extra1 = &zero,
1596 .extra2 = &one,
1598 #endif
1599 #ifdef CONFIG_MEMORY_FAILURE
1601 .procname = "memory_failure_early_kill",
1602 .data = &sysctl_memory_failure_early_kill,
1603 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1604 .mode = 0644,
1605 .proc_handler = proc_dointvec_minmax,
1606 .extra1 = &zero,
1607 .extra2 = &one,
1610 .procname = "memory_failure_recovery",
1611 .data = &sysctl_memory_failure_recovery,
1612 .maxlen = sizeof(sysctl_memory_failure_recovery),
1613 .mode = 0644,
1614 .proc_handler = proc_dointvec_minmax,
1615 .extra1 = &zero,
1616 .extra2 = &one,
1618 #endif
1620 .procname = "user_reserve_kbytes",
1621 .data = &sysctl_user_reserve_kbytes,
1622 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1623 .mode = 0644,
1624 .proc_handler = proc_doulongvec_minmax,
1627 .procname = "admin_reserve_kbytes",
1628 .data = &sysctl_admin_reserve_kbytes,
1629 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1630 .mode = 0644,
1631 .proc_handler = proc_doulongvec_minmax,
1633 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1635 .procname = "mmap_rnd_bits",
1636 .data = &mmap_rnd_bits,
1637 .maxlen = sizeof(mmap_rnd_bits),
1638 .mode = 0600,
1639 .proc_handler = proc_dointvec_minmax,
1640 .extra1 = (void *)&mmap_rnd_bits_min,
1641 .extra2 = (void *)&mmap_rnd_bits_max,
1643 #endif
1644 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1646 .procname = "mmap_rnd_compat_bits",
1647 .data = &mmap_rnd_compat_bits,
1648 .maxlen = sizeof(mmap_rnd_compat_bits),
1649 .mode = 0600,
1650 .proc_handler = proc_dointvec_minmax,
1651 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1652 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1654 #endif
1658 static struct ctl_table fs_table[] = {
1660 .procname = "inode-nr",
1661 .data = &inodes_stat,
1662 .maxlen = 2*sizeof(long),
1663 .mode = 0444,
1664 .proc_handler = proc_nr_inodes,
1667 .procname = "inode-state",
1668 .data = &inodes_stat,
1669 .maxlen = 7*sizeof(long),
1670 .mode = 0444,
1671 .proc_handler = proc_nr_inodes,
1674 .procname = "file-nr",
1675 .data = &files_stat,
1676 .maxlen = sizeof(files_stat),
1677 .mode = 0444,
1678 .proc_handler = proc_nr_files,
1681 .procname = "file-max",
1682 .data = &files_stat.max_files,
1683 .maxlen = sizeof(files_stat.max_files),
1684 .mode = 0644,
1685 .proc_handler = proc_doulongvec_minmax,
1686 .extra1 = &zero_ul,
1687 .extra2 = &long_max,
1690 .procname = "nr_open",
1691 .data = &sysctl_nr_open,
1692 .maxlen = sizeof(unsigned int),
1693 .mode = 0644,
1694 .proc_handler = proc_dointvec_minmax,
1695 .extra1 = &sysctl_nr_open_min,
1696 .extra2 = &sysctl_nr_open_max,
1699 .procname = "dentry-state",
1700 .data = &dentry_stat,
1701 .maxlen = 6*sizeof(long),
1702 .mode = 0444,
1703 .proc_handler = proc_nr_dentry,
1706 .procname = "overflowuid",
1707 .data = &fs_overflowuid,
1708 .maxlen = sizeof(int),
1709 .mode = 0644,
1710 .proc_handler = proc_dointvec_minmax,
1711 .extra1 = &minolduid,
1712 .extra2 = &maxolduid,
1715 .procname = "overflowgid",
1716 .data = &fs_overflowgid,
1717 .maxlen = sizeof(int),
1718 .mode = 0644,
1719 .proc_handler = proc_dointvec_minmax,
1720 .extra1 = &minolduid,
1721 .extra2 = &maxolduid,
1723 #ifdef CONFIG_FILE_LOCKING
1725 .procname = "leases-enable",
1726 .data = &leases_enable,
1727 .maxlen = sizeof(int),
1728 .mode = 0644,
1729 .proc_handler = proc_dointvec,
1731 #endif
1732 #ifdef CONFIG_DNOTIFY
1734 .procname = "dir-notify-enable",
1735 .data = &dir_notify_enable,
1736 .maxlen = sizeof(int),
1737 .mode = 0644,
1738 .proc_handler = proc_dointvec,
1740 #endif
1741 #ifdef CONFIG_MMU
1742 #ifdef CONFIG_FILE_LOCKING
1744 .procname = "lease-break-time",
1745 .data = &lease_break_time,
1746 .maxlen = sizeof(int),
1747 .mode = 0644,
1748 .proc_handler = proc_dointvec,
1750 #endif
1751 #ifdef CONFIG_AIO
1753 .procname = "aio-nr",
1754 .data = &aio_nr,
1755 .maxlen = sizeof(aio_nr),
1756 .mode = 0444,
1757 .proc_handler = proc_doulongvec_minmax,
1760 .procname = "aio-max-nr",
1761 .data = &aio_max_nr,
1762 .maxlen = sizeof(aio_max_nr),
1763 .mode = 0644,
1764 .proc_handler = proc_doulongvec_minmax,
1766 #endif /* CONFIG_AIO */
1767 #ifdef CONFIG_INOTIFY_USER
1769 .procname = "inotify",
1770 .mode = 0555,
1771 .child = inotify_table,
1773 #endif
1774 #ifdef CONFIG_EPOLL
1776 .procname = "epoll",
1777 .mode = 0555,
1778 .child = epoll_table,
1780 #endif
1781 #endif
1783 .procname = "protected_symlinks",
1784 .data = &sysctl_protected_symlinks,
1785 .maxlen = sizeof(int),
1786 .mode = 0600,
1787 .proc_handler = proc_dointvec_minmax,
1788 .extra1 = &zero,
1789 .extra2 = &one,
1792 .procname = "protected_hardlinks",
1793 .data = &sysctl_protected_hardlinks,
1794 .maxlen = sizeof(int),
1795 .mode = 0600,
1796 .proc_handler = proc_dointvec_minmax,
1797 .extra1 = &zero,
1798 .extra2 = &one,
1801 .procname = "protected_fifos",
1802 .data = &sysctl_protected_fifos,
1803 .maxlen = sizeof(int),
1804 .mode = 0600,
1805 .proc_handler = proc_dointvec_minmax,
1806 .extra1 = &zero,
1807 .extra2 = &two,
1810 .procname = "protected_regular",
1811 .data = &sysctl_protected_regular,
1812 .maxlen = sizeof(int),
1813 .mode = 0600,
1814 .proc_handler = proc_dointvec_minmax,
1815 .extra1 = &zero,
1816 .extra2 = &two,
1819 .procname = "suid_dumpable",
1820 .data = &suid_dumpable,
1821 .maxlen = sizeof(int),
1822 .mode = 0644,
1823 .proc_handler = proc_dointvec_minmax_coredump,
1824 .extra1 = &zero,
1825 .extra2 = &two,
1827 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1829 .procname = "binfmt_misc",
1830 .mode = 0555,
1831 .child = sysctl_mount_point,
1833 #endif
1835 .procname = "pipe-max-size",
1836 .data = &pipe_max_size,
1837 .maxlen = sizeof(pipe_max_size),
1838 .mode = 0644,
1839 .proc_handler = &pipe_proc_fn,
1840 .extra1 = &pipe_min_size,
1843 .procname = "pipe-user-pages-hard",
1844 .data = &pipe_user_pages_hard,
1845 .maxlen = sizeof(pipe_user_pages_hard),
1846 .mode = 0644,
1847 .proc_handler = proc_doulongvec_minmax,
1850 .procname = "pipe-user-pages-soft",
1851 .data = &pipe_user_pages_soft,
1852 .maxlen = sizeof(pipe_user_pages_soft),
1853 .mode = 0644,
1854 .proc_handler = proc_doulongvec_minmax,
1857 .procname = "mount-max",
1858 .data = &sysctl_mount_max,
1859 .maxlen = sizeof(unsigned int),
1860 .mode = 0644,
1861 .proc_handler = proc_dointvec_minmax,
1862 .extra1 = &one,
1867 static struct ctl_table debug_table[] = {
1868 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1870 .procname = "exception-trace",
1871 .data = &show_unhandled_signals,
1872 .maxlen = sizeof(int),
1873 .mode = 0644,
1874 .proc_handler = proc_dointvec
1876 #endif
1877 #if defined(CONFIG_OPTPROBES)
1879 .procname = "kprobes-optimization",
1880 .data = &sysctl_kprobes_optimization,
1881 .maxlen = sizeof(int),
1882 .mode = 0644,
1883 .proc_handler = proc_kprobes_optimization_handler,
1884 .extra1 = &zero,
1885 .extra2 = &one,
1887 #endif
1891 static struct ctl_table dev_table[] = {
1895 int __init sysctl_init(void)
1897 struct ctl_table_header *hdr;
1899 hdr = register_sysctl_table(sysctl_base_table);
1900 kmemleak_not_leak(hdr);
1901 return 0;
1904 #endif /* CONFIG_SYSCTL */
1907 * /proc/sys support
1910 #ifdef CONFIG_PROC_SYSCTL
1912 static int _proc_do_string(char *data, int maxlen, int write,
1913 char __user *buffer,
1914 size_t *lenp, loff_t *ppos)
1916 size_t len;
1917 char __user *p;
1918 char c;
1920 if (!data || !maxlen || !*lenp) {
1921 *lenp = 0;
1922 return 0;
1925 if (write) {
1926 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1927 /* Only continue writes not past the end of buffer. */
1928 len = strlen(data);
1929 if (len > maxlen - 1)
1930 len = maxlen - 1;
1932 if (*ppos > len)
1933 return 0;
1934 len = *ppos;
1935 } else {
1936 /* Start writing from beginning of buffer. */
1937 len = 0;
1940 *ppos += *lenp;
1941 p = buffer;
1942 while ((p - buffer) < *lenp && len < maxlen - 1) {
1943 if (get_user(c, p++))
1944 return -EFAULT;
1945 if (c == 0 || c == '\n')
1946 break;
1947 data[len++] = c;
1949 data[len] = 0;
1950 } else {
1951 len = strlen(data);
1952 if (len > maxlen)
1953 len = maxlen;
1955 if (*ppos > len) {
1956 *lenp = 0;
1957 return 0;
1960 data += *ppos;
1961 len -= *ppos;
1963 if (len > *lenp)
1964 len = *lenp;
1965 if (len)
1966 if (copy_to_user(buffer, data, len))
1967 return -EFAULT;
1968 if (len < *lenp) {
1969 if (put_user('\n', buffer + len))
1970 return -EFAULT;
1971 len++;
1973 *lenp = len;
1974 *ppos += len;
1976 return 0;
1979 static void warn_sysctl_write(struct ctl_table *table)
1981 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1982 "This will not be supported in the future. To silence this\n"
1983 "warning, set kernel.sysctl_writes_strict = -1\n",
1984 current->comm, table->procname);
1988 * proc_first_pos_non_zero_ignore - check if firs position is allowed
1989 * @ppos: file position
1990 * @table: the sysctl table
1992 * Returns true if the first position is non-zero and the sysctl_writes_strict
1993 * mode indicates this is not allowed for numeric input types. String proc
1994 * hadlers can ignore the return value.
1996 static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
1997 struct ctl_table *table)
1999 if (!*ppos)
2000 return false;
2002 switch (sysctl_writes_strict) {
2003 case SYSCTL_WRITES_STRICT:
2004 return true;
2005 case SYSCTL_WRITES_WARN:
2006 warn_sysctl_write(table);
2007 return false;
2008 default:
2009 return false;
2014 * proc_dostring - read a string sysctl
2015 * @table: the sysctl table
2016 * @write: %TRUE if this is a write to the sysctl file
2017 * @buffer: the user buffer
2018 * @lenp: the size of the user buffer
2019 * @ppos: file position
2021 * Reads/writes a string from/to the user buffer. If the kernel
2022 * buffer provided is not large enough to hold the string, the
2023 * string is truncated. The copied string is %NULL-terminated.
2024 * If the string is being read by the user process, it is copied
2025 * and a newline '\n' is added. It is truncated if the buffer is
2026 * not large enough.
2028 * Returns 0 on success.
2030 int proc_dostring(struct ctl_table *table, int write,
2031 void __user *buffer, size_t *lenp, loff_t *ppos)
2033 if (write)
2034 proc_first_pos_non_zero_ignore(ppos, table);
2036 return _proc_do_string((char *)(table->data), table->maxlen, write,
2037 (char __user *)buffer, lenp, ppos);
2040 static size_t proc_skip_spaces(char **buf)
2042 size_t ret;
2043 char *tmp = skip_spaces(*buf);
2044 ret = tmp - *buf;
2045 *buf = tmp;
2046 return ret;
2049 static void proc_skip_char(char **buf, size_t *size, const char v)
2051 while (*size) {
2052 if (**buf != v)
2053 break;
2054 (*size)--;
2055 (*buf)++;
2059 #define TMPBUFLEN 22
2061 * proc_get_long - reads an ASCII formatted integer from a user buffer
2063 * @buf: a kernel buffer
2064 * @size: size of the kernel buffer
2065 * @val: this is where the number will be stored
2066 * @neg: set to %TRUE if number is negative
2067 * @perm_tr: a vector which contains the allowed trailers
2068 * @perm_tr_len: size of the perm_tr vector
2069 * @tr: pointer to store the trailer character
2071 * In case of success %0 is returned and @buf and @size are updated with
2072 * the amount of bytes read. If @tr is non-NULL and a trailing
2073 * character exists (size is non-zero after returning from this
2074 * function), @tr is updated with the trailing character.
2076 static int proc_get_long(char **buf, size_t *size,
2077 unsigned long *val, bool *neg,
2078 const char *perm_tr, unsigned perm_tr_len, char *tr)
2080 int len;
2081 char *p, tmp[TMPBUFLEN];
2083 if (!*size)
2084 return -EINVAL;
2086 len = *size;
2087 if (len > TMPBUFLEN - 1)
2088 len = TMPBUFLEN - 1;
2090 memcpy(tmp, *buf, len);
2092 tmp[len] = 0;
2093 p = tmp;
2094 if (*p == '-' && *size > 1) {
2095 *neg = true;
2096 p++;
2097 } else
2098 *neg = false;
2099 if (!isdigit(*p))
2100 return -EINVAL;
2102 *val = simple_strtoul(p, &p, 0);
2104 len = p - tmp;
2106 /* We don't know if the next char is whitespace thus we may accept
2107 * invalid integers (e.g. 1234...a) or two integers instead of one
2108 * (e.g. 123...1). So lets not allow such large numbers. */
2109 if (len == TMPBUFLEN - 1)
2110 return -EINVAL;
2112 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2113 return -EINVAL;
2115 if (tr && (len < *size))
2116 *tr = *p;
2118 *buf += len;
2119 *size -= len;
2121 return 0;
2125 * proc_put_long - converts an integer to a decimal ASCII formatted string
2127 * @buf: the user buffer
2128 * @size: the size of the user buffer
2129 * @val: the integer to be converted
2130 * @neg: sign of the number, %TRUE for negative
2132 * In case of success %0 is returned and @buf and @size are updated with
2133 * the amount of bytes written.
2135 static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2136 bool neg)
2138 int len;
2139 char tmp[TMPBUFLEN], *p = tmp;
2141 sprintf(p, "%s%lu", neg ? "-" : "", val);
2142 len = strlen(tmp);
2143 if (len > *size)
2144 len = *size;
2145 if (copy_to_user(*buf, tmp, len))
2146 return -EFAULT;
2147 *size -= len;
2148 *buf += len;
2149 return 0;
2151 #undef TMPBUFLEN
2153 static int proc_put_char(void __user **buf, size_t *size, char c)
2155 if (*size) {
2156 char __user **buffer = (char __user **)buf;
2157 if (put_user(c, *buffer))
2158 return -EFAULT;
2159 (*size)--, (*buffer)++;
2160 *buf = *buffer;
2162 return 0;
2165 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
2166 int *valp,
2167 int write, void *data)
2169 if (write) {
2170 if (*negp) {
2171 if (*lvalp > (unsigned long) INT_MAX + 1)
2172 return -EINVAL;
2173 *valp = -*lvalp;
2174 } else {
2175 if (*lvalp > (unsigned long) INT_MAX)
2176 return -EINVAL;
2177 *valp = *lvalp;
2179 } else {
2180 int val = *valp;
2181 if (val < 0) {
2182 *negp = true;
2183 *lvalp = -(unsigned long)val;
2184 } else {
2185 *negp = false;
2186 *lvalp = (unsigned long)val;
2189 return 0;
2192 static int do_proc_douintvec_conv(unsigned long *lvalp,
2193 unsigned int *valp,
2194 int write, void *data)
2196 if (write) {
2197 if (*lvalp > UINT_MAX)
2198 return -EINVAL;
2199 *valp = *lvalp;
2200 } else {
2201 unsigned int val = *valp;
2202 *lvalp = (unsigned long)val;
2204 return 0;
2207 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2209 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
2210 int write, void __user *buffer,
2211 size_t *lenp, loff_t *ppos,
2212 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2213 int write, void *data),
2214 void *data)
2216 int *i, vleft, first = 1, err = 0;
2217 size_t left;
2218 char *kbuf = NULL, *p;
2220 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2221 *lenp = 0;
2222 return 0;
2225 i = (int *) tbl_data;
2226 vleft = table->maxlen / sizeof(*i);
2227 left = *lenp;
2229 if (!conv)
2230 conv = do_proc_dointvec_conv;
2232 if (write) {
2233 if (proc_first_pos_non_zero_ignore(ppos, table))
2234 goto out;
2236 if (left > PAGE_SIZE - 1)
2237 left = PAGE_SIZE - 1;
2238 p = kbuf = memdup_user_nul(buffer, left);
2239 if (IS_ERR(kbuf))
2240 return PTR_ERR(kbuf);
2243 for (; left && vleft--; i++, first=0) {
2244 unsigned long lval;
2245 bool neg;
2247 if (write) {
2248 left -= proc_skip_spaces(&p);
2250 if (!left)
2251 break;
2252 err = proc_get_long(&p, &left, &lval, &neg,
2253 proc_wspace_sep,
2254 sizeof(proc_wspace_sep), NULL);
2255 if (err)
2256 break;
2257 if (conv(&neg, &lval, i, 1, data)) {
2258 err = -EINVAL;
2259 break;
2261 } else {
2262 if (conv(&neg, &lval, i, 0, data)) {
2263 err = -EINVAL;
2264 break;
2266 if (!first)
2267 err = proc_put_char(&buffer, &left, '\t');
2268 if (err)
2269 break;
2270 err = proc_put_long(&buffer, &left, lval, neg);
2271 if (err)
2272 break;
2276 if (!write && !first && left && !err)
2277 err = proc_put_char(&buffer, &left, '\n');
2278 if (write && !err && left)
2279 left -= proc_skip_spaces(&p);
2280 if (write) {
2281 kfree(kbuf);
2282 if (first)
2283 return err ? : -EINVAL;
2285 *lenp -= left;
2286 out:
2287 *ppos += *lenp;
2288 return err;
2291 static int do_proc_dointvec(struct ctl_table *table, int write,
2292 void __user *buffer, size_t *lenp, loff_t *ppos,
2293 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2294 int write, void *data),
2295 void *data)
2297 return __do_proc_dointvec(table->data, table, write,
2298 buffer, lenp, ppos, conv, data);
2301 static int do_proc_douintvec_w(unsigned int *tbl_data,
2302 struct ctl_table *table,
2303 void __user *buffer,
2304 size_t *lenp, loff_t *ppos,
2305 int (*conv)(unsigned long *lvalp,
2306 unsigned int *valp,
2307 int write, void *data),
2308 void *data)
2310 unsigned long lval;
2311 int err = 0;
2312 size_t left;
2313 bool neg;
2314 char *kbuf = NULL, *p;
2316 left = *lenp;
2318 if (proc_first_pos_non_zero_ignore(ppos, table))
2319 goto bail_early;
2321 if (left > PAGE_SIZE - 1)
2322 left = PAGE_SIZE - 1;
2324 p = kbuf = memdup_user_nul(buffer, left);
2325 if (IS_ERR(kbuf))
2326 return -EINVAL;
2328 left -= proc_skip_spaces(&p);
2329 if (!left) {
2330 err = -EINVAL;
2331 goto out_free;
2334 err = proc_get_long(&p, &left, &lval, &neg,
2335 proc_wspace_sep,
2336 sizeof(proc_wspace_sep), NULL);
2337 if (err || neg) {
2338 err = -EINVAL;
2339 goto out_free;
2342 if (conv(&lval, tbl_data, 1, data)) {
2343 err = -EINVAL;
2344 goto out_free;
2347 if (!err && left)
2348 left -= proc_skip_spaces(&p);
2350 out_free:
2351 kfree(kbuf);
2352 if (err)
2353 return -EINVAL;
2355 return 0;
2357 /* This is in keeping with old __do_proc_dointvec() */
2358 bail_early:
2359 *ppos += *lenp;
2360 return err;
2363 static int do_proc_douintvec_r(unsigned int *tbl_data, void __user *buffer,
2364 size_t *lenp, loff_t *ppos,
2365 int (*conv)(unsigned long *lvalp,
2366 unsigned int *valp,
2367 int write, void *data),
2368 void *data)
2370 unsigned long lval;
2371 int err = 0;
2372 size_t left;
2374 left = *lenp;
2376 if (conv(&lval, tbl_data, 0, data)) {
2377 err = -EINVAL;
2378 goto out;
2381 err = proc_put_long(&buffer, &left, lval, false);
2382 if (err || !left)
2383 goto out;
2385 err = proc_put_char(&buffer, &left, '\n');
2387 out:
2388 *lenp -= left;
2389 *ppos += *lenp;
2391 return err;
2394 static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
2395 int write, void __user *buffer,
2396 size_t *lenp, loff_t *ppos,
2397 int (*conv)(unsigned long *lvalp,
2398 unsigned int *valp,
2399 int write, void *data),
2400 void *data)
2402 unsigned int *i, vleft;
2404 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2405 *lenp = 0;
2406 return 0;
2409 i = (unsigned int *) tbl_data;
2410 vleft = table->maxlen / sizeof(*i);
2413 * Arrays are not supported, keep this simple. *Do not* add
2414 * support for them.
2416 if (vleft != 1) {
2417 *lenp = 0;
2418 return -EINVAL;
2421 if (!conv)
2422 conv = do_proc_douintvec_conv;
2424 if (write)
2425 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
2426 conv, data);
2427 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
2430 static int do_proc_douintvec(struct ctl_table *table, int write,
2431 void __user *buffer, size_t *lenp, loff_t *ppos,
2432 int (*conv)(unsigned long *lvalp,
2433 unsigned int *valp,
2434 int write, void *data),
2435 void *data)
2437 return __do_proc_douintvec(table->data, table, write,
2438 buffer, lenp, ppos, conv, data);
2442 * proc_dointvec - read a vector of integers
2443 * @table: the sysctl table
2444 * @write: %TRUE if this is a write to the sysctl file
2445 * @buffer: the user buffer
2446 * @lenp: the size of the user buffer
2447 * @ppos: file position
2449 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2450 * values from/to the user buffer, treated as an ASCII string.
2452 * Returns 0 on success.
2454 int proc_dointvec(struct ctl_table *table, int write,
2455 void __user *buffer, size_t *lenp, loff_t *ppos)
2457 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2461 * proc_douintvec - read a vector of unsigned integers
2462 * @table: the sysctl table
2463 * @write: %TRUE if this is a write to the sysctl file
2464 * @buffer: the user buffer
2465 * @lenp: the size of the user buffer
2466 * @ppos: file position
2468 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2469 * values from/to the user buffer, treated as an ASCII string.
2471 * Returns 0 on success.
2473 int proc_douintvec(struct ctl_table *table, int write,
2474 void __user *buffer, size_t *lenp, loff_t *ppos)
2476 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2477 do_proc_douintvec_conv, NULL);
2481 * Taint values can only be increased
2482 * This means we can safely use a temporary.
2484 static int proc_taint(struct ctl_table *table, int write,
2485 void __user *buffer, size_t *lenp, loff_t *ppos)
2487 struct ctl_table t;
2488 unsigned long tmptaint = get_taint();
2489 int err;
2491 if (write && !capable(CAP_SYS_ADMIN))
2492 return -EPERM;
2494 t = *table;
2495 t.data = &tmptaint;
2496 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
2497 if (err < 0)
2498 return err;
2500 if (write) {
2502 * Poor man's atomic or. Not worth adding a primitive
2503 * to everyone's atomic.h for this
2505 int i;
2506 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2507 if ((tmptaint >> i) & 1)
2508 add_taint(i, LOCKDEP_STILL_OK);
2512 return err;
2515 #ifdef CONFIG_PRINTK
2516 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
2517 void __user *buffer, size_t *lenp, loff_t *ppos)
2519 if (write && !capable(CAP_SYS_ADMIN))
2520 return -EPERM;
2522 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2524 #endif
2526 struct do_proc_dointvec_minmax_conv_param {
2527 int *min;
2528 int *max;
2531 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2532 int *valp,
2533 int write, void *data)
2535 struct do_proc_dointvec_minmax_conv_param *param = data;
2536 if (write) {
2537 int val;
2538 if (*negp) {
2539 if (*lvalp > (unsigned long) INT_MAX + 1)
2540 return -EINVAL;
2541 val = -*lvalp;
2542 } else {
2543 if (*lvalp > (unsigned long) INT_MAX)
2544 return -EINVAL;
2545 val = *lvalp;
2547 if ((param->min && *param->min > val) ||
2548 (param->max && *param->max < val))
2549 return -EINVAL;
2550 *valp = val;
2551 } else {
2552 int val = *valp;
2553 if (val < 0) {
2554 *negp = true;
2555 *lvalp = -(unsigned long)val;
2556 } else {
2557 *negp = false;
2558 *lvalp = (unsigned long)val;
2561 return 0;
2565 * proc_dointvec_minmax - read a vector of integers with min/max values
2566 * @table: the sysctl table
2567 * @write: %TRUE if this is a write to the sysctl file
2568 * @buffer: the user buffer
2569 * @lenp: the size of the user buffer
2570 * @ppos: file position
2572 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2573 * values from/to the user buffer, treated as an ASCII string.
2575 * This routine will ensure the values are within the range specified by
2576 * table->extra1 (min) and table->extra2 (max).
2578 * Returns 0 on success.
2580 int proc_dointvec_minmax(struct ctl_table *table, int write,
2581 void __user *buffer, size_t *lenp, loff_t *ppos)
2583 struct do_proc_dointvec_minmax_conv_param param = {
2584 .min = (int *) table->extra1,
2585 .max = (int *) table->extra2,
2587 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2588 do_proc_dointvec_minmax_conv, &param);
2591 struct do_proc_douintvec_minmax_conv_param {
2592 unsigned int *min;
2593 unsigned int *max;
2596 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
2597 unsigned int *valp,
2598 int write, void *data)
2600 struct do_proc_douintvec_minmax_conv_param *param = data;
2602 if (write) {
2603 unsigned int val = *lvalp;
2605 if ((param->min && *param->min > val) ||
2606 (param->max && *param->max < val))
2607 return -ERANGE;
2609 if (*lvalp > UINT_MAX)
2610 return -EINVAL;
2611 *valp = val;
2612 } else {
2613 unsigned int val = *valp;
2614 *lvalp = (unsigned long) val;
2617 return 0;
2621 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2622 * @table: the sysctl table
2623 * @write: %TRUE if this is a write to the sysctl file
2624 * @buffer: the user buffer
2625 * @lenp: the size of the user buffer
2626 * @ppos: file position
2628 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2629 * values from/to the user buffer, treated as an ASCII string. Negative
2630 * strings are not allowed.
2632 * This routine will ensure the values are within the range specified by
2633 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2634 * check for UINT_MAX to avoid having to support wrap around uses from
2635 * userspace.
2637 * Returns 0 on success.
2639 int proc_douintvec_minmax(struct ctl_table *table, int write,
2640 void __user *buffer, size_t *lenp, loff_t *ppos)
2642 struct do_proc_douintvec_minmax_conv_param param = {
2643 .min = (unsigned int *) table->extra1,
2644 .max = (unsigned int *) table->extra2,
2646 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2647 do_proc_douintvec_minmax_conv, &param);
2650 static void validate_coredump_safety(void)
2652 #ifdef CONFIG_COREDUMP
2653 if (suid_dumpable == SUID_DUMP_ROOT &&
2654 core_pattern[0] != '/' && core_pattern[0] != '|') {
2655 printk(KERN_WARNING
2656 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2657 "Pipe handler or fully qualified core dump path required.\n"
2658 "Set kernel.core_pattern before fs.suid_dumpable.\n"
2661 #endif
2664 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2665 void __user *buffer, size_t *lenp, loff_t *ppos)
2667 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2668 if (!error)
2669 validate_coredump_safety();
2670 return error;
2673 #ifdef CONFIG_COREDUMP
2674 static int proc_dostring_coredump(struct ctl_table *table, int write,
2675 void __user *buffer, size_t *lenp, loff_t *ppos)
2677 int error = proc_dostring(table, write, buffer, lenp, ppos);
2678 if (!error)
2679 validate_coredump_safety();
2680 return error;
2682 #endif
2684 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
2685 void __user *buffer,
2686 size_t *lenp, loff_t *ppos,
2687 unsigned long convmul,
2688 unsigned long convdiv)
2690 unsigned long *i, *min, *max;
2691 int vleft, first = 1, err = 0;
2692 size_t left;
2693 char *kbuf = NULL, *p;
2695 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
2696 *lenp = 0;
2697 return 0;
2700 i = (unsigned long *) data;
2701 min = (unsigned long *) table->extra1;
2702 max = (unsigned long *) table->extra2;
2703 vleft = table->maxlen / sizeof(unsigned long);
2704 left = *lenp;
2706 if (write) {
2707 if (proc_first_pos_non_zero_ignore(ppos, table))
2708 goto out;
2710 if (left > PAGE_SIZE - 1)
2711 left = PAGE_SIZE - 1;
2712 p = kbuf = memdup_user_nul(buffer, left);
2713 if (IS_ERR(kbuf))
2714 return PTR_ERR(kbuf);
2717 for (; left && vleft--; i++, first = 0) {
2718 unsigned long val;
2720 if (write) {
2721 bool neg;
2723 left -= proc_skip_spaces(&p);
2724 if (!left)
2725 break;
2727 err = proc_get_long(&p, &left, &val, &neg,
2728 proc_wspace_sep,
2729 sizeof(proc_wspace_sep), NULL);
2730 if (err)
2731 break;
2732 if (neg)
2733 continue;
2734 val = convmul * val / convdiv;
2735 if ((min && val < *min) || (max && val > *max)) {
2736 err = -EINVAL;
2737 break;
2739 *i = val;
2740 } else {
2741 val = convdiv * (*i) / convmul;
2742 if (!first) {
2743 err = proc_put_char(&buffer, &left, '\t');
2744 if (err)
2745 break;
2747 err = proc_put_long(&buffer, &left, val, false);
2748 if (err)
2749 break;
2753 if (!write && !first && left && !err)
2754 err = proc_put_char(&buffer, &left, '\n');
2755 if (write && !err)
2756 left -= proc_skip_spaces(&p);
2757 if (write) {
2758 kfree(kbuf);
2759 if (first)
2760 return err ? : -EINVAL;
2762 *lenp -= left;
2763 out:
2764 *ppos += *lenp;
2765 return err;
2768 static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
2769 void __user *buffer,
2770 size_t *lenp, loff_t *ppos,
2771 unsigned long convmul,
2772 unsigned long convdiv)
2774 return __do_proc_doulongvec_minmax(table->data, table, write,
2775 buffer, lenp, ppos, convmul, convdiv);
2779 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2780 * @table: the sysctl table
2781 * @write: %TRUE if this is a write to the sysctl file
2782 * @buffer: the user buffer
2783 * @lenp: the size of the user buffer
2784 * @ppos: file position
2786 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2787 * values from/to the user buffer, treated as an ASCII string.
2789 * This routine will ensure the values are within the range specified by
2790 * table->extra1 (min) and table->extra2 (max).
2792 * Returns 0 on success.
2794 int proc_doulongvec_minmax(struct ctl_table *table, int write,
2795 void __user *buffer, size_t *lenp, loff_t *ppos)
2797 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
2801 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2802 * @table: the sysctl table
2803 * @write: %TRUE if this is a write to the sysctl file
2804 * @buffer: the user buffer
2805 * @lenp: the size of the user buffer
2806 * @ppos: file position
2808 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2809 * values from/to the user buffer, treated as an ASCII string. The values
2810 * are treated as milliseconds, and converted to jiffies when they are stored.
2812 * This routine will ensure the values are within the range specified by
2813 * table->extra1 (min) and table->extra2 (max).
2815 * Returns 0 on success.
2817 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
2818 void __user *buffer,
2819 size_t *lenp, loff_t *ppos)
2821 return do_proc_doulongvec_minmax(table, write, buffer,
2822 lenp, ppos, HZ, 1000l);
2826 static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
2827 int *valp,
2828 int write, void *data)
2830 if (write) {
2831 if (*lvalp > INT_MAX / HZ)
2832 return 1;
2833 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2834 } else {
2835 int val = *valp;
2836 unsigned long lval;
2837 if (val < 0) {
2838 *negp = true;
2839 lval = -(unsigned long)val;
2840 } else {
2841 *negp = false;
2842 lval = (unsigned long)val;
2844 *lvalp = lval / HZ;
2846 return 0;
2849 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
2850 int *valp,
2851 int write, void *data)
2853 if (write) {
2854 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2855 return 1;
2856 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2857 } else {
2858 int val = *valp;
2859 unsigned long lval;
2860 if (val < 0) {
2861 *negp = true;
2862 lval = -(unsigned long)val;
2863 } else {
2864 *negp = false;
2865 lval = (unsigned long)val;
2867 *lvalp = jiffies_to_clock_t(lval);
2869 return 0;
2872 static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
2873 int *valp,
2874 int write, void *data)
2876 if (write) {
2877 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2879 if (jif > INT_MAX)
2880 return 1;
2881 *valp = (int)jif;
2882 } else {
2883 int val = *valp;
2884 unsigned long lval;
2885 if (val < 0) {
2886 *negp = true;
2887 lval = -(unsigned long)val;
2888 } else {
2889 *negp = false;
2890 lval = (unsigned long)val;
2892 *lvalp = jiffies_to_msecs(lval);
2894 return 0;
2898 * proc_dointvec_jiffies - read a vector of integers as seconds
2899 * @table: the sysctl table
2900 * @write: %TRUE if this is a write to the sysctl file
2901 * @buffer: the user buffer
2902 * @lenp: the size of the user buffer
2903 * @ppos: file position
2905 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2906 * values from/to the user buffer, treated as an ASCII string.
2907 * The values read are assumed to be in seconds, and are converted into
2908 * jiffies.
2910 * Returns 0 on success.
2912 int proc_dointvec_jiffies(struct ctl_table *table, int write,
2913 void __user *buffer, size_t *lenp, loff_t *ppos)
2915 return do_proc_dointvec(table,write,buffer,lenp,ppos,
2916 do_proc_dointvec_jiffies_conv,NULL);
2920 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2921 * @table: the sysctl table
2922 * @write: %TRUE if this is a write to the sysctl file
2923 * @buffer: the user buffer
2924 * @lenp: the size of the user buffer
2925 * @ppos: pointer to the file position
2927 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2928 * values from/to the user buffer, treated as an ASCII string.
2929 * The values read are assumed to be in 1/USER_HZ seconds, and
2930 * are converted into jiffies.
2932 * Returns 0 on success.
2934 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
2935 void __user *buffer, size_t *lenp, loff_t *ppos)
2937 return do_proc_dointvec(table,write,buffer,lenp,ppos,
2938 do_proc_dointvec_userhz_jiffies_conv,NULL);
2942 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2943 * @table: the sysctl table
2944 * @write: %TRUE if this is a write to the sysctl file
2945 * @buffer: the user buffer
2946 * @lenp: the size of the user buffer
2947 * @ppos: file position
2948 * @ppos: the current position in the file
2950 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2951 * values from/to the user buffer, treated as an ASCII string.
2952 * The values read are assumed to be in 1/1000 seconds, and
2953 * are converted into jiffies.
2955 * Returns 0 on success.
2957 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
2958 void __user *buffer, size_t *lenp, loff_t *ppos)
2960 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2961 do_proc_dointvec_ms_jiffies_conv, NULL);
2964 static int proc_do_cad_pid(struct ctl_table *table, int write,
2965 void __user *buffer, size_t *lenp, loff_t *ppos)
2967 struct pid *new_pid;
2968 pid_t tmp;
2969 int r;
2971 tmp = pid_vnr(cad_pid);
2973 r = __do_proc_dointvec(&tmp, table, write, buffer,
2974 lenp, ppos, NULL, NULL);
2975 if (r || !write)
2976 return r;
2978 new_pid = find_get_pid(tmp);
2979 if (!new_pid)
2980 return -ESRCH;
2982 put_pid(xchg(&cad_pid, new_pid));
2983 return 0;
2987 * proc_do_large_bitmap - read/write from/to a large bitmap
2988 * @table: the sysctl table
2989 * @write: %TRUE if this is a write to the sysctl file
2990 * @buffer: the user buffer
2991 * @lenp: the size of the user buffer
2992 * @ppos: file position
2994 * The bitmap is stored at table->data and the bitmap length (in bits)
2995 * in table->maxlen.
2997 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2998 * large bitmaps may be represented in a compact manner. Writing into
2999 * the file will clear the bitmap then update it with the given input.
3001 * Returns 0 on success.
3003 int proc_do_large_bitmap(struct ctl_table *table, int write,
3004 void __user *buffer, size_t *lenp, loff_t *ppos)
3006 int err = 0;
3007 bool first = 1;
3008 size_t left = *lenp;
3009 unsigned long bitmap_len = table->maxlen;
3010 unsigned long *bitmap = *(unsigned long **) table->data;
3011 unsigned long *tmp_bitmap = NULL;
3012 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
3014 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
3015 *lenp = 0;
3016 return 0;
3019 if (write) {
3020 char *kbuf, *p;
3022 if (left > PAGE_SIZE - 1)
3023 left = PAGE_SIZE - 1;
3025 p = kbuf = memdup_user_nul(buffer, left);
3026 if (IS_ERR(kbuf))
3027 return PTR_ERR(kbuf);
3029 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
3030 GFP_KERNEL);
3031 if (!tmp_bitmap) {
3032 kfree(kbuf);
3033 return -ENOMEM;
3035 proc_skip_char(&p, &left, '\n');
3036 while (!err && left) {
3037 unsigned long val_a, val_b;
3038 bool neg;
3040 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
3041 sizeof(tr_a), &c);
3042 if (err)
3043 break;
3044 if (val_a >= bitmap_len || neg) {
3045 err = -EINVAL;
3046 break;
3049 val_b = val_a;
3050 if (left) {
3051 p++;
3052 left--;
3055 if (c == '-') {
3056 err = proc_get_long(&p, &left, &val_b,
3057 &neg, tr_b, sizeof(tr_b),
3058 &c);
3059 if (err)
3060 break;
3061 if (val_b >= bitmap_len || neg ||
3062 val_a > val_b) {
3063 err = -EINVAL;
3064 break;
3066 if (left) {
3067 p++;
3068 left--;
3072 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
3073 first = 0;
3074 proc_skip_char(&p, &left, '\n');
3076 kfree(kbuf);
3077 } else {
3078 unsigned long bit_a, bit_b = 0;
3080 while (left) {
3081 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3082 if (bit_a >= bitmap_len)
3083 break;
3084 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3085 bit_a + 1) - 1;
3087 if (!first) {
3088 err = proc_put_char(&buffer, &left, ',');
3089 if (err)
3090 break;
3092 err = proc_put_long(&buffer, &left, bit_a, false);
3093 if (err)
3094 break;
3095 if (bit_a != bit_b) {
3096 err = proc_put_char(&buffer, &left, '-');
3097 if (err)
3098 break;
3099 err = proc_put_long(&buffer, &left, bit_b, false);
3100 if (err)
3101 break;
3104 first = 0; bit_b++;
3106 if (!err)
3107 err = proc_put_char(&buffer, &left, '\n');
3110 if (!err) {
3111 if (write) {
3112 if (*ppos)
3113 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3114 else
3115 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
3117 kfree(tmp_bitmap);
3118 *lenp -= left;
3119 *ppos += *lenp;
3120 return 0;
3121 } else {
3122 kfree(tmp_bitmap);
3123 return err;
3127 #else /* CONFIG_PROC_SYSCTL */
3129 int proc_dostring(struct ctl_table *table, int write,
3130 void __user *buffer, size_t *lenp, loff_t *ppos)
3132 return -ENOSYS;
3135 int proc_dointvec(struct ctl_table *table, int write,
3136 void __user *buffer, size_t *lenp, loff_t *ppos)
3138 return -ENOSYS;
3141 int proc_douintvec(struct ctl_table *table, int write,
3142 void __user *buffer, size_t *lenp, loff_t *ppos)
3144 return -ENOSYS;
3147 int proc_dointvec_minmax(struct ctl_table *table, int write,
3148 void __user *buffer, size_t *lenp, loff_t *ppos)
3150 return -ENOSYS;
3153 int proc_douintvec_minmax(struct ctl_table *table, int write,
3154 void __user *buffer, size_t *lenp, loff_t *ppos)
3156 return -ENOSYS;
3159 int proc_dointvec_jiffies(struct ctl_table *table, int write,
3160 void __user *buffer, size_t *lenp, loff_t *ppos)
3162 return -ENOSYS;
3165 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
3166 void __user *buffer, size_t *lenp, loff_t *ppos)
3168 return -ENOSYS;
3171 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
3172 void __user *buffer, size_t *lenp, loff_t *ppos)
3174 return -ENOSYS;
3177 int proc_doulongvec_minmax(struct ctl_table *table, int write,
3178 void __user *buffer, size_t *lenp, loff_t *ppos)
3180 return -ENOSYS;
3183 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
3184 void __user *buffer,
3185 size_t *lenp, loff_t *ppos)
3187 return -ENOSYS;
3191 #endif /* CONFIG_PROC_SYSCTL */
3194 * No sense putting this after each symbol definition, twice,
3195 * exception granted :-)
3197 EXPORT_SYMBOL(proc_dointvec);
3198 EXPORT_SYMBOL(proc_douintvec);
3199 EXPORT_SYMBOL(proc_dointvec_jiffies);
3200 EXPORT_SYMBOL(proc_dointvec_minmax);
3201 EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
3202 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3203 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3204 EXPORT_SYMBOL(proc_dostring);
3205 EXPORT_SYMBOL(proc_doulongvec_minmax);
3206 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);