blob: 7df6be31be3617ed780fa52d24fe7611458011b1 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * sysctl.c: General linux system control interface
3 *
4 * Begun 24 March 1995, Stephen Tweedie
5 * Added /proc support, Dec 1995
6 * Added bdflush entry and intvec min/max checking, 2/23/96, Tom Dyas.
7 * Added hooks for /proc/sys/net (minor, minor patch), 96/4/1, Mike Shaver.
8 * Added kernel/java-{interpreter,appletviewer}, 96/5/10, Mike Shaver.
9 * Dynamic registration fixes, Stephen Tweedie.
10 * Added kswapd-interval, ctrl-alt-del, printk stuff, 1/8/97, Chris Horn.
11 * Made sysctl support optional via CONFIG_SYSCTL, 1/10/97, Chris
12 * Horn.
13 * Added proc_doulongvec_ms_jiffies_minmax, 09/08/99, Carlos H. Bauer.
14 * Added proc_doulongvec_minmax, 09/08/99, Carlos H. Bauer.
15 * Changed linked lists to use list.h instead of lists.h, 02/24/00, Bill
16 * Wendling.
17 * The list_for_each() macro wasn't appropriate for the sysctl loop.
18 * Removed it and replaced it with older style, 03/23/00, Bill Wendling
19 */
20
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <linux/module.h>
Christoph Hellwige2e40f22015-02-22 08:58:50 -080022#include <linux/aio.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/mm.h>
24#include <linux/swap.h>
25#include <linux/slab.h>
26#include <linux/sysctl.h>
Akinobu Mita5a04cca2012-03-28 14:42:50 -070027#include <linux/bitmap.h>
Dave Youngd33ed522010-03-10 15:23:59 -080028#include <linux/signal.h>
Dan Rosenberg455cd5a2011-01-12 16:59:41 -080029#include <linux/printk.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070030#include <linux/proc_fs.h>
Andrew Morgan72c2d582007-10-18 03:05:59 -070031#include <linux/security.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032#include <linux/ctype.h>
Vegard Nossumdfec0722008-04-04 00:51:41 +020033#include <linux/kmemcheck.h>
Steven Rostedtfd4b6162012-07-30 14:42:48 -070034#include <linux/kmemleak.h>
Adrian Bunk62239ac2007-07-17 04:03:45 -070035#include <linux/fs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070036#include <linux/init.h>
37#include <linux/kernel.h>
Kay Sievers0296b222005-11-11 05:33:52 +010038#include <linux/kobject.h>
Arnaldo Carvalho de Melo20380732005-08-16 02:18:02 -030039#include <linux/net.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070040#include <linux/sysrq.h>
41#include <linux/highuid.h>
42#include <linux/writeback.h>
Ingo Molnar3fff4c42009-09-22 16:18:09 +020043#include <linux/ratelimit.h>
Mel Gorman76ab0f52010-05-24 14:32:28 -070044#include <linux/compaction.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <linux/hugetlb.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070046#include <linux/initrd.h>
David Howells0b77f5b2008-04-29 01:01:32 -070047#include <linux/key.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#include <linux/times.h>
49#include <linux/limits.h>
50#include <linux/dcache.h>
Alexey Dobriyan6e006702010-01-20 22:27:56 +020051#include <linux/dnotify.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070052#include <linux/syscalls.h>
Adrian Bunkc748e132008-07-23 21:27:03 -070053#include <linux/vmstat.h>
Pavel Machekc255d842006-02-20 18:27:58 -080054#include <linux/nfs_fs.h>
55#include <linux/acpi.h>
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -070056#include <linux/reboot.h>
Steven Rostedtb0fc4942008-05-12 21:20:43 +020057#include <linux/ftrace.h>
Ingo Molnarcdd6c482009-09-21 12:02:48 +020058#include <linux/perf_event.h>
Masami Hiramatsub2be84d2010-02-25 08:34:15 -050059#include <linux/kprobes.h>
Jens Axboeb492e952010-05-19 21:03:16 +020060#include <linux/pipe_fs_i.h>
David Rientjes8e4228e2010-08-09 17:18:56 -070061#include <linux/oom.h>
Eric Paris17f60a72011-04-01 17:07:50 -040062#include <linux/kmod.h>
Dan Ballard73efc032011-10-31 17:11:20 -070063#include <linux/capability.h>
Al Viro40401532012-02-13 03:58:52 +000064#include <linux/binfmts.h>
Clark Williamscf4aebc22013-02-07 09:46:59 -060065#include <linux/sched/sysctl.h>
Kees Cook79847542014-01-23 15:55:59 -080066#include <linux/kexec.h>
Alexei Starovoitov1be7f752015-10-07 22:23:21 -070067#include <linux/bpf.h>
Eric W. Biedermand2921682016-09-28 00:27:17 -050068#include <linux/mount.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70#include <asm/uaccess.h>
71#include <asm/processor.h>
72
Andi Kleen29cbc782006-09-30 01:47:55 +020073#ifdef CONFIG_X86
74#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010075#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010076#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020077#endif
David Howellsd550bbd2012-03-28 18:30:03 +010078#ifdef CONFIG_SPARC
79#include <asm/setup.h>
80#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080081#ifdef CONFIG_BSD_PROCESS_ACCT
82#include <linux/acct.h>
83#endif
Dave Young4f0e0562010-03-10 15:24:09 -080084#ifdef CONFIG_RT_MUTEXES
85#include <linux/rtmutex.h>
86#endif
Dave Young2edf5e42010-03-10 15:24:10 -080087#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
88#include <linux/lockdep.h>
89#endif
Dave Young15485a42010-03-10 15:24:07 -080090#ifdef CONFIG_CHR_DEV_SG
91#include <scsi/sg.h>
92#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020093
Don Zickus58687ac2010-05-07 17:11:44 -040094#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050095#include <linux/nmi.h>
96#endif
97
Linus Torvalds1da177e2005-04-16 15:20:36 -070098#if defined(CONFIG_SYSCTL)
99
100/* External variables not in a header file. */
Alan Coxd6e71142005-06-23 00:09:43 -0700101extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700102#ifdef CONFIG_COREDUMP
103extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700105extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700106#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800109extern int percpu_pagelist_fraction;
Arjan van de Ven97455122008-01-25 21:08:34 +0100110extern int latencytop_enabled;
Alexey Dobriyan9b80a182016-09-02 00:38:52 +0300111extern unsigned int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000112#ifndef CONFIG_MMU
113extern int sysctl_nr_trim_pages;
114#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700116/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400117#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700118static int sixty = 60;
119#endif
120
Aaron Tomlin270750db2014-01-20 17:34:13 +0000121static int __maybe_unused neg_one = -1;
122
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700123static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700124static int __maybe_unused one = 1;
125static int __maybe_unused two = 2;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700126static int __maybe_unused four = 4;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800127static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700128static int one_hundred = 100;
Johannes Weiner795ae7a2016-03-17 14:19:14 -0700129static int one_thousand = 1000;
Dave Youngaf913222009-09-22 16:43:33 -0700130#ifdef CONFIG_PRINTK
131static int ten_thousand = 10000;
132#endif
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -0300133#ifdef CONFIG_PERF_EVENTS
134static int six_hundred_forty_kb = 640 * 1024;
135#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700136
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700137/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
138static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
139
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
141static int maxolduid = 65535;
142static int minolduid;
143
144static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700145static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146
Liu Hua80df2842014-04-07 15:38:57 -0700147/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
148#ifdef CONFIG_DETECT_HUNG_TASK
149static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
150#endif
151
Dave Youngd14f1722010-02-25 20:28:57 -0500152#ifdef CONFIG_INOTIFY_USER
153#include <linux/inotify.h>
154#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700155#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156#endif
157
158#ifdef __hppa__
159extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530160#endif
161
162#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163extern int unaligned_enabled;
164#endif
165
Jes Sorensend2b176e2006-02-28 09:42:23 -0800166#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800167extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800168#endif
169
Vineet Guptab6fca722013-01-09 20:06:28 +0530170#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
171extern int no_unaligned_warning;
172#endif
173
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700174#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700175
176#define SYSCTL_WRITES_LEGACY -1
177#define SYSCTL_WRITES_WARN 0
178#define SYSCTL_WRITES_STRICT 1
179
Kees Cook41662f52016-01-20 15:00:45 -0800180static int sysctl_writes_strict = SYSCTL_WRITES_STRICT;
Kees Cookf4aacea2014-06-06 14:37:19 -0700181
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700182static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700183 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700184static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800185 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700186#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700187
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700188#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700189static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700190 void __user *buffer, size_t *lenp, loff_t *ppos);
191#endif
192
Kees Cook54b50192012-07-30 14:39:18 -0700193static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
194 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700195#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700196static int proc_dostring_coredump(struct ctl_table *table, int write,
197 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700198#endif
Kees Cook54b50192012-07-30 14:39:18 -0700199
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700200#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800201/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100202static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700203
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700204static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700205 void __user *buffer, size_t *lenp,
206 loff_t *ppos)
207{
208 int error;
209
210 error = proc_dointvec(table, write, buffer, lenp, ppos);
211 if (error)
212 return error;
213
214 if (write)
215 sysrq_toggle_support(__sysrq_enabled);
216
217 return 0;
218}
219
220#endif
221
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700222static struct ctl_table kern_table[];
223static struct ctl_table vm_table[];
224static struct ctl_table fs_table[];
225static struct ctl_table debug_table[];
226static struct ctl_table dev_table[];
227extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800228#ifdef CONFIG_EPOLL
229extern struct ctl_table epoll_table[];
230#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231
232#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
233int sysctl_legacy_va_layout;
234#endif
235
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236/* The default sysctl tables: */
237
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800238static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 .procname = "kernel",
241 .mode = 0555,
242 .child = kern_table,
243 },
244 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 .procname = "vm",
246 .mode = 0555,
247 .child = vm_table,
248 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 .procname = "fs",
251 .mode = 0555,
252 .child = fs_table,
253 },
254 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 .procname = "debug",
256 .mode = 0555,
257 .child = debug_table,
258 },
259 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260 .procname = "dev",
261 .mode = 0555,
262 .child = dev_table,
263 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700264 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265};
266
Ingo Molnar77e54a12007-07-09 18:52:00 +0200267#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100268static int min_sched_granularity_ns = 100000; /* 100 usecs */
269static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
270static int min_wakeup_granularity_ns; /* 0 usecs */
271static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200272#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100273static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
274static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200275#endif /* CONFIG_SMP */
276#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200277
Mel Gorman5e771902010-05-24 14:32:31 -0700278#ifdef CONFIG_COMPACTION
279static int min_extfrag_threshold;
280static int max_extfrag_threshold = 1000;
281#endif
282
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700283static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200284 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200285 .procname = "sched_child_runs_first",
286 .data = &sysctl_sched_child_runs_first,
287 .maxlen = sizeof(unsigned int),
288 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800289 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200290 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200291#ifdef CONFIG_SCHED_DEBUG
292 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100293 .procname = "sched_min_granularity_ns",
294 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200295 .maxlen = sizeof(unsigned int),
296 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800297 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100298 .extra1 = &min_sched_granularity_ns,
299 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200300 },
301 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200302 .procname = "sched_latency_ns",
303 .data = &sysctl_sched_latency,
304 .maxlen = sizeof(unsigned int),
305 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800306 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200307 .extra1 = &min_sched_granularity_ns,
308 .extra2 = &max_sched_granularity_ns,
309 },
310 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200311 .procname = "sched_wakeup_granularity_ns",
312 .data = &sysctl_sched_wakeup_granularity,
313 .maxlen = sizeof(unsigned int),
314 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800315 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200316 .extra1 = &min_wakeup_granularity_ns,
317 .extra2 = &max_wakeup_granularity_ns,
318 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200319#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200320 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100321 .procname = "sched_tunable_scaling",
322 .data = &sysctl_sched_tunable_scaling,
323 .maxlen = sizeof(enum sched_tunable_scaling),
324 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800325 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100326 .extra1 = &min_sched_tunable_scaling,
327 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200328 },
329 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900330 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200331 .data = &sysctl_sched_migration_cost,
332 .maxlen = sizeof(unsigned int),
333 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800334 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200335 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100336 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100337 .procname = "sched_nr_migrate",
338 .data = &sysctl_sched_nr_migrate,
339 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100340 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800341 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100342 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530343 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900344 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200345 .data = &sysctl_sched_time_avg,
346 .maxlen = sizeof(unsigned int),
347 .mode = 0644,
Ethan Zhaofe0034a2017-09-04 13:59:34 +0800348 .proc_handler = proc_dointvec_minmax,
349 .extra1 = &one,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200350 },
351 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900352 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800353 .data = &sysctl_sched_shares_window,
354 .maxlen = sizeof(unsigned int),
355 .mode = 0644,
356 .proc_handler = proc_dointvec,
357 },
Mel Gormancb251762016-02-05 09:08:36 +0000358#ifdef CONFIG_SCHEDSTATS
359 {
360 .procname = "sched_schedstats",
361 .data = NULL,
362 .maxlen = sizeof(unsigned int),
363 .mode = 0644,
364 .proc_handler = sysctl_schedstats,
365 .extra1 = &zero,
366 .extra2 = &one,
367 },
368#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200369#endif /* CONFIG_SMP */
370#ifdef CONFIG_NUMA_BALANCING
371 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200372 .procname = "numa_balancing_scan_delay_ms",
373 .data = &sysctl_numa_balancing_scan_delay,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
376 .proc_handler = proc_dointvec,
377 },
378 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200379 .procname = "numa_balancing_scan_period_min_ms",
380 .data = &sysctl_numa_balancing_scan_period_min,
381 .maxlen = sizeof(unsigned int),
382 .mode = 0644,
383 .proc_handler = proc_dointvec,
384 },
385 {
386 .procname = "numa_balancing_scan_period_max_ms",
387 .data = &sysctl_numa_balancing_scan_period_max,
388 .maxlen = sizeof(unsigned int),
389 .mode = 0644,
390 .proc_handler = proc_dointvec,
391 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200392 {
393 .procname = "numa_balancing_scan_size_mb",
394 .data = &sysctl_numa_balancing_scan_size,
395 .maxlen = sizeof(unsigned int),
396 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400397 .proc_handler = proc_dointvec_minmax,
398 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200399 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100400 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800401 .procname = "numa_balancing",
402 .data = NULL, /* filled in by handler */
403 .maxlen = sizeof(unsigned int),
404 .mode = 0644,
405 .proc_handler = sysctl_numa_balancing,
406 .extra1 = &zero,
407 .extra2 = &one,
408 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200409#endif /* CONFIG_NUMA_BALANCING */
410#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200411 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100412 .procname = "sched_rt_period_us",
413 .data = &sysctl_sched_rt_period,
414 .maxlen = sizeof(unsigned int),
415 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800416 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100417 },
418 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100419 .procname = "sched_rt_runtime_us",
420 .data = &sysctl_sched_rt_runtime,
421 .maxlen = sizeof(int),
422 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800423 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100424 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600425 {
426 .procname = "sched_rr_timeslice_ms",
427 .data = &sched_rr_timeslice,
428 .maxlen = sizeof(int),
429 .mode = 0644,
430 .proc_handler = sched_rr_handler,
431 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100432#ifdef CONFIG_SCHED_AUTOGROUP
433 {
434 .procname = "sched_autogroup_enabled",
435 .data = &sysctl_sched_autogroup_enabled,
436 .maxlen = sizeof(unsigned int),
437 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800438 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100439 .extra1 = &zero,
440 .extra2 = &one,
441 },
442#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700443#ifdef CONFIG_CFS_BANDWIDTH
444 {
445 .procname = "sched_cfs_bandwidth_slice_us",
446 .data = &sysctl_sched_cfs_bandwidth_slice,
447 .maxlen = sizeof(unsigned int),
448 .mode = 0644,
449 .proc_handler = proc_dointvec_minmax,
450 .extra1 = &one,
451 },
452#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700453#ifdef CONFIG_PROVE_LOCKING
454 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700455 .procname = "prove_locking",
456 .data = &prove_locking,
457 .maxlen = sizeof(int),
458 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800459 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700460 },
461#endif
462#ifdef CONFIG_LOCK_STAT
463 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700464 .procname = "lock_stat",
465 .data = &lock_stat,
466 .maxlen = sizeof(int),
467 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800468 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700469 },
470#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200471 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 .procname = "panic",
473 .data = &panic_timeout,
474 .maxlen = sizeof(int),
475 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800476 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 },
Alex Kelly046d6622012-10-04 17:15:23 -0700478#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 .procname = "core_uses_pid",
481 .data = &core_uses_pid,
482 .maxlen = sizeof(int),
483 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800484 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 },
486 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 .procname = "core_pattern",
488 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700489 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700491 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 },
Neil Hormana2939802009-09-23 15:56:56 -0700493 {
Neil Hormana2939802009-09-23 15:56:56 -0700494 .procname = "core_pipe_limit",
495 .data = &core_pipe_limit,
496 .maxlen = sizeof(unsigned int),
497 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800498 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700499 },
Alex Kelly046d6622012-10-04 17:15:23 -0700500#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800501#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700504 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800505 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800506 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700508 {
509 .procname = "sysctl_writes_strict",
510 .data = &sysctl_writes_strict,
511 .maxlen = sizeof(int),
512 .mode = 0644,
513 .proc_handler = proc_dointvec_minmax,
514 .extra1 = &neg_one,
515 .extra2 = &one,
516 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800517#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100518#ifdef CONFIG_LATENCYTOP
519 {
520 .procname = "latencytop",
521 .data = &latencytop_enabled,
522 .maxlen = sizeof(int),
523 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000524 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100525 },
526#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527#ifdef CONFIG_BLK_DEV_INITRD
528 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 .procname = "real-root-dev",
530 .data = &real_root_dev,
531 .maxlen = sizeof(int),
532 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800533 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 },
535#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700536 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700537 .procname = "print-fatal-signals",
538 .data = &print_fatal_signals,
539 .maxlen = sizeof(int),
540 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800541 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700542 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700543#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 .procname = "reboot-cmd",
546 .data = reboot_command,
547 .maxlen = 256,
548 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800549 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 },
551 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 .procname = "stop-a",
553 .data = &stop_a_enabled,
554 .maxlen = sizeof (int),
555 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800556 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 },
558 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 .procname = "scons-poweroff",
560 .data = &scons_pwroff,
561 .maxlen = sizeof (int),
562 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800563 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 },
565#endif
David S. Miller08714202008-11-16 23:49:24 -0800566#ifdef CONFIG_SPARC64
567 {
David S. Miller08714202008-11-16 23:49:24 -0800568 .procname = "tsb-ratio",
569 .data = &sysctl_tsb_ratio,
570 .maxlen = sizeof (int),
571 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800572 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800573 },
574#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575#ifdef __hppa__
576 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 .procname = "soft-power",
578 .data = &pwrsw_enabled,
579 .maxlen = sizeof (int),
580 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800581 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530583#endif
584#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 .procname = "unaligned-trap",
587 .data = &unaligned_enabled,
588 .maxlen = sizeof (int),
589 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800590 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 },
592#endif
593 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 .procname = "ctrl-alt-del",
595 .data = &C_A_D,
596 .maxlen = sizeof(int),
597 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800598 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400600#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200601 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200602 .procname = "ftrace_enabled",
603 .data = &ftrace_enabled,
604 .maxlen = sizeof(int),
605 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800606 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200607 },
608#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500609#ifdef CONFIG_STACK_TRACER
610 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500611 .procname = "stack_tracer_enabled",
612 .data = &stack_tracer_enabled,
613 .maxlen = sizeof(int),
614 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800615 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500616 },
617#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400618#ifdef CONFIG_TRACING
619 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100620 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400621 .data = &ftrace_dump_on_oops,
622 .maxlen = sizeof(int),
623 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800624 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400625 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400626 {
627 .procname = "traceoff_on_warning",
628 .data = &__disable_trace_on_warning,
629 .maxlen = sizeof(__disable_trace_on_warning),
630 .mode = 0644,
631 .proc_handler = proc_dointvec,
632 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500633 {
634 .procname = "tracepoint_printk",
635 .data = &tracepoint_printk,
636 .maxlen = sizeof(tracepoint_printk),
637 .mode = 0644,
638 .proc_handler = proc_dointvec,
639 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400640#endif
Dave Young2965faa2015-09-09 15:38:55 -0700641#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800642 {
643 .procname = "kexec_load_disabled",
644 .data = &kexec_load_disabled,
645 .maxlen = sizeof(int),
646 .mode = 0644,
647 /* only handle a transition from default "0" to "1" */
648 .proc_handler = proc_dointvec_minmax,
649 .extra1 = &one,
650 .extra2 = &one,
651 },
652#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200653#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 .procname = "modprobe",
656 .data = &modprobe_path,
657 .maxlen = KMOD_PATH_LEN,
658 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800659 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 },
Kees Cook3d433212009-04-02 15:49:29 -0700661 {
Kees Cook3d433212009-04-02 15:49:29 -0700662 .procname = "modules_disabled",
663 .data = &modules_disabled,
664 .maxlen = sizeof(int),
665 .mode = 0644,
666 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800667 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700668 .extra1 = &one,
669 .extra2 = &one,
670 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700672#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100675 .data = &uevent_helper,
676 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800678 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 },
Michael Marineau86d56132014-04-10 14:09:31 -0700680#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681#ifdef CONFIG_CHR_DEV_SG
682 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 .procname = "sg-big-buff",
684 .data = &sg_big_buff,
685 .maxlen = sizeof (int),
686 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800687 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 },
689#endif
690#ifdef CONFIG_BSD_PROCESS_ACCT
691 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 .procname = "acct",
693 .data = &acct_parm,
694 .maxlen = 3*sizeof(int),
695 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800696 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 },
698#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699#ifdef CONFIG_MAGIC_SYSRQ
700 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800702 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 .maxlen = sizeof (int),
704 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700705 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 },
707#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700708#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700711 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 .maxlen = sizeof (int),
713 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800714 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700716#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700719 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 .maxlen = sizeof(int),
721 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700722 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 },
724 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 .procname = "random",
726 .mode = 0555,
727 .child = random_table,
728 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 {
Eric Paris17f60a72011-04-01 17:07:50 -0400730 .procname = "usermodehelper",
731 .mode = 0555,
732 .child = usermodehelper_table,
733 },
734 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 .procname = "overflowuid",
736 .data = &overflowuid,
737 .maxlen = sizeof(int),
738 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800739 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 .extra1 = &minolduid,
741 .extra2 = &maxolduid,
742 },
743 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 .procname = "overflowgid",
745 .data = &overflowgid,
746 .maxlen = sizeof(int),
747 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800748 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 .extra1 = &minolduid,
750 .extra2 = &maxolduid,
751 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800752#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753#ifdef CONFIG_MATHEMU
754 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 .procname = "ieee_emulation_warnings",
756 .data = &sysctl_ieee_emulation_warnings,
757 .maxlen = sizeof(int),
758 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800759 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 },
761#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200764 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 .maxlen = sizeof(int),
766 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800767 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 },
769#endif
770 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 .procname = "pid_max",
772 .data = &pid_max,
773 .maxlen = sizeof (int),
774 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800775 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 .extra1 = &pid_max_min,
777 .extra2 = &pid_max_max,
778 },
779 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 .procname = "panic_on_oops",
781 .data = &panic_on_oops,
782 .maxlen = sizeof(int),
783 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800784 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800786#if defined CONFIG_PRINTK
787 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800788 .procname = "printk",
789 .data = &console_loglevel,
790 .maxlen = 4*sizeof(int),
791 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800792 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800793 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700796 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 .maxlen = sizeof(int),
798 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800799 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 },
801 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700803 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 .maxlen = sizeof(int),
805 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800806 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 },
Dave Youngaf913222009-09-22 16:43:33 -0700808 {
Dave Youngaf913222009-09-22 16:43:33 -0700809 .procname = "printk_delay",
810 .data = &printk_delay_msec,
811 .maxlen = sizeof(int),
812 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800813 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700814 .extra1 = &zero,
815 .extra2 = &ten_thousand,
816 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700818 .procname = "printk_devkmsg",
819 .data = devkmsg_log_str,
820 .maxlen = DEVKMSG_STR_MAX_SIZE,
821 .mode = 0644,
822 .proc_handler = devkmsg_sysctl_set_loglvl,
823 },
824 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800825 .procname = "dmesg_restrict",
826 .data = &dmesg_restrict,
827 .maxlen = sizeof(int),
828 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700829 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800830 .extra1 = &zero,
831 .extra2 = &one,
832 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800833 {
834 .procname = "kptr_restrict",
835 .data = &kptr_restrict,
836 .maxlen = sizeof(int),
837 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700838 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800839 .extra1 = &zero,
840 .extra2 = &two,
841 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800842#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800843 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 .procname = "ngroups_max",
845 .data = &ngroups_max,
846 .maxlen = sizeof (int),
847 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800848 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 },
Dan Ballard73efc032011-10-31 17:11:20 -0700850 {
851 .procname = "cap_last_cap",
852 .data = (void *)&cap_last_cap,
853 .maxlen = sizeof(int),
854 .mode = 0444,
855 .proc_handler = proc_dointvec,
856 },
Don Zickus58687ac2010-05-07 17:11:44 -0400857#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500858 {
Don Zickus58687ac2010-05-07 17:11:44 -0400859 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200860 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500861 .maxlen = sizeof (int),
862 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700863 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700864 .extra1 = &zero,
865 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400866 },
867 {
868 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700869 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400870 .maxlen = sizeof(int),
871 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700872 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800873 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400874 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500875 },
Don Zickus2508ce12010-05-07 17:11:46 -0400876 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700877 .procname = "nmi_watchdog",
878 .data = &nmi_watchdog_enabled,
879 .maxlen = sizeof (int),
880 .mode = 0644,
881 .proc_handler = proc_nmi_watchdog,
882 .extra1 = &zero,
883#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
884 .extra2 = &one,
885#else
886 .extra2 = &zero,
887#endif
888 },
889 {
890 .procname = "soft_watchdog",
891 .data = &soft_watchdog_enabled,
892 .maxlen = sizeof (int),
893 .mode = 0644,
894 .proc_handler = proc_soft_watchdog,
895 .extra1 = &zero,
896 .extra2 = &one,
897 },
898 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700899 .procname = "watchdog_cpumask",
900 .data = &watchdog_cpumask_bits,
901 .maxlen = NR_CPUS,
902 .mode = 0644,
903 .proc_handler = proc_watchdog_cpumask,
904 },
905 {
Don Zickus2508ce12010-05-07 17:11:46 -0400906 .procname = "softlockup_panic",
907 .data = &softlockup_panic,
908 .maxlen = sizeof(int),
909 .mode = 0644,
910 .proc_handler = proc_dointvec_minmax,
911 .extra1 = &zero,
912 .extra2 = &one,
913 },
Don Zickusac1f5912015-11-05 18:44:44 -0800914#ifdef CONFIG_HARDLOCKUP_DETECTOR
915 {
916 .procname = "hardlockup_panic",
917 .data = &hardlockup_panic,
918 .maxlen = sizeof(int),
919 .mode = 0644,
920 .proc_handler = proc_dointvec_minmax,
921 .extra1 = &zero,
922 .extra2 = &one,
923 },
924#endif
Aaron Tomlined235872014-06-23 13:22:05 -0700925#ifdef CONFIG_SMP
926 {
927 .procname = "softlockup_all_cpu_backtrace",
928 .data = &sysctl_softlockup_all_cpu_backtrace,
929 .maxlen = sizeof(int),
930 .mode = 0644,
931 .proc_handler = proc_dointvec_minmax,
932 .extra1 = &zero,
933 .extra2 = &one,
934 },
Jiri Kosina55537872015-11-05 18:44:41 -0800935 {
936 .procname = "hardlockup_all_cpu_backtrace",
937 .data = &sysctl_hardlockup_all_cpu_backtrace,
938 .maxlen = sizeof(int),
939 .mode = 0644,
940 .proc_handler = proc_dointvec_minmax,
941 .extra1 = &zero,
942 .extra2 = &one,
943 },
Aaron Tomlined235872014-06-23 13:22:05 -0700944#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -0500945#endif
946#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
947 {
948 .procname = "unknown_nmi_panic",
949 .data = &unknown_nmi_panic,
950 .maxlen = sizeof (int),
951 .mode = 0644,
952 .proc_handler = proc_dointvec,
953 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500954#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955#if defined(CONFIG_X86)
956 {
Don Zickus8da5add2006-09-26 10:52:27 +0200957 .procname = "panic_on_unrecovered_nmi",
958 .data = &panic_on_unrecovered_nmi,
959 .maxlen = sizeof(int),
960 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800961 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200962 },
963 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700964 .procname = "panic_on_io_nmi",
965 .data = &panic_on_io_nmi,
966 .maxlen = sizeof(int),
967 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800968 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700969 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900970#ifdef CONFIG_DEBUG_STACKOVERFLOW
971 {
972 .procname = "panic_on_stackoverflow",
973 .data = &sysctl_panic_on_stackoverflow,
974 .maxlen = sizeof(int),
975 .mode = 0644,
976 .proc_handler = proc_dointvec,
977 },
978#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700979 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 .procname = "bootloader_type",
981 .data = &bootloader_type,
982 .maxlen = sizeof (int),
983 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800984 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100986 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700987 .procname = "bootloader_version",
988 .data = &bootloader_version,
989 .maxlen = sizeof (int),
990 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800991 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700992 },
993 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100994 .procname = "kstack_depth_to_print",
995 .data = &kstack_depth_to_print,
996 .maxlen = sizeof(int),
997 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800998 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100999 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001000 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001001 .procname = "io_delay_type",
1002 .data = &io_delay_type,
1003 .maxlen = sizeof(int),
1004 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001005 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001006 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001007#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001008#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001009 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010 .procname = "randomize_va_space",
1011 .data = &randomize_va_space,
1012 .maxlen = sizeof(int),
1013 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001014 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001016#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001017#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001018 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001019 .procname = "spin_retry",
1020 .data = &spin_retry,
1021 .maxlen = sizeof (int),
1022 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001023 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001024 },
1025#endif
Len Brown673d5b42007-07-28 03:33:16 -04001026#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001027 {
Pavel Machekc255d842006-02-20 18:27:58 -08001028 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001029 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001030 .maxlen = sizeof (unsigned long),
1031 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001032 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001033 },
1034#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301035#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001036 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001037 .procname = "ignore-unaligned-usertrap",
1038 .data = &no_unaligned_warning,
1039 .maxlen = sizeof (int),
1040 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001041 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001042 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301043#endif
1044#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001045 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001046 .procname = "unaligned-dump-stack",
1047 .data = &unaligned_dump_stack,
1048 .maxlen = sizeof (int),
1049 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001050 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001051 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001052#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001053#ifdef CONFIG_DETECT_HUNG_TASK
1054 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001055 .procname = "hung_task_panic",
1056 .data = &sysctl_hung_task_panic,
1057 .maxlen = sizeof(int),
1058 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001059 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001060 .extra1 = &zero,
1061 .extra2 = &one,
1062 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001063 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001064 .procname = "hung_task_check_count",
1065 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001066 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001067 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001068 .proc_handler = proc_dointvec_minmax,
1069 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001070 },
1071 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001072 .procname = "hung_task_timeout_secs",
1073 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001074 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001075 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001076 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001077 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001078 },
1079 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001080 .procname = "hung_task_warnings",
1081 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001082 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001083 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001084 .proc_handler = proc_dointvec_minmax,
1085 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001086 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001087#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001088#ifdef CONFIG_RT_MUTEXES
1089 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001090 .procname = "max_lock_depth",
1091 .data = &max_lock_depth,
1092 .maxlen = sizeof(int),
1093 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001094 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001095 },
1096#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001097 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001098 .procname = "poweroff_cmd",
1099 .data = &poweroff_cmd,
1100 .maxlen = POWEROFF_CMD_PATH_LEN,
1101 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001102 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001103 },
David Howells0b77f5b2008-04-29 01:01:32 -07001104#ifdef CONFIG_KEYS
1105 {
David Howells0b77f5b2008-04-29 01:01:32 -07001106 .procname = "keys",
1107 .mode = 0555,
1108 .child = key_sysctls,
1109 },
1110#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001111#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001112 /*
1113 * User-space scripts rely on the existence of this file
1114 * as a feature check for perf_events being enabled.
1115 *
1116 * So it's an ABI, do not remove!
1117 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001118 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001119 .procname = "perf_event_paranoid",
1120 .data = &sysctl_perf_event_paranoid,
1121 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001122 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001123 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001124 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001125 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001126 .procname = "perf_event_mlock_kb",
1127 .data = &sysctl_perf_event_mlock,
1128 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001129 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001130 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001131 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001132 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001133 .procname = "perf_event_max_sample_rate",
1134 .data = &sysctl_perf_event_sample_rate,
1135 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001136 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001137 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001138 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001139 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001140 {
1141 .procname = "perf_cpu_time_max_percent",
1142 .data = &sysctl_perf_cpu_time_max_percent,
1143 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1144 .mode = 0644,
1145 .proc_handler = perf_cpu_time_max_percent_handler,
1146 .extra1 = &zero,
1147 .extra2 = &one_hundred,
1148 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001149 {
1150 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001151 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001152 .maxlen = sizeof(sysctl_perf_event_max_stack),
1153 .mode = 0644,
1154 .proc_handler = perf_event_max_stack_handler,
1155 .extra1 = &zero,
1156 .extra2 = &six_hundred_forty_kb,
1157 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001158 {
1159 .procname = "perf_event_max_contexts_per_stack",
1160 .data = &sysctl_perf_event_max_contexts_per_stack,
1161 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1162 .mode = 0644,
1163 .proc_handler = perf_event_max_stack_handler,
1164 .extra1 = &zero,
1165 .extra2 = &one_thousand,
1166 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001167#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001168#ifdef CONFIG_KMEMCHECK
1169 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001170 .procname = "kmemcheck",
1171 .data = &kmemcheck_enabled,
1172 .maxlen = sizeof(int),
1173 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001174 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001175 },
1176#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001177 {
1178 .procname = "panic_on_warn",
1179 .data = &panic_on_warn,
1180 .maxlen = sizeof(int),
1181 .mode = 0644,
1182 .proc_handler = proc_dointvec_minmax,
1183 .extra1 = &zero,
1184 .extra2 = &one,
1185 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001186#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1187 {
1188 .procname = "timer_migration",
1189 .data = &sysctl_timer_migration,
1190 .maxlen = sizeof(unsigned int),
1191 .mode = 0644,
1192 .proc_handler = timer_migration_handler,
Myungho Jung4c000152017-04-19 15:24:50 -07001193 .extra1 = &zero,
1194 .extra2 = &one,
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001195 },
1196#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001197#ifdef CONFIG_BPF_SYSCALL
1198 {
1199 .procname = "unprivileged_bpf_disabled",
1200 .data = &sysctl_unprivileged_bpf_disabled,
1201 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1202 .mode = 0644,
1203 /* only handle a transition from default "0" to "1" */
1204 .proc_handler = proc_dointvec_minmax,
1205 .extra1 = &one,
1206 .extra2 = &one,
1207 },
1208#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001209#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1210 {
1211 .procname = "panic_on_rcu_stall",
1212 .data = &sysctl_panic_on_rcu_stall,
1213 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1214 .mode = 0644,
1215 .proc_handler = proc_dointvec_minmax,
1216 .extra1 = &zero,
1217 .extra2 = &one,
1218 },
1219#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001220 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001221};
1222
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001223static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001224 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001225 .procname = "overcommit_memory",
1226 .data = &sysctl_overcommit_memory,
1227 .maxlen = sizeof(sysctl_overcommit_memory),
1228 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001229 .proc_handler = proc_dointvec_minmax,
1230 .extra1 = &zero,
1231 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232 },
1233 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001234 .procname = "panic_on_oom",
1235 .data = &sysctl_panic_on_oom,
1236 .maxlen = sizeof(sysctl_panic_on_oom),
1237 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001238 .proc_handler = proc_dointvec_minmax,
1239 .extra1 = &zero,
1240 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001241 },
1242 {
David Rientjesfe071d72007-10-16 23:25:56 -07001243 .procname = "oom_kill_allocating_task",
1244 .data = &sysctl_oom_kill_allocating_task,
1245 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1246 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001247 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001248 },
1249 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001250 .procname = "oom_dump_tasks",
1251 .data = &sysctl_oom_dump_tasks,
1252 .maxlen = sizeof(sysctl_oom_dump_tasks),
1253 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001254 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001255 },
1256 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257 .procname = "overcommit_ratio",
1258 .data = &sysctl_overcommit_ratio,
1259 .maxlen = sizeof(sysctl_overcommit_ratio),
1260 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001261 .proc_handler = overcommit_ratio_handler,
1262 },
1263 {
1264 .procname = "overcommit_kbytes",
1265 .data = &sysctl_overcommit_kbytes,
1266 .maxlen = sizeof(sysctl_overcommit_kbytes),
1267 .mode = 0644,
1268 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001269 },
1270 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271 .procname = "page-cluster",
1272 .data = &page_cluster,
1273 .maxlen = sizeof(int),
1274 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001275 .proc_handler = proc_dointvec_minmax,
1276 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001277 },
1278 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001279 .procname = "dirty_background_ratio",
1280 .data = &dirty_background_ratio,
1281 .maxlen = sizeof(dirty_background_ratio),
1282 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001283 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001284 .extra1 = &zero,
1285 .extra2 = &one_hundred,
1286 },
1287 {
David Rientjes2da02992009-01-06 14:39:31 -08001288 .procname = "dirty_background_bytes",
1289 .data = &dirty_background_bytes,
1290 .maxlen = sizeof(dirty_background_bytes),
1291 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001292 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001293 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001294 },
1295 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001296 .procname = "dirty_ratio",
1297 .data = &vm_dirty_ratio,
1298 .maxlen = sizeof(vm_dirty_ratio),
1299 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001300 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001301 .extra1 = &zero,
1302 .extra2 = &one_hundred,
1303 },
1304 {
David Rientjes2da02992009-01-06 14:39:31 -08001305 .procname = "dirty_bytes",
1306 .data = &vm_dirty_bytes,
1307 .maxlen = sizeof(vm_dirty_bytes),
1308 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001309 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001310 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001311 },
1312 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001313 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001314 .data = &dirty_writeback_interval,
1315 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001317 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001318 },
1319 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001321 .data = &dirty_expire_interval,
1322 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001323 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001324 .proc_handler = proc_dointvec_minmax,
1325 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001326 },
1327 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001328 .procname = "dirtytime_expire_seconds",
1329 .data = &dirtytime_expire_interval,
1330 .maxlen = sizeof(dirty_expire_interval),
1331 .mode = 0644,
1332 .proc_handler = dirtytime_interval_handler,
1333 .extra1 = &zero,
1334 },
1335 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001336 .procname = "nr_pdflush_threads",
1337 .mode = 0444 /* read-only */,
1338 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001339 },
1340 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001341 .procname = "swappiness",
1342 .data = &vm_swappiness,
1343 .maxlen = sizeof(vm_swappiness),
1344 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001345 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001346 .extra1 = &zero,
1347 .extra2 = &one_hundred,
1348 },
1349#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001350 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001351 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001352 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 .maxlen = sizeof(unsigned long),
1354 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001355 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001356 },
1357#ifdef CONFIG_NUMA
1358 {
1359 .procname = "nr_hugepages_mempolicy",
1360 .data = NULL,
1361 .maxlen = sizeof(unsigned long),
1362 .mode = 0644,
1363 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001364 },
1365#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001366 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001367 .procname = "hugetlb_shm_group",
1368 .data = &sysctl_hugetlb_shm_group,
1369 .maxlen = sizeof(gid_t),
1370 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001371 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372 },
Mel Gorman396faf02007-07-17 04:03:13 -07001373 {
Mel Gorman396faf02007-07-17 04:03:13 -07001374 .procname = "hugepages_treat_as_movable",
1375 .data = &hugepages_treat_as_movable,
1376 .maxlen = sizeof(int),
1377 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001378 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001379 },
Adam Litke54f9f802007-10-16 01:26:20 -07001380 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001381 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001382 .data = NULL,
1383 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001384 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001385 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001386 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001387#endif
1388 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001389 .procname = "lowmem_reserve_ratio",
1390 .data = &sysctl_lowmem_reserve_ratio,
1391 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1392 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001393 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001394 },
1395 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001396 .procname = "drop_caches",
1397 .data = &sysctl_drop_caches,
1398 .maxlen = sizeof(int),
1399 .mode = 0644,
1400 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001401 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001402 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001403 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001404#ifdef CONFIG_COMPACTION
1405 {
1406 .procname = "compact_memory",
1407 .data = &sysctl_compact_memory,
1408 .maxlen = sizeof(int),
1409 .mode = 0200,
1410 .proc_handler = sysctl_compaction_handler,
1411 },
Mel Gorman5e771902010-05-24 14:32:31 -07001412 {
1413 .procname = "extfrag_threshold",
1414 .data = &sysctl_extfrag_threshold,
1415 .maxlen = sizeof(int),
1416 .mode = 0644,
1417 .proc_handler = sysctl_extfrag_handler,
1418 .extra1 = &min_extfrag_threshold,
1419 .extra2 = &max_extfrag_threshold,
1420 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001421 {
1422 .procname = "compact_unevictable_allowed",
1423 .data = &sysctl_compact_unevictable_allowed,
1424 .maxlen = sizeof(int),
1425 .mode = 0644,
1426 .proc_handler = proc_dointvec,
1427 .extra1 = &zero,
1428 .extra2 = &one,
1429 },
Mel Gorman5e771902010-05-24 14:32:31 -07001430
Mel Gorman76ab0f52010-05-24 14:32:28 -07001431#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001432 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001433 .procname = "min_free_kbytes",
1434 .data = &min_free_kbytes,
1435 .maxlen = sizeof(min_free_kbytes),
1436 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001437 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001438 .extra1 = &zero,
1439 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001440 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001441 .procname = "watermark_scale_factor",
1442 .data = &watermark_scale_factor,
1443 .maxlen = sizeof(watermark_scale_factor),
1444 .mode = 0644,
1445 .proc_handler = watermark_scale_factor_sysctl_handler,
1446 .extra1 = &one,
1447 .extra2 = &one_thousand,
1448 },
1449 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001450 .procname = "percpu_pagelist_fraction",
1451 .data = &percpu_pagelist_fraction,
1452 .maxlen = sizeof(percpu_pagelist_fraction),
1453 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001454 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001455 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001456 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001457#ifdef CONFIG_MMU
1458 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001459 .procname = "max_map_count",
1460 .data = &sysctl_max_map_count,
1461 .maxlen = sizeof(sysctl_max_map_count),
1462 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001463 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001464 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001465 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001466#else
1467 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001468 .procname = "nr_trim_pages",
1469 .data = &sysctl_nr_trim_pages,
1470 .maxlen = sizeof(sysctl_nr_trim_pages),
1471 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001472 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001473 .extra1 = &zero,
1474 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001475#endif
1476 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 .procname = "laptop_mode",
1478 .data = &laptop_mode,
1479 .maxlen = sizeof(laptop_mode),
1480 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001481 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001482 },
1483 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001484 .procname = "block_dump",
1485 .data = &block_dump,
1486 .maxlen = sizeof(block_dump),
1487 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001488 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001489 .extra1 = &zero,
1490 },
1491 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492 .procname = "vfs_cache_pressure",
1493 .data = &sysctl_vfs_cache_pressure,
1494 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1495 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001496 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001497 .extra1 = &zero,
1498 },
1499#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1500 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001501 .procname = "legacy_va_layout",
1502 .data = &sysctl_legacy_va_layout,
1503 .maxlen = sizeof(sysctl_legacy_va_layout),
1504 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001505 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506 .extra1 = &zero,
1507 },
1508#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001509#ifdef CONFIG_NUMA
1510 {
Christoph Lameter17436602006-01-18 17:42:32 -08001511 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001512 .data = &node_reclaim_mode,
1513 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001514 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001515 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001516 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001517 },
Christoph Lameter96146342006-07-03 00:24:13 -07001518 {
Christoph Lameter96146342006-07-03 00:24:13 -07001519 .procname = "min_unmapped_ratio",
1520 .data = &sysctl_min_unmapped_ratio,
1521 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1522 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001523 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001524 .extra1 = &zero,
1525 .extra2 = &one_hundred,
1526 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001527 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001528 .procname = "min_slab_ratio",
1529 .data = &sysctl_min_slab_ratio,
1530 .maxlen = sizeof(sysctl_min_slab_ratio),
1531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001532 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001533 .extra1 = &zero,
1534 .extra2 = &one_hundred,
1535 },
Christoph Lameter17436602006-01-18 17:42:32 -08001536#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001537#ifdef CONFIG_SMP
1538 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001539 .procname = "stat_interval",
1540 .data = &sysctl_stat_interval,
1541 .maxlen = sizeof(sysctl_stat_interval),
1542 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001543 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001544 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001545 {
1546 .procname = "stat_refresh",
1547 .data = NULL,
1548 .maxlen = 0,
1549 .mode = 0600,
1550 .proc_handler = vmstat_refresh,
1551 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001552#endif
David Howells6e141542009-12-15 19:27:45 +00001553#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001554 {
Eric Parised032182007-06-28 15:55:21 -04001555 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001556 .data = &dac_mmap_min_addr,
1557 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001558 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001559 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001560 },
David Howells6e141542009-12-15 19:27:45 +00001561#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001562#ifdef CONFIG_NUMA
1563 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001564 .procname = "numa_zonelist_order",
1565 .data = &numa_zonelist_order,
1566 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1567 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001568 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001569 },
1570#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001571#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001572 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001573 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001574 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001575#ifdef CONFIG_X86_32
1576 .data = &vdso32_enabled,
1577 .maxlen = sizeof(vdso32_enabled),
1578#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001579 .data = &vdso_enabled,
1580 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001581#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001582 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001583 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001584 .extra1 = &zero,
1585 },
1586#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001587#ifdef CONFIG_HIGHMEM
1588 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001589 .procname = "highmem_is_dirtyable",
1590 .data = &vm_highmem_is_dirtyable,
1591 .maxlen = sizeof(vm_highmem_is_dirtyable),
1592 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001593 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001594 .extra1 = &zero,
1595 .extra2 = &one,
1596 },
1597#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001598#ifdef CONFIG_MEMORY_FAILURE
1599 {
Andi Kleen6a460792009-09-16 11:50:15 +02001600 .procname = "memory_failure_early_kill",
1601 .data = &sysctl_memory_failure_early_kill,
1602 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1603 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001604 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001605 .extra1 = &zero,
1606 .extra2 = &one,
1607 },
1608 {
Andi Kleen6a460792009-09-16 11:50:15 +02001609 .procname = "memory_failure_recovery",
1610 .data = &sysctl_memory_failure_recovery,
1611 .maxlen = sizeof(sysctl_memory_failure_recovery),
1612 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001613 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001614 .extra1 = &zero,
1615 .extra2 = &one,
1616 },
1617#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001618 {
1619 .procname = "user_reserve_kbytes",
1620 .data = &sysctl_user_reserve_kbytes,
1621 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1622 .mode = 0644,
1623 .proc_handler = proc_doulongvec_minmax,
1624 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001625 {
1626 .procname = "admin_reserve_kbytes",
1627 .data = &sysctl_admin_reserve_kbytes,
1628 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1629 .mode = 0644,
1630 .proc_handler = proc_doulongvec_minmax,
1631 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001632#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1633 {
1634 .procname = "mmap_rnd_bits",
1635 .data = &mmap_rnd_bits,
1636 .maxlen = sizeof(mmap_rnd_bits),
1637 .mode = 0600,
1638 .proc_handler = proc_dointvec_minmax,
1639 .extra1 = (void *)&mmap_rnd_bits_min,
1640 .extra2 = (void *)&mmap_rnd_bits_max,
1641 },
1642#endif
1643#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1644 {
1645 .procname = "mmap_rnd_compat_bits",
1646 .data = &mmap_rnd_compat_bits,
1647 .maxlen = sizeof(mmap_rnd_compat_bits),
1648 .mode = 0600,
1649 .proc_handler = proc_dointvec_minmax,
1650 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1651 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1652 },
1653#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001654 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655};
1656
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001657static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001658 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001659 .procname = "inode-nr",
1660 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001661 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001662 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001663 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664 },
1665 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001666 .procname = "inode-state",
1667 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001668 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001669 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001670 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001671 },
1672 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001673 .procname = "file-nr",
1674 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001675 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001676 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001677 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001678 },
1679 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001680 .procname = "file-max",
1681 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001682 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001684 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685 },
1686 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001687 .procname = "nr_open",
1688 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001689 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001690 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001691 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001692 .extra1 = &sysctl_nr_open_min,
1693 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001694 },
1695 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696 .procname = "dentry-state",
1697 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001698 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001699 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001700 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001701 },
1702 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001703 .procname = "overflowuid",
1704 .data = &fs_overflowuid,
1705 .maxlen = sizeof(int),
1706 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001707 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001708 .extra1 = &minolduid,
1709 .extra2 = &maxolduid,
1710 },
1711 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001712 .procname = "overflowgid",
1713 .data = &fs_overflowgid,
1714 .maxlen = sizeof(int),
1715 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001716 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001717 .extra1 = &minolduid,
1718 .extra2 = &maxolduid,
1719 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001720#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001721 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001722 .procname = "leases-enable",
1723 .data = &leases_enable,
1724 .maxlen = sizeof(int),
1725 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001726 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001727 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001728#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729#ifdef CONFIG_DNOTIFY
1730 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001731 .procname = "dir-notify-enable",
1732 .data = &dir_notify_enable,
1733 .maxlen = sizeof(int),
1734 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001735 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736 },
1737#endif
1738#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001739#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001740 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001741 .procname = "lease-break-time",
1742 .data = &lease_break_time,
1743 .maxlen = sizeof(int),
1744 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001745 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001746 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001747#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001748#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001749 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750 .procname = "aio-nr",
1751 .data = &aio_nr,
1752 .maxlen = sizeof(aio_nr),
1753 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001754 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001755 },
1756 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001757 .procname = "aio-max-nr",
1758 .data = &aio_max_nr,
1759 .maxlen = sizeof(aio_max_nr),
1760 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001761 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001762 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001763#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001764#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001765 {
Robert Love0399cb02005-07-13 12:38:18 -04001766 .procname = "inotify",
1767 .mode = 0555,
1768 .child = inotify_table,
1769 },
1770#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001771#ifdef CONFIG_EPOLL
1772 {
1773 .procname = "epoll",
1774 .mode = 0555,
1775 .child = epoll_table,
1776 },
1777#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001778#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001779 {
Kees Cook800179c2012-07-25 17:29:07 -07001780 .procname = "protected_symlinks",
1781 .data = &sysctl_protected_symlinks,
1782 .maxlen = sizeof(int),
1783 .mode = 0600,
1784 .proc_handler = proc_dointvec_minmax,
1785 .extra1 = &zero,
1786 .extra2 = &one,
1787 },
1788 {
1789 .procname = "protected_hardlinks",
1790 .data = &sysctl_protected_hardlinks,
1791 .maxlen = sizeof(int),
1792 .mode = 0600,
1793 .proc_handler = proc_dointvec_minmax,
1794 .extra1 = &zero,
1795 .extra2 = &one,
1796 },
1797 {
Alan Coxd6e71142005-06-23 00:09:43 -07001798 .procname = "suid_dumpable",
1799 .data = &suid_dumpable,
1800 .maxlen = sizeof(int),
1801 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001802 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001803 .extra1 = &zero,
1804 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001805 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001806#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1807 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001808 .procname = "binfmt_misc",
1809 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001810 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001811 },
1812#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001813 {
Jens Axboeff9da692010-06-03 14:54:39 +02001814 .procname = "pipe-max-size",
1815 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001816 .maxlen = sizeof(int),
1817 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001818 .proc_handler = &pipe_proc_fn,
1819 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001820 },
Willy Tarreau759c0112016-01-18 16:36:09 +01001821 {
1822 .procname = "pipe-user-pages-hard",
1823 .data = &pipe_user_pages_hard,
1824 .maxlen = sizeof(pipe_user_pages_hard),
1825 .mode = 0644,
1826 .proc_handler = proc_doulongvec_minmax,
1827 },
1828 {
1829 .procname = "pipe-user-pages-soft",
1830 .data = &pipe_user_pages_soft,
1831 .maxlen = sizeof(pipe_user_pages_soft),
1832 .mode = 0644,
1833 .proc_handler = proc_doulongvec_minmax,
1834 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05001835 {
1836 .procname = "mount-max",
1837 .data = &sysctl_mount_max,
1838 .maxlen = sizeof(unsigned int),
1839 .mode = 0644,
1840 .proc_handler = proc_dointvec_minmax,
1841 .extra1 = &one,
1842 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001843 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001844};
1845
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001846static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001847#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001848 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001849 .procname = "exception-trace",
1850 .data = &show_unhandled_signals,
1851 .maxlen = sizeof(int),
1852 .mode = 0644,
1853 .proc_handler = proc_dointvec
1854 },
1855#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001856#if defined(CONFIG_OPTPROBES)
1857 {
1858 .procname = "kprobes-optimization",
1859 .data = &sysctl_kprobes_optimization,
1860 .maxlen = sizeof(int),
1861 .mode = 0644,
1862 .proc_handler = proc_kprobes_optimization_handler,
1863 .extra1 = &zero,
1864 .extra2 = &one,
1865 },
1866#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001867 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001868};
1869
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001870static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001871 { }
Robert Love0eeca282005-07-12 17:06:03 -04001872};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001873
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001874int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001875{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001876 struct ctl_table_header *hdr;
1877
1878 hdr = register_sysctl_table(sysctl_base_table);
1879 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001880 return 0;
1881}
1882
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001883#endif /* CONFIG_SYSCTL */
1884
Linus Torvalds1da177e2005-04-16 15:20:36 -07001885/*
1886 * /proc/sys support
1887 */
1888
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001889#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001890
Kees Cookf8808302014-06-06 14:37:17 -07001891static int _proc_do_string(char *data, int maxlen, int write,
1892 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001893 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001894{
1895 size_t len;
1896 char __user *p;
1897 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001898
1899 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001900 *lenp = 0;
1901 return 0;
1902 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001903
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001904 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001905 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1906 /* Only continue writes not past the end of buffer. */
1907 len = strlen(data);
1908 if (len > maxlen - 1)
1909 len = maxlen - 1;
1910
1911 if (*ppos > len)
1912 return 0;
1913 len = *ppos;
1914 } else {
1915 /* Start writing from beginning of buffer. */
1916 len = 0;
1917 }
1918
Kees Cook2ca9bb42014-06-06 14:37:18 -07001919 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001920 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001921 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001922 if (get_user(c, p++))
1923 return -EFAULT;
1924 if (c == 0 || c == '\n')
1925 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001926 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001927 }
Kees Cookf8808302014-06-06 14:37:17 -07001928 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001929 } else {
1930 len = strlen(data);
1931 if (len > maxlen)
1932 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001933
1934 if (*ppos > len) {
1935 *lenp = 0;
1936 return 0;
1937 }
1938
1939 data += *ppos;
1940 len -= *ppos;
1941
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001942 if (len > *lenp)
1943 len = *lenp;
1944 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001945 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001946 return -EFAULT;
1947 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001948 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001949 return -EFAULT;
1950 len++;
1951 }
1952 *lenp = len;
1953 *ppos += len;
1954 }
1955 return 0;
1956}
1957
Kees Cookf4aacea2014-06-06 14:37:19 -07001958static void warn_sysctl_write(struct ctl_table *table)
1959{
1960 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1961 "This will not be supported in the future. To silence this\n"
1962 "warning, set kernel.sysctl_writes_strict = -1\n",
1963 current->comm, table->procname);
1964}
1965
Linus Torvalds1da177e2005-04-16 15:20:36 -07001966/**
1967 * proc_dostring - read a string sysctl
1968 * @table: the sysctl table
1969 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001970 * @buffer: the user buffer
1971 * @lenp: the size of the user buffer
1972 * @ppos: file position
1973 *
1974 * Reads/writes a string from/to the user buffer. If the kernel
1975 * buffer provided is not large enough to hold the string, the
1976 * string is truncated. The copied string is %NULL-terminated.
1977 * If the string is being read by the user process, it is copied
1978 * and a newline '\n' is added. It is truncated if the buffer is
1979 * not large enough.
1980 *
1981 * Returns 0 on success.
1982 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001983int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001984 void __user *buffer, size_t *lenp, loff_t *ppos)
1985{
Kees Cookf4aacea2014-06-06 14:37:19 -07001986 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
1987 warn_sysctl_write(table);
1988
Kees Cookf8808302014-06-06 14:37:17 -07001989 return _proc_do_string((char *)(table->data), table->maxlen, write,
1990 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001991}
1992
Amerigo Wang00b7c332010-05-05 00:26:45 +00001993static size_t proc_skip_spaces(char **buf)
1994{
1995 size_t ret;
1996 char *tmp = skip_spaces(*buf);
1997 ret = tmp - *buf;
1998 *buf = tmp;
1999 return ret;
2000}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002001
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002002static void proc_skip_char(char **buf, size_t *size, const char v)
2003{
2004 while (*size) {
2005 if (**buf != v)
2006 break;
2007 (*size)--;
2008 (*buf)++;
2009 }
2010}
2011
Amerigo Wang00b7c332010-05-05 00:26:45 +00002012#define TMPBUFLEN 22
2013/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002014 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002015 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002016 * @buf: a kernel buffer
2017 * @size: size of the kernel buffer
2018 * @val: this is where the number will be stored
2019 * @neg: set to %TRUE if number is negative
2020 * @perm_tr: a vector which contains the allowed trailers
2021 * @perm_tr_len: size of the perm_tr vector
2022 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002023 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002024 * In case of success %0 is returned and @buf and @size are updated with
2025 * the amount of bytes read. If @tr is non-NULL and a trailing
2026 * character exists (size is non-zero after returning from this
2027 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002028 */
2029static int proc_get_long(char **buf, size_t *size,
2030 unsigned long *val, bool *neg,
2031 const char *perm_tr, unsigned perm_tr_len, char *tr)
2032{
2033 int len;
2034 char *p, tmp[TMPBUFLEN];
2035
2036 if (!*size)
2037 return -EINVAL;
2038
2039 len = *size;
2040 if (len > TMPBUFLEN - 1)
2041 len = TMPBUFLEN - 1;
2042
2043 memcpy(tmp, *buf, len);
2044
2045 tmp[len] = 0;
2046 p = tmp;
2047 if (*p == '-' && *size > 1) {
2048 *neg = true;
2049 p++;
2050 } else
2051 *neg = false;
2052 if (!isdigit(*p))
2053 return -EINVAL;
2054
2055 *val = simple_strtoul(p, &p, 0);
2056
2057 len = p - tmp;
2058
2059 /* We don't know if the next char is whitespace thus we may accept
2060 * invalid integers (e.g. 1234...a) or two integers instead of one
2061 * (e.g. 123...1). So lets not allow such large numbers. */
2062 if (len == TMPBUFLEN - 1)
2063 return -EINVAL;
2064
2065 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2066 return -EINVAL;
2067
2068 if (tr && (len < *size))
2069 *tr = *p;
2070
2071 *buf += len;
2072 *size -= len;
2073
2074 return 0;
2075}
2076
2077/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002078 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002079 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002080 * @buf: the user buffer
2081 * @size: the size of the user buffer
2082 * @val: the integer to be converted
2083 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002084 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002085 * In case of success %0 is returned and @buf and @size are updated with
2086 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002087 */
2088static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2089 bool neg)
2090{
2091 int len;
2092 char tmp[TMPBUFLEN], *p = tmp;
2093
2094 sprintf(p, "%s%lu", neg ? "-" : "", val);
2095 len = strlen(tmp);
2096 if (len > *size)
2097 len = *size;
2098 if (copy_to_user(*buf, tmp, len))
2099 return -EFAULT;
2100 *size -= len;
2101 *buf += len;
2102 return 0;
2103}
2104#undef TMPBUFLEN
2105
2106static int proc_put_char(void __user **buf, size_t *size, char c)
2107{
2108 if (*size) {
2109 char __user **buffer = (char __user **)buf;
2110 if (put_user(c, *buffer))
2111 return -EFAULT;
2112 (*size)--, (*buffer)++;
2113 *buf = *buffer;
2114 }
2115 return 0;
2116}
2117
2118static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002119 int *valp,
2120 int write, void *data)
2121{
2122 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002123 if (*negp) {
2124 if (*lvalp > (unsigned long) INT_MAX + 1)
2125 return -EINVAL;
2126 *valp = -*lvalp;
2127 } else {
2128 if (*lvalp > (unsigned long) INT_MAX)
2129 return -EINVAL;
2130 *valp = *lvalp;
2131 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002132 } else {
2133 int val = *valp;
2134 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002135 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002136 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002137 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002138 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002139 *lvalp = (unsigned long)val;
2140 }
2141 }
2142 return 0;
2143}
2144
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002145static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2146 int *valp,
2147 int write, void *data)
2148{
2149 if (write) {
2150 if (*negp)
2151 return -EINVAL;
Liping Zhang7bdacd32017-04-07 23:51:07 +08002152 if (*lvalp > UINT_MAX)
2153 return -EINVAL;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002154 *valp = *lvalp;
2155 } else {
2156 unsigned int val = *valp;
Liping Zhang3a20c572017-04-07 23:51:06 +08002157 *negp = false;
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002158 *lvalp = (unsigned long)val;
2159 }
2160 return 0;
2161}
2162
Amerigo Wang00b7c332010-05-05 00:26:45 +00002163static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2164
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002165static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002166 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002167 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002168 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002169 int write, void *data),
2170 void *data)
2171{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002172 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002173 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002174 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002175
Amerigo Wang00b7c332010-05-05 00:26:45 +00002176 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002177 *lenp = 0;
2178 return 0;
2179 }
2180
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002181 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002182 vleft = table->maxlen / sizeof(*i);
2183 left = *lenp;
2184
2185 if (!conv)
2186 conv = do_proc_dointvec_conv;
2187
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002189 if (*ppos) {
2190 switch (sysctl_writes_strict) {
2191 case SYSCTL_WRITES_STRICT:
2192 goto out;
2193 case SYSCTL_WRITES_WARN:
2194 warn_sysctl_write(table);
2195 break;
2196 default:
2197 break;
2198 }
2199 }
2200
Amerigo Wang00b7c332010-05-05 00:26:45 +00002201 if (left > PAGE_SIZE - 1)
2202 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002203 p = kbuf = memdup_user_nul(buffer, left);
2204 if (IS_ERR(kbuf))
2205 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002206 }
2207
2208 for (; left && vleft--; i++, first=0) {
2209 unsigned long lval;
2210 bool neg;
2211
2212 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002213 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002214
J. R. Okajima563b0462010-05-25 16:10:14 -07002215 if (!left)
2216 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002217 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002218 proc_wspace_sep,
2219 sizeof(proc_wspace_sep), NULL);
2220 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002222 if (conv(&neg, &lval, i, 1, data)) {
2223 err = -EINVAL;
2224 break;
2225 }
2226 } else {
2227 if (conv(&neg, &lval, i, 0, data)) {
2228 err = -EINVAL;
2229 break;
2230 }
2231 if (!first)
2232 err = proc_put_char(&buffer, &left, '\t');
2233 if (err)
2234 break;
2235 err = proc_put_long(&buffer, &left, lval, neg);
2236 if (err)
2237 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002238 }
2239 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002240
2241 if (!write && !first && left && !err)
2242 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002243 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002244 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002245 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002246 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002247 if (first)
2248 return err ? : -EINVAL;
2249 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002250 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002251out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002252 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002253 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002254}
2255
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002256static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002257 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002258 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002259 int write, void *data),
2260 void *data)
2261{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002262 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002263 buffer, lenp, ppos, conv, data);
2264}
2265
Linus Torvalds1da177e2005-04-16 15:20:36 -07002266/**
2267 * proc_dointvec - read a vector of integers
2268 * @table: the sysctl table
2269 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270 * @buffer: the user buffer
2271 * @lenp: the size of the user buffer
2272 * @ppos: file position
2273 *
2274 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2275 * values from/to the user buffer, treated as an ASCII string.
2276 *
2277 * Returns 0 on success.
2278 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002279int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002280 void __user *buffer, size_t *lenp, loff_t *ppos)
2281{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002282 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2283}
2284
2285/**
2286 * proc_douintvec - read a vector of unsigned integers
2287 * @table: the sysctl table
2288 * @write: %TRUE if this is a write to the sysctl file
2289 * @buffer: the user buffer
2290 * @lenp: the size of the user buffer
2291 * @ppos: file position
2292 *
2293 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2294 * values from/to the user buffer, treated as an ASCII string.
2295 *
2296 * Returns 0 on success.
2297 */
2298int proc_douintvec(struct ctl_table *table, int write,
2299 void __user *buffer, size_t *lenp, loff_t *ppos)
2300{
2301 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2302 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002303}
2304
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002305/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002306 * Taint values can only be increased
2307 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002308 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002309static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002310 void __user *buffer, size_t *lenp, loff_t *ppos)
2311{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002312 struct ctl_table t;
2313 unsigned long tmptaint = get_taint();
2314 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002315
Bastian Blank91fcd412007-04-23 14:41:14 -07002316 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002317 return -EPERM;
2318
Andi Kleen25ddbb12008-10-15 22:01:41 -07002319 t = *table;
2320 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002321 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002322 if (err < 0)
2323 return err;
2324
2325 if (write) {
2326 /*
2327 * Poor man's atomic or. Not worth adding a primitive
2328 * to everyone's atomic.h for this
2329 */
2330 int i;
2331 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2332 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302333 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002334 }
2335 }
2336
2337 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002338}
2339
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002340#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002341static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002342 void __user *buffer, size_t *lenp, loff_t *ppos)
2343{
2344 if (write && !capable(CAP_SYS_ADMIN))
2345 return -EPERM;
2346
2347 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2348}
2349#endif
2350
Linus Torvalds1da177e2005-04-16 15:20:36 -07002351struct do_proc_dointvec_minmax_conv_param {
2352 int *min;
2353 int *max;
2354};
2355
Amerigo Wang00b7c332010-05-05 00:26:45 +00002356static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2357 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002358 int write, void *data)
2359{
2360 struct do_proc_dointvec_minmax_conv_param *param = data;
2361 if (write) {
2362 int val = *negp ? -*lvalp : *lvalp;
2363 if ((param->min && *param->min > val) ||
2364 (param->max && *param->max < val))
2365 return -EINVAL;
2366 *valp = val;
2367 } else {
2368 int val = *valp;
2369 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002370 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002371 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002372 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002373 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002374 *lvalp = (unsigned long)val;
2375 }
2376 }
2377 return 0;
2378}
2379
2380/**
2381 * proc_dointvec_minmax - read a vector of integers with min/max values
2382 * @table: the sysctl table
2383 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384 * @buffer: the user buffer
2385 * @lenp: the size of the user buffer
2386 * @ppos: file position
2387 *
2388 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2389 * values from/to the user buffer, treated as an ASCII string.
2390 *
2391 * This routine will ensure the values are within the range specified by
2392 * table->extra1 (min) and table->extra2 (max).
2393 *
2394 * Returns 0 on success.
2395 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002396int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002397 void __user *buffer, size_t *lenp, loff_t *ppos)
2398{
2399 struct do_proc_dointvec_minmax_conv_param param = {
2400 .min = (int *) table->extra1,
2401 .max = (int *) table->extra2,
2402 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002403 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002404 do_proc_dointvec_minmax_conv, &param);
2405}
2406
Kees Cook54b50192012-07-30 14:39:18 -07002407static void validate_coredump_safety(void)
2408{
Alex Kelly046d6622012-10-04 17:15:23 -07002409#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002410 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002411 core_pattern[0] != '/' && core_pattern[0] != '|') {
2412 printk(KERN_WARNING "Unsafe core_pattern used with "\
2413 "suid_dumpable=2. Pipe handler or fully qualified "\
2414 "core dump path required.\n");
2415 }
Alex Kelly046d6622012-10-04 17:15:23 -07002416#endif
Kees Cook54b50192012-07-30 14:39:18 -07002417}
2418
2419static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2420 void __user *buffer, size_t *lenp, loff_t *ppos)
2421{
2422 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2423 if (!error)
2424 validate_coredump_safety();
2425 return error;
2426}
2427
Alex Kelly046d6622012-10-04 17:15:23 -07002428#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002429static int proc_dostring_coredump(struct ctl_table *table, int write,
2430 void __user *buffer, size_t *lenp, loff_t *ppos)
2431{
2432 int error = proc_dostring(table, write, buffer, lenp, ppos);
2433 if (!error)
2434 validate_coredump_safety();
2435 return error;
2436}
Alex Kelly046d6622012-10-04 17:15:23 -07002437#endif
Kees Cook54b50192012-07-30 14:39:18 -07002438
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002439static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002440 void __user *buffer,
2441 size_t *lenp, loff_t *ppos,
2442 unsigned long convmul,
2443 unsigned long convdiv)
2444{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002445 unsigned long *i, *min, *max;
2446 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002447 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002448 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002449
2450 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002451 *lenp = 0;
2452 return 0;
2453 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002454
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002455 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002456 min = (unsigned long *) table->extra1;
2457 max = (unsigned long *) table->extra2;
2458 vleft = table->maxlen / sizeof(unsigned long);
2459 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002460
2461 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002462 if (*ppos) {
2463 switch (sysctl_writes_strict) {
2464 case SYSCTL_WRITES_STRICT:
2465 goto out;
2466 case SYSCTL_WRITES_WARN:
2467 warn_sysctl_write(table);
2468 break;
2469 default:
2470 break;
2471 }
2472 }
2473
Amerigo Wang00b7c332010-05-05 00:26:45 +00002474 if (left > PAGE_SIZE - 1)
2475 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002476 p = kbuf = memdup_user_nul(buffer, left);
2477 if (IS_ERR(kbuf))
2478 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002479 }
2480
Eric Dumazet27b3d802010-10-07 12:59:29 -07002481 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002482 unsigned long val;
2483
Linus Torvalds1da177e2005-04-16 15:20:36 -07002484 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002485 bool neg;
2486
Al Viro70f6cbb2015-12-24 00:13:10 -05002487 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002488
Al Viro70f6cbb2015-12-24 00:13:10 -05002489 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002490 proc_wspace_sep,
2491 sizeof(proc_wspace_sep), NULL);
2492 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002493 break;
2494 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002495 continue;
Eric Dumazet03707d62017-01-25 18:20:55 -08002496 val = convmul * val / convdiv;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002497 if ((min && val < *min) || (max && val > *max))
2498 continue;
2499 *i = val;
2500 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002501 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002502 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002503 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002504 if (err)
2505 break;
2506 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002507 err = proc_put_long(&buffer, &left, val, false);
2508 if (err)
2509 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002510 }
2511 }
2512
Amerigo Wang00b7c332010-05-05 00:26:45 +00002513 if (!write && !first && left && !err)
2514 err = proc_put_char(&buffer, &left, '\n');
2515 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002516 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002517 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002518 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002519 if (first)
2520 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002521 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002522 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002523out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002524 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002525 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002526}
2527
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002528static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002529 void __user *buffer,
2530 size_t *lenp, loff_t *ppos,
2531 unsigned long convmul,
2532 unsigned long convdiv)
2533{
2534 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002535 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002536}
2537
Linus Torvalds1da177e2005-04-16 15:20:36 -07002538/**
2539 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2540 * @table: the sysctl table
2541 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002542 * @buffer: the user buffer
2543 * @lenp: the size of the user buffer
2544 * @ppos: file position
2545 *
2546 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2547 * values from/to the user buffer, treated as an ASCII string.
2548 *
2549 * This routine will ensure the values are within the range specified by
2550 * table->extra1 (min) and table->extra2 (max).
2551 *
2552 * Returns 0 on success.
2553 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002554int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002555 void __user *buffer, size_t *lenp, loff_t *ppos)
2556{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002557 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002558}
2559
2560/**
2561 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2562 * @table: the sysctl table
2563 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002564 * @buffer: the user buffer
2565 * @lenp: the size of the user buffer
2566 * @ppos: file position
2567 *
2568 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2569 * values from/to the user buffer, treated as an ASCII string. The values
2570 * are treated as milliseconds, and converted to jiffies when they are stored.
2571 *
2572 * This routine will ensure the values are within the range specified by
2573 * table->extra1 (min) and table->extra2 (max).
2574 *
2575 * Returns 0 on success.
2576 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002577int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002578 void __user *buffer,
2579 size_t *lenp, loff_t *ppos)
2580{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002581 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002582 lenp, ppos, HZ, 1000l);
2583}
2584
2585
Amerigo Wang00b7c332010-05-05 00:26:45 +00002586static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002587 int *valp,
2588 int write, void *data)
2589{
2590 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002591 if (*lvalp > LONG_MAX / HZ)
2592 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2594 } else {
2595 int val = *valp;
2596 unsigned long lval;
2597 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002598 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002599 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002600 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002601 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002602 lval = (unsigned long)val;
2603 }
2604 *lvalp = lval / HZ;
2605 }
2606 return 0;
2607}
2608
Amerigo Wang00b7c332010-05-05 00:26:45 +00002609static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002610 int *valp,
2611 int write, void *data)
2612{
2613 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002614 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2615 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002616 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2617 } else {
2618 int val = *valp;
2619 unsigned long lval;
2620 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002621 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002622 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002623 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002624 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002625 lval = (unsigned long)val;
2626 }
2627 *lvalp = jiffies_to_clock_t(lval);
2628 }
2629 return 0;
2630}
2631
Amerigo Wang00b7c332010-05-05 00:26:45 +00002632static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002633 int *valp,
2634 int write, void *data)
2635{
2636 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002637 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2638
2639 if (jif > INT_MAX)
2640 return 1;
2641 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002642 } else {
2643 int val = *valp;
2644 unsigned long lval;
2645 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002646 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002647 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002648 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002649 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002650 lval = (unsigned long)val;
2651 }
2652 *lvalp = jiffies_to_msecs(lval);
2653 }
2654 return 0;
2655}
2656
2657/**
2658 * proc_dointvec_jiffies - read a vector of integers as seconds
2659 * @table: the sysctl table
2660 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002661 * @buffer: the user buffer
2662 * @lenp: the size of the user buffer
2663 * @ppos: file position
2664 *
2665 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2666 * values from/to the user buffer, treated as an ASCII string.
2667 * The values read are assumed to be in seconds, and are converted into
2668 * jiffies.
2669 *
2670 * Returns 0 on success.
2671 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002672int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002673 void __user *buffer, size_t *lenp, loff_t *ppos)
2674{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002675 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002676 do_proc_dointvec_jiffies_conv,NULL);
2677}
2678
2679/**
2680 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2681 * @table: the sysctl table
2682 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002683 * @buffer: the user buffer
2684 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002685 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002686 *
2687 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2688 * values from/to the user buffer, treated as an ASCII string.
2689 * The values read are assumed to be in 1/USER_HZ seconds, and
2690 * are converted into jiffies.
2691 *
2692 * Returns 0 on success.
2693 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002694int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002695 void __user *buffer, size_t *lenp, loff_t *ppos)
2696{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002697 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002698 do_proc_dointvec_userhz_jiffies_conv,NULL);
2699}
2700
2701/**
2702 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2703 * @table: the sysctl table
2704 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002705 * @buffer: the user buffer
2706 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002707 * @ppos: file position
2708 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002709 *
2710 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2711 * values from/to the user buffer, treated as an ASCII string.
2712 * The values read are assumed to be in 1/1000 seconds, and
2713 * are converted into jiffies.
2714 *
2715 * Returns 0 on success.
2716 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002717int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002718 void __user *buffer, size_t *lenp, loff_t *ppos)
2719{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002720 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002721 do_proc_dointvec_ms_jiffies_conv, NULL);
2722}
2723
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002724static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002725 void __user *buffer, size_t *lenp, loff_t *ppos)
2726{
2727 struct pid *new_pid;
2728 pid_t tmp;
2729 int r;
2730
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002731 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002732
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002733 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002734 lenp, ppos, NULL, NULL);
2735 if (r || !write)
2736 return r;
2737
2738 new_pid = find_get_pid(tmp);
2739 if (!new_pid)
2740 return -ESRCH;
2741
2742 put_pid(xchg(&cad_pid, new_pid));
2743 return 0;
2744}
2745
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002746/**
2747 * proc_do_large_bitmap - read/write from/to a large bitmap
2748 * @table: the sysctl table
2749 * @write: %TRUE if this is a write to the sysctl file
2750 * @buffer: the user buffer
2751 * @lenp: the size of the user buffer
2752 * @ppos: file position
2753 *
2754 * The bitmap is stored at table->data and the bitmap length (in bits)
2755 * in table->maxlen.
2756 *
2757 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2758 * large bitmaps may be represented in a compact manner. Writing into
2759 * the file will clear the bitmap then update it with the given input.
2760 *
2761 * Returns 0 on success.
2762 */
2763int proc_do_large_bitmap(struct ctl_table *table, int write,
2764 void __user *buffer, size_t *lenp, loff_t *ppos)
2765{
2766 int err = 0;
2767 bool first = 1;
2768 size_t left = *lenp;
2769 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002770 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002771 unsigned long *tmp_bitmap = NULL;
2772 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2773
WANG Cong122ff242014-05-12 16:04:53 -07002774 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002775 *lenp = 0;
2776 return 0;
2777 }
2778
2779 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002780 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002781
2782 if (left > PAGE_SIZE - 1)
2783 left = PAGE_SIZE - 1;
2784
Al Viro70f6cbb2015-12-24 00:13:10 -05002785 p = kbuf = memdup_user_nul(buffer, left);
2786 if (IS_ERR(kbuf))
2787 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002788
2789 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2790 GFP_KERNEL);
2791 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002792 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002793 return -ENOMEM;
2794 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002795 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002796 while (!err && left) {
2797 unsigned long val_a, val_b;
2798 bool neg;
2799
Al Viro70f6cbb2015-12-24 00:13:10 -05002800 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002801 sizeof(tr_a), &c);
2802 if (err)
2803 break;
2804 if (val_a >= bitmap_len || neg) {
2805 err = -EINVAL;
2806 break;
2807 }
2808
2809 val_b = val_a;
2810 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002811 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002812 left--;
2813 }
2814
2815 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05002816 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002817 &neg, tr_b, sizeof(tr_b),
2818 &c);
2819 if (err)
2820 break;
2821 if (val_b >= bitmap_len || neg ||
2822 val_a > val_b) {
2823 err = -EINVAL;
2824 break;
2825 }
2826 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002827 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002828 left--;
2829 }
2830 }
2831
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002832 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002833 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05002834 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002835 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002836 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002837 } else {
2838 unsigned long bit_a, bit_b = 0;
2839
2840 while (left) {
2841 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2842 if (bit_a >= bitmap_len)
2843 break;
2844 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2845 bit_a + 1) - 1;
2846
2847 if (!first) {
2848 err = proc_put_char(&buffer, &left, ',');
2849 if (err)
2850 break;
2851 }
2852 err = proc_put_long(&buffer, &left, bit_a, false);
2853 if (err)
2854 break;
2855 if (bit_a != bit_b) {
2856 err = proc_put_char(&buffer, &left, '-');
2857 if (err)
2858 break;
2859 err = proc_put_long(&buffer, &left, bit_b, false);
2860 if (err)
2861 break;
2862 }
2863
2864 first = 0; bit_b++;
2865 }
2866 if (!err)
2867 err = proc_put_char(&buffer, &left, '\n');
2868 }
2869
2870 if (!err) {
2871 if (write) {
2872 if (*ppos)
2873 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2874 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002875 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002876 }
2877 kfree(tmp_bitmap);
2878 *lenp -= left;
2879 *ppos += *lenp;
2880 return 0;
2881 } else {
2882 kfree(tmp_bitmap);
2883 return err;
2884 }
2885}
2886
Jovi Zhang55610502011-01-12 17:00:45 -08002887#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002888
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002889int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002890 void __user *buffer, size_t *lenp, loff_t *ppos)
2891{
2892 return -ENOSYS;
2893}
2894
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002895int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002896 void __user *buffer, size_t *lenp, loff_t *ppos)
2897{
2898 return -ENOSYS;
2899}
2900
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002901int proc_douintvec(struct ctl_table *table, int write,
2902 void __user *buffer, size_t *lenp, loff_t *ppos)
2903{
2904 return -ENOSYS;
2905}
2906
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002907int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002908 void __user *buffer, size_t *lenp, loff_t *ppos)
2909{
2910 return -ENOSYS;
2911}
2912
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002913int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002914 void __user *buffer, size_t *lenp, loff_t *ppos)
2915{
2916 return -ENOSYS;
2917}
2918
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002919int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002920 void __user *buffer, size_t *lenp, loff_t *ppos)
2921{
2922 return -ENOSYS;
2923}
2924
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002925int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002926 void __user *buffer, size_t *lenp, loff_t *ppos)
2927{
2928 return -ENOSYS;
2929}
2930
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002931int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002932 void __user *buffer, size_t *lenp, loff_t *ppos)
2933{
2934 return -ENOSYS;
2935}
2936
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002937int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002938 void __user *buffer,
2939 size_t *lenp, loff_t *ppos)
2940{
2941 return -ENOSYS;
2942}
2943
2944
Jovi Zhang55610502011-01-12 17:00:45 -08002945#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002946
Linus Torvalds1da177e2005-04-16 15:20:36 -07002947/*
2948 * No sense putting this after each symbol definition, twice,
2949 * exception granted :-)
2950 */
2951EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002952EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002953EXPORT_SYMBOL(proc_dointvec_jiffies);
2954EXPORT_SYMBOL(proc_dointvec_minmax);
2955EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2956EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2957EXPORT_SYMBOL(proc_dostring);
2958EXPORT_SYMBOL(proc_doulongvec_minmax);
2959EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);