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>
68 #include <linux/mount.h>
70 #include <asm/uaccess.h>
71 #include <asm/processor.h>
75 #include <asm/stacktrace.h>
79 #include <asm/setup.h>
81 #ifdef CONFIG_BSD_PROCESS_ACCT
82 #include <linux/acct.h>
84 #ifdef CONFIG_RT_MUTEXES
85 #include <linux/rtmutex.h>
87 #if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
88 #include <linux/lockdep.h>
90 #ifdef CONFIG_CHR_DEV_SG
94 #ifdef CONFIG_LOCKUP_DETECTOR
95 #include <linux/nmi.h>
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
;
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
;
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
= "printk_devkmsg",
818 .data
= devkmsg_log_str
,
819 .maxlen
= DEVKMSG_STR_MAX_SIZE
,
821 .proc_handler
= devkmsg_sysctl_set_loglvl
,
824 .procname
= "dmesg_restrict",
825 .data
= &dmesg_restrict
,
826 .maxlen
= sizeof(int),
828 .proc_handler
= proc_dointvec_minmax_sysadmin
,
833 .procname
= "kptr_restrict",
834 .data
= &kptr_restrict
,
835 .maxlen
= sizeof(int),
837 .proc_handler
= proc_dointvec_minmax_sysadmin
,
843 .procname
= "ngroups_max",
844 .data
= &ngroups_max
,
845 .maxlen
= sizeof (int),
847 .proc_handler
= proc_dointvec
,
850 .procname
= "cap_last_cap",
851 .data
= (void *)&cap_last_cap
,
852 .maxlen
= sizeof(int),
854 .proc_handler
= proc_dointvec
,
856 #if defined(CONFIG_LOCKUP_DETECTOR)
858 .procname
= "watchdog",
859 .data
= &watchdog_user_enabled
,
860 .maxlen
= sizeof (int),
862 .proc_handler
= proc_watchdog
,
867 .procname
= "watchdog_thresh",
868 .data
= &watchdog_thresh
,
869 .maxlen
= sizeof(int),
871 .proc_handler
= proc_watchdog_thresh
,
876 .procname
= "nmi_watchdog",
877 .data
= &nmi_watchdog_enabled
,
878 .maxlen
= sizeof (int),
880 .proc_handler
= proc_nmi_watchdog
,
882 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
889 .procname
= "soft_watchdog",
890 .data
= &soft_watchdog_enabled
,
891 .maxlen
= sizeof (int),
893 .proc_handler
= proc_soft_watchdog
,
898 .procname
= "watchdog_cpumask",
899 .data
= &watchdog_cpumask_bits
,
902 .proc_handler
= proc_watchdog_cpumask
,
905 .procname
= "softlockup_panic",
906 .data
= &softlockup_panic
,
907 .maxlen
= sizeof(int),
909 .proc_handler
= proc_dointvec_minmax
,
913 #ifdef CONFIG_HARDLOCKUP_DETECTOR
915 .procname
= "hardlockup_panic",
916 .data
= &hardlockup_panic
,
917 .maxlen
= sizeof(int),
919 .proc_handler
= proc_dointvec_minmax
,
926 .procname
= "softlockup_all_cpu_backtrace",
927 .data
= &sysctl_softlockup_all_cpu_backtrace
,
928 .maxlen
= sizeof(int),
930 .proc_handler
= proc_dointvec_minmax
,
935 .procname
= "hardlockup_all_cpu_backtrace",
936 .data
= &sysctl_hardlockup_all_cpu_backtrace
,
937 .maxlen
= sizeof(int),
939 .proc_handler
= proc_dointvec_minmax
,
943 #endif /* CONFIG_SMP */
945 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
947 .procname
= "unknown_nmi_panic",
948 .data
= &unknown_nmi_panic
,
949 .maxlen
= sizeof (int),
951 .proc_handler
= proc_dointvec
,
954 #if defined(CONFIG_X86)
956 .procname
= "panic_on_unrecovered_nmi",
957 .data
= &panic_on_unrecovered_nmi
,
958 .maxlen
= sizeof(int),
960 .proc_handler
= proc_dointvec
,
963 .procname
= "panic_on_io_nmi",
964 .data
= &panic_on_io_nmi
,
965 .maxlen
= sizeof(int),
967 .proc_handler
= proc_dointvec
,
969 #ifdef CONFIG_DEBUG_STACKOVERFLOW
971 .procname
= "panic_on_stackoverflow",
972 .data
= &sysctl_panic_on_stackoverflow
,
973 .maxlen
= sizeof(int),
975 .proc_handler
= proc_dointvec
,
979 .procname
= "bootloader_type",
980 .data
= &bootloader_type
,
981 .maxlen
= sizeof (int),
983 .proc_handler
= proc_dointvec
,
986 .procname
= "bootloader_version",
987 .data
= &bootloader_version
,
988 .maxlen
= sizeof (int),
990 .proc_handler
= proc_dointvec
,
993 .procname
= "kstack_depth_to_print",
994 .data
= &kstack_depth_to_print
,
995 .maxlen
= sizeof(int),
997 .proc_handler
= proc_dointvec
,
1000 .procname
= "io_delay_type",
1001 .data
= &io_delay_type
,
1002 .maxlen
= sizeof(int),
1004 .proc_handler
= proc_dointvec
,
1007 #if defined(CONFIG_MMU)
1009 .procname
= "randomize_va_space",
1010 .data
= &randomize_va_space
,
1011 .maxlen
= sizeof(int),
1013 .proc_handler
= proc_dointvec
,
1016 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1018 .procname
= "spin_retry",
1019 .data
= &spin_retry
,
1020 .maxlen
= sizeof (int),
1022 .proc_handler
= proc_dointvec
,
1025 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1027 .procname
= "acpi_video_flags",
1028 .data
= &acpi_realmode_flags
,
1029 .maxlen
= sizeof (unsigned long),
1031 .proc_handler
= proc_doulongvec_minmax
,
1034 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1036 .procname
= "ignore-unaligned-usertrap",
1037 .data
= &no_unaligned_warning
,
1038 .maxlen
= sizeof (int),
1040 .proc_handler
= proc_dointvec
,
1045 .procname
= "unaligned-dump-stack",
1046 .data
= &unaligned_dump_stack
,
1047 .maxlen
= sizeof (int),
1049 .proc_handler
= proc_dointvec
,
1052 #ifdef CONFIG_DETECT_HUNG_TASK
1054 .procname
= "hung_task_panic",
1055 .data
= &sysctl_hung_task_panic
,
1056 .maxlen
= sizeof(int),
1058 .proc_handler
= proc_dointvec_minmax
,
1063 .procname
= "hung_task_check_count",
1064 .data
= &sysctl_hung_task_check_count
,
1065 .maxlen
= sizeof(int),
1067 .proc_handler
= proc_dointvec_minmax
,
1071 .procname
= "hung_task_timeout_secs",
1072 .data
= &sysctl_hung_task_timeout_secs
,
1073 .maxlen
= sizeof(unsigned long),
1075 .proc_handler
= proc_dohung_task_timeout_secs
,
1076 .extra2
= &hung_task_timeout_max
,
1079 .procname
= "hung_task_warnings",
1080 .data
= &sysctl_hung_task_warnings
,
1081 .maxlen
= sizeof(int),
1083 .proc_handler
= proc_dointvec_minmax
,
1087 #ifdef CONFIG_RT_MUTEXES
1089 .procname
= "max_lock_depth",
1090 .data
= &max_lock_depth
,
1091 .maxlen
= sizeof(int),
1093 .proc_handler
= proc_dointvec
,
1097 .procname
= "poweroff_cmd",
1098 .data
= &poweroff_cmd
,
1099 .maxlen
= POWEROFF_CMD_PATH_LEN
,
1101 .proc_handler
= proc_dostring
,
1107 .child
= key_sysctls
,
1110 #ifdef CONFIG_PERF_EVENTS
1112 * User-space scripts rely on the existence of this file
1113 * as a feature check for perf_events being enabled.
1115 * So it's an ABI, do not remove!
1118 .procname
= "perf_event_paranoid",
1119 .data
= &sysctl_perf_event_paranoid
,
1120 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
1122 .proc_handler
= proc_dointvec
,
1125 .procname
= "perf_event_mlock_kb",
1126 .data
= &sysctl_perf_event_mlock
,
1127 .maxlen
= sizeof(sysctl_perf_event_mlock
),
1129 .proc_handler
= proc_dointvec
,
1132 .procname
= "perf_event_max_sample_rate",
1133 .data
= &sysctl_perf_event_sample_rate
,
1134 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1136 .proc_handler
= perf_proc_update_handler
,
1140 .procname
= "perf_cpu_time_max_percent",
1141 .data
= &sysctl_perf_cpu_time_max_percent
,
1142 .maxlen
= sizeof(sysctl_perf_cpu_time_max_percent
),
1144 .proc_handler
= perf_cpu_time_max_percent_handler
,
1146 .extra2
= &one_hundred
,
1149 .procname
= "perf_event_max_stack",
1150 .data
= &sysctl_perf_event_max_stack
,
1151 .maxlen
= sizeof(sysctl_perf_event_max_stack
),
1153 .proc_handler
= perf_event_max_stack_handler
,
1155 .extra2
= &six_hundred_forty_kb
,
1158 .procname
= "perf_event_max_contexts_per_stack",
1159 .data
= &sysctl_perf_event_max_contexts_per_stack
,
1160 .maxlen
= sizeof(sysctl_perf_event_max_contexts_per_stack
),
1162 .proc_handler
= perf_event_max_stack_handler
,
1164 .extra2
= &one_thousand
,
1167 #ifdef CONFIG_KMEMCHECK
1169 .procname
= "kmemcheck",
1170 .data
= &kmemcheck_enabled
,
1171 .maxlen
= sizeof(int),
1173 .proc_handler
= proc_dointvec
,
1177 .procname
= "panic_on_warn",
1178 .data
= &panic_on_warn
,
1179 .maxlen
= sizeof(int),
1181 .proc_handler
= proc_dointvec_minmax
,
1185 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1187 .procname
= "timer_migration",
1188 .data
= &sysctl_timer_migration
,
1189 .maxlen
= sizeof(unsigned int),
1191 .proc_handler
= timer_migration_handler
,
1194 #ifdef CONFIG_BPF_SYSCALL
1196 .procname
= "unprivileged_bpf_disabled",
1197 .data
= &sysctl_unprivileged_bpf_disabled
,
1198 .maxlen
= sizeof(sysctl_unprivileged_bpf_disabled
),
1200 /* only handle a transition from default "0" to "1" */
1201 .proc_handler
= proc_dointvec_minmax
,
1206 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1208 .procname
= "panic_on_rcu_stall",
1209 .data
= &sysctl_panic_on_rcu_stall
,
1210 .maxlen
= sizeof(sysctl_panic_on_rcu_stall
),
1212 .proc_handler
= proc_dointvec_minmax
,
1220 static struct ctl_table vm_table
[] = {
1222 .procname
= "overcommit_memory",
1223 .data
= &sysctl_overcommit_memory
,
1224 .maxlen
= sizeof(sysctl_overcommit_memory
),
1226 .proc_handler
= proc_dointvec_minmax
,
1231 .procname
= "panic_on_oom",
1232 .data
= &sysctl_panic_on_oom
,
1233 .maxlen
= sizeof(sysctl_panic_on_oom
),
1235 .proc_handler
= proc_dointvec_minmax
,
1240 .procname
= "oom_kill_allocating_task",
1241 .data
= &sysctl_oom_kill_allocating_task
,
1242 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
1244 .proc_handler
= proc_dointvec
,
1247 .procname
= "oom_dump_tasks",
1248 .data
= &sysctl_oom_dump_tasks
,
1249 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
1251 .proc_handler
= proc_dointvec
,
1254 .procname
= "overcommit_ratio",
1255 .data
= &sysctl_overcommit_ratio
,
1256 .maxlen
= sizeof(sysctl_overcommit_ratio
),
1258 .proc_handler
= overcommit_ratio_handler
,
1261 .procname
= "overcommit_kbytes",
1262 .data
= &sysctl_overcommit_kbytes
,
1263 .maxlen
= sizeof(sysctl_overcommit_kbytes
),
1265 .proc_handler
= overcommit_kbytes_handler
,
1268 .procname
= "page-cluster",
1269 .data
= &page_cluster
,
1270 .maxlen
= sizeof(int),
1272 .proc_handler
= proc_dointvec_minmax
,
1276 .procname
= "dirty_background_ratio",
1277 .data
= &dirty_background_ratio
,
1278 .maxlen
= sizeof(dirty_background_ratio
),
1280 .proc_handler
= dirty_background_ratio_handler
,
1282 .extra2
= &one_hundred
,
1285 .procname
= "dirty_background_bytes",
1286 .data
= &dirty_background_bytes
,
1287 .maxlen
= sizeof(dirty_background_bytes
),
1289 .proc_handler
= dirty_background_bytes_handler
,
1293 .procname
= "dirty_ratio",
1294 .data
= &vm_dirty_ratio
,
1295 .maxlen
= sizeof(vm_dirty_ratio
),
1297 .proc_handler
= dirty_ratio_handler
,
1299 .extra2
= &one_hundred
,
1302 .procname
= "dirty_bytes",
1303 .data
= &vm_dirty_bytes
,
1304 .maxlen
= sizeof(vm_dirty_bytes
),
1306 .proc_handler
= dirty_bytes_handler
,
1307 .extra1
= &dirty_bytes_min
,
1310 .procname
= "dirty_writeback_centisecs",
1311 .data
= &dirty_writeback_interval
,
1312 .maxlen
= sizeof(dirty_writeback_interval
),
1314 .proc_handler
= dirty_writeback_centisecs_handler
,
1317 .procname
= "dirty_expire_centisecs",
1318 .data
= &dirty_expire_interval
,
1319 .maxlen
= sizeof(dirty_expire_interval
),
1321 .proc_handler
= proc_dointvec_minmax
,
1325 .procname
= "dirtytime_expire_seconds",
1326 .data
= &dirtytime_expire_interval
,
1327 .maxlen
= sizeof(dirty_expire_interval
),
1329 .proc_handler
= dirtytime_interval_handler
,
1333 .procname
= "nr_pdflush_threads",
1334 .mode
= 0444 /* read-only */,
1335 .proc_handler
= pdflush_proc_obsolete
,
1338 .procname
= "swappiness",
1339 .data
= &vm_swappiness
,
1340 .maxlen
= sizeof(vm_swappiness
),
1342 .proc_handler
= proc_dointvec_minmax
,
1344 .extra2
= &one_hundred
,
1346 #ifdef CONFIG_HUGETLB_PAGE
1348 .procname
= "nr_hugepages",
1350 .maxlen
= sizeof(unsigned long),
1352 .proc_handler
= hugetlb_sysctl_handler
,
1356 .procname
= "nr_hugepages_mempolicy",
1358 .maxlen
= sizeof(unsigned long),
1360 .proc_handler
= &hugetlb_mempolicy_sysctl_handler
,
1364 .procname
= "hugetlb_shm_group",
1365 .data
= &sysctl_hugetlb_shm_group
,
1366 .maxlen
= sizeof(gid_t
),
1368 .proc_handler
= proc_dointvec
,
1371 .procname
= "hugepages_treat_as_movable",
1372 .data
= &hugepages_treat_as_movable
,
1373 .maxlen
= sizeof(int),
1375 .proc_handler
= proc_dointvec
,
1378 .procname
= "nr_overcommit_hugepages",
1380 .maxlen
= sizeof(unsigned long),
1382 .proc_handler
= hugetlb_overcommit_handler
,
1386 .procname
= "lowmem_reserve_ratio",
1387 .data
= &sysctl_lowmem_reserve_ratio
,
1388 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
1390 .proc_handler
= lowmem_reserve_ratio_sysctl_handler
,
1393 .procname
= "drop_caches",
1394 .data
= &sysctl_drop_caches
,
1395 .maxlen
= sizeof(int),
1397 .proc_handler
= drop_caches_sysctl_handler
,
1401 #ifdef CONFIG_COMPACTION
1403 .procname
= "compact_memory",
1404 .data
= &sysctl_compact_memory
,
1405 .maxlen
= sizeof(int),
1407 .proc_handler
= sysctl_compaction_handler
,
1410 .procname
= "extfrag_threshold",
1411 .data
= &sysctl_extfrag_threshold
,
1412 .maxlen
= sizeof(int),
1414 .proc_handler
= sysctl_extfrag_handler
,
1415 .extra1
= &min_extfrag_threshold
,
1416 .extra2
= &max_extfrag_threshold
,
1419 .procname
= "compact_unevictable_allowed",
1420 .data
= &sysctl_compact_unevictable_allowed
,
1421 .maxlen
= sizeof(int),
1423 .proc_handler
= proc_dointvec
,
1428 #endif /* CONFIG_COMPACTION */
1430 .procname
= "min_free_kbytes",
1431 .data
= &min_free_kbytes
,
1432 .maxlen
= sizeof(min_free_kbytes
),
1434 .proc_handler
= min_free_kbytes_sysctl_handler
,
1438 .procname
= "watermark_scale_factor",
1439 .data
= &watermark_scale_factor
,
1440 .maxlen
= sizeof(watermark_scale_factor
),
1442 .proc_handler
= watermark_scale_factor_sysctl_handler
,
1444 .extra2
= &one_thousand
,
1447 .procname
= "percpu_pagelist_fraction",
1448 .data
= &percpu_pagelist_fraction
,
1449 .maxlen
= sizeof(percpu_pagelist_fraction
),
1451 .proc_handler
= percpu_pagelist_fraction_sysctl_handler
,
1456 .procname
= "max_map_count",
1457 .data
= &sysctl_max_map_count
,
1458 .maxlen
= sizeof(sysctl_max_map_count
),
1460 .proc_handler
= proc_dointvec_minmax
,
1465 .procname
= "nr_trim_pages",
1466 .data
= &sysctl_nr_trim_pages
,
1467 .maxlen
= sizeof(sysctl_nr_trim_pages
),
1469 .proc_handler
= proc_dointvec_minmax
,
1474 .procname
= "laptop_mode",
1475 .data
= &laptop_mode
,
1476 .maxlen
= sizeof(laptop_mode
),
1478 .proc_handler
= proc_dointvec_jiffies
,
1481 .procname
= "block_dump",
1482 .data
= &block_dump
,
1483 .maxlen
= sizeof(block_dump
),
1485 .proc_handler
= proc_dointvec
,
1489 .procname
= "vfs_cache_pressure",
1490 .data
= &sysctl_vfs_cache_pressure
,
1491 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1493 .proc_handler
= proc_dointvec
,
1496 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1498 .procname
= "legacy_va_layout",
1499 .data
= &sysctl_legacy_va_layout
,
1500 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1502 .proc_handler
= proc_dointvec
,
1508 .procname
= "zone_reclaim_mode",
1509 .data
= &node_reclaim_mode
,
1510 .maxlen
= sizeof(node_reclaim_mode
),
1512 .proc_handler
= proc_dointvec
,
1516 .procname
= "min_unmapped_ratio",
1517 .data
= &sysctl_min_unmapped_ratio
,
1518 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1520 .proc_handler
= sysctl_min_unmapped_ratio_sysctl_handler
,
1522 .extra2
= &one_hundred
,
1525 .procname
= "min_slab_ratio",
1526 .data
= &sysctl_min_slab_ratio
,
1527 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1529 .proc_handler
= sysctl_min_slab_ratio_sysctl_handler
,
1531 .extra2
= &one_hundred
,
1536 .procname
= "stat_interval",
1537 .data
= &sysctl_stat_interval
,
1538 .maxlen
= sizeof(sysctl_stat_interval
),
1540 .proc_handler
= proc_dointvec_jiffies
,
1543 .procname
= "stat_refresh",
1547 .proc_handler
= vmstat_refresh
,
1552 .procname
= "mmap_min_addr",
1553 .data
= &dac_mmap_min_addr
,
1554 .maxlen
= sizeof(unsigned long),
1556 .proc_handler
= mmap_min_addr_handler
,
1561 .procname
= "numa_zonelist_order",
1562 .data
= &numa_zonelist_order
,
1563 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1565 .proc_handler
= numa_zonelist_order_handler
,
1568 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1569 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1571 .procname
= "vdso_enabled",
1572 #ifdef CONFIG_X86_32
1573 .data
= &vdso32_enabled
,
1574 .maxlen
= sizeof(vdso32_enabled
),
1576 .data
= &vdso_enabled
,
1577 .maxlen
= sizeof(vdso_enabled
),
1580 .proc_handler
= proc_dointvec
,
1584 #ifdef CONFIG_HIGHMEM
1586 .procname
= "highmem_is_dirtyable",
1587 .data
= &vm_highmem_is_dirtyable
,
1588 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
1590 .proc_handler
= proc_dointvec_minmax
,
1595 #ifdef CONFIG_MEMORY_FAILURE
1597 .procname
= "memory_failure_early_kill",
1598 .data
= &sysctl_memory_failure_early_kill
,
1599 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
1601 .proc_handler
= proc_dointvec_minmax
,
1606 .procname
= "memory_failure_recovery",
1607 .data
= &sysctl_memory_failure_recovery
,
1608 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
1610 .proc_handler
= proc_dointvec_minmax
,
1616 .procname
= "user_reserve_kbytes",
1617 .data
= &sysctl_user_reserve_kbytes
,
1618 .maxlen
= sizeof(sysctl_user_reserve_kbytes
),
1620 .proc_handler
= proc_doulongvec_minmax
,
1623 .procname
= "admin_reserve_kbytes",
1624 .data
= &sysctl_admin_reserve_kbytes
,
1625 .maxlen
= sizeof(sysctl_admin_reserve_kbytes
),
1627 .proc_handler
= proc_doulongvec_minmax
,
1629 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1631 .procname
= "mmap_rnd_bits",
1632 .data
= &mmap_rnd_bits
,
1633 .maxlen
= sizeof(mmap_rnd_bits
),
1635 .proc_handler
= proc_dointvec_minmax
,
1636 .extra1
= (void *)&mmap_rnd_bits_min
,
1637 .extra2
= (void *)&mmap_rnd_bits_max
,
1640 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1642 .procname
= "mmap_rnd_compat_bits",
1643 .data
= &mmap_rnd_compat_bits
,
1644 .maxlen
= sizeof(mmap_rnd_compat_bits
),
1646 .proc_handler
= proc_dointvec_minmax
,
1647 .extra1
= (void *)&mmap_rnd_compat_bits_min
,
1648 .extra2
= (void *)&mmap_rnd_compat_bits_max
,
1654 static struct ctl_table fs_table
[] = {
1656 .procname
= "inode-nr",
1657 .data
= &inodes_stat
,
1658 .maxlen
= 2*sizeof(long),
1660 .proc_handler
= proc_nr_inodes
,
1663 .procname
= "inode-state",
1664 .data
= &inodes_stat
,
1665 .maxlen
= 7*sizeof(long),
1667 .proc_handler
= proc_nr_inodes
,
1670 .procname
= "file-nr",
1671 .data
= &files_stat
,
1672 .maxlen
= sizeof(files_stat
),
1674 .proc_handler
= proc_nr_files
,
1677 .procname
= "file-max",
1678 .data
= &files_stat
.max_files
,
1679 .maxlen
= sizeof(files_stat
.max_files
),
1681 .proc_handler
= proc_doulongvec_minmax
,
1684 .procname
= "nr_open",
1685 .data
= &sysctl_nr_open
,
1686 .maxlen
= sizeof(unsigned int),
1688 .proc_handler
= proc_dointvec_minmax
,
1689 .extra1
= &sysctl_nr_open_min
,
1690 .extra2
= &sysctl_nr_open_max
,
1693 .procname
= "dentry-state",
1694 .data
= &dentry_stat
,
1695 .maxlen
= 6*sizeof(long),
1697 .proc_handler
= proc_nr_dentry
,
1700 .procname
= "overflowuid",
1701 .data
= &fs_overflowuid
,
1702 .maxlen
= sizeof(int),
1704 .proc_handler
= proc_dointvec_minmax
,
1705 .extra1
= &minolduid
,
1706 .extra2
= &maxolduid
,
1709 .procname
= "overflowgid",
1710 .data
= &fs_overflowgid
,
1711 .maxlen
= sizeof(int),
1713 .proc_handler
= proc_dointvec_minmax
,
1714 .extra1
= &minolduid
,
1715 .extra2
= &maxolduid
,
1717 #ifdef CONFIG_FILE_LOCKING
1719 .procname
= "leases-enable",
1720 .data
= &leases_enable
,
1721 .maxlen
= sizeof(int),
1723 .proc_handler
= proc_dointvec
,
1726 #ifdef CONFIG_DNOTIFY
1728 .procname
= "dir-notify-enable",
1729 .data
= &dir_notify_enable
,
1730 .maxlen
= sizeof(int),
1732 .proc_handler
= proc_dointvec
,
1736 #ifdef CONFIG_FILE_LOCKING
1738 .procname
= "lease-break-time",
1739 .data
= &lease_break_time
,
1740 .maxlen
= sizeof(int),
1742 .proc_handler
= proc_dointvec
,
1747 .procname
= "aio-nr",
1749 .maxlen
= sizeof(aio_nr
),
1751 .proc_handler
= proc_doulongvec_minmax
,
1754 .procname
= "aio-max-nr",
1755 .data
= &aio_max_nr
,
1756 .maxlen
= sizeof(aio_max_nr
),
1758 .proc_handler
= proc_doulongvec_minmax
,
1760 #endif /* CONFIG_AIO */
1761 #ifdef CONFIG_INOTIFY_USER
1763 .procname
= "inotify",
1765 .child
= inotify_table
,
1770 .procname
= "epoll",
1772 .child
= epoll_table
,
1777 .procname
= "protected_symlinks",
1778 .data
= &sysctl_protected_symlinks
,
1779 .maxlen
= sizeof(int),
1781 .proc_handler
= proc_dointvec_minmax
,
1786 .procname
= "protected_hardlinks",
1787 .data
= &sysctl_protected_hardlinks
,
1788 .maxlen
= sizeof(int),
1790 .proc_handler
= proc_dointvec_minmax
,
1795 .procname
= "suid_dumpable",
1796 .data
= &suid_dumpable
,
1797 .maxlen
= sizeof(int),
1799 .proc_handler
= proc_dointvec_minmax_coredump
,
1803 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1805 .procname
= "binfmt_misc",
1807 .child
= sysctl_mount_point
,
1811 .procname
= "pipe-max-size",
1812 .data
= &pipe_max_size
,
1813 .maxlen
= sizeof(int),
1815 .proc_handler
= &pipe_proc_fn
,
1816 .extra1
= &pipe_min_size
,
1819 .procname
= "pipe-user-pages-hard",
1820 .data
= &pipe_user_pages_hard
,
1821 .maxlen
= sizeof(pipe_user_pages_hard
),
1823 .proc_handler
= proc_doulongvec_minmax
,
1826 .procname
= "pipe-user-pages-soft",
1827 .data
= &pipe_user_pages_soft
,
1828 .maxlen
= sizeof(pipe_user_pages_soft
),
1830 .proc_handler
= proc_doulongvec_minmax
,
1833 .procname
= "mount-max",
1834 .data
= &sysctl_mount_max
,
1835 .maxlen
= sizeof(unsigned int),
1837 .proc_handler
= proc_dointvec_minmax
,
1843 static struct ctl_table debug_table
[] = {
1844 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1846 .procname
= "exception-trace",
1847 .data
= &show_unhandled_signals
,
1848 .maxlen
= sizeof(int),
1850 .proc_handler
= proc_dointvec
1853 #if defined(CONFIG_OPTPROBES)
1855 .procname
= "kprobes-optimization",
1856 .data
= &sysctl_kprobes_optimization
,
1857 .maxlen
= sizeof(int),
1859 .proc_handler
= proc_kprobes_optimization_handler
,
1867 static struct ctl_table dev_table
[] = {
1871 int __init
sysctl_init(void)
1873 struct ctl_table_header
*hdr
;
1875 hdr
= register_sysctl_table(sysctl_base_table
);
1876 kmemleak_not_leak(hdr
);
1880 #endif /* CONFIG_SYSCTL */
1886 #ifdef CONFIG_PROC_SYSCTL
1888 static int _proc_do_string(char *data
, int maxlen
, int write
,
1889 char __user
*buffer
,
1890 size_t *lenp
, loff_t
*ppos
)
1896 if (!data
|| !maxlen
|| !*lenp
) {
1902 if (sysctl_writes_strict
== SYSCTL_WRITES_STRICT
) {
1903 /* Only continue writes not past the end of buffer. */
1905 if (len
> maxlen
- 1)
1912 /* Start writing from beginning of buffer. */
1918 while ((p
- buffer
) < *lenp
&& len
< maxlen
- 1) {
1919 if (get_user(c
, p
++))
1921 if (c
== 0 || c
== '\n')
1942 if (copy_to_user(buffer
, data
, len
))
1945 if (put_user('\n', buffer
+ len
))
1955 static void warn_sysctl_write(struct ctl_table
*table
)
1957 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1958 "This will not be supported in the future. To silence this\n"
1959 "warning, set kernel.sysctl_writes_strict = -1\n",
1960 current
->comm
, table
->procname
);
1964 * proc_dostring - read a string sysctl
1965 * @table: the sysctl table
1966 * @write: %TRUE if this is a write to the sysctl file
1967 * @buffer: the user buffer
1968 * @lenp: the size of the user buffer
1969 * @ppos: file position
1971 * Reads/writes a string from/to the user buffer. If the kernel
1972 * buffer provided is not large enough to hold the string, the
1973 * string is truncated. The copied string is %NULL-terminated.
1974 * If the string is being read by the user process, it is copied
1975 * and a newline '\n' is added. It is truncated if the buffer is
1978 * Returns 0 on success.
1980 int proc_dostring(struct ctl_table
*table
, int write
,
1981 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1983 if (write
&& *ppos
&& sysctl_writes_strict
== SYSCTL_WRITES_WARN
)
1984 warn_sysctl_write(table
);
1986 return _proc_do_string((char *)(table
->data
), table
->maxlen
, write
,
1987 (char __user
*)buffer
, lenp
, ppos
);
1990 static size_t proc_skip_spaces(char **buf
)
1993 char *tmp
= skip_spaces(*buf
);
1999 static void proc_skip_char(char **buf
, size_t *size
, const char v
)
2009 #define TMPBUFLEN 22
2011 * proc_get_long - reads an ASCII formatted integer from a user buffer
2013 * @buf: a kernel buffer
2014 * @size: size of the kernel buffer
2015 * @val: this is where the number will be stored
2016 * @neg: set to %TRUE if number is negative
2017 * @perm_tr: a vector which contains the allowed trailers
2018 * @perm_tr_len: size of the perm_tr vector
2019 * @tr: pointer to store the trailer character
2021 * In case of success %0 is returned and @buf and @size are updated with
2022 * the amount of bytes read. If @tr is non-NULL and a trailing
2023 * character exists (size is non-zero after returning from this
2024 * function), @tr is updated with the trailing character.
2026 static int proc_get_long(char **buf
, size_t *size
,
2027 unsigned long *val
, bool *neg
,
2028 const char *perm_tr
, unsigned perm_tr_len
, char *tr
)
2031 char *p
, tmp
[TMPBUFLEN
];
2037 if (len
> TMPBUFLEN
- 1)
2038 len
= TMPBUFLEN
- 1;
2040 memcpy(tmp
, *buf
, len
);
2044 if (*p
== '-' && *size
> 1) {
2052 *val
= simple_strtoul(p
, &p
, 0);
2056 /* We don't know if the next char is whitespace thus we may accept
2057 * invalid integers (e.g. 1234...a) or two integers instead of one
2058 * (e.g. 123...1). So lets not allow such large numbers. */
2059 if (len
== TMPBUFLEN
- 1)
2062 if (len
< *size
&& perm_tr_len
&& !memchr(perm_tr
, *p
, perm_tr_len
))
2065 if (tr
&& (len
< *size
))
2075 * proc_put_long - converts an integer to a decimal ASCII formatted string
2077 * @buf: the user buffer
2078 * @size: the size of the user buffer
2079 * @val: the integer to be converted
2080 * @neg: sign of the number, %TRUE for negative
2082 * In case of success %0 is returned and @buf and @size are updated with
2083 * the amount of bytes written.
2085 static int proc_put_long(void __user
**buf
, size_t *size
, unsigned long val
,
2089 char tmp
[TMPBUFLEN
], *p
= tmp
;
2091 sprintf(p
, "%s%lu", neg
? "-" : "", val
);
2095 if (copy_to_user(*buf
, tmp
, len
))
2103 static int proc_put_char(void __user
**buf
, size_t *size
, char c
)
2106 char __user
**buffer
= (char __user
**)buf
;
2107 if (put_user(c
, *buffer
))
2109 (*size
)--, (*buffer
)++;
2115 static int do_proc_dointvec_conv(bool *negp
, unsigned long *lvalp
,
2117 int write
, void *data
)
2121 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2125 if (*lvalp
> (unsigned long) INT_MAX
)
2133 *lvalp
= -(unsigned long)val
;
2136 *lvalp
= (unsigned long)val
;
2142 static int do_proc_douintvec_conv(bool *negp
, unsigned long *lvalp
,
2144 int write
, void *data
)
2151 unsigned int val
= *valp
;
2152 *lvalp
= (unsigned long)val
;
2157 static const char proc_wspace_sep
[] = { ' ', '\t', '\n' };
2159 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2160 int write
, void __user
*buffer
,
2161 size_t *lenp
, loff_t
*ppos
,
2162 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2163 int write
, void *data
),
2166 int *i
, vleft
, first
= 1, err
= 0;
2168 char *kbuf
= NULL
, *p
;
2170 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2175 i
= (int *) tbl_data
;
2176 vleft
= table
->maxlen
/ sizeof(*i
);
2180 conv
= do_proc_dointvec_conv
;
2184 switch (sysctl_writes_strict
) {
2185 case SYSCTL_WRITES_STRICT
:
2187 case SYSCTL_WRITES_WARN
:
2188 warn_sysctl_write(table
);
2195 if (left
> PAGE_SIZE
- 1)
2196 left
= PAGE_SIZE
- 1;
2197 p
= kbuf
= memdup_user_nul(buffer
, left
);
2199 return PTR_ERR(kbuf
);
2202 for (; left
&& vleft
--; i
++, first
=0) {
2207 left
-= proc_skip_spaces(&p
);
2211 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2213 sizeof(proc_wspace_sep
), NULL
);
2216 if (conv(&neg
, &lval
, i
, 1, data
)) {
2221 if (conv(&neg
, &lval
, i
, 0, data
)) {
2226 err
= proc_put_char(&buffer
, &left
, '\t');
2229 err
= proc_put_long(&buffer
, &left
, lval
, neg
);
2235 if (!write
&& !first
&& left
&& !err
)
2236 err
= proc_put_char(&buffer
, &left
, '\n');
2237 if (write
&& !err
&& left
)
2238 left
-= proc_skip_spaces(&p
);
2242 return err
? : -EINVAL
;
2250 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2251 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2252 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2253 int write
, void *data
),
2256 return __do_proc_dointvec(table
->data
, table
, write
,
2257 buffer
, lenp
, ppos
, conv
, data
);
2261 * proc_dointvec - read a vector of integers
2262 * @table: the sysctl table
2263 * @write: %TRUE if this is a write to the sysctl file
2264 * @buffer: the user buffer
2265 * @lenp: the size of the user buffer
2266 * @ppos: file position
2268 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2269 * values from/to the user buffer, treated as an ASCII string.
2271 * Returns 0 on success.
2273 int proc_dointvec(struct ctl_table
*table
, int write
,
2274 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2276 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
, NULL
, NULL
);
2280 * proc_douintvec - read a vector of unsigned integers
2281 * @table: the sysctl table
2282 * @write: %TRUE if this is a write to the sysctl file
2283 * @buffer: the user buffer
2284 * @lenp: the size of the user buffer
2285 * @ppos: file position
2287 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2288 * values from/to the user buffer, treated as an ASCII string.
2290 * Returns 0 on success.
2292 int proc_douintvec(struct ctl_table
*table
, int write
,
2293 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2295 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2296 do_proc_douintvec_conv
, NULL
);
2300 * Taint values can only be increased
2301 * This means we can safely use a temporary.
2303 static int proc_taint(struct ctl_table
*table
, int write
,
2304 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2307 unsigned long tmptaint
= get_taint();
2310 if (write
&& !capable(CAP_SYS_ADMIN
))
2315 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2321 * Poor man's atomic or. Not worth adding a primitive
2322 * to everyone's atomic.h for this
2325 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2326 if ((tmptaint
>> i
) & 1)
2327 add_taint(i
, LOCKDEP_STILL_OK
);
2334 #ifdef CONFIG_PRINTK
2335 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
2336 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2338 if (write
&& !capable(CAP_SYS_ADMIN
))
2341 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2345 struct do_proc_dointvec_minmax_conv_param
{
2350 static int do_proc_dointvec_minmax_conv(bool *negp
, unsigned long *lvalp
,
2352 int write
, void *data
)
2354 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2356 int val
= *negp
? -*lvalp
: *lvalp
;
2357 if ((param
->min
&& *param
->min
> val
) ||
2358 (param
->max
&& *param
->max
< val
))
2365 *lvalp
= -(unsigned long)val
;
2368 *lvalp
= (unsigned long)val
;
2375 * proc_dointvec_minmax - read a vector of integers with min/max values
2376 * @table: the sysctl table
2377 * @write: %TRUE if this is a write to the sysctl file
2378 * @buffer: the user buffer
2379 * @lenp: the size of the user buffer
2380 * @ppos: file position
2382 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2383 * values from/to the user buffer, treated as an ASCII string.
2385 * This routine will ensure the values are within the range specified by
2386 * table->extra1 (min) and table->extra2 (max).
2388 * Returns 0 on success.
2390 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2391 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2393 struct do_proc_dointvec_minmax_conv_param param
= {
2394 .min
= (int *) table
->extra1
,
2395 .max
= (int *) table
->extra2
,
2397 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2398 do_proc_dointvec_minmax_conv
, ¶m
);
2401 static void validate_coredump_safety(void)
2403 #ifdef CONFIG_COREDUMP
2404 if (suid_dumpable
== SUID_DUMP_ROOT
&&
2405 core_pattern
[0] != '/' && core_pattern
[0] != '|') {
2406 printk(KERN_WARNING
"Unsafe core_pattern used with "\
2407 "suid_dumpable=2. Pipe handler or fully qualified "\
2408 "core dump path required.\n");
2413 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
2414 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2416 int error
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2418 validate_coredump_safety();
2422 #ifdef CONFIG_COREDUMP
2423 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
2424 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2426 int error
= proc_dostring(table
, write
, buffer
, lenp
, ppos
);
2428 validate_coredump_safety();
2433 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2434 void __user
*buffer
,
2435 size_t *lenp
, loff_t
*ppos
,
2436 unsigned long convmul
,
2437 unsigned long convdiv
)
2439 unsigned long *i
, *min
, *max
;
2440 int vleft
, first
= 1, err
= 0;
2442 char *kbuf
= NULL
, *p
;
2444 if (!data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2449 i
= (unsigned long *) data
;
2450 min
= (unsigned long *) table
->extra1
;
2451 max
= (unsigned long *) table
->extra2
;
2452 vleft
= table
->maxlen
/ sizeof(unsigned long);
2457 switch (sysctl_writes_strict
) {
2458 case SYSCTL_WRITES_STRICT
:
2460 case SYSCTL_WRITES_WARN
:
2461 warn_sysctl_write(table
);
2468 if (left
> PAGE_SIZE
- 1)
2469 left
= PAGE_SIZE
- 1;
2470 p
= kbuf
= memdup_user_nul(buffer
, left
);
2472 return PTR_ERR(kbuf
);
2475 for (; left
&& vleft
--; i
++, first
= 0) {
2481 left
-= proc_skip_spaces(&p
);
2483 err
= proc_get_long(&p
, &left
, &val
, &neg
,
2485 sizeof(proc_wspace_sep
), NULL
);
2490 val
= convmul
* val
/ convdiv
;
2491 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2495 val
= convdiv
* (*i
) / convmul
;
2497 err
= proc_put_char(&buffer
, &left
, '\t');
2501 err
= proc_put_long(&buffer
, &left
, val
, false);
2507 if (!write
&& !first
&& left
&& !err
)
2508 err
= proc_put_char(&buffer
, &left
, '\n');
2510 left
-= proc_skip_spaces(&p
);
2514 return err
? : -EINVAL
;
2522 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2523 void __user
*buffer
,
2524 size_t *lenp
, loff_t
*ppos
,
2525 unsigned long convmul
,
2526 unsigned long convdiv
)
2528 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2529 buffer
, lenp
, ppos
, convmul
, convdiv
);
2533 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2534 * @table: the sysctl table
2535 * @write: %TRUE if this is a write to the sysctl file
2536 * @buffer: the user buffer
2537 * @lenp: the size of the user buffer
2538 * @ppos: file position
2540 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2541 * values from/to the user buffer, treated as an ASCII string.
2543 * This routine will ensure the values are within the range specified by
2544 * table->extra1 (min) and table->extra2 (max).
2546 * Returns 0 on success.
2548 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2549 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2551 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2555 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2556 * @table: the sysctl table
2557 * @write: %TRUE if this is a write to the sysctl file
2558 * @buffer: the user buffer
2559 * @lenp: the size of the user buffer
2560 * @ppos: file position
2562 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2563 * values from/to the user buffer, treated as an ASCII string. The values
2564 * are treated as milliseconds, and converted to jiffies when they are stored.
2566 * This routine will ensure the values are within the range specified by
2567 * table->extra1 (min) and table->extra2 (max).
2569 * Returns 0 on success.
2571 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2572 void __user
*buffer
,
2573 size_t *lenp
, loff_t
*ppos
)
2575 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2576 lenp
, ppos
, HZ
, 1000l);
2580 static int do_proc_dointvec_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2582 int write
, void *data
)
2585 if (*lvalp
> LONG_MAX
/ HZ
)
2587 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2593 lval
= -(unsigned long)val
;
2596 lval
= (unsigned long)val
;
2603 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2605 int write
, void *data
)
2608 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2610 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2616 lval
= -(unsigned long)val
;
2619 lval
= (unsigned long)val
;
2621 *lvalp
= jiffies_to_clock_t(lval
);
2626 static int do_proc_dointvec_ms_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2628 int write
, void *data
)
2631 unsigned long jif
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2641 lval
= -(unsigned long)val
;
2644 lval
= (unsigned long)val
;
2646 *lvalp
= jiffies_to_msecs(lval
);
2652 * proc_dointvec_jiffies - read a vector of integers as seconds
2653 * @table: the sysctl table
2654 * @write: %TRUE if this is a write to the sysctl file
2655 * @buffer: the user buffer
2656 * @lenp: the size of the user buffer
2657 * @ppos: file position
2659 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2660 * values from/to the user buffer, treated as an ASCII string.
2661 * The values read are assumed to be in seconds, and are converted into
2664 * Returns 0 on success.
2666 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2667 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2669 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2670 do_proc_dointvec_jiffies_conv
,NULL
);
2674 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2675 * @table: the sysctl table
2676 * @write: %TRUE if this is a write to the sysctl file
2677 * @buffer: the user buffer
2678 * @lenp: the size of the user buffer
2679 * @ppos: pointer to the file position
2681 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2682 * values from/to the user buffer, treated as an ASCII string.
2683 * The values read are assumed to be in 1/USER_HZ seconds, and
2684 * are converted into jiffies.
2686 * Returns 0 on success.
2688 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2689 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2691 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2692 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2696 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2697 * @table: the sysctl table
2698 * @write: %TRUE if this is a write to the sysctl file
2699 * @buffer: the user buffer
2700 * @lenp: the size of the user buffer
2701 * @ppos: file position
2702 * @ppos: the current position in the file
2704 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2705 * values from/to the user buffer, treated as an ASCII string.
2706 * The values read are assumed to be in 1/1000 seconds, and
2707 * are converted into jiffies.
2709 * Returns 0 on success.
2711 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2712 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2714 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2715 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2718 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
2719 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2721 struct pid
*new_pid
;
2725 tmp
= pid_vnr(cad_pid
);
2727 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
2728 lenp
, ppos
, NULL
, NULL
);
2732 new_pid
= find_get_pid(tmp
);
2736 put_pid(xchg(&cad_pid
, new_pid
));
2741 * proc_do_large_bitmap - read/write from/to a large bitmap
2742 * @table: the sysctl table
2743 * @write: %TRUE if this is a write to the sysctl file
2744 * @buffer: the user buffer
2745 * @lenp: the size of the user buffer
2746 * @ppos: file position
2748 * The bitmap is stored at table->data and the bitmap length (in bits)
2751 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2752 * large bitmaps may be represented in a compact manner. Writing into
2753 * the file will clear the bitmap then update it with the given input.
2755 * Returns 0 on success.
2757 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
2758 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2762 size_t left
= *lenp
;
2763 unsigned long bitmap_len
= table
->maxlen
;
2764 unsigned long *bitmap
= *(unsigned long **) table
->data
;
2765 unsigned long *tmp_bitmap
= NULL
;
2766 char tr_a
[] = { '-', ',', '\n' }, tr_b
[] = { ',', '\n', 0 }, c
;
2768 if (!bitmap
|| !bitmap_len
|| !left
|| (*ppos
&& !write
)) {
2776 if (left
> PAGE_SIZE
- 1)
2777 left
= PAGE_SIZE
- 1;
2779 p
= kbuf
= memdup_user_nul(buffer
, left
);
2781 return PTR_ERR(kbuf
);
2783 tmp_bitmap
= kzalloc(BITS_TO_LONGS(bitmap_len
) * sizeof(unsigned long),
2789 proc_skip_char(&p
, &left
, '\n');
2790 while (!err
&& left
) {
2791 unsigned long val_a
, val_b
;
2794 err
= proc_get_long(&p
, &left
, &val_a
, &neg
, tr_a
,
2798 if (val_a
>= bitmap_len
|| neg
) {
2810 err
= proc_get_long(&p
, &left
, &val_b
,
2811 &neg
, tr_b
, sizeof(tr_b
),
2815 if (val_b
>= bitmap_len
|| neg
||
2826 bitmap_set(tmp_bitmap
, val_a
, val_b
- val_a
+ 1);
2828 proc_skip_char(&p
, &left
, '\n');
2832 unsigned long bit_a
, bit_b
= 0;
2835 bit_a
= find_next_bit(bitmap
, bitmap_len
, bit_b
);
2836 if (bit_a
>= bitmap_len
)
2838 bit_b
= find_next_zero_bit(bitmap
, bitmap_len
,
2842 err
= proc_put_char(&buffer
, &left
, ',');
2846 err
= proc_put_long(&buffer
, &left
, bit_a
, false);
2849 if (bit_a
!= bit_b
) {
2850 err
= proc_put_char(&buffer
, &left
, '-');
2853 err
= proc_put_long(&buffer
, &left
, bit_b
, false);
2861 err
= proc_put_char(&buffer
, &left
, '\n');
2867 bitmap_or(bitmap
, bitmap
, tmp_bitmap
, bitmap_len
);
2869 bitmap_copy(bitmap
, tmp_bitmap
, bitmap_len
);
2881 #else /* CONFIG_PROC_SYSCTL */
2883 int proc_dostring(struct ctl_table
*table
, int write
,
2884 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2889 int proc_dointvec(struct ctl_table
*table
, int write
,
2890 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2895 int proc_douintvec(struct ctl_table
*table
, int write
,
2896 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2901 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2902 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2907 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2908 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2913 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2914 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2919 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2920 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2925 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2926 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2931 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2932 void __user
*buffer
,
2933 size_t *lenp
, loff_t
*ppos
)
2939 #endif /* CONFIG_PROC_SYSCTL */
2942 * No sense putting this after each symbol definition, twice,
2943 * exception granted :-)
2945 EXPORT_SYMBOL(proc_dointvec
);
2946 EXPORT_SYMBOL(proc_douintvec
);
2947 EXPORT_SYMBOL(proc_dointvec_jiffies
);
2948 EXPORT_SYMBOL(proc_dointvec_minmax
);
2949 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
2950 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
2951 EXPORT_SYMBOL(proc_dostring
);
2952 EXPORT_SYMBOL(proc_doulongvec_minmax
);
2953 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);