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 latencytop_enabled
;
110 extern int sysctl_nr_open_min
, sysctl_nr_open_max
;
112 extern int sysctl_nr_trim_pages
;
115 /* Constants used for minimum and maximum */
116 #ifdef CONFIG_LOCKUP_DETECTOR
117 static int sixty
= 60;
120 static int __maybe_unused neg_one
= -1;
123 static int __maybe_unused one
= 1;
124 static int __maybe_unused two
= 2;
125 static int __maybe_unused four
= 4;
126 static unsigned long one_ul
= 1;
127 static int one_hundred
= 100;
128 static int one_thousand
= 1000;
130 static int ten_thousand
= 10000;
132 #ifdef CONFIG_PERF_EVENTS
133 static int six_hundred_forty_kb
= 640 * 1024;
136 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
137 static unsigned long dirty_bytes_min
= 2 * PAGE_SIZE
;
139 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
140 static int maxolduid
= 65535;
141 static int minolduid
;
143 static int ngroups_max
= NGROUPS_MAX
;
144 static const int cap_last_cap
= CAP_LAST_CAP
;
146 /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
147 #ifdef CONFIG_DETECT_HUNG_TASK
148 static unsigned long hung_task_timeout_max
= (LONG_MAX
/HZ
);
151 #ifdef CONFIG_INOTIFY_USER
152 #include <linux/inotify.h>
158 extern int pwrsw_enabled
;
161 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
162 extern int unaligned_enabled
;
166 extern int unaligned_dump_stack
;
169 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
170 extern int no_unaligned_warning
;
173 #ifdef CONFIG_PROC_SYSCTL
175 #define SYSCTL_WRITES_LEGACY -1
176 #define SYSCTL_WRITES_WARN 0
177 #define SYSCTL_WRITES_STRICT 1
179 static int sysctl_writes_strict
= SYSCTL_WRITES_STRICT
;
181 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
182 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
183 static int proc_taint(struct ctl_table
*table
, int write
,
184 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
188 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
189 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
192 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
193 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
194 #ifdef CONFIG_COREDUMP
195 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
196 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
199 #ifdef CONFIG_MAGIC_SYSRQ
200 /* Note: sysrq code uses it's own private copy */
201 static int __sysrq_enabled
= CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE
;
203 static int sysrq_sysctl_handler(struct ctl_table
*table
, int write
,
204 void __user
*buffer
, size_t *lenp
,
209 error
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
214 sysrq_toggle_support(__sysrq_enabled
);
221 static struct ctl_table kern_table
[];
222 static struct ctl_table vm_table
[];
223 static struct ctl_table fs_table
[];
224 static struct ctl_table debug_table
[];
225 static struct ctl_table dev_table
[];
226 extern struct ctl_table random_table
[];
228 extern struct ctl_table epoll_table
[];
231 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
232 int sysctl_legacy_va_layout
;
235 /* The default sysctl tables: */
237 static struct ctl_table sysctl_base_table
[] = {
239 .procname
= "kernel",
256 .child
= debug_table
,
266 #ifdef CONFIG_SCHED_DEBUG
267 static int min_sched_granularity_ns
= 100000; /* 100 usecs */
268 static int max_sched_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
269 static int min_wakeup_granularity_ns
; /* 0 usecs */
270 static int max_wakeup_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
272 static int min_sched_tunable_scaling
= SCHED_TUNABLESCALING_NONE
;
273 static int max_sched_tunable_scaling
= SCHED_TUNABLESCALING_END
-1;
274 #endif /* CONFIG_SMP */
275 #endif /* CONFIG_SCHED_DEBUG */
277 #ifdef CONFIG_COMPACTION
278 static int min_extfrag_threshold
;
279 static int max_extfrag_threshold
= 1000;
282 static struct ctl_table kern_table
[] = {
284 .procname
= "sched_child_runs_first",
285 .data
= &sysctl_sched_child_runs_first
,
286 .maxlen
= sizeof(unsigned int),
288 .proc_handler
= proc_dointvec
,
290 #ifdef CONFIG_SCHED_DEBUG
292 .procname
= "sched_min_granularity_ns",
293 .data
= &sysctl_sched_min_granularity
,
294 .maxlen
= sizeof(unsigned int),
296 .proc_handler
= sched_proc_update_handler
,
297 .extra1
= &min_sched_granularity_ns
,
298 .extra2
= &max_sched_granularity_ns
,
301 .procname
= "sched_latency_ns",
302 .data
= &sysctl_sched_latency
,
303 .maxlen
= sizeof(unsigned int),
305 .proc_handler
= sched_proc_update_handler
,
306 .extra1
= &min_sched_granularity_ns
,
307 .extra2
= &max_sched_granularity_ns
,
310 .procname
= "sched_wakeup_granularity_ns",
311 .data
= &sysctl_sched_wakeup_granularity
,
312 .maxlen
= sizeof(unsigned int),
314 .proc_handler
= sched_proc_update_handler
,
315 .extra1
= &min_wakeup_granularity_ns
,
316 .extra2
= &max_wakeup_granularity_ns
,
320 .procname
= "sched_tunable_scaling",
321 .data
= &sysctl_sched_tunable_scaling
,
322 .maxlen
= sizeof(enum sched_tunable_scaling
),
324 .proc_handler
= sched_proc_update_handler
,
325 .extra1
= &min_sched_tunable_scaling
,
326 .extra2
= &max_sched_tunable_scaling
,
329 .procname
= "sched_migration_cost_ns",
330 .data
= &sysctl_sched_migration_cost
,
331 .maxlen
= sizeof(unsigned int),
333 .proc_handler
= proc_dointvec
,
336 .procname
= "sched_nr_migrate",
337 .data
= &sysctl_sched_nr_migrate
,
338 .maxlen
= sizeof(unsigned int),
340 .proc_handler
= proc_dointvec
,
343 .procname
= "sched_time_avg_ms",
344 .data
= &sysctl_sched_time_avg
,
345 .maxlen
= sizeof(unsigned int),
347 .proc_handler
= proc_dointvec
,
350 .procname
= "sched_shares_window_ns",
351 .data
= &sysctl_sched_shares_window
,
352 .maxlen
= sizeof(unsigned int),
354 .proc_handler
= proc_dointvec
,
356 #ifdef CONFIG_SCHEDSTATS
358 .procname
= "sched_schedstats",
360 .maxlen
= sizeof(unsigned int),
362 .proc_handler
= sysctl_schedstats
,
366 #endif /* CONFIG_SCHEDSTATS */
367 #endif /* CONFIG_SMP */
368 #ifdef CONFIG_NUMA_BALANCING
370 .procname
= "numa_balancing_scan_delay_ms",
371 .data
= &sysctl_numa_balancing_scan_delay
,
372 .maxlen
= sizeof(unsigned int),
374 .proc_handler
= proc_dointvec
,
377 .procname
= "numa_balancing_scan_period_min_ms",
378 .data
= &sysctl_numa_balancing_scan_period_min
,
379 .maxlen
= sizeof(unsigned int),
381 .proc_handler
= proc_dointvec
,
384 .procname
= "numa_balancing_scan_period_max_ms",
385 .data
= &sysctl_numa_balancing_scan_period_max
,
386 .maxlen
= sizeof(unsigned int),
388 .proc_handler
= proc_dointvec
,
391 .procname
= "numa_balancing_scan_size_mb",
392 .data
= &sysctl_numa_balancing_scan_size
,
393 .maxlen
= sizeof(unsigned int),
395 .proc_handler
= proc_dointvec_minmax
,
399 .procname
= "numa_balancing",
400 .data
= NULL
, /* filled in by handler */
401 .maxlen
= sizeof(unsigned int),
403 .proc_handler
= sysctl_numa_balancing
,
407 #endif /* CONFIG_NUMA_BALANCING */
408 #endif /* CONFIG_SCHED_DEBUG */
410 .procname
= "sched_rt_period_us",
411 .data
= &sysctl_sched_rt_period
,
412 .maxlen
= sizeof(unsigned int),
414 .proc_handler
= sched_rt_handler
,
417 .procname
= "sched_rt_runtime_us",
418 .data
= &sysctl_sched_rt_runtime
,
419 .maxlen
= sizeof(int),
421 .proc_handler
= sched_rt_handler
,
424 .procname
= "sched_rr_timeslice_ms",
425 .data
= &sched_rr_timeslice
,
426 .maxlen
= sizeof(int),
428 .proc_handler
= sched_rr_handler
,
430 #ifdef CONFIG_SCHED_AUTOGROUP
432 .procname
= "sched_autogroup_enabled",
433 .data
= &sysctl_sched_autogroup_enabled
,
434 .maxlen
= sizeof(unsigned int),
436 .proc_handler
= proc_dointvec_minmax
,
441 #ifdef CONFIG_CFS_BANDWIDTH
443 .procname
= "sched_cfs_bandwidth_slice_us",
444 .data
= &sysctl_sched_cfs_bandwidth_slice
,
445 .maxlen
= sizeof(unsigned int),
447 .proc_handler
= proc_dointvec_minmax
,
451 #ifdef CONFIG_PROVE_LOCKING
453 .procname
= "prove_locking",
454 .data
= &prove_locking
,
455 .maxlen
= sizeof(int),
457 .proc_handler
= proc_dointvec
,
460 #ifdef CONFIG_LOCK_STAT
462 .procname
= "lock_stat",
464 .maxlen
= sizeof(int),
466 .proc_handler
= proc_dointvec
,
471 .data
= &panic_timeout
,
472 .maxlen
= sizeof(int),
474 .proc_handler
= proc_dointvec
,
476 #ifdef CONFIG_COREDUMP
478 .procname
= "core_uses_pid",
479 .data
= &core_uses_pid
,
480 .maxlen
= sizeof(int),
482 .proc_handler
= proc_dointvec
,
485 .procname
= "core_pattern",
486 .data
= core_pattern
,
487 .maxlen
= CORENAME_MAX_SIZE
,
489 .proc_handler
= proc_dostring_coredump
,
492 .procname
= "core_pipe_limit",
493 .data
= &core_pipe_limit
,
494 .maxlen
= sizeof(unsigned int),
496 .proc_handler
= proc_dointvec
,
499 #ifdef CONFIG_PROC_SYSCTL
501 .procname
= "tainted",
502 .maxlen
= sizeof(long),
504 .proc_handler
= proc_taint
,
507 .procname
= "sysctl_writes_strict",
508 .data
= &sysctl_writes_strict
,
509 .maxlen
= sizeof(int),
511 .proc_handler
= proc_dointvec_minmax
,
516 #ifdef CONFIG_LATENCYTOP
518 .procname
= "latencytop",
519 .data
= &latencytop_enabled
,
520 .maxlen
= sizeof(int),
522 .proc_handler
= sysctl_latencytop
,
525 #ifdef CONFIG_BLK_DEV_INITRD
527 .procname
= "real-root-dev",
528 .data
= &real_root_dev
,
529 .maxlen
= sizeof(int),
531 .proc_handler
= proc_dointvec
,
535 .procname
= "print-fatal-signals",
536 .data
= &print_fatal_signals
,
537 .maxlen
= sizeof(int),
539 .proc_handler
= proc_dointvec
,
543 .procname
= "reboot-cmd",
544 .data
= reboot_command
,
547 .proc_handler
= proc_dostring
,
550 .procname
= "stop-a",
551 .data
= &stop_a_enabled
,
552 .maxlen
= sizeof (int),
554 .proc_handler
= proc_dointvec
,
557 .procname
= "scons-poweroff",
558 .data
= &scons_pwroff
,
559 .maxlen
= sizeof (int),
561 .proc_handler
= proc_dointvec
,
564 #ifdef CONFIG_SPARC64
566 .procname
= "tsb-ratio",
567 .data
= &sysctl_tsb_ratio
,
568 .maxlen
= sizeof (int),
570 .proc_handler
= proc_dointvec
,
575 .procname
= "soft-power",
576 .data
= &pwrsw_enabled
,
577 .maxlen
= sizeof (int),
579 .proc_handler
= proc_dointvec
,
582 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
584 .procname
= "unaligned-trap",
585 .data
= &unaligned_enabled
,
586 .maxlen
= sizeof (int),
588 .proc_handler
= proc_dointvec
,
592 .procname
= "ctrl-alt-del",
594 .maxlen
= sizeof(int),
596 .proc_handler
= proc_dointvec
,
598 #ifdef CONFIG_FUNCTION_TRACER
600 .procname
= "ftrace_enabled",
601 .data
= &ftrace_enabled
,
602 .maxlen
= sizeof(int),
604 .proc_handler
= ftrace_enable_sysctl
,
607 #ifdef CONFIG_STACK_TRACER
609 .procname
= "stack_tracer_enabled",
610 .data
= &stack_tracer_enabled
,
611 .maxlen
= sizeof(int),
613 .proc_handler
= stack_trace_sysctl
,
616 #ifdef CONFIG_TRACING
618 .procname
= "ftrace_dump_on_oops",
619 .data
= &ftrace_dump_on_oops
,
620 .maxlen
= sizeof(int),
622 .proc_handler
= proc_dointvec
,
625 .procname
= "traceoff_on_warning",
626 .data
= &__disable_trace_on_warning
,
627 .maxlen
= sizeof(__disable_trace_on_warning
),
629 .proc_handler
= proc_dointvec
,
632 .procname
= "tracepoint_printk",
633 .data
= &tracepoint_printk
,
634 .maxlen
= sizeof(tracepoint_printk
),
636 .proc_handler
= proc_dointvec
,
639 #ifdef CONFIG_KEXEC_CORE
641 .procname
= "kexec_load_disabled",
642 .data
= &kexec_load_disabled
,
643 .maxlen
= sizeof(int),
645 /* only handle a transition from default "0" to "1" */
646 .proc_handler
= proc_dointvec_minmax
,
651 #ifdef CONFIG_MODULES
653 .procname
= "modprobe",
654 .data
= &modprobe_path
,
655 .maxlen
= KMOD_PATH_LEN
,
657 .proc_handler
= proc_dostring
,
660 .procname
= "modules_disabled",
661 .data
= &modules_disabled
,
662 .maxlen
= sizeof(int),
664 /* only handle a transition from default "0" to "1" */
665 .proc_handler
= proc_dointvec_minmax
,
670 #ifdef CONFIG_UEVENT_HELPER
672 .procname
= "hotplug",
673 .data
= &uevent_helper
,
674 .maxlen
= UEVENT_HELPER_PATH_LEN
,
676 .proc_handler
= proc_dostring
,
679 #ifdef CONFIG_CHR_DEV_SG
681 .procname
= "sg-big-buff",
682 .data
= &sg_big_buff
,
683 .maxlen
= sizeof (int),
685 .proc_handler
= proc_dointvec
,
688 #ifdef CONFIG_BSD_PROCESS_ACCT
692 .maxlen
= 3*sizeof(int),
694 .proc_handler
= proc_dointvec
,
697 #ifdef CONFIG_MAGIC_SYSRQ
700 .data
= &__sysrq_enabled
,
701 .maxlen
= sizeof (int),
703 .proc_handler
= sysrq_sysctl_handler
,
706 #ifdef CONFIG_PROC_SYSCTL
708 .procname
= "cad_pid",
710 .maxlen
= sizeof (int),
712 .proc_handler
= proc_do_cad_pid
,
716 .procname
= "threads-max",
718 .maxlen
= sizeof(int),
720 .proc_handler
= sysctl_max_threads
,
723 .procname
= "random",
725 .child
= random_table
,
728 .procname
= "usermodehelper",
730 .child
= usermodehelper_table
,
733 .procname
= "overflowuid",
734 .data
= &overflowuid
,
735 .maxlen
= sizeof(int),
737 .proc_handler
= proc_dointvec_minmax
,
738 .extra1
= &minolduid
,
739 .extra2
= &maxolduid
,
742 .procname
= "overflowgid",
743 .data
= &overflowgid
,
744 .maxlen
= sizeof(int),
746 .proc_handler
= proc_dointvec_minmax
,
747 .extra1
= &minolduid
,
748 .extra2
= &maxolduid
,
751 #ifdef CONFIG_MATHEMU
753 .procname
= "ieee_emulation_warnings",
754 .data
= &sysctl_ieee_emulation_warnings
,
755 .maxlen
= sizeof(int),
757 .proc_handler
= proc_dointvec
,
761 .procname
= "userprocess_debug",
762 .data
= &show_unhandled_signals
,
763 .maxlen
= sizeof(int),
765 .proc_handler
= proc_dointvec
,
769 .procname
= "pid_max",
771 .maxlen
= sizeof (int),
773 .proc_handler
= proc_dointvec_minmax
,
774 .extra1
= &pid_max_min
,
775 .extra2
= &pid_max_max
,
778 .procname
= "panic_on_oops",
779 .data
= &panic_on_oops
,
780 .maxlen
= sizeof(int),
782 .proc_handler
= proc_dointvec
,
784 #if defined CONFIG_PRINTK
786 .procname
= "printk",
787 .data
= &console_loglevel
,
788 .maxlen
= 4*sizeof(int),
790 .proc_handler
= proc_dointvec
,
793 .procname
= "printk_ratelimit",
794 .data
= &printk_ratelimit_state
.interval
,
795 .maxlen
= sizeof(int),
797 .proc_handler
= proc_dointvec_jiffies
,
800 .procname
= "printk_ratelimit_burst",
801 .data
= &printk_ratelimit_state
.burst
,
802 .maxlen
= sizeof(int),
804 .proc_handler
= proc_dointvec
,
807 .procname
= "printk_delay",
808 .data
= &printk_delay_msec
,
809 .maxlen
= sizeof(int),
811 .proc_handler
= proc_dointvec_minmax
,
813 .extra2
= &ten_thousand
,
816 .procname
= "printk_devkmsg",
817 .data
= devkmsg_log_str
,
818 .maxlen
= DEVKMSG_STR_MAX_SIZE
,
820 .proc_handler
= devkmsg_sysctl_set_loglvl
,
823 .procname
= "dmesg_restrict",
824 .data
= &dmesg_restrict
,
825 .maxlen
= sizeof(int),
827 .proc_handler
= proc_dointvec_minmax_sysadmin
,
832 .procname
= "kptr_restrict",
833 .data
= &kptr_restrict
,
834 .maxlen
= sizeof(int),
836 .proc_handler
= proc_dointvec_minmax_sysadmin
,
842 .procname
= "ngroups_max",
843 .data
= &ngroups_max
,
844 .maxlen
= sizeof (int),
846 .proc_handler
= proc_dointvec
,
849 .procname
= "cap_last_cap",
850 .data
= (void *)&cap_last_cap
,
851 .maxlen
= sizeof(int),
853 .proc_handler
= proc_dointvec
,
855 #if defined(CONFIG_LOCKUP_DETECTOR)
857 .procname
= "watchdog",
858 .data
= &watchdog_user_enabled
,
859 .maxlen
= sizeof (int),
861 .proc_handler
= proc_watchdog
,
866 .procname
= "watchdog_thresh",
867 .data
= &watchdog_thresh
,
868 .maxlen
= sizeof(int),
870 .proc_handler
= proc_watchdog_thresh
,
875 .procname
= "nmi_watchdog",
876 .data
= &nmi_watchdog_enabled
,
877 .maxlen
= sizeof (int),
879 .proc_handler
= proc_nmi_watchdog
,
881 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
888 .procname
= "soft_watchdog",
889 .data
= &soft_watchdog_enabled
,
890 .maxlen
= sizeof (int),
892 .proc_handler
= proc_soft_watchdog
,
897 .procname
= "watchdog_cpumask",
898 .data
= &watchdog_cpumask_bits
,
901 .proc_handler
= proc_watchdog_cpumask
,
904 .procname
= "softlockup_panic",
905 .data
= &softlockup_panic
,
906 .maxlen
= sizeof(int),
908 .proc_handler
= proc_dointvec_minmax
,
912 #ifdef CONFIG_HARDLOCKUP_DETECTOR
914 .procname
= "hardlockup_panic",
915 .data
= &hardlockup_panic
,
916 .maxlen
= sizeof(int),
918 .proc_handler
= proc_dointvec_minmax
,
925 .procname
= "softlockup_all_cpu_backtrace",
926 .data
= &sysctl_softlockup_all_cpu_backtrace
,
927 .maxlen
= sizeof(int),
929 .proc_handler
= proc_dointvec_minmax
,
934 .procname
= "hardlockup_all_cpu_backtrace",
935 .data
= &sysctl_hardlockup_all_cpu_backtrace
,
936 .maxlen
= sizeof(int),
938 .proc_handler
= proc_dointvec_minmax
,
942 #endif /* CONFIG_SMP */
944 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
946 .procname
= "unknown_nmi_panic",
947 .data
= &unknown_nmi_panic
,
948 .maxlen
= sizeof (int),
950 .proc_handler
= proc_dointvec
,
953 #if defined(CONFIG_X86)
955 .procname
= "panic_on_unrecovered_nmi",
956 .data
= &panic_on_unrecovered_nmi
,
957 .maxlen
= sizeof(int),
959 .proc_handler
= proc_dointvec
,
962 .procname
= "panic_on_io_nmi",
963 .data
= &panic_on_io_nmi
,
964 .maxlen
= sizeof(int),
966 .proc_handler
= proc_dointvec
,
968 #ifdef CONFIG_DEBUG_STACKOVERFLOW
970 .procname
= "panic_on_stackoverflow",
971 .data
= &sysctl_panic_on_stackoverflow
,
972 .maxlen
= sizeof(int),
974 .proc_handler
= proc_dointvec
,
978 .procname
= "bootloader_type",
979 .data
= &bootloader_type
,
980 .maxlen
= sizeof (int),
982 .proc_handler
= proc_dointvec
,
985 .procname
= "bootloader_version",
986 .data
= &bootloader_version
,
987 .maxlen
= sizeof (int),
989 .proc_handler
= proc_dointvec
,
992 .procname
= "kstack_depth_to_print",
993 .data
= &kstack_depth_to_print
,
994 .maxlen
= sizeof(int),
996 .proc_handler
= proc_dointvec
,
999 .procname
= "io_delay_type",
1000 .data
= &io_delay_type
,
1001 .maxlen
= sizeof(int),
1003 .proc_handler
= proc_dointvec
,
1006 #if defined(CONFIG_MMU)
1008 .procname
= "randomize_va_space",
1009 .data
= &randomize_va_space
,
1010 .maxlen
= sizeof(int),
1012 .proc_handler
= proc_dointvec
,
1015 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1017 .procname
= "spin_retry",
1018 .data
= &spin_retry
,
1019 .maxlen
= sizeof (int),
1021 .proc_handler
= proc_dointvec
,
1024 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1026 .procname
= "acpi_video_flags",
1027 .data
= &acpi_realmode_flags
,
1028 .maxlen
= sizeof (unsigned long),
1030 .proc_handler
= proc_doulongvec_minmax
,
1033 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1035 .procname
= "ignore-unaligned-usertrap",
1036 .data
= &no_unaligned_warning
,
1037 .maxlen
= sizeof (int),
1039 .proc_handler
= proc_dointvec
,
1044 .procname
= "unaligned-dump-stack",
1045 .data
= &unaligned_dump_stack
,
1046 .maxlen
= sizeof (int),
1048 .proc_handler
= proc_dointvec
,
1051 #ifdef CONFIG_DETECT_HUNG_TASK
1053 .procname
= "hung_task_panic",
1054 .data
= &sysctl_hung_task_panic
,
1055 .maxlen
= sizeof(int),
1057 .proc_handler
= proc_dointvec_minmax
,
1062 .procname
= "hung_task_check_count",
1063 .data
= &sysctl_hung_task_check_count
,
1064 .maxlen
= sizeof(int),
1066 .proc_handler
= proc_dointvec_minmax
,
1070 .procname
= "hung_task_timeout_secs",
1071 .data
= &sysctl_hung_task_timeout_secs
,
1072 .maxlen
= sizeof(unsigned long),
1074 .proc_handler
= proc_dohung_task_timeout_secs
,
1075 .extra2
= &hung_task_timeout_max
,
1078 .procname
= "hung_task_warnings",
1079 .data
= &sysctl_hung_task_warnings
,
1080 .maxlen
= sizeof(int),
1082 .proc_handler
= proc_dointvec_minmax
,
1086 #ifdef CONFIG_RT_MUTEXES
1088 .procname
= "max_lock_depth",
1089 .data
= &max_lock_depth
,
1090 .maxlen
= sizeof(int),
1092 .proc_handler
= proc_dointvec
,
1096 .procname
= "poweroff_cmd",
1097 .data
= &poweroff_cmd
,
1098 .maxlen
= POWEROFF_CMD_PATH_LEN
,
1100 .proc_handler
= proc_dostring
,
1106 .child
= key_sysctls
,
1109 #ifdef CONFIG_PERF_EVENTS
1111 * User-space scripts rely on the existence of this file
1112 * as a feature check for perf_events being enabled.
1114 * So it's an ABI, do not remove!
1117 .procname
= "perf_event_paranoid",
1118 .data
= &sysctl_perf_event_paranoid
,
1119 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
1121 .proc_handler
= proc_dointvec
,
1124 .procname
= "perf_event_mlock_kb",
1125 .data
= &sysctl_perf_event_mlock
,
1126 .maxlen
= sizeof(sysctl_perf_event_mlock
),
1128 .proc_handler
= proc_dointvec
,
1131 .procname
= "perf_event_max_sample_rate",
1132 .data
= &sysctl_perf_event_sample_rate
,
1133 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1135 .proc_handler
= perf_proc_update_handler
,
1139 .procname
= "perf_cpu_time_max_percent",
1140 .data
= &sysctl_perf_cpu_time_max_percent
,
1141 .maxlen
= sizeof(sysctl_perf_cpu_time_max_percent
),
1143 .proc_handler
= perf_cpu_time_max_percent_handler
,
1145 .extra2
= &one_hundred
,
1148 .procname
= "perf_event_max_stack",
1149 .data
= &sysctl_perf_event_max_stack
,
1150 .maxlen
= sizeof(sysctl_perf_event_max_stack
),
1152 .proc_handler
= perf_event_max_stack_handler
,
1154 .extra2
= &six_hundred_forty_kb
,
1157 .procname
= "perf_event_max_contexts_per_stack",
1158 .data
= &sysctl_perf_event_max_contexts_per_stack
,
1159 .maxlen
= sizeof(sysctl_perf_event_max_contexts_per_stack
),
1161 .proc_handler
= perf_event_max_stack_handler
,
1163 .extra2
= &one_thousand
,
1166 #ifdef CONFIG_KMEMCHECK
1168 .procname
= "kmemcheck",
1169 .data
= &kmemcheck_enabled
,
1170 .maxlen
= sizeof(int),
1172 .proc_handler
= proc_dointvec
,
1176 .procname
= "panic_on_warn",
1177 .data
= &panic_on_warn
,
1178 .maxlen
= sizeof(int),
1180 .proc_handler
= proc_dointvec_minmax
,
1184 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1186 .procname
= "timer_migration",
1187 .data
= &sysctl_timer_migration
,
1188 .maxlen
= sizeof(unsigned int),
1190 .proc_handler
= timer_migration_handler
,
1193 #ifdef CONFIG_BPF_SYSCALL
1195 .procname
= "unprivileged_bpf_disabled",
1196 .data
= &sysctl_unprivileged_bpf_disabled
,
1197 .maxlen
= sizeof(sysctl_unprivileged_bpf_disabled
),
1199 /* only handle a transition from default "0" to "1" */
1200 .proc_handler
= proc_dointvec_minmax
,
1205 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1207 .procname
= "panic_on_rcu_stall",
1208 .data
= &sysctl_panic_on_rcu_stall
,
1209 .maxlen
= sizeof(sysctl_panic_on_rcu_stall
),
1211 .proc_handler
= proc_dointvec_minmax
,
1219 static struct ctl_table vm_table
[] = {
1221 .procname
= "overcommit_memory",
1222 .data
= &sysctl_overcommit_memory
,
1223 .maxlen
= sizeof(sysctl_overcommit_memory
),
1225 .proc_handler
= proc_dointvec_minmax
,
1230 .procname
= "panic_on_oom",
1231 .data
= &sysctl_panic_on_oom
,
1232 .maxlen
= sizeof(sysctl_panic_on_oom
),
1234 .proc_handler
= proc_dointvec_minmax
,
1239 .procname
= "oom_kill_allocating_task",
1240 .data
= &sysctl_oom_kill_allocating_task
,
1241 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
1243 .proc_handler
= proc_dointvec
,
1246 .procname
= "oom_dump_tasks",
1247 .data
= &sysctl_oom_dump_tasks
,
1248 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
1250 .proc_handler
= proc_dointvec
,
1253 .procname
= "overcommit_ratio",
1254 .data
= &sysctl_overcommit_ratio
,
1255 .maxlen
= sizeof(sysctl_overcommit_ratio
),
1257 .proc_handler
= overcommit_ratio_handler
,
1260 .procname
= "overcommit_kbytes",
1261 .data
= &sysctl_overcommit_kbytes
,
1262 .maxlen
= sizeof(sysctl_overcommit_kbytes
),
1264 .proc_handler
= overcommit_kbytes_handler
,
1267 .procname
= "page-cluster",
1268 .data
= &page_cluster
,
1269 .maxlen
= sizeof(int),
1271 .proc_handler
= proc_dointvec_minmax
,
1275 .procname
= "dirty_background_ratio",
1276 .data
= &dirty_background_ratio
,
1277 .maxlen
= sizeof(dirty_background_ratio
),
1279 .proc_handler
= dirty_background_ratio_handler
,
1281 .extra2
= &one_hundred
,
1284 .procname
= "dirty_background_bytes",
1285 .data
= &dirty_background_bytes
,
1286 .maxlen
= sizeof(dirty_background_bytes
),
1288 .proc_handler
= dirty_background_bytes_handler
,
1292 .procname
= "dirty_ratio",
1293 .data
= &vm_dirty_ratio
,
1294 .maxlen
= sizeof(vm_dirty_ratio
),
1296 .proc_handler
= dirty_ratio_handler
,
1298 .extra2
= &one_hundred
,
1301 .procname
= "dirty_bytes",
1302 .data
= &vm_dirty_bytes
,
1303 .maxlen
= sizeof(vm_dirty_bytes
),
1305 .proc_handler
= dirty_bytes_handler
,
1306 .extra1
= &dirty_bytes_min
,
1309 .procname
= "dirty_writeback_centisecs",
1310 .data
= &dirty_writeback_interval
,
1311 .maxlen
= sizeof(dirty_writeback_interval
),
1313 .proc_handler
= dirty_writeback_centisecs_handler
,
1316 .procname
= "dirty_expire_centisecs",
1317 .data
= &dirty_expire_interval
,
1318 .maxlen
= sizeof(dirty_expire_interval
),
1320 .proc_handler
= proc_dointvec_minmax
,
1324 .procname
= "dirtytime_expire_seconds",
1325 .data
= &dirtytime_expire_interval
,
1326 .maxlen
= sizeof(dirty_expire_interval
),
1328 .proc_handler
= dirtytime_interval_handler
,
1332 .procname
= "nr_pdflush_threads",
1333 .mode
= 0444 /* read-only */,
1334 .proc_handler
= pdflush_proc_obsolete
,
1337 .procname
= "swappiness",
1338 .data
= &vm_swappiness
,
1339 .maxlen
= sizeof(vm_swappiness
),
1341 .proc_handler
= proc_dointvec_minmax
,
1343 .extra2
= &one_hundred
,
1345 #ifdef CONFIG_HUGETLB_PAGE
1347 .procname
= "nr_hugepages",
1349 .maxlen
= sizeof(unsigned long),
1351 .proc_handler
= hugetlb_sysctl_handler
,
1355 .procname
= "nr_hugepages_mempolicy",
1357 .maxlen
= sizeof(unsigned long),
1359 .proc_handler
= &hugetlb_mempolicy_sysctl_handler
,
1363 .procname
= "hugetlb_shm_group",
1364 .data
= &sysctl_hugetlb_shm_group
,
1365 .maxlen
= sizeof(gid_t
),
1367 .proc_handler
= proc_dointvec
,
1370 .procname
= "hugepages_treat_as_movable",
1371 .data
= &hugepages_treat_as_movable
,
1372 .maxlen
= sizeof(int),
1374 .proc_handler
= proc_dointvec
,
1377 .procname
= "nr_overcommit_hugepages",
1379 .maxlen
= sizeof(unsigned long),
1381 .proc_handler
= hugetlb_overcommit_handler
,
1385 .procname
= "lowmem_reserve_ratio",
1386 .data
= &sysctl_lowmem_reserve_ratio
,
1387 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
1389 .proc_handler
= lowmem_reserve_ratio_sysctl_handler
,
1392 .procname
= "drop_caches",
1393 .data
= &sysctl_drop_caches
,
1394 .maxlen
= sizeof(int),
1396 .proc_handler
= drop_caches_sysctl_handler
,
1400 #ifdef CONFIG_COMPACTION
1402 .procname
= "compact_memory",
1403 .data
= &sysctl_compact_memory
,
1404 .maxlen
= sizeof(int),
1406 .proc_handler
= sysctl_compaction_handler
,
1409 .procname
= "extfrag_threshold",
1410 .data
= &sysctl_extfrag_threshold
,
1411 .maxlen
= sizeof(int),
1413 .proc_handler
= sysctl_extfrag_handler
,
1414 .extra1
= &min_extfrag_threshold
,
1415 .extra2
= &max_extfrag_threshold
,
1418 .procname
= "compact_unevictable_allowed",
1419 .data
= &sysctl_compact_unevictable_allowed
,
1420 .maxlen
= sizeof(int),
1422 .proc_handler
= proc_dointvec
,
1427 #endif /* CONFIG_COMPACTION */
1429 .procname
= "min_free_kbytes",
1430 .data
= &min_free_kbytes
,
1431 .maxlen
= sizeof(min_free_kbytes
),
1433 .proc_handler
= min_free_kbytes_sysctl_handler
,
1437 .procname
= "watermark_scale_factor",
1438 .data
= &watermark_scale_factor
,
1439 .maxlen
= sizeof(watermark_scale_factor
),
1441 .proc_handler
= watermark_scale_factor_sysctl_handler
,
1443 .extra2
= &one_thousand
,
1446 .procname
= "percpu_pagelist_fraction",
1447 .data
= &percpu_pagelist_fraction
,
1448 .maxlen
= sizeof(percpu_pagelist_fraction
),
1450 .proc_handler
= percpu_pagelist_fraction_sysctl_handler
,
1455 .procname
= "max_map_count",
1456 .data
= &sysctl_max_map_count
,
1457 .maxlen
= sizeof(sysctl_max_map_count
),
1459 .proc_handler
= proc_dointvec_minmax
,
1464 .procname
= "nr_trim_pages",
1465 .data
= &sysctl_nr_trim_pages
,
1466 .maxlen
= sizeof(sysctl_nr_trim_pages
),
1468 .proc_handler
= proc_dointvec_minmax
,
1473 .procname
= "laptop_mode",
1474 .data
= &laptop_mode
,
1475 .maxlen
= sizeof(laptop_mode
),
1477 .proc_handler
= proc_dointvec_jiffies
,
1480 .procname
= "block_dump",
1481 .data
= &block_dump
,
1482 .maxlen
= sizeof(block_dump
),
1484 .proc_handler
= proc_dointvec
,
1488 .procname
= "vfs_cache_pressure",
1489 .data
= &sysctl_vfs_cache_pressure
,
1490 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1492 .proc_handler
= proc_dointvec
,
1495 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1497 .procname
= "legacy_va_layout",
1498 .data
= &sysctl_legacy_va_layout
,
1499 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1501 .proc_handler
= proc_dointvec
,
1507 .procname
= "zone_reclaim_mode",
1508 .data
= &node_reclaim_mode
,
1509 .maxlen
= sizeof(node_reclaim_mode
),
1511 .proc_handler
= proc_dointvec
,
1515 .procname
= "min_unmapped_ratio",
1516 .data
= &sysctl_min_unmapped_ratio
,
1517 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1519 .proc_handler
= sysctl_min_unmapped_ratio_sysctl_handler
,
1521 .extra2
= &one_hundred
,
1524 .procname
= "min_slab_ratio",
1525 .data
= &sysctl_min_slab_ratio
,
1526 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1528 .proc_handler
= sysctl_min_slab_ratio_sysctl_handler
,
1530 .extra2
= &one_hundred
,
1535 .procname
= "stat_interval",
1536 .data
= &sysctl_stat_interval
,
1537 .maxlen
= sizeof(sysctl_stat_interval
),
1539 .proc_handler
= proc_dointvec_jiffies
,
1542 .procname
= "stat_refresh",
1546 .proc_handler
= vmstat_refresh
,
1551 .procname
= "mmap_min_addr",
1552 .data
= &dac_mmap_min_addr
,
1553 .maxlen
= sizeof(unsigned long),
1555 .proc_handler
= mmap_min_addr_handler
,
1560 .procname
= "numa_zonelist_order",
1561 .data
= &numa_zonelist_order
,
1562 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1564 .proc_handler
= numa_zonelist_order_handler
,
1567 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1568 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1570 .procname
= "vdso_enabled",
1571 #ifdef CONFIG_X86_32
1572 .data
= &vdso32_enabled
,
1573 .maxlen
= sizeof(vdso32_enabled
),
1575 .data
= &vdso_enabled
,
1576 .maxlen
= sizeof(vdso_enabled
),
1579 .proc_handler
= proc_dointvec
,
1583 #ifdef CONFIG_HIGHMEM
1585 .procname
= "highmem_is_dirtyable",
1586 .data
= &vm_highmem_is_dirtyable
,
1587 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
1589 .proc_handler
= proc_dointvec_minmax
,
1594 #ifdef CONFIG_MEMORY_FAILURE
1596 .procname
= "memory_failure_early_kill",
1597 .data
= &sysctl_memory_failure_early_kill
,
1598 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
1600 .proc_handler
= proc_dointvec_minmax
,
1605 .procname
= "memory_failure_recovery",
1606 .data
= &sysctl_memory_failure_recovery
,
1607 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
1609 .proc_handler
= proc_dointvec_minmax
,
1615 .procname
= "user_reserve_kbytes",
1616 .data
= &sysctl_user_reserve_kbytes
,
1617 .maxlen
= sizeof(sysctl_user_reserve_kbytes
),
1619 .proc_handler
= proc_doulongvec_minmax
,
1622 .procname
= "admin_reserve_kbytes",
1623 .data
= &sysctl_admin_reserve_kbytes
,
1624 .maxlen
= sizeof(sysctl_admin_reserve_kbytes
),
1626 .proc_handler
= proc_doulongvec_minmax
,
1628 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1630 .procname
= "mmap_rnd_bits",
1631 .data
= &mmap_rnd_bits
,
1632 .maxlen
= sizeof(mmap_rnd_bits
),
1634 .proc_handler
= proc_dointvec_minmax
,
1635 .extra1
= (void *)&mmap_rnd_bits_min
,
1636 .extra2
= (void *)&mmap_rnd_bits_max
,
1639 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1641 .procname
= "mmap_rnd_compat_bits",
1642 .data
= &mmap_rnd_compat_bits
,
1643 .maxlen
= sizeof(mmap_rnd_compat_bits
),
1645 .proc_handler
= proc_dointvec_minmax
,
1646 .extra1
= (void *)&mmap_rnd_compat_bits_min
,
1647 .extra2
= (void *)&mmap_rnd_compat_bits_max
,
1653 static struct ctl_table fs_table
[] = {
1655 .procname
= "inode-nr",
1656 .data
= &inodes_stat
,
1657 .maxlen
= 2*sizeof(long),
1659 .proc_handler
= proc_nr_inodes
,
1662 .procname
= "inode-state",
1663 .data
= &inodes_stat
,
1664 .maxlen
= 7*sizeof(long),
1666 .proc_handler
= proc_nr_inodes
,
1669 .procname
= "file-nr",
1670 .data
= &files_stat
,
1671 .maxlen
= sizeof(files_stat
),
1673 .proc_handler
= proc_nr_files
,
1676 .procname
= "file-max",
1677 .data
= &files_stat
.max_files
,
1678 .maxlen
= sizeof(files_stat
.max_files
),
1680 .proc_handler
= proc_doulongvec_minmax
,
1683 .procname
= "nr_open",
1684 .data
= &sysctl_nr_open
,
1685 .maxlen
= sizeof(int),
1687 .proc_handler
= proc_dointvec_minmax
,
1688 .extra1
= &sysctl_nr_open_min
,
1689 .extra2
= &sysctl_nr_open_max
,
1692 .procname
= "dentry-state",
1693 .data
= &dentry_stat
,
1694 .maxlen
= 6*sizeof(long),
1696 .proc_handler
= proc_nr_dentry
,
1699 .procname
= "overflowuid",
1700 .data
= &fs_overflowuid
,
1701 .maxlen
= sizeof(int),
1703 .proc_handler
= proc_dointvec_minmax
,
1704 .extra1
= &minolduid
,
1705 .extra2
= &maxolduid
,
1708 .procname
= "overflowgid",
1709 .data
= &fs_overflowgid
,
1710 .maxlen
= sizeof(int),
1712 .proc_handler
= proc_dointvec_minmax
,
1713 .extra1
= &minolduid
,
1714 .extra2
= &maxolduid
,
1716 #ifdef CONFIG_FILE_LOCKING
1718 .procname
= "leases-enable",
1719 .data
= &leases_enable
,
1720 .maxlen
= sizeof(int),
1722 .proc_handler
= proc_dointvec
,
1725 #ifdef CONFIG_DNOTIFY
1727 .procname
= "dir-notify-enable",
1728 .data
= &dir_notify_enable
,
1729 .maxlen
= sizeof(int),
1731 .proc_handler
= proc_dointvec
,
1735 #ifdef CONFIG_FILE_LOCKING
1737 .procname
= "lease-break-time",
1738 .data
= &lease_break_time
,
1739 .maxlen
= sizeof(int),
1741 .proc_handler
= proc_dointvec
,
1746 .procname
= "aio-nr",
1748 .maxlen
= sizeof(aio_nr
),
1750 .proc_handler
= proc_doulongvec_minmax
,
1753 .procname
= "aio-max-nr",
1754 .data
= &aio_max_nr
,
1755 .maxlen
= sizeof(aio_max_nr
),
1757 .proc_handler
= proc_doulongvec_minmax
,
1759 #endif /* CONFIG_AIO */
1760 #ifdef CONFIG_INOTIFY_USER
1762 .procname
= "inotify",
1764 .child
= inotify_table
,
1769 .procname
= "epoll",
1771 .child
= epoll_table
,
1776 .procname
= "protected_symlinks",
1777 .data
= &sysctl_protected_symlinks
,
1778 .maxlen
= sizeof(int),
1780 .proc_handler
= proc_dointvec_minmax
,
1785 .procname
= "protected_hardlinks",
1786 .data
= &sysctl_protected_hardlinks
,
1787 .maxlen
= sizeof(int),
1789 .proc_handler
= proc_dointvec_minmax
,
1794 .procname
= "suid_dumpable",
1795 .data
= &suid_dumpable
,
1796 .maxlen
= sizeof(int),
1798 .proc_handler
= proc_dointvec_minmax_coredump
,
1802 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1804 .procname
= "binfmt_misc",
1806 .child
= sysctl_mount_point
,
1810 .procname
= "pipe-max-size",
1811 .data
= &pipe_max_size
,
1812 .maxlen
= sizeof(int),
1814 .proc_handler
= &pipe_proc_fn
,
1815 .extra1
= &pipe_min_size
,
1818 .procname
= "pipe-user-pages-hard",
1819 .data
= &pipe_user_pages_hard
,
1820 .maxlen
= sizeof(pipe_user_pages_hard
),
1822 .proc_handler
= proc_doulongvec_minmax
,
1825 .procname
= "pipe-user-pages-soft",
1826 .data
= &pipe_user_pages_soft
,
1827 .maxlen
= sizeof(pipe_user_pages_soft
),
1829 .proc_handler
= proc_doulongvec_minmax
,
1834 static struct ctl_table debug_table
[] = {
1835 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1837 .procname
= "exception-trace",
1838 .data
= &show_unhandled_signals
,
1839 .maxlen
= sizeof(int),
1841 .proc_handler
= proc_dointvec
1844 #if defined(CONFIG_OPTPROBES)
1846 .procname
= "kprobes-optimization",
1847 .data
= &sysctl_kprobes_optimization
,
1848 .maxlen
= sizeof(int),
1850 .proc_handler
= proc_kprobes_optimization_handler
,
1858 static struct ctl_table dev_table
[] = {
1862 int __init
sysctl_init(void)
1864 struct ctl_table_header
*hdr
;
1866 hdr
= register_sysctl_table(sysctl_base_table
);
1867 kmemleak_not_leak(hdr
);
1871 #endif /* CONFIG_SYSCTL */
1877 #ifdef CONFIG_PROC_SYSCTL
1879 static int _proc_do_string(char *data
, int maxlen
, int write
,
1880 char __user
*buffer
,
1881 size_t *lenp
, loff_t
*ppos
)
1887 if (!data
|| !maxlen
|| !*lenp
) {
1893 if (sysctl_writes_strict
== SYSCTL_WRITES_STRICT
) {
1894 /* Only continue writes not past the end of buffer. */
1896 if (len
> maxlen
- 1)
1903 /* Start writing from beginning of buffer. */
1909 while ((p
- buffer
) < *lenp
&& len
< maxlen
- 1) {
1910 if (get_user(c
, p
++))
1912 if (c
== 0 || c
== '\n')
1933 if (copy_to_user(buffer
, data
, len
))
1936 if (put_user('\n', buffer
+ len
))
1946 static void warn_sysctl_write(struct ctl_table
*table
)
1948 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1949 "This will not be supported in the future. To silence this\n"
1950 "warning, set kernel.sysctl_writes_strict = -1\n",
1951 current
->comm
, table
->procname
);
1955 * proc_dostring - read a string sysctl
1956 * @table: the sysctl table
1957 * @write: %TRUE if this is a write to the sysctl file
1958 * @buffer: the user buffer
1959 * @lenp: the size of the user buffer
1960 * @ppos: file position
1962 * Reads/writes a string from/to the user buffer. If the kernel
1963 * buffer provided is not large enough to hold the string, the
1964 * string is truncated. The copied string is %NULL-terminated.
1965 * If the string is being read by the user process, it is copied
1966 * and a newline '\n' is added. It is truncated if the buffer is
1969 * Returns 0 on success.
1971 int proc_dostring(struct ctl_table
*table
, int write
,
1972 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
1974 if (write
&& *ppos
&& sysctl_writes_strict
== SYSCTL_WRITES_WARN
)
1975 warn_sysctl_write(table
);
1977 return _proc_do_string((char *)(table
->data
), table
->maxlen
, write
,
1978 (char __user
*)buffer
, lenp
, ppos
);
1981 static size_t proc_skip_spaces(char **buf
)
1984 char *tmp
= skip_spaces(*buf
);
1990 static void proc_skip_char(char **buf
, size_t *size
, const char v
)
2000 #define TMPBUFLEN 22
2002 * proc_get_long - reads an ASCII formatted integer from a user buffer
2004 * @buf: a kernel buffer
2005 * @size: size of the kernel buffer
2006 * @val: this is where the number will be stored
2007 * @neg: set to %TRUE if number is negative
2008 * @perm_tr: a vector which contains the allowed trailers
2009 * @perm_tr_len: size of the perm_tr vector
2010 * @tr: pointer to store the trailer character
2012 * In case of success %0 is returned and @buf and @size are updated with
2013 * the amount of bytes read. If @tr is non-NULL and a trailing
2014 * character exists (size is non-zero after returning from this
2015 * function), @tr is updated with the trailing character.
2017 static int proc_get_long(char **buf
, size_t *size
,
2018 unsigned long *val
, bool *neg
,
2019 const char *perm_tr
, unsigned perm_tr_len
, char *tr
)
2022 char *p
, tmp
[TMPBUFLEN
];
2028 if (len
> TMPBUFLEN
- 1)
2029 len
= TMPBUFLEN
- 1;
2031 memcpy(tmp
, *buf
, len
);
2035 if (*p
== '-' && *size
> 1) {
2043 *val
= simple_strtoul(p
, &p
, 0);
2047 /* We don't know if the next char is whitespace thus we may accept
2048 * invalid integers (e.g. 1234...a) or two integers instead of one
2049 * (e.g. 123...1). So lets not allow such large numbers. */
2050 if (len
== TMPBUFLEN
- 1)
2053 if (len
< *size
&& perm_tr_len
&& !memchr(perm_tr
, *p
, perm_tr_len
))
2056 if (tr
&& (len
< *size
))
2066 * proc_put_long - converts an integer to a decimal ASCII formatted string
2068 * @buf: the user buffer
2069 * @size: the size of the user buffer
2070 * @val: the integer to be converted
2071 * @neg: sign of the number, %TRUE for negative
2073 * In case of success %0 is returned and @buf and @size are updated with
2074 * the amount of bytes written.
2076 static int proc_put_long(void __user
**buf
, size_t *size
, unsigned long val
,
2080 char tmp
[TMPBUFLEN
], *p
= tmp
;
2082 sprintf(p
, "%s%lu", neg
? "-" : "", val
);
2086 if (copy_to_user(*buf
, tmp
, len
))
2094 static int proc_put_char(void __user
**buf
, size_t *size
, char c
)
2097 char __user
**buffer
= (char __user
**)buf
;
2098 if (put_user(c
, *buffer
))
2100 (*size
)--, (*buffer
)++;
2106 static int do_proc_dointvec_conv(bool *negp
, unsigned long *lvalp
,
2108 int write
, void *data
)
2112 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2116 if (*lvalp
> (unsigned long) INT_MAX
)
2124 *lvalp
= -(unsigned long)val
;
2127 *lvalp
= (unsigned long)val
;
2133 static int do_proc_douintvec_conv(bool *negp
, unsigned long *lvalp
,
2135 int write
, void *data
)
2142 unsigned int val
= *valp
;
2143 *lvalp
= (unsigned long)val
;
2148 static const char proc_wspace_sep
[] = { ' ', '\t', '\n' };
2150 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2151 int write
, void __user
*buffer
,
2152 size_t *lenp
, loff_t
*ppos
,
2153 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2154 int write
, void *data
),
2157 int *i
, vleft
, first
= 1, err
= 0;
2159 char *kbuf
= NULL
, *p
;
2161 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2166 i
= (int *) tbl_data
;
2167 vleft
= table
->maxlen
/ sizeof(*i
);
2171 conv
= do_proc_dointvec_conv
;
2175 switch (sysctl_writes_strict
) {
2176 case SYSCTL_WRITES_STRICT
:
2178 case SYSCTL_WRITES_WARN
:
2179 warn_sysctl_write(table
);
2186 if (left
> PAGE_SIZE
- 1)
2187 left
= PAGE_SIZE
- 1;
2188 p
= kbuf
= memdup_user_nul(buffer
, left
);
2190 return PTR_ERR(kbuf
);
2193 for (; left
&& vleft
--; i
++, first
=0) {
2198 left
-= proc_skip_spaces(&p
);
2202 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2204 sizeof(proc_wspace_sep
), NULL
);
2207 if (conv(&neg
, &lval
, i
, 1, data
)) {
2212 if (conv(&neg
, &lval
, i
, 0, data
)) {
2217 err
= proc_put_char(&buffer
, &left
, '\t');
2220 err
= proc_put_long(&buffer
, &left
, lval
, neg
);
2226 if (!write
&& !first
&& left
&& !err
)
2227 err
= proc_put_char(&buffer
, &left
, '\n');
2228 if (write
&& !err
&& left
)
2229 left
-= proc_skip_spaces(&p
);
2233 return err
? : -EINVAL
;
2241 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2242 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2243 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2244 int write
, void *data
),
2247 return __do_proc_dointvec(table
->data
, table
, write
,
2248 buffer
, lenp
, ppos
, conv
, data
);
2252 * proc_dointvec - read a vector of integers
2253 * @table: the sysctl table
2254 * @write: %TRUE if this is a write to the sysctl file
2255 * @buffer: the user buffer
2256 * @lenp: the size of the user buffer
2257 * @ppos: file position
2259 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2260 * values from/to the user buffer, treated as an ASCII string.
2262 * Returns 0 on success.
2264 int proc_dointvec(struct ctl_table
*table
, int write
,
2265 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2267 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
, NULL
, NULL
);
2271 * proc_douintvec - read a vector of unsigned integers
2272 * @table: the sysctl table
2273 * @write: %TRUE if this is a write to the sysctl file
2274 * @buffer: the user buffer
2275 * @lenp: the size of the user buffer
2276 * @ppos: file position
2278 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2279 * values from/to the user buffer, treated as an ASCII string.
2281 * Returns 0 on success.
2283 int proc_douintvec(struct ctl_table
*table
, int write
,
2284 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2286 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2287 do_proc_douintvec_conv
, NULL
);
2291 * Taint values can only be increased
2292 * This means we can safely use a temporary.
2294 static int proc_taint(struct ctl_table
*table
, int write
,
2295 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2298 unsigned long tmptaint
= get_taint();
2301 if (write
&& !capable(CAP_SYS_ADMIN
))
2306 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2312 * Poor man's atomic or. Not worth adding a primitive
2313 * to everyone's atomic.h for this
2316 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2317 if ((tmptaint
>> i
) & 1)
2318 add_taint(i
, LOCKDEP_STILL_OK
);
2325 #ifdef CONFIG_PRINTK
2326 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
2327 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2329 if (write
&& !capable(CAP_SYS_ADMIN
))
2332 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2336 struct do_proc_dointvec_minmax_conv_param
{
2341 static int do_proc_dointvec_minmax_conv(bool *negp
, unsigned long *lvalp
,
2343 int write
, void *data
)
2345 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2347 int val
= *negp
? -*lvalp
: *lvalp
;
2348 if ((param
->min
&& *param
->min
> val
) ||
2349 (param
->max
&& *param
->max
< val
))
2356 *lvalp
= -(unsigned long)val
;
2359 *lvalp
= (unsigned long)val
;
2366 * proc_dointvec_minmax - read a vector of integers with min/max values
2367 * @table: the sysctl table
2368 * @write: %TRUE if this is a write to the sysctl file
2369 * @buffer: the user buffer
2370 * @lenp: the size of the user buffer
2371 * @ppos: file position
2373 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2374 * values from/to the user buffer, treated as an ASCII string.
2376 * This routine will ensure the values are within the range specified by
2377 * table->extra1 (min) and table->extra2 (max).
2379 * Returns 0 on success.
2381 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2382 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2384 struct do_proc_dointvec_minmax_conv_param param
= {
2385 .min
= (int *) table
->extra1
,
2386 .max
= (int *) table
->extra2
,
2388 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2389 do_proc_dointvec_minmax_conv
, ¶m
);
2392 static void validate_coredump_safety(void)
2394 #ifdef CONFIG_COREDUMP
2395 if (suid_dumpable
== SUID_DUMP_ROOT
&&
2396 core_pattern
[0] != '/' && core_pattern
[0] != '|') {
2397 printk(KERN_WARNING
"Unsafe core_pattern used with "\
2398 "suid_dumpable=2. Pipe handler or fully qualified "\
2399 "core dump path required.\n");
2404 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
2405 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2407 int error
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2409 validate_coredump_safety();
2413 #ifdef CONFIG_COREDUMP
2414 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
2415 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2417 int error
= proc_dostring(table
, write
, buffer
, lenp
, ppos
);
2419 validate_coredump_safety();
2424 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2425 void __user
*buffer
,
2426 size_t *lenp
, loff_t
*ppos
,
2427 unsigned long convmul
,
2428 unsigned long convdiv
)
2430 unsigned long *i
, *min
, *max
;
2431 int vleft
, first
= 1, err
= 0;
2433 char *kbuf
= NULL
, *p
;
2435 if (!data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2440 i
= (unsigned long *) data
;
2441 min
= (unsigned long *) table
->extra1
;
2442 max
= (unsigned long *) table
->extra2
;
2443 vleft
= table
->maxlen
/ sizeof(unsigned long);
2448 switch (sysctl_writes_strict
) {
2449 case SYSCTL_WRITES_STRICT
:
2451 case SYSCTL_WRITES_WARN
:
2452 warn_sysctl_write(table
);
2459 if (left
> PAGE_SIZE
- 1)
2460 left
= PAGE_SIZE
- 1;
2461 p
= kbuf
= memdup_user_nul(buffer
, left
);
2463 return PTR_ERR(kbuf
);
2466 for (; left
&& vleft
--; i
++, first
= 0) {
2472 left
-= proc_skip_spaces(&p
);
2474 err
= proc_get_long(&p
, &left
, &val
, &neg
,
2476 sizeof(proc_wspace_sep
), NULL
);
2481 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2485 val
= convdiv
* (*i
) / convmul
;
2487 err
= proc_put_char(&buffer
, &left
, '\t');
2491 err
= proc_put_long(&buffer
, &left
, val
, false);
2497 if (!write
&& !first
&& left
&& !err
)
2498 err
= proc_put_char(&buffer
, &left
, '\n');
2500 left
-= proc_skip_spaces(&p
);
2504 return err
? : -EINVAL
;
2512 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2513 void __user
*buffer
,
2514 size_t *lenp
, loff_t
*ppos
,
2515 unsigned long convmul
,
2516 unsigned long convdiv
)
2518 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2519 buffer
, lenp
, ppos
, convmul
, convdiv
);
2523 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2524 * @table: the sysctl table
2525 * @write: %TRUE if this is a write to the sysctl file
2526 * @buffer: the user buffer
2527 * @lenp: the size of the user buffer
2528 * @ppos: file position
2530 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2531 * values from/to the user buffer, treated as an ASCII string.
2533 * This routine will ensure the values are within the range specified by
2534 * table->extra1 (min) and table->extra2 (max).
2536 * Returns 0 on success.
2538 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2539 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2541 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2545 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2546 * @table: the sysctl table
2547 * @write: %TRUE if this is a write to the sysctl file
2548 * @buffer: the user buffer
2549 * @lenp: the size of the user buffer
2550 * @ppos: file position
2552 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2553 * values from/to the user buffer, treated as an ASCII string. The values
2554 * are treated as milliseconds, and converted to jiffies when they are stored.
2556 * This routine will ensure the values are within the range specified by
2557 * table->extra1 (min) and table->extra2 (max).
2559 * Returns 0 on success.
2561 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2562 void __user
*buffer
,
2563 size_t *lenp
, loff_t
*ppos
)
2565 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2566 lenp
, ppos
, HZ
, 1000l);
2570 static int do_proc_dointvec_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2572 int write
, void *data
)
2575 if (*lvalp
> LONG_MAX
/ HZ
)
2577 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2583 lval
= -(unsigned long)val
;
2586 lval
= (unsigned long)val
;
2593 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2595 int write
, void *data
)
2598 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2600 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2606 lval
= -(unsigned long)val
;
2609 lval
= (unsigned long)val
;
2611 *lvalp
= jiffies_to_clock_t(lval
);
2616 static int do_proc_dointvec_ms_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2618 int write
, void *data
)
2621 unsigned long jif
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2631 lval
= -(unsigned long)val
;
2634 lval
= (unsigned long)val
;
2636 *lvalp
= jiffies_to_msecs(lval
);
2642 * proc_dointvec_jiffies - read a vector of integers as seconds
2643 * @table: the sysctl table
2644 * @write: %TRUE if this is a write to the sysctl file
2645 * @buffer: the user buffer
2646 * @lenp: the size of the user buffer
2647 * @ppos: file position
2649 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2650 * values from/to the user buffer, treated as an ASCII string.
2651 * The values read are assumed to be in seconds, and are converted into
2654 * Returns 0 on success.
2656 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2657 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2659 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2660 do_proc_dointvec_jiffies_conv
,NULL
);
2664 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2665 * @table: the sysctl table
2666 * @write: %TRUE if this is a write to the sysctl file
2667 * @buffer: the user buffer
2668 * @lenp: the size of the user buffer
2669 * @ppos: pointer to the file position
2671 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2672 * values from/to the user buffer, treated as an ASCII string.
2673 * The values read are assumed to be in 1/USER_HZ seconds, and
2674 * are converted into jiffies.
2676 * Returns 0 on success.
2678 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2679 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2681 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2682 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2686 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2687 * @table: the sysctl table
2688 * @write: %TRUE if this is a write to the sysctl file
2689 * @buffer: the user buffer
2690 * @lenp: the size of the user buffer
2691 * @ppos: file position
2692 * @ppos: the current position in the file
2694 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2695 * values from/to the user buffer, treated as an ASCII string.
2696 * The values read are assumed to be in 1/1000 seconds, and
2697 * are converted into jiffies.
2699 * Returns 0 on success.
2701 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2702 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2704 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2705 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2708 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
2709 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2711 struct pid
*new_pid
;
2715 tmp
= pid_vnr(cad_pid
);
2717 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
2718 lenp
, ppos
, NULL
, NULL
);
2722 new_pid
= find_get_pid(tmp
);
2726 put_pid(xchg(&cad_pid
, new_pid
));
2731 * proc_do_large_bitmap - read/write from/to a large bitmap
2732 * @table: the sysctl table
2733 * @write: %TRUE if this is a write to the sysctl file
2734 * @buffer: the user buffer
2735 * @lenp: the size of the user buffer
2736 * @ppos: file position
2738 * The bitmap is stored at table->data and the bitmap length (in bits)
2741 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2742 * large bitmaps may be represented in a compact manner. Writing into
2743 * the file will clear the bitmap then update it with the given input.
2745 * Returns 0 on success.
2747 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
2748 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2752 size_t left
= *lenp
;
2753 unsigned long bitmap_len
= table
->maxlen
;
2754 unsigned long *bitmap
= *(unsigned long **) table
->data
;
2755 unsigned long *tmp_bitmap
= NULL
;
2756 char tr_a
[] = { '-', ',', '\n' }, tr_b
[] = { ',', '\n', 0 }, c
;
2758 if (!bitmap
|| !bitmap_len
|| !left
|| (*ppos
&& !write
)) {
2766 if (left
> PAGE_SIZE
- 1)
2767 left
= PAGE_SIZE
- 1;
2769 p
= kbuf
= memdup_user_nul(buffer
, left
);
2771 return PTR_ERR(kbuf
);
2773 tmp_bitmap
= kzalloc(BITS_TO_LONGS(bitmap_len
) * sizeof(unsigned long),
2779 proc_skip_char(&p
, &left
, '\n');
2780 while (!err
&& left
) {
2781 unsigned long val_a
, val_b
;
2784 err
= proc_get_long(&p
, &left
, &val_a
, &neg
, tr_a
,
2788 if (val_a
>= bitmap_len
|| neg
) {
2800 err
= proc_get_long(&p
, &left
, &val_b
,
2801 &neg
, tr_b
, sizeof(tr_b
),
2805 if (val_b
>= bitmap_len
|| neg
||
2816 bitmap_set(tmp_bitmap
, val_a
, val_b
- val_a
+ 1);
2818 proc_skip_char(&p
, &left
, '\n');
2822 unsigned long bit_a
, bit_b
= 0;
2825 bit_a
= find_next_bit(bitmap
, bitmap_len
, bit_b
);
2826 if (bit_a
>= bitmap_len
)
2828 bit_b
= find_next_zero_bit(bitmap
, bitmap_len
,
2832 err
= proc_put_char(&buffer
, &left
, ',');
2836 err
= proc_put_long(&buffer
, &left
, bit_a
, false);
2839 if (bit_a
!= bit_b
) {
2840 err
= proc_put_char(&buffer
, &left
, '-');
2843 err
= proc_put_long(&buffer
, &left
, bit_b
, false);
2851 err
= proc_put_char(&buffer
, &left
, '\n');
2857 bitmap_or(bitmap
, bitmap
, tmp_bitmap
, bitmap_len
);
2859 bitmap_copy(bitmap
, tmp_bitmap
, bitmap_len
);
2871 #else /* CONFIG_PROC_SYSCTL */
2873 int proc_dostring(struct ctl_table
*table
, int write
,
2874 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2879 int proc_dointvec(struct ctl_table
*table
, int write
,
2880 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2885 int proc_douintvec(struct ctl_table
*table
, int write
,
2886 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2891 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2892 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2897 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2898 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2903 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2904 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2909 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2910 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2915 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2916 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2921 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2922 void __user
*buffer
,
2923 size_t *lenp
, loff_t
*ppos
)
2929 #endif /* CONFIG_PROC_SYSCTL */
2932 * No sense putting this after each symbol definition, twice,
2933 * exception granted :-)
2935 EXPORT_SYMBOL(proc_dointvec
);
2936 EXPORT_SYMBOL(proc_douintvec
);
2937 EXPORT_SYMBOL(proc_dointvec_jiffies
);
2938 EXPORT_SYMBOL(proc_dointvec_minmax
);
2939 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
2940 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
2941 EXPORT_SYMBOL(proc_dostring
);
2942 EXPORT_SYMBOL(proc_doulongvec_minmax
);
2943 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);