blob: 5515d578095b50d668219cd836d982b5f36c811f [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;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800109extern int percpu_pagelist_fraction;
Arjan van de Ven97455122008-01-25 21:08:34 +0100110extern int latencytop_enabled;
Alexey Dobriyan9b80a182016-09-02 00:38:52 +0300111extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000112#ifndef CONFIG_MMU
113extern int sysctl_nr_trim_pages;
114#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700116/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400117#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700118static int sixty = 60;
119#endif
120
Aaron Tomlin270750db2014-01-20 17:34:13 +0000121static int __maybe_unused neg_one = -1;
122
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700123static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700124static int __maybe_unused one = 1;
125static int __maybe_unused two = 2;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700126static int __maybe_unused four = 4;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800127static unsigned long one_ul = 1;
Christian Brauner6b65c262019-03-07 16:29:43 -0800128static unsigned long long_max = LONG_MAX;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700129static int one_hundred = 100;
Johannes Weiner795ae7a2016-03-17 14:19:14 -0700130static int one_thousand = 1000;
Dave Youngaf913222009-09-22 16:43:33 -0700131#ifdef CONFIG_PRINTK
132static int ten_thousand = 10000;
133#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300134#ifdef CONFIG_PERF_EVENTS
135static int six_hundred_forty_kb = 640 * 1024;
136#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700137
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700138/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
139static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
142static int maxolduid = 65535;
143static int minolduid;
144
145static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700146static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
Liu Hua80df2842014-04-07 15:38:57 -0700148/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
149#ifdef CONFIG_DETECT_HUNG_TASK
150static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
151#endif
152
Dave Youngd14f1722010-02-25 20:28:57 -0500153#ifdef CONFIG_INOTIFY_USER
154#include <linux/inotify.h>
155#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700156#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157#endif
158
159#ifdef __hppa__
160extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530161#endif
162
163#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164extern int unaligned_enabled;
165#endif
166
Jes Sorensend2b176e2006-02-28 09:42:23 -0800167#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800168extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800169#endif
170
Vineet Guptab6fca722013-01-09 20:06:28 +0530171#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
172extern int no_unaligned_warning;
173#endif
174
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700175#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700176
177#define SYSCTL_WRITES_LEGACY -1
178#define SYSCTL_WRITES_WARN 0
179#define SYSCTL_WRITES_STRICT 1
180
Kees Cook41662f52016-01-20 15:00:45 -0800181static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700182
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700183static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700184 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700185static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800186 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700187#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700188
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700189#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700190static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700191 void __user *buffer, size_t *lenp, loff_t *ppos);
192#endif
193
Kees Cook54b50192012-07-30 14:39:18 -0700194static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
195 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700196#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700197static int proc_dostring_coredump(struct ctl_table *table, int write,
198 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700199#endif
Kees Cook54b50192012-07-30 14:39:18 -0700200
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700201#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800202/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100203static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700204
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700205static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700206 void __user *buffer, size_t *lenp,
207 loff_t *ppos)
208{
209 int error;
210
211 error = proc_dointvec(table, write, buffer, lenp, ppos);
212 if (error)
213 return error;
214
215 if (write)
216 sysrq_toggle_support(__sysrq_enabled);
217
218 return 0;
219}
220
221#endif
222
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700223static struct ctl_table kern_table[];
224static struct ctl_table vm_table[];
225static struct ctl_table fs_table[];
226static struct ctl_table debug_table[];
227static struct ctl_table dev_table[];
228extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800229#ifdef CONFIG_EPOLL
230extern struct ctl_table epoll_table[];
231#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700232
233#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
234int sysctl_legacy_va_layout;
235#endif
236
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237/* The default sysctl tables: */
238
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800239static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 .procname = "kernel",
242 .mode = 0555,
243 .child = kern_table,
244 },
245 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 .procname = "vm",
247 .mode = 0555,
248 .child = vm_table,
249 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700251 .procname = "fs",
252 .mode = 0555,
253 .child = fs_table,
254 },
255 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 .procname = "debug",
257 .mode = 0555,
258 .child = debug_table,
259 },
260 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 .procname = "dev",
262 .mode = 0555,
263 .child = dev_table,
264 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700265 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266};
267
Ingo Molnar77e54a12007-07-09 18:52:00 +0200268#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100269static int min_sched_granularity_ns = 100000; /* 100 usecs */
270static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
271static int min_wakeup_granularity_ns; /* 0 usecs */
272static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200273#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100274static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
275static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200276#endif /* CONFIG_SMP */
277#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200278
Mel Gorman5e771902010-05-24 14:32:31 -0700279#ifdef CONFIG_COMPACTION
280static int min_extfrag_threshold;
281static int max_extfrag_threshold = 1000;
282#endif
283
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700284static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200285 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200286 .procname = "sched_child_runs_first",
287 .data = &sysctl_sched_child_runs_first,
288 .maxlen = sizeof(unsigned int),
289 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800290 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200291 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200292#ifdef CONFIG_SCHED_DEBUG
293 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100294 .procname = "sched_min_granularity_ns",
295 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200296 .maxlen = sizeof(unsigned int),
297 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800298 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100299 .extra1 = &min_sched_granularity_ns,
300 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200301 },
302 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200303 .procname = "sched_latency_ns",
304 .data = &sysctl_sched_latency,
305 .maxlen = sizeof(unsigned int),
306 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800307 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200308 .extra1 = &min_sched_granularity_ns,
309 .extra2 = &max_sched_granularity_ns,
310 },
311 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200312 .procname = "sched_wakeup_granularity_ns",
313 .data = &sysctl_sched_wakeup_granularity,
314 .maxlen = sizeof(unsigned int),
315 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800316 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200317 .extra1 = &min_wakeup_granularity_ns,
318 .extra2 = &max_wakeup_granularity_ns,
319 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200320#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200321 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100322 .procname = "sched_tunable_scaling",
323 .data = &sysctl_sched_tunable_scaling,
324 .maxlen = sizeof(enum sched_tunable_scaling),
325 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800326 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100327 .extra1 = &min_sched_tunable_scaling,
328 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200329 },
330 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900331 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200332 .data = &sysctl_sched_migration_cost,
333 .maxlen = sizeof(unsigned int),
334 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800335 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200336 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100337 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100338 .procname = "sched_nr_migrate",
339 .data = &sysctl_sched_nr_migrate,
340 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100341 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800342 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100343 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530344 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900345 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200346 .data = &sysctl_sched_time_avg,
347 .maxlen = sizeof(unsigned int),
348 .mode = 0644,
Ethan Zhaofe0034a2017-09-04 13:59:34 +0800349 .proc_handler = proc_dointvec_minmax,
350 .extra1 = &one,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200351 },
352 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900353 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800354 .data = &sysctl_sched_shares_window,
355 .maxlen = sizeof(unsigned int),
356 .mode = 0644,
357 .proc_handler = proc_dointvec,
358 },
Mel Gormancb251762016-02-05 09:08:36 +0000359#ifdef CONFIG_SCHEDSTATS
360 {
361 .procname = "sched_schedstats",
362 .data = NULL,
363 .maxlen = sizeof(unsigned int),
364 .mode = 0644,
365 .proc_handler = sysctl_schedstats,
366 .extra1 = &zero,
367 .extra2 = &one,
368 },
369#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200370#endif /* CONFIG_SMP */
371#ifdef CONFIG_NUMA_BALANCING
372 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200373 .procname = "numa_balancing_scan_delay_ms",
374 .data = &sysctl_numa_balancing_scan_delay,
375 .maxlen = sizeof(unsigned int),
376 .mode = 0644,
377 .proc_handler = proc_dointvec,
378 },
379 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200380 .procname = "numa_balancing_scan_period_min_ms",
381 .data = &sysctl_numa_balancing_scan_period_min,
382 .maxlen = sizeof(unsigned int),
383 .mode = 0644,
384 .proc_handler = proc_dointvec,
385 },
386 {
387 .procname = "numa_balancing_scan_period_max_ms",
388 .data = &sysctl_numa_balancing_scan_period_max,
389 .maxlen = sizeof(unsigned int),
390 .mode = 0644,
391 .proc_handler = proc_dointvec,
392 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200393 {
394 .procname = "numa_balancing_scan_size_mb",
395 .data = &sysctl_numa_balancing_scan_size,
396 .maxlen = sizeof(unsigned int),
397 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400398 .proc_handler = proc_dointvec_minmax,
399 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200400 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100401 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800402 .procname = "numa_balancing",
403 .data = NULL, /* filled in by handler */
404 .maxlen = sizeof(unsigned int),
405 .mode = 0644,
406 .proc_handler = sysctl_numa_balancing,
407 .extra1 = &zero,
408 .extra2 = &one,
409 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200410#endif /* CONFIG_NUMA_BALANCING */
411#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200412 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100413 .procname = "sched_rt_period_us",
414 .data = &sysctl_sched_rt_period,
415 .maxlen = sizeof(unsigned int),
416 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800417 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100418 },
419 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100420 .procname = "sched_rt_runtime_us",
421 .data = &sysctl_sched_rt_runtime,
422 .maxlen = sizeof(int),
423 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800424 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100425 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600426 {
427 .procname = "sched_rr_timeslice_ms",
428 .data = &sched_rr_timeslice,
429 .maxlen = sizeof(int),
430 .mode = 0644,
431 .proc_handler = sched_rr_handler,
432 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100433#ifdef CONFIG_SCHED_AUTOGROUP
434 {
435 .procname = "sched_autogroup_enabled",
436 .data = &sysctl_sched_autogroup_enabled,
437 .maxlen = sizeof(unsigned int),
438 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800439 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100440 .extra1 = &zero,
441 .extra2 = &one,
442 },
443#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700444#ifdef CONFIG_CFS_BANDWIDTH
445 {
446 .procname = "sched_cfs_bandwidth_slice_us",
447 .data = &sysctl_sched_cfs_bandwidth_slice,
448 .maxlen = sizeof(unsigned int),
449 .mode = 0644,
450 .proc_handler = proc_dointvec_minmax,
451 .extra1 = &one,
452 },
453#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700454#ifdef CONFIG_PROVE_LOCKING
455 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700456 .procname = "prove_locking",
457 .data = &prove_locking,
458 .maxlen = sizeof(int),
459 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800460 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700461 },
462#endif
463#ifdef CONFIG_LOCK_STAT
464 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700465 .procname = "lock_stat",
466 .data = &lock_stat,
467 .maxlen = sizeof(int),
468 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800469 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700470 },
471#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200472 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 .procname = "panic",
474 .data = &panic_timeout,
475 .maxlen = sizeof(int),
476 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800477 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 },
Alex Kelly046d6622012-10-04 17:15:23 -0700479#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 .procname = "core_uses_pid",
482 .data = &core_uses_pid,
483 .maxlen = sizeof(int),
484 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800485 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 },
487 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 .procname = "core_pattern",
489 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700490 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700492 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 },
Neil Hormana2939802009-09-23 15:56:56 -0700494 {
Neil Hormana2939802009-09-23 15:56:56 -0700495 .procname = "core_pipe_limit",
496 .data = &core_pipe_limit,
497 .maxlen = sizeof(unsigned int),
498 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800499 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700500 },
Alex Kelly046d6622012-10-04 17:15:23 -0700501#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800502#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700505 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800506 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800507 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700508 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700509 {
510 .procname = "sysctl_writes_strict",
511 .data = &sysctl_writes_strict,
512 .maxlen = sizeof(int),
513 .mode = 0644,
514 .proc_handler = proc_dointvec_minmax,
515 .extra1 = &neg_one,
516 .extra2 = &one,
517 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800518#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100519#ifdef CONFIG_LATENCYTOP
520 {
521 .procname = "latencytop",
522 .data = &latencytop_enabled,
523 .maxlen = sizeof(int),
524 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000525 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100526 },
527#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528#ifdef CONFIG_BLK_DEV_INITRD
529 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 .procname = "real-root-dev",
531 .data = &real_root_dev,
532 .maxlen = sizeof(int),
533 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800534 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 },
536#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700537 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700538 .procname = "print-fatal-signals",
539 .data = &print_fatal_signals,
540 .maxlen = sizeof(int),
541 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800542 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700543 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700544#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 .procname = "reboot-cmd",
547 .data = reboot_command,
548 .maxlen = 256,
549 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800550 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 },
552 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 .procname = "stop-a",
554 .data = &stop_a_enabled,
555 .maxlen = sizeof (int),
556 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800557 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 },
559 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 .procname = "scons-poweroff",
561 .data = &scons_pwroff,
562 .maxlen = sizeof (int),
563 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800564 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 },
566#endif
David S. Miller08714202008-11-16 23:49:24 -0800567#ifdef CONFIG_SPARC64
568 {
David S. Miller08714202008-11-16 23:49:24 -0800569 .procname = "tsb-ratio",
570 .data = &sysctl_tsb_ratio,
571 .maxlen = sizeof (int),
572 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800573 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800574 },
575#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576#ifdef __hppa__
577 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 .procname = "soft-power",
579 .data = &pwrsw_enabled,
580 .maxlen = sizeof (int),
581 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800582 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530584#endif
585#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 .procname = "unaligned-trap",
588 .data = &unaligned_enabled,
589 .maxlen = sizeof (int),
590 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800591 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 },
593#endif
594 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 .procname = "ctrl-alt-del",
596 .data = &C_A_D,
597 .maxlen = sizeof(int),
598 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800599 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400601#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200602 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200603 .procname = "ftrace_enabled",
604 .data = &ftrace_enabled,
605 .maxlen = sizeof(int),
606 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800607 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200608 },
609#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500610#ifdef CONFIG_STACK_TRACER
611 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500612 .procname = "stack_tracer_enabled",
613 .data = &stack_tracer_enabled,
614 .maxlen = sizeof(int),
615 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800616 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500617 },
618#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400619#ifdef CONFIG_TRACING
620 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100621 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400622 .data = &ftrace_dump_on_oops,
623 .maxlen = sizeof(int),
624 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800625 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400626 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400627 {
628 .procname = "traceoff_on_warning",
629 .data = &__disable_trace_on_warning,
630 .maxlen = sizeof(__disable_trace_on_warning),
631 .mode = 0644,
632 .proc_handler = proc_dointvec,
633 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500634 {
635 .procname = "tracepoint_printk",
636 .data = &tracepoint_printk,
637 .maxlen = sizeof(tracepoint_printk),
638 .mode = 0644,
639 .proc_handler = proc_dointvec,
640 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400641#endif
Dave Young2965faa2015-09-09 15:38:55 -0700642#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800643 {
644 .procname = "kexec_load_disabled",
645 .data = &kexec_load_disabled,
646 .maxlen = sizeof(int),
647 .mode = 0644,
648 /* only handle a transition from default "0" to "1" */
649 .proc_handler = proc_dointvec_minmax,
650 .extra1 = &one,
651 .extra2 = &one,
652 },
653#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200654#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 .procname = "modprobe",
657 .data = &modprobe_path,
658 .maxlen = KMOD_PATH_LEN,
659 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800660 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 },
Kees Cook3d433212009-04-02 15:49:29 -0700662 {
Kees Cook3d433212009-04-02 15:49:29 -0700663 .procname = "modules_disabled",
664 .data = &modules_disabled,
665 .maxlen = sizeof(int),
666 .mode = 0644,
667 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800668 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700669 .extra1 = &one,
670 .extra2 = &one,
671 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700673#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100676 .data = &uevent_helper,
677 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800679 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 },
Michael Marineau86d56132014-04-10 14:09:31 -0700681#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682#ifdef CONFIG_CHR_DEV_SG
683 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 .procname = "sg-big-buff",
685 .data = &sg_big_buff,
686 .maxlen = sizeof (int),
687 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800688 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 },
690#endif
691#ifdef CONFIG_BSD_PROCESS_ACCT
692 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 .procname = "acct",
694 .data = &acct_parm,
695 .maxlen = 3*sizeof(int),
696 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800697 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 },
699#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700#ifdef CONFIG_MAGIC_SYSRQ
701 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800703 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 .maxlen = sizeof (int),
705 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700706 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 },
708#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700709#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700712 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 .maxlen = sizeof (int),
714 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800715 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700717#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700720 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 .maxlen = sizeof(int),
722 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700723 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 },
725 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 .procname = "random",
727 .mode = 0555,
728 .child = random_table,
729 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 {
Eric Paris17f60a72011-04-01 17:07:50 -0400731 .procname = "usermodehelper",
732 .mode = 0555,
733 .child = usermodehelper_table,
734 },
735 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 .procname = "overflowuid",
737 .data = &overflowuid,
738 .maxlen = sizeof(int),
739 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800740 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 .extra1 = &minolduid,
742 .extra2 = &maxolduid,
743 },
744 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 .procname = "overflowgid",
746 .data = &overflowgid,
747 .maxlen = sizeof(int),
748 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800749 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 .extra1 = &minolduid,
751 .extra2 = &maxolduid,
752 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800753#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754#ifdef CONFIG_MATHEMU
755 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 .procname = "ieee_emulation_warnings",
757 .data = &sysctl_ieee_emulation_warnings,
758 .maxlen = sizeof(int),
759 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800760 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 },
762#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200765 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 .maxlen = sizeof(int),
767 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800768 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 },
770#endif
771 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 .procname = "pid_max",
773 .data = &pid_max,
774 .maxlen = sizeof (int),
775 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800776 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 .extra1 = &pid_max_min,
778 .extra2 = &pid_max_max,
779 },
780 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 .procname = "panic_on_oops",
782 .data = &panic_on_oops,
783 .maxlen = sizeof(int),
784 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800785 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800787#if defined CONFIG_PRINTK
788 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800789 .procname = "printk",
790 .data = &console_loglevel,
791 .maxlen = 4*sizeof(int),
792 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800793 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800794 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700797 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 .maxlen = sizeof(int),
799 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800800 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 },
802 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700804 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 .maxlen = sizeof(int),
806 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800807 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 },
Dave Youngaf913222009-09-22 16:43:33 -0700809 {
Dave Youngaf913222009-09-22 16:43:33 -0700810 .procname = "printk_delay",
811 .data = &printk_delay_msec,
812 .maxlen = sizeof(int),
813 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800814 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700815 .extra1 = &zero,
816 .extra2 = &ten_thousand,
817 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700819 .procname = "printk_devkmsg",
820 .data = devkmsg_log_str,
821 .maxlen = DEVKMSG_STR_MAX_SIZE,
822 .mode = 0644,
823 .proc_handler = devkmsg_sysctl_set_loglvl,
824 },
825 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800826 .procname = "dmesg_restrict",
827 .data = &dmesg_restrict,
828 .maxlen = sizeof(int),
829 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700830 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800831 .extra1 = &zero,
832 .extra2 = &one,
833 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800834 {
835 .procname = "kptr_restrict",
836 .data = &kptr_restrict,
837 .maxlen = sizeof(int),
838 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700839 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800840 .extra1 = &zero,
841 .extra2 = &two,
842 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800843#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800844 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 .procname = "ngroups_max",
846 .data = &ngroups_max,
847 .maxlen = sizeof (int),
848 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800849 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 },
Dan Ballard73efc032011-10-31 17:11:20 -0700851 {
852 .procname = "cap_last_cap",
853 .data = (void *)&cap_last_cap,
854 .maxlen = sizeof(int),
855 .mode = 0444,
856 .proc_handler = proc_dointvec,
857 },
Don Zickus58687ac2010-05-07 17:11:44 -0400858#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500859 {
Don Zickus58687ac2010-05-07 17:11:44 -0400860 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200861 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500862 .maxlen = sizeof (int),
863 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700864 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700865 .extra1 = &zero,
866 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400867 },
868 {
869 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700870 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400871 .maxlen = sizeof(int),
872 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700873 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800874 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400875 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500876 },
Don Zickus2508ce12010-05-07 17:11:46 -0400877 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700878 .procname = "nmi_watchdog",
879 .data = &nmi_watchdog_enabled,
880 .maxlen = sizeof (int),
881 .mode = 0644,
882 .proc_handler = proc_nmi_watchdog,
883 .extra1 = &zero,
884#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
885 .extra2 = &one,
886#else
887 .extra2 = &zero,
888#endif
889 },
890 {
891 .procname = "soft_watchdog",
892 .data = &soft_watchdog_enabled,
893 .maxlen = sizeof (int),
894 .mode = 0644,
895 .proc_handler = proc_soft_watchdog,
896 .extra1 = &zero,
897 .extra2 = &one,
898 },
899 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700900 .procname = "watchdog_cpumask",
901 .data = &watchdog_cpumask_bits,
902 .maxlen = NR_CPUS,
903 .mode = 0644,
904 .proc_handler = proc_watchdog_cpumask,
905 },
906 {
Don Zickus2508ce12010-05-07 17:11:46 -0400907 .procname = "softlockup_panic",
908 .data = &softlockup_panic,
909 .maxlen = sizeof(int),
910 .mode = 0644,
911 .proc_handler = proc_dointvec_minmax,
912 .extra1 = &zero,
913 .extra2 = &one,
914 },
Don Zickusac1f5912015-11-05 18:44:44 -0800915#ifdef CONFIG_HARDLOCKUP_DETECTOR
916 {
917 .procname = "hardlockup_panic",
918 .data = &hardlockup_panic,
919 .maxlen = sizeof(int),
920 .mode = 0644,
921 .proc_handler = proc_dointvec_minmax,
922 .extra1 = &zero,
923 .extra2 = &one,
924 },
925#endif
Aaron Tomlined235872014-06-23 13:22:05 -0700926#ifdef CONFIG_SMP
927 {
928 .procname = "softlockup_all_cpu_backtrace",
929 .data = &sysctl_softlockup_all_cpu_backtrace,
930 .maxlen = sizeof(int),
931 .mode = 0644,
932 .proc_handler = proc_dointvec_minmax,
933 .extra1 = &zero,
934 .extra2 = &one,
935 },
Jiri Kosina55537872015-11-05 18:44:41 -0800936 {
937 .procname = "hardlockup_all_cpu_backtrace",
938 .data = &sysctl_hardlockup_all_cpu_backtrace,
939 .maxlen = sizeof(int),
940 .mode = 0644,
941 .proc_handler = proc_dointvec_minmax,
942 .extra1 = &zero,
943 .extra2 = &one,
944 },
Aaron Tomlined235872014-06-23 13:22:05 -0700945#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -0500946#endif
947#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
948 {
949 .procname = "unknown_nmi_panic",
950 .data = &unknown_nmi_panic,
951 .maxlen = sizeof (int),
952 .mode = 0644,
953 .proc_handler = proc_dointvec,
954 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500955#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956#if defined(CONFIG_X86)
957 {
Don Zickus8da5add2006-09-26 10:52:27 +0200958 .procname = "panic_on_unrecovered_nmi",
959 .data = &panic_on_unrecovered_nmi,
960 .maxlen = sizeof(int),
961 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800962 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200963 },
964 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700965 .procname = "panic_on_io_nmi",
966 .data = &panic_on_io_nmi,
967 .maxlen = sizeof(int),
968 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800969 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700970 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900971#ifdef CONFIG_DEBUG_STACKOVERFLOW
972 {
973 .procname = "panic_on_stackoverflow",
974 .data = &sysctl_panic_on_stackoverflow,
975 .maxlen = sizeof(int),
976 .mode = 0644,
977 .proc_handler = proc_dointvec,
978 },
979#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700980 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700981 .procname = "bootloader_type",
982 .data = &bootloader_type,
983 .maxlen = sizeof (int),
984 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800985 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100987 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700988 .procname = "bootloader_version",
989 .data = &bootloader_version,
990 .maxlen = sizeof (int),
991 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800992 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700993 },
994 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100995 .procname = "kstack_depth_to_print",
996 .data = &kstack_depth_to_print,
997 .maxlen = sizeof(int),
998 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800999 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001000 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001001 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001002 .procname = "io_delay_type",
1003 .data = &io_delay_type,
1004 .maxlen = sizeof(int),
1005 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001006 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001007 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001008#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001009#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011 .procname = "randomize_va_space",
1012 .data = &randomize_va_space,
1013 .maxlen = sizeof(int),
1014 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001015 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001016 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001017#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001018#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001019 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001020 .procname = "spin_retry",
1021 .data = &spin_retry,
1022 .maxlen = sizeof (int),
1023 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001024 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001025 },
1026#endif
Len Brown673d5b42007-07-28 03:33:16 -04001027#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001028 {
Pavel Machekc255d842006-02-20 18:27:58 -08001029 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001030 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001031 .maxlen = sizeof (unsigned long),
1032 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001033 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001034 },
1035#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301036#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001037 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001038 .procname = "ignore-unaligned-usertrap",
1039 .data = &no_unaligned_warning,
1040 .maxlen = sizeof (int),
1041 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001042 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001043 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301044#endif
1045#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001046 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001047 .procname = "unaligned-dump-stack",
1048 .data = &unaligned_dump_stack,
1049 .maxlen = sizeof (int),
1050 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001051 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001052 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001053#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001054#ifdef CONFIG_DETECT_HUNG_TASK
1055 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001056 .procname = "hung_task_panic",
1057 .data = &sysctl_hung_task_panic,
1058 .maxlen = sizeof(int),
1059 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001060 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001061 .extra1 = &zero,
1062 .extra2 = &one,
1063 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001064 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001065 .procname = "hung_task_check_count",
1066 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001067 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001068 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001069 .proc_handler = proc_dointvec_minmax,
1070 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001071 },
1072 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001073 .procname = "hung_task_timeout_secs",
1074 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001075 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001076 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001077 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001078 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001079 },
1080 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001081 .procname = "hung_task_warnings",
1082 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001083 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001084 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001085 .proc_handler = proc_dointvec_minmax,
1086 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001087 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001088#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001089#ifdef CONFIG_RT_MUTEXES
1090 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001091 .procname = "max_lock_depth",
1092 .data = &max_lock_depth,
1093 .maxlen = sizeof(int),
1094 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001095 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001096 },
1097#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001098 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001099 .procname = "poweroff_cmd",
1100 .data = &poweroff_cmd,
1101 .maxlen = POWEROFF_CMD_PATH_LEN,
1102 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001103 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001104 },
David Howells0b77f5b2008-04-29 01:01:32 -07001105#ifdef CONFIG_KEYS
1106 {
David Howells0b77f5b2008-04-29 01:01:32 -07001107 .procname = "keys",
1108 .mode = 0555,
1109 .child = key_sysctls,
1110 },
1111#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001112#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001113 /*
1114 * User-space scripts rely on the existence of this file
1115 * as a feature check for perf_events being enabled.
1116 *
1117 * So it's an ABI, do not remove!
1118 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001119 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001120 .procname = "perf_event_paranoid",
1121 .data = &sysctl_perf_event_paranoid,
1122 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001123 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001124 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001125 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001126 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001127 .procname = "perf_event_mlock_kb",
1128 .data = &sysctl_perf_event_mlock,
1129 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001130 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001131 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001132 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001133 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001134 .procname = "perf_event_max_sample_rate",
1135 .data = &sysctl_perf_event_sample_rate,
1136 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001137 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001138 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001139 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001140 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001141 {
1142 .procname = "perf_cpu_time_max_percent",
1143 .data = &sysctl_perf_cpu_time_max_percent,
1144 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1145 .mode = 0644,
1146 .proc_handler = perf_cpu_time_max_percent_handler,
1147 .extra1 = &zero,
1148 .extra2 = &one_hundred,
1149 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001150 {
1151 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001152 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001153 .maxlen = sizeof(sysctl_perf_event_max_stack),
1154 .mode = 0644,
1155 .proc_handler = perf_event_max_stack_handler,
1156 .extra1 = &zero,
1157 .extra2 = &six_hundred_forty_kb,
1158 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001159 {
1160 .procname = "perf_event_max_contexts_per_stack",
1161 .data = &sysctl_perf_event_max_contexts_per_stack,
1162 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1163 .mode = 0644,
1164 .proc_handler = perf_event_max_stack_handler,
1165 .extra1 = &zero,
1166 .extra2 = &one_thousand,
1167 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001168#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001169#ifdef CONFIG_KMEMCHECK
1170 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001171 .procname = "kmemcheck",
1172 .data = &kmemcheck_enabled,
1173 .maxlen = sizeof(int),
1174 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001175 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001176 },
1177#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001178 {
1179 .procname = "panic_on_warn",
1180 .data = &panic_on_warn,
1181 .maxlen = sizeof(int),
1182 .mode = 0644,
1183 .proc_handler = proc_dointvec_minmax,
1184 .extra1 = &zero,
1185 .extra2 = &one,
1186 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001187#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1188 {
1189 .procname = "timer_migration",
1190 .data = &sysctl_timer_migration,
1191 .maxlen = sizeof(unsigned int),
1192 .mode = 0644,
1193 .proc_handler = timer_migration_handler,
Myungho Jung4c000152017-04-19 15:24:50 -07001194 .extra1 = &zero,
1195 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001196 },
1197#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001198#ifdef CONFIG_BPF_SYSCALL
1199 {
1200 .procname = "unprivileged_bpf_disabled",
1201 .data = &sysctl_unprivileged_bpf_disabled,
1202 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1203 .mode = 0644,
1204 /* only handle a transition from default "0" to "1" */
1205 .proc_handler = proc_dointvec_minmax,
1206 .extra1 = &one,
1207 .extra2 = &one,
1208 },
1209#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001210#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1211 {
1212 .procname = "panic_on_rcu_stall",
1213 .data = &sysctl_panic_on_rcu_stall,
1214 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1215 .mode = 0644,
1216 .proc_handler = proc_dointvec_minmax,
1217 .extra1 = &zero,
1218 .extra2 = &one,
1219 },
1220#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001221 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001222};
1223
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001224static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001226 .procname = "overcommit_memory",
1227 .data = &sysctl_overcommit_memory,
1228 .maxlen = sizeof(sysctl_overcommit_memory),
1229 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001230 .proc_handler = proc_dointvec_minmax,
1231 .extra1 = &zero,
1232 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001233 },
1234 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001235 .procname = "panic_on_oom",
1236 .data = &sysctl_panic_on_oom,
1237 .maxlen = sizeof(sysctl_panic_on_oom),
1238 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001239 .proc_handler = proc_dointvec_minmax,
1240 .extra1 = &zero,
1241 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001242 },
1243 {
David Rientjesfe071d72007-10-16 23:25:56 -07001244 .procname = "oom_kill_allocating_task",
1245 .data = &sysctl_oom_kill_allocating_task,
1246 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1247 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001248 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001249 },
1250 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001251 .procname = "oom_dump_tasks",
1252 .data = &sysctl_oom_dump_tasks,
1253 .maxlen = sizeof(sysctl_oom_dump_tasks),
1254 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001255 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001256 },
1257 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001258 .procname = "overcommit_ratio",
1259 .data = &sysctl_overcommit_ratio,
1260 .maxlen = sizeof(sysctl_overcommit_ratio),
1261 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001262 .proc_handler = overcommit_ratio_handler,
1263 },
1264 {
1265 .procname = "overcommit_kbytes",
1266 .data = &sysctl_overcommit_kbytes,
1267 .maxlen = sizeof(sysctl_overcommit_kbytes),
1268 .mode = 0644,
1269 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001270 },
1271 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001272 .procname = "page-cluster",
1273 .data = &page_cluster,
1274 .maxlen = sizeof(int),
1275 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001276 .proc_handler = proc_dointvec_minmax,
1277 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001278 },
1279 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 .procname = "dirty_background_ratio",
1281 .data = &dirty_background_ratio,
1282 .maxlen = sizeof(dirty_background_ratio),
1283 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001284 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001285 .extra1 = &zero,
1286 .extra2 = &one_hundred,
1287 },
1288 {
David Rientjes2da02992009-01-06 14:39:31 -08001289 .procname = "dirty_background_bytes",
1290 .data = &dirty_background_bytes,
1291 .maxlen = sizeof(dirty_background_bytes),
1292 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001293 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001294 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001295 },
1296 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297 .procname = "dirty_ratio",
1298 .data = &vm_dirty_ratio,
1299 .maxlen = sizeof(vm_dirty_ratio),
1300 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001301 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001302 .extra1 = &zero,
1303 .extra2 = &one_hundred,
1304 },
1305 {
David Rientjes2da02992009-01-06 14:39:31 -08001306 .procname = "dirty_bytes",
1307 .data = &vm_dirty_bytes,
1308 .maxlen = sizeof(vm_dirty_bytes),
1309 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001310 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001311 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001312 },
1313 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001314 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001315 .data = &dirty_writeback_interval,
1316 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001318 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001319 },
1320 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001321 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001322 .data = &dirty_expire_interval,
1323 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001324 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001325 .proc_handler = proc_dointvec_minmax,
1326 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001327 },
1328 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001329 .procname = "dirtytime_expire_seconds",
1330 .data = &dirtytime_expire_interval,
1331 .maxlen = sizeof(dirty_expire_interval),
1332 .mode = 0644,
1333 .proc_handler = dirtytime_interval_handler,
1334 .extra1 = &zero,
1335 },
1336 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001337 .procname = "nr_pdflush_threads",
1338 .mode = 0444 /* read-only */,
1339 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001340 },
1341 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001342 .procname = "swappiness",
1343 .data = &vm_swappiness,
1344 .maxlen = sizeof(vm_swappiness),
1345 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001346 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001347 .extra1 = &zero,
1348 .extra2 = &one_hundred,
1349 },
1350#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001351 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001352 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001353 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001354 .maxlen = sizeof(unsigned long),
1355 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001356 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001357 },
1358#ifdef CONFIG_NUMA
1359 {
1360 .procname = "nr_hugepages_mempolicy",
1361 .data = NULL,
1362 .maxlen = sizeof(unsigned long),
1363 .mode = 0644,
1364 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001365 },
1366#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001367 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001368 .procname = "hugetlb_shm_group",
1369 .data = &sysctl_hugetlb_shm_group,
1370 .maxlen = sizeof(gid_t),
1371 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001372 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001373 },
Mel Gorman396faf02007-07-17 04:03:13 -07001374 {
Mel Gorman396faf02007-07-17 04:03:13 -07001375 .procname = "hugepages_treat_as_movable",
1376 .data = &hugepages_treat_as_movable,
1377 .maxlen = sizeof(int),
1378 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001379 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001380 },
Adam Litke54f9f802007-10-16 01:26:20 -07001381 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001382 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001383 .data = NULL,
1384 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001385 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001386 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001387 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001388#endif
1389 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390 .procname = "lowmem_reserve_ratio",
1391 .data = &sysctl_lowmem_reserve_ratio,
1392 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1393 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001394 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001395 },
1396 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001397 .procname = "drop_caches",
1398 .data = &sysctl_drop_caches,
1399 .maxlen = sizeof(int),
1400 .mode = 0644,
1401 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001402 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001403 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001404 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001405#ifdef CONFIG_COMPACTION
1406 {
1407 .procname = "compact_memory",
1408 .data = &sysctl_compact_memory,
1409 .maxlen = sizeof(int),
1410 .mode = 0200,
1411 .proc_handler = sysctl_compaction_handler,
1412 },
Mel Gorman5e771902010-05-24 14:32:31 -07001413 {
1414 .procname = "extfrag_threshold",
1415 .data = &sysctl_extfrag_threshold,
1416 .maxlen = sizeof(int),
1417 .mode = 0644,
1418 .proc_handler = sysctl_extfrag_handler,
1419 .extra1 = &min_extfrag_threshold,
1420 .extra2 = &max_extfrag_threshold,
1421 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001422 {
1423 .procname = "compact_unevictable_allowed",
1424 .data = &sysctl_compact_unevictable_allowed,
1425 .maxlen = sizeof(int),
1426 .mode = 0644,
1427 .proc_handler = proc_dointvec,
1428 .extra1 = &zero,
1429 .extra2 = &one,
1430 },
Mel Gorman5e771902010-05-24 14:32:31 -07001431
Mel Gorman76ab0f52010-05-24 14:32:28 -07001432#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001433 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001434 .procname = "min_free_kbytes",
1435 .data = &min_free_kbytes,
1436 .maxlen = sizeof(min_free_kbytes),
1437 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001438 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439 .extra1 = &zero,
1440 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001441 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001442 .procname = "watermark_scale_factor",
1443 .data = &watermark_scale_factor,
1444 .maxlen = sizeof(watermark_scale_factor),
1445 .mode = 0644,
1446 .proc_handler = watermark_scale_factor_sysctl_handler,
1447 .extra1 = &one,
1448 .extra2 = &one_thousand,
1449 },
1450 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001451 .procname = "percpu_pagelist_fraction",
1452 .data = &percpu_pagelist_fraction,
1453 .maxlen = sizeof(percpu_pagelist_fraction),
1454 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001455 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001456 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001457 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001458#ifdef CONFIG_MMU
1459 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001460 .procname = "max_map_count",
1461 .data = &sysctl_max_map_count,
1462 .maxlen = sizeof(sysctl_max_map_count),
1463 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001464 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001465 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001466 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001467#else
1468 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001469 .procname = "nr_trim_pages",
1470 .data = &sysctl_nr_trim_pages,
1471 .maxlen = sizeof(sysctl_nr_trim_pages),
1472 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001473 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001474 .extra1 = &zero,
1475 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476#endif
1477 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001478 .procname = "laptop_mode",
1479 .data = &laptop_mode,
1480 .maxlen = sizeof(laptop_mode),
1481 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001482 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483 },
1484 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001485 .procname = "block_dump",
1486 .data = &block_dump,
1487 .maxlen = sizeof(block_dump),
1488 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001489 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 .extra1 = &zero,
1491 },
1492 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493 .procname = "vfs_cache_pressure",
1494 .data = &sysctl_vfs_cache_pressure,
1495 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1496 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001497 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498 .extra1 = &zero,
1499 },
1500#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1501 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001502 .procname = "legacy_va_layout",
1503 .data = &sysctl_legacy_va_layout,
1504 .maxlen = sizeof(sysctl_legacy_va_layout),
1505 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001506 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001507 .extra1 = &zero,
1508 },
1509#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001510#ifdef CONFIG_NUMA
1511 {
Christoph Lameter17436602006-01-18 17:42:32 -08001512 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001513 .data = &node_reclaim_mode,
1514 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001515 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001516 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001517 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001518 },
Christoph Lameter96146342006-07-03 00:24:13 -07001519 {
Christoph Lameter96146342006-07-03 00:24:13 -07001520 .procname = "min_unmapped_ratio",
1521 .data = &sysctl_min_unmapped_ratio,
1522 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1523 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001524 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001525 .extra1 = &zero,
1526 .extra2 = &one_hundred,
1527 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001528 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001529 .procname = "min_slab_ratio",
1530 .data = &sysctl_min_slab_ratio,
1531 .maxlen = sizeof(sysctl_min_slab_ratio),
1532 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001533 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001534 .extra1 = &zero,
1535 .extra2 = &one_hundred,
1536 },
Christoph Lameter17436602006-01-18 17:42:32 -08001537#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001538#ifdef CONFIG_SMP
1539 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001540 .procname = "stat_interval",
1541 .data = &sysctl_stat_interval,
1542 .maxlen = sizeof(sysctl_stat_interval),
1543 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001544 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001545 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001546 {
1547 .procname = "stat_refresh",
1548 .data = NULL,
1549 .maxlen = 0,
1550 .mode = 0600,
1551 .proc_handler = vmstat_refresh,
1552 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001553#endif
David Howells6e141542009-12-15 19:27:45 +00001554#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001555 {
Eric Parised032182007-06-28 15:55:21 -04001556 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001557 .data = &dac_mmap_min_addr,
1558 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001559 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001560 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001561 },
David Howells6e141542009-12-15 19:27:45 +00001562#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001563#ifdef CONFIG_NUMA
1564 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001565 .procname = "numa_zonelist_order",
1566 .data = &numa_zonelist_order,
1567 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1568 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001569 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001570 },
1571#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001572#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001573 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001574 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001575 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001576#ifdef CONFIG_X86_32
1577 .data = &vdso32_enabled,
1578 .maxlen = sizeof(vdso32_enabled),
1579#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001580 .data = &vdso_enabled,
1581 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001582#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001583 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001584 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001585 .extra1 = &zero,
1586 },
1587#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001588#ifdef CONFIG_HIGHMEM
1589 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001590 .procname = "highmem_is_dirtyable",
1591 .data = &vm_highmem_is_dirtyable,
1592 .maxlen = sizeof(vm_highmem_is_dirtyable),
1593 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001594 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001595 .extra1 = &zero,
1596 .extra2 = &one,
1597 },
1598#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001599#ifdef CONFIG_MEMORY_FAILURE
1600 {
Andi Kleen6a460792009-09-16 11:50:15 +02001601 .procname = "memory_failure_early_kill",
1602 .data = &sysctl_memory_failure_early_kill,
1603 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1604 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001605 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001606 .extra1 = &zero,
1607 .extra2 = &one,
1608 },
1609 {
Andi Kleen6a460792009-09-16 11:50:15 +02001610 .procname = "memory_failure_recovery",
1611 .data = &sysctl_memory_failure_recovery,
1612 .maxlen = sizeof(sysctl_memory_failure_recovery),
1613 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001614 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001615 .extra1 = &zero,
1616 .extra2 = &one,
1617 },
1618#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001619 {
1620 .procname = "user_reserve_kbytes",
1621 .data = &sysctl_user_reserve_kbytes,
1622 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1623 .mode = 0644,
1624 .proc_handler = proc_doulongvec_minmax,
1625 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001626 {
1627 .procname = "admin_reserve_kbytes",
1628 .data = &sysctl_admin_reserve_kbytes,
1629 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1630 .mode = 0644,
1631 .proc_handler = proc_doulongvec_minmax,
1632 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001633#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1634 {
1635 .procname = "mmap_rnd_bits",
1636 .data = &mmap_rnd_bits,
1637 .maxlen = sizeof(mmap_rnd_bits),
1638 .mode = 0600,
1639 .proc_handler = proc_dointvec_minmax,
1640 .extra1 = (void *)&mmap_rnd_bits_min,
1641 .extra2 = (void *)&mmap_rnd_bits_max,
1642 },
1643#endif
1644#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1645 {
1646 .procname = "mmap_rnd_compat_bits",
1647 .data = &mmap_rnd_compat_bits,
1648 .maxlen = sizeof(mmap_rnd_compat_bits),
1649 .mode = 0600,
1650 .proc_handler = proc_dointvec_minmax,
1651 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1652 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1653 },
1654#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001655 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001656};
1657
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001658static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001659 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001660 .procname = "inode-nr",
1661 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001662 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001663 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001664 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001665 },
1666 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001667 .procname = "inode-state",
1668 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001669 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001670 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001671 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001672 },
1673 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001674 .procname = "file-nr",
1675 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001676 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001678 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001679 },
1680 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001681 .procname = "file-max",
1682 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001683 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001684 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001685 .proc_handler = proc_doulongvec_minmax,
Christian Brauner6b65c262019-03-07 16:29:43 -08001686 .extra1 = &zero,
1687 .extra2 = &long_max,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001688 },
1689 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001690 .procname = "nr_open",
1691 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001692 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001693 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001694 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001695 .extra1 = &sysctl_nr_open_min,
1696 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001697 },
1698 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001699 .procname = "dentry-state",
1700 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001701 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001702 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001703 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001704 },
1705 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001706 .procname = "overflowuid",
1707 .data = &fs_overflowuid,
1708 .maxlen = sizeof(int),
1709 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001710 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001711 .extra1 = &minolduid,
1712 .extra2 = &maxolduid,
1713 },
1714 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001715 .procname = "overflowgid",
1716 .data = &fs_overflowgid,
1717 .maxlen = sizeof(int),
1718 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001719 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001720 .extra1 = &minolduid,
1721 .extra2 = &maxolduid,
1722 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001723#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001724 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001725 .procname = "leases-enable",
1726 .data = &leases_enable,
1727 .maxlen = sizeof(int),
1728 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001729 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001730 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001731#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001732#ifdef CONFIG_DNOTIFY
1733 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001734 .procname = "dir-notify-enable",
1735 .data = &dir_notify_enable,
1736 .maxlen = sizeof(int),
1737 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001738 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001739 },
1740#endif
1741#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001742#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001743 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001744 .procname = "lease-break-time",
1745 .data = &lease_break_time,
1746 .maxlen = sizeof(int),
1747 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001748 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001749 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001750#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001751#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001752 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001753 .procname = "aio-nr",
1754 .data = &aio_nr,
1755 .maxlen = sizeof(aio_nr),
1756 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001757 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001758 },
1759 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001760 .procname = "aio-max-nr",
1761 .data = &aio_max_nr,
1762 .maxlen = sizeof(aio_max_nr),
1763 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001764 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001765 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001766#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001767#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001768 {
Robert Love0399cb02005-07-13 12:38:18 -04001769 .procname = "inotify",
1770 .mode = 0555,
1771 .child = inotify_table,
1772 },
1773#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001774#ifdef CONFIG_EPOLL
1775 {
1776 .procname = "epoll",
1777 .mode = 0555,
1778 .child = epoll_table,
1779 },
1780#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001781#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001782 {
Kees Cook800179c2012-07-25 17:29:07 -07001783 .procname = "protected_symlinks",
1784 .data = &sysctl_protected_symlinks,
1785 .maxlen = sizeof(int),
1786 .mode = 0600,
1787 .proc_handler = proc_dointvec_minmax,
1788 .extra1 = &zero,
1789 .extra2 = &one,
1790 },
1791 {
1792 .procname = "protected_hardlinks",
1793 .data = &sysctl_protected_hardlinks,
1794 .maxlen = sizeof(int),
1795 .mode = 0600,
1796 .proc_handler = proc_dointvec_minmax,
1797 .extra1 = &zero,
1798 .extra2 = &one,
1799 },
1800 {
Salvatore Mesoraca0c41bee2018-08-23 17:00:35 -07001801 .procname = "protected_fifos",
1802 .data = &sysctl_protected_fifos,
1803 .maxlen = sizeof(int),
1804 .mode = 0600,
1805 .proc_handler = proc_dointvec_minmax,
1806 .extra1 = &zero,
1807 .extra2 = &two,
1808 },
1809 {
1810 .procname = "protected_regular",
1811 .data = &sysctl_protected_regular,
1812 .maxlen = sizeof(int),
1813 .mode = 0600,
1814 .proc_handler = proc_dointvec_minmax,
1815 .extra1 = &zero,
1816 .extra2 = &two,
1817 },
1818 {
Alan Coxd6e71142005-06-23 00:09:43 -07001819 .procname = "suid_dumpable",
1820 .data = &suid_dumpable,
1821 .maxlen = sizeof(int),
1822 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001823 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001824 .extra1 = &zero,
1825 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001826 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001827#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1828 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001829 .procname = "binfmt_misc",
1830 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001831 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001832 },
1833#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001834 {
Jens Axboeff9da692010-06-03 14:54:39 +02001835 .procname = "pipe-max-size",
1836 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001837 .maxlen = sizeof(int),
1838 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001839 .proc_handler = &pipe_proc_fn,
1840 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001841 },
Willy Tarreau759c0112016-01-18 16:36:09 +01001842 {
1843 .procname = "pipe-user-pages-hard",
1844 .data = &pipe_user_pages_hard,
1845 .maxlen = sizeof(pipe_user_pages_hard),
1846 .mode = 0644,
1847 .proc_handler = proc_doulongvec_minmax,
1848 },
1849 {
1850 .procname = "pipe-user-pages-soft",
1851 .data = &pipe_user_pages_soft,
1852 .maxlen = sizeof(pipe_user_pages_soft),
1853 .mode = 0644,
1854 .proc_handler = proc_doulongvec_minmax,
1855 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05001856 {
1857 .procname = "mount-max",
1858 .data = &sysctl_mount_max,
1859 .maxlen = sizeof(unsigned int),
1860 .mode = 0644,
1861 .proc_handler = proc_dointvec_minmax,
1862 .extra1 = &one,
1863 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001864 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001865};
1866
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001867static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001868#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001869 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001870 .procname = "exception-trace",
1871 .data = &show_unhandled_signals,
1872 .maxlen = sizeof(int),
1873 .mode = 0644,
1874 .proc_handler = proc_dointvec
1875 },
1876#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001877#if defined(CONFIG_OPTPROBES)
1878 {
1879 .procname = "kprobes-optimization",
1880 .data = &sysctl_kprobes_optimization,
1881 .maxlen = sizeof(int),
1882 .mode = 0644,
1883 .proc_handler = proc_kprobes_optimization_handler,
1884 .extra1 = &zero,
1885 .extra2 = &one,
1886 },
1887#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001888 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001889};
1890
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001891static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001892 { }
Robert Love0eeca282005-07-12 17:06:03 -04001893};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001894
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001895int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001896{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001897 struct ctl_table_header *hdr;
1898
1899 hdr = register_sysctl_table(sysctl_base_table);
1900 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001901 return 0;
1902}
1903
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001904#endif /* CONFIG_SYSCTL */
1905
Linus Torvalds1da177e2005-04-16 15:20:36 -07001906/*
1907 * /proc/sys support
1908 */
1909
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001910#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001911
Kees Cookf8808302014-06-06 14:37:17 -07001912static int _proc_do_string(char *data, int maxlen, int write,
1913 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001914 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001915{
1916 size_t len;
1917 char __user *p;
1918 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001919
1920 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001921 *lenp = 0;
1922 return 0;
1923 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001924
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001925 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001926 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1927 /* Only continue writes not past the end of buffer. */
1928 len = strlen(data);
1929 if (len > maxlen - 1)
1930 len = maxlen - 1;
1931
1932 if (*ppos > len)
1933 return 0;
1934 len = *ppos;
1935 } else {
1936 /* Start writing from beginning of buffer. */
1937 len = 0;
1938 }
1939
Kees Cook2ca9bb42014-06-06 14:37:18 -07001940 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001941 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001942 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001943 if (get_user(c, p++))
1944 return -EFAULT;
1945 if (c == 0 || c == '\n')
1946 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001947 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001948 }
Kees Cookf8808302014-06-06 14:37:17 -07001949 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001950 } else {
1951 len = strlen(data);
1952 if (len > maxlen)
1953 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001954
1955 if (*ppos > len) {
1956 *lenp = 0;
1957 return 0;
1958 }
1959
1960 data += *ppos;
1961 len -= *ppos;
1962
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001963 if (len > *lenp)
1964 len = *lenp;
1965 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001966 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001967 return -EFAULT;
1968 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001969 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001970 return -EFAULT;
1971 len++;
1972 }
1973 *lenp = len;
1974 *ppos += len;
1975 }
1976 return 0;
1977}
1978
Kees Cookf4aacea2014-06-06 14:37:19 -07001979static void warn_sysctl_write(struct ctl_table *table)
1980{
1981 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1982 "This will not be supported in the future. To silence this\n"
1983 "warning, set kernel.sysctl_writes_strict = -1\n",
1984 current->comm, table->procname);
1985}
1986
Linus Torvalds1da177e2005-04-16 15:20:36 -07001987/**
1988 * proc_dostring - read a string sysctl
1989 * @table: the sysctl table
1990 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001991 * @buffer: the user buffer
1992 * @lenp: the size of the user buffer
1993 * @ppos: file position
1994 *
1995 * Reads/writes a string from/to the user buffer. If the kernel
1996 * buffer provided is not large enough to hold the string, the
1997 * string is truncated. The copied string is %NULL-terminated.
1998 * If the string is being read by the user process, it is copied
1999 * and a newline '\n' is added. It is truncated if the buffer is
2000 * not large enough.
2001 *
2002 * Returns 0 on success.
2003 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002004int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002005 void __user *buffer, size_t *lenp, loff_t *ppos)
2006{
Kees Cookf4aacea2014-06-06 14:37:19 -07002007 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2008 warn_sysctl_write(table);
2009
Kees Cookf8808302014-06-06 14:37:17 -07002010 return _proc_do_string((char *)(table->data), table->maxlen, write,
2011 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002012}
2013
Amerigo Wang00b7c332010-05-05 00:26:45 +00002014static size_t proc_skip_spaces(char **buf)
2015{
2016 size_t ret;
2017 char *tmp = skip_spaces(*buf);
2018 ret = tmp - *buf;
2019 *buf = tmp;
2020 return ret;
2021}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002022
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002023static void proc_skip_char(char **buf, size_t *size, const char v)
2024{
2025 while (*size) {
2026 if (**buf != v)
2027 break;
2028 (*size)--;
2029 (*buf)++;
2030 }
2031}
2032
Amerigo Wang00b7c332010-05-05 00:26:45 +00002033#define TMPBUFLEN 22
2034/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002035 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002036 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002037 * @buf: a kernel buffer
2038 * @size: size of the kernel buffer
2039 * @val: this is where the number will be stored
2040 * @neg: set to %TRUE if number is negative
2041 * @perm_tr: a vector which contains the allowed trailers
2042 * @perm_tr_len: size of the perm_tr vector
2043 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002044 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002045 * In case of success %0 is returned and @buf and @size are updated with
2046 * the amount of bytes read. If @tr is non-NULL and a trailing
2047 * character exists (size is non-zero after returning from this
2048 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002049 */
2050static int proc_get_long(char **buf, size_t *size,
2051 unsigned long *val, bool *neg,
2052 const char *perm_tr, unsigned perm_tr_len, char *tr)
2053{
2054 int len;
2055 char *p, tmp[TMPBUFLEN];
2056
2057 if (!*size)
2058 return -EINVAL;
2059
2060 len = *size;
2061 if (len > TMPBUFLEN - 1)
2062 len = TMPBUFLEN - 1;
2063
2064 memcpy(tmp, *buf, len);
2065
2066 tmp[len] = 0;
2067 p = tmp;
2068 if (*p == '-' && *size > 1) {
2069 *neg = true;
2070 p++;
2071 } else
2072 *neg = false;
2073 if (!isdigit(*p))
2074 return -EINVAL;
2075
2076 *val = simple_strtoul(p, &p, 0);
2077
2078 len = p - tmp;
2079
2080 /* We don't know if the next char is whitespace thus we may accept
2081 * invalid integers (e.g. 1234...a) or two integers instead of one
2082 * (e.g. 123...1). So lets not allow such large numbers. */
2083 if (len == TMPBUFLEN - 1)
2084 return -EINVAL;
2085
2086 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2087 return -EINVAL;
2088
2089 if (tr && (len < *size))
2090 *tr = *p;
2091
2092 *buf += len;
2093 *size -= len;
2094
2095 return 0;
2096}
2097
2098/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002099 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002100 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002101 * @buf: the user buffer
2102 * @size: the size of the user buffer
2103 * @val: the integer to be converted
2104 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002105 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002106 * In case of success %0 is returned and @buf and @size are updated with
2107 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002108 */
2109static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2110 bool neg)
2111{
2112 int len;
2113 char tmp[TMPBUFLEN], *p = tmp;
2114
2115 sprintf(p, "%s%lu", neg ? "-" : "", val);
2116 len = strlen(tmp);
2117 if (len > *size)
2118 len = *size;
2119 if (copy_to_user(*buf, tmp, len))
2120 return -EFAULT;
2121 *size -= len;
2122 *buf += len;
2123 return 0;
2124}
2125#undef TMPBUFLEN
2126
2127static int proc_put_char(void __user **buf, size_t *size, char c)
2128{
2129 if (*size) {
2130 char __user **buffer = (char __user **)buf;
2131 if (put_user(c, *buffer))
2132 return -EFAULT;
2133 (*size)--, (*buffer)++;
2134 *buf = *buffer;
2135 }
2136 return 0;
2137}
2138
2139static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002140 int *valp,
2141 int write, void *data)
2142{
2143 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002144 if (*negp) {
2145 if (*lvalp > (unsigned long) INT_MAX + 1)
2146 return -EINVAL;
2147 *valp = -*lvalp;
2148 } else {
2149 if (*lvalp > (unsigned long) INT_MAX)
2150 return -EINVAL;
2151 *valp = *lvalp;
2152 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002153 } else {
2154 int val = *valp;
2155 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002156 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002157 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002158 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002159 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002160 *lvalp = (unsigned long)val;
2161 }
2162 }
2163 return 0;
2164}
2165
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002166static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2167 int *valp,
2168 int write, void *data)
2169{
2170 if (write) {
2171 if (*negp)
2172 return -EINVAL;
Liping Zhang7bdacd32017-04-07 23:51:07 +08002173 if (*lvalp > UINT_MAX)
2174 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002175 *valp = *lvalp;
2176 } else {
2177 unsigned int val = *valp;
Liping Zhang3a20c572017-04-07 23:51:06 +08002178 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002179 *lvalp = (unsigned long)val;
2180 }
2181 return 0;
2182}
2183
Amerigo Wang00b7c332010-05-05 00:26:45 +00002184static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2185
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002186static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002187 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002188 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002189 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002190 int write, void *data),
2191 void *data)
2192{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002193 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002194 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002195 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002196
Amerigo Wang00b7c332010-05-05 00:26:45 +00002197 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002198 *lenp = 0;
2199 return 0;
2200 }
2201
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002202 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002203 vleft = table->maxlen / sizeof(*i);
2204 left = *lenp;
2205
2206 if (!conv)
2207 conv = do_proc_dointvec_conv;
2208
Linus Torvalds1da177e2005-04-16 15:20:36 -07002209 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002210 if (*ppos) {
2211 switch (sysctl_writes_strict) {
2212 case SYSCTL_WRITES_STRICT:
2213 goto out;
2214 case SYSCTL_WRITES_WARN:
2215 warn_sysctl_write(table);
2216 break;
2217 default:
2218 break;
2219 }
2220 }
2221
Amerigo Wang00b7c332010-05-05 00:26:45 +00002222 if (left > PAGE_SIZE - 1)
2223 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002224 p = kbuf = memdup_user_nul(buffer, left);
2225 if (IS_ERR(kbuf))
2226 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002227 }
2228
2229 for (; left && vleft--; i++, first=0) {
2230 unsigned long lval;
2231 bool neg;
2232
2233 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002234 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002235
J. R. Okajima563b0462010-05-25 16:10:14 -07002236 if (!left)
2237 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002238 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002239 proc_wspace_sep,
2240 sizeof(proc_wspace_sep), NULL);
2241 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002242 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002243 if (conv(&neg, &lval, i, 1, data)) {
2244 err = -EINVAL;
2245 break;
2246 }
2247 } else {
2248 if (conv(&neg, &lval, i, 0, data)) {
2249 err = -EINVAL;
2250 break;
2251 }
2252 if (!first)
2253 err = proc_put_char(&buffer, &left, '\t');
2254 if (err)
2255 break;
2256 err = proc_put_long(&buffer, &left, lval, neg);
2257 if (err)
2258 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002259 }
2260 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002261
2262 if (!write && !first && left && !err)
2263 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002264 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002265 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002266 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002267 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002268 if (first)
2269 return err ? : -EINVAL;
2270 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002271 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002272out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002273 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002274 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275}
2276
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002277static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002278 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002279 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002280 int write, void *data),
2281 void *data)
2282{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002283 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002284 buffer, lenp, ppos, conv, data);
2285}
2286
Linus Torvalds1da177e2005-04-16 15:20:36 -07002287/**
2288 * proc_dointvec - read a vector of integers
2289 * @table: the sysctl table
2290 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002291 * @buffer: the user buffer
2292 * @lenp: the size of the user buffer
2293 * @ppos: file position
2294 *
2295 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2296 * values from/to the user buffer, treated as an ASCII string.
2297 *
2298 * Returns 0 on success.
2299 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002300int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002301 void __user *buffer, size_t *lenp, loff_t *ppos)
2302{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002303 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2304}
2305
2306/**
2307 * proc_douintvec - read a vector of unsigned integers
2308 * @table: the sysctl table
2309 * @write: %TRUE if this is a write to the sysctl file
2310 * @buffer: the user buffer
2311 * @lenp: the size of the user buffer
2312 * @ppos: file position
2313 *
2314 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2315 * values from/to the user buffer, treated as an ASCII string.
2316 *
2317 * Returns 0 on success.
2318 */
2319int proc_douintvec(struct ctl_table *table, int write,
2320 void __user *buffer, size_t *lenp, loff_t *ppos)
2321{
2322 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2323 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002324}
2325
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002326/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002327 * Taint values can only be increased
2328 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002329 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002330static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002331 void __user *buffer, size_t *lenp, loff_t *ppos)
2332{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002333 struct ctl_table t;
2334 unsigned long tmptaint = get_taint();
2335 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002336
Bastian Blank91fcd412007-04-23 14:41:14 -07002337 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002338 return -EPERM;
2339
Andi Kleen25ddbb12008-10-15 22:01:41 -07002340 t = *table;
2341 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002342 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002343 if (err < 0)
2344 return err;
2345
2346 if (write) {
2347 /*
2348 * Poor man's atomic or. Not worth adding a primitive
2349 * to everyone's atomic.h for this
2350 */
2351 int i;
2352 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2353 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302354 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002355 }
2356 }
2357
2358 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002359}
2360
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002361#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002362static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002363 void __user *buffer, size_t *lenp, loff_t *ppos)
2364{
2365 if (write && !capable(CAP_SYS_ADMIN))
2366 return -EPERM;
2367
2368 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2369}
2370#endif
2371
Linus Torvalds1da177e2005-04-16 15:20:36 -07002372struct do_proc_dointvec_minmax_conv_param {
2373 int *min;
2374 int *max;
2375};
2376
Amerigo Wang00b7c332010-05-05 00:26:45 +00002377static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2378 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002379 int write, void *data)
2380{
2381 struct do_proc_dointvec_minmax_conv_param *param = data;
2382 if (write) {
Zev Weiss45a67f12019-03-11 23:28:02 -07002383 int val;
2384 if (*negp) {
2385 if (*lvalp > (unsigned long) INT_MAX + 1)
2386 return -EINVAL;
2387 val = -*lvalp;
2388 } else {
2389 if (*lvalp > (unsigned long) INT_MAX)
2390 return -EINVAL;
2391 val = *lvalp;
2392 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002393 if ((param->min && *param->min > val) ||
2394 (param->max && *param->max < val))
2395 return -EINVAL;
2396 *valp = val;
2397 } else {
2398 int val = *valp;
2399 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002400 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002401 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002402 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002403 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002404 *lvalp = (unsigned long)val;
2405 }
2406 }
2407 return 0;
2408}
2409
2410/**
2411 * proc_dointvec_minmax - read a vector of integers with min/max values
2412 * @table: the sysctl table
2413 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002414 * @buffer: the user buffer
2415 * @lenp: the size of the user buffer
2416 * @ppos: file position
2417 *
2418 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2419 * values from/to the user buffer, treated as an ASCII string.
2420 *
2421 * This routine will ensure the values are within the range specified by
2422 * table->extra1 (min) and table->extra2 (max).
2423 *
2424 * Returns 0 on success.
2425 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002426int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002427 void __user *buffer, size_t *lenp, loff_t *ppos)
2428{
2429 struct do_proc_dointvec_minmax_conv_param param = {
2430 .min = (int *) table->extra1,
2431 .max = (int *) table->extra2,
2432 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002433 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002434 do_proc_dointvec_minmax_conv, &param);
2435}
2436
Kees Cook54b50192012-07-30 14:39:18 -07002437static void validate_coredump_safety(void)
2438{
Alex Kelly046d6622012-10-04 17:15:23 -07002439#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002440 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002441 core_pattern[0] != '/' && core_pattern[0] != '|') {
2442 printk(KERN_WARNING "Unsafe core_pattern used with "\
2443 "suid_dumpable=2. Pipe handler or fully qualified "\
2444 "core dump path required.\n");
2445 }
Alex Kelly046d6622012-10-04 17:15:23 -07002446#endif
Kees Cook54b50192012-07-30 14:39:18 -07002447}
2448
2449static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2450 void __user *buffer, size_t *lenp, loff_t *ppos)
2451{
2452 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2453 if (!error)
2454 validate_coredump_safety();
2455 return error;
2456}
2457
Alex Kelly046d6622012-10-04 17:15:23 -07002458#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002459static int proc_dostring_coredump(struct ctl_table *table, int write,
2460 void __user *buffer, size_t *lenp, loff_t *ppos)
2461{
2462 int error = proc_dostring(table, write, buffer, lenp, ppos);
2463 if (!error)
2464 validate_coredump_safety();
2465 return error;
2466}
Alex Kelly046d6622012-10-04 17:15:23 -07002467#endif
Kees Cook54b50192012-07-30 14:39:18 -07002468
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002469static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002470 void __user *buffer,
2471 size_t *lenp, loff_t *ppos,
2472 unsigned long convmul,
2473 unsigned long convdiv)
2474{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002475 unsigned long *i, *min, *max;
2476 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002477 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002478 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002479
2480 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002481 *lenp = 0;
2482 return 0;
2483 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002484
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002485 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002486 min = (unsigned long *) table->extra1;
2487 max = (unsigned long *) table->extra2;
2488 vleft = table->maxlen / sizeof(unsigned long);
2489 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002490
2491 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002492 if (*ppos) {
2493 switch (sysctl_writes_strict) {
2494 case SYSCTL_WRITES_STRICT:
2495 goto out;
2496 case SYSCTL_WRITES_WARN:
2497 warn_sysctl_write(table);
2498 break;
2499 default:
2500 break;
2501 }
2502 }
2503
Amerigo Wang00b7c332010-05-05 00:26:45 +00002504 if (left > PAGE_SIZE - 1)
2505 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002506 p = kbuf = memdup_user_nul(buffer, left);
2507 if (IS_ERR(kbuf))
2508 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002509 }
2510
Eric Dumazet27b3d802010-10-07 12:59:29 -07002511 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002512 unsigned long val;
2513
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002515 bool neg;
2516
Al Viro70f6cbb2015-12-24 00:13:10 -05002517 left -= proc_skip_spaces(&p);
Cheng Lin0e5c7502019-01-03 15:26:13 -08002518 if (!left)
2519 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002520
Al Viro70f6cbb2015-12-24 00:13:10 -05002521 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002522 proc_wspace_sep,
2523 sizeof(proc_wspace_sep), NULL);
2524 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002525 break;
2526 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002527 continue;
Eric Dumazet03707d62017-01-25 18:20:55 -08002528 val = convmul * val / convdiv;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002529 if ((min && val < *min) || (max && val > *max))
2530 continue;
2531 *i = val;
2532 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002533 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002534 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002535 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002536 if (err)
2537 break;
2538 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002539 err = proc_put_long(&buffer, &left, val, false);
2540 if (err)
2541 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002542 }
2543 }
2544
Amerigo Wang00b7c332010-05-05 00:26:45 +00002545 if (!write && !first && left && !err)
2546 err = proc_put_char(&buffer, &left, '\n');
2547 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002548 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002549 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002550 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002551 if (first)
2552 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002553 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002554 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002555out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002556 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002557 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002558}
2559
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002560static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002561 void __user *buffer,
2562 size_t *lenp, loff_t *ppos,
2563 unsigned long convmul,
2564 unsigned long convdiv)
2565{
2566 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002567 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002568}
2569
Linus Torvalds1da177e2005-04-16 15:20:36 -07002570/**
2571 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2572 * @table: the sysctl table
2573 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002574 * @buffer: the user buffer
2575 * @lenp: the size of the user buffer
2576 * @ppos: file position
2577 *
2578 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2579 * values from/to the user buffer, treated as an ASCII string.
2580 *
2581 * This routine will ensure the values are within the range specified by
2582 * table->extra1 (min) and table->extra2 (max).
2583 *
2584 * Returns 0 on success.
2585 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002586int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002587 void __user *buffer, size_t *lenp, loff_t *ppos)
2588{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002589 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002590}
2591
2592/**
2593 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2594 * @table: the sysctl table
2595 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002596 * @buffer: the user buffer
2597 * @lenp: the size of the user buffer
2598 * @ppos: file position
2599 *
2600 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2601 * values from/to the user buffer, treated as an ASCII string. The values
2602 * are treated as milliseconds, and converted to jiffies when they are stored.
2603 *
2604 * This routine will ensure the values are within the range specified by
2605 * table->extra1 (min) and table->extra2 (max).
2606 *
2607 * Returns 0 on success.
2608 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002609int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002610 void __user *buffer,
2611 size_t *lenp, loff_t *ppos)
2612{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002613 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002614 lenp, ppos, HZ, 1000l);
2615}
2616
2617
Amerigo Wang00b7c332010-05-05 00:26:45 +00002618static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002619 int *valp,
2620 int write, void *data)
2621{
2622 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002623 if (*lvalp > LONG_MAX / HZ)
2624 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002625 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2626 } else {
2627 int val = *valp;
2628 unsigned long lval;
2629 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002630 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002631 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002632 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002633 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002634 lval = (unsigned long)val;
2635 }
2636 *lvalp = lval / HZ;
2637 }
2638 return 0;
2639}
2640
Amerigo Wang00b7c332010-05-05 00:26:45 +00002641static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002642 int *valp,
2643 int write, void *data)
2644{
2645 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002646 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2647 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002648 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2649 } else {
2650 int val = *valp;
2651 unsigned long lval;
2652 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002653 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002654 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002655 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002656 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002657 lval = (unsigned long)val;
2658 }
2659 *lvalp = jiffies_to_clock_t(lval);
2660 }
2661 return 0;
2662}
2663
Amerigo Wang00b7c332010-05-05 00:26:45 +00002664static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002665 int *valp,
2666 int write, void *data)
2667{
2668 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002669 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2670
2671 if (jif > INT_MAX)
2672 return 1;
2673 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002674 } else {
2675 int val = *valp;
2676 unsigned long lval;
2677 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002678 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002679 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002680 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002681 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002682 lval = (unsigned long)val;
2683 }
2684 *lvalp = jiffies_to_msecs(lval);
2685 }
2686 return 0;
2687}
2688
2689/**
2690 * proc_dointvec_jiffies - read a vector of integers as seconds
2691 * @table: the sysctl table
2692 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002693 * @buffer: the user buffer
2694 * @lenp: the size of the user buffer
2695 * @ppos: file position
2696 *
2697 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2698 * values from/to the user buffer, treated as an ASCII string.
2699 * The values read are assumed to be in seconds, and are converted into
2700 * jiffies.
2701 *
2702 * Returns 0 on success.
2703 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002704int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002705 void __user *buffer, size_t *lenp, loff_t *ppos)
2706{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002707 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002708 do_proc_dointvec_jiffies_conv,NULL);
2709}
2710
2711/**
2712 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2713 * @table: the sysctl table
2714 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002715 * @buffer: the user buffer
2716 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002717 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002718 *
2719 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2720 * values from/to the user buffer, treated as an ASCII string.
2721 * The values read are assumed to be in 1/USER_HZ seconds, and
2722 * are converted into jiffies.
2723 *
2724 * Returns 0 on success.
2725 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002726int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002727 void __user *buffer, size_t *lenp, loff_t *ppos)
2728{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002729 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002730 do_proc_dointvec_userhz_jiffies_conv,NULL);
2731}
2732
2733/**
2734 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2735 * @table: the sysctl table
2736 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002737 * @buffer: the user buffer
2738 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002739 * @ppos: file position
2740 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002741 *
2742 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2743 * values from/to the user buffer, treated as an ASCII string.
2744 * The values read are assumed to be in 1/1000 seconds, and
2745 * are converted into jiffies.
2746 *
2747 * Returns 0 on success.
2748 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002749int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002750 void __user *buffer, size_t *lenp, loff_t *ppos)
2751{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002752 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002753 do_proc_dointvec_ms_jiffies_conv, NULL);
2754}
2755
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002756static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002757 void __user *buffer, size_t *lenp, loff_t *ppos)
2758{
2759 struct pid *new_pid;
2760 pid_t tmp;
2761 int r;
2762
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002763 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002764
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002765 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002766 lenp, ppos, NULL, NULL);
2767 if (r || !write)
2768 return r;
2769
2770 new_pid = find_get_pid(tmp);
2771 if (!new_pid)
2772 return -ESRCH;
2773
2774 put_pid(xchg(&cad_pid, new_pid));
2775 return 0;
2776}
2777
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002778/**
2779 * proc_do_large_bitmap - read/write from/to a large bitmap
2780 * @table: the sysctl table
2781 * @write: %TRUE if this is a write to the sysctl file
2782 * @buffer: the user buffer
2783 * @lenp: the size of the user buffer
2784 * @ppos: file position
2785 *
2786 * The bitmap is stored at table->data and the bitmap length (in bits)
2787 * in table->maxlen.
2788 *
2789 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2790 * large bitmaps may be represented in a compact manner. Writing into
2791 * the file will clear the bitmap then update it with the given input.
2792 *
2793 * Returns 0 on success.
2794 */
2795int proc_do_large_bitmap(struct ctl_table *table, int write,
2796 void __user *buffer, size_t *lenp, loff_t *ppos)
2797{
2798 int err = 0;
2799 bool first = 1;
2800 size_t left = *lenp;
2801 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002802 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002803 unsigned long *tmp_bitmap = NULL;
2804 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2805
WANG Cong122ff242014-05-12 16:04:53 -07002806 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002807 *lenp = 0;
2808 return 0;
2809 }
2810
2811 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002812 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002813
2814 if (left > PAGE_SIZE - 1)
2815 left = PAGE_SIZE - 1;
2816
Al Viro70f6cbb2015-12-24 00:13:10 -05002817 p = kbuf = memdup_user_nul(buffer, left);
2818 if (IS_ERR(kbuf))
2819 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002820
2821 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2822 GFP_KERNEL);
2823 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002824 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002825 return -ENOMEM;
2826 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002827 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002828 while (!err && left) {
2829 unsigned long val_a, val_b;
2830 bool neg;
2831
Al Viro70f6cbb2015-12-24 00:13:10 -05002832 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002833 sizeof(tr_a), &c);
2834 if (err)
2835 break;
2836 if (val_a >= bitmap_len || neg) {
2837 err = -EINVAL;
2838 break;
2839 }
2840
2841 val_b = val_a;
2842 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002843 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002844 left--;
2845 }
2846
2847 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05002848 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002849 &neg, tr_b, sizeof(tr_b),
2850 &c);
2851 if (err)
2852 break;
2853 if (val_b >= bitmap_len || neg ||
2854 val_a > val_b) {
2855 err = -EINVAL;
2856 break;
2857 }
2858 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002859 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002860 left--;
2861 }
2862 }
2863
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002864 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002865 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05002866 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002867 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002868 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002869 } else {
2870 unsigned long bit_a, bit_b = 0;
2871
2872 while (left) {
2873 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2874 if (bit_a >= bitmap_len)
2875 break;
2876 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2877 bit_a + 1) - 1;
2878
2879 if (!first) {
2880 err = proc_put_char(&buffer, &left, ',');
2881 if (err)
2882 break;
2883 }
2884 err = proc_put_long(&buffer, &left, bit_a, false);
2885 if (err)
2886 break;
2887 if (bit_a != bit_b) {
2888 err = proc_put_char(&buffer, &left, '-');
2889 if (err)
2890 break;
2891 err = proc_put_long(&buffer, &left, bit_b, false);
2892 if (err)
2893 break;
2894 }
2895
2896 first = 0; bit_b++;
2897 }
2898 if (!err)
2899 err = proc_put_char(&buffer, &left, '\n');
2900 }
2901
2902 if (!err) {
2903 if (write) {
2904 if (*ppos)
2905 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2906 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002907 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002908 }
2909 kfree(tmp_bitmap);
2910 *lenp -= left;
2911 *ppos += *lenp;
2912 return 0;
2913 } else {
2914 kfree(tmp_bitmap);
2915 return err;
2916 }
2917}
2918
Jovi Zhang55610502011-01-12 17:00:45 -08002919#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002920
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002921int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002922 void __user *buffer, size_t *lenp, loff_t *ppos)
2923{
2924 return -ENOSYS;
2925}
2926
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002927int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002928 void __user *buffer, size_t *lenp, loff_t *ppos)
2929{
2930 return -ENOSYS;
2931}
2932
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002933int proc_douintvec(struct ctl_table *table, int write,
2934 void __user *buffer, size_t *lenp, loff_t *ppos)
2935{
2936 return -ENOSYS;
2937}
2938
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002939int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002940 void __user *buffer, size_t *lenp, loff_t *ppos)
2941{
2942 return -ENOSYS;
2943}
2944
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002945int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002946 void __user *buffer, size_t *lenp, loff_t *ppos)
2947{
2948 return -ENOSYS;
2949}
2950
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002951int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002952 void __user *buffer, size_t *lenp, loff_t *ppos)
2953{
2954 return -ENOSYS;
2955}
2956
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002957int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002958 void __user *buffer, size_t *lenp, loff_t *ppos)
2959{
2960 return -ENOSYS;
2961}
2962
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002963int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002964 void __user *buffer, size_t *lenp, loff_t *ppos)
2965{
2966 return -ENOSYS;
2967}
2968
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002969int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002970 void __user *buffer,
2971 size_t *lenp, loff_t *ppos)
2972{
2973 return -ENOSYS;
2974}
2975
2976
Jovi Zhang55610502011-01-12 17:00:45 -08002977#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002978
Linus Torvalds1da177e2005-04-16 15:20:36 -07002979/*
2980 * No sense putting this after each symbol definition, twice,
2981 * exception granted :-)
2982 */
2983EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002984EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002985EXPORT_SYMBOL(proc_dointvec_jiffies);
2986EXPORT_SYMBOL(proc_dointvec_minmax);
2987EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2988EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2989EXPORT_SYMBOL(proc_dostring);
2990EXPORT_SYMBOL(proc_doulongvec_minmax);
2991EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);