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 extra_free_kbytes;
109 extern int pid_max_min, pid_max_max;
110 extern int percpu_pagelist_fraction;
111 extern int compat_log;
112 extern int latencytop_enabled;
113 extern int sysctl_nr_open_min, sysctl_nr_open_max;
115 extern int sysctl_nr_trim_pages;
118 /* Constants used for minimum and maximum */
119 #ifdef CONFIG_LOCKUP_DETECTOR
120 static int sixty = 60;
123 static int __maybe_unused neg_one = -1;
126 static int __maybe_unused one = 1;
127 static int __maybe_unused two = 2;
128 static int __maybe_unused three = 3;
129 static int __maybe_unused four = 4;
130 static unsigned long one_ul = 1;
131 static int one_hundred = 100;
133 static int ten_thousand = 10000;
135 #ifdef CONFIG_SCHED_HMP
136 static int one_thousand = 1000;
137 static int max_freq_reporting_policy = FREQ_REPORT_INVALID_POLICY - 1;
140 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
141 static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
143 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
144 static int maxolduid = 65535;
145 static int minolduid;
147 static int ngroups_max = NGROUPS_MAX;
148 static const int cap_last_cap = CAP_LAST_CAP;
150 /*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
151 #ifdef CONFIG_DETECT_HUNG_TASK
152 static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
155 #ifdef CONFIG_INOTIFY_USER
156 #include <linux/inotify.h>
162 extern int pwrsw_enabled;
165 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
166 extern int unaligned_enabled;
170 extern int unaligned_dump_stack;
173 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
174 extern int no_unaligned_warning;
177 #ifdef CONFIG_PROC_SYSCTL
179 #define SYSCTL_WRITES_LEGACY -1
180 #define SYSCTL_WRITES_WARN 0
181 #define SYSCTL_WRITES_STRICT 1
183 static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
185 static int proc_do_cad_pid(struct ctl_table *table, int write,
186 void __user *buffer, size_t *lenp, loff_t *ppos);
187 static int proc_taint(struct ctl_table *table, int write,
188 void __user *buffer, size_t *lenp, loff_t *ppos);
192 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
193 void __user *buffer, size_t *lenp, loff_t *ppos);
196 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
197 void __user *buffer, size_t *lenp, loff_t *ppos);
198 #ifdef CONFIG_COREDUMP
199 static int proc_dostring_coredump(struct ctl_table *table, int write,
200 void __user *buffer, size_t *lenp, loff_t *ppos);
203 #ifdef CONFIG_MAGIC_SYSRQ
204 /* Note: sysrq code uses it's own private copy */
205 static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
207 static int sysrq_sysctl_handler(struct ctl_table *table, int write,
208 void __user *buffer, size_t *lenp,
213 error = proc_dointvec(table, write, buffer, lenp, ppos);
218 sysrq_toggle_support(__sysrq_enabled);
225 static struct ctl_table kern_table[];
226 static struct ctl_table vm_table[];
227 static struct ctl_table fs_table[];
228 static struct ctl_table debug_table[];
229 static struct ctl_table dev_table[];
230 extern struct ctl_table random_table[];
232 extern struct ctl_table epoll_table[];
235 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
236 int sysctl_legacy_va_layout;
239 /* The default sysctl tables: */
241 static struct ctl_table sysctl_base_table[] = {
243 .procname = "kernel",
260 .child = debug_table,
270 #ifdef CONFIG_SCHED_DEBUG
271 static int min_sched_granularity_ns = 100000; /* 100 usecs */
272 static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
273 static int min_wakeup_granularity_ns; /* 0 usecs */
274 static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
276 static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
277 static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
278 #endif /* CONFIG_SMP */
279 #endif /* CONFIG_SCHED_DEBUG */
281 #ifdef CONFIG_COMPACTION
282 static int min_extfrag_threshold;
283 static int max_extfrag_threshold = 1000;
286 static struct ctl_table kern_table[] = {
288 .procname = "sched_child_runs_first",
289 .data = &sysctl_sched_child_runs_first,
290 .maxlen = sizeof(unsigned int),
292 .proc_handler = proc_dointvec,
294 #ifdef CONFIG_SCHED_HMP
296 .procname = "sched_freq_reporting_policy",
297 .data = &sysctl_sched_freq_reporting_policy,
298 .maxlen = sizeof(unsigned int),
300 .proc_handler = proc_dointvec_minmax,
302 .extra2 = &max_freq_reporting_policy,
305 .procname = "sched_freq_inc_notify",
306 .data = &sysctl_sched_freq_inc_notify,
307 .maxlen = sizeof(unsigned int),
309 .proc_handler = proc_dointvec_minmax,
313 .procname = "sched_freq_dec_notify",
314 .data = &sysctl_sched_freq_dec_notify,
315 .maxlen = sizeof(unsigned int),
317 .proc_handler = proc_dointvec_minmax,
321 .procname = "sched_cpu_high_irqload",
322 .data = &sysctl_sched_cpu_high_irqload,
323 .maxlen = sizeof(unsigned int),
325 .proc_handler = proc_dointvec,
328 .procname = "sched_ravg_hist_size",
329 .data = &sysctl_sched_ravg_hist_size,
330 .maxlen = sizeof(unsigned int),
332 .proc_handler = sched_window_update_handler,
335 .procname = "sched_window_stats_policy",
336 .data = &sysctl_sched_window_stats_policy,
337 .maxlen = sizeof(unsigned int),
339 .proc_handler = sched_window_update_handler,
342 .procname = "sched_spill_load",
343 .data = &sysctl_sched_spill_load_pct,
344 .maxlen = sizeof(unsigned int),
346 .proc_handler = sched_hmp_proc_update_handler,
348 .extra2 = &one_hundred,
351 .procname = "sched_spill_nr_run",
352 .data = &sysctl_sched_spill_nr_run,
353 .maxlen = sizeof(unsigned int),
355 .proc_handler = proc_dointvec_minmax,
359 .procname = "sched_upmigrate",
360 .data = &sysctl_sched_upmigrate_pct,
361 .maxlen = sizeof(unsigned int),
363 .proc_handler = sched_hmp_proc_update_handler,
365 .extra2 = &one_hundred,
368 .procname = "sched_downmigrate",
369 .data = &sysctl_sched_downmigrate_pct,
370 .maxlen = sizeof(unsigned int),
372 .proc_handler = sched_hmp_proc_update_handler,
374 .extra2 = &one_hundred,
377 .procname = "sched_group_upmigrate",
378 .data = &sysctl_sched_group_upmigrate_pct,
379 .maxlen = sizeof(unsigned int),
381 .proc_handler = sched_hmp_proc_update_handler,
385 .procname = "sched_group_downmigrate",
386 .data = &sysctl_sched_group_downmigrate_pct,
387 .maxlen = sizeof(unsigned int),
389 .proc_handler = sched_hmp_proc_update_handler,
393 .procname = "sched_init_task_load",
394 .data = &sysctl_sched_init_task_load_pct,
395 .maxlen = sizeof(unsigned int),
397 .proc_handler = sched_hmp_proc_update_handler,
399 .extra2 = &one_hundred,
402 .procname = "sched_select_prev_cpu_us",
403 .data = &sysctl_sched_select_prev_cpu_us,
404 .maxlen = sizeof(unsigned int),
406 .proc_handler = sched_hmp_proc_update_handler,
410 .procname = "sched_restrict_cluster_spill",
411 .data = &sysctl_sched_restrict_cluster_spill,
412 .maxlen = sizeof(unsigned int),
414 .proc_handler = proc_dointvec_minmax,
419 .procname = "sched_small_wakee_task_load",
420 .data = &sysctl_sched_small_wakee_task_load_pct,
421 .maxlen = sizeof(unsigned int),
423 .proc_handler = sched_hmp_proc_update_handler,
425 .extra2 = &one_hundred,
428 .procname = "sched_big_waker_task_load",
429 .data = &sysctl_sched_big_waker_task_load_pct,
430 .maxlen = sizeof(unsigned int),
432 .proc_handler = sched_hmp_proc_update_handler,
434 .extra2 = &one_hundred,
437 .procname = "sched_prefer_sync_wakee_to_waker",
438 .data = &sysctl_sched_prefer_sync_wakee_to_waker,
439 .maxlen = sizeof(unsigned int),
441 .proc_handler = proc_dointvec_minmax,
446 .procname = "sched_enable_thread_grouping",
447 .data = &sysctl_sched_enable_thread_grouping,
448 .maxlen = sizeof(unsigned int),
450 .proc_handler = proc_dointvec,
453 .procname = "sched_pred_alert_freq",
454 .data = &sysctl_sched_pred_alert_freq,
455 .maxlen = sizeof(unsigned int),
457 .proc_handler = proc_dointvec_minmax,
461 .procname = "sched_freq_aggregate",
462 .data = &sysctl_sched_freq_aggregate,
463 .maxlen = sizeof(unsigned int),
465 .proc_handler = sched_window_update_handler,
468 .procname = "sched_freq_aggregate_threshold",
469 .data = &sysctl_sched_freq_aggregate_threshold_pct,
470 .maxlen = sizeof(unsigned int),
472 .proc_handler = sched_hmp_proc_update_handler,
475 * Special handling for sched_freq_aggregate_threshold_pct
476 * which can be greater than 100. Use 1000 as an upper bound
477 * value which works for all practical use cases.
479 .extra2 = &one_thousand,
482 .procname = "sched_boost",
483 .data = &sysctl_sched_boost,
484 .maxlen = sizeof(unsigned int),
486 .proc_handler = sched_boost_handler,
491 .procname = "sched_short_burst_ns",
492 .data = &sysctl_sched_short_burst,
493 .maxlen = sizeof(unsigned int),
495 .proc_handler = proc_dointvec,
498 .procname = "sched_short_sleep_ns",
499 .data = &sysctl_sched_short_sleep,
500 .maxlen = sizeof(unsigned int),
502 .proc_handler = proc_dointvec,
504 #endif /* CONFIG_SCHED_HMP */
505 #ifdef CONFIG_SCHED_DEBUG
507 .procname = "sched_min_granularity_ns",
508 .data = &sysctl_sched_min_granularity,
509 .maxlen = sizeof(unsigned int),
511 .proc_handler = sched_proc_update_handler,
512 .extra1 = &min_sched_granularity_ns,
513 .extra2 = &max_sched_granularity_ns,
516 .procname = "sched_latency_ns",
517 .data = &sysctl_sched_latency,
518 .maxlen = sizeof(unsigned int),
520 .proc_handler = sched_proc_update_handler,
521 .extra1 = &min_sched_granularity_ns,
522 .extra2 = &max_sched_granularity_ns,
525 .procname = "sched_sync_hint_enable",
526 .data = &sysctl_sched_sync_hint_enable,
527 .maxlen = sizeof(unsigned int),
529 .proc_handler = proc_dointvec,
532 .procname = "sched_initial_task_util",
533 .data = &sysctl_sched_initial_task_util,
534 .maxlen = sizeof(unsigned int),
536 .proc_handler = proc_dointvec,
539 .procname = "sched_cstate_aware",
540 .data = &sysctl_sched_cstate_aware,
541 .maxlen = sizeof(unsigned int),
543 .proc_handler = proc_dointvec,
546 .procname = "sched_wakeup_granularity_ns",
547 .data = &sysctl_sched_wakeup_granularity,
548 .maxlen = sizeof(unsigned int),
550 .proc_handler = sched_proc_update_handler,
551 .extra1 = &min_wakeup_granularity_ns,
552 .extra2 = &max_wakeup_granularity_ns,
556 .procname = "sched_tunable_scaling",
557 .data = &sysctl_sched_tunable_scaling,
558 .maxlen = sizeof(enum sched_tunable_scaling),
560 .proc_handler = sched_proc_update_handler,
561 .extra1 = &min_sched_tunable_scaling,
562 .extra2 = &max_sched_tunable_scaling,
565 .procname = "sched_migration_cost_ns",
566 .data = &sysctl_sched_migration_cost,
567 .maxlen = sizeof(unsigned int),
569 .proc_handler = proc_dointvec,
572 .procname = "sched_nr_migrate",
573 .data = &sysctl_sched_nr_migrate,
574 .maxlen = sizeof(unsigned int),
576 .proc_handler = proc_dointvec,
579 .procname = "sched_time_avg_ms",
580 .data = &sysctl_sched_time_avg,
581 .maxlen = sizeof(unsigned int),
583 .proc_handler = proc_dointvec_minmax,
587 .procname = "sched_shares_window_ns",
588 .data = &sysctl_sched_shares_window,
589 .maxlen = sizeof(unsigned int),
591 .proc_handler = proc_dointvec,
593 #endif /* CONFIG_SMP */
594 #ifdef CONFIG_NUMA_BALANCING
596 .procname = "numa_balancing_scan_delay_ms",
597 .data = &sysctl_numa_balancing_scan_delay,
598 .maxlen = sizeof(unsigned int),
600 .proc_handler = proc_dointvec,
603 .procname = "numa_balancing_scan_period_min_ms",
604 .data = &sysctl_numa_balancing_scan_period_min,
605 .maxlen = sizeof(unsigned int),
607 .proc_handler = proc_dointvec,
610 .procname = "numa_balancing_scan_period_max_ms",
611 .data = &sysctl_numa_balancing_scan_period_max,
612 .maxlen = sizeof(unsigned int),
614 .proc_handler = proc_dointvec,
617 .procname = "numa_balancing_scan_size_mb",
618 .data = &sysctl_numa_balancing_scan_size,
619 .maxlen = sizeof(unsigned int),
621 .proc_handler = proc_dointvec_minmax,
625 .procname = "numa_balancing",
626 .data = NULL, /* filled in by handler */
627 .maxlen = sizeof(unsigned int),
629 .proc_handler = sysctl_numa_balancing,
633 #endif /* CONFIG_NUMA_BALANCING */
634 #endif /* CONFIG_SCHED_DEBUG */
636 .procname = "sched_rt_period_us",
637 .data = &sysctl_sched_rt_period,
638 .maxlen = sizeof(unsigned int),
640 .proc_handler = sched_rt_handler,
643 .procname = "sched_rt_runtime_us",
644 .data = &sysctl_sched_rt_runtime,
645 .maxlen = sizeof(int),
647 .proc_handler = sched_rt_handler,
650 .procname = "sched_rr_timeslice_ms",
651 .data = &sched_rr_timeslice,
652 .maxlen = sizeof(int),
654 .proc_handler = sched_rr_handler,
656 #ifdef CONFIG_SCHED_AUTOGROUP
658 .procname = "sched_autogroup_enabled",
659 .data = &sysctl_sched_autogroup_enabled,
660 .maxlen = sizeof(unsigned int),
662 .proc_handler = proc_dointvec_minmax,
667 #ifdef CONFIG_CFS_BANDWIDTH
669 .procname = "sched_cfs_bandwidth_slice_us",
670 .data = &sysctl_sched_cfs_bandwidth_slice,
671 .maxlen = sizeof(unsigned int),
673 .proc_handler = proc_dointvec_minmax,
677 #ifdef CONFIG_SCHED_TUNE
679 .procname = "sched_cfs_boost",
680 .data = &sysctl_sched_cfs_boost,
681 .maxlen = sizeof(sysctl_sched_cfs_boost),
682 #ifdef CONFIG_CGROUP_SCHEDTUNE
687 .proc_handler = &sysctl_sched_cfs_boost_handler,
689 .extra2 = &one_hundred,
692 #ifdef CONFIG_PROVE_LOCKING
694 .procname = "prove_locking",
695 .data = &prove_locking,
696 .maxlen = sizeof(int),
698 .proc_handler = proc_dointvec,
701 #ifdef CONFIG_LOCK_STAT
703 .procname = "lock_stat",
705 .maxlen = sizeof(int),
707 .proc_handler = proc_dointvec,
712 .data = &panic_timeout,
713 .maxlen = sizeof(int),
715 .proc_handler = proc_dointvec,
717 #ifdef CONFIG_COREDUMP
719 .procname = "core_uses_pid",
720 .data = &core_uses_pid,
721 .maxlen = sizeof(int),
723 .proc_handler = proc_dointvec,
726 .procname = "core_pattern",
727 .data = core_pattern,
728 .maxlen = CORENAME_MAX_SIZE,
730 .proc_handler = proc_dostring_coredump,
733 .procname = "core_pipe_limit",
734 .data = &core_pipe_limit,
735 .maxlen = sizeof(unsigned int),
737 .proc_handler = proc_dointvec,
740 #ifdef CONFIG_PROC_SYSCTL
742 .procname = "tainted",
743 .maxlen = sizeof(long),
745 .proc_handler = proc_taint,
748 .procname = "sysctl_writes_strict",
749 .data = &sysctl_writes_strict,
750 .maxlen = sizeof(int),
752 .proc_handler = proc_dointvec_minmax,
757 #ifdef CONFIG_LATENCYTOP
759 .procname = "latencytop",
760 .data = &latencytop_enabled,
761 .maxlen = sizeof(int),
763 .proc_handler = proc_dointvec,
766 #ifdef CONFIG_BLK_DEV_INITRD
768 .procname = "real-root-dev",
769 .data = &real_root_dev,
770 .maxlen = sizeof(int),
772 .proc_handler = proc_dointvec,
776 .procname = "print-fatal-signals",
777 .data = &print_fatal_signals,
778 .maxlen = sizeof(int),
780 .proc_handler = proc_dointvec,
784 .procname = "reboot-cmd",
785 .data = reboot_command,
788 .proc_handler = proc_dostring,
791 .procname = "stop-a",
792 .data = &stop_a_enabled,
793 .maxlen = sizeof (int),
795 .proc_handler = proc_dointvec,
798 .procname = "scons-poweroff",
799 .data = &scons_pwroff,
800 .maxlen = sizeof (int),
802 .proc_handler = proc_dointvec,
805 #ifdef CONFIG_SPARC64
807 .procname = "tsb-ratio",
808 .data = &sysctl_tsb_ratio,
809 .maxlen = sizeof (int),
811 .proc_handler = proc_dointvec,
816 .procname = "soft-power",
817 .data = &pwrsw_enabled,
818 .maxlen = sizeof (int),
820 .proc_handler = proc_dointvec,
823 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
825 .procname = "unaligned-trap",
826 .data = &unaligned_enabled,
827 .maxlen = sizeof (int),
829 .proc_handler = proc_dointvec,
833 .procname = "ctrl-alt-del",
835 .maxlen = sizeof(int),
837 .proc_handler = proc_dointvec,
839 #ifdef CONFIG_FUNCTION_TRACER
841 .procname = "ftrace_enabled",
842 .data = &ftrace_enabled,
843 .maxlen = sizeof(int),
845 .proc_handler = ftrace_enable_sysctl,
848 #ifdef CONFIG_STACK_TRACER
850 .procname = "stack_tracer_enabled",
851 .data = &stack_tracer_enabled,
852 .maxlen = sizeof(int),
854 .proc_handler = stack_trace_sysctl,
857 #ifdef CONFIG_TRACING
859 .procname = "ftrace_dump_on_oops",
860 .data = &ftrace_dump_on_oops,
861 .maxlen = sizeof(int),
863 .proc_handler = proc_dointvec,
866 .procname = "traceoff_on_warning",
867 .data = &__disable_trace_on_warning,
868 .maxlen = sizeof(__disable_trace_on_warning),
870 .proc_handler = proc_dointvec,
873 .procname = "tracepoint_printk",
874 .data = &tracepoint_printk,
875 .maxlen = sizeof(tracepoint_printk),
877 .proc_handler = proc_dointvec,
880 #ifdef CONFIG_KEXEC_CORE
882 .procname = "kexec_load_disabled",
883 .data = &kexec_load_disabled,
884 .maxlen = sizeof(int),
886 /* only handle a transition from default "0" to "1" */
887 .proc_handler = proc_dointvec_minmax,
892 #ifdef CONFIG_MODULES
894 .procname = "modprobe",
895 .data = &modprobe_path,
896 .maxlen = KMOD_PATH_LEN,
898 .proc_handler = proc_dostring,
901 .procname = "modules_disabled",
902 .data = &modules_disabled,
903 .maxlen = sizeof(int),
905 /* only handle a transition from default "0" to "1" */
906 .proc_handler = proc_dointvec_minmax,
911 #ifdef CONFIG_UEVENT_HELPER
913 .procname = "hotplug",
914 .data = &uevent_helper,
915 .maxlen = UEVENT_HELPER_PATH_LEN,
917 .proc_handler = proc_dostring,
920 #ifdef CONFIG_CHR_DEV_SG
922 .procname = "sg-big-buff",
923 .data = &sg_big_buff,
924 .maxlen = sizeof (int),
926 .proc_handler = proc_dointvec,
929 #ifdef CONFIG_BSD_PROCESS_ACCT
933 .maxlen = 3*sizeof(int),
935 .proc_handler = proc_dointvec,
938 #ifdef CONFIG_MAGIC_SYSRQ
941 .data = &__sysrq_enabled,
942 .maxlen = sizeof (int),
944 .proc_handler = sysrq_sysctl_handler,
947 #ifdef CONFIG_PROC_SYSCTL
949 .procname = "cad_pid",
951 .maxlen = sizeof (int),
953 .proc_handler = proc_do_cad_pid,
957 .procname = "threads-max",
959 .maxlen = sizeof(int),
961 .proc_handler = sysctl_max_threads,
964 .procname = "random",
966 .child = random_table,
969 .procname = "usermodehelper",
971 .child = usermodehelper_table,
974 .procname = "overflowuid",
975 .data = &overflowuid,
976 .maxlen = sizeof(int),
978 .proc_handler = proc_dointvec_minmax,
979 .extra1 = &minolduid,
980 .extra2 = &maxolduid,
983 .procname = "overflowgid",
984 .data = &overflowgid,
985 .maxlen = sizeof(int),
987 .proc_handler = proc_dointvec_minmax,
988 .extra1 = &minolduid,
989 .extra2 = &maxolduid,
992 #ifdef CONFIG_MATHEMU
994 .procname = "ieee_emulation_warnings",
995 .data = &sysctl_ieee_emulation_warnings,
996 .maxlen = sizeof(int),
998 .proc_handler = proc_dointvec,
1002 .procname = "userprocess_debug",
1003 .data = &show_unhandled_signals,
1004 .maxlen = sizeof(int),
1006 .proc_handler = proc_dointvec,
1010 .procname = "pid_max",
1012 .maxlen = sizeof (int),
1014 .proc_handler = proc_dointvec_minmax,
1015 .extra1 = &pid_max_min,
1016 .extra2 = &pid_max_max,
1019 .procname = "panic_on_oops",
1020 .data = &panic_on_oops,
1021 .maxlen = sizeof(int),
1023 .proc_handler = proc_dointvec,
1025 #if defined CONFIG_PRINTK
1027 .procname = "printk",
1028 .data = &console_loglevel,
1029 .maxlen = 4*sizeof(int),
1031 .proc_handler = proc_dointvec,
1034 .procname = "printk_ratelimit",
1035 .data = &printk_ratelimit_state.interval,
1036 .maxlen = sizeof(int),
1038 .proc_handler = proc_dointvec_jiffies,
1041 .procname = "printk_ratelimit_burst",
1042 .data = &printk_ratelimit_state.burst,
1043 .maxlen = sizeof(int),
1045 .proc_handler = proc_dointvec,
1048 .procname = "printk_delay",
1049 .data = &printk_delay_msec,
1050 .maxlen = sizeof(int),
1052 .proc_handler = proc_dointvec_minmax,
1054 .extra2 = &ten_thousand,
1057 .procname = "dmesg_restrict",
1058 .data = &dmesg_restrict,
1059 .maxlen = sizeof(int),
1061 .proc_handler = proc_dointvec_minmax_sysadmin,
1066 .procname = "kptr_restrict",
1067 .data = &kptr_restrict,
1068 .maxlen = sizeof(int),
1070 .proc_handler = proc_dointvec_minmax_sysadmin,
1076 .procname = "ngroups_max",
1077 .data = &ngroups_max,
1078 .maxlen = sizeof (int),
1080 .proc_handler = proc_dointvec,
1083 .procname = "cap_last_cap",
1084 .data = (void *)&cap_last_cap,
1085 .maxlen = sizeof(int),
1087 .proc_handler = proc_dointvec,
1089 #if defined(CONFIG_LOCKUP_DETECTOR)
1091 .procname = "watchdog",
1092 .data = &watchdog_user_enabled,
1093 .maxlen = sizeof (int),
1095 .proc_handler = proc_watchdog,
1100 .procname = "watchdog_thresh",
1101 .data = &watchdog_thresh,
1102 .maxlen = sizeof(int),
1104 .proc_handler = proc_watchdog_thresh,
1109 .procname = "nmi_watchdog",
1110 .data = &nmi_watchdog_enabled,
1111 .maxlen = sizeof (int),
1113 .proc_handler = proc_nmi_watchdog,
1115 #if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
1122 .procname = "soft_watchdog",
1123 .data = &soft_watchdog_enabled,
1124 .maxlen = sizeof (int),
1126 .proc_handler = proc_soft_watchdog,
1131 .procname = "watchdog_cpumask",
1132 .data = &watchdog_cpumask_bits,
1135 .proc_handler = proc_watchdog_cpumask,
1138 .procname = "softlockup_panic",
1139 .data = &softlockup_panic,
1140 .maxlen = sizeof(int),
1142 .proc_handler = proc_dointvec_minmax,
1146 #ifdef CONFIG_HARDLOCKUP_DETECTOR
1148 .procname = "hardlockup_panic",
1149 .data = &hardlockup_panic,
1150 .maxlen = sizeof(int),
1152 .proc_handler = proc_dointvec_minmax,
1159 .procname = "softlockup_all_cpu_backtrace",
1160 .data = &sysctl_softlockup_all_cpu_backtrace,
1161 .maxlen = sizeof(int),
1163 .proc_handler = proc_dointvec_minmax,
1168 .procname = "hardlockup_all_cpu_backtrace",
1169 .data = &sysctl_hardlockup_all_cpu_backtrace,
1170 .maxlen = sizeof(int),
1172 .proc_handler = proc_dointvec_minmax,
1176 #endif /* CONFIG_SMP */
1178 #if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
1180 .procname = "unknown_nmi_panic",
1181 .data = &unknown_nmi_panic,
1182 .maxlen = sizeof (int),
1184 .proc_handler = proc_dointvec,
1187 #if defined(CONFIG_X86)
1189 .procname = "panic_on_unrecovered_nmi",
1190 .data = &panic_on_unrecovered_nmi,
1191 .maxlen = sizeof(int),
1193 .proc_handler = proc_dointvec,
1196 .procname = "panic_on_io_nmi",
1197 .data = &panic_on_io_nmi,
1198 .maxlen = sizeof(int),
1200 .proc_handler = proc_dointvec,
1202 #ifdef CONFIG_DEBUG_STACKOVERFLOW
1204 .procname = "panic_on_stackoverflow",
1205 .data = &sysctl_panic_on_stackoverflow,
1206 .maxlen = sizeof(int),
1208 .proc_handler = proc_dointvec,
1212 .procname = "bootloader_type",
1213 .data = &bootloader_type,
1214 .maxlen = sizeof (int),
1216 .proc_handler = proc_dointvec,
1219 .procname = "bootloader_version",
1220 .data = &bootloader_version,
1221 .maxlen = sizeof (int),
1223 .proc_handler = proc_dointvec,
1226 .procname = "kstack_depth_to_print",
1227 .data = &kstack_depth_to_print,
1228 .maxlen = sizeof(int),
1230 .proc_handler = proc_dointvec,
1233 .procname = "io_delay_type",
1234 .data = &io_delay_type,
1235 .maxlen = sizeof(int),
1237 .proc_handler = proc_dointvec,
1240 #if defined(CONFIG_MMU)
1242 .procname = "randomize_va_space",
1243 .data = &randomize_va_space,
1244 .maxlen = sizeof(int),
1246 .proc_handler = proc_dointvec,
1249 #if defined(CONFIG_S390) && defined(CONFIG_SMP)
1251 .procname = "spin_retry",
1252 .data = &spin_retry,
1253 .maxlen = sizeof (int),
1255 .proc_handler = proc_dointvec,
1258 #if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
1260 .procname = "acpi_video_flags",
1261 .data = &acpi_realmode_flags,
1262 .maxlen = sizeof (unsigned long),
1264 .proc_handler = proc_doulongvec_minmax,
1267 #ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
1269 .procname = "ignore-unaligned-usertrap",
1270 .data = &no_unaligned_warning,
1271 .maxlen = sizeof (int),
1273 .proc_handler = proc_dointvec,
1278 .procname = "unaligned-dump-stack",
1279 .data = &unaligned_dump_stack,
1280 .maxlen = sizeof (int),
1282 .proc_handler = proc_dointvec,
1285 #ifdef CONFIG_DETECT_HUNG_TASK
1287 .procname = "hung_task_panic",
1288 .data = &sysctl_hung_task_panic,
1289 .maxlen = sizeof(int),
1291 .proc_handler = proc_dointvec_minmax,
1296 .procname = "hung_task_check_count",
1297 .data = &sysctl_hung_task_check_count,
1298 .maxlen = sizeof(int),
1300 .proc_handler = proc_dointvec_minmax,
1304 .procname = "hung_task_timeout_secs",
1305 .data = &sysctl_hung_task_timeout_secs,
1306 .maxlen = sizeof(unsigned long),
1308 .proc_handler = proc_dohung_task_timeout_secs,
1309 .extra2 = &hung_task_timeout_max,
1312 .procname = "hung_task_warnings",
1313 .data = &sysctl_hung_task_warnings,
1314 .maxlen = sizeof(int),
1316 .proc_handler = proc_dointvec_minmax,
1320 #ifdef CONFIG_COMPAT
1322 .procname = "compat-log",
1323 .data = &compat_log,
1324 .maxlen = sizeof (int),
1326 .proc_handler = proc_dointvec,
1329 #ifdef CONFIG_RT_MUTEXES
1331 .procname = "max_lock_depth",
1332 .data = &max_lock_depth,
1333 .maxlen = sizeof(int),
1335 .proc_handler = proc_dointvec,
1339 .procname = "poweroff_cmd",
1340 .data = &poweroff_cmd,
1341 .maxlen = POWEROFF_CMD_PATH_LEN,
1343 .proc_handler = proc_dostring,
1349 .child = key_sysctls,
1352 #ifdef CONFIG_PERF_EVENTS
1354 * User-space scripts rely on the existence of this file
1355 * as a feature check for perf_events being enabled.
1357 * So it's an ABI, do not remove!
1360 .procname = "perf_event_paranoid",
1361 .data = &sysctl_perf_event_paranoid,
1362 .maxlen = sizeof(sysctl_perf_event_paranoid),
1364 .proc_handler = proc_dointvec,
1367 .procname = "perf_event_mlock_kb",
1368 .data = &sysctl_perf_event_mlock,
1369 .maxlen = sizeof(sysctl_perf_event_mlock),
1371 .proc_handler = proc_dointvec,
1374 .procname = "perf_event_max_sample_rate",
1375 .data = &sysctl_perf_event_sample_rate,
1376 .maxlen = sizeof(sysctl_perf_event_sample_rate),
1378 .proc_handler = perf_proc_update_handler,
1382 .procname = "perf_cpu_time_max_percent",
1383 .data = &sysctl_perf_cpu_time_max_percent,
1384 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1386 .proc_handler = perf_cpu_time_max_percent_handler,
1388 .extra2 = &one_hundred,
1391 #ifdef CONFIG_KMEMCHECK
1393 .procname = "kmemcheck",
1394 .data = &kmemcheck_enabled,
1395 .maxlen = sizeof(int),
1397 .proc_handler = proc_dointvec,
1401 .procname = "panic_on_warn",
1402 .data = &panic_on_warn,
1403 .maxlen = sizeof(int),
1405 .proc_handler = proc_dointvec_minmax,
1409 #if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1411 .procname = "timer_migration",
1412 .data = &sysctl_timer_migration,
1413 .maxlen = sizeof(unsigned int),
1415 .proc_handler = timer_migration_handler,
1420 #ifdef CONFIG_BPF_SYSCALL
1422 .procname = "unprivileged_bpf_disabled",
1423 .data = &sysctl_unprivileged_bpf_disabled,
1424 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1426 /* only handle a transition from default "0" to "1" */
1427 .proc_handler = proc_dointvec_minmax,
1432 #if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
1434 .procname = "boot_reason",
1435 .data = &boot_reason,
1436 .maxlen = sizeof(int),
1438 .proc_handler = proc_dointvec,
1442 .procname = "cold_boot",
1444 .maxlen = sizeof(int),
1446 .proc_handler = proc_dointvec,
1450 * NOTE: do not add new entries to this table unless you have read
1451 * Documentation/sysctl/ctl_unnumbered.txt
1456 static struct ctl_table vm_table[] = {
1458 .procname = "overcommit_memory",
1459 .data = &sysctl_overcommit_memory,
1460 .maxlen = sizeof(sysctl_overcommit_memory),
1462 .proc_handler = proc_dointvec_minmax,
1467 .procname = "panic_on_oom",
1468 .data = &sysctl_panic_on_oom,
1469 .maxlen = sizeof(sysctl_panic_on_oom),
1471 .proc_handler = proc_dointvec_minmax,
1476 .procname = "oom_kill_allocating_task",
1477 .data = &sysctl_oom_kill_allocating_task,
1478 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1480 .proc_handler = proc_dointvec,
1483 .procname = "oom_dump_tasks",
1484 .data = &sysctl_oom_dump_tasks,
1485 .maxlen = sizeof(sysctl_oom_dump_tasks),
1487 .proc_handler = proc_dointvec,
1490 .procname = "overcommit_ratio",
1491 .data = &sysctl_overcommit_ratio,
1492 .maxlen = sizeof(sysctl_overcommit_ratio),
1494 .proc_handler = overcommit_ratio_handler,
1497 .procname = "overcommit_kbytes",
1498 .data = &sysctl_overcommit_kbytes,
1499 .maxlen = sizeof(sysctl_overcommit_kbytes),
1501 .proc_handler = overcommit_kbytes_handler,
1504 .procname = "page-cluster",
1505 .data = &page_cluster,
1506 .maxlen = sizeof(int),
1508 .proc_handler = proc_dointvec_minmax,
1512 .procname = "dirty_background_ratio",
1513 .data = &dirty_background_ratio,
1514 .maxlen = sizeof(dirty_background_ratio),
1516 .proc_handler = dirty_background_ratio_handler,
1518 .extra2 = &one_hundred,
1521 .procname = "dirty_background_bytes",
1522 .data = &dirty_background_bytes,
1523 .maxlen = sizeof(dirty_background_bytes),
1525 .proc_handler = dirty_background_bytes_handler,
1529 .procname = "dirty_ratio",
1530 .data = &vm_dirty_ratio,
1531 .maxlen = sizeof(vm_dirty_ratio),
1533 .proc_handler = dirty_ratio_handler,
1535 .extra2 = &one_hundred,
1538 .procname = "dirty_bytes",
1539 .data = &vm_dirty_bytes,
1540 .maxlen = sizeof(vm_dirty_bytes),
1542 .proc_handler = dirty_bytes_handler,
1543 .extra1 = &dirty_bytes_min,
1546 .procname = "dirty_writeback_centisecs",
1547 .data = &dirty_writeback_interval,
1548 .maxlen = sizeof(dirty_writeback_interval),
1550 .proc_handler = dirty_writeback_centisecs_handler,
1553 .procname = "dirty_expire_centisecs",
1554 .data = &dirty_expire_interval,
1555 .maxlen = sizeof(dirty_expire_interval),
1557 .proc_handler = proc_dointvec_minmax,
1561 .procname = "dirtytime_expire_seconds",
1562 .data = &dirtytime_expire_interval,
1563 .maxlen = sizeof(dirty_expire_interval),
1565 .proc_handler = dirtytime_interval_handler,
1569 .procname = "nr_pdflush_threads",
1570 .mode = 0444 /* read-only */,
1571 .proc_handler = pdflush_proc_obsolete,
1574 .procname = "swappiness",
1575 .data = &vm_swappiness,
1576 .maxlen = sizeof(vm_swappiness),
1578 .proc_handler = proc_dointvec_minmax,
1580 .extra2 = &one_hundred,
1582 #ifdef CONFIG_HUGETLB_PAGE
1584 .procname = "nr_hugepages",
1586 .maxlen = sizeof(unsigned long),
1588 .proc_handler = hugetlb_sysctl_handler,
1592 .procname = "nr_hugepages_mempolicy",
1594 .maxlen = sizeof(unsigned long),
1596 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
1600 .procname = "hugetlb_shm_group",
1601 .data = &sysctl_hugetlb_shm_group,
1602 .maxlen = sizeof(gid_t),
1604 .proc_handler = proc_dointvec,
1607 .procname = "hugepages_treat_as_movable",
1608 .data = &hugepages_treat_as_movable,
1609 .maxlen = sizeof(int),
1611 .proc_handler = proc_dointvec,
1614 .procname = "nr_overcommit_hugepages",
1616 .maxlen = sizeof(unsigned long),
1618 .proc_handler = hugetlb_overcommit_handler,
1622 .procname = "lowmem_reserve_ratio",
1623 .data = &sysctl_lowmem_reserve_ratio,
1624 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1626 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
1629 .procname = "drop_caches",
1630 .data = &sysctl_drop_caches,
1631 .maxlen = sizeof(int),
1633 .proc_handler = drop_caches_sysctl_handler,
1637 #ifdef CONFIG_COMPACTION
1639 .procname = "compact_memory",
1640 .data = &sysctl_compact_memory,
1641 .maxlen = sizeof(int),
1643 .proc_handler = sysctl_compaction_handler,
1646 .procname = "extfrag_threshold",
1647 .data = &sysctl_extfrag_threshold,
1648 .maxlen = sizeof(int),
1650 .proc_handler = sysctl_extfrag_handler,
1651 .extra1 = &min_extfrag_threshold,
1652 .extra2 = &max_extfrag_threshold,
1655 .procname = "compact_unevictable_allowed",
1656 .data = &sysctl_compact_unevictable_allowed,
1657 .maxlen = sizeof(int),
1659 .proc_handler = proc_dointvec,
1664 #endif /* CONFIG_COMPACTION */
1666 .procname = "min_free_kbytes",
1667 .data = &min_free_kbytes,
1668 .maxlen = sizeof(min_free_kbytes),
1670 .proc_handler = min_free_kbytes_sysctl_handler,
1674 .procname = "extra_free_kbytes",
1675 .data = &extra_free_kbytes,
1676 .maxlen = sizeof(extra_free_kbytes),
1678 .proc_handler = min_free_kbytes_sysctl_handler,
1682 .procname = "percpu_pagelist_fraction",
1683 .data = &percpu_pagelist_fraction,
1684 .maxlen = sizeof(percpu_pagelist_fraction),
1686 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
1691 .procname = "max_map_count",
1692 .data = &sysctl_max_map_count,
1693 .maxlen = sizeof(sysctl_max_map_count),
1695 .proc_handler = proc_dointvec_minmax,
1700 .procname = "nr_trim_pages",
1701 .data = &sysctl_nr_trim_pages,
1702 .maxlen = sizeof(sysctl_nr_trim_pages),
1704 .proc_handler = proc_dointvec_minmax,
1709 .procname = "laptop_mode",
1710 .data = &laptop_mode,
1711 .maxlen = sizeof(laptop_mode),
1713 .proc_handler = proc_dointvec_jiffies,
1716 .procname = "block_dump",
1717 .data = &block_dump,
1718 .maxlen = sizeof(block_dump),
1720 .proc_handler = proc_dointvec,
1724 .procname = "vfs_cache_pressure",
1725 .data = &sysctl_vfs_cache_pressure,
1726 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1728 .proc_handler = proc_dointvec,
1731 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1733 .procname = "legacy_va_layout",
1734 .data = &sysctl_legacy_va_layout,
1735 .maxlen = sizeof(sysctl_legacy_va_layout),
1737 .proc_handler = proc_dointvec,
1743 .procname = "zone_reclaim_mode",
1744 .data = &zone_reclaim_mode,
1745 .maxlen = sizeof(zone_reclaim_mode),
1747 .proc_handler = proc_dointvec,
1751 .procname = "min_unmapped_ratio",
1752 .data = &sysctl_min_unmapped_ratio,
1753 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1755 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
1757 .extra2 = &one_hundred,
1760 .procname = "min_slab_ratio",
1761 .data = &sysctl_min_slab_ratio,
1762 .maxlen = sizeof(sysctl_min_slab_ratio),
1764 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
1766 .extra2 = &one_hundred,
1771 .procname = "stat_interval",
1772 .data = &sysctl_stat_interval,
1773 .maxlen = sizeof(sysctl_stat_interval),
1775 .proc_handler = proc_dointvec_jiffies,
1780 .procname = "mmap_min_addr",
1781 .data = &dac_mmap_min_addr,
1782 .maxlen = sizeof(unsigned long),
1784 .proc_handler = mmap_min_addr_handler,
1789 .procname = "numa_zonelist_order",
1790 .data = &numa_zonelist_order,
1791 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1793 .proc_handler = numa_zonelist_order_handler,
1796 #if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
1797 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
1799 .procname = "vdso_enabled",
1800 #ifdef CONFIG_X86_32
1801 .data = &vdso32_enabled,
1802 .maxlen = sizeof(vdso32_enabled),
1804 .data = &vdso_enabled,
1805 .maxlen = sizeof(vdso_enabled),
1808 .proc_handler = proc_dointvec,
1812 #ifdef CONFIG_HIGHMEM
1814 .procname = "highmem_is_dirtyable",
1815 .data = &vm_highmem_is_dirtyable,
1816 .maxlen = sizeof(vm_highmem_is_dirtyable),
1818 .proc_handler = proc_dointvec_minmax,
1823 #ifdef CONFIG_MEMORY_FAILURE
1825 .procname = "memory_failure_early_kill",
1826 .data = &sysctl_memory_failure_early_kill,
1827 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1829 .proc_handler = proc_dointvec_minmax,
1834 .procname = "memory_failure_recovery",
1835 .data = &sysctl_memory_failure_recovery,
1836 .maxlen = sizeof(sysctl_memory_failure_recovery),
1838 .proc_handler = proc_dointvec_minmax,
1844 .procname = "user_reserve_kbytes",
1845 .data = &sysctl_user_reserve_kbytes,
1846 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1848 .proc_handler = proc_doulongvec_minmax,
1851 .procname = "admin_reserve_kbytes",
1852 .data = &sysctl_admin_reserve_kbytes,
1853 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1855 .proc_handler = proc_doulongvec_minmax,
1857 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1859 .procname = "mmap_rnd_bits",
1860 .data = &mmap_rnd_bits,
1861 .maxlen = sizeof(mmap_rnd_bits),
1863 .proc_handler = proc_dointvec_minmax,
1864 .extra1 = (void *)&mmap_rnd_bits_min,
1865 .extra2 = (void *)&mmap_rnd_bits_max,
1868 #ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1870 .procname = "mmap_rnd_compat_bits",
1871 .data = &mmap_rnd_compat_bits,
1872 .maxlen = sizeof(mmap_rnd_compat_bits),
1874 .proc_handler = proc_dointvec_minmax,
1875 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1876 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1881 .procname = "swap_ratio",
1882 .data = &sysctl_swap_ratio,
1883 .maxlen = sizeof(sysctl_swap_ratio),
1885 .proc_handler = proc_dointvec_minmax,
1888 .procname = "swap_ratio_enable",
1889 .data = &sysctl_swap_ratio_enable,
1890 .maxlen = sizeof(sysctl_swap_ratio_enable),
1892 .proc_handler = proc_dointvec_minmax,
1898 static struct ctl_table fs_table[] = {
1900 .procname = "inode-nr",
1901 .data = &inodes_stat,
1902 .maxlen = 2*sizeof(long),
1904 .proc_handler = proc_nr_inodes,
1907 .procname = "inode-state",
1908 .data = &inodes_stat,
1909 .maxlen = 7*sizeof(long),
1911 .proc_handler = proc_nr_inodes,
1914 .procname = "file-nr",
1915 .data = &files_stat,
1916 .maxlen = sizeof(files_stat),
1918 .proc_handler = proc_nr_files,
1921 .procname = "file-max",
1922 .data = &files_stat.max_files,
1923 .maxlen = sizeof(files_stat.max_files),
1925 .proc_handler = proc_doulongvec_minmax,
1928 .procname = "nr_open",
1929 .data = &sysctl_nr_open,
1930 .maxlen = sizeof(int),
1932 .proc_handler = proc_dointvec_minmax,
1933 .extra1 = &sysctl_nr_open_min,
1934 .extra2 = &sysctl_nr_open_max,
1937 .procname = "dentry-state",
1938 .data = &dentry_stat,
1939 .maxlen = 6*sizeof(long),
1941 .proc_handler = proc_nr_dentry,
1944 .procname = "overflowuid",
1945 .data = &fs_overflowuid,
1946 .maxlen = sizeof(int),
1948 .proc_handler = proc_dointvec_minmax,
1949 .extra1 = &minolduid,
1950 .extra2 = &maxolduid,
1953 .procname = "overflowgid",
1954 .data = &fs_overflowgid,
1955 .maxlen = sizeof(int),
1957 .proc_handler = proc_dointvec_minmax,
1958 .extra1 = &minolduid,
1959 .extra2 = &maxolduid,
1961 #ifdef CONFIG_FILE_LOCKING
1963 .procname = "leases-enable",
1964 .data = &leases_enable,
1965 .maxlen = sizeof(int),
1967 .proc_handler = proc_dointvec,
1970 #ifdef CONFIG_DNOTIFY
1972 .procname = "dir-notify-enable",
1973 .data = &dir_notify_enable,
1974 .maxlen = sizeof(int),
1976 .proc_handler = proc_dointvec,
1980 #ifdef CONFIG_FILE_LOCKING
1982 .procname = "lease-break-time",
1983 .data = &lease_break_time,
1984 .maxlen = sizeof(int),
1986 .proc_handler = proc_dointvec,
1991 .procname = "aio-nr",
1993 .maxlen = sizeof(aio_nr),
1995 .proc_handler = proc_doulongvec_minmax,
1998 .procname = "aio-max-nr",
1999 .data = &aio_max_nr,
2000 .maxlen = sizeof(aio_max_nr),
2002 .proc_handler = proc_doulongvec_minmax,
2004 #endif /* CONFIG_AIO */
2005 #ifdef CONFIG_INOTIFY_USER
2007 .procname = "inotify",
2009 .child = inotify_table,
2014 .procname = "epoll",
2016 .child = epoll_table,
2021 .procname = "protected_symlinks",
2022 .data = &sysctl_protected_symlinks,
2023 .maxlen = sizeof(int),
2025 .proc_handler = proc_dointvec_minmax,
2030 .procname = "protected_hardlinks",
2031 .data = &sysctl_protected_hardlinks,
2032 .maxlen = sizeof(int),
2034 .proc_handler = proc_dointvec_minmax,
2039 .procname = "suid_dumpable",
2040 .data = &suid_dumpable,
2041 .maxlen = sizeof(int),
2043 .proc_handler = proc_dointvec_minmax_coredump,
2047 #if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
2049 .procname = "binfmt_misc",
2051 .child = sysctl_mount_point,
2055 .procname = "pipe-max-size",
2056 .data = &pipe_max_size,
2057 .maxlen = sizeof(int),
2059 .proc_handler = &pipe_proc_fn,
2060 .extra1 = &pipe_min_size,
2063 .procname = "pipe-user-pages-hard",
2064 .data = &pipe_user_pages_hard,
2065 .maxlen = sizeof(pipe_user_pages_hard),
2067 .proc_handler = proc_doulongvec_minmax,
2070 .procname = "pipe-user-pages-soft",
2071 .data = &pipe_user_pages_soft,
2072 .maxlen = sizeof(pipe_user_pages_soft),
2074 .proc_handler = proc_doulongvec_minmax,
2077 .procname = "mount-max",
2078 .data = &sysctl_mount_max,
2079 .maxlen = sizeof(unsigned int),
2081 .proc_handler = proc_dointvec_minmax,
2087 static struct ctl_table debug_table[] = {
2088 #ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
2090 .procname = "exception-trace",
2091 .data = &show_unhandled_signals,
2092 .maxlen = sizeof(int),
2094 .proc_handler = proc_dointvec
2097 #if defined(CONFIG_OPTPROBES)
2099 .procname = "kprobes-optimization",
2100 .data = &sysctl_kprobes_optimization,
2101 .maxlen = sizeof(int),
2103 .proc_handler = proc_kprobes_optimization_handler,
2111 static struct ctl_table dev_table[] = {
2115 int __init sysctl_init(void)
2117 struct ctl_table_header *hdr;
2119 hdr = register_sysctl_table(sysctl_base_table);
2120 kmemleak_not_leak(hdr);
2124 #endif /* CONFIG_SYSCTL */
2130 #ifdef CONFIG_PROC_SYSCTL
2132 static int _proc_do_string(char *data, int maxlen, int write,
2133 char __user *buffer,
2134 size_t *lenp, loff_t *ppos)
2140 if (!data || !maxlen || !*lenp) {
2146 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
2147 /* Only continue writes not past the end of buffer. */
2149 if (len > maxlen - 1)
2156 /* Start writing from beginning of buffer. */
2162 while ((p - buffer) < *lenp && len < maxlen - 1) {
2163 if (get_user(c, p++))
2165 if (c == 0 || c == '\n')
2186 if (copy_to_user(buffer, data, len))
2189 if (put_user('\n', buffer + len))
2199 static void warn_sysctl_write(struct ctl_table *table)
2201 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2202 "This will not be supported in the future. To silence this\n"
2203 "warning, set kernel.sysctl_writes_strict = -1\n",
2204 current->comm, table->procname);
2208 * proc_dostring - read a string sysctl
2209 * @table: the sysctl table
2210 * @write: %TRUE if this is a write to the sysctl file
2211 * @buffer: the user buffer
2212 * @lenp: the size of the user buffer
2213 * @ppos: file position
2215 * Reads/writes a string from/to the user buffer. If the kernel
2216 * buffer provided is not large enough to hold the string, the
2217 * string is truncated. The copied string is %NULL-terminated.
2218 * If the string is being read by the user process, it is copied
2219 * and a newline '\n' is added. It is truncated if the buffer is
2222 * Returns 0 on success.
2224 int proc_dostring(struct ctl_table *table, int write,
2225 void __user *buffer, size_t *lenp, loff_t *ppos)
2227 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2228 warn_sysctl_write(table);
2230 return _proc_do_string((char *)(table->data), table->maxlen, write,
2231 (char __user *)buffer, lenp, ppos);
2234 static size_t proc_skip_spaces(char **buf)
2237 char *tmp = skip_spaces(*buf);
2243 static void proc_skip_char(char **buf, size_t *size, const char v)
2253 #define TMPBUFLEN 22
2255 * proc_get_long - reads an ASCII formatted integer from a user buffer
2257 * @buf: a kernel buffer
2258 * @size: size of the kernel buffer
2259 * @val: this is where the number will be stored
2260 * @neg: set to %TRUE if number is negative
2261 * @perm_tr: a vector which contains the allowed trailers
2262 * @perm_tr_len: size of the perm_tr vector
2263 * @tr: pointer to store the trailer character
2265 * In case of success %0 is returned and @buf and @size are updated with
2266 * the amount of bytes read. If @tr is non-NULL and a trailing
2267 * character exists (size is non-zero after returning from this
2268 * function), @tr is updated with the trailing character.
2270 static int proc_get_long(char **buf, size_t *size,
2271 unsigned long *val, bool *neg,
2272 const char *perm_tr, unsigned perm_tr_len, char *tr)
2275 char *p, tmp[TMPBUFLEN];
2281 if (len > TMPBUFLEN - 1)
2282 len = TMPBUFLEN - 1;
2284 memcpy(tmp, *buf, len);
2288 if (*p == '-' && *size > 1) {
2296 *val = simple_strtoul(p, &p, 0);
2300 /* We don't know if the next char is whitespace thus we may accept
2301 * invalid integers (e.g. 1234...a) or two integers instead of one
2302 * (e.g. 123...1). So lets not allow such large numbers. */
2303 if (len == TMPBUFLEN - 1)
2306 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2309 if (tr && (len < *size))
2319 * proc_put_long - converts an integer to a decimal ASCII formatted string
2321 * @buf: the user buffer
2322 * @size: the size of the user buffer
2323 * @val: the integer to be converted
2324 * @neg: sign of the number, %TRUE for negative
2326 * In case of success %0 is returned and @buf and @size are updated with
2327 * the amount of bytes written.
2329 static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2333 char tmp[TMPBUFLEN], *p = tmp;
2335 sprintf(p, "%s%lu", neg ? "-" : "", val);
2339 if (copy_to_user(*buf, tmp, len))
2347 static int proc_put_char(void __user **buf, size_t *size, char c)
2350 char __user **buffer = (char __user **)buf;
2351 if (put_user(c, *buffer))
2353 (*size)--, (*buffer)++;
2359 static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
2361 int write, void *data)
2364 *valp = *negp ? -*lvalp : *lvalp;
2369 *lvalp = -(unsigned long)val;
2372 *lvalp = (unsigned long)val;
2378 static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2380 int write, void *data)
2385 if (*lvalp > UINT_MAX)
2389 unsigned int val = *valp;
2391 *lvalp = (unsigned long)val;
2396 static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2398 static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
2399 int write, void __user *buffer,
2400 size_t *lenp, loff_t *ppos,
2401 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2402 int write, void *data),
2405 int *i, vleft, first = 1, err = 0;
2406 unsigned long page = 0;
2410 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2415 i = (int *) tbl_data;
2416 vleft = table->maxlen / sizeof(*i);
2420 conv = do_proc_dointvec_conv;
2424 switch (sysctl_writes_strict) {
2425 case SYSCTL_WRITES_STRICT:
2427 case SYSCTL_WRITES_WARN:
2428 warn_sysctl_write(table);
2435 if (left > PAGE_SIZE - 1)
2436 left = PAGE_SIZE - 1;
2437 page = __get_free_page(GFP_TEMPORARY);
2438 kbuf = (char *) page;
2441 if (copy_from_user(kbuf, buffer, left)) {
2448 for (; left && vleft--; i++, first=0) {
2453 left -= proc_skip_spaces(&kbuf);
2457 err = proc_get_long(&kbuf, &left, &lval, &neg,
2459 sizeof(proc_wspace_sep), NULL);
2462 if (conv(&neg, &lval, i, 1, data)) {
2467 if (conv(&neg, &lval, i, 0, data)) {
2472 err = proc_put_char(&buffer, &left, '\t');
2475 err = proc_put_long(&buffer, &left, lval, neg);
2481 if (!write && !first && left && !err)
2482 err = proc_put_char(&buffer, &left, '\n');
2483 if (write && !err && left)
2484 left -= proc_skip_spaces(&kbuf);
2489 return err ? : -EINVAL;
2497 static int do_proc_dointvec(struct ctl_table *table, int write,
2498 void __user *buffer, size_t *lenp, loff_t *ppos,
2499 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
2500 int write, void *data),
2503 return __do_proc_dointvec(table->data, table, write,
2504 buffer, lenp, ppos, conv, data);
2508 * proc_dointvec - read a vector of integers
2509 * @table: the sysctl table
2510 * @write: %TRUE if this is a write to the sysctl file
2511 * @buffer: the user buffer
2512 * @lenp: the size of the user buffer
2513 * @ppos: file position
2515 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2516 * values from/to the user buffer, treated as an ASCII string.
2518 * Returns 0 on success.
2520 int proc_dointvec(struct ctl_table *table, int write,
2521 void __user *buffer, size_t *lenp, loff_t *ppos)
2523 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2527 * proc_douintvec - read a vector of unsigned integers
2528 * @table: the sysctl table
2529 * @write: %TRUE if this is a write to the sysctl file
2530 * @buffer: the user buffer
2531 * @lenp: the size of the user buffer
2532 * @ppos: file position
2534 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2535 * values from/to the user buffer, treated as an ASCII string.
2537 * Returns 0 on success.
2539 int proc_douintvec(struct ctl_table *table, int write,
2540 void __user *buffer, size_t *lenp, loff_t *ppos)
2542 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2543 do_proc_douintvec_conv, NULL);
2547 * Taint values can only be increased
2548 * This means we can safely use a temporary.
2550 static int proc_taint(struct ctl_table *table, int write,
2551 void __user *buffer, size_t *lenp, loff_t *ppos)
2554 unsigned long tmptaint = get_taint();
2557 if (write && !capable(CAP_SYS_ADMIN))
2562 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
2568 * Poor man's atomic or. Not worth adding a primitive
2569 * to everyone's atomic.h for this
2572 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2573 if ((tmptaint >> i) & 1)
2574 add_taint(i, LOCKDEP_STILL_OK);
2581 #ifdef CONFIG_PRINTK
2582 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
2583 void __user *buffer, size_t *lenp, loff_t *ppos)
2585 if (write && !capable(CAP_SYS_ADMIN))
2588 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2592 struct do_proc_dointvec_minmax_conv_param {
2597 static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2599 int write, void *data)
2601 struct do_proc_dointvec_minmax_conv_param *param = data;
2603 int val = *negp ? -*lvalp : *lvalp;
2604 if ((param->min && *param->min > val) ||
2605 (param->max && *param->max < val))
2612 *lvalp = -(unsigned long)val;
2615 *lvalp = (unsigned long)val;
2622 * proc_dointvec_minmax - read a vector of integers with min/max values
2623 * @table: the sysctl table
2624 * @write: %TRUE if this is a write to the sysctl file
2625 * @buffer: the user buffer
2626 * @lenp: the size of the user buffer
2627 * @ppos: file position
2629 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2630 * values from/to the user buffer, treated as an ASCII string.
2632 * This routine will ensure the values are within the range specified by
2633 * table->extra1 (min) and table->extra2 (max).
2635 * Returns 0 on success.
2637 int proc_dointvec_minmax(struct ctl_table *table, int write,
2638 void __user *buffer, size_t *lenp, loff_t *ppos)
2640 struct do_proc_dointvec_minmax_conv_param param = {
2641 .min = (int *) table->extra1,
2642 .max = (int *) table->extra2,
2644 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2645 do_proc_dointvec_minmax_conv, ¶m);
2648 static void validate_coredump_safety(void)
2650 #ifdef CONFIG_COREDUMP
2651 if (suid_dumpable == SUID_DUMP_ROOT &&
2652 core_pattern[0] != '/' && core_pattern[0] != '|') {
2653 printk(KERN_WARNING "Unsafe core_pattern used with "\
2654 "suid_dumpable=2. Pipe handler or fully qualified "\
2655 "core dump path required.\n");
2660 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2661 void __user *buffer, size_t *lenp, loff_t *ppos)
2663 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2665 validate_coredump_safety();
2669 #ifdef CONFIG_COREDUMP
2670 static int proc_dostring_coredump(struct ctl_table *table, int write,
2671 void __user *buffer, size_t *lenp, loff_t *ppos)
2673 int error = proc_dostring(table, write, buffer, lenp, ppos);
2675 validate_coredump_safety();
2680 static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
2681 void __user *buffer,
2682 size_t *lenp, loff_t *ppos,
2683 unsigned long convmul,
2684 unsigned long convdiv)
2686 unsigned long *i, *min, *max;
2687 int vleft, first = 1, err = 0;
2688 unsigned long page = 0;
2692 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
2697 i = (unsigned long *) data;
2698 min = (unsigned long *) table->extra1;
2699 max = (unsigned long *) table->extra2;
2700 vleft = table->maxlen / sizeof(unsigned long);
2705 switch (sysctl_writes_strict) {
2706 case SYSCTL_WRITES_STRICT:
2708 case SYSCTL_WRITES_WARN:
2709 warn_sysctl_write(table);
2716 if (left > PAGE_SIZE - 1)
2717 left = PAGE_SIZE - 1;
2718 page = __get_free_page(GFP_TEMPORARY);
2719 kbuf = (char *) page;
2722 if (copy_from_user(kbuf, buffer, left)) {
2729 for (; left && vleft--; i++, first = 0) {
2735 left -= proc_skip_spaces(&kbuf);
2737 err = proc_get_long(&kbuf, &left, &val, &neg,
2739 sizeof(proc_wspace_sep), NULL);
2744 val = convmul * val / convdiv;
2745 if ((min && val < *min) || (max && val > *max))
2749 val = convdiv * (*i) / convmul;
2751 err = proc_put_char(&buffer, &left, '\t');
2755 err = proc_put_long(&buffer, &left, val, false);
2761 if (!write && !first && left && !err)
2762 err = proc_put_char(&buffer, &left, '\n');
2764 left -= proc_skip_spaces(&kbuf);
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 > LONG_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)) {
3029 unsigned long page = 0;
3032 if (left > PAGE_SIZE - 1)
3033 left = PAGE_SIZE - 1;
3035 page = __get_free_page(GFP_TEMPORARY);
3036 kbuf = (char *) page;
3039 if (copy_from_user(kbuf, buffer, left)) {
3045 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
3051 proc_skip_char(&kbuf, &left, '\n');
3052 while (!err && left) {
3053 unsigned long val_a, val_b;
3056 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
3060 if (val_a >= bitmap_len || neg) {
3072 err = proc_get_long(&kbuf, &left, &val_b,
3073 &neg, tr_b, sizeof(tr_b),
3077 if (val_b >= bitmap_len || neg ||
3088 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
3090 proc_skip_char(&kbuf, &left, '\n');
3094 unsigned long bit_a, bit_b = 0;
3097 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3098 if (bit_a >= bitmap_len)
3100 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3104 err = proc_put_char(&buffer, &left, ',');
3108 err = proc_put_long(&buffer, &left, bit_a, false);
3111 if (bit_a != bit_b) {
3112 err = proc_put_char(&buffer, &left, '-');
3115 err = proc_put_long(&buffer, &left, bit_b, false);
3123 err = proc_put_char(&buffer, &left, '\n');
3129 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3131 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
3143 #else /* CONFIG_PROC_SYSCTL */
3145 int proc_dostring(struct ctl_table *table, int write,
3146 void __user *buffer, size_t *lenp, loff_t *ppos)
3151 int proc_dointvec(struct ctl_table *table, int write,
3152 void __user *buffer, size_t *lenp, loff_t *ppos)
3157 int proc_douintvec(struct ctl_table *table, int write,
3158 void __user *buffer, size_t *lenp, loff_t *ppos)
3163 int proc_dointvec_minmax(struct ctl_table *table, int write,
3164 void __user *buffer, size_t *lenp, loff_t *ppos)
3169 int proc_dointvec_jiffies(struct ctl_table *table, int write,
3170 void __user *buffer, size_t *lenp, loff_t *ppos)
3175 int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
3176 void __user *buffer, size_t *lenp, loff_t *ppos)
3181 int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
3182 void __user *buffer, size_t *lenp, loff_t *ppos)
3187 int proc_doulongvec_minmax(struct ctl_table *table, int write,
3188 void __user *buffer, size_t *lenp, loff_t *ppos)
3193 int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
3194 void __user *buffer,
3195 size_t *lenp, loff_t *ppos)
3201 #endif /* CONFIG_PROC_SYSCTL */
3204 * No sense putting this after each symbol definition, twice,
3205 * exception granted :-)
3207 EXPORT_SYMBOL(proc_dointvec);
3208 EXPORT_SYMBOL(proc_douintvec);
3209 EXPORT_SYMBOL(proc_dointvec_jiffies);
3210 EXPORT_SYMBOL(proc_dointvec_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);