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_minmax
,
352 .procname
= "sched_shares_window_ns",
353 .data
= &sysctl_sched_shares_window
,
354 .maxlen
= sizeof(unsigned int),
356 .proc_handler
= proc_dointvec
,
358 #ifdef CONFIG_SCHEDSTATS
360 .procname
= "sched_schedstats",
362 .maxlen
= sizeof(unsigned int),
364 .proc_handler
= sysctl_schedstats
,
368 #endif /* CONFIG_SCHEDSTATS */
369 #endif /* CONFIG_SMP */
370 #ifdef CONFIG_NUMA_BALANCING
372 .procname
= "numa_balancing_scan_delay_ms",
373 .data
= &sysctl_numa_balancing_scan_delay
,
374 .maxlen
= sizeof(unsigned int),
376 .proc_handler
= proc_dointvec
,
379 .procname
= "numa_balancing_scan_period_min_ms",
380 .data
= &sysctl_numa_balancing_scan_period_min
,
381 .maxlen
= sizeof(unsigned int),
383 .proc_handler
= proc_dointvec
,
386 .procname
= "numa_balancing_scan_period_max_ms",
387 .data
= &sysctl_numa_balancing_scan_period_max
,
388 .maxlen
= sizeof(unsigned int),
390 .proc_handler
= proc_dointvec
,
393 .procname
= "numa_balancing_scan_size_mb",
394 .data
= &sysctl_numa_balancing_scan_size
,
395 .maxlen
= sizeof(unsigned int),
397 .proc_handler
= proc_dointvec_minmax
,
401 .procname
= "numa_balancing",
402 .data
= NULL
, /* filled in by handler */
403 .maxlen
= sizeof(unsigned int),
405 .proc_handler
= sysctl_numa_balancing
,
409 #endif /* CONFIG_NUMA_BALANCING */
410 #endif /* CONFIG_SCHED_DEBUG */
412 .procname
= "sched_rt_period_us",
413 .data
= &sysctl_sched_rt_period
,
414 .maxlen
= sizeof(unsigned int),
416 .proc_handler
= sched_rt_handler
,
419 .procname
= "sched_rt_runtime_us",
420 .data
= &sysctl_sched_rt_runtime
,
421 .maxlen
= sizeof(int),
423 .proc_handler
= sched_rt_handler
,
426 .procname
= "sched_rr_timeslice_ms",
427 .data
= &sched_rr_timeslice
,
428 .maxlen
= sizeof(int),
430 .proc_handler
= sched_rr_handler
,
432 #ifdef CONFIG_SCHED_AUTOGROUP
434 .procname
= "sched_autogroup_enabled",
435 .data
= &sysctl_sched_autogroup_enabled
,
436 .maxlen
= sizeof(unsigned int),
438 .proc_handler
= proc_dointvec_minmax
,
443 #ifdef CONFIG_CFS_BANDWIDTH
445 .procname
= "sched_cfs_bandwidth_slice_us",
446 .data
= &sysctl_sched_cfs_bandwidth_slice
,
447 .maxlen
= sizeof(unsigned int),
449 .proc_handler
= proc_dointvec_minmax
,
453 #ifdef CONFIG_PROVE_LOCKING
455 .procname
= "prove_locking",
456 .data
= &prove_locking
,
457 .maxlen
= sizeof(int),
459 .proc_handler
= proc_dointvec
,
462 #ifdef CONFIG_LOCK_STAT
464 .procname
= "lock_stat",
466 .maxlen
= sizeof(int),
468 .proc_handler
= proc_dointvec
,
473 .data
= &panic_timeout
,
474 .maxlen
= sizeof(int),
476 .proc_handler
= proc_dointvec
,
478 #ifdef CONFIG_COREDUMP
480 .procname
= "core_uses_pid",
481 .data
= &core_uses_pid
,
482 .maxlen
= sizeof(int),
484 .proc_handler
= proc_dointvec
,
487 .procname
= "core_pattern",
488 .data
= core_pattern
,
489 .maxlen
= CORENAME_MAX_SIZE
,
491 .proc_handler
= proc_dostring_coredump
,
494 .procname
= "core_pipe_limit",
495 .data
= &core_pipe_limit
,
496 .maxlen
= sizeof(unsigned int),
498 .proc_handler
= proc_dointvec
,
501 #ifdef CONFIG_PROC_SYSCTL
503 .procname
= "tainted",
504 .maxlen
= sizeof(long),
506 .proc_handler
= proc_taint
,
509 .procname
= "sysctl_writes_strict",
510 .data
= &sysctl_writes_strict
,
511 .maxlen
= sizeof(int),
513 .proc_handler
= proc_dointvec_minmax
,
518 #ifdef CONFIG_LATENCYTOP
520 .procname
= "latencytop",
521 .data
= &latencytop_enabled
,
522 .maxlen
= sizeof(int),
524 .proc_handler
= sysctl_latencytop
,
527 #ifdef CONFIG_BLK_DEV_INITRD
529 .procname
= "real-root-dev",
530 .data
= &real_root_dev
,
531 .maxlen
= sizeof(int),
533 .proc_handler
= proc_dointvec
,
537 .procname
= "print-fatal-signals",
538 .data
= &print_fatal_signals
,
539 .maxlen
= sizeof(int),
541 .proc_handler
= proc_dointvec
,
545 .procname
= "reboot-cmd",
546 .data
= reboot_command
,
549 .proc_handler
= proc_dostring
,
552 .procname
= "stop-a",
553 .data
= &stop_a_enabled
,
554 .maxlen
= sizeof (int),
556 .proc_handler
= proc_dointvec
,
559 .procname
= "scons-poweroff",
560 .data
= &scons_pwroff
,
561 .maxlen
= sizeof (int),
563 .proc_handler
= proc_dointvec
,
566 #ifdef CONFIG_SPARC64
568 .procname
= "tsb-ratio",
569 .data
= &sysctl_tsb_ratio
,
570 .maxlen
= sizeof (int),
572 .proc_handler
= proc_dointvec
,
577 .procname
= "soft-power",
578 .data
= &pwrsw_enabled
,
579 .maxlen
= sizeof (int),
581 .proc_handler
= proc_dointvec
,
584 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
586 .procname
= "unaligned-trap",
587 .data
= &unaligned_enabled
,
588 .maxlen
= sizeof (int),
590 .proc_handler
= proc_dointvec
,
594 .procname
= "ctrl-alt-del",
596 .maxlen
= sizeof(int),
598 .proc_handler
= proc_dointvec
,
600 #ifdef CONFIG_FUNCTION_TRACER
602 .procname
= "ftrace_enabled",
603 .data
= &ftrace_enabled
,
604 .maxlen
= sizeof(int),
606 .proc_handler
= ftrace_enable_sysctl
,
609 #ifdef CONFIG_STACK_TRACER
611 .procname
= "stack_tracer_enabled",
612 .data
= &stack_tracer_enabled
,
613 .maxlen
= sizeof(int),
615 .proc_handler
= stack_trace_sysctl
,
618 #ifdef CONFIG_TRACING
620 .procname
= "ftrace_dump_on_oops",
621 .data
= &ftrace_dump_on_oops
,
622 .maxlen
= sizeof(int),
624 .proc_handler
= proc_dointvec
,
627 .procname
= "traceoff_on_warning",
628 .data
= &__disable_trace_on_warning
,
629 .maxlen
= sizeof(__disable_trace_on_warning
),
631 .proc_handler
= proc_dointvec
,
634 .procname
= "tracepoint_printk",
635 .data
= &tracepoint_printk
,
636 .maxlen
= sizeof(tracepoint_printk
),
638 .proc_handler
= proc_dointvec
,
641 #ifdef CONFIG_KEXEC_CORE
643 .procname
= "kexec_load_disabled",
644 .data
= &kexec_load_disabled
,
645 .maxlen
= sizeof(int),
647 /* only handle a transition from default "0" to "1" */
648 .proc_handler
= proc_dointvec_minmax
,
653 #ifdef CONFIG_MODULES
655 .procname
= "modprobe",
656 .data
= &modprobe_path
,
657 .maxlen
= KMOD_PATH_LEN
,
659 .proc_handler
= proc_dostring
,
662 .procname
= "modules_disabled",
663 .data
= &modules_disabled
,
664 .maxlen
= sizeof(int),
666 /* only handle a transition from default "0" to "1" */
667 .proc_handler
= proc_dointvec_minmax
,
672 #ifdef CONFIG_UEVENT_HELPER
674 .procname
= "hotplug",
675 .data
= &uevent_helper
,
676 .maxlen
= UEVENT_HELPER_PATH_LEN
,
678 .proc_handler
= proc_dostring
,
681 #ifdef CONFIG_CHR_DEV_SG
683 .procname
= "sg-big-buff",
684 .data
= &sg_big_buff
,
685 .maxlen
= sizeof (int),
687 .proc_handler
= proc_dointvec
,
690 #ifdef CONFIG_BSD_PROCESS_ACCT
694 .maxlen
= 3*sizeof(int),
696 .proc_handler
= proc_dointvec
,
699 #ifdef CONFIG_MAGIC_SYSRQ
702 .data
= &__sysrq_enabled
,
703 .maxlen
= sizeof (int),
705 .proc_handler
= sysrq_sysctl_handler
,
708 #ifdef CONFIG_PROC_SYSCTL
710 .procname
= "cad_pid",
712 .maxlen
= sizeof (int),
714 .proc_handler
= proc_do_cad_pid
,
718 .procname
= "threads-max",
720 .maxlen
= sizeof(int),
722 .proc_handler
= sysctl_max_threads
,
725 .procname
= "random",
727 .child
= random_table
,
730 .procname
= "usermodehelper",
732 .child
= usermodehelper_table
,
735 .procname
= "overflowuid",
736 .data
= &overflowuid
,
737 .maxlen
= sizeof(int),
739 .proc_handler
= proc_dointvec_minmax
,
740 .extra1
= &minolduid
,
741 .extra2
= &maxolduid
,
744 .procname
= "overflowgid",
745 .data
= &overflowgid
,
746 .maxlen
= sizeof(int),
748 .proc_handler
= proc_dointvec_minmax
,
749 .extra1
= &minolduid
,
750 .extra2
= &maxolduid
,
753 #ifdef CONFIG_MATHEMU
755 .procname
= "ieee_emulation_warnings",
756 .data
= &sysctl_ieee_emulation_warnings
,
757 .maxlen
= sizeof(int),
759 .proc_handler
= proc_dointvec
,
763 .procname
= "userprocess_debug",
764 .data
= &show_unhandled_signals
,
765 .maxlen
= sizeof(int),
767 .proc_handler
= proc_dointvec
,
771 .procname
= "pid_max",
773 .maxlen
= sizeof (int),
775 .proc_handler
= proc_dointvec_minmax
,
776 .extra1
= &pid_max_min
,
777 .extra2
= &pid_max_max
,
780 .procname
= "panic_on_oops",
781 .data
= &panic_on_oops
,
782 .maxlen
= sizeof(int),
784 .proc_handler
= proc_dointvec
,
786 #if defined CONFIG_PRINTK
788 .procname
= "printk",
789 .data
= &console_loglevel
,
790 .maxlen
= 4*sizeof(int),
792 .proc_handler
= proc_dointvec
,
795 .procname
= "printk_ratelimit",
796 .data
= &printk_ratelimit_state
.interval
,
797 .maxlen
= sizeof(int),
799 .proc_handler
= proc_dointvec_jiffies
,
802 .procname
= "printk_ratelimit_burst",
803 .data
= &printk_ratelimit_state
.burst
,
804 .maxlen
= sizeof(int),
806 .proc_handler
= proc_dointvec
,
809 .procname
= "printk_delay",
810 .data
= &printk_delay_msec
,
811 .maxlen
= sizeof(int),
813 .proc_handler
= proc_dointvec_minmax
,
815 .extra2
= &ten_thousand
,
818 .procname
= "printk_devkmsg",
819 .data
= devkmsg_log_str
,
820 .maxlen
= DEVKMSG_STR_MAX_SIZE
,
822 .proc_handler
= devkmsg_sysctl_set_loglvl
,
825 .procname
= "dmesg_restrict",
826 .data
= &dmesg_restrict
,
827 .maxlen
= sizeof(int),
829 .proc_handler
= proc_dointvec_minmax_sysadmin
,
834 .procname
= "kptr_restrict",
835 .data
= &kptr_restrict
,
836 .maxlen
= sizeof(int),
838 .proc_handler
= proc_dointvec_minmax_sysadmin
,
844 .procname
= "ngroups_max",
845 .data
= &ngroups_max
,
846 .maxlen
= sizeof (int),
848 .proc_handler
= proc_dointvec
,
851 .procname
= "cap_last_cap",
852 .data
= (void *)&cap_last_cap
,
853 .maxlen
= sizeof(int),
855 .proc_handler
= proc_dointvec
,
857 #if defined(CONFIG_LOCKUP_DETECTOR)
859 .procname
= "watchdog",
860 .data
= &watchdog_user_enabled
,
861 .maxlen
= sizeof (int),
863 .proc_handler
= proc_watchdog
,
868 .procname
= "watchdog_thresh",
869 .data
= &watchdog_thresh
,
870 .maxlen
= sizeof(int),
872 .proc_handler
= proc_watchdog_thresh
,
877 .procname
= "nmi_watchdog",
878 .data
= &nmi_watchdog_enabled
,
879 .maxlen
= sizeof (int),
881 .proc_handler
= proc_nmi_watchdog
,
883 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
890 .procname
= "soft_watchdog",
891 .data
= &soft_watchdog_enabled
,
892 .maxlen
= sizeof (int),
894 .proc_handler
= proc_soft_watchdog
,
899 .procname
= "watchdog_cpumask",
900 .data
= &watchdog_cpumask_bits
,
903 .proc_handler
= proc_watchdog_cpumask
,
906 .procname
= "softlockup_panic",
907 .data
= &softlockup_panic
,
908 .maxlen
= sizeof(int),
910 .proc_handler
= proc_dointvec_minmax
,
914 #ifdef CONFIG_HARDLOCKUP_DETECTOR
916 .procname
= "hardlockup_panic",
917 .data
= &hardlockup_panic
,
918 .maxlen
= sizeof(int),
920 .proc_handler
= proc_dointvec_minmax
,
927 .procname
= "softlockup_all_cpu_backtrace",
928 .data
= &sysctl_softlockup_all_cpu_backtrace
,
929 .maxlen
= sizeof(int),
931 .proc_handler
= proc_dointvec_minmax
,
936 .procname
= "hardlockup_all_cpu_backtrace",
937 .data
= &sysctl_hardlockup_all_cpu_backtrace
,
938 .maxlen
= sizeof(int),
940 .proc_handler
= proc_dointvec_minmax
,
944 #endif /* CONFIG_SMP */
946 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
948 .procname
= "unknown_nmi_panic",
949 .data
= &unknown_nmi_panic
,
950 .maxlen
= sizeof (int),
952 .proc_handler
= proc_dointvec
,
955 #if defined(CONFIG_X86)
957 .procname
= "panic_on_unrecovered_nmi",
958 .data
= &panic_on_unrecovered_nmi
,
959 .maxlen
= sizeof(int),
961 .proc_handler
= proc_dointvec
,
964 .procname
= "panic_on_io_nmi",
965 .data
= &panic_on_io_nmi
,
966 .maxlen
= sizeof(int),
968 .proc_handler
= proc_dointvec
,
970 #ifdef CONFIG_DEBUG_STACKOVERFLOW
972 .procname
= "panic_on_stackoverflow",
973 .data
= &sysctl_panic_on_stackoverflow
,
974 .maxlen
= sizeof(int),
976 .proc_handler
= proc_dointvec
,
980 .procname
= "bootloader_type",
981 .data
= &bootloader_type
,
982 .maxlen
= sizeof (int),
984 .proc_handler
= proc_dointvec
,
987 .procname
= "bootloader_version",
988 .data
= &bootloader_version
,
989 .maxlen
= sizeof (int),
991 .proc_handler
= proc_dointvec
,
994 .procname
= "kstack_depth_to_print",
995 .data
= &kstack_depth_to_print
,
996 .maxlen
= sizeof(int),
998 .proc_handler
= proc_dointvec
,
1001 .procname
= "io_delay_type",
1002 .data
= &io_delay_type
,
1003 .maxlen
= sizeof(int),
1005 .proc_handler
= proc_dointvec
,
1008 #if defined(CONFIG_MMU)
1010 .procname
= "randomize_va_space",
1011 .data
= &randomize_va_space
,
1012 .maxlen
= sizeof(int),
1014 .proc_handler
= proc_dointvec
,
1017 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1019 .procname
= "spin_retry",
1020 .data
= &spin_retry
,
1021 .maxlen
= sizeof (int),
1023 .proc_handler
= proc_dointvec
,
1026 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1028 .procname
= "acpi_video_flags",
1029 .data
= &acpi_realmode_flags
,
1030 .maxlen
= sizeof (unsigned long),
1032 .proc_handler
= proc_doulongvec_minmax
,
1035 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1037 .procname
= "ignore-unaligned-usertrap",
1038 .data
= &no_unaligned_warning
,
1039 .maxlen
= sizeof (int),
1041 .proc_handler
= proc_dointvec
,
1046 .procname
= "unaligned-dump-stack",
1047 .data
= &unaligned_dump_stack
,
1048 .maxlen
= sizeof (int),
1050 .proc_handler
= proc_dointvec
,
1053 #ifdef CONFIG_DETECT_HUNG_TASK
1055 .procname
= "hung_task_panic",
1056 .data
= &sysctl_hung_task_panic
,
1057 .maxlen
= sizeof(int),
1059 .proc_handler
= proc_dointvec_minmax
,
1064 .procname
= "hung_task_check_count",
1065 .data
= &sysctl_hung_task_check_count
,
1066 .maxlen
= sizeof(int),
1068 .proc_handler
= proc_dointvec_minmax
,
1072 .procname
= "hung_task_timeout_secs",
1073 .data
= &sysctl_hung_task_timeout_secs
,
1074 .maxlen
= sizeof(unsigned long),
1076 .proc_handler
= proc_dohung_task_timeout_secs
,
1077 .extra2
= &hung_task_timeout_max
,
1080 .procname
= "hung_task_warnings",
1081 .data
= &sysctl_hung_task_warnings
,
1082 .maxlen
= sizeof(int),
1084 .proc_handler
= proc_dointvec_minmax
,
1088 #ifdef CONFIG_RT_MUTEXES
1090 .procname
= "max_lock_depth",
1091 .data
= &max_lock_depth
,
1092 .maxlen
= sizeof(int),
1094 .proc_handler
= proc_dointvec
,
1098 .procname
= "poweroff_cmd",
1099 .data
= &poweroff_cmd
,
1100 .maxlen
= POWEROFF_CMD_PATH_LEN
,
1102 .proc_handler
= proc_dostring
,
1108 .child
= key_sysctls
,
1111 #ifdef CONFIG_PERF_EVENTS
1113 * User-space scripts rely on the existence of this file
1114 * as a feature check for perf_events being enabled.
1116 * So it's an ABI, do not remove!
1119 .procname
= "perf_event_paranoid",
1120 .data
= &sysctl_perf_event_paranoid
,
1121 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
1123 .proc_handler
= proc_dointvec
,
1126 .procname
= "perf_event_mlock_kb",
1127 .data
= &sysctl_perf_event_mlock
,
1128 .maxlen
= sizeof(sysctl_perf_event_mlock
),
1130 .proc_handler
= proc_dointvec
,
1133 .procname
= "perf_event_max_sample_rate",
1134 .data
= &sysctl_perf_event_sample_rate
,
1135 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1137 .proc_handler
= perf_proc_update_handler
,
1141 .procname
= "perf_cpu_time_max_percent",
1142 .data
= &sysctl_perf_cpu_time_max_percent
,
1143 .maxlen
= sizeof(sysctl_perf_cpu_time_max_percent
),
1145 .proc_handler
= perf_cpu_time_max_percent_handler
,
1147 .extra2
= &one_hundred
,
1150 .procname
= "perf_event_max_stack",
1151 .data
= &sysctl_perf_event_max_stack
,
1152 .maxlen
= sizeof(sysctl_perf_event_max_stack
),
1154 .proc_handler
= perf_event_max_stack_handler
,
1156 .extra2
= &six_hundred_forty_kb
,
1159 .procname
= "perf_event_max_contexts_per_stack",
1160 .data
= &sysctl_perf_event_max_contexts_per_stack
,
1161 .maxlen
= sizeof(sysctl_perf_event_max_contexts_per_stack
),
1163 .proc_handler
= perf_event_max_stack_handler
,
1165 .extra2
= &one_thousand
,
1168 #ifdef CONFIG_KMEMCHECK
1170 .procname
= "kmemcheck",
1171 .data
= &kmemcheck_enabled
,
1172 .maxlen
= sizeof(int),
1174 .proc_handler
= proc_dointvec
,
1178 .procname
= "panic_on_warn",
1179 .data
= &panic_on_warn
,
1180 .maxlen
= sizeof(int),
1182 .proc_handler
= proc_dointvec_minmax
,
1186 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1188 .procname
= "timer_migration",
1189 .data
= &sysctl_timer_migration
,
1190 .maxlen
= sizeof(unsigned int),
1192 .proc_handler
= timer_migration_handler
,
1197 #ifdef CONFIG_BPF_SYSCALL
1199 .procname
= "unprivileged_bpf_disabled",
1200 .data
= &sysctl_unprivileged_bpf_disabled
,
1201 .maxlen
= sizeof(sysctl_unprivileged_bpf_disabled
),
1203 /* only handle a transition from default "0" to "1" */
1204 .proc_handler
= proc_dointvec_minmax
,
1209 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1211 .procname
= "panic_on_rcu_stall",
1212 .data
= &sysctl_panic_on_rcu_stall
,
1213 .maxlen
= sizeof(sysctl_panic_on_rcu_stall
),
1215 .proc_handler
= proc_dointvec_minmax
,
1223 static struct ctl_table vm_table
[] = {
1225 .procname
= "overcommit_memory",
1226 .data
= &sysctl_overcommit_memory
,
1227 .maxlen
= sizeof(sysctl_overcommit_memory
),
1229 .proc_handler
= proc_dointvec_minmax
,
1234 .procname
= "panic_on_oom",
1235 .data
= &sysctl_panic_on_oom
,
1236 .maxlen
= sizeof(sysctl_panic_on_oom
),
1238 .proc_handler
= proc_dointvec_minmax
,
1243 .procname
= "oom_kill_allocating_task",
1244 .data
= &sysctl_oom_kill_allocating_task
,
1245 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
1247 .proc_handler
= proc_dointvec
,
1250 .procname
= "oom_dump_tasks",
1251 .data
= &sysctl_oom_dump_tasks
,
1252 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
1254 .proc_handler
= proc_dointvec
,
1257 .procname
= "overcommit_ratio",
1258 .data
= &sysctl_overcommit_ratio
,
1259 .maxlen
= sizeof(sysctl_overcommit_ratio
),
1261 .proc_handler
= overcommit_ratio_handler
,
1264 .procname
= "overcommit_kbytes",
1265 .data
= &sysctl_overcommit_kbytes
,
1266 .maxlen
= sizeof(sysctl_overcommit_kbytes
),
1268 .proc_handler
= overcommit_kbytes_handler
,
1271 .procname
= "page-cluster",
1272 .data
= &page_cluster
,
1273 .maxlen
= sizeof(int),
1275 .proc_handler
= proc_dointvec_minmax
,
1279 .procname
= "dirty_background_ratio",
1280 .data
= &dirty_background_ratio
,
1281 .maxlen
= sizeof(dirty_background_ratio
),
1283 .proc_handler
= dirty_background_ratio_handler
,
1285 .extra2
= &one_hundred
,
1288 .procname
= "dirty_background_bytes",
1289 .data
= &dirty_background_bytes
,
1290 .maxlen
= sizeof(dirty_background_bytes
),
1292 .proc_handler
= dirty_background_bytes_handler
,
1296 .procname
= "dirty_ratio",
1297 .data
= &vm_dirty_ratio
,
1298 .maxlen
= sizeof(vm_dirty_ratio
),
1300 .proc_handler
= dirty_ratio_handler
,
1302 .extra2
= &one_hundred
,
1305 .procname
= "dirty_bytes",
1306 .data
= &vm_dirty_bytes
,
1307 .maxlen
= sizeof(vm_dirty_bytes
),
1309 .proc_handler
= dirty_bytes_handler
,
1310 .extra1
= &dirty_bytes_min
,
1313 .procname
= "dirty_writeback_centisecs",
1314 .data
= &dirty_writeback_interval
,
1315 .maxlen
= sizeof(dirty_writeback_interval
),
1317 .proc_handler
= dirty_writeback_centisecs_handler
,
1320 .procname
= "dirty_expire_centisecs",
1321 .data
= &dirty_expire_interval
,
1322 .maxlen
= sizeof(dirty_expire_interval
),
1324 .proc_handler
= proc_dointvec_minmax
,
1328 .procname
= "dirtytime_expire_seconds",
1329 .data
= &dirtytime_expire_interval
,
1330 .maxlen
= sizeof(dirty_expire_interval
),
1332 .proc_handler
= dirtytime_interval_handler
,
1336 .procname
= "nr_pdflush_threads",
1337 .mode
= 0444 /* read-only */,
1338 .proc_handler
= pdflush_proc_obsolete
,
1341 .procname
= "swappiness",
1342 .data
= &vm_swappiness
,
1343 .maxlen
= sizeof(vm_swappiness
),
1345 .proc_handler
= proc_dointvec_minmax
,
1347 .extra2
= &one_hundred
,
1349 #ifdef CONFIG_HUGETLB_PAGE
1351 .procname
= "nr_hugepages",
1353 .maxlen
= sizeof(unsigned long),
1355 .proc_handler
= hugetlb_sysctl_handler
,
1359 .procname
= "nr_hugepages_mempolicy",
1361 .maxlen
= sizeof(unsigned long),
1363 .proc_handler
= &hugetlb_mempolicy_sysctl_handler
,
1367 .procname
= "hugetlb_shm_group",
1368 .data
= &sysctl_hugetlb_shm_group
,
1369 .maxlen
= sizeof(gid_t
),
1371 .proc_handler
= proc_dointvec
,
1374 .procname
= "hugepages_treat_as_movable",
1375 .data
= &hugepages_treat_as_movable
,
1376 .maxlen
= sizeof(int),
1378 .proc_handler
= proc_dointvec
,
1381 .procname
= "nr_overcommit_hugepages",
1383 .maxlen
= sizeof(unsigned long),
1385 .proc_handler
= hugetlb_overcommit_handler
,
1389 .procname
= "lowmem_reserve_ratio",
1390 .data
= &sysctl_lowmem_reserve_ratio
,
1391 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
1393 .proc_handler
= lowmem_reserve_ratio_sysctl_handler
,
1396 .procname
= "drop_caches",
1397 .data
= &sysctl_drop_caches
,
1398 .maxlen
= sizeof(int),
1400 .proc_handler
= drop_caches_sysctl_handler
,
1404 #ifdef CONFIG_COMPACTION
1406 .procname
= "compact_memory",
1407 .data
= &sysctl_compact_memory
,
1408 .maxlen
= sizeof(int),
1410 .proc_handler
= sysctl_compaction_handler
,
1413 .procname
= "extfrag_threshold",
1414 .data
= &sysctl_extfrag_threshold
,
1415 .maxlen
= sizeof(int),
1417 .proc_handler
= sysctl_extfrag_handler
,
1418 .extra1
= &min_extfrag_threshold
,
1419 .extra2
= &max_extfrag_threshold
,
1422 .procname
= "compact_unevictable_allowed",
1423 .data
= &sysctl_compact_unevictable_allowed
,
1424 .maxlen
= sizeof(int),
1426 .proc_handler
= proc_dointvec
,
1431 #endif /* CONFIG_COMPACTION */
1433 .procname
= "min_free_kbytes",
1434 .data
= &min_free_kbytes
,
1435 .maxlen
= sizeof(min_free_kbytes
),
1437 .proc_handler
= min_free_kbytes_sysctl_handler
,
1441 .procname
= "watermark_scale_factor",
1442 .data
= &watermark_scale_factor
,
1443 .maxlen
= sizeof(watermark_scale_factor
),
1445 .proc_handler
= watermark_scale_factor_sysctl_handler
,
1447 .extra2
= &one_thousand
,
1450 .procname
= "percpu_pagelist_fraction",
1451 .data
= &percpu_pagelist_fraction
,
1452 .maxlen
= sizeof(percpu_pagelist_fraction
),
1454 .proc_handler
= percpu_pagelist_fraction_sysctl_handler
,
1459 .procname
= "max_map_count",
1460 .data
= &sysctl_max_map_count
,
1461 .maxlen
= sizeof(sysctl_max_map_count
),
1463 .proc_handler
= proc_dointvec_minmax
,
1468 .procname
= "nr_trim_pages",
1469 .data
= &sysctl_nr_trim_pages
,
1470 .maxlen
= sizeof(sysctl_nr_trim_pages
),
1472 .proc_handler
= proc_dointvec_minmax
,
1477 .procname
= "laptop_mode",
1478 .data
= &laptop_mode
,
1479 .maxlen
= sizeof(laptop_mode
),
1481 .proc_handler
= proc_dointvec_jiffies
,
1484 .procname
= "block_dump",
1485 .data
= &block_dump
,
1486 .maxlen
= sizeof(block_dump
),
1488 .proc_handler
= proc_dointvec
,
1492 .procname
= "vfs_cache_pressure",
1493 .data
= &sysctl_vfs_cache_pressure
,
1494 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1496 .proc_handler
= proc_dointvec
,
1499 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1501 .procname
= "legacy_va_layout",
1502 .data
= &sysctl_legacy_va_layout
,
1503 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1505 .proc_handler
= proc_dointvec
,
1511 .procname
= "zone_reclaim_mode",
1512 .data
= &node_reclaim_mode
,
1513 .maxlen
= sizeof(node_reclaim_mode
),
1515 .proc_handler
= proc_dointvec
,
1519 .procname
= "min_unmapped_ratio",
1520 .data
= &sysctl_min_unmapped_ratio
,
1521 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1523 .proc_handler
= sysctl_min_unmapped_ratio_sysctl_handler
,
1525 .extra2
= &one_hundred
,
1528 .procname
= "min_slab_ratio",
1529 .data
= &sysctl_min_slab_ratio
,
1530 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1532 .proc_handler
= sysctl_min_slab_ratio_sysctl_handler
,
1534 .extra2
= &one_hundred
,
1539 .procname
= "stat_interval",
1540 .data
= &sysctl_stat_interval
,
1541 .maxlen
= sizeof(sysctl_stat_interval
),
1543 .proc_handler
= proc_dointvec_jiffies
,
1546 .procname
= "stat_refresh",
1550 .proc_handler
= vmstat_refresh
,
1555 .procname
= "mmap_min_addr",
1556 .data
= &dac_mmap_min_addr
,
1557 .maxlen
= sizeof(unsigned long),
1559 .proc_handler
= mmap_min_addr_handler
,
1564 .procname
= "numa_zonelist_order",
1565 .data
= &numa_zonelist_order
,
1566 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1568 .proc_handler
= numa_zonelist_order_handler
,
1571 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1572 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1574 .procname
= "vdso_enabled",
1575 #ifdef CONFIG_X86_32
1576 .data
= &vdso32_enabled
,
1577 .maxlen
= sizeof(vdso32_enabled
),
1579 .data
= &vdso_enabled
,
1580 .maxlen
= sizeof(vdso_enabled
),
1583 .proc_handler
= proc_dointvec
,
1587 #ifdef CONFIG_HIGHMEM
1589 .procname
= "highmem_is_dirtyable",
1590 .data
= &vm_highmem_is_dirtyable
,
1591 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
1593 .proc_handler
= proc_dointvec_minmax
,
1598 #ifdef CONFIG_MEMORY_FAILURE
1600 .procname
= "memory_failure_early_kill",
1601 .data
= &sysctl_memory_failure_early_kill
,
1602 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
1604 .proc_handler
= proc_dointvec_minmax
,
1609 .procname
= "memory_failure_recovery",
1610 .data
= &sysctl_memory_failure_recovery
,
1611 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
1613 .proc_handler
= proc_dointvec_minmax
,
1619 .procname
= "user_reserve_kbytes",
1620 .data
= &sysctl_user_reserve_kbytes
,
1621 .maxlen
= sizeof(sysctl_user_reserve_kbytes
),
1623 .proc_handler
= proc_doulongvec_minmax
,
1626 .procname
= "admin_reserve_kbytes",
1627 .data
= &sysctl_admin_reserve_kbytes
,
1628 .maxlen
= sizeof(sysctl_admin_reserve_kbytes
),
1630 .proc_handler
= proc_doulongvec_minmax
,
1632 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1634 .procname
= "mmap_rnd_bits",
1635 .data
= &mmap_rnd_bits
,
1636 .maxlen
= sizeof(mmap_rnd_bits
),
1638 .proc_handler
= proc_dointvec_minmax
,
1639 .extra1
= (void *)&mmap_rnd_bits_min
,
1640 .extra2
= (void *)&mmap_rnd_bits_max
,
1643 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1645 .procname
= "mmap_rnd_compat_bits",
1646 .data
= &mmap_rnd_compat_bits
,
1647 .maxlen
= sizeof(mmap_rnd_compat_bits
),
1649 .proc_handler
= proc_dointvec_minmax
,
1650 .extra1
= (void *)&mmap_rnd_compat_bits_min
,
1651 .extra2
= (void *)&mmap_rnd_compat_bits_max
,
1657 static struct ctl_table fs_table
[] = {
1659 .procname
= "inode-nr",
1660 .data
= &inodes_stat
,
1661 .maxlen
= 2*sizeof(long),
1663 .proc_handler
= proc_nr_inodes
,
1666 .procname
= "inode-state",
1667 .data
= &inodes_stat
,
1668 .maxlen
= 7*sizeof(long),
1670 .proc_handler
= proc_nr_inodes
,
1673 .procname
= "file-nr",
1674 .data
= &files_stat
,
1675 .maxlen
= sizeof(files_stat
),
1677 .proc_handler
= proc_nr_files
,
1680 .procname
= "file-max",
1681 .data
= &files_stat
.max_files
,
1682 .maxlen
= sizeof(files_stat
.max_files
),
1684 .proc_handler
= proc_doulongvec_minmax
,
1687 .procname
= "nr_open",
1688 .data
= &sysctl_nr_open
,
1689 .maxlen
= sizeof(unsigned int),
1691 .proc_handler
= proc_dointvec_minmax
,
1692 .extra1
= &sysctl_nr_open_min
,
1693 .extra2
= &sysctl_nr_open_max
,
1696 .procname
= "dentry-state",
1697 .data
= &dentry_stat
,
1698 .maxlen
= 6*sizeof(long),
1700 .proc_handler
= proc_nr_dentry
,
1703 .procname
= "overflowuid",
1704 .data
= &fs_overflowuid
,
1705 .maxlen
= sizeof(int),
1707 .proc_handler
= proc_dointvec_minmax
,
1708 .extra1
= &minolduid
,
1709 .extra2
= &maxolduid
,
1712 .procname
= "overflowgid",
1713 .data
= &fs_overflowgid
,
1714 .maxlen
= sizeof(int),
1716 .proc_handler
= proc_dointvec_minmax
,
1717 .extra1
= &minolduid
,
1718 .extra2
= &maxolduid
,
1720 #ifdef CONFIG_FILE_LOCKING
1722 .procname
= "leases-enable",
1723 .data
= &leases_enable
,
1724 .maxlen
= sizeof(int),
1726 .proc_handler
= proc_dointvec
,
1729 #ifdef CONFIG_DNOTIFY
1731 .procname
= "dir-notify-enable",
1732 .data
= &dir_notify_enable
,
1733 .maxlen
= sizeof(int),
1735 .proc_handler
= proc_dointvec
,
1739 #ifdef CONFIG_FILE_LOCKING
1741 .procname
= "lease-break-time",
1742 .data
= &lease_break_time
,
1743 .maxlen
= sizeof(int),
1745 .proc_handler
= proc_dointvec
,
1750 .procname
= "aio-nr",
1752 .maxlen
= sizeof(aio_nr
),
1754 .proc_handler
= proc_doulongvec_minmax
,
1757 .procname
= "aio-max-nr",
1758 .data
= &aio_max_nr
,
1759 .maxlen
= sizeof(aio_max_nr
),
1761 .proc_handler
= proc_doulongvec_minmax
,
1763 #endif /* CONFIG_AIO */
1764 #ifdef CONFIG_INOTIFY_USER
1766 .procname
= "inotify",
1768 .child
= inotify_table
,
1773 .procname
= "epoll",
1775 .child
= epoll_table
,
1780 .procname
= "protected_symlinks",
1781 .data
= &sysctl_protected_symlinks
,
1782 .maxlen
= sizeof(int),
1784 .proc_handler
= proc_dointvec_minmax
,
1789 .procname
= "protected_hardlinks",
1790 .data
= &sysctl_protected_hardlinks
,
1791 .maxlen
= sizeof(int),
1793 .proc_handler
= proc_dointvec_minmax
,
1798 .procname
= "protected_fifos",
1799 .data
= &sysctl_protected_fifos
,
1800 .maxlen
= sizeof(int),
1802 .proc_handler
= proc_dointvec_minmax
,
1807 .procname
= "protected_regular",
1808 .data
= &sysctl_protected_regular
,
1809 .maxlen
= sizeof(int),
1811 .proc_handler
= proc_dointvec_minmax
,
1816 .procname
= "suid_dumpable",
1817 .data
= &suid_dumpable
,
1818 .maxlen
= sizeof(int),
1820 .proc_handler
= proc_dointvec_minmax_coredump
,
1824 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1826 .procname
= "binfmt_misc",
1828 .child
= sysctl_mount_point
,
1832 .procname
= "pipe-max-size",
1833 .data
= &pipe_max_size
,
1834 .maxlen
= sizeof(int),
1836 .proc_handler
= &pipe_proc_fn
,
1837 .extra1
= &pipe_min_size
,
1840 .procname
= "pipe-user-pages-hard",
1841 .data
= &pipe_user_pages_hard
,
1842 .maxlen
= sizeof(pipe_user_pages_hard
),
1844 .proc_handler
= proc_doulongvec_minmax
,
1847 .procname
= "pipe-user-pages-soft",
1848 .data
= &pipe_user_pages_soft
,
1849 .maxlen
= sizeof(pipe_user_pages_soft
),
1851 .proc_handler
= proc_doulongvec_minmax
,
1854 .procname
= "mount-max",
1855 .data
= &sysctl_mount_max
,
1856 .maxlen
= sizeof(unsigned int),
1858 .proc_handler
= proc_dointvec_minmax
,
1864 static struct ctl_table debug_table
[] = {
1865 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1867 .procname
= "exception-trace",
1868 .data
= &show_unhandled_signals
,
1869 .maxlen
= sizeof(int),
1871 .proc_handler
= proc_dointvec
1874 #if defined(CONFIG_OPTPROBES)
1876 .procname
= "kprobes-optimization",
1877 .data
= &sysctl_kprobes_optimization
,
1878 .maxlen
= sizeof(int),
1880 .proc_handler
= proc_kprobes_optimization_handler
,
1888 static struct ctl_table dev_table
[] = {
1892 int __init
sysctl_init(void)
1894 struct ctl_table_header
*hdr
;
1896 hdr
= register_sysctl_table(sysctl_base_table
);
1897 kmemleak_not_leak(hdr
);
1901 #endif /* CONFIG_SYSCTL */
1907 #ifdef CONFIG_PROC_SYSCTL
1909 static int _proc_do_string(char *data
, int maxlen
, int write
,
1910 char __user
*buffer
,
1911 size_t *lenp
, loff_t
*ppos
)
1917 if (!data
|| !maxlen
|| !*lenp
) {
1923 if (sysctl_writes_strict
== SYSCTL_WRITES_STRICT
) {
1924 /* Only continue writes not past the end of buffer. */
1926 if (len
> maxlen
- 1)
1933 /* Start writing from beginning of buffer. */
1939 while ((p
- buffer
) < *lenp
&& len
< maxlen
- 1) {
1940 if (get_user(c
, p
++))
1942 if (c
== 0 || c
== '\n')
1963 if (copy_to_user(buffer
, data
, len
))
1966 if (put_user('\n', buffer
+ len
))
1976 static void warn_sysctl_write(struct ctl_table
*table
)
1978 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1979 "This will not be supported in the future. To silence this\n"
1980 "warning, set kernel.sysctl_writes_strict = -1\n",
1981 current
->comm
, table
->procname
);
1985 * proc_dostring - read a string sysctl
1986 * @table: the sysctl table
1987 * @write: %TRUE if this is a write to the sysctl file
1988 * @buffer: the user buffer
1989 * @lenp: the size of the user buffer
1990 * @ppos: file position
1992 * Reads/writes a string from/to the user buffer. If the kernel
1993 * buffer provided is not large enough to hold the string, the
1994 * string is truncated. The copied string is %NULL-terminated.
1995 * If the string is being read by the user process, it is copied
1996 * and a newline '\n' is added. It is truncated if the buffer is
1999 * Returns 0 on success.
2001 int proc_dostring(struct ctl_table
*table
, int write
,
2002 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2004 if (write
&& *ppos
&& sysctl_writes_strict
== SYSCTL_WRITES_WARN
)
2005 warn_sysctl_write(table
);
2007 return _proc_do_string((char *)(table
->data
), table
->maxlen
, write
,
2008 (char __user
*)buffer
, lenp
, ppos
);
2011 static size_t proc_skip_spaces(char **buf
)
2014 char *tmp
= skip_spaces(*buf
);
2020 static void proc_skip_char(char **buf
, size_t *size
, const char v
)
2030 #define TMPBUFLEN 22
2032 * proc_get_long - reads an ASCII formatted integer from a user buffer
2034 * @buf: a kernel buffer
2035 * @size: size of the kernel buffer
2036 * @val: this is where the number will be stored
2037 * @neg: set to %TRUE if number is negative
2038 * @perm_tr: a vector which contains the allowed trailers
2039 * @perm_tr_len: size of the perm_tr vector
2040 * @tr: pointer to store the trailer character
2042 * In case of success %0 is returned and @buf and @size are updated with
2043 * the amount of bytes read. If @tr is non-NULL and a trailing
2044 * character exists (size is non-zero after returning from this
2045 * function), @tr is updated with the trailing character.
2047 static int proc_get_long(char **buf
, size_t *size
,
2048 unsigned long *val
, bool *neg
,
2049 const char *perm_tr
, unsigned perm_tr_len
, char *tr
)
2052 char *p
, tmp
[TMPBUFLEN
];
2058 if (len
> TMPBUFLEN
- 1)
2059 len
= TMPBUFLEN
- 1;
2061 memcpy(tmp
, *buf
, len
);
2065 if (*p
== '-' && *size
> 1) {
2073 *val
= simple_strtoul(p
, &p
, 0);
2077 /* We don't know if the next char is whitespace thus we may accept
2078 * invalid integers (e.g. 1234...a) or two integers instead of one
2079 * (e.g. 123...1). So lets not allow such large numbers. */
2080 if (len
== TMPBUFLEN
- 1)
2083 if (len
< *size
&& perm_tr_len
&& !memchr(perm_tr
, *p
, perm_tr_len
))
2086 if (tr
&& (len
< *size
))
2096 * proc_put_long - converts an integer to a decimal ASCII formatted string
2098 * @buf: the user buffer
2099 * @size: the size of the user buffer
2100 * @val: the integer to be converted
2101 * @neg: sign of the number, %TRUE for negative
2103 * In case of success %0 is returned and @buf and @size are updated with
2104 * the amount of bytes written.
2106 static int proc_put_long(void __user
**buf
, size_t *size
, unsigned long val
,
2110 char tmp
[TMPBUFLEN
], *p
= tmp
;
2112 sprintf(p
, "%s%lu", neg
? "-" : "", val
);
2116 if (copy_to_user(*buf
, tmp
, len
))
2124 static int proc_put_char(void __user
**buf
, size_t *size
, char c
)
2127 char __user
**buffer
= (char __user
**)buf
;
2128 if (put_user(c
, *buffer
))
2130 (*size
)--, (*buffer
)++;
2136 static int do_proc_dointvec_conv(bool *negp
, unsigned long *lvalp
,
2138 int write
, void *data
)
2142 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2146 if (*lvalp
> (unsigned long) INT_MAX
)
2154 *lvalp
= -(unsigned long)val
;
2157 *lvalp
= (unsigned long)val
;
2163 static int do_proc_douintvec_conv(bool *negp
, unsigned long *lvalp
,
2165 int write
, void *data
)
2170 if (*lvalp
> UINT_MAX
)
2174 unsigned int val
= *valp
;
2176 *lvalp
= (unsigned long)val
;
2181 static const char proc_wspace_sep
[] = { ' ', '\t', '\n' };
2183 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2184 int write
, void __user
*buffer
,
2185 size_t *lenp
, loff_t
*ppos
,
2186 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2187 int write
, void *data
),
2190 int *i
, vleft
, first
= 1, err
= 0;
2192 char *kbuf
= NULL
, *p
;
2194 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2199 i
= (int *) tbl_data
;
2200 vleft
= table
->maxlen
/ sizeof(*i
);
2204 conv
= do_proc_dointvec_conv
;
2208 switch (sysctl_writes_strict
) {
2209 case SYSCTL_WRITES_STRICT
:
2211 case SYSCTL_WRITES_WARN
:
2212 warn_sysctl_write(table
);
2219 if (left
> PAGE_SIZE
- 1)
2220 left
= PAGE_SIZE
- 1;
2221 p
= kbuf
= memdup_user_nul(buffer
, left
);
2223 return PTR_ERR(kbuf
);
2226 for (; left
&& vleft
--; i
++, first
=0) {
2231 left
-= proc_skip_spaces(&p
);
2235 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2237 sizeof(proc_wspace_sep
), NULL
);
2240 if (conv(&neg
, &lval
, i
, 1, data
)) {
2245 if (conv(&neg
, &lval
, i
, 0, data
)) {
2250 err
= proc_put_char(&buffer
, &left
, '\t');
2253 err
= proc_put_long(&buffer
, &left
, lval
, neg
);
2259 if (!write
&& !first
&& left
&& !err
)
2260 err
= proc_put_char(&buffer
, &left
, '\n');
2261 if (write
&& !err
&& left
)
2262 left
-= proc_skip_spaces(&p
);
2266 return err
? : -EINVAL
;
2274 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2275 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2276 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2277 int write
, void *data
),
2280 return __do_proc_dointvec(table
->data
, table
, write
,
2281 buffer
, lenp
, ppos
, conv
, data
);
2285 * proc_dointvec - read a vector of integers
2286 * @table: the sysctl table
2287 * @write: %TRUE if this is a write to the sysctl file
2288 * @buffer: the user buffer
2289 * @lenp: the size of the user buffer
2290 * @ppos: file position
2292 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2293 * values from/to the user buffer, treated as an ASCII string.
2295 * Returns 0 on success.
2297 int proc_dointvec(struct ctl_table
*table
, int write
,
2298 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2300 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
, NULL
, NULL
);
2304 * proc_douintvec - read a vector of unsigned integers
2305 * @table: the sysctl table
2306 * @write: %TRUE if this is a write to the sysctl file
2307 * @buffer: the user buffer
2308 * @lenp: the size of the user buffer
2309 * @ppos: file position
2311 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2312 * values from/to the user buffer, treated as an ASCII string.
2314 * Returns 0 on success.
2316 int proc_douintvec(struct ctl_table
*table
, int write
,
2317 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2319 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2320 do_proc_douintvec_conv
, NULL
);
2324 * Taint values can only be increased
2325 * This means we can safely use a temporary.
2327 static int proc_taint(struct ctl_table
*table
, int write
,
2328 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2331 unsigned long tmptaint
= get_taint();
2334 if (write
&& !capable(CAP_SYS_ADMIN
))
2339 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2345 * Poor man's atomic or. Not worth adding a primitive
2346 * to everyone's atomic.h for this
2349 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2350 if ((tmptaint
>> i
) & 1)
2351 add_taint(i
, LOCKDEP_STILL_OK
);
2358 #ifdef CONFIG_PRINTK
2359 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
2360 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2362 if (write
&& !capable(CAP_SYS_ADMIN
))
2365 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2369 struct do_proc_dointvec_minmax_conv_param
{
2374 static int do_proc_dointvec_minmax_conv(bool *negp
, unsigned long *lvalp
,
2376 int write
, void *data
)
2378 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2380 int val
= *negp
? -*lvalp
: *lvalp
;
2381 if ((param
->min
&& *param
->min
> val
) ||
2382 (param
->max
&& *param
->max
< val
))
2389 *lvalp
= -(unsigned long)val
;
2392 *lvalp
= (unsigned long)val
;
2399 * proc_dointvec_minmax - read a vector of integers with min/max values
2400 * @table: the sysctl table
2401 * @write: %TRUE if this is a write to the sysctl file
2402 * @buffer: the user buffer
2403 * @lenp: the size of the user buffer
2404 * @ppos: file position
2406 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2407 * values from/to the user buffer, treated as an ASCII string.
2409 * This routine will ensure the values are within the range specified by
2410 * table->extra1 (min) and table->extra2 (max).
2412 * Returns 0 on success.
2414 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2415 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2417 struct do_proc_dointvec_minmax_conv_param param
= {
2418 .min
= (int *) table
->extra1
,
2419 .max
= (int *) table
->extra2
,
2421 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2422 do_proc_dointvec_minmax_conv
, ¶m
);
2425 static void validate_coredump_safety(void)
2427 #ifdef CONFIG_COREDUMP
2428 if (suid_dumpable
== SUID_DUMP_ROOT
&&
2429 core_pattern
[0] != '/' && core_pattern
[0] != '|') {
2430 printk(KERN_WARNING
"Unsafe core_pattern used with "\
2431 "suid_dumpable=2. Pipe handler or fully qualified "\
2432 "core dump path required.\n");
2437 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
2438 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2440 int error
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2442 validate_coredump_safety();
2446 #ifdef CONFIG_COREDUMP
2447 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
2448 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2450 int error
= proc_dostring(table
, write
, buffer
, lenp
, ppos
);
2452 validate_coredump_safety();
2457 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2458 void __user
*buffer
,
2459 size_t *lenp
, loff_t
*ppos
,
2460 unsigned long convmul
,
2461 unsigned long convdiv
)
2463 unsigned long *i
, *min
, *max
;
2464 int vleft
, first
= 1, err
= 0;
2466 char *kbuf
= NULL
, *p
;
2468 if (!data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2473 i
= (unsigned long *) data
;
2474 min
= (unsigned long *) table
->extra1
;
2475 max
= (unsigned long *) table
->extra2
;
2476 vleft
= table
->maxlen
/ sizeof(unsigned long);
2481 switch (sysctl_writes_strict
) {
2482 case SYSCTL_WRITES_STRICT
:
2484 case SYSCTL_WRITES_WARN
:
2485 warn_sysctl_write(table
);
2492 if (left
> PAGE_SIZE
- 1)
2493 left
= PAGE_SIZE
- 1;
2494 p
= kbuf
= memdup_user_nul(buffer
, left
);
2496 return PTR_ERR(kbuf
);
2499 for (; left
&& vleft
--; i
++, first
= 0) {
2505 left
-= proc_skip_spaces(&p
);
2507 err
= proc_get_long(&p
, &left
, &val
, &neg
,
2509 sizeof(proc_wspace_sep
), NULL
);
2514 val
= convmul
* val
/ convdiv
;
2515 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2519 val
= convdiv
* (*i
) / convmul
;
2521 err
= proc_put_char(&buffer
, &left
, '\t');
2525 err
= proc_put_long(&buffer
, &left
, val
, false);
2531 if (!write
&& !first
&& left
&& !err
)
2532 err
= proc_put_char(&buffer
, &left
, '\n');
2534 left
-= proc_skip_spaces(&p
);
2538 return err
? : -EINVAL
;
2546 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2547 void __user
*buffer
,
2548 size_t *lenp
, loff_t
*ppos
,
2549 unsigned long convmul
,
2550 unsigned long convdiv
)
2552 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2553 buffer
, lenp
, ppos
, convmul
, convdiv
);
2557 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2558 * @table: the sysctl table
2559 * @write: %TRUE if this is a write to the sysctl file
2560 * @buffer: the user buffer
2561 * @lenp: the size of the user buffer
2562 * @ppos: file position
2564 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2565 * values from/to the user buffer, treated as an ASCII string.
2567 * This routine will ensure the values are within the range specified by
2568 * table->extra1 (min) and table->extra2 (max).
2570 * Returns 0 on success.
2572 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2573 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2575 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2579 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2580 * @table: the sysctl table
2581 * @write: %TRUE if this is a write to the sysctl file
2582 * @buffer: the user buffer
2583 * @lenp: the size of the user buffer
2584 * @ppos: file position
2586 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2587 * values from/to the user buffer, treated as an ASCII string. The values
2588 * are treated as milliseconds, and converted to jiffies when they are stored.
2590 * This routine will ensure the values are within the range specified by
2591 * table->extra1 (min) and table->extra2 (max).
2593 * Returns 0 on success.
2595 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2596 void __user
*buffer
,
2597 size_t *lenp
, loff_t
*ppos
)
2599 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2600 lenp
, ppos
, HZ
, 1000l);
2604 static int do_proc_dointvec_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2606 int write
, void *data
)
2609 if (*lvalp
> LONG_MAX
/ HZ
)
2611 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2617 lval
= -(unsigned long)val
;
2620 lval
= (unsigned long)val
;
2627 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2629 int write
, void *data
)
2632 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2634 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2640 lval
= -(unsigned long)val
;
2643 lval
= (unsigned long)val
;
2645 *lvalp
= jiffies_to_clock_t(lval
);
2650 static int do_proc_dointvec_ms_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2652 int write
, void *data
)
2655 unsigned long jif
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2665 lval
= -(unsigned long)val
;
2668 lval
= (unsigned long)val
;
2670 *lvalp
= jiffies_to_msecs(lval
);
2676 * proc_dointvec_jiffies - read a vector of integers as seconds
2677 * @table: the sysctl table
2678 * @write: %TRUE if this is a write to the sysctl file
2679 * @buffer: the user buffer
2680 * @lenp: the size of the user buffer
2681 * @ppos: file position
2683 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2684 * values from/to the user buffer, treated as an ASCII string.
2685 * The values read are assumed to be in seconds, and are converted into
2688 * Returns 0 on success.
2690 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2691 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2693 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2694 do_proc_dointvec_jiffies_conv
,NULL
);
2698 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2699 * @table: the sysctl table
2700 * @write: %TRUE if this is a write to the sysctl file
2701 * @buffer: the user buffer
2702 * @lenp: the size of the user buffer
2703 * @ppos: pointer to the file position
2705 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2706 * values from/to the user buffer, treated as an ASCII string.
2707 * The values read are assumed to be in 1/USER_HZ seconds, and
2708 * are converted into jiffies.
2710 * Returns 0 on success.
2712 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2713 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2715 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2716 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2720 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2721 * @table: the sysctl table
2722 * @write: %TRUE if this is a write to the sysctl file
2723 * @buffer: the user buffer
2724 * @lenp: the size of the user buffer
2725 * @ppos: file position
2726 * @ppos: the current position in the file
2728 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2729 * values from/to the user buffer, treated as an ASCII string.
2730 * The values read are assumed to be in 1/1000 seconds, and
2731 * are converted into jiffies.
2733 * Returns 0 on success.
2735 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2736 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2738 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2739 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2742 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
2743 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2745 struct pid
*new_pid
;
2749 tmp
= pid_vnr(cad_pid
);
2751 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
2752 lenp
, ppos
, NULL
, NULL
);
2756 new_pid
= find_get_pid(tmp
);
2760 put_pid(xchg(&cad_pid
, new_pid
));
2765 * proc_do_large_bitmap - read/write from/to a large bitmap
2766 * @table: the sysctl table
2767 * @write: %TRUE if this is a write to the sysctl file
2768 * @buffer: the user buffer
2769 * @lenp: the size of the user buffer
2770 * @ppos: file position
2772 * The bitmap is stored at table->data and the bitmap length (in bits)
2775 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2776 * large bitmaps may be represented in a compact manner. Writing into
2777 * the file will clear the bitmap then update it with the given input.
2779 * Returns 0 on success.
2781 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
2782 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2786 size_t left
= *lenp
;
2787 unsigned long bitmap_len
= table
->maxlen
;
2788 unsigned long *bitmap
= *(unsigned long **) table
->data
;
2789 unsigned long *tmp_bitmap
= NULL
;
2790 char tr_a
[] = { '-', ',', '\n' }, tr_b
[] = { ',', '\n', 0 }, c
;
2792 if (!bitmap
|| !bitmap_len
|| !left
|| (*ppos
&& !write
)) {
2800 if (left
> PAGE_SIZE
- 1)
2801 left
= PAGE_SIZE
- 1;
2803 p
= kbuf
= memdup_user_nul(buffer
, left
);
2805 return PTR_ERR(kbuf
);
2807 tmp_bitmap
= kzalloc(BITS_TO_LONGS(bitmap_len
) * sizeof(unsigned long),
2813 proc_skip_char(&p
, &left
, '\n');
2814 while (!err
&& left
) {
2815 unsigned long val_a
, val_b
;
2818 err
= proc_get_long(&p
, &left
, &val_a
, &neg
, tr_a
,
2822 if (val_a
>= bitmap_len
|| neg
) {
2834 err
= proc_get_long(&p
, &left
, &val_b
,
2835 &neg
, tr_b
, sizeof(tr_b
),
2839 if (val_b
>= bitmap_len
|| neg
||
2850 bitmap_set(tmp_bitmap
, val_a
, val_b
- val_a
+ 1);
2852 proc_skip_char(&p
, &left
, '\n');
2856 unsigned long bit_a
, bit_b
= 0;
2859 bit_a
= find_next_bit(bitmap
, bitmap_len
, bit_b
);
2860 if (bit_a
>= bitmap_len
)
2862 bit_b
= find_next_zero_bit(bitmap
, bitmap_len
,
2866 err
= proc_put_char(&buffer
, &left
, ',');
2870 err
= proc_put_long(&buffer
, &left
, bit_a
, false);
2873 if (bit_a
!= bit_b
) {
2874 err
= proc_put_char(&buffer
, &left
, '-');
2877 err
= proc_put_long(&buffer
, &left
, bit_b
, false);
2885 err
= proc_put_char(&buffer
, &left
, '\n');
2891 bitmap_or(bitmap
, bitmap
, tmp_bitmap
, bitmap_len
);
2893 bitmap_copy(bitmap
, tmp_bitmap
, bitmap_len
);
2905 #else /* CONFIG_PROC_SYSCTL */
2907 int proc_dostring(struct ctl_table
*table
, int write
,
2908 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2913 int proc_dointvec(struct ctl_table
*table
, int write
,
2914 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2919 int proc_douintvec(struct ctl_table
*table
, int write
,
2920 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2925 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2926 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2931 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2932 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2937 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2938 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2943 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2944 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2949 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2950 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2955 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2956 void __user
*buffer
,
2957 size_t *lenp
, loff_t
*ppos
)
2963 #endif /* CONFIG_PROC_SYSCTL */
2966 * No sense putting this after each symbol definition, twice,
2967 * exception granted :-)
2969 EXPORT_SYMBOL(proc_dointvec
);
2970 EXPORT_SYMBOL(proc_douintvec
);
2971 EXPORT_SYMBOL(proc_dointvec_jiffies
);
2972 EXPORT_SYMBOL(proc_dointvec_minmax
);
2973 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
2974 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
2975 EXPORT_SYMBOL(proc_dostring
);
2976 EXPORT_SYMBOL(proc_doulongvec_minmax
);
2977 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);