blob: 4dfba1a76cc360f649cbe6f35b57cf9413f2f5e1 [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 Rostedtf38f1d22008-12-16 23:06:40 -0500602#ifdef CONFIG_STACK_TRACER
603 {
Steven Rostedtf38f1d22008-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 Rostedtf38f1d22008-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 Metcalffe4ba3c32015-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,
Myungho Jungb94bf592017-04-19 15:24:50 -07001179 .extra1 = &zero,
1180 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001181 },
1182#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001183#ifdef CONFIG_BPF_SYSCALL
1184 {
1185 .procname = "unprivileged_bpf_disabled",
1186 .data = &sysctl_unprivileged_bpf_disabled,
1187 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1188 .mode = 0644,
1189 /* only handle a transition from default "0" to "1" */
1190 .proc_handler = proc_dointvec_minmax,
1191 .extra1 = &one,
1192 .extra2 = &one,
1193 },
1194#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001195#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1196 {
1197 .procname = "panic_on_rcu_stall",
1198 .data = &sysctl_panic_on_rcu_stall,
1199 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1200 .mode = 0644,
1201 .proc_handler = proc_dointvec_minmax,
1202 .extra1 = &zero,
1203 .extra2 = &one,
1204 },
1205#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001206 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207};
1208
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001209static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001210 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001211 .procname = "overcommit_memory",
1212 .data = &sysctl_overcommit_memory,
1213 .maxlen = sizeof(sysctl_overcommit_memory),
1214 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001215 .proc_handler = proc_dointvec_minmax,
1216 .extra1 = &zero,
1217 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218 },
1219 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001220 .procname = "panic_on_oom",
1221 .data = &sysctl_panic_on_oom,
1222 .maxlen = sizeof(sysctl_panic_on_oom),
1223 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001224 .proc_handler = proc_dointvec_minmax,
1225 .extra1 = &zero,
1226 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001227 },
1228 {
David Rientjesfe071d72007-10-16 23:25:56 -07001229 .procname = "oom_kill_allocating_task",
1230 .data = &sysctl_oom_kill_allocating_task,
1231 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1232 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001233 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001234 },
1235 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001236 .procname = "oom_dump_tasks",
1237 .data = &sysctl_oom_dump_tasks,
1238 .maxlen = sizeof(sysctl_oom_dump_tasks),
1239 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001240 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001241 },
1242 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243 .procname = "overcommit_ratio",
1244 .data = &sysctl_overcommit_ratio,
1245 .maxlen = sizeof(sysctl_overcommit_ratio),
1246 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001247 .proc_handler = overcommit_ratio_handler,
1248 },
1249 {
1250 .procname = "overcommit_kbytes",
1251 .data = &sysctl_overcommit_kbytes,
1252 .maxlen = sizeof(sysctl_overcommit_kbytes),
1253 .mode = 0644,
1254 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255 },
1256 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257 .procname = "page-cluster",
1258 .data = &page_cluster,
1259 .maxlen = sizeof(int),
1260 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001261 .proc_handler = proc_dointvec_minmax,
1262 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001263 },
1264 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001265 .procname = "dirty_background_ratio",
1266 .data = &dirty_background_ratio,
1267 .maxlen = sizeof(dirty_background_ratio),
1268 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001269 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001270 .extra1 = &zero,
1271 .extra2 = &one_hundred,
1272 },
1273 {
David Rientjes2da02992009-01-06 14:39:31 -08001274 .procname = "dirty_background_bytes",
1275 .data = &dirty_background_bytes,
1276 .maxlen = sizeof(dirty_background_bytes),
1277 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001278 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001279 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001280 },
1281 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001282 .procname = "dirty_ratio",
1283 .data = &vm_dirty_ratio,
1284 .maxlen = sizeof(vm_dirty_ratio),
1285 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001286 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001287 .extra1 = &zero,
1288 .extra2 = &one_hundred,
1289 },
1290 {
David Rientjes2da02992009-01-06 14:39:31 -08001291 .procname = "dirty_bytes",
1292 .data = &vm_dirty_bytes,
1293 .maxlen = sizeof(vm_dirty_bytes),
1294 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001295 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001296 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001297 },
1298 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001299 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001300 .data = &dirty_writeback_interval,
1301 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001302 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001303 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001304 },
1305 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001306 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001307 .data = &dirty_expire_interval,
1308 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001309 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001310 .proc_handler = proc_dointvec_minmax,
1311 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312 },
1313 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001314 .procname = "dirtytime_expire_seconds",
1315 .data = &dirtytime_expire_interval,
1316 .maxlen = sizeof(dirty_expire_interval),
1317 .mode = 0644,
1318 .proc_handler = dirtytime_interval_handler,
1319 .extra1 = &zero,
1320 },
1321 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001322 .procname = "nr_pdflush_threads",
1323 .mode = 0444 /* read-only */,
1324 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 },
1326 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001327 .procname = "swappiness",
1328 .data = &vm_swappiness,
1329 .maxlen = sizeof(vm_swappiness),
1330 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001331 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001332 .extra1 = &zero,
1333 .extra2 = &one_hundred,
1334 },
1335#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001336 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001338 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339 .maxlen = sizeof(unsigned long),
1340 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001341 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001342 },
1343#ifdef CONFIG_NUMA
1344 {
1345 .procname = "nr_hugepages_mempolicy",
1346 .data = NULL,
1347 .maxlen = sizeof(unsigned long),
1348 .mode = 0644,
1349 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001350 },
1351#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001352 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 .procname = "hugetlb_shm_group",
1354 .data = &sysctl_hugetlb_shm_group,
1355 .maxlen = sizeof(gid_t),
1356 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001357 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001358 },
Mel Gorman396faf02007-07-17 04:03:13 -07001359 {
Mel Gorman396faf02007-07-17 04:03:13 -07001360 .procname = "hugepages_treat_as_movable",
1361 .data = &hugepages_treat_as_movable,
1362 .maxlen = sizeof(int),
1363 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001364 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001365 },
Adam Litke54f9f802007-10-16 01:26:20 -07001366 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001367 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001368 .data = NULL,
1369 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001370 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001371 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001372 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001373#endif
1374 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001375 .procname = "lowmem_reserve_ratio",
1376 .data = &sysctl_lowmem_reserve_ratio,
1377 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1378 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001379 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001380 },
1381 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001382 .procname = "drop_caches",
1383 .data = &sysctl_drop_caches,
1384 .maxlen = sizeof(int),
1385 .mode = 0644,
1386 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001387 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001388 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001389 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001390#ifdef CONFIG_COMPACTION
1391 {
1392 .procname = "compact_memory",
1393 .data = &sysctl_compact_memory,
1394 .maxlen = sizeof(int),
1395 .mode = 0200,
1396 .proc_handler = sysctl_compaction_handler,
1397 },
Mel Gorman5e771902010-05-24 14:32:31 -07001398 {
1399 .procname = "extfrag_threshold",
1400 .data = &sysctl_extfrag_threshold,
1401 .maxlen = sizeof(int),
1402 .mode = 0644,
1403 .proc_handler = sysctl_extfrag_handler,
1404 .extra1 = &min_extfrag_threshold,
1405 .extra2 = &max_extfrag_threshold,
1406 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001407 {
1408 .procname = "compact_unevictable_allowed",
1409 .data = &sysctl_compact_unevictable_allowed,
1410 .maxlen = sizeof(int),
1411 .mode = 0644,
1412 .proc_handler = proc_dointvec,
1413 .extra1 = &zero,
1414 .extra2 = &one,
1415 },
Mel Gorman5e771902010-05-24 14:32:31 -07001416
Mel Gorman76ab0f52010-05-24 14:32:28 -07001417#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001418 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001419 .procname = "min_free_kbytes",
1420 .data = &min_free_kbytes,
1421 .maxlen = sizeof(min_free_kbytes),
1422 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001423 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001424 .extra1 = &zero,
1425 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001426 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001427 .procname = "watermark_scale_factor",
1428 .data = &watermark_scale_factor,
1429 .maxlen = sizeof(watermark_scale_factor),
1430 .mode = 0644,
1431 .proc_handler = watermark_scale_factor_sysctl_handler,
1432 .extra1 = &one,
1433 .extra2 = &one_thousand,
1434 },
1435 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001436 .procname = "percpu_pagelist_fraction",
1437 .data = &percpu_pagelist_fraction,
1438 .maxlen = sizeof(percpu_pagelist_fraction),
1439 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001440 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001441 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001442 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001443#ifdef CONFIG_MMU
1444 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001445 .procname = "max_map_count",
1446 .data = &sysctl_max_map_count,
1447 .maxlen = sizeof(sysctl_max_map_count),
1448 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001449 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001450 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001451 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001452#else
1453 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001454 .procname = "nr_trim_pages",
1455 .data = &sysctl_nr_trim_pages,
1456 .maxlen = sizeof(sysctl_nr_trim_pages),
1457 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001458 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001459 .extra1 = &zero,
1460 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001461#endif
1462 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001463 .procname = "laptop_mode",
1464 .data = &laptop_mode,
1465 .maxlen = sizeof(laptop_mode),
1466 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001467 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001468 },
1469 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001470 .procname = "block_dump",
1471 .data = &block_dump,
1472 .maxlen = sizeof(block_dump),
1473 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001474 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001475 .extra1 = &zero,
1476 },
1477 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001478 .procname = "vfs_cache_pressure",
1479 .data = &sysctl_vfs_cache_pressure,
1480 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1481 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001482 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001483 .extra1 = &zero,
1484 },
1485#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1486 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001487 .procname = "legacy_va_layout",
1488 .data = &sysctl_legacy_va_layout,
1489 .maxlen = sizeof(sysctl_legacy_va_layout),
1490 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001491 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492 .extra1 = &zero,
1493 },
1494#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001495#ifdef CONFIG_NUMA
1496 {
Christoph Lameter17436602006-01-18 17:42:32 -08001497 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001498 .data = &node_reclaim_mode,
1499 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001500 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001501 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001502 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001503 },
Christoph Lameter96146342006-07-03 00:24:13 -07001504 {
Christoph Lameter96146342006-07-03 00:24:13 -07001505 .procname = "min_unmapped_ratio",
1506 .data = &sysctl_min_unmapped_ratio,
1507 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1508 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001509 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001510 .extra1 = &zero,
1511 .extra2 = &one_hundred,
1512 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001513 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001514 .procname = "min_slab_ratio",
1515 .data = &sysctl_min_slab_ratio,
1516 .maxlen = sizeof(sysctl_min_slab_ratio),
1517 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001518 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001519 .extra1 = &zero,
1520 .extra2 = &one_hundred,
1521 },
Christoph Lameter17436602006-01-18 17:42:32 -08001522#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001523#ifdef CONFIG_SMP
1524 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001525 .procname = "stat_interval",
1526 .data = &sysctl_stat_interval,
1527 .maxlen = sizeof(sysctl_stat_interval),
1528 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001529 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001530 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001531 {
1532 .procname = "stat_refresh",
1533 .data = NULL,
1534 .maxlen = 0,
1535 .mode = 0600,
1536 .proc_handler = vmstat_refresh,
1537 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001538#endif
David Howells6e141542009-12-15 19:27:45 +00001539#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001540 {
Eric Parised032182007-06-28 15:55:21 -04001541 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001542 .data = &dac_mmap_min_addr,
1543 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001544 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001545 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001546 },
David Howells6e141542009-12-15 19:27:45 +00001547#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001548#ifdef CONFIG_NUMA
1549 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001550 .procname = "numa_zonelist_order",
1551 .data = &numa_zonelist_order,
1552 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1553 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001554 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001555 },
1556#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001557#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001558 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001559 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001560 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001561#ifdef CONFIG_X86_32
1562 .data = &vdso32_enabled,
1563 .maxlen = sizeof(vdso32_enabled),
1564#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001565 .data = &vdso_enabled,
1566 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001567#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001568 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001569 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001570 .extra1 = &zero,
1571 },
1572#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001573#ifdef CONFIG_HIGHMEM
1574 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001575 .procname = "highmem_is_dirtyable",
1576 .data = &vm_highmem_is_dirtyable,
1577 .maxlen = sizeof(vm_highmem_is_dirtyable),
1578 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001579 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001580 .extra1 = &zero,
1581 .extra2 = &one,
1582 },
1583#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001584#ifdef CONFIG_MEMORY_FAILURE
1585 {
Andi Kleen6a460792009-09-16 11:50:15 +02001586 .procname = "memory_failure_early_kill",
1587 .data = &sysctl_memory_failure_early_kill,
1588 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1589 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001590 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001591 .extra1 = &zero,
1592 .extra2 = &one,
1593 },
1594 {
Andi Kleen6a460792009-09-16 11:50:15 +02001595 .procname = "memory_failure_recovery",
1596 .data = &sysctl_memory_failure_recovery,
1597 .maxlen = sizeof(sysctl_memory_failure_recovery),
1598 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001599 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001600 .extra1 = &zero,
1601 .extra2 = &one,
1602 },
1603#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001604 {
1605 .procname = "user_reserve_kbytes",
1606 .data = &sysctl_user_reserve_kbytes,
1607 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1608 .mode = 0644,
1609 .proc_handler = proc_doulongvec_minmax,
1610 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001611 {
1612 .procname = "admin_reserve_kbytes",
1613 .data = &sysctl_admin_reserve_kbytes,
1614 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1615 .mode = 0644,
1616 .proc_handler = proc_doulongvec_minmax,
1617 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001618#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1619 {
1620 .procname = "mmap_rnd_bits",
1621 .data = &mmap_rnd_bits,
1622 .maxlen = sizeof(mmap_rnd_bits),
1623 .mode = 0600,
1624 .proc_handler = proc_dointvec_minmax,
1625 .extra1 = (void *)&mmap_rnd_bits_min,
1626 .extra2 = (void *)&mmap_rnd_bits_max,
1627 },
1628#endif
1629#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1630 {
1631 .procname = "mmap_rnd_compat_bits",
1632 .data = &mmap_rnd_compat_bits,
1633 .maxlen = sizeof(mmap_rnd_compat_bits),
1634 .mode = 0600,
1635 .proc_handler = proc_dointvec_minmax,
1636 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1637 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1638 },
1639#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001640 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001641};
1642
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001643static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001644 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001645 .procname = "inode-nr",
1646 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001647 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001648 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001649 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001650 },
1651 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001652 .procname = "inode-state",
1653 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001654 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001656 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001657 },
1658 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001659 .procname = "file-nr",
1660 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001661 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001662 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001663 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664 },
1665 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001666 .procname = "file-max",
1667 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001668 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001669 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001670 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001671 },
1672 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001673 .procname = "nr_open",
1674 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001675 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001676 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001677 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001678 .extra1 = &sysctl_nr_open_min,
1679 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001680 },
1681 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001682 .procname = "dentry-state",
1683 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001684 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001686 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001687 },
1688 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001689 .procname = "overflowuid",
1690 .data = &fs_overflowuid,
1691 .maxlen = sizeof(int),
1692 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001693 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001694 .extra1 = &minolduid,
1695 .extra2 = &maxolduid,
1696 },
1697 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001698 .procname = "overflowgid",
1699 .data = &fs_overflowgid,
1700 .maxlen = sizeof(int),
1701 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001702 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001703 .extra1 = &minolduid,
1704 .extra2 = &maxolduid,
1705 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001706#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001707 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001708 .procname = "leases-enable",
1709 .data = &leases_enable,
1710 .maxlen = sizeof(int),
1711 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001712 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001713 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001714#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001715#ifdef CONFIG_DNOTIFY
1716 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001717 .procname = "dir-notify-enable",
1718 .data = &dir_notify_enable,
1719 .maxlen = sizeof(int),
1720 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001721 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001722 },
1723#endif
1724#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001725#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001726 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001727 .procname = "lease-break-time",
1728 .data = &lease_break_time,
1729 .maxlen = sizeof(int),
1730 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001731 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001732 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001733#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001734#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001735 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736 .procname = "aio-nr",
1737 .data = &aio_nr,
1738 .maxlen = sizeof(aio_nr),
1739 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001740 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001741 },
1742 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001743 .procname = "aio-max-nr",
1744 .data = &aio_max_nr,
1745 .maxlen = sizeof(aio_max_nr),
1746 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001747 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001748 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001749#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001750#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001751 {
Robert Love0399cb02005-07-13 12:38:18 -04001752 .procname = "inotify",
1753 .mode = 0555,
1754 .child = inotify_table,
1755 },
1756#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001757#ifdef CONFIG_EPOLL
1758 {
1759 .procname = "epoll",
1760 .mode = 0555,
1761 .child = epoll_table,
1762 },
1763#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001764#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001765 {
Kees Cook800179c2012-07-25 17:29:07 -07001766 .procname = "protected_symlinks",
1767 .data = &sysctl_protected_symlinks,
1768 .maxlen = sizeof(int),
1769 .mode = 0600,
1770 .proc_handler = proc_dointvec_minmax,
1771 .extra1 = &zero,
1772 .extra2 = &one,
1773 },
1774 {
1775 .procname = "protected_hardlinks",
1776 .data = &sysctl_protected_hardlinks,
1777 .maxlen = sizeof(int),
1778 .mode = 0600,
1779 .proc_handler = proc_dointvec_minmax,
1780 .extra1 = &zero,
1781 .extra2 = &one,
1782 },
1783 {
Alan Coxd6e71142005-06-23 00:09:43 -07001784 .procname = "suid_dumpable",
1785 .data = &suid_dumpable,
1786 .maxlen = sizeof(int),
1787 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001788 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001789 .extra1 = &zero,
1790 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001791 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001792#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1793 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001794 .procname = "binfmt_misc",
1795 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001796 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001797 },
1798#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001799 {
Jens Axboeff9da692010-06-03 14:54:39 +02001800 .procname = "pipe-max-size",
1801 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001802 .maxlen = sizeof(int),
1803 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001804 .proc_handler = &pipe_proc_fn,
1805 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001806 },
Willy Tarreau759c0112016-01-18 16:36:09 +01001807 {
1808 .procname = "pipe-user-pages-hard",
1809 .data = &pipe_user_pages_hard,
1810 .maxlen = sizeof(pipe_user_pages_hard),
1811 .mode = 0644,
1812 .proc_handler = proc_doulongvec_minmax,
1813 },
1814 {
1815 .procname = "pipe-user-pages-soft",
1816 .data = &pipe_user_pages_soft,
1817 .maxlen = sizeof(pipe_user_pages_soft),
1818 .mode = 0644,
1819 .proc_handler = proc_doulongvec_minmax,
1820 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05001821 {
1822 .procname = "mount-max",
1823 .data = &sysctl_mount_max,
1824 .maxlen = sizeof(unsigned int),
1825 .mode = 0644,
1826 .proc_handler = proc_dointvec_minmax,
1827 .extra1 = &one,
1828 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001829 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001830};
1831
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001832static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001833#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001834 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001835 .procname = "exception-trace",
1836 .data = &show_unhandled_signals,
1837 .maxlen = sizeof(int),
1838 .mode = 0644,
1839 .proc_handler = proc_dointvec
1840 },
1841#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001842#if defined(CONFIG_OPTPROBES)
1843 {
1844 .procname = "kprobes-optimization",
1845 .data = &sysctl_kprobes_optimization,
1846 .maxlen = sizeof(int),
1847 .mode = 0644,
1848 .proc_handler = proc_kprobes_optimization_handler,
1849 .extra1 = &zero,
1850 .extra2 = &one,
1851 },
1852#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001853 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001854};
1855
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001856static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001857 { }
Robert Love0eeca282005-07-12 17:06:03 -04001858};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001859
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001860int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001861{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001862 struct ctl_table_header *hdr;
1863
1864 hdr = register_sysctl_table(sysctl_base_table);
1865 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001866 return 0;
1867}
1868
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001869#endif /* CONFIG_SYSCTL */
1870
Linus Torvalds1da177e2005-04-16 15:20:36 -07001871/*
1872 * /proc/sys support
1873 */
1874
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001875#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001876
Kees Cookf8808302014-06-06 14:37:17 -07001877static int _proc_do_string(char *data, int maxlen, int write,
1878 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001879 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001880{
1881 size_t len;
1882 char __user *p;
1883 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001884
1885 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001886 *lenp = 0;
1887 return 0;
1888 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001889
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001890 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001891 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1892 /* Only continue writes not past the end of buffer. */
1893 len = strlen(data);
1894 if (len > maxlen - 1)
1895 len = maxlen - 1;
1896
1897 if (*ppos > len)
1898 return 0;
1899 len = *ppos;
1900 } else {
1901 /* Start writing from beginning of buffer. */
1902 len = 0;
1903 }
1904
Kees Cook2ca9bb42014-06-06 14:37:18 -07001905 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001906 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001907 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001908 if (get_user(c, p++))
1909 return -EFAULT;
1910 if (c == 0 || c == '\n')
1911 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001912 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001913 }
Kees Cookf8808302014-06-06 14:37:17 -07001914 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001915 } else {
1916 len = strlen(data);
1917 if (len > maxlen)
1918 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001919
1920 if (*ppos > len) {
1921 *lenp = 0;
1922 return 0;
1923 }
1924
1925 data += *ppos;
1926 len -= *ppos;
1927
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001928 if (len > *lenp)
1929 len = *lenp;
1930 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001931 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001932 return -EFAULT;
1933 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001934 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001935 return -EFAULT;
1936 len++;
1937 }
1938 *lenp = len;
1939 *ppos += len;
1940 }
1941 return 0;
1942}
1943
Kees Cookf4aacea2014-06-06 14:37:19 -07001944static void warn_sysctl_write(struct ctl_table *table)
1945{
1946 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1947 "This will not be supported in the future. To silence this\n"
1948 "warning, set kernel.sysctl_writes_strict = -1\n",
1949 current->comm, table->procname);
1950}
1951
Linus Torvalds1da177e2005-04-16 15:20:36 -07001952/**
1953 * proc_dostring - read a string sysctl
1954 * @table: the sysctl table
1955 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001956 * @buffer: the user buffer
1957 * @lenp: the size of the user buffer
1958 * @ppos: file position
1959 *
1960 * Reads/writes a string from/to the user buffer. If the kernel
1961 * buffer provided is not large enough to hold the string, the
1962 * string is truncated. The copied string is %NULL-terminated.
1963 * If the string is being read by the user process, it is copied
1964 * and a newline '\n' is added. It is truncated if the buffer is
1965 * not large enough.
1966 *
1967 * Returns 0 on success.
1968 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001969int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001970 void __user *buffer, size_t *lenp, loff_t *ppos)
1971{
Kees Cookf4aacea2014-06-06 14:37:19 -07001972 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
1973 warn_sysctl_write(table);
1974
Kees Cookf8808302014-06-06 14:37:17 -07001975 return _proc_do_string((char *)(table->data), table->maxlen, write,
1976 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001977}
1978
Amerigo Wang00b7c332010-05-05 00:26:45 +00001979static size_t proc_skip_spaces(char **buf)
1980{
1981 size_t ret;
1982 char *tmp = skip_spaces(*buf);
1983 ret = tmp - *buf;
1984 *buf = tmp;
1985 return ret;
1986}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001987
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001988static void proc_skip_char(char **buf, size_t *size, const char v)
1989{
1990 while (*size) {
1991 if (**buf != v)
1992 break;
1993 (*size)--;
1994 (*buf)++;
1995 }
1996}
1997
Amerigo Wang00b7c332010-05-05 00:26:45 +00001998#define TMPBUFLEN 22
1999/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002000 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002001 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002002 * @buf: a kernel buffer
2003 * @size: size of the kernel buffer
2004 * @val: this is where the number will be stored
2005 * @neg: set to %TRUE if number is negative
2006 * @perm_tr: a vector which contains the allowed trailers
2007 * @perm_tr_len: size of the perm_tr vector
2008 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002009 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002010 * In case of success %0 is returned and @buf and @size are updated with
2011 * the amount of bytes read. If @tr is non-NULL and a trailing
2012 * character exists (size is non-zero after returning from this
2013 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002014 */
2015static int proc_get_long(char **buf, size_t *size,
2016 unsigned long *val, bool *neg,
2017 const char *perm_tr, unsigned perm_tr_len, char *tr)
2018{
2019 int len;
2020 char *p, tmp[TMPBUFLEN];
2021
2022 if (!*size)
2023 return -EINVAL;
2024
2025 len = *size;
2026 if (len > TMPBUFLEN - 1)
2027 len = TMPBUFLEN - 1;
2028
2029 memcpy(tmp, *buf, len);
2030
2031 tmp[len] = 0;
2032 p = tmp;
2033 if (*p == '-' && *size > 1) {
2034 *neg = true;
2035 p++;
2036 } else
2037 *neg = false;
2038 if (!isdigit(*p))
2039 return -EINVAL;
2040
2041 *val = simple_strtoul(p, &p, 0);
2042
2043 len = p - tmp;
2044
2045 /* We don't know if the next char is whitespace thus we may accept
2046 * invalid integers (e.g. 1234...a) or two integers instead of one
2047 * (e.g. 123...1). So lets not allow such large numbers. */
2048 if (len == TMPBUFLEN - 1)
2049 return -EINVAL;
2050
2051 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2052 return -EINVAL;
2053
2054 if (tr && (len < *size))
2055 *tr = *p;
2056
2057 *buf += len;
2058 *size -= len;
2059
2060 return 0;
2061}
2062
2063/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002064 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002065 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002066 * @buf: the user buffer
2067 * @size: the size of the user buffer
2068 * @val: the integer to be converted
2069 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002070 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002071 * In case of success %0 is returned and @buf and @size are updated with
2072 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002073 */
2074static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2075 bool neg)
2076{
2077 int len;
2078 char tmp[TMPBUFLEN], *p = tmp;
2079
2080 sprintf(p, "%s%lu", neg ? "-" : "", val);
2081 len = strlen(tmp);
2082 if (len > *size)
2083 len = *size;
2084 if (copy_to_user(*buf, tmp, len))
2085 return -EFAULT;
2086 *size -= len;
2087 *buf += len;
2088 return 0;
2089}
2090#undef TMPBUFLEN
2091
2092static int proc_put_char(void __user **buf, size_t *size, char c)
2093{
2094 if (*size) {
2095 char __user **buffer = (char __user **)buf;
2096 if (put_user(c, *buffer))
2097 return -EFAULT;
2098 (*size)--, (*buffer)++;
2099 *buf = *buffer;
2100 }
2101 return 0;
2102}
2103
2104static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002105 int *valp,
2106 int write, void *data)
2107{
2108 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002109 if (*negp) {
2110 if (*lvalp > (unsigned long) INT_MAX + 1)
2111 return -EINVAL;
2112 *valp = -*lvalp;
2113 } else {
2114 if (*lvalp > (unsigned long) INT_MAX)
2115 return -EINVAL;
2116 *valp = *lvalp;
2117 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002118 } else {
2119 int val = *valp;
2120 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002121 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002122 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002123 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002124 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002125 *lvalp = (unsigned long)val;
2126 }
2127 }
2128 return 0;
2129}
2130
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002131static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2132 int *valp,
2133 int write, void *data)
2134{
2135 if (write) {
2136 if (*negp)
2137 return -EINVAL;
Liping Zhang425fffd2017-04-07 23:51:07 +08002138 if (*lvalp > UINT_MAX)
2139 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002140 *valp = *lvalp;
2141 } else {
2142 unsigned int val = *valp;
Liping Zhang5380e562017-04-07 23:51:06 +08002143 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002144 *lvalp = (unsigned long)val;
2145 }
2146 return 0;
2147}
2148
Amerigo Wang00b7c332010-05-05 00:26:45 +00002149static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2150
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002151static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002152 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002153 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002154 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002155 int write, void *data),
2156 void *data)
2157{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002158 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002159 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002160 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002161
Amerigo Wang00b7c332010-05-05 00:26:45 +00002162 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002163 *lenp = 0;
2164 return 0;
2165 }
2166
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002167 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002168 vleft = table->maxlen / sizeof(*i);
2169 left = *lenp;
2170
2171 if (!conv)
2172 conv = do_proc_dointvec_conv;
2173
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002175 if (*ppos) {
2176 switch (sysctl_writes_strict) {
2177 case SYSCTL_WRITES_STRICT:
2178 goto out;
2179 case SYSCTL_WRITES_WARN:
2180 warn_sysctl_write(table);
2181 break;
2182 default:
2183 break;
2184 }
2185 }
2186
Amerigo Wang00b7c332010-05-05 00:26:45 +00002187 if (left > PAGE_SIZE - 1)
2188 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002189 p = kbuf = memdup_user_nul(buffer, left);
2190 if (IS_ERR(kbuf))
2191 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002192 }
2193
2194 for (; left && vleft--; i++, first=0) {
2195 unsigned long lval;
2196 bool neg;
2197
2198 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002199 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002200
J. R. Okajima563b0462010-05-25 16:10:14 -07002201 if (!left)
2202 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002203 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002204 proc_wspace_sep,
2205 sizeof(proc_wspace_sep), NULL);
2206 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002207 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002208 if (conv(&neg, &lval, i, 1, data)) {
2209 err = -EINVAL;
2210 break;
2211 }
2212 } else {
2213 if (conv(&neg, &lval, i, 0, data)) {
2214 err = -EINVAL;
2215 break;
2216 }
2217 if (!first)
2218 err = proc_put_char(&buffer, &left, '\t');
2219 if (err)
2220 break;
2221 err = proc_put_long(&buffer, &left, lval, neg);
2222 if (err)
2223 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002224 }
2225 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002226
2227 if (!write && !first && left && !err)
2228 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002229 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002230 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002231 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002232 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002233 if (first)
2234 return err ? : -EINVAL;
2235 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002236 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002237out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002238 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002239 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002240}
2241
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002242static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002243 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002244 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002245 int write, void *data),
2246 void *data)
2247{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002248 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002249 buffer, lenp, ppos, conv, data);
2250}
2251
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252/**
2253 * proc_dointvec - read a vector of integers
2254 * @table: the sysctl table
2255 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002256 * @buffer: the user buffer
2257 * @lenp: the size of the user buffer
2258 * @ppos: file position
2259 *
2260 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2261 * values from/to the user buffer, treated as an ASCII string.
2262 *
2263 * Returns 0 on success.
2264 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002265int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002266 void __user *buffer, size_t *lenp, loff_t *ppos)
2267{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002268 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2269}
2270
2271/**
2272 * proc_douintvec - read a vector of unsigned integers
2273 * @table: the sysctl table
2274 * @write: %TRUE if this is a write to the sysctl file
2275 * @buffer: the user buffer
2276 * @lenp: the size of the user buffer
2277 * @ppos: file position
2278 *
2279 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2280 * values from/to the user buffer, treated as an ASCII string.
2281 *
2282 * Returns 0 on success.
2283 */
2284int proc_douintvec(struct ctl_table *table, int write,
2285 void __user *buffer, size_t *lenp, loff_t *ppos)
2286{
2287 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2288 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002289}
2290
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002291/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002292 * Taint values can only be increased
2293 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002294 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002295static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002296 void __user *buffer, size_t *lenp, loff_t *ppos)
2297{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002298 struct ctl_table t;
2299 unsigned long tmptaint = get_taint();
2300 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002301
Bastian Blank91fcd412007-04-23 14:41:14 -07002302 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002303 return -EPERM;
2304
Andi Kleen25ddbb12008-10-15 22:01:41 -07002305 t = *table;
2306 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002307 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002308 if (err < 0)
2309 return err;
2310
2311 if (write) {
2312 /*
2313 * Poor man's atomic or. Not worth adding a primitive
2314 * to everyone's atomic.h for this
2315 */
2316 int i;
2317 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2318 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302319 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002320 }
2321 }
2322
2323 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002324}
2325
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002326#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002327static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002328 void __user *buffer, size_t *lenp, loff_t *ppos)
2329{
2330 if (write && !capable(CAP_SYS_ADMIN))
2331 return -EPERM;
2332
2333 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2334}
2335#endif
2336
Linus Torvalds1da177e2005-04-16 15:20:36 -07002337struct do_proc_dointvec_minmax_conv_param {
2338 int *min;
2339 int *max;
2340};
2341
Amerigo Wang00b7c332010-05-05 00:26:45 +00002342static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2343 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002344 int write, void *data)
2345{
2346 struct do_proc_dointvec_minmax_conv_param *param = data;
2347 if (write) {
2348 int val = *negp ? -*lvalp : *lvalp;
2349 if ((param->min && *param->min > val) ||
2350 (param->max && *param->max < val))
2351 return -EINVAL;
2352 *valp = val;
2353 } else {
2354 int val = *valp;
2355 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002356 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002357 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002358 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002359 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002360 *lvalp = (unsigned long)val;
2361 }
2362 }
2363 return 0;
2364}
2365
2366/**
2367 * proc_dointvec_minmax - read a vector of integers with min/max values
2368 * @table: the sysctl table
2369 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370 * @buffer: the user buffer
2371 * @lenp: the size of the user buffer
2372 * @ppos: file position
2373 *
2374 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2375 * values from/to the user buffer, treated as an ASCII string.
2376 *
2377 * This routine will ensure the values are within the range specified by
2378 * table->extra1 (min) and table->extra2 (max).
2379 *
2380 * Returns 0 on success.
2381 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002382int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002383 void __user *buffer, size_t *lenp, loff_t *ppos)
2384{
2385 struct do_proc_dointvec_minmax_conv_param param = {
2386 .min = (int *) table->extra1,
2387 .max = (int *) table->extra2,
2388 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002389 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390 do_proc_dointvec_minmax_conv, &param);
2391}
2392
Kees Cook54b50192012-07-30 14:39:18 -07002393static void validate_coredump_safety(void)
2394{
Alex Kelly046d6622012-10-04 17:15:23 -07002395#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002396 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002397 core_pattern[0] != '/' && core_pattern[0] != '|') {
Alexey Dobriyan760c6a92016-12-14 15:04:14 -08002398 printk(KERN_WARNING
2399"Unsafe core_pattern used with fs.suid_dumpable=2.\n"
2400"Pipe handler or fully qualified core dump path required.\n"
2401"Set kernel.core_pattern before fs.suid_dumpable.\n"
2402 );
Kees Cook54b50192012-07-30 14:39:18 -07002403 }
Alex Kelly046d6622012-10-04 17:15:23 -07002404#endif
Kees Cook54b50192012-07-30 14:39:18 -07002405}
2406
2407static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2408 void __user *buffer, size_t *lenp, loff_t *ppos)
2409{
2410 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2411 if (!error)
2412 validate_coredump_safety();
2413 return error;
2414}
2415
Alex Kelly046d6622012-10-04 17:15:23 -07002416#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002417static int proc_dostring_coredump(struct ctl_table *table, int write,
2418 void __user *buffer, size_t *lenp, loff_t *ppos)
2419{
2420 int error = proc_dostring(table, write, buffer, lenp, ppos);
2421 if (!error)
2422 validate_coredump_safety();
2423 return error;
2424}
Alex Kelly046d6622012-10-04 17:15:23 -07002425#endif
Kees Cook54b50192012-07-30 14:39:18 -07002426
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002427static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002428 void __user *buffer,
2429 size_t *lenp, loff_t *ppos,
2430 unsigned long convmul,
2431 unsigned long convdiv)
2432{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002433 unsigned long *i, *min, *max;
2434 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002435 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002436 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002437
2438 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 *lenp = 0;
2440 return 0;
2441 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002442
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002443 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002444 min = (unsigned long *) table->extra1;
2445 max = (unsigned long *) table->extra2;
2446 vleft = table->maxlen / sizeof(unsigned long);
2447 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002448
2449 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002450 if (*ppos) {
2451 switch (sysctl_writes_strict) {
2452 case SYSCTL_WRITES_STRICT:
2453 goto out;
2454 case SYSCTL_WRITES_WARN:
2455 warn_sysctl_write(table);
2456 break;
2457 default:
2458 break;
2459 }
2460 }
2461
Amerigo Wang00b7c332010-05-05 00:26:45 +00002462 if (left > PAGE_SIZE - 1)
2463 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002464 p = kbuf = memdup_user_nul(buffer, left);
2465 if (IS_ERR(kbuf))
2466 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002467 }
2468
Eric Dumazet27b3d802010-10-07 12:59:29 -07002469 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002470 unsigned long val;
2471
Linus Torvalds1da177e2005-04-16 15:20:36 -07002472 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002473 bool neg;
2474
Al Viro70f6cbb2015-12-24 00:13:10 -05002475 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002476
Al Viro70f6cbb2015-12-24 00:13:10 -05002477 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002478 proc_wspace_sep,
2479 sizeof(proc_wspace_sep), NULL);
2480 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002481 break;
2482 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002483 continue;
Eric Dumazetff9f8a72017-01-25 18:20:55 -08002484 val = convmul * val / convdiv;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002485 if ((min && val < *min) || (max && val > *max))
2486 continue;
2487 *i = val;
2488 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002489 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002490 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002491 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002492 if (err)
2493 break;
2494 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002495 err = proc_put_long(&buffer, &left, val, false);
2496 if (err)
2497 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002498 }
2499 }
2500
Amerigo Wang00b7c332010-05-05 00:26:45 +00002501 if (!write && !first && left && !err)
2502 err = proc_put_char(&buffer, &left, '\n');
2503 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002504 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002505 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002506 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002507 if (first)
2508 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002509 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002510 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002511out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002512 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002513 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514}
2515
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002516static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002517 void __user *buffer,
2518 size_t *lenp, loff_t *ppos,
2519 unsigned long convmul,
2520 unsigned long convdiv)
2521{
2522 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002523 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002524}
2525
Linus Torvalds1da177e2005-04-16 15:20:36 -07002526/**
2527 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2528 * @table: the sysctl table
2529 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002530 * @buffer: the user buffer
2531 * @lenp: the size of the user buffer
2532 * @ppos: file position
2533 *
2534 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2535 * values from/to the user buffer, treated as an ASCII string.
2536 *
2537 * This routine will ensure the values are within the range specified by
2538 * table->extra1 (min) and table->extra2 (max).
2539 *
2540 * Returns 0 on success.
2541 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002542int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002543 void __user *buffer, size_t *lenp, loff_t *ppos)
2544{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002545 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546}
2547
2548/**
2549 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2550 * @table: the sysctl table
2551 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002552 * @buffer: the user buffer
2553 * @lenp: the size of the user buffer
2554 * @ppos: file position
2555 *
2556 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2557 * values from/to the user buffer, treated as an ASCII string. The values
2558 * are treated as milliseconds, and converted to jiffies when they are stored.
2559 *
2560 * This routine will ensure the values are within the range specified by
2561 * table->extra1 (min) and table->extra2 (max).
2562 *
2563 * Returns 0 on success.
2564 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002565int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002566 void __user *buffer,
2567 size_t *lenp, loff_t *ppos)
2568{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002569 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002570 lenp, ppos, HZ, 1000l);
2571}
2572
2573
Amerigo Wang00b7c332010-05-05 00:26:45 +00002574static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002575 int *valp,
2576 int write, void *data)
2577{
2578 if (write) {
Gao Feng63259452017-05-08 15:54:58 -07002579 if (*lvalp > INT_MAX / HZ)
Bart Samwelcba9f332006-03-24 03:15:50 -08002580 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002581 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2582 } else {
2583 int val = *valp;
2584 unsigned long lval;
2585 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002586 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002587 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002588 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002589 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002590 lval = (unsigned long)val;
2591 }
2592 *lvalp = lval / HZ;
2593 }
2594 return 0;
2595}
2596
Amerigo Wang00b7c332010-05-05 00:26:45 +00002597static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002598 int *valp,
2599 int write, void *data)
2600{
2601 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002602 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2603 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002604 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2605 } else {
2606 int val = *valp;
2607 unsigned long lval;
2608 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002609 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002610 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002611 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002612 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002613 lval = (unsigned long)val;
2614 }
2615 *lvalp = jiffies_to_clock_t(lval);
2616 }
2617 return 0;
2618}
2619
Amerigo Wang00b7c332010-05-05 00:26:45 +00002620static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002621 int *valp,
2622 int write, void *data)
2623{
2624 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002625 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2626
2627 if (jif > INT_MAX)
2628 return 1;
2629 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002630 } else {
2631 int val = *valp;
2632 unsigned long lval;
2633 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002634 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002635 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002636 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002637 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002638 lval = (unsigned long)val;
2639 }
2640 *lvalp = jiffies_to_msecs(lval);
2641 }
2642 return 0;
2643}
2644
2645/**
2646 * proc_dointvec_jiffies - read a vector of integers as seconds
2647 * @table: the sysctl table
2648 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002649 * @buffer: the user buffer
2650 * @lenp: the size of the user buffer
2651 * @ppos: file position
2652 *
2653 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2654 * values from/to the user buffer, treated as an ASCII string.
2655 * The values read are assumed to be in seconds, and are converted into
2656 * jiffies.
2657 *
2658 * Returns 0 on success.
2659 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002660int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002661 void __user *buffer, size_t *lenp, loff_t *ppos)
2662{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002663 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002664 do_proc_dointvec_jiffies_conv,NULL);
2665}
2666
2667/**
2668 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2669 * @table: the sysctl table
2670 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002671 * @buffer: the user buffer
2672 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002673 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002674 *
2675 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2676 * values from/to the user buffer, treated as an ASCII string.
2677 * The values read are assumed to be in 1/USER_HZ seconds, and
2678 * are converted into jiffies.
2679 *
2680 * Returns 0 on success.
2681 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002682int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002683 void __user *buffer, size_t *lenp, loff_t *ppos)
2684{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002685 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002686 do_proc_dointvec_userhz_jiffies_conv,NULL);
2687}
2688
2689/**
2690 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2691 * @table: the sysctl table
2692 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002693 * @buffer: the user buffer
2694 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002695 * @ppos: file position
2696 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002697 *
2698 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2699 * values from/to the user buffer, treated as an ASCII string.
2700 * The values read are assumed to be in 1/1000 seconds, and
2701 * are converted into jiffies.
2702 *
2703 * Returns 0 on success.
2704 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002705int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002706 void __user *buffer, size_t *lenp, loff_t *ppos)
2707{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002708 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002709 do_proc_dointvec_ms_jiffies_conv, NULL);
2710}
2711
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002712static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002713 void __user *buffer, size_t *lenp, loff_t *ppos)
2714{
2715 struct pid *new_pid;
2716 pid_t tmp;
2717 int r;
2718
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002719 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002720
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002721 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002722 lenp, ppos, NULL, NULL);
2723 if (r || !write)
2724 return r;
2725
2726 new_pid = find_get_pid(tmp);
2727 if (!new_pid)
2728 return -ESRCH;
2729
2730 put_pid(xchg(&cad_pid, new_pid));
2731 return 0;
2732}
2733
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002734/**
2735 * proc_do_large_bitmap - read/write from/to a large bitmap
2736 * @table: the sysctl table
2737 * @write: %TRUE if this is a write to the sysctl file
2738 * @buffer: the user buffer
2739 * @lenp: the size of the user buffer
2740 * @ppos: file position
2741 *
2742 * The bitmap is stored at table->data and the bitmap length (in bits)
2743 * in table->maxlen.
2744 *
2745 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2746 * large bitmaps may be represented in a compact manner. Writing into
2747 * the file will clear the bitmap then update it with the given input.
2748 *
2749 * Returns 0 on success.
2750 */
2751int proc_do_large_bitmap(struct ctl_table *table, int write,
2752 void __user *buffer, size_t *lenp, loff_t *ppos)
2753{
2754 int err = 0;
2755 bool first = 1;
2756 size_t left = *lenp;
2757 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002758 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002759 unsigned long *tmp_bitmap = NULL;
2760 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2761
WANG Cong122ff242014-05-12 16:04:53 -07002762 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002763 *lenp = 0;
2764 return 0;
2765 }
2766
2767 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002768 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002769
2770 if (left > PAGE_SIZE - 1)
2771 left = PAGE_SIZE - 1;
2772
Al Viro70f6cbb2015-12-24 00:13:10 -05002773 p = kbuf = memdup_user_nul(buffer, left);
2774 if (IS_ERR(kbuf))
2775 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002776
2777 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2778 GFP_KERNEL);
2779 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002780 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002781 return -ENOMEM;
2782 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002783 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002784 while (!err && left) {
2785 unsigned long val_a, val_b;
2786 bool neg;
2787
Al Viro70f6cbb2015-12-24 00:13:10 -05002788 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002789 sizeof(tr_a), &c);
2790 if (err)
2791 break;
2792 if (val_a >= bitmap_len || neg) {
2793 err = -EINVAL;
2794 break;
2795 }
2796
2797 val_b = val_a;
2798 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002799 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002800 left--;
2801 }
2802
2803 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05002804 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002805 &neg, tr_b, sizeof(tr_b),
2806 &c);
2807 if (err)
2808 break;
2809 if (val_b >= bitmap_len || neg ||
2810 val_a > val_b) {
2811 err = -EINVAL;
2812 break;
2813 }
2814 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002815 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002816 left--;
2817 }
2818 }
2819
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002820 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002821 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05002822 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002823 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002824 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002825 } else {
2826 unsigned long bit_a, bit_b = 0;
2827
2828 while (left) {
2829 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2830 if (bit_a >= bitmap_len)
2831 break;
2832 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2833 bit_a + 1) - 1;
2834
2835 if (!first) {
2836 err = proc_put_char(&buffer, &left, ',');
2837 if (err)
2838 break;
2839 }
2840 err = proc_put_long(&buffer, &left, bit_a, false);
2841 if (err)
2842 break;
2843 if (bit_a != bit_b) {
2844 err = proc_put_char(&buffer, &left, '-');
2845 if (err)
2846 break;
2847 err = proc_put_long(&buffer, &left, bit_b, false);
2848 if (err)
2849 break;
2850 }
2851
2852 first = 0; bit_b++;
2853 }
2854 if (!err)
2855 err = proc_put_char(&buffer, &left, '\n');
2856 }
2857
2858 if (!err) {
2859 if (write) {
2860 if (*ppos)
2861 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2862 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002863 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002864 }
2865 kfree(tmp_bitmap);
2866 *lenp -= left;
2867 *ppos += *lenp;
2868 return 0;
2869 } else {
2870 kfree(tmp_bitmap);
2871 return err;
2872 }
2873}
2874
Jovi Zhang55610502011-01-12 17:00:45 -08002875#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002876
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002877int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002878 void __user *buffer, size_t *lenp, loff_t *ppos)
2879{
2880 return -ENOSYS;
2881}
2882
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002883int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002884 void __user *buffer, size_t *lenp, loff_t *ppos)
2885{
2886 return -ENOSYS;
2887}
2888
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002889int proc_douintvec(struct ctl_table *table, int write,
2890 void __user *buffer, size_t *lenp, loff_t *ppos)
2891{
2892 return -ENOSYS;
2893}
2894
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002895int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002896 void __user *buffer, size_t *lenp, loff_t *ppos)
2897{
2898 return -ENOSYS;
2899}
2900
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002901int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002902 void __user *buffer, size_t *lenp, loff_t *ppos)
2903{
2904 return -ENOSYS;
2905}
2906
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002907int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002908 void __user *buffer, size_t *lenp, loff_t *ppos)
2909{
2910 return -ENOSYS;
2911}
2912
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002913int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002914 void __user *buffer, size_t *lenp, loff_t *ppos)
2915{
2916 return -ENOSYS;
2917}
2918
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002919int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002920 void __user *buffer, size_t *lenp, loff_t *ppos)
2921{
2922 return -ENOSYS;
2923}
2924
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002925int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002926 void __user *buffer,
2927 size_t *lenp, loff_t *ppos)
2928{
2929 return -ENOSYS;
2930}
2931
2932
Jovi Zhang55610502011-01-12 17:00:45 -08002933#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002934
Linus Torvalds1da177e2005-04-16 15:20:36 -07002935/*
2936 * No sense putting this after each symbol definition, twice,
2937 * exception granted :-)
2938 */
2939EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002940EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002941EXPORT_SYMBOL(proc_dointvec_jiffies);
2942EXPORT_SYMBOL(proc_dointvec_minmax);
2943EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2944EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2945EXPORT_SYMBOL(proc_dostring);
2946EXPORT_SYMBOL(proc_doulongvec_minmax);
2947EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);