blob: 812fcc3fd3906f7a095888a3fde0fe4893027cb6 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
68#include <asm/uaccess.h>
69#include <asm/processor.h>
70
Andi Kleen29cbc782006-09-30 01:47:55 +020071#ifdef CONFIG_X86
72#include <asm/nmi.h>
Chuck Ebbert0741f4d2006-12-07 02:14:11 +010073#include <asm/stacktrace.h>
Ingo Molnar6e7c4022008-01-30 13:30:05 +010074#include <asm/io.h>
Andi Kleen29cbc782006-09-30 01:47:55 +020075#endif
David Howellsd550bbd2012-03-28 18:30:03 +010076#ifdef CONFIG_SPARC
77#include <asm/setup.h>
78#endif
Dave Youngc55b7c32010-03-10 15:24:08 -080079#ifdef CONFIG_BSD_PROCESS_ACCT
80#include <linux/acct.h>
81#endif
Dave Young4f0e0562010-03-10 15:24:09 -080082#ifdef CONFIG_RT_MUTEXES
83#include <linux/rtmutex.h>
84#endif
Dave Young2edf5e42010-03-10 15:24:10 -080085#if defined(CONFIG_PROVE_LOCKING) || defined(CONFIG_LOCK_STAT)
86#include <linux/lockdep.h>
87#endif
Dave Young15485a42010-03-10 15:24:07 -080088#ifdef CONFIG_CHR_DEV_SG
89#include <scsi/sg.h>
90#endif
Andi Kleen29cbc782006-09-30 01:47:55 +020091
Don Zickus58687ac2010-05-07 17:11:44 -040092#ifdef CONFIG_LOCKUP_DETECTOR
Don Zickus504d7cf2010-02-12 17:19:19 -050093#include <linux/nmi.h>
94#endif
95
Linus Torvalds1da177e2005-04-16 15:20:36 -070096#if defined(CONFIG_SYSCTL)
97
98/* External variables not in a header file. */
Alan Coxd6e71142005-06-23 00:09:43 -070099extern int suid_dumpable;
Alex Kelly046d6622012-10-04 17:15:23 -0700100#ifdef CONFIG_COREDUMP
101extern int core_uses_pid;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102extern char core_pattern[];
Neil Hormana2939802009-09-23 15:56:56 -0700103extern unsigned int core_pipe_limit;
Alex Kelly046d6622012-10-04 17:15:23 -0700104#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105extern int pid_max;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106extern int pid_max_min, pid_max_max;
Rohit Seth8ad4b1f2006-01-08 01:00:40 -0800107extern int percpu_pagelist_fraction;
Andi Kleenbebfa102006-06-26 13:56:52 +0200108extern int compat_log;
Arjan van de Ven97455122008-01-25 21:08:34 +0100109extern int latencytop_enabled;
Al Viroeceea0b2008-05-10 10:08:32 -0400110extern int sysctl_nr_open_min, sysctl_nr_open_max;
Paul Mundtdd8632a2009-01-08 12:04:47 +0000111#ifndef CONFIG_MMU
112extern int sysctl_nr_trim_pages;
113#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700115/* Constants used for minimum and maximum */
Don Zickus2508ce12010-05-07 17:11:46 -0400116#ifdef CONFIG_LOCKUP_DETECTOR
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700117static int sixty = 60;
118#endif
119
Aaron Tomlin270750db2014-01-20 17:34:13 +0000120static int __maybe_unused neg_one = -1;
121
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700122static int zero;
Linus Torvaldscd5f9a42009-04-06 13:38:46 -0700123static int __maybe_unused one = 1;
124static int __maybe_unused two = 2;
Dave Hansen5509a5d2014-04-03 14:48:19 -0700125static int __maybe_unused four = 4;
Sven Wegenerfc3501d2009-02-11 13:04:23 -0800126static unsigned long one_ul = 1;
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700127static int one_hundred = 100;
Dave Youngaf913222009-09-22 16:43:33 -0700128#ifdef CONFIG_PRINTK
129static int ten_thousand = 10000;
130#endif
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -0700131
Andrea Righi9e4a5bd2009-04-30 15:08:57 -0700132/* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
133static unsigned long dirty_bytes_min = 2 * PAGE_SIZE;
134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135/* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
136static int maxolduid = 65535;
137static int minolduid;
138
139static int ngroups_max = NGROUPS_MAX;
Dan Ballard73efc032011-10-31 17:11:20 -0700140static const int cap_last_cap = CAP_LAST_CAP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141
Liu Hua80df2842014-04-07 15:38:57 -0700142/*this is needed for proc_doulongvec_minmax of sysctl_hung_task_timeout_secs */
143#ifdef CONFIG_DETECT_HUNG_TASK
144static unsigned long hung_task_timeout_max = (LONG_MAX/HZ);
145#endif
146
Dave Youngd14f1722010-02-25 20:28:57 -0500147#ifdef CONFIG_INOTIFY_USER
148#include <linux/inotify.h>
149#endif
David S. Miller72c57ed2008-09-11 23:29:54 -0700150#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151#endif
152
153#ifdef __hppa__
154extern int pwrsw_enabled;
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530155#endif
156
157#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158extern int unaligned_enabled;
159#endif
160
Jes Sorensend2b176e2006-02-28 09:42:23 -0800161#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -0800162extern int unaligned_dump_stack;
Jes Sorensend2b176e2006-02-28 09:42:23 -0800163#endif
164
Vineet Guptab6fca722013-01-09 20:06:28 +0530165#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
166extern int no_unaligned_warning;
167#endif
168
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700169#ifdef CONFIG_PROC_SYSCTL
Kees Cookf4aacea2014-06-06 14:37:19 -0700170
171#define SYSCTL_WRITES_LEGACY -1
172#define SYSCTL_WRITES_WARN 0
173#define SYSCTL_WRITES_STRICT 1
174
175static int sysctl_writes_strict = SYSCTL_WRITES_WARN;
176
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700177static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700178 void __user *buffer, size_t *lenp, loff_t *ppos);
Alexey Dobriyan8d65af72009-09-23 15:57:19 -0700179static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800180 void __user *buffer, size_t *lenp, loff_t *ppos);
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700181#endif
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700182
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700183#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -0700184static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -0700185 void __user *buffer, size_t *lenp, loff_t *ppos);
186#endif
187
Kees Cook54b50192012-07-30 14:39:18 -0700188static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
189 void __user *buffer, size_t *lenp, loff_t *ppos);
Alex Kelly046d6622012-10-04 17:15:23 -0700190#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -0700191static int proc_dostring_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#endif
Kees Cook54b50192012-07-30 14:39:18 -0700194
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700195#ifdef CONFIG_MAGIC_SYSRQ
Andy Whitcroft8c6a98b2011-01-24 09:31:38 -0800196/* Note: sysrq code uses it's own private copy */
Ben Hutchings8eaede42013-10-07 01:05:46 +0100197static int __sysrq_enabled = CONFIG_MAGIC_SYSRQ_DEFAULT_ENABLE;
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700198
Joe Perches6f8fd1d2014-06-06 14:38:08 -0700199static int sysrq_sysctl_handler(struct ctl_table *table, int write,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700200 void __user *buffer, size_t *lenp,
201 loff_t *ppos)
202{
203 int error;
204
205 error = proc_dointvec(table, write, buffer, lenp, ppos);
206 if (error)
207 return error;
208
209 if (write)
210 sysrq_toggle_support(__sysrq_enabled);
211
212 return 0;
213}
214
215#endif
216
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700217static struct ctl_table kern_table[];
218static struct ctl_table vm_table[];
219static struct ctl_table fs_table[];
220static struct ctl_table debug_table[];
221static struct ctl_table dev_table[];
222extern struct ctl_table random_table[];
Davide Libenzi7ef99642008-12-01 13:13:55 -0800223#ifdef CONFIG_EPOLL
224extern struct ctl_table epoll_table[];
225#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226
227#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
228int sysctl_legacy_va_layout;
229#endif
230
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231/* The default sysctl tables: */
232
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -0800233static struct ctl_table sysctl_base_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 .procname = "kernel",
236 .mode = 0555,
237 .child = kern_table,
238 },
239 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 .procname = "vm",
241 .mode = 0555,
242 .child = vm_table,
243 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700245 .procname = "fs",
246 .mode = 0555,
247 .child = fs_table,
248 },
249 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 .procname = "debug",
251 .mode = 0555,
252 .child = debug_table,
253 },
254 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255 .procname = "dev",
256 .mode = 0555,
257 .child = dev_table,
258 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -0700259 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260};
261
Ingo Molnar77e54a12007-07-09 18:52:00 +0200262#ifdef CONFIG_SCHED_DEBUG
Eric Dumazet73c4efd2007-12-18 15:21:13 +0100263static int min_sched_granularity_ns = 100000; /* 100 usecs */
264static int max_sched_granularity_ns = NSEC_PER_SEC; /* 1 second */
265static int min_wakeup_granularity_ns; /* 0 usecs */
266static int max_wakeup_granularity_ns = NSEC_PER_SEC; /* 1 second */
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200267#ifdef CONFIG_SMP
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100268static int min_sched_tunable_scaling = SCHED_TUNABLESCALING_NONE;
269static int max_sched_tunable_scaling = SCHED_TUNABLESCALING_END-1;
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200270#endif /* CONFIG_SMP */
271#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar77e54a12007-07-09 18:52:00 +0200272
Mel Gorman5e771902010-05-24 14:32:31 -0700273#ifdef CONFIG_COMPACTION
274static int min_extfrag_threshold;
275static int max_extfrag_threshold = 1000;
276#endif
277
Eric W. Biedermand8217f02007-10-18 03:05:22 -0700278static struct ctl_table kern_table[] = {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200279 {
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200280 .procname = "sched_child_runs_first",
281 .data = &sysctl_sched_child_runs_first,
282 .maxlen = sizeof(unsigned int),
283 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800284 .proc_handler = proc_dointvec,
Mike Galbraith2bba22c2009-09-09 15:41:37 +0200285 },
Ingo Molnar77e54a12007-07-09 18:52:00 +0200286#ifdef CONFIG_SCHED_DEBUG
287 {
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100288 .procname = "sched_min_granularity_ns",
289 .data = &sysctl_sched_min_granularity,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200290 .maxlen = sizeof(unsigned int),
291 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800292 .proc_handler = sched_proc_update_handler,
Peter Zijlstrab2be5e92007-11-09 22:39:37 +0100293 .extra1 = &min_sched_granularity_ns,
294 .extra2 = &max_sched_granularity_ns,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200295 },
296 {
Peter Zijlstra21805082007-08-25 18:41:53 +0200297 .procname = "sched_latency_ns",
298 .data = &sysctl_sched_latency,
299 .maxlen = sizeof(unsigned int),
300 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800301 .proc_handler = sched_proc_update_handler,
Peter Zijlstra21805082007-08-25 18:41:53 +0200302 .extra1 = &min_sched_granularity_ns,
303 .extra2 = &max_sched_granularity_ns,
304 },
305 {
Ingo Molnar77e54a12007-07-09 18:52:00 +0200306 .procname = "sched_wakeup_granularity_ns",
307 .data = &sysctl_sched_wakeup_granularity,
308 .maxlen = sizeof(unsigned int),
309 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800310 .proc_handler = sched_proc_update_handler,
Ingo Molnar77e54a12007-07-09 18:52:00 +0200311 .extra1 = &min_wakeup_granularity_ns,
312 .extra2 = &max_wakeup_granularity_ns,
313 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200314#ifdef CONFIG_SMP
Ingo Molnar77e54a12007-07-09 18:52:00 +0200315 {
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100316 .procname = "sched_tunable_scaling",
317 .data = &sysctl_sched_tunable_scaling,
318 .maxlen = sizeof(enum sched_tunable_scaling),
319 .mode = 0644,
Linus Torvalds702a7c72009-12-12 11:34:10 -0800320 .proc_handler = sched_proc_update_handler,
Christian Ehrhardt1983a922009-11-30 12:16:47 +0100321 .extra1 = &min_sched_tunable_scaling,
322 .extra2 = &max_sched_tunable_scaling,
Peter Zijlstra2398f2c2008-06-27 13:41:35 +0200323 },
324 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900325 .procname = "sched_migration_cost_ns",
Ingo Molnarda84d962007-10-15 17:00:18 +0200326 .data = &sysctl_sched_migration_cost,
327 .maxlen = sizeof(unsigned int),
328 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800329 .proc_handler = proc_dointvec,
Ingo Molnarda84d962007-10-15 17:00:18 +0200330 },
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100331 {
Peter Zijlstrab82d9fd2007-11-09 22:39:39 +0100332 .procname = "sched_nr_migrate",
333 .data = &sysctl_sched_nr_migrate,
334 .maxlen = sizeof(unsigned int),
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100335 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800336 .proc_handler = proc_dointvec,
Peter Zijlstrafa85ae22008-01-25 21:08:29 +0100337 },
Arun R Bharadwajcd1bb942009-04-16 12:15:34 +0530338 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900339 .procname = "sched_time_avg_ms",
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200340 .data = &sysctl_sched_time_avg,
341 .maxlen = sizeof(unsigned int),
342 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800343 .proc_handler = proc_dointvec,
Peter Zijlstrae9e92502009-09-01 10:34:37 +0200344 },
345 {
Namhyung Kimd00535d2012-08-16 11:15:30 +0900346 .procname = "sched_shares_window_ns",
Paul Turnera7a4f8a2010-11-15 15:47:06 -0800347 .data = &sysctl_sched_shares_window,
348 .maxlen = sizeof(unsigned int),
349 .mode = 0644,
350 .proc_handler = proc_dointvec,
351 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200352#endif /* CONFIG_SMP */
353#ifdef CONFIG_NUMA_BALANCING
354 {
Peter Zijlstra4b96a292012-10-25 14:16:47 +0200355 .procname = "numa_balancing_scan_delay_ms",
356 .data = &sysctl_numa_balancing_scan_delay,
357 .maxlen = sizeof(unsigned int),
358 .mode = 0644,
359 .proc_handler = proc_dointvec,
360 },
361 {
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200362 .procname = "numa_balancing_scan_period_min_ms",
363 .data = &sysctl_numa_balancing_scan_period_min,
364 .maxlen = sizeof(unsigned int),
365 .mode = 0644,
366 .proc_handler = proc_dointvec,
367 },
368 {
369 .procname = "numa_balancing_scan_period_max_ms",
370 .data = &sysctl_numa_balancing_scan_period_max,
371 .maxlen = sizeof(unsigned int),
372 .mode = 0644,
373 .proc_handler = proc_dointvec,
374 },
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200375 {
376 .procname = "numa_balancing_scan_size_mb",
377 .data = &sysctl_numa_balancing_scan_size,
378 .maxlen = sizeof(unsigned int),
379 .mode = 0644,
Kirill Tkhai64192652014-10-16 14:39:37 +0400380 .proc_handler = proc_dointvec_minmax,
381 .extra1 = &one,
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200382 },
Mel Gorman3a7053b2013-10-07 11:29:00 +0100383 {
Andi Kleen54a43d52014-01-23 15:53:13 -0800384 .procname = "numa_balancing",
385 .data = NULL, /* filled in by handler */
386 .maxlen = sizeof(unsigned int),
387 .mode = 0644,
388 .proc_handler = sysctl_numa_balancing,
389 .extra1 = &zero,
390 .extra2 = &one,
391 },
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200392#endif /* CONFIG_NUMA_BALANCING */
393#endif /* CONFIG_SCHED_DEBUG */
Ingo Molnar1799e352007-09-19 23:34:46 +0200394 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100395 .procname = "sched_rt_period_us",
396 .data = &sysctl_sched_rt_period,
397 .maxlen = sizeof(unsigned int),
398 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800399 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100400 },
401 {
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100402 .procname = "sched_rt_runtime_us",
403 .data = &sysctl_sched_rt_runtime,
404 .maxlen = sizeof(int),
405 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800406 .proc_handler = sched_rt_handler,
Peter Zijlstra9f0c1e52008-02-13 15:45:39 +0100407 },
Clark Williamsce0dbbb2013-02-07 09:47:04 -0600408 {
409 .procname = "sched_rr_timeslice_ms",
410 .data = &sched_rr_timeslice,
411 .maxlen = sizeof(int),
412 .mode = 0644,
413 .proc_handler = sched_rr_handler,
414 },
Mike Galbraith5091faa2010-11-30 14:18:03 +0100415#ifdef CONFIG_SCHED_AUTOGROUP
416 {
417 .procname = "sched_autogroup_enabled",
418 .data = &sysctl_sched_autogroup_enabled,
419 .maxlen = sizeof(unsigned int),
420 .mode = 0644,
Yong Zhang1747b212011-02-20 15:08:12 +0800421 .proc_handler = proc_dointvec_minmax,
Mike Galbraith5091faa2010-11-30 14:18:03 +0100422 .extra1 = &zero,
423 .extra2 = &one,
424 },
425#endif
Paul Turnerec12cb72011-07-21 09:43:30 -0700426#ifdef CONFIG_CFS_BANDWIDTH
427 {
428 .procname = "sched_cfs_bandwidth_slice_us",
429 .data = &sysctl_sched_cfs_bandwidth_slice,
430 .maxlen = sizeof(unsigned int),
431 .mode = 0644,
432 .proc_handler = proc_dointvec_minmax,
433 .extra1 = &one,
434 },
435#endif
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700436#ifdef CONFIG_PROVE_LOCKING
437 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700438 .procname = "prove_locking",
439 .data = &prove_locking,
440 .maxlen = sizeof(int),
441 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800442 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700443 },
444#endif
445#ifdef CONFIG_LOCK_STAT
446 {
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700447 .procname = "lock_stat",
448 .data = &lock_stat,
449 .maxlen = sizeof(int),
450 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800451 .proc_handler = proc_dointvec,
Peter Zijlstraf20786f2007-07-19 01:48:56 -0700452 },
453#endif
Ingo Molnar77e54a12007-07-09 18:52:00 +0200454 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 .procname = "panic",
456 .data = &panic_timeout,
457 .maxlen = sizeof(int),
458 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800459 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 },
Alex Kelly046d6622012-10-04 17:15:23 -0700461#ifdef CONFIG_COREDUMP
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 .procname = "core_uses_pid",
464 .data = &core_uses_pid,
465 .maxlen = sizeof(int),
466 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800467 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468 },
469 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 .procname = "core_pattern",
471 .data = core_pattern,
Dan Aloni71ce92f2007-05-16 22:11:16 -0700472 .maxlen = CORENAME_MAX_SIZE,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -0700474 .proc_handler = proc_dostring_coredump,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 },
Neil Hormana2939802009-09-23 15:56:56 -0700476 {
Neil Hormana2939802009-09-23 15:56:56 -0700477 .procname = "core_pipe_limit",
478 .data = &core_pipe_limit,
479 .maxlen = sizeof(unsigned int),
480 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800481 .proc_handler = proc_dointvec,
Neil Hormana2939802009-09-23 15:56:56 -0700482 },
Alex Kelly046d6622012-10-04 17:15:23 -0700483#endif
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800484#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 .procname = "tainted",
Andi Kleen25ddbb12008-10-15 22:01:41 -0700487 .maxlen = sizeof(long),
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800488 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800489 .proc_handler = proc_taint,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 },
Kees Cookf4aacea2014-06-06 14:37:19 -0700491 {
492 .procname = "sysctl_writes_strict",
493 .data = &sysctl_writes_strict,
494 .maxlen = sizeof(int),
495 .mode = 0644,
496 .proc_handler = proc_dointvec_minmax,
497 .extra1 = &neg_one,
498 .extra2 = &one,
499 },
Theodore Ts'o34f5a392007-02-10 01:45:24 -0800500#endif
Arjan van de Ven97455122008-01-25 21:08:34 +0100501#ifdef CONFIG_LATENCYTOP
502 {
503 .procname = "latencytop",
504 .data = &latencytop_enabled,
505 .maxlen = sizeof(int),
506 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800507 .proc_handler = proc_dointvec,
Arjan van de Ven97455122008-01-25 21:08:34 +0100508 },
509#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510#ifdef CONFIG_BLK_DEV_INITRD
511 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 .procname = "real-root-dev",
513 .data = &real_root_dev,
514 .maxlen = sizeof(int),
515 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800516 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 },
518#endif
Ingo Molnar45807a12007-07-15 23:40:10 -0700519 {
Ingo Molnar45807a12007-07-15 23:40:10 -0700520 .procname = "print-fatal-signals",
521 .data = &print_fatal_signals,
522 .maxlen = sizeof(int),
523 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800524 .proc_handler = proc_dointvec,
Ingo Molnar45807a12007-07-15 23:40:10 -0700525 },
David S. Miller72c57ed2008-09-11 23:29:54 -0700526#ifdef CONFIG_SPARC
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 .procname = "reboot-cmd",
529 .data = reboot_command,
530 .maxlen = 256,
531 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800532 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 },
534 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 .procname = "stop-a",
536 .data = &stop_a_enabled,
537 .maxlen = sizeof (int),
538 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800539 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 },
541 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 .procname = "scons-poweroff",
543 .data = &scons_pwroff,
544 .maxlen = sizeof (int),
545 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800546 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 },
548#endif
David S. Miller08714202008-11-16 23:49:24 -0800549#ifdef CONFIG_SPARC64
550 {
David S. Miller08714202008-11-16 23:49:24 -0800551 .procname = "tsb-ratio",
552 .data = &sysctl_tsb_ratio,
553 .maxlen = sizeof (int),
554 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800555 .proc_handler = proc_dointvec,
David S. Miller08714202008-11-16 23:49:24 -0800556 },
557#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558#ifdef __hppa__
559 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 .procname = "soft-power",
561 .data = &pwrsw_enabled,
562 .maxlen = sizeof (int),
563 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800564 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 },
Vineet Guptabf14e3b2013-01-18 15:12:24 +0530566#endif
567#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_ALLOW
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 .procname = "unaligned-trap",
570 .data = &unaligned_enabled,
571 .maxlen = sizeof (int),
572 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800573 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 },
575#endif
576 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 .procname = "ctrl-alt-del",
578 .data = &C_A_D,
579 .maxlen = sizeof(int),
580 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800581 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 },
Steven Rostedt606576c2008-10-06 19:06:12 -0400583#ifdef CONFIG_FUNCTION_TRACER
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200584 {
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200585 .procname = "ftrace_enabled",
586 .data = &ftrace_enabled,
587 .maxlen = sizeof(int),
588 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800589 .proc_handler = ftrace_enable_sysctl,
Steven Rostedtb0fc4942008-05-12 21:20:43 +0200590 },
591#endif
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500592#ifdef CONFIG_STACK_TRACER
593 {
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500594 .procname = "stack_tracer_enabled",
595 .data = &stack_tracer_enabled,
596 .maxlen = sizeof(int),
597 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800598 .proc_handler = stack_trace_sysctl,
Steven Rostedtf38f1d22008-12-16 23:06:40 -0500599 },
600#endif
Steven Rostedt944ac422008-10-23 19:26:08 -0400601#ifdef CONFIG_TRACING
602 {
Peter Zijlstra3299b4d2008-11-04 11:58:21 +0100603 .procname = "ftrace_dump_on_oops",
Steven Rostedt944ac422008-10-23 19:26:08 -0400604 .data = &ftrace_dump_on_oops,
605 .maxlen = sizeof(int),
606 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800607 .proc_handler = proc_dointvec,
Steven Rostedt944ac422008-10-23 19:26:08 -0400608 },
Steven Rostedt (Red Hat)de7edd32013-06-14 16:21:43 -0400609 {
610 .procname = "traceoff_on_warning",
611 .data = &__disable_trace_on_warning,
612 .maxlen = sizeof(__disable_trace_on_warning),
613 .mode = 0644,
614 .proc_handler = proc_dointvec,
615 },
Steven Rostedt (Red Hat)0daa23022014-12-12 22:27:10 -0500616 {
617 .procname = "tracepoint_printk",
618 .data = &tracepoint_printk,
619 .maxlen = sizeof(tracepoint_printk),
620 .mode = 0644,
621 .proc_handler = proc_dointvec,
622 },
Steven Rostedt944ac422008-10-23 19:26:08 -0400623#endif
Kees Cook79847542014-01-23 15:55:59 -0800624#ifdef CONFIG_KEXEC
625 {
626 .procname = "kexec_load_disabled",
627 .data = &kexec_load_disabled,
628 .maxlen = sizeof(int),
629 .mode = 0644,
630 /* only handle a transition from default "0" to "1" */
631 .proc_handler = proc_dointvec_minmax,
632 .extra1 = &one,
633 .extra2 = &one,
634 },
635#endif
Johannes Berga1ef5ad2008-07-08 19:00:17 +0200636#ifdef CONFIG_MODULES
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 .procname = "modprobe",
639 .data = &modprobe_path,
640 .maxlen = KMOD_PATH_LEN,
641 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800642 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 },
Kees Cook3d433212009-04-02 15:49:29 -0700644 {
Kees Cook3d433212009-04-02 15:49:29 -0700645 .procname = "modules_disabled",
646 .data = &modules_disabled,
647 .maxlen = sizeof(int),
648 .mode = 0644,
649 /* only handle a transition from default "0" to "1" */
Eric W. Biederman6d456112009-11-16 03:11:48 -0800650 .proc_handler = proc_dointvec_minmax,
Kees Cook3d433212009-04-02 15:49:29 -0700651 .extra1 = &one,
652 .extra2 = &one,
653 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654#endif
Michael Marineau86d56132014-04-10 14:09:31 -0700655#ifdef CONFIG_UEVENT_HELPER
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 .procname = "hotplug",
Kay Sievers312c0042005-11-16 09:00:00 +0100658 .data = &uevent_helper,
659 .maxlen = UEVENT_HELPER_PATH_LEN,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800661 .proc_handler = proc_dostring,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 },
Michael Marineau86d56132014-04-10 14:09:31 -0700663#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664#ifdef CONFIG_CHR_DEV_SG
665 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 .procname = "sg-big-buff",
667 .data = &sg_big_buff,
668 .maxlen = sizeof (int),
669 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800670 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 },
672#endif
673#ifdef CONFIG_BSD_PROCESS_ACCT
674 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 .procname = "acct",
676 .data = &acct_parm,
677 .maxlen = 3*sizeof(int),
678 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800679 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 },
681#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682#ifdef CONFIG_MAGIC_SYSRQ
683 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 .procname = "sysrq",
Ingo Molnar5d6f6472006-12-13 00:34:36 -0800685 .data = &__sysrq_enabled,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 .maxlen = sizeof (int),
687 .mode = 0644,
Dmitry Torokhov97f5f0c2010-03-21 22:31:26 -0700688 .proc_handler = sysrq_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 },
690#endif
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700691#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 .procname = "cad_pid",
Cedric Le Goater9ec52092006-10-02 02:19:00 -0700694 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 .maxlen = sizeof (int),
696 .mode = 0600,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800697 .proc_handler = proc_do_cad_pid,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 },
Randy Dunlapd6f8ff72006-10-19 23:28:34 -0700699#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 .procname = "threads-max",
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700702 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 .maxlen = sizeof(int),
704 .mode = 0644,
Heinrich Schuchardt16db3d32015-04-16 12:47:50 -0700705 .proc_handler = sysctl_max_threads,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 },
707 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 .procname = "random",
709 .mode = 0555,
710 .child = random_table,
711 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 {
Eric Paris17f60a72011-04-01 17:07:50 -0400713 .procname = "usermodehelper",
714 .mode = 0555,
715 .child = usermodehelper_table,
716 },
717 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 .procname = "overflowuid",
719 .data = &overflowuid,
720 .maxlen = sizeof(int),
721 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800722 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 .extra1 = &minolduid,
724 .extra2 = &maxolduid,
725 },
726 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 .procname = "overflowgid",
728 .data = &overflowgid,
729 .maxlen = sizeof(int),
730 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800731 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 .extra1 = &minolduid,
733 .extra2 = &maxolduid,
734 },
Martin Schwidefsky347a8dc2006-01-06 00:19:28 -0800735#ifdef CONFIG_S390
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736#ifdef CONFIG_MATHEMU
737 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 .procname = "ieee_emulation_warnings",
739 .data = &sysctl_ieee_emulation_warnings,
740 .maxlen = sizeof(int),
741 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800742 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 },
744#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 .procname = "userprocess_debug",
Heiko Carstensab3c68e2010-05-17 10:00:21 +0200747 .data = &show_unhandled_signals,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 .maxlen = sizeof(int),
749 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800750 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 },
752#endif
753 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 .procname = "pid_max",
755 .data = &pid_max,
756 .maxlen = sizeof (int),
757 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800758 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 .extra1 = &pid_max_min,
760 .extra2 = &pid_max_max,
761 },
762 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 .procname = "panic_on_oops",
764 .data = &panic_on_oops,
765 .maxlen = sizeof(int),
766 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800767 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 },
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800769#if defined CONFIG_PRINTK
770 {
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800771 .procname = "printk",
772 .data = &console_loglevel,
773 .maxlen = 4*sizeof(int),
774 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800775 .proc_handler = proc_dointvec,
Joe Perches7ef3d2f2008-02-08 04:21:25 -0800776 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 .procname = "printk_ratelimit",
Dave Young717115e2008-07-25 01:45:58 -0700779 .data = &printk_ratelimit_state.interval,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 .maxlen = sizeof(int),
781 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800782 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 },
784 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 .procname = "printk_ratelimit_burst",
Dave Young717115e2008-07-25 01:45:58 -0700786 .data = &printk_ratelimit_state.burst,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 .maxlen = sizeof(int),
788 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800789 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 },
Dave Youngaf913222009-09-22 16:43:33 -0700791 {
Dave Youngaf913222009-09-22 16:43:33 -0700792 .procname = "printk_delay",
793 .data = &printk_delay_msec,
794 .maxlen = sizeof(int),
795 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800796 .proc_handler = proc_dointvec_minmax,
Dave Youngaf913222009-09-22 16:43:33 -0700797 .extra1 = &zero,
798 .extra2 = &ten_thousand,
799 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 {
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800801 .procname = "dmesg_restrict",
802 .data = &dmesg_restrict,
803 .maxlen = sizeof(int),
804 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700805 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800806 .extra1 = &zero,
807 .extra2 = &one,
808 },
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800809 {
810 .procname = "kptr_restrict",
811 .data = &kptr_restrict,
812 .maxlen = sizeof(int),
813 .mode = 0644,
Kees Cook620f6e82012-04-04 11:40:19 -0700814 .proc_handler = proc_dointvec_minmax_sysadmin,
Dan Rosenberg455cd5a2011-01-12 16:59:41 -0800815 .extra1 = &zero,
816 .extra2 = &two,
817 },
Joe Perchesdf6e61d2010-11-15 21:17:27 -0800818#endif
Dan Rosenbergeaf06b22010-11-11 14:05:18 -0800819 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 .procname = "ngroups_max",
821 .data = &ngroups_max,
822 .maxlen = sizeof (int),
823 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800824 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 },
Dan Ballard73efc032011-10-31 17:11:20 -0700826 {
827 .procname = "cap_last_cap",
828 .data = (void *)&cap_last_cap,
829 .maxlen = sizeof(int),
830 .mode = 0444,
831 .proc_handler = proc_dointvec,
832 },
Don Zickus58687ac2010-05-07 17:11:44 -0400833#if defined(CONFIG_LOCKUP_DETECTOR)
Don Zickus504d7cf2010-02-12 17:19:19 -0500834 {
Don Zickus58687ac2010-05-07 17:11:44 -0400835 .procname = "watchdog",
Frederic Weisbecker3c00ea82013-05-19 20:45:15 +0200836 .data = &watchdog_user_enabled,
Don Zickus504d7cf2010-02-12 17:19:19 -0500837 .maxlen = sizeof (int),
838 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700839 .proc_handler = proc_watchdog,
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700840 .extra1 = &zero,
841 .extra2 = &one,
Don Zickus58687ac2010-05-07 17:11:44 -0400842 },
843 {
844 .procname = "watchdog_thresh",
Mandeep Singh Baines586692a2011-05-22 22:10:22 -0700845 .data = &watchdog_thresh,
Don Zickus58687ac2010-05-07 17:11:44 -0400846 .maxlen = sizeof(int),
847 .mode = 0644,
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700848 .proc_handler = proc_watchdog_thresh,
Li Zefana6572f82013-05-17 10:31:04 +0800849 .extra1 = &zero,
Don Zickus58687ac2010-05-07 17:11:44 -0400850 .extra2 = &sixty,
Don Zickus504d7cf2010-02-12 17:19:19 -0500851 },
Don Zickus2508ce12010-05-07 17:11:46 -0400852 {
Ulrich Obergfell195daf62015-04-14 15:44:13 -0700853 .procname = "nmi_watchdog",
854 .data = &nmi_watchdog_enabled,
855 .maxlen = sizeof (int),
856 .mode = 0644,
857 .proc_handler = proc_nmi_watchdog,
858 .extra1 = &zero,
859#if defined(CONFIG_HAVE_NMI_WATCHDOG) || defined(CONFIG_HARDLOCKUP_DETECTOR)
860 .extra2 = &one,
861#else
862 .extra2 = &zero,
863#endif
864 },
865 {
866 .procname = "soft_watchdog",
867 .data = &soft_watchdog_enabled,
868 .maxlen = sizeof (int),
869 .mode = 0644,
870 .proc_handler = proc_soft_watchdog,
871 .extra1 = &zero,
872 .extra2 = &one,
873 },
874 {
Chris Metcalffe4ba3c2015-06-24 16:55:45 -0700875 .procname = "watchdog_cpumask",
876 .data = &watchdog_cpumask_bits,
877 .maxlen = NR_CPUS,
878 .mode = 0644,
879 .proc_handler = proc_watchdog_cpumask,
880 },
881 {
Don Zickus2508ce12010-05-07 17:11:46 -0400882 .procname = "softlockup_panic",
883 .data = &softlockup_panic,
884 .maxlen = sizeof(int),
885 .mode = 0644,
886 .proc_handler = proc_dointvec_minmax,
887 .extra1 = &zero,
888 .extra2 = &one,
889 },
Aaron Tomlined235872014-06-23 13:22:05 -0700890#ifdef CONFIG_SMP
891 {
892 .procname = "softlockup_all_cpu_backtrace",
893 .data = &sysctl_softlockup_all_cpu_backtrace,
894 .maxlen = sizeof(int),
895 .mode = 0644,
896 .proc_handler = proc_dointvec_minmax,
897 .extra1 = &zero,
898 .extra2 = &one,
899 },
900#endif /* CONFIG_SMP */
Don Zickus5dc30552010-11-29 17:07:17 -0500901#endif
902#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86)
903 {
904 .procname = "unknown_nmi_panic",
905 .data = &unknown_nmi_panic,
906 .maxlen = sizeof (int),
907 .mode = 0644,
908 .proc_handler = proc_dointvec,
909 },
Don Zickus504d7cf2010-02-12 17:19:19 -0500910#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911#if defined(CONFIG_X86)
912 {
Don Zickus8da5add2006-09-26 10:52:27 +0200913 .procname = "panic_on_unrecovered_nmi",
914 .data = &panic_on_unrecovered_nmi,
915 .maxlen = sizeof(int),
916 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800917 .proc_handler = proc_dointvec,
Don Zickus8da5add2006-09-26 10:52:27 +0200918 },
919 {
Kurt Garloff5211a242009-06-24 14:32:11 -0700920 .procname = "panic_on_io_nmi",
921 .data = &panic_on_io_nmi,
922 .maxlen = sizeof(int),
923 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800924 .proc_handler = proc_dointvec,
Kurt Garloff5211a242009-06-24 14:32:11 -0700925 },
Mitsuo Hayasaka55af7792011-11-29 15:08:36 +0900926#ifdef CONFIG_DEBUG_STACKOVERFLOW
927 {
928 .procname = "panic_on_stackoverflow",
929 .data = &sysctl_panic_on_stackoverflow,
930 .maxlen = sizeof(int),
931 .mode = 0644,
932 .proc_handler = proc_dointvec,
933 },
934#endif
Kurt Garloff5211a242009-06-24 14:32:11 -0700935 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936 .procname = "bootloader_type",
937 .data = &bootloader_type,
938 .maxlen = sizeof (int),
939 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800940 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941 },
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100942 {
H. Peter Anvin50312962009-05-07 16:54:11 -0700943 .procname = "bootloader_version",
944 .data = &bootloader_version,
945 .maxlen = sizeof (int),
946 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800947 .proc_handler = proc_dointvec,
H. Peter Anvin50312962009-05-07 16:54:11 -0700948 },
949 {
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100950 .procname = "kstack_depth_to_print",
951 .data = &kstack_depth_to_print,
952 .maxlen = sizeof(int),
953 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800954 .proc_handler = proc_dointvec,
Chuck Ebbert0741f4d2006-12-07 02:14:11 +0100955 },
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100956 {
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100957 .procname = "io_delay_type",
958 .data = &io_delay_type,
959 .maxlen = sizeof(int),
960 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800961 .proc_handler = proc_dointvec,
Ingo Molnar6e7c4022008-01-30 13:30:05 +0100962 },
Linus Torvalds1da177e2005-04-16 15:20:36 -0700963#endif
Luke Yang7a9166e2006-02-20 18:28:07 -0800964#if defined(CONFIG_MMU)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700965 {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966 .procname = "randomize_va_space",
967 .data = &randomize_va_space,
968 .maxlen = sizeof(int),
969 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800970 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971 },
Luke Yang7a9166e2006-02-20 18:28:07 -0800972#endif
Martin Schwidefsky0152fb32006-01-14 13:21:00 -0800973#if defined(CONFIG_S390) && defined(CONFIG_SMP)
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700974 {
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700975 .procname = "spin_retry",
976 .data = &spin_retry,
977 .maxlen = sizeof (int),
978 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800979 .proc_handler = proc_dointvec,
Martin Schwidefsky951f22d2005-07-27 11:44:57 -0700980 },
981#endif
Len Brown673d5b42007-07-28 03:33:16 -0400982#if defined(CONFIG_ACPI_SLEEP) && defined(CONFIG_X86)
Pavel Machekc255d842006-02-20 18:27:58 -0800983 {
Pavel Machekc255d842006-02-20 18:27:58 -0800984 .procname = "acpi_video_flags",
Pavel Machek77afcf72007-07-19 01:47:41 -0700985 .data = &acpi_realmode_flags,
Pavel Machekc255d842006-02-20 18:27:58 -0800986 .maxlen = sizeof (unsigned long),
987 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800988 .proc_handler = proc_doulongvec_minmax,
Pavel Machekc255d842006-02-20 18:27:58 -0800989 },
990#endif
Vineet Guptab6fca722013-01-09 20:06:28 +0530991#ifdef CONFIG_SYSCTL_ARCH_UNALIGN_NO_WARN
Jes Sorensend2b176e2006-02-28 09:42:23 -0800992 {
Jes Sorensend2b176e2006-02-28 09:42:23 -0800993 .procname = "ignore-unaligned-usertrap",
994 .data = &no_unaligned_warning,
995 .maxlen = sizeof (int),
996 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -0800997 .proc_handler = proc_dointvec,
Jes Sorensend2b176e2006-02-28 09:42:23 -0800998 },
Vineet Guptab6fca722013-01-09 20:06:28 +0530999#endif
1000#ifdef CONFIG_IA64
Doug Chapman88fc2412009-01-15 10:38:56 -08001001 {
Doug Chapman88fc2412009-01-15 10:38:56 -08001002 .procname = "unaligned-dump-stack",
1003 .data = &unaligned_dump_stack,
1004 .maxlen = sizeof (int),
1005 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001006 .proc_handler = proc_dointvec,
Doug Chapman88fc2412009-01-15 10:38:56 -08001007 },
Jes Sorensend2b176e2006-02-28 09:42:23 -08001008#endif
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001009#ifdef CONFIG_DETECT_HUNG_TASK
1010 {
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001011 .procname = "hung_task_panic",
1012 .data = &sysctl_hung_task_panic,
1013 .maxlen = sizeof(int),
1014 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001015 .proc_handler = proc_dointvec_minmax,
Mandeep Singh Bainese162b392009-01-15 11:08:40 -08001016 .extra1 = &zero,
1017 .extra2 = &one,
1018 },
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001019 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001020 .procname = "hung_task_check_count",
1021 .data = &sysctl_hung_task_check_count,
Li Zefancd646472013-09-23 16:43:58 +08001022 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001023 .mode = 0644,
Li Zefancd646472013-09-23 16:43:58 +08001024 .proc_handler = proc_dointvec_minmax,
1025 .extra1 = &zero,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001026 },
1027 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001028 .procname = "hung_task_timeout_secs",
1029 .data = &sysctl_hung_task_timeout_secs,
Ingo Molnar90739082008-01-25 21:08:34 +01001030 .maxlen = sizeof(unsigned long),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001031 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001032 .proc_handler = proc_dohung_task_timeout_secs,
Liu Hua80df2842014-04-07 15:38:57 -07001033 .extra2 = &hung_task_timeout_max,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001034 },
1035 {
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001036 .procname = "hung_task_warnings",
1037 .data = &sysctl_hung_task_warnings,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001038 .maxlen = sizeof(int),
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001039 .mode = 0644,
Aaron Tomlin270750db2014-01-20 17:34:13 +00001040 .proc_handler = proc_dointvec_minmax,
1041 .extra1 = &neg_one,
Ingo Molnar82a1fcb2008-01-25 21:08:02 +01001042 },
Ravikiran G Thirumalaic4f3b632007-10-16 23:26:09 -07001043#endif
Andi Kleenbebfa102006-06-26 13:56:52 +02001044#ifdef CONFIG_COMPAT
1045 {
Andi Kleenbebfa102006-06-26 13:56:52 +02001046 .procname = "compat-log",
1047 .data = &compat_log,
1048 .maxlen = sizeof (int),
1049 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001050 .proc_handler = proc_dointvec,
Andi Kleenbebfa102006-06-26 13:56:52 +02001051 },
1052#endif
Ingo Molnar23f78d42006-06-27 02:54:53 -07001053#ifdef CONFIG_RT_MUTEXES
1054 {
Ingo Molnar23f78d42006-06-27 02:54:53 -07001055 .procname = "max_lock_depth",
1056 .data = &max_lock_depth,
1057 .maxlen = sizeof(int),
1058 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001059 .proc_handler = proc_dointvec,
Ingo Molnar23f78d42006-06-27 02:54:53 -07001060 },
1061#endif
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001062 {
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001063 .procname = "poweroff_cmd",
1064 .data = &poweroff_cmd,
1065 .maxlen = POWEROFF_CMD_PATH_LEN,
1066 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001067 .proc_handler = proc_dostring,
Jeremy Fitzhardinge10a0a8d2007-07-17 18:37:02 -07001068 },
David Howells0b77f5b2008-04-29 01:01:32 -07001069#ifdef CONFIG_KEYS
1070 {
David Howells0b77f5b2008-04-29 01:01:32 -07001071 .procname = "keys",
1072 .mode = 0555,
1073 .child = key_sysctls,
1074 },
1075#endif
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001076#ifdef CONFIG_PERF_EVENTS
Vince Weaveraa4a2212011-06-03 17:54:40 -04001077 /*
1078 * User-space scripts rely on the existence of this file
1079 * as a feature check for perf_events being enabled.
1080 *
1081 * So it's an ABI, do not remove!
1082 */
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001083 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001084 .procname = "perf_event_paranoid",
1085 .data = &sysctl_perf_event_paranoid,
1086 .maxlen = sizeof(sysctl_perf_event_paranoid),
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001087 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001088 .proc_handler = proc_dointvec,
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001089 },
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001090 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001091 .procname = "perf_event_mlock_kb",
1092 .data = &sysctl_perf_event_mlock,
1093 .maxlen = sizeof(sysctl_perf_event_mlock),
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001094 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001095 .proc_handler = proc_dointvec,
Peter Zijlstrac5078f72009-05-05 17:50:24 +02001096 },
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001097 {
Ingo Molnarcdd6c482009-09-21 12:02:48 +02001098 .procname = "perf_event_max_sample_rate",
1099 .data = &sysctl_perf_event_sample_rate,
1100 .maxlen = sizeof(sysctl_perf_event_sample_rate),
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001101 .mode = 0644,
Peter Zijlstra163ec432011-02-16 11:22:34 +01001102 .proc_handler = perf_proc_update_handler,
Knut Petersen723478c2013-09-25 14:29:37 +02001103 .extra1 = &one,
Peter Zijlstraa78ac322009-05-25 17:39:05 +02001104 },
Dave Hansen14c63f12013-06-21 08:51:36 -07001105 {
1106 .procname = "perf_cpu_time_max_percent",
1107 .data = &sysctl_perf_cpu_time_max_percent,
1108 .maxlen = sizeof(sysctl_perf_cpu_time_max_percent),
1109 .mode = 0644,
1110 .proc_handler = perf_cpu_time_max_percent_handler,
1111 .extra1 = &zero,
1112 .extra2 = &one_hundred,
1113 },
Peter Zijlstra1ccd1542009-04-09 10:53:45 +02001114#endif
Vegard Nossumdfec0722008-04-04 00:51:41 +02001115#ifdef CONFIG_KMEMCHECK
1116 {
Vegard Nossumdfec0722008-04-04 00:51:41 +02001117 .procname = "kmemcheck",
1118 .data = &kmemcheck_enabled,
1119 .maxlen = sizeof(int),
1120 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001121 .proc_handler = proc_dointvec,
Vegard Nossumdfec0722008-04-04 00:51:41 +02001122 },
1123#endif
Prarit Bhargava9e3961a2014-12-10 15:45:50 -08001124 {
1125 .procname = "panic_on_warn",
1126 .data = &panic_on_warn,
1127 .maxlen = sizeof(int),
1128 .mode = 0644,
1129 .proc_handler = proc_dointvec_minmax,
1130 .extra1 = &zero,
1131 .extra2 = &one,
1132 },
Thomas Gleixnerbc7a34b2015-05-26 22:50:33 +00001133#if defined(CONFIG_SMP) && defined(CONFIG_NO_HZ_COMMON)
1134 {
1135 .procname = "timer_migration",
1136 .data = &sysctl_timer_migration,
1137 .maxlen = sizeof(unsigned int),
1138 .mode = 0644,
1139 .proc_handler = timer_migration_handler,
1140 },
1141#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001142 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143};
1144
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001145static struct ctl_table vm_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001146 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147 .procname = "overcommit_memory",
1148 .data = &sysctl_overcommit_memory,
1149 .maxlen = sizeof(sysctl_overcommit_memory),
1150 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001151 .proc_handler = proc_dointvec_minmax,
1152 .extra1 = &zero,
1153 .extra2 = &two,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 },
1155 {
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001156 .procname = "panic_on_oom",
1157 .data = &sysctl_panic_on_oom,
1158 .maxlen = sizeof(sysctl_panic_on_oom),
1159 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001160 .proc_handler = proc_dointvec_minmax,
1161 .extra1 = &zero,
1162 .extra2 = &two,
KAMEZAWA Hiroyukifadd8fb2006-06-23 02:03:13 -07001163 },
1164 {
David Rientjesfe071d72007-10-16 23:25:56 -07001165 .procname = "oom_kill_allocating_task",
1166 .data = &sysctl_oom_kill_allocating_task,
1167 .maxlen = sizeof(sysctl_oom_kill_allocating_task),
1168 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001169 .proc_handler = proc_dointvec,
David Rientjesfe071d72007-10-16 23:25:56 -07001170 },
1171 {
David Rientjesfef1bdd2008-02-07 00:14:07 -08001172 .procname = "oom_dump_tasks",
1173 .data = &sysctl_oom_dump_tasks,
1174 .maxlen = sizeof(sysctl_oom_dump_tasks),
1175 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001176 .proc_handler = proc_dointvec,
David Rientjesfef1bdd2008-02-07 00:14:07 -08001177 },
1178 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179 .procname = "overcommit_ratio",
1180 .data = &sysctl_overcommit_ratio,
1181 .maxlen = sizeof(sysctl_overcommit_ratio),
1182 .mode = 0644,
Jerome Marchand49f0ce52014-01-21 15:49:14 -08001183 .proc_handler = overcommit_ratio_handler,
1184 },
1185 {
1186 .procname = "overcommit_kbytes",
1187 .data = &sysctl_overcommit_kbytes,
1188 .maxlen = sizeof(sysctl_overcommit_kbytes),
1189 .mode = 0644,
1190 .proc_handler = overcommit_kbytes_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001191 },
1192 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001193 .procname = "page-cluster",
1194 .data = &page_cluster,
1195 .maxlen = sizeof(int),
1196 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001197 .proc_handler = proc_dointvec_minmax,
1198 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001199 },
1200 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001201 .procname = "dirty_background_ratio",
1202 .data = &dirty_background_ratio,
1203 .maxlen = sizeof(dirty_background_ratio),
1204 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001205 .proc_handler = dirty_background_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206 .extra1 = &zero,
1207 .extra2 = &one_hundred,
1208 },
1209 {
David Rientjes2da02992009-01-06 14:39:31 -08001210 .procname = "dirty_background_bytes",
1211 .data = &dirty_background_bytes,
1212 .maxlen = sizeof(dirty_background_bytes),
1213 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001214 .proc_handler = dirty_background_bytes_handler,
Sven Wegenerfc3501d2009-02-11 13:04:23 -08001215 .extra1 = &one_ul,
David Rientjes2da02992009-01-06 14:39:31 -08001216 },
1217 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001218 .procname = "dirty_ratio",
1219 .data = &vm_dirty_ratio,
1220 .maxlen = sizeof(vm_dirty_ratio),
1221 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001222 .proc_handler = dirty_ratio_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001223 .extra1 = &zero,
1224 .extra2 = &one_hundred,
1225 },
1226 {
David Rientjes2da02992009-01-06 14:39:31 -08001227 .procname = "dirty_bytes",
1228 .data = &vm_dirty_bytes,
1229 .maxlen = sizeof(vm_dirty_bytes),
1230 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001231 .proc_handler = dirty_bytes_handler,
Andrea Righi9e4a5bd2009-04-30 15:08:57 -07001232 .extra1 = &dirty_bytes_min,
David Rientjes2da02992009-01-06 14:39:31 -08001233 },
1234 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001235 .procname = "dirty_writeback_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001236 .data = &dirty_writeback_interval,
1237 .maxlen = sizeof(dirty_writeback_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001239 .proc_handler = dirty_writeback_centisecs_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001240 },
1241 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001242 .procname = "dirty_expire_centisecs",
Bart Samwelf6ef9432006-03-24 03:15:48 -08001243 .data = &dirty_expire_interval,
1244 .maxlen = sizeof(dirty_expire_interval),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001245 .mode = 0644,
Petr Holasekcb16e952011-03-23 16:43:09 -07001246 .proc_handler = proc_dointvec_minmax,
1247 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001248 },
1249 {
Theodore Ts'o1efff912015-03-17 12:23:32 -04001250 .procname = "dirtytime_expire_seconds",
1251 .data = &dirtytime_expire_interval,
1252 .maxlen = sizeof(dirty_expire_interval),
1253 .mode = 0644,
1254 .proc_handler = dirtytime_interval_handler,
1255 .extra1 = &zero,
1256 },
1257 {
Wanpeng Li3965c9a2012-07-31 16:41:52 -07001258 .procname = "nr_pdflush_threads",
1259 .mode = 0444 /* read-only */,
1260 .proc_handler = pdflush_proc_obsolete,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001261 },
1262 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001263 .procname = "swappiness",
1264 .data = &vm_swappiness,
1265 .maxlen = sizeof(vm_swappiness),
1266 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001267 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001268 .extra1 = &zero,
1269 .extra2 = &one_hundred,
1270 },
1271#ifdef CONFIG_HUGETLB_PAGE
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001272 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001273 .procname = "nr_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001274 .data = NULL,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001275 .maxlen = sizeof(unsigned long),
1276 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001277 .proc_handler = hugetlb_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001278 },
1279#ifdef CONFIG_NUMA
1280 {
1281 .procname = "nr_hugepages_mempolicy",
1282 .data = NULL,
1283 .maxlen = sizeof(unsigned long),
1284 .mode = 0644,
1285 .proc_handler = &hugetlb_mempolicy_sysctl_handler,
Lee Schermerhorn06808b02009-12-14 17:58:21 -08001286 },
1287#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001288 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001289 .procname = "hugetlb_shm_group",
1290 .data = &sysctl_hugetlb_shm_group,
1291 .maxlen = sizeof(gid_t),
1292 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001293 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001294 },
Mel Gorman396faf02007-07-17 04:03:13 -07001295 {
Mel Gorman396faf02007-07-17 04:03:13 -07001296 .procname = "hugepages_treat_as_movable",
1297 .data = &hugepages_treat_as_movable,
1298 .maxlen = sizeof(int),
1299 .mode = 0644,
Naoya Horiguchi86cdb462013-09-11 14:22:13 -07001300 .proc_handler = proc_dointvec,
Mel Gorman396faf02007-07-17 04:03:13 -07001301 },
Adam Litke54f9f802007-10-16 01:26:20 -07001302 {
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001303 .procname = "nr_overcommit_hugepages",
Andi Kleene5ff2152008-07-23 21:27:42 -07001304 .data = NULL,
1305 .maxlen = sizeof(unsigned long),
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001306 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001307 .proc_handler = hugetlb_overcommit_handler,
Nishanth Aravamudand1c3fb12007-12-17 16:20:12 -08001308 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001309#endif
1310 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001311 .procname = "lowmem_reserve_ratio",
1312 .data = &sysctl_lowmem_reserve_ratio,
1313 .maxlen = sizeof(sysctl_lowmem_reserve_ratio),
1314 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001315 .proc_handler = lowmem_reserve_ratio_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001316 },
1317 {
Andrew Morton9d0243b2006-01-08 01:00:39 -08001318 .procname = "drop_caches",
1319 .data = &sysctl_drop_caches,
1320 .maxlen = sizeof(int),
1321 .mode = 0644,
1322 .proc_handler = drop_caches_sysctl_handler,
Petr Holasekcb16e952011-03-23 16:43:09 -07001323 .extra1 = &one,
Dave Hansen5509a5d2014-04-03 14:48:19 -07001324 .extra2 = &four,
Andrew Morton9d0243b2006-01-08 01:00:39 -08001325 },
Mel Gorman76ab0f52010-05-24 14:32:28 -07001326#ifdef CONFIG_COMPACTION
1327 {
1328 .procname = "compact_memory",
1329 .data = &sysctl_compact_memory,
1330 .maxlen = sizeof(int),
1331 .mode = 0200,
1332 .proc_handler = sysctl_compaction_handler,
1333 },
Mel Gorman5e771902010-05-24 14:32:31 -07001334 {
1335 .procname = "extfrag_threshold",
1336 .data = &sysctl_extfrag_threshold,
1337 .maxlen = sizeof(int),
1338 .mode = 0644,
1339 .proc_handler = sysctl_extfrag_handler,
1340 .extra1 = &min_extfrag_threshold,
1341 .extra2 = &max_extfrag_threshold,
1342 },
Eric B Munson5bbe3542015-04-15 16:13:20 -07001343 {
1344 .procname = "compact_unevictable_allowed",
1345 .data = &sysctl_compact_unevictable_allowed,
1346 .maxlen = sizeof(int),
1347 .mode = 0644,
1348 .proc_handler = proc_dointvec,
1349 .extra1 = &zero,
1350 .extra2 = &one,
1351 },
Mel Gorman5e771902010-05-24 14:32:31 -07001352
Mel Gorman76ab0f52010-05-24 14:32:28 -07001353#endif /* CONFIG_COMPACTION */
Andrew Morton9d0243b2006-01-08 01:00:39 -08001354 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001355 .procname = "min_free_kbytes",
1356 .data = &min_free_kbytes,
1357 .maxlen = sizeof(min_free_kbytes),
1358 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001359 .proc_handler = min_free_kbytes_sysctl_handler,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001360 .extra1 = &zero,
1361 },
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001362 {
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001363 .procname = "percpu_pagelist_fraction",
1364 .data = &percpu_pagelist_fraction,
1365 .maxlen = sizeof(percpu_pagelist_fraction),
1366 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001367 .proc_handler = percpu_pagelist_fraction_sysctl_handler,
David Rientjes7cd2b0a2014-06-23 13:22:04 -07001368 .extra1 = &zero,
Rohit Seth8ad4b1f2006-01-08 01:00:40 -08001369 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001370#ifdef CONFIG_MMU
1371 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001372 .procname = "max_map_count",
1373 .data = &sysctl_max_map_count,
1374 .maxlen = sizeof(sysctl_max_map_count),
1375 .mode = 0644,
WANG Cong3e261202009-12-17 15:27:05 -08001376 .proc_handler = proc_dointvec_minmax,
Amerigo Wang70da2342009-12-14 17:59:52 -08001377 .extra1 = &zero,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001378 },
Paul Mundtdd8632a2009-01-08 12:04:47 +00001379#else
1380 {
Paul Mundtdd8632a2009-01-08 12:04:47 +00001381 .procname = "nr_trim_pages",
1382 .data = &sysctl_nr_trim_pages,
1383 .maxlen = sizeof(sysctl_nr_trim_pages),
1384 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001385 .proc_handler = proc_dointvec_minmax,
Paul Mundtdd8632a2009-01-08 12:04:47 +00001386 .extra1 = &zero,
1387 },
Linus Torvalds1da177e2005-04-16 15:20:36 -07001388#endif
1389 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390 .procname = "laptop_mode",
1391 .data = &laptop_mode,
1392 .maxlen = sizeof(laptop_mode),
1393 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001394 .proc_handler = proc_dointvec_jiffies,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001395 },
1396 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001397 .procname = "block_dump",
1398 .data = &block_dump,
1399 .maxlen = sizeof(block_dump),
1400 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001401 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001402 .extra1 = &zero,
1403 },
1404 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001405 .procname = "vfs_cache_pressure",
1406 .data = &sysctl_vfs_cache_pressure,
1407 .maxlen = sizeof(sysctl_vfs_cache_pressure),
1408 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001409 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001410 .extra1 = &zero,
1411 },
1412#ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
1413 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001414 .procname = "legacy_va_layout",
1415 .data = &sysctl_legacy_va_layout,
1416 .maxlen = sizeof(sysctl_legacy_va_layout),
1417 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001418 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001419 .extra1 = &zero,
1420 },
1421#endif
Christoph Lameter17436602006-01-18 17:42:32 -08001422#ifdef CONFIG_NUMA
1423 {
Christoph Lameter17436602006-01-18 17:42:32 -08001424 .procname = "zone_reclaim_mode",
1425 .data = &zone_reclaim_mode,
1426 .maxlen = sizeof(zone_reclaim_mode),
1427 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001428 .proc_handler = proc_dointvec,
Christoph Lameterc84db232006-02-01 03:05:29 -08001429 .extra1 = &zero,
Christoph Lameter17436602006-01-18 17:42:32 -08001430 },
Christoph Lameter96146342006-07-03 00:24:13 -07001431 {
Christoph Lameter96146342006-07-03 00:24:13 -07001432 .procname = "min_unmapped_ratio",
1433 .data = &sysctl_min_unmapped_ratio,
1434 .maxlen = sizeof(sysctl_min_unmapped_ratio),
1435 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001436 .proc_handler = sysctl_min_unmapped_ratio_sysctl_handler,
Christoph Lameter96146342006-07-03 00:24:13 -07001437 .extra1 = &zero,
1438 .extra2 = &one_hundred,
1439 },
Christoph Lameter0ff38492006-09-25 23:31:52 -07001440 {
Christoph Lameter0ff38492006-09-25 23:31:52 -07001441 .procname = "min_slab_ratio",
1442 .data = &sysctl_min_slab_ratio,
1443 .maxlen = sizeof(sysctl_min_slab_ratio),
1444 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001445 .proc_handler = sysctl_min_slab_ratio_sysctl_handler,
Christoph Lameter0ff38492006-09-25 23:31:52 -07001446 .extra1 = &zero,
1447 .extra2 = &one_hundred,
1448 },
Christoph Lameter17436602006-01-18 17:42:32 -08001449#endif
Christoph Lameter77461ab2007-05-09 02:35:13 -07001450#ifdef CONFIG_SMP
1451 {
Christoph Lameter77461ab2007-05-09 02:35:13 -07001452 .procname = "stat_interval",
1453 .data = &sysctl_stat_interval,
1454 .maxlen = sizeof(sysctl_stat_interval),
1455 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001456 .proc_handler = proc_dointvec_jiffies,
Christoph Lameter77461ab2007-05-09 02:35:13 -07001457 },
1458#endif
David Howells6e141542009-12-15 19:27:45 +00001459#ifdef CONFIG_MMU
Eric Parised032182007-06-28 15:55:21 -04001460 {
Eric Parised032182007-06-28 15:55:21 -04001461 .procname = "mmap_min_addr",
Eric Paris788084a2009-07-31 12:54:11 -04001462 .data = &dac_mmap_min_addr,
1463 .maxlen = sizeof(unsigned long),
Eric Parised032182007-06-28 15:55:21 -04001464 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001465 .proc_handler = mmap_min_addr_handler,
Eric Parised032182007-06-28 15:55:21 -04001466 },
David Howells6e141542009-12-15 19:27:45 +00001467#endif
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001468#ifdef CONFIG_NUMA
1469 {
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001470 .procname = "numa_zonelist_order",
1471 .data = &numa_zonelist_order,
1472 .maxlen = NUMA_ZONELIST_ORDER_LEN,
1473 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001474 .proc_handler = numa_zonelist_order_handler,
KAMEZAWA Hiroyukif0c0b2b2007-07-15 23:38:01 -07001475 },
1476#endif
Al Viro2b8232c2007-10-13 08:16:04 +01001477#if (defined(CONFIG_X86_32) && !defined(CONFIG_UML))|| \
Paul Mundt5c36e652007-03-01 10:07:42 +09001478 (defined(CONFIG_SUPERH) && defined(CONFIG_VSYSCALL))
Ingo Molnare6e54942006-06-27 02:53:50 -07001479 {
Ingo Molnare6e54942006-06-27 02:53:50 -07001480 .procname = "vdso_enabled",
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001481#ifdef CONFIG_X86_32
1482 .data = &vdso32_enabled,
1483 .maxlen = sizeof(vdso32_enabled),
1484#else
Ingo Molnare6e54942006-06-27 02:53:50 -07001485 .data = &vdso_enabled,
1486 .maxlen = sizeof(vdso_enabled),
Andy Lutomirski3d7ee962014-05-05 12:19:32 -07001487#endif
Ingo Molnare6e54942006-06-27 02:53:50 -07001488 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001489 .proc_handler = proc_dointvec,
Ingo Molnare6e54942006-06-27 02:53:50 -07001490 .extra1 = &zero,
1491 },
1492#endif
Bron Gondwana195cf452008-02-04 22:29:20 -08001493#ifdef CONFIG_HIGHMEM
1494 {
Bron Gondwana195cf452008-02-04 22:29:20 -08001495 .procname = "highmem_is_dirtyable",
1496 .data = &vm_highmem_is_dirtyable,
1497 .maxlen = sizeof(vm_highmem_is_dirtyable),
1498 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001499 .proc_handler = proc_dointvec_minmax,
Bron Gondwana195cf452008-02-04 22:29:20 -08001500 .extra1 = &zero,
1501 .extra2 = &one,
1502 },
1503#endif
Andi Kleen6a460792009-09-16 11:50:15 +02001504#ifdef CONFIG_MEMORY_FAILURE
1505 {
Andi Kleen6a460792009-09-16 11:50:15 +02001506 .procname = "memory_failure_early_kill",
1507 .data = &sysctl_memory_failure_early_kill,
1508 .maxlen = sizeof(sysctl_memory_failure_early_kill),
1509 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001510 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001511 .extra1 = &zero,
1512 .extra2 = &one,
1513 },
1514 {
Andi Kleen6a460792009-09-16 11:50:15 +02001515 .procname = "memory_failure_recovery",
1516 .data = &sysctl_memory_failure_recovery,
1517 .maxlen = sizeof(sysctl_memory_failure_recovery),
1518 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001519 .proc_handler = proc_dointvec_minmax,
Andi Kleen6a460792009-09-16 11:50:15 +02001520 .extra1 = &zero,
1521 .extra2 = &one,
1522 },
1523#endif
Andrew Shewmakerc9b1d092013-04-29 15:08:10 -07001524 {
1525 .procname = "user_reserve_kbytes",
1526 .data = &sysctl_user_reserve_kbytes,
1527 .maxlen = sizeof(sysctl_user_reserve_kbytes),
1528 .mode = 0644,
1529 .proc_handler = proc_doulongvec_minmax,
1530 },
Andrew Shewmaker4eeab4f2013-04-29 15:08:11 -07001531 {
1532 .procname = "admin_reserve_kbytes",
1533 .data = &sysctl_admin_reserve_kbytes,
1534 .maxlen = sizeof(sysctl_admin_reserve_kbytes),
1535 .mode = 0644,
1536 .proc_handler = proc_doulongvec_minmax,
1537 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001538 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001539};
1540
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001541#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001542static struct ctl_table binfmt_misc_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001543 { }
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001544};
1545#endif
1546
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001547static struct ctl_table fs_table[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001548 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001549 .procname = "inode-nr",
1550 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001551 .maxlen = 2*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001552 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001553 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001554 },
1555 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001556 .procname = "inode-state",
1557 .data = &inodes_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001558 .maxlen = 7*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559 .mode = 0444,
Dave Chinnercffbc8a2010-10-23 05:03:02 -04001560 .proc_handler = proc_nr_inodes,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001561 },
1562 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563 .procname = "file-nr",
1564 .data = &files_stat,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001565 .maxlen = sizeof(files_stat),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001566 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001567 .proc_handler = proc_nr_files,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001568 },
1569 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001570 .procname = "file-max",
1571 .data = &files_stat.max_files,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001572 .maxlen = sizeof(files_stat.max_files),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001573 .mode = 0644,
Eric Dumazet518de9b2010-10-26 14:22:44 -07001574 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001575 },
1576 {
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001577 .procname = "nr_open",
1578 .data = &sysctl_nr_open,
1579 .maxlen = sizeof(int),
1580 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001581 .proc_handler = proc_dointvec_minmax,
Al Viroeceea0b2008-05-10 10:08:32 -04001582 .extra1 = &sysctl_nr_open_min,
1583 .extra2 = &sysctl_nr_open_max,
Eric Dumazet9cfe0152008-02-06 01:37:16 -08001584 },
1585 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001586 .procname = "dentry-state",
1587 .data = &dentry_stat,
Glauber Costa3942c072013-08-28 10:17:53 +10001588 .maxlen = 6*sizeof(long),
Linus Torvalds1da177e2005-04-16 15:20:36 -07001589 .mode = 0444,
Christoph Hellwig312d3ca2010-10-10 05:36:23 -04001590 .proc_handler = proc_nr_dentry,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001591 },
1592 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001593 .procname = "overflowuid",
1594 .data = &fs_overflowuid,
1595 .maxlen = sizeof(int),
1596 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001597 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001598 .extra1 = &minolduid,
1599 .extra2 = &maxolduid,
1600 },
1601 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001602 .procname = "overflowgid",
1603 .data = &fs_overflowgid,
1604 .maxlen = sizeof(int),
1605 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001606 .proc_handler = proc_dointvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001607 .extra1 = &minolduid,
1608 .extra2 = &maxolduid,
1609 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001610#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001611 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001612 .procname = "leases-enable",
1613 .data = &leases_enable,
1614 .maxlen = sizeof(int),
1615 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001616 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001617 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001618#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001619#ifdef CONFIG_DNOTIFY
1620 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001621 .procname = "dir-notify-enable",
1622 .data = &dir_notify_enable,
1623 .maxlen = sizeof(int),
1624 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001625 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001626 },
1627#endif
1628#ifdef CONFIG_MMU
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001629#ifdef CONFIG_FILE_LOCKING
Linus Torvalds1da177e2005-04-16 15:20:36 -07001630 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001631 .procname = "lease-break-time",
1632 .data = &lease_break_time,
1633 .maxlen = sizeof(int),
1634 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001635 .proc_handler = proc_dointvec,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001636 },
Thomas Petazzonibfcd17a2008-08-06 15:12:22 +02001637#endif
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001638#ifdef CONFIG_AIO
Linus Torvalds1da177e2005-04-16 15:20:36 -07001639 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001640 .procname = "aio-nr",
1641 .data = &aio_nr,
1642 .maxlen = sizeof(aio_nr),
1643 .mode = 0444,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001644 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001645 },
1646 {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001647 .procname = "aio-max-nr",
1648 .data = &aio_max_nr,
1649 .maxlen = sizeof(aio_max_nr),
1650 .mode = 0644,
Eric W. Biederman6d456112009-11-16 03:11:48 -08001651 .proc_handler = proc_doulongvec_minmax,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001652 },
Thomas Petazzoniebf3f092008-10-15 22:05:12 -07001653#endif /* CONFIG_AIO */
Amy Griffis2d9048e2006-06-01 13:10:59 -07001654#ifdef CONFIG_INOTIFY_USER
Robert Love0399cb02005-07-13 12:38:18 -04001655 {
Robert Love0399cb02005-07-13 12:38:18 -04001656 .procname = "inotify",
1657 .mode = 0555,
1658 .child = inotify_table,
1659 },
1660#endif
Davide Libenzi7ef99642008-12-01 13:13:55 -08001661#ifdef CONFIG_EPOLL
1662 {
1663 .procname = "epoll",
1664 .mode = 0555,
1665 .child = epoll_table,
1666 },
1667#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001668#endif
Alan Coxd6e71142005-06-23 00:09:43 -07001669 {
Kees Cook800179c2012-07-25 17:29:07 -07001670 .procname = "protected_symlinks",
1671 .data = &sysctl_protected_symlinks,
1672 .maxlen = sizeof(int),
1673 .mode = 0600,
1674 .proc_handler = proc_dointvec_minmax,
1675 .extra1 = &zero,
1676 .extra2 = &one,
1677 },
1678 {
1679 .procname = "protected_hardlinks",
1680 .data = &sysctl_protected_hardlinks,
1681 .maxlen = sizeof(int),
1682 .mode = 0600,
1683 .proc_handler = proc_dointvec_minmax,
1684 .extra1 = &zero,
1685 .extra2 = &one,
1686 },
1687 {
Alan Coxd6e71142005-06-23 00:09:43 -07001688 .procname = "suid_dumpable",
1689 .data = &suid_dumpable,
1690 .maxlen = sizeof(int),
1691 .mode = 0644,
Kees Cook54b50192012-07-30 14:39:18 -07001692 .proc_handler = proc_dointvec_minmax_coredump,
Matthew Wilcox8e654fb2009-04-02 16:58:33 -07001693 .extra1 = &zero,
1694 .extra2 = &two,
Alan Coxd6e71142005-06-23 00:09:43 -07001695 },
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001696#if defined(CONFIG_BINFMT_MISC) || defined(CONFIG_BINFMT_MISC_MODULE)
1697 {
Eric W. Biederman2abc26f2007-02-14 00:34:07 -08001698 .procname = "binfmt_misc",
1699 .mode = 0555,
1700 .child = binfmt_misc_table,
1701 },
1702#endif
Jens Axboeb492e952010-05-19 21:03:16 +02001703 {
Jens Axboeff9da692010-06-03 14:54:39 +02001704 .procname = "pipe-max-size",
1705 .data = &pipe_max_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001706 .maxlen = sizeof(int),
1707 .mode = 0644,
Jens Axboeff9da692010-06-03 14:54:39 +02001708 .proc_handler = &pipe_proc_fn,
1709 .extra1 = &pipe_min_size,
Jens Axboeb492e952010-05-19 21:03:16 +02001710 },
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001711 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001712};
1713
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001714static struct ctl_table debug_table[] = {
Catalin Marinas7ac57a82012-10-08 16:28:16 -07001715#ifdef CONFIG_SYSCTL_EXCEPTION_TRACE
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001716 {
Masoud Asgharifard Sharbianiabd4f752007-07-22 11:12:28 +02001717 .procname = "exception-trace",
1718 .data = &show_unhandled_signals,
1719 .maxlen = sizeof(int),
1720 .mode = 0644,
1721 .proc_handler = proc_dointvec
1722 },
1723#endif
Masami Hiramatsub2be84d2010-02-25 08:34:15 -05001724#if defined(CONFIG_OPTPROBES)
1725 {
1726 .procname = "kprobes-optimization",
1727 .data = &sysctl_kprobes_optimization,
1728 .maxlen = sizeof(int),
1729 .mode = 0644,
1730 .proc_handler = proc_kprobes_optimization_handler,
1731 .extra1 = &zero,
1732 .extra2 = &one,
1733 },
1734#endif
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001735 { }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001736};
1737
Eric W. Biedermand8217f02007-10-18 03:05:22 -07001738static struct ctl_table dev_table[] = {
Eric W. Biederman6fce56e2009-04-03 02:30:53 -07001739 { }
Robert Love0eeca282005-07-12 17:06:03 -04001740};
Linus Torvalds1da177e2005-04-16 15:20:36 -07001741
Eric W. Biedermande4e83bd2012-01-06 03:34:20 -08001742int __init sysctl_init(void)
Al Viro330d57f2005-11-04 10:18:40 +00001743{
Steven Rostedtfd4b6162012-07-30 14:42:48 -07001744 struct ctl_table_header *hdr;
1745
1746 hdr = register_sysctl_table(sysctl_base_table);
1747 kmemleak_not_leak(hdr);
Eric W. Biedermand912b0c2007-02-14 00:34:13 -08001748 return 0;
1749}
1750
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001751#endif /* CONFIG_SYSCTL */
1752
Linus Torvalds1da177e2005-04-16 15:20:36 -07001753/*
1754 * /proc/sys support
1755 */
1756
Eric W. Biedermanb89a8172006-09-27 01:51:04 -07001757#ifdef CONFIG_PROC_SYSCTL
Linus Torvalds1da177e2005-04-16 15:20:36 -07001758
Kees Cookf8808302014-06-06 14:37:17 -07001759static int _proc_do_string(char *data, int maxlen, int write,
1760 char __user *buffer,
Adrian Bunkb1ba4dd2006-10-02 02:18:05 -07001761 size_t *lenp, loff_t *ppos)
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001762{
1763 size_t len;
1764 char __user *p;
1765 char c;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001766
1767 if (!data || !maxlen || !*lenp) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001768 *lenp = 0;
1769 return 0;
1770 }
Oleg Nesterov8d060872007-02-10 01:46:38 -08001771
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001772 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07001773 if (sysctl_writes_strict == SYSCTL_WRITES_STRICT) {
1774 /* Only continue writes not past the end of buffer. */
1775 len = strlen(data);
1776 if (len > maxlen - 1)
1777 len = maxlen - 1;
1778
1779 if (*ppos > len)
1780 return 0;
1781 len = *ppos;
1782 } else {
1783 /* Start writing from beginning of buffer. */
1784 len = 0;
1785 }
1786
Kees Cook2ca9bb42014-06-06 14:37:18 -07001787 *ppos += *lenp;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001788 p = buffer;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001789 while ((p - buffer) < *lenp && len < maxlen - 1) {
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001790 if (get_user(c, p++))
1791 return -EFAULT;
1792 if (c == 0 || c == '\n')
1793 break;
Kees Cook2ca9bb42014-06-06 14:37:18 -07001794 data[len++] = c;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001795 }
Kees Cookf8808302014-06-06 14:37:17 -07001796 data[len] = 0;
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001797 } else {
1798 len = strlen(data);
1799 if (len > maxlen)
1800 len = maxlen;
Oleg Nesterov8d060872007-02-10 01:46:38 -08001801
1802 if (*ppos > len) {
1803 *lenp = 0;
1804 return 0;
1805 }
1806
1807 data += *ppos;
1808 len -= *ppos;
1809
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001810 if (len > *lenp)
1811 len = *lenp;
1812 if (len)
Kees Cookf8808302014-06-06 14:37:17 -07001813 if (copy_to_user(buffer, data, len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001814 return -EFAULT;
1815 if (len < *lenp) {
Kees Cookf8808302014-06-06 14:37:17 -07001816 if (put_user('\n', buffer + len))
Sam Vilainf5dd3d62006-10-02 02:18:04 -07001817 return -EFAULT;
1818 len++;
1819 }
1820 *lenp = len;
1821 *ppos += len;
1822 }
1823 return 0;
1824}
1825
Kees Cookf4aacea2014-06-06 14:37:19 -07001826static void warn_sysctl_write(struct ctl_table *table)
1827{
1828 pr_warn_once("%s wrote to %s when file position was not 0!\n"
1829 "This will not be supported in the future. To silence this\n"
1830 "warning, set kernel.sysctl_writes_strict = -1\n",
1831 current->comm, table->procname);
1832}
1833
Linus Torvalds1da177e2005-04-16 15:20:36 -07001834/**
1835 * proc_dostring - read a string sysctl
1836 * @table: the sysctl table
1837 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07001838 * @buffer: the user buffer
1839 * @lenp: the size of the user buffer
1840 * @ppos: file position
1841 *
1842 * Reads/writes a string from/to the user buffer. If the kernel
1843 * buffer provided is not large enough to hold the string, the
1844 * string is truncated. The copied string is %NULL-terminated.
1845 * If the string is being read by the user process, it is copied
1846 * and a newline '\n' is added. It is truncated if the buffer is
1847 * not large enough.
1848 *
1849 * Returns 0 on success.
1850 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07001851int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001852 void __user *buffer, size_t *lenp, loff_t *ppos)
1853{
Kees Cookf4aacea2014-06-06 14:37:19 -07001854 if (write && *ppos && sysctl_writes_strict == SYSCTL_WRITES_WARN)
1855 warn_sysctl_write(table);
1856
Kees Cookf8808302014-06-06 14:37:17 -07001857 return _proc_do_string((char *)(table->data), table->maxlen, write,
1858 (char __user *)buffer, lenp, ppos);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001859}
1860
Amerigo Wang00b7c332010-05-05 00:26:45 +00001861static size_t proc_skip_spaces(char **buf)
1862{
1863 size_t ret;
1864 char *tmp = skip_spaces(*buf);
1865 ret = tmp - *buf;
1866 *buf = tmp;
1867 return ret;
1868}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869
Octavian Purdila9f977fb2010-05-05 00:26:55 +00001870static void proc_skip_char(char **buf, size_t *size, const char v)
1871{
1872 while (*size) {
1873 if (**buf != v)
1874 break;
1875 (*size)--;
1876 (*buf)++;
1877 }
1878}
1879
Amerigo Wang00b7c332010-05-05 00:26:45 +00001880#define TMPBUFLEN 22
1881/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001882 * proc_get_long - reads an ASCII formatted integer from a user buffer
Amerigo Wang00b7c332010-05-05 00:26:45 +00001883 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001884 * @buf: a kernel buffer
1885 * @size: size of the kernel buffer
1886 * @val: this is where the number will be stored
1887 * @neg: set to %TRUE if number is negative
1888 * @perm_tr: a vector which contains the allowed trailers
1889 * @perm_tr_len: size of the perm_tr vector
1890 * @tr: pointer to store the trailer character
Amerigo Wang00b7c332010-05-05 00:26:45 +00001891 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001892 * In case of success %0 is returned and @buf and @size are updated with
1893 * the amount of bytes read. If @tr is non-NULL and a trailing
1894 * character exists (size is non-zero after returning from this
1895 * function), @tr is updated with the trailing character.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001896 */
1897static int proc_get_long(char **buf, size_t *size,
1898 unsigned long *val, bool *neg,
1899 const char *perm_tr, unsigned perm_tr_len, char *tr)
1900{
1901 int len;
1902 char *p, tmp[TMPBUFLEN];
1903
1904 if (!*size)
1905 return -EINVAL;
1906
1907 len = *size;
1908 if (len > TMPBUFLEN - 1)
1909 len = TMPBUFLEN - 1;
1910
1911 memcpy(tmp, *buf, len);
1912
1913 tmp[len] = 0;
1914 p = tmp;
1915 if (*p == '-' && *size > 1) {
1916 *neg = true;
1917 p++;
1918 } else
1919 *neg = false;
1920 if (!isdigit(*p))
1921 return -EINVAL;
1922
1923 *val = simple_strtoul(p, &p, 0);
1924
1925 len = p - tmp;
1926
1927 /* We don't know if the next char is whitespace thus we may accept
1928 * invalid integers (e.g. 1234...a) or two integers instead of one
1929 * (e.g. 123...1). So lets not allow such large numbers. */
1930 if (len == TMPBUFLEN - 1)
1931 return -EINVAL;
1932
1933 if (len < *size && perm_tr_len && !memchr(perm_tr, *p, perm_tr_len))
1934 return -EINVAL;
1935
1936 if (tr && (len < *size))
1937 *tr = *p;
1938
1939 *buf += len;
1940 *size -= len;
1941
1942 return 0;
1943}
1944
1945/**
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001946 * proc_put_long - converts an integer to a decimal ASCII formatted string
Amerigo Wang00b7c332010-05-05 00:26:45 +00001947 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001948 * @buf: the user buffer
1949 * @size: the size of the user buffer
1950 * @val: the integer to be converted
1951 * @neg: sign of the number, %TRUE for negative
Amerigo Wang00b7c332010-05-05 00:26:45 +00001952 *
Randy Dunlap0fc377b2010-05-21 11:29:53 -07001953 * In case of success %0 is returned and @buf and @size are updated with
1954 * the amount of bytes written.
Amerigo Wang00b7c332010-05-05 00:26:45 +00001955 */
1956static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
1957 bool neg)
1958{
1959 int len;
1960 char tmp[TMPBUFLEN], *p = tmp;
1961
1962 sprintf(p, "%s%lu", neg ? "-" : "", val);
1963 len = strlen(tmp);
1964 if (len > *size)
1965 len = *size;
1966 if (copy_to_user(*buf, tmp, len))
1967 return -EFAULT;
1968 *size -= len;
1969 *buf += len;
1970 return 0;
1971}
1972#undef TMPBUFLEN
1973
1974static int proc_put_char(void __user **buf, size_t *size, char c)
1975{
1976 if (*size) {
1977 char __user **buffer = (char __user **)buf;
1978 if (put_user(c, *buffer))
1979 return -EFAULT;
1980 (*size)--, (*buffer)++;
1981 *buf = *buffer;
1982 }
1983 return 0;
1984}
1985
1986static int do_proc_dointvec_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07001987 int *valp,
1988 int write, void *data)
1989{
1990 if (write) {
Heinrich Schuchardt230633d2015-04-16 12:48:07 -07001991 if (*negp) {
1992 if (*lvalp > (unsigned long) INT_MAX + 1)
1993 return -EINVAL;
1994 *valp = -*lvalp;
1995 } else {
1996 if (*lvalp > (unsigned long) INT_MAX)
1997 return -EINVAL;
1998 *valp = *lvalp;
1999 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002000 } else {
2001 int val = *valp;
2002 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002003 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002004 *lvalp = (unsigned long)-val;
2005 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002006 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002007 *lvalp = (unsigned long)val;
2008 }
2009 }
2010 return 0;
2011}
2012
Amerigo Wang00b7c332010-05-05 00:26:45 +00002013static const char proc_wspace_sep[] = { ' ', '\t', '\n' };
2014
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002015static int __do_proc_dointvec(void *tbl_data, struct ctl_table *table,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002016 int write, void __user *buffer,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002017 size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002018 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002019 int write, void *data),
2020 void *data)
2021{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002022 int *i, vleft, first = 1, err = 0;
2023 unsigned long page = 0;
2024 size_t left;
2025 char *kbuf;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002026
Amerigo Wang00b7c332010-05-05 00:26:45 +00002027 if (!tbl_data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002028 *lenp = 0;
2029 return 0;
2030 }
2031
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002032 i = (int *) tbl_data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002033 vleft = table->maxlen / sizeof(*i);
2034 left = *lenp;
2035
2036 if (!conv)
2037 conv = do_proc_dointvec_conv;
2038
Linus Torvalds1da177e2005-04-16 15:20:36 -07002039 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002040 if (*ppos) {
2041 switch (sysctl_writes_strict) {
2042 case SYSCTL_WRITES_STRICT:
2043 goto out;
2044 case SYSCTL_WRITES_WARN:
2045 warn_sysctl_write(table);
2046 break;
2047 default:
2048 break;
2049 }
2050 }
2051
Amerigo Wang00b7c332010-05-05 00:26:45 +00002052 if (left > PAGE_SIZE - 1)
2053 left = PAGE_SIZE - 1;
2054 page = __get_free_page(GFP_TEMPORARY);
2055 kbuf = (char *) page;
2056 if (!kbuf)
2057 return -ENOMEM;
2058 if (copy_from_user(kbuf, buffer, left)) {
2059 err = -EFAULT;
2060 goto free;
2061 }
2062 kbuf[left] = 0;
2063 }
2064
2065 for (; left && vleft--; i++, first=0) {
2066 unsigned long lval;
2067 bool neg;
2068
2069 if (write) {
2070 left -= proc_skip_spaces(&kbuf);
2071
J. R. Okajima563b0462010-05-25 16:10:14 -07002072 if (!left)
2073 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002074 err = proc_get_long(&kbuf, &left, &lval, &neg,
2075 proc_wspace_sep,
2076 sizeof(proc_wspace_sep), NULL);
2077 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002078 break;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002079 if (conv(&neg, &lval, i, 1, data)) {
2080 err = -EINVAL;
2081 break;
2082 }
2083 } else {
2084 if (conv(&neg, &lval, i, 0, data)) {
2085 err = -EINVAL;
2086 break;
2087 }
2088 if (!first)
2089 err = proc_put_char(&buffer, &left, '\t');
2090 if (err)
2091 break;
2092 err = proc_put_long(&buffer, &left, lval, neg);
2093 if (err)
2094 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002095 }
2096 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002097
2098 if (!write && !first && left && !err)
2099 err = proc_put_char(&buffer, &left, '\n');
J. R. Okajima563b0462010-05-25 16:10:14 -07002100 if (write && !err && left)
Amerigo Wang00b7c332010-05-05 00:26:45 +00002101 left -= proc_skip_spaces(&kbuf);
2102free:
2103 if (write) {
2104 free_page(page);
2105 if (first)
2106 return err ? : -EINVAL;
2107 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002108 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002109out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002110 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002111 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002112}
2113
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002114static int do_proc_dointvec(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002115 void __user *buffer, size_t *lenp, loff_t *ppos,
Amerigo Wang00b7c332010-05-05 00:26:45 +00002116 int (*conv)(bool *negp, unsigned long *lvalp, int *valp,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002117 int write, void *data),
2118 void *data)
2119{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002120 return __do_proc_dointvec(table->data, table, write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002121 buffer, lenp, ppos, conv, data);
2122}
2123
Linus Torvalds1da177e2005-04-16 15:20:36 -07002124/**
2125 * proc_dointvec - read a vector of integers
2126 * @table: the sysctl table
2127 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002128 * @buffer: the user buffer
2129 * @lenp: the size of the user buffer
2130 * @ppos: file position
2131 *
2132 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2133 * values from/to the user buffer, treated as an ASCII string.
2134 *
2135 * Returns 0 on success.
2136 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002137int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002138 void __user *buffer, size_t *lenp, loff_t *ppos)
2139{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002140 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002141 NULL,NULL);
2142}
2143
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002144/*
Andi Kleen25ddbb12008-10-15 22:01:41 -07002145 * Taint values can only be increased
2146 * This means we can safely use a temporary.
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002147 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002148static int proc_taint(struct ctl_table *table, int write,
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002149 void __user *buffer, size_t *lenp, loff_t *ppos)
2150{
Andi Kleen25ddbb12008-10-15 22:01:41 -07002151 struct ctl_table t;
2152 unsigned long tmptaint = get_taint();
2153 int err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002154
Bastian Blank91fcd412007-04-23 14:41:14 -07002155 if (write && !capable(CAP_SYS_ADMIN))
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002156 return -EPERM;
2157
Andi Kleen25ddbb12008-10-15 22:01:41 -07002158 t = *table;
2159 t.data = &tmptaint;
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002160 err = proc_doulongvec_minmax(&t, write, buffer, lenp, ppos);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002161 if (err < 0)
2162 return err;
2163
2164 if (write) {
2165 /*
2166 * Poor man's atomic or. Not worth adding a primitive
2167 * to everyone's atomic.h for this
2168 */
2169 int i;
2170 for (i = 0; i < BITS_PER_LONG && tmptaint >> i; i++) {
2171 if ((tmptaint >> i) & 1)
Rusty Russell373d4d02013-01-21 17:17:39 +10302172 add_taint(i, LOCKDEP_STILL_OK);
Andi Kleen25ddbb12008-10-15 22:01:41 -07002173 }
2174 }
2175
2176 return err;
Theodore Ts'o34f5a392007-02-10 01:45:24 -08002177}
2178
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002179#ifdef CONFIG_PRINTK
Kees Cook620f6e82012-04-04 11:40:19 -07002180static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
Richard Weinbergerbfdc0b42011-03-23 16:43:11 -07002181 void __user *buffer, size_t *lenp, loff_t *ppos)
2182{
2183 if (write && !capable(CAP_SYS_ADMIN))
2184 return -EPERM;
2185
2186 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2187}
2188#endif
2189
Linus Torvalds1da177e2005-04-16 15:20:36 -07002190struct do_proc_dointvec_minmax_conv_param {
2191 int *min;
2192 int *max;
2193};
2194
Amerigo Wang00b7c332010-05-05 00:26:45 +00002195static int do_proc_dointvec_minmax_conv(bool *negp, unsigned long *lvalp,
2196 int *valp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002197 int write, void *data)
2198{
2199 struct do_proc_dointvec_minmax_conv_param *param = data;
2200 if (write) {
2201 int val = *negp ? -*lvalp : *lvalp;
2202 if ((param->min && *param->min > val) ||
2203 (param->max && *param->max < val))
2204 return -EINVAL;
2205 *valp = val;
2206 } else {
2207 int val = *valp;
2208 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002209 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002210 *lvalp = (unsigned long)-val;
2211 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002212 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002213 *lvalp = (unsigned long)val;
2214 }
2215 }
2216 return 0;
2217}
2218
2219/**
2220 * proc_dointvec_minmax - read a vector of integers with min/max values
2221 * @table: the sysctl table
2222 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002223 * @buffer: the user buffer
2224 * @lenp: the size of the user buffer
2225 * @ppos: file position
2226 *
2227 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2228 * values from/to the user buffer, treated as an ASCII string.
2229 *
2230 * This routine will ensure the values are within the range specified by
2231 * table->extra1 (min) and table->extra2 (max).
2232 *
2233 * Returns 0 on success.
2234 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002235int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002236 void __user *buffer, size_t *lenp, loff_t *ppos)
2237{
2238 struct do_proc_dointvec_minmax_conv_param param = {
2239 .min = (int *) table->extra1,
2240 .max = (int *) table->extra2,
2241 };
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002242 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002243 do_proc_dointvec_minmax_conv, &param);
2244}
2245
Kees Cook54b50192012-07-30 14:39:18 -07002246static void validate_coredump_safety(void)
2247{
Alex Kelly046d6622012-10-04 17:15:23 -07002248#ifdef CONFIG_COREDUMP
Kees Cooke579d2c2013-02-27 17:03:15 -08002249 if (suid_dumpable == SUID_DUMP_ROOT &&
Kees Cook54b50192012-07-30 14:39:18 -07002250 core_pattern[0] != '/' && core_pattern[0] != '|') {
2251 printk(KERN_WARNING "Unsafe core_pattern used with "\
2252 "suid_dumpable=2. Pipe handler or fully qualified "\
2253 "core dump path required.\n");
2254 }
Alex Kelly046d6622012-10-04 17:15:23 -07002255#endif
Kees Cook54b50192012-07-30 14:39:18 -07002256}
2257
2258static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
2259 void __user *buffer, size_t *lenp, loff_t *ppos)
2260{
2261 int error = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
2262 if (!error)
2263 validate_coredump_safety();
2264 return error;
2265}
2266
Alex Kelly046d6622012-10-04 17:15:23 -07002267#ifdef CONFIG_COREDUMP
Kees Cook54b50192012-07-30 14:39:18 -07002268static int proc_dostring_coredump(struct ctl_table *table, int write,
2269 void __user *buffer, size_t *lenp, loff_t *ppos)
2270{
2271 int error = proc_dostring(table, write, buffer, lenp, ppos);
2272 if (!error)
2273 validate_coredump_safety();
2274 return error;
2275}
Alex Kelly046d6622012-10-04 17:15:23 -07002276#endif
Kees Cook54b50192012-07-30 14:39:18 -07002277
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002278static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002279 void __user *buffer,
2280 size_t *lenp, loff_t *ppos,
2281 unsigned long convmul,
2282 unsigned long convdiv)
2283{
Amerigo Wang00b7c332010-05-05 00:26:45 +00002284 unsigned long *i, *min, *max;
2285 int vleft, first = 1, err = 0;
2286 unsigned long page = 0;
2287 size_t left;
2288 char *kbuf;
2289
2290 if (!data || !table->maxlen || !*lenp || (*ppos && !write)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002291 *lenp = 0;
2292 return 0;
2293 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002294
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002295 i = (unsigned long *) data;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002296 min = (unsigned long *) table->extra1;
2297 max = (unsigned long *) table->extra2;
2298 vleft = table->maxlen / sizeof(unsigned long);
2299 left = *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002300
2301 if (write) {
Kees Cookf4aacea2014-06-06 14:37:19 -07002302 if (*ppos) {
2303 switch (sysctl_writes_strict) {
2304 case SYSCTL_WRITES_STRICT:
2305 goto out;
2306 case SYSCTL_WRITES_WARN:
2307 warn_sysctl_write(table);
2308 break;
2309 default:
2310 break;
2311 }
2312 }
2313
Amerigo Wang00b7c332010-05-05 00:26:45 +00002314 if (left > PAGE_SIZE - 1)
2315 left = PAGE_SIZE - 1;
2316 page = __get_free_page(GFP_TEMPORARY);
2317 kbuf = (char *) page;
2318 if (!kbuf)
2319 return -ENOMEM;
2320 if (copy_from_user(kbuf, buffer, left)) {
2321 err = -EFAULT;
2322 goto free;
2323 }
2324 kbuf[left] = 0;
2325 }
2326
Eric Dumazet27b3d802010-10-07 12:59:29 -07002327 for (; left && vleft--; i++, first = 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002328 unsigned long val;
2329
Linus Torvalds1da177e2005-04-16 15:20:36 -07002330 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002331 bool neg;
2332
2333 left -= proc_skip_spaces(&kbuf);
2334
2335 err = proc_get_long(&kbuf, &left, &val, &neg,
2336 proc_wspace_sep,
2337 sizeof(proc_wspace_sep), NULL);
2338 if (err)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002339 break;
2340 if (neg)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002341 continue;
2342 if ((min && val < *min) || (max && val > *max))
2343 continue;
2344 *i = val;
2345 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002346 val = convdiv * (*i) / convmul;
Chen Gang78338192013-11-12 15:11:21 -08002347 if (!first) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002348 err = proc_put_char(&buffer, &left, '\t');
Chen Gang78338192013-11-12 15:11:21 -08002349 if (err)
2350 break;
2351 }
Amerigo Wang00b7c332010-05-05 00:26:45 +00002352 err = proc_put_long(&buffer, &left, val, false);
2353 if (err)
2354 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002355 }
2356 }
2357
Amerigo Wang00b7c332010-05-05 00:26:45 +00002358 if (!write && !first && left && !err)
2359 err = proc_put_char(&buffer, &left, '\n');
2360 if (write && !err)
2361 left -= proc_skip_spaces(&kbuf);
2362free:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002363 if (write) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002364 free_page(page);
2365 if (first)
2366 return err ? : -EINVAL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002367 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002368 *lenp -= left;
Kees Cookf4aacea2014-06-06 14:37:19 -07002369out:
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370 *ppos += *lenp;
Amerigo Wang00b7c332010-05-05 00:26:45 +00002371 return err;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002372}
2373
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002374static int do_proc_doulongvec_minmax(struct ctl_table *table, int write,
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002375 void __user *buffer,
2376 size_t *lenp, loff_t *ppos,
2377 unsigned long convmul,
2378 unsigned long convdiv)
2379{
2380 return __do_proc_doulongvec_minmax(table->data, table, write,
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002381 buffer, lenp, ppos, convmul, convdiv);
Kirill Korotaevfcfbd542006-10-02 02:18:23 -07002382}
2383
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384/**
2385 * proc_doulongvec_minmax - read a vector of long integers with min/max values
2386 * @table: the sysctl table
2387 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388 * @buffer: the user buffer
2389 * @lenp: the size of the user buffer
2390 * @ppos: file position
2391 *
2392 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2393 * values from/to the user buffer, treated as an ASCII string.
2394 *
2395 * This routine will ensure the values are within the range specified by
2396 * table->extra1 (min) and table->extra2 (max).
2397 *
2398 * Returns 0 on success.
2399 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002400int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002401 void __user *buffer, size_t *lenp, loff_t *ppos)
2402{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002403 return do_proc_doulongvec_minmax(table, write, buffer, lenp, ppos, 1l, 1l);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002404}
2405
2406/**
2407 * proc_doulongvec_ms_jiffies_minmax - read a vector of millisecond values with min/max values
2408 * @table: the sysctl table
2409 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002410 * @buffer: the user buffer
2411 * @lenp: the size of the user buffer
2412 * @ppos: file position
2413 *
2414 * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long
2415 * values from/to the user buffer, treated as an ASCII string. The values
2416 * are treated as milliseconds, and converted to jiffies when they are stored.
2417 *
2418 * This routine will ensure the values are within the range specified by
2419 * table->extra1 (min) and table->extra2 (max).
2420 *
2421 * Returns 0 on success.
2422 */
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002423int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002424 void __user *buffer,
2425 size_t *lenp, loff_t *ppos)
2426{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002427 return do_proc_doulongvec_minmax(table, write, buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002428 lenp, ppos, HZ, 1000l);
2429}
2430
2431
Amerigo Wang00b7c332010-05-05 00:26:45 +00002432static int do_proc_dointvec_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002433 int *valp,
2434 int write, void *data)
2435{
2436 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002437 if (*lvalp > LONG_MAX / HZ)
2438 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002439 *valp = *negp ? -(*lvalp*HZ) : (*lvalp*HZ);
2440 } else {
2441 int val = *valp;
2442 unsigned long lval;
2443 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002444 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002445 lval = (unsigned long)-val;
2446 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002447 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002448 lval = (unsigned long)val;
2449 }
2450 *lvalp = lval / HZ;
2451 }
2452 return 0;
2453}
2454
Amerigo Wang00b7c332010-05-05 00:26:45 +00002455static int do_proc_dointvec_userhz_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002456 int *valp,
2457 int write, void *data)
2458{
2459 if (write) {
Bart Samwelcba9f332006-03-24 03:15:50 -08002460 if (USER_HZ < HZ && *lvalp > (LONG_MAX / HZ) * USER_HZ)
2461 return 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002462 *valp = clock_t_to_jiffies(*negp ? -*lvalp : *lvalp);
2463 } else {
2464 int val = *valp;
2465 unsigned long lval;
2466 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002467 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002468 lval = (unsigned long)-val;
2469 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002470 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002471 lval = (unsigned long)val;
2472 }
2473 *lvalp = jiffies_to_clock_t(lval);
2474 }
2475 return 0;
2476}
2477
Amerigo Wang00b7c332010-05-05 00:26:45 +00002478static int do_proc_dointvec_ms_jiffies_conv(bool *negp, unsigned long *lvalp,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002479 int *valp,
2480 int write, void *data)
2481{
2482 if (write) {
Francesco Fuscod738ce82013-07-24 10:39:07 +02002483 unsigned long jif = msecs_to_jiffies(*negp ? -*lvalp : *lvalp);
2484
2485 if (jif > INT_MAX)
2486 return 1;
2487 *valp = (int)jif;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002488 } else {
2489 int val = *valp;
2490 unsigned long lval;
2491 if (val < 0) {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002492 *negp = true;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002493 lval = (unsigned long)-val;
2494 } else {
Amerigo Wang00b7c332010-05-05 00:26:45 +00002495 *negp = false;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002496 lval = (unsigned long)val;
2497 }
2498 *lvalp = jiffies_to_msecs(lval);
2499 }
2500 return 0;
2501}
2502
2503/**
2504 * proc_dointvec_jiffies - read a vector of integers as seconds
2505 * @table: the sysctl table
2506 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002507 * @buffer: the user buffer
2508 * @lenp: the size of the user buffer
2509 * @ppos: file position
2510 *
2511 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2512 * values from/to the user buffer, treated as an ASCII string.
2513 * The values read are assumed to be in seconds, and are converted into
2514 * jiffies.
2515 *
2516 * Returns 0 on success.
2517 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002518int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002519 void __user *buffer, size_t *lenp, loff_t *ppos)
2520{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002521 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002522 do_proc_dointvec_jiffies_conv,NULL);
2523}
2524
2525/**
2526 * proc_dointvec_userhz_jiffies - read a vector of integers as 1/USER_HZ seconds
2527 * @table: the sysctl table
2528 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002529 * @buffer: the user buffer
2530 * @lenp: the size of the user buffer
Randy Dunlap1e5d5332005-11-07 01:01:06 -08002531 * @ppos: pointer to the file position
Linus Torvalds1da177e2005-04-16 15:20:36 -07002532 *
2533 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2534 * values from/to the user buffer, treated as an ASCII string.
2535 * The values read are assumed to be in 1/USER_HZ seconds, and
2536 * are converted into jiffies.
2537 *
2538 * Returns 0 on success.
2539 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002540int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002541 void __user *buffer, size_t *lenp, loff_t *ppos)
2542{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002543 return do_proc_dointvec(table,write,buffer,lenp,ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002544 do_proc_dointvec_userhz_jiffies_conv,NULL);
2545}
2546
2547/**
2548 * proc_dointvec_ms_jiffies - read a vector of integers as 1 milliseconds
2549 * @table: the sysctl table
2550 * @write: %TRUE if this is a write to the sysctl file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551 * @buffer: the user buffer
2552 * @lenp: the size of the user buffer
Martin Waitz67be2dd2005-05-01 08:59:26 -07002553 * @ppos: file position
2554 * @ppos: the current position in the file
Linus Torvalds1da177e2005-04-16 15:20:36 -07002555 *
2556 * Reads/writes up to table->maxlen/sizeof(unsigned int) integer
2557 * values from/to the user buffer, treated as an ASCII string.
2558 * The values read are assumed to be in 1/1000 seconds, and
2559 * are converted into jiffies.
2560 *
2561 * Returns 0 on success.
2562 */
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002563int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002564 void __user *buffer, size_t *lenp, loff_t *ppos)
2565{
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002566 return do_proc_dointvec(table, write, buffer, lenp, ppos,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002567 do_proc_dointvec_ms_jiffies_conv, NULL);
2568}
2569
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002570static int proc_do_cad_pid(struct ctl_table *table, int write,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002571 void __user *buffer, size_t *lenp, loff_t *ppos)
2572{
2573 struct pid *new_pid;
2574 pid_t tmp;
2575 int r;
2576
Pavel Emelyanov6c5f3e72008-02-08 04:19:20 -08002577 tmp = pid_vnr(cad_pid);
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002578
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002579 r = __do_proc_dointvec(&tmp, table, write, buffer,
Cedric Le Goater9ec52092006-10-02 02:19:00 -07002580 lenp, ppos, NULL, NULL);
2581 if (r || !write)
2582 return r;
2583
2584 new_pid = find_get_pid(tmp);
2585 if (!new_pid)
2586 return -ESRCH;
2587
2588 put_pid(xchg(&cad_pid, new_pid));
2589 return 0;
2590}
2591
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002592/**
2593 * proc_do_large_bitmap - read/write from/to a large bitmap
2594 * @table: the sysctl table
2595 * @write: %TRUE if this is a write to the sysctl file
2596 * @buffer: the user buffer
2597 * @lenp: the size of the user buffer
2598 * @ppos: file position
2599 *
2600 * The bitmap is stored at table->data and the bitmap length (in bits)
2601 * in table->maxlen.
2602 *
2603 * We use a range comma separated format (e.g. 1,3-4,10-10) so that
2604 * large bitmaps may be represented in a compact manner. Writing into
2605 * the file will clear the bitmap then update it with the given input.
2606 *
2607 * Returns 0 on success.
2608 */
2609int proc_do_large_bitmap(struct ctl_table *table, int write,
2610 void __user *buffer, size_t *lenp, loff_t *ppos)
2611{
2612 int err = 0;
2613 bool first = 1;
2614 size_t left = *lenp;
2615 unsigned long bitmap_len = table->maxlen;
WANG Cong122ff242014-05-12 16:04:53 -07002616 unsigned long *bitmap = *(unsigned long **) table->data;
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002617 unsigned long *tmp_bitmap = NULL;
2618 char tr_a[] = { '-', ',', '\n' }, tr_b[] = { ',', '\n', 0 }, c;
2619
WANG Cong122ff242014-05-12 16:04:53 -07002620 if (!bitmap || !bitmap_len || !left || (*ppos && !write)) {
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002621 *lenp = 0;
2622 return 0;
2623 }
2624
2625 if (write) {
2626 unsigned long page = 0;
2627 char *kbuf;
2628
2629 if (left > PAGE_SIZE - 1)
2630 left = PAGE_SIZE - 1;
2631
2632 page = __get_free_page(GFP_TEMPORARY);
2633 kbuf = (char *) page;
2634 if (!kbuf)
2635 return -ENOMEM;
2636 if (copy_from_user(kbuf, buffer, left)) {
2637 free_page(page);
2638 return -EFAULT;
2639 }
2640 kbuf[left] = 0;
2641
2642 tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
2643 GFP_KERNEL);
2644 if (!tmp_bitmap) {
2645 free_page(page);
2646 return -ENOMEM;
2647 }
2648 proc_skip_char(&kbuf, &left, '\n');
2649 while (!err && left) {
2650 unsigned long val_a, val_b;
2651 bool neg;
2652
2653 err = proc_get_long(&kbuf, &left, &val_a, &neg, tr_a,
2654 sizeof(tr_a), &c);
2655 if (err)
2656 break;
2657 if (val_a >= bitmap_len || neg) {
2658 err = -EINVAL;
2659 break;
2660 }
2661
2662 val_b = val_a;
2663 if (left) {
2664 kbuf++;
2665 left--;
2666 }
2667
2668 if (c == '-') {
2669 err = proc_get_long(&kbuf, &left, &val_b,
2670 &neg, tr_b, sizeof(tr_b),
2671 &c);
2672 if (err)
2673 break;
2674 if (val_b >= bitmap_len || neg ||
2675 val_a > val_b) {
2676 err = -EINVAL;
2677 break;
2678 }
2679 if (left) {
2680 kbuf++;
2681 left--;
2682 }
2683 }
2684
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002685 bitmap_set(tmp_bitmap, val_a, val_b - val_a + 1);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002686 first = 0;
2687 proc_skip_char(&kbuf, &left, '\n');
2688 }
2689 free_page(page);
2690 } else {
2691 unsigned long bit_a, bit_b = 0;
2692
2693 while (left) {
2694 bit_a = find_next_bit(bitmap, bitmap_len, bit_b);
2695 if (bit_a >= bitmap_len)
2696 break;
2697 bit_b = find_next_zero_bit(bitmap, bitmap_len,
2698 bit_a + 1) - 1;
2699
2700 if (!first) {
2701 err = proc_put_char(&buffer, &left, ',');
2702 if (err)
2703 break;
2704 }
2705 err = proc_put_long(&buffer, &left, bit_a, false);
2706 if (err)
2707 break;
2708 if (bit_a != bit_b) {
2709 err = proc_put_char(&buffer, &left, '-');
2710 if (err)
2711 break;
2712 err = proc_put_long(&buffer, &left, bit_b, false);
2713 if (err)
2714 break;
2715 }
2716
2717 first = 0; bit_b++;
2718 }
2719 if (!err)
2720 err = proc_put_char(&buffer, &left, '\n');
2721 }
2722
2723 if (!err) {
2724 if (write) {
2725 if (*ppos)
2726 bitmap_or(bitmap, bitmap, tmp_bitmap, bitmap_len);
2727 else
Akinobu Mita5a04cca2012-03-28 14:42:50 -07002728 bitmap_copy(bitmap, tmp_bitmap, bitmap_len);
Octavian Purdila9f977fb2010-05-05 00:26:55 +00002729 }
2730 kfree(tmp_bitmap);
2731 *lenp -= left;
2732 *ppos += *lenp;
2733 return 0;
2734 } else {
2735 kfree(tmp_bitmap);
2736 return err;
2737 }
2738}
2739
Jovi Zhang55610502011-01-12 17:00:45 -08002740#else /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002741
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002742int proc_dostring(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002743 void __user *buffer, size_t *lenp, loff_t *ppos)
2744{
2745 return -ENOSYS;
2746}
2747
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002748int proc_dointvec(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002749 void __user *buffer, size_t *lenp, loff_t *ppos)
2750{
2751 return -ENOSYS;
2752}
2753
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002754int proc_dointvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002755 void __user *buffer, size_t *lenp, loff_t *ppos)
2756{
2757 return -ENOSYS;
2758}
2759
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002760int proc_dointvec_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002761 void __user *buffer, size_t *lenp, loff_t *ppos)
2762{
2763 return -ENOSYS;
2764}
2765
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002766int proc_dointvec_userhz_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002767 void __user *buffer, size_t *lenp, loff_t *ppos)
2768{
2769 return -ENOSYS;
2770}
2771
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002772int proc_dointvec_ms_jiffies(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002773 void __user *buffer, size_t *lenp, loff_t *ppos)
2774{
2775 return -ENOSYS;
2776}
2777
Alexey Dobriyan8d65af72009-09-23 15:57:19 -07002778int proc_doulongvec_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002779 void __user *buffer, size_t *lenp, loff_t *ppos)
2780{
2781 return -ENOSYS;
2782}
2783
Eric W. Biedermand8217f02007-10-18 03:05:22 -07002784int proc_doulongvec_ms_jiffies_minmax(struct ctl_table *table, int write,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002785 void __user *buffer,
2786 size_t *lenp, loff_t *ppos)
2787{
2788 return -ENOSYS;
2789}
2790
2791
Jovi Zhang55610502011-01-12 17:00:45 -08002792#endif /* CONFIG_PROC_SYSCTL */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002793
Linus Torvalds1da177e2005-04-16 15:20:36 -07002794/*
2795 * No sense putting this after each symbol definition, twice,
2796 * exception granted :-)
2797 */
2798EXPORT_SYMBOL(proc_dointvec);
2799EXPORT_SYMBOL(proc_dointvec_jiffies);
2800EXPORT_SYMBOL(proc_dointvec_minmax);
2801EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
2802EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
2803EXPORT_SYMBOL(proc_dostring);
2804EXPORT_SYMBOL(proc_doulongvec_minmax);
2805EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);