blob: 0befbb606a853479127ab73e6698970412a58ef4 [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>
Vegard Nossumdfec0722008-04-04 00:51:41 +020033#include <linux/kmemcheck.h>
Steven Rostedtfd4b6162012-07-30 14:42:48 -070034#include <linux/kmemleak.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070035#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/init.h>
37#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010038#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030039#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <linux/sysrq.h>
41#include <linux/highuid.h>
42#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020043#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070044#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070047#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#include <linux/times.h>
49#include <linux/limits.h>
50#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020051#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070053#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080054#include <linux/nfs_fs.h>
55#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070056#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020057#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020058#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050059#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020060#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070061#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040062#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070063#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000064#include <linux/binfmts.h>
Clark Williamscf4aebc22013-02-07 09:46:59 -060065#include <linux/sched/sysctl.h>
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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70#include <asm/uaccess.h>
71#include <asm/processor.h>
72
Andi Kleen29cbc782006-09-30 01:47:55 +020073#ifdef CONFIG_X86
74#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010075#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010076#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020077#endif
David Howellsd550bbd2012-03-28 18:30:03 +010078#ifdef CONFIG_SPARC
79#include <asm/setup.h>
80#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080081#ifdef CONFIG_BSD_PROCESS_ACCT
82#include <linux/acct.h>
83#endif
Dave Young4f0e0562010-03-10 15:24:09 -080084#ifdef CONFIG_RT_MUTEXES
85#include <linux/rtmutex.h>
86#endif
Dave Young2edf5e42010-03-10 15:24:10 -080087#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
88#include <linux/lockdep.h>
89#endif
Dave Young15485a42010-03-10 15:24:07 -080090#ifdef CONFIG_CHR_DEV_SG
91#include <scsi/sg.h>
92#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020093
Don Zickus58687ac2010-05-07 17:11:44 -040094#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050095#include <linux/nmi.h>
96#endif
97
Linus Torvalds1da177e2005-04-16 15:20:36 -070098#if defined(CONFIG_SYSCTL)
99
100/* External variables not in a header file. */
Alan Coxd6e71142005-06-23 00:09:43 -0700101extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700102#ifdef CONFIG_COREDUMP
103extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700105extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700106#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern int pid_max;
Rik van Rieldbe0f612011-09-01 15:26:50 -0400108extern int extra_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800110extern int percpu_pagelist_fraction;
Arjan van de Ven97455122008-01-25 21:08:34 +0100111extern int latencytop_enabled;
Alexey Dobriyan9b80a182016-09-02 00:38:52 +0300112extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000113#ifndef CONFIG_MMU
114extern int sysctl_nr_trim_pages;
115#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700117/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400118#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700119static int sixty = 60;
120#endif
121
Aaron Tomlin270750db2014-01-20 17:34:13 +0000122static int __maybe_unused neg_one = -1;
123
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700124static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700125static int __maybe_unused one = 1;
126static int __maybe_unused two = 2;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700127static int __maybe_unused four = 4;
Will Deacon3141fcc2019-04-05 18:39:38 -0700128static unsigned long zero_ul;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800129static unsigned long one_ul = 1;
Christian Brauner6b65c262019-03-07 16:29:43 -0800130static unsigned long long_max = LONG_MAX;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700131static int one_hundred = 100;
Johannes Weiner795ae7a2016-03-17 14:19:14 -0700132static int one_thousand = 1000;
Dave Youngaf913222009-09-22 16:43:33 -0700133#ifdef CONFIG_PRINTK
134static int ten_thousand = 10000;
135#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300136#ifdef CONFIG_PERF_EVENTS
137static int six_hundred_forty_kb = 640 * 1024;
138#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700139
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700140/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
141static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
142
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
144static int maxolduid = 65535;
145static int minolduid;
146
147static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700148static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700149
Liu Hua80df2842014-04-07 15:38:57 -0700150/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
151#ifdef CONFIG_DETECT_HUNG_TASK
152static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
153#endif
154
Dave Youngd14f1722010-02-25 20:28:57 -0500155#ifdef CONFIG_INOTIFY_USER
156#include <linux/inotify.h>
157#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700158#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159#endif
160
161#ifdef __hppa__
162extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530163#endif
164
165#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166extern int unaligned_enabled;
167#endif
168
Jes Sorensend2b176e2006-02-28 09:42:23 -0800169#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800170extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800171#endif
172
Vineet Guptab6fca722013-01-09 20:06:28 +0530173#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
174extern int no_unaligned_warning;
175#endif
176
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700177#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700178
179#define SYSCTL_WRITES_LEGACY -1
180#define SYSCTL_WRITES_WARN 0
181#define SYSCTL_WRITES_STRICT 1
182
Kees Cook41662f52016-01-20 15:00:45 -0800183static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700184
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700185static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700186 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700187static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800188 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700189#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700190
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700191#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700192static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700193 void __user *buffer, size_t *lenp, loff_t *ppos);
194#endif
195
Kees Cook54b50192012-07-30 14:39:18 -0700196static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
197 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700198#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700199static int proc_dostring_coredump(struct ctl_table *table, int write,
200 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700201#endif
Kees Cook54b50192012-07-30 14:39:18 -0700202
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700203#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800204/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100205static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700206
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700207static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700208 void __user *buffer, size_t *lenp,
209 loff_t *ppos)
210{
211 int error;
212
213 error = proc_dointvec(table, write, buffer, lenp, ppos);
214 if (error)
215 return error;
216
217 if (write)
218 sysrq_toggle_support(__sysrq_enabled);
219
220 return 0;
221}
222
223#endif
224
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700225static struct ctl_table kern_table[];
226static struct ctl_table vm_table[];
227static struct ctl_table fs_table[];
228static struct ctl_table debug_table[];
229static struct ctl_table dev_table[];
230extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800231#ifdef CONFIG_EPOLL
232extern struct ctl_table epoll_table[];
233#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234
235#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
236int sysctl_legacy_va_layout;
237#endif
238
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239/* The default sysctl tables: */
240
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800241static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 .procname = "kernel",
244 .mode = 0555,
245 .child = kern_table,
246 },
247 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 .procname = "vm",
249 .mode = 0555,
250 .child = vm_table,
251 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 .procname = "fs",
254 .mode = 0555,
255 .child = fs_table,
256 },
257 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 .procname = "debug",
259 .mode = 0555,
260 .child = debug_table,
261 },
262 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 .procname = "dev",
264 .mode = 0555,
265 .child = dev_table,
266 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700267 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268};
269
Ingo Molnar77e54a12007-07-09 18:52:00 +0200270#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100271static int min_sched_granularity_ns = 100000; /* 100 usecs */
272static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
273static int min_wakeup_granularity_ns; /* 0 usecs */
274static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200275#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100276static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
277static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200278#endif /* CONFIG_SMP */
279#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200280
Mel Gorman5e771902010-05-24 14:32:31 -0700281#ifdef CONFIG_COMPACTION
282static int min_extfrag_threshold;
283static int max_extfrag_threshold = 1000;
284#endif
285
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700286static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200287 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200288 .procname = "sched_child_runs_first",
289 .data = &sysctl_sched_child_runs_first,
290 .maxlen = sizeof(unsigned int),
291 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800292 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200293 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200294#ifdef CONFIG_SCHED_DEBUG
295 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100296 .procname = "sched_min_granularity_ns",
297 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200298 .maxlen = sizeof(unsigned int),
299 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800300 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100301 .extra1 = &min_sched_granularity_ns,
302 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200303 },
304 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200305 .procname = "sched_latency_ns",
306 .data = &sysctl_sched_latency,
307 .maxlen = sizeof(unsigned int),
308 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800309 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200310 .extra1 = &min_sched_granularity_ns,
311 .extra2 = &max_sched_granularity_ns,
312 },
313 {
Dietmar Eggemannea5a7f22017-01-13 13:51:24 +0000314 .procname = "sched_sync_hint_enable",
315 .data = &sysctl_sched_sync_hint_enable,
Juri Lelli1931b932016-07-29 14:04:11 +0100316 .maxlen = sizeof(unsigned int),
317 .mode = 0644,
318 .proc_handler = proc_dointvec,
319 },
Srivatsa Vaddagiri26c21542016-05-31 09:08:38 -0700320#ifdef CONFIG_SCHED_WALT
321 {
322 .procname = "sched_use_walt_cpu_util",
323 .data = &sysctl_sched_use_walt_cpu_util,
324 .maxlen = sizeof(unsigned int),
325 .mode = 0644,
326 .proc_handler = proc_dointvec,
327 },
328 {
329 .procname = "sched_use_walt_task_util",
330 .data = &sysctl_sched_use_walt_task_util,
331 .maxlen = sizeof(unsigned int),
332 .mode = 0644,
333 .proc_handler = proc_dointvec,
334 },
335 {
336 .procname = "sched_walt_init_task_load_pct",
337 .data = &sysctl_sched_walt_init_task_load_pct,
338 .maxlen = sizeof(unsigned int),
339 .mode = 0644,
340 .proc_handler = proc_dointvec,
341 },
Srinath Sridharan3a73c962016-07-22 13:21:15 +0100342 {
343 .procname = "sched_walt_cpu_high_irqload",
344 .data = &sysctl_sched_walt_cpu_high_irqload,
345 .maxlen = sizeof(unsigned int),
346 .mode = 0644,
347 .proc_handler = proc_dointvec,
348 },
Srivatsa Vaddagiri26c21542016-05-31 09:08:38 -0700349#endif
Juri Lelli1931b932016-07-29 14:04:11 +0100350 {
Srinath Sridharanbf47bdd2016-07-14 09:57:29 +0100351 .procname = "sched_cstate_aware",
352 .data = &sysctl_sched_cstate_aware,
353 .maxlen = sizeof(unsigned int),
354 .mode = 0644,
355 .proc_handler = proc_dointvec,
356 },
357 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200358 .procname = "sched_wakeup_granularity_ns",
359 .data = &sysctl_sched_wakeup_granularity,
360 .maxlen = sizeof(unsigned int),
361 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800362 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200363 .extra1 = &min_wakeup_granularity_ns,
364 .extra2 = &max_wakeup_granularity_ns,
365 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200366#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200367 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100368 .procname = "sched_tunable_scaling",
369 .data = &sysctl_sched_tunable_scaling,
370 .maxlen = sizeof(enum sched_tunable_scaling),
371 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800372 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100373 .extra1 = &min_sched_tunable_scaling,
374 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200375 },
376 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900377 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200378 .data = &sysctl_sched_migration_cost,
379 .maxlen = sizeof(unsigned int),
380 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800381 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200382 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100383 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100384 .procname = "sched_nr_migrate",
385 .data = &sysctl_sched_nr_migrate,
386 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100387 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800388 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100389 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530390 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900391 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200392 .data = &sysctl_sched_time_avg,
393 .maxlen = sizeof(unsigned int),
394 .mode = 0644,
Ethan Zhaofe0034a2017-09-04 13:59:34 +0800395 .proc_handler = proc_dointvec_minmax,
396 .extra1 = &one,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200397 },
398 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900399 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800400 .data = &sysctl_sched_shares_window,
401 .maxlen = sizeof(unsigned int),
402 .mode = 0644,
403 .proc_handler = proc_dointvec,
404 },
Mel Gormancb251762016-02-05 09:08:36 +0000405#ifdef CONFIG_SCHEDSTATS
406 {
407 .procname = "sched_schedstats",
408 .data = NULL,
409 .maxlen = sizeof(unsigned int),
410 .mode = 0644,
411 .proc_handler = sysctl_schedstats,
412 .extra1 = &zero,
413 .extra2 = &one,
414 },
415#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200416#endif /* CONFIG_SMP */
417#ifdef CONFIG_NUMA_BALANCING
418 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200419 .procname = "numa_balancing_scan_delay_ms",
420 .data = &sysctl_numa_balancing_scan_delay,
421 .maxlen = sizeof(unsigned int),
422 .mode = 0644,
423 .proc_handler = proc_dointvec,
424 },
425 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200426 .procname = "numa_balancing_scan_period_min_ms",
427 .data = &sysctl_numa_balancing_scan_period_min,
428 .maxlen = sizeof(unsigned int),
429 .mode = 0644,
430 .proc_handler = proc_dointvec,
431 },
432 {
433 .procname = "numa_balancing_scan_period_max_ms",
434 .data = &sysctl_numa_balancing_scan_period_max,
435 .maxlen = sizeof(unsigned int),
436 .mode = 0644,
437 .proc_handler = proc_dointvec,
438 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200439 {
440 .procname = "numa_balancing_scan_size_mb",
441 .data = &sysctl_numa_balancing_scan_size,
442 .maxlen = sizeof(unsigned int),
443 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400444 .proc_handler = proc_dointvec_minmax,
445 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200446 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100447 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800448 .procname = "numa_balancing",
449 .data = NULL, /* filled in by handler */
450 .maxlen = sizeof(unsigned int),
451 .mode = 0644,
452 .proc_handler = sysctl_numa_balancing,
453 .extra1 = &zero,
454 .extra2 = &one,
455 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200456#endif /* CONFIG_NUMA_BALANCING */
457#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200458 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100459 .procname = "sched_rt_period_us",
460 .data = &sysctl_sched_rt_period,
461 .maxlen = sizeof(unsigned int),
462 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800463 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100464 },
465 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100466 .procname = "sched_rt_runtime_us",
467 .data = &sysctl_sched_rt_runtime,
468 .maxlen = sizeof(int),
469 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800470 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100471 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600472 {
473 .procname = "sched_rr_timeslice_ms",
474 .data = &sched_rr_timeslice,
475 .maxlen = sizeof(int),
476 .mode = 0644,
477 .proc_handler = sched_rr_handler,
478 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100479#ifdef CONFIG_SCHED_AUTOGROUP
480 {
481 .procname = "sched_autogroup_enabled",
482 .data = &sysctl_sched_autogroup_enabled,
483 .maxlen = sizeof(unsigned int),
484 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800485 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100486 .extra1 = &zero,
487 .extra2 = &one,
488 },
489#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700490#ifdef CONFIG_CFS_BANDWIDTH
491 {
492 .procname = "sched_cfs_bandwidth_slice_us",
493 .data = &sysctl_sched_cfs_bandwidth_slice,
494 .maxlen = sizeof(unsigned int),
495 .mode = 0644,
496 .proc_handler = proc_dointvec_minmax,
497 .extra1 = &one,
498 },
499#endif
Patrick Bellasi69fa4c72015-06-22 18:11:44 +0100500#ifdef CONFIG_SCHED_TUNE
501 {
502 .procname = "sched_cfs_boost",
503 .data = &sysctl_sched_cfs_boost,
504 .maxlen = sizeof(sysctl_sched_cfs_boost),
Patrick Bellasiae710302015-06-23 09:17:54 +0100505#ifdef CONFIG_CGROUP_SCHEDTUNE
506 .mode = 0444,
507#else
Patrick Bellasi69fa4c72015-06-22 18:11:44 +0100508 .mode = 0644,
Patrick Bellasiae710302015-06-23 09:17:54 +0100509#endif
Patrick Bellasi69fa4c72015-06-22 18:11:44 +0100510 .proc_handler = &sysctl_sched_cfs_boost_handler,
511 .extra1 = &zero,
512 .extra2 = &one_hundred,
513 },
514#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700515#ifdef CONFIG_PROVE_LOCKING
516 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700517 .procname = "prove_locking",
518 .data = &prove_locking,
519 .maxlen = sizeof(int),
520 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800521 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700522 },
523#endif
524#ifdef CONFIG_LOCK_STAT
525 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700526 .procname = "lock_stat",
527 .data = &lock_stat,
528 .maxlen = sizeof(int),
529 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800530 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700531 },
532#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200533 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 .procname = "panic",
535 .data = &panic_timeout,
536 .maxlen = sizeof(int),
537 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800538 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 },
Alex Kelly046d6622012-10-04 17:15:23 -0700540#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 .procname = "core_uses_pid",
543 .data = &core_uses_pid,
544 .maxlen = sizeof(int),
545 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800546 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 },
548 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 .procname = "core_pattern",
550 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700551 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700553 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 },
Neil Hormana2939802009-09-23 15:56:56 -0700555 {
Neil Hormana2939802009-09-23 15:56:56 -0700556 .procname = "core_pipe_limit",
557 .data = &core_pipe_limit,
558 .maxlen = sizeof(unsigned int),
559 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800560 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700561 },
Alex Kelly046d6622012-10-04 17:15:23 -0700562#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800563#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700566 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800567 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800568 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700570 {
571 .procname = "sysctl_writes_strict",
572 .data = &sysctl_writes_strict,
573 .maxlen = sizeof(int),
574 .mode = 0644,
575 .proc_handler = proc_dointvec_minmax,
576 .extra1 = &neg_one,
577 .extra2 = &one,
578 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800579#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100580#ifdef CONFIG_LATENCYTOP
581 {
582 .procname = "latencytop",
583 .data = &latencytop_enabled,
584 .maxlen = sizeof(int),
585 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000586 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100587 },
588#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589#ifdef CONFIG_BLK_DEV_INITRD
590 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 .procname = "real-root-dev",
592 .data = &real_root_dev,
593 .maxlen = sizeof(int),
594 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800595 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 },
597#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700598 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700599 .procname = "print-fatal-signals",
600 .data = &print_fatal_signals,
601 .maxlen = sizeof(int),
602 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800603 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700604 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700605#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 .procname = "reboot-cmd",
608 .data = reboot_command,
609 .maxlen = 256,
610 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800611 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 },
613 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700614 .procname = "stop-a",
615 .data = &stop_a_enabled,
616 .maxlen = sizeof (int),
617 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800618 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 },
620 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 .procname = "scons-poweroff",
622 .data = &scons_pwroff,
623 .maxlen = sizeof (int),
624 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800625 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 },
627#endif
David S. Miller08714202008-11-16 23:49:24 -0800628#ifdef CONFIG_SPARC64
629 {
David S. Miller08714202008-11-16 23:49:24 -0800630 .procname = "tsb-ratio",
631 .data = &sysctl_tsb_ratio,
632 .maxlen = sizeof (int),
633 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800634 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800635 },
636#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637#ifdef __hppa__
638 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 .procname = "soft-power",
640 .data = &pwrsw_enabled,
641 .maxlen = sizeof (int),
642 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800643 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530645#endif
646#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 .procname = "unaligned-trap",
649 .data = &unaligned_enabled,
650 .maxlen = sizeof (int),
651 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800652 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 },
654#endif
655 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 .procname = "ctrl-alt-del",
657 .data = &C_A_D,
658 .maxlen = sizeof(int),
659 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800660 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400662#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200663 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200664 .procname = "ftrace_enabled",
665 .data = &ftrace_enabled,
666 .maxlen = sizeof(int),
667 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800668 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200669 },
670#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500671#ifdef CONFIG_STACK_TRACER
672 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500673 .procname = "stack_tracer_enabled",
674 .data = &stack_tracer_enabled,
675 .maxlen = sizeof(int),
676 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800677 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500678 },
679#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400680#ifdef CONFIG_TRACING
681 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100682 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400683 .data = &ftrace_dump_on_oops,
684 .maxlen = sizeof(int),
685 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800686 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400687 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400688 {
689 .procname = "traceoff_on_warning",
690 .data = &__disable_trace_on_warning,
691 .maxlen = sizeof(__disable_trace_on_warning),
692 .mode = 0644,
693 .proc_handler = proc_dointvec,
694 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500695 {
696 .procname = "tracepoint_printk",
697 .data = &tracepoint_printk,
698 .maxlen = sizeof(tracepoint_printk),
699 .mode = 0644,
700 .proc_handler = proc_dointvec,
701 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400702#endif
Dave Young2965faa2015-09-09 15:38:55 -0700703#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800704 {
705 .procname = "kexec_load_disabled",
706 .data = &kexec_load_disabled,
707 .maxlen = sizeof(int),
708 .mode = 0644,
709 /* only handle a transition from default "0" to "1" */
710 .proc_handler = proc_dointvec_minmax,
711 .extra1 = &one,
712 .extra2 = &one,
713 },
714#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200715#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 .procname = "modprobe",
718 .data = &modprobe_path,
719 .maxlen = KMOD_PATH_LEN,
720 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800721 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 },
Kees Cook3d433212009-04-02 15:49:29 -0700723 {
Kees Cook3d433212009-04-02 15:49:29 -0700724 .procname = "modules_disabled",
725 .data = &modules_disabled,
726 .maxlen = sizeof(int),
727 .mode = 0644,
728 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800729 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700730 .extra1 = &one,
731 .extra2 = &one,
732 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700734#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100737 .data = &uevent_helper,
738 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800740 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 },
Michael Marineau86d56132014-04-10 14:09:31 -0700742#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743#ifdef CONFIG_CHR_DEV_SG
744 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 .procname = "sg-big-buff",
746 .data = &sg_big_buff,
747 .maxlen = sizeof (int),
748 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800749 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 },
751#endif
752#ifdef CONFIG_BSD_PROCESS_ACCT
753 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 .procname = "acct",
755 .data = &acct_parm,
756 .maxlen = 3*sizeof(int),
757 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800758 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 },
760#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761#ifdef CONFIG_MAGIC_SYSRQ
762 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800764 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 .maxlen = sizeof (int),
766 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700767 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 },
769#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700770#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700773 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 .maxlen = sizeof (int),
775 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800776 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700778#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700781 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 .maxlen = sizeof(int),
783 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700784 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 },
786 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 .procname = "random",
788 .mode = 0555,
789 .child = random_table,
790 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 {
Eric Paris17f60a72011-04-01 17:07:50 -0400792 .procname = "usermodehelper",
793 .mode = 0555,
794 .child = usermodehelper_table,
795 },
796 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 .procname = "overflowuid",
798 .data = &overflowuid,
799 .maxlen = sizeof(int),
800 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800801 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 .extra1 = &minolduid,
803 .extra2 = &maxolduid,
804 },
805 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 .procname = "overflowgid",
807 .data = &overflowgid,
808 .maxlen = sizeof(int),
809 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800810 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 .extra1 = &minolduid,
812 .extra2 = &maxolduid,
813 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800814#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815#ifdef CONFIG_MATHEMU
816 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 .procname = "ieee_emulation_warnings",
818 .data = &sysctl_ieee_emulation_warnings,
819 .maxlen = sizeof(int),
820 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800821 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 },
823#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200826 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 .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 },
831#endif
832 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833 .procname = "pid_max",
834 .data = &pid_max,
835 .maxlen = sizeof (int),
836 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800837 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 .extra1 = &pid_max_min,
839 .extra2 = &pid_max_max,
840 },
841 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 .procname = "panic_on_oops",
843 .data = &panic_on_oops,
844 .maxlen = sizeof(int),
845 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800846 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800848#if defined CONFIG_PRINTK
849 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800850 .procname = "printk",
851 .data = &console_loglevel,
852 .maxlen = 4*sizeof(int),
853 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800854 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800855 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700858 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859 .maxlen = sizeof(int),
860 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800861 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 },
863 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700865 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 .maxlen = sizeof(int),
867 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800868 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869 },
Dave Youngaf913222009-09-22 16:43:33 -0700870 {
Dave Youngaf913222009-09-22 16:43:33 -0700871 .procname = "printk_delay",
872 .data = &printk_delay_msec,
873 .maxlen = sizeof(int),
874 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800875 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700876 .extra1 = &zero,
877 .extra2 = &ten_thousand,
878 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700880 .procname = "printk_devkmsg",
881 .data = devkmsg_log_str,
882 .maxlen = DEVKMSG_STR_MAX_SIZE,
883 .mode = 0644,
884 .proc_handler = devkmsg_sysctl_set_loglvl,
885 },
886 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800887 .procname = "dmesg_restrict",
888 .data = &dmesg_restrict,
889 .maxlen = sizeof(int),
890 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700891 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800892 .extra1 = &zero,
893 .extra2 = &one,
894 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800895 {
896 .procname = "kptr_restrict",
897 .data = &kptr_restrict,
898 .maxlen = sizeof(int),
899 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700900 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800901 .extra1 = &zero,
902 .extra2 = &two,
903 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800904#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800905 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 .procname = "ngroups_max",
907 .data = &ngroups_max,
908 .maxlen = sizeof (int),
909 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800910 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911 },
Dan Ballard73efc032011-10-31 17:11:20 -0700912 {
913 .procname = "cap_last_cap",
914 .data = (void *)&cap_last_cap,
915 .maxlen = sizeof(int),
916 .mode = 0444,
917 .proc_handler = proc_dointvec,
918 },
Don Zickus58687ac2010-05-07 17:11:44 -0400919#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500920 {
Don Zickus58687ac2010-05-07 17:11:44 -0400921 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200922 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500923 .maxlen = sizeof (int),
924 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700925 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700926 .extra1 = &zero,
927 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400928 },
929 {
930 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700931 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400932 .maxlen = sizeof(int),
933 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700934 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800935 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400936 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500937 },
Don Zickus2508ce12010-05-07 17:11:46 -0400938 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700939 .procname = "nmi_watchdog",
940 .data = &nmi_watchdog_enabled,
941 .maxlen = sizeof (int),
942 .mode = 0644,
943 .proc_handler = proc_nmi_watchdog,
944 .extra1 = &zero,
945#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
946 .extra2 = &one,
947#else
948 .extra2 = &zero,
949#endif
950 },
951 {
952 .procname = "soft_watchdog",
953 .data = &soft_watchdog_enabled,
954 .maxlen = sizeof (int),
955 .mode = 0644,
956 .proc_handler = proc_soft_watchdog,
957 .extra1 = &zero,
958 .extra2 = &one,
959 },
960 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700961 .procname = "watchdog_cpumask",
962 .data = &watchdog_cpumask_bits,
963 .maxlen = NR_CPUS,
964 .mode = 0644,
965 .proc_handler = proc_watchdog_cpumask,
966 },
967 {
Don Zickus2508ce12010-05-07 17:11:46 -0400968 .procname = "softlockup_panic",
969 .data = &softlockup_panic,
970 .maxlen = sizeof(int),
971 .mode = 0644,
972 .proc_handler = proc_dointvec_minmax,
973 .extra1 = &zero,
974 .extra2 = &one,
975 },
Don Zickusac1f5912015-11-05 18:44:44 -0800976#ifdef CONFIG_HARDLOCKUP_DETECTOR
977 {
978 .procname = "hardlockup_panic",
979 .data = &hardlockup_panic,
980 .maxlen = sizeof(int),
981 .mode = 0644,
982 .proc_handler = proc_dointvec_minmax,
983 .extra1 = &zero,
984 .extra2 = &one,
985 },
986#endif
Aaron Tomlined235872014-06-23 13:22:05 -0700987#ifdef CONFIG_SMP
988 {
989 .procname = "softlockup_all_cpu_backtrace",
990 .data = &sysctl_softlockup_all_cpu_backtrace,
991 .maxlen = sizeof(int),
992 .mode = 0644,
993 .proc_handler = proc_dointvec_minmax,
994 .extra1 = &zero,
995 .extra2 = &one,
996 },
Jiri Kosina55537872015-11-05 18:44:41 -0800997 {
998 .procname = "hardlockup_all_cpu_backtrace",
999 .data = &sysctl_hardlockup_all_cpu_backtrace,
1000 .maxlen = sizeof(int),
1001 .mode = 0644,
1002 .proc_handler = proc_dointvec_minmax,
1003 .extra1 = &zero,
1004 .extra2 = &one,
1005 },
Aaron Tomlined235872014-06-23 13:22:05 -07001006#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -05001007#endif
1008#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
1009 {
1010 .procname = "unknown_nmi_panic",
1011 .data = &unknown_nmi_panic,
1012 .maxlen = sizeof (int),
1013 .mode = 0644,
1014 .proc_handler = proc_dointvec,
1015 },
Don Zickus504d7cf2010-02-12 17:19:19 -05001016#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001017#if defined(CONFIG_X86)
1018 {
Don Zickus8da5add2006-09-26 10:52:27 +02001019 .procname = "panic_on_unrecovered_nmi",
1020 .data = &panic_on_unrecovered_nmi,
1021 .maxlen = sizeof(int),
1022 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001023 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +02001024 },
1025 {
Kurt Garloff5211a242009-06-24 14:32:11 -07001026 .procname = "panic_on_io_nmi",
1027 .data = &panic_on_io_nmi,
1028 .maxlen = sizeof(int),
1029 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001030 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -07001031 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +09001032#ifdef CONFIG_DEBUG_STACKOVERFLOW
1033 {
1034 .procname = "panic_on_stackoverflow",
1035 .data = &sysctl_panic_on_stackoverflow,
1036 .maxlen = sizeof(int),
1037 .mode = 0644,
1038 .proc_handler = proc_dointvec,
1039 },
1040#endif
Kurt Garloff5211a242009-06-24 14:32:11 -07001041 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001042 .procname = "bootloader_type",
1043 .data = &bootloader_type,
1044 .maxlen = sizeof (int),
1045 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001046 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001048 {
H. Peter Anvin50312962009-05-07 16:54:11 -07001049 .procname = "bootloader_version",
1050 .data = &bootloader_version,
1051 .maxlen = sizeof (int),
1052 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001053 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -07001054 },
1055 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001056 .procname = "kstack_depth_to_print",
1057 .data = &kstack_depth_to_print,
1058 .maxlen = sizeof(int),
1059 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001060 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001061 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001062 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001063 .procname = "io_delay_type",
1064 .data = &io_delay_type,
1065 .maxlen = sizeof(int),
1066 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001067 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001068 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001069#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001070#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001071 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001072 .procname = "randomize_va_space",
1073 .data = &randomize_va_space,
1074 .maxlen = sizeof(int),
1075 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001076 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001077 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001078#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001079#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001080 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001081 .procname = "spin_retry",
1082 .data = &spin_retry,
1083 .maxlen = sizeof (int),
1084 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001085 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001086 },
1087#endif
Len Brown673d5b42007-07-28 03:33:16 -04001088#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001089 {
Pavel Machekc255d842006-02-20 18:27:58 -08001090 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001091 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001092 .maxlen = sizeof (unsigned long),
1093 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001094 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001095 },
1096#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301097#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001098 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001099 .procname = "ignore-unaligned-usertrap",
1100 .data = &no_unaligned_warning,
1101 .maxlen = sizeof (int),
1102 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001103 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001104 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301105#endif
1106#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001107 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001108 .procname = "unaligned-dump-stack",
1109 .data = &unaligned_dump_stack,
1110 .maxlen = sizeof (int),
1111 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001112 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001113 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001114#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001115#ifdef CONFIG_DETECT_HUNG_TASK
1116 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001117 .procname = "hung_task_panic",
1118 .data = &sysctl_hung_task_panic,
1119 .maxlen = sizeof(int),
1120 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001121 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001122 .extra1 = &zero,
1123 .extra2 = &one,
1124 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001125 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001126 .procname = "hung_task_check_count",
1127 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001128 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001129 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001130 .proc_handler = proc_dointvec_minmax,
1131 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001132 },
1133 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001134 .procname = "hung_task_timeout_secs",
1135 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001136 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001137 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001138 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001139 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001140 },
1141 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001142 .procname = "hung_task_warnings",
1143 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001144 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001145 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001146 .proc_handler = proc_dointvec_minmax,
1147 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001148 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001149#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001150#ifdef CONFIG_RT_MUTEXES
1151 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001152 .procname = "max_lock_depth",
1153 .data = &max_lock_depth,
1154 .maxlen = sizeof(int),
1155 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001156 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001157 },
1158#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001159 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001160 .procname = "poweroff_cmd",
1161 .data = &poweroff_cmd,
1162 .maxlen = POWEROFF_CMD_PATH_LEN,
1163 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001164 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001165 },
David Howells0b77f5b2008-04-29 01:01:32 -07001166#ifdef CONFIG_KEYS
1167 {
David Howells0b77f5b2008-04-29 01:01:32 -07001168 .procname = "keys",
1169 .mode = 0555,
1170 .child = key_sysctls,
1171 },
1172#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001173#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001174 /*
1175 * User-space scripts rely on the existence of this file
1176 * as a feature check for perf_events being enabled.
1177 *
1178 * So it's an ABI, do not remove!
1179 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001180 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001181 .procname = "perf_event_paranoid",
1182 .data = &sysctl_perf_event_paranoid,
1183 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001184 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001185 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001186 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001187 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001188 .procname = "perf_event_mlock_kb",
1189 .data = &sysctl_perf_event_mlock,
1190 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001191 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001192 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001193 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001194 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001195 .procname = "perf_event_max_sample_rate",
1196 .data = &sysctl_perf_event_sample_rate,
1197 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001198 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001199 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001200 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001201 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001202 {
1203 .procname = "perf_cpu_time_max_percent",
1204 .data = &sysctl_perf_cpu_time_max_percent,
1205 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1206 .mode = 0644,
1207 .proc_handler = perf_cpu_time_max_percent_handler,
1208 .extra1 = &zero,
1209 .extra2 = &one_hundred,
1210 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001211 {
1212 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001213 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001214 .maxlen = sizeof(sysctl_perf_event_max_stack),
1215 .mode = 0644,
1216 .proc_handler = perf_event_max_stack_handler,
1217 .extra1 = &zero,
1218 .extra2 = &six_hundred_forty_kb,
1219 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001220 {
1221 .procname = "perf_event_max_contexts_per_stack",
1222 .data = &sysctl_perf_event_max_contexts_per_stack,
1223 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1224 .mode = 0644,
1225 .proc_handler = perf_event_max_stack_handler,
1226 .extra1 = &zero,
1227 .extra2 = &one_thousand,
1228 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001229#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001230#ifdef CONFIG_KMEMCHECK
1231 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001232 .procname = "kmemcheck",
1233 .data = &kmemcheck_enabled,
1234 .maxlen = sizeof(int),
1235 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001236 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001237 },
1238#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001239 {
1240 .procname = "panic_on_warn",
1241 .data = &panic_on_warn,
1242 .maxlen = sizeof(int),
1243 .mode = 0644,
1244 .proc_handler = proc_dointvec_minmax,
1245 .extra1 = &zero,
1246 .extra2 = &one,
1247 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001248#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1249 {
1250 .procname = "timer_migration",
1251 .data = &sysctl_timer_migration,
1252 .maxlen = sizeof(unsigned int),
1253 .mode = 0644,
1254 .proc_handler = timer_migration_handler,
Myungho Jung4c000152017-04-19 15:24:50 -07001255 .extra1 = &zero,
1256 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001257 },
1258#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001259#ifdef CONFIG_BPF_SYSCALL
1260 {
1261 .procname = "unprivileged_bpf_disabled",
1262 .data = &sysctl_unprivileged_bpf_disabled,
1263 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1264 .mode = 0644,
1265 /* only handle a transition from default "0" to "1" */
1266 .proc_handler = proc_dointvec_minmax,
1267 .extra1 = &one,
1268 .extra2 = &one,
1269 },
1270#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001271#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1272 {
1273 .procname = "panic_on_rcu_stall",
1274 .data = &sysctl_panic_on_rcu_stall,
1275 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1276 .mode = 0644,
1277 .proc_handler = proc_dointvec_minmax,
1278 .extra1 = &zero,
1279 .extra2 = &one,
1280 },
1281#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001282 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001283};
1284
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001285static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001286 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001287 .procname = "overcommit_memory",
1288 .data = &sysctl_overcommit_memory,
1289 .maxlen = sizeof(sysctl_overcommit_memory),
1290 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001291 .proc_handler = proc_dointvec_minmax,
1292 .extra1 = &zero,
1293 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294 },
1295 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001296 .procname = "panic_on_oom",
1297 .data = &sysctl_panic_on_oom,
1298 .maxlen = sizeof(sysctl_panic_on_oom),
1299 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001300 .proc_handler = proc_dointvec_minmax,
1301 .extra1 = &zero,
1302 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001303 },
1304 {
David Rientjesfe071d72007-10-16 23:25:56 -07001305 .procname = "oom_kill_allocating_task",
1306 .data = &sysctl_oom_kill_allocating_task,
1307 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1308 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001309 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001310 },
1311 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001312 .procname = "oom_dump_tasks",
1313 .data = &sysctl_oom_dump_tasks,
1314 .maxlen = sizeof(sysctl_oom_dump_tasks),
1315 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001316 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001317 },
1318 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001319 .procname = "overcommit_ratio",
1320 .data = &sysctl_overcommit_ratio,
1321 .maxlen = sizeof(sysctl_overcommit_ratio),
1322 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001323 .proc_handler = overcommit_ratio_handler,
1324 },
1325 {
1326 .procname = "overcommit_kbytes",
1327 .data = &sysctl_overcommit_kbytes,
1328 .maxlen = sizeof(sysctl_overcommit_kbytes),
1329 .mode = 0644,
1330 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001331 },
1332 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001333 .procname = "page-cluster",
1334 .data = &page_cluster,
1335 .maxlen = sizeof(int),
1336 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001337 .proc_handler = proc_dointvec_minmax,
1338 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339 },
1340 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001341 .procname = "dirty_background_ratio",
1342 .data = &dirty_background_ratio,
1343 .maxlen = sizeof(dirty_background_ratio),
1344 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001345 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001346 .extra1 = &zero,
1347 .extra2 = &one_hundred,
1348 },
1349 {
David Rientjes2da02992009-01-06 14:39:31 -08001350 .procname = "dirty_background_bytes",
1351 .data = &dirty_background_bytes,
1352 .maxlen = sizeof(dirty_background_bytes),
1353 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001354 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001355 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001356 },
1357 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001358 .procname = "dirty_ratio",
1359 .data = &vm_dirty_ratio,
1360 .maxlen = sizeof(vm_dirty_ratio),
1361 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001362 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001363 .extra1 = &zero,
1364 .extra2 = &one_hundred,
1365 },
1366 {
David Rientjes2da02992009-01-06 14:39:31 -08001367 .procname = "dirty_bytes",
1368 .data = &vm_dirty_bytes,
1369 .maxlen = sizeof(vm_dirty_bytes),
1370 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001371 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001372 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001373 },
1374 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001375 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001376 .data = &dirty_writeback_interval,
1377 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001379 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380 },
1381 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001382 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001383 .data = &dirty_expire_interval,
1384 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001385 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001386 .proc_handler = proc_dointvec_minmax,
1387 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001388 },
1389 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001390 .procname = "dirtytime_expire_seconds",
1391 .data = &dirtytime_expire_interval,
1392 .maxlen = sizeof(dirty_expire_interval),
1393 .mode = 0644,
1394 .proc_handler = dirtytime_interval_handler,
1395 .extra1 = &zero,
1396 },
1397 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001398 .procname = "nr_pdflush_threads",
1399 .mode = 0444 /* read-only */,
1400 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401 },
1402 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001403 .procname = "swappiness",
1404 .data = &vm_swappiness,
1405 .maxlen = sizeof(vm_swappiness),
1406 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001407 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408 .extra1 = &zero,
1409 .extra2 = &one_hundred,
1410 },
1411#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001412 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001414 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001415 .maxlen = sizeof(unsigned long),
1416 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001417 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001418 },
1419#ifdef CONFIG_NUMA
1420 {
1421 .procname = "nr_hugepages_mempolicy",
1422 .data = NULL,
1423 .maxlen = sizeof(unsigned long),
1424 .mode = 0644,
1425 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001426 },
1427#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001428 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001429 .procname = "hugetlb_shm_group",
1430 .data = &sysctl_hugetlb_shm_group,
1431 .maxlen = sizeof(gid_t),
1432 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001433 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001434 },
Mel Gorman396faf02007-07-17 04:03:13 -07001435 {
Mel Gorman396faf02007-07-17 04:03:13 -07001436 .procname = "hugepages_treat_as_movable",
1437 .data = &hugepages_treat_as_movable,
1438 .maxlen = sizeof(int),
1439 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001440 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -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,
1479 .proc_handler = sysctl_extfrag_handler,
1480 .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 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001503 .procname = "watermark_scale_factor",
1504 .data = &watermark_scale_factor,
1505 .maxlen = sizeof(watermark_scale_factor),
1506 .mode = 0644,
1507 .proc_handler = watermark_scale_factor_sysctl_handler,
1508 .extra1 = &one,
1509 .extra2 = &one_thousand,
1510 },
1511 {
Rik van Rieldbe0f612011-09-01 15:26:50 -04001512 .procname = "extra_free_kbytes",
1513 .data = &extra_free_kbytes,
1514 .maxlen = sizeof(extra_free_kbytes),
1515 .mode = 0644,
1516 .proc_handler = min_free_kbytes_sysctl_handler,
1517 .extra1 = &zero,
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
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001724 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001725};
1726
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001727static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001728 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729 .procname = "inode-nr",
1730 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001731 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001732 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001733 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001734 },
1735 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736 .procname = "inode-state",
1737 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001738 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001739 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001740 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001741 },
1742 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001743 .procname = "file-nr",
1744 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001745 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001746 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001747 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001748 },
1749 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750 .procname = "file-max",
1751 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001752 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001753 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001754 .proc_handler = proc_doulongvec_minmax,
Will Deacon3141fcc2019-04-05 18:39:38 -07001755 .extra1 = &zero_ul,
Christian Brauner6b65c262019-03-07 16:29:43 -08001756 .extra2 = &long_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001757 },
1758 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001759 .procname = "nr_open",
1760 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001761 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001762 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001763 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001764 .extra1 = &sysctl_nr_open_min,
1765 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001766 },
1767 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001768 .procname = "dentry-state",
1769 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001770 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001771 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001772 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001773 },
1774 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001775 .procname = "overflowuid",
1776 .data = &fs_overflowuid,
1777 .maxlen = sizeof(int),
1778 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001779 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001780 .extra1 = &minolduid,
1781 .extra2 = &maxolduid,
1782 },
1783 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001784 .procname = "overflowgid",
1785 .data = &fs_overflowgid,
1786 .maxlen = sizeof(int),
1787 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001788 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001789 .extra1 = &minolduid,
1790 .extra2 = &maxolduid,
1791 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001792#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001793 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001794 .procname = "leases-enable",
1795 .data = &leases_enable,
1796 .maxlen = sizeof(int),
1797 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001798 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001799 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001800#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001801#ifdef CONFIG_DNOTIFY
1802 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001803 .procname = "dir-notify-enable",
1804 .data = &dir_notify_enable,
1805 .maxlen = sizeof(int),
1806 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001807 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001808 },
1809#endif
1810#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001811#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001812 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001813 .procname = "lease-break-time",
1814 .data = &lease_break_time,
1815 .maxlen = sizeof(int),
1816 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001817 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001818 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001819#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001820#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001821 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001822 .procname = "aio-nr",
1823 .data = &aio_nr,
1824 .maxlen = sizeof(aio_nr),
1825 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001826 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001827 },
1828 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001829 .procname = "aio-max-nr",
1830 .data = &aio_max_nr,
1831 .maxlen = sizeof(aio_max_nr),
1832 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001833 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001834 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001835#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001836#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001837 {
Robert Love0399cb02005-07-13 12:38:18 -04001838 .procname = "inotify",
1839 .mode = 0555,
1840 .child = inotify_table,
1841 },
1842#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001843#ifdef CONFIG_EPOLL
1844 {
1845 .procname = "epoll",
1846 .mode = 0555,
1847 .child = epoll_table,
1848 },
1849#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001850#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001851 {
Kees Cook800179c2012-07-25 17:29:07 -07001852 .procname = "protected_symlinks",
1853 .data = &sysctl_protected_symlinks,
1854 .maxlen = sizeof(int),
1855 .mode = 0600,
1856 .proc_handler = proc_dointvec_minmax,
1857 .extra1 = &zero,
1858 .extra2 = &one,
1859 },
1860 {
1861 .procname = "protected_hardlinks",
1862 .data = &sysctl_protected_hardlinks,
1863 .maxlen = sizeof(int),
1864 .mode = 0600,
1865 .proc_handler = proc_dointvec_minmax,
1866 .extra1 = &zero,
1867 .extra2 = &one,
1868 },
1869 {
Salvatore Mesoraca0c41bee2018-08-23 17:00:35 -07001870 .procname = "protected_fifos",
1871 .data = &sysctl_protected_fifos,
1872 .maxlen = sizeof(int),
1873 .mode = 0600,
1874 .proc_handler = proc_dointvec_minmax,
1875 .extra1 = &zero,
1876 .extra2 = &two,
1877 },
1878 {
1879 .procname = "protected_regular",
1880 .data = &sysctl_protected_regular,
1881 .maxlen = sizeof(int),
1882 .mode = 0600,
1883 .proc_handler = proc_dointvec_minmax,
1884 .extra1 = &zero,
1885 .extra2 = &two,
1886 },
1887 {
Alan Coxd6e71142005-06-23 00:09:43 -07001888 .procname = "suid_dumpable",
1889 .data = &suid_dumpable,
1890 .maxlen = sizeof(int),
1891 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001892 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001893 .extra1 = &zero,
1894 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001895 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001896#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1897 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001898 .procname = "binfmt_misc",
1899 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001900 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001901 },
1902#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001903 {
Jens Axboeff9da692010-06-03 14:54:39 +02001904 .procname = "pipe-max-size",
1905 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001906 .maxlen = sizeof(int),
1907 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001908 .proc_handler = &pipe_proc_fn,
1909 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001910 },
Willy Tarreau759c0112016-01-18 16:36:09 +01001911 {
1912 .procname = "pipe-user-pages-hard",
1913 .data = &pipe_user_pages_hard,
1914 .maxlen = sizeof(pipe_user_pages_hard),
1915 .mode = 0644,
1916 .proc_handler = proc_doulongvec_minmax,
1917 },
1918 {
1919 .procname = "pipe-user-pages-soft",
1920 .data = &pipe_user_pages_soft,
1921 .maxlen = sizeof(pipe_user_pages_soft),
1922 .mode = 0644,
1923 .proc_handler = proc_doulongvec_minmax,
1924 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05001925 {
1926 .procname = "mount-max",
1927 .data = &sysctl_mount_max,
1928 .maxlen = sizeof(unsigned int),
1929 .mode = 0644,
1930 .proc_handler = proc_dointvec_minmax,
1931 .extra1 = &one,
1932 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001933 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001934};
1935
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001936static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001937#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001938 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001939 .procname = "exception-trace",
1940 .data = &show_unhandled_signals,
1941 .maxlen = sizeof(int),
1942 .mode = 0644,
1943 .proc_handler = proc_dointvec
1944 },
1945#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001946#if defined(CONFIG_OPTPROBES)
1947 {
1948 .procname = "kprobes-optimization",
1949 .data = &sysctl_kprobes_optimization,
1950 .maxlen = sizeof(int),
1951 .mode = 0644,
1952 .proc_handler = proc_kprobes_optimization_handler,
1953 .extra1 = &zero,
1954 .extra2 = &one,
1955 },
1956#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001957 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001958};
1959
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001960static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001961 { }
Robert Love0eeca282005-07-12 17:06:03 -04001962};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001963
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001964int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001965{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001966 struct ctl_table_header *hdr;
1967
1968 hdr = register_sysctl_table(sysctl_base_table);
1969 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001970 return 0;
1971}
1972
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001973#endif /* CONFIG_SYSCTL */
1974
Linus Torvalds1da177e2005-04-16 15:20:36 -07001975/*
1976 * /proc/sys support
1977 */
1978
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001979#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001980
Kees Cookf8808302014-06-06 14:37:17 -07001981static int _proc_do_string(char *data, int maxlen, int write,
1982 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001983 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001984{
1985 size_t len;
1986 char __user *p;
1987 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001988
1989 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001990 *lenp = 0;
1991 return 0;
1992 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001993
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001994 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001995 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1996 /* Only continue writes not past the end of buffer. */
1997 len = strlen(data);
1998 if (len > maxlen - 1)
1999 len = maxlen - 1;
2000
2001 if (*ppos > len)
2002 return 0;
2003 len = *ppos;
2004 } else {
2005 /* Start writing from beginning of buffer. */
2006 len = 0;
2007 }
2008
Kees Cook2ca9bb42014-06-06 14:37:18 -07002009 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002010 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002011 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002012 if (get_user(c, p++))
2013 return -EFAULT;
2014 if (c == 0 || c == '\n')
2015 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07002016 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002017 }
Kees Cookf8808302014-06-06 14:37:17 -07002018 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002019 } else {
2020 len = strlen(data);
2021 if (len > maxlen)
2022 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08002023
2024 if (*ppos > len) {
2025 *lenp = 0;
2026 return 0;
2027 }
2028
2029 data += *ppos;
2030 len -= *ppos;
2031
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002032 if (len > *lenp)
2033 len = *lenp;
2034 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07002035 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002036 return -EFAULT;
2037 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07002038 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07002039 return -EFAULT;
2040 len++;
2041 }
2042 *lenp = len;
2043 *ppos += len;
2044 }
2045 return 0;
2046}
2047
Kees Cookf4aacea2014-06-06 14:37:19 -07002048static void warn_sysctl_write(struct ctl_table *table)
2049{
2050 pr_warn_once("%s wrote to %s when file position was not 0!\n"
2051 "This will not be supported in the future. To silence this\n"
2052 "warning, set kernel.sysctl_writes_strict = -1\n",
2053 current->comm, table->procname);
2054}
2055
Linus Torvalds1da177e2005-04-16 15:20:36 -07002056/**
2057 * proc_dostring - read a string sysctl
2058 * @table: the sysctl table
2059 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002060 * @buffer: the user buffer
2061 * @lenp: the size of the user buffer
2062 * @ppos: file position
2063 *
2064 * Reads/writes a string from/to the user buffer. If the kernel
2065 * buffer provided is not large enough to hold the string, the
2066 * string is truncated. The copied string is %NULL-terminated.
2067 * If the string is being read by the user process, it is copied
2068 * and a newline '\n' is added. It is truncated if the buffer is
2069 * not large enough.
2070 *
2071 * Returns 0 on success.
2072 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002073int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002074 void __user *buffer, size_t *lenp, loff_t *ppos)
2075{
Kees Cookf4aacea2014-06-06 14:37:19 -07002076 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2077 warn_sysctl_write(table);
2078
Kees Cookf8808302014-06-06 14:37:17 -07002079 return _proc_do_string((char *)(table->data), table->maxlen, write,
2080 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002081}
2082
Amerigo Wang00b7c332010-05-05 00:26:45 +00002083static size_t proc_skip_spaces(char **buf)
2084{
2085 size_t ret;
2086 char *tmp = skip_spaces(*buf);
2087 ret = tmp - *buf;
2088 *buf = tmp;
2089 return ret;
2090}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002091
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002092static void proc_skip_char(char **buf, size_t *size, const char v)
2093{
2094 while (*size) {
2095 if (**buf != v)
2096 break;
2097 (*size)--;
2098 (*buf)++;
2099 }
2100}
2101
Amerigo Wang00b7c332010-05-05 00:26:45 +00002102#define TMPBUFLEN 22
2103/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002104 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002105 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002106 * @buf: a kernel buffer
2107 * @size: size of the kernel buffer
2108 * @val: this is where the number will be stored
2109 * @neg: set to %TRUE if number is negative
2110 * @perm_tr: a vector which contains the allowed trailers
2111 * @perm_tr_len: size of the perm_tr vector
2112 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002113 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002114 * In case of success %0 is returned and @buf and @size are updated with
2115 * the amount of bytes read. If @tr is non-NULL and a trailing
2116 * character exists (size is non-zero after returning from this
2117 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002118 */
2119static int proc_get_long(char **buf, size_t *size,
2120 unsigned long *val, bool *neg,
2121 const char *perm_tr, unsigned perm_tr_len, char *tr)
2122{
2123 int len;
2124 char *p, tmp[TMPBUFLEN];
2125
2126 if (!*size)
2127 return -EINVAL;
2128
2129 len = *size;
2130 if (len > TMPBUFLEN - 1)
2131 len = TMPBUFLEN - 1;
2132
2133 memcpy(tmp, *buf, len);
2134
2135 tmp[len] = 0;
2136 p = tmp;
2137 if (*p == '-' && *size > 1) {
2138 *neg = true;
2139 p++;
2140 } else
2141 *neg = false;
2142 if (!isdigit(*p))
2143 return -EINVAL;
2144
2145 *val = simple_strtoul(p, &p, 0);
2146
2147 len = p - tmp;
2148
2149 /* We don't know if the next char is whitespace thus we may accept
2150 * invalid integers (e.g. 1234...a) or two integers instead of one
2151 * (e.g. 123...1). So lets not allow such large numbers. */
2152 if (len == TMPBUFLEN - 1)
2153 return -EINVAL;
2154
2155 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2156 return -EINVAL;
2157
2158 if (tr && (len < *size))
2159 *tr = *p;
2160
2161 *buf += len;
2162 *size -= len;
2163
2164 return 0;
2165}
2166
2167/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002168 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002169 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002170 * @buf: the user buffer
2171 * @size: the size of the user buffer
2172 * @val: the integer to be converted
2173 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002174 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002175 * In case of success %0 is returned and @buf and @size are updated with
2176 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002177 */
2178static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2179 bool neg)
2180{
2181 int len;
2182 char tmp[TMPBUFLEN], *p = tmp;
2183
2184 sprintf(p, "%s%lu", neg ? "-" : "", val);
2185 len = strlen(tmp);
2186 if (len > *size)
2187 len = *size;
2188 if (copy_to_user(*buf, tmp, len))
2189 return -EFAULT;
2190 *size -= len;
2191 *buf += len;
2192 return 0;
2193}
2194#undef TMPBUFLEN
2195
2196static int proc_put_char(void __user **buf, size_t *size, char c)
2197{
2198 if (*size) {
2199 char __user **buffer = (char __user **)buf;
2200 if (put_user(c, *buffer))
2201 return -EFAULT;
2202 (*size)--, (*buffer)++;
2203 *buf = *buffer;
2204 }
2205 return 0;
2206}
2207
2208static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002209 int *valp,
2210 int write, void *data)
2211{
2212 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002213 if (*negp) {
2214 if (*lvalp > (unsigned long) INT_MAX + 1)
2215 return -EINVAL;
2216 *valp = -*lvalp;
2217 } else {
2218 if (*lvalp > (unsigned long) INT_MAX)
2219 return -EINVAL;
2220 *valp = *lvalp;
2221 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002222 } else {
2223 int val = *valp;
2224 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002225 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002226 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002227 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002228 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002229 *lvalp = (unsigned long)val;
2230 }
2231 }
2232 return 0;
2233}
2234
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002235static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2236 int *valp,
2237 int write, void *data)
2238{
2239 if (write) {
2240 if (*negp)
2241 return -EINVAL;
Liping Zhang7bdacd32017-04-07 23:51:07 +08002242 if (*lvalp > UINT_MAX)
2243 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002244 *valp = *lvalp;
2245 } else {
2246 unsigned int val = *valp;
Liping Zhang3a20c572017-04-07 23:51:06 +08002247 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002248 *lvalp = (unsigned long)val;
2249 }
2250 return 0;
2251}
2252
Amerigo Wang00b7c332010-05-05 00:26:45 +00002253static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2254
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002255static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002256 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002257 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002258 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002259 int write, void *data),
2260 void *data)
2261{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002262 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002263 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002264 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002265
Amerigo Wang00b7c332010-05-05 00:26:45 +00002266 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002267 *lenp = 0;
2268 return 0;
2269 }
2270
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002271 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002272 vleft = table->maxlen / sizeof(*i);
2273 left = *lenp;
2274
2275 if (!conv)
2276 conv = do_proc_dointvec_conv;
2277
Linus Torvalds1da177e2005-04-16 15:20:36 -07002278 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002279 if (*ppos) {
2280 switch (sysctl_writes_strict) {
2281 case SYSCTL_WRITES_STRICT:
2282 goto out;
2283 case SYSCTL_WRITES_WARN:
2284 warn_sysctl_write(table);
2285 break;
2286 default:
2287 break;
2288 }
2289 }
2290
Amerigo Wang00b7c332010-05-05 00:26:45 +00002291 if (left > PAGE_SIZE - 1)
2292 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002293 p = kbuf = memdup_user_nul(buffer, left);
2294 if (IS_ERR(kbuf))
2295 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002296 }
2297
2298 for (; left && vleft--; i++, first=0) {
2299 unsigned long lval;
2300 bool neg;
2301
2302 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002303 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002304
J. R. Okajima563b0462010-05-25 16:10:14 -07002305 if (!left)
2306 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002307 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002308 proc_wspace_sep,
2309 sizeof(proc_wspace_sep), NULL);
2310 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002311 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002312 if (conv(&neg, &lval, i, 1, data)) {
2313 err = -EINVAL;
2314 break;
2315 }
2316 } else {
2317 if (conv(&neg, &lval, i, 0, data)) {
2318 err = -EINVAL;
2319 break;
2320 }
2321 if (!first)
2322 err = proc_put_char(&buffer, &left, '\t');
2323 if (err)
2324 break;
2325 err = proc_put_long(&buffer, &left, lval, neg);
2326 if (err)
2327 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002328 }
2329 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002330
2331 if (!write && !first && left && !err)
2332 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002333 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002334 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002335 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002336 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002337 if (first)
2338 return err ? : -EINVAL;
2339 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002340 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002341out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002342 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002343 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002344}
2345
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002346static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002347 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002348 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002349 int write, void *data),
2350 void *data)
2351{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002352 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002353 buffer, lenp, ppos, conv, data);
2354}
2355
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356/**
2357 * proc_dointvec - read a vector of integers
2358 * @table: the sysctl table
2359 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002360 * @buffer: the user buffer
2361 * @lenp: the size of the user buffer
2362 * @ppos: file position
2363 *
2364 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2365 * values from/to the user buffer, treated as an ASCII string.
2366 *
2367 * Returns 0 on success.
2368 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002369int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370 void __user *buffer, size_t *lenp, loff_t *ppos)
2371{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002372 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2373}
2374
2375/**
2376 * proc_douintvec - read a vector of unsigned integers
2377 * @table: the sysctl table
2378 * @write: %TRUE if this is a write to the sysctl file
2379 * @buffer: the user buffer
2380 * @lenp: the size of the user buffer
2381 * @ppos: file position
2382 *
2383 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2384 * values from/to the user buffer, treated as an ASCII string.
2385 *
2386 * Returns 0 on success.
2387 */
2388int proc_douintvec(struct ctl_table *table, int write,
2389 void __user *buffer, size_t *lenp, loff_t *ppos)
2390{
2391 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2392 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393}
2394
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002395/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002396 * Taint values can only be increased
2397 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002398 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002399static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002400 void __user *buffer, size_t *lenp, loff_t *ppos)
2401{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002402 struct ctl_table t;
2403 unsigned long tmptaint = get_taint();
2404 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002405
Bastian Blank91fcd412007-04-23 14:41:14 -07002406 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002407 return -EPERM;
2408
Andi Kleen25ddbb12008-10-15 22:01:41 -07002409 t = *table;
2410 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002411 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002412 if (err < 0)
2413 return err;
2414
2415 if (write) {
2416 /*
2417 * Poor man's atomic or. Not worth adding a primitive
2418 * to everyone's atomic.h for this
2419 */
2420 int i;
2421 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2422 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302423 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002424 }
2425 }
2426
2427 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002428}
2429
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002430#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002431static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002432 void __user *buffer, size_t *lenp, loff_t *ppos)
2433{
2434 if (write && !capable(CAP_SYS_ADMIN))
2435 return -EPERM;
2436
2437 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2438}
2439#endif
2440
Linus Torvalds1da177e2005-04-16 15:20:36 -07002441struct do_proc_dointvec_minmax_conv_param {
2442 int *min;
2443 int *max;
2444};
2445
Amerigo Wang00b7c332010-05-05 00:26:45 +00002446static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2447 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002448 int write, void *data)
2449{
2450 struct do_proc_dointvec_minmax_conv_param *param = data;
2451 if (write) {
Zev Weiss45a67f12019-03-11 23:28:02 -07002452 int val;
2453 if (*negp) {
2454 if (*lvalp > (unsigned long) INT_MAX + 1)
2455 return -EINVAL;
2456 val = -*lvalp;
2457 } else {
2458 if (*lvalp > (unsigned long) INT_MAX)
2459 return -EINVAL;
2460 val = *lvalp;
2461 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002462 if ((param->min && *param->min > val) ||
2463 (param->max && *param->max < val))
2464 return -EINVAL;
2465 *valp = val;
2466 } else {
2467 int val = *valp;
2468 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002469 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002470 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002472 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002473 *lvalp = (unsigned long)val;
2474 }
2475 }
2476 return 0;
2477}
2478
2479/**
2480 * proc_dointvec_minmax - read a vector of integers with min/max values
2481 * @table: the sysctl table
2482 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483 * @buffer: the user buffer
2484 * @lenp: the size of the user buffer
2485 * @ppos: file position
2486 *
2487 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2488 * values from/to the user buffer, treated as an ASCII string.
2489 *
2490 * This routine will ensure the values are within the range specified by
2491 * table->extra1 (min) and table->extra2 (max).
2492 *
2493 * Returns 0 on success.
2494 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002495int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002496 void __user *buffer, size_t *lenp, loff_t *ppos)
2497{
2498 struct do_proc_dointvec_minmax_conv_param param = {
2499 .min = (int *) table->extra1,
2500 .max = (int *) table->extra2,
2501 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002502 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002503 do_proc_dointvec_minmax_conv, &param);
2504}
2505
Kees Cook54b50192012-07-30 14:39:18 -07002506static void validate_coredump_safety(void)
2507{
Alex Kelly046d6622012-10-04 17:15:23 -07002508#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002509 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002510 core_pattern[0] != '/' && core_pattern[0] != '|') {
2511 printk(KERN_WARNING "Unsafe core_pattern used with "\
2512 "suid_dumpable=2. Pipe handler or fully qualified "\
2513 "core dump path required.\n");
2514 }
Alex Kelly046d6622012-10-04 17:15:23 -07002515#endif
Kees Cook54b50192012-07-30 14:39:18 -07002516}
2517
2518static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2519 void __user *buffer, size_t *lenp, loff_t *ppos)
2520{
2521 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2522 if (!error)
2523 validate_coredump_safety();
2524 return error;
2525}
2526
Alex Kelly046d6622012-10-04 17:15:23 -07002527#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002528static int proc_dostring_coredump(struct ctl_table *table, int write,
2529 void __user *buffer, size_t *lenp, loff_t *ppos)
2530{
2531 int error = proc_dostring(table, write, buffer, lenp, ppos);
2532 if (!error)
2533 validate_coredump_safety();
2534 return error;
2535}
Alex Kelly046d6622012-10-04 17:15:23 -07002536#endif
Kees Cook54b50192012-07-30 14:39:18 -07002537
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002538static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002539 void __user *buffer,
2540 size_t *lenp, loff_t *ppos,
2541 unsigned long convmul,
2542 unsigned long convdiv)
2543{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002544 unsigned long *i, *min, *max;
2545 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002546 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002547 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002548
2549 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550 *lenp = 0;
2551 return 0;
2552 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002553
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002554 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002555 min = (unsigned long *) table->extra1;
2556 max = (unsigned long *) table->extra2;
2557 vleft = table->maxlen / sizeof(unsigned long);
2558 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002559
2560 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002561 if (*ppos) {
2562 switch (sysctl_writes_strict) {
2563 case SYSCTL_WRITES_STRICT:
2564 goto out;
2565 case SYSCTL_WRITES_WARN:
2566 warn_sysctl_write(table);
2567 break;
2568 default:
2569 break;
2570 }
2571 }
2572
Amerigo Wang00b7c332010-05-05 00:26:45 +00002573 if (left > PAGE_SIZE - 1)
2574 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002575 p = kbuf = memdup_user_nul(buffer, left);
2576 if (IS_ERR(kbuf))
2577 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002578 }
2579
Eric Dumazet27b3d802010-10-07 12:59:29 -07002580 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002581 unsigned long val;
2582
Linus Torvalds1da177e2005-04-16 15:20:36 -07002583 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002584 bool neg;
2585
Al Viro70f6cbb2015-12-24 00:13:10 -05002586 left -= proc_skip_spaces(&p);
Cheng Lin0e5c7502019-01-03 15:26:13 -08002587 if (!left)
2588 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002589
Al Viro70f6cbb2015-12-24 00:13:10 -05002590 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002591 proc_wspace_sep,
2592 sizeof(proc_wspace_sep), NULL);
2593 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002594 break;
2595 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002596 continue;
Eric Dumazet03707d62017-01-25 18:20:55 -08002597 val = convmul * val / convdiv;
Christian Brauner726f69d2019-05-14 15:44:55 -07002598 if ((min && val < *min) || (max && val > *max)) {
2599 err = -EINVAL;
2600 break;
2601 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002602 *i = val;
2603 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002604 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002605 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002606 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002607 if (err)
2608 break;
2609 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002610 err = proc_put_long(&buffer, &left, val, false);
2611 if (err)
2612 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002613 }
2614 }
2615
Amerigo Wang00b7c332010-05-05 00:26:45 +00002616 if (!write && !first && left && !err)
2617 err = proc_put_char(&buffer, &left, '\n');
2618 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002619 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002621 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002622 if (first)
2623 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002624 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002625 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002626out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002627 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002628 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629}
2630
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002631static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002632 void __user *buffer,
2633 size_t *lenp, loff_t *ppos,
2634 unsigned long convmul,
2635 unsigned long convdiv)
2636{
2637 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002638 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002639}
2640
Linus Torvalds1da177e2005-04-16 15:20:36 -07002641/**
2642 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2643 * @table: the sysctl table
2644 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002645 * @buffer: the user buffer
2646 * @lenp: the size of the user buffer
2647 * @ppos: file position
2648 *
2649 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2650 * values from/to the user buffer, treated as an ASCII string.
2651 *
2652 * This routine will ensure the values are within the range specified by
2653 * table->extra1 (min) and table->extra2 (max).
2654 *
2655 * Returns 0 on success.
2656 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002657int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002658 void __user *buffer, size_t *lenp, loff_t *ppos)
2659{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002660 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002661}
2662
2663/**
2664 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2665 * @table: the sysctl table
2666 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667 * @buffer: the user buffer
2668 * @lenp: the size of the user buffer
2669 * @ppos: file position
2670 *
2671 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2672 * values from/to the user buffer, treated as an ASCII string. The values
2673 * are treated as milliseconds, and converted to jiffies when they are stored.
2674 *
2675 * This routine will ensure the values are within the range specified by
2676 * table->extra1 (min) and table->extra2 (max).
2677 *
2678 * Returns 0 on success.
2679 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002680int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002681 void __user *buffer,
2682 size_t *lenp, loff_t *ppos)
2683{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002684 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002685 lenp, ppos, HZ, 1000l);
2686}
2687
2688
Amerigo Wang00b7c332010-05-05 00:26:45 +00002689static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002690 int *valp,
2691 int write, void *data)
2692{
2693 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002694 if (*lvalp > LONG_MAX / HZ)
2695 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002696 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2697 } else {
2698 int val = *valp;
2699 unsigned long lval;
2700 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002701 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002702 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002703 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002704 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002705 lval = (unsigned long)val;
2706 }
2707 *lvalp = lval / HZ;
2708 }
2709 return 0;
2710}
2711
Amerigo Wang00b7c332010-05-05 00:26:45 +00002712static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002713 int *valp,
2714 int write, void *data)
2715{
2716 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002717 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2718 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002719 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2720 } else {
2721 int val = *valp;
2722 unsigned long lval;
2723 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002724 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002725 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002726 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002727 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002728 lval = (unsigned long)val;
2729 }
2730 *lvalp = jiffies_to_clock_t(lval);
2731 }
2732 return 0;
2733}
2734
Amerigo Wang00b7c332010-05-05 00:26:45 +00002735static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002736 int *valp,
2737 int write, void *data)
2738{
2739 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002740 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2741
2742 if (jif > INT_MAX)
2743 return 1;
2744 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002745 } else {
2746 int val = *valp;
2747 unsigned long lval;
2748 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002749 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002750 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002751 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002752 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002753 lval = (unsigned long)val;
2754 }
2755 *lvalp = jiffies_to_msecs(lval);
2756 }
2757 return 0;
2758}
2759
2760/**
2761 * proc_dointvec_jiffies - read a vector of integers as seconds
2762 * @table: the sysctl table
2763 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002764 * @buffer: the user buffer
2765 * @lenp: the size of the user buffer
2766 * @ppos: file position
2767 *
2768 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2769 * values from/to the user buffer, treated as an ASCII string.
2770 * The values read are assumed to be in seconds, and are converted into
2771 * jiffies.
2772 *
2773 * Returns 0 on success.
2774 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002775int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002776 void __user *buffer, size_t *lenp, loff_t *ppos)
2777{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002778 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002779 do_proc_dointvec_jiffies_conv,NULL);
2780}
2781
2782/**
2783 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2784 * @table: the sysctl table
2785 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002786 * @buffer: the user buffer
2787 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002788 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002789 *
2790 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2791 * values from/to the user buffer, treated as an ASCII string.
2792 * The values read are assumed to be in 1/USER_HZ seconds, and
2793 * are converted into jiffies.
2794 *
2795 * Returns 0 on success.
2796 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002797int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002798 void __user *buffer, size_t *lenp, loff_t *ppos)
2799{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002800 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002801 do_proc_dointvec_userhz_jiffies_conv,NULL);
2802}
2803
2804/**
2805 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2806 * @table: the sysctl table
2807 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002808 * @buffer: the user buffer
2809 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002810 * @ppos: file position
2811 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002812 *
2813 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2814 * values from/to the user buffer, treated as an ASCII string.
2815 * The values read are assumed to be in 1/1000 seconds, and
2816 * are converted into jiffies.
2817 *
2818 * Returns 0 on success.
2819 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002820int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002821 void __user *buffer, size_t *lenp, loff_t *ppos)
2822{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002823 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002824 do_proc_dointvec_ms_jiffies_conv, NULL);
2825}
2826
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002827static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002828 void __user *buffer, size_t *lenp, loff_t *ppos)
2829{
2830 struct pid *new_pid;
2831 pid_t tmp;
2832 int r;
2833
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002834 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002835
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002836 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002837 lenp, ppos, NULL, NULL);
2838 if (r || !write)
2839 return r;
2840
2841 new_pid = find_get_pid(tmp);
2842 if (!new_pid)
2843 return -ESRCH;
2844
2845 put_pid(xchg(&cad_pid, new_pid));
2846 return 0;
2847}
2848
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002849/**
2850 * proc_do_large_bitmap - read/write from/to a large bitmap
2851 * @table: the sysctl table
2852 * @write: %TRUE if this is a write to the sysctl file
2853 * @buffer: the user buffer
2854 * @lenp: the size of the user buffer
2855 * @ppos: file position
2856 *
2857 * The bitmap is stored at table->data and the bitmap length (in bits)
2858 * in table->maxlen.
2859 *
2860 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2861 * large bitmaps may be represented in a compact manner. Writing into
2862 * the file will clear the bitmap then update it with the given input.
2863 *
2864 * Returns 0 on success.
2865 */
2866int proc_do_large_bitmap(struct ctl_table *table, int write,
2867 void __user *buffer, size_t *lenp, loff_t *ppos)
2868{
2869 int err = 0;
2870 bool first = 1;
2871 size_t left = *lenp;
2872 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002873 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002874 unsigned long *tmp_bitmap = NULL;
2875 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2876
WANG Cong122ff242014-05-12 16:04:53 -07002877 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002878 *lenp = 0;
2879 return 0;
2880 }
2881
2882 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002883 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002884
2885 if (left > PAGE_SIZE - 1)
2886 left = PAGE_SIZE - 1;
2887
Al Viro70f6cbb2015-12-24 00:13:10 -05002888 p = kbuf = memdup_user_nul(buffer, left);
2889 if (IS_ERR(kbuf))
2890 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002891
2892 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2893 GFP_KERNEL);
2894 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002895 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002896 return -ENOMEM;
2897 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002898 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002899 while (!err && left) {
2900 unsigned long val_a, val_b;
2901 bool neg;
2902
Al Viro70f6cbb2015-12-24 00:13:10 -05002903 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002904 sizeof(tr_a), &c);
2905 if (err)
2906 break;
2907 if (val_a >= bitmap_len || neg) {
2908 err = -EINVAL;
2909 break;
2910 }
2911
2912 val_b = val_a;
2913 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002914 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002915 left--;
2916 }
2917
2918 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05002919 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002920 &neg, tr_b, sizeof(tr_b),
2921 &c);
2922 if (err)
2923 break;
2924 if (val_b >= bitmap_len || neg ||
2925 val_a > val_b) {
2926 err = -EINVAL;
2927 break;
2928 }
2929 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002930 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002931 left--;
2932 }
2933 }
2934
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002935 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002936 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05002937 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002938 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002939 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002940 } else {
2941 unsigned long bit_a, bit_b = 0;
2942
2943 while (left) {
2944 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2945 if (bit_a >= bitmap_len)
2946 break;
2947 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2948 bit_a + 1) - 1;
2949
2950 if (!first) {
2951 err = proc_put_char(&buffer, &left, ',');
2952 if (err)
2953 break;
2954 }
2955 err = proc_put_long(&buffer, &left, bit_a, false);
2956 if (err)
2957 break;
2958 if (bit_a != bit_b) {
2959 err = proc_put_char(&buffer, &left, '-');
2960 if (err)
2961 break;
2962 err = proc_put_long(&buffer, &left, bit_b, false);
2963 if (err)
2964 break;
2965 }
2966
2967 first = 0; bit_b++;
2968 }
2969 if (!err)
2970 err = proc_put_char(&buffer, &left, '\n');
2971 }
2972
2973 if (!err) {
2974 if (write) {
2975 if (*ppos)
2976 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2977 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002978 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002979 }
2980 kfree(tmp_bitmap);
2981 *lenp -= left;
2982 *ppos += *lenp;
2983 return 0;
2984 } else {
2985 kfree(tmp_bitmap);
2986 return err;
2987 }
2988}
2989
Jovi Zhang55610502011-01-12 17:00:45 -08002990#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002991
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002992int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002993 void __user *buffer, size_t *lenp, loff_t *ppos)
2994{
2995 return -ENOSYS;
2996}
2997
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002998int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002999 void __user *buffer, size_t *lenp, loff_t *ppos)
3000{
3001 return -ENOSYS;
3002}
3003
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003004int proc_douintvec(struct ctl_table *table, int write,
3005 void __user *buffer, size_t *lenp, loff_t *ppos)
3006{
3007 return -ENOSYS;
3008}
3009
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003010int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003011 void __user *buffer, size_t *lenp, loff_t *ppos)
3012{
3013 return -ENOSYS;
3014}
3015
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003016int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003017 void __user *buffer, size_t *lenp, loff_t *ppos)
3018{
3019 return -ENOSYS;
3020}
3021
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003022int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003023 void __user *buffer, size_t *lenp, loff_t *ppos)
3024{
3025 return -ENOSYS;
3026}
3027
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003028int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003029 void __user *buffer, size_t *lenp, loff_t *ppos)
3030{
3031 return -ENOSYS;
3032}
3033
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07003034int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003035 void __user *buffer, size_t *lenp, loff_t *ppos)
3036{
3037 return -ENOSYS;
3038}
3039
Eric W. Biedermand8217f02007-10-18 03:05:22 -07003040int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003041 void __user *buffer,
3042 size_t *lenp, loff_t *ppos)
3043{
3044 return -ENOSYS;
3045}
3046
3047
Jovi Zhang55610502011-01-12 17:00:45 -08003048#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003049
Linus Torvalds1da177e2005-04-16 15:20:36 -07003050/*
3051 * No sense putting this after each symbol definition, twice,
3052 * exception granted :-)
3053 */
3054EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07003055EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003056EXPORT_SYMBOL(proc_dointvec_jiffies);
3057EXPORT_SYMBOL(proc_dointvec_minmax);
3058EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
3059EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
3060EXPORT_SYMBOL(proc_dostring);
3061EXPORT_SYMBOL(proc_doulongvec_minmax);
3062EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);