blob: 943c89178e3d3eb04accf784b38f18813d35abbc [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
Christoph Hellwige2e40f22015-02-22 08:58:50 -080022#include <linux/aio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/mm.h>
24#include <linux/swap.h>
25#include <linux/slab.h>
26#include <linux/sysctl.h>
Akinobu Mita5a04cca2012-03-28 14:42:50 -070027#include <linux/bitmap.h>
Dave Youngd33ed522010-03-10 15:23:59 -080028#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080029#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070031#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/ctype.h>
Steven Rostedtfd4b6162012-07-30 14:42:48 -070033#include <linux/kmemleak.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070034#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070035#include <linux/init.h>
36#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010037#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030038#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070039#include <linux/sysrq.h>
40#include <linux/highuid.h>
41#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020042#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070043#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070046#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070047#include <linux/times.h>
48#include <linux/limits.h>
49#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020050#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070051#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070052#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080053#include <linux/nfs_fs.h>
54#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070055#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020056#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020057#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050058#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020059#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070060#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040061#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070062#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000063#include <linux/binfmts.h>
Clark Williamscf4aebc22013-02-07 09:46:59 -060064#include <linux/sched/sysctl.h>
Ingo Molnarf7ccbae2017-02-08 18:51:30 +010065#include <linux/sched/coredump.h>
Kees Cook79847542014-01-23 15:55:59 -080066#include <linux/kexec.h>
Alexei Starovoitov1be7f752015-10-07 22:23:21 -070067#include <linux/bpf.h>
Eric W. Biedermand2921682016-09-28 00:27:17 -050068#include <linux/mount.h>
Peter Xucefdca02019-05-13 17:16:41 -070069#include <linux/userfaultfd_k.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Christian Brauner7f2923c2019-03-07 16:29:40 -080071#include "../lib/kstrtox.h"
72
Linus Torvalds7c0f6ba2016-12-24 11:46:01 -080073#include <linux/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070074#include <asm/processor.h>
75
Andi Kleen29cbc782006-09-30 01:47:55 +020076#ifdef CONFIG_X86
77#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010078#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010079#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020080#endif
David Howellsd550bbd2012-03-28 18:30:03 +010081#ifdef CONFIG_SPARC
82#include <asm/setup.h>
83#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080084#ifdef CONFIG_BSD_PROCESS_ACCT
85#include <linux/acct.h>
86#endif
Dave Young4f0e0562010-03-10 15:24:09 -080087#ifdef CONFIG_RT_MUTEXES
88#include <linux/rtmutex.h>
89#endif
Dave Young2edf5e42010-03-10 15:24:10 -080090#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
91#include <linux/lockdep.h>
92#endif
Dave Young15485a42010-03-10 15:24:07 -080093#ifdef CONFIG_CHR_DEV_SG
94#include <scsi/sg.h>
95#endif
Alexander Popov964c9df2018-08-17 01:17:03 +030096#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
97#include <linux/stackleak.h>
98#endif
Don Zickus58687ac2010-05-07 17:11:44 -040099#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -0500100#include <linux/nmi.h>
101#endif
102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103#if defined(CONFIG_SYSCTL)
104
105/* External variables not in a header file. */
Alan Coxd6e71142005-06-23 00:09:43 -0700106extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700107#ifdef CONFIG_COREDUMP
108extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700110extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700111#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800114extern int percpu_pagelist_fraction;
Arjan van de Ven97455122008-01-25 21:08:34 +0100115extern int latencytop_enabled;
Alexey Dobriyan9b80a182016-09-02 00:38:52 +0300116extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000117#ifndef CONFIG_MMU
118extern int sysctl_nr_trim_pages;
119#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700121/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400122#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700123static int sixty = 60;
124#endif
125
Aaron Tomlin270750db2014-01-20 17:34:13 +0000126static int __maybe_unused neg_one = -1;
127
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700128static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700129static int __maybe_unused one = 1;
130static int __maybe_unused two = 2;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700131static int __maybe_unused four = 4;
Will Deacon9002b212019-04-05 18:39:38 -0700132static unsigned long zero_ul;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800133static unsigned long one_ul = 1;
Christian Brauner32a5ad92019-03-07 16:29:43 -0800134static unsigned long long_max = LONG_MAX;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700135static int one_hundred = 100;
Johannes Weiner795ae7a2016-03-17 14:19:14 -0700136static int one_thousand = 1000;
Dave Youngaf913222009-09-22 16:43:33 -0700137#ifdef CONFIG_PRINTK
138static int ten_thousand = 10000;
139#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300140#ifdef CONFIG_PERF_EVENTS
141static int six_hundred_forty_kb = 640 * 1024;
142#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700143
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700144/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
145static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
146
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
148static int maxolduid = 65535;
149static int minolduid;
150
151static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700152static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
Dmitry Vyukova2e51442018-08-21 21:55:52 -0700154/*
155 * This is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs
156 * and hung_task_check_interval_secs
157 */
Liu Hua80df2842014-04-07 15:38:57 -0700158#ifdef CONFIG_DETECT_HUNG_TASK
159static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
160#endif
161
Dave Youngd14f1722010-02-25 20:28:57 -0500162#ifdef CONFIG_INOTIFY_USER
163#include <linux/inotify.h>
164#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700165#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166#endif
167
168#ifdef __hppa__
169extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530170#endif
171
172#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173extern int unaligned_enabled;
174#endif
175
Jes Sorensend2b176e2006-02-28 09:42:23 -0800176#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800177extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800178#endif
179
Vineet Guptab6fca722013-01-09 20:06:28 +0530180#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
181extern int no_unaligned_warning;
182#endif
183
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700184#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700185
Luis R. Rodrigueza19ac332017-07-12 14:33:30 -0700186/**
187 * enum sysctl_writes_mode - supported sysctl write modes
188 *
189 * @SYSCTL_WRITES_LEGACY: each write syscall must fully contain the sysctl value
190 * to be written, and multiple writes on the same sysctl file descriptor
191 * will rewrite the sysctl value, regardless of file position. No warning
192 * is issued when the initial position is not 0.
193 * @SYSCTL_WRITES_WARN: same as above but warn when the initial file position is
194 * not 0.
195 * @SYSCTL_WRITES_STRICT: writes to numeric sysctl entries must always be at
196 * file position 0 and the value must be fully contained in the buffer
197 * sent to the write syscall. If dealing with strings respect the file
198 * position, but restrict this to the max length of the buffer, anything
199 * passed the max lenght will be ignored. Multiple writes will append
200 * to the buffer.
201 *
202 * These write modes control how current file position affects the behavior of
203 * updating sysctl values through the proc interface on each write.
204 */
205enum sysctl_writes_mode {
206 SYSCTL_WRITES_LEGACY = -1,
207 SYSCTL_WRITES_WARN = 0,
208 SYSCTL_WRITES_STRICT = 1,
209};
Kees Cookf4aacea2014-06-06 14:37:19 -0700210
Luis R. Rodrigueza19ac332017-07-12 14:33:30 -0700211static enum sysctl_writes_mode sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700212
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700213static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700214 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700215static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800216 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700217#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700218
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700219#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700220static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700221 void __user *buffer, size_t *lenp, loff_t *ppos);
222#endif
223
Kees Cook54b50192012-07-30 14:39:18 -0700224static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
225 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700226#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700227static int proc_dostring_coredump(struct ctl_table *table, int write,
228 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700229#endif
Eric Biggers319e0a22018-02-06 15:41:49 -0800230static int proc_dopipe_max_size(struct ctl_table *table, int write,
231 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexei Starovoitov3fcc55302019-02-27 18:30:44 -0800232#ifdef CONFIG_BPF_SYSCALL
Alexei Starovoitov492ecee2019-02-25 14:28:39 -0800233static int proc_dointvec_minmax_bpf_stats(struct ctl_table *table, int write,
234 void __user *buffer, size_t *lenp,
235 loff_t *ppos);
Alexei Starovoitov3fcc55302019-02-27 18:30:44 -0800236#endif
Kees Cook54b50192012-07-30 14:39:18 -0700237
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700238#ifdef CONFIG_MAGIC_SYSRQ
Randy Dunlap5f733e82018-08-21 22:01:06 -0700239/* Note: sysrq code uses its own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100240static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700241
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700242static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700243 void __user *buffer, size_t *lenp,
244 loff_t *ppos)
245{
246 int error;
247
248 error = proc_dointvec(table, write, buffer, lenp, ppos);
249 if (error)
250 return error;
251
252 if (write)
253 sysrq_toggle_support(__sysrq_enabled);
254
255 return 0;
256}
257
258#endif
259
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700260static struct ctl_table kern_table[];
261static struct ctl_table vm_table[];
262static struct ctl_table fs_table[];
263static struct ctl_table debug_table[];
264static struct ctl_table dev_table[];
265extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800266#ifdef CONFIG_EPOLL
267extern struct ctl_table epoll_table[];
268#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700269
Luis R. Rodriguezceb18132018-03-10 06:14:51 -0800270#ifdef CONFIG_FW_LOADER_USER_HELPER
271extern struct ctl_table firmware_config_table[];
272#endif
273
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
275int sysctl_legacy_va_layout;
276#endif
277
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278/* The default sysctl tables: */
279
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800280static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 .procname = "kernel",
283 .mode = 0555,
284 .child = kern_table,
285 },
286 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287 .procname = "vm",
288 .mode = 0555,
289 .child = vm_table,
290 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292 .procname = "fs",
293 .mode = 0555,
294 .child = fs_table,
295 },
296 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 .procname = "debug",
298 .mode = 0555,
299 .child = debug_table,
300 },
301 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 .procname = "dev",
303 .mode = 0555,
304 .child = dev_table,
305 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700306 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307};
308
Ingo Molnar77e54a12007-07-09 18:52:00 +0200309#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100310static int min_sched_granularity_ns = 100000; /* 100 usecs */
311static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
312static int min_wakeup_granularity_ns; /* 0 usecs */
313static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200314#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100315static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
316static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200317#endif /* CONFIG_SMP */
318#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200319
Mel Gorman5e771902010-05-24 14:32:31 -0700320#ifdef CONFIG_COMPACTION
321static int min_extfrag_threshold;
322static int max_extfrag_threshold = 1000;
323#endif
324
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700325static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200326 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200327 .procname = "sched_child_runs_first",
328 .data = &sysctl_sched_child_runs_first,
329 .maxlen = sizeof(unsigned int),
330 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800331 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200332 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200333#ifdef CONFIG_SCHED_DEBUG
334 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100335 .procname = "sched_min_granularity_ns",
336 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200337 .maxlen = sizeof(unsigned int),
338 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800339 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100340 .extra1 = &min_sched_granularity_ns,
341 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200342 },
343 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200344 .procname = "sched_latency_ns",
345 .data = &sysctl_sched_latency,
346 .maxlen = sizeof(unsigned int),
347 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800348 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200349 .extra1 = &min_sched_granularity_ns,
350 .extra2 = &max_sched_granularity_ns,
351 },
352 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200353 .procname = "sched_wakeup_granularity_ns",
354 .data = &sysctl_sched_wakeup_granularity,
355 .maxlen = sizeof(unsigned int),
356 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800357 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200358 .extra1 = &min_wakeup_granularity_ns,
359 .extra2 = &max_wakeup_granularity_ns,
360 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200361#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200362 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100363 .procname = "sched_tunable_scaling",
364 .data = &sysctl_sched_tunable_scaling,
365 .maxlen = sizeof(enum sched_tunable_scaling),
366 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800367 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100368 .extra1 = &min_sched_tunable_scaling,
369 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200370 },
371 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900372 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200373 .data = &sysctl_sched_migration_cost,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800376 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200377 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100378 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100379 .procname = "sched_nr_migrate",
380 .data = &sysctl_sched_nr_migrate,
381 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100382 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800383 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100384 },
Mel Gormancb251762016-02-05 09:08:36 +0000385#ifdef CONFIG_SCHEDSTATS
386 {
387 .procname = "sched_schedstats",
388 .data = NULL,
389 .maxlen = sizeof(unsigned int),
390 .mode = 0644,
391 .proc_handler = sysctl_schedstats,
392 .extra1 = &zero,
393 .extra2 = &one,
394 },
395#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200396#endif /* CONFIG_SMP */
397#ifdef CONFIG_NUMA_BALANCING
398 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200399 .procname = "numa_balancing_scan_delay_ms",
400 .data = &sysctl_numa_balancing_scan_delay,
401 .maxlen = sizeof(unsigned int),
402 .mode = 0644,
403 .proc_handler = proc_dointvec,
404 },
405 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200406 .procname = "numa_balancing_scan_period_min_ms",
407 .data = &sysctl_numa_balancing_scan_period_min,
408 .maxlen = sizeof(unsigned int),
409 .mode = 0644,
410 .proc_handler = proc_dointvec,
411 },
412 {
413 .procname = "numa_balancing_scan_period_max_ms",
414 .data = &sysctl_numa_balancing_scan_period_max,
415 .maxlen = sizeof(unsigned int),
416 .mode = 0644,
417 .proc_handler = proc_dointvec,
418 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200419 {
420 .procname = "numa_balancing_scan_size_mb",
421 .data = &sysctl_numa_balancing_scan_size,
422 .maxlen = sizeof(unsigned int),
423 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400424 .proc_handler = proc_dointvec_minmax,
425 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200426 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100427 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800428 .procname = "numa_balancing",
429 .data = NULL, /* filled in by handler */
430 .maxlen = sizeof(unsigned int),
431 .mode = 0644,
432 .proc_handler = sysctl_numa_balancing,
433 .extra1 = &zero,
434 .extra2 = &one,
435 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200436#endif /* CONFIG_NUMA_BALANCING */
437#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200438 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100439 .procname = "sched_rt_period_us",
440 .data = &sysctl_sched_rt_period,
441 .maxlen = sizeof(unsigned int),
442 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800443 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100444 },
445 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100446 .procname = "sched_rt_runtime_us",
447 .data = &sysctl_sched_rt_runtime,
448 .maxlen = sizeof(int),
449 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800450 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100451 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600452 {
453 .procname = "sched_rr_timeslice_ms",
Shile Zhang975e1552017-01-28 22:00:49 +0800454 .data = &sysctl_sched_rr_timeslice,
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600455 .maxlen = sizeof(int),
456 .mode = 0644,
457 .proc_handler = sched_rr_handler,
458 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100459#ifdef CONFIG_SCHED_AUTOGROUP
460 {
461 .procname = "sched_autogroup_enabled",
462 .data = &sysctl_sched_autogroup_enabled,
463 .maxlen = sizeof(unsigned int),
464 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800465 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100466 .extra1 = &zero,
467 .extra2 = &one,
468 },
469#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700470#ifdef CONFIG_CFS_BANDWIDTH
471 {
472 .procname = "sched_cfs_bandwidth_slice_us",
473 .data = &sysctl_sched_cfs_bandwidth_slice,
474 .maxlen = sizeof(unsigned int),
475 .mode = 0644,
476 .proc_handler = proc_dointvec_minmax,
477 .extra1 = &one,
478 },
479#endif
Quentin Perret8d5d0cf2018-12-03 09:56:23 +0000480#if defined(CONFIG_ENERGY_MODEL) && defined(CONFIG_CPU_FREQ_GOV_SCHEDUTIL)
481 {
482 .procname = "sched_energy_aware",
483 .data = &sysctl_sched_energy_aware,
484 .maxlen = sizeof(unsigned int),
485 .mode = 0644,
486 .proc_handler = sched_energy_aware_handler,
487 .extra1 = &zero,
488 .extra2 = &one,
489 },
490#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700491#ifdef CONFIG_PROVE_LOCKING
492 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700493 .procname = "prove_locking",
494 .data = &prove_locking,
495 .maxlen = sizeof(int),
496 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800497 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700498 },
499#endif
500#ifdef CONFIG_LOCK_STAT
501 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700502 .procname = "lock_stat",
503 .data = &lock_stat,
504 .maxlen = sizeof(int),
505 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800506 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700507 },
508#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200509 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 .procname = "panic",
511 .data = &panic_timeout,
512 .maxlen = sizeof(int),
513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800514 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 },
Alex Kelly046d6622012-10-04 17:15:23 -0700516#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 .procname = "core_uses_pid",
519 .data = &core_uses_pid,
520 .maxlen = sizeof(int),
521 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800522 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 },
524 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 .procname = "core_pattern",
526 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700527 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700529 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 },
Neil Hormana2939802009-09-23 15:56:56 -0700531 {
Neil Hormana2939802009-09-23 15:56:56 -0700532 .procname = "core_pipe_limit",
533 .data = &core_pipe_limit,
534 .maxlen = sizeof(unsigned int),
535 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800536 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700537 },
Alex Kelly046d6622012-10-04 17:15:23 -0700538#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800539#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700542 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800543 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800544 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700546 {
547 .procname = "sysctl_writes_strict",
548 .data = &sysctl_writes_strict,
549 .maxlen = sizeof(int),
550 .mode = 0644,
551 .proc_handler = proc_dointvec_minmax,
552 .extra1 = &neg_one,
553 .extra2 = &one,
554 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800555#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100556#ifdef CONFIG_LATENCYTOP
557 {
558 .procname = "latencytop",
559 .data = &latencytop_enabled,
560 .maxlen = sizeof(int),
561 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000562 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100563 },
564#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565#ifdef CONFIG_BLK_DEV_INITRD
566 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 .procname = "real-root-dev",
568 .data = &real_root_dev,
569 .maxlen = sizeof(int),
570 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800571 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 },
573#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700574 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700575 .procname = "print-fatal-signals",
576 .data = &print_fatal_signals,
577 .maxlen = sizeof(int),
578 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800579 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700580 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700581#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 .procname = "reboot-cmd",
584 .data = reboot_command,
585 .maxlen = 256,
586 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800587 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 },
589 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 .procname = "stop-a",
591 .data = &stop_a_enabled,
592 .maxlen = sizeof (int),
593 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800594 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 },
596 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 .procname = "scons-poweroff",
598 .data = &scons_pwroff,
599 .maxlen = sizeof (int),
600 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800601 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 },
603#endif
David S. Miller08714202008-11-16 23:49:24 -0800604#ifdef CONFIG_SPARC64
605 {
David S. Miller08714202008-11-16 23:49:24 -0800606 .procname = "tsb-ratio",
607 .data = &sysctl_tsb_ratio,
608 .maxlen = sizeof (int),
609 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800610 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800611 },
612#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613#ifdef __hppa__
614 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 .procname = "soft-power",
616 .data = &pwrsw_enabled,
617 .maxlen = sizeof (int),
618 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800619 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530621#endif
622#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700624 .procname = "unaligned-trap",
625 .data = &unaligned_enabled,
626 .maxlen = sizeof (int),
627 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800628 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 },
630#endif
631 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 .procname = "ctrl-alt-del",
633 .data = &C_A_D,
634 .maxlen = sizeof(int),
635 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800636 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400638#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200639 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200640 .procname = "ftrace_enabled",
641 .data = &ftrace_enabled,
642 .maxlen = sizeof(int),
643 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800644 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200645 },
646#endif
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500647#ifdef CONFIG_STACK_TRACER
648 {
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500649 .procname = "stack_tracer_enabled",
650 .data = &stack_tracer_enabled,
651 .maxlen = sizeof(int),
652 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800653 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500654 },
655#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400656#ifdef CONFIG_TRACING
657 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100658 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400659 .data = &ftrace_dump_on_oops,
660 .maxlen = sizeof(int),
661 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800662 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400663 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400664 {
665 .procname = "traceoff_on_warning",
666 .data = &__disable_trace_on_warning,
667 .maxlen = sizeof(__disable_trace_on_warning),
668 .mode = 0644,
669 .proc_handler = proc_dointvec,
670 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500671 {
672 .procname = "tracepoint_printk",
673 .data = &tracepoint_printk,
674 .maxlen = sizeof(tracepoint_printk),
675 .mode = 0644,
Steven Rostedt (Red Hat)423917452016-11-23 15:52:45 -0500676 .proc_handler = tracepoint_printk_sysctl,
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500677 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400678#endif
Dave Young2965faa2015-09-09 15:38:55 -0700679#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800680 {
681 .procname = "kexec_load_disabled",
682 .data = &kexec_load_disabled,
683 .maxlen = sizeof(int),
684 .mode = 0644,
685 /* only handle a transition from default "0" to "1" */
686 .proc_handler = proc_dointvec_minmax,
687 .extra1 = &one,
688 .extra2 = &one,
689 },
690#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200691#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 .procname = "modprobe",
694 .data = &modprobe_path,
695 .maxlen = KMOD_PATH_LEN,
696 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800697 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 },
Kees Cook3d433212009-04-02 15:49:29 -0700699 {
Kees Cook3d433212009-04-02 15:49:29 -0700700 .procname = "modules_disabled",
701 .data = &modules_disabled,
702 .maxlen = sizeof(int),
703 .mode = 0644,
704 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800705 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700706 .extra1 = &one,
707 .extra2 = &one,
708 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700710#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100713 .data = &uevent_helper,
714 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800716 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 },
Michael Marineau86d56132014-04-10 14:09:31 -0700718#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719#ifdef CONFIG_CHR_DEV_SG
720 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 .procname = "sg-big-buff",
722 .data = &sg_big_buff,
723 .maxlen = sizeof (int),
724 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800725 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 },
727#endif
728#ifdef CONFIG_BSD_PROCESS_ACCT
729 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 .procname = "acct",
731 .data = &acct_parm,
732 .maxlen = 3*sizeof(int),
733 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800734 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 },
736#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737#ifdef CONFIG_MAGIC_SYSRQ
738 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800740 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 .maxlen = sizeof (int),
742 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700743 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 },
745#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700746#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700749 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 .maxlen = sizeof (int),
751 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800752 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700754#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700757 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 .maxlen = sizeof(int),
759 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700760 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 },
762 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 .procname = "random",
764 .mode = 0555,
765 .child = random_table,
766 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 {
Eric Paris17f60a72011-04-01 17:07:50 -0400768 .procname = "usermodehelper",
769 .mode = 0555,
770 .child = usermodehelper_table,
771 },
Luis R. Rodriguezceb18132018-03-10 06:14:51 -0800772#ifdef CONFIG_FW_LOADER_USER_HELPER
773 {
774 .procname = "firmware_config",
775 .mode = 0555,
776 .child = firmware_config_table,
777 },
778#endif
Eric Paris17f60a72011-04-01 17:07:50 -0400779 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 .procname = "overflowuid",
781 .data = &overflowuid,
782 .maxlen = sizeof(int),
783 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800784 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 .extra1 = &minolduid,
786 .extra2 = &maxolduid,
787 },
788 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 .procname = "overflowgid",
790 .data = &overflowgid,
791 .maxlen = sizeof(int),
792 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800793 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 .extra1 = &minolduid,
795 .extra2 = &maxolduid,
796 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800797#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798#ifdef CONFIG_MATHEMU
799 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 .procname = "ieee_emulation_warnings",
801 .data = &sysctl_ieee_emulation_warnings,
802 .maxlen = sizeof(int),
803 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800804 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 },
806#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200809 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810 .maxlen = sizeof(int),
811 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800812 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 },
814#endif
815 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 .procname = "pid_max",
817 .data = &pid_max,
818 .maxlen = sizeof (int),
819 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800820 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 .extra1 = &pid_max_min,
822 .extra2 = &pid_max_max,
823 },
824 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 .procname = "panic_on_oops",
826 .data = &panic_on_oops,
827 .maxlen = sizeof(int),
828 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800829 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 },
Feng Tang81c9d432019-01-03 15:28:20 -0800831 {
832 .procname = "panic_print",
833 .data = &panic_print,
834 .maxlen = sizeof(unsigned long),
835 .mode = 0644,
836 .proc_handler = proc_doulongvec_minmax,
837 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800838#if defined CONFIG_PRINTK
839 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800840 .procname = "printk",
841 .data = &console_loglevel,
842 .maxlen = 4*sizeof(int),
843 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800844 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800845 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700848 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 .maxlen = sizeof(int),
850 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800851 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 },
853 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700855 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856 .maxlen = sizeof(int),
857 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800858 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859 },
Dave Youngaf913222009-09-22 16:43:33 -0700860 {
Dave Youngaf913222009-09-22 16:43:33 -0700861 .procname = "printk_delay",
862 .data = &printk_delay_msec,
863 .maxlen = sizeof(int),
864 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800865 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700866 .extra1 = &zero,
867 .extra2 = &ten_thousand,
868 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700870 .procname = "printk_devkmsg",
871 .data = devkmsg_log_str,
872 .maxlen = DEVKMSG_STR_MAX_SIZE,
873 .mode = 0644,
874 .proc_handler = devkmsg_sysctl_set_loglvl,
875 },
876 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800877 .procname = "dmesg_restrict",
878 .data = &dmesg_restrict,
879 .maxlen = sizeof(int),
880 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700881 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800882 .extra1 = &zero,
883 .extra2 = &one,
884 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800885 {
886 .procname = "kptr_restrict",
887 .data = &kptr_restrict,
888 .maxlen = sizeof(int),
889 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700890 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800891 .extra1 = &zero,
892 .extra2 = &two,
893 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800894#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800895 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 .procname = "ngroups_max",
897 .data = &ngroups_max,
898 .maxlen = sizeof (int),
899 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800900 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901 },
Dan Ballard73efc032011-10-31 17:11:20 -0700902 {
903 .procname = "cap_last_cap",
904 .data = (void *)&cap_last_cap,
905 .maxlen = sizeof(int),
906 .mode = 0444,
907 .proc_handler = proc_dointvec,
908 },
Don Zickus58687ac2010-05-07 17:11:44 -0400909#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500910 {
Don Zickus58687ac2010-05-07 17:11:44 -0400911 .procname = "watchdog",
Thomas Gleixner7feeb9c2017-09-12 21:37:15 +0200912 .data = &watchdog_user_enabled,
913 .maxlen = sizeof(int),
914 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700915 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700916 .extra1 = &zero,
917 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400918 },
919 {
920 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700921 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400922 .maxlen = sizeof(int),
923 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700924 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800925 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400926 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500927 },
Don Zickus2508ce12010-05-07 17:11:46 -0400928 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700929 .procname = "nmi_watchdog",
Thomas Gleixner7feeb9c2017-09-12 21:37:15 +0200930 .data = &nmi_watchdog_user_enabled,
931 .maxlen = sizeof(int),
Thomas Gleixner51d40522017-09-12 21:37:14 +0200932 .mode = NMI_WATCHDOG_SYSCTL_PERM,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700933 .proc_handler = proc_nmi_watchdog,
934 .extra1 = &zero,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700935 .extra2 = &one,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700936 },
937 {
Nicholas Piggin05a4a952017-07-12 14:35:46 -0700938 .procname = "watchdog_cpumask",
939 .data = &watchdog_cpumask_bits,
940 .maxlen = NR_CPUS,
941 .mode = 0644,
942 .proc_handler = proc_watchdog_cpumask,
943 },
944#ifdef CONFIG_SOFTLOCKUP_DETECTOR
945 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700946 .procname = "soft_watchdog",
Thomas Gleixner7feeb9c2017-09-12 21:37:15 +0200947 .data = &soft_watchdog_user_enabled,
948 .maxlen = sizeof(int),
949 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700950 .proc_handler = proc_soft_watchdog,
951 .extra1 = &zero,
952 .extra2 = &one,
953 },
954 {
Don Zickus2508ce12010-05-07 17:11:46 -0400955 .procname = "softlockup_panic",
956 .data = &softlockup_panic,
957 .maxlen = sizeof(int),
958 .mode = 0644,
959 .proc_handler = proc_dointvec_minmax,
960 .extra1 = &zero,
961 .extra2 = &one,
962 },
Aaron Tomlined235872014-06-23 13:22:05 -0700963#ifdef CONFIG_SMP
964 {
965 .procname = "softlockup_all_cpu_backtrace",
966 .data = &sysctl_softlockup_all_cpu_backtrace,
967 .maxlen = sizeof(int),
968 .mode = 0644,
969 .proc_handler = proc_dointvec_minmax,
970 .extra1 = &zero,
971 .extra2 = &one,
972 },
Nicholas Piggin05a4a952017-07-12 14:35:46 -0700973#endif /* CONFIG_SMP */
974#endif
975#ifdef CONFIG_HARDLOCKUP_DETECTOR
976 {
977 .procname = "hardlockup_panic",
978 .data = &hardlockup_panic,
979 .maxlen = sizeof(int),
980 .mode = 0644,
981 .proc_handler = proc_dointvec_minmax,
982 .extra1 = &zero,
983 .extra2 = &one,
984 },
985#ifdef CONFIG_SMP
Jiri Kosina55537872015-11-05 18:44:41 -0800986 {
987 .procname = "hardlockup_all_cpu_backtrace",
988 .data = &sysctl_hardlockup_all_cpu_backtrace,
989 .maxlen = sizeof(int),
990 .mode = 0644,
991 .proc_handler = proc_dointvec_minmax,
992 .extra1 = &zero,
993 .extra2 = &one,
994 },
Aaron Tomlined235872014-06-23 13:22:05 -0700995#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -0500996#endif
Nicholas Piggin05a4a952017-07-12 14:35:46 -0700997#endif
998
Don Zickus5dc30552010-11-29 17:07:17 -0500999#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
1000 {
1001 .procname = "unknown_nmi_panic",
1002 .data = &unknown_nmi_panic,
1003 .maxlen = sizeof (int),
1004 .mode = 0644,
1005 .proc_handler = proc_dointvec,
1006 },
Don Zickus504d7cf2010-02-12 17:19:19 -05001007#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001008#if defined(CONFIG_X86)
1009 {
Don Zickus8da5add2006-09-26 10:52:27 +02001010 .procname = "panic_on_unrecovered_nmi",
1011 .data = &panic_on_unrecovered_nmi,
1012 .maxlen = sizeof(int),
1013 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001014 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +02001015 },
1016 {
Kurt Garloff5211a242009-06-24 14:32:11 -07001017 .procname = "panic_on_io_nmi",
1018 .data = &panic_on_io_nmi,
1019 .maxlen = sizeof(int),
1020 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001021 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -07001022 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +09001023#ifdef CONFIG_DEBUG_STACKOVERFLOW
1024 {
1025 .procname = "panic_on_stackoverflow",
1026 .data = &sysctl_panic_on_stackoverflow,
1027 .maxlen = sizeof(int),
1028 .mode = 0644,
1029 .proc_handler = proc_dointvec,
1030 },
1031#endif
Kurt Garloff5211a242009-06-24 14:32:11 -07001032 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001033 .procname = "bootloader_type",
1034 .data = &bootloader_type,
1035 .maxlen = sizeof (int),
1036 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001037 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001039 {
H. Peter Anvin50312962009-05-07 16:54:11 -07001040 .procname = "bootloader_version",
1041 .data = &bootloader_version,
1042 .maxlen = sizeof (int),
1043 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001044 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -07001045 },
1046 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001047 .procname = "io_delay_type",
1048 .data = &io_delay_type,
1049 .maxlen = sizeof(int),
1050 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001051 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001052 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001054#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056 .procname = "randomize_va_space",
1057 .data = &randomize_va_space,
1058 .maxlen = sizeof(int),
1059 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001060 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001061 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001062#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001063#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001064 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001065 .procname = "spin_retry",
1066 .data = &spin_retry,
1067 .maxlen = sizeof (int),
1068 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001069 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001070 },
1071#endif
Len Brown673d5b42007-07-28 03:33:16 -04001072#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001073 {
Pavel Machekc255d842006-02-20 18:27:58 -08001074 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001075 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001076 .maxlen = sizeof (unsigned long),
1077 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001078 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001079 },
1080#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301081#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001082 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001083 .procname = "ignore-unaligned-usertrap",
1084 .data = &no_unaligned_warning,
1085 .maxlen = sizeof (int),
1086 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001087 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001088 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301089#endif
1090#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001091 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001092 .procname = "unaligned-dump-stack",
1093 .data = &unaligned_dump_stack,
1094 .maxlen = sizeof (int),
1095 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001096 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001097 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001098#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001099#ifdef CONFIG_DETECT_HUNG_TASK
1100 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001101 .procname = "hung_task_panic",
1102 .data = &sysctl_hung_task_panic,
1103 .maxlen = sizeof(int),
1104 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001105 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001106 .extra1 = &zero,
1107 .extra2 = &one,
1108 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001109 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001110 .procname = "hung_task_check_count",
1111 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001112 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001113 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001114 .proc_handler = proc_dointvec_minmax,
1115 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001116 },
1117 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001118 .procname = "hung_task_timeout_secs",
1119 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001120 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001121 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001122 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001123 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001124 },
1125 {
Dmitry Vyukova2e51442018-08-21 21:55:52 -07001126 .procname = "hung_task_check_interval_secs",
1127 .data = &sysctl_hung_task_check_interval_secs,
1128 .maxlen = sizeof(unsigned long),
1129 .mode = 0644,
1130 .proc_handler = proc_dohung_task_timeout_secs,
1131 .extra2 = &hung_task_timeout_max,
1132 },
1133 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001134 .procname = "hung_task_warnings",
1135 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001136 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001137 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001138 .proc_handler = proc_dointvec_minmax,
1139 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001140 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001141#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001142#ifdef CONFIG_RT_MUTEXES
1143 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001144 .procname = "max_lock_depth",
1145 .data = &max_lock_depth,
1146 .maxlen = sizeof(int),
1147 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001148 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001149 },
1150#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001151 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001152 .procname = "poweroff_cmd",
1153 .data = &poweroff_cmd,
1154 .maxlen = POWEROFF_CMD_PATH_LEN,
1155 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001156 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001157 },
David Howells0b77f5b2008-04-29 01:01:32 -07001158#ifdef CONFIG_KEYS
1159 {
David Howells0b77f5b2008-04-29 01:01:32 -07001160 .procname = "keys",
1161 .mode = 0555,
1162 .child = key_sysctls,
1163 },
1164#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001165#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001166 /*
1167 * User-space scripts rely on the existence of this file
1168 * as a feature check for perf_events being enabled.
1169 *
1170 * So it's an ABI, do not remove!
1171 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001172 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001173 .procname = "perf_event_paranoid",
1174 .data = &sysctl_perf_event_paranoid,
1175 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001176 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001177 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001178 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001179 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001180 .procname = "perf_event_mlock_kb",
1181 .data = &sysctl_perf_event_mlock,
1182 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001183 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001184 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001185 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001186 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001187 .procname = "perf_event_max_sample_rate",
1188 .data = &sysctl_perf_event_sample_rate,
1189 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001190 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001191 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001192 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001193 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001194 {
1195 .procname = "perf_cpu_time_max_percent",
1196 .data = &sysctl_perf_cpu_time_max_percent,
1197 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1198 .mode = 0644,
1199 .proc_handler = perf_cpu_time_max_percent_handler,
1200 .extra1 = &zero,
1201 .extra2 = &one_hundred,
1202 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001203 {
1204 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001205 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001206 .maxlen = sizeof(sysctl_perf_event_max_stack),
1207 .mode = 0644,
1208 .proc_handler = perf_event_max_stack_handler,
1209 .extra1 = &zero,
1210 .extra2 = &six_hundred_forty_kb,
1211 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001212 {
1213 .procname = "perf_event_max_contexts_per_stack",
1214 .data = &sysctl_perf_event_max_contexts_per_stack,
1215 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1216 .mode = 0644,
1217 .proc_handler = perf_event_max_stack_handler,
1218 .extra1 = &zero,
1219 .extra2 = &one_thousand,
1220 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001221#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001222 {
1223 .procname = "panic_on_warn",
1224 .data = &panic_on_warn,
1225 .maxlen = sizeof(int),
1226 .mode = 0644,
1227 .proc_handler = proc_dointvec_minmax,
1228 .extra1 = &zero,
1229 .extra2 = &one,
1230 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001231#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1232 {
1233 .procname = "timer_migration",
1234 .data = &sysctl_timer_migration,
1235 .maxlen = sizeof(unsigned int),
1236 .mode = 0644,
1237 .proc_handler = timer_migration_handler,
Myungho Jungb94bf592017-04-19 15:24:50 -07001238 .extra1 = &zero,
1239 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001240 },
1241#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001242#ifdef CONFIG_BPF_SYSCALL
1243 {
1244 .procname = "unprivileged_bpf_disabled",
1245 .data = &sysctl_unprivileged_bpf_disabled,
1246 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1247 .mode = 0644,
1248 /* only handle a transition from default "0" to "1" */
1249 .proc_handler = proc_dointvec_minmax,
1250 .extra1 = &one,
1251 .extra2 = &one,
1252 },
Alexei Starovoitov492ecee2019-02-25 14:28:39 -08001253 {
1254 .procname = "bpf_stats_enabled",
1255 .data = &sysctl_bpf_stats_enabled,
1256 .maxlen = sizeof(sysctl_bpf_stats_enabled),
1257 .mode = 0644,
1258 .proc_handler = proc_dointvec_minmax_bpf_stats,
1259 .extra1 = &zero,
1260 .extra2 = &one,
1261 },
Alexei Starovoitov3fcc55302019-02-27 18:30:44 -08001262#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001263#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1264 {
1265 .procname = "panic_on_rcu_stall",
1266 .data = &sysctl_panic_on_rcu_stall,
1267 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1268 .mode = 0644,
1269 .proc_handler = proc_dointvec_minmax,
1270 .extra1 = &zero,
1271 .extra2 = &one,
1272 },
1273#endif
Alexander Popov964c9df2018-08-17 01:17:03 +03001274#ifdef CONFIG_STACKLEAK_RUNTIME_DISABLE
1275 {
1276 .procname = "stack_erasing",
1277 .data = NULL,
1278 .maxlen = sizeof(int),
1279 .mode = 0600,
1280 .proc_handler = stack_erasing_sysctl,
1281 .extra1 = &zero,
1282 .extra2 = &one,
1283 },
1284#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001285 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001286};
1287
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001288static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001289 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001290 .procname = "overcommit_memory",
1291 .data = &sysctl_overcommit_memory,
1292 .maxlen = sizeof(sysctl_overcommit_memory),
1293 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001294 .proc_handler = proc_dointvec_minmax,
1295 .extra1 = &zero,
1296 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297 },
1298 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001299 .procname = "panic_on_oom",
1300 .data = &sysctl_panic_on_oom,
1301 .maxlen = sizeof(sysctl_panic_on_oom),
1302 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001303 .proc_handler = proc_dointvec_minmax,
1304 .extra1 = &zero,
1305 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001306 },
1307 {
David Rientjesfe071d72007-10-16 23:25:56 -07001308 .procname = "oom_kill_allocating_task",
1309 .data = &sysctl_oom_kill_allocating_task,
1310 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1311 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001312 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001313 },
1314 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001315 .procname = "oom_dump_tasks",
1316 .data = &sysctl_oom_dump_tasks,
1317 .maxlen = sizeof(sysctl_oom_dump_tasks),
1318 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001319 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001320 },
1321 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001322 .procname = "overcommit_ratio",
1323 .data = &sysctl_overcommit_ratio,
1324 .maxlen = sizeof(sysctl_overcommit_ratio),
1325 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001326 .proc_handler = overcommit_ratio_handler,
1327 },
1328 {
1329 .procname = "overcommit_kbytes",
1330 .data = &sysctl_overcommit_kbytes,
1331 .maxlen = sizeof(sysctl_overcommit_kbytes),
1332 .mode = 0644,
1333 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001334 },
1335 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001336 .procname = "page-cluster",
1337 .data = &page_cluster,
1338 .maxlen = sizeof(int),
1339 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001340 .proc_handler = proc_dointvec_minmax,
1341 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342 },
1343 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001344 .procname = "dirty_background_ratio",
1345 .data = &dirty_background_ratio,
1346 .maxlen = sizeof(dirty_background_ratio),
1347 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001348 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001349 .extra1 = &zero,
1350 .extra2 = &one_hundred,
1351 },
1352 {
David Rientjes2da02992009-01-06 14:39:31 -08001353 .procname = "dirty_background_bytes",
1354 .data = &dirty_background_bytes,
1355 .maxlen = sizeof(dirty_background_bytes),
1356 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001357 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001358 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001359 },
1360 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001361 .procname = "dirty_ratio",
1362 .data = &vm_dirty_ratio,
1363 .maxlen = sizeof(vm_dirty_ratio),
1364 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001365 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001366 .extra1 = &zero,
1367 .extra2 = &one_hundred,
1368 },
1369 {
David Rientjes2da02992009-01-06 14:39:31 -08001370 .procname = "dirty_bytes",
1371 .data = &vm_dirty_bytes,
1372 .maxlen = sizeof(vm_dirty_bytes),
1373 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001374 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001375 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001376 },
1377 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001379 .data = &dirty_writeback_interval,
1380 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001381 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001382 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001383 },
1384 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001386 .data = &dirty_expire_interval,
1387 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001388 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001389 .proc_handler = proc_dointvec_minmax,
1390 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391 },
1392 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001393 .procname = "dirtytime_expire_seconds",
1394 .data = &dirtytime_expire_interval,
Randy Dunlap2d87b302018-04-10 16:35:14 -07001395 .maxlen = sizeof(dirtytime_expire_interval),
Theodore Ts'o1efff912015-03-17 12:23:32 -04001396 .mode = 0644,
1397 .proc_handler = dirtytime_interval_handler,
1398 .extra1 = &zero,
1399 },
1400 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401 .procname = "swappiness",
1402 .data = &vm_swappiness,
1403 .maxlen = sizeof(vm_swappiness),
1404 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001405 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001406 .extra1 = &zero,
1407 .extra2 = &one_hundred,
1408 },
1409#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001410 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001412 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413 .maxlen = sizeof(unsigned long),
1414 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001415 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001416 },
1417#ifdef CONFIG_NUMA
1418 {
1419 .procname = "nr_hugepages_mempolicy",
1420 .data = NULL,
1421 .maxlen = sizeof(unsigned long),
1422 .mode = 0644,
1423 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001424 },
Kemi Wang45180852017-11-15 17:38:22 -08001425 {
1426 .procname = "numa_stat",
1427 .data = &sysctl_vm_numa_stat,
1428 .maxlen = sizeof(int),
1429 .mode = 0644,
1430 .proc_handler = sysctl_vm_numa_stat_handler,
1431 .extra1 = &zero,
1432 .extra2 = &one,
1433 },
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001434#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001436 .procname = "hugetlb_shm_group",
1437 .data = &sysctl_hugetlb_shm_group,
1438 .maxlen = sizeof(gid_t),
1439 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001440 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001441 },
Adam Litke54f9f802007-10-16 01:26:20 -07001442 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001443 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001444 .data = NULL,
1445 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001446 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001447 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001448 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001449#endif
1450 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001451 .procname = "lowmem_reserve_ratio",
1452 .data = &sysctl_lowmem_reserve_ratio,
1453 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1454 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001455 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456 },
1457 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001458 .procname = "drop_caches",
1459 .data = &sysctl_drop_caches,
1460 .maxlen = sizeof(int),
1461 .mode = 0644,
1462 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001463 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001464 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001465 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001466#ifdef CONFIG_COMPACTION
1467 {
1468 .procname = "compact_memory",
1469 .data = &sysctl_compact_memory,
1470 .maxlen = sizeof(int),
1471 .mode = 0200,
1472 .proc_handler = sysctl_compaction_handler,
1473 },
Mel Gorman5e771902010-05-24 14:32:31 -07001474 {
1475 .procname = "extfrag_threshold",
1476 .data = &sysctl_extfrag_threshold,
1477 .maxlen = sizeof(int),
1478 .mode = 0644,
Matthew Wilcox6b7e5ca2019-03-05 15:43:41 -08001479 .proc_handler = proc_dointvec_minmax,
Mel Gorman5e771902010-05-24 14:32:31 -07001480 .extra1 = &min_extfrag_threshold,
1481 .extra2 = &max_extfrag_threshold,
1482 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001483 {
1484 .procname = "compact_unevictable_allowed",
1485 .data = &sysctl_compact_unevictable_allowed,
1486 .maxlen = sizeof(int),
1487 .mode = 0644,
1488 .proc_handler = proc_dointvec,
1489 .extra1 = &zero,
1490 .extra2 = &one,
1491 },
Mel Gorman5e771902010-05-24 14:32:31 -07001492
Mel Gorman76ab0f52010-05-24 14:32:28 -07001493#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001494 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001495 .procname = "min_free_kbytes",
1496 .data = &min_free_kbytes,
1497 .maxlen = sizeof(min_free_kbytes),
1498 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001499 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001500 .extra1 = &zero,
1501 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001502 {
Mel Gorman1c308442018-12-28 00:35:52 -08001503 .procname = "watermark_boost_factor",
1504 .data = &watermark_boost_factor,
1505 .maxlen = sizeof(watermark_boost_factor),
1506 .mode = 0644,
1507 .proc_handler = watermark_boost_factor_sysctl_handler,
1508 .extra1 = &zero,
1509 },
1510 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001511 .procname = "watermark_scale_factor",
1512 .data = &watermark_scale_factor,
1513 .maxlen = sizeof(watermark_scale_factor),
1514 .mode = 0644,
1515 .proc_handler = watermark_scale_factor_sysctl_handler,
1516 .extra1 = &one,
1517 .extra2 = &one_thousand,
1518 },
1519 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001520 .procname = "percpu_pagelist_fraction",
1521 .data = &percpu_pagelist_fraction,
1522 .maxlen = sizeof(percpu_pagelist_fraction),
1523 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001524 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001525 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001526 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001527#ifdef CONFIG_MMU
1528 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001529 .procname = "max_map_count",
1530 .data = &sysctl_max_map_count,
1531 .maxlen = sizeof(sysctl_max_map_count),
1532 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001533 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001534 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001535 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001536#else
1537 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001538 .procname = "nr_trim_pages",
1539 .data = &sysctl_nr_trim_pages,
1540 .maxlen = sizeof(sysctl_nr_trim_pages),
1541 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001542 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001543 .extra1 = &zero,
1544 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001545#endif
1546 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001547 .procname = "laptop_mode",
1548 .data = &laptop_mode,
1549 .maxlen = sizeof(laptop_mode),
1550 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001551 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001552 },
1553 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001554 .procname = "block_dump",
1555 .data = &block_dump,
1556 .maxlen = sizeof(block_dump),
1557 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001558 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559 .extra1 = &zero,
1560 },
1561 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001562 .procname = "vfs_cache_pressure",
1563 .data = &sysctl_vfs_cache_pressure,
1564 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1565 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001566 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001567 .extra1 = &zero,
1568 },
1569#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1570 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001571 .procname = "legacy_va_layout",
1572 .data = &sysctl_legacy_va_layout,
1573 .maxlen = sizeof(sysctl_legacy_va_layout),
1574 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001575 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001576 .extra1 = &zero,
1577 },
1578#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001579#ifdef CONFIG_NUMA
1580 {
Christoph Lameter17436602006-01-18 17:42:32 -08001581 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001582 .data = &node_reclaim_mode,
1583 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001584 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001585 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001586 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001587 },
Christoph Lameter96146342006-07-03 00:24:13 -07001588 {
Christoph Lameter96146342006-07-03 00:24:13 -07001589 .procname = "min_unmapped_ratio",
1590 .data = &sysctl_min_unmapped_ratio,
1591 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1592 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001593 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001594 .extra1 = &zero,
1595 .extra2 = &one_hundred,
1596 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001597 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001598 .procname = "min_slab_ratio",
1599 .data = &sysctl_min_slab_ratio,
1600 .maxlen = sizeof(sysctl_min_slab_ratio),
1601 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001602 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001603 .extra1 = &zero,
1604 .extra2 = &one_hundred,
1605 },
Christoph Lameter17436602006-01-18 17:42:32 -08001606#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001607#ifdef CONFIG_SMP
1608 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001609 .procname = "stat_interval",
1610 .data = &sysctl_stat_interval,
1611 .maxlen = sizeof(sysctl_stat_interval),
1612 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001613 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001614 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001615 {
1616 .procname = "stat_refresh",
1617 .data = NULL,
1618 .maxlen = 0,
1619 .mode = 0600,
1620 .proc_handler = vmstat_refresh,
1621 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001622#endif
David Howells6e141542009-12-15 19:27:45 +00001623#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001624 {
Eric Parised032182007-06-28 15:55:21 -04001625 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001626 .data = &dac_mmap_min_addr,
1627 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001628 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001629 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001630 },
David Howells6e141542009-12-15 19:27:45 +00001631#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001632#ifdef CONFIG_NUMA
1633 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001634 .procname = "numa_zonelist_order",
1635 .data = &numa_zonelist_order,
1636 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1637 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001638 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001639 },
1640#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001641#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001642 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001643 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001644 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001645#ifdef CONFIG_X86_32
1646 .data = &vdso32_enabled,
1647 .maxlen = sizeof(vdso32_enabled),
1648#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001649 .data = &vdso_enabled,
1650 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001651#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001652 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001653 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001654 .extra1 = &zero,
1655 },
1656#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001657#ifdef CONFIG_HIGHMEM
1658 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001659 .procname = "highmem_is_dirtyable",
1660 .data = &vm_highmem_is_dirtyable,
1661 .maxlen = sizeof(vm_highmem_is_dirtyable),
1662 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001663 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001664 .extra1 = &zero,
1665 .extra2 = &one,
1666 },
1667#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001668#ifdef CONFIG_MEMORY_FAILURE
1669 {
Andi Kleen6a460792009-09-16 11:50:15 +02001670 .procname = "memory_failure_early_kill",
1671 .data = &sysctl_memory_failure_early_kill,
1672 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1673 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001674 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001675 .extra1 = &zero,
1676 .extra2 = &one,
1677 },
1678 {
Andi Kleen6a460792009-09-16 11:50:15 +02001679 .procname = "memory_failure_recovery",
1680 .data = &sysctl_memory_failure_recovery,
1681 .maxlen = sizeof(sysctl_memory_failure_recovery),
1682 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001683 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001684 .extra1 = &zero,
1685 .extra2 = &one,
1686 },
1687#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001688 {
1689 .procname = "user_reserve_kbytes",
1690 .data = &sysctl_user_reserve_kbytes,
1691 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1692 .mode = 0644,
1693 .proc_handler = proc_doulongvec_minmax,
1694 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001695 {
1696 .procname = "admin_reserve_kbytes",
1697 .data = &sysctl_admin_reserve_kbytes,
1698 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1699 .mode = 0644,
1700 .proc_handler = proc_doulongvec_minmax,
1701 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001702#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1703 {
1704 .procname = "mmap_rnd_bits",
1705 .data = &mmap_rnd_bits,
1706 .maxlen = sizeof(mmap_rnd_bits),
1707 .mode = 0600,
1708 .proc_handler = proc_dointvec_minmax,
1709 .extra1 = (void *)&mmap_rnd_bits_min,
1710 .extra2 = (void *)&mmap_rnd_bits_max,
1711 },
1712#endif
1713#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1714 {
1715 .procname = "mmap_rnd_compat_bits",
1716 .data = &mmap_rnd_compat_bits,
1717 .maxlen = sizeof(mmap_rnd_compat_bits),
1718 .mode = 0600,
1719 .proc_handler = proc_dointvec_minmax,
1720 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1721 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1722 },
1723#endif
Peter Xucefdca02019-05-13 17:16:41 -07001724#ifdef CONFIG_USERFAULTFD
1725 {
1726 .procname = "unprivileged_userfaultfd",
1727 .data = &sysctl_unprivileged_userfaultfd,
1728 .maxlen = sizeof(sysctl_unprivileged_userfaultfd),
1729 .mode = 0644,
1730 .proc_handler = proc_dointvec_minmax,
1731 .extra1 = &zero,
1732 .extra2 = &one,
1733 },
1734#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001735 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736};
1737
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001738static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001739 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740 .procname = "inode-nr",
1741 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001742 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001743 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001744 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001745 },
1746 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001747 .procname = "inode-state",
1748 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001749 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001751 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001752 },
1753 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001754 .procname = "file-nr",
1755 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001756 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001757 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001758 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001759 },
1760 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001761 .procname = "file-max",
1762 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001763 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001764 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001765 .proc_handler = proc_doulongvec_minmax,
Will Deacon9002b212019-04-05 18:39:38 -07001766 .extra1 = &zero_ul,
Christian Brauner32a5ad92019-03-07 16:29:43 -08001767 .extra2 = &long_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001768 },
1769 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001770 .procname = "nr_open",
1771 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001772 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001773 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001774 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001775 .extra1 = &sysctl_nr_open_min,
1776 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001777 },
1778 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001779 .procname = "dentry-state",
1780 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001781 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001782 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001783 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001784 },
1785 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001786 .procname = "overflowuid",
1787 .data = &fs_overflowuid,
1788 .maxlen = sizeof(int),
1789 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001790 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001791 .extra1 = &minolduid,
1792 .extra2 = &maxolduid,
1793 },
1794 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001795 .procname = "overflowgid",
1796 .data = &fs_overflowgid,
1797 .maxlen = sizeof(int),
1798 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001799 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001800 .extra1 = &minolduid,
1801 .extra2 = &maxolduid,
1802 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001803#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001804 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001805 .procname = "leases-enable",
1806 .data = &leases_enable,
1807 .maxlen = sizeof(int),
1808 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001809 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001810 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001811#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001812#ifdef CONFIG_DNOTIFY
1813 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001814 .procname = "dir-notify-enable",
1815 .data = &dir_notify_enable,
1816 .maxlen = sizeof(int),
1817 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001818 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001819 },
1820#endif
1821#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001822#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001823 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001824 .procname = "lease-break-time",
1825 .data = &lease_break_time,
1826 .maxlen = sizeof(int),
1827 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001828 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001829 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001830#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001831#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001832 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001833 .procname = "aio-nr",
1834 .data = &aio_nr,
1835 .maxlen = sizeof(aio_nr),
1836 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001837 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001838 },
1839 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001840 .procname = "aio-max-nr",
1841 .data = &aio_max_nr,
1842 .maxlen = sizeof(aio_max_nr),
1843 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001844 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001845 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001846#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001847#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001848 {
Robert Love0399cb02005-07-13 12:38:18 -04001849 .procname = "inotify",
1850 .mode = 0555,
1851 .child = inotify_table,
1852 },
1853#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001854#ifdef CONFIG_EPOLL
1855 {
1856 .procname = "epoll",
1857 .mode = 0555,
1858 .child = epoll_table,
1859 },
1860#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001861#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001862 {
Kees Cook800179c2012-07-25 17:29:07 -07001863 .procname = "protected_symlinks",
1864 .data = &sysctl_protected_symlinks,
1865 .maxlen = sizeof(int),
1866 .mode = 0600,
1867 .proc_handler = proc_dointvec_minmax,
1868 .extra1 = &zero,
1869 .extra2 = &one,
1870 },
1871 {
1872 .procname = "protected_hardlinks",
1873 .data = &sysctl_protected_hardlinks,
1874 .maxlen = sizeof(int),
1875 .mode = 0600,
1876 .proc_handler = proc_dointvec_minmax,
1877 .extra1 = &zero,
1878 .extra2 = &one,
1879 },
1880 {
Salvatore Mesoraca30aba662018-08-23 17:00:35 -07001881 .procname = "protected_fifos",
1882 .data = &sysctl_protected_fifos,
1883 .maxlen = sizeof(int),
1884 .mode = 0600,
1885 .proc_handler = proc_dointvec_minmax,
1886 .extra1 = &zero,
1887 .extra2 = &two,
1888 },
1889 {
1890 .procname = "protected_regular",
1891 .data = &sysctl_protected_regular,
1892 .maxlen = sizeof(int),
1893 .mode = 0600,
1894 .proc_handler = proc_dointvec_minmax,
1895 .extra1 = &zero,
1896 .extra2 = &two,
1897 },
1898 {
Alan Coxd6e71142005-06-23 00:09:43 -07001899 .procname = "suid_dumpable",
1900 .data = &suid_dumpable,
1901 .maxlen = sizeof(int),
1902 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001903 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001904 .extra1 = &zero,
1905 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001906 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001907#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1908 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001909 .procname = "binfmt_misc",
1910 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001911 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001912 },
1913#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001914 {
Jens Axboeff9da692010-06-03 14:54:39 +02001915 .procname = "pipe-max-size",
1916 .data = &pipe_max_size,
Joe Lawrence98159d92017-11-17 15:29:17 -08001917 .maxlen = sizeof(pipe_max_size),
Jens Axboeb492e952010-05-19 21:03:16 +02001918 .mode = 0644,
Eric Biggers319e0a22018-02-06 15:41:49 -08001919 .proc_handler = proc_dopipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001920 },
Willy Tarreau759c0112016-01-18 16:36:09 +01001921 {
1922 .procname = "pipe-user-pages-hard",
1923 .data = &pipe_user_pages_hard,
1924 .maxlen = sizeof(pipe_user_pages_hard),
1925 .mode = 0644,
1926 .proc_handler = proc_doulongvec_minmax,
1927 },
1928 {
1929 .procname = "pipe-user-pages-soft",
1930 .data = &pipe_user_pages_soft,
1931 .maxlen = sizeof(pipe_user_pages_soft),
1932 .mode = 0644,
1933 .proc_handler = proc_doulongvec_minmax,
1934 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05001935 {
1936 .procname = "mount-max",
1937 .data = &sysctl_mount_max,
1938 .maxlen = sizeof(unsigned int),
1939 .mode = 0644,
1940 .proc_handler = proc_dointvec_minmax,
1941 .extra1 = &one,
1942 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001943 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001944};
1945
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001946static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001947#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001948 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001949 .procname = "exception-trace",
1950 .data = &show_unhandled_signals,
1951 .maxlen = sizeof(int),
1952 .mode = 0644,
1953 .proc_handler = proc_dointvec
1954 },
1955#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001956#if defined(CONFIG_OPTPROBES)
1957 {
1958 .procname = "kprobes-optimization",
1959 .data = &sysctl_kprobes_optimization,
1960 .maxlen = sizeof(int),
1961 .mode = 0644,
1962 .proc_handler = proc_kprobes_optimization_handler,
1963 .extra1 = &zero,
1964 .extra2 = &one,
1965 },
1966#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001967 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001968};
1969
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001970static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001971 { }
Robert Love0eeca282005-07-12 17:06:03 -04001972};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001973
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001974int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001975{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001976 struct ctl_table_header *hdr;
1977
1978 hdr = register_sysctl_table(sysctl_base_table);
1979 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001980 return 0;
1981}
1982
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001983#endif /* CONFIG_SYSCTL */
1984
Linus Torvalds1da177e2005-04-16 15:20:36 -07001985/*
1986 * /proc/sys support
1987 */
1988
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001989#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001990
Kees Cookf8808302014-06-06 14:37:17 -07001991static int _proc_do_string(char *data, int maxlen, int write,
1992 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001993 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001994{
1995 size_t len;
1996 char __user *p;
1997 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001998
1999 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002000 *lenp = 0;
2001 return 0;
2002 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08002003
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002004 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002005 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
2006 /* Only continue writes not past the end of buffer. */
2007 len = strlen(data);
2008 if (len > maxlen - 1)
2009 len = maxlen - 1;
2010
2011 if (*ppos > len)
2012 return 0;
2013 len = *ppos;
2014 } else {
2015 /* Start writing from beginning of buffer. */
2016 len = 0;
2017 }
2018
Kees Cook2ca9bb42014-06-06 14:37:18 -07002019 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002020 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002021 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002022 if (get_user(c, p++))
2023 return -EFAULT;
2024 if (c == 0 || c == '\n')
2025 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002026 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002027 }
Kees Cookf8808302014-06-06 14:37:17 -07002028 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002029 } else {
2030 len = strlen(data);
2031 if (len > maxlen)
2032 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002033
2034 if (*ppos > len) {
2035 *lenp = 0;
2036 return 0;
2037 }
2038
2039 data += *ppos;
2040 len -= *ppos;
2041
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002042 if (len > *lenp)
2043 len = *lenp;
2044 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07002045 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002046 return -EFAULT;
2047 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07002048 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002049 return -EFAULT;
2050 len++;
2051 }
2052 *lenp = len;
2053 *ppos += len;
2054 }
2055 return 0;
2056}
2057
Kees Cookf4aacea2014-06-06 14:37:19 -07002058static void warn_sysctl_write(struct ctl_table *table)
2059{
2060 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2061 "This will not be supported in the future. To silence this\n"
2062 "warning, set kernel.sysctl_writes_strict = -1\n",
2063 current->comm, table->procname);
2064}
2065
Linus Torvalds1da177e2005-04-16 15:20:36 -07002066/**
Randy Dunlap5f733e82018-08-21 22:01:06 -07002067 * proc_first_pos_non_zero_ignore - check if first position is allowed
Luis R. Rodriguezd383d482017-07-12 14:33:33 -07002068 * @ppos: file position
2069 * @table: the sysctl table
2070 *
2071 * Returns true if the first position is non-zero and the sysctl_writes_strict
2072 * mode indicates this is not allowed for numeric input types. String proc
Randy Dunlap5f733e82018-08-21 22:01:06 -07002073 * handlers can ignore the return value.
Luis R. Rodriguezd383d482017-07-12 14:33:33 -07002074 */
2075static bool proc_first_pos_non_zero_ignore(loff_t *ppos,
2076 struct ctl_table *table)
2077{
2078 if (!*ppos)
2079 return false;
2080
2081 switch (sysctl_writes_strict) {
2082 case SYSCTL_WRITES_STRICT:
2083 return true;
2084 case SYSCTL_WRITES_WARN:
2085 warn_sysctl_write(table);
2086 return false;
2087 default:
2088 return false;
2089 }
2090}
2091
2092/**
Linus Torvalds1da177e2005-04-16 15:20:36 -07002093 * proc_dostring - read a string sysctl
2094 * @table: the sysctl table
2095 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002096 * @buffer: the user buffer
2097 * @lenp: the size of the user buffer
2098 * @ppos: file position
2099 *
2100 * Reads/writes a string from/to the user buffer. If the kernel
2101 * buffer provided is not large enough to hold the string, the
2102 * string is truncated. The copied string is %NULL-terminated.
2103 * If the string is being read by the user process, it is copied
2104 * and a newline '\n' is added. It is truncated if the buffer is
2105 * not large enough.
2106 *
2107 * Returns 0 on success.
2108 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002109int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002110 void __user *buffer, size_t *lenp, loff_t *ppos)
2111{
Luis R. Rodriguezd383d482017-07-12 14:33:33 -07002112 if (write)
2113 proc_first_pos_non_zero_ignore(ppos, table);
Kees Cookf4aacea2014-06-06 14:37:19 -07002114
Kees Cookf8808302014-06-06 14:37:17 -07002115 return _proc_do_string((char *)(table->data), table->maxlen, write,
2116 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002117}
2118
Amerigo Wang00b7c332010-05-05 00:26:45 +00002119static size_t proc_skip_spaces(char **buf)
2120{
2121 size_t ret;
2122 char *tmp = skip_spaces(*buf);
2123 ret = tmp - *buf;
2124 *buf = tmp;
2125 return ret;
2126}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002127
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002128static void proc_skip_char(char **buf, size_t *size, const char v)
2129{
2130 while (*size) {
2131 if (**buf != v)
2132 break;
2133 (*size)--;
2134 (*buf)++;
2135 }
2136}
2137
Christian Brauner7f2923c2019-03-07 16:29:40 -08002138/**
2139 * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
2140 * fail on overflow
2141 *
2142 * @cp: kernel buffer containing the string to parse
2143 * @endp: pointer to store the trailing characters
2144 * @base: the base to use
2145 * @res: where the parsed integer will be stored
2146 *
2147 * In case of success 0 is returned and @res will contain the parsed integer,
2148 * @endp will hold any trailing characters.
2149 * This function will fail the parse on overflow. If there wasn't an overflow
2150 * the function will defer the decision what characters count as invalid to the
2151 * caller.
2152 */
2153static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
2154 unsigned long *res)
2155{
2156 unsigned long long result;
2157 unsigned int rv;
2158
2159 cp = _parse_integer_fixup_radix(cp, &base);
2160 rv = _parse_integer(cp, base, &result);
2161 if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
2162 return -ERANGE;
2163
2164 cp += rv;
2165
2166 if (endp)
2167 *endp = (char *)cp;
2168
2169 *res = (unsigned long)result;
2170 return 0;
2171}
2172
Amerigo Wang00b7c332010-05-05 00:26:45 +00002173#define TMPBUFLEN 22
2174/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002175 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002176 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002177 * @buf: a kernel buffer
2178 * @size: size of the kernel buffer
2179 * @val: this is where the number will be stored
2180 * @neg: set to %TRUE if number is negative
2181 * @perm_tr: a vector which contains the allowed trailers
2182 * @perm_tr_len: size of the perm_tr vector
2183 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002184 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002185 * In case of success %0 is returned and @buf and @size are updated with
2186 * the amount of bytes read. If @tr is non-NULL and a trailing
2187 * character exists (size is non-zero after returning from this
2188 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002189 */
2190static int proc_get_long(char **buf, size_t *size,
2191 unsigned long *val, bool *neg,
2192 const char *perm_tr, unsigned perm_tr_len, char *tr)
2193{
2194 int len;
2195 char *p, tmp[TMPBUFLEN];
2196
2197 if (!*size)
2198 return -EINVAL;
2199
2200 len = *size;
2201 if (len > TMPBUFLEN - 1)
2202 len = TMPBUFLEN - 1;
2203
2204 memcpy(tmp, *buf, len);
2205
2206 tmp[len] = 0;
2207 p = tmp;
2208 if (*p == '-' && *size > 1) {
2209 *neg = true;
2210 p++;
2211 } else
2212 *neg = false;
2213 if (!isdigit(*p))
2214 return -EINVAL;
2215
Christian Brauner7f2923c2019-03-07 16:29:40 -08002216 if (strtoul_lenient(p, &p, 0, val))
2217 return -EINVAL;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002218
2219 len = p - tmp;
2220
2221 /* We don't know if the next char is whitespace thus we may accept
2222 * invalid integers (e.g. 1234...a) or two integers instead of one
2223 * (e.g. 123...1). So lets not allow such large numbers. */
2224 if (len == TMPBUFLEN - 1)
2225 return -EINVAL;
2226
2227 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2228 return -EINVAL;
2229
2230 if (tr && (len < *size))
2231 *tr = *p;
2232
2233 *buf += len;
2234 *size -= len;
2235
2236 return 0;
2237}
2238
2239/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002240 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002241 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002242 * @buf: the user buffer
2243 * @size: the size of the user buffer
2244 * @val: the integer to be converted
2245 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002246 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002247 * In case of success %0 is returned and @buf and @size are updated with
2248 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002249 */
2250static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2251 bool neg)
2252{
2253 int len;
2254 char tmp[TMPBUFLEN], *p = tmp;
2255
2256 sprintf(p, "%s%lu", neg ? "-" : "", val);
2257 len = strlen(tmp);
2258 if (len > *size)
2259 len = *size;
2260 if (copy_to_user(*buf, tmp, len))
2261 return -EFAULT;
2262 *size -= len;
2263 *buf += len;
2264 return 0;
2265}
2266#undef TMPBUFLEN
2267
2268static int proc_put_char(void __user **buf, size_t *size, char c)
2269{
2270 if (*size) {
2271 char __user **buffer = (char __user **)buf;
2272 if (put_user(c, *buffer))
2273 return -EFAULT;
2274 (*size)--, (*buffer)++;
2275 *buf = *buffer;
2276 }
2277 return 0;
2278}
2279
2280static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002281 int *valp,
2282 int write, void *data)
2283{
2284 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002285 if (*negp) {
2286 if (*lvalp > (unsigned long) INT_MAX + 1)
2287 return -EINVAL;
2288 *valp = -*lvalp;
2289 } else {
2290 if (*lvalp > (unsigned long) INT_MAX)
2291 return -EINVAL;
2292 *valp = *lvalp;
2293 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002294 } else {
2295 int val = *valp;
2296 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002297 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002298 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002299 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002300 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002301 *lvalp = (unsigned long)val;
2302 }
2303 }
2304 return 0;
2305}
2306
Luis R. Rodriguez4f2fec02017-07-12 14:33:36 -07002307static int do_proc_douintvec_conv(unsigned long *lvalp,
2308 unsigned int *valp,
2309 int write, void *data)
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002310{
2311 if (write) {
Luis R. Rodriguez4f2fec02017-07-12 14:33:36 -07002312 if (*lvalp > UINT_MAX)
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002313 return -EINVAL;
2314 *valp = *lvalp;
2315 } else {
2316 unsigned int val = *valp;
2317 *lvalp = (unsigned long)val;
2318 }
2319 return 0;
2320}
2321
Amerigo Wang00b7c332010-05-05 00:26:45 +00002322static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2323
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002324static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002325 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002326 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002327 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002328 int write, void *data),
2329 void *data)
2330{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002331 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002332 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002333 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002334
Amerigo Wang00b7c332010-05-05 00:26:45 +00002335 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002336 *lenp = 0;
2337 return 0;
2338 }
2339
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002340 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002341 vleft = table->maxlen / sizeof(*i);
2342 left = *lenp;
2343
2344 if (!conv)
2345 conv = do_proc_dointvec_conv;
2346
Linus Torvalds1da177e2005-04-16 15:20:36 -07002347 if (write) {
Luis R. Rodriguezd383d482017-07-12 14:33:33 -07002348 if (proc_first_pos_non_zero_ignore(ppos, table))
2349 goto out;
Kees Cookf4aacea2014-06-06 14:37:19 -07002350
Amerigo Wang00b7c332010-05-05 00:26:45 +00002351 if (left > PAGE_SIZE - 1)
2352 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002353 p = kbuf = memdup_user_nul(buffer, left);
2354 if (IS_ERR(kbuf))
2355 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002356 }
2357
2358 for (; left && vleft--; i++, first=0) {
2359 unsigned long lval;
2360 bool neg;
2361
2362 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002363 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002364
J. R. Okajima563b0462010-05-25 16:10:14 -07002365 if (!left)
2366 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002367 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002368 proc_wspace_sep,
2369 sizeof(proc_wspace_sep), NULL);
2370 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002371 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002372 if (conv(&neg, &lval, i, 1, data)) {
2373 err = -EINVAL;
2374 break;
2375 }
2376 } else {
2377 if (conv(&neg, &lval, i, 0, data)) {
2378 err = -EINVAL;
2379 break;
2380 }
2381 if (!first)
2382 err = proc_put_char(&buffer, &left, '\t');
2383 if (err)
2384 break;
2385 err = proc_put_long(&buffer, &left, lval, neg);
2386 if (err)
2387 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388 }
2389 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002390
2391 if (!write && !first && left && !err)
2392 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002393 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002394 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002395 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002396 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002397 if (first)
2398 return err ? : -EINVAL;
2399 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002400 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002401out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002402 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002403 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002404}
2405
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002406static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002407 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002408 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002409 int write, void *data),
2410 void *data)
2411{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002412 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002413 buffer, lenp, ppos, conv, data);
2414}
2415
Luis R. Rodriguez4f2fec02017-07-12 14:33:36 -07002416static int do_proc_douintvec_w(unsigned int *tbl_data,
2417 struct ctl_table *table,
2418 void __user *buffer,
2419 size_t *lenp, loff_t *ppos,
2420 int (*conv)(unsigned long *lvalp,
2421 unsigned int *valp,
2422 int write, void *data),
2423 void *data)
2424{
2425 unsigned long lval;
2426 int err = 0;
2427 size_t left;
2428 bool neg;
2429 char *kbuf = NULL, *p;
2430
2431 left = *lenp;
2432
2433 if (proc_first_pos_non_zero_ignore(ppos, table))
2434 goto bail_early;
2435
2436 if (left > PAGE_SIZE - 1)
2437 left = PAGE_SIZE - 1;
2438
2439 p = kbuf = memdup_user_nul(buffer, left);
2440 if (IS_ERR(kbuf))
2441 return -EINVAL;
2442
2443 left -= proc_skip_spaces(&p);
2444 if (!left) {
2445 err = -EINVAL;
2446 goto out_free;
2447 }
2448
2449 err = proc_get_long(&p, &left, &lval, &neg,
2450 proc_wspace_sep,
2451 sizeof(proc_wspace_sep), NULL);
2452 if (err || neg) {
2453 err = -EINVAL;
2454 goto out_free;
2455 }
2456
2457 if (conv(&lval, tbl_data, 1, data)) {
2458 err = -EINVAL;
2459 goto out_free;
2460 }
2461
2462 if (!err && left)
2463 left -= proc_skip_spaces(&p);
2464
2465out_free:
2466 kfree(kbuf);
2467 if (err)
2468 return -EINVAL;
2469
2470 return 0;
2471
2472 /* This is in keeping with old __do_proc_dointvec() */
2473bail_early:
2474 *ppos += *lenp;
2475 return err;
2476}
2477
2478static int do_proc_douintvec_r(unsigned int *tbl_data, void __user *buffer,
2479 size_t *lenp, loff_t *ppos,
2480 int (*conv)(unsigned long *lvalp,
2481 unsigned int *valp,
2482 int write, void *data),
2483 void *data)
2484{
2485 unsigned long lval;
2486 int err = 0;
2487 size_t left;
2488
2489 left = *lenp;
2490
2491 if (conv(&lval, tbl_data, 0, data)) {
2492 err = -EINVAL;
2493 goto out;
2494 }
2495
2496 err = proc_put_long(&buffer, &left, lval, false);
2497 if (err || !left)
2498 goto out;
2499
2500 err = proc_put_char(&buffer, &left, '\n');
2501
2502out:
2503 *lenp -= left;
2504 *ppos += *lenp;
2505
2506 return err;
2507}
2508
2509static int __do_proc_douintvec(void *tbl_data, struct ctl_table *table,
2510 int write, void __user *buffer,
2511 size_t *lenp, loff_t *ppos,
2512 int (*conv)(unsigned long *lvalp,
2513 unsigned int *valp,
2514 int write, void *data),
2515 void *data)
2516{
2517 unsigned int *i, vleft;
2518
2519 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
2520 *lenp = 0;
2521 return 0;
2522 }
2523
2524 i = (unsigned int *) tbl_data;
2525 vleft = table->maxlen / sizeof(*i);
2526
2527 /*
2528 * Arrays are not supported, keep this simple. *Do not* add
2529 * support for them.
2530 */
2531 if (vleft != 1) {
2532 *lenp = 0;
2533 return -EINVAL;
2534 }
2535
2536 if (!conv)
2537 conv = do_proc_douintvec_conv;
2538
2539 if (write)
2540 return do_proc_douintvec_w(i, table, buffer, lenp, ppos,
2541 conv, data);
2542 return do_proc_douintvec_r(i, buffer, lenp, ppos, conv, data);
2543}
2544
2545static int do_proc_douintvec(struct ctl_table *table, int write,
2546 void __user *buffer, size_t *lenp, loff_t *ppos,
2547 int (*conv)(unsigned long *lvalp,
2548 unsigned int *valp,
2549 int write, void *data),
2550 void *data)
2551{
2552 return __do_proc_douintvec(table->data, table, write,
2553 buffer, lenp, ppos, conv, data);
2554}
2555
Linus Torvalds1da177e2005-04-16 15:20:36 -07002556/**
2557 * proc_dointvec - read a vector of integers
2558 * @table: the sysctl table
2559 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002560 * @buffer: the user buffer
2561 * @lenp: the size of the user buffer
2562 * @ppos: file position
2563 *
2564 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2565 * values from/to the user buffer, treated as an ASCII string.
2566 *
2567 * Returns 0 on success.
2568 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002569int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002570 void __user *buffer, size_t *lenp, loff_t *ppos)
2571{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002572 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2573}
2574
2575/**
2576 * proc_douintvec - read a vector of unsigned integers
2577 * @table: the sysctl table
2578 * @write: %TRUE if this is a write to the sysctl file
2579 * @buffer: the user buffer
2580 * @lenp: the size of the user buffer
2581 * @ppos: file position
2582 *
2583 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2584 * values from/to the user buffer, treated as an ASCII string.
2585 *
2586 * Returns 0 on success.
2587 */
2588int proc_douintvec(struct ctl_table *table, int write,
2589 void __user *buffer, size_t *lenp, loff_t *ppos)
2590{
Luis R. Rodriguez4f2fec02017-07-12 14:33:36 -07002591 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2592 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593}
2594
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002595/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002596 * Taint values can only be increased
2597 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002598 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002599static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002600 void __user *buffer, size_t *lenp, loff_t *ppos)
2601{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002602 struct ctl_table t;
2603 unsigned long tmptaint = get_taint();
2604 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002605
Bastian Blank91fcd412007-04-23 14:41:14 -07002606 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002607 return -EPERM;
2608
Andi Kleen25ddbb12008-10-15 22:01:41 -07002609 t = *table;
2610 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002611 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002612 if (err < 0)
2613 return err;
2614
2615 if (write) {
2616 /*
2617 * Poor man's atomic or. Not worth adding a primitive
2618 * to everyone's atomic.h for this
2619 */
2620 int i;
2621 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2622 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302623 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002624 }
2625 }
2626
2627 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002628}
2629
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002630#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002631static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002632 void __user *buffer, size_t *lenp, loff_t *ppos)
2633{
2634 if (write && !capable(CAP_SYS_ADMIN))
2635 return -EPERM;
2636
2637 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2638}
2639#endif
2640
Waiman Long24704f32018-04-10 16:35:38 -07002641/**
2642 * struct do_proc_dointvec_minmax_conv_param - proc_dointvec_minmax() range checking structure
2643 * @min: pointer to minimum allowable value
2644 * @max: pointer to maximum allowable value
2645 *
2646 * The do_proc_dointvec_minmax_conv_param structure provides the
2647 * minimum and maximum values for doing range checking for those sysctl
2648 * parameters that use the proc_dointvec_minmax() handler.
2649 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002650struct do_proc_dointvec_minmax_conv_param {
2651 int *min;
2652 int *max;
2653};
2654
Amerigo Wang00b7c332010-05-05 00:26:45 +00002655static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2656 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002657 int write, void *data)
2658{
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002659 int tmp, ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002660 struct do_proc_dointvec_minmax_conv_param *param = data;
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002661 /*
2662 * If writing, first do so via a temporary local int so we can
2663 * bounds-check it before touching *valp.
2664 */
2665 int *ip = write ? &tmp : valp;
2666
2667 ret = do_proc_dointvec_conv(negp, lvalp, ip, write, data);
2668 if (ret)
2669 return ret;
2670
Linus Torvalds1da177e2005-04-16 15:20:36 -07002671 if (write) {
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002672 if ((param->min && *param->min > tmp) ||
2673 (param->max && *param->max < tmp))
Linus Torvalds1da177e2005-04-16 15:20:36 -07002674 return -EINVAL;
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002675 *valp = tmp;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002676 }
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002677
Linus Torvalds1da177e2005-04-16 15:20:36 -07002678 return 0;
2679}
2680
2681/**
2682 * proc_dointvec_minmax - read a vector of integers with min/max values
2683 * @table: the sysctl table
2684 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002685 * @buffer: the user buffer
2686 * @lenp: the size of the user buffer
2687 * @ppos: file position
2688 *
2689 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2690 * values from/to the user buffer, treated as an ASCII string.
2691 *
2692 * This routine will ensure the values are within the range specified by
2693 * table->extra1 (min) and table->extra2 (max).
2694 *
Waiman Long24704f32018-04-10 16:35:38 -07002695 * Returns 0 on success or -EINVAL on write when the range check fails.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002696 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002697int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002698 void __user *buffer, size_t *lenp, loff_t *ppos)
2699{
2700 struct do_proc_dointvec_minmax_conv_param param = {
2701 .min = (int *) table->extra1,
2702 .max = (int *) table->extra2,
2703 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002704 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002705 do_proc_dointvec_minmax_conv, &param);
2706}
2707
Waiman Long24704f32018-04-10 16:35:38 -07002708/**
2709 * struct do_proc_douintvec_minmax_conv_param - proc_douintvec_minmax() range checking structure
2710 * @min: pointer to minimum allowable value
2711 * @max: pointer to maximum allowable value
2712 *
2713 * The do_proc_douintvec_minmax_conv_param structure provides the
2714 * minimum and maximum values for doing range checking for those sysctl
2715 * parameters that use the proc_douintvec_minmax() handler.
2716 */
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07002717struct do_proc_douintvec_minmax_conv_param {
2718 unsigned int *min;
2719 unsigned int *max;
2720};
2721
2722static int do_proc_douintvec_minmax_conv(unsigned long *lvalp,
2723 unsigned int *valp,
2724 int write, void *data)
2725{
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002726 int ret;
2727 unsigned int tmp;
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07002728 struct do_proc_douintvec_minmax_conv_param *param = data;
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002729 /* write via temporary local uint for bounds-checking */
2730 unsigned int *up = write ? &tmp : valp;
2731
2732 ret = do_proc_douintvec_conv(lvalp, up, write, data);
2733 if (ret)
2734 return ret;
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07002735
2736 if (write) {
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002737 if ((param->min && *param->min > tmp) ||
2738 (param->max && *param->max < tmp))
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07002739 return -ERANGE;
2740
Zev Weiss2bc4fc62019-03-11 23:28:06 -07002741 *valp = tmp;
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07002742 }
2743
2744 return 0;
2745}
2746
2747/**
2748 * proc_douintvec_minmax - read a vector of unsigned ints with min/max values
2749 * @table: the sysctl table
2750 * @write: %TRUE if this is a write to the sysctl file
2751 * @buffer: the user buffer
2752 * @lenp: the size of the user buffer
2753 * @ppos: file position
2754 *
2755 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2756 * values from/to the user buffer, treated as an ASCII string. Negative
2757 * strings are not allowed.
2758 *
2759 * This routine will ensure the values are within the range specified by
2760 * table->extra1 (min) and table->extra2 (max). There is a final sanity
2761 * check for UINT_MAX to avoid having to support wrap around uses from
2762 * userspace.
2763 *
Waiman Long24704f32018-04-10 16:35:38 -07002764 * Returns 0 on success or -ERANGE on write when the range check fails.
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07002765 */
2766int proc_douintvec_minmax(struct ctl_table *table, int write,
2767 void __user *buffer, size_t *lenp, loff_t *ppos)
2768{
2769 struct do_proc_douintvec_minmax_conv_param param = {
2770 .min = (unsigned int *) table->extra1,
2771 .max = (unsigned int *) table->extra2,
2772 };
2773 return do_proc_douintvec(table, write, buffer, lenp, ppos,
2774 do_proc_douintvec_minmax_conv, &param);
2775}
2776
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002777static int do_proc_dopipe_max_size_conv(unsigned long *lvalp,
2778 unsigned int *valp,
2779 int write, void *data)
2780{
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002781 if (write) {
Joe Lawrencefb910c42017-11-17 15:29:28 -08002782 unsigned int val;
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002783
Joe Lawrencefb910c42017-11-17 15:29:28 -08002784 val = round_pipe_size(*lvalp);
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002785 if (val == 0)
2786 return -EINVAL;
2787
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002788 *valp = val;
2789 } else {
2790 unsigned int val = *valp;
2791 *lvalp = (unsigned long) val;
2792 }
2793
2794 return 0;
2795}
2796
Eric Biggers319e0a22018-02-06 15:41:49 -08002797static int proc_dopipe_max_size(struct ctl_table *table, int write,
2798 void __user *buffer, size_t *lenp, loff_t *ppos)
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002799{
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002800 return do_proc_douintvec(table, write, buffer, lenp, ppos,
Eric Biggers4c2e4be2018-02-06 15:41:45 -08002801 do_proc_dopipe_max_size_conv, NULL);
Joe Lawrence7a8d1812017-11-17 15:29:24 -08002802}
2803
Kees Cook54b50192012-07-30 14:39:18 -07002804static void validate_coredump_safety(void)
2805{
Alex Kelly046d6622012-10-04 17:15:23 -07002806#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002807 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002808 core_pattern[0] != '/' && core_pattern[0] != '|') {
Alexey Dobriyan760c6a92016-12-14 15:04:14 -08002809 printk(KERN_WARNING
2810"Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2811"Pipe handler or fully qualified core dump path required.\n"
2812"Set kernel.core_pattern before fs.suid_dumpable.\n"
2813 );
Kees Cook54b50192012-07-30 14:39:18 -07002814 }
Alex Kelly046d6622012-10-04 17:15:23 -07002815#endif
Kees Cook54b50192012-07-30 14:39:18 -07002816}
2817
2818static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2819 void __user *buffer, size_t *lenp, loff_t *ppos)
2820{
2821 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2822 if (!error)
2823 validate_coredump_safety();
2824 return error;
2825}
2826
Alex Kelly046d6622012-10-04 17:15:23 -07002827#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002828static int proc_dostring_coredump(struct ctl_table *table, int write,
2829 void __user *buffer, size_t *lenp, loff_t *ppos)
2830{
2831 int error = proc_dostring(table, write, buffer, lenp, ppos);
2832 if (!error)
2833 validate_coredump_safety();
2834 return error;
2835}
Alex Kelly046d6622012-10-04 17:15:23 -07002836#endif
Kees Cook54b50192012-07-30 14:39:18 -07002837
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002838static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002839 void __user *buffer,
2840 size_t *lenp, loff_t *ppos,
2841 unsigned long convmul,
2842 unsigned long convdiv)
2843{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002844 unsigned long *i, *min, *max;
2845 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002846 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002847 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002848
2849 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002850 *lenp = 0;
2851 return 0;
2852 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002853
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002854 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002855 min = (unsigned long *) table->extra1;
2856 max = (unsigned long *) table->extra2;
2857 vleft = table->maxlen / sizeof(unsigned long);
2858 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002859
2860 if (write) {
Luis R. Rodriguezd383d482017-07-12 14:33:33 -07002861 if (proc_first_pos_non_zero_ignore(ppos, table))
2862 goto out;
Kees Cookf4aacea2014-06-06 14:37:19 -07002863
Amerigo Wang00b7c332010-05-05 00:26:45 +00002864 if (left > PAGE_SIZE - 1)
2865 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002866 p = kbuf = memdup_user_nul(buffer, left);
2867 if (IS_ERR(kbuf))
2868 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002869 }
2870
Eric Dumazet27b3d802010-10-07 12:59:29 -07002871 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002872 unsigned long val;
2873
Linus Torvalds1da177e2005-04-16 15:20:36 -07002874 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002875 bool neg;
2876
Al Viro70f6cbb2015-12-24 00:13:10 -05002877 left -= proc_skip_spaces(&p);
Cheng Lin09be1782019-01-03 15:26:13 -08002878 if (!left)
2879 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002880
Al Viro70f6cbb2015-12-24 00:13:10 -05002881 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002882 proc_wspace_sep,
2883 sizeof(proc_wspace_sep), NULL);
2884 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002885 break;
2886 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002887 continue;
Eric Dumazetff9f8a72017-01-25 18:20:55 -08002888 val = convmul * val / convdiv;
Christian Braunere260ad02019-05-14 15:44:55 -07002889 if ((min && val < *min) || (max && val > *max)) {
2890 err = -EINVAL;
2891 break;
2892 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002893 *i = val;
2894 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002895 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002896 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002897 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002898 if (err)
2899 break;
2900 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002901 err = proc_put_long(&buffer, &left, val, false);
2902 if (err)
2903 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002904 }
2905 }
2906
Amerigo Wang00b7c332010-05-05 00:26:45 +00002907 if (!write && !first && left && !err)
2908 err = proc_put_char(&buffer, &left, '\n');
2909 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002910 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002911 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002912 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002913 if (first)
2914 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002915 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002916 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002917out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002918 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002919 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002920}
2921
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002922static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002923 void __user *buffer,
2924 size_t *lenp, loff_t *ppos,
2925 unsigned long convmul,
2926 unsigned long convdiv)
2927{
2928 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002929 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002930}
2931
Linus Torvalds1da177e2005-04-16 15:20:36 -07002932/**
2933 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2934 * @table: the sysctl table
2935 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002936 * @buffer: the user buffer
2937 * @lenp: the size of the user buffer
2938 * @ppos: file position
2939 *
2940 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2941 * values from/to the user buffer, treated as an ASCII string.
2942 *
2943 * This routine will ensure the values are within the range specified by
2944 * table->extra1 (min) and table->extra2 (max).
2945 *
2946 * Returns 0 on success.
2947 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002948int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002949 void __user *buffer, size_t *lenp, loff_t *ppos)
2950{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002951 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002952}
2953
2954/**
2955 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2956 * @table: the sysctl table
2957 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002958 * @buffer: the user buffer
2959 * @lenp: the size of the user buffer
2960 * @ppos: file position
2961 *
2962 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2963 * values from/to the user buffer, treated as an ASCII string. The values
2964 * are treated as milliseconds, and converted to jiffies when they are stored.
2965 *
2966 * This routine will ensure the values are within the range specified by
2967 * table->extra1 (min) and table->extra2 (max).
2968 *
2969 * Returns 0 on success.
2970 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002971int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002972 void __user *buffer,
2973 size_t *lenp, loff_t *ppos)
2974{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002975 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002976 lenp, ppos, HZ, 1000l);
2977}
2978
2979
Amerigo Wang00b7c332010-05-05 00:26:45 +00002980static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002981 int *valp,
2982 int write, void *data)
2983{
2984 if (write) {
Gao Feng63259452017-05-08 15:54:58 -07002985 if (*lvalp > INT_MAX / HZ)
Bart Samwelcba9f332006-03-24 03:15:50 -08002986 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002987 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2988 } else {
2989 int val = *valp;
2990 unsigned long lval;
2991 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002992 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002993 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002994 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002995 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002996 lval = (unsigned long)val;
2997 }
2998 *lvalp = lval / HZ;
2999 }
3000 return 0;
3001}
3002
Amerigo Wang00b7c332010-05-05 00:26:45 +00003003static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003004 int *valp,
3005 int write, void *data)
3006{
3007 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08003008 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
3009 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003010 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
3011 } else {
3012 int val = *valp;
3013 unsigned long lval;
3014 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00003015 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07003016 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003017 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00003018 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003019 lval = (unsigned long)val;
3020 }
3021 *lvalp = jiffies_to_clock_t(lval);
3022 }
3023 return 0;
3024}
3025
Amerigo Wang00b7c332010-05-05 00:26:45 +00003026static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003027 int *valp,
3028 int write, void *data)
3029{
3030 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02003031 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
3032
3033 if (jif > INT_MAX)
3034 return 1;
3035 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003036 } else {
3037 int val = *valp;
3038 unsigned long lval;
3039 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00003040 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07003041 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003042 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00003043 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003044 lval = (unsigned long)val;
3045 }
3046 *lvalp = jiffies_to_msecs(lval);
3047 }
3048 return 0;
3049}
3050
3051/**
3052 * proc_dointvec_jiffies - read a vector of integers as seconds
3053 * @table: the sysctl table
3054 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07003055 * @buffer: the user buffer
3056 * @lenp: the size of the user buffer
3057 * @ppos: file position
3058 *
3059 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3060 * values from/to the user buffer, treated as an ASCII string.
3061 * The values read are assumed to be in seconds, and are converted into
3062 * jiffies.
3063 *
3064 * Returns 0 on success.
3065 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003066int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003067 void __user *buffer, size_t *lenp, loff_t *ppos)
3068{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003069 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003070 do_proc_dointvec_jiffies_conv,NULL);
3071}
3072
3073/**
3074 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
3075 * @table: the sysctl table
3076 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07003077 * @buffer: the user buffer
3078 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08003079 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07003080 *
3081 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3082 * values from/to the user buffer, treated as an ASCII string.
3083 * The values read are assumed to be in 1/USER_HZ seconds, and
3084 * are converted into jiffies.
3085 *
3086 * Returns 0 on success.
3087 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003088int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003089 void __user *buffer, size_t *lenp, loff_t *ppos)
3090{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003091 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003092 do_proc_dointvec_userhz_jiffies_conv,NULL);
3093}
3094
3095/**
3096 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
3097 * @table: the sysctl table
3098 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07003099 * @buffer: the user buffer
3100 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07003101 * @ppos: file position
3102 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07003103 *
3104 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
3105 * values from/to the user buffer, treated as an ASCII string.
3106 * The values read are assumed to be in 1/1000 seconds, and
3107 * are converted into jiffies.
3108 *
3109 * Returns 0 on success.
3110 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003111int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003112 void __user *buffer, size_t *lenp, loff_t *ppos)
3113{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003114 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003115 do_proc_dointvec_ms_jiffies_conv, NULL);
3116}
3117
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003118static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07003119 void __user *buffer, size_t *lenp, loff_t *ppos)
3120{
3121 struct pid *new_pid;
3122 pid_t tmp;
3123 int r;
3124
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08003125 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07003126
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003127 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07003128 lenp, ppos, NULL, NULL);
3129 if (r || !write)
3130 return r;
3131
3132 new_pid = find_get_pid(tmp);
3133 if (!new_pid)
3134 return -ESRCH;
3135
3136 put_pid(xchg(&cad_pid, new_pid));
3137 return 0;
3138}
3139
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003140/**
3141 * proc_do_large_bitmap - read/write from/to a large bitmap
3142 * @table: the sysctl table
3143 * @write: %TRUE if this is a write to the sysctl file
3144 * @buffer: the user buffer
3145 * @lenp: the size of the user buffer
3146 * @ppos: file position
3147 *
3148 * The bitmap is stored at table->data and the bitmap length (in bits)
3149 * in table->maxlen.
3150 *
3151 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
3152 * large bitmaps may be represented in a compact manner. Writing into
3153 * the file will clear the bitmap then update it with the given input.
3154 *
3155 * Returns 0 on success.
3156 */
3157int proc_do_large_bitmap(struct ctl_table *table, int write,
3158 void __user *buffer, size_t *lenp, loff_t *ppos)
3159{
3160 int err = 0;
3161 bool first = 1;
3162 size_t left = *lenp;
3163 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07003164 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003165 unsigned long *tmp_bitmap = NULL;
3166 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
3167
WANG Cong122ff242014-05-12 16:04:53 -07003168 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003169 *lenp = 0;
3170 return 0;
3171 }
3172
3173 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003174 char *kbuf, *p;
Eric Sandeen3116ad32019-05-14 15:45:13 -07003175 size_t skipped = 0;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003176
Eric Sandeen3116ad32019-05-14 15:45:13 -07003177 if (left > PAGE_SIZE - 1) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003178 left = PAGE_SIZE - 1;
Eric Sandeen3116ad32019-05-14 15:45:13 -07003179 /* How much of the buffer we'll skip this pass */
3180 skipped = *lenp - left;
3181 }
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003182
Al Viro70f6cbb2015-12-24 00:13:10 -05003183 p = kbuf = memdup_user_nul(buffer, left);
3184 if (IS_ERR(kbuf))
3185 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003186
Andy Shevchenko475dae32019-05-14 15:44:52 -07003187 tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003188 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003189 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003190 return -ENOMEM;
3191 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003192 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003193 while (!err && left) {
3194 unsigned long val_a, val_b;
3195 bool neg;
Eric Sandeen3116ad32019-05-14 15:45:13 -07003196 size_t saved_left;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003197
Eric Sandeen3116ad32019-05-14 15:45:13 -07003198 /* In case we stop parsing mid-number, we can reset */
3199 saved_left = left;
Al Viro70f6cbb2015-12-24 00:13:10 -05003200 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003201 sizeof(tr_a), &c);
Eric Sandeen3116ad32019-05-14 15:45:13 -07003202 /*
3203 * If we consumed the entirety of a truncated buffer or
3204 * only one char is left (may be a "-"), then stop here,
3205 * reset, & come back for more.
3206 */
3207 if ((left <= 1) && skipped) {
3208 left = saved_left;
3209 break;
3210 }
3211
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003212 if (err)
3213 break;
3214 if (val_a >= bitmap_len || neg) {
3215 err = -EINVAL;
3216 break;
3217 }
3218
3219 val_b = val_a;
3220 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003221 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003222 left--;
3223 }
3224
3225 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05003226 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003227 &neg, tr_b, sizeof(tr_b),
3228 &c);
Eric Sandeen3116ad32019-05-14 15:45:13 -07003229 /*
3230 * If we consumed all of a truncated buffer or
3231 * then stop here, reset, & come back for more.
3232 */
3233 if (!left && skipped) {
3234 left = saved_left;
3235 break;
3236 }
3237
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003238 if (err)
3239 break;
3240 if (val_b >= bitmap_len || neg ||
3241 val_a > val_b) {
3242 err = -EINVAL;
3243 break;
3244 }
3245 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05003246 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003247 left--;
3248 }
3249 }
3250
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003251 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003252 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05003253 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003254 }
Al Viro70f6cbb2015-12-24 00:13:10 -05003255 kfree(kbuf);
Eric Sandeen3116ad32019-05-14 15:45:13 -07003256 left += skipped;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003257 } else {
3258 unsigned long bit_a, bit_b = 0;
3259
3260 while (left) {
3261 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
3262 if (bit_a >= bitmap_len)
3263 break;
3264 bit_b = find_next_zero_bit(bitmap, bitmap_len,
3265 bit_a + 1) - 1;
3266
3267 if (!first) {
3268 err = proc_put_char(&buffer, &left, ',');
3269 if (err)
3270 break;
3271 }
3272 err = proc_put_long(&buffer, &left, bit_a, false);
3273 if (err)
3274 break;
3275 if (bit_a != bit_b) {
3276 err = proc_put_char(&buffer, &left, '-');
3277 if (err)
3278 break;
3279 err = proc_put_long(&buffer, &left, bit_b, false);
3280 if (err)
3281 break;
3282 }
3283
3284 first = 0; bit_b++;
3285 }
3286 if (!err)
3287 err = proc_put_char(&buffer, &left, '\n');
3288 }
3289
3290 if (!err) {
3291 if (write) {
3292 if (*ppos)
3293 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
3294 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07003295 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003296 }
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003297 *lenp -= left;
3298 *ppos += *lenp;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003299 }
Ola N. Kaldestadf9eb2fd2017-11-17 15:30:26 -08003300
Andy Shevchenko475dae32019-05-14 15:44:52 -07003301 bitmap_free(tmp_bitmap);
Ola N. Kaldestadf9eb2fd2017-11-17 15:30:26 -08003302 return err;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00003303}
3304
Jovi Zhang55610502011-01-12 17:00:45 -08003305#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003306
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003307int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003308 void __user *buffer, size_t *lenp, loff_t *ppos)
3309{
3310 return -ENOSYS;
3311}
3312
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003313int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003314 void __user *buffer, size_t *lenp, loff_t *ppos)
3315{
3316 return -ENOSYS;
3317}
3318
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003319int proc_douintvec(struct ctl_table *table, int write,
3320 void __user *buffer, size_t *lenp, loff_t *ppos)
3321{
3322 return -ENOSYS;
3323}
3324
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003325int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003326 void __user *buffer, size_t *lenp, loff_t *ppos)
3327{
3328 return -ENOSYS;
3329}
3330
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07003331int proc_douintvec_minmax(struct ctl_table *table, int write,
3332 void __user *buffer, size_t *lenp, loff_t *ppos)
3333{
3334 return -ENOSYS;
3335}
3336
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003337int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003338 void __user *buffer, size_t *lenp, loff_t *ppos)
3339{
3340 return -ENOSYS;
3341}
3342
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003343int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003344 void __user *buffer, size_t *lenp, loff_t *ppos)
3345{
3346 return -ENOSYS;
3347}
3348
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003349int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003350 void __user *buffer, size_t *lenp, loff_t *ppos)
3351{
3352 return -ENOSYS;
3353}
3354
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003355int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003356 void __user *buffer, size_t *lenp, loff_t *ppos)
3357{
3358 return -ENOSYS;
3359}
3360
Eric W. Biedermand8217f02007-10-18 03:05:22 -07003361int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003362 void __user *buffer,
3363 size_t *lenp, loff_t *ppos)
3364{
3365 return -ENOSYS;
3366}
3367
Stephen Suryaputra0bc19982019-04-17 16:35:49 -04003368int proc_do_large_bitmap(struct ctl_table *table, int write,
3369 void __user *buffer, size_t *lenp, loff_t *ppos)
3370{
3371 return -ENOSYS;
3372}
Linus Torvalds1da177e2005-04-16 15:20:36 -07003373
Jovi Zhang55610502011-01-12 17:00:45 -08003374#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003375
Arnd Bergmann78c3aff2019-03-04 21:34:12 +01003376#if defined(CONFIG_BPF_SYSCALL) && defined(CONFIG_SYSCTL)
Alexei Starovoitov492ecee2019-02-25 14:28:39 -08003377static int proc_dointvec_minmax_bpf_stats(struct ctl_table *table, int write,
3378 void __user *buffer, size_t *lenp,
3379 loff_t *ppos)
3380{
3381 int ret, bpf_stats = *(int *)table->data;
3382 struct ctl_table tmp = *table;
3383
3384 if (write && !capable(CAP_SYS_ADMIN))
3385 return -EPERM;
3386
3387 tmp.data = &bpf_stats;
3388 ret = proc_dointvec_minmax(&tmp, write, buffer, lenp, ppos);
3389 if (write && !ret) {
3390 *(int *)table->data = bpf_stats;
3391 if (bpf_stats)
3392 static_branch_enable(&bpf_stats_enabled_key);
3393 else
3394 static_branch_disable(&bpf_stats_enabled_key);
3395 }
3396 return ret;
3397}
Alexei Starovoitov3fcc55302019-02-27 18:30:44 -08003398#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07003399/*
3400 * No sense putting this after each symbol definition, twice,
3401 * exception granted :-)
3402 */
3403EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003404EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003405EXPORT_SYMBOL(proc_dointvec_jiffies);
3406EXPORT_SYMBOL(proc_dointvec_minmax);
Luis R. Rodriguez61d9b562017-07-12 14:33:40 -07003407EXPORT_SYMBOL_GPL(proc_douintvec_minmax);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003408EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3409EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3410EXPORT_SYMBOL(proc_dostring);
3411EXPORT_SYMBOL(proc_doulongvec_minmax);
3412EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
Stephen Suryaputra0bc19982019-04-17 16:35:49 -04003413EXPORT_SYMBOL(proc_do_large_bitmap);