blob: 8cca4c7bb21f04f4a5d136dbeed69ef9870ca97c [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>
Ingo Molnarf7ccbae2017-02-08 18:51:30 +010066#include <linux/sched/coredump.h>
Kees Cook79847542014-01-23 15:55:59 -080067#include <linux/kexec.h>
Alexei Starovoitov1be7f752015-10-07 22:23:21 -070068#include <linux/bpf.h>
Eric W. Biedermand2921682016-09-28 00:27:17 -050069#include <linux/mount.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070070
Linus Torvalds7c0f6ba2016-12-24 11:46:01 -080071#include <linux/uaccess.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070072#include <asm/processor.h>
73
Andi Kleen29cbc782006-09-30 01:47:55 +020074#ifdef CONFIG_X86
75#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010076#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010077#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020078#endif
David Howellsd550bbd2012-03-28 18:30:03 +010079#ifdef CONFIG_SPARC
80#include <asm/setup.h>
81#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080082#ifdef CONFIG_BSD_PROCESS_ACCT
83#include <linux/acct.h>
84#endif
Dave Young4f0e0562010-03-10 15:24:09 -080085#ifdef CONFIG_RT_MUTEXES
86#include <linux/rtmutex.h>
87#endif
Dave Young2edf5e42010-03-10 15:24:10 -080088#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
89#include <linux/lockdep.h>
90#endif
Dave Young15485a42010-03-10 15:24:07 -080091#ifdef CONFIG_CHR_DEV_SG
92#include <scsi/sg.h>
93#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020094
Don Zickus58687ac2010-05-07 17:11:44 -040095#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050096#include <linux/nmi.h>
97#endif
98
Linus Torvalds1da177e2005-04-16 15:20:36 -070099#if defined(CONFIG_SYSCTL)
100
101/* External variables not in a header file. */
Alan Coxd6e71142005-06-23 00:09:43 -0700102extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700103#ifdef CONFIG_COREDUMP
104extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700106extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700107#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800110extern int percpu_pagelist_fraction;
Arjan van de Ven97455122008-01-25 21:08:34 +0100111extern int latencytop_enabled;
Alexey Dobriyan9b80a182016-09-02 00:38:52 +0300112extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000113#ifndef CONFIG_MMU
114extern int sysctl_nr_trim_pages;
115#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700117/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400118#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700119static int sixty = 60;
120#endif
121
Aaron Tomlin270750db2014-01-20 17:34:13 +0000122static int __maybe_unused neg_one = -1;
123
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700124static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700125static int __maybe_unused one = 1;
126static int __maybe_unused two = 2;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700127static int __maybe_unused four = 4;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800128static unsigned long one_ul = 1;
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,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800349 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200350 },
Mel Gormancb251762016-02-05 09:08:36 +0000351#ifdef CONFIG_SCHEDSTATS
352 {
353 .procname = "sched_schedstats",
354 .data = NULL,
355 .maxlen = sizeof(unsigned int),
356 .mode = 0644,
357 .proc_handler = sysctl_schedstats,
358 .extra1 = &zero,
359 .extra2 = &one,
360 },
361#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200362#endif /* CONFIG_SMP */
363#ifdef CONFIG_NUMA_BALANCING
364 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200365 .procname = "numa_balancing_scan_delay_ms",
366 .data = &sysctl_numa_balancing_scan_delay,
367 .maxlen = sizeof(unsigned int),
368 .mode = 0644,
369 .proc_handler = proc_dointvec,
370 },
371 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200372 .procname = "numa_balancing_scan_period_min_ms",
373 .data = &sysctl_numa_balancing_scan_period_min,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
376 .proc_handler = proc_dointvec,
377 },
378 {
379 .procname = "numa_balancing_scan_period_max_ms",
380 .data = &sysctl_numa_balancing_scan_period_max,
381 .maxlen = sizeof(unsigned int),
382 .mode = 0644,
383 .proc_handler = proc_dointvec,
384 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200385 {
386 .procname = "numa_balancing_scan_size_mb",
387 .data = &sysctl_numa_balancing_scan_size,
388 .maxlen = sizeof(unsigned int),
389 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400390 .proc_handler = proc_dointvec_minmax,
391 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200392 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100393 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800394 .procname = "numa_balancing",
395 .data = NULL, /* filled in by handler */
396 .maxlen = sizeof(unsigned int),
397 .mode = 0644,
398 .proc_handler = sysctl_numa_balancing,
399 .extra1 = &zero,
400 .extra2 = &one,
401 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200402#endif /* CONFIG_NUMA_BALANCING */
403#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200404 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100405 .procname = "sched_rt_period_us",
406 .data = &sysctl_sched_rt_period,
407 .maxlen = sizeof(unsigned int),
408 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800409 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100410 },
411 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100412 .procname = "sched_rt_runtime_us",
413 .data = &sysctl_sched_rt_runtime,
414 .maxlen = sizeof(int),
415 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800416 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100417 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600418 {
419 .procname = "sched_rr_timeslice_ms",
Shile Zhang975e1552017-01-28 22:00:49 +0800420 .data = &sysctl_sched_rr_timeslice,
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600421 .maxlen = sizeof(int),
422 .mode = 0644,
423 .proc_handler = sched_rr_handler,
424 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100425#ifdef CONFIG_SCHED_AUTOGROUP
426 {
427 .procname = "sched_autogroup_enabled",
428 .data = &sysctl_sched_autogroup_enabled,
429 .maxlen = sizeof(unsigned int),
430 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800431 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100432 .extra1 = &zero,
433 .extra2 = &one,
434 },
435#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700436#ifdef CONFIG_CFS_BANDWIDTH
437 {
438 .procname = "sched_cfs_bandwidth_slice_us",
439 .data = &sysctl_sched_cfs_bandwidth_slice,
440 .maxlen = sizeof(unsigned int),
441 .mode = 0644,
442 .proc_handler = proc_dointvec_minmax,
443 .extra1 = &one,
444 },
445#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700446#ifdef CONFIG_PROVE_LOCKING
447 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700448 .procname = "prove_locking",
449 .data = &prove_locking,
450 .maxlen = sizeof(int),
451 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800452 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700453 },
454#endif
455#ifdef CONFIG_LOCK_STAT
456 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700457 .procname = "lock_stat",
458 .data = &lock_stat,
459 .maxlen = sizeof(int),
460 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800461 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700462 },
463#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200464 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 .procname = "panic",
466 .data = &panic_timeout,
467 .maxlen = sizeof(int),
468 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800469 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 },
Alex Kelly046d6622012-10-04 17:15:23 -0700471#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 .procname = "core_uses_pid",
474 .data = &core_uses_pid,
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 },
479 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 .procname = "core_pattern",
481 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700482 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700484 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 },
Neil Hormana2939802009-09-23 15:56:56 -0700486 {
Neil Hormana2939802009-09-23 15:56:56 -0700487 .procname = "core_pipe_limit",
488 .data = &core_pipe_limit,
489 .maxlen = sizeof(unsigned int),
490 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800491 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700492 },
Alex Kelly046d6622012-10-04 17:15:23 -0700493#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800494#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700497 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800498 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800499 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700501 {
502 .procname = "sysctl_writes_strict",
503 .data = &sysctl_writes_strict,
504 .maxlen = sizeof(int),
505 .mode = 0644,
506 .proc_handler = proc_dointvec_minmax,
507 .extra1 = &neg_one,
508 .extra2 = &one,
509 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800510#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100511#ifdef CONFIG_LATENCYTOP
512 {
513 .procname = "latencytop",
514 .data = &latencytop_enabled,
515 .maxlen = sizeof(int),
516 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000517 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100518 },
519#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520#ifdef CONFIG_BLK_DEV_INITRD
521 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 .procname = "real-root-dev",
523 .data = &real_root_dev,
524 .maxlen = sizeof(int),
525 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800526 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 },
528#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700529 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700530 .procname = "print-fatal-signals",
531 .data = &print_fatal_signals,
532 .maxlen = sizeof(int),
533 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800534 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700535 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700536#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 .procname = "reboot-cmd",
539 .data = reboot_command,
540 .maxlen = 256,
541 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800542 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 },
544 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 .procname = "stop-a",
546 .data = &stop_a_enabled,
547 .maxlen = sizeof (int),
548 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800549 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 },
551 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 .procname = "scons-poweroff",
553 .data = &scons_pwroff,
554 .maxlen = sizeof (int),
555 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800556 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 },
558#endif
David S. Miller08714202008-11-16 23:49:24 -0800559#ifdef CONFIG_SPARC64
560 {
David S. Miller08714202008-11-16 23:49:24 -0800561 .procname = "tsb-ratio",
562 .data = &sysctl_tsb_ratio,
563 .maxlen = sizeof (int),
564 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800565 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800566 },
567#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568#ifdef __hppa__
569 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700570 .procname = "soft-power",
571 .data = &pwrsw_enabled,
572 .maxlen = sizeof (int),
573 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800574 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530576#endif
577#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 .procname = "unaligned-trap",
580 .data = &unaligned_enabled,
581 .maxlen = sizeof (int),
582 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800583 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 },
585#endif
586 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 .procname = "ctrl-alt-del",
588 .data = &C_A_D,
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 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400593#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200594 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200595 .procname = "ftrace_enabled",
596 .data = &ftrace_enabled,
597 .maxlen = sizeof(int),
598 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800599 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200600 },
601#endif
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500602#ifdef CONFIG_STACK_TRACER
603 {
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500604 .procname = "stack_tracer_enabled",
605 .data = &stack_tracer_enabled,
606 .maxlen = sizeof(int),
607 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800608 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d2a2008-12-16 23:06:40 -0500609 },
610#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400611#ifdef CONFIG_TRACING
612 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100613 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400614 .data = &ftrace_dump_on_oops,
615 .maxlen = sizeof(int),
616 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800617 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400618 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400619 {
620 .procname = "traceoff_on_warning",
621 .data = &__disable_trace_on_warning,
622 .maxlen = sizeof(__disable_trace_on_warning),
623 .mode = 0644,
624 .proc_handler = proc_dointvec,
625 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500626 {
627 .procname = "tracepoint_printk",
628 .data = &tracepoint_printk,
629 .maxlen = sizeof(tracepoint_printk),
630 .mode = 0644,
Steven Rostedt (Red Hat)423917452016-11-23 15:52:45 -0500631 .proc_handler = tracepoint_printk_sysctl,
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500632 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400633#endif
Dave Young2965faa2015-09-09 15:38:55 -0700634#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800635 {
636 .procname = "kexec_load_disabled",
637 .data = &kexec_load_disabled,
638 .maxlen = sizeof(int),
639 .mode = 0644,
640 /* only handle a transition from default "0" to "1" */
641 .proc_handler = proc_dointvec_minmax,
642 .extra1 = &one,
643 .extra2 = &one,
644 },
645#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200646#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 .procname = "modprobe",
649 .data = &modprobe_path,
650 .maxlen = KMOD_PATH_LEN,
651 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800652 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 },
Kees Cook3d433212009-04-02 15:49:29 -0700654 {
Kees Cook3d433212009-04-02 15:49:29 -0700655 .procname = "modules_disabled",
656 .data = &modules_disabled,
657 .maxlen = sizeof(int),
658 .mode = 0644,
659 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800660 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700661 .extra1 = &one,
662 .extra2 = &one,
663 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700665#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100668 .data = &uevent_helper,
669 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800671 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 },
Michael Marineau86d56132014-04-10 14:09:31 -0700673#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674#ifdef CONFIG_CHR_DEV_SG
675 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 .procname = "sg-big-buff",
677 .data = &sg_big_buff,
678 .maxlen = sizeof (int),
679 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800680 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 },
682#endif
683#ifdef CONFIG_BSD_PROCESS_ACCT
684 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 .procname = "acct",
686 .data = &acct_parm,
687 .maxlen = 3*sizeof(int),
688 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800689 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 },
691#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692#ifdef CONFIG_MAGIC_SYSRQ
693 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800695 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 .maxlen = sizeof (int),
697 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700698 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 },
700#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700701#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700704 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 .maxlen = sizeof (int),
706 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800707 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700709#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700712 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 .maxlen = sizeof(int),
714 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700715 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 },
717 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 .procname = "random",
719 .mode = 0555,
720 .child = random_table,
721 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 {
Eric Paris17f60a72011-04-01 17:07:50 -0400723 .procname = "usermodehelper",
724 .mode = 0555,
725 .child = usermodehelper_table,
726 },
727 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 .procname = "overflowuid",
729 .data = &overflowuid,
730 .maxlen = sizeof(int),
731 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800732 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 .extra1 = &minolduid,
734 .extra2 = &maxolduid,
735 },
736 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 .procname = "overflowgid",
738 .data = &overflowgid,
739 .maxlen = sizeof(int),
740 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800741 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 .extra1 = &minolduid,
743 .extra2 = &maxolduid,
744 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800745#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746#ifdef CONFIG_MATHEMU
747 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 .procname = "ieee_emulation_warnings",
749 .data = &sysctl_ieee_emulation_warnings,
750 .maxlen = sizeof(int),
751 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800752 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 },
754#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200757 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 .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
763 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 .procname = "pid_max",
765 .data = &pid_max,
766 .maxlen = sizeof (int),
767 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800768 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 .extra1 = &pid_max_min,
770 .extra2 = &pid_max_max,
771 },
772 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773 .procname = "panic_on_oops",
774 .data = &panic_on_oops,
775 .maxlen = sizeof(int),
776 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800777 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800779#if defined CONFIG_PRINTK
780 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800781 .procname = "printk",
782 .data = &console_loglevel,
783 .maxlen = 4*sizeof(int),
784 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800785 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800786 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700789 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 .maxlen = sizeof(int),
791 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800792 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 },
794 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700796 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 .maxlen = sizeof(int),
798 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800799 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 },
Dave Youngaf913222009-09-22 16:43:33 -0700801 {
Dave Youngaf913222009-09-22 16:43:33 -0700802 .procname = "printk_delay",
803 .data = &printk_delay_msec,
804 .maxlen = sizeof(int),
805 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800806 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700807 .extra1 = &zero,
808 .extra2 = &ten_thousand,
809 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700811 .procname = "printk_devkmsg",
812 .data = devkmsg_log_str,
813 .maxlen = DEVKMSG_STR_MAX_SIZE,
814 .mode = 0644,
815 .proc_handler = devkmsg_sysctl_set_loglvl,
816 },
817 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800818 .procname = "dmesg_restrict",
819 .data = &dmesg_restrict,
820 .maxlen = sizeof(int),
821 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700822 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800823 .extra1 = &zero,
824 .extra2 = &one,
825 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800826 {
827 .procname = "kptr_restrict",
828 .data = &kptr_restrict,
829 .maxlen = sizeof(int),
830 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700831 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800832 .extra1 = &zero,
833 .extra2 = &two,
834 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800835#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800836 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 .procname = "ngroups_max",
838 .data = &ngroups_max,
839 .maxlen = sizeof (int),
840 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800841 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 },
Dan Ballard73efc032011-10-31 17:11:20 -0700843 {
844 .procname = "cap_last_cap",
845 .data = (void *)&cap_last_cap,
846 .maxlen = sizeof(int),
847 .mode = 0444,
848 .proc_handler = proc_dointvec,
849 },
Don Zickus58687ac2010-05-07 17:11:44 -0400850#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500851 {
Don Zickus58687ac2010-05-07 17:11:44 -0400852 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200853 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500854 .maxlen = sizeof (int),
855 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700856 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700857 .extra1 = &zero,
858 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400859 },
860 {
861 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700862 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400863 .maxlen = sizeof(int),
864 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700865 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800866 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400867 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500868 },
Don Zickus2508ce12010-05-07 17:11:46 -0400869 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700870 .procname = "nmi_watchdog",
871 .data = &nmi_watchdog_enabled,
872 .maxlen = sizeof (int),
873 .mode = 0644,
874 .proc_handler = proc_nmi_watchdog,
875 .extra1 = &zero,
876#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
877 .extra2 = &one,
878#else
879 .extra2 = &zero,
880#endif
881 },
882 {
883 .procname = "soft_watchdog",
884 .data = &soft_watchdog_enabled,
885 .maxlen = sizeof (int),
886 .mode = 0644,
887 .proc_handler = proc_soft_watchdog,
888 .extra1 = &zero,
889 .extra2 = &one,
890 },
891 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700892 .procname = "watchdog_cpumask",
893 .data = &watchdog_cpumask_bits,
894 .maxlen = NR_CPUS,
895 .mode = 0644,
896 .proc_handler = proc_watchdog_cpumask,
897 },
898 {
Don Zickus2508ce12010-05-07 17:11:46 -0400899 .procname = "softlockup_panic",
900 .data = &softlockup_panic,
901 .maxlen = sizeof(int),
902 .mode = 0644,
903 .proc_handler = proc_dointvec_minmax,
904 .extra1 = &zero,
905 .extra2 = &one,
906 },
Don Zickusac1f5912015-11-05 18:44:44 -0800907#ifdef CONFIG_HARDLOCKUP_DETECTOR
908 {
909 .procname = "hardlockup_panic",
910 .data = &hardlockup_panic,
911 .maxlen = sizeof(int),
912 .mode = 0644,
913 .proc_handler = proc_dointvec_minmax,
914 .extra1 = &zero,
915 .extra2 = &one,
916 },
917#endif
Aaron Tomlined235872014-06-23 13:22:05 -0700918#ifdef CONFIG_SMP
919 {
920 .procname = "softlockup_all_cpu_backtrace",
921 .data = &sysctl_softlockup_all_cpu_backtrace,
922 .maxlen = sizeof(int),
923 .mode = 0644,
924 .proc_handler = proc_dointvec_minmax,
925 .extra1 = &zero,
926 .extra2 = &one,
927 },
Jiri Kosina55537872015-11-05 18:44:41 -0800928 {
929 .procname = "hardlockup_all_cpu_backtrace",
930 .data = &sysctl_hardlockup_all_cpu_backtrace,
931 .maxlen = sizeof(int),
932 .mode = 0644,
933 .proc_handler = proc_dointvec_minmax,
934 .extra1 = &zero,
935 .extra2 = &one,
936 },
Aaron Tomlined235872014-06-23 13:22:05 -0700937#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -0500938#endif
939#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
940 {
941 .procname = "unknown_nmi_panic",
942 .data = &unknown_nmi_panic,
943 .maxlen = sizeof (int),
944 .mode = 0644,
945 .proc_handler = proc_dointvec,
946 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500947#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948#if defined(CONFIG_X86)
949 {
Don Zickus8da5add2006-09-26 10:52:27 +0200950 .procname = "panic_on_unrecovered_nmi",
951 .data = &panic_on_unrecovered_nmi,
952 .maxlen = sizeof(int),
953 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800954 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200955 },
956 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700957 .procname = "panic_on_io_nmi",
958 .data = &panic_on_io_nmi,
959 .maxlen = sizeof(int),
960 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800961 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700962 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900963#ifdef CONFIG_DEBUG_STACKOVERFLOW
964 {
965 .procname = "panic_on_stackoverflow",
966 .data = &sysctl_panic_on_stackoverflow,
967 .maxlen = sizeof(int),
968 .mode = 0644,
969 .proc_handler = proc_dointvec,
970 },
971#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700972 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973 .procname = "bootloader_type",
974 .data = &bootloader_type,
975 .maxlen = sizeof (int),
976 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800977 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700978 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100979 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700980 .procname = "bootloader_version",
981 .data = &bootloader_version,
982 .maxlen = sizeof (int),
983 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800984 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700985 },
986 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100987 .procname = "io_delay_type",
988 .data = &io_delay_type,
989 .maxlen = sizeof(int),
990 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800991 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100992 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800994#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996 .procname = "randomize_va_space",
997 .data = &randomize_va_space,
998 .maxlen = sizeof(int),
999 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001000 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001002#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001003#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001004 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001005 .procname = "spin_retry",
1006 .data = &spin_retry,
1007 .maxlen = sizeof (int),
1008 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001009 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001010 },
1011#endif
Len Brown673d5b42007-07-28 03:33:16 -04001012#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001013 {
Pavel Machekc255d842006-02-20 18:27:58 -08001014 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001015 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001016 .maxlen = sizeof (unsigned long),
1017 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001018 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001019 },
1020#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301021#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001022 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001023 .procname = "ignore-unaligned-usertrap",
1024 .data = &no_unaligned_warning,
1025 .maxlen = sizeof (int),
1026 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001027 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001028 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301029#endif
1030#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001031 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001032 .procname = "unaligned-dump-stack",
1033 .data = &unaligned_dump_stack,
1034 .maxlen = sizeof (int),
1035 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001036 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001037 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001038#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001039#ifdef CONFIG_DETECT_HUNG_TASK
1040 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001041 .procname = "hung_task_panic",
1042 .data = &sysctl_hung_task_panic,
1043 .maxlen = sizeof(int),
1044 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001045 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001046 .extra1 = &zero,
1047 .extra2 = &one,
1048 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001049 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001050 .procname = "hung_task_check_count",
1051 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001052 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001053 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001054 .proc_handler = proc_dointvec_minmax,
1055 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001056 },
1057 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001058 .procname = "hung_task_timeout_secs",
1059 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001060 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001061 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001062 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001063 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001064 },
1065 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001066 .procname = "hung_task_warnings",
1067 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001068 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001069 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001070 .proc_handler = proc_dointvec_minmax,
1071 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001072 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001073#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001074#ifdef CONFIG_RT_MUTEXES
1075 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001076 .procname = "max_lock_depth",
1077 .data = &max_lock_depth,
1078 .maxlen = sizeof(int),
1079 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001080 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001081 },
1082#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001083 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001084 .procname = "poweroff_cmd",
1085 .data = &poweroff_cmd,
1086 .maxlen = POWEROFF_CMD_PATH_LEN,
1087 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001088 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001089 },
David Howells0b77f5b2008-04-29 01:01:32 -07001090#ifdef CONFIG_KEYS
1091 {
David Howells0b77f5b2008-04-29 01:01:32 -07001092 .procname = "keys",
1093 .mode = 0555,
1094 .child = key_sysctls,
1095 },
1096#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001097#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001098 /*
1099 * User-space scripts rely on the existence of this file
1100 * as a feature check for perf_events being enabled.
1101 *
1102 * So it's an ABI, do not remove!
1103 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001104 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001105 .procname = "perf_event_paranoid",
1106 .data = &sysctl_perf_event_paranoid,
1107 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001108 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001109 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001110 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001111 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001112 .procname = "perf_event_mlock_kb",
1113 .data = &sysctl_perf_event_mlock,
1114 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001115 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001116 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001117 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001118 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001119 .procname = "perf_event_max_sample_rate",
1120 .data = &sysctl_perf_event_sample_rate,
1121 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001122 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001123 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001124 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001125 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001126 {
1127 .procname = "perf_cpu_time_max_percent",
1128 .data = &sysctl_perf_cpu_time_max_percent,
1129 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1130 .mode = 0644,
1131 .proc_handler = perf_cpu_time_max_percent_handler,
1132 .extra1 = &zero,
1133 .extra2 = &one_hundred,
1134 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001135 {
1136 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001137 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001138 .maxlen = sizeof(sysctl_perf_event_max_stack),
1139 .mode = 0644,
1140 .proc_handler = perf_event_max_stack_handler,
1141 .extra1 = &zero,
1142 .extra2 = &six_hundred_forty_kb,
1143 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001144 {
1145 .procname = "perf_event_max_contexts_per_stack",
1146 .data = &sysctl_perf_event_max_contexts_per_stack,
1147 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1148 .mode = 0644,
1149 .proc_handler = perf_event_max_stack_handler,
1150 .extra1 = &zero,
1151 .extra2 = &one_thousand,
1152 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001153#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001154#ifdef CONFIG_KMEMCHECK
1155 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001156 .procname = "kmemcheck",
1157 .data = &kmemcheck_enabled,
1158 .maxlen = sizeof(int),
1159 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001160 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001161 },
1162#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001163 {
1164 .procname = "panic_on_warn",
1165 .data = &panic_on_warn,
1166 .maxlen = sizeof(int),
1167 .mode = 0644,
1168 .proc_handler = proc_dointvec_minmax,
1169 .extra1 = &zero,
1170 .extra2 = &one,
1171 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001172#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1173 {
1174 .procname = "timer_migration",
1175 .data = &sysctl_timer_migration,
1176 .maxlen = sizeof(unsigned int),
1177 .mode = 0644,
1178 .proc_handler = timer_migration_handler,
1179 },
1180#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001181#ifdef CONFIG_BPF_SYSCALL
1182 {
1183 .procname = "unprivileged_bpf_disabled",
1184 .data = &sysctl_unprivileged_bpf_disabled,
1185 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1186 .mode = 0644,
1187 /* only handle a transition from default "0" to "1" */
1188 .proc_handler = proc_dointvec_minmax,
1189 .extra1 = &one,
1190 .extra2 = &one,
1191 },
1192#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001193#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1194 {
1195 .procname = "panic_on_rcu_stall",
1196 .data = &sysctl_panic_on_rcu_stall,
1197 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1198 .mode = 0644,
1199 .proc_handler = proc_dointvec_minmax,
1200 .extra1 = &zero,
1201 .extra2 = &one,
1202 },
1203#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001204 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001205};
1206
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001207static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001208 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001209 .procname = "overcommit_memory",
1210 .data = &sysctl_overcommit_memory,
1211 .maxlen = sizeof(sysctl_overcommit_memory),
1212 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001213 .proc_handler = proc_dointvec_minmax,
1214 .extra1 = &zero,
1215 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001216 },
1217 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001218 .procname = "panic_on_oom",
1219 .data = &sysctl_panic_on_oom,
1220 .maxlen = sizeof(sysctl_panic_on_oom),
1221 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001222 .proc_handler = proc_dointvec_minmax,
1223 .extra1 = &zero,
1224 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001225 },
1226 {
David Rientjesfe071d72007-10-16 23:25:56 -07001227 .procname = "oom_kill_allocating_task",
1228 .data = &sysctl_oom_kill_allocating_task,
1229 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1230 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001231 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001232 },
1233 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001234 .procname = "oom_dump_tasks",
1235 .data = &sysctl_oom_dump_tasks,
1236 .maxlen = sizeof(sysctl_oom_dump_tasks),
1237 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001238 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001239 },
1240 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241 .procname = "overcommit_ratio",
1242 .data = &sysctl_overcommit_ratio,
1243 .maxlen = sizeof(sysctl_overcommit_ratio),
1244 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001245 .proc_handler = overcommit_ratio_handler,
1246 },
1247 {
1248 .procname = "overcommit_kbytes",
1249 .data = &sysctl_overcommit_kbytes,
1250 .maxlen = sizeof(sysctl_overcommit_kbytes),
1251 .mode = 0644,
1252 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001253 },
1254 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255 .procname = "page-cluster",
1256 .data = &page_cluster,
1257 .maxlen = sizeof(int),
1258 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001259 .proc_handler = proc_dointvec_minmax,
1260 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001261 },
1262 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001263 .procname = "dirty_background_ratio",
1264 .data = &dirty_background_ratio,
1265 .maxlen = sizeof(dirty_background_ratio),
1266 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001267 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001268 .extra1 = &zero,
1269 .extra2 = &one_hundred,
1270 },
1271 {
David Rientjes2da02992009-01-06 14:39:31 -08001272 .procname = "dirty_background_bytes",
1273 .data = &dirty_background_bytes,
1274 .maxlen = sizeof(dirty_background_bytes),
1275 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001276 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001277 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001278 },
1279 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 .procname = "dirty_ratio",
1281 .data = &vm_dirty_ratio,
1282 .maxlen = sizeof(vm_dirty_ratio),
1283 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001284 .proc_handler = dirty_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_bytes",
1290 .data = &vm_dirty_bytes,
1291 .maxlen = sizeof(vm_dirty_bytes),
1292 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001293 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001294 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001295 },
1296 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001297 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001298 .data = &dirty_writeback_interval,
1299 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001300 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001301 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001302 },
1303 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001304 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001305 .data = &dirty_expire_interval,
1306 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001307 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001308 .proc_handler = proc_dointvec_minmax,
1309 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001310 },
1311 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001312 .procname = "dirtytime_expire_seconds",
1313 .data = &dirtytime_expire_interval,
1314 .maxlen = sizeof(dirty_expire_interval),
1315 .mode = 0644,
1316 .proc_handler = dirtytime_interval_handler,
1317 .extra1 = &zero,
1318 },
1319 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001320 .procname = "nr_pdflush_threads",
1321 .mode = 0444 /* read-only */,
1322 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323 },
1324 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 .procname = "swappiness",
1326 .data = &vm_swappiness,
1327 .maxlen = sizeof(vm_swappiness),
1328 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001329 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001330 .extra1 = &zero,
1331 .extra2 = &one_hundred,
1332 },
1333#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001334 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001335 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001336 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337 .maxlen = sizeof(unsigned long),
1338 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001339 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001340 },
1341#ifdef CONFIG_NUMA
1342 {
1343 .procname = "nr_hugepages_mempolicy",
1344 .data = NULL,
1345 .maxlen = sizeof(unsigned long),
1346 .mode = 0644,
1347 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001348 },
1349#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001351 .procname = "hugetlb_shm_group",
1352 .data = &sysctl_hugetlb_shm_group,
1353 .maxlen = sizeof(gid_t),
1354 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001355 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001356 },
Mel Gorman396faf02007-07-17 04:03:13 -07001357 {
Mel Gorman396faf02007-07-17 04:03:13 -07001358 .procname = "hugepages_treat_as_movable",
1359 .data = &hugepages_treat_as_movable,
1360 .maxlen = sizeof(int),
1361 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001362 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001363 },
Adam Litke54f9f802007-10-16 01:26:20 -07001364 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001365 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001366 .data = NULL,
1367 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001368 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001369 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001370 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001371#endif
1372 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001373 .procname = "lowmem_reserve_ratio",
1374 .data = &sysctl_lowmem_reserve_ratio,
1375 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1376 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001377 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378 },
1379 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001380 .procname = "drop_caches",
1381 .data = &sysctl_drop_caches,
1382 .maxlen = sizeof(int),
1383 .mode = 0644,
1384 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001385 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001386 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001387 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001388#ifdef CONFIG_COMPACTION
1389 {
1390 .procname = "compact_memory",
1391 .data = &sysctl_compact_memory,
1392 .maxlen = sizeof(int),
1393 .mode = 0200,
1394 .proc_handler = sysctl_compaction_handler,
1395 },
Mel Gorman5e771902010-05-24 14:32:31 -07001396 {
1397 .procname = "extfrag_threshold",
1398 .data = &sysctl_extfrag_threshold,
1399 .maxlen = sizeof(int),
1400 .mode = 0644,
1401 .proc_handler = sysctl_extfrag_handler,
1402 .extra1 = &min_extfrag_threshold,
1403 .extra2 = &max_extfrag_threshold,
1404 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001405 {
1406 .procname = "compact_unevictable_allowed",
1407 .data = &sysctl_compact_unevictable_allowed,
1408 .maxlen = sizeof(int),
1409 .mode = 0644,
1410 .proc_handler = proc_dointvec,
1411 .extra1 = &zero,
1412 .extra2 = &one,
1413 },
Mel Gorman5e771902010-05-24 14:32:31 -07001414
Mel Gorman76ab0f52010-05-24 14:32:28 -07001415#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001416 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001417 .procname = "min_free_kbytes",
1418 .data = &min_free_kbytes,
1419 .maxlen = sizeof(min_free_kbytes),
1420 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001421 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001422 .extra1 = &zero,
1423 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001424 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001425 .procname = "watermark_scale_factor",
1426 .data = &watermark_scale_factor,
1427 .maxlen = sizeof(watermark_scale_factor),
1428 .mode = 0644,
1429 .proc_handler = watermark_scale_factor_sysctl_handler,
1430 .extra1 = &one,
1431 .extra2 = &one_thousand,
1432 },
1433 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001434 .procname = "percpu_pagelist_fraction",
1435 .data = &percpu_pagelist_fraction,
1436 .maxlen = sizeof(percpu_pagelist_fraction),
1437 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001438 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001439 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001440 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001441#ifdef CONFIG_MMU
1442 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001443 .procname = "max_map_count",
1444 .data = &sysctl_max_map_count,
1445 .maxlen = sizeof(sysctl_max_map_count),
1446 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001447 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001448 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001449 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001450#else
1451 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001452 .procname = "nr_trim_pages",
1453 .data = &sysctl_nr_trim_pages,
1454 .maxlen = sizeof(sysctl_nr_trim_pages),
1455 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001456 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001457 .extra1 = &zero,
1458 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459#endif
1460 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001461 .procname = "laptop_mode",
1462 .data = &laptop_mode,
1463 .maxlen = sizeof(laptop_mode),
1464 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001465 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001466 },
1467 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001468 .procname = "block_dump",
1469 .data = &block_dump,
1470 .maxlen = sizeof(block_dump),
1471 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001472 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001473 .extra1 = &zero,
1474 },
1475 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001476 .procname = "vfs_cache_pressure",
1477 .data = &sysctl_vfs_cache_pressure,
1478 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1479 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001480 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 .extra1 = &zero,
1482 },
1483#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1484 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001485 .procname = "legacy_va_layout",
1486 .data = &sysctl_legacy_va_layout,
1487 .maxlen = sizeof(sysctl_legacy_va_layout),
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#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001493#ifdef CONFIG_NUMA
1494 {
Christoph Lameter17436602006-01-18 17:42:32 -08001495 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001496 .data = &node_reclaim_mode,
1497 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001498 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001499 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001500 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001501 },
Christoph Lameter96146342006-07-03 00:24:13 -07001502 {
Christoph Lameter96146342006-07-03 00:24:13 -07001503 .procname = "min_unmapped_ratio",
1504 .data = &sysctl_min_unmapped_ratio,
1505 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1506 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001507 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001508 .extra1 = &zero,
1509 .extra2 = &one_hundred,
1510 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001511 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001512 .procname = "min_slab_ratio",
1513 .data = &sysctl_min_slab_ratio,
1514 .maxlen = sizeof(sysctl_min_slab_ratio),
1515 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001516 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001517 .extra1 = &zero,
1518 .extra2 = &one_hundred,
1519 },
Christoph Lameter17436602006-01-18 17:42:32 -08001520#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001521#ifdef CONFIG_SMP
1522 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001523 .procname = "stat_interval",
1524 .data = &sysctl_stat_interval,
1525 .maxlen = sizeof(sysctl_stat_interval),
1526 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001527 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001528 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001529 {
1530 .procname = "stat_refresh",
1531 .data = NULL,
1532 .maxlen = 0,
1533 .mode = 0600,
1534 .proc_handler = vmstat_refresh,
1535 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001536#endif
David Howells6e141542009-12-15 19:27:45 +00001537#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001538 {
Eric Parised032182007-06-28 15:55:21 -04001539 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001540 .data = &dac_mmap_min_addr,
1541 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001542 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001543 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001544 },
David Howells6e141542009-12-15 19:27:45 +00001545#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001546#ifdef CONFIG_NUMA
1547 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001548 .procname = "numa_zonelist_order",
1549 .data = &numa_zonelist_order,
1550 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1551 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001552 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001553 },
1554#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001555#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001556 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001557 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001558 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001559#ifdef CONFIG_X86_32
1560 .data = &vdso32_enabled,
1561 .maxlen = sizeof(vdso32_enabled),
1562#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001563 .data = &vdso_enabled,
1564 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001565#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001566 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001567 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001568 .extra1 = &zero,
1569 },
1570#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001571#ifdef CONFIG_HIGHMEM
1572 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001573 .procname = "highmem_is_dirtyable",
1574 .data = &vm_highmem_is_dirtyable,
1575 .maxlen = sizeof(vm_highmem_is_dirtyable),
1576 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001577 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001578 .extra1 = &zero,
1579 .extra2 = &one,
1580 },
1581#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001582#ifdef CONFIG_MEMORY_FAILURE
1583 {
Andi Kleen6a460792009-09-16 11:50:15 +02001584 .procname = "memory_failure_early_kill",
1585 .data = &sysctl_memory_failure_early_kill,
1586 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1587 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001588 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001589 .extra1 = &zero,
1590 .extra2 = &one,
1591 },
1592 {
Andi Kleen6a460792009-09-16 11:50:15 +02001593 .procname = "memory_failure_recovery",
1594 .data = &sysctl_memory_failure_recovery,
1595 .maxlen = sizeof(sysctl_memory_failure_recovery),
1596 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001597 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001598 .extra1 = &zero,
1599 .extra2 = &one,
1600 },
1601#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001602 {
1603 .procname = "user_reserve_kbytes",
1604 .data = &sysctl_user_reserve_kbytes,
1605 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1606 .mode = 0644,
1607 .proc_handler = proc_doulongvec_minmax,
1608 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001609 {
1610 .procname = "admin_reserve_kbytes",
1611 .data = &sysctl_admin_reserve_kbytes,
1612 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1613 .mode = 0644,
1614 .proc_handler = proc_doulongvec_minmax,
1615 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001616#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1617 {
1618 .procname = "mmap_rnd_bits",
1619 .data = &mmap_rnd_bits,
1620 .maxlen = sizeof(mmap_rnd_bits),
1621 .mode = 0600,
1622 .proc_handler = proc_dointvec_minmax,
1623 .extra1 = (void *)&mmap_rnd_bits_min,
1624 .extra2 = (void *)&mmap_rnd_bits_max,
1625 },
1626#endif
1627#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1628 {
1629 .procname = "mmap_rnd_compat_bits",
1630 .data = &mmap_rnd_compat_bits,
1631 .maxlen = sizeof(mmap_rnd_compat_bits),
1632 .mode = 0600,
1633 .proc_handler = proc_dointvec_minmax,
1634 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1635 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1636 },
1637#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001638 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001639};
1640
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001641static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001642 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001643 .procname = "inode-nr",
1644 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001645 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001646 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001647 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001648 },
1649 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001650 .procname = "inode-state",
1651 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001652 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001653 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001654 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655 },
1656 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001657 .procname = "file-nr",
1658 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001659 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001660 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001661 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001662 },
1663 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664 .procname = "file-max",
1665 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001666 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001667 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001668 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001669 },
1670 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001671 .procname = "nr_open",
1672 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001673 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001674 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001675 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001676 .extra1 = &sysctl_nr_open_min,
1677 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001678 },
1679 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001680 .procname = "dentry-state",
1681 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001682 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001684 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685 },
1686 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001687 .procname = "overflowuid",
1688 .data = &fs_overflowuid,
1689 .maxlen = sizeof(int),
1690 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001691 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001692 .extra1 = &minolduid,
1693 .extra2 = &maxolduid,
1694 },
1695 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696 .procname = "overflowgid",
1697 .data = &fs_overflowgid,
1698 .maxlen = sizeof(int),
1699 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001700 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001701 .extra1 = &minolduid,
1702 .extra2 = &maxolduid,
1703 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001704#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001705 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001706 .procname = "leases-enable",
1707 .data = &leases_enable,
1708 .maxlen = sizeof(int),
1709 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001710 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001711 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001712#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001713#ifdef CONFIG_DNOTIFY
1714 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001715 .procname = "dir-notify-enable",
1716 .data = &dir_notify_enable,
1717 .maxlen = sizeof(int),
1718 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001719 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001720 },
1721#endif
1722#ifdef CONFIG_MMU
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 = "lease-break-time",
1726 .data = &lease_break_time,
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
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001732#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001733 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001734 .procname = "aio-nr",
1735 .data = &aio_nr,
1736 .maxlen = sizeof(aio_nr),
1737 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001738 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001739 },
1740 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001741 .procname = "aio-max-nr",
1742 .data = &aio_max_nr,
1743 .maxlen = sizeof(aio_max_nr),
1744 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001745 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001746 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001747#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001748#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001749 {
Robert Love0399cb02005-07-13 12:38:18 -04001750 .procname = "inotify",
1751 .mode = 0555,
1752 .child = inotify_table,
1753 },
1754#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001755#ifdef CONFIG_EPOLL
1756 {
1757 .procname = "epoll",
1758 .mode = 0555,
1759 .child = epoll_table,
1760 },
1761#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001762#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001763 {
Kees Cook800179c2012-07-25 17:29:07 -07001764 .procname = "protected_symlinks",
1765 .data = &sysctl_protected_symlinks,
1766 .maxlen = sizeof(int),
1767 .mode = 0600,
1768 .proc_handler = proc_dointvec_minmax,
1769 .extra1 = &zero,
1770 .extra2 = &one,
1771 },
1772 {
1773 .procname = "protected_hardlinks",
1774 .data = &sysctl_protected_hardlinks,
1775 .maxlen = sizeof(int),
1776 .mode = 0600,
1777 .proc_handler = proc_dointvec_minmax,
1778 .extra1 = &zero,
1779 .extra2 = &one,
1780 },
1781 {
Alan Coxd6e71142005-06-23 00:09:43 -07001782 .procname = "suid_dumpable",
1783 .data = &suid_dumpable,
1784 .maxlen = sizeof(int),
1785 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001786 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001787 .extra1 = &zero,
1788 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001789 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001790#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1791 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001792 .procname = "binfmt_misc",
1793 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001794 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001795 },
1796#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001797 {
Jens Axboeff9da692010-06-03 14:54:39 +02001798 .procname = "pipe-max-size",
1799 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001800 .maxlen = sizeof(int),
1801 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001802 .proc_handler = &pipe_proc_fn,
1803 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001804 },
Willy Tarreau759c0112016-01-18 16:36:09 +01001805 {
1806 .procname = "pipe-user-pages-hard",
1807 .data = &pipe_user_pages_hard,
1808 .maxlen = sizeof(pipe_user_pages_hard),
1809 .mode = 0644,
1810 .proc_handler = proc_doulongvec_minmax,
1811 },
1812 {
1813 .procname = "pipe-user-pages-soft",
1814 .data = &pipe_user_pages_soft,
1815 .maxlen = sizeof(pipe_user_pages_soft),
1816 .mode = 0644,
1817 .proc_handler = proc_doulongvec_minmax,
1818 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05001819 {
1820 .procname = "mount-max",
1821 .data = &sysctl_mount_max,
1822 .maxlen = sizeof(unsigned int),
1823 .mode = 0644,
1824 .proc_handler = proc_dointvec_minmax,
1825 .extra1 = &one,
1826 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001827 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001828};
1829
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001830static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001831#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001832 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001833 .procname = "exception-trace",
1834 .data = &show_unhandled_signals,
1835 .maxlen = sizeof(int),
1836 .mode = 0644,
1837 .proc_handler = proc_dointvec
1838 },
1839#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001840#if defined(CONFIG_OPTPROBES)
1841 {
1842 .procname = "kprobes-optimization",
1843 .data = &sysctl_kprobes_optimization,
1844 .maxlen = sizeof(int),
1845 .mode = 0644,
1846 .proc_handler = proc_kprobes_optimization_handler,
1847 .extra1 = &zero,
1848 .extra2 = &one,
1849 },
1850#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001851 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001852};
1853
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001854static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001855 { }
Robert Love0eeca282005-07-12 17:06:03 -04001856};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001857
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001858int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001859{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001860 struct ctl_table_header *hdr;
1861
1862 hdr = register_sysctl_table(sysctl_base_table);
1863 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001864 return 0;
1865}
1866
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001867#endif /* CONFIG_SYSCTL */
1868
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869/*
1870 * /proc/sys support
1871 */
1872
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001873#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001874
Kees Cookf8808302014-06-06 14:37:17 -07001875static int _proc_do_string(char *data, int maxlen, int write,
1876 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001877 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001878{
1879 size_t len;
1880 char __user *p;
1881 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001882
1883 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001884 *lenp = 0;
1885 return 0;
1886 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001887
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001888 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001889 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1890 /* Only continue writes not past the end of buffer. */
1891 len = strlen(data);
1892 if (len > maxlen - 1)
1893 len = maxlen - 1;
1894
1895 if (*ppos > len)
1896 return 0;
1897 len = *ppos;
1898 } else {
1899 /* Start writing from beginning of buffer. */
1900 len = 0;
1901 }
1902
Kees Cook2ca9bb42014-06-06 14:37:18 -07001903 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001904 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001905 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001906 if (get_user(c, p++))
1907 return -EFAULT;
1908 if (c == 0 || c == '\n')
1909 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001910 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001911 }
Kees Cookf8808302014-06-06 14:37:17 -07001912 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001913 } else {
1914 len = strlen(data);
1915 if (len > maxlen)
1916 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001917
1918 if (*ppos > len) {
1919 *lenp = 0;
1920 return 0;
1921 }
1922
1923 data += *ppos;
1924 len -= *ppos;
1925
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001926 if (len > *lenp)
1927 len = *lenp;
1928 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001929 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001930 return -EFAULT;
1931 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001932 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001933 return -EFAULT;
1934 len++;
1935 }
1936 *lenp = len;
1937 *ppos += len;
1938 }
1939 return 0;
1940}
1941
Kees Cookf4aacea2014-06-06 14:37:19 -07001942static void warn_sysctl_write(struct ctl_table *table)
1943{
1944 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1945 "This will not be supported in the future. To silence this\n"
1946 "warning, set kernel.sysctl_writes_strict = -1\n",
1947 current->comm, table->procname);
1948}
1949
Linus Torvalds1da177e2005-04-16 15:20:36 -07001950/**
1951 * proc_dostring - read a string sysctl
1952 * @table: the sysctl table
1953 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001954 * @buffer: the user buffer
1955 * @lenp: the size of the user buffer
1956 * @ppos: file position
1957 *
1958 * Reads/writes a string from/to the user buffer. If the kernel
1959 * buffer provided is not large enough to hold the string, the
1960 * string is truncated. The copied string is %NULL-terminated.
1961 * If the string is being read by the user process, it is copied
1962 * and a newline '\n' is added. It is truncated if the buffer is
1963 * not large enough.
1964 *
1965 * Returns 0 on success.
1966 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001967int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001968 void __user *buffer, size_t *lenp, loff_t *ppos)
1969{
Kees Cookf4aacea2014-06-06 14:37:19 -07001970 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
1971 warn_sysctl_write(table);
1972
Kees Cookf8808302014-06-06 14:37:17 -07001973 return _proc_do_string((char *)(table->data), table->maxlen, write,
1974 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001975}
1976
Amerigo Wang00b7c332010-05-05 00:26:45 +00001977static size_t proc_skip_spaces(char **buf)
1978{
1979 size_t ret;
1980 char *tmp = skip_spaces(*buf);
1981 ret = tmp - *buf;
1982 *buf = tmp;
1983 return ret;
1984}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001985
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001986static void proc_skip_char(char **buf, size_t *size, const char v)
1987{
1988 while (*size) {
1989 if (**buf != v)
1990 break;
1991 (*size)--;
1992 (*buf)++;
1993 }
1994}
1995
Amerigo Wang00b7c332010-05-05 00:26:45 +00001996#define TMPBUFLEN 22
1997/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001998 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001999 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002000 * @buf: a kernel buffer
2001 * @size: size of the kernel buffer
2002 * @val: this is where the number will be stored
2003 * @neg: set to %TRUE if number is negative
2004 * @perm_tr: a vector which contains the allowed trailers
2005 * @perm_tr_len: size of the perm_tr vector
2006 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002007 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002008 * In case of success %0 is returned and @buf and @size are updated with
2009 * the amount of bytes read. If @tr is non-NULL and a trailing
2010 * character exists (size is non-zero after returning from this
2011 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002012 */
2013static int proc_get_long(char **buf, size_t *size,
2014 unsigned long *val, bool *neg,
2015 const char *perm_tr, unsigned perm_tr_len, char *tr)
2016{
2017 int len;
2018 char *p, tmp[TMPBUFLEN];
2019
2020 if (!*size)
2021 return -EINVAL;
2022
2023 len = *size;
2024 if (len > TMPBUFLEN - 1)
2025 len = TMPBUFLEN - 1;
2026
2027 memcpy(tmp, *buf, len);
2028
2029 tmp[len] = 0;
2030 p = tmp;
2031 if (*p == '-' && *size > 1) {
2032 *neg = true;
2033 p++;
2034 } else
2035 *neg = false;
2036 if (!isdigit(*p))
2037 return -EINVAL;
2038
2039 *val = simple_strtoul(p, &p, 0);
2040
2041 len = p - tmp;
2042
2043 /* We don't know if the next char is whitespace thus we may accept
2044 * invalid integers (e.g. 1234...a) or two integers instead of one
2045 * (e.g. 123...1). So lets not allow such large numbers. */
2046 if (len == TMPBUFLEN - 1)
2047 return -EINVAL;
2048
2049 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2050 return -EINVAL;
2051
2052 if (tr && (len < *size))
2053 *tr = *p;
2054
2055 *buf += len;
2056 *size -= len;
2057
2058 return 0;
2059}
2060
2061/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002062 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002063 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002064 * @buf: the user buffer
2065 * @size: the size of the user buffer
2066 * @val: the integer to be converted
2067 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002068 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002069 * In case of success %0 is returned and @buf and @size are updated with
2070 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002071 */
2072static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2073 bool neg)
2074{
2075 int len;
2076 char tmp[TMPBUFLEN], *p = tmp;
2077
2078 sprintf(p, "%s%lu", neg ? "-" : "", val);
2079 len = strlen(tmp);
2080 if (len > *size)
2081 len = *size;
2082 if (copy_to_user(*buf, tmp, len))
2083 return -EFAULT;
2084 *size -= len;
2085 *buf += len;
2086 return 0;
2087}
2088#undef TMPBUFLEN
2089
2090static int proc_put_char(void __user **buf, size_t *size, char c)
2091{
2092 if (*size) {
2093 char __user **buffer = (char __user **)buf;
2094 if (put_user(c, *buffer))
2095 return -EFAULT;
2096 (*size)--, (*buffer)++;
2097 *buf = *buffer;
2098 }
2099 return 0;
2100}
2101
2102static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002103 int *valp,
2104 int write, void *data)
2105{
2106 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002107 if (*negp) {
2108 if (*lvalp > (unsigned long) INT_MAX + 1)
2109 return -EINVAL;
2110 *valp = -*lvalp;
2111 } else {
2112 if (*lvalp > (unsigned long) INT_MAX)
2113 return -EINVAL;
2114 *valp = *lvalp;
2115 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002116 } else {
2117 int val = *valp;
2118 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002119 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002120 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002121 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002122 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002123 *lvalp = (unsigned long)val;
2124 }
2125 }
2126 return 0;
2127}
2128
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002129static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2130 int *valp,
2131 int write, void *data)
2132{
2133 if (write) {
2134 if (*negp)
2135 return -EINVAL;
2136 *valp = *lvalp;
2137 } else {
2138 unsigned int val = *valp;
Liping Zhang5380e562017-04-07 23:51:06 +08002139 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002140 *lvalp = (unsigned long)val;
2141 }
2142 return 0;
2143}
2144
Amerigo Wang00b7c332010-05-05 00:26:45 +00002145static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2146
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002147static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002148 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002149 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002150 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002151 int write, void *data),
2152 void *data)
2153{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002154 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002155 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002156 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002157
Amerigo Wang00b7c332010-05-05 00:26:45 +00002158 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002159 *lenp = 0;
2160 return 0;
2161 }
2162
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002163 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002164 vleft = table->maxlen / sizeof(*i);
2165 left = *lenp;
2166
2167 if (!conv)
2168 conv = do_proc_dointvec_conv;
2169
Linus Torvalds1da177e2005-04-16 15:20:36 -07002170 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002171 if (*ppos) {
2172 switch (sysctl_writes_strict) {
2173 case SYSCTL_WRITES_STRICT:
2174 goto out;
2175 case SYSCTL_WRITES_WARN:
2176 warn_sysctl_write(table);
2177 break;
2178 default:
2179 break;
2180 }
2181 }
2182
Amerigo Wang00b7c332010-05-05 00:26:45 +00002183 if (left > PAGE_SIZE - 1)
2184 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002185 p = kbuf = memdup_user_nul(buffer, left);
2186 if (IS_ERR(kbuf))
2187 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002188 }
2189
2190 for (; left && vleft--; i++, first=0) {
2191 unsigned long lval;
2192 bool neg;
2193
2194 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002195 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002196
J. R. Okajima563b0462010-05-25 16:10:14 -07002197 if (!left)
2198 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002199 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002200 proc_wspace_sep,
2201 sizeof(proc_wspace_sep), NULL);
2202 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002203 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002204 if (conv(&neg, &lval, i, 1, data)) {
2205 err = -EINVAL;
2206 break;
2207 }
2208 } else {
2209 if (conv(&neg, &lval, i, 0, data)) {
2210 err = -EINVAL;
2211 break;
2212 }
2213 if (!first)
2214 err = proc_put_char(&buffer, &left, '\t');
2215 if (err)
2216 break;
2217 err = proc_put_long(&buffer, &left, lval, neg);
2218 if (err)
2219 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002220 }
2221 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002222
2223 if (!write && !first && left && !err)
2224 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002225 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002226 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002227 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002228 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002229 if (first)
2230 return err ? : -EINVAL;
2231 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002232 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002233out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002234 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002235 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002236}
2237
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002238static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002239 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002240 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002241 int write, void *data),
2242 void *data)
2243{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002244 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002245 buffer, lenp, ppos, conv, data);
2246}
2247
Linus Torvalds1da177e2005-04-16 15:20:36 -07002248/**
2249 * proc_dointvec - read a vector of integers
2250 * @table: the sysctl table
2251 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252 * @buffer: the user buffer
2253 * @lenp: the size of the user buffer
2254 * @ppos: file position
2255 *
2256 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2257 * values from/to the user buffer, treated as an ASCII string.
2258 *
2259 * Returns 0 on success.
2260 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002261int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002262 void __user *buffer, size_t *lenp, loff_t *ppos)
2263{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002264 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2265}
2266
2267/**
2268 * proc_douintvec - read a vector of unsigned integers
2269 * @table: the sysctl table
2270 * @write: %TRUE if this is a write to the sysctl file
2271 * @buffer: the user buffer
2272 * @lenp: the size of the user buffer
2273 * @ppos: file position
2274 *
2275 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2276 * values from/to the user buffer, treated as an ASCII string.
2277 *
2278 * Returns 0 on success.
2279 */
2280int proc_douintvec(struct ctl_table *table, int write,
2281 void __user *buffer, size_t *lenp, loff_t *ppos)
2282{
2283 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2284 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002285}
2286
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002287/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002288 * Taint values can only be increased
2289 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002290 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002291static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002292 void __user *buffer, size_t *lenp, loff_t *ppos)
2293{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002294 struct ctl_table t;
2295 unsigned long tmptaint = get_taint();
2296 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002297
Bastian Blank91fcd412007-04-23 14:41:14 -07002298 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002299 return -EPERM;
2300
Andi Kleen25ddbb12008-10-15 22:01:41 -07002301 t = *table;
2302 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002303 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002304 if (err < 0)
2305 return err;
2306
2307 if (write) {
2308 /*
2309 * Poor man's atomic or. Not worth adding a primitive
2310 * to everyone's atomic.h for this
2311 */
2312 int i;
2313 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2314 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302315 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002316 }
2317 }
2318
2319 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002320}
2321
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002322#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002323static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002324 void __user *buffer, size_t *lenp, loff_t *ppos)
2325{
2326 if (write && !capable(CAP_SYS_ADMIN))
2327 return -EPERM;
2328
2329 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2330}
2331#endif
2332
Linus Torvalds1da177e2005-04-16 15:20:36 -07002333struct do_proc_dointvec_minmax_conv_param {
2334 int *min;
2335 int *max;
2336};
2337
Amerigo Wang00b7c332010-05-05 00:26:45 +00002338static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2339 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002340 int write, void *data)
2341{
2342 struct do_proc_dointvec_minmax_conv_param *param = data;
2343 if (write) {
2344 int val = *negp ? -*lvalp : *lvalp;
2345 if ((param->min && *param->min > val) ||
2346 (param->max && *param->max < val))
2347 return -EINVAL;
2348 *valp = val;
2349 } else {
2350 int val = *valp;
2351 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002352 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002353 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002354 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002355 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356 *lvalp = (unsigned long)val;
2357 }
2358 }
2359 return 0;
2360}
2361
2362/**
2363 * proc_dointvec_minmax - read a vector of integers with min/max values
2364 * @table: the sysctl table
2365 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002366 * @buffer: the user buffer
2367 * @lenp: the size of the user buffer
2368 * @ppos: file position
2369 *
2370 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2371 * values from/to the user buffer, treated as an ASCII string.
2372 *
2373 * This routine will ensure the values are within the range specified by
2374 * table->extra1 (min) and table->extra2 (max).
2375 *
2376 * Returns 0 on success.
2377 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002378int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002379 void __user *buffer, size_t *lenp, loff_t *ppos)
2380{
2381 struct do_proc_dointvec_minmax_conv_param param = {
2382 .min = (int *) table->extra1,
2383 .max = (int *) table->extra2,
2384 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002385 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002386 do_proc_dointvec_minmax_conv, &param);
2387}
2388
Kees Cook54b50192012-07-30 14:39:18 -07002389static void validate_coredump_safety(void)
2390{
Alex Kelly046d6622012-10-04 17:15:23 -07002391#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002392 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002393 core_pattern[0] != '/' && core_pattern[0] != '|') {
Alexey Dobriyan760c6a92016-12-14 15:04:14 -08002394 printk(KERN_WARNING
2395"Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2396"Pipe handler or fully qualified core dump path required.\n"
2397"Set kernel.core_pattern before fs.suid_dumpable.\n"
2398 );
Kees Cook54b50192012-07-30 14:39:18 -07002399 }
Alex Kelly046d6622012-10-04 17:15:23 -07002400#endif
Kees Cook54b50192012-07-30 14:39:18 -07002401}
2402
2403static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2404 void __user *buffer, size_t *lenp, loff_t *ppos)
2405{
2406 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2407 if (!error)
2408 validate_coredump_safety();
2409 return error;
2410}
2411
Alex Kelly046d6622012-10-04 17:15:23 -07002412#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002413static int proc_dostring_coredump(struct ctl_table *table, int write,
2414 void __user *buffer, size_t *lenp, loff_t *ppos)
2415{
2416 int error = proc_dostring(table, write, buffer, lenp, ppos);
2417 if (!error)
2418 validate_coredump_safety();
2419 return error;
2420}
Alex Kelly046d6622012-10-04 17:15:23 -07002421#endif
Kees Cook54b50192012-07-30 14:39:18 -07002422
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002423static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002424 void __user *buffer,
2425 size_t *lenp, loff_t *ppos,
2426 unsigned long convmul,
2427 unsigned long convdiv)
2428{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002429 unsigned long *i, *min, *max;
2430 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002431 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002432 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002433
2434 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002435 *lenp = 0;
2436 return 0;
2437 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002438
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002439 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002440 min = (unsigned long *) table->extra1;
2441 max = (unsigned long *) table->extra2;
2442 vleft = table->maxlen / sizeof(unsigned long);
2443 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002444
2445 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002446 if (*ppos) {
2447 switch (sysctl_writes_strict) {
2448 case SYSCTL_WRITES_STRICT:
2449 goto out;
2450 case SYSCTL_WRITES_WARN:
2451 warn_sysctl_write(table);
2452 break;
2453 default:
2454 break;
2455 }
2456 }
2457
Amerigo Wang00b7c332010-05-05 00:26:45 +00002458 if (left > PAGE_SIZE - 1)
2459 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002460 p = kbuf = memdup_user_nul(buffer, left);
2461 if (IS_ERR(kbuf))
2462 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002463 }
2464
Eric Dumazet27b3d802010-10-07 12:59:29 -07002465 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002466 unsigned long val;
2467
Linus Torvalds1da177e2005-04-16 15:20:36 -07002468 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002469 bool neg;
2470
Al Viro70f6cbb2015-12-24 00:13:10 -05002471 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002472
Al Viro70f6cbb2015-12-24 00:13:10 -05002473 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002474 proc_wspace_sep,
2475 sizeof(proc_wspace_sep), NULL);
2476 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002477 break;
2478 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002479 continue;
Eric Dumazetff9f8a72017-01-25 18:20:55 -08002480 val = convmul * val / convdiv;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002481 if ((min && val < *min) || (max && val > *max))
2482 continue;
2483 *i = val;
2484 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002485 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002486 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002487 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002488 if (err)
2489 break;
2490 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002491 err = proc_put_long(&buffer, &left, val, false);
2492 if (err)
2493 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494 }
2495 }
2496
Amerigo Wang00b7c332010-05-05 00:26:45 +00002497 if (!write && !first && left && !err)
2498 err = proc_put_char(&buffer, &left, '\n');
2499 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002500 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002501 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002502 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002503 if (first)
2504 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002505 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002506 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002507out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002508 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002509 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002510}
2511
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002512static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002513 void __user *buffer,
2514 size_t *lenp, loff_t *ppos,
2515 unsigned long convmul,
2516 unsigned long convdiv)
2517{
2518 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002519 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002520}
2521
Linus Torvalds1da177e2005-04-16 15:20:36 -07002522/**
2523 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2524 * @table: the sysctl table
2525 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002526 * @buffer: the user buffer
2527 * @lenp: the size of the user buffer
2528 * @ppos: file position
2529 *
2530 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2531 * values from/to the user buffer, treated as an ASCII string.
2532 *
2533 * This routine will ensure the values are within the range specified by
2534 * table->extra1 (min) and table->extra2 (max).
2535 *
2536 * Returns 0 on success.
2537 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002538int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002539 void __user *buffer, size_t *lenp, loff_t *ppos)
2540{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002541 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002542}
2543
2544/**
2545 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2546 * @table: the sysctl table
2547 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002548 * @buffer: the user buffer
2549 * @lenp: the size of the user buffer
2550 * @ppos: file position
2551 *
2552 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2553 * values from/to the user buffer, treated as an ASCII string. The values
2554 * are treated as milliseconds, and converted to jiffies when they are stored.
2555 *
2556 * This routine will ensure the values are within the range specified by
2557 * table->extra1 (min) and table->extra2 (max).
2558 *
2559 * Returns 0 on success.
2560 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002561int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002562 void __user *buffer,
2563 size_t *lenp, loff_t *ppos)
2564{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002565 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002566 lenp, ppos, HZ, 1000l);
2567}
2568
2569
Amerigo Wang00b7c332010-05-05 00:26:45 +00002570static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571 int *valp,
2572 int write, void *data)
2573{
2574 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002575 if (*lvalp > LONG_MAX / HZ)
2576 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002577 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2578 } else {
2579 int val = *valp;
2580 unsigned long lval;
2581 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002582 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002583 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002584 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002585 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002586 lval = (unsigned long)val;
2587 }
2588 *lvalp = lval / HZ;
2589 }
2590 return 0;
2591}
2592
Amerigo Wang00b7c332010-05-05 00:26:45 +00002593static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002594 int *valp,
2595 int write, void *data)
2596{
2597 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002598 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2599 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002600 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2601 } else {
2602 int val = *valp;
2603 unsigned long lval;
2604 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002605 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002606 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002607 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002608 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002609 lval = (unsigned long)val;
2610 }
2611 *lvalp = jiffies_to_clock_t(lval);
2612 }
2613 return 0;
2614}
2615
Amerigo Wang00b7c332010-05-05 00:26:45 +00002616static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002617 int *valp,
2618 int write, void *data)
2619{
2620 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002621 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2622
2623 if (jif > INT_MAX)
2624 return 1;
2625 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002626 } 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 = jiffies_to_msecs(lval);
2637 }
2638 return 0;
2639}
2640
2641/**
2642 * proc_dointvec_jiffies - read a vector of integers as seconds
2643 * @table: the sysctl table
2644 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002645 * @buffer: the user buffer
2646 * @lenp: the size of the user buffer
2647 * @ppos: file position
2648 *
2649 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2650 * values from/to the user buffer, treated as an ASCII string.
2651 * The values read are assumed to be in seconds, and are converted into
2652 * jiffies.
2653 *
2654 * Returns 0 on success.
2655 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002656int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002657 void __user *buffer, size_t *lenp, loff_t *ppos)
2658{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002659 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002660 do_proc_dointvec_jiffies_conv,NULL);
2661}
2662
2663/**
2664 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2665 * @table: the sysctl table
2666 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667 * @buffer: the user buffer
2668 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002669 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002670 *
2671 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2672 * values from/to the user buffer, treated as an ASCII string.
2673 * The values read are assumed to be in 1/USER_HZ seconds, and
2674 * are converted into jiffies.
2675 *
2676 * Returns 0 on success.
2677 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002678int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002679 void __user *buffer, size_t *lenp, loff_t *ppos)
2680{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002681 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002682 do_proc_dointvec_userhz_jiffies_conv,NULL);
2683}
2684
2685/**
2686 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2687 * @table: the sysctl table
2688 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002689 * @buffer: the user buffer
2690 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002691 * @ppos: file position
2692 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002693 *
2694 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2695 * values from/to the user buffer, treated as an ASCII string.
2696 * The values read are assumed to be in 1/1000 seconds, and
2697 * are converted into jiffies.
2698 *
2699 * Returns 0 on success.
2700 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002701int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002702 void __user *buffer, size_t *lenp, loff_t *ppos)
2703{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002704 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002705 do_proc_dointvec_ms_jiffies_conv, NULL);
2706}
2707
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002708static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002709 void __user *buffer, size_t *lenp, loff_t *ppos)
2710{
2711 struct pid *new_pid;
2712 pid_t tmp;
2713 int r;
2714
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002715 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002716
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002717 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002718 lenp, ppos, NULL, NULL);
2719 if (r || !write)
2720 return r;
2721
2722 new_pid = find_get_pid(tmp);
2723 if (!new_pid)
2724 return -ESRCH;
2725
2726 put_pid(xchg(&cad_pid, new_pid));
2727 return 0;
2728}
2729
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002730/**
2731 * proc_do_large_bitmap - read/write from/to a large bitmap
2732 * @table: the sysctl table
2733 * @write: %TRUE if this is a write to the sysctl file
2734 * @buffer: the user buffer
2735 * @lenp: the size of the user buffer
2736 * @ppos: file position
2737 *
2738 * The bitmap is stored at table->data and the bitmap length (in bits)
2739 * in table->maxlen.
2740 *
2741 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2742 * large bitmaps may be represented in a compact manner. Writing into
2743 * the file will clear the bitmap then update it with the given input.
2744 *
2745 * Returns 0 on success.
2746 */
2747int proc_do_large_bitmap(struct ctl_table *table, int write,
2748 void __user *buffer, size_t *lenp, loff_t *ppos)
2749{
2750 int err = 0;
2751 bool first = 1;
2752 size_t left = *lenp;
2753 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002754 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002755 unsigned long *tmp_bitmap = NULL;
2756 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2757
WANG Cong122ff242014-05-12 16:04:53 -07002758 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002759 *lenp = 0;
2760 return 0;
2761 }
2762
2763 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002764 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002765
2766 if (left > PAGE_SIZE - 1)
2767 left = PAGE_SIZE - 1;
2768
Al Viro70f6cbb2015-12-24 00:13:10 -05002769 p = kbuf = memdup_user_nul(buffer, left);
2770 if (IS_ERR(kbuf))
2771 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002772
2773 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2774 GFP_KERNEL);
2775 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002776 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002777 return -ENOMEM;
2778 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002779 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002780 while (!err && left) {
2781 unsigned long val_a, val_b;
2782 bool neg;
2783
Al Viro70f6cbb2015-12-24 00:13:10 -05002784 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002785 sizeof(tr_a), &c);
2786 if (err)
2787 break;
2788 if (val_a >= bitmap_len || neg) {
2789 err = -EINVAL;
2790 break;
2791 }
2792
2793 val_b = val_a;
2794 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002795 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002796 left--;
2797 }
2798
2799 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05002800 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002801 &neg, tr_b, sizeof(tr_b),
2802 &c);
2803 if (err)
2804 break;
2805 if (val_b >= bitmap_len || neg ||
2806 val_a > val_b) {
2807 err = -EINVAL;
2808 break;
2809 }
2810 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002811 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002812 left--;
2813 }
2814 }
2815
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002816 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002817 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05002818 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002819 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002820 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002821 } else {
2822 unsigned long bit_a, bit_b = 0;
2823
2824 while (left) {
2825 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2826 if (bit_a >= bitmap_len)
2827 break;
2828 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2829 bit_a + 1) - 1;
2830
2831 if (!first) {
2832 err = proc_put_char(&buffer, &left, ',');
2833 if (err)
2834 break;
2835 }
2836 err = proc_put_long(&buffer, &left, bit_a, false);
2837 if (err)
2838 break;
2839 if (bit_a != bit_b) {
2840 err = proc_put_char(&buffer, &left, '-');
2841 if (err)
2842 break;
2843 err = proc_put_long(&buffer, &left, bit_b, false);
2844 if (err)
2845 break;
2846 }
2847
2848 first = 0; bit_b++;
2849 }
2850 if (!err)
2851 err = proc_put_char(&buffer, &left, '\n');
2852 }
2853
2854 if (!err) {
2855 if (write) {
2856 if (*ppos)
2857 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2858 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002859 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002860 }
2861 kfree(tmp_bitmap);
2862 *lenp -= left;
2863 *ppos += *lenp;
2864 return 0;
2865 } else {
2866 kfree(tmp_bitmap);
2867 return err;
2868 }
2869}
2870
Jovi Zhang55610502011-01-12 17:00:45 -08002871#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002872
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002873int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002874 void __user *buffer, size_t *lenp, loff_t *ppos)
2875{
2876 return -ENOSYS;
2877}
2878
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002879int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002880 void __user *buffer, size_t *lenp, loff_t *ppos)
2881{
2882 return -ENOSYS;
2883}
2884
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002885int proc_douintvec(struct ctl_table *table, int write,
2886 void __user *buffer, size_t *lenp, loff_t *ppos)
2887{
2888 return -ENOSYS;
2889}
2890
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002891int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002892 void __user *buffer, size_t *lenp, loff_t *ppos)
2893{
2894 return -ENOSYS;
2895}
2896
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002897int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002898 void __user *buffer, size_t *lenp, loff_t *ppos)
2899{
2900 return -ENOSYS;
2901}
2902
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002903int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002904 void __user *buffer, size_t *lenp, loff_t *ppos)
2905{
2906 return -ENOSYS;
2907}
2908
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002909int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002910 void __user *buffer, size_t *lenp, loff_t *ppos)
2911{
2912 return -ENOSYS;
2913}
2914
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002915int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002916 void __user *buffer, size_t *lenp, loff_t *ppos)
2917{
2918 return -ENOSYS;
2919}
2920
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002921int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002922 void __user *buffer,
2923 size_t *lenp, loff_t *ppos)
2924{
2925 return -ENOSYS;
2926}
2927
2928
Jovi Zhang55610502011-01-12 17:00:45 -08002929#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002930
Linus Torvalds1da177e2005-04-16 15:20:36 -07002931/*
2932 * No sense putting this after each symbol definition, twice,
2933 * exception granted :-)
2934 */
2935EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002936EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002937EXPORT_SYMBOL(proc_dointvec_jiffies);
2938EXPORT_SYMBOL(proc_dointvec_minmax);
2939EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2940EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2941EXPORT_SYMBOL(proc_dostring);
2942EXPORT_SYMBOL(proc_doulongvec_minmax);
2943EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);