blob: 7d1008be6173313c807b2abb23f3171ef05cddc8 [file] [log] [blame]
Thomas Gleixner457c8992019-05-19 13:08:55 +01001// SPDX-License-Identifier: GPL-2.0-only
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
3 * sysctl.c: General linux system control interface
4 *
5 * Begun 24 March 1995, Stephen Tweedie
6 * Added /proc support, Dec 1995
7 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
8 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
9 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
10 * Dynamic registration fixes, Stephen Tweedie.
11 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
12 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
13 * Horn.
14 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
15 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
16 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
17 * Wendling.
18 * The list_for_each() macro wasn't appropriate for the sysctl loop.
19 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
20 */
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <linux/module.h>
Christoph Hellwige2e40f22015-02-22 08:58:50 -080023#include <linux/aio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <linux/mm.h>
25#include <linux/swap.h>
26#include <linux/slab.h>
27#include <linux/sysctl.h>
Akinobu Mita5a04cca2012-03-28 14:42:50 -070028#include <linux/bitmap.h>
Dave Youngd33ed522010-03-10 15:23:59 -080029#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080030#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070031#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070032#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070033#include <linux/ctype.h>
Steven Rostedtfd4b6162012-07-30 14:42:48 -070034#include <linux/kmemleak.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070035#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/init.h>
37#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010038#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030039#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <linux/sysrq.h>
41#include <linux/highuid.h>
42#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020043#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070044#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070047#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#include <linux/times.h>
49#include <linux/limits.h>
50#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020051#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070053#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080054#include <linux/nfs_fs.h>
55#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070056#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020057#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020058#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050059#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020060#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070061#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040062#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070063#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000064#include <linux/binfmts.h>
Clark Williamscf4aebc22013-02-07 09:46:59 -060065#include <linux/sched/sysctl.h>
Ingo Molnarf7ccbae2017-02-08 18:51:30 +010066#include <linux/sched/coredump.h>
Kees Cook79847542014-01-23 15:55:59 -080067#include <linux/kexec.h>
Alexei Starovoitov1be7f752015-10-07 22:23:21 -070068#include <linux/bpf.h>
Eric W. Biedermand2921682016-09-28 00:27:17 -050069#include <linux/mount.h>
Peter Xucefdca02019-05-13 17:16:41 -070070#include <linux/userfaultfd_k.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
Christian Brauner7f2923c2019-03-07 16:29:40 -080072#include "../lib/kstrtox.h"
73
Linus Torvalds7c0f6ba2016-12-24 11:46:01 -080074#include <linux/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070075#include <asm/processor.h>
76
Andi Kleen29cbc782006-09-30 01:47:55 +020077#ifdef CONFIG_X86
78#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010079#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010080#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020081#endif
David Howellsd550bbd2012-03-28 18:30:03 +010082#ifdef CONFIG_SPARC
83#include <asm/setup.h>
84#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080085#ifdef CONFIG_BSD_PROCESS_ACCT
86#include <linux/acct.h>
87#endif
Dave Young4f0e0562010-03-10 15:24:09 -080088#ifdef CONFIG_RT_MUTEXES
89#include <linux/rtmutex.h>
90#endif
Dave Young2edf5e42010-03-10 15:24:10 -080091#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
92#include <linux/lockdep.h>
93#endif
Dave Young15485a42010-03-10 15:24:07 -080094#ifdef CONFIG_CHR_DEV_SG
95#include <scsi/sg.h>
96#endif
Alexander Popov964c9df2018-08-17 01:17:03 +030097#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
98#include <linux/stackleak.h>
99#endif
Don Zickus58687ac2010-05-07 17:11:44 -0400100#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -0500101#include <linux/nmi.h>
102#endif
103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104#if defined(CONFIG_SYSCTL)
105
106/* External variables not in a header file. */
Alan Coxd6e71142005-06-23 00:09:43 -0700107extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700108#ifdef CONFIG_COREDUMP
109extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700111extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700112#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800115extern int percpu_pagelist_fraction;
Arjan van de Ven97455122008-01-25 21:08:34 +0100116extern int latencytop_enabled;
Alexey Dobriyan9b80a182016-09-02 00:38:52 +0300117extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000118#ifndef CONFIG_MMU
119extern int sysctl_nr_trim_pages;
120#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700122/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400123#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700124static int sixty = 60;
125#endif
126
Aaron Tomlin270750db2014-01-20 17:34:13 +0000127static int __maybe_unused neg_one = -1;
128
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700129static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700130static int __maybe_unused one = 1;
131static int __maybe_unused two = 2;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700132static int __maybe_unused four = 4;
Will Deacon9002b212019-04-05 18:39:38 -0700133static unsigned long zero_ul;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800134static unsigned long one_ul = 1;
Christian Brauner32a5ad92019-03-07 16:29:43 -0800135static unsigned long long_max = LONG_MAX;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700136static int one_hundred = 100;
Johannes Weiner795ae7a2016-03-17 14:19:14 -0700137static int one_thousand = 1000;
Dave Youngaf913222009-09-22 16:43:33 -0700138#ifdef CONFIG_PRINTK
139static int ten_thousand = 10000;
140#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300141#ifdef CONFIG_PERF_EVENTS
142static int six_hundred_forty_kb = 640 * 1024;
143#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700144
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700145/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
146static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
147
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
149static int maxolduid = 65535;
150static int minolduid;
151
152static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700153static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
Dmitry Vyukova2e51442018-08-21 21:55:52 -0700155/*
156 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
157 * and hung_task_check_interval_secs
158 */
Liu Hua80df2842014-04-07 15:38:57 -0700159#ifdef CONFIG_DETECT_HUNG_TASK
160static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
161#endif
162
Dave Youngd14f1722010-02-25 20:28:57 -0500163#ifdef CONFIG_INOTIFY_USER
164#include <linux/inotify.h>
165#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700166#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167#endif
168
169#ifdef __hppa__
170extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530171#endif
172
173#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174extern int unaligned_enabled;
175#endif
176
Jes Sorensend2b176e2006-02-28 09:42:23 -0800177#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800178extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800179#endif
180
Vineet Guptab6fca722013-01-09 20:06:28 +0530181#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
182extern int no_unaligned_warning;
183#endif
184
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700185#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700186
Luis R. Rodrigueza19ac332017-07-12 14:33:30 -0700187/**
188 * enum sysctl_writes_mode - supported sysctl write modes
189 *
190 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
191 * to be written, and multiple writes on the same sysctl file descriptor
192 * will rewrite the sysctl value, regardless of file position. No warning
193 * is issued when the initial position is not 0.
194 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
195 * not 0.
196 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
197 * file position 0 and the value must be fully contained in the buffer
198 * sent to the write syscall. If dealing with strings respect the file
199 * position, but restrict this to the max length of the buffer, anything
200 * passed the max lenght will be ignored. Multiple writes will append
201 * to the buffer.
202 *
203 * These write modes control how current file position affects the behavior of
204 * updating sysctl values through the proc interface on each write.
205 */
206enum sysctl_writes_mode {
207 SYSCTL_WRITES_LEGACY = -1,
208 SYSCTL_WRITES_WARN = 0,
209 SYSCTL_WRITES_STRICT = 1,
210};
Kees Cookf4aacea2014-06-06 14:37:19 -0700211
Luis R. Rodrigueza19ac332017-07-12 14:33:30 -0700212static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700213
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700214static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700215 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700216static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800217 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700218#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700219
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700220#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700221static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700222 void __user *buffer, size_t *lenp, loff_t *ppos);
223#endif
224
Kees Cook54b50192012-07-30 14:39:18 -0700225static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
226 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700227#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700228static int proc_dostring_coredump(struct ctl_table *table, int write,
229 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700230#endif
Eric Biggers319e0a22018-02-06 15:41:49 -0800231static int proc_dopipe_max_size(struct ctl_table *table, int write,
232 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexei Starovoitov3fcc55302019-02-27 18:30:44 -0800233#ifdef CONFIG_BPF_SYSCALL
Alexei Starovoitov492ecee2019-02-25 14:28:39 -0800234static int proc_dointvec_minmax_bpf_stats(struct ctl_table *table, int write,
235 void __user *buffer, size_t *lenp,
236 loff_t *ppos);
Alexei Starovoitov3fcc55302019-02-27 18:30:44 -0800237#endif
Kees Cook54b50192012-07-30 14:39:18 -0700238
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700239#ifdef CONFIG_MAGIC_SYSRQ
Randy Dunlap5f733e82018-08-21 22:01:06 -0700240/* Note: sysrq code uses its own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100241static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700242
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700243static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700244 void __user *buffer, size_t *lenp,
245 loff_t *ppos)
246{
247 int error;
248
249 error = proc_dointvec(table, write, buffer, lenp, ppos);
250 if (error)
251 return error;
252
253 if (write)
254 sysrq_toggle_support(__sysrq_enabled);
255
256 return 0;
257}
258
259#endif
260
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700261static struct ctl_table kern_table[];
262static struct ctl_table vm_table[];
263static struct ctl_table fs_table[];
264static struct ctl_table debug_table[];
265static struct ctl_table dev_table[];
266extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800267#ifdef CONFIG_EPOLL
268extern struct ctl_table epoll_table[];
269#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
Luis R. Rodriguezceb18132018-03-10 06:14:51 -0800271#ifdef CONFIG_FW_LOADER_USER_HELPER
272extern struct ctl_table firmware_config_table[];
273#endif
274
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
276int sysctl_legacy_va_layout;
277#endif
278
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279/* The default sysctl tables: */
280
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800281static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 .procname = "kernel",
284 .mode = 0555,
285 .child = kern_table,
286 },
287 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288 .procname = "vm",
289 .mode = 0555,
290 .child = vm_table,
291 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 .procname = "fs",
294 .mode = 0555,
295 .child = fs_table,
296 },
297 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 .procname = "debug",
299 .mode = 0555,
300 .child = debug_table,
301 },
302 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 .procname = "dev",
304 .mode = 0555,
305 .child = dev_table,
306 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700307 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700308};
309
Ingo Molnar77e54a12007-07-09 18:52:00 +0200310#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100311static int min_sched_granularity_ns = 100000; /* 100 usecs */
312static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
313static int min_wakeup_granularity_ns; /* 0 usecs */
314static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200315#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100316static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
317static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200318#endif /* CONFIG_SMP */
319#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200320
Mel Gorman5e771902010-05-24 14:32:31 -0700321#ifdef CONFIG_COMPACTION
322static int min_extfrag_threshold;
323static int max_extfrag_threshold = 1000;
324#endif
325
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700326static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200327 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200328 .procname = "sched_child_runs_first",
329 .data = &sysctl_sched_child_runs_first,
330 .maxlen = sizeof(unsigned int),
331 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800332 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200333 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200334#ifdef CONFIG_SCHED_DEBUG
335 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100336 .procname = "sched_min_granularity_ns",
337 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200338 .maxlen = sizeof(unsigned int),
339 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800340 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100341 .extra1 = &min_sched_granularity_ns,
342 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200343 },
344 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200345 .procname = "sched_latency_ns",
346 .data = &sysctl_sched_latency,
347 .maxlen = sizeof(unsigned int),
348 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800349 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200350 .extra1 = &min_sched_granularity_ns,
351 .extra2 = &max_sched_granularity_ns,
352 },
353 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200354 .procname = "sched_wakeup_granularity_ns",
355 .data = &sysctl_sched_wakeup_granularity,
356 .maxlen = sizeof(unsigned int),
357 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800358 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200359 .extra1 = &min_wakeup_granularity_ns,
360 .extra2 = &max_wakeup_granularity_ns,
361 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200362#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200363 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100364 .procname = "sched_tunable_scaling",
365 .data = &sysctl_sched_tunable_scaling,
366 .maxlen = sizeof(enum sched_tunable_scaling),
367 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800368 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100369 .extra1 = &min_sched_tunable_scaling,
370 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200371 },
372 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900373 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200374 .data = &sysctl_sched_migration_cost,
375 .maxlen = sizeof(unsigned int),
376 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800377 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200378 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100379 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100380 .procname = "sched_nr_migrate",
381 .data = &sysctl_sched_nr_migrate,
382 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100383 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800384 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100385 },
Mel Gormancb251762016-02-05 09:08:36 +0000386#ifdef CONFIG_SCHEDSTATS
387 {
388 .procname = "sched_schedstats",
389 .data = NULL,
390 .maxlen = sizeof(unsigned int),
391 .mode = 0644,
392 .proc_handler = sysctl_schedstats,
393 .extra1 = &zero,
394 .extra2 = &one,
395 },
396#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200397#endif /* CONFIG_SMP */
398#ifdef CONFIG_NUMA_BALANCING
399 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200400 .procname = "numa_balancing_scan_delay_ms",
401 .data = &sysctl_numa_balancing_scan_delay,
402 .maxlen = sizeof(unsigned int),
403 .mode = 0644,
404 .proc_handler = proc_dointvec,
405 },
406 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200407 .procname = "numa_balancing_scan_period_min_ms",
408 .data = &sysctl_numa_balancing_scan_period_min,
409 .maxlen = sizeof(unsigned int),
410 .mode = 0644,
411 .proc_handler = proc_dointvec,
412 },
413 {
414 .procname = "numa_balancing_scan_period_max_ms",
415 .data = &sysctl_numa_balancing_scan_period_max,
416 .maxlen = sizeof(unsigned int),
417 .mode = 0644,
418 .proc_handler = proc_dointvec,
419 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200420 {
421 .procname = "numa_balancing_scan_size_mb",
422 .data = &sysctl_numa_balancing_scan_size,
423 .maxlen = sizeof(unsigned int),
424 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400425 .proc_handler = proc_dointvec_minmax,
426 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200427 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100428 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800429 .procname = "numa_balancing",
430 .data = NULL, /* filled in by handler */
431 .maxlen = sizeof(unsigned int),
432 .mode = 0644,
433 .proc_handler = sysctl_numa_balancing,
434 .extra1 = &zero,
435 .extra2 = &one,
436 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200437#endif /* CONFIG_NUMA_BALANCING */
438#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200439 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100440 .procname = "sched_rt_period_us",
441 .data = &sysctl_sched_rt_period,
442 .maxlen = sizeof(unsigned int),
443 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800444 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100445 },
446 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100447 .procname = "sched_rt_runtime_us",
448 .data = &sysctl_sched_rt_runtime,
449 .maxlen = sizeof(int),
450 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800451 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100452 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600453 {
454 .procname = "sched_rr_timeslice_ms",
Shile Zhang975e1552017-01-28 22:00:49 +0800455 .data = &sysctl_sched_rr_timeslice,
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600456 .maxlen = sizeof(int),
457 .mode = 0644,
458 .proc_handler = sched_rr_handler,
459 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100460#ifdef CONFIG_SCHED_AUTOGROUP
461 {
462 .procname = "sched_autogroup_enabled",
463 .data = &sysctl_sched_autogroup_enabled,
464 .maxlen = sizeof(unsigned int),
465 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800466 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100467 .extra1 = &zero,
468 .extra2 = &one,
469 },
470#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700471#ifdef CONFIG_CFS_BANDWIDTH
472 {
473 .procname = "sched_cfs_bandwidth_slice_us",
474 .data = &sysctl_sched_cfs_bandwidth_slice,
475 .maxlen = sizeof(unsigned int),
476 .mode = 0644,
477 .proc_handler = proc_dointvec_minmax,
478 .extra1 = &one,
479 },
480#endif
Quentin Perret8d5d0cf2018-12-03 09:56:23 +0000481#if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
482 {
483 .procname = "sched_energy_aware",
484 .data = &sysctl_sched_energy_aware,
485 .maxlen = sizeof(unsigned int),
486 .mode = 0644,
487 .proc_handler = sched_energy_aware_handler,
488 .extra1 = &zero,
489 .extra2 = &one,
490 },
491#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700492#ifdef CONFIG_PROVE_LOCKING
493 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700494 .procname = "prove_locking",
495 .data = &prove_locking,
496 .maxlen = sizeof(int),
497 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800498 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700499 },
500#endif
501#ifdef CONFIG_LOCK_STAT
502 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700503 .procname = "lock_stat",
504 .data = &lock_stat,
505 .maxlen = sizeof(int),
506 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800507 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700508 },
509#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200510 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 .procname = "panic",
512 .data = &panic_timeout,
513 .maxlen = sizeof(int),
514 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800515 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 },
Alex Kelly046d6622012-10-04 17:15:23 -0700517#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 .procname = "core_uses_pid",
520 .data = &core_uses_pid,
521 .maxlen = sizeof(int),
522 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800523 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700524 },
525 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 .procname = "core_pattern",
527 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700528 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700530 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 },
Neil Hormana2939802009-09-23 15:56:56 -0700532 {
Neil Hormana2939802009-09-23 15:56:56 -0700533 .procname = "core_pipe_limit",
534 .data = &core_pipe_limit,
535 .maxlen = sizeof(unsigned int),
536 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800537 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700538 },
Alex Kelly046d6622012-10-04 17:15:23 -0700539#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800540#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700543 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800544 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800545 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700547 {
548 .procname = "sysctl_writes_strict",
549 .data = &sysctl_writes_strict,
550 .maxlen = sizeof(int),
551 .mode = 0644,
552 .proc_handler = proc_dointvec_minmax,
553 .extra1 = &neg_one,
554 .extra2 = &one,
555 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800556#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100557#ifdef CONFIG_LATENCYTOP
558 {
559 .procname = "latencytop",
560 .data = &latencytop_enabled,
561 .maxlen = sizeof(int),
562 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000563 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100564 },
565#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566#ifdef CONFIG_BLK_DEV_INITRD
567 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 .procname = "real-root-dev",
569 .data = &real_root_dev,
570 .maxlen = sizeof(int),
571 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800572 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 },
574#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700575 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700576 .procname = "print-fatal-signals",
577 .data = &print_fatal_signals,
578 .maxlen = sizeof(int),
579 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800580 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700581 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700582#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 .procname = "reboot-cmd",
585 .data = reboot_command,
586 .maxlen = 256,
587 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800588 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 },
590 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 .procname = "stop-a",
592 .data = &stop_a_enabled,
593 .maxlen = sizeof (int),
594 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800595 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 },
597 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 .procname = "scons-poweroff",
599 .data = &scons_pwroff,
600 .maxlen = sizeof (int),
601 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800602 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 },
604#endif
David S. Miller08714202008-11-16 23:49:24 -0800605#ifdef CONFIG_SPARC64
606 {
David S. Miller08714202008-11-16 23:49:24 -0800607 .procname = "tsb-ratio",
608 .data = &sysctl_tsb_ratio,
609 .maxlen = sizeof (int),
610 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800611 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800612 },
613#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614#ifdef __hppa__
615 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 .procname = "soft-power",
617 .data = &pwrsw_enabled,
618 .maxlen = sizeof (int),
619 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800620 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530622#endif
623#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 .procname = "unaligned-trap",
626 .data = &unaligned_enabled,
627 .maxlen = sizeof (int),
628 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800629 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 },
631#endif
632 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 .procname = "ctrl-alt-del",
634 .data = &C_A_D,
635 .maxlen = sizeof(int),
636 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800637 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400639#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200640 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200641 .procname = "ftrace_enabled",
642 .data = &ftrace_enabled,
643 .maxlen = sizeof(int),
644 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800645 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200646 },
647#endif
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500648#ifdef CONFIG_STACK_TRACER
649 {
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500650 .procname = "stack_tracer_enabled",
651 .data = &stack_tracer_enabled,
652 .maxlen = sizeof(int),
653 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800654 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500655 },
656#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400657#ifdef CONFIG_TRACING
658 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100659 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400660 .data = &ftrace_dump_on_oops,
661 .maxlen = sizeof(int),
662 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800663 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400664 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400665 {
666 .procname = "traceoff_on_warning",
667 .data = &__disable_trace_on_warning,
668 .maxlen = sizeof(__disable_trace_on_warning),
669 .mode = 0644,
670 .proc_handler = proc_dointvec,
671 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500672 {
673 .procname = "tracepoint_printk",
674 .data = &tracepoint_printk,
675 .maxlen = sizeof(tracepoint_printk),
676 .mode = 0644,
Steven Rostedt (Red Hat)423917452016-11-23 15:52:45 -0500677 .proc_handler = tracepoint_printk_sysctl,
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500678 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400679#endif
Dave Young2965faa2015-09-09 15:38:55 -0700680#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800681 {
682 .procname = "kexec_load_disabled",
683 .data = &kexec_load_disabled,
684 .maxlen = sizeof(int),
685 .mode = 0644,
686 /* only handle a transition from default "0" to "1" */
687 .proc_handler = proc_dointvec_minmax,
688 .extra1 = &one,
689 .extra2 = &one,
690 },
691#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200692#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 .procname = "modprobe",
695 .data = &modprobe_path,
696 .maxlen = KMOD_PATH_LEN,
697 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800698 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 },
Kees Cook3d433212009-04-02 15:49:29 -0700700 {
Kees Cook3d433212009-04-02 15:49:29 -0700701 .procname = "modules_disabled",
702 .data = &modules_disabled,
703 .maxlen = sizeof(int),
704 .mode = 0644,
705 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800706 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700707 .extra1 = &one,
708 .extra2 = &one,
709 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700711#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100714 .data = &uevent_helper,
715 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800717 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 },
Michael Marineau86d56132014-04-10 14:09:31 -0700719#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720#ifdef CONFIG_CHR_DEV_SG
721 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 .procname = "sg-big-buff",
723 .data = &sg_big_buff,
724 .maxlen = sizeof (int),
725 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800726 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 },
728#endif
729#ifdef CONFIG_BSD_PROCESS_ACCT
730 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 .procname = "acct",
732 .data = &acct_parm,
733 .maxlen = 3*sizeof(int),
734 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800735 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 },
737#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738#ifdef CONFIG_MAGIC_SYSRQ
739 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800741 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 .maxlen = sizeof (int),
743 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700744 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 },
746#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700747#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700750 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 .maxlen = sizeof (int),
752 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800753 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700755#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700758 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 .maxlen = sizeof(int),
760 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700761 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 },
763 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 .procname = "random",
765 .mode = 0555,
766 .child = random_table,
767 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 {
Eric Paris17f60a72011-04-01 17:07:50 -0400769 .procname = "usermodehelper",
770 .mode = 0555,
771 .child = usermodehelper_table,
772 },
Luis R. Rodriguezceb18132018-03-10 06:14:51 -0800773#ifdef CONFIG_FW_LOADER_USER_HELPER
774 {
775 .procname = "firmware_config",
776 .mode = 0555,
777 .child = firmware_config_table,
778 },
779#endif
Eric Paris17f60a72011-04-01 17:07:50 -0400780 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 .procname = "overflowuid",
782 .data = &overflowuid,
783 .maxlen = sizeof(int),
784 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800785 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 .extra1 = &minolduid,
787 .extra2 = &maxolduid,
788 },
789 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 .procname = "overflowgid",
791 .data = &overflowgid,
792 .maxlen = sizeof(int),
793 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800794 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 .extra1 = &minolduid,
796 .extra2 = &maxolduid,
797 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800798#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799#ifdef CONFIG_MATHEMU
800 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 .procname = "ieee_emulation_warnings",
802 .data = &sysctl_ieee_emulation_warnings,
803 .maxlen = sizeof(int),
804 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800805 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 },
807#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200810 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 .maxlen = sizeof(int),
812 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800813 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 },
815#endif
816 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 .procname = "pid_max",
818 .data = &pid_max,
819 .maxlen = sizeof (int),
820 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800821 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 .extra1 = &pid_max_min,
823 .extra2 = &pid_max_max,
824 },
825 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826 .procname = "panic_on_oops",
827 .data = &panic_on_oops,
828 .maxlen = sizeof(int),
829 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800830 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 },
Feng Tang81c9d432019-01-03 15:28:20 -0800832 {
833 .procname = "panic_print",
834 .data = &panic_print,
835 .maxlen = sizeof(unsigned long),
836 .mode = 0644,
837 .proc_handler = proc_doulongvec_minmax,
838 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800839#if defined CONFIG_PRINTK
840 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800841 .procname = "printk",
842 .data = &console_loglevel,
843 .maxlen = 4*sizeof(int),
844 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800845 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800846 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700849 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 .maxlen = sizeof(int),
851 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800852 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853 },
854 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700856 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 .maxlen = sizeof(int),
858 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800859 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860 },
Dave Youngaf913222009-09-22 16:43:33 -0700861 {
Dave Youngaf913222009-09-22 16:43:33 -0700862 .procname = "printk_delay",
863 .data = &printk_delay_msec,
864 .maxlen = sizeof(int),
865 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800866 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700867 .extra1 = &zero,
868 .extra2 = &ten_thousand,
869 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700871 .procname = "printk_devkmsg",
872 .data = devkmsg_log_str,
873 .maxlen = DEVKMSG_STR_MAX_SIZE,
874 .mode = 0644,
875 .proc_handler = devkmsg_sysctl_set_loglvl,
876 },
877 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800878 .procname = "dmesg_restrict",
879 .data = &dmesg_restrict,
880 .maxlen = sizeof(int),
881 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700882 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800883 .extra1 = &zero,
884 .extra2 = &one,
885 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800886 {
887 .procname = "kptr_restrict",
888 .data = &kptr_restrict,
889 .maxlen = sizeof(int),
890 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700891 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800892 .extra1 = &zero,
893 .extra2 = &two,
894 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800895#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800896 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 .procname = "ngroups_max",
898 .data = &ngroups_max,
899 .maxlen = sizeof (int),
900 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800901 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 },
Dan Ballard73efc032011-10-31 17:11:20 -0700903 {
904 .procname = "cap_last_cap",
905 .data = (void *)&cap_last_cap,
906 .maxlen = sizeof(int),
907 .mode = 0444,
908 .proc_handler = proc_dointvec,
909 },
Don Zickus58687ac2010-05-07 17:11:44 -0400910#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500911 {
Don Zickus58687ac2010-05-07 17:11:44 -0400912 .procname = "watchdog",
Thomas Gleixner7feeb9c2017-09-12 21:37:15 +0200913 .data = &watchdog_user_enabled,
914 .maxlen = sizeof(int),
915 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700916 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700917 .extra1 = &zero,
918 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400919 },
920 {
921 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700922 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400923 .maxlen = sizeof(int),
924 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700925 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800926 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400927 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500928 },
Don Zickus2508ce12010-05-07 17:11:46 -0400929 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700930 .procname = "nmi_watchdog",
Thomas Gleixner7feeb9c2017-09-12 21:37:15 +0200931 .data = &nmi_watchdog_user_enabled,
932 .maxlen = sizeof(int),
Thomas Gleixner51d40522017-09-12 21:37:14 +0200933 .mode = NMI_WATCHDOG_SYSCTL_PERM,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700934 .proc_handler = proc_nmi_watchdog,
935 .extra1 = &zero,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700936 .extra2 = &one,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700937 },
938 {
Nicholas Piggin05a4a952017-07-12 14:35:46 -0700939 .procname = "watchdog_cpumask",
940 .data = &watchdog_cpumask_bits,
941 .maxlen = NR_CPUS,
942 .mode = 0644,
943 .proc_handler = proc_watchdog_cpumask,
944 },
945#ifdef CONFIG_SOFTLOCKUP_DETECTOR
946 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700947 .procname = "soft_watchdog",
Thomas Gleixner7feeb9c2017-09-12 21:37:15 +0200948 .data = &soft_watchdog_user_enabled,
949 .maxlen = sizeof(int),
950 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700951 .proc_handler = proc_soft_watchdog,
952 .extra1 = &zero,
953 .extra2 = &one,
954 },
955 {
Don Zickus2508ce12010-05-07 17:11:46 -0400956 .procname = "softlockup_panic",
957 .data = &softlockup_panic,
958 .maxlen = sizeof(int),
959 .mode = 0644,
960 .proc_handler = proc_dointvec_minmax,
961 .extra1 = &zero,
962 .extra2 = &one,
963 },
Aaron Tomlined235872014-06-23 13:22:05 -0700964#ifdef CONFIG_SMP
965 {
966 .procname = "softlockup_all_cpu_backtrace",
967 .data = &sysctl_softlockup_all_cpu_backtrace,
968 .maxlen = sizeof(int),
969 .mode = 0644,
970 .proc_handler = proc_dointvec_minmax,
971 .extra1 = &zero,
972 .extra2 = &one,
973 },
Nicholas Piggin05a4a952017-07-12 14:35:46 -0700974#endif /* CONFIG_SMP */
975#endif
976#ifdef CONFIG_HARDLOCKUP_DETECTOR
977 {
978 .procname = "hardlockup_panic",
979 .data = &hardlockup_panic,
980 .maxlen = sizeof(int),
981 .mode = 0644,
982 .proc_handler = proc_dointvec_minmax,
983 .extra1 = &zero,
984 .extra2 = &one,
985 },
986#ifdef CONFIG_SMP
Jiri Kosina55537872015-11-05 18:44:41 -0800987 {
988 .procname = "hardlockup_all_cpu_backtrace",
989 .data = &sysctl_hardlockup_all_cpu_backtrace,
990 .maxlen = sizeof(int),
991 .mode = 0644,
992 .proc_handler = proc_dointvec_minmax,
993 .extra1 = &zero,
994 .extra2 = &one,
995 },
Aaron Tomlined235872014-06-23 13:22:05 -0700996#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -0500997#endif
Nicholas Piggin05a4a952017-07-12 14:35:46 -0700998#endif
999
Don Zickus5dc30552010-11-29 17:07:17 -05001000#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
1001 {
1002 .procname = "unknown_nmi_panic",
1003 .data = &unknown_nmi_panic,
1004 .maxlen = sizeof (int),
1005 .mode = 0644,
1006 .proc_handler = proc_dointvec,
1007 },
Don Zickus504d7cf2010-02-12 17:19:19 -05001008#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001009#if defined(CONFIG_X86)
1010 {
Don Zickus8da5add2006-09-26 10:52:27 +02001011 .procname = "panic_on_unrecovered_nmi",
1012 .data = &panic_on_unrecovered_nmi,
1013 .maxlen = sizeof(int),
1014 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001015 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +02001016 },
1017 {
Kurt Garloff5211a242009-06-24 14:32:11 -07001018 .procname = "panic_on_io_nmi",
1019 .data = &panic_on_io_nmi,
1020 .maxlen = sizeof(int),
1021 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001022 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -07001023 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +09001024#ifdef CONFIG_DEBUG_STACKOVERFLOW
1025 {
1026 .procname = "panic_on_stackoverflow",
1027 .data = &sysctl_panic_on_stackoverflow,
1028 .maxlen = sizeof(int),
1029 .mode = 0644,
1030 .proc_handler = proc_dointvec,
1031 },
1032#endif
Kurt Garloff5211a242009-06-24 14:32:11 -07001033 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034 .procname = "bootloader_type",
1035 .data = &bootloader_type,
1036 .maxlen = sizeof (int),
1037 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001038 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001039 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001040 {
H. Peter Anvin50312962009-05-07 16:54:11 -07001041 .procname = "bootloader_version",
1042 .data = &bootloader_version,
1043 .maxlen = sizeof (int),
1044 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001045 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -07001046 },
1047 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001048 .procname = "io_delay_type",
1049 .data = &io_delay_type,
1050 .maxlen = sizeof(int),
1051 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001052 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001053 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001055#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001057 .procname = "randomize_va_space",
1058 .data = &randomize_va_space,
1059 .maxlen = sizeof(int),
1060 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001061 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001062 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001063#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001064#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001065 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001066 .procname = "spin_retry",
1067 .data = &spin_retry,
1068 .maxlen = sizeof (int),
1069 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001070 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001071 },
1072#endif
Len Brown673d5b42007-07-28 03:33:16 -04001073#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001074 {
Pavel Machekc255d842006-02-20 18:27:58 -08001075 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001076 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001077 .maxlen = sizeof (unsigned long),
1078 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001079 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001080 },
1081#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301082#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001083 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001084 .procname = "ignore-unaligned-usertrap",
1085 .data = &no_unaligned_warning,
1086 .maxlen = sizeof (int),
1087 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001088 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001089 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301090#endif
1091#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001092 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001093 .procname = "unaligned-dump-stack",
1094 .data = &unaligned_dump_stack,
1095 .maxlen = sizeof (int),
1096 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001097 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001098 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001099#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001100#ifdef CONFIG_DETECT_HUNG_TASK
1101 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001102 .procname = "hung_task_panic",
1103 .data = &sysctl_hung_task_panic,
1104 .maxlen = sizeof(int),
1105 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001106 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001107 .extra1 = &zero,
1108 .extra2 = &one,
1109 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001110 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001111 .procname = "hung_task_check_count",
1112 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001113 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001114 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001115 .proc_handler = proc_dointvec_minmax,
1116 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001117 },
1118 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001119 .procname = "hung_task_timeout_secs",
1120 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001121 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001122 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001123 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001124 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001125 },
1126 {
Dmitry Vyukova2e51442018-08-21 21:55:52 -07001127 .procname = "hung_task_check_interval_secs",
1128 .data = &sysctl_hung_task_check_interval_secs,
1129 .maxlen = sizeof(unsigned long),
1130 .mode = 0644,
1131 .proc_handler = proc_dohung_task_timeout_secs,
1132 .extra2 = &hung_task_timeout_max,
1133 },
1134 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001135 .procname = "hung_task_warnings",
1136 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001137 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001138 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001139 .proc_handler = proc_dointvec_minmax,
1140 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001141 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001142#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001143#ifdef CONFIG_RT_MUTEXES
1144 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001145 .procname = "max_lock_depth",
1146 .data = &max_lock_depth,
1147 .maxlen = sizeof(int),
1148 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001149 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001150 },
1151#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001152 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001153 .procname = "poweroff_cmd",
1154 .data = &poweroff_cmd,
1155 .maxlen = POWEROFF_CMD_PATH_LEN,
1156 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001157 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001158 },
David Howells0b77f5b2008-04-29 01:01:32 -07001159#ifdef CONFIG_KEYS
1160 {
David Howells0b77f5b2008-04-29 01:01:32 -07001161 .procname = "keys",
1162 .mode = 0555,
1163 .child = key_sysctls,
1164 },
1165#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001166#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001167 /*
1168 * User-space scripts rely on the existence of this file
1169 * as a feature check for perf_events being enabled.
1170 *
1171 * So it's an ABI, do not remove!
1172 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001173 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001174 .procname = "perf_event_paranoid",
1175 .data = &sysctl_perf_event_paranoid,
1176 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001177 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001178 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001179 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001180 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001181 .procname = "perf_event_mlock_kb",
1182 .data = &sysctl_perf_event_mlock,
1183 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001184 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001185 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001186 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001187 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001188 .procname = "perf_event_max_sample_rate",
1189 .data = &sysctl_perf_event_sample_rate,
1190 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001191 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001192 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001193 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001194 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001195 {
1196 .procname = "perf_cpu_time_max_percent",
1197 .data = &sysctl_perf_cpu_time_max_percent,
1198 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1199 .mode = 0644,
1200 .proc_handler = perf_cpu_time_max_percent_handler,
1201 .extra1 = &zero,
1202 .extra2 = &one_hundred,
1203 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001204 {
1205 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001206 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001207 .maxlen = sizeof(sysctl_perf_event_max_stack),
1208 .mode = 0644,
1209 .proc_handler = perf_event_max_stack_handler,
1210 .extra1 = &zero,
1211 .extra2 = &six_hundred_forty_kb,
1212 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001213 {
1214 .procname = "perf_event_max_contexts_per_stack",
1215 .data = &sysctl_perf_event_max_contexts_per_stack,
1216 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1217 .mode = 0644,
1218 .proc_handler = perf_event_max_stack_handler,
1219 .extra1 = &zero,
1220 .extra2 = &one_thousand,
1221 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001222#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001223 {
1224 .procname = "panic_on_warn",
1225 .data = &panic_on_warn,
1226 .maxlen = sizeof(int),
1227 .mode = 0644,
1228 .proc_handler = proc_dointvec_minmax,
1229 .extra1 = &zero,
1230 .extra2 = &one,
1231 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001232#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1233 {
1234 .procname = "timer_migration",
1235 .data = &sysctl_timer_migration,
1236 .maxlen = sizeof(unsigned int),
1237 .mode = 0644,
1238 .proc_handler = timer_migration_handler,
Myungho Jungb94bf592017-04-19 15:24:50 -07001239 .extra1 = &zero,
1240 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001241 },
1242#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001243#ifdef CONFIG_BPF_SYSCALL
1244 {
1245 .procname = "unprivileged_bpf_disabled",
1246 .data = &sysctl_unprivileged_bpf_disabled,
1247 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1248 .mode = 0644,
1249 /* only handle a transition from default "0" to "1" */
1250 .proc_handler = proc_dointvec_minmax,
1251 .extra1 = &one,
1252 .extra2 = &one,
1253 },
Alexei Starovoitov492ecee2019-02-25 14:28:39 -08001254 {
1255 .procname = "bpf_stats_enabled",
1256 .data = &sysctl_bpf_stats_enabled,
1257 .maxlen = sizeof(sysctl_bpf_stats_enabled),
1258 .mode = 0644,
1259 .proc_handler = proc_dointvec_minmax_bpf_stats,
1260 .extra1 = &zero,
1261 .extra2 = &one,
1262 },
Alexei Starovoitov3fcc55302019-02-27 18:30:44 -08001263#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001264#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1265 {
1266 .procname = "panic_on_rcu_stall",
1267 .data = &sysctl_panic_on_rcu_stall,
1268 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1269 .mode = 0644,
1270 .proc_handler = proc_dointvec_minmax,
1271 .extra1 = &zero,
1272 .extra2 = &one,
1273 },
1274#endif
Alexander Popov964c9df2018-08-17 01:17:03 +03001275#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
1276 {
1277 .procname = "stack_erasing",
1278 .data = NULL,
1279 .maxlen = sizeof(int),
1280 .mode = 0600,
1281 .proc_handler = stack_erasing_sysctl,
1282 .extra1 = &zero,
1283 .extra2 = &one,
1284 },
1285#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001286 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001287};
1288
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001289static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001290 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001291 .procname = "overcommit_memory",
1292 .data = &sysctl_overcommit_memory,
1293 .maxlen = sizeof(sysctl_overcommit_memory),
1294 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001295 .proc_handler = proc_dointvec_minmax,
1296 .extra1 = &zero,
1297 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001298 },
1299 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001300 .procname = "panic_on_oom",
1301 .data = &sysctl_panic_on_oom,
1302 .maxlen = sizeof(sysctl_panic_on_oom),
1303 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001304 .proc_handler = proc_dointvec_minmax,
1305 .extra1 = &zero,
1306 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001307 },
1308 {
David Rientjesfe071d72007-10-16 23:25:56 -07001309 .procname = "oom_kill_allocating_task",
1310 .data = &sysctl_oom_kill_allocating_task,
1311 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1312 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001313 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001314 },
1315 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001316 .procname = "oom_dump_tasks",
1317 .data = &sysctl_oom_dump_tasks,
1318 .maxlen = sizeof(sysctl_oom_dump_tasks),
1319 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001320 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001321 },
1322 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323 .procname = "overcommit_ratio",
1324 .data = &sysctl_overcommit_ratio,
1325 .maxlen = sizeof(sysctl_overcommit_ratio),
1326 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001327 .proc_handler = overcommit_ratio_handler,
1328 },
1329 {
1330 .procname = "overcommit_kbytes",
1331 .data = &sysctl_overcommit_kbytes,
1332 .maxlen = sizeof(sysctl_overcommit_kbytes),
1333 .mode = 0644,
1334 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001335 },
1336 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337 .procname = "page-cluster",
1338 .data = &page_cluster,
1339 .maxlen = sizeof(int),
1340 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001341 .proc_handler = proc_dointvec_minmax,
1342 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001343 },
1344 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001345 .procname = "dirty_background_ratio",
1346 .data = &dirty_background_ratio,
1347 .maxlen = sizeof(dirty_background_ratio),
1348 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001349 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350 .extra1 = &zero,
1351 .extra2 = &one_hundred,
1352 },
1353 {
David Rientjes2da02992009-01-06 14:39:31 -08001354 .procname = "dirty_background_bytes",
1355 .data = &dirty_background_bytes,
1356 .maxlen = sizeof(dirty_background_bytes),
1357 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001358 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001359 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001360 },
1361 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001362 .procname = "dirty_ratio",
1363 .data = &vm_dirty_ratio,
1364 .maxlen = sizeof(vm_dirty_ratio),
1365 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001366 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001367 .extra1 = &zero,
1368 .extra2 = &one_hundred,
1369 },
1370 {
David Rientjes2da02992009-01-06 14:39:31 -08001371 .procname = "dirty_bytes",
1372 .data = &vm_dirty_bytes,
1373 .maxlen = sizeof(vm_dirty_bytes),
1374 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001375 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001376 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001377 },
1378 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001379 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001380 .data = &dirty_writeback_interval,
1381 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001382 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001383 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384 },
1385 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001386 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001387 .data = &dirty_expire_interval,
1388 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001390 .proc_handler = proc_dointvec_minmax,
1391 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392 },
1393 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001394 .procname = "dirtytime_expire_seconds",
1395 .data = &dirtytime_expire_interval,
Randy Dunlap2d87b302018-04-10 16:35:14 -07001396 .maxlen = sizeof(dirtytime_expire_interval),
Theodore Ts'o1efff912015-03-17 12:23:32 -04001397 .mode = 0644,
1398 .proc_handler = dirtytime_interval_handler,
1399 .extra1 = &zero,
1400 },
1401 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001402 .procname = "swappiness",
1403 .data = &vm_swappiness,
1404 .maxlen = sizeof(vm_swappiness),
1405 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001406 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001407 .extra1 = &zero,
1408 .extra2 = &one_hundred,
1409 },
1410#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001411 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001412 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001413 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001414 .maxlen = sizeof(unsigned long),
1415 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001416 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001417 },
1418#ifdef CONFIG_NUMA
1419 {
1420 .procname = "nr_hugepages_mempolicy",
1421 .data = NULL,
1422 .maxlen = sizeof(unsigned long),
1423 .mode = 0644,
1424 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001425 },
Kemi Wang45180852017-11-15 17:38:22 -08001426 {
1427 .procname = "numa_stat",
1428 .data = &sysctl_vm_numa_stat,
1429 .maxlen = sizeof(int),
1430 .mode = 0644,
1431 .proc_handler = sysctl_vm_numa_stat_handler,
1432 .extra1 = &zero,
1433 .extra2 = &one,
1434 },
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001435#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001436 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001437 .procname = "hugetlb_shm_group",
1438 .data = &sysctl_hugetlb_shm_group,
1439 .maxlen = sizeof(gid_t),
1440 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001441 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001442 },
Adam Litke54f9f802007-10-16 01:26:20 -07001443 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001444 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001445 .data = NULL,
1446 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001447 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001448 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001449 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001450#endif
1451 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001452 .procname = "lowmem_reserve_ratio",
1453 .data = &sysctl_lowmem_reserve_ratio,
1454 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1455 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001456 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457 },
1458 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001459 .procname = "drop_caches",
1460 .data = &sysctl_drop_caches,
1461 .maxlen = sizeof(int),
1462 .mode = 0644,
1463 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001464 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001465 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001466 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001467#ifdef CONFIG_COMPACTION
1468 {
1469 .procname = "compact_memory",
1470 .data = &sysctl_compact_memory,
1471 .maxlen = sizeof(int),
1472 .mode = 0200,
1473 .proc_handler = sysctl_compaction_handler,
1474 },
Mel Gorman5e771902010-05-24 14:32:31 -07001475 {
1476 .procname = "extfrag_threshold",
1477 .data = &sysctl_extfrag_threshold,
1478 .maxlen = sizeof(int),
1479 .mode = 0644,
Matthew Wilcox6b7e5ca2019-03-05 15:43:41 -08001480 .proc_handler = proc_dointvec_minmax,
Mel Gorman5e771902010-05-24 14:32:31 -07001481 .extra1 = &min_extfrag_threshold,
1482 .extra2 = &max_extfrag_threshold,
1483 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001484 {
1485 .procname = "compact_unevictable_allowed",
1486 .data = &sysctl_compact_unevictable_allowed,
1487 .maxlen = sizeof(int),
1488 .mode = 0644,
1489 .proc_handler = proc_dointvec,
1490 .extra1 = &zero,
1491 .extra2 = &one,
1492 },
Mel Gorman5e771902010-05-24 14:32:31 -07001493
Mel Gorman76ab0f52010-05-24 14:32:28 -07001494#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001495 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001496 .procname = "min_free_kbytes",
1497 .data = &min_free_kbytes,
1498 .maxlen = sizeof(min_free_kbytes),
1499 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001500 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 .extra1 = &zero,
1502 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001503 {
Mel Gorman1c308442018-12-28 00:35:52 -08001504 .procname = "watermark_boost_factor",
1505 .data = &watermark_boost_factor,
1506 .maxlen = sizeof(watermark_boost_factor),
1507 .mode = 0644,
1508 .proc_handler = watermark_boost_factor_sysctl_handler,
1509 .extra1 = &zero,
1510 },
1511 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001512 .procname = "watermark_scale_factor",
1513 .data = &watermark_scale_factor,
1514 .maxlen = sizeof(watermark_scale_factor),
1515 .mode = 0644,
1516 .proc_handler = watermark_scale_factor_sysctl_handler,
1517 .extra1 = &one,
1518 .extra2 = &one_thousand,
1519 },
1520 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001521 .procname = "percpu_pagelist_fraction",
1522 .data = &percpu_pagelist_fraction,
1523 .maxlen = sizeof(percpu_pagelist_fraction),
1524 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001525 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001526 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001527 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001528#ifdef CONFIG_MMU
1529 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 .procname = "max_map_count",
1531 .data = &sysctl_max_map_count,
1532 .maxlen = sizeof(sysctl_max_map_count),
1533 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001534 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001535 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001536 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001537#else
1538 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001539 .procname = "nr_trim_pages",
1540 .data = &sysctl_nr_trim_pages,
1541 .maxlen = sizeof(sysctl_nr_trim_pages),
1542 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001543 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001544 .extra1 = &zero,
1545 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001546#endif
1547 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001548 .procname = "laptop_mode",
1549 .data = &laptop_mode,
1550 .maxlen = sizeof(laptop_mode),
1551 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001552 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001553 },
1554 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001555 .procname = "block_dump",
1556 .data = &block_dump,
1557 .maxlen = sizeof(block_dump),
1558 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001559 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001560 .extra1 = &zero,
1561 },
1562 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563 .procname = "vfs_cache_pressure",
1564 .data = &sysctl_vfs_cache_pressure,
1565 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1566 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001567 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001568 .extra1 = &zero,
1569 },
1570#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1571 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001572 .procname = "legacy_va_layout",
1573 .data = &sysctl_legacy_va_layout,
1574 .maxlen = sizeof(sysctl_legacy_va_layout),
1575 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001576 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001577 .extra1 = &zero,
1578 },
1579#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001580#ifdef CONFIG_NUMA
1581 {
Christoph Lameter17436602006-01-18 17:42:32 -08001582 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001583 .data = &node_reclaim_mode,
1584 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001585 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001586 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001587 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001588 },
Christoph Lameter96146342006-07-03 00:24:13 -07001589 {
Christoph Lameter96146342006-07-03 00:24:13 -07001590 .procname = "min_unmapped_ratio",
1591 .data = &sysctl_min_unmapped_ratio,
1592 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1593 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001594 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001595 .extra1 = &zero,
1596 .extra2 = &one_hundred,
1597 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001598 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001599 .procname = "min_slab_ratio",
1600 .data = &sysctl_min_slab_ratio,
1601 .maxlen = sizeof(sysctl_min_slab_ratio),
1602 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001603 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001604 .extra1 = &zero,
1605 .extra2 = &one_hundred,
1606 },
Christoph Lameter17436602006-01-18 17:42:32 -08001607#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001608#ifdef CONFIG_SMP
1609 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001610 .procname = "stat_interval",
1611 .data = &sysctl_stat_interval,
1612 .maxlen = sizeof(sysctl_stat_interval),
1613 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001614 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001615 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001616 {
1617 .procname = "stat_refresh",
1618 .data = NULL,
1619 .maxlen = 0,
1620 .mode = 0600,
1621 .proc_handler = vmstat_refresh,
1622 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001623#endif
David Howells6e141542009-12-15 19:27:45 +00001624#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001625 {
Eric Parised032182007-06-28 15:55:21 -04001626 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001627 .data = &dac_mmap_min_addr,
1628 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001629 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001630 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001631 },
David Howells6e141542009-12-15 19:27:45 +00001632#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001633#ifdef CONFIG_NUMA
1634 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001635 .procname = "numa_zonelist_order",
1636 .data = &numa_zonelist_order,
1637 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1638 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001639 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001640 },
1641#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001642#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001643 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001644 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001645 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001646#ifdef CONFIG_X86_32
1647 .data = &vdso32_enabled,
1648 .maxlen = sizeof(vdso32_enabled),
1649#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001650 .data = &vdso_enabled,
1651 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001652#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001653 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001654 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001655 .extra1 = &zero,
1656 },
1657#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001658#ifdef CONFIG_HIGHMEM
1659 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001660 .procname = "highmem_is_dirtyable",
1661 .data = &vm_highmem_is_dirtyable,
1662 .maxlen = sizeof(vm_highmem_is_dirtyable),
1663 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001664 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001665 .extra1 = &zero,
1666 .extra2 = &one,
1667 },
1668#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001669#ifdef CONFIG_MEMORY_FAILURE
1670 {
Andi Kleen6a460792009-09-16 11:50:15 +02001671 .procname = "memory_failure_early_kill",
1672 .data = &sysctl_memory_failure_early_kill,
1673 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1674 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001675 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001676 .extra1 = &zero,
1677 .extra2 = &one,
1678 },
1679 {
Andi Kleen6a460792009-09-16 11:50:15 +02001680 .procname = "memory_failure_recovery",
1681 .data = &sysctl_memory_failure_recovery,
1682 .maxlen = sizeof(sysctl_memory_failure_recovery),
1683 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001684 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001685 .extra1 = &zero,
1686 .extra2 = &one,
1687 },
1688#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001689 {
1690 .procname = "user_reserve_kbytes",
1691 .data = &sysctl_user_reserve_kbytes,
1692 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1693 .mode = 0644,
1694 .proc_handler = proc_doulongvec_minmax,
1695 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001696 {
1697 .procname = "admin_reserve_kbytes",
1698 .data = &sysctl_admin_reserve_kbytes,
1699 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1700 .mode = 0644,
1701 .proc_handler = proc_doulongvec_minmax,
1702 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001703#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1704 {
1705 .procname = "mmap_rnd_bits",
1706 .data = &mmap_rnd_bits,
1707 .maxlen = sizeof(mmap_rnd_bits),
1708 .mode = 0600,
1709 .proc_handler = proc_dointvec_minmax,
1710 .extra1 = (void *)&mmap_rnd_bits_min,
1711 .extra2 = (void *)&mmap_rnd_bits_max,
1712 },
1713#endif
1714#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1715 {
1716 .procname = "mmap_rnd_compat_bits",
1717 .data = &mmap_rnd_compat_bits,
1718 .maxlen = sizeof(mmap_rnd_compat_bits),
1719 .mode = 0600,
1720 .proc_handler = proc_dointvec_minmax,
1721 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1722 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1723 },
1724#endif
Peter Xucefdca02019-05-13 17:16:41 -07001725#ifdef CONFIG_USERFAULTFD
1726 {
1727 .procname = "unprivileged_userfaultfd",
1728 .data = &sysctl_unprivileged_userfaultfd,
1729 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
1730 .mode = 0644,
1731 .proc_handler = proc_dointvec_minmax,
1732 .extra1 = &zero,
1733 .extra2 = &one,
1734 },
1735#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001736 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001737};
1738
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001739static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001741 .procname = "inode-nr",
1742 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001743 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001744 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001745 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001746 },
1747 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001748 .procname = "inode-state",
1749 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001750 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001751 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001752 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001753 },
1754 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001755 .procname = "file-nr",
1756 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001757 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001758 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001759 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001760 },
1761 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001762 .procname = "file-max",
1763 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001764 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001765 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001766 .proc_handler = proc_doulongvec_minmax,
Will Deacon9002b212019-04-05 18:39:38 -07001767 .extra1 = &zero_ul,
Christian Brauner32a5ad92019-03-07 16:29:43 -08001768 .extra2 = &long_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001769 },
1770 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001771 .procname = "nr_open",
1772 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001773 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001774 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001775 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001776 .extra1 = &sysctl_nr_open_min,
1777 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001778 },
1779 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001780 .procname = "dentry-state",
1781 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001782 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001783 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001784 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001785 },
1786 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001787 .procname = "overflowuid",
1788 .data = &fs_overflowuid,
1789 .maxlen = sizeof(int),
1790 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001791 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001792 .extra1 = &minolduid,
1793 .extra2 = &maxolduid,
1794 },
1795 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001796 .procname = "overflowgid",
1797 .data = &fs_overflowgid,
1798 .maxlen = sizeof(int),
1799 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001800 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001801 .extra1 = &minolduid,
1802 .extra2 = &maxolduid,
1803 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001804#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001805 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001806 .procname = "leases-enable",
1807 .data = &leases_enable,
1808 .maxlen = sizeof(int),
1809 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001810 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001811 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001812#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001813#ifdef CONFIG_DNOTIFY
1814 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001815 .procname = "dir-notify-enable",
1816 .data = &dir_notify_enable,
1817 .maxlen = sizeof(int),
1818 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001819 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001820 },
1821#endif
1822#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001823#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001824 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001825 .procname = "lease-break-time",
1826 .data = &lease_break_time,
1827 .maxlen = sizeof(int),
1828 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001829 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001830 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001831#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001832#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001833 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001834 .procname = "aio-nr",
1835 .data = &aio_nr,
1836 .maxlen = sizeof(aio_nr),
1837 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001838 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001839 },
1840 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001841 .procname = "aio-max-nr",
1842 .data = &aio_max_nr,
1843 .maxlen = sizeof(aio_max_nr),
1844 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001845 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001846 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001847#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001848#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001849 {
Robert Love0399cb02005-07-13 12:38:18 -04001850 .procname = "inotify",
1851 .mode = 0555,
1852 .child = inotify_table,
1853 },
1854#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001855#ifdef CONFIG_EPOLL
1856 {
1857 .procname = "epoll",
1858 .mode = 0555,
1859 .child = epoll_table,
1860 },
1861#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001863 {
Kees Cook800179c2012-07-25 17:29:07 -07001864 .procname = "protected_symlinks",
1865 .data = &sysctl_protected_symlinks,
1866 .maxlen = sizeof(int),
1867 .mode = 0600,
1868 .proc_handler = proc_dointvec_minmax,
1869 .extra1 = &zero,
1870 .extra2 = &one,
1871 },
1872 {
1873 .procname = "protected_hardlinks",
1874 .data = &sysctl_protected_hardlinks,
1875 .maxlen = sizeof(int),
1876 .mode = 0600,
1877 .proc_handler = proc_dointvec_minmax,
1878 .extra1 = &zero,
1879 .extra2 = &one,
1880 },
1881 {
Salvatore Mesoraca30aba662018-08-23 17:00:35 -07001882 .procname = "protected_fifos",
1883 .data = &sysctl_protected_fifos,
1884 .maxlen = sizeof(int),
1885 .mode = 0600,
1886 .proc_handler = proc_dointvec_minmax,
1887 .extra1 = &zero,
1888 .extra2 = &two,
1889 },
1890 {
1891 .procname = "protected_regular",
1892 .data = &sysctl_protected_regular,
1893 .maxlen = sizeof(int),
1894 .mode = 0600,
1895 .proc_handler = proc_dointvec_minmax,
1896 .extra1 = &zero,
1897 .extra2 = &two,
1898 },
1899 {
Alan Coxd6e71142005-06-23 00:09:43 -07001900 .procname = "suid_dumpable",
1901 .data = &suid_dumpable,
1902 .maxlen = sizeof(int),
1903 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001904 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001905 .extra1 = &zero,
1906 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001907 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001908#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1909 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001910 .procname = "binfmt_misc",
1911 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001912 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001913 },
1914#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001915 {
Jens Axboeff9da692010-06-03 14:54:39 +02001916 .procname = "pipe-max-size",
1917 .data = &pipe_max_size,
Joe Lawrence98159d92017-11-17 15:29:17 -08001918 .maxlen = sizeof(pipe_max_size),
Jens Axboeb492e952010-05-19 21:03:16 +02001919 .mode = 0644,
Eric Biggers319e0a22018-02-06 15:41:49 -08001920 .proc_handler = proc_dopipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001921 },
Willy Tarreau759c0112016-01-18 16:36:09 +01001922 {
1923 .procname = "pipe-user-pages-hard",
1924 .data = &pipe_user_pages_hard,
1925 .maxlen = sizeof(pipe_user_pages_hard),
1926 .mode = 0644,
1927 .proc_handler = proc_doulongvec_minmax,
1928 },
1929 {
1930 .procname = "pipe-user-pages-soft",
1931 .data = &pipe_user_pages_soft,
1932 .maxlen = sizeof(pipe_user_pages_soft),
1933 .mode = 0644,
1934 .proc_handler = proc_doulongvec_minmax,
1935 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05001936 {
1937 .procname = "mount-max",
1938 .data = &sysctl_mount_max,
1939 .maxlen = sizeof(unsigned int),
1940 .mode = 0644,
1941 .proc_handler = proc_dointvec_minmax,
1942 .extra1 = &one,
1943 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001944 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001945};
1946
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001947static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001948#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001949 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001950 .procname = "exception-trace",
1951 .data = &show_unhandled_signals,
1952 .maxlen = sizeof(int),
1953 .mode = 0644,
1954 .proc_handler = proc_dointvec
1955 },
1956#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001957#if defined(CONFIG_OPTPROBES)
1958 {
1959 .procname = "kprobes-optimization",
1960 .data = &sysctl_kprobes_optimization,
1961 .maxlen = sizeof(int),
1962 .mode = 0644,
1963 .proc_handler = proc_kprobes_optimization_handler,
1964 .extra1 = &zero,
1965 .extra2 = &one,
1966 },
1967#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001968 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001969};
1970
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001971static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001972 { }
Robert Love0eeca282005-07-12 17:06:03 -04001973};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001974
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001975int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001976{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001977 struct ctl_table_header *hdr;
1978
1979 hdr = register_sysctl_table(sysctl_base_table);
1980 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001981 return 0;
1982}
1983
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001984#endif /* CONFIG_SYSCTL */
1985
Linus Torvalds1da177e2005-04-16 15:20:36 -07001986/*
1987 * /proc/sys support
1988 */
1989
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001990#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001991
Kees Cookf8808302014-06-06 14:37:17 -07001992static int _proc_do_string(char *data, int maxlen, int write,
1993 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001994 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001995{
1996 size_t len;
1997 char __user *p;
1998 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001999
2000 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002001 *lenp = 0;
2002 return 0;
2003 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002004
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002005 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002006 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
2007 /* Only continue writes not past the end of buffer. */
2008 len = strlen(data);
2009 if (len > maxlen - 1)
2010 len = maxlen - 1;
2011
2012 if (*ppos > len)
2013 return 0;
2014 len = *ppos;
2015 } else {
2016 /* Start writing from beginning of buffer. */
2017 len = 0;
2018 }
2019
Kees Cook2ca9bb42014-06-06 14:37:18 -07002020 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002021 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002022 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002023 if (get_user(c, p++))
2024 return -EFAULT;
2025 if (c == 0 || c == '\n')
2026 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002027 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002028 }
Kees Cookf8808302014-06-06 14:37:17 -07002029 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002030 } else {
2031 len = strlen(data);
2032 if (len > maxlen)
2033 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002034
2035 if (*ppos > len) {
2036 *lenp = 0;
2037 return 0;
2038 }
2039
2040 data += *ppos;
2041 len -= *ppos;
2042
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002043 if (len > *lenp)
2044 len = *lenp;
2045 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07002046 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002047 return -EFAULT;
2048 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07002049 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002050 return -EFAULT;
2051 len++;
2052 }
2053 *lenp = len;
2054 *ppos += len;
2055 }
2056 return 0;
2057}
2058
Kees Cookf4aacea2014-06-06 14:37:19 -07002059static void warn_sysctl_write(struct ctl_table *table)
2060{
2061 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2062 "This will not be supported in the future. To silence this\n"
2063 "warning, set kernel.sysctl_writes_strict = -1\n",
2064 current->comm, table->procname);
2065}
2066
Linus Torvalds1da177e2005-04-16 15:20:36 -07002067/**
Randy Dunlap5f733e82018-08-21 22:01:06 -07002068 * proc_first_pos_non_zero_ignore - check if first position is allowed
Luis R. Rodriguezd383d482017-07-12 14:33:33 -07002069 * @ppos: file position
2070 * @table: the sysctl table
2071 *
2072 * Returns true if the first position is non-zero and the sysctl_writes_strict
2073 * mode indicates this is not allowed for numeric input types. String proc
Randy Dunlap5f733e82018-08-21 22:01:06 -07002074 * handlers can ignore the return value.
Luis R. Rodriguezd383d482017-07-12 14:33:33 -07002075 */
2076static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
2077 struct ctl_table *table)
2078{
2079 if (!*ppos)
2080 return false;
2081
2082 switch (sysctl_writes_strict) {
2083 case SYSCTL_WRITES_STRICT:
2084 return true;
2085 case SYSCTL_WRITES_WARN:
2086 warn_sysctl_write(table);
2087 return false;
2088 default:
2089 return false;
2090 }
2091}
2092
2093/**
Linus Torvalds1da177e2005-04-16 15:20:36 -07002094 * proc_dostring - read a string sysctl
2095 * @table: the sysctl table
2096 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002097 * @buffer: the user buffer
2098 * @lenp: the size of the user buffer
2099 * @ppos: file position
2100 *
2101 * Reads/writes a string from/to the user buffer. If the kernel
2102 * buffer provided is not large enough to hold the string, the
2103 * string is truncated. The copied string is %NULL-terminated.
2104 * If the string is being read by the user process, it is copied
2105 * and a newline '\n' is added. It is truncated if the buffer is
2106 * not large enough.
2107 *
2108 * Returns 0 on success.
2109 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002110int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002111 void __user *buffer, size_t *lenp, loff_t *ppos)
2112{
Luis R. Rodriguezd383d482017-07-12 14:33:33 -07002113 if (write)
2114 proc_first_pos_non_zero_ignore(ppos, table);
Kees Cookf4aacea2014-06-06 14:37:19 -07002115
Kees Cookf8808302014-06-06 14:37:17 -07002116 return _proc_do_string((char *)(table->data), table->maxlen, write,
2117 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002118}
2119
Amerigo Wang00b7c332010-05-05 00:26:45 +00002120static size_t proc_skip_spaces(char **buf)
2121{
2122 size_t ret;
2123 char *tmp = skip_spaces(*buf);
2124 ret = tmp - *buf;
2125 *buf = tmp;
2126 return ret;
2127}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002128
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002129static void proc_skip_char(char **buf, size_t *size, const char v)
2130{
2131 while (*size) {
2132 if (**buf != v)
2133 break;
2134 (*size)--;
2135 (*buf)++;
2136 }
2137}
2138
Christian Brauner7f2923c2019-03-07 16:29:40 -08002139/**
2140 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
2141 * fail on overflow
2142 *
2143 * @cp: kernel buffer containing the string to parse
2144 * @endp: pointer to store the trailing characters
2145 * @base: the base to use
2146 * @res: where the parsed integer will be stored
2147 *
2148 * In case of success 0 is returned and @res will contain the parsed integer,
2149 * @endp will hold any trailing characters.
2150 * This function will fail the parse on overflow. If there wasn't an overflow
2151 * the function will defer the decision what characters count as invalid to the
2152 * caller.
2153 */
2154static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
2155 unsigned long *res)
2156{
2157 unsigned long long result;
2158 unsigned int rv;
2159
2160 cp = _parse_integer_fixup_radix(cp, &base);
2161 rv = _parse_integer(cp, base, &result);
2162 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
2163 return -ERANGE;
2164
2165 cp += rv;
2166
2167 if (endp)
2168 *endp = (char *)cp;
2169
2170 *res = (unsigned long)result;
2171 return 0;
2172}
2173
Amerigo Wang00b7c332010-05-05 00:26:45 +00002174#define TMPBUFLEN 22
2175/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002176 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002177 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002178 * @buf: a kernel buffer
2179 * @size: size of the kernel buffer
2180 * @val: this is where the number will be stored
2181 * @neg: set to %TRUE if number is negative
2182 * @perm_tr: a vector which contains the allowed trailers
2183 * @perm_tr_len: size of the perm_tr vector
2184 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002185 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002186 * In case of success %0 is returned and @buf and @size are updated with
2187 * the amount of bytes read. If @tr is non-NULL and a trailing
2188 * character exists (size is non-zero after returning from this
2189 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002190 */
2191static int proc_get_long(char **buf, size_t *size,
2192 unsigned long *val, bool *neg,
2193 const char *perm_tr, unsigned perm_tr_len, char *tr)
2194{
2195 int len;
2196 char *p, tmp[TMPBUFLEN];
2197
2198 if (!*size)
2199 return -EINVAL;
2200
2201 len = *size;
2202 if (len > TMPBUFLEN - 1)
2203 len = TMPBUFLEN - 1;
2204
2205 memcpy(tmp, *buf, len);
2206
2207 tmp[len] = 0;
2208 p = tmp;
2209 if (*p == '-' && *size > 1) {
2210 *neg = true;
2211 p++;
2212 } else
2213 *neg = false;
2214 if (!isdigit(*p))
2215 return -EINVAL;
2216
Christian Brauner7f2923c2019-03-07 16:29:40 -08002217 if (strtoul_lenient(p, &p, 0, val))
2218 return -EINVAL;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002219
2220 len = p - tmp;
2221
2222 /* We don't know if the next char is whitespace thus we may accept
2223 * invalid integers (e.g. 1234...a) or two integers instead of one
2224 * (e.g. 123...1). So lets not allow such large numbers. */
2225 if (len == TMPBUFLEN - 1)
2226 return -EINVAL;
2227
2228 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2229 return -EINVAL;
2230
2231 if (tr && (len < *size))
2232 *tr = *p;
2233
2234 *buf += len;
2235 *size -= len;
2236
2237 return 0;
2238}
2239
2240/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002241 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002242 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002243 * @buf: the user buffer
2244 * @size: the size of the user buffer
2245 * @val: the integer to be converted
2246 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002247 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002248 * In case of success %0 is returned and @buf and @size are updated with
2249 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002250 */
2251static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2252 bool neg)
2253{
2254 int len;
2255 char tmp[TMPBUFLEN], *p = tmp;
2256
2257 sprintf(p, "%s%lu", neg ? "-" : "", val);
2258 len = strlen(tmp);
2259 if (len > *size)
2260 len = *size;
2261 if (copy_to_user(*buf, tmp, len))
2262 return -EFAULT;
2263 *size -= len;
2264 *buf += len;
2265 return 0;
2266}
2267#undef TMPBUFLEN
2268
2269static int proc_put_char(void __user **buf, size_t *size, char c)
2270{
2271 if (*size) {
2272 char __user **buffer = (char __user **)buf;
2273 if (put_user(c, *buffer))
2274 return -EFAULT;
2275 (*size)--, (*buffer)++;
2276 *buf = *buffer;
2277 }
2278 return 0;
2279}
2280
2281static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002282 int *valp,
2283 int write, void *data)
2284{
2285 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002286 if (*negp) {
2287 if (*lvalp > (unsigned long) INT_MAX + 1)
2288 return -EINVAL;
2289 *valp = -*lvalp;
2290 } else {
2291 if (*lvalp > (unsigned long) INT_MAX)
2292 return -EINVAL;
2293 *valp = *lvalp;
2294 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002295 } else {
2296 int val = *valp;
2297 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002298 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002299 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002300 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002301 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002302 *lvalp = (unsigned long)val;
2303 }
2304 }
2305 return 0;
2306}
2307
Luis R. Rodriguez4f2fec02017-07-12 14:33:36 -07002308static int do_proc_douintvec_conv(unsigned long *lvalp,
2309 unsigned int *valp,
2310 int write, void *data)
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002311{
2312 if (write) {
Luis R. Rodriguez4f2fec02017-07-12 14:33:36 -07002313 if (*lvalp > UINT_MAX)
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002314 return -EINVAL;
2315 *valp = *lvalp;
2316 } else {
2317 unsigned int val = *valp;
2318 *lvalp = (unsigned long)val;
2319 }
2320 return 0;
2321}
2322
Amerigo Wang00b7c332010-05-05 00:26:45 +00002323static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2324
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002325static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002326 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002327 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002328 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002329 int write, void *data),
2330 void *data)
2331{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002332 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002333 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002334 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002335
Amerigo Wang00b7c332010-05-05 00:26:45 +00002336 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337 *lenp = 0;
2338 return 0;
2339 }
2340
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002341 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002342 vleft = table->maxlen / sizeof(*i);
2343 left = *lenp;
2344
2345 if (!conv)
2346 conv = do_proc_dointvec_conv;
2347
Linus Torvalds1da177e2005-04-16 15:20:36 -07002348 if (write) {
Luis R. Rodriguezd383d482017-07-12 14:33:33 -07002349 if (proc_first_pos_non_zero_ignore(ppos, table))
2350 goto out;
Kees Cookf4aacea2014-06-06 14:37:19 -07002351
Amerigo Wang00b7c332010-05-05 00:26:45 +00002352 if (left > PAGE_SIZE - 1)
2353 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002354 p = kbuf = memdup_user_nul(buffer, left);
2355 if (IS_ERR(kbuf))
2356 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002357 }
2358
2359 for (; left && vleft--; i++, first=0) {
2360 unsigned long lval;
2361 bool neg;
2362
2363 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002364 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002365
J. R. Okajima563b0462010-05-25 16:10:14 -07002366 if (!left)
2367 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002368 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002369 proc_wspace_sep,
2370 sizeof(proc_wspace_sep), NULL);
2371 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002372 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002373 if (conv(&neg, &lval, i, 1, data)) {
2374 err = -EINVAL;
2375 break;
2376 }
2377 } else {
2378 if (conv(&neg, &lval, i, 0, data)) {
2379 err = -EINVAL;
2380 break;
2381 }
2382 if (!first)
2383 err = proc_put_char(&buffer, &left, '\t');
2384 if (err)
2385 break;
2386 err = proc_put_long(&buffer, &left, lval, neg);
2387 if (err)
2388 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002389 }
2390 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002391
2392 if (!write && !first && left && !err)
2393 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002394 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002395 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002396 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002397 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002398 if (first)
2399 return err ? : -EINVAL;
2400 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002402out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002403 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002404 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002405}
2406
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002407static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002408 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002409 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002410 int write, void *data),
2411 void *data)
2412{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002413 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002414 buffer, lenp, ppos, conv, data);
2415}
2416
Luis R. Rodriguez4f2fec02017-07-12 14:33:36 -07002417static int do_proc_douintvec_w(unsigned int *tbl_data,
2418 struct ctl_table *table,
2419 void __user *buffer,
2420 size_t *lenp, loff_t *ppos,
2421 int (*conv)(unsigned long *lvalp,
2422 unsigned int *valp,
2423 int write, void *data),
2424 void *data)
2425{
2426 unsigned long lval;
2427 int err = 0;
2428 size_t left;
2429 bool neg;
2430 char *kbuf = NULL, *p;
2431
2432 left = *lenp;
2433
2434 if (proc_first_pos_non_zero_ignore(ppos, table))
2435 goto bail_early;
2436
2437 if (left > PAGE_SIZE - 1)
2438 left = PAGE_SIZE - 1;
2439
2440 p = kbuf = memdup_user_nul(buffer, left);
2441 if (IS_ERR(kbuf))
2442 return -EINVAL;
2443
2444 left -= proc_skip_spaces(&p);
2445 if (!left) {
2446 err = -EINVAL;
2447 goto out_free;
2448 }
2449
2450 err = proc_get_long(&p, &left, &lval, &neg,
2451 proc_wspace_sep,
2452 sizeof(proc_wspace_sep), NULL);
2453 if (err || neg) {
2454 err = -EINVAL;
2455 goto out_free;
2456 }
2457
2458 if (conv(&lval, tbl_data, 1, data)) {
2459 err = -EINVAL;
2460 goto out_free;
2461 }
2462
2463 if (!err && left)
2464 left -= proc_skip_spaces(&p);
2465
2466out_free:
2467 kfree(kbuf);
2468 if (err)
2469 return -EINVAL;
2470
2471 return 0;
2472
2473 /* This is in keeping with old __do_proc_dointvec() */
2474bail_early:
2475 *ppos += *lenp;
2476 return err;
2477}
2478
2479static int do_proc_douintvec_r(unsigned int *tbl_data, void __user *buffer,
2480 size_t *lenp, loff_t *ppos,
2481 int (*conv)(unsigned long *lvalp,
2482 unsigned int *valp,
2483 int write, void *data),
2484 void *data)
2485{
2486 unsigned long lval;
2487 int err = 0;
2488 size_t left;
2489
2490 left = *lenp;
2491
2492 if (conv(&lval, tbl_data, 0, data)) {
2493 err = -EINVAL;
2494 goto out;
2495 }
2496
2497 err = proc_put_long(&buffer, &left, lval, false);
2498 if (err || !left)
2499 goto out;
2500
2501 err = proc_put_char(&buffer, &left, '\n');
2502
2503out:
2504 *lenp -= left;
2505 *ppos += *lenp;
2506
2507 return err;
2508}
2509
2510static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
2511 int write, void __user *buffer,
2512 size_t *lenp, loff_t *ppos,
2513 int (*conv)(unsigned long *lvalp,
2514 unsigned int *valp,
2515 int write, void *data),
2516 void *data)
2517{
2518 unsigned int *i, vleft;
2519
2520 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2521 *lenp = 0;
2522 return 0;
2523 }
2524
2525 i = (unsigned int *) tbl_data;
2526 vleft = table->maxlen / sizeof(*i);
2527
2528 /*
2529 * Arrays are not supported, keep this simple. *Do not* add
2530 * support for them.
2531 */
2532 if (vleft != 1) {
2533 *lenp = 0;
2534 return -EINVAL;
2535 }
2536
2537 if (!conv)
2538 conv = do_proc_douintvec_conv;
2539
2540 if (write)
2541 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
2542 conv, data);
2543 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
2544}
2545
2546static int do_proc_douintvec(struct ctl_table *table, int write,
2547 void __user *buffer, size_t *lenp, loff_t *ppos,
2548 int (*conv)(unsigned long *lvalp,
2549 unsigned int *valp,
2550 int write, void *data),
2551 void *data)
2552{
2553 return __do_proc_douintvec(table->data, table, write,
2554 buffer, lenp, ppos, conv, data);
2555}
2556
Linus Torvalds1da177e2005-04-16 15:20:36 -07002557/**
2558 * proc_dointvec - read a vector of integers
2559 * @table: the sysctl table
2560 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002561 * @buffer: the user buffer
2562 * @lenp: the size of the user buffer
2563 * @ppos: file position
2564 *
2565 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2566 * values from/to the user buffer, treated as an ASCII string.
2567 *
2568 * Returns 0 on success.
2569 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002570int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571 void __user *buffer, size_t *lenp, loff_t *ppos)
2572{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002573 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2574}
2575
2576/**
2577 * proc_douintvec - read a vector of unsigned integers
2578 * @table: the sysctl table
2579 * @write: %TRUE if this is a write to the sysctl file
2580 * @buffer: the user buffer
2581 * @lenp: the size of the user buffer
2582 * @ppos: file position
2583 *
2584 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2585 * values from/to the user buffer, treated as an ASCII string.
2586 *
2587 * Returns 0 on success.
2588 */
2589int proc_douintvec(struct ctl_table *table, int write,
2590 void __user *buffer, size_t *lenp, loff_t *ppos)
2591{
Luis R. Rodriguez4f2fec02017-07-12 14:33:36 -07002592 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2593 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002594}
2595
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002596/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002597 * Taint values can only be increased
2598 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002599 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002600static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002601 void __user *buffer, size_t *lenp, loff_t *ppos)
2602{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002603 struct ctl_table t;
2604 unsigned long tmptaint = get_taint();
2605 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002606
Bastian Blank91fcd412007-04-23 14:41:14 -07002607 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002608 return -EPERM;
2609
Andi Kleen25ddbb12008-10-15 22:01:41 -07002610 t = *table;
2611 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002612 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002613 if (err < 0)
2614 return err;
2615
2616 if (write) {
2617 /*
2618 * Poor man's atomic or. Not worth adding a primitive
2619 * to everyone's atomic.h for this
2620 */
2621 int i;
2622 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2623 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302624 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002625 }
2626 }
2627
2628 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002629}
2630
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002631#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002632static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002633 void __user *buffer, size_t *lenp, loff_t *ppos)
2634{
2635 if (write && !capable(CAP_SYS_ADMIN))
2636 return -EPERM;
2637
2638 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2639}
2640#endif
2641
Waiman Long24704f32018-04-10 16:35:38 -07002642/**
2643 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
2644 * @min: pointer to minimum allowable value
2645 * @max: pointer to maximum allowable value
2646 *
2647 * The do_proc_dointvec_minmax_conv_param structure provides the
2648 * minimum and maximum values for doing range checking for those sysctl
2649 * parameters that use the proc_dointvec_minmax() handler.
2650 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002651struct do_proc_dointvec_minmax_conv_param {
2652 int *min;
2653 int *max;
2654};
2655
Amerigo Wang00b7c332010-05-05 00:26:45 +00002656static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2657 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002658 int write, void *data)
2659{
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002660 int tmp, ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002661 struct do_proc_dointvec_minmax_conv_param *param = data;
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002662 /*
2663 * If writing, first do so via a temporary local int so we can
2664 * bounds-check it before touching *valp.
2665 */
2666 int *ip = write ? &tmp : valp;
2667
2668 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
2669 if (ret)
2670 return ret;
2671
Linus Torvalds1da177e2005-04-16 15:20:36 -07002672 if (write) {
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002673 if ((param->min && *param->min > tmp) ||
2674 (param->max && *param->max < tmp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002675 return -EINVAL;
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002676 *valp = tmp;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002677 }
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002678
Linus Torvalds1da177e2005-04-16 15:20:36 -07002679 return 0;
2680}
2681
2682/**
2683 * proc_dointvec_minmax - read a vector of integers with min/max values
2684 * @table: the sysctl table
2685 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002686 * @buffer: the user buffer
2687 * @lenp: the size of the user buffer
2688 * @ppos: file position
2689 *
2690 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2691 * values from/to the user buffer, treated as an ASCII string.
2692 *
2693 * This routine will ensure the values are within the range specified by
2694 * table->extra1 (min) and table->extra2 (max).
2695 *
Waiman Long24704f32018-04-10 16:35:38 -07002696 * Returns 0 on success or -EINVAL on write when the range check fails.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002697 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002698int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002699 void __user *buffer, size_t *lenp, loff_t *ppos)
2700{
2701 struct do_proc_dointvec_minmax_conv_param param = {
2702 .min = (int *) table->extra1,
2703 .max = (int *) table->extra2,
2704 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002705 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002706 do_proc_dointvec_minmax_conv, &param);
2707}
2708
Waiman Long24704f32018-04-10 16:35:38 -07002709/**
2710 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
2711 * @min: pointer to minimum allowable value
2712 * @max: pointer to maximum allowable value
2713 *
2714 * The do_proc_douintvec_minmax_conv_param structure provides the
2715 * minimum and maximum values for doing range checking for those sysctl
2716 * parameters that use the proc_douintvec_minmax() handler.
2717 */
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07002718struct do_proc_douintvec_minmax_conv_param {
2719 unsigned int *min;
2720 unsigned int *max;
2721};
2722
2723static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
2724 unsigned int *valp,
2725 int write, void *data)
2726{
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002727 int ret;
2728 unsigned int tmp;
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07002729 struct do_proc_douintvec_minmax_conv_param *param = data;
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002730 /* write via temporary local uint for bounds-checking */
2731 unsigned int *up = write ? &tmp : valp;
2732
2733 ret = do_proc_douintvec_conv(lvalp, up, write, data);
2734 if (ret)
2735 return ret;
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07002736
2737 if (write) {
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002738 if ((param->min && *param->min > tmp) ||
2739 (param->max && *param->max < tmp))
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07002740 return -ERANGE;
2741
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002742 *valp = tmp;
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07002743 }
2744
2745 return 0;
2746}
2747
2748/**
2749 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2750 * @table: the sysctl table
2751 * @write: %TRUE if this is a write to the sysctl file
2752 * @buffer: the user buffer
2753 * @lenp: the size of the user buffer
2754 * @ppos: file position
2755 *
2756 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2757 * values from/to the user buffer, treated as an ASCII string. Negative
2758 * strings are not allowed.
2759 *
2760 * This routine will ensure the values are within the range specified by
2761 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2762 * check for UINT_MAX to avoid having to support wrap around uses from
2763 * userspace.
2764 *
Waiman Long24704f32018-04-10 16:35:38 -07002765 * Returns 0 on success or -ERANGE on write when the range check fails.
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07002766 */
2767int proc_douintvec_minmax(struct ctl_table *table, int write,
2768 void __user *buffer, size_t *lenp, loff_t *ppos)
2769{
2770 struct do_proc_douintvec_minmax_conv_param param = {
2771 .min = (unsigned int *) table->extra1,
2772 .max = (unsigned int *) table->extra2,
2773 };
2774 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2775 do_proc_douintvec_minmax_conv, &param);
2776}
2777
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002778static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
2779 unsigned int *valp,
2780 int write, void *data)
2781{
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002782 if (write) {
Joe Lawrencefb910c42017-11-17 15:29:28 -08002783 unsigned int val;
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002784
Joe Lawrencefb910c42017-11-17 15:29:28 -08002785 val = round_pipe_size(*lvalp);
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002786 if (val == 0)
2787 return -EINVAL;
2788
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002789 *valp = val;
2790 } else {
2791 unsigned int val = *valp;
2792 *lvalp = (unsigned long) val;
2793 }
2794
2795 return 0;
2796}
2797
Eric Biggers319e0a22018-02-06 15:41:49 -08002798static int proc_dopipe_max_size(struct ctl_table *table, int write,
2799 void __user *buffer, size_t *lenp, loff_t *ppos)
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002800{
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002801 return do_proc_douintvec(table, write, buffer, lenp, ppos,
Eric Biggers4c2e4be2018-02-06 15:41:45 -08002802 do_proc_dopipe_max_size_conv, NULL);
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002803}
2804
Kees Cook54b50192012-07-30 14:39:18 -07002805static void validate_coredump_safety(void)
2806{
Alex Kelly046d6622012-10-04 17:15:23 -07002807#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002808 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002809 core_pattern[0] != '/' && core_pattern[0] != '|') {
Alexey Dobriyan760c6a92016-12-14 15:04:14 -08002810 printk(KERN_WARNING
2811"Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2812"Pipe handler or fully qualified core dump path required.\n"
2813"Set kernel.core_pattern before fs.suid_dumpable.\n"
2814 );
Kees Cook54b50192012-07-30 14:39:18 -07002815 }
Alex Kelly046d6622012-10-04 17:15:23 -07002816#endif
Kees Cook54b50192012-07-30 14:39:18 -07002817}
2818
2819static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2820 void __user *buffer, size_t *lenp, loff_t *ppos)
2821{
2822 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2823 if (!error)
2824 validate_coredump_safety();
2825 return error;
2826}
2827
Alex Kelly046d6622012-10-04 17:15:23 -07002828#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002829static int proc_dostring_coredump(struct ctl_table *table, int write,
2830 void __user *buffer, size_t *lenp, loff_t *ppos)
2831{
2832 int error = proc_dostring(table, write, buffer, lenp, ppos);
2833 if (!error)
2834 validate_coredump_safety();
2835 return error;
2836}
Alex Kelly046d6622012-10-04 17:15:23 -07002837#endif
Kees Cook54b50192012-07-30 14:39:18 -07002838
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002839static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002840 void __user *buffer,
2841 size_t *lenp, loff_t *ppos,
2842 unsigned long convmul,
2843 unsigned long convdiv)
2844{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002845 unsigned long *i, *min, *max;
2846 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002847 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002848 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002849
2850 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002851 *lenp = 0;
2852 return 0;
2853 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002854
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002855 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002856 min = (unsigned long *) table->extra1;
2857 max = (unsigned long *) table->extra2;
2858 vleft = table->maxlen / sizeof(unsigned long);
2859 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002860
2861 if (write) {
Luis R. Rodriguezd383d482017-07-12 14:33:33 -07002862 if (proc_first_pos_non_zero_ignore(ppos, table))
2863 goto out;
Kees Cookf4aacea2014-06-06 14:37:19 -07002864
Amerigo Wang00b7c332010-05-05 00:26:45 +00002865 if (left > PAGE_SIZE - 1)
2866 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002867 p = kbuf = memdup_user_nul(buffer, left);
2868 if (IS_ERR(kbuf))
2869 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002870 }
2871
Eric Dumazet27b3d802010-10-07 12:59:29 -07002872 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002873 unsigned long val;
2874
Linus Torvalds1da177e2005-04-16 15:20:36 -07002875 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002876 bool neg;
2877
Al Viro70f6cbb2015-12-24 00:13:10 -05002878 left -= proc_skip_spaces(&p);
Cheng Lin09be1782019-01-03 15:26:13 -08002879 if (!left)
2880 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002881
Al Viro70f6cbb2015-12-24 00:13:10 -05002882 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002883 proc_wspace_sep,
2884 sizeof(proc_wspace_sep), NULL);
2885 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002886 break;
2887 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002888 continue;
Eric Dumazetff9f8a72017-01-25 18:20:55 -08002889 val = convmul * val / convdiv;
Christian Braunere260ad02019-05-14 15:44:55 -07002890 if ((min && val < *min) || (max && val > *max)) {
2891 err = -EINVAL;
2892 break;
2893 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002894 *i = val;
2895 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002896 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002897 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002898 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002899 if (err)
2900 break;
2901 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002902 err = proc_put_long(&buffer, &left, val, false);
2903 if (err)
2904 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002905 }
2906 }
2907
Amerigo Wang00b7c332010-05-05 00:26:45 +00002908 if (!write && !first && left && !err)
2909 err = proc_put_char(&buffer, &left, '\n');
2910 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002911 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002912 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002913 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002914 if (first)
2915 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002916 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002917 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002918out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002919 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002920 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002921}
2922
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002923static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002924 void __user *buffer,
2925 size_t *lenp, loff_t *ppos,
2926 unsigned long convmul,
2927 unsigned long convdiv)
2928{
2929 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002930 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002931}
2932
Linus Torvalds1da177e2005-04-16 15:20:36 -07002933/**
2934 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2935 * @table: the sysctl table
2936 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002937 * @buffer: the user buffer
2938 * @lenp: the size of the user buffer
2939 * @ppos: file position
2940 *
2941 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2942 * values from/to the user buffer, treated as an ASCII string.
2943 *
2944 * This routine will ensure the values are within the range specified by
2945 * table->extra1 (min) and table->extra2 (max).
2946 *
2947 * Returns 0 on success.
2948 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002949int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002950 void __user *buffer, size_t *lenp, loff_t *ppos)
2951{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002952 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002953}
2954
2955/**
2956 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2957 * @table: the sysctl table
2958 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002959 * @buffer: the user buffer
2960 * @lenp: the size of the user buffer
2961 * @ppos: file position
2962 *
2963 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2964 * values from/to the user buffer, treated as an ASCII string. The values
2965 * are treated as milliseconds, and converted to jiffies when they are stored.
2966 *
2967 * This routine will ensure the values are within the range specified by
2968 * table->extra1 (min) and table->extra2 (max).
2969 *
2970 * Returns 0 on success.
2971 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002972int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002973 void __user *buffer,
2974 size_t *lenp, loff_t *ppos)
2975{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002976 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002977 lenp, ppos, HZ, 1000l);
2978}
2979
2980
Amerigo Wang00b7c332010-05-05 00:26:45 +00002981static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002982 int *valp,
2983 int write, void *data)
2984{
2985 if (write) {
Gao Feng63259452017-05-08 15:54:58 -07002986 if (*lvalp > INT_MAX / HZ)
Bart Samwelcba9f332006-03-24 03:15:50 -08002987 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002988 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2989 } else {
2990 int val = *valp;
2991 unsigned long lval;
2992 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002993 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002994 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002995 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002996 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002997 lval = (unsigned long)val;
2998 }
2999 *lvalp = lval / HZ;
3000 }
3001 return 0;
3002}
3003
Amerigo Wang00b7c332010-05-05 00:26:45 +00003004static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003005 int *valp,
3006 int write, void *data)
3007{
3008 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08003009 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
3010 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003011 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
3012 } else {
3013 int val = *valp;
3014 unsigned long lval;
3015 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00003016 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07003017 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003018 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00003019 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003020 lval = (unsigned long)val;
3021 }
3022 *lvalp = jiffies_to_clock_t(lval);
3023 }
3024 return 0;
3025}
3026
Amerigo Wang00b7c332010-05-05 00:26:45 +00003027static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003028 int *valp,
3029 int write, void *data)
3030{
3031 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02003032 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
3033
3034 if (jif > INT_MAX)
3035 return 1;
3036 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003037 } else {
3038 int val = *valp;
3039 unsigned long lval;
3040 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00003041 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07003042 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003043 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00003044 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003045 lval = (unsigned long)val;
3046 }
3047 *lvalp = jiffies_to_msecs(lval);
3048 }
3049 return 0;
3050}
3051
3052/**
3053 * proc_dointvec_jiffies - read a vector of integers as seconds
3054 * @table: the sysctl table
3055 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07003056 * @buffer: the user buffer
3057 * @lenp: the size of the user buffer
3058 * @ppos: file position
3059 *
3060 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3061 * values from/to the user buffer, treated as an ASCII string.
3062 * The values read are assumed to be in seconds, and are converted into
3063 * jiffies.
3064 *
3065 * Returns 0 on success.
3066 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003067int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003068 void __user *buffer, size_t *lenp, loff_t *ppos)
3069{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003070 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003071 do_proc_dointvec_jiffies_conv,NULL);
3072}
3073
3074/**
3075 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
3076 * @table: the sysctl table
3077 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07003078 * @buffer: the user buffer
3079 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08003080 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07003081 *
3082 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3083 * values from/to the user buffer, treated as an ASCII string.
3084 * The values read are assumed to be in 1/USER_HZ seconds, and
3085 * are converted into jiffies.
3086 *
3087 * Returns 0 on success.
3088 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003089int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003090 void __user *buffer, size_t *lenp, loff_t *ppos)
3091{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003092 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003093 do_proc_dointvec_userhz_jiffies_conv,NULL);
3094}
3095
3096/**
3097 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
3098 * @table: the sysctl table
3099 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07003100 * @buffer: the user buffer
3101 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07003102 * @ppos: file position
3103 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07003104 *
3105 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3106 * values from/to the user buffer, treated as an ASCII string.
3107 * The values read are assumed to be in 1/1000 seconds, and
3108 * are converted into jiffies.
3109 *
3110 * Returns 0 on success.
3111 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003112int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003113 void __user *buffer, size_t *lenp, loff_t *ppos)
3114{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003115 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003116 do_proc_dointvec_ms_jiffies_conv, NULL);
3117}
3118
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003119static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07003120 void __user *buffer, size_t *lenp, loff_t *ppos)
3121{
3122 struct pid *new_pid;
3123 pid_t tmp;
3124 int r;
3125
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08003126 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07003127
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003128 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07003129 lenp, ppos, NULL, NULL);
3130 if (r || !write)
3131 return r;
3132
3133 new_pid = find_get_pid(tmp);
3134 if (!new_pid)
3135 return -ESRCH;
3136
3137 put_pid(xchg(&cad_pid, new_pid));
3138 return 0;
3139}
3140
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003141/**
3142 * proc_do_large_bitmap - read/write from/to a large bitmap
3143 * @table: the sysctl table
3144 * @write: %TRUE if this is a write to the sysctl file
3145 * @buffer: the user buffer
3146 * @lenp: the size of the user buffer
3147 * @ppos: file position
3148 *
3149 * The bitmap is stored at table->data and the bitmap length (in bits)
3150 * in table->maxlen.
3151 *
3152 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
3153 * large bitmaps may be represented in a compact manner. Writing into
3154 * the file will clear the bitmap then update it with the given input.
3155 *
3156 * Returns 0 on success.
3157 */
3158int proc_do_large_bitmap(struct ctl_table *table, int write,
3159 void __user *buffer, size_t *lenp, loff_t *ppos)
3160{
3161 int err = 0;
3162 bool first = 1;
3163 size_t left = *lenp;
3164 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07003165 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003166 unsigned long *tmp_bitmap = NULL;
3167 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
3168
WANG Cong122ff242014-05-12 16:04:53 -07003169 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003170 *lenp = 0;
3171 return 0;
3172 }
3173
3174 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003175 char *kbuf, *p;
Eric Sandeen3116ad32019-05-14 15:45:13 -07003176 size_t skipped = 0;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003177
Eric Sandeen3116ad32019-05-14 15:45:13 -07003178 if (left > PAGE_SIZE - 1) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003179 left = PAGE_SIZE - 1;
Eric Sandeen3116ad32019-05-14 15:45:13 -07003180 /* How much of the buffer we'll skip this pass */
3181 skipped = *lenp - left;
3182 }
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003183
Al Viro70f6cbb2015-12-24 00:13:10 -05003184 p = kbuf = memdup_user_nul(buffer, left);
3185 if (IS_ERR(kbuf))
3186 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003187
Andy Shevchenko475dae32019-05-14 15:44:52 -07003188 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003189 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003190 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003191 return -ENOMEM;
3192 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003193 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003194 while (!err && left) {
3195 unsigned long val_a, val_b;
3196 bool neg;
Eric Sandeen3116ad32019-05-14 15:45:13 -07003197 size_t saved_left;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003198
Eric Sandeen3116ad32019-05-14 15:45:13 -07003199 /* In case we stop parsing mid-number, we can reset */
3200 saved_left = left;
Al Viro70f6cbb2015-12-24 00:13:10 -05003201 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003202 sizeof(tr_a), &c);
Eric Sandeen3116ad32019-05-14 15:45:13 -07003203 /*
3204 * If we consumed the entirety of a truncated buffer or
3205 * only one char is left (may be a "-"), then stop here,
3206 * reset, & come back for more.
3207 */
3208 if ((left <= 1) && skipped) {
3209 left = saved_left;
3210 break;
3211 }
3212
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003213 if (err)
3214 break;
3215 if (val_a >= bitmap_len || neg) {
3216 err = -EINVAL;
3217 break;
3218 }
3219
3220 val_b = val_a;
3221 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003222 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003223 left--;
3224 }
3225
3226 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05003227 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003228 &neg, tr_b, sizeof(tr_b),
3229 &c);
Eric Sandeen3116ad32019-05-14 15:45:13 -07003230 /*
3231 * If we consumed all of a truncated buffer or
3232 * then stop here, reset, & come back for more.
3233 */
3234 if (!left && skipped) {
3235 left = saved_left;
3236 break;
3237 }
3238
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003239 if (err)
3240 break;
3241 if (val_b >= bitmap_len || neg ||
3242 val_a > val_b) {
3243 err = -EINVAL;
3244 break;
3245 }
3246 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003247 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003248 left--;
3249 }
3250 }
3251
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003252 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003253 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05003254 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003255 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003256 kfree(kbuf);
Eric Sandeen3116ad32019-05-14 15:45:13 -07003257 left += skipped;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003258 } else {
3259 unsigned long bit_a, bit_b = 0;
3260
3261 while (left) {
3262 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3263 if (bit_a >= bitmap_len)
3264 break;
3265 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3266 bit_a + 1) - 1;
3267
3268 if (!first) {
3269 err = proc_put_char(&buffer, &left, ',');
3270 if (err)
3271 break;
3272 }
3273 err = proc_put_long(&buffer, &left, bit_a, false);
3274 if (err)
3275 break;
3276 if (bit_a != bit_b) {
3277 err = proc_put_char(&buffer, &left, '-');
3278 if (err)
3279 break;
3280 err = proc_put_long(&buffer, &left, bit_b, false);
3281 if (err)
3282 break;
3283 }
3284
3285 first = 0; bit_b++;
3286 }
3287 if (!err)
3288 err = proc_put_char(&buffer, &left, '\n');
3289 }
3290
3291 if (!err) {
3292 if (write) {
3293 if (*ppos)
3294 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3295 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003296 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003297 }
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003298 *lenp -= left;
3299 *ppos += *lenp;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003300 }
Ola N. Kaldestadf9eb2fd2017-11-17 15:30:26 -08003301
Andy Shevchenko475dae32019-05-14 15:44:52 -07003302 bitmap_free(tmp_bitmap);
Ola N. Kaldestadf9eb2fd2017-11-17 15:30:26 -08003303 return err;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003304}
3305
Jovi Zhang55610502011-01-12 17:00:45 -08003306#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003307
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003308int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003309 void __user *buffer, size_t *lenp, loff_t *ppos)
3310{
3311 return -ENOSYS;
3312}
3313
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003314int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003315 void __user *buffer, size_t *lenp, loff_t *ppos)
3316{
3317 return -ENOSYS;
3318}
3319
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003320int proc_douintvec(struct ctl_table *table, int write,
3321 void __user *buffer, size_t *lenp, loff_t *ppos)
3322{
3323 return -ENOSYS;
3324}
3325
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003326int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003327 void __user *buffer, size_t *lenp, loff_t *ppos)
3328{
3329 return -ENOSYS;
3330}
3331
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07003332int proc_douintvec_minmax(struct ctl_table *table, int write,
3333 void __user *buffer, size_t *lenp, loff_t *ppos)
3334{
3335 return -ENOSYS;
3336}
3337
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003338int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003339 void __user *buffer, size_t *lenp, loff_t *ppos)
3340{
3341 return -ENOSYS;
3342}
3343
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003344int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003345 void __user *buffer, size_t *lenp, loff_t *ppos)
3346{
3347 return -ENOSYS;
3348}
3349
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003350int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003351 void __user *buffer, size_t *lenp, loff_t *ppos)
3352{
3353 return -ENOSYS;
3354}
3355
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003356int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003357 void __user *buffer, size_t *lenp, loff_t *ppos)
3358{
3359 return -ENOSYS;
3360}
3361
Eric W. Biedermand8217f02007-10-18 03:05:22 -07003362int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003363 void __user *buffer,
3364 size_t *lenp, loff_t *ppos)
3365{
3366 return -ENOSYS;
3367}
3368
Stephen Suryaputra0bc19982019-04-17 16:35:49 -04003369int proc_do_large_bitmap(struct ctl_table *table, int write,
3370 void __user *buffer, size_t *lenp, loff_t *ppos)
3371{
3372 return -ENOSYS;
3373}
Linus Torvalds1da177e2005-04-16 15:20:36 -07003374
Jovi Zhang55610502011-01-12 17:00:45 -08003375#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003376
Arnd Bergmann78c3aff2019-03-04 21:34:12 +01003377#if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
Alexei Starovoitov492ecee2019-02-25 14:28:39 -08003378static int proc_dointvec_minmax_bpf_stats(struct ctl_table *table, int write,
3379 void __user *buffer, size_t *lenp,
3380 loff_t *ppos)
3381{
3382 int ret, bpf_stats = *(int *)table->data;
3383 struct ctl_table tmp = *table;
3384
3385 if (write && !capable(CAP_SYS_ADMIN))
3386 return -EPERM;
3387
3388 tmp.data = &bpf_stats;
3389 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
3390 if (write && !ret) {
3391 *(int *)table->data = bpf_stats;
3392 if (bpf_stats)
3393 static_branch_enable(&bpf_stats_enabled_key);
3394 else
3395 static_branch_disable(&bpf_stats_enabled_key);
3396 }
3397 return ret;
3398}
Alexei Starovoitov3fcc55302019-02-27 18:30:44 -08003399#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003400/*
3401 * No sense putting this after each symbol definition, twice,
3402 * exception granted :-)
3403 */
3404EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003405EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003406EXPORT_SYMBOL(proc_dointvec_jiffies);
3407EXPORT_SYMBOL(proc_dointvec_minmax);
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07003408EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003409EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3410EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3411EXPORT_SYMBOL(proc_dostring);
3412EXPORT_SYMBOL(proc_doulongvec_minmax);
3413EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
Stephen Suryaputra0bc19982019-04-17 16:35:49 -04003414EXPORT_SYMBOL(proc_do_large_bitmap);