blob: a025ba15a09a45f1eb8bdd0cf32cce304741527f [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 {
Juri Lelli1931b932016-07-29 14:04:11 +0100311 .procname = "sched_is_big_little",
312 .data = &sysctl_sched_is_big_little,
313 .maxlen = sizeof(unsigned int),
314 .mode = 0644,
315 .proc_handler = proc_dointvec,
316 },
317 {
318 .procname = "sched_sync_hint_enable",
319 .data = &sysctl_sched_sync_hint_enable,
320 .maxlen = sizeof(unsigned int),
321 .mode = 0644,
322 .proc_handler = proc_dointvec,
323 },
324 {
Srinath Sridharanbf47bdd2016-07-14 09:57:29 +0100325 .procname = "sched_cstate_aware",
326 .data = &sysctl_sched_cstate_aware,
327 .maxlen = sizeof(unsigned int),
328 .mode = 0644,
329 .proc_handler = proc_dointvec,
330 },
331 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200332 .procname = "sched_wakeup_granularity_ns",
333 .data = &sysctl_sched_wakeup_granularity,
334 .maxlen = sizeof(unsigned int),
335 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800336 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200337 .extra1 = &min_wakeup_granularity_ns,
338 .extra2 = &max_wakeup_granularity_ns,
339 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200340#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200341 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100342 .procname = "sched_tunable_scaling",
343 .data = &sysctl_sched_tunable_scaling,
344 .maxlen = sizeof(enum sched_tunable_scaling),
345 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800346 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100347 .extra1 = &min_sched_tunable_scaling,
348 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200349 },
350 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900351 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200352 .data = &sysctl_sched_migration_cost,
353 .maxlen = sizeof(unsigned int),
354 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800355 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200356 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100357 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100358 .procname = "sched_nr_migrate",
359 .data = &sysctl_sched_nr_migrate,
360 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100361 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800362 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100363 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530364 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900365 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200366 .data = &sysctl_sched_time_avg,
367 .maxlen = sizeof(unsigned int),
368 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800369 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200370 },
371 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900372 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800373 .data = &sysctl_sched_shares_window,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
376 .proc_handler = proc_dointvec,
377 },
Mel Gormancb251762016-02-05 09:08:36 +0000378#ifdef CONFIG_SCHEDSTATS
379 {
380 .procname = "sched_schedstats",
381 .data = NULL,
382 .maxlen = sizeof(unsigned int),
383 .mode = 0644,
384 .proc_handler = sysctl_schedstats,
385 .extra1 = &zero,
386 .extra2 = &one,
387 },
388#endif /* CONFIG_SCHEDSTATS */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200389#endif /* CONFIG_SMP */
390#ifdef CONFIG_NUMA_BALANCING
391 {
Peter Zijlstra4b96a29b2012-10-25 14:16:47 +0200392 .procname = "numa_balancing_scan_delay_ms",
393 .data = &sysctl_numa_balancing_scan_delay,
394 .maxlen = sizeof(unsigned int),
395 .mode = 0644,
396 .proc_handler = proc_dointvec,
397 },
398 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200399 .procname = "numa_balancing_scan_period_min_ms",
400 .data = &sysctl_numa_balancing_scan_period_min,
401 .maxlen = sizeof(unsigned int),
402 .mode = 0644,
403 .proc_handler = proc_dointvec,
404 },
405 {
406 .procname = "numa_balancing_scan_period_max_ms",
407 .data = &sysctl_numa_balancing_scan_period_max,
408 .maxlen = sizeof(unsigned int),
409 .mode = 0644,
410 .proc_handler = proc_dointvec,
411 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200412 {
413 .procname = "numa_balancing_scan_size_mb",
414 .data = &sysctl_numa_balancing_scan_size,
415 .maxlen = sizeof(unsigned int),
416 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400417 .proc_handler = proc_dointvec_minmax,
418 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200419 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100420 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800421 .procname = "numa_balancing",
422 .data = NULL, /* filled in by handler */
423 .maxlen = sizeof(unsigned int),
424 .mode = 0644,
425 .proc_handler = sysctl_numa_balancing,
426 .extra1 = &zero,
427 .extra2 = &one,
428 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200429#endif /* CONFIG_NUMA_BALANCING */
430#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200431 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100432 .procname = "sched_rt_period_us",
433 .data = &sysctl_sched_rt_period,
434 .maxlen = sizeof(unsigned int),
435 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800436 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100437 },
438 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100439 .procname = "sched_rt_runtime_us",
440 .data = &sysctl_sched_rt_runtime,
441 .maxlen = sizeof(int),
442 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800443 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100444 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600445 {
446 .procname = "sched_rr_timeslice_ms",
447 .data = &sched_rr_timeslice,
448 .maxlen = sizeof(int),
449 .mode = 0644,
450 .proc_handler = sched_rr_handler,
451 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100452#ifdef CONFIG_SCHED_AUTOGROUP
453 {
454 .procname = "sched_autogroup_enabled",
455 .data = &sysctl_sched_autogroup_enabled,
456 .maxlen = sizeof(unsigned int),
457 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800458 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100459 .extra1 = &zero,
460 .extra2 = &one,
461 },
462#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700463#ifdef CONFIG_CFS_BANDWIDTH
464 {
465 .procname = "sched_cfs_bandwidth_slice_us",
466 .data = &sysctl_sched_cfs_bandwidth_slice,
467 .maxlen = sizeof(unsigned int),
468 .mode = 0644,
469 .proc_handler = proc_dointvec_minmax,
470 .extra1 = &one,
471 },
472#endif
Patrick Bellasi69fa4c72015-06-22 18:11:44 +0100473#ifdef CONFIG_SCHED_TUNE
474 {
475 .procname = "sched_cfs_boost",
476 .data = &sysctl_sched_cfs_boost,
477 .maxlen = sizeof(sysctl_sched_cfs_boost),
Patrick Bellasiae710302015-06-23 09:17:54 +0100478#ifdef CONFIG_CGROUP_SCHEDTUNE
479 .mode = 0444,
480#else
Patrick Bellasi69fa4c72015-06-22 18:11:44 +0100481 .mode = 0644,
Patrick Bellasiae710302015-06-23 09:17:54 +0100482#endif
Patrick Bellasi69fa4c72015-06-22 18:11:44 +0100483 .proc_handler = &sysctl_sched_cfs_boost_handler,
484 .extra1 = &zero,
485 .extra2 = &one_hundred,
486 },
487#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700488#ifdef CONFIG_PROVE_LOCKING
489 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700490 .procname = "prove_locking",
491 .data = &prove_locking,
492 .maxlen = sizeof(int),
493 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800494 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700495 },
496#endif
497#ifdef CONFIG_LOCK_STAT
498 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700499 .procname = "lock_stat",
500 .data = &lock_stat,
501 .maxlen = sizeof(int),
502 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800503 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700504 },
505#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200506 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 .procname = "panic",
508 .data = &panic_timeout,
509 .maxlen = sizeof(int),
510 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800511 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 },
Alex Kelly046d6622012-10-04 17:15:23 -0700513#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 .procname = "core_uses_pid",
516 .data = &core_uses_pid,
517 .maxlen = sizeof(int),
518 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800519 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 },
521 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 .procname = "core_pattern",
523 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700524 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700526 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 },
Neil Hormana2939802009-09-23 15:56:56 -0700528 {
Neil Hormana2939802009-09-23 15:56:56 -0700529 .procname = "core_pipe_limit",
530 .data = &core_pipe_limit,
531 .maxlen = sizeof(unsigned int),
532 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800533 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700534 },
Alex Kelly046d6622012-10-04 17:15:23 -0700535#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800536#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700539 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800540 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800541 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700543 {
544 .procname = "sysctl_writes_strict",
545 .data = &sysctl_writes_strict,
546 .maxlen = sizeof(int),
547 .mode = 0644,
548 .proc_handler = proc_dointvec_minmax,
549 .extra1 = &neg_one,
550 .extra2 = &one,
551 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800552#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100553#ifdef CONFIG_LATENCYTOP
554 {
555 .procname = "latencytop",
556 .data = &latencytop_enabled,
557 .maxlen = sizeof(int),
558 .mode = 0644,
Mel Gormancb251762016-02-05 09:08:36 +0000559 .proc_handler = sysctl_latencytop,
Arjan van de Ven97455122008-01-25 21:08:34 +0100560 },
561#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562#ifdef CONFIG_BLK_DEV_INITRD
563 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 .procname = "real-root-dev",
565 .data = &real_root_dev,
566 .maxlen = sizeof(int),
567 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800568 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 },
570#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700571 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700572 .procname = "print-fatal-signals",
573 .data = &print_fatal_signals,
574 .maxlen = sizeof(int),
575 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800576 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700577 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700578#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 .procname = "reboot-cmd",
581 .data = reboot_command,
582 .maxlen = 256,
583 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800584 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 },
586 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 .procname = "stop-a",
588 .data = &stop_a_enabled,
589 .maxlen = sizeof (int),
590 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800591 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 },
593 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 .procname = "scons-poweroff",
595 .data = &scons_pwroff,
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 },
600#endif
David S. Miller08714202008-11-16 23:49:24 -0800601#ifdef CONFIG_SPARC64
602 {
David S. Miller08714202008-11-16 23:49:24 -0800603 .procname = "tsb-ratio",
604 .data = &sysctl_tsb_ratio,
605 .maxlen = sizeof (int),
606 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800607 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800608 },
609#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610#ifdef __hppa__
611 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 .procname = "soft-power",
613 .data = &pwrsw_enabled,
614 .maxlen = sizeof (int),
615 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800616 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530618#endif
619#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 .procname = "unaligned-trap",
622 .data = &unaligned_enabled,
623 .maxlen = sizeof (int),
624 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800625 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 },
627#endif
628 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 .procname = "ctrl-alt-del",
630 .data = &C_A_D,
631 .maxlen = sizeof(int),
632 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800633 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400635#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200636 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200637 .procname = "ftrace_enabled",
638 .data = &ftrace_enabled,
639 .maxlen = sizeof(int),
640 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800641 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200642 },
643#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500644#ifdef CONFIG_STACK_TRACER
645 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500646 .procname = "stack_tracer_enabled",
647 .data = &stack_tracer_enabled,
648 .maxlen = sizeof(int),
649 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800650 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500651 },
652#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400653#ifdef CONFIG_TRACING
654 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100655 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400656 .data = &ftrace_dump_on_oops,
657 .maxlen = sizeof(int),
658 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800659 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400660 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400661 {
662 .procname = "traceoff_on_warning",
663 .data = &__disable_trace_on_warning,
664 .maxlen = sizeof(__disable_trace_on_warning),
665 .mode = 0644,
666 .proc_handler = proc_dointvec,
667 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500668 {
669 .procname = "tracepoint_printk",
670 .data = &tracepoint_printk,
671 .maxlen = sizeof(tracepoint_printk),
672 .mode = 0644,
673 .proc_handler = proc_dointvec,
674 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400675#endif
Dave Young2965faa2015-09-09 15:38:55 -0700676#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800677 {
678 .procname = "kexec_load_disabled",
679 .data = &kexec_load_disabled,
680 .maxlen = sizeof(int),
681 .mode = 0644,
682 /* only handle a transition from default "0" to "1" */
683 .proc_handler = proc_dointvec_minmax,
684 .extra1 = &one,
685 .extra2 = &one,
686 },
687#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200688#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 .procname = "modprobe",
691 .data = &modprobe_path,
692 .maxlen = KMOD_PATH_LEN,
693 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800694 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 },
Kees Cook3d433212009-04-02 15:49:29 -0700696 {
Kees Cook3d433212009-04-02 15:49:29 -0700697 .procname = "modules_disabled",
698 .data = &modules_disabled,
699 .maxlen = sizeof(int),
700 .mode = 0644,
701 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800702 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700703 .extra1 = &one,
704 .extra2 = &one,
705 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700707#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100710 .data = &uevent_helper,
711 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800713 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 },
Michael Marineau86d56132014-04-10 14:09:31 -0700715#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716#ifdef CONFIG_CHR_DEV_SG
717 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 .procname = "sg-big-buff",
719 .data = &sg_big_buff,
720 .maxlen = sizeof (int),
721 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800722 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 },
724#endif
725#ifdef CONFIG_BSD_PROCESS_ACCT
726 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 .procname = "acct",
728 .data = &acct_parm,
729 .maxlen = 3*sizeof(int),
730 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800731 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 },
733#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734#ifdef CONFIG_MAGIC_SYSRQ
735 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800737 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 .maxlen = sizeof (int),
739 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700740 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 },
742#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700743#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700746 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 .maxlen = sizeof (int),
748 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800749 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700751#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700754 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 .maxlen = sizeof(int),
756 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700757 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 },
759 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 .procname = "random",
761 .mode = 0555,
762 .child = random_table,
763 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 {
Eric Paris17f60a72011-04-01 17:07:50 -0400765 .procname = "usermodehelper",
766 .mode = 0555,
767 .child = usermodehelper_table,
768 },
769 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 .procname = "overflowuid",
771 .data = &overflowuid,
772 .maxlen = sizeof(int),
773 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800774 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 .extra1 = &minolduid,
776 .extra2 = &maxolduid,
777 },
778 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 .procname = "overflowgid",
780 .data = &overflowgid,
781 .maxlen = sizeof(int),
782 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800783 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784 .extra1 = &minolduid,
785 .extra2 = &maxolduid,
786 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800787#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788#ifdef CONFIG_MATHEMU
789 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 .procname = "ieee_emulation_warnings",
791 .data = &sysctl_ieee_emulation_warnings,
792 .maxlen = sizeof(int),
793 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800794 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 },
796#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200799 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 .maxlen = sizeof(int),
801 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800802 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 },
804#endif
805 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 .procname = "pid_max",
807 .data = &pid_max,
808 .maxlen = sizeof (int),
809 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800810 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 .extra1 = &pid_max_min,
812 .extra2 = &pid_max_max,
813 },
814 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 .procname = "panic_on_oops",
816 .data = &panic_on_oops,
817 .maxlen = sizeof(int),
818 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800819 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800821#if defined CONFIG_PRINTK
822 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800823 .procname = "printk",
824 .data = &console_loglevel,
825 .maxlen = 4*sizeof(int),
826 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800827 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800828 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700831 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 .maxlen = sizeof(int),
833 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800834 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700835 },
836 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700838 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839 .maxlen = sizeof(int),
840 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800841 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 },
Dave Youngaf913222009-09-22 16:43:33 -0700843 {
Dave Youngaf913222009-09-22 16:43:33 -0700844 .procname = "printk_delay",
845 .data = &printk_delay_msec,
846 .maxlen = sizeof(int),
847 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800848 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700849 .extra1 = &zero,
850 .extra2 = &ten_thousand,
851 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 {
Borislav Petkov750afe72016-08-02 14:04:07 -0700853 .procname = "printk_devkmsg",
854 .data = devkmsg_log_str,
855 .maxlen = DEVKMSG_STR_MAX_SIZE,
856 .mode = 0644,
857 .proc_handler = devkmsg_sysctl_set_loglvl,
858 },
859 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800860 .procname = "dmesg_restrict",
861 .data = &dmesg_restrict,
862 .maxlen = sizeof(int),
863 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700864 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800865 .extra1 = &zero,
866 .extra2 = &one,
867 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800868 {
869 .procname = "kptr_restrict",
870 .data = &kptr_restrict,
871 .maxlen = sizeof(int),
872 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700873 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800874 .extra1 = &zero,
875 .extra2 = &two,
876 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800877#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800878 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879 .procname = "ngroups_max",
880 .data = &ngroups_max,
881 .maxlen = sizeof (int),
882 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800883 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 },
Dan Ballard73efc032011-10-31 17:11:20 -0700885 {
886 .procname = "cap_last_cap",
887 .data = (void *)&cap_last_cap,
888 .maxlen = sizeof(int),
889 .mode = 0444,
890 .proc_handler = proc_dointvec,
891 },
Don Zickus58687ac2010-05-07 17:11:44 -0400892#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500893 {
Don Zickus58687ac2010-05-07 17:11:44 -0400894 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200895 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500896 .maxlen = sizeof (int),
897 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700898 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700899 .extra1 = &zero,
900 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400901 },
902 {
903 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700904 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400905 .maxlen = sizeof(int),
906 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700907 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800908 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400909 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500910 },
Don Zickus2508ce12010-05-07 17:11:46 -0400911 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700912 .procname = "nmi_watchdog",
913 .data = &nmi_watchdog_enabled,
914 .maxlen = sizeof (int),
915 .mode = 0644,
916 .proc_handler = proc_nmi_watchdog,
917 .extra1 = &zero,
918#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
919 .extra2 = &one,
920#else
921 .extra2 = &zero,
922#endif
923 },
924 {
925 .procname = "soft_watchdog",
926 .data = &soft_watchdog_enabled,
927 .maxlen = sizeof (int),
928 .mode = 0644,
929 .proc_handler = proc_soft_watchdog,
930 .extra1 = &zero,
931 .extra2 = &one,
932 },
933 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700934 .procname = "watchdog_cpumask",
935 .data = &watchdog_cpumask_bits,
936 .maxlen = NR_CPUS,
937 .mode = 0644,
938 .proc_handler = proc_watchdog_cpumask,
939 },
940 {
Don Zickus2508ce12010-05-07 17:11:46 -0400941 .procname = "softlockup_panic",
942 .data = &softlockup_panic,
943 .maxlen = sizeof(int),
944 .mode = 0644,
945 .proc_handler = proc_dointvec_minmax,
946 .extra1 = &zero,
947 .extra2 = &one,
948 },
Don Zickusac1f5912015-11-05 18:44:44 -0800949#ifdef CONFIG_HARDLOCKUP_DETECTOR
950 {
951 .procname = "hardlockup_panic",
952 .data = &hardlockup_panic,
953 .maxlen = sizeof(int),
954 .mode = 0644,
955 .proc_handler = proc_dointvec_minmax,
956 .extra1 = &zero,
957 .extra2 = &one,
958 },
959#endif
Aaron Tomlined235872014-06-23 13:22:05 -0700960#ifdef CONFIG_SMP
961 {
962 .procname = "softlockup_all_cpu_backtrace",
963 .data = &sysctl_softlockup_all_cpu_backtrace,
964 .maxlen = sizeof(int),
965 .mode = 0644,
966 .proc_handler = proc_dointvec_minmax,
967 .extra1 = &zero,
968 .extra2 = &one,
969 },
Jiri Kosina55537872015-11-05 18:44:41 -0800970 {
971 .procname = "hardlockup_all_cpu_backtrace",
972 .data = &sysctl_hardlockup_all_cpu_backtrace,
973 .maxlen = sizeof(int),
974 .mode = 0644,
975 .proc_handler = proc_dointvec_minmax,
976 .extra1 = &zero,
977 .extra2 = &one,
978 },
Aaron Tomlined235872014-06-23 13:22:05 -0700979#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -0500980#endif
981#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
982 {
983 .procname = "unknown_nmi_panic",
984 .data = &unknown_nmi_panic,
985 .maxlen = sizeof (int),
986 .mode = 0644,
987 .proc_handler = proc_dointvec,
988 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500989#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990#if defined(CONFIG_X86)
991 {
Don Zickus8da5add2006-09-26 10:52:27 +0200992 .procname = "panic_on_unrecovered_nmi",
993 .data = &panic_on_unrecovered_nmi,
994 .maxlen = sizeof(int),
995 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800996 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200997 },
998 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700999 .procname = "panic_on_io_nmi",
1000 .data = &panic_on_io_nmi,
1001 .maxlen = sizeof(int),
1002 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001003 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -07001004 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +09001005#ifdef CONFIG_DEBUG_STACKOVERFLOW
1006 {
1007 .procname = "panic_on_stackoverflow",
1008 .data = &sysctl_panic_on_stackoverflow,
1009 .maxlen = sizeof(int),
1010 .mode = 0644,
1011 .proc_handler = proc_dointvec,
1012 },
1013#endif
Kurt Garloff5211a242009-06-24 14:32:11 -07001014 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 .procname = "bootloader_type",
1016 .data = &bootloader_type,
1017 .maxlen = sizeof (int),
1018 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001019 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001020 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001021 {
H. Peter Anvin50312962009-05-07 16:54:11 -07001022 .procname = "bootloader_version",
1023 .data = &bootloader_version,
1024 .maxlen = sizeof (int),
1025 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001026 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -07001027 },
1028 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001029 .procname = "kstack_depth_to_print",
1030 .data = &kstack_depth_to_print,
1031 .maxlen = sizeof(int),
1032 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001033 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +01001034 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001035 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001036 .procname = "io_delay_type",
1037 .data = &io_delay_type,
1038 .maxlen = sizeof(int),
1039 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001040 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +01001041 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001042#endif
Luke Yang7a9166e2006-02-20 18:28:07 -08001043#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001044 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001045 .procname = "randomize_va_space",
1046 .data = &randomize_va_space,
1047 .maxlen = sizeof(int),
1048 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001049 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001050 },
Luke Yang7a9166e2006-02-20 18:28:07 -08001051#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -08001052#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001053 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001054 .procname = "spin_retry",
1055 .data = &spin_retry,
1056 .maxlen = sizeof (int),
1057 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001058 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001059 },
1060#endif
Len Brown673d5b42007-07-28 03:33:16 -04001061#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001062 {
Pavel Machekc255d842006-02-20 18:27:58 -08001063 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001064 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001065 .maxlen = sizeof (unsigned long),
1066 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001067 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001068 },
1069#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301070#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001071 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001072 .procname = "ignore-unaligned-usertrap",
1073 .data = &no_unaligned_warning,
1074 .maxlen = sizeof (int),
1075 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001076 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001077 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301078#endif
1079#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001080 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001081 .procname = "unaligned-dump-stack",
1082 .data = &unaligned_dump_stack,
1083 .maxlen = sizeof (int),
1084 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001085 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001086 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001087#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001088#ifdef CONFIG_DETECT_HUNG_TASK
1089 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001090 .procname = "hung_task_panic",
1091 .data = &sysctl_hung_task_panic,
1092 .maxlen = sizeof(int),
1093 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001094 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001095 .extra1 = &zero,
1096 .extra2 = &one,
1097 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001098 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001099 .procname = "hung_task_check_count",
1100 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001101 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001102 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001103 .proc_handler = proc_dointvec_minmax,
1104 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001105 },
1106 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001107 .procname = "hung_task_timeout_secs",
1108 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001109 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001110 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001111 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001112 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001113 },
1114 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001115 .procname = "hung_task_warnings",
1116 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001117 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001118 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001119 .proc_handler = proc_dointvec_minmax,
1120 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001121 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001122#endif
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001123#ifdef CONFIG_RT_MUTEXES
1124 {
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001125 .procname = "max_lock_depth",
1126 .data = &max_lock_depth,
1127 .maxlen = sizeof(int),
1128 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001129 .proc_handler = proc_dointvec,
Ingo Molnar23f78d4a2006-06-27 02:54:53 -07001130 },
1131#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001132 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001133 .procname = "poweroff_cmd",
1134 .data = &poweroff_cmd,
1135 .maxlen = POWEROFF_CMD_PATH_LEN,
1136 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001137 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001138 },
David Howells0b77f5b2008-04-29 01:01:32 -07001139#ifdef CONFIG_KEYS
1140 {
David Howells0b77f5b2008-04-29 01:01:32 -07001141 .procname = "keys",
1142 .mode = 0555,
1143 .child = key_sysctls,
1144 },
1145#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001146#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001147 /*
1148 * User-space scripts rely on the existence of this file
1149 * as a feature check for perf_events being enabled.
1150 *
1151 * So it's an ABI, do not remove!
1152 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001153 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001154 .procname = "perf_event_paranoid",
1155 .data = &sysctl_perf_event_paranoid,
1156 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001157 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001158 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001159 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001160 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001161 .procname = "perf_event_mlock_kb",
1162 .data = &sysctl_perf_event_mlock,
1163 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001164 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001165 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001166 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001167 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001168 .procname = "perf_event_max_sample_rate",
1169 .data = &sysctl_perf_event_sample_rate,
1170 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001171 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001172 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001173 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001174 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001175 {
1176 .procname = "perf_cpu_time_max_percent",
1177 .data = &sysctl_perf_cpu_time_max_percent,
1178 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1179 .mode = 0644,
1180 .proc_handler = perf_cpu_time_max_percent_handler,
1181 .extra1 = &zero,
1182 .extra2 = &one_hundred,
1183 },
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001184 {
1185 .procname = "perf_event_max_stack",
Arnaldo Carvalho de Meloa8311002016-05-10 16:34:53 -03001186 .data = &sysctl_perf_event_max_stack,
Arnaldo Carvalho de Meloc5dfd782016-04-21 12:28:50 -03001187 .maxlen = sizeof(sysctl_perf_event_max_stack),
1188 .mode = 0644,
1189 .proc_handler = perf_event_max_stack_handler,
1190 .extra1 = &zero,
1191 .extra2 = &six_hundred_forty_kb,
1192 },
Arnaldo Carvalho de Meloc85b0332016-05-12 13:06:21 -03001193 {
1194 .procname = "perf_event_max_contexts_per_stack",
1195 .data = &sysctl_perf_event_max_contexts_per_stack,
1196 .maxlen = sizeof(sysctl_perf_event_max_contexts_per_stack),
1197 .mode = 0644,
1198 .proc_handler = perf_event_max_stack_handler,
1199 .extra1 = &zero,
1200 .extra2 = &one_thousand,
1201 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001202#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001203#ifdef CONFIG_KMEMCHECK
1204 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001205 .procname = "kmemcheck",
1206 .data = &kmemcheck_enabled,
1207 .maxlen = sizeof(int),
1208 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001209 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001210 },
1211#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001212 {
1213 .procname = "panic_on_warn",
1214 .data = &panic_on_warn,
1215 .maxlen = sizeof(int),
1216 .mode = 0644,
1217 .proc_handler = proc_dointvec_minmax,
1218 .extra1 = &zero,
1219 .extra2 = &one,
1220 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001221#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1222 {
1223 .procname = "timer_migration",
1224 .data = &sysctl_timer_migration,
1225 .maxlen = sizeof(unsigned int),
1226 .mode = 0644,
1227 .proc_handler = timer_migration_handler,
1228 },
1229#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001230#ifdef CONFIG_BPF_SYSCALL
1231 {
1232 .procname = "unprivileged_bpf_disabled",
1233 .data = &sysctl_unprivileged_bpf_disabled,
1234 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1235 .mode = 0644,
1236 /* only handle a transition from default "0" to "1" */
1237 .proc_handler = proc_dointvec_minmax,
1238 .extra1 = &one,
1239 .extra2 = &one,
1240 },
1241#endif
Daniel Bristot de Oliveira088e9d22016-06-02 13:51:41 -03001242#if defined(CONFIG_TREE_RCU) || defined(CONFIG_PREEMPT_RCU)
1243 {
1244 .procname = "panic_on_rcu_stall",
1245 .data = &sysctl_panic_on_rcu_stall,
1246 .maxlen = sizeof(sysctl_panic_on_rcu_stall),
1247 .mode = 0644,
1248 .proc_handler = proc_dointvec_minmax,
1249 .extra1 = &zero,
1250 .extra2 = &one,
1251 },
1252#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001253 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001254};
1255
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001256static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001258 .procname = "overcommit_memory",
1259 .data = &sysctl_overcommit_memory,
1260 .maxlen = sizeof(sysctl_overcommit_memory),
1261 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001262 .proc_handler = proc_dointvec_minmax,
1263 .extra1 = &zero,
1264 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001265 },
1266 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001267 .procname = "panic_on_oom",
1268 .data = &sysctl_panic_on_oom,
1269 .maxlen = sizeof(sysctl_panic_on_oom),
1270 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001271 .proc_handler = proc_dointvec_minmax,
1272 .extra1 = &zero,
1273 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001274 },
1275 {
David Rientjesfe071d72007-10-16 23:25:56 -07001276 .procname = "oom_kill_allocating_task",
1277 .data = &sysctl_oom_kill_allocating_task,
1278 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1279 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001280 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001281 },
1282 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001283 .procname = "oom_dump_tasks",
1284 .data = &sysctl_oom_dump_tasks,
1285 .maxlen = sizeof(sysctl_oom_dump_tasks),
1286 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001287 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001288 },
1289 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001290 .procname = "overcommit_ratio",
1291 .data = &sysctl_overcommit_ratio,
1292 .maxlen = sizeof(sysctl_overcommit_ratio),
1293 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001294 .proc_handler = overcommit_ratio_handler,
1295 },
1296 {
1297 .procname = "overcommit_kbytes",
1298 .data = &sysctl_overcommit_kbytes,
1299 .maxlen = sizeof(sysctl_overcommit_kbytes),
1300 .mode = 0644,
1301 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001302 },
1303 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001304 .procname = "page-cluster",
1305 .data = &page_cluster,
1306 .maxlen = sizeof(int),
1307 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001308 .proc_handler = proc_dointvec_minmax,
1309 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001310 },
1311 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312 .procname = "dirty_background_ratio",
1313 .data = &dirty_background_ratio,
1314 .maxlen = sizeof(dirty_background_ratio),
1315 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001316 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317 .extra1 = &zero,
1318 .extra2 = &one_hundred,
1319 },
1320 {
David Rientjes2da02992009-01-06 14:39:31 -08001321 .procname = "dirty_background_bytes",
1322 .data = &dirty_background_bytes,
1323 .maxlen = sizeof(dirty_background_bytes),
1324 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001325 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001326 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001327 },
1328 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001329 .procname = "dirty_ratio",
1330 .data = &vm_dirty_ratio,
1331 .maxlen = sizeof(vm_dirty_ratio),
1332 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001333 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001334 .extra1 = &zero,
1335 .extra2 = &one_hundred,
1336 },
1337 {
David Rientjes2da02992009-01-06 14:39:31 -08001338 .procname = "dirty_bytes",
1339 .data = &vm_dirty_bytes,
1340 .maxlen = sizeof(vm_dirty_bytes),
1341 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001342 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001343 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001344 },
1345 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001346 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001347 .data = &dirty_writeback_interval,
1348 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001349 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001350 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001351 },
1352 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001354 .data = &dirty_expire_interval,
1355 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001356 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001357 .proc_handler = proc_dointvec_minmax,
1358 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001359 },
1360 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001361 .procname = "dirtytime_expire_seconds",
1362 .data = &dirtytime_expire_interval,
1363 .maxlen = sizeof(dirty_expire_interval),
1364 .mode = 0644,
1365 .proc_handler = dirtytime_interval_handler,
1366 .extra1 = &zero,
1367 },
1368 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001369 .procname = "nr_pdflush_threads",
1370 .mode = 0444 /* read-only */,
1371 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372 },
1373 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001374 .procname = "swappiness",
1375 .data = &vm_swappiness,
1376 .maxlen = sizeof(vm_swappiness),
1377 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001378 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001379 .extra1 = &zero,
1380 .extra2 = &one_hundred,
1381 },
1382#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001383 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001385 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001386 .maxlen = sizeof(unsigned long),
1387 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001388 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001389 },
1390#ifdef CONFIG_NUMA
1391 {
1392 .procname = "nr_hugepages_mempolicy",
1393 .data = NULL,
1394 .maxlen = sizeof(unsigned long),
1395 .mode = 0644,
1396 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001397 },
1398#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001399 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001400 .procname = "hugetlb_shm_group",
1401 .data = &sysctl_hugetlb_shm_group,
1402 .maxlen = sizeof(gid_t),
1403 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001404 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001405 },
Mel Gorman396faf02007-07-17 04:03:13 -07001406 {
Mel Gorman396faf02007-07-17 04:03:13 -07001407 .procname = "hugepages_treat_as_movable",
1408 .data = &hugepages_treat_as_movable,
1409 .maxlen = sizeof(int),
1410 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001411 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001412 },
Adam Litke54f9f802007-10-16 01:26:20 -07001413 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001414 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001415 .data = NULL,
1416 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001417 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001418 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001419 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420#endif
1421 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001422 .procname = "lowmem_reserve_ratio",
1423 .data = &sysctl_lowmem_reserve_ratio,
1424 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1425 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001426 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001427 },
1428 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001429 .procname = "drop_caches",
1430 .data = &sysctl_drop_caches,
1431 .maxlen = sizeof(int),
1432 .mode = 0644,
1433 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001434 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001435 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001436 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001437#ifdef CONFIG_COMPACTION
1438 {
1439 .procname = "compact_memory",
1440 .data = &sysctl_compact_memory,
1441 .maxlen = sizeof(int),
1442 .mode = 0200,
1443 .proc_handler = sysctl_compaction_handler,
1444 },
Mel Gorman5e771902010-05-24 14:32:31 -07001445 {
1446 .procname = "extfrag_threshold",
1447 .data = &sysctl_extfrag_threshold,
1448 .maxlen = sizeof(int),
1449 .mode = 0644,
1450 .proc_handler = sysctl_extfrag_handler,
1451 .extra1 = &min_extfrag_threshold,
1452 .extra2 = &max_extfrag_threshold,
1453 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001454 {
1455 .procname = "compact_unevictable_allowed",
1456 .data = &sysctl_compact_unevictable_allowed,
1457 .maxlen = sizeof(int),
1458 .mode = 0644,
1459 .proc_handler = proc_dointvec,
1460 .extra1 = &zero,
1461 .extra2 = &one,
1462 },
Mel Gorman5e771902010-05-24 14:32:31 -07001463
Mel Gorman76ab0f52010-05-24 14:32:28 -07001464#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001465 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001466 .procname = "min_free_kbytes",
1467 .data = &min_free_kbytes,
1468 .maxlen = sizeof(min_free_kbytes),
1469 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001470 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001471 .extra1 = &zero,
1472 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001473 {
Johannes Weiner795ae7a2016-03-17 14:19:14 -07001474 .procname = "watermark_scale_factor",
1475 .data = &watermark_scale_factor,
1476 .maxlen = sizeof(watermark_scale_factor),
1477 .mode = 0644,
1478 .proc_handler = watermark_scale_factor_sysctl_handler,
1479 .extra1 = &one,
1480 .extra2 = &one_thousand,
1481 },
1482 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001483 .procname = "percpu_pagelist_fraction",
1484 .data = &percpu_pagelist_fraction,
1485 .maxlen = sizeof(percpu_pagelist_fraction),
1486 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001487 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001488 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001489 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490#ifdef CONFIG_MMU
1491 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001492 .procname = "max_map_count",
1493 .data = &sysctl_max_map_count,
1494 .maxlen = sizeof(sysctl_max_map_count),
1495 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001496 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001497 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001498 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001499#else
1500 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001501 .procname = "nr_trim_pages",
1502 .data = &sysctl_nr_trim_pages,
1503 .maxlen = sizeof(sysctl_nr_trim_pages),
1504 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001505 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001506 .extra1 = &zero,
1507 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001508#endif
1509 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001510 .procname = "laptop_mode",
1511 .data = &laptop_mode,
1512 .maxlen = sizeof(laptop_mode),
1513 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001514 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001515 },
1516 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001517 .procname = "block_dump",
1518 .data = &block_dump,
1519 .maxlen = sizeof(block_dump),
1520 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001521 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001522 .extra1 = &zero,
1523 },
1524 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001525 .procname = "vfs_cache_pressure",
1526 .data = &sysctl_vfs_cache_pressure,
1527 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1528 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001529 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001530 .extra1 = &zero,
1531 },
1532#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1533 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001534 .procname = "legacy_va_layout",
1535 .data = &sysctl_legacy_va_layout,
1536 .maxlen = sizeof(sysctl_legacy_va_layout),
1537 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001538 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001539 .extra1 = &zero,
1540 },
1541#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001542#ifdef CONFIG_NUMA
1543 {
Christoph Lameter17436602006-01-18 17:42:32 -08001544 .procname = "zone_reclaim_mode",
Mel Gormana5f5f912016-07-28 15:46:32 -07001545 .data = &node_reclaim_mode,
1546 .maxlen = sizeof(node_reclaim_mode),
Christoph Lameter17436602006-01-18 17:42:32 -08001547 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001548 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001549 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001550 },
Christoph Lameter96146342006-07-03 00:24:13 -07001551 {
Christoph Lameter96146342006-07-03 00:24:13 -07001552 .procname = "min_unmapped_ratio",
1553 .data = &sysctl_min_unmapped_ratio,
1554 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1555 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001556 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001557 .extra1 = &zero,
1558 .extra2 = &one_hundred,
1559 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001560 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001561 .procname = "min_slab_ratio",
1562 .data = &sysctl_min_slab_ratio,
1563 .maxlen = sizeof(sysctl_min_slab_ratio),
1564 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001565 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001566 .extra1 = &zero,
1567 .extra2 = &one_hundred,
1568 },
Christoph Lameter17436602006-01-18 17:42:32 -08001569#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001570#ifdef CONFIG_SMP
1571 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001572 .procname = "stat_interval",
1573 .data = &sysctl_stat_interval,
1574 .maxlen = sizeof(sysctl_stat_interval),
1575 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001576 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001577 },
Hugh Dickins52b6f462016-05-19 17:12:50 -07001578 {
1579 .procname = "stat_refresh",
1580 .data = NULL,
1581 .maxlen = 0,
1582 .mode = 0600,
1583 .proc_handler = vmstat_refresh,
1584 },
Christoph Lameter77461ab2007-05-09 02:35:13 -07001585#endif
David Howells6e141542009-12-15 19:27:45 +00001586#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001587 {
Eric Parised032182007-06-28 15:55:21 -04001588 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001589 .data = &dac_mmap_min_addr,
1590 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001591 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001592 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001593 },
David Howells6e141542009-12-15 19:27:45 +00001594#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001595#ifdef CONFIG_NUMA
1596 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001597 .procname = "numa_zonelist_order",
1598 .data = &numa_zonelist_order,
1599 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1600 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001601 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001602 },
1603#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001604#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001605 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001606 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001607 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001608#ifdef CONFIG_X86_32
1609 .data = &vdso32_enabled,
1610 .maxlen = sizeof(vdso32_enabled),
1611#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001612 .data = &vdso_enabled,
1613 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001614#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001615 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001616 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001617 .extra1 = &zero,
1618 },
1619#endif
Bron Gondwana195cf4532008-02-04 22:29:20 -08001620#ifdef CONFIG_HIGHMEM
1621 {
Bron Gondwana195cf4532008-02-04 22:29:20 -08001622 .procname = "highmem_is_dirtyable",
1623 .data = &vm_highmem_is_dirtyable,
1624 .maxlen = sizeof(vm_highmem_is_dirtyable),
1625 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001626 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf4532008-02-04 22:29:20 -08001627 .extra1 = &zero,
1628 .extra2 = &one,
1629 },
1630#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001631#ifdef CONFIG_MEMORY_FAILURE
1632 {
Andi Kleen6a460792009-09-16 11:50:15 +02001633 .procname = "memory_failure_early_kill",
1634 .data = &sysctl_memory_failure_early_kill,
1635 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1636 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001637 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001638 .extra1 = &zero,
1639 .extra2 = &one,
1640 },
1641 {
Andi Kleen6a460792009-09-16 11:50:15 +02001642 .procname = "memory_failure_recovery",
1643 .data = &sysctl_memory_failure_recovery,
1644 .maxlen = sizeof(sysctl_memory_failure_recovery),
1645 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001646 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001647 .extra1 = &zero,
1648 .extra2 = &one,
1649 },
1650#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001651 {
1652 .procname = "user_reserve_kbytes",
1653 .data = &sysctl_user_reserve_kbytes,
1654 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1655 .mode = 0644,
1656 .proc_handler = proc_doulongvec_minmax,
1657 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001658 {
1659 .procname = "admin_reserve_kbytes",
1660 .data = &sysctl_admin_reserve_kbytes,
1661 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1662 .mode = 0644,
1663 .proc_handler = proc_doulongvec_minmax,
1664 },
Daniel Cashmand07e2252016-01-14 15:19:53 -08001665#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1666 {
1667 .procname = "mmap_rnd_bits",
1668 .data = &mmap_rnd_bits,
1669 .maxlen = sizeof(mmap_rnd_bits),
1670 .mode = 0600,
1671 .proc_handler = proc_dointvec_minmax,
1672 .extra1 = (void *)&mmap_rnd_bits_min,
1673 .extra2 = (void *)&mmap_rnd_bits_max,
1674 },
1675#endif
1676#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1677 {
1678 .procname = "mmap_rnd_compat_bits",
1679 .data = &mmap_rnd_compat_bits,
1680 .maxlen = sizeof(mmap_rnd_compat_bits),
1681 .mode = 0600,
1682 .proc_handler = proc_dointvec_minmax,
1683 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1684 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1685 },
1686#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001687 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001688};
1689
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001690static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001691 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001692 .procname = "inode-nr",
1693 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001694 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001695 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001696 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001697 },
1698 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001699 .procname = "inode-state",
1700 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001701 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001702 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001703 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001704 },
1705 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001706 .procname = "file-nr",
1707 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001708 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001709 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001710 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001711 },
1712 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001713 .procname = "file-max",
1714 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001715 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001716 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001717 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001718 },
1719 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001720 .procname = "nr_open",
1721 .data = &sysctl_nr_open,
Alexey Dobriyan9b80a182016-09-02 00:38:52 +03001722 .maxlen = sizeof(unsigned int),
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001723 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001724 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001725 .extra1 = &sysctl_nr_open_min,
1726 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001727 },
1728 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001729 .procname = "dentry-state",
1730 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001731 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001732 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001733 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001734 },
1735 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736 .procname = "overflowuid",
1737 .data = &fs_overflowuid,
1738 .maxlen = sizeof(int),
1739 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001740 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001741 .extra1 = &minolduid,
1742 .extra2 = &maxolduid,
1743 },
1744 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001745 .procname = "overflowgid",
1746 .data = &fs_overflowgid,
1747 .maxlen = sizeof(int),
1748 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001749 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750 .extra1 = &minolduid,
1751 .extra2 = &maxolduid,
1752 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001753#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001754 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001755 .procname = "leases-enable",
1756 .data = &leases_enable,
1757 .maxlen = sizeof(int),
1758 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001759 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001760 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001761#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001762#ifdef CONFIG_DNOTIFY
1763 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001764 .procname = "dir-notify-enable",
1765 .data = &dir_notify_enable,
1766 .maxlen = sizeof(int),
1767 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001768 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001769 },
1770#endif
1771#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001772#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001773 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001774 .procname = "lease-break-time",
1775 .data = &lease_break_time,
1776 .maxlen = sizeof(int),
1777 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001778 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001779 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001780#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001781#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001782 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001783 .procname = "aio-nr",
1784 .data = &aio_nr,
1785 .maxlen = sizeof(aio_nr),
1786 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001787 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001788 },
1789 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001790 .procname = "aio-max-nr",
1791 .data = &aio_max_nr,
1792 .maxlen = sizeof(aio_max_nr),
1793 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001794 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001795 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001796#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001797#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001798 {
Robert Love0399cb02005-07-13 12:38:18 -04001799 .procname = "inotify",
1800 .mode = 0555,
1801 .child = inotify_table,
1802 },
1803#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001804#ifdef CONFIG_EPOLL
1805 {
1806 .procname = "epoll",
1807 .mode = 0555,
1808 .child = epoll_table,
1809 },
1810#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001811#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001812 {
Kees Cook800179c2012-07-25 17:29:07 -07001813 .procname = "protected_symlinks",
1814 .data = &sysctl_protected_symlinks,
1815 .maxlen = sizeof(int),
1816 .mode = 0600,
1817 .proc_handler = proc_dointvec_minmax,
1818 .extra1 = &zero,
1819 .extra2 = &one,
1820 },
1821 {
1822 .procname = "protected_hardlinks",
1823 .data = &sysctl_protected_hardlinks,
1824 .maxlen = sizeof(int),
1825 .mode = 0600,
1826 .proc_handler = proc_dointvec_minmax,
1827 .extra1 = &zero,
1828 .extra2 = &one,
1829 },
1830 {
Alan Coxd6e71142005-06-23 00:09:43 -07001831 .procname = "suid_dumpable",
1832 .data = &suid_dumpable,
1833 .maxlen = sizeof(int),
1834 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001835 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001836 .extra1 = &zero,
1837 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001838 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001839#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1840 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001841 .procname = "binfmt_misc",
1842 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001843 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001844 },
1845#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001846 {
Jens Axboeff9da692010-06-03 14:54:39 +02001847 .procname = "pipe-max-size",
1848 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001849 .maxlen = sizeof(int),
1850 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001851 .proc_handler = &pipe_proc_fn,
1852 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001853 },
Willy Tarreau759c0112016-01-18 16:36:09 +01001854 {
1855 .procname = "pipe-user-pages-hard",
1856 .data = &pipe_user_pages_hard,
1857 .maxlen = sizeof(pipe_user_pages_hard),
1858 .mode = 0644,
1859 .proc_handler = proc_doulongvec_minmax,
1860 },
1861 {
1862 .procname = "pipe-user-pages-soft",
1863 .data = &pipe_user_pages_soft,
1864 .maxlen = sizeof(pipe_user_pages_soft),
1865 .mode = 0644,
1866 .proc_handler = proc_doulongvec_minmax,
1867 },
Eric W. Biedermand2921682016-09-28 00:27:17 -05001868 {
1869 .procname = "mount-max",
1870 .data = &sysctl_mount_max,
1871 .maxlen = sizeof(unsigned int),
1872 .mode = 0644,
1873 .proc_handler = proc_dointvec_minmax,
1874 .extra1 = &one,
1875 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001876 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001877};
1878
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001879static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001880#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001881 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001882 .procname = "exception-trace",
1883 .data = &show_unhandled_signals,
1884 .maxlen = sizeof(int),
1885 .mode = 0644,
1886 .proc_handler = proc_dointvec
1887 },
1888#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001889#if defined(CONFIG_OPTPROBES)
1890 {
1891 .procname = "kprobes-optimization",
1892 .data = &sysctl_kprobes_optimization,
1893 .maxlen = sizeof(int),
1894 .mode = 0644,
1895 .proc_handler = proc_kprobes_optimization_handler,
1896 .extra1 = &zero,
1897 .extra2 = &one,
1898 },
1899#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001900 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001901};
1902
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001903static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001904 { }
Robert Love0eeca282005-07-12 17:06:03 -04001905};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001906
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001907int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001908{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001909 struct ctl_table_header *hdr;
1910
1911 hdr = register_sysctl_table(sysctl_base_table);
1912 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001913 return 0;
1914}
1915
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001916#endif /* CONFIG_SYSCTL */
1917
Linus Torvalds1da177e2005-04-16 15:20:36 -07001918/*
1919 * /proc/sys support
1920 */
1921
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001922#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001923
Kees Cookf8808302014-06-06 14:37:17 -07001924static int _proc_do_string(char *data, int maxlen, int write,
1925 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001926 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001927{
1928 size_t len;
1929 char __user *p;
1930 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001931
1932 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001933 *lenp = 0;
1934 return 0;
1935 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001936
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001937 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001938 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1939 /* Only continue writes not past the end of buffer. */
1940 len = strlen(data);
1941 if (len > maxlen - 1)
1942 len = maxlen - 1;
1943
1944 if (*ppos > len)
1945 return 0;
1946 len = *ppos;
1947 } else {
1948 /* Start writing from beginning of buffer. */
1949 len = 0;
1950 }
1951
Kees Cook2ca9bb42014-06-06 14:37:18 -07001952 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001953 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001954 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001955 if (get_user(c, p++))
1956 return -EFAULT;
1957 if (c == 0 || c == '\n')
1958 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001959 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001960 }
Kees Cookf8808302014-06-06 14:37:17 -07001961 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001962 } else {
1963 len = strlen(data);
1964 if (len > maxlen)
1965 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001966
1967 if (*ppos > len) {
1968 *lenp = 0;
1969 return 0;
1970 }
1971
1972 data += *ppos;
1973 len -= *ppos;
1974
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001975 if (len > *lenp)
1976 len = *lenp;
1977 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001978 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001979 return -EFAULT;
1980 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001981 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001982 return -EFAULT;
1983 len++;
1984 }
1985 *lenp = len;
1986 *ppos += len;
1987 }
1988 return 0;
1989}
1990
Kees Cookf4aacea2014-06-06 14:37:19 -07001991static void warn_sysctl_write(struct ctl_table *table)
1992{
1993 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1994 "This will not be supported in the future. To silence this\n"
1995 "warning, set kernel.sysctl_writes_strict = -1\n",
1996 current->comm, table->procname);
1997}
1998
Linus Torvalds1da177e2005-04-16 15:20:36 -07001999/**
2000 * proc_dostring - read a string sysctl
2001 * @table: the sysctl table
2002 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002003 * @buffer: the user buffer
2004 * @lenp: the size of the user buffer
2005 * @ppos: file position
2006 *
2007 * Reads/writes a string from/to the user buffer. If the kernel
2008 * buffer provided is not large enough to hold the string, the
2009 * string is truncated. The copied string is %NULL-terminated.
2010 * If the string is being read by the user process, it is copied
2011 * and a newline '\n' is added. It is truncated if the buffer is
2012 * not large enough.
2013 *
2014 * Returns 0 on success.
2015 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002016int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002017 void __user *buffer, size_t *lenp, loff_t *ppos)
2018{
Kees Cookf4aacea2014-06-06 14:37:19 -07002019 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
2020 warn_sysctl_write(table);
2021
Kees Cookf8808302014-06-06 14:37:17 -07002022 return _proc_do_string((char *)(table->data), table->maxlen, write,
2023 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002024}
2025
Amerigo Wang00b7c332010-05-05 00:26:45 +00002026static size_t proc_skip_spaces(char **buf)
2027{
2028 size_t ret;
2029 char *tmp = skip_spaces(*buf);
2030 ret = tmp - *buf;
2031 *buf = tmp;
2032 return ret;
2033}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002034
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002035static void proc_skip_char(char **buf, size_t *size, const char v)
2036{
2037 while (*size) {
2038 if (**buf != v)
2039 break;
2040 (*size)--;
2041 (*buf)++;
2042 }
2043}
2044
Amerigo Wang00b7c332010-05-05 00:26:45 +00002045#define TMPBUFLEN 22
2046/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002047 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00002048 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002049 * @buf: a kernel buffer
2050 * @size: size of the kernel buffer
2051 * @val: this is where the number will be stored
2052 * @neg: set to %TRUE if number is negative
2053 * @perm_tr: a vector which contains the allowed trailers
2054 * @perm_tr_len: size of the perm_tr vector
2055 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00002056 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002057 * In case of success %0 is returned and @buf and @size are updated with
2058 * the amount of bytes read. If @tr is non-NULL and a trailing
2059 * character exists (size is non-zero after returning from this
2060 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002061 */
2062static int proc_get_long(char **buf, size_t *size,
2063 unsigned long *val, bool *neg,
2064 const char *perm_tr, unsigned perm_tr_len, char *tr)
2065{
2066 int len;
2067 char *p, tmp[TMPBUFLEN];
2068
2069 if (!*size)
2070 return -EINVAL;
2071
2072 len = *size;
2073 if (len > TMPBUFLEN - 1)
2074 len = TMPBUFLEN - 1;
2075
2076 memcpy(tmp, *buf, len);
2077
2078 tmp[len] = 0;
2079 p = tmp;
2080 if (*p == '-' && *size > 1) {
2081 *neg = true;
2082 p++;
2083 } else
2084 *neg = false;
2085 if (!isdigit(*p))
2086 return -EINVAL;
2087
2088 *val = simple_strtoul(p, &p, 0);
2089
2090 len = p - tmp;
2091
2092 /* We don't know if the next char is whitespace thus we may accept
2093 * invalid integers (e.g. 1234...a) or two integers instead of one
2094 * (e.g. 123...1). So lets not allow such large numbers. */
2095 if (len == TMPBUFLEN - 1)
2096 return -EINVAL;
2097
2098 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2099 return -EINVAL;
2100
2101 if (tr && (len < *size))
2102 *tr = *p;
2103
2104 *buf += len;
2105 *size -= len;
2106
2107 return 0;
2108}
2109
2110/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002111 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002112 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002113 * @buf: the user buffer
2114 * @size: the size of the user buffer
2115 * @val: the integer to be converted
2116 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002117 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002118 * In case of success %0 is returned and @buf and @size are updated with
2119 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002120 */
2121static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2122 bool neg)
2123{
2124 int len;
2125 char tmp[TMPBUFLEN], *p = tmp;
2126
2127 sprintf(p, "%s%lu", neg ? "-" : "", val);
2128 len = strlen(tmp);
2129 if (len > *size)
2130 len = *size;
2131 if (copy_to_user(*buf, tmp, len))
2132 return -EFAULT;
2133 *size -= len;
2134 *buf += len;
2135 return 0;
2136}
2137#undef TMPBUFLEN
2138
2139static int proc_put_char(void __user **buf, size_t *size, char c)
2140{
2141 if (*size) {
2142 char __user **buffer = (char __user **)buf;
2143 if (put_user(c, *buffer))
2144 return -EFAULT;
2145 (*size)--, (*buffer)++;
2146 *buf = *buffer;
2147 }
2148 return 0;
2149}
2150
2151static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002152 int *valp,
2153 int write, void *data)
2154{
2155 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002156 if (*negp) {
2157 if (*lvalp > (unsigned long) INT_MAX + 1)
2158 return -EINVAL;
2159 *valp = -*lvalp;
2160 } else {
2161 if (*lvalp > (unsigned long) INT_MAX)
2162 return -EINVAL;
2163 *valp = *lvalp;
2164 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002165 } else {
2166 int val = *valp;
2167 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002168 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002169 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002170 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002171 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002172 *lvalp = (unsigned long)val;
2173 }
2174 }
2175 return 0;
2176}
2177
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002178static int do_proc_douintvec_conv(bool *negp, unsigned long *lvalp,
2179 int *valp,
2180 int write, void *data)
2181{
2182 if (write) {
2183 if (*negp)
2184 return -EINVAL;
2185 *valp = *lvalp;
2186 } else {
2187 unsigned int val = *valp;
2188 *lvalp = (unsigned long)val;
2189 }
2190 return 0;
2191}
2192
Amerigo Wang00b7c332010-05-05 00:26:45 +00002193static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2194
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002195static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002196 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002197 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002198 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002199 int write, void *data),
2200 void *data)
2201{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002202 int *i, vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002203 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002204 char *kbuf = NULL, *p;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002205
Amerigo Wang00b7c332010-05-05 00:26:45 +00002206 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002207 *lenp = 0;
2208 return 0;
2209 }
2210
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002211 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002212 vleft = table->maxlen / sizeof(*i);
2213 left = *lenp;
2214
2215 if (!conv)
2216 conv = do_proc_dointvec_conv;
2217
Linus Torvalds1da177e2005-04-16 15:20:36 -07002218 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002219 if (*ppos) {
2220 switch (sysctl_writes_strict) {
2221 case SYSCTL_WRITES_STRICT:
2222 goto out;
2223 case SYSCTL_WRITES_WARN:
2224 warn_sysctl_write(table);
2225 break;
2226 default:
2227 break;
2228 }
2229 }
2230
Amerigo Wang00b7c332010-05-05 00:26:45 +00002231 if (left > PAGE_SIZE - 1)
2232 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002233 p = kbuf = memdup_user_nul(buffer, left);
2234 if (IS_ERR(kbuf))
2235 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002236 }
2237
2238 for (; left && vleft--; i++, first=0) {
2239 unsigned long lval;
2240 bool neg;
2241
2242 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002243 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002244
J. R. Okajima563b0462010-05-25 16:10:14 -07002245 if (!left)
2246 break;
Al Viro70f6cbb2015-12-24 00:13:10 -05002247 err = proc_get_long(&p, &left, &lval, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002248 proc_wspace_sep,
2249 sizeof(proc_wspace_sep), NULL);
2250 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002251 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002252 if (conv(&neg, &lval, i, 1, data)) {
2253 err = -EINVAL;
2254 break;
2255 }
2256 } else {
2257 if (conv(&neg, &lval, i, 0, data)) {
2258 err = -EINVAL;
2259 break;
2260 }
2261 if (!first)
2262 err = proc_put_char(&buffer, &left, '\t');
2263 if (err)
2264 break;
2265 err = proc_put_long(&buffer, &left, lval, neg);
2266 if (err)
2267 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002268 }
2269 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002270
2271 if (!write && !first && left && !err)
2272 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002273 if (write && !err && left)
Al Viro70f6cbb2015-12-24 00:13:10 -05002274 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002275 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002276 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002277 if (first)
2278 return err ? : -EINVAL;
2279 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002280 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002281out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002282 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002283 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002284}
2285
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002286static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002287 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002288 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002289 int write, void *data),
2290 void *data)
2291{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002292 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002293 buffer, lenp, ppos, conv, data);
2294}
2295
Linus Torvalds1da177e2005-04-16 15:20:36 -07002296/**
2297 * proc_dointvec - read a vector of integers
2298 * @table: the sysctl table
2299 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002300 * @buffer: the user buffer
2301 * @lenp: the size of the user buffer
2302 * @ppos: file position
2303 *
2304 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2305 * values from/to the user buffer, treated as an ASCII string.
2306 *
2307 * Returns 0 on success.
2308 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002309int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002310 void __user *buffer, size_t *lenp, loff_t *ppos)
2311{
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002312 return do_proc_dointvec(table, write, buffer, lenp, ppos, NULL, NULL);
2313}
2314
2315/**
2316 * proc_douintvec - read a vector of unsigned integers
2317 * @table: the sysctl table
2318 * @write: %TRUE if this is a write to the sysctl file
2319 * @buffer: the user buffer
2320 * @lenp: the size of the user buffer
2321 * @ppos: file position
2322 *
2323 * Reads/writes up to table->maxlen/sizeof(unsigned int) unsigned integer
2324 * values from/to the user buffer, treated as an ASCII string.
2325 *
2326 * Returns 0 on success.
2327 */
2328int proc_douintvec(struct ctl_table *table, int write,
2329 void __user *buffer, size_t *lenp, loff_t *ppos)
2330{
2331 return do_proc_dointvec(table, write, buffer, lenp, ppos,
2332 do_proc_douintvec_conv, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002333}
2334
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002335/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002336 * Taint values can only be increased
2337 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002338 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002339static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002340 void __user *buffer, size_t *lenp, loff_t *ppos)
2341{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002342 struct ctl_table t;
2343 unsigned long tmptaint = get_taint();
2344 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002345
Bastian Blank91fcd412007-04-23 14:41:14 -07002346 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002347 return -EPERM;
2348
Andi Kleen25ddbb12008-10-15 22:01:41 -07002349 t = *table;
2350 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002351 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002352 if (err < 0)
2353 return err;
2354
2355 if (write) {
2356 /*
2357 * Poor man's atomic or. Not worth adding a primitive
2358 * to everyone's atomic.h for this
2359 */
2360 int i;
2361 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2362 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302363 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002364 }
2365 }
2366
2367 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002368}
2369
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002370#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002371static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002372 void __user *buffer, size_t *lenp, loff_t *ppos)
2373{
2374 if (write && !capable(CAP_SYS_ADMIN))
2375 return -EPERM;
2376
2377 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2378}
2379#endif
2380
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381struct do_proc_dointvec_minmax_conv_param {
2382 int *min;
2383 int *max;
2384};
2385
Amerigo Wang00b7c332010-05-05 00:26:45 +00002386static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2387 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388 int write, void *data)
2389{
2390 struct do_proc_dointvec_minmax_conv_param *param = data;
2391 if (write) {
2392 int val = *negp ? -*lvalp : *lvalp;
2393 if ((param->min && *param->min > val) ||
2394 (param->max && *param->max < val))
2395 return -EINVAL;
2396 *valp = val;
2397 } else {
2398 int val = *valp;
2399 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002400 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002401 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002402 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002403 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002404 *lvalp = (unsigned long)val;
2405 }
2406 }
2407 return 0;
2408}
2409
2410/**
2411 * proc_dointvec_minmax - read a vector of integers with min/max values
2412 * @table: the sysctl table
2413 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002414 * @buffer: the user buffer
2415 * @lenp: the size of the user buffer
2416 * @ppos: file position
2417 *
2418 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2419 * values from/to the user buffer, treated as an ASCII string.
2420 *
2421 * This routine will ensure the values are within the range specified by
2422 * table->extra1 (min) and table->extra2 (max).
2423 *
2424 * Returns 0 on success.
2425 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002426int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002427 void __user *buffer, size_t *lenp, loff_t *ppos)
2428{
2429 struct do_proc_dointvec_minmax_conv_param param = {
2430 .min = (int *) table->extra1,
2431 .max = (int *) table->extra2,
2432 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002433 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002434 do_proc_dointvec_minmax_conv, &param);
2435}
2436
Kees Cook54b50192012-07-30 14:39:18 -07002437static void validate_coredump_safety(void)
2438{
Alex Kelly046d6622012-10-04 17:15:23 -07002439#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002440 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002441 core_pattern[0] != '/' && core_pattern[0] != '|') {
2442 printk(KERN_WARNING "Unsafe core_pattern used with "\
2443 "suid_dumpable=2. Pipe handler or fully qualified "\
2444 "core dump path required.\n");
2445 }
Alex Kelly046d6622012-10-04 17:15:23 -07002446#endif
Kees Cook54b50192012-07-30 14:39:18 -07002447}
2448
2449static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2450 void __user *buffer, size_t *lenp, loff_t *ppos)
2451{
2452 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2453 if (!error)
2454 validate_coredump_safety();
2455 return error;
2456}
2457
Alex Kelly046d6622012-10-04 17:15:23 -07002458#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002459static int proc_dostring_coredump(struct ctl_table *table, int write,
2460 void __user *buffer, size_t *lenp, loff_t *ppos)
2461{
2462 int error = proc_dostring(table, write, buffer, lenp, ppos);
2463 if (!error)
2464 validate_coredump_safety();
2465 return error;
2466}
Alex Kelly046d6622012-10-04 17:15:23 -07002467#endif
Kees Cook54b50192012-07-30 14:39:18 -07002468
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002469static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002470 void __user *buffer,
2471 size_t *lenp, loff_t *ppos,
2472 unsigned long convmul,
2473 unsigned long convdiv)
2474{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002475 unsigned long *i, *min, *max;
2476 int vleft, first = 1, err = 0;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002477 size_t left;
Al Viro70f6cbb2015-12-24 00:13:10 -05002478 char *kbuf = NULL, *p;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002479
2480 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002481 *lenp = 0;
2482 return 0;
2483 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002484
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002485 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002486 min = (unsigned long *) table->extra1;
2487 max = (unsigned long *) table->extra2;
2488 vleft = table->maxlen / sizeof(unsigned long);
2489 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002490
2491 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002492 if (*ppos) {
2493 switch (sysctl_writes_strict) {
2494 case SYSCTL_WRITES_STRICT:
2495 goto out;
2496 case SYSCTL_WRITES_WARN:
2497 warn_sysctl_write(table);
2498 break;
2499 default:
2500 break;
2501 }
2502 }
2503
Amerigo Wang00b7c332010-05-05 00:26:45 +00002504 if (left > PAGE_SIZE - 1)
2505 left = PAGE_SIZE - 1;
Al Viro70f6cbb2015-12-24 00:13:10 -05002506 p = kbuf = memdup_user_nul(buffer, left);
2507 if (IS_ERR(kbuf))
2508 return PTR_ERR(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002509 }
2510
Eric Dumazet27b3d802010-10-07 12:59:29 -07002511 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002512 unsigned long val;
2513
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002515 bool neg;
2516
Al Viro70f6cbb2015-12-24 00:13:10 -05002517 left -= proc_skip_spaces(&p);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002518
Al Viro70f6cbb2015-12-24 00:13:10 -05002519 err = proc_get_long(&p, &left, &val, &neg,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002520 proc_wspace_sep,
2521 sizeof(proc_wspace_sep), NULL);
2522 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002523 break;
2524 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002525 continue;
2526 if ((min && val < *min) || (max && val > *max))
2527 continue;
2528 *i = val;
2529 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002530 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002531 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002532 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002533 if (err)
2534 break;
2535 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002536 err = proc_put_long(&buffer, &left, val, false);
2537 if (err)
2538 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002539 }
2540 }
2541
Amerigo Wang00b7c332010-05-05 00:26:45 +00002542 if (!write && !first && left && !err)
2543 err = proc_put_char(&buffer, &left, '\n');
2544 if (write && !err)
Al Viro70f6cbb2015-12-24 00:13:10 -05002545 left -= proc_skip_spaces(&p);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002547 kfree(kbuf);
Amerigo Wang00b7c332010-05-05 00:26:45 +00002548 if (first)
2549 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002550 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002552out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002553 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002554 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002555}
2556
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002557static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002558 void __user *buffer,
2559 size_t *lenp, loff_t *ppos,
2560 unsigned long convmul,
2561 unsigned long convdiv)
2562{
2563 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002564 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002565}
2566
Linus Torvalds1da177e2005-04-16 15:20:36 -07002567/**
2568 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2569 * @table: the sysctl table
2570 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002571 * @buffer: the user buffer
2572 * @lenp: the size of the user buffer
2573 * @ppos: file position
2574 *
2575 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2576 * values from/to the user buffer, treated as an ASCII string.
2577 *
2578 * This routine will ensure the values are within the range specified by
2579 * table->extra1 (min) and table->extra2 (max).
2580 *
2581 * Returns 0 on success.
2582 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002583int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002584 void __user *buffer, size_t *lenp, loff_t *ppos)
2585{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002586 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002587}
2588
2589/**
2590 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2591 * @table: the sysctl table
2592 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002593 * @buffer: the user buffer
2594 * @lenp: the size of the user buffer
2595 * @ppos: file position
2596 *
2597 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2598 * values from/to the user buffer, treated as an ASCII string. The values
2599 * are treated as milliseconds, and converted to jiffies when they are stored.
2600 *
2601 * This routine will ensure the values are within the range specified by
2602 * table->extra1 (min) and table->extra2 (max).
2603 *
2604 * Returns 0 on success.
2605 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002606int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002607 void __user *buffer,
2608 size_t *lenp, loff_t *ppos)
2609{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002610 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002611 lenp, ppos, HZ, 1000l);
2612}
2613
2614
Amerigo Wang00b7c332010-05-05 00:26:45 +00002615static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002616 int *valp,
2617 int write, void *data)
2618{
2619 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002620 if (*lvalp > LONG_MAX / HZ)
2621 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002622 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2623 } else {
2624 int val = *valp;
2625 unsigned long lval;
2626 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002627 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002628 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002630 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002631 lval = (unsigned long)val;
2632 }
2633 *lvalp = lval / HZ;
2634 }
2635 return 0;
2636}
2637
Amerigo Wang00b7c332010-05-05 00:26:45 +00002638static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002639 int *valp,
2640 int write, void *data)
2641{
2642 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002643 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2644 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002645 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2646 } else {
2647 int val = *valp;
2648 unsigned long lval;
2649 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002650 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002651 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002652 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002653 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002654 lval = (unsigned long)val;
2655 }
2656 *lvalp = jiffies_to_clock_t(lval);
2657 }
2658 return 0;
2659}
2660
Amerigo Wang00b7c332010-05-05 00:26:45 +00002661static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002662 int *valp,
2663 int write, void *data)
2664{
2665 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002666 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2667
2668 if (jif > INT_MAX)
2669 return 1;
2670 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002671 } else {
2672 int val = *valp;
2673 unsigned long lval;
2674 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002675 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002676 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002677 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002678 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002679 lval = (unsigned long)val;
2680 }
2681 *lvalp = jiffies_to_msecs(lval);
2682 }
2683 return 0;
2684}
2685
2686/**
2687 * proc_dointvec_jiffies - read a vector of integers as seconds
2688 * @table: the sysctl table
2689 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002690 * @buffer: the user buffer
2691 * @lenp: the size of the user buffer
2692 * @ppos: file position
2693 *
2694 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2695 * values from/to the user buffer, treated as an ASCII string.
2696 * The values read are assumed to be in seconds, and are converted into
2697 * jiffies.
2698 *
2699 * Returns 0 on success.
2700 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002701int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002702 void __user *buffer, size_t *lenp, loff_t *ppos)
2703{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002704 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002705 do_proc_dointvec_jiffies_conv,NULL);
2706}
2707
2708/**
2709 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2710 * @table: the sysctl table
2711 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002712 * @buffer: the user buffer
2713 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002714 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002715 *
2716 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2717 * values from/to the user buffer, treated as an ASCII string.
2718 * The values read are assumed to be in 1/USER_HZ seconds, and
2719 * are converted into jiffies.
2720 *
2721 * Returns 0 on success.
2722 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002723int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002724 void __user *buffer, size_t *lenp, loff_t *ppos)
2725{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002726 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002727 do_proc_dointvec_userhz_jiffies_conv,NULL);
2728}
2729
2730/**
2731 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2732 * @table: the sysctl table
2733 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002734 * @buffer: the user buffer
2735 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002736 * @ppos: file position
2737 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002738 *
2739 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2740 * values from/to the user buffer, treated as an ASCII string.
2741 * The values read are assumed to be in 1/1000 seconds, and
2742 * are converted into jiffies.
2743 *
2744 * Returns 0 on success.
2745 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002746int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002747 void __user *buffer, size_t *lenp, loff_t *ppos)
2748{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002749 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002750 do_proc_dointvec_ms_jiffies_conv, NULL);
2751}
2752
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002753static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002754 void __user *buffer, size_t *lenp, loff_t *ppos)
2755{
2756 struct pid *new_pid;
2757 pid_t tmp;
2758 int r;
2759
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002760 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002761
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002762 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002763 lenp, ppos, NULL, NULL);
2764 if (r || !write)
2765 return r;
2766
2767 new_pid = find_get_pid(tmp);
2768 if (!new_pid)
2769 return -ESRCH;
2770
2771 put_pid(xchg(&cad_pid, new_pid));
2772 return 0;
2773}
2774
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002775/**
2776 * proc_do_large_bitmap - read/write from/to a large bitmap
2777 * @table: the sysctl table
2778 * @write: %TRUE if this is a write to the sysctl file
2779 * @buffer: the user buffer
2780 * @lenp: the size of the user buffer
2781 * @ppos: file position
2782 *
2783 * The bitmap is stored at table->data and the bitmap length (in bits)
2784 * in table->maxlen.
2785 *
2786 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2787 * large bitmaps may be represented in a compact manner. Writing into
2788 * the file will clear the bitmap then update it with the given input.
2789 *
2790 * Returns 0 on success.
2791 */
2792int proc_do_large_bitmap(struct ctl_table *table, int write,
2793 void __user *buffer, size_t *lenp, loff_t *ppos)
2794{
2795 int err = 0;
2796 bool first = 1;
2797 size_t left = *lenp;
2798 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002799 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002800 unsigned long *tmp_bitmap = NULL;
2801 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2802
WANG Cong122ff242014-05-12 16:04:53 -07002803 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002804 *lenp = 0;
2805 return 0;
2806 }
2807
2808 if (write) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002809 char *kbuf, *p;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002810
2811 if (left > PAGE_SIZE - 1)
2812 left = PAGE_SIZE - 1;
2813
Al Viro70f6cbb2015-12-24 00:13:10 -05002814 p = kbuf = memdup_user_nul(buffer, left);
2815 if (IS_ERR(kbuf))
2816 return PTR_ERR(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002817
2818 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2819 GFP_KERNEL);
2820 if (!tmp_bitmap) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002821 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002822 return -ENOMEM;
2823 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002824 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002825 while (!err && left) {
2826 unsigned long val_a, val_b;
2827 bool neg;
2828
Al Viro70f6cbb2015-12-24 00:13:10 -05002829 err = proc_get_long(&p, &left, &val_a, &neg, tr_a,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002830 sizeof(tr_a), &c);
2831 if (err)
2832 break;
2833 if (val_a >= bitmap_len || neg) {
2834 err = -EINVAL;
2835 break;
2836 }
2837
2838 val_b = val_a;
2839 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002840 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002841 left--;
2842 }
2843
2844 if (c == '-') {
Al Viro70f6cbb2015-12-24 00:13:10 -05002845 err = proc_get_long(&p, &left, &val_b,
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002846 &neg, tr_b, sizeof(tr_b),
2847 &c);
2848 if (err)
2849 break;
2850 if (val_b >= bitmap_len || neg ||
2851 val_a > val_b) {
2852 err = -EINVAL;
2853 break;
2854 }
2855 if (left) {
Al Viro70f6cbb2015-12-24 00:13:10 -05002856 p++;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002857 left--;
2858 }
2859 }
2860
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002861 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002862 first = 0;
Al Viro70f6cbb2015-12-24 00:13:10 -05002863 proc_skip_char(&p, &left, '\n');
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002864 }
Al Viro70f6cbb2015-12-24 00:13:10 -05002865 kfree(kbuf);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002866 } else {
2867 unsigned long bit_a, bit_b = 0;
2868
2869 while (left) {
2870 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2871 if (bit_a >= bitmap_len)
2872 break;
2873 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2874 bit_a + 1) - 1;
2875
2876 if (!first) {
2877 err = proc_put_char(&buffer, &left, ',');
2878 if (err)
2879 break;
2880 }
2881 err = proc_put_long(&buffer, &left, bit_a, false);
2882 if (err)
2883 break;
2884 if (bit_a != bit_b) {
2885 err = proc_put_char(&buffer, &left, '-');
2886 if (err)
2887 break;
2888 err = proc_put_long(&buffer, &left, bit_b, false);
2889 if (err)
2890 break;
2891 }
2892
2893 first = 0; bit_b++;
2894 }
2895 if (!err)
2896 err = proc_put_char(&buffer, &left, '\n');
2897 }
2898
2899 if (!err) {
2900 if (write) {
2901 if (*ppos)
2902 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2903 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002904 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002905 }
2906 kfree(tmp_bitmap);
2907 *lenp -= left;
2908 *ppos += *lenp;
2909 return 0;
2910 } else {
2911 kfree(tmp_bitmap);
2912 return err;
2913 }
2914}
2915
Jovi Zhang55610502011-01-12 17:00:45 -08002916#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002917
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002918int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002919 void __user *buffer, size_t *lenp, loff_t *ppos)
2920{
2921 return -ENOSYS;
2922}
2923
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002924int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002925 void __user *buffer, size_t *lenp, loff_t *ppos)
2926{
2927 return -ENOSYS;
2928}
2929
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002930int proc_douintvec(struct ctl_table *table, int write,
2931 void __user *buffer, size_t *lenp, loff_t *ppos)
2932{
2933 return -ENOSYS;
2934}
2935
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002936int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002937 void __user *buffer, size_t *lenp, loff_t *ppos)
2938{
2939 return -ENOSYS;
2940}
2941
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002942int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002943 void __user *buffer, size_t *lenp, loff_t *ppos)
2944{
2945 return -ENOSYS;
2946}
2947
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002948int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002949 void __user *buffer, size_t *lenp, loff_t *ppos)
2950{
2951 return -ENOSYS;
2952}
2953
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002954int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002955 void __user *buffer, size_t *lenp, loff_t *ppos)
2956{
2957 return -ENOSYS;
2958}
2959
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002960int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002961 void __user *buffer, size_t *lenp, loff_t *ppos)
2962{
2963 return -ENOSYS;
2964}
2965
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002966int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002967 void __user *buffer,
2968 size_t *lenp, loff_t *ppos)
2969{
2970 return -ENOSYS;
2971}
2972
2973
Jovi Zhang55610502011-01-12 17:00:45 -08002974#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002975
Linus Torvalds1da177e2005-04-16 15:20:36 -07002976/*
2977 * No sense putting this after each symbol definition, twice,
2978 * exception granted :-)
2979 */
2980EXPORT_SYMBOL(proc_dointvec);
Subash Abhinov Kasiviswanathane7d316a2016-08-25 15:16:51 -07002981EXPORT_SYMBOL(proc_douintvec);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002982EXPORT_SYMBOL(proc_dointvec_jiffies);
2983EXPORT_SYMBOL(proc_dointvec_minmax);
2984EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2985EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2986EXPORT_SYMBOL(proc_dostring);
2987EXPORT_SYMBOL(proc_doulongvec_minmax);
2988EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);