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
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
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>
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/kmemcheck.h>
34 #include <linux/kmemleak.h>
36 #include <linux/init.h>
37 #include <linux/kernel.h>
38 #include <linux/kobject.h>
39 #include <linux/net.h>
40 #include <linux/sysrq.h>
41 #include <linux/highuid.h>
42 #include <linux/writeback.h>
43 #include <linux/ratelimit.h>
44 #include <linux/compaction.h>
45 #include <linux/hugetlb.h>
46 #include <linux/initrd.h>
47 #include <linux/key.h>
48 #include <linux/times.h>
49 #include <linux/limits.h>
50 #include <linux/dcache.h>
51 #include <linux/dnotify.h>
52 #include <linux/syscalls.h>
53 #include <linux/vmstat.h>
54 #include <linux/nfs_fs.h>
55 #include <linux/acpi.h>
56 #include <linux/reboot.h>
57 #include <linux/ftrace.h>
58 #include <linux/perf_event.h>
59 #include <linux/kprobes.h>
60 #include <linux/pipe_fs_i.h>
61 #include <linux/oom.h>
62 #include <linux/kmod.h>
63 #include <linux/capability.h>
64 #include <linux/binfmts.h>
65 #include <linux/sched/sysctl.h>
66 #include <linux/kexec.h>
67 #include <linux/bpf.h>
69 #include <asm/uaccess.h>
70 #include <asm/processor.h>
74 #include <asm/stacktrace.h>
78 #include <asm/setup.h>
80 #ifdef CONFIG_BSD_PROCESS_ACCT
81 #include <linux/acct.h>
83 #ifdef CONFIG_RT_MUTEXES
84 #include <linux/rtmutex.h>
86 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
87 #include <linux/lockdep.h>
89 #ifdef CONFIG_CHR_DEV_SG
93 #ifdef CONFIG_LOCKUP_DETECTOR
94 #include <linux/nmi.h>
97 #if defined(CONFIG_SYSCTL)
99 /* External variables not in a header file. */
100 extern int suid_dumpable
;
101 #ifdef CONFIG_COREDUMP
102 extern int core_uses_pid
;
103 extern char core_pattern
[];
104 extern unsigned int core_pipe_limit
;
107 extern int pid_max_min
, pid_max_max
;
108 extern int percpu_pagelist_fraction
;
109 extern int compat_log
;
110 extern int latencytop_enabled
;
111 extern int sysctl_nr_open_min
, sysctl_nr_open_max
;
113 extern int sysctl_nr_trim_pages
;
116 /* Constants used for minimum and maximum */
117 #ifdef CONFIG_LOCKUP_DETECTOR
118 static int sixty
= 60;
121 static int __maybe_unused neg_one
= -1;
124 static int __maybe_unused one
= 1;
125 static int __maybe_unused two
= 2;
126 static int __maybe_unused four
= 4;
127 static unsigned long one_ul
= 1;
128 static int one_hundred
= 100;
129 static int one_thousand
= 1000;
131 static int ten_thousand
= 10000;
133 #ifdef CONFIG_PERF_EVENTS
134 static int six_hundred_forty_kb
= 640 * 1024;
137 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
138 static unsigned long dirty_bytes_min
= 2 * PAGE_SIZE
;
140 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
141 static int maxolduid
= 65535;
142 static int minolduid
;
144 static int ngroups_max
= NGROUPS_MAX
;
145 static const int cap_last_cap
= CAP_LAST_CAP
;
147 /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
148 #ifdef CONFIG_DETECT_HUNG_TASK
149 static unsigned long hung_task_timeout_max
= (LONG_MAX
/HZ
);
152 #ifdef CONFIG_INOTIFY_USER
153 #include <linux/inotify.h>
159 extern int pwrsw_enabled
;
162 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
163 extern int unaligned_enabled
;
167 extern int unaligned_dump_stack
;
170 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
171 extern int no_unaligned_warning
;
174 #ifdef CONFIG_PROC_SYSCTL
176 #define SYSCTL_WRITES_LEGACY -1
177 #define SYSCTL_WRITES_WARN 0
178 #define SYSCTL_WRITES_STRICT 1
180 static int sysctl_writes_strict
= SYSCTL_WRITES_STRICT
;
182 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
183 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
184 static int proc_taint(struct ctl_table
*table
, int write
,
185 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
189 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
190 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
193 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
194 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
195 #ifdef CONFIG_COREDUMP
196 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
197 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
200 #ifdef CONFIG_MAGIC_SYSRQ
201 /* Note: sysrq code uses it's own private copy */
202 static int __sysrq_enabled
= CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE
;
204 static int sysrq_sysctl_handler(struct ctl_table
*table
, int write
,
205 void __user
*buffer
, size_t *lenp
,
210 error
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
215 sysrq_toggle_support(__sysrq_enabled
);
222 static struct ctl_table kern_table
[];
223 static struct ctl_table vm_table
[];
224 static struct ctl_table fs_table
[];
225 static struct ctl_table debug_table
[];
226 static struct ctl_table dev_table
[];
227 extern struct ctl_table random_table
[];
229 extern struct ctl_table epoll_table
[];
232 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
233 int sysctl_legacy_va_layout
;
236 /* The default sysctl tables: */
238 static struct ctl_table sysctl_base_table
[] = {
240 .procname
= "kernel",
257 .child
= debug_table
,
267 #ifdef CONFIG_SCHED_DEBUG
268 static int min_sched_granularity_ns
= 100000; /* 100 usecs */
269 static int max_sched_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
270 static int min_wakeup_granularity_ns
; /* 0 usecs */
271 static int max_wakeup_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
273 static int min_sched_tunable_scaling
= SCHED_TUNABLESCALING_NONE
;
274 static int max_sched_tunable_scaling
= SCHED_TUNABLESCALING_END
-1;
275 #endif /* CONFIG_SMP */
276 #endif /* CONFIG_SCHED_DEBUG */
278 #ifdef CONFIG_COMPACTION
279 static int min_extfrag_threshold
;
280 static int max_extfrag_threshold
= 1000;
283 static struct ctl_table kern_table
[] = {
285 .procname
= "sched_child_runs_first",
286 .data
= &sysctl_sched_child_runs_first
,
287 .maxlen
= sizeof(unsigned int),
289 .proc_handler
= proc_dointvec
,
291 #ifdef CONFIG_SCHED_DEBUG
293 .procname
= "sched_min_granularity_ns",
294 .data
= &sysctl_sched_min_granularity
,
295 .maxlen
= sizeof(unsigned int),
297 .proc_handler
= sched_proc_update_handler
,
298 .extra1
= &min_sched_granularity_ns
,
299 .extra2
= &max_sched_granularity_ns
,
302 .procname
= "sched_latency_ns",
303 .data
= &sysctl_sched_latency
,
304 .maxlen
= sizeof(unsigned int),
306 .proc_handler
= sched_proc_update_handler
,
307 .extra1
= &min_sched_granularity_ns
,
308 .extra2
= &max_sched_granularity_ns
,
311 .procname
= "sched_wakeup_granularity_ns",
312 .data
= &sysctl_sched_wakeup_granularity
,
313 .maxlen
= sizeof(unsigned int),
315 .proc_handler
= sched_proc_update_handler
,
316 .extra1
= &min_wakeup_granularity_ns
,
317 .extra2
= &max_wakeup_granularity_ns
,
321 .procname
= "sched_tunable_scaling",
322 .data
= &sysctl_sched_tunable_scaling
,
323 .maxlen
= sizeof(enum sched_tunable_scaling
),
325 .proc_handler
= sched_proc_update_handler
,
326 .extra1
= &min_sched_tunable_scaling
,
327 .extra2
= &max_sched_tunable_scaling
,
330 .procname
= "sched_migration_cost_ns",
331 .data
= &sysctl_sched_migration_cost
,
332 .maxlen
= sizeof(unsigned int),
334 .proc_handler
= proc_dointvec
,
337 .procname
= "sched_nr_migrate",
338 .data
= &sysctl_sched_nr_migrate
,
339 .maxlen
= sizeof(unsigned int),
341 .proc_handler
= proc_dointvec
,
344 .procname
= "sched_time_avg_ms",
345 .data
= &sysctl_sched_time_avg
,
346 .maxlen
= sizeof(unsigned int),
348 .proc_handler
= proc_dointvec
,
351 .procname
= "sched_shares_window_ns",
352 .data
= &sysctl_sched_shares_window
,
353 .maxlen
= sizeof(unsigned int),
355 .proc_handler
= proc_dointvec
,
357 #ifdef CONFIG_SCHEDSTATS
359 .procname
= "sched_schedstats",
361 .maxlen
= sizeof(unsigned int),
363 .proc_handler
= sysctl_schedstats
,
367 #endif /* CONFIG_SCHEDSTATS */
368 #endif /* CONFIG_SMP */
369 #ifdef CONFIG_NUMA_BALANCING
371 .procname
= "numa_balancing_scan_delay_ms",
372 .data
= &sysctl_numa_balancing_scan_delay
,
373 .maxlen
= sizeof(unsigned int),
375 .proc_handler
= proc_dointvec
,
378 .procname
= "numa_balancing_scan_period_min_ms",
379 .data
= &sysctl_numa_balancing_scan_period_min
,
380 .maxlen
= sizeof(unsigned int),
382 .proc_handler
= proc_dointvec
,
385 .procname
= "numa_balancing_scan_period_max_ms",
386 .data
= &sysctl_numa_balancing_scan_period_max
,
387 .maxlen
= sizeof(unsigned int),
389 .proc_handler
= proc_dointvec
,
392 .procname
= "numa_balancing_scan_size_mb",
393 .data
= &sysctl_numa_balancing_scan_size
,
394 .maxlen
= sizeof(unsigned int),
396 .proc_handler
= proc_dointvec_minmax
,
400 .procname
= "numa_balancing",
401 .data
= NULL
, /* filled in by handler */
402 .maxlen
= sizeof(unsigned int),
404 .proc_handler
= sysctl_numa_balancing
,
408 #endif /* CONFIG_NUMA_BALANCING */
409 #endif /* CONFIG_SCHED_DEBUG */
411 .procname
= "sched_rt_period_us",
412 .data
= &sysctl_sched_rt_period
,
413 .maxlen
= sizeof(unsigned int),
415 .proc_handler
= sched_rt_handler
,
418 .procname
= "sched_rt_runtime_us",
419 .data
= &sysctl_sched_rt_runtime
,
420 .maxlen
= sizeof(int),
422 .proc_handler
= sched_rt_handler
,
425 .procname
= "sched_rr_timeslice_ms",
426 .data
= &sched_rr_timeslice
,
427 .maxlen
= sizeof(int),
429 .proc_handler
= sched_rr_handler
,
431 #ifdef CONFIG_SCHED_AUTOGROUP
433 .procname
= "sched_autogroup_enabled",
434 .data
= &sysctl_sched_autogroup_enabled
,
435 .maxlen
= sizeof(unsigned int),
437 .proc_handler
= proc_dointvec_minmax
,
442 #ifdef CONFIG_CFS_BANDWIDTH
444 .procname
= "sched_cfs_bandwidth_slice_us",
445 .data
= &sysctl_sched_cfs_bandwidth_slice
,
446 .maxlen
= sizeof(unsigned int),
448 .proc_handler
= proc_dointvec_minmax
,
452 #ifdef CONFIG_PROVE_LOCKING
454 .procname
= "prove_locking",
455 .data
= &prove_locking
,
456 .maxlen
= sizeof(int),
458 .proc_handler
= proc_dointvec
,
461 #ifdef CONFIG_LOCK_STAT
463 .procname
= "lock_stat",
465 .maxlen
= sizeof(int),
467 .proc_handler
= proc_dointvec
,
472 .data
= &panic_timeout
,
473 .maxlen
= sizeof(int),
475 .proc_handler
= proc_dointvec
,
477 #ifdef CONFIG_COREDUMP
479 .procname
= "core_uses_pid",
480 .data
= &core_uses_pid
,
481 .maxlen
= sizeof(int),
483 .proc_handler
= proc_dointvec
,
486 .procname
= "core_pattern",
487 .data
= core_pattern
,
488 .maxlen
= CORENAME_MAX_SIZE
,
490 .proc_handler
= proc_dostring_coredump
,
493 .procname
= "core_pipe_limit",
494 .data
= &core_pipe_limit
,
495 .maxlen
= sizeof(unsigned int),
497 .proc_handler
= proc_dointvec
,
500 #ifdef CONFIG_PROC_SYSCTL
502 .procname
= "tainted",
503 .maxlen
= sizeof(long),
505 .proc_handler
= proc_taint
,
508 .procname
= "sysctl_writes_strict",
509 .data
= &sysctl_writes_strict
,
510 .maxlen
= sizeof(int),
512 .proc_handler
= proc_dointvec_minmax
,
517 #ifdef CONFIG_LATENCYTOP
519 .procname
= "latencytop",
520 .data
= &latencytop_enabled
,
521 .maxlen
= sizeof(int),
523 .proc_handler
= sysctl_latencytop
,
526 #ifdef CONFIG_BLK_DEV_INITRD
528 .procname
= "real-root-dev",
529 .data
= &real_root_dev
,
530 .maxlen
= sizeof(int),
532 .proc_handler
= proc_dointvec
,
536 .procname
= "print-fatal-signals",
537 .data
= &print_fatal_signals
,
538 .maxlen
= sizeof(int),
540 .proc_handler
= proc_dointvec
,
544 .procname
= "reboot-cmd",
545 .data
= reboot_command
,
548 .proc_handler
= proc_dostring
,
551 .procname
= "stop-a",
552 .data
= &stop_a_enabled
,
553 .maxlen
= sizeof (int),
555 .proc_handler
= proc_dointvec
,
558 .procname
= "scons-poweroff",
559 .data
= &scons_pwroff
,
560 .maxlen
= sizeof (int),
562 .proc_handler
= proc_dointvec
,
565 #ifdef CONFIG_SPARC64
567 .procname
= "tsb-ratio",
568 .data
= &sysctl_tsb_ratio
,
569 .maxlen
= sizeof (int),
571 .proc_handler
= proc_dointvec
,
576 .procname
= "soft-power",
577 .data
= &pwrsw_enabled
,
578 .maxlen
= sizeof (int),
580 .proc_handler
= proc_dointvec
,
583 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
585 .procname
= "unaligned-trap",
586 .data
= &unaligned_enabled
,
587 .maxlen
= sizeof (int),
589 .proc_handler
= proc_dointvec
,
593 .procname
= "ctrl-alt-del",
595 .maxlen
= sizeof(int),
597 .proc_handler
= proc_dointvec
,
599 #ifdef CONFIG_FUNCTION_TRACER
601 .procname
= "ftrace_enabled",
602 .data
= &ftrace_enabled
,
603 .maxlen
= sizeof(int),
605 .proc_handler
= ftrace_enable_sysctl
,
608 #ifdef CONFIG_STACK_TRACER
610 .procname
= "stack_tracer_enabled",
611 .data
= &stack_tracer_enabled
,
612 .maxlen
= sizeof(int),
614 .proc_handler
= stack_trace_sysctl
,
617 #ifdef CONFIG_TRACING
619 .procname
= "ftrace_dump_on_oops",
620 .data
= &ftrace_dump_on_oops
,
621 .maxlen
= sizeof(int),
623 .proc_handler
= proc_dointvec
,
626 .procname
= "traceoff_on_warning",
627 .data
= &__disable_trace_on_warning
,
628 .maxlen
= sizeof(__disable_trace_on_warning
),
630 .proc_handler
= proc_dointvec
,
633 .procname
= "tracepoint_printk",
634 .data
= &tracepoint_printk
,
635 .maxlen
= sizeof(tracepoint_printk
),
637 .proc_handler
= proc_dointvec
,
640 #ifdef CONFIG_KEXEC_CORE
642 .procname
= "kexec_load_disabled",
643 .data
= &kexec_load_disabled
,
644 .maxlen
= sizeof(int),
646 /* only handle a transition from default "0" to "1" */
647 .proc_handler
= proc_dointvec_minmax
,
652 #ifdef CONFIG_MODULES
654 .procname
= "modprobe",
655 .data
= &modprobe_path
,
656 .maxlen
= KMOD_PATH_LEN
,
658 .proc_handler
= proc_dostring
,
661 .procname
= "modules_disabled",
662 .data
= &modules_disabled
,
663 .maxlen
= sizeof(int),
665 /* only handle a transition from default "0" to "1" */
666 .proc_handler
= proc_dointvec_minmax
,
671 #ifdef CONFIG_UEVENT_HELPER
673 .procname
= "hotplug",
674 .data
= &uevent_helper
,
675 .maxlen
= UEVENT_HELPER_PATH_LEN
,
677 .proc_handler
= proc_dostring
,
680 #ifdef CONFIG_CHR_DEV_SG
682 .procname
= "sg-big-buff",
683 .data
= &sg_big_buff
,
684 .maxlen
= sizeof (int),
686 .proc_handler
= proc_dointvec
,
689 #ifdef CONFIG_BSD_PROCESS_ACCT
693 .maxlen
= 3*sizeof(int),
695 .proc_handler
= proc_dointvec
,
698 #ifdef CONFIG_MAGIC_SYSRQ
701 .data
= &__sysrq_enabled
,
702 .maxlen
= sizeof (int),
704 .proc_handler
= sysrq_sysctl_handler
,
707 #ifdef CONFIG_PROC_SYSCTL
709 .procname
= "cad_pid",
711 .maxlen
= sizeof (int),
713 .proc_handler
= proc_do_cad_pid
,
717 .procname
= "threads-max",
719 .maxlen
= sizeof(int),
721 .proc_handler
= sysctl_max_threads
,
724 .procname
= "random",
726 .child
= random_table
,
729 .procname
= "usermodehelper",
731 .child
= usermodehelper_table
,
734 .procname
= "overflowuid",
735 .data
= &overflowuid
,
736 .maxlen
= sizeof(int),
738 .proc_handler
= proc_dointvec_minmax
,
739 .extra1
= &minolduid
,
740 .extra2
= &maxolduid
,
743 .procname
= "overflowgid",
744 .data
= &overflowgid
,
745 .maxlen
= sizeof(int),
747 .proc_handler
= proc_dointvec_minmax
,
748 .extra1
= &minolduid
,
749 .extra2
= &maxolduid
,
752 #ifdef CONFIG_MATHEMU
754 .procname
= "ieee_emulation_warnings",
755 .data
= &sysctl_ieee_emulation_warnings
,
756 .maxlen
= sizeof(int),
758 .proc_handler
= proc_dointvec
,
762 .procname
= "userprocess_debug",
763 .data
= &show_unhandled_signals
,
764 .maxlen
= sizeof(int),
766 .proc_handler
= proc_dointvec
,
770 .procname
= "pid_max",
772 .maxlen
= sizeof (int),
774 .proc_handler
= proc_dointvec_minmax
,
775 .extra1
= &pid_max_min
,
776 .extra2
= &pid_max_max
,
779 .procname
= "panic_on_oops",
780 .data
= &panic_on_oops
,
781 .maxlen
= sizeof(int),
783 .proc_handler
= proc_dointvec
,
785 #if defined CONFIG_PRINTK
787 .procname
= "printk",
788 .data
= &console_loglevel
,
789 .maxlen
= 4*sizeof(int),
791 .proc_handler
= proc_dointvec
,
794 .procname
= "printk_ratelimit",
795 .data
= &printk_ratelimit_state
.interval
,
796 .maxlen
= sizeof(int),
798 .proc_handler
= proc_dointvec_jiffies
,
801 .procname
= "printk_ratelimit_burst",
802 .data
= &printk_ratelimit_state
.burst
,
803 .maxlen
= sizeof(int),
805 .proc_handler
= proc_dointvec
,
808 .procname
= "printk_delay",
809 .data
= &printk_delay_msec
,
810 .maxlen
= sizeof(int),
812 .proc_handler
= proc_dointvec_minmax
,
814 .extra2
= &ten_thousand
,
817 .procname
= "dmesg_restrict",
818 .data
= &dmesg_restrict
,
819 .maxlen
= sizeof(int),
821 .proc_handler
= proc_dointvec_minmax_sysadmin
,
826 .procname
= "kptr_restrict",
827 .data
= &kptr_restrict
,
828 .maxlen
= sizeof(int),
830 .proc_handler
= proc_dointvec_minmax_sysadmin
,
836 .procname
= "ngroups_max",
837 .data
= &ngroups_max
,
838 .maxlen
= sizeof (int),
840 .proc_handler
= proc_dointvec
,
843 .procname
= "cap_last_cap",
844 .data
= (void *)&cap_last_cap
,
845 .maxlen
= sizeof(int),
847 .proc_handler
= proc_dointvec
,
849 #if defined(CONFIG_LOCKUP_DETECTOR)
851 .procname
= "watchdog",
852 .data
= &watchdog_user_enabled
,
853 .maxlen
= sizeof (int),
855 .proc_handler
= proc_watchdog
,
860 .procname
= "watchdog_thresh",
861 .data
= &watchdog_thresh
,
862 .maxlen
= sizeof(int),
864 .proc_handler
= proc_watchdog_thresh
,
869 .procname
= "nmi_watchdog",
870 .data
= &nmi_watchdog_enabled
,
871 .maxlen
= sizeof (int),
873 .proc_handler
= proc_nmi_watchdog
,
875 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
882 .procname
= "soft_watchdog",
883 .data
= &soft_watchdog_enabled
,
884 .maxlen
= sizeof (int),
886 .proc_handler
= proc_soft_watchdog
,
891 .procname
= "watchdog_cpumask",
892 .data
= &watchdog_cpumask_bits
,
895 .proc_handler
= proc_watchdog_cpumask
,
898 .procname
= "softlockup_panic",
899 .data
= &softlockup_panic
,
900 .maxlen
= sizeof(int),
902 .proc_handler
= proc_dointvec_minmax
,
906 #ifdef CONFIG_HARDLOCKUP_DETECTOR
908 .procname
= "hardlockup_panic",
909 .data
= &hardlockup_panic
,
910 .maxlen
= sizeof(int),
912 .proc_handler
= proc_dointvec_minmax
,
919 .procname
= "softlockup_all_cpu_backtrace",
920 .data
= &sysctl_softlockup_all_cpu_backtrace
,
921 .maxlen
= sizeof(int),
923 .proc_handler
= proc_dointvec_minmax
,
928 .procname
= "hardlockup_all_cpu_backtrace",
929 .data
= &sysctl_hardlockup_all_cpu_backtrace
,
930 .maxlen
= sizeof(int),
932 .proc_handler
= proc_dointvec_minmax
,
936 #endif /* CONFIG_SMP */
938 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
940 .procname
= "unknown_nmi_panic",
941 .data
= &unknown_nmi_panic
,
942 .maxlen
= sizeof (int),
944 .proc_handler
= proc_dointvec
,
947 #if defined(CONFIG_X86)
949 .procname
= "panic_on_unrecovered_nmi",
950 .data
= &panic_on_unrecovered_nmi
,
951 .maxlen
= sizeof(int),
953 .proc_handler
= proc_dointvec
,
956 .procname
= "panic_on_io_nmi",
957 .data
= &panic_on_io_nmi
,
958 .maxlen
= sizeof(int),
960 .proc_handler
= proc_dointvec
,
962 #ifdef CONFIG_DEBUG_STACKOVERFLOW
964 .procname
= "panic_on_stackoverflow",
965 .data
= &sysctl_panic_on_stackoverflow
,
966 .maxlen
= sizeof(int),
968 .proc_handler
= proc_dointvec
,
972 .procname
= "bootloader_type",
973 .data
= &bootloader_type
,
974 .maxlen
= sizeof (int),
976 .proc_handler
= proc_dointvec
,
979 .procname
= "bootloader_version",
980 .data
= &bootloader_version
,
981 .maxlen
= sizeof (int),
983 .proc_handler
= proc_dointvec
,
986 .procname
= "kstack_depth_to_print",
987 .data
= &kstack_depth_to_print
,
988 .maxlen
= sizeof(int),
990 .proc_handler
= proc_dointvec
,
993 .procname
= "io_delay_type",
994 .data
= &io_delay_type
,
995 .maxlen
= sizeof(int),
997 .proc_handler
= proc_dointvec
,
1000 #if defined(CONFIG_MMU)
1002 .procname
= "randomize_va_space",
1003 .data
= &randomize_va_space
,
1004 .maxlen
= sizeof(int),
1006 .proc_handler
= proc_dointvec
,
1009 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1011 .procname
= "spin_retry",
1012 .data
= &spin_retry
,
1013 .maxlen
= sizeof (int),
1015 .proc_handler
= proc_dointvec
,
1018 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1020 .procname
= "acpi_video_flags",
1021 .data
= &acpi_realmode_flags
,
1022 .maxlen
= sizeof (unsigned long),
1024 .proc_handler
= proc_doulongvec_minmax
,
1027 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1029 .procname
= "ignore-unaligned-usertrap",
1030 .data
= &no_unaligned_warning
,
1031 .maxlen
= sizeof (int),
1033 .proc_handler
= proc_dointvec
,
1038 .procname
= "unaligned-dump-stack",
1039 .data
= &unaligned_dump_stack
,
1040 .maxlen
= sizeof (int),
1042 .proc_handler
= proc_dointvec
,
1045 #ifdef CONFIG_DETECT_HUNG_TASK
1047 .procname
= "hung_task_panic",
1048 .data
= &sysctl_hung_task_panic
,
1049 .maxlen
= sizeof(int),
1051 .proc_handler
= proc_dointvec_minmax
,
1056 .procname
= "hung_task_check_count",
1057 .data
= &sysctl_hung_task_check_count
,
1058 .maxlen
= sizeof(int),
1060 .proc_handler
= proc_dointvec_minmax
,
1064 .procname
= "hung_task_timeout_secs",
1065 .data
= &sysctl_hung_task_timeout_secs
,
1066 .maxlen
= sizeof(unsigned long),
1068 .proc_handler
= proc_dohung_task_timeout_secs
,
1069 .extra2
= &hung_task_timeout_max
,
1072 .procname
= "hung_task_warnings",
1073 .data
= &sysctl_hung_task_warnings
,
1074 .maxlen
= sizeof(int),
1076 .proc_handler
= proc_dointvec_minmax
,
1080 #ifdef CONFIG_COMPAT
1082 .procname
= "compat-log",
1083 .data
= &compat_log
,
1084 .maxlen
= sizeof (int),
1086 .proc_handler
= proc_dointvec
,
1089 #ifdef CONFIG_RT_MUTEXES
1091 .procname
= "max_lock_depth",
1092 .data
= &max_lock_depth
,
1093 .maxlen
= sizeof(int),
1095 .proc_handler
= proc_dointvec
,
1099 .procname
= "poweroff_cmd",
1100 .data
= &poweroff_cmd
,
1101 .maxlen
= POWEROFF_CMD_PATH_LEN
,
1103 .proc_handler
= proc_dostring
,
1109 .child
= key_sysctls
,
1112 #ifdef CONFIG_PERF_EVENTS
1114 * User-space scripts rely on the existence of this file
1115 * as a feature check for perf_events being enabled.
1117 * So it's an ABI, do not remove!
1120 .procname
= "perf_event_paranoid",
1121 .data
= &sysctl_perf_event_paranoid
,
1122 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
1124 .proc_handler
= proc_dointvec
,
1127 .procname
= "perf_event_mlock_kb",
1128 .data
= &sysctl_perf_event_mlock
,
1129 .maxlen
= sizeof(sysctl_perf_event_mlock
),
1131 .proc_handler
= proc_dointvec
,
1134 .procname
= "perf_event_max_sample_rate",
1135 .data
= &sysctl_perf_event_sample_rate
,
1136 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1138 .proc_handler
= perf_proc_update_handler
,
1142 .procname
= "perf_cpu_time_max_percent",
1143 .data
= &sysctl_perf_cpu_time_max_percent
,
1144 .maxlen
= sizeof(sysctl_perf_cpu_time_max_percent
),
1146 .proc_handler
= perf_cpu_time_max_percent_handler
,
1148 .extra2
= &one_hundred
,
1151 .procname
= "perf_event_max_stack",
1152 .data
= &sysctl_perf_event_max_stack
,
1153 .maxlen
= sizeof(sysctl_perf_event_max_stack
),
1155 .proc_handler
= perf_event_max_stack_handler
,
1157 .extra2
= &six_hundred_forty_kb
,
1160 .procname
= "perf_event_max_contexts_per_stack",
1161 .data
= &sysctl_perf_event_max_contexts_per_stack
,
1162 .maxlen
= sizeof(sysctl_perf_event_max_contexts_per_stack
),
1164 .proc_handler
= perf_event_max_stack_handler
,
1166 .extra2
= &one_thousand
,
1169 #ifdef CONFIG_KMEMCHECK
1171 .procname
= "kmemcheck",
1172 .data
= &kmemcheck_enabled
,
1173 .maxlen
= sizeof(int),
1175 .proc_handler
= proc_dointvec
,
1179 .procname
= "panic_on_warn",
1180 .data
= &panic_on_warn
,
1181 .maxlen
= sizeof(int),
1183 .proc_handler
= proc_dointvec_minmax
,
1187 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1189 .procname
= "timer_migration",
1190 .data
= &sysctl_timer_migration
,
1191 .maxlen
= sizeof(unsigned int),
1193 .proc_handler
= timer_migration_handler
,
1196 #ifdef CONFIG_BPF_SYSCALL
1198 .procname
= "unprivileged_bpf_disabled",
1199 .data
= &sysctl_unprivileged_bpf_disabled
,
1200 .maxlen
= sizeof(sysctl_unprivileged_bpf_disabled
),
1202 /* only handle a transition from default "0" to "1" */
1203 .proc_handler
= proc_dointvec_minmax
,
1211 static struct ctl_table vm_table
[] = {
1213 .procname
= "overcommit_memory",
1214 .data
= &sysctl_overcommit_memory
,
1215 .maxlen
= sizeof(sysctl_overcommit_memory
),
1217 .proc_handler
= proc_dointvec_minmax
,
1222 .procname
= "panic_on_oom",
1223 .data
= &sysctl_panic_on_oom
,
1224 .maxlen
= sizeof(sysctl_panic_on_oom
),
1226 .proc_handler
= proc_dointvec_minmax
,
1231 .procname
= "oom_kill_allocating_task",
1232 .data
= &sysctl_oom_kill_allocating_task
,
1233 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
1235 .proc_handler
= proc_dointvec
,
1238 .procname
= "oom_dump_tasks",
1239 .data
= &sysctl_oom_dump_tasks
,
1240 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
1242 .proc_handler
= proc_dointvec
,
1245 .procname
= "overcommit_ratio",
1246 .data
= &sysctl_overcommit_ratio
,
1247 .maxlen
= sizeof(sysctl_overcommit_ratio
),
1249 .proc_handler
= overcommit_ratio_handler
,
1252 .procname
= "overcommit_kbytes",
1253 .data
= &sysctl_overcommit_kbytes
,
1254 .maxlen
= sizeof(sysctl_overcommit_kbytes
),
1256 .proc_handler
= overcommit_kbytes_handler
,
1259 .procname
= "page-cluster",
1260 .data
= &page_cluster
,
1261 .maxlen
= sizeof(int),
1263 .proc_handler
= proc_dointvec_minmax
,
1267 .procname
= "dirty_background_ratio",
1268 .data
= &dirty_background_ratio
,
1269 .maxlen
= sizeof(dirty_background_ratio
),
1271 .proc_handler
= dirty_background_ratio_handler
,
1273 .extra2
= &one_hundred
,
1276 .procname
= "dirty_background_bytes",
1277 .data
= &dirty_background_bytes
,
1278 .maxlen
= sizeof(dirty_background_bytes
),
1280 .proc_handler
= dirty_background_bytes_handler
,
1284 .procname
= "dirty_ratio",
1285 .data
= &vm_dirty_ratio
,
1286 .maxlen
= sizeof(vm_dirty_ratio
),
1288 .proc_handler
= dirty_ratio_handler
,
1290 .extra2
= &one_hundred
,
1293 .procname
= "dirty_bytes",
1294 .data
= &vm_dirty_bytes
,
1295 .maxlen
= sizeof(vm_dirty_bytes
),
1297 .proc_handler
= dirty_bytes_handler
,
1298 .extra1
= &dirty_bytes_min
,
1301 .procname
= "dirty_writeback_centisecs",
1302 .data
= &dirty_writeback_interval
,
1303 .maxlen
= sizeof(dirty_writeback_interval
),
1305 .proc_handler
= dirty_writeback_centisecs_handler
,
1308 .procname
= "dirty_expire_centisecs",
1309 .data
= &dirty_expire_interval
,
1310 .maxlen
= sizeof(dirty_expire_interval
),
1312 .proc_handler
= proc_dointvec_minmax
,
1316 .procname
= "dirtytime_expire_seconds",
1317 .data
= &dirtytime_expire_interval
,
1318 .maxlen
= sizeof(dirty_expire_interval
),
1320 .proc_handler
= dirtytime_interval_handler
,
1324 .procname
= "nr_pdflush_threads",
1325 .mode
= 0444 /* read-only */,
1326 .proc_handler
= pdflush_proc_obsolete
,
1329 .procname
= "swappiness",
1330 .data
= &vm_swappiness
,
1331 .maxlen
= sizeof(vm_swappiness
),
1333 .proc_handler
= proc_dointvec_minmax
,
1335 .extra2
= &one_hundred
,
1337 #ifdef CONFIG_HUGETLB_PAGE
1339 .procname
= "nr_hugepages",
1341 .maxlen
= sizeof(unsigned long),
1343 .proc_handler
= hugetlb_sysctl_handler
,
1347 .procname
= "nr_hugepages_mempolicy",
1349 .maxlen
= sizeof(unsigned long),
1351 .proc_handler
= &hugetlb_mempolicy_sysctl_handler
,
1355 .procname
= "hugetlb_shm_group",
1356 .data
= &sysctl_hugetlb_shm_group
,
1357 .maxlen
= sizeof(gid_t
),
1359 .proc_handler
= proc_dointvec
,
1362 .procname
= "hugepages_treat_as_movable",
1363 .data
= &hugepages_treat_as_movable
,
1364 .maxlen
= sizeof(int),
1366 .proc_handler
= proc_dointvec
,
1369 .procname
= "nr_overcommit_hugepages",
1371 .maxlen
= sizeof(unsigned long),
1373 .proc_handler
= hugetlb_overcommit_handler
,
1377 .procname
= "lowmem_reserve_ratio",
1378 .data
= &sysctl_lowmem_reserve_ratio
,
1379 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
1381 .proc_handler
= lowmem_reserve_ratio_sysctl_handler
,
1384 .procname
= "drop_caches",
1385 .data
= &sysctl_drop_caches
,
1386 .maxlen
= sizeof(int),
1388 .proc_handler
= drop_caches_sysctl_handler
,
1392 #ifdef CONFIG_COMPACTION
1394 .procname
= "compact_memory",
1395 .data
= &sysctl_compact_memory
,
1396 .maxlen
= sizeof(int),
1398 .proc_handler
= sysctl_compaction_handler
,
1401 .procname
= "extfrag_threshold",
1402 .data
= &sysctl_extfrag_threshold
,
1403 .maxlen
= sizeof(int),
1405 .proc_handler
= sysctl_extfrag_handler
,
1406 .extra1
= &min_extfrag_threshold
,
1407 .extra2
= &max_extfrag_threshold
,
1410 .procname
= "compact_unevictable_allowed",
1411 .data
= &sysctl_compact_unevictable_allowed
,
1412 .maxlen
= sizeof(int),
1414 .proc_handler
= proc_dointvec
,
1419 #endif /* CONFIG_COMPACTION */
1421 .procname
= "min_free_kbytes",
1422 .data
= &min_free_kbytes
,
1423 .maxlen
= sizeof(min_free_kbytes
),
1425 .proc_handler
= min_free_kbytes_sysctl_handler
,
1429 .procname
= "watermark_scale_factor",
1430 .data
= &watermark_scale_factor
,
1431 .maxlen
= sizeof(watermark_scale_factor
),
1433 .proc_handler
= watermark_scale_factor_sysctl_handler
,
1435 .extra2
= &one_thousand
,
1438 .procname
= "percpu_pagelist_fraction",
1439 .data
= &percpu_pagelist_fraction
,
1440 .maxlen
= sizeof(percpu_pagelist_fraction
),
1442 .proc_handler
= percpu_pagelist_fraction_sysctl_handler
,
1447 .procname
= "max_map_count",
1448 .data
= &sysctl_max_map_count
,
1449 .maxlen
= sizeof(sysctl_max_map_count
),
1451 .proc_handler
= proc_dointvec_minmax
,
1456 .procname
= "nr_trim_pages",
1457 .data
= &sysctl_nr_trim_pages
,
1458 .maxlen
= sizeof(sysctl_nr_trim_pages
),
1460 .proc_handler
= proc_dointvec_minmax
,
1465 .procname
= "laptop_mode",
1466 .data
= &laptop_mode
,
1467 .maxlen
= sizeof(laptop_mode
),
1469 .proc_handler
= proc_dointvec_jiffies
,
1472 .procname
= "block_dump",
1473 .data
= &block_dump
,
1474 .maxlen
= sizeof(block_dump
),
1476 .proc_handler
= proc_dointvec
,
1480 .procname
= "vfs_cache_pressure",
1481 .data
= &sysctl_vfs_cache_pressure
,
1482 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1484 .proc_handler
= proc_dointvec
,
1487 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1489 .procname
= "legacy_va_layout",
1490 .data
= &sysctl_legacy_va_layout
,
1491 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1493 .proc_handler
= proc_dointvec
,
1499 .procname
= "zone_reclaim_mode",
1500 .data
= &zone_reclaim_mode
,
1501 .maxlen
= sizeof(zone_reclaim_mode
),
1503 .proc_handler
= proc_dointvec
,
1507 .procname
= "min_unmapped_ratio",
1508 .data
= &sysctl_min_unmapped_ratio
,
1509 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1511 .proc_handler
= sysctl_min_unmapped_ratio_sysctl_handler
,
1513 .extra2
= &one_hundred
,
1516 .procname
= "min_slab_ratio",
1517 .data
= &sysctl_min_slab_ratio
,
1518 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1520 .proc_handler
= sysctl_min_slab_ratio_sysctl_handler
,
1522 .extra2
= &one_hundred
,
1527 .procname
= "stat_interval",
1528 .data
= &sysctl_stat_interval
,
1529 .maxlen
= sizeof(sysctl_stat_interval
),
1531 .proc_handler
= proc_dointvec_jiffies
,
1534 .procname
= "stat_refresh",
1538 .proc_handler
= vmstat_refresh
,
1543 .procname
= "mmap_min_addr",
1544 .data
= &dac_mmap_min_addr
,
1545 .maxlen
= sizeof(unsigned long),
1547 .proc_handler
= mmap_min_addr_handler
,
1552 .procname
= "numa_zonelist_order",
1553 .data
= &numa_zonelist_order
,
1554 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1556 .proc_handler
= numa_zonelist_order_handler
,
1559 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1560 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1562 .procname
= "vdso_enabled",
1563 #ifdef CONFIG_X86_32
1564 .data
= &vdso32_enabled
,
1565 .maxlen
= sizeof(vdso32_enabled
),
1567 .data
= &vdso_enabled
,
1568 .maxlen
= sizeof(vdso_enabled
),
1571 .proc_handler
= proc_dointvec
,
1575 #ifdef CONFIG_HIGHMEM
1577 .procname
= "highmem_is_dirtyable",
1578 .data
= &vm_highmem_is_dirtyable
,
1579 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
1581 .proc_handler
= proc_dointvec_minmax
,
1586 #ifdef CONFIG_MEMORY_FAILURE
1588 .procname
= "memory_failure_early_kill",
1589 .data
= &sysctl_memory_failure_early_kill
,
1590 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
1592 .proc_handler
= proc_dointvec_minmax
,
1597 .procname
= "memory_failure_recovery",
1598 .data
= &sysctl_memory_failure_recovery
,
1599 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
1601 .proc_handler
= proc_dointvec_minmax
,
1607 .procname
= "user_reserve_kbytes",
1608 .data
= &sysctl_user_reserve_kbytes
,
1609 .maxlen
= sizeof(sysctl_user_reserve_kbytes
),
1611 .proc_handler
= proc_doulongvec_minmax
,
1614 .procname
= "admin_reserve_kbytes",
1615 .data
= &sysctl_admin_reserve_kbytes
,
1616 .maxlen
= sizeof(sysctl_admin_reserve_kbytes
),
1618 .proc_handler
= proc_doulongvec_minmax
,
1620 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1622 .procname
= "mmap_rnd_bits",
1623 .data
= &mmap_rnd_bits
,
1624 .maxlen
= sizeof(mmap_rnd_bits
),
1626 .proc_handler
= proc_dointvec_minmax
,
1627 .extra1
= (void *)&mmap_rnd_bits_min
,
1628 .extra2
= (void *)&mmap_rnd_bits_max
,
1631 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1633 .procname
= "mmap_rnd_compat_bits",
1634 .data
= &mmap_rnd_compat_bits
,
1635 .maxlen
= sizeof(mmap_rnd_compat_bits
),
1637 .proc_handler
= proc_dointvec_minmax
,
1638 .extra1
= (void *)&mmap_rnd_compat_bits_min
,
1639 .extra2
= (void *)&mmap_rnd_compat_bits_max
,
1645 static struct ctl_table fs_table
[] = {
1647 .procname
= "inode-nr",
1648 .data
= &inodes_stat
,
1649 .maxlen
= 2*sizeof(long),
1651 .proc_handler
= proc_nr_inodes
,
1654 .procname
= "inode-state",
1655 .data
= &inodes_stat
,
1656 .maxlen
= 7*sizeof(long),
1658 .proc_handler
= proc_nr_inodes
,
1661 .procname
= "file-nr",
1662 .data
= &files_stat
,
1663 .maxlen
= sizeof(files_stat
),
1665 .proc_handler
= proc_nr_files
,
1668 .procname
= "file-max",
1669 .data
= &files_stat
.max_files
,
1670 .maxlen
= sizeof(files_stat
.max_files
),
1672 .proc_handler
= proc_doulongvec_minmax
,
1675 .procname
= "nr_open",
1676 .data
= &sysctl_nr_open
,
1677 .maxlen
= sizeof(int),
1679 .proc_handler
= proc_dointvec_minmax
,
1680 .extra1
= &sysctl_nr_open_min
,
1681 .extra2
= &sysctl_nr_open_max
,
1684 .procname
= "dentry-state",
1685 .data
= &dentry_stat
,
1686 .maxlen
= 6*sizeof(long),
1688 .proc_handler
= proc_nr_dentry
,
1691 .procname
= "overflowuid",
1692 .data
= &fs_overflowuid
,
1693 .maxlen
= sizeof(int),
1695 .proc_handler
= proc_dointvec_minmax
,
1696 .extra1
= &minolduid
,
1697 .extra2
= &maxolduid
,
1700 .procname
= "overflowgid",
1701 .data
= &fs_overflowgid
,
1702 .maxlen
= sizeof(int),
1704 .proc_handler
= proc_dointvec_minmax
,
1705 .extra1
= &minolduid
,
1706 .extra2
= &maxolduid
,
1708 #ifdef CONFIG_FILE_LOCKING
1710 .procname
= "leases-enable",
1711 .data
= &leases_enable
,
1712 .maxlen
= sizeof(int),
1714 .proc_handler
= proc_dointvec
,
1717 #ifdef CONFIG_DNOTIFY
1719 .procname
= "dir-notify-enable",
1720 .data
= &dir_notify_enable
,
1721 .maxlen
= sizeof(int),
1723 .proc_handler
= proc_dointvec
,
1727 #ifdef CONFIG_FILE_LOCKING
1729 .procname
= "lease-break-time",
1730 .data
= &lease_break_time
,
1731 .maxlen
= sizeof(int),
1733 .proc_handler
= proc_dointvec
,
1738 .procname
= "aio-nr",
1740 .maxlen
= sizeof(aio_nr
),
1742 .proc_handler
= proc_doulongvec_minmax
,
1745 .procname
= "aio-max-nr",
1746 .data
= &aio_max_nr
,
1747 .maxlen
= sizeof(aio_max_nr
),
1749 .proc_handler
= proc_doulongvec_minmax
,
1751 #endif /* CONFIG_AIO */
1752 #ifdef CONFIG_INOTIFY_USER
1754 .procname
= "inotify",
1756 .child
= inotify_table
,
1761 .procname
= "epoll",
1763 .child
= epoll_table
,
1768 .procname
= "protected_symlinks",
1769 .data
= &sysctl_protected_symlinks
,
1770 .maxlen
= sizeof(int),
1772 .proc_handler
= proc_dointvec_minmax
,
1777 .procname
= "protected_hardlinks",
1778 .data
= &sysctl_protected_hardlinks
,
1779 .maxlen
= sizeof(int),
1781 .proc_handler
= proc_dointvec_minmax
,
1786 .procname
= "suid_dumpable",
1787 .data
= &suid_dumpable
,
1788 .maxlen
= sizeof(int),
1790 .proc_handler
= proc_dointvec_minmax_coredump
,
1794 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1796 .procname
= "binfmt_misc",
1798 .child
= sysctl_mount_point
,
1802 .procname
= "pipe-max-size",
1803 .data
= &pipe_max_size
,
1804 .maxlen
= sizeof(int),
1806 .proc_handler
= &pipe_proc_fn
,
1807 .extra1
= &pipe_min_size
,
1810 .procname
= "pipe-user-pages-hard",
1811 .data
= &pipe_user_pages_hard
,
1812 .maxlen
= sizeof(pipe_user_pages_hard
),
1814 .proc_handler
= proc_doulongvec_minmax
,
1817 .procname
= "pipe-user-pages-soft",
1818 .data
= &pipe_user_pages_soft
,
1819 .maxlen
= sizeof(pipe_user_pages_soft
),
1821 .proc_handler
= proc_doulongvec_minmax
,
1826 static struct ctl_table debug_table
[] = {
1827 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1829 .procname
= "exception-trace",
1830 .data
= &show_unhandled_signals
,
1831 .maxlen
= sizeof(int),
1833 .proc_handler
= proc_dointvec
1836 #if defined(CONFIG_OPTPROBES)
1838 .procname
= "kprobes-optimization",
1839 .data
= &sysctl_kprobes_optimization
,
1840 .maxlen
= sizeof(int),
1842 .proc_handler
= proc_kprobes_optimization_handler
,
1850 static struct ctl_table dev_table
[] = {
1854 int __init
sysctl_init(void)
1856 struct ctl_table_header
*hdr
;
1858 hdr
= register_sysctl_table(sysctl_base_table
);
1859 kmemleak_not_leak(hdr
);
1863 #endif /* CONFIG_SYSCTL */
1869 #ifdef CONFIG_PROC_SYSCTL
1871 static int _proc_do_string(char *data
, int maxlen
, int write
,
1872 char __user
*buffer
,
1873 size_t *lenp
, loff_t
*ppos
)
1879 if (!data
|| !maxlen
|| !*lenp
) {
1885 if (sysctl_writes_strict
== SYSCTL_WRITES_STRICT
) {
1886 /* Only continue writes not past the end of buffer. */
1888 if (len
> maxlen
- 1)
1895 /* Start writing from beginning of buffer. */
1901 while ((p
- buffer
) < *lenp
&& len
< maxlen
- 1) {
1902 if (get_user(c
, p
++))
1904 if (c
== 0 || c
== '\n')
1925 if (copy_to_user(buffer
, data
, len
))
1928 if (put_user('\n', buffer
+ len
))
1938 static void warn_sysctl_write(struct ctl_table
*table
)
1940 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1941 "This will not be supported in the future. To silence this\n"
1942 "warning, set kernel.sysctl_writes_strict = -1\n",
1943 current
->comm
, table
->procname
);
1947 * proc_dostring - read a string sysctl
1948 * @table: the sysctl table
1949 * @write: %TRUE if this is a write to the sysctl file
1950 * @buffer: the user buffer
1951 * @lenp: the size of the user buffer
1952 * @ppos: file position
1954 * Reads/writes a string from/to the user buffer. If the kernel
1955 * buffer provided is not large enough to hold the string, the
1956 * string is truncated. The copied string is %NULL-terminated.
1957 * If the string is being read by the user process, it is copied
1958 * and a newline '\n' is added. It is truncated if the buffer is
1961 * Returns 0 on success.
1963 int proc_dostring(struct ctl_table
*table
, int write
,
1964 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1966 if (write
&& *ppos
&& sysctl_writes_strict
== SYSCTL_WRITES_WARN
)
1967 warn_sysctl_write(table
);
1969 return _proc_do_string((char *)(table
->data
), table
->maxlen
, write
,
1970 (char __user
*)buffer
, lenp
, ppos
);
1973 static size_t proc_skip_spaces(char **buf
)
1976 char *tmp
= skip_spaces(*buf
);
1982 static void proc_skip_char(char **buf
, size_t *size
, const char v
)
1992 #define TMPBUFLEN 22
1994 * proc_get_long - reads an ASCII formatted integer from a user buffer
1996 * @buf: a kernel buffer
1997 * @size: size of the kernel buffer
1998 * @val: this is where the number will be stored
1999 * @neg: set to %TRUE if number is negative
2000 * @perm_tr: a vector which contains the allowed trailers
2001 * @perm_tr_len: size of the perm_tr vector
2002 * @tr: pointer to store the trailer character
2004 * In case of success %0 is returned and @buf and @size are updated with
2005 * the amount of bytes read. If @tr is non-NULL and a trailing
2006 * character exists (size is non-zero after returning from this
2007 * function), @tr is updated with the trailing character.
2009 static int proc_get_long(char **buf
, size_t *size
,
2010 unsigned long *val
, bool *neg
,
2011 const char *perm_tr
, unsigned perm_tr_len
, char *tr
)
2014 char *p
, tmp
[TMPBUFLEN
];
2020 if (len
> TMPBUFLEN
- 1)
2021 len
= TMPBUFLEN
- 1;
2023 memcpy(tmp
, *buf
, len
);
2027 if (*p
== '-' && *size
> 1) {
2035 *val
= simple_strtoul(p
, &p
, 0);
2039 /* We don't know if the next char is whitespace thus we may accept
2040 * invalid integers (e.g. 1234...a) or two integers instead of one
2041 * (e.g. 123...1). So lets not allow such large numbers. */
2042 if (len
== TMPBUFLEN
- 1)
2045 if (len
< *size
&& perm_tr_len
&& !memchr(perm_tr
, *p
, perm_tr_len
))
2048 if (tr
&& (len
< *size
))
2058 * proc_put_long - converts an integer to a decimal ASCII formatted string
2060 * @buf: the user buffer
2061 * @size: the size of the user buffer
2062 * @val: the integer to be converted
2063 * @neg: sign of the number, %TRUE for negative
2065 * In case of success %0 is returned and @buf and @size are updated with
2066 * the amount of bytes written.
2068 static int proc_put_long(void __user
**buf
, size_t *size
, unsigned long val
,
2072 char tmp
[TMPBUFLEN
], *p
= tmp
;
2074 sprintf(p
, "%s%lu", neg
? "-" : "", val
);
2078 if (copy_to_user(*buf
, tmp
, len
))
2086 static int proc_put_char(void __user
**buf
, size_t *size
, char c
)
2089 char __user
**buffer
= (char __user
**)buf
;
2090 if (put_user(c
, *buffer
))
2092 (*size
)--, (*buffer
)++;
2098 static int do_proc_dointvec_conv(bool *negp
, unsigned long *lvalp
,
2100 int write
, void *data
)
2104 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2108 if (*lvalp
> (unsigned long) INT_MAX
)
2116 *lvalp
= -(unsigned long)val
;
2119 *lvalp
= (unsigned long)val
;
2125 static const char proc_wspace_sep
[] = { ' ', '\t', '\n' };
2127 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2128 int write
, void __user
*buffer
,
2129 size_t *lenp
, loff_t
*ppos
,
2130 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2131 int write
, void *data
),
2134 int *i
, vleft
, first
= 1, err
= 0;
2136 char *kbuf
= NULL
, *p
;
2138 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2143 i
= (int *) tbl_data
;
2144 vleft
= table
->maxlen
/ sizeof(*i
);
2148 conv
= do_proc_dointvec_conv
;
2152 switch (sysctl_writes_strict
) {
2153 case SYSCTL_WRITES_STRICT
:
2155 case SYSCTL_WRITES_WARN
:
2156 warn_sysctl_write(table
);
2163 if (left
> PAGE_SIZE
- 1)
2164 left
= PAGE_SIZE
- 1;
2165 p
= kbuf
= memdup_user_nul(buffer
, left
);
2167 return PTR_ERR(kbuf
);
2170 for (; left
&& vleft
--; i
++, first
=0) {
2175 left
-= proc_skip_spaces(&p
);
2179 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2181 sizeof(proc_wspace_sep
), NULL
);
2184 if (conv(&neg
, &lval
, i
, 1, data
)) {
2189 if (conv(&neg
, &lval
, i
, 0, data
)) {
2194 err
= proc_put_char(&buffer
, &left
, '\t');
2197 err
= proc_put_long(&buffer
, &left
, lval
, neg
);
2203 if (!write
&& !first
&& left
&& !err
)
2204 err
= proc_put_char(&buffer
, &left
, '\n');
2205 if (write
&& !err
&& left
)
2206 left
-= proc_skip_spaces(&p
);
2210 return err
? : -EINVAL
;
2218 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2219 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2220 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2221 int write
, void *data
),
2224 return __do_proc_dointvec(table
->data
, table
, write
,
2225 buffer
, lenp
, ppos
, conv
, data
);
2229 * proc_dointvec - read a vector of integers
2230 * @table: the sysctl table
2231 * @write: %TRUE if this is a write to the sysctl file
2232 * @buffer: the user buffer
2233 * @lenp: the size of the user buffer
2234 * @ppos: file position
2236 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2237 * values from/to the user buffer, treated as an ASCII string.
2239 * Returns 0 on success.
2241 int proc_dointvec(struct ctl_table
*table
, int write
,
2242 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2244 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2249 * Taint values can only be increased
2250 * This means we can safely use a temporary.
2252 static int proc_taint(struct ctl_table
*table
, int write
,
2253 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2256 unsigned long tmptaint
= get_taint();
2259 if (write
&& !capable(CAP_SYS_ADMIN
))
2264 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2270 * Poor man's atomic or. Not worth adding a primitive
2271 * to everyone's atomic.h for this
2274 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2275 if ((tmptaint
>> i
) & 1)
2276 add_taint(i
, LOCKDEP_STILL_OK
);
2283 #ifdef CONFIG_PRINTK
2284 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
2285 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2287 if (write
&& !capable(CAP_SYS_ADMIN
))
2290 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2294 struct do_proc_dointvec_minmax_conv_param
{
2299 static int do_proc_dointvec_minmax_conv(bool *negp
, unsigned long *lvalp
,
2301 int write
, void *data
)
2303 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2305 int val
= *negp
? -*lvalp
: *lvalp
;
2306 if ((param
->min
&& *param
->min
> val
) ||
2307 (param
->max
&& *param
->max
< val
))
2314 *lvalp
= -(unsigned long)val
;
2317 *lvalp
= (unsigned long)val
;
2324 * proc_dointvec_minmax - read a vector of integers with min/max values
2325 * @table: the sysctl table
2326 * @write: %TRUE if this is a write to the sysctl file
2327 * @buffer: the user buffer
2328 * @lenp: the size of the user buffer
2329 * @ppos: file position
2331 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2332 * values from/to the user buffer, treated as an ASCII string.
2334 * This routine will ensure the values are within the range specified by
2335 * table->extra1 (min) and table->extra2 (max).
2337 * Returns 0 on success.
2339 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2340 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2342 struct do_proc_dointvec_minmax_conv_param param
= {
2343 .min
= (int *) table
->extra1
,
2344 .max
= (int *) table
->extra2
,
2346 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2347 do_proc_dointvec_minmax_conv
, ¶m
);
2350 static void validate_coredump_safety(void)
2352 #ifdef CONFIG_COREDUMP
2353 if (suid_dumpable
== SUID_DUMP_ROOT
&&
2354 core_pattern
[0] != '/' && core_pattern
[0] != '|') {
2355 printk(KERN_WARNING
"Unsafe core_pattern used with "\
2356 "suid_dumpable=2. Pipe handler or fully qualified "\
2357 "core dump path required.\n");
2362 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
2363 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2365 int error
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2367 validate_coredump_safety();
2371 #ifdef CONFIG_COREDUMP
2372 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
2373 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2375 int error
= proc_dostring(table
, write
, buffer
, lenp
, ppos
);
2377 validate_coredump_safety();
2382 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2383 void __user
*buffer
,
2384 size_t *lenp
, loff_t
*ppos
,
2385 unsigned long convmul
,
2386 unsigned long convdiv
)
2388 unsigned long *i
, *min
, *max
;
2389 int vleft
, first
= 1, err
= 0;
2391 char *kbuf
= NULL
, *p
;
2393 if (!data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2398 i
= (unsigned long *) data
;
2399 min
= (unsigned long *) table
->extra1
;
2400 max
= (unsigned long *) table
->extra2
;
2401 vleft
= table
->maxlen
/ sizeof(unsigned long);
2406 switch (sysctl_writes_strict
) {
2407 case SYSCTL_WRITES_STRICT
:
2409 case SYSCTL_WRITES_WARN
:
2410 warn_sysctl_write(table
);
2417 if (left
> PAGE_SIZE
- 1)
2418 left
= PAGE_SIZE
- 1;
2419 p
= kbuf
= memdup_user_nul(buffer
, left
);
2421 return PTR_ERR(kbuf
);
2424 for (; left
&& vleft
--; i
++, first
= 0) {
2430 left
-= proc_skip_spaces(&p
);
2432 err
= proc_get_long(&p
, &left
, &val
, &neg
,
2434 sizeof(proc_wspace_sep
), NULL
);
2439 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2443 val
= convdiv
* (*i
) / convmul
;
2445 err
= proc_put_char(&buffer
, &left
, '\t');
2449 err
= proc_put_long(&buffer
, &left
, val
, false);
2455 if (!write
&& !first
&& left
&& !err
)
2456 err
= proc_put_char(&buffer
, &left
, '\n');
2458 left
-= proc_skip_spaces(&p
);
2462 return err
? : -EINVAL
;
2470 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2471 void __user
*buffer
,
2472 size_t *lenp
, loff_t
*ppos
,
2473 unsigned long convmul
,
2474 unsigned long convdiv
)
2476 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2477 buffer
, lenp
, ppos
, convmul
, convdiv
);
2481 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2482 * @table: the sysctl table
2483 * @write: %TRUE if this is a write to the sysctl file
2484 * @buffer: the user buffer
2485 * @lenp: the size of the user buffer
2486 * @ppos: file position
2488 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2489 * values from/to the user buffer, treated as an ASCII string.
2491 * This routine will ensure the values are within the range specified by
2492 * table->extra1 (min) and table->extra2 (max).
2494 * Returns 0 on success.
2496 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2497 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2499 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2503 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2504 * @table: the sysctl table
2505 * @write: %TRUE if this is a write to the sysctl file
2506 * @buffer: the user buffer
2507 * @lenp: the size of the user buffer
2508 * @ppos: file position
2510 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2511 * values from/to the user buffer, treated as an ASCII string. The values
2512 * are treated as milliseconds, and converted to jiffies when they are stored.
2514 * This routine will ensure the values are within the range specified by
2515 * table->extra1 (min) and table->extra2 (max).
2517 * Returns 0 on success.
2519 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2520 void __user
*buffer
,
2521 size_t *lenp
, loff_t
*ppos
)
2523 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2524 lenp
, ppos
, HZ
, 1000l);
2528 static int do_proc_dointvec_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2530 int write
, void *data
)
2533 if (*lvalp
> LONG_MAX
/ HZ
)
2535 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2541 lval
= -(unsigned long)val
;
2544 lval
= (unsigned long)val
;
2551 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2553 int write
, void *data
)
2556 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2558 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2564 lval
= -(unsigned long)val
;
2567 lval
= (unsigned long)val
;
2569 *lvalp
= jiffies_to_clock_t(lval
);
2574 static int do_proc_dointvec_ms_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2576 int write
, void *data
)
2579 unsigned long jif
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2589 lval
= -(unsigned long)val
;
2592 lval
= (unsigned long)val
;
2594 *lvalp
= jiffies_to_msecs(lval
);
2600 * proc_dointvec_jiffies - read a vector of integers as seconds
2601 * @table: the sysctl table
2602 * @write: %TRUE if this is a write to the sysctl file
2603 * @buffer: the user buffer
2604 * @lenp: the size of the user buffer
2605 * @ppos: file position
2607 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2608 * values from/to the user buffer, treated as an ASCII string.
2609 * The values read are assumed to be in seconds, and are converted into
2612 * Returns 0 on success.
2614 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2615 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2617 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2618 do_proc_dointvec_jiffies_conv
,NULL
);
2622 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2623 * @table: the sysctl table
2624 * @write: %TRUE if this is a write to the sysctl file
2625 * @buffer: the user buffer
2626 * @lenp: the size of the user buffer
2627 * @ppos: pointer to the file position
2629 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2630 * values from/to the user buffer, treated as an ASCII string.
2631 * The values read are assumed to be in 1/USER_HZ seconds, and
2632 * are converted into jiffies.
2634 * Returns 0 on success.
2636 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2637 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2639 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2640 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2644 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2645 * @table: the sysctl table
2646 * @write: %TRUE if this is a write to the sysctl file
2647 * @buffer: the user buffer
2648 * @lenp: the size of the user buffer
2649 * @ppos: file position
2650 * @ppos: the current position in the file
2652 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2653 * values from/to the user buffer, treated as an ASCII string.
2654 * The values read are assumed to be in 1/1000 seconds, and
2655 * are converted into jiffies.
2657 * Returns 0 on success.
2659 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2660 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2662 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2663 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2666 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
2667 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2669 struct pid
*new_pid
;
2673 tmp
= pid_vnr(cad_pid
);
2675 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
2676 lenp
, ppos
, NULL
, NULL
);
2680 new_pid
= find_get_pid(tmp
);
2684 put_pid(xchg(&cad_pid
, new_pid
));
2689 * proc_do_large_bitmap - read/write from/to a large bitmap
2690 * @table: the sysctl table
2691 * @write: %TRUE if this is a write to the sysctl file
2692 * @buffer: the user buffer
2693 * @lenp: the size of the user buffer
2694 * @ppos: file position
2696 * The bitmap is stored at table->data and the bitmap length (in bits)
2699 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2700 * large bitmaps may be represented in a compact manner. Writing into
2701 * the file will clear the bitmap then update it with the given input.
2703 * Returns 0 on success.
2705 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
2706 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2710 size_t left
= *lenp
;
2711 unsigned long bitmap_len
= table
->maxlen
;
2712 unsigned long *bitmap
= *(unsigned long **) table
->data
;
2713 unsigned long *tmp_bitmap
= NULL
;
2714 char tr_a
[] = { '-', ',', '\n' }, tr_b
[] = { ',', '\n', 0 }, c
;
2716 if (!bitmap
|| !bitmap_len
|| !left
|| (*ppos
&& !write
)) {
2724 if (left
> PAGE_SIZE
- 1)
2725 left
= PAGE_SIZE
- 1;
2727 p
= kbuf
= memdup_user_nul(buffer
, left
);
2729 return PTR_ERR(kbuf
);
2731 tmp_bitmap
= kzalloc(BITS_TO_LONGS(bitmap_len
) * sizeof(unsigned long),
2737 proc_skip_char(&p
, &left
, '\n');
2738 while (!err
&& left
) {
2739 unsigned long val_a
, val_b
;
2742 err
= proc_get_long(&p
, &left
, &val_a
, &neg
, tr_a
,
2746 if (val_a
>= bitmap_len
|| neg
) {
2758 err
= proc_get_long(&p
, &left
, &val_b
,
2759 &neg
, tr_b
, sizeof(tr_b
),
2763 if (val_b
>= bitmap_len
|| neg
||
2774 bitmap_set(tmp_bitmap
, val_a
, val_b
- val_a
+ 1);
2776 proc_skip_char(&p
, &left
, '\n');
2780 unsigned long bit_a
, bit_b
= 0;
2783 bit_a
= find_next_bit(bitmap
, bitmap_len
, bit_b
);
2784 if (bit_a
>= bitmap_len
)
2786 bit_b
= find_next_zero_bit(bitmap
, bitmap_len
,
2790 err
= proc_put_char(&buffer
, &left
, ',');
2794 err
= proc_put_long(&buffer
, &left
, bit_a
, false);
2797 if (bit_a
!= bit_b
) {
2798 err
= proc_put_char(&buffer
, &left
, '-');
2801 err
= proc_put_long(&buffer
, &left
, bit_b
, false);
2809 err
= proc_put_char(&buffer
, &left
, '\n');
2815 bitmap_or(bitmap
, bitmap
, tmp_bitmap
, bitmap_len
);
2817 bitmap_copy(bitmap
, tmp_bitmap
, bitmap_len
);
2829 #else /* CONFIG_PROC_SYSCTL */
2831 int proc_dostring(struct ctl_table
*table
, int write
,
2832 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2837 int proc_dointvec(struct ctl_table
*table
, int write
,
2838 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2843 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2844 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2849 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2850 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2855 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2856 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2861 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2862 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2867 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2868 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2873 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2874 void __user
*buffer
,
2875 size_t *lenp
, loff_t
*ppos
)
2881 #endif /* CONFIG_PROC_SYSCTL */
2884 * No sense putting this after each symbol definition, twice,
2885 * exception granted :-)
2887 EXPORT_SYMBOL(proc_dointvec
);
2888 EXPORT_SYMBOL(proc_dointvec_jiffies
);
2889 EXPORT_SYMBOL(proc_dointvec_minmax
);
2890 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
2891 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
2892 EXPORT_SYMBOL(proc_dostring
);
2893 EXPORT_SYMBOL(proc_doulongvec_minmax
);
2894 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);