blob: 265e0d0216e35d2a1fd144b92a3d2add6a1d76f2 [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,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800348 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200349 },
350 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900351 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800352 .data = &sysctl_sched_shares_window,
353 .maxlen = sizeof(unsigned int),
354 .mode = 0644,
355 .proc_handler = proc_dointvec,
356 },
Mel Gormancb251762016-02-05 09:08:36 +0000357#ifdef CONFIG_SCHEDSTATS
358 {
359 .procname = "sched_schedstats",
360 .data = NULL,
361 .maxlen = sizeof(unsigned int),
362 .mode = 0644,
363 .proc_handler = sysctl_schedstats,
364 .extra1 = &zero,
365 .extra2 = &one,
366 },
367#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200368#endif /* CONFIG_SMP */
369#ifdef CONFIG_NUMA_BALANCING
370 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200371 .procname = "numa_balancing_scan_delay_ms",
372 .data = &sysctl_numa_balancing_scan_delay,
373 .maxlen = sizeof(unsigned int),
374 .mode = 0644,
375 .proc_handler = proc_dointvec,
376 },
377 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200378 .procname = "numa_balancing_scan_period_min_ms",
379 .data = &sysctl_numa_balancing_scan_period_min,
380 .maxlen = sizeof(unsigned int),
381 .mode = 0644,
382 .proc_handler = proc_dointvec,
383 },
384 {
385 .procname = "numa_balancing_scan_period_max_ms",
386 .data = &sysctl_numa_balancing_scan_period_max,
387 .maxlen = sizeof(unsigned int),
388 .mode = 0644,
389 .proc_handler = proc_dointvec,
390 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200391 {
392 .procname = "numa_balancing_scan_size_mb",
393 .data = &sysctl_numa_balancing_scan_size,
394 .maxlen = sizeof(unsigned int),
395 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400396 .proc_handler = proc_dointvec_minmax,
397 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200398 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100399 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800400 .procname = "numa_balancing",
401 .data = NULL, /* filled in by handler */
402 .maxlen = sizeof(unsigned int),
403 .mode = 0644,
404 .proc_handler = sysctl_numa_balancing,
405 .extra1 = &zero,
406 .extra2 = &one,
407 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200408#endif /* CONFIG_NUMA_BALANCING */
409#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200410 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100411 .procname = "sched_rt_period_us",
412 .data = &sysctl_sched_rt_period,
413 .maxlen = sizeof(unsigned int),
414 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800415 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100416 },
417 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100418 .procname = "sched_rt_runtime_us",
419 .data = &sysctl_sched_rt_runtime,
420 .maxlen = sizeof(int),
421 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800422 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100423 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600424 {
425 .procname = "sched_rr_timeslice_ms",
426 .data = &sched_rr_timeslice,
427 .maxlen = sizeof(int),
428 .mode = 0644,
429 .proc_handler = sched_rr_handler,
430 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100431#ifdef CONFIG_SCHED_AUTOGROUP
432 {
433 .procname = "sched_autogroup_enabled",
434 .data = &sysctl_sched_autogroup_enabled,
435 .maxlen = sizeof(unsigned int),
436 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800437 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100438 .extra1 = &zero,
439 .extra2 = &one,
440 },
441#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700442#ifdef CONFIG_CFS_BANDWIDTH
443 {
444 .procname = "sched_cfs_bandwidth_slice_us",
445 .data = &sysctl_sched_cfs_bandwidth_slice,
446 .maxlen = sizeof(unsigned int),
447 .mode = 0644,
448 .proc_handler = proc_dointvec_minmax,
449 .extra1 = &one,
450 },
451#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700452#ifdef CONFIG_PROVE_LOCKING
453 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700454 .procname = "prove_locking",
455 .data = &prove_locking,
456 .maxlen = sizeof(int),
457 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800458 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700459 },
460#endif
461#ifdef CONFIG_LOCK_STAT
462 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700463 .procname = "lock_stat",
464 .data = &lock_stat,
465 .maxlen = sizeof(int),
466 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800467 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700468 },
469#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200470 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 .procname = "panic",
472 .data = &panic_timeout,
473 .maxlen = sizeof(int),
474 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800475 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 },
Alex Kelly046d6622012-10-04 17:15:23 -0700477#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 .procname = "core_uses_pid",
480 .data = &core_uses_pid,
481 .maxlen = sizeof(int),
482 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800483 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 },
485 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 .procname = "core_pattern",
487 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700488 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700490 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 },
Neil Hormana2939802009-09-23 15:56:56 -0700492 {
Neil Hormana2939802009-09-23 15:56:56 -0700493 .procname = "core_pipe_limit",
494 .data = &core_pipe_limit,
495 .maxlen = sizeof(unsigned int),
496 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800497 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700498 },
Alex Kelly046d6622012-10-04 17:15:23 -0700499#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800500#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700503 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800504 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800505 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700507 {
508 .procname = "sysctl_writes_strict",
509 .data = &sysctl_writes_strict,
510 .maxlen = sizeof(int),
511 .mode = 0644,
512 .proc_handler = proc_dointvec_minmax,
513 .extra1 = &neg_one,
514 .extra2 = &one,
515 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800516#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100517#ifdef CONFIG_LATENCYTOP
518 {
519 .procname = "latencytop",
520 .data = &latencytop_enabled,
521 .maxlen = sizeof(int),
522 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000523 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100524 },
525#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526#ifdef CONFIG_BLK_DEV_INITRD
527 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 .procname = "real-root-dev",
529 .data = &real_root_dev,
530 .maxlen = sizeof(int),
531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800532 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 },
534#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700535 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700536 .procname = "print-fatal-signals",
537 .data = &print_fatal_signals,
538 .maxlen = sizeof(int),
539 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800540 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700541 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700542#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 .procname = "reboot-cmd",
545 .data = reboot_command,
546 .maxlen = 256,
547 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800548 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 },
550 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 .procname = "stop-a",
552 .data = &stop_a_enabled,
553 .maxlen = sizeof (int),
554 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800555 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 },
557 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 .procname = "scons-poweroff",
559 .data = &scons_pwroff,
560 .maxlen = sizeof (int),
561 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800562 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 },
564#endif
David S. Miller08714202008-11-16 23:49:24 -0800565#ifdef CONFIG_SPARC64
566 {
David S. Miller08714202008-11-16 23:49:24 -0800567 .procname = "tsb-ratio",
568 .data = &sysctl_tsb_ratio,
569 .maxlen = sizeof (int),
570 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800571 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800572 },
573#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574#ifdef __hppa__
575 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 .procname = "soft-power",
577 .data = &pwrsw_enabled,
578 .maxlen = sizeof (int),
579 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800580 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530582#endif
583#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 .procname = "unaligned-trap",
586 .data = &unaligned_enabled,
587 .maxlen = sizeof (int),
588 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800589 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 },
591#endif
592 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 .procname = "ctrl-alt-del",
594 .data = &C_A_D,
595 .maxlen = sizeof(int),
596 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800597 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400599#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200600 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200601 .procname = "ftrace_enabled",
602 .data = &ftrace_enabled,
603 .maxlen = sizeof(int),
604 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800605 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200606 },
607#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500608#ifdef CONFIG_STACK_TRACER
609 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500610 .procname = "stack_tracer_enabled",
611 .data = &stack_tracer_enabled,
612 .maxlen = sizeof(int),
613 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800614 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500615 },
616#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400617#ifdef CONFIG_TRACING
618 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100619 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400620 .data = &ftrace_dump_on_oops,
621 .maxlen = sizeof(int),
622 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800623 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400624 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400625 {
626 .procname = "traceoff_on_warning",
627 .data = &__disable_trace_on_warning,
628 .maxlen = sizeof(__disable_trace_on_warning),
629 .mode = 0644,
630 .proc_handler = proc_dointvec,
631 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500632 {
633 .procname = "tracepoint_printk",
634 .data = &tracepoint_printk,
635 .maxlen = sizeof(tracepoint_printk),
636 .mode = 0644,
637 .proc_handler = proc_dointvec,
638 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400639#endif
Dave Young2965faa2015-09-09 15:38:55 -0700640#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800641 {
642 .procname = "kexec_load_disabled",
643 .data = &kexec_load_disabled,
644 .maxlen = sizeof(int),
645 .mode = 0644,
646 /* only handle a transition from default "0" to "1" */
647 .proc_handler = proc_dointvec_minmax,
648 .extra1 = &one,
649 .extra2 = &one,
650 },
651#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200652#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 .procname = "modprobe",
655 .data = &modprobe_path,
656 .maxlen = KMOD_PATH_LEN,
657 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800658 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 },
Kees Cook3d433212009-04-02 15:49:29 -0700660 {
Kees Cook3d433212009-04-02 15:49:29 -0700661 .procname = "modules_disabled",
662 .data = &modules_disabled,
663 .maxlen = sizeof(int),
664 .mode = 0644,
665 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800666 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700667 .extra1 = &one,
668 .extra2 = &one,
669 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700671#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100674 .data = &uevent_helper,
675 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800677 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 },
Michael Marineau86d56132014-04-10 14:09:31 -0700679#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680#ifdef CONFIG_CHR_DEV_SG
681 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 .procname = "sg-big-buff",
683 .data = &sg_big_buff,
684 .maxlen = sizeof (int),
685 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800686 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 },
688#endif
689#ifdef CONFIG_BSD_PROCESS_ACCT
690 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 .procname = "acct",
692 .data = &acct_parm,
693 .maxlen = 3*sizeof(int),
694 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800695 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 },
697#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698#ifdef CONFIG_MAGIC_SYSRQ
699 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800701 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 .maxlen = sizeof (int),
703 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700704 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 },
706#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700707#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700710 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 .maxlen = sizeof (int),
712 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800713 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700715#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700718 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 .maxlen = sizeof(int),
720 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700721 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 },
723 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 .procname = "random",
725 .mode = 0555,
726 .child = random_table,
727 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 {
Eric Paris17f60a72011-04-01 17:07:50 -0400729 .procname = "usermodehelper",
730 .mode = 0555,
731 .child = usermodehelper_table,
732 },
733 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 .procname = "overflowuid",
735 .data = &overflowuid,
736 .maxlen = sizeof(int),
737 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800738 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 .extra1 = &minolduid,
740 .extra2 = &maxolduid,
741 },
742 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 .procname = "overflowgid",
744 .data = &overflowgid,
745 .maxlen = sizeof(int),
746 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800747 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 .extra1 = &minolduid,
749 .extra2 = &maxolduid,
750 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800751#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752#ifdef CONFIG_MATHEMU
753 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 .procname = "ieee_emulation_warnings",
755 .data = &sysctl_ieee_emulation_warnings,
756 .maxlen = sizeof(int),
757 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800758 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 },
760#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200763 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 .maxlen = sizeof(int),
765 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800766 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 },
768#endif
769 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 .procname = "pid_max",
771 .data = &pid_max,
772 .maxlen = sizeof (int),
773 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800774 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 .extra1 = &pid_max_min,
776 .extra2 = &pid_max_max,
777 },
778 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 .procname = "panic_on_oops",
780 .data = &panic_on_oops,
781 .maxlen = sizeof(int),
782 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800783 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800785#if defined CONFIG_PRINTK
786 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800787 .procname = "printk",
788 .data = &console_loglevel,
789 .maxlen = 4*sizeof(int),
790 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800791 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800792 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700795 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 .maxlen = sizeof(int),
797 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800798 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 },
800 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700802 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 .maxlen = sizeof(int),
804 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800805 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 },
Dave Youngaf913222009-09-22 16:43:33 -0700807 {
Dave Youngaf913222009-09-22 16:43:33 -0700808 .procname = "printk_delay",
809 .data = &printk_delay_msec,
810 .maxlen = sizeof(int),
811 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800812 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700813 .extra1 = &zero,
814 .extra2 = &ten_thousand,
815 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700817 .procname = "printk_devkmsg",
818 .data = devkmsg_log_str,
819 .maxlen = DEVKMSG_STR_MAX_SIZE,
820 .mode = 0644,
821 .proc_handler = devkmsg_sysctl_set_loglvl,
822 },
823 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800824 .procname = "dmesg_restrict",
825 .data = &dmesg_restrict,
826 .maxlen = sizeof(int),
827 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700828 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800829 .extra1 = &zero,
830 .extra2 = &one,
831 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800832 {
833 .procname = "kptr_restrict",
834 .data = &kptr_restrict,
835 .maxlen = sizeof(int),
836 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700837 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800838 .extra1 = &zero,
839 .extra2 = &two,
840 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800841#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800842 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 .procname = "ngroups_max",
844 .data = &ngroups_max,
845 .maxlen = sizeof (int),
846 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800847 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848 },
Dan Ballard73efc032011-10-31 17:11:20 -0700849 {
850 .procname = "cap_last_cap",
851 .data = (void *)&cap_last_cap,
852 .maxlen = sizeof(int),
853 .mode = 0444,
854 .proc_handler = proc_dointvec,
855 },
Don Zickus58687ac2010-05-07 17:11:44 -0400856#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500857 {
Don Zickus58687ac2010-05-07 17:11:44 -0400858 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200859 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500860 .maxlen = sizeof (int),
861 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700862 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700863 .extra1 = &zero,
864 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400865 },
866 {
867 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700868 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400869 .maxlen = sizeof(int),
870 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700871 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800872 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400873 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500874 },
Don Zickus2508ce12010-05-07 17:11:46 -0400875 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700876 .procname = "nmi_watchdog",
877 .data = &nmi_watchdog_enabled,
878 .maxlen = sizeof (int),
879 .mode = 0644,
880 .proc_handler = proc_nmi_watchdog,
881 .extra1 = &zero,
882#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
883 .extra2 = &one,
884#else
885 .extra2 = &zero,
886#endif
887 },
888 {
889 .procname = "soft_watchdog",
890 .data = &soft_watchdog_enabled,
891 .maxlen = sizeof (int),
892 .mode = 0644,
893 .proc_handler = proc_soft_watchdog,
894 .extra1 = &zero,
895 .extra2 = &one,
896 },
897 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700898 .procname = "watchdog_cpumask",
899 .data = &watchdog_cpumask_bits,
900 .maxlen = NR_CPUS,
901 .mode = 0644,
902 .proc_handler = proc_watchdog_cpumask,
903 },
904 {
Don Zickus2508ce12010-05-07 17:11:46 -0400905 .procname = "softlockup_panic",
906 .data = &softlockup_panic,
907 .maxlen = sizeof(int),
908 .mode = 0644,
909 .proc_handler = proc_dointvec_minmax,
910 .extra1 = &zero,
911 .extra2 = &one,
912 },
Don Zickusac1f5912015-11-05 18:44:44 -0800913#ifdef CONFIG_HARDLOCKUP_DETECTOR
914 {
915 .procname = "hardlockup_panic",
916 .data = &hardlockup_panic,
917 .maxlen = sizeof(int),
918 .mode = 0644,
919 .proc_handler = proc_dointvec_minmax,
920 .extra1 = &zero,
921 .extra2 = &one,
922 },
923#endif
Aaron Tomlined235872014-06-23 13:22:05 -0700924#ifdef CONFIG_SMP
925 {
926 .procname = "softlockup_all_cpu_backtrace",
927 .data = &sysctl_softlockup_all_cpu_backtrace,
928 .maxlen = sizeof(int),
929 .mode = 0644,
930 .proc_handler = proc_dointvec_minmax,
931 .extra1 = &zero,
932 .extra2 = &one,
933 },
Jiri Kosina55537872015-11-05 18:44:41 -0800934 {
935 .procname = "hardlockup_all_cpu_backtrace",
936 .data = &sysctl_hardlockup_all_cpu_backtrace,
937 .maxlen = sizeof(int),
938 .mode = 0644,
939 .proc_handler = proc_dointvec_minmax,
940 .extra1 = &zero,
941 .extra2 = &one,
942 },
Aaron Tomlined235872014-06-23 13:22:05 -0700943#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -0500944#endif
945#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
946 {
947 .procname = "unknown_nmi_panic",
948 .data = &unknown_nmi_panic,
949 .maxlen = sizeof (int),
950 .mode = 0644,
951 .proc_handler = proc_dointvec,
952 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500953#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700954#if defined(CONFIG_X86)
955 {
Don Zickus8da5add2006-09-26 10:52:27 +0200956 .procname = "panic_on_unrecovered_nmi",
957 .data = &panic_on_unrecovered_nmi,
958 .maxlen = sizeof(int),
959 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800960 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200961 },
962 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700963 .procname = "panic_on_io_nmi",
964 .data = &panic_on_io_nmi,
965 .maxlen = sizeof(int),
966 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800967 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700968 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900969#ifdef CONFIG_DEBUG_STACKOVERFLOW
970 {
971 .procname = "panic_on_stackoverflow",
972 .data = &sysctl_panic_on_stackoverflow,
973 .maxlen = sizeof(int),
974 .mode = 0644,
975 .proc_handler = proc_dointvec,
976 },
977#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700978 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 .procname = "bootloader_type",
980 .data = &bootloader_type,
981 .maxlen = sizeof (int),
982 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800983 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100985 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700986 .procname = "bootloader_version",
987 .data = &bootloader_version,
988 .maxlen = sizeof (int),
989 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800990 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700991 },
992 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100993 .procname = "kstack_depth_to_print",
994 .data = &kstack_depth_to_print,
995 .maxlen = sizeof(int),
996 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800997 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100998 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100999 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001000 .procname = "io_delay_type",
1001 .data = &io_delay_type,
1002 .maxlen = sizeof(int),
1003 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001004 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001005 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001007#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001008 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001009 .procname = "randomize_va_space",
1010 .data = &randomize_va_space,
1011 .maxlen = sizeof(int),
1012 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001013 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001014 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001015#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001016#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001017 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001018 .procname = "spin_retry",
1019 .data = &spin_retry,
1020 .maxlen = sizeof (int),
1021 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001022 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001023 },
1024#endif
Len Brown673d5b42007-07-28 03:33:16 -04001025#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001026 {
Pavel Machekc255d842006-02-20 18:27:58 -08001027 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001028 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001029 .maxlen = sizeof (unsigned long),
1030 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001031 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001032 },
1033#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301034#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001035 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001036 .procname = "ignore-unaligned-usertrap",
1037 .data = &no_unaligned_warning,
1038 .maxlen = sizeof (int),
1039 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001040 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001041 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301042#endif
1043#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001044 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001045 .procname = "unaligned-dump-stack",
1046 .data = &unaligned_dump_stack,
1047 .maxlen = sizeof (int),
1048 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001049 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001050 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001051#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001052#ifdef CONFIG_DETECT_HUNG_TASK
1053 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001054 .procname = "hung_task_panic",
1055 .data = &sysctl_hung_task_panic,
1056 .maxlen = sizeof(int),
1057 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001058 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001059 .extra1 = &zero,
1060 .extra2 = &one,
1061 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001062 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001063 .procname = "hung_task_check_count",
1064 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001065 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001066 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001067 .proc_handler = proc_dointvec_minmax,
1068 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001069 },
1070 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001071 .procname = "hung_task_timeout_secs",
1072 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001073 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001074 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001075 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001076 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001077 },
1078 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001079 .procname = "hung_task_warnings",
1080 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001081 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001082 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001083 .proc_handler = proc_dointvec_minmax,
1084 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001085 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001086#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001087#ifdef CONFIG_RT_MUTEXES
1088 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001089 .procname = "max_lock_depth",
1090 .data = &max_lock_depth,
1091 .maxlen = sizeof(int),
1092 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001093 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001094 },
1095#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001096 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001097 .procname = "poweroff_cmd",
1098 .data = &poweroff_cmd,
1099 .maxlen = POWEROFF_CMD_PATH_LEN,
1100 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001101 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001102 },
David Howells0b77f5b2008-04-29 01:01:32 -07001103#ifdef CONFIG_KEYS
1104 {
David Howells0b77f5b2008-04-29 01:01:32 -07001105 .procname = "keys",
1106 .mode = 0555,
1107 .child = key_sysctls,
1108 },
1109#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001110#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001111 /*
1112 * User-space scripts rely on the existence of this file
1113 * as a feature check for perf_events being enabled.
1114 *
1115 * So it's an ABI, do not remove!
1116 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001117 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001118 .procname = "perf_event_paranoid",
1119 .data = &sysctl_perf_event_paranoid,
1120 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001121 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001122 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001123 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001124 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001125 .procname = "perf_event_mlock_kb",
1126 .data = &sysctl_perf_event_mlock,
1127 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001128 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001129 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001130 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001131 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001132 .procname = "perf_event_max_sample_rate",
1133 .data = &sysctl_perf_event_sample_rate,
1134 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001135 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001136 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001137 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001138 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001139 {
1140 .procname = "perf_cpu_time_max_percent",
1141 .data = &sysctl_perf_cpu_time_max_percent,
1142 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1143 .mode = 0644,
1144 .proc_handler = perf_cpu_time_max_percent_handler,
1145 .extra1 = &zero,
1146 .extra2 = &one_hundred,
1147 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001148 {
1149 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001150 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001151 .maxlen = sizeof(sysctl_perf_event_max_stack),
1152 .mode = 0644,
1153 .proc_handler = perf_event_max_stack_handler,
1154 .extra1 = &zero,
1155 .extra2 = &six_hundred_forty_kb,
1156 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001157 {
1158 .procname = "perf_event_max_contexts_per_stack",
1159 .data = &sysctl_perf_event_max_contexts_per_stack,
1160 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1161 .mode = 0644,
1162 .proc_handler = perf_event_max_stack_handler,
1163 .extra1 = &zero,
1164 .extra2 = &one_thousand,
1165 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001166#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001167#ifdef CONFIG_KMEMCHECK
1168 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001169 .procname = "kmemcheck",
1170 .data = &kmemcheck_enabled,
1171 .maxlen = sizeof(int),
1172 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001173 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001174 },
1175#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001176 {
1177 .procname = "panic_on_warn",
1178 .data = &panic_on_warn,
1179 .maxlen = sizeof(int),
1180 .mode = 0644,
1181 .proc_handler = proc_dointvec_minmax,
1182 .extra1 = &zero,
1183 .extra2 = &one,
1184 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001185#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1186 {
1187 .procname = "timer_migration",
1188 .data = &sysctl_timer_migration,
1189 .maxlen = sizeof(unsigned int),
1190 .mode = 0644,
1191 .proc_handler = timer_migration_handler,
1192 },
1193#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001194#ifdef CONFIG_BPF_SYSCALL
1195 {
1196 .procname = "unprivileged_bpf_disabled",
1197 .data = &sysctl_unprivileged_bpf_disabled,
1198 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1199 .mode = 0644,
1200 /* only handle a transition from default "0" to "1" */
1201 .proc_handler = proc_dointvec_minmax,
1202 .extra1 = &one,
1203 .extra2 = &one,
1204 },
1205#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001206#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1207 {
1208 .procname = "panic_on_rcu_stall",
1209 .data = &sysctl_panic_on_rcu_stall,
1210 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1211 .mode = 0644,
1212 .proc_handler = proc_dointvec_minmax,
1213 .extra1 = &zero,
1214 .extra2 = &one,
1215 },
1216#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001217 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218};
1219
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001220static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001221 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001222 .procname = "overcommit_memory",
1223 .data = &sysctl_overcommit_memory,
1224 .maxlen = sizeof(sysctl_overcommit_memory),
1225 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001226 .proc_handler = proc_dointvec_minmax,
1227 .extra1 = &zero,
1228 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001229 },
1230 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001231 .procname = "panic_on_oom",
1232 .data = &sysctl_panic_on_oom,
1233 .maxlen = sizeof(sysctl_panic_on_oom),
1234 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001235 .proc_handler = proc_dointvec_minmax,
1236 .extra1 = &zero,
1237 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001238 },
1239 {
David Rientjesfe071d72007-10-16 23:25:56 -07001240 .procname = "oom_kill_allocating_task",
1241 .data = &sysctl_oom_kill_allocating_task,
1242 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1243 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001244 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001245 },
1246 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001247 .procname = "oom_dump_tasks",
1248 .data = &sysctl_oom_dump_tasks,
1249 .maxlen = sizeof(sysctl_oom_dump_tasks),
1250 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001251 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001252 },
1253 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254 .procname = "overcommit_ratio",
1255 .data = &sysctl_overcommit_ratio,
1256 .maxlen = sizeof(sysctl_overcommit_ratio),
1257 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001258 .proc_handler = overcommit_ratio_handler,
1259 },
1260 {
1261 .procname = "overcommit_kbytes",
1262 .data = &sysctl_overcommit_kbytes,
1263 .maxlen = sizeof(sysctl_overcommit_kbytes),
1264 .mode = 0644,
1265 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001266 },
1267 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001268 .procname = "page-cluster",
1269 .data = &page_cluster,
1270 .maxlen = sizeof(int),
1271 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001272 .proc_handler = proc_dointvec_minmax,
1273 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001274 },
1275 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001276 .procname = "dirty_background_ratio",
1277 .data = &dirty_background_ratio,
1278 .maxlen = sizeof(dirty_background_ratio),
1279 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001280 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001281 .extra1 = &zero,
1282 .extra2 = &one_hundred,
1283 },
1284 {
David Rientjes2da02992009-01-06 14:39:31 -08001285 .procname = "dirty_background_bytes",
1286 .data = &dirty_background_bytes,
1287 .maxlen = sizeof(dirty_background_bytes),
1288 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001289 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001290 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001291 },
1292 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001293 .procname = "dirty_ratio",
1294 .data = &vm_dirty_ratio,
1295 .maxlen = sizeof(vm_dirty_ratio),
1296 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001297 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001298 .extra1 = &zero,
1299 .extra2 = &one_hundred,
1300 },
1301 {
David Rientjes2da02992009-01-06 14:39:31 -08001302 .procname = "dirty_bytes",
1303 .data = &vm_dirty_bytes,
1304 .maxlen = sizeof(vm_dirty_bytes),
1305 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001306 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001307 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001308 },
1309 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001310 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001311 .data = &dirty_writeback_interval,
1312 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001313 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001314 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001315 },
1316 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001318 .data = &dirty_expire_interval,
1319 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001321 .proc_handler = proc_dointvec_minmax,
1322 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323 },
1324 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001325 .procname = "dirtytime_expire_seconds",
1326 .data = &dirtytime_expire_interval,
1327 .maxlen = sizeof(dirty_expire_interval),
1328 .mode = 0644,
1329 .proc_handler = dirtytime_interval_handler,
1330 .extra1 = &zero,
1331 },
1332 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001333 .procname = "nr_pdflush_threads",
1334 .mode = 0444 /* read-only */,
1335 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001336 },
1337 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001338 .procname = "swappiness",
1339 .data = &vm_swappiness,
1340 .maxlen = sizeof(vm_swappiness),
1341 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001342 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001343 .extra1 = &zero,
1344 .extra2 = &one_hundred,
1345 },
1346#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001347 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001348 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001349 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350 .maxlen = sizeof(unsigned long),
1351 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001352 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001353 },
1354#ifdef CONFIG_NUMA
1355 {
1356 .procname = "nr_hugepages_mempolicy",
1357 .data = NULL,
1358 .maxlen = sizeof(unsigned long),
1359 .mode = 0644,
1360 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001361 },
1362#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001363 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001364 .procname = "hugetlb_shm_group",
1365 .data = &sysctl_hugetlb_shm_group,
1366 .maxlen = sizeof(gid_t),
1367 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001368 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001369 },
Mel Gorman396faf02007-07-17 04:03:13 -07001370 {
Mel Gorman396faf02007-07-17 04:03:13 -07001371 .procname = "hugepages_treat_as_movable",
1372 .data = &hugepages_treat_as_movable,
1373 .maxlen = sizeof(int),
1374 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001375 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001376 },
Adam Litke54f9f802007-10-16 01:26:20 -07001377 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001378 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001379 .data = NULL,
1380 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001381 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001382 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001383 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384#endif
1385 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001386 .procname = "lowmem_reserve_ratio",
1387 .data = &sysctl_lowmem_reserve_ratio,
1388 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1389 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001390 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001391 },
1392 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001393 .procname = "drop_caches",
1394 .data = &sysctl_drop_caches,
1395 .maxlen = sizeof(int),
1396 .mode = 0644,
1397 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001398 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001399 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001400 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001401#ifdef CONFIG_COMPACTION
1402 {
1403 .procname = "compact_memory",
1404 .data = &sysctl_compact_memory,
1405 .maxlen = sizeof(int),
1406 .mode = 0200,
1407 .proc_handler = sysctl_compaction_handler,
1408 },
Mel Gorman5e771902010-05-24 14:32:31 -07001409 {
1410 .procname = "extfrag_threshold",
1411 .data = &sysctl_extfrag_threshold,
1412 .maxlen = sizeof(int),
1413 .mode = 0644,
1414 .proc_handler = sysctl_extfrag_handler,
1415 .extra1 = &min_extfrag_threshold,
1416 .extra2 = &max_extfrag_threshold,
1417 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001418 {
1419 .procname = "compact_unevictable_allowed",
1420 .data = &sysctl_compact_unevictable_allowed,
1421 .maxlen = sizeof(int),
1422 .mode = 0644,
1423 .proc_handler = proc_dointvec,
1424 .extra1 = &zero,
1425 .extra2 = &one,
1426 },
Mel Gorman5e771902010-05-24 14:32:31 -07001427
Mel Gorman76ab0f52010-05-24 14:32:28 -07001428#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001429 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001430 .procname = "min_free_kbytes",
1431 .data = &min_free_kbytes,
1432 .maxlen = sizeof(min_free_kbytes),
1433 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001434 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001435 .extra1 = &zero,
1436 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001437 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001438 .procname = "watermark_scale_factor",
1439 .data = &watermark_scale_factor,
1440 .maxlen = sizeof(watermark_scale_factor),
1441 .mode = 0644,
1442 .proc_handler = watermark_scale_factor_sysctl_handler,
1443 .extra1 = &one,
1444 .extra2 = &one_thousand,
1445 },
1446 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001447 .procname = "percpu_pagelist_fraction",
1448 .data = &percpu_pagelist_fraction,
1449 .maxlen = sizeof(percpu_pagelist_fraction),
1450 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001451 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001452 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001453 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001454#ifdef CONFIG_MMU
1455 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456 .procname = "max_map_count",
1457 .data = &sysctl_max_map_count,
1458 .maxlen = sizeof(sysctl_max_map_count),
1459 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001460 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001461 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001463#else
1464 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001465 .procname = "nr_trim_pages",
1466 .data = &sysctl_nr_trim_pages,
1467 .maxlen = sizeof(sysctl_nr_trim_pages),
1468 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001469 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001470 .extra1 = &zero,
1471 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001472#endif
1473 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001474 .procname = "laptop_mode",
1475 .data = &laptop_mode,
1476 .maxlen = sizeof(laptop_mode),
1477 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001478 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479 },
1480 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481 .procname = "block_dump",
1482 .data = &block_dump,
1483 .maxlen = sizeof(block_dump),
1484 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001485 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001486 .extra1 = &zero,
1487 },
1488 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001489 .procname = "vfs_cache_pressure",
1490 .data = &sysctl_vfs_cache_pressure,
1491 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1492 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001493 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 .extra1 = &zero,
1495 },
1496#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1497 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498 .procname = "legacy_va_layout",
1499 .data = &sysctl_legacy_va_layout,
1500 .maxlen = sizeof(sysctl_legacy_va_layout),
1501 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001502 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001503 .extra1 = &zero,
1504 },
1505#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001506#ifdef CONFIG_NUMA
1507 {
Christoph Lameter17436602006-01-18 17:42:32 -08001508 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001509 .data = &node_reclaim_mode,
1510 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001511 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001512 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001513 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001514 },
Christoph Lameter96146342006-07-03 00:24:13 -07001515 {
Christoph Lameter96146342006-07-03 00:24:13 -07001516 .procname = "min_unmapped_ratio",
1517 .data = &sysctl_min_unmapped_ratio,
1518 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1519 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001520 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001521 .extra1 = &zero,
1522 .extra2 = &one_hundred,
1523 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001524 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001525 .procname = "min_slab_ratio",
1526 .data = &sysctl_min_slab_ratio,
1527 .maxlen = sizeof(sysctl_min_slab_ratio),
1528 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001529 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001530 .extra1 = &zero,
1531 .extra2 = &one_hundred,
1532 },
Christoph Lameter17436602006-01-18 17:42:32 -08001533#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001534#ifdef CONFIG_SMP
1535 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001536 .procname = "stat_interval",
1537 .data = &sysctl_stat_interval,
1538 .maxlen = sizeof(sysctl_stat_interval),
1539 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001540 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001541 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001542 {
1543 .procname = "stat_refresh",
1544 .data = NULL,
1545 .maxlen = 0,
1546 .mode = 0600,
1547 .proc_handler = vmstat_refresh,
1548 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001549#endif
David Howells6e141542009-12-15 19:27:45 +00001550#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001551 {
Eric Parised032182007-06-28 15:55:21 -04001552 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001553 .data = &dac_mmap_min_addr,
1554 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001555 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001556 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001557 },
David Howells6e141542009-12-15 19:27:45 +00001558#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001559#ifdef CONFIG_NUMA
1560 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001561 .procname = "numa_zonelist_order",
1562 .data = &numa_zonelist_order,
1563 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1564 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001565 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001566 },
1567#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001568#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001569 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001570 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001571 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001572#ifdef CONFIG_X86_32
1573 .data = &vdso32_enabled,
1574 .maxlen = sizeof(vdso32_enabled),
1575#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001576 .data = &vdso_enabled,
1577 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001578#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001579 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001580 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001581 .extra1 = &zero,
1582 },
1583#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001584#ifdef CONFIG_HIGHMEM
1585 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001586 .procname = "highmem_is_dirtyable",
1587 .data = &vm_highmem_is_dirtyable,
1588 .maxlen = sizeof(vm_highmem_is_dirtyable),
1589 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001590 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001591 .extra1 = &zero,
1592 .extra2 = &one,
1593 },
1594#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001595#ifdef CONFIG_MEMORY_FAILURE
1596 {
Andi Kleen6a460792009-09-16 11:50:15 +02001597 .procname = "memory_failure_early_kill",
1598 .data = &sysctl_memory_failure_early_kill,
1599 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1600 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001601 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001602 .extra1 = &zero,
1603 .extra2 = &one,
1604 },
1605 {
Andi Kleen6a460792009-09-16 11:50:15 +02001606 .procname = "memory_failure_recovery",
1607 .data = &sysctl_memory_failure_recovery,
1608 .maxlen = sizeof(sysctl_memory_failure_recovery),
1609 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001610 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001611 .extra1 = &zero,
1612 .extra2 = &one,
1613 },
1614#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001615 {
1616 .procname = "user_reserve_kbytes",
1617 .data = &sysctl_user_reserve_kbytes,
1618 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1619 .mode = 0644,
1620 .proc_handler = proc_doulongvec_minmax,
1621 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001622 {
1623 .procname = "admin_reserve_kbytes",
1624 .data = &sysctl_admin_reserve_kbytes,
1625 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1626 .mode = 0644,
1627 .proc_handler = proc_doulongvec_minmax,
1628 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001629#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1630 {
1631 .procname = "mmap_rnd_bits",
1632 .data = &mmap_rnd_bits,
1633 .maxlen = sizeof(mmap_rnd_bits),
1634 .mode = 0600,
1635 .proc_handler = proc_dointvec_minmax,
1636 .extra1 = (void *)&mmap_rnd_bits_min,
1637 .extra2 = (void *)&mmap_rnd_bits_max,
1638 },
1639#endif
1640#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1641 {
1642 .procname = "mmap_rnd_compat_bits",
1643 .data = &mmap_rnd_compat_bits,
1644 .maxlen = sizeof(mmap_rnd_compat_bits),
1645 .mode = 0600,
1646 .proc_handler = proc_dointvec_minmax,
1647 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1648 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1649 },
1650#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001651 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001652};
1653
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001654static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001656 .procname = "inode-nr",
1657 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001658 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001659 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001660 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001661 },
1662 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001663 .procname = "inode-state",
1664 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001665 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001666 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001667 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001668 },
1669 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001670 .procname = "file-nr",
1671 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001672 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001673 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001674 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001675 },
1676 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677 .procname = "file-max",
1678 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001679 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001680 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001681 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001682 },
1683 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001684 .procname = "nr_open",
1685 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001686 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001687 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001688 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001689 .extra1 = &sysctl_nr_open_min,
1690 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001691 },
1692 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001693 .procname = "dentry-state",
1694 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001695 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001697 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001698 },
1699 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001700 .procname = "overflowuid",
1701 .data = &fs_overflowuid,
1702 .maxlen = sizeof(int),
1703 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001704 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001705 .extra1 = &minolduid,
1706 .extra2 = &maxolduid,
1707 },
1708 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001709 .procname = "overflowgid",
1710 .data = &fs_overflowgid,
1711 .maxlen = sizeof(int),
1712 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001713 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001714 .extra1 = &minolduid,
1715 .extra2 = &maxolduid,
1716 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001717#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001718 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001719 .procname = "leases-enable",
1720 .data = &leases_enable,
1721 .maxlen = sizeof(int),
1722 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001723 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001724 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001725#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001726#ifdef CONFIG_DNOTIFY
1727 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001728 .procname = "dir-notify-enable",
1729 .data = &dir_notify_enable,
1730 .maxlen = sizeof(int),
1731 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001732 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001733 },
1734#endif
1735#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001736#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001737 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001738 .procname = "lease-break-time",
1739 .data = &lease_break_time,
1740 .maxlen = sizeof(int),
1741 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001742 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001743 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001744#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001745#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001746 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001747 .procname = "aio-nr",
1748 .data = &aio_nr,
1749 .maxlen = sizeof(aio_nr),
1750 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001751 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001752 },
1753 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001754 .procname = "aio-max-nr",
1755 .data = &aio_max_nr,
1756 .maxlen = sizeof(aio_max_nr),
1757 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001758 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001759 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001760#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001761#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001762 {
Robert Love0399cb02005-07-13 12:38:18 -04001763 .procname = "inotify",
1764 .mode = 0555,
1765 .child = inotify_table,
1766 },
1767#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001768#ifdef CONFIG_EPOLL
1769 {
1770 .procname = "epoll",
1771 .mode = 0555,
1772 .child = epoll_table,
1773 },
1774#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001775#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001776 {
Kees Cook800179c2012-07-25 17:29:07 -07001777 .procname = "protected_symlinks",
1778 .data = &sysctl_protected_symlinks,
1779 .maxlen = sizeof(int),
1780 .mode = 0600,
1781 .proc_handler = proc_dointvec_minmax,
1782 .extra1 = &zero,
1783 .extra2 = &one,
1784 },
1785 {
1786 .procname = "protected_hardlinks",
1787 .data = &sysctl_protected_hardlinks,
1788 .maxlen = sizeof(int),
1789 .mode = 0600,
1790 .proc_handler = proc_dointvec_minmax,
1791 .extra1 = &zero,
1792 .extra2 = &one,
1793 },
1794 {
Alan Coxd6e71142005-06-23 00:09:43 -07001795 .procname = "suid_dumpable",
1796 .data = &suid_dumpable,
1797 .maxlen = sizeof(int),
1798 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001799 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001800 .extra1 = &zero,
1801 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001802 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001803#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1804 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001805 .procname = "binfmt_misc",
1806 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001807 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001808 },
1809#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001810 {
Jens Axboeff9da692010-06-03 14:54:39 +02001811 .procname = "pipe-max-size",
1812 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001813 .maxlen = sizeof(int),
1814 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001815 .proc_handler = &pipe_proc_fn,
1816 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001817 },
Willy Tarreau759c0112016-01-18 16:36:09 +01001818 {
1819 .procname = "pipe-user-pages-hard",
1820 .data = &pipe_user_pages_hard,
1821 .maxlen = sizeof(pipe_user_pages_hard),
1822 .mode = 0644,
1823 .proc_handler = proc_doulongvec_minmax,
1824 },
1825 {
1826 .procname = "pipe-user-pages-soft",
1827 .data = &pipe_user_pages_soft,
1828 .maxlen = sizeof(pipe_user_pages_soft),
1829 .mode = 0644,
1830 .proc_handler = proc_doulongvec_minmax,
1831 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05001832 {
1833 .procname = "mount-max",
1834 .data = &sysctl_mount_max,
1835 .maxlen = sizeof(unsigned int),
1836 .mode = 0644,
1837 .proc_handler = proc_dointvec_minmax,
1838 .extra1 = &one,
1839 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001840 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001841};
1842
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001843static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001844#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001845 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001846 .procname = "exception-trace",
1847 .data = &show_unhandled_signals,
1848 .maxlen = sizeof(int),
1849 .mode = 0644,
1850 .proc_handler = proc_dointvec
1851 },
1852#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001853#if defined(CONFIG_OPTPROBES)
1854 {
1855 .procname = "kprobes-optimization",
1856 .data = &sysctl_kprobes_optimization,
1857 .maxlen = sizeof(int),
1858 .mode = 0644,
1859 .proc_handler = proc_kprobes_optimization_handler,
1860 .extra1 = &zero,
1861 .extra2 = &one,
1862 },
1863#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001864 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001865};
1866
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001867static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001868 { }
Robert Love0eeca282005-07-12 17:06:03 -04001869};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001870
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001871int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001872{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001873 struct ctl_table_header *hdr;
1874
1875 hdr = register_sysctl_table(sysctl_base_table);
1876 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001877 return 0;
1878}
1879
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001880#endif /* CONFIG_SYSCTL */
1881
Linus Torvalds1da177e2005-04-16 15:20:36 -07001882/*
1883 * /proc/sys support
1884 */
1885
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001886#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001887
Kees Cookf8808302014-06-06 14:37:17 -07001888static int _proc_do_string(char *data, int maxlen, int write,
1889 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001890 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001891{
1892 size_t len;
1893 char __user *p;
1894 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001895
1896 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001897 *lenp = 0;
1898 return 0;
1899 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001900
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001901 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001902 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1903 /* Only continue writes not past the end of buffer. */
1904 len = strlen(data);
1905 if (len > maxlen - 1)
1906 len = maxlen - 1;
1907
1908 if (*ppos > len)
1909 return 0;
1910 len = *ppos;
1911 } else {
1912 /* Start writing from beginning of buffer. */
1913 len = 0;
1914 }
1915
Kees Cook2ca9bb42014-06-06 14:37:18 -07001916 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001917 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001918 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001919 if (get_user(c, p++))
1920 return -EFAULT;
1921 if (c == 0 || c == '\n')
1922 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001923 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001924 }
Kees Cookf8808302014-06-06 14:37:17 -07001925 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001926 } else {
1927 len = strlen(data);
1928 if (len > maxlen)
1929 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001930
1931 if (*ppos > len) {
1932 *lenp = 0;
1933 return 0;
1934 }
1935
1936 data += *ppos;
1937 len -= *ppos;
1938
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001939 if (len > *lenp)
1940 len = *lenp;
1941 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001942 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001943 return -EFAULT;
1944 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001945 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001946 return -EFAULT;
1947 len++;
1948 }
1949 *lenp = len;
1950 *ppos += len;
1951 }
1952 return 0;
1953}
1954
Kees Cookf4aacea2014-06-06 14:37:19 -07001955static void warn_sysctl_write(struct ctl_table *table)
1956{
1957 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1958 "This will not be supported in the future. To silence this\n"
1959 "warning, set kernel.sysctl_writes_strict = -1\n",
1960 current->comm, table->procname);
1961}
1962
Linus Torvalds1da177e2005-04-16 15:20:36 -07001963/**
1964 * proc_dostring - read a string sysctl
1965 * @table: the sysctl table
1966 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001967 * @buffer: the user buffer
1968 * @lenp: the size of the user buffer
1969 * @ppos: file position
1970 *
1971 * Reads/writes a string from/to the user buffer. If the kernel
1972 * buffer provided is not large enough to hold the string, the
1973 * string is truncated. The copied string is %NULL-terminated.
1974 * If the string is being read by the user process, it is copied
1975 * and a newline '\n' is added. It is truncated if the buffer is
1976 * not large enough.
1977 *
1978 * Returns 0 on success.
1979 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001980int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001981 void __user *buffer, size_t *lenp, loff_t *ppos)
1982{
Kees Cookf4aacea2014-06-06 14:37:19 -07001983 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
1984 warn_sysctl_write(table);
1985
Kees Cookf8808302014-06-06 14:37:17 -07001986 return _proc_do_string((char *)(table->data), table->maxlen, write,
1987 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001988}
1989
Amerigo Wang00b7c332010-05-05 00:26:45 +00001990static size_t proc_skip_spaces(char **buf)
1991{
1992 size_t ret;
1993 char *tmp = skip_spaces(*buf);
1994 ret = tmp - *buf;
1995 *buf = tmp;
1996 return ret;
1997}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001998
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001999static void proc_skip_char(char **buf, size_t *size, const char v)
2000{
2001 while (*size) {
2002 if (**buf != v)
2003 break;
2004 (*size)--;
2005 (*buf)++;
2006 }
2007}
2008
Amerigo Wang00b7c332010-05-05 00:26:45 +00002009#define TMPBUFLEN 22
2010/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002011 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002012 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002013 * @buf: a kernel buffer
2014 * @size: size of the kernel buffer
2015 * @val: this is where the number will be stored
2016 * @neg: set to %TRUE if number is negative
2017 * @perm_tr: a vector which contains the allowed trailers
2018 * @perm_tr_len: size of the perm_tr vector
2019 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002020 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002021 * In case of success %0 is returned and @buf and @size are updated with
2022 * the amount of bytes read. If @tr is non-NULL and a trailing
2023 * character exists (size is non-zero after returning from this
2024 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002025 */
2026static int proc_get_long(char **buf, size_t *size,
2027 unsigned long *val, bool *neg,
2028 const char *perm_tr, unsigned perm_tr_len, char *tr)
2029{
2030 int len;
2031 char *p, tmp[TMPBUFLEN];
2032
2033 if (!*size)
2034 return -EINVAL;
2035
2036 len = *size;
2037 if (len > TMPBUFLEN - 1)
2038 len = TMPBUFLEN - 1;
2039
2040 memcpy(tmp, *buf, len);
2041
2042 tmp[len] = 0;
2043 p = tmp;
2044 if (*p == '-' && *size > 1) {
2045 *neg = true;
2046 p++;
2047 } else
2048 *neg = false;
2049 if (!isdigit(*p))
2050 return -EINVAL;
2051
2052 *val = simple_strtoul(p, &p, 0);
2053
2054 len = p - tmp;
2055
2056 /* We don't know if the next char is whitespace thus we may accept
2057 * invalid integers (e.g. 1234...a) or two integers instead of one
2058 * (e.g. 123...1). So lets not allow such large numbers. */
2059 if (len == TMPBUFLEN - 1)
2060 return -EINVAL;
2061
2062 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2063 return -EINVAL;
2064
2065 if (tr && (len < *size))
2066 *tr = *p;
2067
2068 *buf += len;
2069 *size -= len;
2070
2071 return 0;
2072}
2073
2074/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002075 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002076 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002077 * @buf: the user buffer
2078 * @size: the size of the user buffer
2079 * @val: the integer to be converted
2080 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002081 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002082 * In case of success %0 is returned and @buf and @size are updated with
2083 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002084 */
2085static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2086 bool neg)
2087{
2088 int len;
2089 char tmp[TMPBUFLEN], *p = tmp;
2090
2091 sprintf(p, "%s%lu", neg ? "-" : "", val);
2092 len = strlen(tmp);
2093 if (len > *size)
2094 len = *size;
2095 if (copy_to_user(*buf, tmp, len))
2096 return -EFAULT;
2097 *size -= len;
2098 *buf += len;
2099 return 0;
2100}
2101#undef TMPBUFLEN
2102
2103static int proc_put_char(void __user **buf, size_t *size, char c)
2104{
2105 if (*size) {
2106 char __user **buffer = (char __user **)buf;
2107 if (put_user(c, *buffer))
2108 return -EFAULT;
2109 (*size)--, (*buffer)++;
2110 *buf = *buffer;
2111 }
2112 return 0;
2113}
2114
2115static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002116 int *valp,
2117 int write, void *data)
2118{
2119 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002120 if (*negp) {
2121 if (*lvalp > (unsigned long) INT_MAX + 1)
2122 return -EINVAL;
2123 *valp = -*lvalp;
2124 } else {
2125 if (*lvalp > (unsigned long) INT_MAX)
2126 return -EINVAL;
2127 *valp = *lvalp;
2128 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002129 } else {
2130 int val = *valp;
2131 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002132 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002133 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002134 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002135 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002136 *lvalp = (unsigned long)val;
2137 }
2138 }
2139 return 0;
2140}
2141
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002142static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2143 int *valp,
2144 int write, void *data)
2145{
2146 if (write) {
2147 if (*negp)
2148 return -EINVAL;
Liping Zhang7bdacd32017-04-07 23:51:07 +08002149 if (*lvalp > UINT_MAX)
2150 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002151 *valp = *lvalp;
2152 } else {
2153 unsigned int val = *valp;
Liping Zhang3a20c572017-04-07 23:51:06 +08002154 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002155 *lvalp = (unsigned long)val;
2156 }
2157 return 0;
2158}
2159
Amerigo Wang00b7c332010-05-05 00:26:45 +00002160static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2161
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002162static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002163 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002164 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002165 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002166 int write, void *data),
2167 void *data)
2168{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002169 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002170 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002171 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002172
Amerigo Wang00b7c332010-05-05 00:26:45 +00002173 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174 *lenp = 0;
2175 return 0;
2176 }
2177
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002178 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002179 vleft = table->maxlen / sizeof(*i);
2180 left = *lenp;
2181
2182 if (!conv)
2183 conv = do_proc_dointvec_conv;
2184
Linus Torvalds1da177e2005-04-16 15:20:36 -07002185 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002186 if (*ppos) {
2187 switch (sysctl_writes_strict) {
2188 case SYSCTL_WRITES_STRICT:
2189 goto out;
2190 case SYSCTL_WRITES_WARN:
2191 warn_sysctl_write(table);
2192 break;
2193 default:
2194 break;
2195 }
2196 }
2197
Amerigo Wang00b7c332010-05-05 00:26:45 +00002198 if (left > PAGE_SIZE - 1)
2199 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002200 p = kbuf = memdup_user_nul(buffer, left);
2201 if (IS_ERR(kbuf))
2202 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002203 }
2204
2205 for (; left && vleft--; i++, first=0) {
2206 unsigned long lval;
2207 bool neg;
2208
2209 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002210 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002211
J. R. Okajima563b0462010-05-25 16:10:14 -07002212 if (!left)
2213 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002214 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002215 proc_wspace_sep,
2216 sizeof(proc_wspace_sep), NULL);
2217 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002218 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002219 if (conv(&neg, &lval, i, 1, data)) {
2220 err = -EINVAL;
2221 break;
2222 }
2223 } else {
2224 if (conv(&neg, &lval, i, 0, data)) {
2225 err = -EINVAL;
2226 break;
2227 }
2228 if (!first)
2229 err = proc_put_char(&buffer, &left, '\t');
2230 if (err)
2231 break;
2232 err = proc_put_long(&buffer, &left, lval, neg);
2233 if (err)
2234 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002235 }
2236 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002237
2238 if (!write && !first && left && !err)
2239 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002240 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002241 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002242 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002243 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002244 if (first)
2245 return err ? : -EINVAL;
2246 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002247 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002248out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002249 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002250 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002251}
2252
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002253static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002254 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002255 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002256 int write, void *data),
2257 void *data)
2258{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002259 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002260 buffer, lenp, ppos, conv, data);
2261}
2262
Linus Torvalds1da177e2005-04-16 15:20:36 -07002263/**
2264 * proc_dointvec - read a vector of integers
2265 * @table: the sysctl table
2266 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002267 * @buffer: the user buffer
2268 * @lenp: the size of the user buffer
2269 * @ppos: file position
2270 *
2271 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2272 * values from/to the user buffer, treated as an ASCII string.
2273 *
2274 * Returns 0 on success.
2275 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002276int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002277 void __user *buffer, size_t *lenp, loff_t *ppos)
2278{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002279 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2280}
2281
2282/**
2283 * proc_douintvec - read a vector of unsigned integers
2284 * @table: the sysctl table
2285 * @write: %TRUE if this is a write to the sysctl file
2286 * @buffer: the user buffer
2287 * @lenp: the size of the user buffer
2288 * @ppos: file position
2289 *
2290 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2291 * values from/to the user buffer, treated as an ASCII string.
2292 *
2293 * Returns 0 on success.
2294 */
2295int proc_douintvec(struct ctl_table *table, int write,
2296 void __user *buffer, size_t *lenp, loff_t *ppos)
2297{
2298 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2299 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002300}
2301
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002302/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002303 * Taint values can only be increased
2304 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002305 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002306static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002307 void __user *buffer, size_t *lenp, loff_t *ppos)
2308{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002309 struct ctl_table t;
2310 unsigned long tmptaint = get_taint();
2311 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002312
Bastian Blank91fcd412007-04-23 14:41:14 -07002313 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002314 return -EPERM;
2315
Andi Kleen25ddbb12008-10-15 22:01:41 -07002316 t = *table;
2317 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002318 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002319 if (err < 0)
2320 return err;
2321
2322 if (write) {
2323 /*
2324 * Poor man's atomic or. Not worth adding a primitive
2325 * to everyone's atomic.h for this
2326 */
2327 int i;
2328 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2329 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302330 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002331 }
2332 }
2333
2334 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002335}
2336
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002337#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002338static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002339 void __user *buffer, size_t *lenp, loff_t *ppos)
2340{
2341 if (write && !capable(CAP_SYS_ADMIN))
2342 return -EPERM;
2343
2344 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2345}
2346#endif
2347
Linus Torvalds1da177e2005-04-16 15:20:36 -07002348struct do_proc_dointvec_minmax_conv_param {
2349 int *min;
2350 int *max;
2351};
2352
Amerigo Wang00b7c332010-05-05 00:26:45 +00002353static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2354 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002355 int write, void *data)
2356{
2357 struct do_proc_dointvec_minmax_conv_param *param = data;
2358 if (write) {
2359 int val = *negp ? -*lvalp : *lvalp;
2360 if ((param->min && *param->min > val) ||
2361 (param->max && *param->max < val))
2362 return -EINVAL;
2363 *valp = val;
2364 } else {
2365 int val = *valp;
2366 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002367 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002368 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002370 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002371 *lvalp = (unsigned long)val;
2372 }
2373 }
2374 return 0;
2375}
2376
2377/**
2378 * proc_dointvec_minmax - read a vector of integers with min/max values
2379 * @table: the sysctl table
2380 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381 * @buffer: the user buffer
2382 * @lenp: the size of the user buffer
2383 * @ppos: file position
2384 *
2385 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2386 * values from/to the user buffer, treated as an ASCII string.
2387 *
2388 * This routine will ensure the values are within the range specified by
2389 * table->extra1 (min) and table->extra2 (max).
2390 *
2391 * Returns 0 on success.
2392 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002393int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002394 void __user *buffer, size_t *lenp, loff_t *ppos)
2395{
2396 struct do_proc_dointvec_minmax_conv_param param = {
2397 .min = (int *) table->extra1,
2398 .max = (int *) table->extra2,
2399 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002400 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 do_proc_dointvec_minmax_conv, &param);
2402}
2403
Kees Cook54b50192012-07-30 14:39:18 -07002404static void validate_coredump_safety(void)
2405{
Alex Kelly046d6622012-10-04 17:15:23 -07002406#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002407 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002408 core_pattern[0] != '/' && core_pattern[0] != '|') {
2409 printk(KERN_WARNING "Unsafe core_pattern used with "\
2410 "suid_dumpable=2. Pipe handler or fully qualified "\
2411 "core dump path required.\n");
2412 }
Alex Kelly046d6622012-10-04 17:15:23 -07002413#endif
Kees Cook54b50192012-07-30 14:39:18 -07002414}
2415
2416static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2417 void __user *buffer, size_t *lenp, loff_t *ppos)
2418{
2419 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2420 if (!error)
2421 validate_coredump_safety();
2422 return error;
2423}
2424
Alex Kelly046d6622012-10-04 17:15:23 -07002425#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002426static int proc_dostring_coredump(struct ctl_table *table, int write,
2427 void __user *buffer, size_t *lenp, loff_t *ppos)
2428{
2429 int error = proc_dostring(table, write, buffer, lenp, ppos);
2430 if (!error)
2431 validate_coredump_safety();
2432 return error;
2433}
Alex Kelly046d6622012-10-04 17:15:23 -07002434#endif
Kees Cook54b50192012-07-30 14:39:18 -07002435
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002436static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002437 void __user *buffer,
2438 size_t *lenp, loff_t *ppos,
2439 unsigned long convmul,
2440 unsigned long convdiv)
2441{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002442 unsigned long *i, *min, *max;
2443 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002444 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002445 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002446
2447 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002448 *lenp = 0;
2449 return 0;
2450 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002451
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002452 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002453 min = (unsigned long *) table->extra1;
2454 max = (unsigned long *) table->extra2;
2455 vleft = table->maxlen / sizeof(unsigned long);
2456 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002457
2458 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002459 if (*ppos) {
2460 switch (sysctl_writes_strict) {
2461 case SYSCTL_WRITES_STRICT:
2462 goto out;
2463 case SYSCTL_WRITES_WARN:
2464 warn_sysctl_write(table);
2465 break;
2466 default:
2467 break;
2468 }
2469 }
2470
Amerigo Wang00b7c332010-05-05 00:26:45 +00002471 if (left > PAGE_SIZE - 1)
2472 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002473 p = kbuf = memdup_user_nul(buffer, left);
2474 if (IS_ERR(kbuf))
2475 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002476 }
2477
Eric Dumazet27b3d802010-10-07 12:59:29 -07002478 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002479 unsigned long val;
2480
Linus Torvalds1da177e2005-04-16 15:20:36 -07002481 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002482 bool neg;
2483
Al Viro70f6cbb2015-12-24 00:13:10 -05002484 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002485
Al Viro70f6cbb2015-12-24 00:13:10 -05002486 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002487 proc_wspace_sep,
2488 sizeof(proc_wspace_sep), NULL);
2489 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002490 break;
2491 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492 continue;
Eric Dumazet03707d62017-01-25 18:20:55 -08002493 val = convmul * val / convdiv;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494 if ((min && val < *min) || (max && val > *max))
2495 continue;
2496 *i = val;
2497 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002498 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002499 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002500 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002501 if (err)
2502 break;
2503 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002504 err = proc_put_long(&buffer, &left, val, false);
2505 if (err)
2506 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002507 }
2508 }
2509
Amerigo Wang00b7c332010-05-05 00:26:45 +00002510 if (!write && !first && left && !err)
2511 err = proc_put_char(&buffer, &left, '\n');
2512 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002513 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002515 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002516 if (first)
2517 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002518 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002519 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002520out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002521 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002522 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002523}
2524
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002525static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002526 void __user *buffer,
2527 size_t *lenp, loff_t *ppos,
2528 unsigned long convmul,
2529 unsigned long convdiv)
2530{
2531 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002532 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002533}
2534
Linus Torvalds1da177e2005-04-16 15:20:36 -07002535/**
2536 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2537 * @table: the sysctl table
2538 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002539 * @buffer: the user buffer
2540 * @lenp: the size of the user buffer
2541 * @ppos: file position
2542 *
2543 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2544 * values from/to the user buffer, treated as an ASCII string.
2545 *
2546 * This routine will ensure the values are within the range specified by
2547 * table->extra1 (min) and table->extra2 (max).
2548 *
2549 * Returns 0 on success.
2550 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002551int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002552 void __user *buffer, size_t *lenp, loff_t *ppos)
2553{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002554 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002555}
2556
2557/**
2558 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2559 * @table: the sysctl table
2560 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002561 * @buffer: the user buffer
2562 * @lenp: the size of the user buffer
2563 * @ppos: file position
2564 *
2565 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2566 * values from/to the user buffer, treated as an ASCII string. The values
2567 * are treated as milliseconds, and converted to jiffies when they are stored.
2568 *
2569 * This routine will ensure the values are within the range specified by
2570 * table->extra1 (min) and table->extra2 (max).
2571 *
2572 * Returns 0 on success.
2573 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002574int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002575 void __user *buffer,
2576 size_t *lenp, loff_t *ppos)
2577{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002578 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002579 lenp, ppos, HZ, 1000l);
2580}
2581
2582
Amerigo Wang00b7c332010-05-05 00:26:45 +00002583static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002584 int *valp,
2585 int write, void *data)
2586{
2587 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002588 if (*lvalp > LONG_MAX / HZ)
2589 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002590 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2591 } else {
2592 int val = *valp;
2593 unsigned long lval;
2594 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002595 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002596 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002597 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002598 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002599 lval = (unsigned long)val;
2600 }
2601 *lvalp = lval / HZ;
2602 }
2603 return 0;
2604}
2605
Amerigo Wang00b7c332010-05-05 00:26:45 +00002606static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002607 int *valp,
2608 int write, void *data)
2609{
2610 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002611 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2612 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002613 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2614 } else {
2615 int val = *valp;
2616 unsigned long lval;
2617 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002618 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002619 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002621 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002622 lval = (unsigned long)val;
2623 }
2624 *lvalp = jiffies_to_clock_t(lval);
2625 }
2626 return 0;
2627}
2628
Amerigo Wang00b7c332010-05-05 00:26:45 +00002629static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002630 int *valp,
2631 int write, void *data)
2632{
2633 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002634 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2635
2636 if (jif > INT_MAX)
2637 return 1;
2638 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002639 } else {
2640 int val = *valp;
2641 unsigned long lval;
2642 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002643 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002644 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002645 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002646 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002647 lval = (unsigned long)val;
2648 }
2649 *lvalp = jiffies_to_msecs(lval);
2650 }
2651 return 0;
2652}
2653
2654/**
2655 * proc_dointvec_jiffies - read a vector of integers as seconds
2656 * @table: the sysctl table
2657 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002658 * @buffer: the user buffer
2659 * @lenp: the size of the user buffer
2660 * @ppos: file position
2661 *
2662 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2663 * values from/to the user buffer, treated as an ASCII string.
2664 * The values read are assumed to be in seconds, and are converted into
2665 * jiffies.
2666 *
2667 * Returns 0 on success.
2668 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002669int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002670 void __user *buffer, size_t *lenp, loff_t *ppos)
2671{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002672 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002673 do_proc_dointvec_jiffies_conv,NULL);
2674}
2675
2676/**
2677 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2678 * @table: the sysctl table
2679 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002680 * @buffer: the user buffer
2681 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002682 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002683 *
2684 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2685 * values from/to the user buffer, treated as an ASCII string.
2686 * The values read are assumed to be in 1/USER_HZ seconds, and
2687 * are converted into jiffies.
2688 *
2689 * Returns 0 on success.
2690 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002691int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002692 void __user *buffer, size_t *lenp, loff_t *ppos)
2693{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002694 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002695 do_proc_dointvec_userhz_jiffies_conv,NULL);
2696}
2697
2698/**
2699 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2700 * @table: the sysctl table
2701 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002702 * @buffer: the user buffer
2703 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002704 * @ppos: file position
2705 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002706 *
2707 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2708 * values from/to the user buffer, treated as an ASCII string.
2709 * The values read are assumed to be in 1/1000 seconds, and
2710 * are converted into jiffies.
2711 *
2712 * Returns 0 on success.
2713 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002714int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002715 void __user *buffer, size_t *lenp, loff_t *ppos)
2716{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002717 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002718 do_proc_dointvec_ms_jiffies_conv, NULL);
2719}
2720
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002721static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002722 void __user *buffer, size_t *lenp, loff_t *ppos)
2723{
2724 struct pid *new_pid;
2725 pid_t tmp;
2726 int r;
2727
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002728 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002729
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002730 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002731 lenp, ppos, NULL, NULL);
2732 if (r || !write)
2733 return r;
2734
2735 new_pid = find_get_pid(tmp);
2736 if (!new_pid)
2737 return -ESRCH;
2738
2739 put_pid(xchg(&cad_pid, new_pid));
2740 return 0;
2741}
2742
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002743/**
2744 * proc_do_large_bitmap - read/write from/to a large bitmap
2745 * @table: the sysctl table
2746 * @write: %TRUE if this is a write to the sysctl file
2747 * @buffer: the user buffer
2748 * @lenp: the size of the user buffer
2749 * @ppos: file position
2750 *
2751 * The bitmap is stored at table->data and the bitmap length (in bits)
2752 * in table->maxlen.
2753 *
2754 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2755 * large bitmaps may be represented in a compact manner. Writing into
2756 * the file will clear the bitmap then update it with the given input.
2757 *
2758 * Returns 0 on success.
2759 */
2760int proc_do_large_bitmap(struct ctl_table *table, int write,
2761 void __user *buffer, size_t *lenp, loff_t *ppos)
2762{
2763 int err = 0;
2764 bool first = 1;
2765 size_t left = *lenp;
2766 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002767 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002768 unsigned long *tmp_bitmap = NULL;
2769 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2770
WANG Cong122ff242014-05-12 16:04:53 -07002771 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002772 *lenp = 0;
2773 return 0;
2774 }
2775
2776 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002777 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002778
2779 if (left > PAGE_SIZE - 1)
2780 left = PAGE_SIZE - 1;
2781
Al Viro70f6cbb2015-12-24 00:13:10 -05002782 p = kbuf = memdup_user_nul(buffer, left);
2783 if (IS_ERR(kbuf))
2784 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002785
2786 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2787 GFP_KERNEL);
2788 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002789 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002790 return -ENOMEM;
2791 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002792 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002793 while (!err && left) {
2794 unsigned long val_a, val_b;
2795 bool neg;
2796
Al Viro70f6cbb2015-12-24 00:13:10 -05002797 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002798 sizeof(tr_a), &c);
2799 if (err)
2800 break;
2801 if (val_a >= bitmap_len || neg) {
2802 err = -EINVAL;
2803 break;
2804 }
2805
2806 val_b = val_a;
2807 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002808 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002809 left--;
2810 }
2811
2812 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05002813 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002814 &neg, tr_b, sizeof(tr_b),
2815 &c);
2816 if (err)
2817 break;
2818 if (val_b >= bitmap_len || neg ||
2819 val_a > val_b) {
2820 err = -EINVAL;
2821 break;
2822 }
2823 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002824 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002825 left--;
2826 }
2827 }
2828
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002829 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002830 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05002831 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002832 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002833 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002834 } else {
2835 unsigned long bit_a, bit_b = 0;
2836
2837 while (left) {
2838 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2839 if (bit_a >= bitmap_len)
2840 break;
2841 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2842 bit_a + 1) - 1;
2843
2844 if (!first) {
2845 err = proc_put_char(&buffer, &left, ',');
2846 if (err)
2847 break;
2848 }
2849 err = proc_put_long(&buffer, &left, bit_a, false);
2850 if (err)
2851 break;
2852 if (bit_a != bit_b) {
2853 err = proc_put_char(&buffer, &left, '-');
2854 if (err)
2855 break;
2856 err = proc_put_long(&buffer, &left, bit_b, false);
2857 if (err)
2858 break;
2859 }
2860
2861 first = 0; bit_b++;
2862 }
2863 if (!err)
2864 err = proc_put_char(&buffer, &left, '\n');
2865 }
2866
2867 if (!err) {
2868 if (write) {
2869 if (*ppos)
2870 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2871 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002872 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002873 }
2874 kfree(tmp_bitmap);
2875 *lenp -= left;
2876 *ppos += *lenp;
2877 return 0;
2878 } else {
2879 kfree(tmp_bitmap);
2880 return err;
2881 }
2882}
2883
Jovi Zhang55610502011-01-12 17:00:45 -08002884#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002885
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002886int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002887 void __user *buffer, size_t *lenp, loff_t *ppos)
2888{
2889 return -ENOSYS;
2890}
2891
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002892int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002893 void __user *buffer, size_t *lenp, loff_t *ppos)
2894{
2895 return -ENOSYS;
2896}
2897
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002898int proc_douintvec(struct ctl_table *table, int write,
2899 void __user *buffer, size_t *lenp, loff_t *ppos)
2900{
2901 return -ENOSYS;
2902}
2903
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002904int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002905 void __user *buffer, size_t *lenp, loff_t *ppos)
2906{
2907 return -ENOSYS;
2908}
2909
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002910int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002911 void __user *buffer, size_t *lenp, loff_t *ppos)
2912{
2913 return -ENOSYS;
2914}
2915
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002916int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002917 void __user *buffer, size_t *lenp, loff_t *ppos)
2918{
2919 return -ENOSYS;
2920}
2921
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002922int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002923 void __user *buffer, size_t *lenp, loff_t *ppos)
2924{
2925 return -ENOSYS;
2926}
2927
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002928int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002929 void __user *buffer, size_t *lenp, loff_t *ppos)
2930{
2931 return -ENOSYS;
2932}
2933
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002934int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002935 void __user *buffer,
2936 size_t *lenp, loff_t *ppos)
2937{
2938 return -ENOSYS;
2939}
2940
2941
Jovi Zhang55610502011-01-12 17:00:45 -08002942#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002943
Linus Torvalds1da177e2005-04-16 15:20:36 -07002944/*
2945 * No sense putting this after each symbol definition, twice,
2946 * exception granted :-)
2947 */
2948EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002949EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002950EXPORT_SYMBOL(proc_dointvec_jiffies);
2951EXPORT_SYMBOL(proc_dointvec_minmax);
2952EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2953EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2954EXPORT_SYMBOL(proc_dostring);
2955EXPORT_SYMBOL(proc_doulongvec_minmax);
2956EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);