blob: 23f658d311c05d40797e3459c7fdfcb2df6c046b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
Christoph Hellwige2e40f22015-02-22 08:58:50 -080022#include <linux/aio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/mm.h>
24#include <linux/swap.h>
25#include <linux/slab.h>
26#include <linux/sysctl.h>
Akinobu Mita5a04cca2012-03-28 14:42:50 -070027#include <linux/bitmap.h>
Dave Youngd33ed522010-03-10 15:23:59 -080028#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080029#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070031#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020033#include <linux/kmemcheck.h>
Steven Rostedtfd4b6162012-07-30 14:42:48 -070034#include <linux/kmemleak.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070035#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/init.h>
37#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010038#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030039#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <linux/sysrq.h>
41#include <linux/highuid.h>
42#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020043#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070044#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070047#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#include <linux/times.h>
49#include <linux/limits.h>
50#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020051#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070053#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080054#include <linux/nfs_fs.h>
55#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070056#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020057#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020058#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050059#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020060#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070061#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040062#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070063#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000064#include <linux/binfmts.h>
Clark Williamscf4aebc22013-02-07 09:46:59 -060065#include <linux/sched/sysctl.h>
Kees Cook79847542014-01-23 15:55:59 -080066#include <linux/kexec.h>
Alexei Starovoitov1be7f752015-10-07 22:23:21 -070067#include <linux/bpf.h>
Eric W. Biedermand2921682016-09-28 00:27:17 -050068#include <linux/mount.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70#include <asm/uaccess.h>
71#include <asm/processor.h>
72
Andi Kleen29cbc782006-09-30 01:47:55 +020073#ifdef CONFIG_X86
74#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010075#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010076#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020077#endif
David Howellsd550bbd2012-03-28 18:30:03 +010078#ifdef CONFIG_SPARC
79#include <asm/setup.h>
80#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080081#ifdef CONFIG_BSD_PROCESS_ACCT
82#include <linux/acct.h>
83#endif
Dave Young4f0e0562010-03-10 15:24:09 -080084#ifdef CONFIG_RT_MUTEXES
85#include <linux/rtmutex.h>
86#endif
Dave Young2edf5e42010-03-10 15:24:10 -080087#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
88#include <linux/lockdep.h>
89#endif
Dave Young15485a42010-03-10 15:24:07 -080090#ifdef CONFIG_CHR_DEV_SG
91#include <scsi/sg.h>
92#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020093
Don Zickus58687ac2010-05-07 17:11:44 -040094#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050095#include <linux/nmi.h>
96#endif
97
Linus Torvalds1da177e2005-04-16 15:20:36 -070098#if defined(CONFIG_SYSCTL)
99
100/* External variables not in a header file. */
Alan Coxd6e71142005-06-23 00:09:43 -0700101extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700102#ifdef CONFIG_COREDUMP
103extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700105extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700106#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800109extern int percpu_pagelist_fraction;
Arjan van de Ven97455122008-01-25 21:08:34 +0100110extern int latencytop_enabled;
Alexey Dobriyan9b80a182016-09-02 00:38:52 +0300111extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000112#ifndef CONFIG_MMU
113extern int sysctl_nr_trim_pages;
114#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700116/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400117#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700118static int sixty = 60;
119#endif
120
Aaron Tomlin270750db2014-01-20 17:34:13 +0000121static int __maybe_unused neg_one = -1;
122
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700123static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700124static int __maybe_unused one = 1;
125static int __maybe_unused two = 2;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700126static int __maybe_unused four = 4;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800127static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700128static int one_hundred = 100;
Johannes Weiner795ae7a2016-03-17 14:19:14 -0700129static int one_thousand = 1000;
Dave Youngaf913222009-09-22 16:43:33 -0700130#ifdef CONFIG_PRINTK
131static int ten_thousand = 10000;
132#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300133#ifdef CONFIG_PERF_EVENTS
134static int six_hundred_forty_kb = 640 * 1024;
135#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700136
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700137/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
138static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
141static int maxolduid = 65535;
142static int minolduid;
143
144static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700145static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Liu Hua80df2842014-04-07 15:38:57 -0700147/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
148#ifdef CONFIG_DETECT_HUNG_TASK
149static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
150#endif
151
Dave Youngd14f1722010-02-25 20:28:57 -0500152#ifdef CONFIG_INOTIFY_USER
153#include <linux/inotify.h>
154#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700155#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156#endif
157
158#ifdef __hppa__
159extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530160#endif
161
162#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163extern int unaligned_enabled;
164#endif
165
Jes Sorensend2b176e2006-02-28 09:42:23 -0800166#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800167extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800168#endif
169
Vineet Guptab6fca722013-01-09 20:06:28 +0530170#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
171extern int no_unaligned_warning;
172#endif
173
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700174#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700175
176#define SYSCTL_WRITES_LEGACY -1
177#define SYSCTL_WRITES_WARN 0
178#define SYSCTL_WRITES_STRICT 1
179
Kees Cook41662f52016-01-20 15:00:45 -0800180static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700181
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700182static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700183 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700184static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800185 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700186#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700187
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700188#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700189static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700190 void __user *buffer, size_t *lenp, loff_t *ppos);
191#endif
192
Kees Cook54b50192012-07-30 14:39:18 -0700193static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
194 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700195#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700196static int proc_dostring_coredump(struct ctl_table *table, int write,
197 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700198#endif
Kees Cook54b50192012-07-30 14:39:18 -0700199
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700200#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800201/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100202static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700203
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700204static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700205 void __user *buffer, size_t *lenp,
206 loff_t *ppos)
207{
208 int error;
209
210 error = proc_dointvec(table, write, buffer, lenp, ppos);
211 if (error)
212 return error;
213
214 if (write)
215 sysrq_toggle_support(__sysrq_enabled);
216
217 return 0;
218}
219
220#endif
221
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700222static struct ctl_table kern_table[];
223static struct ctl_table vm_table[];
224static struct ctl_table fs_table[];
225static struct ctl_table debug_table[];
226static struct ctl_table dev_table[];
227extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800228#ifdef CONFIG_EPOLL
229extern struct ctl_table epoll_table[];
230#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
232#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
233int sysctl_legacy_va_layout;
234#endif
235
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236/* The default sysctl tables: */
237
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800238static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 .procname = "kernel",
241 .mode = 0555,
242 .child = kern_table,
243 },
244 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 .procname = "vm",
246 .mode = 0555,
247 .child = vm_table,
248 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 .procname = "fs",
251 .mode = 0555,
252 .child = fs_table,
253 },
254 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 .procname = "debug",
256 .mode = 0555,
257 .child = debug_table,
258 },
259 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 .procname = "dev",
261 .mode = 0555,
262 .child = dev_table,
263 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700264 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265};
266
Ingo Molnar77e54a12007-07-09 18:52:00 +0200267#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100268static int min_sched_granularity_ns = 100000; /* 100 usecs */
269static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
270static int min_wakeup_granularity_ns; /* 0 usecs */
271static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200272#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100273static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
274static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200275#endif /* CONFIG_SMP */
276#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200277
Mel Gorman5e771902010-05-24 14:32:31 -0700278#ifdef CONFIG_COMPACTION
279static int min_extfrag_threshold;
280static int max_extfrag_threshold = 1000;
281#endif
282
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700283static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200284 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200285 .procname = "sched_child_runs_first",
286 .data = &sysctl_sched_child_runs_first,
287 .maxlen = sizeof(unsigned int),
288 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800289 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200290 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200291#ifdef CONFIG_SCHED_DEBUG
292 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100293 .procname = "sched_min_granularity_ns",
294 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200295 .maxlen = sizeof(unsigned int),
296 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800297 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100298 .extra1 = &min_sched_granularity_ns,
299 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200300 },
301 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200302 .procname = "sched_latency_ns",
303 .data = &sysctl_sched_latency,
304 .maxlen = sizeof(unsigned int),
305 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800306 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200307 .extra1 = &min_sched_granularity_ns,
308 .extra2 = &max_sched_granularity_ns,
309 },
310 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200311 .procname = "sched_wakeup_granularity_ns",
312 .data = &sysctl_sched_wakeup_granularity,
313 .maxlen = sizeof(unsigned int),
314 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800315 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200316 .extra1 = &min_wakeup_granularity_ns,
317 .extra2 = &max_wakeup_granularity_ns,
318 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200319#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200320 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100321 .procname = "sched_tunable_scaling",
322 .data = &sysctl_sched_tunable_scaling,
323 .maxlen = sizeof(enum sched_tunable_scaling),
324 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800325 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100326 .extra1 = &min_sched_tunable_scaling,
327 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200328 },
329 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900330 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200331 .data = &sysctl_sched_migration_cost,
332 .maxlen = sizeof(unsigned int),
333 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800334 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200335 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100336 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100337 .procname = "sched_nr_migrate",
338 .data = &sysctl_sched_nr_migrate,
339 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100340 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800341 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100342 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530343 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900344 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200345 .data = &sysctl_sched_time_avg,
346 .maxlen = sizeof(unsigned int),
347 .mode = 0644,
Ethan Zhaofe0034a2017-09-04 13:59:34 +0800348 .proc_handler = proc_dointvec_minmax,
349 .extra1 = &one,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200350 },
351 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900352 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800353 .data = &sysctl_sched_shares_window,
354 .maxlen = sizeof(unsigned int),
355 .mode = 0644,
356 .proc_handler = proc_dointvec,
357 },
Mel Gormancb251762016-02-05 09:08:36 +0000358#ifdef CONFIG_SCHEDSTATS
359 {
360 .procname = "sched_schedstats",
361 .data = NULL,
362 .maxlen = sizeof(unsigned int),
363 .mode = 0644,
364 .proc_handler = sysctl_schedstats,
365 .extra1 = &zero,
366 .extra2 = &one,
367 },
368#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200369#endif /* CONFIG_SMP */
370#ifdef CONFIG_NUMA_BALANCING
371 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200372 .procname = "numa_balancing_scan_delay_ms",
373 .data = &sysctl_numa_balancing_scan_delay,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
376 .proc_handler = proc_dointvec,
377 },
378 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200379 .procname = "numa_balancing_scan_period_min_ms",
380 .data = &sysctl_numa_balancing_scan_period_min,
381 .maxlen = sizeof(unsigned int),
382 .mode = 0644,
383 .proc_handler = proc_dointvec,
384 },
385 {
386 .procname = "numa_balancing_scan_period_max_ms",
387 .data = &sysctl_numa_balancing_scan_period_max,
388 .maxlen = sizeof(unsigned int),
389 .mode = 0644,
390 .proc_handler = proc_dointvec,
391 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200392 {
393 .procname = "numa_balancing_scan_size_mb",
394 .data = &sysctl_numa_balancing_scan_size,
395 .maxlen = sizeof(unsigned int),
396 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400397 .proc_handler = proc_dointvec_minmax,
398 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200399 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100400 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800401 .procname = "numa_balancing",
402 .data = NULL, /* filled in by handler */
403 .maxlen = sizeof(unsigned int),
404 .mode = 0644,
405 .proc_handler = sysctl_numa_balancing,
406 .extra1 = &zero,
407 .extra2 = &one,
408 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200409#endif /* CONFIG_NUMA_BALANCING */
410#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200411 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100412 .procname = "sched_rt_period_us",
413 .data = &sysctl_sched_rt_period,
414 .maxlen = sizeof(unsigned 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 },
418 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100419 .procname = "sched_rt_runtime_us",
420 .data = &sysctl_sched_rt_runtime,
421 .maxlen = sizeof(int),
422 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800423 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100424 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600425 {
426 .procname = "sched_rr_timeslice_ms",
427 .data = &sched_rr_timeslice,
428 .maxlen = sizeof(int),
429 .mode = 0644,
430 .proc_handler = sched_rr_handler,
431 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100432#ifdef CONFIG_SCHED_AUTOGROUP
433 {
434 .procname = "sched_autogroup_enabled",
435 .data = &sysctl_sched_autogroup_enabled,
436 .maxlen = sizeof(unsigned int),
437 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800438 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100439 .extra1 = &zero,
440 .extra2 = &one,
441 },
442#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700443#ifdef CONFIG_CFS_BANDWIDTH
444 {
445 .procname = "sched_cfs_bandwidth_slice_us",
446 .data = &sysctl_sched_cfs_bandwidth_slice,
447 .maxlen = sizeof(unsigned int),
448 .mode = 0644,
449 .proc_handler = proc_dointvec_minmax,
450 .extra1 = &one,
451 },
452#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700453#ifdef CONFIG_PROVE_LOCKING
454 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700455 .procname = "prove_locking",
456 .data = &prove_locking,
457 .maxlen = sizeof(int),
458 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800459 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700460 },
461#endif
462#ifdef CONFIG_LOCK_STAT
463 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700464 .procname = "lock_stat",
465 .data = &lock_stat,
466 .maxlen = sizeof(int),
467 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800468 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700469 },
470#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200471 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 .procname = "panic",
473 .data = &panic_timeout,
474 .maxlen = sizeof(int),
475 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800476 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 },
Alex Kelly046d6622012-10-04 17:15:23 -0700478#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 .procname = "core_uses_pid",
481 .data = &core_uses_pid,
482 .maxlen = sizeof(int),
483 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800484 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 },
486 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 .procname = "core_pattern",
488 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700489 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700491 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 },
Neil Hormana2939802009-09-23 15:56:56 -0700493 {
Neil Hormana2939802009-09-23 15:56:56 -0700494 .procname = "core_pipe_limit",
495 .data = &core_pipe_limit,
496 .maxlen = sizeof(unsigned int),
497 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800498 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700499 },
Alex Kelly046d6622012-10-04 17:15:23 -0700500#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800501#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700504 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800505 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800506 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700508 {
509 .procname = "sysctl_writes_strict",
510 .data = &sysctl_writes_strict,
511 .maxlen = sizeof(int),
512 .mode = 0644,
513 .proc_handler = proc_dointvec_minmax,
514 .extra1 = &neg_one,
515 .extra2 = &one,
516 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800517#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100518#ifdef CONFIG_LATENCYTOP
519 {
520 .procname = "latencytop",
521 .data = &latencytop_enabled,
522 .maxlen = sizeof(int),
523 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000524 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100525 },
526#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527#ifdef CONFIG_BLK_DEV_INITRD
528 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 .procname = "real-root-dev",
530 .data = &real_root_dev,
531 .maxlen = sizeof(int),
532 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800533 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 },
535#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700536 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700537 .procname = "print-fatal-signals",
538 .data = &print_fatal_signals,
539 .maxlen = sizeof(int),
540 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800541 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700542 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700543#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 .procname = "reboot-cmd",
546 .data = reboot_command,
547 .maxlen = 256,
548 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800549 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 },
551 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 .procname = "stop-a",
553 .data = &stop_a_enabled,
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 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 .procname = "scons-poweroff",
560 .data = &scons_pwroff,
561 .maxlen = sizeof (int),
562 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800563 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 },
565#endif
David S. Miller08714202008-11-16 23:49:24 -0800566#ifdef CONFIG_SPARC64
567 {
David S. Miller08714202008-11-16 23:49:24 -0800568 .procname = "tsb-ratio",
569 .data = &sysctl_tsb_ratio,
570 .maxlen = sizeof (int),
571 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800572 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800573 },
574#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575#ifdef __hppa__
576 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 .procname = "soft-power",
578 .data = &pwrsw_enabled,
579 .maxlen = sizeof (int),
580 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800581 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530583#endif
584#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 .procname = "unaligned-trap",
587 .data = &unaligned_enabled,
588 .maxlen = sizeof (int),
589 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800590 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 },
592#endif
593 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 .procname = "ctrl-alt-del",
595 .data = &C_A_D,
596 .maxlen = sizeof(int),
597 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800598 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400600#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200601 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200602 .procname = "ftrace_enabled",
603 .data = &ftrace_enabled,
604 .maxlen = sizeof(int),
605 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800606 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200607 },
608#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500609#ifdef CONFIG_STACK_TRACER
610 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500611 .procname = "stack_tracer_enabled",
612 .data = &stack_tracer_enabled,
613 .maxlen = sizeof(int),
614 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800615 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500616 },
617#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400618#ifdef CONFIG_TRACING
619 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100620 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400621 .data = &ftrace_dump_on_oops,
622 .maxlen = sizeof(int),
623 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800624 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400625 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400626 {
627 .procname = "traceoff_on_warning",
628 .data = &__disable_trace_on_warning,
629 .maxlen = sizeof(__disable_trace_on_warning),
630 .mode = 0644,
631 .proc_handler = proc_dointvec,
632 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500633 {
634 .procname = "tracepoint_printk",
635 .data = &tracepoint_printk,
636 .maxlen = sizeof(tracepoint_printk),
637 .mode = 0644,
638 .proc_handler = proc_dointvec,
639 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400640#endif
Dave Young2965faa2015-09-09 15:38:55 -0700641#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800642 {
643 .procname = "kexec_load_disabled",
644 .data = &kexec_load_disabled,
645 .maxlen = sizeof(int),
646 .mode = 0644,
647 /* only handle a transition from default "0" to "1" */
648 .proc_handler = proc_dointvec_minmax,
649 .extra1 = &one,
650 .extra2 = &one,
651 },
652#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200653#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 .procname = "modprobe",
656 .data = &modprobe_path,
657 .maxlen = KMOD_PATH_LEN,
658 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800659 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 },
Kees Cook3d433212009-04-02 15:49:29 -0700661 {
Kees Cook3d433212009-04-02 15:49:29 -0700662 .procname = "modules_disabled",
663 .data = &modules_disabled,
664 .maxlen = sizeof(int),
665 .mode = 0644,
666 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800667 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700668 .extra1 = &one,
669 .extra2 = &one,
670 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700672#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100675 .data = &uevent_helper,
676 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800678 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 },
Michael Marineau86d56132014-04-10 14:09:31 -0700680#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681#ifdef CONFIG_CHR_DEV_SG
682 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 .procname = "sg-big-buff",
684 .data = &sg_big_buff,
685 .maxlen = sizeof (int),
686 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800687 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 },
689#endif
690#ifdef CONFIG_BSD_PROCESS_ACCT
691 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 .procname = "acct",
693 .data = &acct_parm,
694 .maxlen = 3*sizeof(int),
695 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800696 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 },
698#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699#ifdef CONFIG_MAGIC_SYSRQ
700 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800702 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 .maxlen = sizeof (int),
704 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700705 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 },
707#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700708#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700711 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 .maxlen = sizeof (int),
713 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800714 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700716#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700719 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 .maxlen = sizeof(int),
721 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700722 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 },
724 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 .procname = "random",
726 .mode = 0555,
727 .child = random_table,
728 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 {
Eric Paris17f60a72011-04-01 17:07:50 -0400730 .procname = "usermodehelper",
731 .mode = 0555,
732 .child = usermodehelper_table,
733 },
734 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 .procname = "overflowuid",
736 .data = &overflowuid,
737 .maxlen = sizeof(int),
738 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800739 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 .extra1 = &minolduid,
741 .extra2 = &maxolduid,
742 },
743 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 .procname = "overflowgid",
745 .data = &overflowgid,
746 .maxlen = sizeof(int),
747 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800748 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 .extra1 = &minolduid,
750 .extra2 = &maxolduid,
751 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800752#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753#ifdef CONFIG_MATHEMU
754 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 .procname = "ieee_emulation_warnings",
756 .data = &sysctl_ieee_emulation_warnings,
757 .maxlen = sizeof(int),
758 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800759 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 },
761#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200764 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 .maxlen = sizeof(int),
766 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800767 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 },
769#endif
770 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 .procname = "pid_max",
772 .data = &pid_max,
773 .maxlen = sizeof (int),
774 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800775 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 .extra1 = &pid_max_min,
777 .extra2 = &pid_max_max,
778 },
779 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 .procname = "panic_on_oops",
781 .data = &panic_on_oops,
782 .maxlen = sizeof(int),
783 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800784 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800786#if defined CONFIG_PRINTK
787 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800788 .procname = "printk",
789 .data = &console_loglevel,
790 .maxlen = 4*sizeof(int),
791 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800792 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800793 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700796 .data = &printk_ratelimit_state.interval,
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_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 },
801 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700803 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 .maxlen = sizeof(int),
805 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800806 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 },
Dave Youngaf913222009-09-22 16:43:33 -0700808 {
Dave Youngaf913222009-09-22 16:43:33 -0700809 .procname = "printk_delay",
810 .data = &printk_delay_msec,
811 .maxlen = sizeof(int),
812 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800813 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700814 .extra1 = &zero,
815 .extra2 = &ten_thousand,
816 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700818 .procname = "printk_devkmsg",
819 .data = devkmsg_log_str,
820 .maxlen = DEVKMSG_STR_MAX_SIZE,
821 .mode = 0644,
822 .proc_handler = devkmsg_sysctl_set_loglvl,
823 },
824 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800825 .procname = "dmesg_restrict",
826 .data = &dmesg_restrict,
827 .maxlen = sizeof(int),
828 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700829 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800830 .extra1 = &zero,
831 .extra2 = &one,
832 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800833 {
834 .procname = "kptr_restrict",
835 .data = &kptr_restrict,
836 .maxlen = sizeof(int),
837 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700838 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800839 .extra1 = &zero,
840 .extra2 = &two,
841 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800842#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800843 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 .procname = "ngroups_max",
845 .data = &ngroups_max,
846 .maxlen = sizeof (int),
847 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800848 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 },
Dan Ballard73efc032011-10-31 17:11:20 -0700850 {
851 .procname = "cap_last_cap",
852 .data = (void *)&cap_last_cap,
853 .maxlen = sizeof(int),
854 .mode = 0444,
855 .proc_handler = proc_dointvec,
856 },
Don Zickus58687ac2010-05-07 17:11:44 -0400857#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500858 {
Don Zickus58687ac2010-05-07 17:11:44 -0400859 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200860 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500861 .maxlen = sizeof (int),
862 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700863 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700864 .extra1 = &zero,
865 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400866 },
867 {
868 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700869 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400870 .maxlen = sizeof(int),
871 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700872 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800873 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400874 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500875 },
Don Zickus2508ce12010-05-07 17:11:46 -0400876 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700877 .procname = "nmi_watchdog",
878 .data = &nmi_watchdog_enabled,
879 .maxlen = sizeof (int),
880 .mode = 0644,
881 .proc_handler = proc_nmi_watchdog,
882 .extra1 = &zero,
883#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
884 .extra2 = &one,
885#else
886 .extra2 = &zero,
887#endif
888 },
889 {
890 .procname = "soft_watchdog",
891 .data = &soft_watchdog_enabled,
892 .maxlen = sizeof (int),
893 .mode = 0644,
894 .proc_handler = proc_soft_watchdog,
895 .extra1 = &zero,
896 .extra2 = &one,
897 },
898 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700899 .procname = "watchdog_cpumask",
900 .data = &watchdog_cpumask_bits,
901 .maxlen = NR_CPUS,
902 .mode = 0644,
903 .proc_handler = proc_watchdog_cpumask,
904 },
905 {
Don Zickus2508ce12010-05-07 17:11:46 -0400906 .procname = "softlockup_panic",
907 .data = &softlockup_panic,
908 .maxlen = sizeof(int),
909 .mode = 0644,
910 .proc_handler = proc_dointvec_minmax,
911 .extra1 = &zero,
912 .extra2 = &one,
913 },
Don Zickusac1f5912015-11-05 18:44:44 -0800914#ifdef CONFIG_HARDLOCKUP_DETECTOR
915 {
916 .procname = "hardlockup_panic",
917 .data = &hardlockup_panic,
918 .maxlen = sizeof(int),
919 .mode = 0644,
920 .proc_handler = proc_dointvec_minmax,
921 .extra1 = &zero,
922 .extra2 = &one,
923 },
924#endif
Aaron Tomlined235872014-06-23 13:22:05 -0700925#ifdef CONFIG_SMP
926 {
927 .procname = "softlockup_all_cpu_backtrace",
928 .data = &sysctl_softlockup_all_cpu_backtrace,
929 .maxlen = sizeof(int),
930 .mode = 0644,
931 .proc_handler = proc_dointvec_minmax,
932 .extra1 = &zero,
933 .extra2 = &one,
934 },
Jiri Kosina55537872015-11-05 18:44:41 -0800935 {
936 .procname = "hardlockup_all_cpu_backtrace",
937 .data = &sysctl_hardlockup_all_cpu_backtrace,
938 .maxlen = sizeof(int),
939 .mode = 0644,
940 .proc_handler = proc_dointvec_minmax,
941 .extra1 = &zero,
942 .extra2 = &one,
943 },
Aaron Tomlined235872014-06-23 13:22:05 -0700944#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -0500945#endif
946#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
947 {
948 .procname = "unknown_nmi_panic",
949 .data = &unknown_nmi_panic,
950 .maxlen = sizeof (int),
951 .mode = 0644,
952 .proc_handler = proc_dointvec,
953 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500954#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955#if defined(CONFIG_X86)
956 {
Don Zickus8da5add2006-09-26 10:52:27 +0200957 .procname = "panic_on_unrecovered_nmi",
958 .data = &panic_on_unrecovered_nmi,
959 .maxlen = sizeof(int),
960 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800961 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200962 },
963 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700964 .procname = "panic_on_io_nmi",
965 .data = &panic_on_io_nmi,
966 .maxlen = sizeof(int),
967 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800968 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700969 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900970#ifdef CONFIG_DEBUG_STACKOVERFLOW
971 {
972 .procname = "panic_on_stackoverflow",
973 .data = &sysctl_panic_on_stackoverflow,
974 .maxlen = sizeof(int),
975 .mode = 0644,
976 .proc_handler = proc_dointvec,
977 },
978#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700979 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 .procname = "bootloader_type",
981 .data = &bootloader_type,
982 .maxlen = sizeof (int),
983 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800984 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100986 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700987 .procname = "bootloader_version",
988 .data = &bootloader_version,
989 .maxlen = sizeof (int),
990 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800991 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700992 },
993 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100994 .procname = "kstack_depth_to_print",
995 .data = &kstack_depth_to_print,
996 .maxlen = sizeof(int),
997 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800998 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100999 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001000 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001001 .procname = "io_delay_type",
1002 .data = &io_delay_type,
1003 .maxlen = sizeof(int),
1004 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001005 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001006 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001007#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001008#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001009 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010 .procname = "randomize_va_space",
1011 .data = &randomize_va_space,
1012 .maxlen = sizeof(int),
1013 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001014 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001016#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001017#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001018 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001019 .procname = "spin_retry",
1020 .data = &spin_retry,
1021 .maxlen = sizeof (int),
1022 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001023 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001024 },
1025#endif
Len Brown673d5b42007-07-28 03:33:16 -04001026#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001027 {
Pavel Machekc255d842006-02-20 18:27:58 -08001028 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001029 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001030 .maxlen = sizeof (unsigned long),
1031 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001032 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001033 },
1034#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301035#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001036 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001037 .procname = "ignore-unaligned-usertrap",
1038 .data = &no_unaligned_warning,
1039 .maxlen = sizeof (int),
1040 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001041 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001042 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301043#endif
1044#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001045 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001046 .procname = "unaligned-dump-stack",
1047 .data = &unaligned_dump_stack,
1048 .maxlen = sizeof (int),
1049 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001050 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001051 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001052#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001053#ifdef CONFIG_DETECT_HUNG_TASK
1054 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001055 .procname = "hung_task_panic",
1056 .data = &sysctl_hung_task_panic,
1057 .maxlen = sizeof(int),
1058 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001059 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001060 .extra1 = &zero,
1061 .extra2 = &one,
1062 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001063 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001064 .procname = "hung_task_check_count",
1065 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001066 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001067 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001068 .proc_handler = proc_dointvec_minmax,
1069 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001070 },
1071 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001072 .procname = "hung_task_timeout_secs",
1073 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001074 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001075 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001076 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001077 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001078 },
1079 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001080 .procname = "hung_task_warnings",
1081 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001082 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001083 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001084 .proc_handler = proc_dointvec_minmax,
1085 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001086 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001087#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001088#ifdef CONFIG_RT_MUTEXES
1089 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001090 .procname = "max_lock_depth",
1091 .data = &max_lock_depth,
1092 .maxlen = sizeof(int),
1093 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001094 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001095 },
1096#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001097 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001098 .procname = "poweroff_cmd",
1099 .data = &poweroff_cmd,
1100 .maxlen = POWEROFF_CMD_PATH_LEN,
1101 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001102 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001103 },
David Howells0b77f5b2008-04-29 01:01:32 -07001104#ifdef CONFIG_KEYS
1105 {
David Howells0b77f5b2008-04-29 01:01:32 -07001106 .procname = "keys",
1107 .mode = 0555,
1108 .child = key_sysctls,
1109 },
1110#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001111#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001112 /*
1113 * User-space scripts rely on the existence of this file
1114 * as a feature check for perf_events being enabled.
1115 *
1116 * So it's an ABI, do not remove!
1117 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001118 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001119 .procname = "perf_event_paranoid",
1120 .data = &sysctl_perf_event_paranoid,
1121 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001122 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001123 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001124 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001125 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001126 .procname = "perf_event_mlock_kb",
1127 .data = &sysctl_perf_event_mlock,
1128 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001129 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001130 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001131 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001132 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001133 .procname = "perf_event_max_sample_rate",
1134 .data = &sysctl_perf_event_sample_rate,
1135 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001136 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001137 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001138 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001139 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001140 {
1141 .procname = "perf_cpu_time_max_percent",
1142 .data = &sysctl_perf_cpu_time_max_percent,
1143 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1144 .mode = 0644,
1145 .proc_handler = perf_cpu_time_max_percent_handler,
1146 .extra1 = &zero,
1147 .extra2 = &one_hundred,
1148 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001149 {
1150 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001151 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001152 .maxlen = sizeof(sysctl_perf_event_max_stack),
1153 .mode = 0644,
1154 .proc_handler = perf_event_max_stack_handler,
1155 .extra1 = &zero,
1156 .extra2 = &six_hundred_forty_kb,
1157 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001158 {
1159 .procname = "perf_event_max_contexts_per_stack",
1160 .data = &sysctl_perf_event_max_contexts_per_stack,
1161 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1162 .mode = 0644,
1163 .proc_handler = perf_event_max_stack_handler,
1164 .extra1 = &zero,
1165 .extra2 = &one_thousand,
1166 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001167#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001168#ifdef CONFIG_KMEMCHECK
1169 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001170 .procname = "kmemcheck",
1171 .data = &kmemcheck_enabled,
1172 .maxlen = sizeof(int),
1173 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001174 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001175 },
1176#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001177 {
1178 .procname = "panic_on_warn",
1179 .data = &panic_on_warn,
1180 .maxlen = sizeof(int),
1181 .mode = 0644,
1182 .proc_handler = proc_dointvec_minmax,
1183 .extra1 = &zero,
1184 .extra2 = &one,
1185 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001186#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1187 {
1188 .procname = "timer_migration",
1189 .data = &sysctl_timer_migration,
1190 .maxlen = sizeof(unsigned int),
1191 .mode = 0644,
1192 .proc_handler = timer_migration_handler,
Myungho Jung4c000152017-04-19 15:24:50 -07001193 .extra1 = &zero,
1194 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001195 },
1196#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001197#ifdef CONFIG_BPF_SYSCALL
1198 {
1199 .procname = "unprivileged_bpf_disabled",
1200 .data = &sysctl_unprivileged_bpf_disabled,
1201 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1202 .mode = 0644,
1203 /* only handle a transition from default "0" to "1" */
1204 .proc_handler = proc_dointvec_minmax,
1205 .extra1 = &one,
1206 .extra2 = &one,
1207 },
1208#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001209#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1210 {
1211 .procname = "panic_on_rcu_stall",
1212 .data = &sysctl_panic_on_rcu_stall,
1213 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1214 .mode = 0644,
1215 .proc_handler = proc_dointvec_minmax,
1216 .extra1 = &zero,
1217 .extra2 = &one,
1218 },
1219#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001220 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001221};
1222
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001223static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001224 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225 .procname = "overcommit_memory",
1226 .data = &sysctl_overcommit_memory,
1227 .maxlen = sizeof(sysctl_overcommit_memory),
1228 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001229 .proc_handler = proc_dointvec_minmax,
1230 .extra1 = &zero,
1231 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232 },
1233 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001234 .procname = "panic_on_oom",
1235 .data = &sysctl_panic_on_oom,
1236 .maxlen = sizeof(sysctl_panic_on_oom),
1237 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001238 .proc_handler = proc_dointvec_minmax,
1239 .extra1 = &zero,
1240 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001241 },
1242 {
David Rientjesfe071d72007-10-16 23:25:56 -07001243 .procname = "oom_kill_allocating_task",
1244 .data = &sysctl_oom_kill_allocating_task,
1245 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1246 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001247 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001248 },
1249 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001250 .procname = "oom_dump_tasks",
1251 .data = &sysctl_oom_dump_tasks,
1252 .maxlen = sizeof(sysctl_oom_dump_tasks),
1253 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001254 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001255 },
1256 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257 .procname = "overcommit_ratio",
1258 .data = &sysctl_overcommit_ratio,
1259 .maxlen = sizeof(sysctl_overcommit_ratio),
1260 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001261 .proc_handler = overcommit_ratio_handler,
1262 },
1263 {
1264 .procname = "overcommit_kbytes",
1265 .data = &sysctl_overcommit_kbytes,
1266 .maxlen = sizeof(sysctl_overcommit_kbytes),
1267 .mode = 0644,
1268 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001269 },
1270 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271 .procname = "page-cluster",
1272 .data = &page_cluster,
1273 .maxlen = sizeof(int),
1274 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001275 .proc_handler = proc_dointvec_minmax,
1276 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001277 },
1278 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001279 .procname = "dirty_background_ratio",
1280 .data = &dirty_background_ratio,
1281 .maxlen = sizeof(dirty_background_ratio),
1282 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001283 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001284 .extra1 = &zero,
1285 .extra2 = &one_hundred,
1286 },
1287 {
David Rientjes2da02992009-01-06 14:39:31 -08001288 .procname = "dirty_background_bytes",
1289 .data = &dirty_background_bytes,
1290 .maxlen = sizeof(dirty_background_bytes),
1291 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001292 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001293 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001294 },
1295 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001296 .procname = "dirty_ratio",
1297 .data = &vm_dirty_ratio,
1298 .maxlen = sizeof(vm_dirty_ratio),
1299 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001300 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001301 .extra1 = &zero,
1302 .extra2 = &one_hundred,
1303 },
1304 {
David Rientjes2da02992009-01-06 14:39:31 -08001305 .procname = "dirty_bytes",
1306 .data = &vm_dirty_bytes,
1307 .maxlen = sizeof(vm_dirty_bytes),
1308 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001309 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001310 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001311 },
1312 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001313 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001314 .data = &dirty_writeback_interval,
1315 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001317 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001318 },
1319 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001321 .data = &dirty_expire_interval,
1322 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001324 .proc_handler = proc_dointvec_minmax,
1325 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001326 },
1327 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001328 .procname = "dirtytime_expire_seconds",
1329 .data = &dirtytime_expire_interval,
1330 .maxlen = sizeof(dirty_expire_interval),
1331 .mode = 0644,
1332 .proc_handler = dirtytime_interval_handler,
1333 .extra1 = &zero,
1334 },
1335 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001336 .procname = "nr_pdflush_threads",
1337 .mode = 0444 /* read-only */,
1338 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339 },
1340 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001341 .procname = "swappiness",
1342 .data = &vm_swappiness,
1343 .maxlen = sizeof(vm_swappiness),
1344 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001345 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001346 .extra1 = &zero,
1347 .extra2 = &one_hundred,
1348 },
1349#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001350 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001351 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001352 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 .maxlen = sizeof(unsigned long),
1354 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001355 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001356 },
1357#ifdef CONFIG_NUMA
1358 {
1359 .procname = "nr_hugepages_mempolicy",
1360 .data = NULL,
1361 .maxlen = sizeof(unsigned long),
1362 .mode = 0644,
1363 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001364 },
1365#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001366 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001367 .procname = "hugetlb_shm_group",
1368 .data = &sysctl_hugetlb_shm_group,
1369 .maxlen = sizeof(gid_t),
1370 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001371 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372 },
Mel Gorman396faf02007-07-17 04:03:13 -07001373 {
Mel Gorman396faf02007-07-17 04:03:13 -07001374 .procname = "hugepages_treat_as_movable",
1375 .data = &hugepages_treat_as_movable,
1376 .maxlen = sizeof(int),
1377 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001378 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001379 },
Adam Litke54f9f802007-10-16 01:26:20 -07001380 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001381 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001382 .data = NULL,
1383 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001384 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001385 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001386 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001387#endif
1388 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389 .procname = "lowmem_reserve_ratio",
1390 .data = &sysctl_lowmem_reserve_ratio,
1391 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1392 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001393 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001394 },
1395 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001396 .procname = "drop_caches",
1397 .data = &sysctl_drop_caches,
1398 .maxlen = sizeof(int),
1399 .mode = 0644,
1400 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001401 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001402 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001403 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001404#ifdef CONFIG_COMPACTION
1405 {
1406 .procname = "compact_memory",
1407 .data = &sysctl_compact_memory,
1408 .maxlen = sizeof(int),
1409 .mode = 0200,
1410 .proc_handler = sysctl_compaction_handler,
1411 },
Mel Gorman5e771902010-05-24 14:32:31 -07001412 {
1413 .procname = "extfrag_threshold",
1414 .data = &sysctl_extfrag_threshold,
1415 .maxlen = sizeof(int),
1416 .mode = 0644,
1417 .proc_handler = sysctl_extfrag_handler,
1418 .extra1 = &min_extfrag_threshold,
1419 .extra2 = &max_extfrag_threshold,
1420 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001421 {
1422 .procname = "compact_unevictable_allowed",
1423 .data = &sysctl_compact_unevictable_allowed,
1424 .maxlen = sizeof(int),
1425 .mode = 0644,
1426 .proc_handler = proc_dointvec,
1427 .extra1 = &zero,
1428 .extra2 = &one,
1429 },
Mel Gorman5e771902010-05-24 14:32:31 -07001430
Mel Gorman76ab0f52010-05-24 14:32:28 -07001431#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001432 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001433 .procname = "min_free_kbytes",
1434 .data = &min_free_kbytes,
1435 .maxlen = sizeof(min_free_kbytes),
1436 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001437 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001438 .extra1 = &zero,
1439 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001440 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001441 .procname = "watermark_scale_factor",
1442 .data = &watermark_scale_factor,
1443 .maxlen = sizeof(watermark_scale_factor),
1444 .mode = 0644,
1445 .proc_handler = watermark_scale_factor_sysctl_handler,
1446 .extra1 = &one,
1447 .extra2 = &one_thousand,
1448 },
1449 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001450 .procname = "percpu_pagelist_fraction",
1451 .data = &percpu_pagelist_fraction,
1452 .maxlen = sizeof(percpu_pagelist_fraction),
1453 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001454 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001455 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001456 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457#ifdef CONFIG_MMU
1458 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459 .procname = "max_map_count",
1460 .data = &sysctl_max_map_count,
1461 .maxlen = sizeof(sysctl_max_map_count),
1462 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001463 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001464 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001466#else
1467 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001468 .procname = "nr_trim_pages",
1469 .data = &sysctl_nr_trim_pages,
1470 .maxlen = sizeof(sysctl_nr_trim_pages),
1471 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001472 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001473 .extra1 = &zero,
1474 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001475#endif
1476 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 .procname = "laptop_mode",
1478 .data = &laptop_mode,
1479 .maxlen = sizeof(laptop_mode),
1480 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001481 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001482 },
1483 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001484 .procname = "block_dump",
1485 .data = &block_dump,
1486 .maxlen = sizeof(block_dump),
1487 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001488 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001489 .extra1 = &zero,
1490 },
1491 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492 .procname = "vfs_cache_pressure",
1493 .data = &sysctl_vfs_cache_pressure,
1494 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1495 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001496 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001497 .extra1 = &zero,
1498 },
1499#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1500 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 .procname = "legacy_va_layout",
1502 .data = &sysctl_legacy_va_layout,
1503 .maxlen = sizeof(sysctl_legacy_va_layout),
1504 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001505 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506 .extra1 = &zero,
1507 },
1508#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001509#ifdef CONFIG_NUMA
1510 {
Christoph Lameter17436602006-01-18 17:42:32 -08001511 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001512 .data = &node_reclaim_mode,
1513 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001514 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001515 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001516 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001517 },
Christoph Lameter96146342006-07-03 00:24:13 -07001518 {
Christoph Lameter96146342006-07-03 00:24:13 -07001519 .procname = "min_unmapped_ratio",
1520 .data = &sysctl_min_unmapped_ratio,
1521 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1522 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001523 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001524 .extra1 = &zero,
1525 .extra2 = &one_hundred,
1526 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001527 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001528 .procname = "min_slab_ratio",
1529 .data = &sysctl_min_slab_ratio,
1530 .maxlen = sizeof(sysctl_min_slab_ratio),
1531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001532 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001533 .extra1 = &zero,
1534 .extra2 = &one_hundred,
1535 },
Christoph Lameter17436602006-01-18 17:42:32 -08001536#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001537#ifdef CONFIG_SMP
1538 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001539 .procname = "stat_interval",
1540 .data = &sysctl_stat_interval,
1541 .maxlen = sizeof(sysctl_stat_interval),
1542 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001543 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001544 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001545 {
1546 .procname = "stat_refresh",
1547 .data = NULL,
1548 .maxlen = 0,
1549 .mode = 0600,
1550 .proc_handler = vmstat_refresh,
1551 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001552#endif
David Howells6e141542009-12-15 19:27:45 +00001553#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001554 {
Eric Parised032182007-06-28 15:55:21 -04001555 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001556 .data = &dac_mmap_min_addr,
1557 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001558 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001559 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001560 },
David Howells6e141542009-12-15 19:27:45 +00001561#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001562#ifdef CONFIG_NUMA
1563 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001564 .procname = "numa_zonelist_order",
1565 .data = &numa_zonelist_order,
1566 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1567 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001568 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001569 },
1570#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001571#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001572 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001573 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001574 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001575#ifdef CONFIG_X86_32
1576 .data = &vdso32_enabled,
1577 .maxlen = sizeof(vdso32_enabled),
1578#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001579 .data = &vdso_enabled,
1580 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001581#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001582 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001583 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001584 .extra1 = &zero,
1585 },
1586#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001587#ifdef CONFIG_HIGHMEM
1588 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001589 .procname = "highmem_is_dirtyable",
1590 .data = &vm_highmem_is_dirtyable,
1591 .maxlen = sizeof(vm_highmem_is_dirtyable),
1592 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001593 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001594 .extra1 = &zero,
1595 .extra2 = &one,
1596 },
1597#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001598#ifdef CONFIG_MEMORY_FAILURE
1599 {
Andi Kleen6a460792009-09-16 11:50:15 +02001600 .procname = "memory_failure_early_kill",
1601 .data = &sysctl_memory_failure_early_kill,
1602 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1603 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001604 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001605 .extra1 = &zero,
1606 .extra2 = &one,
1607 },
1608 {
Andi Kleen6a460792009-09-16 11:50:15 +02001609 .procname = "memory_failure_recovery",
1610 .data = &sysctl_memory_failure_recovery,
1611 .maxlen = sizeof(sysctl_memory_failure_recovery),
1612 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001613 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001614 .extra1 = &zero,
1615 .extra2 = &one,
1616 },
1617#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001618 {
1619 .procname = "user_reserve_kbytes",
1620 .data = &sysctl_user_reserve_kbytes,
1621 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1622 .mode = 0644,
1623 .proc_handler = proc_doulongvec_minmax,
1624 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001625 {
1626 .procname = "admin_reserve_kbytes",
1627 .data = &sysctl_admin_reserve_kbytes,
1628 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1629 .mode = 0644,
1630 .proc_handler = proc_doulongvec_minmax,
1631 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001632#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1633 {
1634 .procname = "mmap_rnd_bits",
1635 .data = &mmap_rnd_bits,
1636 .maxlen = sizeof(mmap_rnd_bits),
1637 .mode = 0600,
1638 .proc_handler = proc_dointvec_minmax,
1639 .extra1 = (void *)&mmap_rnd_bits_min,
1640 .extra2 = (void *)&mmap_rnd_bits_max,
1641 },
1642#endif
1643#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1644 {
1645 .procname = "mmap_rnd_compat_bits",
1646 .data = &mmap_rnd_compat_bits,
1647 .maxlen = sizeof(mmap_rnd_compat_bits),
1648 .mode = 0600,
1649 .proc_handler = proc_dointvec_minmax,
1650 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1651 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1652 },
1653#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001654 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655};
1656
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001657static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001658 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001659 .procname = "inode-nr",
1660 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001661 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001662 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001663 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664 },
1665 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001666 .procname = "inode-state",
1667 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001668 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001669 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001670 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001671 },
1672 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001673 .procname = "file-nr",
1674 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001675 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001676 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001677 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001678 },
1679 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001680 .procname = "file-max",
1681 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001682 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001684 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685 },
1686 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001687 .procname = "nr_open",
1688 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001689 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001690 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001691 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001692 .extra1 = &sysctl_nr_open_min,
1693 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001694 },
1695 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696 .procname = "dentry-state",
1697 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001698 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001699 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001700 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001701 },
1702 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001703 .procname = "overflowuid",
1704 .data = &fs_overflowuid,
1705 .maxlen = sizeof(int),
1706 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001707 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001708 .extra1 = &minolduid,
1709 .extra2 = &maxolduid,
1710 },
1711 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001712 .procname = "overflowgid",
1713 .data = &fs_overflowgid,
1714 .maxlen = sizeof(int),
1715 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001716 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001717 .extra1 = &minolduid,
1718 .extra2 = &maxolduid,
1719 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001720#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001721 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001722 .procname = "leases-enable",
1723 .data = &leases_enable,
1724 .maxlen = sizeof(int),
1725 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001726 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001727 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001728#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729#ifdef CONFIG_DNOTIFY
1730 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001731 .procname = "dir-notify-enable",
1732 .data = &dir_notify_enable,
1733 .maxlen = sizeof(int),
1734 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001735 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736 },
1737#endif
1738#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001739#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001741 .procname = "lease-break-time",
1742 .data = &lease_break_time,
1743 .maxlen = sizeof(int),
1744 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001745 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001746 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001747#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001748#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001749 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750 .procname = "aio-nr",
1751 .data = &aio_nr,
1752 .maxlen = sizeof(aio_nr),
1753 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001754 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001755 },
1756 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001757 .procname = "aio-max-nr",
1758 .data = &aio_max_nr,
1759 .maxlen = sizeof(aio_max_nr),
1760 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001761 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001762 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001763#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001764#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001765 {
Robert Love0399cb02005-07-13 12:38:18 -04001766 .procname = "inotify",
1767 .mode = 0555,
1768 .child = inotify_table,
1769 },
1770#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001771#ifdef CONFIG_EPOLL
1772 {
1773 .procname = "epoll",
1774 .mode = 0555,
1775 .child = epoll_table,
1776 },
1777#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001778#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001779 {
Kees Cook800179c2012-07-25 17:29:07 -07001780 .procname = "protected_symlinks",
1781 .data = &sysctl_protected_symlinks,
1782 .maxlen = sizeof(int),
1783 .mode = 0600,
1784 .proc_handler = proc_dointvec_minmax,
1785 .extra1 = &zero,
1786 .extra2 = &one,
1787 },
1788 {
1789 .procname = "protected_hardlinks",
1790 .data = &sysctl_protected_hardlinks,
1791 .maxlen = sizeof(int),
1792 .mode = 0600,
1793 .proc_handler = proc_dointvec_minmax,
1794 .extra1 = &zero,
1795 .extra2 = &one,
1796 },
1797 {
Salvatore Mesoraca0c41bee2018-08-23 17:00:35 -07001798 .procname = "protected_fifos",
1799 .data = &sysctl_protected_fifos,
1800 .maxlen = sizeof(int),
1801 .mode = 0600,
1802 .proc_handler = proc_dointvec_minmax,
1803 .extra1 = &zero,
1804 .extra2 = &two,
1805 },
1806 {
1807 .procname = "protected_regular",
1808 .data = &sysctl_protected_regular,
1809 .maxlen = sizeof(int),
1810 .mode = 0600,
1811 .proc_handler = proc_dointvec_minmax,
1812 .extra1 = &zero,
1813 .extra2 = &two,
1814 },
1815 {
Alan Coxd6e71142005-06-23 00:09:43 -07001816 .procname = "suid_dumpable",
1817 .data = &suid_dumpable,
1818 .maxlen = sizeof(int),
1819 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001820 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001821 .extra1 = &zero,
1822 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001823 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001824#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1825 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001826 .procname = "binfmt_misc",
1827 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001828 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001829 },
1830#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001831 {
Jens Axboeff9da692010-06-03 14:54:39 +02001832 .procname = "pipe-max-size",
1833 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001834 .maxlen = sizeof(int),
1835 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001836 .proc_handler = &pipe_proc_fn,
1837 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001838 },
Willy Tarreau759c0112016-01-18 16:36:09 +01001839 {
1840 .procname = "pipe-user-pages-hard",
1841 .data = &pipe_user_pages_hard,
1842 .maxlen = sizeof(pipe_user_pages_hard),
1843 .mode = 0644,
1844 .proc_handler = proc_doulongvec_minmax,
1845 },
1846 {
1847 .procname = "pipe-user-pages-soft",
1848 .data = &pipe_user_pages_soft,
1849 .maxlen = sizeof(pipe_user_pages_soft),
1850 .mode = 0644,
1851 .proc_handler = proc_doulongvec_minmax,
1852 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05001853 {
1854 .procname = "mount-max",
1855 .data = &sysctl_mount_max,
1856 .maxlen = sizeof(unsigned int),
1857 .mode = 0644,
1858 .proc_handler = proc_dointvec_minmax,
1859 .extra1 = &one,
1860 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001861 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001862};
1863
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001864static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001865#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001866 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001867 .procname = "exception-trace",
1868 .data = &show_unhandled_signals,
1869 .maxlen = sizeof(int),
1870 .mode = 0644,
1871 .proc_handler = proc_dointvec
1872 },
1873#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001874#if defined(CONFIG_OPTPROBES)
1875 {
1876 .procname = "kprobes-optimization",
1877 .data = &sysctl_kprobes_optimization,
1878 .maxlen = sizeof(int),
1879 .mode = 0644,
1880 .proc_handler = proc_kprobes_optimization_handler,
1881 .extra1 = &zero,
1882 .extra2 = &one,
1883 },
1884#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001885 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001886};
1887
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001888static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001889 { }
Robert Love0eeca282005-07-12 17:06:03 -04001890};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001891
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001892int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001893{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001894 struct ctl_table_header *hdr;
1895
1896 hdr = register_sysctl_table(sysctl_base_table);
1897 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001898 return 0;
1899}
1900
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001901#endif /* CONFIG_SYSCTL */
1902
Linus Torvalds1da177e2005-04-16 15:20:36 -07001903/*
1904 * /proc/sys support
1905 */
1906
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001907#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001908
Kees Cookf8808302014-06-06 14:37:17 -07001909static int _proc_do_string(char *data, int maxlen, int write,
1910 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001911 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001912{
1913 size_t len;
1914 char __user *p;
1915 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001916
1917 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001918 *lenp = 0;
1919 return 0;
1920 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001921
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001922 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001923 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1924 /* Only continue writes not past the end of buffer. */
1925 len = strlen(data);
1926 if (len > maxlen - 1)
1927 len = maxlen - 1;
1928
1929 if (*ppos > len)
1930 return 0;
1931 len = *ppos;
1932 } else {
1933 /* Start writing from beginning of buffer. */
1934 len = 0;
1935 }
1936
Kees Cook2ca9bb42014-06-06 14:37:18 -07001937 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001938 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001939 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001940 if (get_user(c, p++))
1941 return -EFAULT;
1942 if (c == 0 || c == '\n')
1943 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001944 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001945 }
Kees Cookf8808302014-06-06 14:37:17 -07001946 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001947 } else {
1948 len = strlen(data);
1949 if (len > maxlen)
1950 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001951
1952 if (*ppos > len) {
1953 *lenp = 0;
1954 return 0;
1955 }
1956
1957 data += *ppos;
1958 len -= *ppos;
1959
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001960 if (len > *lenp)
1961 len = *lenp;
1962 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001963 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001964 return -EFAULT;
1965 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001966 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001967 return -EFAULT;
1968 len++;
1969 }
1970 *lenp = len;
1971 *ppos += len;
1972 }
1973 return 0;
1974}
1975
Kees Cookf4aacea2014-06-06 14:37:19 -07001976static void warn_sysctl_write(struct ctl_table *table)
1977{
1978 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1979 "This will not be supported in the future. To silence this\n"
1980 "warning, set kernel.sysctl_writes_strict = -1\n",
1981 current->comm, table->procname);
1982}
1983
Linus Torvalds1da177e2005-04-16 15:20:36 -07001984/**
1985 * proc_dostring - read a string sysctl
1986 * @table: the sysctl table
1987 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001988 * @buffer: the user buffer
1989 * @lenp: the size of the user buffer
1990 * @ppos: file position
1991 *
1992 * Reads/writes a string from/to the user buffer. If the kernel
1993 * buffer provided is not large enough to hold the string, the
1994 * string is truncated. The copied string is %NULL-terminated.
1995 * If the string is being read by the user process, it is copied
1996 * and a newline '\n' is added. It is truncated if the buffer is
1997 * not large enough.
1998 *
1999 * Returns 0 on success.
2000 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002001int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002002 void __user *buffer, size_t *lenp, loff_t *ppos)
2003{
Kees Cookf4aacea2014-06-06 14:37:19 -07002004 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2005 warn_sysctl_write(table);
2006
Kees Cookf8808302014-06-06 14:37:17 -07002007 return _proc_do_string((char *)(table->data), table->maxlen, write,
2008 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002009}
2010
Amerigo Wang00b7c332010-05-05 00:26:45 +00002011static size_t proc_skip_spaces(char **buf)
2012{
2013 size_t ret;
2014 char *tmp = skip_spaces(*buf);
2015 ret = tmp - *buf;
2016 *buf = tmp;
2017 return ret;
2018}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002019
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002020static void proc_skip_char(char **buf, size_t *size, const char v)
2021{
2022 while (*size) {
2023 if (**buf != v)
2024 break;
2025 (*size)--;
2026 (*buf)++;
2027 }
2028}
2029
Amerigo Wang00b7c332010-05-05 00:26:45 +00002030#define TMPBUFLEN 22
2031/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002032 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002033 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002034 * @buf: a kernel buffer
2035 * @size: size of the kernel buffer
2036 * @val: this is where the number will be stored
2037 * @neg: set to %TRUE if number is negative
2038 * @perm_tr: a vector which contains the allowed trailers
2039 * @perm_tr_len: size of the perm_tr vector
2040 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002041 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002042 * In case of success %0 is returned and @buf and @size are updated with
2043 * the amount of bytes read. If @tr is non-NULL and a trailing
2044 * character exists (size is non-zero after returning from this
2045 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002046 */
2047static int proc_get_long(char **buf, size_t *size,
2048 unsigned long *val, bool *neg,
2049 const char *perm_tr, unsigned perm_tr_len, char *tr)
2050{
2051 int len;
2052 char *p, tmp[TMPBUFLEN];
2053
2054 if (!*size)
2055 return -EINVAL;
2056
2057 len = *size;
2058 if (len > TMPBUFLEN - 1)
2059 len = TMPBUFLEN - 1;
2060
2061 memcpy(tmp, *buf, len);
2062
2063 tmp[len] = 0;
2064 p = tmp;
2065 if (*p == '-' && *size > 1) {
2066 *neg = true;
2067 p++;
2068 } else
2069 *neg = false;
2070 if (!isdigit(*p))
2071 return -EINVAL;
2072
2073 *val = simple_strtoul(p, &p, 0);
2074
2075 len = p - tmp;
2076
2077 /* We don't know if the next char is whitespace thus we may accept
2078 * invalid integers (e.g. 1234...a) or two integers instead of one
2079 * (e.g. 123...1). So lets not allow such large numbers. */
2080 if (len == TMPBUFLEN - 1)
2081 return -EINVAL;
2082
2083 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2084 return -EINVAL;
2085
2086 if (tr && (len < *size))
2087 *tr = *p;
2088
2089 *buf += len;
2090 *size -= len;
2091
2092 return 0;
2093}
2094
2095/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002096 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002097 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002098 * @buf: the user buffer
2099 * @size: the size of the user buffer
2100 * @val: the integer to be converted
2101 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002102 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002103 * In case of success %0 is returned and @buf and @size are updated with
2104 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002105 */
2106static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2107 bool neg)
2108{
2109 int len;
2110 char tmp[TMPBUFLEN], *p = tmp;
2111
2112 sprintf(p, "%s%lu", neg ? "-" : "", val);
2113 len = strlen(tmp);
2114 if (len > *size)
2115 len = *size;
2116 if (copy_to_user(*buf, tmp, len))
2117 return -EFAULT;
2118 *size -= len;
2119 *buf += len;
2120 return 0;
2121}
2122#undef TMPBUFLEN
2123
2124static int proc_put_char(void __user **buf, size_t *size, char c)
2125{
2126 if (*size) {
2127 char __user **buffer = (char __user **)buf;
2128 if (put_user(c, *buffer))
2129 return -EFAULT;
2130 (*size)--, (*buffer)++;
2131 *buf = *buffer;
2132 }
2133 return 0;
2134}
2135
2136static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002137 int *valp,
2138 int write, void *data)
2139{
2140 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002141 if (*negp) {
2142 if (*lvalp > (unsigned long) INT_MAX + 1)
2143 return -EINVAL;
2144 *valp = -*lvalp;
2145 } else {
2146 if (*lvalp > (unsigned long) INT_MAX)
2147 return -EINVAL;
2148 *valp = *lvalp;
2149 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002150 } else {
2151 int val = *valp;
2152 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002153 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002154 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002155 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002156 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002157 *lvalp = (unsigned long)val;
2158 }
2159 }
2160 return 0;
2161}
2162
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002163static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2164 int *valp,
2165 int write, void *data)
2166{
2167 if (write) {
2168 if (*negp)
2169 return -EINVAL;
Liping Zhang7bdacd32017-04-07 23:51:07 +08002170 if (*lvalp > UINT_MAX)
2171 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002172 *valp = *lvalp;
2173 } else {
2174 unsigned int val = *valp;
Liping Zhang3a20c572017-04-07 23:51:06 +08002175 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002176 *lvalp = (unsigned long)val;
2177 }
2178 return 0;
2179}
2180
Amerigo Wang00b7c332010-05-05 00:26:45 +00002181static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2182
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002183static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002184 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002185 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002186 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002187 int write, void *data),
2188 void *data)
2189{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002190 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002191 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002192 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002193
Amerigo Wang00b7c332010-05-05 00:26:45 +00002194 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002195 *lenp = 0;
2196 return 0;
2197 }
2198
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002199 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002200 vleft = table->maxlen / sizeof(*i);
2201 left = *lenp;
2202
2203 if (!conv)
2204 conv = do_proc_dointvec_conv;
2205
Linus Torvalds1da177e2005-04-16 15:20:36 -07002206 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002207 if (*ppos) {
2208 switch (sysctl_writes_strict) {
2209 case SYSCTL_WRITES_STRICT:
2210 goto out;
2211 case SYSCTL_WRITES_WARN:
2212 warn_sysctl_write(table);
2213 break;
2214 default:
2215 break;
2216 }
2217 }
2218
Amerigo Wang00b7c332010-05-05 00:26:45 +00002219 if (left > PAGE_SIZE - 1)
2220 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002221 p = kbuf = memdup_user_nul(buffer, left);
2222 if (IS_ERR(kbuf))
2223 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002224 }
2225
2226 for (; left && vleft--; i++, first=0) {
2227 unsigned long lval;
2228 bool neg;
2229
2230 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002231 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002232
J. R. Okajima563b0462010-05-25 16:10:14 -07002233 if (!left)
2234 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002235 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002236 proc_wspace_sep,
2237 sizeof(proc_wspace_sep), NULL);
2238 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002239 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002240 if (conv(&neg, &lval, i, 1, data)) {
2241 err = -EINVAL;
2242 break;
2243 }
2244 } else {
2245 if (conv(&neg, &lval, i, 0, data)) {
2246 err = -EINVAL;
2247 break;
2248 }
2249 if (!first)
2250 err = proc_put_char(&buffer, &left, '\t');
2251 if (err)
2252 break;
2253 err = proc_put_long(&buffer, &left, lval, neg);
2254 if (err)
2255 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002256 }
2257 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002258
2259 if (!write && !first && left && !err)
2260 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002261 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002262 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002263 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002264 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002265 if (first)
2266 return err ? : -EINVAL;
2267 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002268 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002269out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002271 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002272}
2273
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002274static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002275 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002276 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002277 int write, void *data),
2278 void *data)
2279{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002280 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002281 buffer, lenp, ppos, conv, data);
2282}
2283
Linus Torvalds1da177e2005-04-16 15:20:36 -07002284/**
2285 * proc_dointvec - read a vector of integers
2286 * @table: the sysctl table
2287 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002288 * @buffer: the user buffer
2289 * @lenp: the size of the user buffer
2290 * @ppos: file position
2291 *
2292 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2293 * values from/to the user buffer, treated as an ASCII string.
2294 *
2295 * Returns 0 on success.
2296 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002297int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002298 void __user *buffer, size_t *lenp, loff_t *ppos)
2299{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002300 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2301}
2302
2303/**
2304 * proc_douintvec - read a vector of unsigned integers
2305 * @table: the sysctl table
2306 * @write: %TRUE if this is a write to the sysctl file
2307 * @buffer: the user buffer
2308 * @lenp: the size of the user buffer
2309 * @ppos: file position
2310 *
2311 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2312 * values from/to the user buffer, treated as an ASCII string.
2313 *
2314 * Returns 0 on success.
2315 */
2316int proc_douintvec(struct ctl_table *table, int write,
2317 void __user *buffer, size_t *lenp, loff_t *ppos)
2318{
2319 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2320 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002321}
2322
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002323/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002324 * Taint values can only be increased
2325 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002326 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002327static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002328 void __user *buffer, size_t *lenp, loff_t *ppos)
2329{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002330 struct ctl_table t;
2331 unsigned long tmptaint = get_taint();
2332 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002333
Bastian Blank91fcd412007-04-23 14:41:14 -07002334 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002335 return -EPERM;
2336
Andi Kleen25ddbb12008-10-15 22:01:41 -07002337 t = *table;
2338 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002339 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002340 if (err < 0)
2341 return err;
2342
2343 if (write) {
2344 /*
2345 * Poor man's atomic or. Not worth adding a primitive
2346 * to everyone's atomic.h for this
2347 */
2348 int i;
2349 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2350 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302351 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002352 }
2353 }
2354
2355 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002356}
2357
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002358#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002359static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002360 void __user *buffer, size_t *lenp, loff_t *ppos)
2361{
2362 if (write && !capable(CAP_SYS_ADMIN))
2363 return -EPERM;
2364
2365 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2366}
2367#endif
2368
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369struct do_proc_dointvec_minmax_conv_param {
2370 int *min;
2371 int *max;
2372};
2373
Amerigo Wang00b7c332010-05-05 00:26:45 +00002374static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2375 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002376 int write, void *data)
2377{
2378 struct do_proc_dointvec_minmax_conv_param *param = data;
2379 if (write) {
2380 int val = *negp ? -*lvalp : *lvalp;
2381 if ((param->min && *param->min > val) ||
2382 (param->max && *param->max < val))
2383 return -EINVAL;
2384 *valp = val;
2385 } else {
2386 int val = *valp;
2387 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002388 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002389 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002390 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002391 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002392 *lvalp = (unsigned long)val;
2393 }
2394 }
2395 return 0;
2396}
2397
2398/**
2399 * proc_dointvec_minmax - read a vector of integers with min/max values
2400 * @table: the sysctl table
2401 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002402 * @buffer: the user buffer
2403 * @lenp: the size of the user buffer
2404 * @ppos: file position
2405 *
2406 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2407 * values from/to the user buffer, treated as an ASCII string.
2408 *
2409 * This routine will ensure the values are within the range specified by
2410 * table->extra1 (min) and table->extra2 (max).
2411 *
2412 * Returns 0 on success.
2413 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002414int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002415 void __user *buffer, size_t *lenp, loff_t *ppos)
2416{
2417 struct do_proc_dointvec_minmax_conv_param param = {
2418 .min = (int *) table->extra1,
2419 .max = (int *) table->extra2,
2420 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002421 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002422 do_proc_dointvec_minmax_conv, &param);
2423}
2424
Kees Cook54b50192012-07-30 14:39:18 -07002425static void validate_coredump_safety(void)
2426{
Alex Kelly046d6622012-10-04 17:15:23 -07002427#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002428 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002429 core_pattern[0] != '/' && core_pattern[0] != '|') {
2430 printk(KERN_WARNING "Unsafe core_pattern used with "\
2431 "suid_dumpable=2. Pipe handler or fully qualified "\
2432 "core dump path required.\n");
2433 }
Alex Kelly046d6622012-10-04 17:15:23 -07002434#endif
Kees Cook54b50192012-07-30 14:39:18 -07002435}
2436
2437static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2438 void __user *buffer, size_t *lenp, loff_t *ppos)
2439{
2440 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2441 if (!error)
2442 validate_coredump_safety();
2443 return error;
2444}
2445
Alex Kelly046d6622012-10-04 17:15:23 -07002446#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002447static int proc_dostring_coredump(struct ctl_table *table, int write,
2448 void __user *buffer, size_t *lenp, loff_t *ppos)
2449{
2450 int error = proc_dostring(table, write, buffer, lenp, ppos);
2451 if (!error)
2452 validate_coredump_safety();
2453 return error;
2454}
Alex Kelly046d6622012-10-04 17:15:23 -07002455#endif
Kees Cook54b50192012-07-30 14:39:18 -07002456
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002457static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002458 void __user *buffer,
2459 size_t *lenp, loff_t *ppos,
2460 unsigned long convmul,
2461 unsigned long convdiv)
2462{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002463 unsigned long *i, *min, *max;
2464 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002465 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002466 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002467
2468 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002469 *lenp = 0;
2470 return 0;
2471 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002472
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002473 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002474 min = (unsigned long *) table->extra1;
2475 max = (unsigned long *) table->extra2;
2476 vleft = table->maxlen / sizeof(unsigned long);
2477 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002478
2479 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002480 if (*ppos) {
2481 switch (sysctl_writes_strict) {
2482 case SYSCTL_WRITES_STRICT:
2483 goto out;
2484 case SYSCTL_WRITES_WARN:
2485 warn_sysctl_write(table);
2486 break;
2487 default:
2488 break;
2489 }
2490 }
2491
Amerigo Wang00b7c332010-05-05 00:26:45 +00002492 if (left > PAGE_SIZE - 1)
2493 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002494 p = kbuf = memdup_user_nul(buffer, left);
2495 if (IS_ERR(kbuf))
2496 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002497 }
2498
Eric Dumazet27b3d802010-10-07 12:59:29 -07002499 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002500 unsigned long val;
2501
Linus Torvalds1da177e2005-04-16 15:20:36 -07002502 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002503 bool neg;
2504
Al Viro70f6cbb2015-12-24 00:13:10 -05002505 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002506
Al Viro70f6cbb2015-12-24 00:13:10 -05002507 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002508 proc_wspace_sep,
2509 sizeof(proc_wspace_sep), NULL);
2510 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002511 break;
2512 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002513 continue;
Eric Dumazet03707d62017-01-25 18:20:55 -08002514 val = convmul * val / convdiv;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002515 if ((min && val < *min) || (max && val > *max))
2516 continue;
2517 *i = val;
2518 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002519 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002520 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002521 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002522 if (err)
2523 break;
2524 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002525 err = proc_put_long(&buffer, &left, val, false);
2526 if (err)
2527 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002528 }
2529 }
2530
Amerigo Wang00b7c332010-05-05 00:26:45 +00002531 if (!write && !first && left && !err)
2532 err = proc_put_char(&buffer, &left, '\n');
2533 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002534 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002535 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002536 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002537 if (first)
2538 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002539 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002540 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002541out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002542 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002543 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544}
2545
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002546static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002547 void __user *buffer,
2548 size_t *lenp, loff_t *ppos,
2549 unsigned long convmul,
2550 unsigned long convdiv)
2551{
2552 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002553 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002554}
2555
Linus Torvalds1da177e2005-04-16 15:20:36 -07002556/**
2557 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2558 * @table: the sysctl table
2559 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002560 * @buffer: the user buffer
2561 * @lenp: the size of the user buffer
2562 * @ppos: file position
2563 *
2564 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2565 * values from/to the user buffer, treated as an ASCII string.
2566 *
2567 * This routine will ensure the values are within the range specified by
2568 * table->extra1 (min) and table->extra2 (max).
2569 *
2570 * Returns 0 on success.
2571 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002572int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002573 void __user *buffer, size_t *lenp, loff_t *ppos)
2574{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002575 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002576}
2577
2578/**
2579 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2580 * @table: the sysctl table
2581 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002582 * @buffer: the user buffer
2583 * @lenp: the size of the user buffer
2584 * @ppos: file position
2585 *
2586 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2587 * values from/to the user buffer, treated as an ASCII string. The values
2588 * are treated as milliseconds, and converted to jiffies when they are stored.
2589 *
2590 * This routine will ensure the values are within the range specified by
2591 * table->extra1 (min) and table->extra2 (max).
2592 *
2593 * Returns 0 on success.
2594 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002595int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002596 void __user *buffer,
2597 size_t *lenp, loff_t *ppos)
2598{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002599 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002600 lenp, ppos, HZ, 1000l);
2601}
2602
2603
Amerigo Wang00b7c332010-05-05 00:26:45 +00002604static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002605 int *valp,
2606 int write, void *data)
2607{
2608 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002609 if (*lvalp > LONG_MAX / HZ)
2610 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002611 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2612 } else {
2613 int val = *valp;
2614 unsigned long lval;
2615 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002616 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002617 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002618 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002619 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620 lval = (unsigned long)val;
2621 }
2622 *lvalp = lval / HZ;
2623 }
2624 return 0;
2625}
2626
Amerigo Wang00b7c332010-05-05 00:26:45 +00002627static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002628 int *valp,
2629 int write, void *data)
2630{
2631 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002632 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2633 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002634 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2635 } else {
2636 int val = *valp;
2637 unsigned long lval;
2638 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002639 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002640 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002641 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002642 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002643 lval = (unsigned long)val;
2644 }
2645 *lvalp = jiffies_to_clock_t(lval);
2646 }
2647 return 0;
2648}
2649
Amerigo Wang00b7c332010-05-05 00:26:45 +00002650static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002651 int *valp,
2652 int write, void *data)
2653{
2654 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002655 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2656
2657 if (jif > INT_MAX)
2658 return 1;
2659 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002660 } else {
2661 int val = *valp;
2662 unsigned long lval;
2663 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002664 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002665 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002666 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002667 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002668 lval = (unsigned long)val;
2669 }
2670 *lvalp = jiffies_to_msecs(lval);
2671 }
2672 return 0;
2673}
2674
2675/**
2676 * proc_dointvec_jiffies - read a vector of integers as seconds
2677 * @table: the sysctl table
2678 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002679 * @buffer: the user buffer
2680 * @lenp: the size of the user buffer
2681 * @ppos: file position
2682 *
2683 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2684 * values from/to the user buffer, treated as an ASCII string.
2685 * The values read are assumed to be in seconds, and are converted into
2686 * jiffies.
2687 *
2688 * Returns 0 on success.
2689 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002690int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002691 void __user *buffer, size_t *lenp, loff_t *ppos)
2692{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002693 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002694 do_proc_dointvec_jiffies_conv,NULL);
2695}
2696
2697/**
2698 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2699 * @table: the sysctl table
2700 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002701 * @buffer: the user buffer
2702 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002703 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002704 *
2705 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2706 * values from/to the user buffer, treated as an ASCII string.
2707 * The values read are assumed to be in 1/USER_HZ seconds, and
2708 * are converted into jiffies.
2709 *
2710 * Returns 0 on success.
2711 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002712int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002713 void __user *buffer, size_t *lenp, loff_t *ppos)
2714{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002715 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002716 do_proc_dointvec_userhz_jiffies_conv,NULL);
2717}
2718
2719/**
2720 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2721 * @table: the sysctl table
2722 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002723 * @buffer: the user buffer
2724 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002725 * @ppos: file position
2726 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002727 *
2728 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2729 * values from/to the user buffer, treated as an ASCII string.
2730 * The values read are assumed to be in 1/1000 seconds, and
2731 * are converted into jiffies.
2732 *
2733 * Returns 0 on success.
2734 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002735int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002736 void __user *buffer, size_t *lenp, loff_t *ppos)
2737{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002738 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002739 do_proc_dointvec_ms_jiffies_conv, NULL);
2740}
2741
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002742static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002743 void __user *buffer, size_t *lenp, loff_t *ppos)
2744{
2745 struct pid *new_pid;
2746 pid_t tmp;
2747 int r;
2748
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002749 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002750
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002751 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002752 lenp, ppos, NULL, NULL);
2753 if (r || !write)
2754 return r;
2755
2756 new_pid = find_get_pid(tmp);
2757 if (!new_pid)
2758 return -ESRCH;
2759
2760 put_pid(xchg(&cad_pid, new_pid));
2761 return 0;
2762}
2763
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002764/**
2765 * proc_do_large_bitmap - read/write from/to a large bitmap
2766 * @table: the sysctl table
2767 * @write: %TRUE if this is a write to the sysctl file
2768 * @buffer: the user buffer
2769 * @lenp: the size of the user buffer
2770 * @ppos: file position
2771 *
2772 * The bitmap is stored at table->data and the bitmap length (in bits)
2773 * in table->maxlen.
2774 *
2775 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2776 * large bitmaps may be represented in a compact manner. Writing into
2777 * the file will clear the bitmap then update it with the given input.
2778 *
2779 * Returns 0 on success.
2780 */
2781int proc_do_large_bitmap(struct ctl_table *table, int write,
2782 void __user *buffer, size_t *lenp, loff_t *ppos)
2783{
2784 int err = 0;
2785 bool first = 1;
2786 size_t left = *lenp;
2787 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002788 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002789 unsigned long *tmp_bitmap = NULL;
2790 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2791
WANG Cong122ff242014-05-12 16:04:53 -07002792 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002793 *lenp = 0;
2794 return 0;
2795 }
2796
2797 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002798 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002799
2800 if (left > PAGE_SIZE - 1)
2801 left = PAGE_SIZE - 1;
2802
Al Viro70f6cbb2015-12-24 00:13:10 -05002803 p = kbuf = memdup_user_nul(buffer, left);
2804 if (IS_ERR(kbuf))
2805 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002806
2807 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2808 GFP_KERNEL);
2809 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002810 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002811 return -ENOMEM;
2812 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002813 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002814 while (!err && left) {
2815 unsigned long val_a, val_b;
2816 bool neg;
2817
Al Viro70f6cbb2015-12-24 00:13:10 -05002818 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002819 sizeof(tr_a), &c);
2820 if (err)
2821 break;
2822 if (val_a >= bitmap_len || neg) {
2823 err = -EINVAL;
2824 break;
2825 }
2826
2827 val_b = val_a;
2828 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002829 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002830 left--;
2831 }
2832
2833 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05002834 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002835 &neg, tr_b, sizeof(tr_b),
2836 &c);
2837 if (err)
2838 break;
2839 if (val_b >= bitmap_len || neg ||
2840 val_a > val_b) {
2841 err = -EINVAL;
2842 break;
2843 }
2844 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002845 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002846 left--;
2847 }
2848 }
2849
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002850 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002851 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05002852 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002853 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002854 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002855 } else {
2856 unsigned long bit_a, bit_b = 0;
2857
2858 while (left) {
2859 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2860 if (bit_a >= bitmap_len)
2861 break;
2862 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2863 bit_a + 1) - 1;
2864
2865 if (!first) {
2866 err = proc_put_char(&buffer, &left, ',');
2867 if (err)
2868 break;
2869 }
2870 err = proc_put_long(&buffer, &left, bit_a, false);
2871 if (err)
2872 break;
2873 if (bit_a != bit_b) {
2874 err = proc_put_char(&buffer, &left, '-');
2875 if (err)
2876 break;
2877 err = proc_put_long(&buffer, &left, bit_b, false);
2878 if (err)
2879 break;
2880 }
2881
2882 first = 0; bit_b++;
2883 }
2884 if (!err)
2885 err = proc_put_char(&buffer, &left, '\n');
2886 }
2887
2888 if (!err) {
2889 if (write) {
2890 if (*ppos)
2891 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2892 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002893 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002894 }
2895 kfree(tmp_bitmap);
2896 *lenp -= left;
2897 *ppos += *lenp;
2898 return 0;
2899 } else {
2900 kfree(tmp_bitmap);
2901 return err;
2902 }
2903}
2904
Jovi Zhang55610502011-01-12 17:00:45 -08002905#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002906
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002907int proc_dostring(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(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
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002919int proc_douintvec(struct ctl_table *table, int write,
2920 void __user *buffer, size_t *lenp, loff_t *ppos)
2921{
2922 return -ENOSYS;
2923}
2924
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002925int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002926 void __user *buffer, size_t *lenp, loff_t *ppos)
2927{
2928 return -ENOSYS;
2929}
2930
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002931int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002932 void __user *buffer, size_t *lenp, loff_t *ppos)
2933{
2934 return -ENOSYS;
2935}
2936
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002937int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002938 void __user *buffer, size_t *lenp, loff_t *ppos)
2939{
2940 return -ENOSYS;
2941}
2942
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002943int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002944 void __user *buffer, size_t *lenp, loff_t *ppos)
2945{
2946 return -ENOSYS;
2947}
2948
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002949int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002950 void __user *buffer, size_t *lenp, loff_t *ppos)
2951{
2952 return -ENOSYS;
2953}
2954
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002955int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002956 void __user *buffer,
2957 size_t *lenp, loff_t *ppos)
2958{
2959 return -ENOSYS;
2960}
2961
2962
Jovi Zhang55610502011-01-12 17:00:45 -08002963#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002964
Linus Torvalds1da177e2005-04-16 15:20:36 -07002965/*
2966 * No sense putting this after each symbol definition, twice,
2967 * exception granted :-)
2968 */
2969EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002970EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002971EXPORT_SYMBOL(proc_dointvec_jiffies);
2972EXPORT_SYMBOL(proc_dointvec_minmax);
2973EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2974EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2975EXPORT_SYMBOL(proc_dostring);
2976EXPORT_SYMBOL(proc_doulongvec_minmax);
2977EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);