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/kmemleak.h>
35 #include <linux/init.h>
36 #include <linux/kernel.h>
37 #include <linux/kobject.h>
38 #include <linux/net.h>
39 #include <linux/sysrq.h>
40 #include <linux/highuid.h>
41 #include <linux/writeback.h>
42 #include <linux/ratelimit.h>
43 #include <linux/compaction.h>
44 #include <linux/hugetlb.h>
45 #include <linux/initrd.h>
46 #include <linux/key.h>
47 #include <linux/times.h>
48 #include <linux/limits.h>
49 #include <linux/dcache.h>
50 #include <linux/dnotify.h>
51 #include <linux/syscalls.h>
52 #include <linux/vmstat.h>
53 #include <linux/nfs_fs.h>
54 #include <linux/acpi.h>
55 #include <linux/reboot.h>
56 #include <linux/ftrace.h>
57 #include <linux/perf_event.h>
58 #include <linux/kprobes.h>
59 #include <linux/pipe_fs_i.h>
60 #include <linux/oom.h>
61 #include <linux/kmod.h>
62 #include <linux/capability.h>
63 #include <linux/binfmts.h>
64 #include <linux/sched/sysctl.h>
65 #include <linux/sched/coredump.h>
66 #include <linux/kexec.h>
67 #include <linux/bpf.h>
68 #include <linux/mount.h>
70 #include <linux/uaccess.h>
71 #include <asm/processor.h>
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
177 * enum sysctl_writes_mode - supported sysctl write modes
179 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
180 * to be written, and multiple writes on the same sysctl file descriptor
181 * will rewrite the sysctl value, regardless of file position. No warning
182 * is issued when the initial position is not 0.
183 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
185 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
186 * file position 0 and the value must be fully contained in the buffer
187 * sent to the write syscall. If dealing with strings respect the file
188 * position, but restrict this to the max length of the buffer, anything
189 * passed the max lenght will be ignored. Multiple writes will append
192 * These write modes control how current file position affects the behavior of
193 * updating sysctl values through the proc interface on each write.
195 enum sysctl_writes_mode
{
196 SYSCTL_WRITES_LEGACY
= -1,
197 SYSCTL_WRITES_WARN
= 0,
198 SYSCTL_WRITES_STRICT
= 1,
201 static enum sysctl_writes_mode sysctl_writes_strict
= SYSCTL_WRITES_STRICT
;
203 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
204 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
205 static int proc_taint(struct ctl_table
*table
, int write
,
206 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
210 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
211 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
214 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
215 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
216 #ifdef CONFIG_COREDUMP
217 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
218 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
);
221 #ifdef CONFIG_MAGIC_SYSRQ
222 /* Note: sysrq code uses it's own private copy */
223 static int __sysrq_enabled
= CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE
;
225 static int sysrq_sysctl_handler(struct ctl_table
*table
, int write
,
226 void __user
*buffer
, size_t *lenp
,
231 error
= proc_dointvec(table
, write
, buffer
, lenp
, ppos
);
236 sysrq_toggle_support(__sysrq_enabled
);
243 static struct ctl_table kern_table
[];
244 static struct ctl_table vm_table
[];
245 static struct ctl_table fs_table
[];
246 static struct ctl_table debug_table
[];
247 static struct ctl_table dev_table
[];
248 extern struct ctl_table random_table
[];
250 extern struct ctl_table epoll_table
[];
253 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
254 int sysctl_legacy_va_layout
;
257 /* The default sysctl tables: */
259 static struct ctl_table sysctl_base_table
[] = {
261 .procname
= "kernel",
278 .child
= debug_table
,
288 #ifdef CONFIG_SCHED_DEBUG
289 static int min_sched_granularity_ns
= 100000; /* 100 usecs */
290 static int max_sched_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
291 static int min_wakeup_granularity_ns
; /* 0 usecs */
292 static int max_wakeup_granularity_ns
= NSEC_PER_SEC
; /* 1 second */
294 static int min_sched_tunable_scaling
= SCHED_TUNABLESCALING_NONE
;
295 static int max_sched_tunable_scaling
= SCHED_TUNABLESCALING_END
-1;
296 #endif /* CONFIG_SMP */
297 #endif /* CONFIG_SCHED_DEBUG */
299 #ifdef CONFIG_COMPACTION
300 static int min_extfrag_threshold
;
301 static int max_extfrag_threshold
= 1000;
304 static struct ctl_table kern_table
[] = {
306 .procname
= "sched_child_runs_first",
307 .data
= &sysctl_sched_child_runs_first
,
308 .maxlen
= sizeof(unsigned int),
310 .proc_handler
= proc_dointvec
,
312 #ifdef CONFIG_SCHED_DEBUG
314 .procname
= "sched_min_granularity_ns",
315 .data
= &sysctl_sched_min_granularity
,
316 .maxlen
= sizeof(unsigned int),
318 .proc_handler
= sched_proc_update_handler
,
319 .extra1
= &min_sched_granularity_ns
,
320 .extra2
= &max_sched_granularity_ns
,
323 .procname
= "sched_latency_ns",
324 .data
= &sysctl_sched_latency
,
325 .maxlen
= sizeof(unsigned int),
327 .proc_handler
= sched_proc_update_handler
,
328 .extra1
= &min_sched_granularity_ns
,
329 .extra2
= &max_sched_granularity_ns
,
331 #ifdef CONFIG_SCHED_WALT
333 .procname
= "sched_use_walt_cpu_util",
334 .data
= &sysctl_sched_use_walt_cpu_util
,
335 .maxlen
= sizeof(unsigned int),
337 .proc_handler
= proc_dointvec
,
340 .procname
= "sched_use_walt_task_util",
341 .data
= &sysctl_sched_use_walt_task_util
,
342 .maxlen
= sizeof(unsigned int),
344 .proc_handler
= proc_dointvec
,
347 .procname
= "sched_walt_init_task_load_pct",
348 .data
= &sysctl_sched_walt_init_task_load_pct
,
349 .maxlen
= sizeof(unsigned int),
351 .proc_handler
= proc_dointvec
,
354 .procname
= "sched_walt_cpu_high_irqload",
355 .data
= &sysctl_sched_walt_cpu_high_irqload
,
356 .maxlen
= sizeof(unsigned int),
358 .proc_handler
= proc_dointvec
,
362 .procname
= "sched_sync_hint_enable",
363 .data
= &sysctl_sched_sync_hint_enable
,
364 .maxlen
= sizeof(unsigned int),
366 .proc_handler
= proc_dointvec
,
369 .procname
= "sched_cstate_aware",
370 .data
= &sysctl_sched_cstate_aware
,
371 .maxlen
= sizeof(unsigned int),
373 .proc_handler
= proc_dointvec
,
376 .procname
= "sched_wakeup_granularity_ns",
377 .data
= &sysctl_sched_wakeup_granularity
,
378 .maxlen
= sizeof(unsigned int),
380 .proc_handler
= sched_proc_update_handler
,
381 .extra1
= &min_wakeup_granularity_ns
,
382 .extra2
= &max_wakeup_granularity_ns
,
386 .procname
= "sched_tunable_scaling",
387 .data
= &sysctl_sched_tunable_scaling
,
388 .maxlen
= sizeof(enum sched_tunable_scaling
),
390 .proc_handler
= sched_proc_update_handler
,
391 .extra1
= &min_sched_tunable_scaling
,
392 .extra2
= &max_sched_tunable_scaling
,
395 .procname
= "sched_migration_cost_ns",
396 .data
= &sysctl_sched_migration_cost
,
397 .maxlen
= sizeof(unsigned int),
399 .proc_handler
= proc_dointvec
,
402 .procname
= "sched_nr_migrate",
403 .data
= &sysctl_sched_nr_migrate
,
404 .maxlen
= sizeof(unsigned int),
406 .proc_handler
= proc_dointvec
,
409 .procname
= "sched_time_avg_ms",
410 .data
= &sysctl_sched_time_avg
,
411 .maxlen
= sizeof(unsigned int),
413 .proc_handler
= proc_dointvec_minmax
,
416 #ifdef CONFIG_SCHEDSTATS
418 .procname
= "sched_schedstats",
420 .maxlen
= sizeof(unsigned int),
422 .proc_handler
= sysctl_schedstats
,
426 #endif /* CONFIG_SCHEDSTATS */
427 #endif /* CONFIG_SMP */
428 #ifdef CONFIG_NUMA_BALANCING
430 .procname
= "numa_balancing_scan_delay_ms",
431 .data
= &sysctl_numa_balancing_scan_delay
,
432 .maxlen
= sizeof(unsigned int),
434 .proc_handler
= proc_dointvec
,
437 .procname
= "numa_balancing_scan_period_min_ms",
438 .data
= &sysctl_numa_balancing_scan_period_min
,
439 .maxlen
= sizeof(unsigned int),
441 .proc_handler
= proc_dointvec
,
444 .procname
= "numa_balancing_scan_period_max_ms",
445 .data
= &sysctl_numa_balancing_scan_period_max
,
446 .maxlen
= sizeof(unsigned int),
448 .proc_handler
= proc_dointvec
,
451 .procname
= "numa_balancing_scan_size_mb",
452 .data
= &sysctl_numa_balancing_scan_size
,
453 .maxlen
= sizeof(unsigned int),
455 .proc_handler
= proc_dointvec_minmax
,
459 .procname
= "numa_balancing",
460 .data
= NULL
, /* filled in by handler */
461 .maxlen
= sizeof(unsigned int),
463 .proc_handler
= sysctl_numa_balancing
,
467 #endif /* CONFIG_NUMA_BALANCING */
468 #endif /* CONFIG_SCHED_DEBUG */
470 .procname
= "sched_rt_period_us",
471 .data
= &sysctl_sched_rt_period
,
472 .maxlen
= sizeof(unsigned int),
474 .proc_handler
= sched_rt_handler
,
477 .procname
= "sched_rt_runtime_us",
478 .data
= &sysctl_sched_rt_runtime
,
479 .maxlen
= sizeof(int),
481 .proc_handler
= sched_rt_handler
,
484 .procname
= "sched_rr_timeslice_ms",
485 .data
= &sysctl_sched_rr_timeslice
,
486 .maxlen
= sizeof(int),
488 .proc_handler
= sched_rr_handler
,
490 #ifdef CONFIG_SCHED_AUTOGROUP
492 .procname
= "sched_autogroup_enabled",
493 .data
= &sysctl_sched_autogroup_enabled
,
494 .maxlen
= sizeof(unsigned int),
496 .proc_handler
= proc_dointvec_minmax
,
501 #ifdef CONFIG_CFS_BANDWIDTH
503 .procname
= "sched_cfs_bandwidth_slice_us",
504 .data
= &sysctl_sched_cfs_bandwidth_slice
,
505 .maxlen
= sizeof(unsigned int),
507 .proc_handler
= proc_dointvec_minmax
,
511 #ifdef CONFIG_PROVE_LOCKING
513 .procname
= "prove_locking",
514 .data
= &prove_locking
,
515 .maxlen
= sizeof(int),
517 .proc_handler
= proc_dointvec
,
520 #ifdef CONFIG_LOCK_STAT
522 .procname
= "lock_stat",
524 .maxlen
= sizeof(int),
526 .proc_handler
= proc_dointvec
,
531 .data
= &panic_timeout
,
532 .maxlen
= sizeof(int),
534 .proc_handler
= proc_dointvec
,
536 #ifdef CONFIG_COREDUMP
538 .procname
= "core_uses_pid",
539 .data
= &core_uses_pid
,
540 .maxlen
= sizeof(int),
542 .proc_handler
= proc_dointvec
,
545 .procname
= "core_pattern",
546 .data
= core_pattern
,
547 .maxlen
= CORENAME_MAX_SIZE
,
549 .proc_handler
= proc_dostring_coredump
,
552 .procname
= "core_pipe_limit",
553 .data
= &core_pipe_limit
,
554 .maxlen
= sizeof(unsigned int),
556 .proc_handler
= proc_dointvec
,
559 #ifdef CONFIG_PROC_SYSCTL
561 .procname
= "tainted",
562 .maxlen
= sizeof(long),
564 .proc_handler
= proc_taint
,
567 .procname
= "sysctl_writes_strict",
568 .data
= &sysctl_writes_strict
,
569 .maxlen
= sizeof(int),
571 .proc_handler
= proc_dointvec_minmax
,
576 #ifdef CONFIG_LATENCYTOP
578 .procname
= "latencytop",
579 .data
= &latencytop_enabled
,
580 .maxlen
= sizeof(int),
582 .proc_handler
= sysctl_latencytop
,
585 #ifdef CONFIG_BLK_DEV_INITRD
587 .procname
= "real-root-dev",
588 .data
= &real_root_dev
,
589 .maxlen
= sizeof(int),
591 .proc_handler
= proc_dointvec
,
595 .procname
= "print-fatal-signals",
596 .data
= &print_fatal_signals
,
597 .maxlen
= sizeof(int),
599 .proc_handler
= proc_dointvec
,
603 .procname
= "reboot-cmd",
604 .data
= reboot_command
,
607 .proc_handler
= proc_dostring
,
610 .procname
= "stop-a",
611 .data
= &stop_a_enabled
,
612 .maxlen
= sizeof (int),
614 .proc_handler
= proc_dointvec
,
617 .procname
= "scons-poweroff",
618 .data
= &scons_pwroff
,
619 .maxlen
= sizeof (int),
621 .proc_handler
= proc_dointvec
,
624 #ifdef CONFIG_SPARC64
626 .procname
= "tsb-ratio",
627 .data
= &sysctl_tsb_ratio
,
628 .maxlen
= sizeof (int),
630 .proc_handler
= proc_dointvec
,
635 .procname
= "soft-power",
636 .data
= &pwrsw_enabled
,
637 .maxlen
= sizeof (int),
639 .proc_handler
= proc_dointvec
,
642 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
644 .procname
= "unaligned-trap",
645 .data
= &unaligned_enabled
,
646 .maxlen
= sizeof (int),
648 .proc_handler
= proc_dointvec
,
652 .procname
= "ctrl-alt-del",
654 .maxlen
= sizeof(int),
656 .proc_handler
= proc_dointvec
,
658 #ifdef CONFIG_FUNCTION_TRACER
660 .procname
= "ftrace_enabled",
661 .data
= &ftrace_enabled
,
662 .maxlen
= sizeof(int),
664 .proc_handler
= ftrace_enable_sysctl
,
667 #ifdef CONFIG_STACK_TRACER
669 .procname
= "stack_tracer_enabled",
670 .data
= &stack_tracer_enabled
,
671 .maxlen
= sizeof(int),
673 .proc_handler
= stack_trace_sysctl
,
676 #ifdef CONFIG_TRACING
678 .procname
= "ftrace_dump_on_oops",
679 .data
= &ftrace_dump_on_oops
,
680 .maxlen
= sizeof(int),
682 .proc_handler
= proc_dointvec
,
685 .procname
= "traceoff_on_warning",
686 .data
= &__disable_trace_on_warning
,
687 .maxlen
= sizeof(__disable_trace_on_warning
),
689 .proc_handler
= proc_dointvec
,
692 .procname
= "tracepoint_printk",
693 .data
= &tracepoint_printk
,
694 .maxlen
= sizeof(tracepoint_printk
),
696 .proc_handler
= tracepoint_printk_sysctl
,
699 #ifdef CONFIG_KEXEC_CORE
701 .procname
= "kexec_load_disabled",
702 .data
= &kexec_load_disabled
,
703 .maxlen
= sizeof(int),
705 /* only handle a transition from default "0" to "1" */
706 .proc_handler
= proc_dointvec_minmax
,
711 #ifdef CONFIG_MODULES
713 .procname
= "modprobe",
714 .data
= &modprobe_path
,
715 .maxlen
= KMOD_PATH_LEN
,
717 .proc_handler
= proc_dostring
,
720 .procname
= "modules_disabled",
721 .data
= &modules_disabled
,
722 .maxlen
= sizeof(int),
724 /* only handle a transition from default "0" to "1" */
725 .proc_handler
= proc_dointvec_minmax
,
730 #ifdef CONFIG_UEVENT_HELPER
732 .procname
= "hotplug",
733 .data
= &uevent_helper
,
734 .maxlen
= UEVENT_HELPER_PATH_LEN
,
736 .proc_handler
= proc_dostring
,
739 #ifdef CONFIG_CHR_DEV_SG
741 .procname
= "sg-big-buff",
742 .data
= &sg_big_buff
,
743 .maxlen
= sizeof (int),
745 .proc_handler
= proc_dointvec
,
748 #ifdef CONFIG_BSD_PROCESS_ACCT
752 .maxlen
= 3*sizeof(int),
754 .proc_handler
= proc_dointvec
,
757 #ifdef CONFIG_MAGIC_SYSRQ
760 .data
= &__sysrq_enabled
,
761 .maxlen
= sizeof (int),
763 .proc_handler
= sysrq_sysctl_handler
,
766 #ifdef CONFIG_PROC_SYSCTL
768 .procname
= "cad_pid",
770 .maxlen
= sizeof (int),
772 .proc_handler
= proc_do_cad_pid
,
776 .procname
= "threads-max",
778 .maxlen
= sizeof(int),
780 .proc_handler
= sysctl_max_threads
,
783 .procname
= "random",
785 .child
= random_table
,
788 .procname
= "usermodehelper",
790 .child
= usermodehelper_table
,
793 .procname
= "overflowuid",
794 .data
= &overflowuid
,
795 .maxlen
= sizeof(int),
797 .proc_handler
= proc_dointvec_minmax
,
798 .extra1
= &minolduid
,
799 .extra2
= &maxolduid
,
802 .procname
= "overflowgid",
803 .data
= &overflowgid
,
804 .maxlen
= sizeof(int),
806 .proc_handler
= proc_dointvec_minmax
,
807 .extra1
= &minolduid
,
808 .extra2
= &maxolduid
,
811 #ifdef CONFIG_MATHEMU
813 .procname
= "ieee_emulation_warnings",
814 .data
= &sysctl_ieee_emulation_warnings
,
815 .maxlen
= sizeof(int),
817 .proc_handler
= proc_dointvec
,
821 .procname
= "userprocess_debug",
822 .data
= &show_unhandled_signals
,
823 .maxlen
= sizeof(int),
825 .proc_handler
= proc_dointvec
,
829 .procname
= "pid_max",
831 .maxlen
= sizeof (int),
833 .proc_handler
= proc_dointvec_minmax
,
834 .extra1
= &pid_max_min
,
835 .extra2
= &pid_max_max
,
838 .procname
= "panic_on_oops",
839 .data
= &panic_on_oops
,
840 .maxlen
= sizeof(int),
842 .proc_handler
= proc_dointvec
,
844 #if defined CONFIG_PRINTK
846 .procname
= "printk",
847 .data
= &console_loglevel
,
848 .maxlen
= 4*sizeof(int),
850 .proc_handler
= proc_dointvec
,
853 .procname
= "printk_ratelimit",
854 .data
= &printk_ratelimit_state
.interval
,
855 .maxlen
= sizeof(int),
857 .proc_handler
= proc_dointvec_jiffies
,
860 .procname
= "printk_ratelimit_burst",
861 .data
= &printk_ratelimit_state
.burst
,
862 .maxlen
= sizeof(int),
864 .proc_handler
= proc_dointvec
,
867 .procname
= "printk_delay",
868 .data
= &printk_delay_msec
,
869 .maxlen
= sizeof(int),
871 .proc_handler
= proc_dointvec_minmax
,
873 .extra2
= &ten_thousand
,
876 .procname
= "printk_devkmsg",
877 .data
= devkmsg_log_str
,
878 .maxlen
= DEVKMSG_STR_MAX_SIZE
,
880 .proc_handler
= devkmsg_sysctl_set_loglvl
,
883 .procname
= "dmesg_restrict",
884 .data
= &dmesg_restrict
,
885 .maxlen
= sizeof(int),
887 .proc_handler
= proc_dointvec_minmax_sysadmin
,
892 .procname
= "kptr_restrict",
893 .data
= &kptr_restrict
,
894 .maxlen
= sizeof(int),
896 .proc_handler
= proc_dointvec_minmax_sysadmin
,
902 .procname
= "ngroups_max",
903 .data
= &ngroups_max
,
904 .maxlen
= sizeof (int),
906 .proc_handler
= proc_dointvec
,
909 .procname
= "cap_last_cap",
910 .data
= (void *)&cap_last_cap
,
911 .maxlen
= sizeof(int),
913 .proc_handler
= proc_dointvec
,
915 #if defined(CONFIG_LOCKUP_DETECTOR)
917 .procname
= "watchdog",
918 .data
= &watchdog_user_enabled
,
919 .maxlen
= sizeof(int),
921 .proc_handler
= proc_watchdog
,
926 .procname
= "watchdog_thresh",
927 .data
= &watchdog_thresh
,
928 .maxlen
= sizeof(int),
930 .proc_handler
= proc_watchdog_thresh
,
935 .procname
= "nmi_watchdog",
936 .data
= &nmi_watchdog_user_enabled
,
937 .maxlen
= sizeof(int),
938 .mode
= NMI_WATCHDOG_SYSCTL_PERM
,
939 .proc_handler
= proc_nmi_watchdog
,
944 .procname
= "watchdog_cpumask",
945 .data
= &watchdog_cpumask_bits
,
948 .proc_handler
= proc_watchdog_cpumask
,
950 #ifdef CONFIG_SOFTLOCKUP_DETECTOR
952 .procname
= "soft_watchdog",
953 .data
= &soft_watchdog_user_enabled
,
954 .maxlen
= sizeof(int),
956 .proc_handler
= proc_soft_watchdog
,
961 .procname
= "softlockup_panic",
962 .data
= &softlockup_panic
,
963 .maxlen
= sizeof(int),
965 .proc_handler
= proc_dointvec_minmax
,
971 .procname
= "softlockup_all_cpu_backtrace",
972 .data
= &sysctl_softlockup_all_cpu_backtrace
,
973 .maxlen
= sizeof(int),
975 .proc_handler
= proc_dointvec_minmax
,
979 #endif /* CONFIG_SMP */
981 #ifdef CONFIG_HARDLOCKUP_DETECTOR
983 .procname
= "hardlockup_panic",
984 .data
= &hardlockup_panic
,
985 .maxlen
= sizeof(int),
987 .proc_handler
= proc_dointvec_minmax
,
993 .procname
= "hardlockup_all_cpu_backtrace",
994 .data
= &sysctl_hardlockup_all_cpu_backtrace
,
995 .maxlen
= sizeof(int),
997 .proc_handler
= proc_dointvec_minmax
,
1001 #endif /* CONFIG_SMP */
1005 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
1007 .procname
= "unknown_nmi_panic",
1008 .data
= &unknown_nmi_panic
,
1009 .maxlen
= sizeof (int),
1011 .proc_handler
= proc_dointvec
,
1014 #if defined(CONFIG_X86)
1016 .procname
= "panic_on_unrecovered_nmi",
1017 .data
= &panic_on_unrecovered_nmi
,
1018 .maxlen
= sizeof(int),
1020 .proc_handler
= proc_dointvec
,
1023 .procname
= "panic_on_io_nmi",
1024 .data
= &panic_on_io_nmi
,
1025 .maxlen
= sizeof(int),
1027 .proc_handler
= proc_dointvec
,
1029 #ifdef CONFIG_DEBUG_STACKOVERFLOW
1031 .procname
= "panic_on_stackoverflow",
1032 .data
= &sysctl_panic_on_stackoverflow
,
1033 .maxlen
= sizeof(int),
1035 .proc_handler
= proc_dointvec
,
1039 .procname
= "bootloader_type",
1040 .data
= &bootloader_type
,
1041 .maxlen
= sizeof (int),
1043 .proc_handler
= proc_dointvec
,
1046 .procname
= "bootloader_version",
1047 .data
= &bootloader_version
,
1048 .maxlen
= sizeof (int),
1050 .proc_handler
= proc_dointvec
,
1053 .procname
= "io_delay_type",
1054 .data
= &io_delay_type
,
1055 .maxlen
= sizeof(int),
1057 .proc_handler
= proc_dointvec
,
1060 #if defined(CONFIG_MMU)
1062 .procname
= "randomize_va_space",
1063 .data
= &randomize_va_space
,
1064 .maxlen
= sizeof(int),
1066 .proc_handler
= proc_dointvec
,
1069 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1071 .procname
= "spin_retry",
1072 .data
= &spin_retry
,
1073 .maxlen
= sizeof (int),
1075 .proc_handler
= proc_dointvec
,
1078 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1080 .procname
= "acpi_video_flags",
1081 .data
= &acpi_realmode_flags
,
1082 .maxlen
= sizeof (unsigned long),
1084 .proc_handler
= proc_doulongvec_minmax
,
1087 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1089 .procname
= "ignore-unaligned-usertrap",
1090 .data
= &no_unaligned_warning
,
1091 .maxlen
= sizeof (int),
1093 .proc_handler
= proc_dointvec
,
1098 .procname
= "unaligned-dump-stack",
1099 .data
= &unaligned_dump_stack
,
1100 .maxlen
= sizeof (int),
1102 .proc_handler
= proc_dointvec
,
1105 #ifdef CONFIG_DETECT_HUNG_TASK
1107 .procname
= "hung_task_panic",
1108 .data
= &sysctl_hung_task_panic
,
1109 .maxlen
= sizeof(int),
1111 .proc_handler
= proc_dointvec_minmax
,
1116 .procname
= "hung_task_check_count",
1117 .data
= &sysctl_hung_task_check_count
,
1118 .maxlen
= sizeof(int),
1120 .proc_handler
= proc_dointvec_minmax
,
1124 .procname
= "hung_task_timeout_secs",
1125 .data
= &sysctl_hung_task_timeout_secs
,
1126 .maxlen
= sizeof(unsigned long),
1128 .proc_handler
= proc_dohung_task_timeout_secs
,
1129 .extra2
= &hung_task_timeout_max
,
1132 .procname
= "hung_task_warnings",
1133 .data
= &sysctl_hung_task_warnings
,
1134 .maxlen
= sizeof(int),
1136 .proc_handler
= proc_dointvec_minmax
,
1140 #ifdef CONFIG_RT_MUTEXES
1142 .procname
= "max_lock_depth",
1143 .data
= &max_lock_depth
,
1144 .maxlen
= sizeof(int),
1146 .proc_handler
= proc_dointvec
,
1150 .procname
= "poweroff_cmd",
1151 .data
= &poweroff_cmd
,
1152 .maxlen
= POWEROFF_CMD_PATH_LEN
,
1154 .proc_handler
= proc_dostring
,
1160 .child
= key_sysctls
,
1163 #ifdef CONFIG_PERF_EVENTS
1165 * User-space scripts rely on the existence of this file
1166 * as a feature check for perf_events being enabled.
1168 * So it's an ABI, do not remove!
1171 .procname
= "perf_event_paranoid",
1172 .data
= &sysctl_perf_event_paranoid
,
1173 .maxlen
= sizeof(sysctl_perf_event_paranoid
),
1175 .proc_handler
= proc_dointvec
,
1178 .procname
= "perf_event_mlock_kb",
1179 .data
= &sysctl_perf_event_mlock
,
1180 .maxlen
= sizeof(sysctl_perf_event_mlock
),
1182 .proc_handler
= proc_dointvec
,
1185 .procname
= "perf_event_max_sample_rate",
1186 .data
= &sysctl_perf_event_sample_rate
,
1187 .maxlen
= sizeof(sysctl_perf_event_sample_rate
),
1189 .proc_handler
= perf_proc_update_handler
,
1193 .procname
= "perf_cpu_time_max_percent",
1194 .data
= &sysctl_perf_cpu_time_max_percent
,
1195 .maxlen
= sizeof(sysctl_perf_cpu_time_max_percent
),
1197 .proc_handler
= perf_cpu_time_max_percent_handler
,
1199 .extra2
= &one_hundred
,
1202 .procname
= "perf_event_max_stack",
1203 .data
= &sysctl_perf_event_max_stack
,
1204 .maxlen
= sizeof(sysctl_perf_event_max_stack
),
1206 .proc_handler
= perf_event_max_stack_handler
,
1208 .extra2
= &six_hundred_forty_kb
,
1211 .procname
= "perf_event_max_contexts_per_stack",
1212 .data
= &sysctl_perf_event_max_contexts_per_stack
,
1213 .maxlen
= sizeof(sysctl_perf_event_max_contexts_per_stack
),
1215 .proc_handler
= perf_event_max_stack_handler
,
1217 .extra2
= &one_thousand
,
1221 .procname
= "panic_on_warn",
1222 .data
= &panic_on_warn
,
1223 .maxlen
= sizeof(int),
1225 .proc_handler
= proc_dointvec_minmax
,
1229 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1231 .procname
= "timer_migration",
1232 .data
= &sysctl_timer_migration
,
1233 .maxlen
= sizeof(unsigned int),
1235 .proc_handler
= timer_migration_handler
,
1240 #ifdef CONFIG_BPF_SYSCALL
1242 .procname
= "unprivileged_bpf_disabled",
1243 .data
= &sysctl_unprivileged_bpf_disabled
,
1244 .maxlen
= sizeof(sysctl_unprivileged_bpf_disabled
),
1246 /* only handle a transition from default "0" to "1" */
1247 .proc_handler
= proc_dointvec_minmax
,
1252 #if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1254 .procname
= "panic_on_rcu_stall",
1255 .data
= &sysctl_panic_on_rcu_stall
,
1256 .maxlen
= sizeof(sysctl_panic_on_rcu_stall
),
1258 .proc_handler
= proc_dointvec_minmax
,
1266 static struct ctl_table vm_table
[] = {
1268 .procname
= "overcommit_memory",
1269 .data
= &sysctl_overcommit_memory
,
1270 .maxlen
= sizeof(sysctl_overcommit_memory
),
1272 .proc_handler
= proc_dointvec_minmax
,
1277 .procname
= "panic_on_oom",
1278 .data
= &sysctl_panic_on_oom
,
1279 .maxlen
= sizeof(sysctl_panic_on_oom
),
1281 .proc_handler
= proc_dointvec_minmax
,
1286 .procname
= "oom_kill_allocating_task",
1287 .data
= &sysctl_oom_kill_allocating_task
,
1288 .maxlen
= sizeof(sysctl_oom_kill_allocating_task
),
1290 .proc_handler
= proc_dointvec
,
1293 .procname
= "oom_dump_tasks",
1294 .data
= &sysctl_oom_dump_tasks
,
1295 .maxlen
= sizeof(sysctl_oom_dump_tasks
),
1297 .proc_handler
= proc_dointvec
,
1300 .procname
= "overcommit_ratio",
1301 .data
= &sysctl_overcommit_ratio
,
1302 .maxlen
= sizeof(sysctl_overcommit_ratio
),
1304 .proc_handler
= overcommit_ratio_handler
,
1307 .procname
= "overcommit_kbytes",
1308 .data
= &sysctl_overcommit_kbytes
,
1309 .maxlen
= sizeof(sysctl_overcommit_kbytes
),
1311 .proc_handler
= overcommit_kbytes_handler
,
1314 .procname
= "page-cluster",
1315 .data
= &page_cluster
,
1316 .maxlen
= sizeof(int),
1318 .proc_handler
= proc_dointvec_minmax
,
1322 .procname
= "dirty_background_ratio",
1323 .data
= &dirty_background_ratio
,
1324 .maxlen
= sizeof(dirty_background_ratio
),
1326 .proc_handler
= dirty_background_ratio_handler
,
1328 .extra2
= &one_hundred
,
1331 .procname
= "dirty_background_bytes",
1332 .data
= &dirty_background_bytes
,
1333 .maxlen
= sizeof(dirty_background_bytes
),
1335 .proc_handler
= dirty_background_bytes_handler
,
1339 .procname
= "dirty_ratio",
1340 .data
= &vm_dirty_ratio
,
1341 .maxlen
= sizeof(vm_dirty_ratio
),
1343 .proc_handler
= dirty_ratio_handler
,
1345 .extra2
= &one_hundred
,
1348 .procname
= "dirty_bytes",
1349 .data
= &vm_dirty_bytes
,
1350 .maxlen
= sizeof(vm_dirty_bytes
),
1352 .proc_handler
= dirty_bytes_handler
,
1353 .extra1
= &dirty_bytes_min
,
1356 .procname
= "dirty_writeback_centisecs",
1357 .data
= &dirty_writeback_interval
,
1358 .maxlen
= sizeof(dirty_writeback_interval
),
1360 .proc_handler
= dirty_writeback_centisecs_handler
,
1363 .procname
= "dirty_expire_centisecs",
1364 .data
= &dirty_expire_interval
,
1365 .maxlen
= sizeof(dirty_expire_interval
),
1367 .proc_handler
= proc_dointvec_minmax
,
1371 .procname
= "dirtytime_expire_seconds",
1372 .data
= &dirtytime_expire_interval
,
1373 .maxlen
= sizeof(dirty_expire_interval
),
1375 .proc_handler
= dirtytime_interval_handler
,
1379 .procname
= "nr_pdflush_threads",
1380 .mode
= 0444 /* read-only */,
1381 .proc_handler
= pdflush_proc_obsolete
,
1384 .procname
= "swappiness",
1385 .data
= &vm_swappiness
,
1386 .maxlen
= sizeof(vm_swappiness
),
1388 .proc_handler
= proc_dointvec_minmax
,
1390 .extra2
= &one_hundred
,
1392 #ifdef CONFIG_HUGETLB_PAGE
1394 .procname
= "nr_hugepages",
1396 .maxlen
= sizeof(unsigned long),
1398 .proc_handler
= hugetlb_sysctl_handler
,
1402 .procname
= "nr_hugepages_mempolicy",
1404 .maxlen
= sizeof(unsigned long),
1406 .proc_handler
= &hugetlb_mempolicy_sysctl_handler
,
1410 .procname
= "hugetlb_shm_group",
1411 .data
= &sysctl_hugetlb_shm_group
,
1412 .maxlen
= sizeof(gid_t
),
1414 .proc_handler
= proc_dointvec
,
1417 .procname
= "hugepages_treat_as_movable",
1418 .data
= &hugepages_treat_as_movable
,
1419 .maxlen
= sizeof(int),
1421 .proc_handler
= proc_dointvec
,
1424 .procname
= "nr_overcommit_hugepages",
1426 .maxlen
= sizeof(unsigned long),
1428 .proc_handler
= hugetlb_overcommit_handler
,
1432 .procname
= "lowmem_reserve_ratio",
1433 .data
= &sysctl_lowmem_reserve_ratio
,
1434 .maxlen
= sizeof(sysctl_lowmem_reserve_ratio
),
1436 .proc_handler
= lowmem_reserve_ratio_sysctl_handler
,
1439 .procname
= "drop_caches",
1440 .data
= &sysctl_drop_caches
,
1441 .maxlen
= sizeof(int),
1443 .proc_handler
= drop_caches_sysctl_handler
,
1447 #ifdef CONFIG_COMPACTION
1449 .procname
= "compact_memory",
1450 .data
= &sysctl_compact_memory
,
1451 .maxlen
= sizeof(int),
1453 .proc_handler
= sysctl_compaction_handler
,
1456 .procname
= "extfrag_threshold",
1457 .data
= &sysctl_extfrag_threshold
,
1458 .maxlen
= sizeof(int),
1460 .proc_handler
= sysctl_extfrag_handler
,
1461 .extra1
= &min_extfrag_threshold
,
1462 .extra2
= &max_extfrag_threshold
,
1465 .procname
= "compact_unevictable_allowed",
1466 .data
= &sysctl_compact_unevictable_allowed
,
1467 .maxlen
= sizeof(int),
1469 .proc_handler
= proc_dointvec
,
1474 #endif /* CONFIG_COMPACTION */
1476 .procname
= "min_free_kbytes",
1477 .data
= &min_free_kbytes
,
1478 .maxlen
= sizeof(min_free_kbytes
),
1480 .proc_handler
= min_free_kbytes_sysctl_handler
,
1484 .procname
= "watermark_scale_factor",
1485 .data
= &watermark_scale_factor
,
1486 .maxlen
= sizeof(watermark_scale_factor
),
1488 .proc_handler
= watermark_scale_factor_sysctl_handler
,
1490 .extra2
= &one_thousand
,
1493 .procname
= "percpu_pagelist_fraction",
1494 .data
= &percpu_pagelist_fraction
,
1495 .maxlen
= sizeof(percpu_pagelist_fraction
),
1497 .proc_handler
= percpu_pagelist_fraction_sysctl_handler
,
1502 .procname
= "max_map_count",
1503 .data
= &sysctl_max_map_count
,
1504 .maxlen
= sizeof(sysctl_max_map_count
),
1506 .proc_handler
= proc_dointvec_minmax
,
1511 .procname
= "nr_trim_pages",
1512 .data
= &sysctl_nr_trim_pages
,
1513 .maxlen
= sizeof(sysctl_nr_trim_pages
),
1515 .proc_handler
= proc_dointvec_minmax
,
1520 .procname
= "laptop_mode",
1521 .data
= &laptop_mode
,
1522 .maxlen
= sizeof(laptop_mode
),
1524 .proc_handler
= proc_dointvec_jiffies
,
1527 .procname
= "block_dump",
1528 .data
= &block_dump
,
1529 .maxlen
= sizeof(block_dump
),
1531 .proc_handler
= proc_dointvec
,
1535 .procname
= "vfs_cache_pressure",
1536 .data
= &sysctl_vfs_cache_pressure
,
1537 .maxlen
= sizeof(sysctl_vfs_cache_pressure
),
1539 .proc_handler
= proc_dointvec
,
1542 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1544 .procname
= "legacy_va_layout",
1545 .data
= &sysctl_legacy_va_layout
,
1546 .maxlen
= sizeof(sysctl_legacy_va_layout
),
1548 .proc_handler
= proc_dointvec
,
1554 .procname
= "zone_reclaim_mode",
1555 .data
= &node_reclaim_mode
,
1556 .maxlen
= sizeof(node_reclaim_mode
),
1558 .proc_handler
= proc_dointvec
,
1562 .procname
= "min_unmapped_ratio",
1563 .data
= &sysctl_min_unmapped_ratio
,
1564 .maxlen
= sizeof(sysctl_min_unmapped_ratio
),
1566 .proc_handler
= sysctl_min_unmapped_ratio_sysctl_handler
,
1568 .extra2
= &one_hundred
,
1571 .procname
= "min_slab_ratio",
1572 .data
= &sysctl_min_slab_ratio
,
1573 .maxlen
= sizeof(sysctl_min_slab_ratio
),
1575 .proc_handler
= sysctl_min_slab_ratio_sysctl_handler
,
1577 .extra2
= &one_hundred
,
1582 .procname
= "stat_interval",
1583 .data
= &sysctl_stat_interval
,
1584 .maxlen
= sizeof(sysctl_stat_interval
),
1586 .proc_handler
= proc_dointvec_jiffies
,
1589 .procname
= "stat_refresh",
1593 .proc_handler
= vmstat_refresh
,
1598 .procname
= "mmap_min_addr",
1599 .data
= &dac_mmap_min_addr
,
1600 .maxlen
= sizeof(unsigned long),
1602 .proc_handler
= mmap_min_addr_handler
,
1607 .procname
= "numa_zonelist_order",
1608 .data
= &numa_zonelist_order
,
1609 .maxlen
= NUMA_ZONELIST_ORDER_LEN
,
1611 .proc_handler
= numa_zonelist_order_handler
,
1614 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1615 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1617 .procname
= "vdso_enabled",
1618 #ifdef CONFIG_X86_32
1619 .data
= &vdso32_enabled
,
1620 .maxlen
= sizeof(vdso32_enabled
),
1622 .data
= &vdso_enabled
,
1623 .maxlen
= sizeof(vdso_enabled
),
1626 .proc_handler
= proc_dointvec
,
1630 #ifdef CONFIG_HIGHMEM
1632 .procname
= "highmem_is_dirtyable",
1633 .data
= &vm_highmem_is_dirtyable
,
1634 .maxlen
= sizeof(vm_highmem_is_dirtyable
),
1636 .proc_handler
= proc_dointvec_minmax
,
1641 #ifdef CONFIG_MEMORY_FAILURE
1643 .procname
= "memory_failure_early_kill",
1644 .data
= &sysctl_memory_failure_early_kill
,
1645 .maxlen
= sizeof(sysctl_memory_failure_early_kill
),
1647 .proc_handler
= proc_dointvec_minmax
,
1652 .procname
= "memory_failure_recovery",
1653 .data
= &sysctl_memory_failure_recovery
,
1654 .maxlen
= sizeof(sysctl_memory_failure_recovery
),
1656 .proc_handler
= proc_dointvec_minmax
,
1662 .procname
= "user_reserve_kbytes",
1663 .data
= &sysctl_user_reserve_kbytes
,
1664 .maxlen
= sizeof(sysctl_user_reserve_kbytes
),
1666 .proc_handler
= proc_doulongvec_minmax
,
1669 .procname
= "admin_reserve_kbytes",
1670 .data
= &sysctl_admin_reserve_kbytes
,
1671 .maxlen
= sizeof(sysctl_admin_reserve_kbytes
),
1673 .proc_handler
= proc_doulongvec_minmax
,
1675 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1677 .procname
= "mmap_rnd_bits",
1678 .data
= &mmap_rnd_bits
,
1679 .maxlen
= sizeof(mmap_rnd_bits
),
1681 .proc_handler
= proc_dointvec_minmax
,
1682 .extra1
= (void *)&mmap_rnd_bits_min
,
1683 .extra2
= (void *)&mmap_rnd_bits_max
,
1686 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1688 .procname
= "mmap_rnd_compat_bits",
1689 .data
= &mmap_rnd_compat_bits
,
1690 .maxlen
= sizeof(mmap_rnd_compat_bits
),
1692 .proc_handler
= proc_dointvec_minmax
,
1693 .extra1
= (void *)&mmap_rnd_compat_bits_min
,
1694 .extra2
= (void *)&mmap_rnd_compat_bits_max
,
1700 static struct ctl_table fs_table
[] = {
1702 .procname
= "inode-nr",
1703 .data
= &inodes_stat
,
1704 .maxlen
= 2*sizeof(long),
1706 .proc_handler
= proc_nr_inodes
,
1709 .procname
= "inode-state",
1710 .data
= &inodes_stat
,
1711 .maxlen
= 7*sizeof(long),
1713 .proc_handler
= proc_nr_inodes
,
1716 .procname
= "file-nr",
1717 .data
= &files_stat
,
1718 .maxlen
= sizeof(files_stat
),
1720 .proc_handler
= proc_nr_files
,
1723 .procname
= "file-max",
1724 .data
= &files_stat
.max_files
,
1725 .maxlen
= sizeof(files_stat
.max_files
),
1727 .proc_handler
= proc_doulongvec_minmax
,
1730 .procname
= "nr_open",
1731 .data
= &sysctl_nr_open
,
1732 .maxlen
= sizeof(unsigned int),
1734 .proc_handler
= proc_dointvec_minmax
,
1735 .extra1
= &sysctl_nr_open_min
,
1736 .extra2
= &sysctl_nr_open_max
,
1739 .procname
= "dentry-state",
1740 .data
= &dentry_stat
,
1741 .maxlen
= 6*sizeof(long),
1743 .proc_handler
= proc_nr_dentry
,
1746 .procname
= "overflowuid",
1747 .data
= &fs_overflowuid
,
1748 .maxlen
= sizeof(int),
1750 .proc_handler
= proc_dointvec_minmax
,
1751 .extra1
= &minolduid
,
1752 .extra2
= &maxolduid
,
1755 .procname
= "overflowgid",
1756 .data
= &fs_overflowgid
,
1757 .maxlen
= sizeof(int),
1759 .proc_handler
= proc_dointvec_minmax
,
1760 .extra1
= &minolduid
,
1761 .extra2
= &maxolduid
,
1763 #ifdef CONFIG_FILE_LOCKING
1765 .procname
= "leases-enable",
1766 .data
= &leases_enable
,
1767 .maxlen
= sizeof(int),
1769 .proc_handler
= proc_dointvec
,
1772 #ifdef CONFIG_DNOTIFY
1774 .procname
= "dir-notify-enable",
1775 .data
= &dir_notify_enable
,
1776 .maxlen
= sizeof(int),
1778 .proc_handler
= proc_dointvec
,
1782 #ifdef CONFIG_FILE_LOCKING
1784 .procname
= "lease-break-time",
1785 .data
= &lease_break_time
,
1786 .maxlen
= sizeof(int),
1788 .proc_handler
= proc_dointvec
,
1793 .procname
= "aio-nr",
1795 .maxlen
= sizeof(aio_nr
),
1797 .proc_handler
= proc_doulongvec_minmax
,
1800 .procname
= "aio-max-nr",
1801 .data
= &aio_max_nr
,
1802 .maxlen
= sizeof(aio_max_nr
),
1804 .proc_handler
= proc_doulongvec_minmax
,
1806 #endif /* CONFIG_AIO */
1807 #ifdef CONFIG_INOTIFY_USER
1809 .procname
= "inotify",
1811 .child
= inotify_table
,
1816 .procname
= "epoll",
1818 .child
= epoll_table
,
1823 .procname
= "protected_symlinks",
1824 .data
= &sysctl_protected_symlinks
,
1825 .maxlen
= sizeof(int),
1827 .proc_handler
= proc_dointvec_minmax
,
1832 .procname
= "protected_hardlinks",
1833 .data
= &sysctl_protected_hardlinks
,
1834 .maxlen
= sizeof(int),
1836 .proc_handler
= proc_dointvec_minmax
,
1841 .procname
= "suid_dumpable",
1842 .data
= &suid_dumpable
,
1843 .maxlen
= sizeof(int),
1845 .proc_handler
= proc_dointvec_minmax_coredump
,
1849 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1851 .procname
= "binfmt_misc",
1853 .child
= sysctl_mount_point
,
1857 .procname
= "pipe-max-size",
1858 .data
= &pipe_max_size
,
1859 .maxlen
= sizeof(pipe_max_size
),
1861 .proc_handler
= &pipe_proc_fn
,
1862 .extra1
= &pipe_min_size
,
1865 .procname
= "pipe-user-pages-hard",
1866 .data
= &pipe_user_pages_hard
,
1867 .maxlen
= sizeof(pipe_user_pages_hard
),
1869 .proc_handler
= proc_doulongvec_minmax
,
1872 .procname
= "pipe-user-pages-soft",
1873 .data
= &pipe_user_pages_soft
,
1874 .maxlen
= sizeof(pipe_user_pages_soft
),
1876 .proc_handler
= proc_doulongvec_minmax
,
1879 .procname
= "mount-max",
1880 .data
= &sysctl_mount_max
,
1881 .maxlen
= sizeof(unsigned int),
1883 .proc_handler
= proc_dointvec_minmax
,
1889 static struct ctl_table debug_table
[] = {
1890 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
1892 .procname
= "exception-trace",
1893 .data
= &show_unhandled_signals
,
1894 .maxlen
= sizeof(int),
1896 .proc_handler
= proc_dointvec
1899 #if defined(CONFIG_OPTPROBES)
1901 .procname
= "kprobes-optimization",
1902 .data
= &sysctl_kprobes_optimization
,
1903 .maxlen
= sizeof(int),
1905 .proc_handler
= proc_kprobes_optimization_handler
,
1913 static struct ctl_table dev_table
[] = {
1917 int __init
sysctl_init(void)
1919 struct ctl_table_header
*hdr
;
1921 hdr
= register_sysctl_table(sysctl_base_table
);
1922 kmemleak_not_leak(hdr
);
1926 #endif /* CONFIG_SYSCTL */
1932 #ifdef CONFIG_PROC_SYSCTL
1934 static int _proc_do_string(char *data
, int maxlen
, int write
,
1935 char __user
*buffer
,
1936 size_t *lenp
, loff_t
*ppos
)
1942 if (!data
|| !maxlen
|| !*lenp
) {
1948 if (sysctl_writes_strict
== SYSCTL_WRITES_STRICT
) {
1949 /* Only continue writes not past the end of buffer. */
1951 if (len
> maxlen
- 1)
1958 /* Start writing from beginning of buffer. */
1964 while ((p
- buffer
) < *lenp
&& len
< maxlen
- 1) {
1965 if (get_user(c
, p
++))
1967 if (c
== 0 || c
== '\n')
1988 if (copy_to_user(buffer
, data
, len
))
1991 if (put_user('\n', buffer
+ len
))
2001 static void warn_sysctl_write(struct ctl_table
*table
)
2003 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2004 "This will not be supported in the future. To silence this\n"
2005 "warning, set kernel.sysctl_writes_strict = -1\n",
2006 current
->comm
, table
->procname
);
2010 * proc_first_pos_non_zero_ignore - check if firs position is allowed
2011 * @ppos: file position
2012 * @table: the sysctl table
2014 * Returns true if the first position is non-zero and the sysctl_writes_strict
2015 * mode indicates this is not allowed for numeric input types. String proc
2016 * hadlers can ignore the return value.
2018 static bool proc_first_pos_non_zero_ignore(loff_t
*ppos
,
2019 struct ctl_table
*table
)
2024 switch (sysctl_writes_strict
) {
2025 case SYSCTL_WRITES_STRICT
:
2027 case SYSCTL_WRITES_WARN
:
2028 warn_sysctl_write(table
);
2036 * proc_dostring - read a string sysctl
2037 * @table: the sysctl table
2038 * @write: %TRUE if this is a write to the sysctl file
2039 * @buffer: the user buffer
2040 * @lenp: the size of the user buffer
2041 * @ppos: file position
2043 * Reads/writes a string from/to the user buffer. If the kernel
2044 * buffer provided is not large enough to hold the string, the
2045 * string is truncated. The copied string is %NULL-terminated.
2046 * If the string is being read by the user process, it is copied
2047 * and a newline '\n' is added. It is truncated if the buffer is
2050 * Returns 0 on success.
2052 int proc_dostring(struct ctl_table
*table
, int write
,
2053 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2056 proc_first_pos_non_zero_ignore(ppos
, table
);
2058 return _proc_do_string((char *)(table
->data
), table
->maxlen
, write
,
2059 (char __user
*)buffer
, lenp
, ppos
);
2062 static size_t proc_skip_spaces(char **buf
)
2065 char *tmp
= skip_spaces(*buf
);
2071 static void proc_skip_char(char **buf
, size_t *size
, const char v
)
2081 #define TMPBUFLEN 22
2083 * proc_get_long - reads an ASCII formatted integer from a user buffer
2085 * @buf: a kernel buffer
2086 * @size: size of the kernel buffer
2087 * @val: this is where the number will be stored
2088 * @neg: set to %TRUE if number is negative
2089 * @perm_tr: a vector which contains the allowed trailers
2090 * @perm_tr_len: size of the perm_tr vector
2091 * @tr: pointer to store the trailer character
2093 * In case of success %0 is returned and @buf and @size are updated with
2094 * the amount of bytes read. If @tr is non-NULL and a trailing
2095 * character exists (size is non-zero after returning from this
2096 * function), @tr is updated with the trailing character.
2098 static int proc_get_long(char **buf
, size_t *size
,
2099 unsigned long *val
, bool *neg
,
2100 const char *perm_tr
, unsigned perm_tr_len
, char *tr
)
2103 char *p
, tmp
[TMPBUFLEN
];
2109 if (len
> TMPBUFLEN
- 1)
2110 len
= TMPBUFLEN
- 1;
2112 memcpy(tmp
, *buf
, len
);
2116 if (*p
== '-' && *size
> 1) {
2124 *val
= simple_strtoul(p
, &p
, 0);
2128 /* We don't know if the next char is whitespace thus we may accept
2129 * invalid integers (e.g. 1234...a) or two integers instead of one
2130 * (e.g. 123...1). So lets not allow such large numbers. */
2131 if (len
== TMPBUFLEN
- 1)
2134 if (len
< *size
&& perm_tr_len
&& !memchr(perm_tr
, *p
, perm_tr_len
))
2137 if (tr
&& (len
< *size
))
2147 * proc_put_long - converts an integer to a decimal ASCII formatted string
2149 * @buf: the user buffer
2150 * @size: the size of the user buffer
2151 * @val: the integer to be converted
2152 * @neg: sign of the number, %TRUE for negative
2154 * In case of success %0 is returned and @buf and @size are updated with
2155 * the amount of bytes written.
2157 static int proc_put_long(void __user
**buf
, size_t *size
, unsigned long val
,
2161 char tmp
[TMPBUFLEN
], *p
= tmp
;
2163 sprintf(p
, "%s%lu", neg
? "-" : "", val
);
2167 if (copy_to_user(*buf
, tmp
, len
))
2175 static int proc_put_char(void __user
**buf
, size_t *size
, char c
)
2178 char __user
**buffer
= (char __user
**)buf
;
2179 if (put_user(c
, *buffer
))
2181 (*size
)--, (*buffer
)++;
2187 static int do_proc_dointvec_conv(bool *negp
, unsigned long *lvalp
,
2189 int write
, void *data
)
2193 if (*lvalp
> (unsigned long) INT_MAX
+ 1)
2197 if (*lvalp
> (unsigned long) INT_MAX
)
2205 *lvalp
= -(unsigned long)val
;
2208 *lvalp
= (unsigned long)val
;
2214 static int do_proc_douintvec_conv(unsigned long *lvalp
,
2216 int write
, void *data
)
2219 if (*lvalp
> UINT_MAX
)
2223 unsigned int val
= *valp
;
2224 *lvalp
= (unsigned long)val
;
2229 static const char proc_wspace_sep
[] = { ' ', '\t', '\n' };
2231 static int __do_proc_dointvec(void *tbl_data
, struct ctl_table
*table
,
2232 int write
, void __user
*buffer
,
2233 size_t *lenp
, loff_t
*ppos
,
2234 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2235 int write
, void *data
),
2238 int *i
, vleft
, first
= 1, err
= 0;
2240 char *kbuf
= NULL
, *p
;
2242 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2247 i
= (int *) tbl_data
;
2248 vleft
= table
->maxlen
/ sizeof(*i
);
2252 conv
= do_proc_dointvec_conv
;
2255 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2258 if (left
> PAGE_SIZE
- 1)
2259 left
= PAGE_SIZE
- 1;
2260 p
= kbuf
= memdup_user_nul(buffer
, left
);
2262 return PTR_ERR(kbuf
);
2265 for (; left
&& vleft
--; i
++, first
=0) {
2270 left
-= proc_skip_spaces(&p
);
2274 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2276 sizeof(proc_wspace_sep
), NULL
);
2279 if (conv(&neg
, &lval
, i
, 1, data
)) {
2284 if (conv(&neg
, &lval
, i
, 0, data
)) {
2289 err
= proc_put_char(&buffer
, &left
, '\t');
2292 err
= proc_put_long(&buffer
, &left
, lval
, neg
);
2298 if (!write
&& !first
&& left
&& !err
)
2299 err
= proc_put_char(&buffer
, &left
, '\n');
2300 if (write
&& !err
&& left
)
2301 left
-= proc_skip_spaces(&p
);
2305 return err
? : -EINVAL
;
2313 static int do_proc_dointvec(struct ctl_table
*table
, int write
,
2314 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2315 int (*conv
)(bool *negp
, unsigned long *lvalp
, int *valp
,
2316 int write
, void *data
),
2319 return __do_proc_dointvec(table
->data
, table
, write
,
2320 buffer
, lenp
, ppos
, conv
, data
);
2323 static int do_proc_douintvec_w(unsigned int *tbl_data
,
2324 struct ctl_table
*table
,
2325 void __user
*buffer
,
2326 size_t *lenp
, loff_t
*ppos
,
2327 int (*conv
)(unsigned long *lvalp
,
2329 int write
, void *data
),
2336 char *kbuf
= NULL
, *p
;
2340 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2343 if (left
> PAGE_SIZE
- 1)
2344 left
= PAGE_SIZE
- 1;
2346 p
= kbuf
= memdup_user_nul(buffer
, left
);
2350 left
-= proc_skip_spaces(&p
);
2356 err
= proc_get_long(&p
, &left
, &lval
, &neg
,
2358 sizeof(proc_wspace_sep
), NULL
);
2364 if (conv(&lval
, tbl_data
, 1, data
)) {
2370 left
-= proc_skip_spaces(&p
);
2379 /* This is in keeping with old __do_proc_dointvec() */
2385 static int do_proc_douintvec_r(unsigned int *tbl_data
, void __user
*buffer
,
2386 size_t *lenp
, loff_t
*ppos
,
2387 int (*conv
)(unsigned long *lvalp
,
2389 int write
, void *data
),
2398 if (conv(&lval
, tbl_data
, 0, data
)) {
2403 err
= proc_put_long(&buffer
, &left
, lval
, false);
2407 err
= proc_put_char(&buffer
, &left
, '\n');
2416 static int __do_proc_douintvec(void *tbl_data
, struct ctl_table
*table
,
2417 int write
, void __user
*buffer
,
2418 size_t *lenp
, loff_t
*ppos
,
2419 int (*conv
)(unsigned long *lvalp
,
2421 int write
, void *data
),
2424 unsigned int *i
, vleft
;
2426 if (!tbl_data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2431 i
= (unsigned int *) tbl_data
;
2432 vleft
= table
->maxlen
/ sizeof(*i
);
2435 * Arrays are not supported, keep this simple. *Do not* add
2444 conv
= do_proc_douintvec_conv
;
2447 return do_proc_douintvec_w(i
, table
, buffer
, lenp
, ppos
,
2449 return do_proc_douintvec_r(i
, buffer
, lenp
, ppos
, conv
, data
);
2452 static int do_proc_douintvec(struct ctl_table
*table
, int write
,
2453 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
,
2454 int (*conv
)(unsigned long *lvalp
,
2456 int write
, void *data
),
2459 return __do_proc_douintvec(table
->data
, table
, write
,
2460 buffer
, lenp
, ppos
, conv
, data
);
2464 * proc_dointvec - read a vector of integers
2465 * @table: the sysctl table
2466 * @write: %TRUE if this is a write to the sysctl file
2467 * @buffer: the user buffer
2468 * @lenp: the size of the user buffer
2469 * @ppos: file position
2471 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2472 * values from/to the user buffer, treated as an ASCII string.
2474 * Returns 0 on success.
2476 int proc_dointvec(struct ctl_table
*table
, int write
,
2477 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2479 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
, NULL
, NULL
);
2483 * proc_douintvec - read a vector of unsigned integers
2484 * @table: the sysctl table
2485 * @write: %TRUE if this is a write to the sysctl file
2486 * @buffer: the user buffer
2487 * @lenp: the size of the user buffer
2488 * @ppos: file position
2490 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2491 * values from/to the user buffer, treated as an ASCII string.
2493 * Returns 0 on success.
2495 int proc_douintvec(struct ctl_table
*table
, int write
,
2496 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2498 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2499 do_proc_douintvec_conv
, NULL
);
2503 * Taint values can only be increased
2504 * This means we can safely use a temporary.
2506 static int proc_taint(struct ctl_table
*table
, int write
,
2507 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2510 unsigned long tmptaint
= get_taint();
2513 if (write
&& !capable(CAP_SYS_ADMIN
))
2518 err
= proc_doulongvec_minmax(&t
, write
, buffer
, lenp
, ppos
);
2524 * Poor man's atomic or. Not worth adding a primitive
2525 * to everyone's atomic.h for this
2528 for (i
= 0; i
< BITS_PER_LONG
&& tmptaint
>> i
; i
++) {
2529 if ((tmptaint
>> i
) & 1)
2530 add_taint(i
, LOCKDEP_STILL_OK
);
2537 #ifdef CONFIG_PRINTK
2538 static int proc_dointvec_minmax_sysadmin(struct ctl_table
*table
, int write
,
2539 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2541 if (write
&& !capable(CAP_SYS_ADMIN
))
2544 return proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2548 struct do_proc_dointvec_minmax_conv_param
{
2553 static int do_proc_dointvec_minmax_conv(bool *negp
, unsigned long *lvalp
,
2555 int write
, void *data
)
2557 struct do_proc_dointvec_minmax_conv_param
*param
= data
;
2559 int val
= *negp
? -*lvalp
: *lvalp
;
2560 if ((param
->min
&& *param
->min
> val
) ||
2561 (param
->max
&& *param
->max
< val
))
2568 *lvalp
= -(unsigned long)val
;
2571 *lvalp
= (unsigned long)val
;
2578 * proc_dointvec_minmax - read a vector of integers with min/max values
2579 * @table: the sysctl table
2580 * @write: %TRUE if this is a write to the sysctl file
2581 * @buffer: the user buffer
2582 * @lenp: the size of the user buffer
2583 * @ppos: file position
2585 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2586 * values from/to the user buffer, treated as an ASCII string.
2588 * This routine will ensure the values are within the range specified by
2589 * table->extra1 (min) and table->extra2 (max).
2591 * Returns 0 on success.
2593 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
2594 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2596 struct do_proc_dointvec_minmax_conv_param param
= {
2597 .min
= (int *) table
->extra1
,
2598 .max
= (int *) table
->extra2
,
2600 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2601 do_proc_dointvec_minmax_conv
, ¶m
);
2604 struct do_proc_douintvec_minmax_conv_param
{
2609 static int do_proc_douintvec_minmax_conv(unsigned long *lvalp
,
2611 int write
, void *data
)
2613 struct do_proc_douintvec_minmax_conv_param
*param
= data
;
2616 unsigned int val
= *lvalp
;
2618 if ((param
->min
&& *param
->min
> val
) ||
2619 (param
->max
&& *param
->max
< val
))
2622 if (*lvalp
> UINT_MAX
)
2626 unsigned int val
= *valp
;
2627 *lvalp
= (unsigned long) val
;
2634 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2635 * @table: the sysctl table
2636 * @write: %TRUE if this is a write to the sysctl file
2637 * @buffer: the user buffer
2638 * @lenp: the size of the user buffer
2639 * @ppos: file position
2641 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2642 * values from/to the user buffer, treated as an ASCII string. Negative
2643 * strings are not allowed.
2645 * This routine will ensure the values are within the range specified by
2646 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2647 * check for UINT_MAX to avoid having to support wrap around uses from
2650 * Returns 0 on success.
2652 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
2653 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2655 struct do_proc_douintvec_minmax_conv_param param
= {
2656 .min
= (unsigned int *) table
->extra1
,
2657 .max
= (unsigned int *) table
->extra2
,
2659 return do_proc_douintvec(table
, write
, buffer
, lenp
, ppos
,
2660 do_proc_douintvec_minmax_conv
, ¶m
);
2663 static void validate_coredump_safety(void)
2665 #ifdef CONFIG_COREDUMP
2666 if (suid_dumpable
== SUID_DUMP_ROOT
&&
2667 core_pattern
[0] != '/' && core_pattern
[0] != '|') {
2669 "Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2670 "Pipe handler or fully qualified core dump path required.\n"
2671 "Set kernel.core_pattern before fs.suid_dumpable.\n"
2677 static int proc_dointvec_minmax_coredump(struct ctl_table
*table
, int write
,
2678 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2680 int error
= proc_dointvec_minmax(table
, write
, buffer
, lenp
, ppos
);
2682 validate_coredump_safety();
2686 #ifdef CONFIG_COREDUMP
2687 static int proc_dostring_coredump(struct ctl_table
*table
, int write
,
2688 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2690 int error
= proc_dostring(table
, write
, buffer
, lenp
, ppos
);
2692 validate_coredump_safety();
2697 static int __do_proc_doulongvec_minmax(void *data
, struct ctl_table
*table
, int write
,
2698 void __user
*buffer
,
2699 size_t *lenp
, loff_t
*ppos
,
2700 unsigned long convmul
,
2701 unsigned long convdiv
)
2703 unsigned long *i
, *min
, *max
;
2704 int vleft
, first
= 1, err
= 0;
2706 char *kbuf
= NULL
, *p
;
2708 if (!data
|| !table
->maxlen
|| !*lenp
|| (*ppos
&& !write
)) {
2713 i
= (unsigned long *) data
;
2714 min
= (unsigned long *) table
->extra1
;
2715 max
= (unsigned long *) table
->extra2
;
2716 vleft
= table
->maxlen
/ sizeof(unsigned long);
2720 if (proc_first_pos_non_zero_ignore(ppos
, table
))
2723 if (left
> PAGE_SIZE
- 1)
2724 left
= PAGE_SIZE
- 1;
2725 p
= kbuf
= memdup_user_nul(buffer
, left
);
2727 return PTR_ERR(kbuf
);
2730 for (; left
&& vleft
--; i
++, first
= 0) {
2736 left
-= proc_skip_spaces(&p
);
2738 err
= proc_get_long(&p
, &left
, &val
, &neg
,
2740 sizeof(proc_wspace_sep
), NULL
);
2745 val
= convmul
* val
/ convdiv
;
2746 if ((min
&& val
< *min
) || (max
&& val
> *max
))
2750 val
= convdiv
* (*i
) / convmul
;
2752 err
= proc_put_char(&buffer
, &left
, '\t');
2756 err
= proc_put_long(&buffer
, &left
, val
, false);
2762 if (!write
&& !first
&& left
&& !err
)
2763 err
= proc_put_char(&buffer
, &left
, '\n');
2765 left
-= proc_skip_spaces(&p
);
2769 return err
? : -EINVAL
;
2777 static int do_proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2778 void __user
*buffer
,
2779 size_t *lenp
, loff_t
*ppos
,
2780 unsigned long convmul
,
2781 unsigned long convdiv
)
2783 return __do_proc_doulongvec_minmax(table
->data
, table
, write
,
2784 buffer
, lenp
, ppos
, convmul
, convdiv
);
2788 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2789 * @table: the sysctl table
2790 * @write: %TRUE if this is a write to the sysctl file
2791 * @buffer: the user buffer
2792 * @lenp: the size of the user buffer
2793 * @ppos: file position
2795 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2796 * values from/to the user buffer, treated as an ASCII string.
2798 * This routine will ensure the values are within the range specified by
2799 * table->extra1 (min) and table->extra2 (max).
2801 * Returns 0 on success.
2803 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
2804 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2806 return do_proc_doulongvec_minmax(table
, write
, buffer
, lenp
, ppos
, 1l, 1l);
2810 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2811 * @table: the sysctl table
2812 * @write: %TRUE if this is a write to the sysctl file
2813 * @buffer: the user buffer
2814 * @lenp: the size of the user buffer
2815 * @ppos: file position
2817 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2818 * values from/to the user buffer, treated as an ASCII string. The values
2819 * are treated as milliseconds, and converted to jiffies when they are stored.
2821 * This routine will ensure the values are within the range specified by
2822 * table->extra1 (min) and table->extra2 (max).
2824 * Returns 0 on success.
2826 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
2827 void __user
*buffer
,
2828 size_t *lenp
, loff_t
*ppos
)
2830 return do_proc_doulongvec_minmax(table
, write
, buffer
,
2831 lenp
, ppos
, HZ
, 1000l);
2835 static int do_proc_dointvec_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2837 int write
, void *data
)
2840 if (*lvalp
> INT_MAX
/ HZ
)
2842 *valp
= *negp
? -(*lvalp
*HZ
) : (*lvalp
*HZ
);
2848 lval
= -(unsigned long)val
;
2851 lval
= (unsigned long)val
;
2858 static int do_proc_dointvec_userhz_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2860 int write
, void *data
)
2863 if (USER_HZ
< HZ
&& *lvalp
> (LONG_MAX
/ HZ
) * USER_HZ
)
2865 *valp
= clock_t_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2871 lval
= -(unsigned long)val
;
2874 lval
= (unsigned long)val
;
2876 *lvalp
= jiffies_to_clock_t(lval
);
2881 static int do_proc_dointvec_ms_jiffies_conv(bool *negp
, unsigned long *lvalp
,
2883 int write
, void *data
)
2886 unsigned long jif
= msecs_to_jiffies(*negp
? -*lvalp
: *lvalp
);
2896 lval
= -(unsigned long)val
;
2899 lval
= (unsigned long)val
;
2901 *lvalp
= jiffies_to_msecs(lval
);
2907 * proc_dointvec_jiffies - read a vector of integers as seconds
2908 * @table: the sysctl table
2909 * @write: %TRUE if this is a write to the sysctl file
2910 * @buffer: the user buffer
2911 * @lenp: the size of the user buffer
2912 * @ppos: file position
2914 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2915 * values from/to the user buffer, treated as an ASCII string.
2916 * The values read are assumed to be in seconds, and are converted into
2919 * Returns 0 on success.
2921 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
2922 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2924 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2925 do_proc_dointvec_jiffies_conv
,NULL
);
2929 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2930 * @table: the sysctl table
2931 * @write: %TRUE if this is a write to the sysctl file
2932 * @buffer: the user buffer
2933 * @lenp: the size of the user buffer
2934 * @ppos: pointer to the file position
2936 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2937 * values from/to the user buffer, treated as an ASCII string.
2938 * The values read are assumed to be in 1/USER_HZ seconds, and
2939 * are converted into jiffies.
2941 * Returns 0 on success.
2943 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
2944 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2946 return do_proc_dointvec(table
,write
,buffer
,lenp
,ppos
,
2947 do_proc_dointvec_userhz_jiffies_conv
,NULL
);
2951 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2952 * @table: the sysctl table
2953 * @write: %TRUE if this is a write to the sysctl file
2954 * @buffer: the user buffer
2955 * @lenp: the size of the user buffer
2956 * @ppos: file position
2957 * @ppos: the current position in the file
2959 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2960 * values from/to the user buffer, treated as an ASCII string.
2961 * The values read are assumed to be in 1/1000 seconds, and
2962 * are converted into jiffies.
2964 * Returns 0 on success.
2966 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
2967 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2969 return do_proc_dointvec(table
, write
, buffer
, lenp
, ppos
,
2970 do_proc_dointvec_ms_jiffies_conv
, NULL
);
2973 static int proc_do_cad_pid(struct ctl_table
*table
, int write
,
2974 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
2976 struct pid
*new_pid
;
2980 tmp
= pid_vnr(cad_pid
);
2982 r
= __do_proc_dointvec(&tmp
, table
, write
, buffer
,
2983 lenp
, ppos
, NULL
, NULL
);
2987 new_pid
= find_get_pid(tmp
);
2991 put_pid(xchg(&cad_pid
, new_pid
));
2996 * proc_do_large_bitmap - read/write from/to a large bitmap
2997 * @table: the sysctl table
2998 * @write: %TRUE if this is a write to the sysctl file
2999 * @buffer: the user buffer
3000 * @lenp: the size of the user buffer
3001 * @ppos: file position
3003 * The bitmap is stored at table->data and the bitmap length (in bits)
3006 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
3007 * large bitmaps may be represented in a compact manner. Writing into
3008 * the file will clear the bitmap then update it with the given input.
3010 * Returns 0 on success.
3012 int proc_do_large_bitmap(struct ctl_table
*table
, int write
,
3013 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3017 size_t left
= *lenp
;
3018 unsigned long bitmap_len
= table
->maxlen
;
3019 unsigned long *bitmap
= *(unsigned long **) table
->data
;
3020 unsigned long *tmp_bitmap
= NULL
;
3021 char tr_a
[] = { '-', ',', '\n' }, tr_b
[] = { ',', '\n', 0 }, c
;
3023 if (!bitmap
|| !bitmap_len
|| !left
|| (*ppos
&& !write
)) {
3031 if (left
> PAGE_SIZE
- 1)
3032 left
= PAGE_SIZE
- 1;
3034 p
= kbuf
= memdup_user_nul(buffer
, left
);
3036 return PTR_ERR(kbuf
);
3038 tmp_bitmap
= kzalloc(BITS_TO_LONGS(bitmap_len
) * sizeof(unsigned long),
3044 proc_skip_char(&p
, &left
, '\n');
3045 while (!err
&& left
) {
3046 unsigned long val_a
, val_b
;
3049 err
= proc_get_long(&p
, &left
, &val_a
, &neg
, tr_a
,
3053 if (val_a
>= bitmap_len
|| neg
) {
3065 err
= proc_get_long(&p
, &left
, &val_b
,
3066 &neg
, tr_b
, sizeof(tr_b
),
3070 if (val_b
>= bitmap_len
|| neg
||
3081 bitmap_set(tmp_bitmap
, val_a
, val_b
- val_a
+ 1);
3083 proc_skip_char(&p
, &left
, '\n');
3087 unsigned long bit_a
, bit_b
= 0;
3090 bit_a
= find_next_bit(bitmap
, bitmap_len
, bit_b
);
3091 if (bit_a
>= bitmap_len
)
3093 bit_b
= find_next_zero_bit(bitmap
, bitmap_len
,
3097 err
= proc_put_char(&buffer
, &left
, ',');
3101 err
= proc_put_long(&buffer
, &left
, bit_a
, false);
3104 if (bit_a
!= bit_b
) {
3105 err
= proc_put_char(&buffer
, &left
, '-');
3108 err
= proc_put_long(&buffer
, &left
, bit_b
, false);
3116 err
= proc_put_char(&buffer
, &left
, '\n');
3122 bitmap_or(bitmap
, bitmap
, tmp_bitmap
, bitmap_len
);
3124 bitmap_copy(bitmap
, tmp_bitmap
, bitmap_len
);
3136 #else /* CONFIG_PROC_SYSCTL */
3138 int proc_dostring(struct ctl_table
*table
, int write
,
3139 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3144 int proc_dointvec(struct ctl_table
*table
, int write
,
3145 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3150 int proc_douintvec(struct ctl_table
*table
, int write
,
3151 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3156 int proc_dointvec_minmax(struct ctl_table
*table
, int write
,
3157 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3162 int proc_douintvec_minmax(struct ctl_table
*table
, int write
,
3163 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3168 int proc_dointvec_jiffies(struct ctl_table
*table
, int write
,
3169 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3174 int proc_dointvec_userhz_jiffies(struct ctl_table
*table
, int write
,
3175 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3180 int proc_dointvec_ms_jiffies(struct ctl_table
*table
, int write
,
3181 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3186 int proc_doulongvec_minmax(struct ctl_table
*table
, int write
,
3187 void __user
*buffer
, size_t *lenp
, loff_t
*ppos
)
3192 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table
*table
, int write
,
3193 void __user
*buffer
,
3194 size_t *lenp
, loff_t
*ppos
)
3200 #endif /* CONFIG_PROC_SYSCTL */
3203 * No sense putting this after each symbol definition, twice,
3204 * exception granted :-)
3206 EXPORT_SYMBOL(proc_dointvec
);
3207 EXPORT_SYMBOL(proc_douintvec
);
3208 EXPORT_SYMBOL(proc_dointvec_jiffies
);
3209 EXPORT_SYMBOL(proc_dointvec_minmax
);
3210 EXPORT_SYMBOL_GPL(proc_douintvec_minmax
);
3211 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies
);
3212 EXPORT_SYMBOL(proc_dointvec_ms_jiffies
);
3213 EXPORT_SYMBOL(proc_dostring
);
3214 EXPORT_SYMBOL(proc_doulongvec_minmax
);
3215 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax
);