blob: 1a7a665df44b10f25bc9c9d422c5807bf2565ab3 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
69#include <asm/uaccess.h>
70#include <asm/processor.h>
71
Andi Kleen29cbc782006-09-30 01:47:55 +020072#ifdef CONFIG_X86
73#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010074#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010075#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020076#endif
David Howellsd550bbd2012-03-28 18:30:03 +010077#ifdef CONFIG_SPARC
78#include <asm/setup.h>
79#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080080#ifdef CONFIG_BSD_PROCESS_ACCT
81#include <linux/acct.h>
82#endif
Dave Young4f0e0562010-03-10 15:24:09 -080083#ifdef CONFIG_RT_MUTEXES
84#include <linux/rtmutex.h>
85#endif
Dave Young2edf5e42010-03-10 15:24:10 -080086#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
87#include <linux/lockdep.h>
88#endif
Dave Young15485a42010-03-10 15:24:07 -080089#ifdef CONFIG_CHR_DEV_SG
90#include <scsi/sg.h>
91#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020092
Don Zickus58687ac2010-05-07 17:11:44 -040093#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050094#include <linux/nmi.h>
95#endif
96
Linus Torvalds1da177e2005-04-16 15:20:36 -070097#if defined(CONFIG_SYSCTL)
98
99/* External variables not in a header file. */
Hiroshi Doyufd608032013-04-12 12:43:43 +0300100extern int sysctl_lazy_vfree_pages;
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;
Rik van Rielf8ade362011-09-01 15:26:50 -0400108extern int extra_free_kbytes;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800110extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200111extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100112extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400113extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000114#ifndef CONFIG_MMU
115extern int sysctl_nr_trim_pages;
116#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700118/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400119#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700120static int sixty = 60;
121#endif
122
Aaron Tomlin270750db2014-01-20 17:34:13 +0000123static int __maybe_unused neg_one = -1;
124
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700125static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700126static int __maybe_unused one = 1;
127static int __maybe_unused two = 2;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700128static int __maybe_unused four = 4;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800129static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700130static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700131#ifdef CONFIG_PRINTK
132static int ten_thousand = 10000;
133#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700134
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700135/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
136static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
139static int maxolduid = 65535;
140static int minolduid;
141
142static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700143static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144
Liu Hua80df2842014-04-07 15:38:57 -0700145/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
146#ifdef CONFIG_DETECT_HUNG_TASK
147static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
148#endif
149
Dave Youngd14f1722010-02-25 20:28:57 -0500150#ifdef CONFIG_INOTIFY_USER
151#include <linux/inotify.h>
152#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700153#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154#endif
155
156#ifdef __hppa__
157extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530158#endif
159
160#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161extern int unaligned_enabled;
162#endif
163
Jes Sorensend2b176e2006-02-28 09:42:23 -0800164#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800165extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800166#endif
167
Vineet Guptab6fca722013-01-09 20:06:28 +0530168#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
169extern int no_unaligned_warning;
170#endif
171
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700172#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700173
174#define SYSCTL_WRITES_LEGACY -1
175#define SYSCTL_WRITES_WARN 0
176#define SYSCTL_WRITES_STRICT 1
177
178static int sysctl_writes_strict = SYSCTL_WRITES_WARN;
179
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700180static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700181 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700182static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800183 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700184#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700185
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700186#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700187static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700188 void __user *buffer, size_t *lenp, loff_t *ppos);
189#endif
190
Kees Cook54b50192012-07-30 14:39:18 -0700191static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
192 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700193#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700194static int proc_dostring_coredump(struct ctl_table *table, int write,
195 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700196#endif
Kees Cook54b50192012-07-30 14:39:18 -0700197
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700198#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800199/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100200static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700201
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700202static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700203 void __user *buffer, size_t *lenp,
204 loff_t *ppos)
205{
206 int error;
207
208 error = proc_dointvec(table, write, buffer, lenp, ppos);
209 if (error)
210 return error;
211
212 if (write)
213 sysrq_toggle_support(__sysrq_enabled);
214
215 return 0;
216}
217
218#endif
219
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700220static struct ctl_table kern_table[];
221static struct ctl_table vm_table[];
222static struct ctl_table fs_table[];
223static struct ctl_table debug_table[];
224static struct ctl_table dev_table[];
225extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800226#ifdef CONFIG_EPOLL
227extern struct ctl_table epoll_table[];
228#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229
230#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
231int sysctl_legacy_va_layout;
232#endif
233
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234/* The default sysctl tables: */
235
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800236static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700238 .procname = "kernel",
239 .mode = 0555,
240 .child = kern_table,
241 },
242 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 .procname = "vm",
244 .mode = 0555,
245 .child = vm_table,
246 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 .procname = "fs",
249 .mode = 0555,
250 .child = fs_table,
251 },
252 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253 .procname = "debug",
254 .mode = 0555,
255 .child = debug_table,
256 },
257 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700258 .procname = "dev",
259 .mode = 0555,
260 .child = dev_table,
261 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700262 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263};
264
Ingo Molnar77e54a12007-07-09 18:52:00 +0200265#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100266static int min_sched_granularity_ns = 100000; /* 100 usecs */
267static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
268static int min_wakeup_granularity_ns; /* 0 usecs */
269static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200270#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100271static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
272static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200273#endif /* CONFIG_SMP */
274#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200275
Mel Gorman5e771902010-05-24 14:32:31 -0700276#ifdef CONFIG_COMPACTION
277static int min_extfrag_threshold;
278static int max_extfrag_threshold = 1000;
279#endif
280
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700281static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200282 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200283 .procname = "sched_child_runs_first",
284 .data = &sysctl_sched_child_runs_first,
285 .maxlen = sizeof(unsigned int),
286 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800287 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200288 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200289#ifdef CONFIG_SCHED_DEBUG
290 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100291 .procname = "sched_min_granularity_ns",
292 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200293 .maxlen = sizeof(unsigned int),
294 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800295 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100296 .extra1 = &min_sched_granularity_ns,
297 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200298 },
299 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200300 .procname = "sched_latency_ns",
301 .data = &sysctl_sched_latency,
302 .maxlen = sizeof(unsigned int),
303 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800304 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200305 .extra1 = &min_sched_granularity_ns,
306 .extra2 = &max_sched_granularity_ns,
307 },
308 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200309 .procname = "sched_wakeup_granularity_ns",
310 .data = &sysctl_sched_wakeup_granularity,
311 .maxlen = sizeof(unsigned int),
312 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800313 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200314 .extra1 = &min_wakeup_granularity_ns,
315 .extra2 = &max_wakeup_granularity_ns,
316 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200317#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200318 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100319 .procname = "sched_tunable_scaling",
320 .data = &sysctl_sched_tunable_scaling,
321 .maxlen = sizeof(enum sched_tunable_scaling),
322 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800323 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100324 .extra1 = &min_sched_tunable_scaling,
325 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200326 },
327 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900328 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200329 .data = &sysctl_sched_migration_cost,
330 .maxlen = sizeof(unsigned int),
331 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800332 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200333 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100334 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100335 .procname = "sched_nr_migrate",
336 .data = &sysctl_sched_nr_migrate,
337 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100338 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800339 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100340 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530341 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900342 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200343 .data = &sysctl_sched_time_avg,
344 .maxlen = sizeof(unsigned int),
345 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800346 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200347 },
348 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900349 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800350 .data = &sysctl_sched_shares_window,
351 .maxlen = sizeof(unsigned int),
352 .mode = 0644,
353 .proc_handler = proc_dointvec,
354 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200355#endif /* CONFIG_SMP */
356#ifdef CONFIG_NUMA_BALANCING
357 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200358 .procname = "numa_balancing_scan_delay_ms",
359 .data = &sysctl_numa_balancing_scan_delay,
360 .maxlen = sizeof(unsigned int),
361 .mode = 0644,
362 .proc_handler = proc_dointvec,
363 },
364 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200365 .procname = "numa_balancing_scan_period_min_ms",
366 .data = &sysctl_numa_balancing_scan_period_min,
367 .maxlen = sizeof(unsigned int),
368 .mode = 0644,
369 .proc_handler = proc_dointvec,
370 },
371 {
372 .procname = "numa_balancing_scan_period_max_ms",
373 .data = &sysctl_numa_balancing_scan_period_max,
374 .maxlen = sizeof(unsigned int),
375 .mode = 0644,
376 .proc_handler = proc_dointvec,
377 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200378 {
379 .procname = "numa_balancing_scan_size_mb",
380 .data = &sysctl_numa_balancing_scan_size,
381 .maxlen = sizeof(unsigned int),
382 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400383 .proc_handler = proc_dointvec_minmax,
384 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200385 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100386 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800387 .procname = "numa_balancing",
388 .data = NULL, /* filled in by handler */
389 .maxlen = sizeof(unsigned int),
390 .mode = 0644,
391 .proc_handler = sysctl_numa_balancing,
392 .extra1 = &zero,
393 .extra2 = &one,
394 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200395#endif /* CONFIG_NUMA_BALANCING */
396#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200397 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100398 .procname = "sched_rt_period_us",
399 .data = &sysctl_sched_rt_period,
400 .maxlen = sizeof(unsigned int),
401 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800402 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100403 },
404 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100405 .procname = "sched_rt_runtime_us",
406 .data = &sysctl_sched_rt_runtime,
407 .maxlen = sizeof(int),
408 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800409 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100410 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600411 {
412 .procname = "sched_rr_timeslice_ms",
413 .data = &sched_rr_timeslice,
414 .maxlen = sizeof(int),
415 .mode = 0644,
416 .proc_handler = sched_rr_handler,
417 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100418#ifdef CONFIG_SCHED_AUTOGROUP
419 {
420 .procname = "sched_autogroup_enabled",
421 .data = &sysctl_sched_autogroup_enabled,
422 .maxlen = sizeof(unsigned int),
423 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800424 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100425 .extra1 = &zero,
426 .extra2 = &one,
427 },
428#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700429#ifdef CONFIG_CFS_BANDWIDTH
430 {
431 .procname = "sched_cfs_bandwidth_slice_us",
432 .data = &sysctl_sched_cfs_bandwidth_slice,
433 .maxlen = sizeof(unsigned int),
434 .mode = 0644,
435 .proc_handler = proc_dointvec_minmax,
436 .extra1 = &one,
437 },
438#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700439#ifdef CONFIG_PROVE_LOCKING
440 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700441 .procname = "prove_locking",
442 .data = &prove_locking,
443 .maxlen = sizeof(int),
444 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800445 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700446 },
447#endif
448#ifdef CONFIG_LOCK_STAT
449 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700450 .procname = "lock_stat",
451 .data = &lock_stat,
452 .maxlen = sizeof(int),
453 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800454 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700455 },
456#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200457 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 .procname = "panic",
459 .data = &panic_timeout,
460 .maxlen = sizeof(int),
461 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800462 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 },
Alex Kelly046d6622012-10-04 17:15:23 -0700464#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 .procname = "core_uses_pid",
467 .data = &core_uses_pid,
468 .maxlen = sizeof(int),
469 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800470 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 },
472 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 .procname = "core_pattern",
474 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700475 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700477 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 },
Neil Hormana2939802009-09-23 15:56:56 -0700479 {
Neil Hormana2939802009-09-23 15:56:56 -0700480 .procname = "core_pipe_limit",
481 .data = &core_pipe_limit,
482 .maxlen = sizeof(unsigned int),
483 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800484 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700485 },
Alex Kelly046d6622012-10-04 17:15:23 -0700486#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800487#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700490 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800491 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800492 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700494 {
495 .procname = "sysctl_writes_strict",
496 .data = &sysctl_writes_strict,
497 .maxlen = sizeof(int),
498 .mode = 0644,
499 .proc_handler = proc_dointvec_minmax,
500 .extra1 = &neg_one,
501 .extra2 = &one,
502 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800503#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100504#ifdef CONFIG_LATENCYTOP
505 {
506 .procname = "latencytop",
507 .data = &latencytop_enabled,
508 .maxlen = sizeof(int),
509 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800510 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100511 },
512#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513#ifdef CONFIG_BLK_DEV_INITRD
514 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 .procname = "real-root-dev",
516 .data = &real_root_dev,
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#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700522 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700523 .procname = "print-fatal-signals",
524 .data = &print_fatal_signals,
525 .maxlen = sizeof(int),
526 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800527 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700528 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700529#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 .procname = "reboot-cmd",
532 .data = reboot_command,
533 .maxlen = 256,
534 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800535 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 },
537 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 .procname = "stop-a",
539 .data = &stop_a_enabled,
540 .maxlen = sizeof (int),
541 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800542 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 },
544 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 .procname = "scons-poweroff",
546 .data = &scons_pwroff,
547 .maxlen = sizeof (int),
548 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800549 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 },
551#endif
David S. Miller08714202008-11-16 23:49:24 -0800552#ifdef CONFIG_SPARC64
553 {
David S. Miller08714202008-11-16 23:49:24 -0800554 .procname = "tsb-ratio",
555 .data = &sysctl_tsb_ratio,
556 .maxlen = sizeof (int),
557 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800558 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800559 },
560#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561#ifdef __hppa__
562 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 .procname = "soft-power",
564 .data = &pwrsw_enabled,
565 .maxlen = sizeof (int),
566 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800567 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530569#endif
570#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 .procname = "unaligned-trap",
573 .data = &unaligned_enabled,
574 .maxlen = sizeof (int),
575 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800576 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 },
578#endif
579 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 .procname = "ctrl-alt-del",
581 .data = &C_A_D,
582 .maxlen = sizeof(int),
583 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800584 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400586#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200587 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200588 .procname = "ftrace_enabled",
589 .data = &ftrace_enabled,
590 .maxlen = sizeof(int),
591 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800592 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200593 },
594#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500595#ifdef CONFIG_STACK_TRACER
596 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500597 .procname = "stack_tracer_enabled",
598 .data = &stack_tracer_enabled,
599 .maxlen = sizeof(int),
600 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800601 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500602 },
603#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400604#ifdef CONFIG_TRACING
605 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100606 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400607 .data = &ftrace_dump_on_oops,
608 .maxlen = sizeof(int),
609 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800610 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400611 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400612 {
613 .procname = "traceoff_on_warning",
614 .data = &__disable_trace_on_warning,
615 .maxlen = sizeof(__disable_trace_on_warning),
616 .mode = 0644,
617 .proc_handler = proc_dointvec,
618 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500619 {
620 .procname = "tracepoint_printk",
621 .data = &tracepoint_printk,
622 .maxlen = sizeof(tracepoint_printk),
623 .mode = 0644,
624 .proc_handler = proc_dointvec,
625 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400626#endif
Dave Young2965faa2015-09-09 15:38:55 -0700627#ifdef CONFIG_KEXEC_CORE
Kees Cook79847542014-01-23 15:55:59 -0800628 {
629 .procname = "kexec_load_disabled",
630 .data = &kexec_load_disabled,
631 .maxlen = sizeof(int),
632 .mode = 0644,
633 /* only handle a transition from default "0" to "1" */
634 .proc_handler = proc_dointvec_minmax,
635 .extra1 = &one,
636 .extra2 = &one,
637 },
638#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200639#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 .procname = "modprobe",
642 .data = &modprobe_path,
643 .maxlen = KMOD_PATH_LEN,
644 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800645 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 },
Kees Cook3d433212009-04-02 15:49:29 -0700647 {
Kees Cook3d433212009-04-02 15:49:29 -0700648 .procname = "modules_disabled",
649 .data = &modules_disabled,
650 .maxlen = sizeof(int),
651 .mode = 0644,
652 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800653 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700654 .extra1 = &one,
655 .extra2 = &one,
656 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700658#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100661 .data = &uevent_helper,
662 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800664 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 },
Michael Marineau86d56132014-04-10 14:09:31 -0700666#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667#ifdef CONFIG_CHR_DEV_SG
668 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 .procname = "sg-big-buff",
670 .data = &sg_big_buff,
671 .maxlen = sizeof (int),
672 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800673 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 },
675#endif
676#ifdef CONFIG_BSD_PROCESS_ACCT
677 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 .procname = "acct",
679 .data = &acct_parm,
680 .maxlen = 3*sizeof(int),
681 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800682 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 },
684#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685#ifdef CONFIG_MAGIC_SYSRQ
686 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800688 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 .maxlen = sizeof (int),
690 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700691 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 },
693#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700694#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700697 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 .maxlen = sizeof (int),
699 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800700 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700702#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700705 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 .maxlen = sizeof(int),
707 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700708 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 },
710 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 .procname = "random",
712 .mode = 0555,
713 .child = random_table,
714 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 {
Eric Paris17f60a72011-04-01 17:07:50 -0400716 .procname = "usermodehelper",
717 .mode = 0555,
718 .child = usermodehelper_table,
719 },
720 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 .procname = "overflowuid",
722 .data = &overflowuid,
723 .maxlen = sizeof(int),
724 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800725 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 .extra1 = &minolduid,
727 .extra2 = &maxolduid,
728 },
729 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 .procname = "overflowgid",
731 .data = &overflowgid,
732 .maxlen = sizeof(int),
733 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800734 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 .extra1 = &minolduid,
736 .extra2 = &maxolduid,
737 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800738#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739#ifdef CONFIG_MATHEMU
740 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 .procname = "ieee_emulation_warnings",
742 .data = &sysctl_ieee_emulation_warnings,
743 .maxlen = sizeof(int),
744 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800745 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 },
747#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200750 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 .maxlen = sizeof(int),
752 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800753 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 },
755#endif
756 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 .procname = "pid_max",
758 .data = &pid_max,
759 .maxlen = sizeof (int),
760 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800761 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 .extra1 = &pid_max_min,
763 .extra2 = &pid_max_max,
764 },
765 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 .procname = "panic_on_oops",
767 .data = &panic_on_oops,
768 .maxlen = sizeof(int),
769 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800770 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800772#if defined CONFIG_PRINTK
773 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800774 .procname = "printk",
775 .data = &console_loglevel,
776 .maxlen = 4*sizeof(int),
777 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800778 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800779 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700782 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 .maxlen = sizeof(int),
784 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800785 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 },
787 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700789 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 .maxlen = sizeof(int),
791 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800792 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 },
Dave Youngaf913222009-09-22 16:43:33 -0700794 {
Dave Youngaf913222009-09-22 16:43:33 -0700795 .procname = "printk_delay",
796 .data = &printk_delay_msec,
797 .maxlen = sizeof(int),
798 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800799 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700800 .extra1 = &zero,
801 .extra2 = &ten_thousand,
802 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800804 .procname = "dmesg_restrict",
805 .data = &dmesg_restrict,
806 .maxlen = sizeof(int),
807 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700808 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800809 .extra1 = &zero,
810 .extra2 = &one,
811 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800812 {
813 .procname = "kptr_restrict",
814 .data = &kptr_restrict,
815 .maxlen = sizeof(int),
816 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700817 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800818 .extra1 = &zero,
819 .extra2 = &two,
820 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800821#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800822 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823 .procname = "ngroups_max",
824 .data = &ngroups_max,
825 .maxlen = sizeof (int),
826 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800827 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 },
Dan Ballard73efc032011-10-31 17:11:20 -0700829 {
830 .procname = "cap_last_cap",
831 .data = (void *)&cap_last_cap,
832 .maxlen = sizeof(int),
833 .mode = 0444,
834 .proc_handler = proc_dointvec,
835 },
Don Zickus58687ac2010-05-07 17:11:44 -0400836#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500837 {
Don Zickus58687ac2010-05-07 17:11:44 -0400838 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200839 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500840 .maxlen = sizeof (int),
841 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700842 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700843 .extra1 = &zero,
844 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400845 },
846 {
847 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700848 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400849 .maxlen = sizeof(int),
850 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700851 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800852 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400853 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500854 },
Don Zickus2508ce12010-05-07 17:11:46 -0400855 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700856 .procname = "nmi_watchdog",
857 .data = &nmi_watchdog_enabled,
858 .maxlen = sizeof (int),
859 .mode = 0644,
860 .proc_handler = proc_nmi_watchdog,
861 .extra1 = &zero,
862#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
863 .extra2 = &one,
864#else
865 .extra2 = &zero,
866#endif
867 },
868 {
869 .procname = "soft_watchdog",
870 .data = &soft_watchdog_enabled,
871 .maxlen = sizeof (int),
872 .mode = 0644,
873 .proc_handler = proc_soft_watchdog,
874 .extra1 = &zero,
875 .extra2 = &one,
876 },
877 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700878 .procname = "watchdog_cpumask",
879 .data = &watchdog_cpumask_bits,
880 .maxlen = NR_CPUS,
881 .mode = 0644,
882 .proc_handler = proc_watchdog_cpumask,
883 },
884 {
Don Zickus2508ce12010-05-07 17:11:46 -0400885 .procname = "softlockup_panic",
886 .data = &softlockup_panic,
887 .maxlen = sizeof(int),
888 .mode = 0644,
889 .proc_handler = proc_dointvec_minmax,
890 .extra1 = &zero,
891 .extra2 = &one,
892 },
Don Zickusac1f5912015-11-05 18:44:44 -0800893#ifdef CONFIG_HARDLOCKUP_DETECTOR
894 {
895 .procname = "hardlockup_panic",
896 .data = &hardlockup_panic,
897 .maxlen = sizeof(int),
898 .mode = 0644,
899 .proc_handler = proc_dointvec_minmax,
900 .extra1 = &zero,
901 .extra2 = &one,
902 },
903#endif
Aaron Tomlined235872014-06-23 13:22:05 -0700904#ifdef CONFIG_SMP
905 {
906 .procname = "softlockup_all_cpu_backtrace",
907 .data = &sysctl_softlockup_all_cpu_backtrace,
908 .maxlen = sizeof(int),
909 .mode = 0644,
910 .proc_handler = proc_dointvec_minmax,
911 .extra1 = &zero,
912 .extra2 = &one,
913 },
Jiri Kosina55537872015-11-05 18:44:41 -0800914 {
915 .procname = "hardlockup_all_cpu_backtrace",
916 .data = &sysctl_hardlockup_all_cpu_backtrace,
917 .maxlen = sizeof(int),
918 .mode = 0644,
919 .proc_handler = proc_dointvec_minmax,
920 .extra1 = &zero,
921 .extra2 = &one,
922 },
Aaron Tomlined235872014-06-23 13:22:05 -0700923#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -0500924#endif
925#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
926 {
927 .procname = "unknown_nmi_panic",
928 .data = &unknown_nmi_panic,
929 .maxlen = sizeof (int),
930 .mode = 0644,
931 .proc_handler = proc_dointvec,
932 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500933#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934#if defined(CONFIG_X86)
935 {
Don Zickus8da5add2006-09-26 10:52:27 +0200936 .procname = "panic_on_unrecovered_nmi",
937 .data = &panic_on_unrecovered_nmi,
938 .maxlen = sizeof(int),
939 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800940 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200941 },
942 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700943 .procname = "panic_on_io_nmi",
944 .data = &panic_on_io_nmi,
945 .maxlen = sizeof(int),
946 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800947 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700948 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900949#ifdef CONFIG_DEBUG_STACKOVERFLOW
950 {
951 .procname = "panic_on_stackoverflow",
952 .data = &sysctl_panic_on_stackoverflow,
953 .maxlen = sizeof(int),
954 .mode = 0644,
955 .proc_handler = proc_dointvec,
956 },
957#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700958 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700959 .procname = "bootloader_type",
960 .data = &bootloader_type,
961 .maxlen = sizeof (int),
962 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800963 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100965 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700966 .procname = "bootloader_version",
967 .data = &bootloader_version,
968 .maxlen = sizeof (int),
969 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800970 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700971 },
972 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100973 .procname = "kstack_depth_to_print",
974 .data = &kstack_depth_to_print,
975 .maxlen = sizeof(int),
976 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800977 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100978 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100979 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100980 .procname = "io_delay_type",
981 .data = &io_delay_type,
982 .maxlen = sizeof(int),
983 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800984 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100985 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800987#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700988 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700989 .procname = "randomize_va_space",
990 .data = &randomize_va_space,
991 .maxlen = sizeof(int),
992 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800993 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800995#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800996#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700997 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700998 .procname = "spin_retry",
999 .data = &spin_retry,
1000 .maxlen = sizeof (int),
1001 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001002 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -07001003 },
1004#endif
Len Brown673d5b42007-07-28 03:33:16 -04001005#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -08001006 {
Pavel Machekc255d842006-02-20 18:27:58 -08001007 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -07001008 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -08001009 .maxlen = sizeof (unsigned long),
1010 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001011 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -08001012 },
1013#endif
Vineet Guptab6fca722013-01-09 20:06:28 +05301014#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -08001015 {
Jes Sorensend2b176e2006-02-28 09:42:23 -08001016 .procname = "ignore-unaligned-usertrap",
1017 .data = &no_unaligned_warning,
1018 .maxlen = sizeof (int),
1019 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001020 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -08001021 },
Vineet Guptab6fca722013-01-09 20:06:28 +05301022#endif
1023#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001024 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001025 .procname = "unaligned-dump-stack",
1026 .data = &unaligned_dump_stack,
1027 .maxlen = sizeof (int),
1028 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001029 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001030 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001031#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001032#ifdef CONFIG_DETECT_HUNG_TASK
1033 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001034 .procname = "hung_task_panic",
1035 .data = &sysctl_hung_task_panic,
1036 .maxlen = sizeof(int),
1037 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001038 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001039 .extra1 = &zero,
1040 .extra2 = &one,
1041 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001042 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001043 .procname = "hung_task_check_count",
1044 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001045 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001046 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001047 .proc_handler = proc_dointvec_minmax,
1048 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001049 },
1050 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001051 .procname = "hung_task_timeout_secs",
1052 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001053 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001054 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001055 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001056 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001057 },
1058 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001059 .procname = "hung_task_warnings",
1060 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001061 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001062 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001063 .proc_handler = proc_dointvec_minmax,
1064 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001065 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001066#endif
Andi Kleenbebfa102006-06-26 13:56:52 +02001067#ifdef CONFIG_COMPAT
1068 {
Andi Kleenbebfa102006-06-26 13:56:52 +02001069 .procname = "compat-log",
1070 .data = &compat_log,
1071 .maxlen = sizeof (int),
1072 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001073 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +02001074 },
1075#endif
Ingo Molnar23f78d42006-06-27 02:54:53 -07001076#ifdef CONFIG_RT_MUTEXES
1077 {
Ingo Molnar23f78d42006-06-27 02:54:53 -07001078 .procname = "max_lock_depth",
1079 .data = &max_lock_depth,
1080 .maxlen = sizeof(int),
1081 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001082 .proc_handler = proc_dointvec,
Ingo Molnar23f78d42006-06-27 02:54:53 -07001083 },
1084#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001085 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001086 .procname = "poweroff_cmd",
1087 .data = &poweroff_cmd,
1088 .maxlen = POWEROFF_CMD_PATH_LEN,
1089 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001090 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001091 },
David Howells0b77f5b2008-04-29 01:01:32 -07001092#ifdef CONFIG_KEYS
1093 {
David Howells0b77f5b2008-04-29 01:01:32 -07001094 .procname = "keys",
1095 .mode = 0555,
1096 .child = key_sysctls,
1097 },
1098#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001099#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001100 /*
1101 * User-space scripts rely on the existence of this file
1102 * as a feature check for perf_events being enabled.
1103 *
1104 * So it's an ABI, do not remove!
1105 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001106 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001107 .procname = "perf_event_paranoid",
1108 .data = &sysctl_perf_event_paranoid,
1109 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001110 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001111 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001112 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001113 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001114 .procname = "perf_event_mlock_kb",
1115 .data = &sysctl_perf_event_mlock,
1116 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001117 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001118 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001119 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001120 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001121 .procname = "perf_event_max_sample_rate",
1122 .data = &sysctl_perf_event_sample_rate,
1123 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001124 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001125 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001126 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001127 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001128 {
1129 .procname = "perf_cpu_time_max_percent",
1130 .data = &sysctl_perf_cpu_time_max_percent,
1131 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1132 .mode = 0644,
1133 .proc_handler = perf_cpu_time_max_percent_handler,
1134 .extra1 = &zero,
1135 .extra2 = &one_hundred,
1136 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001137#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001138#ifdef CONFIG_KMEMCHECK
1139 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001140 .procname = "kmemcheck",
1141 .data = &kmemcheck_enabled,
1142 .maxlen = sizeof(int),
1143 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001144 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001145 },
1146#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001147 {
1148 .procname = "panic_on_warn",
1149 .data = &panic_on_warn,
1150 .maxlen = sizeof(int),
1151 .mode = 0644,
1152 .proc_handler = proc_dointvec_minmax,
1153 .extra1 = &zero,
1154 .extra2 = &one,
1155 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001156#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1157 {
1158 .procname = "timer_migration",
1159 .data = &sysctl_timer_migration,
1160 .maxlen = sizeof(unsigned int),
1161 .mode = 0644,
1162 .proc_handler = timer_migration_handler,
1163 },
1164#endif
Alexei Starovoitov1be7f752015-10-07 22:23:21 -07001165#ifdef CONFIG_BPF_SYSCALL
1166 {
1167 .procname = "unprivileged_bpf_disabled",
1168 .data = &sysctl_unprivileged_bpf_disabled,
1169 .maxlen = sizeof(sysctl_unprivileged_bpf_disabled),
1170 .mode = 0644,
1171 /* only handle a transition from default "0" to "1" */
1172 .proc_handler = proc_dointvec_minmax,
1173 .extra1 = &one,
1174 .extra2 = &one,
1175 },
1176#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001177 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178};
1179
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001180static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181 {
Hiroshi Doyufd608032013-04-12 12:43:43 +03001182 .procname = "lazy_vfree_pages",
1183 .data = &sysctl_lazy_vfree_pages,
1184 .maxlen = sizeof(sysctl_lazy_vfree_pages),
1185 .mode = 0644,
1186 .proc_handler = proc_dointvec,
1187 },
1188 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001189 .procname = "overcommit_memory",
1190 .data = &sysctl_overcommit_memory,
1191 .maxlen = sizeof(sysctl_overcommit_memory),
1192 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001193 .proc_handler = proc_dointvec_minmax,
1194 .extra1 = &zero,
1195 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001196 },
1197 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001198 .procname = "panic_on_oom",
1199 .data = &sysctl_panic_on_oom,
1200 .maxlen = sizeof(sysctl_panic_on_oom),
1201 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001202 .proc_handler = proc_dointvec_minmax,
1203 .extra1 = &zero,
1204 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001205 },
1206 {
David Rientjesfe071d72007-10-16 23:25:56 -07001207 .procname = "oom_kill_allocating_task",
1208 .data = &sysctl_oom_kill_allocating_task,
1209 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1210 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001211 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001212 },
1213 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001214 .procname = "oom_dump_tasks",
1215 .data = &sysctl_oom_dump_tasks,
1216 .maxlen = sizeof(sysctl_oom_dump_tasks),
1217 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001218 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001219 },
1220 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001221 .procname = "overcommit_ratio",
1222 .data = &sysctl_overcommit_ratio,
1223 .maxlen = sizeof(sysctl_overcommit_ratio),
1224 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001225 .proc_handler = overcommit_ratio_handler,
1226 },
1227 {
1228 .procname = "overcommit_kbytes",
1229 .data = &sysctl_overcommit_kbytes,
1230 .maxlen = sizeof(sysctl_overcommit_kbytes),
1231 .mode = 0644,
1232 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001233 },
1234 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001235 .procname = "page-cluster",
1236 .data = &page_cluster,
1237 .maxlen = sizeof(int),
1238 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001239 .proc_handler = proc_dointvec_minmax,
1240 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001241 },
1242 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243 .procname = "dirty_background_ratio",
1244 .data = &dirty_background_ratio,
1245 .maxlen = sizeof(dirty_background_ratio),
1246 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001247 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001248 .extra1 = &zero,
1249 .extra2 = &one_hundred,
1250 },
1251 {
David Rientjes2da02992009-01-06 14:39:31 -08001252 .procname = "dirty_background_bytes",
1253 .data = &dirty_background_bytes,
1254 .maxlen = sizeof(dirty_background_bytes),
1255 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001256 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001257 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001258 },
1259 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001260 .procname = "dirty_ratio",
1261 .data = &vm_dirty_ratio,
1262 .maxlen = sizeof(vm_dirty_ratio),
1263 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001264 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001265 .extra1 = &zero,
1266 .extra2 = &one_hundred,
1267 },
1268 {
David Rientjes2da02992009-01-06 14:39:31 -08001269 .procname = "dirty_bytes",
1270 .data = &vm_dirty_bytes,
1271 .maxlen = sizeof(vm_dirty_bytes),
1272 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001273 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001274 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001275 },
1276 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001277 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001278 .data = &dirty_writeback_interval,
1279 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001280 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001281 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001282 },
1283 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001284 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001285 .data = &dirty_expire_interval,
1286 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001287 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001288 .proc_handler = proc_dointvec_minmax,
1289 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001290 },
1291 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001292 .procname = "dirtytime_expire_seconds",
1293 .data = &dirtytime_expire_interval,
1294 .maxlen = sizeof(dirty_expire_interval),
1295 .mode = 0644,
1296 .proc_handler = dirtytime_interval_handler,
1297 .extra1 = &zero,
1298 },
1299 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001300 .procname = "nr_pdflush_threads",
1301 .mode = 0444 /* read-only */,
1302 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001303 },
1304 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001305 .procname = "swappiness",
1306 .data = &vm_swappiness,
1307 .maxlen = sizeof(vm_swappiness),
1308 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001309 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001310 .extra1 = &zero,
1311 .extra2 = &one_hundred,
1312 },
1313#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001314 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001315 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001316 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317 .maxlen = sizeof(unsigned long),
1318 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001319 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001320 },
1321#ifdef CONFIG_NUMA
1322 {
1323 .procname = "nr_hugepages_mempolicy",
1324 .data = NULL,
1325 .maxlen = sizeof(unsigned long),
1326 .mode = 0644,
1327 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001328 },
1329#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001330 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001331 .procname = "hugetlb_shm_group",
1332 .data = &sysctl_hugetlb_shm_group,
1333 .maxlen = sizeof(gid_t),
1334 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001335 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001336 },
Mel Gorman396faf02007-07-17 04:03:13 -07001337 {
Mel Gorman396faf02007-07-17 04:03:13 -07001338 .procname = "hugepages_treat_as_movable",
1339 .data = &hugepages_treat_as_movable,
1340 .maxlen = sizeof(int),
1341 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001342 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001343 },
Adam Litke54f9f802007-10-16 01:26:20 -07001344 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001345 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001346 .data = NULL,
1347 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001348 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001349 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001350 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001351#endif
1352 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001353 .procname = "lowmem_reserve_ratio",
1354 .data = &sysctl_lowmem_reserve_ratio,
1355 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1356 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001357 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001358 },
1359 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001360 .procname = "drop_caches",
1361 .data = &sysctl_drop_caches,
1362 .maxlen = sizeof(int),
1363 .mode = 0644,
1364 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001365 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001366 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001367 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001368#ifdef CONFIG_COMPACTION
1369 {
1370 .procname = "compact_memory",
1371 .data = &sysctl_compact_memory,
1372 .maxlen = sizeof(int),
1373 .mode = 0200,
1374 .proc_handler = sysctl_compaction_handler,
1375 },
Mel Gorman5e771902010-05-24 14:32:31 -07001376 {
1377 .procname = "extfrag_threshold",
1378 .data = &sysctl_extfrag_threshold,
1379 .maxlen = sizeof(int),
1380 .mode = 0644,
1381 .proc_handler = sysctl_extfrag_handler,
1382 .extra1 = &min_extfrag_threshold,
1383 .extra2 = &max_extfrag_threshold,
1384 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001385 {
1386 .procname = "compact_unevictable_allowed",
1387 .data = &sysctl_compact_unevictable_allowed,
1388 .maxlen = sizeof(int),
1389 .mode = 0644,
1390 .proc_handler = proc_dointvec,
1391 .extra1 = &zero,
1392 .extra2 = &one,
1393 },
Mel Gorman5e771902010-05-24 14:32:31 -07001394
Mel Gorman76ab0f52010-05-24 14:32:28 -07001395#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001396 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001397 .procname = "min_free_kbytes",
1398 .data = &min_free_kbytes,
1399 .maxlen = sizeof(min_free_kbytes),
1400 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001401 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001402 .extra1 = &zero,
1403 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001404 {
Rik van Rielf8ade362011-09-01 15:26:50 -04001405 .procname = "extra_free_kbytes",
1406 .data = &extra_free_kbytes,
1407 .maxlen = sizeof(extra_free_kbytes),
1408 .mode = 0644,
1409 .proc_handler = min_free_kbytes_sysctl_handler,
1410 .extra1 = &zero,
1411 },
1412 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001413 .procname = "percpu_pagelist_fraction",
1414 .data = &percpu_pagelist_fraction,
1415 .maxlen = sizeof(percpu_pagelist_fraction),
1416 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001417 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001418 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001419 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420#ifdef CONFIG_MMU
1421 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001422 .procname = "max_map_count",
1423 .data = &sysctl_max_map_count,
1424 .maxlen = sizeof(sysctl_max_map_count),
1425 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001426 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001427 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001428 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001429#else
1430 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001431 .procname = "nr_trim_pages",
1432 .data = &sysctl_nr_trim_pages,
1433 .maxlen = sizeof(sysctl_nr_trim_pages),
1434 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001435 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001436 .extra1 = &zero,
1437 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001438#endif
1439 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001440 .procname = "laptop_mode",
1441 .data = &laptop_mode,
1442 .maxlen = sizeof(laptop_mode),
1443 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001444 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001445 },
1446 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447 .procname = "block_dump",
1448 .data = &block_dump,
1449 .maxlen = sizeof(block_dump),
1450 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001451 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001452 .extra1 = &zero,
1453 },
1454 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001455 .procname = "vfs_cache_pressure",
1456 .data = &sysctl_vfs_cache_pressure,
1457 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1458 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001459 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001460 .extra1 = &zero,
1461 },
1462#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1463 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 .procname = "legacy_va_layout",
1465 .data = &sysctl_legacy_va_layout,
1466 .maxlen = sizeof(sysctl_legacy_va_layout),
1467 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001468 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 .extra1 = &zero,
1470 },
1471#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001472#ifdef CONFIG_NUMA
1473 {
Christoph Lameter17436602006-01-18 17:42:32 -08001474 .procname = "zone_reclaim_mode",
1475 .data = &zone_reclaim_mode,
1476 .maxlen = sizeof(zone_reclaim_mode),
1477 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001478 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001479 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001480 },
Christoph Lameter96146342006-07-03 00:24:13 -07001481 {
Christoph Lameter96146342006-07-03 00:24:13 -07001482 .procname = "min_unmapped_ratio",
1483 .data = &sysctl_min_unmapped_ratio,
1484 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1485 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001486 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001487 .extra1 = &zero,
1488 .extra2 = &one_hundred,
1489 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001490 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001491 .procname = "min_slab_ratio",
1492 .data = &sysctl_min_slab_ratio,
1493 .maxlen = sizeof(sysctl_min_slab_ratio),
1494 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001495 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001496 .extra1 = &zero,
1497 .extra2 = &one_hundred,
1498 },
Christoph Lameter17436602006-01-18 17:42:32 -08001499#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001500#ifdef CONFIG_SMP
1501 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001502 .procname = "stat_interval",
1503 .data = &sysctl_stat_interval,
1504 .maxlen = sizeof(sysctl_stat_interval),
1505 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001506 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001507 },
1508#endif
David Howells6e141542009-12-15 19:27:45 +00001509#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001510 {
Eric Parised032182007-06-28 15:55:21 -04001511 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001512 .data = &dac_mmap_min_addr,
1513 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001514 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001515 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001516 },
David Howells6e141542009-12-15 19:27:45 +00001517#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001518#ifdef CONFIG_NUMA
1519 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001520 .procname = "numa_zonelist_order",
1521 .data = &numa_zonelist_order,
1522 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1523 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001524 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001525 },
1526#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001527#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001528 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001529 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001530 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001531#ifdef CONFIG_X86_32
1532 .data = &vdso32_enabled,
1533 .maxlen = sizeof(vdso32_enabled),
1534#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001535 .data = &vdso_enabled,
1536 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001537#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001538 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001539 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001540 .extra1 = &zero,
1541 },
1542#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001543#ifdef CONFIG_HIGHMEM
1544 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001545 .procname = "highmem_is_dirtyable",
1546 .data = &vm_highmem_is_dirtyable,
1547 .maxlen = sizeof(vm_highmem_is_dirtyable),
1548 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001549 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001550 .extra1 = &zero,
1551 .extra2 = &one,
1552 },
1553#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001554#ifdef CONFIG_MEMORY_FAILURE
1555 {
Andi Kleen6a460792009-09-16 11:50:15 +02001556 .procname = "memory_failure_early_kill",
1557 .data = &sysctl_memory_failure_early_kill,
1558 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1559 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001560 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001561 .extra1 = &zero,
1562 .extra2 = &one,
1563 },
1564 {
Andi Kleen6a460792009-09-16 11:50:15 +02001565 .procname = "memory_failure_recovery",
1566 .data = &sysctl_memory_failure_recovery,
1567 .maxlen = sizeof(sysctl_memory_failure_recovery),
1568 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001569 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001570 .extra1 = &zero,
1571 .extra2 = &one,
1572 },
1573#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001574 {
1575 .procname = "user_reserve_kbytes",
1576 .data = &sysctl_user_reserve_kbytes,
1577 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1578 .mode = 0644,
1579 .proc_handler = proc_doulongvec_minmax,
1580 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001581 {
1582 .procname = "admin_reserve_kbytes",
1583 .data = &sysctl_admin_reserve_kbytes,
1584 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1585 .mode = 0644,
1586 .proc_handler = proc_doulongvec_minmax,
1587 },
dcashmand49d8872016-01-12 09:18:57 -08001588#ifdef CONFIG_HAVE_ARCH_MMAP_RND_BITS
1589 {
1590 .procname = "mmap_rnd_bits",
1591 .data = &mmap_rnd_bits,
1592 .maxlen = sizeof(mmap_rnd_bits),
1593 .mode = 0600,
1594 .proc_handler = proc_dointvec_minmax,
1595 .extra1 = (void *)&mmap_rnd_bits_min,
1596 .extra2 = (void *)&mmap_rnd_bits_max,
1597 },
1598#endif
1599#ifdef CONFIG_HAVE_ARCH_MMAP_RND_COMPAT_BITS
1600 {
1601 .procname = "mmap_rnd_compat_bits",
1602 .data = &mmap_rnd_compat_bits,
1603 .maxlen = sizeof(mmap_rnd_compat_bits),
1604 .mode = 0600,
1605 .proc_handler = proc_dointvec_minmax,
1606 .extra1 = (void *)&mmap_rnd_compat_bits_min,
1607 .extra2 = (void *)&mmap_rnd_compat_bits_max,
1608 },
1609#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001610 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001611};
1612
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001613static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001614 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001615 .procname = "inode-nr",
1616 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001617 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001618 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001619 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001620 },
1621 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001622 .procname = "inode-state",
1623 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001624 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001625 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001626 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001627 },
1628 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001629 .procname = "file-nr",
1630 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001631 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001632 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001633 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001634 },
1635 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001636 .procname = "file-max",
1637 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001638 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001639 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001640 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001641 },
1642 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001643 .procname = "nr_open",
1644 .data = &sysctl_nr_open,
1645 .maxlen = sizeof(int),
1646 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001647 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001648 .extra1 = &sysctl_nr_open_min,
1649 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001650 },
1651 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001652 .procname = "dentry-state",
1653 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001654 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001655 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001656 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001657 },
1658 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001659 .procname = "overflowuid",
1660 .data = &fs_overflowuid,
1661 .maxlen = sizeof(int),
1662 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001663 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001664 .extra1 = &minolduid,
1665 .extra2 = &maxolduid,
1666 },
1667 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001668 .procname = "overflowgid",
1669 .data = &fs_overflowgid,
1670 .maxlen = sizeof(int),
1671 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001672 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001673 .extra1 = &minolduid,
1674 .extra2 = &maxolduid,
1675 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001676#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001677 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001678 .procname = "leases-enable",
1679 .data = &leases_enable,
1680 .maxlen = sizeof(int),
1681 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001682 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001684#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001685#ifdef CONFIG_DNOTIFY
1686 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001687 .procname = "dir-notify-enable",
1688 .data = &dir_notify_enable,
1689 .maxlen = sizeof(int),
1690 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001691 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001692 },
1693#endif
1694#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001695#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001697 .procname = "lease-break-time",
1698 .data = &lease_break_time,
1699 .maxlen = sizeof(int),
1700 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001701 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001702 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001703#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001704#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001705 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001706 .procname = "aio-nr",
1707 .data = &aio_nr,
1708 .maxlen = sizeof(aio_nr),
1709 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001710 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001711 },
1712 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001713 .procname = "aio-max-nr",
1714 .data = &aio_max_nr,
1715 .maxlen = sizeof(aio_max_nr),
1716 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001717 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001718 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001719#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001720#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001721 {
Robert Love0399cb02005-07-13 12:38:18 -04001722 .procname = "inotify",
1723 .mode = 0555,
1724 .child = inotify_table,
1725 },
1726#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001727#ifdef CONFIG_EPOLL
1728 {
1729 .procname = "epoll",
1730 .mode = 0555,
1731 .child = epoll_table,
1732 },
1733#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001734#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001735 {
Kees Cook800179c2012-07-25 17:29:07 -07001736 .procname = "protected_symlinks",
1737 .data = &sysctl_protected_symlinks,
1738 .maxlen = sizeof(int),
1739 .mode = 0600,
1740 .proc_handler = proc_dointvec_minmax,
1741 .extra1 = &zero,
1742 .extra2 = &one,
1743 },
1744 {
1745 .procname = "protected_hardlinks",
1746 .data = &sysctl_protected_hardlinks,
1747 .maxlen = sizeof(int),
1748 .mode = 0600,
1749 .proc_handler = proc_dointvec_minmax,
1750 .extra1 = &zero,
1751 .extra2 = &one,
1752 },
1753 {
Alan Coxd6e71142005-06-23 00:09:43 -07001754 .procname = "suid_dumpable",
1755 .data = &suid_dumpable,
1756 .maxlen = sizeof(int),
1757 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001758 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001759 .extra1 = &zero,
1760 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001761 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001762#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1763 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001764 .procname = "binfmt_misc",
1765 .mode = 0555,
Eric W. Biedermanf9bd6732015-05-09 22:09:14 -05001766 .child = sysctl_mount_point,
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001767 },
1768#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001769 {
Jens Axboeff9da692010-06-03 14:54:39 +02001770 .procname = "pipe-max-size",
1771 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001772 .maxlen = sizeof(int),
1773 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001774 .proc_handler = &pipe_proc_fn,
1775 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001776 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001777 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001778};
1779
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001780static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001781#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001782 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001783 .procname = "exception-trace",
1784 .data = &show_unhandled_signals,
1785 .maxlen = sizeof(int),
1786 .mode = 0644,
1787 .proc_handler = proc_dointvec
1788 },
1789#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001790#if defined(CONFIG_OPTPROBES)
1791 {
1792 .procname = "kprobes-optimization",
1793 .data = &sysctl_kprobes_optimization,
1794 .maxlen = sizeof(int),
1795 .mode = 0644,
1796 .proc_handler = proc_kprobes_optimization_handler,
1797 .extra1 = &zero,
1798 .extra2 = &one,
1799 },
1800#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001801 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001802};
1803
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001804static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001805 { }
Robert Love0eeca282005-07-12 17:06:03 -04001806};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001807
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001808int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001809{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001810 struct ctl_table_header *hdr;
1811
1812 hdr = register_sysctl_table(sysctl_base_table);
1813 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001814 return 0;
1815}
1816
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001817#endif /* CONFIG_SYSCTL */
1818
Linus Torvalds1da177e2005-04-16 15:20:36 -07001819/*
1820 * /proc/sys support
1821 */
1822
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001823#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001824
Kees Cookf8808302014-06-06 14:37:17 -07001825static int _proc_do_string(char *data, int maxlen, int write,
1826 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001827 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001828{
1829 size_t len;
1830 char __user *p;
1831 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001832
1833 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001834 *lenp = 0;
1835 return 0;
1836 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001837
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001838 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001839 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1840 /* Only continue writes not past the end of buffer. */
1841 len = strlen(data);
1842 if (len > maxlen - 1)
1843 len = maxlen - 1;
1844
1845 if (*ppos > len)
1846 return 0;
1847 len = *ppos;
1848 } else {
1849 /* Start writing from beginning of buffer. */
1850 len = 0;
1851 }
1852
Kees Cook2ca9bb42014-06-06 14:37:18 -07001853 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001854 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001855 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001856 if (get_user(c, p++))
1857 return -EFAULT;
1858 if (c == 0 || c == '\n')
1859 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001860 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001861 }
Kees Cookf8808302014-06-06 14:37:17 -07001862 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001863 } else {
1864 len = strlen(data);
1865 if (len > maxlen)
1866 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001867
1868 if (*ppos > len) {
1869 *lenp = 0;
1870 return 0;
1871 }
1872
1873 data += *ppos;
1874 len -= *ppos;
1875
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001876 if (len > *lenp)
1877 len = *lenp;
1878 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001879 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001880 return -EFAULT;
1881 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001882 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001883 return -EFAULT;
1884 len++;
1885 }
1886 *lenp = len;
1887 *ppos += len;
1888 }
1889 return 0;
1890}
1891
Kees Cookf4aacea2014-06-06 14:37:19 -07001892static void warn_sysctl_write(struct ctl_table *table)
1893{
1894 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1895 "This will not be supported in the future. To silence this\n"
1896 "warning, set kernel.sysctl_writes_strict = -1\n",
1897 current->comm, table->procname);
1898}
1899
Linus Torvalds1da177e2005-04-16 15:20:36 -07001900/**
1901 * proc_dostring - read a string sysctl
1902 * @table: the sysctl table
1903 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001904 * @buffer: the user buffer
1905 * @lenp: the size of the user buffer
1906 * @ppos: file position
1907 *
1908 * Reads/writes a string from/to the user buffer. If the kernel
1909 * buffer provided is not large enough to hold the string, the
1910 * string is truncated. The copied string is %NULL-terminated.
1911 * If the string is being read by the user process, it is copied
1912 * and a newline '\n' is added. It is truncated if the buffer is
1913 * not large enough.
1914 *
1915 * Returns 0 on success.
1916 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001917int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001918 void __user *buffer, size_t *lenp, loff_t *ppos)
1919{
Kees Cookf4aacea2014-06-06 14:37:19 -07001920 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
1921 warn_sysctl_write(table);
1922
Kees Cookf8808302014-06-06 14:37:17 -07001923 return _proc_do_string((char *)(table->data), table->maxlen, write,
1924 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001925}
1926
Amerigo Wang00b7c332010-05-05 00:26:45 +00001927static size_t proc_skip_spaces(char **buf)
1928{
1929 size_t ret;
1930 char *tmp = skip_spaces(*buf);
1931 ret = tmp - *buf;
1932 *buf = tmp;
1933 return ret;
1934}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001935
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001936static void proc_skip_char(char **buf, size_t *size, const char v)
1937{
1938 while (*size) {
1939 if (**buf != v)
1940 break;
1941 (*size)--;
1942 (*buf)++;
1943 }
1944}
1945
Amerigo Wang00b7c332010-05-05 00:26:45 +00001946#define TMPBUFLEN 22
1947/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001948 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001949 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001950 * @buf: a kernel buffer
1951 * @size: size of the kernel buffer
1952 * @val: this is where the number will be stored
1953 * @neg: set to %TRUE if number is negative
1954 * @perm_tr: a vector which contains the allowed trailers
1955 * @perm_tr_len: size of the perm_tr vector
1956 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001957 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001958 * In case of success %0 is returned and @buf and @size are updated with
1959 * the amount of bytes read. If @tr is non-NULL and a trailing
1960 * character exists (size is non-zero after returning from this
1961 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001962 */
1963static int proc_get_long(char **buf, size_t *size,
1964 unsigned long *val, bool *neg,
1965 const char *perm_tr, unsigned perm_tr_len, char *tr)
1966{
1967 int len;
1968 char *p, tmp[TMPBUFLEN];
1969
1970 if (!*size)
1971 return -EINVAL;
1972
1973 len = *size;
1974 if (len > TMPBUFLEN - 1)
1975 len = TMPBUFLEN - 1;
1976
1977 memcpy(tmp, *buf, len);
1978
1979 tmp[len] = 0;
1980 p = tmp;
1981 if (*p == '-' && *size > 1) {
1982 *neg = true;
1983 p++;
1984 } else
1985 *neg = false;
1986 if (!isdigit(*p))
1987 return -EINVAL;
1988
1989 *val = simple_strtoul(p, &p, 0);
1990
1991 len = p - tmp;
1992
1993 /* We don't know if the next char is whitespace thus we may accept
1994 * invalid integers (e.g. 1234...a) or two integers instead of one
1995 * (e.g. 123...1). So lets not allow such large numbers. */
1996 if (len == TMPBUFLEN - 1)
1997 return -EINVAL;
1998
1999 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
2000 return -EINVAL;
2001
2002 if (tr && (len < *size))
2003 *tr = *p;
2004
2005 *buf += len;
2006 *size -= len;
2007
2008 return 0;
2009}
2010
2011/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002012 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00002013 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002014 * @buf: the user buffer
2015 * @size: the size of the user buffer
2016 * @val: the integer to be converted
2017 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00002018 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07002019 * In case of success %0 is returned and @buf and @size are updated with
2020 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00002021 */
2022static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
2023 bool neg)
2024{
2025 int len;
2026 char tmp[TMPBUFLEN], *p = tmp;
2027
2028 sprintf(p, "%s%lu", neg ? "-" : "", val);
2029 len = strlen(tmp);
2030 if (len > *size)
2031 len = *size;
2032 if (copy_to_user(*buf, tmp, len))
2033 return -EFAULT;
2034 *size -= len;
2035 *buf += len;
2036 return 0;
2037}
2038#undef TMPBUFLEN
2039
2040static int proc_put_char(void __user **buf, size_t *size, char c)
2041{
2042 if (*size) {
2043 char __user **buffer = (char __user **)buf;
2044 if (put_user(c, *buffer))
2045 return -EFAULT;
2046 (*size)--, (*buffer)++;
2047 *buf = *buffer;
2048 }
2049 return 0;
2050}
2051
2052static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002053 int *valp,
2054 int write, void *data)
2055{
2056 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07002057 if (*negp) {
2058 if (*lvalp > (unsigned long) INT_MAX + 1)
2059 return -EINVAL;
2060 *valp = -*lvalp;
2061 } else {
2062 if (*lvalp > (unsigned long) INT_MAX)
2063 return -EINVAL;
2064 *valp = *lvalp;
2065 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002066 } else {
2067 int val = *valp;
2068 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002069 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002070 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002071 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002072 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002073 *lvalp = (unsigned long)val;
2074 }
2075 }
2076 return 0;
2077}
2078
Amerigo Wang00b7c332010-05-05 00:26:45 +00002079static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2080
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002081static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002082 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002083 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002084 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002085 int write, void *data),
2086 void *data)
2087{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002088 int *i, vleft, first = 1, err = 0;
2089 unsigned long page = 0;
2090 size_t left;
2091 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002092
Amerigo Wang00b7c332010-05-05 00:26:45 +00002093 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002094 *lenp = 0;
2095 return 0;
2096 }
2097
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002098 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002099 vleft = table->maxlen / sizeof(*i);
2100 left = *lenp;
2101
2102 if (!conv)
2103 conv = do_proc_dointvec_conv;
2104
Linus Torvalds1da177e2005-04-16 15:20:36 -07002105 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002106 if (*ppos) {
2107 switch (sysctl_writes_strict) {
2108 case SYSCTL_WRITES_STRICT:
2109 goto out;
2110 case SYSCTL_WRITES_WARN:
2111 warn_sysctl_write(table);
2112 break;
2113 default:
2114 break;
2115 }
2116 }
2117
Amerigo Wang00b7c332010-05-05 00:26:45 +00002118 if (left > PAGE_SIZE - 1)
2119 left = PAGE_SIZE - 1;
2120 page = __get_free_page(GFP_TEMPORARY);
2121 kbuf = (char *) page;
2122 if (!kbuf)
2123 return -ENOMEM;
2124 if (copy_from_user(kbuf, buffer, left)) {
2125 err = -EFAULT;
2126 goto free;
2127 }
2128 kbuf[left] = 0;
2129 }
2130
2131 for (; left && vleft--; i++, first=0) {
2132 unsigned long lval;
2133 bool neg;
2134
2135 if (write) {
2136 left -= proc_skip_spaces(&kbuf);
2137
J. R. Okajima563b0462010-05-25 16:10:14 -07002138 if (!left)
2139 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002140 err = proc_get_long(&kbuf, &left, &lval, &neg,
2141 proc_wspace_sep,
2142 sizeof(proc_wspace_sep), NULL);
2143 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002144 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002145 if (conv(&neg, &lval, i, 1, data)) {
2146 err = -EINVAL;
2147 break;
2148 }
2149 } else {
2150 if (conv(&neg, &lval, i, 0, data)) {
2151 err = -EINVAL;
2152 break;
2153 }
2154 if (!first)
2155 err = proc_put_char(&buffer, &left, '\t');
2156 if (err)
2157 break;
2158 err = proc_put_long(&buffer, &left, lval, neg);
2159 if (err)
2160 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002161 }
2162 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002163
2164 if (!write && !first && left && !err)
2165 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002166 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002167 left -= proc_skip_spaces(&kbuf);
2168free:
2169 if (write) {
2170 free_page(page);
2171 if (first)
2172 return err ? : -EINVAL;
2173 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002174 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002175out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002176 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002177 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002178}
2179
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002180static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002181 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002182 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002183 int write, void *data),
2184 void *data)
2185{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002186 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002187 buffer, lenp, ppos, conv, data);
2188}
2189
Linus Torvalds1da177e2005-04-16 15:20:36 -07002190/**
2191 * proc_dointvec - read a vector of integers
2192 * @table: the sysctl table
2193 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194 * @buffer: the user buffer
2195 * @lenp: the size of the user buffer
2196 * @ppos: file position
2197 *
2198 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2199 * values from/to the user buffer, treated as an ASCII string.
2200 *
2201 * Returns 0 on success.
2202 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002203int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002204 void __user *buffer, size_t *lenp, loff_t *ppos)
2205{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002206 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002207 NULL,NULL);
2208}
2209
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002210/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002211 * Taint values can only be increased
2212 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002213 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002214static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002215 void __user *buffer, size_t *lenp, loff_t *ppos)
2216{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002217 struct ctl_table t;
2218 unsigned long tmptaint = get_taint();
2219 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002220
Bastian Blank91fcd412007-04-23 14:41:14 -07002221 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002222 return -EPERM;
2223
Andi Kleen25ddbb12008-10-15 22:01:41 -07002224 t = *table;
2225 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002226 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002227 if (err < 0)
2228 return err;
2229
2230 if (write) {
2231 /*
2232 * Poor man's atomic or. Not worth adding a primitive
2233 * to everyone's atomic.h for this
2234 */
2235 int i;
2236 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2237 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302238 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002239 }
2240 }
2241
2242 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002243}
2244
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002245#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002246static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002247 void __user *buffer, size_t *lenp, loff_t *ppos)
2248{
2249 if (write && !capable(CAP_SYS_ADMIN))
2250 return -EPERM;
2251
2252 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2253}
2254#endif
2255
Linus Torvalds1da177e2005-04-16 15:20:36 -07002256struct do_proc_dointvec_minmax_conv_param {
2257 int *min;
2258 int *max;
2259};
2260
Amerigo Wang00b7c332010-05-05 00:26:45 +00002261static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2262 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002263 int write, void *data)
2264{
2265 struct do_proc_dointvec_minmax_conv_param *param = data;
2266 if (write) {
2267 int val = *negp ? -*lvalp : *lvalp;
2268 if ((param->min && *param->min > val) ||
2269 (param->max && *param->max < val))
2270 return -EINVAL;
2271 *valp = val;
2272 } else {
2273 int val = *valp;
2274 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002275 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002276 *lvalp = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002277 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002278 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002279 *lvalp = (unsigned long)val;
2280 }
2281 }
2282 return 0;
2283}
2284
2285/**
2286 * proc_dointvec_minmax - read a vector of integers with min/max values
2287 * @table: the sysctl table
2288 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002289 * @buffer: the user buffer
2290 * @lenp: the size of the user buffer
2291 * @ppos: file position
2292 *
2293 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2294 * values from/to the user buffer, treated as an ASCII string.
2295 *
2296 * This routine will ensure the values are within the range specified by
2297 * table->extra1 (min) and table->extra2 (max).
2298 *
2299 * Returns 0 on success.
2300 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002301int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002302 void __user *buffer, size_t *lenp, loff_t *ppos)
2303{
2304 struct do_proc_dointvec_minmax_conv_param param = {
2305 .min = (int *) table->extra1,
2306 .max = (int *) table->extra2,
2307 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002308 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002309 do_proc_dointvec_minmax_conv, &param);
2310}
2311
Kees Cook54b50192012-07-30 14:39:18 -07002312static void validate_coredump_safety(void)
2313{
Alex Kelly046d6622012-10-04 17:15:23 -07002314#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002315 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002316 core_pattern[0] != '/' && core_pattern[0] != '|') {
2317 printk(KERN_WARNING "Unsafe core_pattern used with "\
2318 "suid_dumpable=2. Pipe handler or fully qualified "\
2319 "core dump path required.\n");
2320 }
Alex Kelly046d6622012-10-04 17:15:23 -07002321#endif
Kees Cook54b50192012-07-30 14:39:18 -07002322}
2323
2324static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2325 void __user *buffer, size_t *lenp, loff_t *ppos)
2326{
2327 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2328 if (!error)
2329 validate_coredump_safety();
2330 return error;
2331}
2332
Alex Kelly046d6622012-10-04 17:15:23 -07002333#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002334static int proc_dostring_coredump(struct ctl_table *table, int write,
2335 void __user *buffer, size_t *lenp, loff_t *ppos)
2336{
2337 int error = proc_dostring(table, write, buffer, lenp, ppos);
2338 if (!error)
2339 validate_coredump_safety();
2340 return error;
2341}
Alex Kelly046d6622012-10-04 17:15:23 -07002342#endif
Kees Cook54b50192012-07-30 14:39:18 -07002343
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002344static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002345 void __user *buffer,
2346 size_t *lenp, loff_t *ppos,
2347 unsigned long convmul,
2348 unsigned long convdiv)
2349{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002350 unsigned long *i, *min, *max;
2351 int vleft, first = 1, err = 0;
2352 unsigned long page = 0;
2353 size_t left;
2354 char *kbuf;
2355
2356 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002357 *lenp = 0;
2358 return 0;
2359 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002360
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002361 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002362 min = (unsigned long *) table->extra1;
2363 max = (unsigned long *) table->extra2;
2364 vleft = table->maxlen / sizeof(unsigned long);
2365 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002366
2367 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002368 if (*ppos) {
2369 switch (sysctl_writes_strict) {
2370 case SYSCTL_WRITES_STRICT:
2371 goto out;
2372 case SYSCTL_WRITES_WARN:
2373 warn_sysctl_write(table);
2374 break;
2375 default:
2376 break;
2377 }
2378 }
2379
Amerigo Wang00b7c332010-05-05 00:26:45 +00002380 if (left > PAGE_SIZE - 1)
2381 left = PAGE_SIZE - 1;
2382 page = __get_free_page(GFP_TEMPORARY);
2383 kbuf = (char *) page;
2384 if (!kbuf)
2385 return -ENOMEM;
2386 if (copy_from_user(kbuf, buffer, left)) {
2387 err = -EFAULT;
2388 goto free;
2389 }
2390 kbuf[left] = 0;
2391 }
2392
Eric Dumazet27b3d802010-10-07 12:59:29 -07002393 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002394 unsigned long val;
2395
Linus Torvalds1da177e2005-04-16 15:20:36 -07002396 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002397 bool neg;
2398
2399 left -= proc_skip_spaces(&kbuf);
2400
2401 err = proc_get_long(&kbuf, &left, &val, &neg,
2402 proc_wspace_sep,
2403 sizeof(proc_wspace_sep), NULL);
2404 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002405 break;
2406 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002407 continue;
2408 if ((min && val < *min) || (max && val > *max))
2409 continue;
2410 *i = val;
2411 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002412 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002413 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002414 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002415 if (err)
2416 break;
2417 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002418 err = proc_put_long(&buffer, &left, val, false);
2419 if (err)
2420 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002421 }
2422 }
2423
Amerigo Wang00b7c332010-05-05 00:26:45 +00002424 if (!write && !first && left && !err)
2425 err = proc_put_char(&buffer, &left, '\n');
2426 if (write && !err)
2427 left -= proc_skip_spaces(&kbuf);
2428free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002429 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002430 free_page(page);
2431 if (first)
2432 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002433 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002434 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002435out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002437 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002438}
2439
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002440static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002441 void __user *buffer,
2442 size_t *lenp, loff_t *ppos,
2443 unsigned long convmul,
2444 unsigned long convdiv)
2445{
2446 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002447 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002448}
2449
Linus Torvalds1da177e2005-04-16 15:20:36 -07002450/**
2451 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2452 * @table: the sysctl table
2453 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002454 * @buffer: the user buffer
2455 * @lenp: the size of the user buffer
2456 * @ppos: file position
2457 *
2458 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2459 * values from/to the user buffer, treated as an ASCII string.
2460 *
2461 * This routine will ensure the values are within the range specified by
2462 * table->extra1 (min) and table->extra2 (max).
2463 *
2464 * Returns 0 on success.
2465 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002466int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002467 void __user *buffer, size_t *lenp, loff_t *ppos)
2468{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002469 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002470}
2471
2472/**
2473 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2474 * @table: the sysctl table
2475 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002476 * @buffer: the user buffer
2477 * @lenp: the size of the user buffer
2478 * @ppos: file position
2479 *
2480 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2481 * values from/to the user buffer, treated as an ASCII string. The values
2482 * are treated as milliseconds, and converted to jiffies when they are stored.
2483 *
2484 * This routine will ensure the values are within the range specified by
2485 * table->extra1 (min) and table->extra2 (max).
2486 *
2487 * Returns 0 on success.
2488 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002489int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002490 void __user *buffer,
2491 size_t *lenp, loff_t *ppos)
2492{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002493 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002494 lenp, ppos, HZ, 1000l);
2495}
2496
2497
Amerigo Wang00b7c332010-05-05 00:26:45 +00002498static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002499 int *valp,
2500 int write, void *data)
2501{
2502 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002503 if (*lvalp > LONG_MAX / HZ)
2504 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002505 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2506 } else {
2507 int val = *valp;
2508 unsigned long lval;
2509 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002510 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002511 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002512 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002513 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002514 lval = (unsigned long)val;
2515 }
2516 *lvalp = lval / HZ;
2517 }
2518 return 0;
2519}
2520
Amerigo Wang00b7c332010-05-05 00:26:45 +00002521static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002522 int *valp,
2523 int write, void *data)
2524{
2525 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002526 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2527 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002528 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2529 } else {
2530 int val = *valp;
2531 unsigned long lval;
2532 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002533 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002534 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002535 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002536 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002537 lval = (unsigned long)val;
2538 }
2539 *lvalp = jiffies_to_clock_t(lval);
2540 }
2541 return 0;
2542}
2543
Amerigo Wang00b7c332010-05-05 00:26:45 +00002544static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002545 int *valp,
2546 int write, void *data)
2547{
2548 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002549 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2550
2551 if (jif > INT_MAX)
2552 return 1;
2553 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002554 } else {
2555 int val = *valp;
2556 unsigned long lval;
2557 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002558 *negp = true;
Ilya Dryomov9a5bc722015-09-09 15:39:06 -07002559 lval = -(unsigned long)val;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002560 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002561 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002562 lval = (unsigned long)val;
2563 }
2564 *lvalp = jiffies_to_msecs(lval);
2565 }
2566 return 0;
2567}
2568
2569/**
2570 * proc_dointvec_jiffies - read a vector of integers as seconds
2571 * @table: the sysctl table
2572 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002573 * @buffer: the user buffer
2574 * @lenp: the size of the user buffer
2575 * @ppos: file position
2576 *
2577 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2578 * values from/to the user buffer, treated as an ASCII string.
2579 * The values read are assumed to be in seconds, and are converted into
2580 * jiffies.
2581 *
2582 * Returns 0 on success.
2583 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002584int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002585 void __user *buffer, size_t *lenp, loff_t *ppos)
2586{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002587 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002588 do_proc_dointvec_jiffies_conv,NULL);
2589}
2590
2591/**
2592 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2593 * @table: the sysctl table
2594 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002595 * @buffer: the user buffer
2596 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002597 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002598 *
2599 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2600 * values from/to the user buffer, treated as an ASCII string.
2601 * The values read are assumed to be in 1/USER_HZ seconds, and
2602 * are converted into jiffies.
2603 *
2604 * Returns 0 on success.
2605 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002606int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002607 void __user *buffer, size_t *lenp, loff_t *ppos)
2608{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002609 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002610 do_proc_dointvec_userhz_jiffies_conv,NULL);
2611}
2612
2613/**
2614 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2615 * @table: the sysctl table
2616 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002617 * @buffer: the user buffer
2618 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002619 * @ppos: file position
2620 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002621 *
2622 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2623 * values from/to the user buffer, treated as an ASCII string.
2624 * The values read are assumed to be in 1/1000 seconds, and
2625 * are converted into jiffies.
2626 *
2627 * Returns 0 on success.
2628 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002629int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002630 void __user *buffer, size_t *lenp, loff_t *ppos)
2631{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002632 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002633 do_proc_dointvec_ms_jiffies_conv, NULL);
2634}
2635
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002636static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002637 void __user *buffer, size_t *lenp, loff_t *ppos)
2638{
2639 struct pid *new_pid;
2640 pid_t tmp;
2641 int r;
2642
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002643 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002644
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002645 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002646 lenp, ppos, NULL, NULL);
2647 if (r || !write)
2648 return r;
2649
2650 new_pid = find_get_pid(tmp);
2651 if (!new_pid)
2652 return -ESRCH;
2653
2654 put_pid(xchg(&cad_pid, new_pid));
2655 return 0;
2656}
2657
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002658/**
2659 * proc_do_large_bitmap - read/write from/to a large bitmap
2660 * @table: the sysctl table
2661 * @write: %TRUE if this is a write to the sysctl file
2662 * @buffer: the user buffer
2663 * @lenp: the size of the user buffer
2664 * @ppos: file position
2665 *
2666 * The bitmap is stored at table->data and the bitmap length (in bits)
2667 * in table->maxlen.
2668 *
2669 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2670 * large bitmaps may be represented in a compact manner. Writing into
2671 * the file will clear the bitmap then update it with the given input.
2672 *
2673 * Returns 0 on success.
2674 */
2675int proc_do_large_bitmap(struct ctl_table *table, int write,
2676 void __user *buffer, size_t *lenp, loff_t *ppos)
2677{
2678 int err = 0;
2679 bool first = 1;
2680 size_t left = *lenp;
2681 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002682 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002683 unsigned long *tmp_bitmap = NULL;
2684 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2685
WANG Cong122ff242014-05-12 16:04:53 -07002686 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002687 *lenp = 0;
2688 return 0;
2689 }
2690
2691 if (write) {
2692 unsigned long page = 0;
2693 char *kbuf;
2694
2695 if (left > PAGE_SIZE - 1)
2696 left = PAGE_SIZE - 1;
2697
2698 page = __get_free_page(GFP_TEMPORARY);
2699 kbuf = (char *) page;
2700 if (!kbuf)
2701 return -ENOMEM;
2702 if (copy_from_user(kbuf, buffer, left)) {
2703 free_page(page);
2704 return -EFAULT;
2705 }
2706 kbuf[left] = 0;
2707
2708 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2709 GFP_KERNEL);
2710 if (!tmp_bitmap) {
2711 free_page(page);
2712 return -ENOMEM;
2713 }
2714 proc_skip_char(&kbuf, &left, '\n');
2715 while (!err && left) {
2716 unsigned long val_a, val_b;
2717 bool neg;
2718
2719 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2720 sizeof(tr_a), &c);
2721 if (err)
2722 break;
2723 if (val_a >= bitmap_len || neg) {
2724 err = -EINVAL;
2725 break;
2726 }
2727
2728 val_b = val_a;
2729 if (left) {
2730 kbuf++;
2731 left--;
2732 }
2733
2734 if (c == '-') {
2735 err = proc_get_long(&kbuf, &left, &val_b,
2736 &neg, tr_b, sizeof(tr_b),
2737 &c);
2738 if (err)
2739 break;
2740 if (val_b >= bitmap_len || neg ||
2741 val_a > val_b) {
2742 err = -EINVAL;
2743 break;
2744 }
2745 if (left) {
2746 kbuf++;
2747 left--;
2748 }
2749 }
2750
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002751 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002752 first = 0;
2753 proc_skip_char(&kbuf, &left, '\n');
2754 }
2755 free_page(page);
2756 } else {
2757 unsigned long bit_a, bit_b = 0;
2758
2759 while (left) {
2760 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2761 if (bit_a >= bitmap_len)
2762 break;
2763 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2764 bit_a + 1) - 1;
2765
2766 if (!first) {
2767 err = proc_put_char(&buffer, &left, ',');
2768 if (err)
2769 break;
2770 }
2771 err = proc_put_long(&buffer, &left, bit_a, false);
2772 if (err)
2773 break;
2774 if (bit_a != bit_b) {
2775 err = proc_put_char(&buffer, &left, '-');
2776 if (err)
2777 break;
2778 err = proc_put_long(&buffer, &left, bit_b, false);
2779 if (err)
2780 break;
2781 }
2782
2783 first = 0; bit_b++;
2784 }
2785 if (!err)
2786 err = proc_put_char(&buffer, &left, '\n');
2787 }
2788
2789 if (!err) {
2790 if (write) {
2791 if (*ppos)
2792 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2793 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002794 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002795 }
2796 kfree(tmp_bitmap);
2797 *lenp -= left;
2798 *ppos += *lenp;
2799 return 0;
2800 } else {
2801 kfree(tmp_bitmap);
2802 return err;
2803 }
2804}
2805
Jovi Zhang55610502011-01-12 17:00:45 -08002806#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002807
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002808int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002809 void __user *buffer, size_t *lenp, loff_t *ppos)
2810{
2811 return -ENOSYS;
2812}
2813
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002814int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002815 void __user *buffer, size_t *lenp, loff_t *ppos)
2816{
2817 return -ENOSYS;
2818}
2819
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002820int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002821 void __user *buffer, size_t *lenp, loff_t *ppos)
2822{
2823 return -ENOSYS;
2824}
2825
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002826int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002827 void __user *buffer, size_t *lenp, loff_t *ppos)
2828{
2829 return -ENOSYS;
2830}
2831
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002832int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002833 void __user *buffer, size_t *lenp, loff_t *ppos)
2834{
2835 return -ENOSYS;
2836}
2837
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002838int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002839 void __user *buffer, size_t *lenp, loff_t *ppos)
2840{
2841 return -ENOSYS;
2842}
2843
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002844int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002845 void __user *buffer, size_t *lenp, loff_t *ppos)
2846{
2847 return -ENOSYS;
2848}
2849
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002850int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002851 void __user *buffer,
2852 size_t *lenp, loff_t *ppos)
2853{
2854 return -ENOSYS;
2855}
2856
2857
Jovi Zhang55610502011-01-12 17:00:45 -08002858#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002859
Linus Torvalds1da177e2005-04-16 15:20:36 -07002860/*
2861 * No sense putting this after each symbol definition, twice,
2862 * exception granted :-)
2863 */
2864EXPORT_SYMBOL(proc_dointvec);
2865EXPORT_SYMBOL(proc_dointvec_jiffies);
2866EXPORT_SYMBOL(proc_dointvec_minmax);
2867EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2868EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2869EXPORT_SYMBOL(proc_dostring);
2870EXPORT_SYMBOL(proc_doulongvec_minmax);
2871EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);